• Resolved Frank

    (@phasar40)


    I created a code snippet with the following code, modified with my URL

    function addtoany_add_follow_services( $services ) {
        $services['viber'] = array(
            'name'  => 'Viber',
            'icon'  => 'viber',
            'color' => '7C529E',
            'href'  => 'https://chats.viber.com/${id}',
        );
        return $services;
    }
    add_filter( 'A2A_FOLLOW_services', 'addtoany_add_follow_services', 10, 1 );'
    
    And the result was a white page with the error
    
    <blockquote>

    Don’t Panic
    The code snippet you are trying to save produced a fatal error on line 73:

    is_readable(): open_basedir restriction in effect. File(/dev/urandom) is not within the allowed path(s): (/var/www/frankf/data:.:/usr/local/stat)
    The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.

    Please use the back button in your browser to return to the previous page and try to fix the code error. If you prefer, you can close this page and discard the changes you just made. No changes will be made to this site.`

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter Frank

    (@phasar40)

    AddToAny Share Buttons says the error is related to Code Snippets and not their plugin or the code I entered

    Thread Starter Frank

    (@phasar40)

    So I’m going to assume I won’t get any support for this

    Plugin Author Shea Bunge

    (@bungeshea)

    I did look into this, but did not come to a definitive answer. I don’t think that this error is coming from Code Snippets itself, as it doesn’t have anything to do with writing to files, and the error is clearly coming from evaluated code, not from the plugin.

    Having said that, the code you quote does not have a line 73, so I don’t see how it’s coming from there either. My best guess is that the snippet you quoted is not the one causing the issue, and you have a different snippet that calls is_readable() on line 73 of the code.

    Thread Starter Frank

    (@phasar40)

    I don’t have any other snippets and this one is the only reason I installed your plugin. It was recommended by AddToAny.

    And they say the error is with your plugin, not their code

    Plugin Author Shea Bunge

    (@bungeshea)

    I’ve tried the code on my own site, and don’t receive any sort of error, especially not like you describe.

    The only thing I can really suggest at this point is copying the snippet as below, just to make sure that it’s properly formatted:

    add_filter( 'A2A_FOLLOW_services', function ( $services ) {
    	$services['viber'] = array(
    		'name'  => 'Viber',
    		'icon'  => 'viber',
    		'color' => '7C529E',
    		'href'  => 'https://chats.viber.com/${id}',
    	);
    	return $services;
    } );
    Thread Starter Frank

    (@phasar40)

    Well I’m using the latest WordPress 5.8 with php7.4

    is “${id}” part of the code or part of the viber link?

    Plugin Author Shea Bunge

    (@bungeshea)

    From what I’ve seen of the plugin, you should leave that part of the code as-is. A2A will know how to process it.

    Thread Starter Frank

    (@phasar40)

    Ok I got it working

    But now, virtually the same code won’t work for Telegram

    when I try to active it I get

    The snippet has been deactivated due to an error on line 2:

    Cannot redeclare function addtoany_add_follow_services.

    Plugin Author Shea Bunge

    (@bungeshea)

    Copy the code I posted, not the original snippet. You can’t declare a named function more than once in PHP.

    Thread Starter Frank

    (@phasar40)

    I did use the code you pasted

    function addtoany_add_follow_services( $services ) {
        $services['telegram'] = array(
            'name'  => 'Telegram',
            'icon'  => 'telegram',
            'color' => '2CA5E0',
            'href'  => 'https://t.me/zp_english_club/${id}',
        );
        return $services;
    }
    add_filter( 'A2A_FOLLOW_services', 'addtoany_add_follow_services', 10, 1 );
    Plugin Author Shea Bunge

    (@bungeshea)

    No, that’s the original code snippet you got from the A2A people. I rewrote it to remove the named function, allowing you to use it multiple times:

    add_filter( 'A2A_FOLLOW_services', function ( $services ) {
    	$services['viber'] = array(
    		'name'  => 'Viber',
    		'icon'  => 'viber',
    		'color' => '7C529E',
    		'href'  => 'https://chats.viber.com/${id}',
    	);
    	return $services;
    } );
    
    add_filter( 'A2A_FOLLOW_services', function ( $services ) {
    	$services['telegram'] = array(
    		'name'  => 'Telegram',
    		'icon'  => 'telegram',
    		'color' => '2CA5E0',
    		'href'  => 'https://t.me/zp_english_club/${id}',
    	);
    	return $services;
    } );

    You can also combine them together into the one filter hook if you are including them in the same snippet:

    add_filter( 'A2A_FOLLOW_services', function ( $services ) {
    	$services['viber'] = array(
    		'name'  => 'Viber',
    		'icon'  => 'viber',
    		'color' => '7C529E',
    		'href'  => 'https://chats.viber.com/${id}',
    	);
    
    	$services['telegram'] = array(
    		'name'  => 'Telegram',
    		'icon'  => 'telegram',
    		'color' => '2CA5E0',
    		'href'  => 'https://t.me/zp_english_club/${id}',
    	);
    	return $services;
    } );
    Thread Starter Frank

    (@phasar40)

    Works Great, THANKS!

    Plugin Author Shea Bunge

    (@bungeshea)

    Good to hear!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Problem with AddToAny Share Buttons’ is closed to new replies.