Plugin / RSS for Yandex Turbo
FlectorFrequently Asked Questions (FAQ)
ДОРОГИЕ ЧИТАТЕЛИ!
Если вам необходимо с нами связаться — позвоните нам (круглосуточно).
Это быстро и бесплатно!
'; $content .= $sign; return $content; } add_filter('yturbo_the_content', 'my_yturbo_sign_buttons'); Добавляем кнопку в виде шорткода. function turbobutton_shortcode($atts, $content) { //получаем настройки плагина, чтобы узнать имя RSS-ленты $yturbo_options = get_option('yturbo_options'); $rssturboname = $yturbo_options['ytrssname']; //если это не наша RSS-лента, то шорткод будет удален if ( !is_feed($rssturboname) ) return ''; //формируем кнопку шорткода $content = ' '; return $content; } add_shortcode ('turbobutton', 'turbobutton_shortcode'); Теперь вам достаточно добавить в контент код [turbobutton] и в нужном месте записи будет выведена кнопка (только на турбо-страницах). Замена указанной ссылки на кнопку. Предположим, что у вас имеется конкретная ссылка и вы хотите ее заменить на кнопку на турбо-страницах. Например, ваша ссылка выглядит так: +7(495)999-88-77 Чтобы заменить ее на турбо-страницах на кнопку вам надо использовать код: function yturbo_replace_link($content) { //что заменить $link = '+7(495)999-88-77'; //на что заменить $button = ''; //производим замену $content = str_replace($link, $button, $content); return $content; } add_filter('yturbo_the_content', 'yturbo_replace_link'); Замена всех ссылок на кнопки по регулярному выражению. Предположим, что у вас есть однотипные ссылки вида: Купить товар «Название товара» Купить товар «Название товара 2» Чтобы заменить их на кнопки на турбо-страницах вы должны использовать код: function yturbo_replace_all_links($content) { //что заменить $pattern = '/Купить товар «(.*?)»<\/a>/i'; //на что заменить $replacement = ''; //производим замену $content = preg_replace($pattern, $replacement, $content); return $content; } add_filter('yturbo_the_content', 'yturbo_replace_all_links'); Если вам нужна будет помощь с регулярками, то спрашивайте на форуме плагина.92332
контент записи
То есть вместо картинки вы получили ID этого массива картинок, а поле типа “Повторитель” вообще было проигнорировано. Вот для обработки таких нестандартных произвольных полей и нужен фильтр yturbo_the_template. Вот пример кода, обрабатывающего эти поля: //обработка произвольных полей плагина ACF begin function yturbo_acf_template($content) { //обрабатываем только нужные нам поля (остальные обработает плагин RSS for Yandex Turbo) if (preg_match_all("/%%(.*?)%%/i", $content, $res)) { foreach ($res[0] as $r) { //обрабатываем поле %%myimage%% (заменяем его на результат работы функции ct_get_myimage) if($r == '%%myimage%%') { $content = str_replace($r, ct_get_myimage(), $content); } //обрабатываем поле %%steps%% (заменяем его на результат работы функции ct_get_steps() ) if($r == '%%steps%%') { $content = str_replace($r, ct_get_steps(), $content); } } } return $content; } add_filter('yturbo_the_template', 'yturbo_acf_template'); //обработка произвольных полей плагина ACF end //обработка произвольного поля %%myimage%% begin function ct_get_myimage() { if ($field = get_field('myimage')) { $output = ''; } return $output; } //обработка произвольного поля %%myimage%% end //обработка произвольного поля %%steps%% begin function ct_get_steps() { if ($items = get_field('steps')) { $count = 0; $i = 1; foreach ($items as $item) {$count++;} foreach ($items as $item) { $output .= 'Шаг ' . $i . ' из ' . $count . '
'; $i++; $output .= ''; $output .= $item['text']; } } return $output; } //обработка произвольного поля %%steps%% end Принцип довольно простой и я думаю, что вам должно быть тут все понятно. Результатом этого кода будет что-то типа:Шаг 1 из 2
первое изображение
Шаг 2 из 2
второе изображение
контент записи
Атрибут alt был заменен на figcaption из-за настроек плагина (учтите, что результат вывода вашего шаблона будет потом обработан фильтрами плагина).Ratings
Rating breakdown
Details Information
Version
First Released
Total Downloads
Wordpress Version
Tested up to:
Require PHP Version:
Tags
Contributors
Languages
DIRECTORY DISCLAIMER
The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.
The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.
Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.
While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.
wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.