Support » Plugin: AddToAny Share Buttons » Suggestion – Add Support For print on AMP

  • Resolved andrei0x309

    (@andrei0x309)


    Hello, the print button on AMP is broken, I use the following workaround:

    $a2a_output = ADDTOANY_SHARE_SAVE_KIT( array( 
            'buttons' => array( 
                'twitter',
                'reddit',
                'pinterest',
                'whatsapp',
                'facebook',
                'email',
                'print' ),
        'output_later' => true) );
    $a2a_output = preg_replace('/<a class="a2a_button_print".*?>/mi', '<a class="a2a_button_print" on="tap:AMP.print()"  href="#" title="Print" rel="nofollow noopener">', $a2a_output);
     echo str_replace('style="background-color:#0166ff"', 'style="background-color:#434343"', $a2a_output);

    It would be nice if I wouldn’t have to do a regex on the output.
    Also for the share icon(the plus sign), there isn’t a way to customize the color on AMP other than replacing the hardcoded style="background-color:#434343 with a str_replace before output.

    For the other icons, you can use a filter like this one:

    
    add_filter('A2A_SHARE_SAVE_services',        function ($A2A_SHARE_SAVE_services) {
        foreach(array_keys($A2A_SHARE_SAVE_services) as $key){
                    $A2A_SHARE_SAVE_services[$key]['color'] = '434343';
                    }
                return($A2A_SHARE_SAVE_services);
            });
     

    but not for the share icon which seems to be hardcoded to style="background-color:#0166ff".

    I didn’t try to submit a PR on GitHub because it seems the repo is out of date.

    Thanks.

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

    (@micropat)

    Thanks andrei0x309,

    Version 1.7.44 (just released) fixes the Print service on AMP and accepts a filter for programmatically changing the icon background color:

    add_filter( 'addtoany_icons_bg_color', function() {
    	if ( function_exists( 'amp_is_request' ) && amp_is_request() ) {
    		return '#434343';
    	}
    } );

    The new filter only applies to AMP in this release, but expect it to be applied globally to all pages in a future release (hence the amp_is_request() conditional in the example above).

    Thread Starter andrei0x309

    (@andrei0x309)

    @micropat
    Great thanks for the change.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Suggestion – Add Support For print on AMP’ is closed to new replies.