I made shortcode [EasyYandexShare] for the plugin instead of the default output
-
RU
Я сделал шорткод для плагина вместо вывода по умолчанию над или под постом, страницей, товаром.Плагин выводит кнопки соцсетей для всех нестандартных (незарегистрированых) типов постов. Например в виджетах с блоками Гутенберг плагина Custom-Post-Widget.
Чтобы этого избежать и выводить кнопки соцсетей 1 раз, стоит сделать шорткод и вставлять его в виджет.
EN
I made a shortcode for the plugin instead of the default output above or below the post, page, product.The plugin displays social media buttons for all non-standard (unregistered) post types. For example, in widgets with Gutenberg blocks of the Custom-Post-Widget plugin.
To avoid this and display the social media buttons 1 time, you should make a shortcode and insert it into the widget.
* * *
STEP 1
find 718-726 – easy-yandex-share.php//функция добавления фильтра с указанным приоритетом begin function yshare_add_filter_with_priority() { $yshare_options = get_option('yshare_options'); add_filter( 'the_content', 'yshare_add_share_block', $yshare_options['priority'] ); } add_action ( 'init', 'yshare_add_filter_with_priority' ); //функция добавления фильтра с указанным приоритетом end
replace with:
function yshare_shortcode($atts, $content = null){ return yshare_add_share_block(""); } add_shortcode( 'EasyYandexShare', 'yshare_shortcode');
* * *
STEP 2
find 279-280 – easy-yandex-share.php<hr> <p style="margin:0;"><?php _e('Save plugin settings to apply the changes.', 'easy-yandex-share'); ?></p>
add after:
<hr> <p style="margin:0; font-size: 150%; line-height: 150%;"><?php _e('Use shortcode <b>[EasyYandexShare]</b> in widget or theme', 'easy-yandex-share'); ?></p>
* * *
STEP 3
shortcode [EasyYandexShare]
- The topic ‘I made shortcode [EasyYandexShare] for the plugin instead of the default output’ is closed to new replies.