Support » Plugin: AddToAny Share Buttons » How can I get to social media icons?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author micropat

    (@micropat)

    Hello,

    You can add the following PHP code to a “functionality” plugin such as the Code Snippets plugin:

    function addtoany_add_follow_services( $services ) {
        // Add Telegram
        $services['telegram_follow_service'] = array(
            'name'  => 'Telegram',
            'href'  => 'https://t.me/${id}',
            'icon'  => 'telegram',
            'color' => 'e50e25',
        );
        // Add VK
        $services['vk_follow_service'] = array(
            'name'  => 'VK',
            'href'  => 'https://vk.com/${id}',
            'icon'  => 'vk',
            'color' => 'e50e25',
        );
    
        return $services;
    }
    add_filter( 'A2A_FOLLOW_services', 'addtoany_add_follow_services', 10, 1 );

    This example adds both Telegram & VK, with their respective AddToAny icons, to your AddToAny Follow widget.

    Thank you, but why Code Snippets? We don’t have one and I don’t think they will be glad with the idea to install another piece of code in order to place yet another one…

    Could you please tell me where exactly (file, place whithin it, etc.) I should place the piece of code shown above to make it work without undertaking any additional roundabouts?

    Thank you,

    Plugin Author micropat

    (@micropat)

    See https://codex.wordpress.org/Functions_File_Explained

    Code Snippets tends to be easiest, and it’s awesome for managing your custom PHP code. Alternatively, use your theme’s functions.php or write your own custom plugin.

    Well, thank you! Now I will try to do my best.
    But… I would still like to ask…
    if I place this code just into a theme’s functions.php will it work as intended?

    I did all as you said but original icons haven’t shown up. The universal one (“+”) instead. What missed?

    Plugin Author micropat

    (@micropat)

    Ah, good catch! In the PHP code, just rename telegram_follow_service to telegram (the service code for Telegram), and vk_follow_service to vk.

    I did. The icon has dissapeared at all as it wasn’t there. I mean even “+” and a link. Just a hollow place.

    Plugin Author micropat

    (@micropat)

    The HTML is still showing a2a_button_telegram_follow_service instead of a2a_button_telegram, so you probably need to delete & re-add Telegram in the AddToAny Follow widget and/or clear the site’s cache.

    Sure it is (I mean HTML) because as I saw the substituting ‘telegram_follow_service’ for just ‘telegram’ doesn’t solve a problem, I turned back to the initial state.

    Here is a snippet’s code you’ve provided me at the beginning:

    function addtoany_add_follow_services( $services ) {
        // Add Telegram
        $services['telegram_follow_service'] = array(
            'name'  => 'Telegram',
            'href'  => 'https://t.me/${id}',
            'icon'  => 'telegram',
            'color' => 'e50e25',
        );
        // Add VK
        $services['vk'] = array(
            'name'  => 'VK',
            'href'  => 'https://vk.com/${id}',
            'icon'  => 'vk',
            'color' => 'e50e25',
        );
    
        return $services;
    }
    add_filter( 'A2A_FOLLOW_services', 'addtoany_add_follow_services', 10, 1 );

    As you can see for VK it’s exactly as you advised to do. But I need not a VK button so I haven’t added it in the widget and we can’t see how this change in the code affects the layout.

    I didn’t know you would want to look at the HTML so now I will do again as you said – substitute ‘telegram_follow_service’ for ‘telegram’. Please, check all you want to.
    I just need a solution (if it can be reached at all).

    Now look, Telegram button has to be right after Youtube’s but it doesn’t. Even a link is absent (if to hover over that place where it should be).
    If I turn back a “+” button will reemerge with a quite valid link. But how to get Telegram icon instead of “+” one? How does the snippet fall back to the ‘universal’ button, why can’t it find Telegram’s?

    Plugin Author micropat

    (@micropat)

    I didn’t know you would want to look at the HTML so now I will do again as you said – substitute ‘telegram_follow_service’ for ‘telegram’. Please, check all you want to.

    Keep that live for help here. Make sure you’re using telegram (not telegram_follow_service), that the widget’s Telegram field is not empty, and that cache(s) are cleared.

    I dont’t know what’s happening but obviously something mysterious.

    I have done all as you said. The Telegram icon with a link once appeared at the front page and then dissapeared again.

    On other pages everything is OK (still, I’m afraid).

    If it was possible to attach screenshots here I would do that, but… but you can look at the pages yourself, the link’s been provided.

    Here is the code of the snippet (as it is put in the plugin):

    function addtoany_add_follow_services( $services ) {
        // Add Telegram
        $services['telegram'] = array(
            'name'  => 'Telegram',
            'href'  => 'https://t.me/${id}',
            'icon'  => 'telegram',
            'color' => 'e50e25',
        );
        // Add VK
        $services['vk'] = array(
            'name'  => 'VK',
            'href'  => 'https://vk.com/${id}',
            'icon'  => 'vk',
            'color' => 'e50e25',
        );
    
        return $services;
    }
    add_filter( 'A2A_FOLLOW_services', 'addtoany_add_follow_services', 10, 1 );

    I may assure you ‘widget’s Telegram field’ is not empty. That’s also obvious as long as it seems other pages except the front page are OK. And that is particularly strange because the same widget caters for all the pages (in the case of a right sidebar).

    The cache has also been emptied. Moreover, I’ve checked the changes with some browsers and devices. As for mobile browsers some of them don’t show icons at all while others do, so I think if a browser doesn’t show icons (and links) in the widget at all it’s rather because of its settings (BTW the heading of the block (under the widget) is seen; you can check it either on your own).

    So as for now I’ve left everything ‘as is’ and look forward to hearing from you any suggestions.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How can I get to social media icons?’ is closed to new replies.