Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #1095307

    Hello!

    The Whatsapp button in the social share blog posts stopped working.
    It now opens a new page instead of sharing to whatsapp.

    My functions.php from the child theme is:

    <?php
    
    /*
    * Add your own functions here. You can also copy some of the theme functions into this file. 
    * WordPress will use those functions instead of the original functions then.
    */
    
    // Register new icon as a theme icon
    add_filter('avf_default_icons','avia_add_custom_icon', 10, 1);
    function avia_add_custom_icon($icons) {
    	$icons['whatsapp']	 = array( 'font' =>'whatsapp-font-icon', 'icon' => 'ue800');
    	return $icons;
    }
    
    //Adjust icons
    add_filter('avia_filter_social_icons', 'avia_filter_social_icons_mod', 10, 1);
    function avia_filter_social_icons_mod($icons) {
    	$icons['Whatsapp'] = 'whatsapp';
    	return $icons;
    }
    
    //Add items on the social share section
    add_filter('avia_social_share_link_arguments', 'avia_add_social_share_link_arguments', 10, 1);
    function avia_add_social_share_link_arguments($args)
    {
    	$args['whatsapp'] = array("encode"=>true, "encode_urls"=>false, "pattern" => "whatsapp://send?text=[title]&url=[permalink]", 'label' => __("Auf Whatsapp teilen",'avia_framework'));
    	return $args;
    }

    Regards

    Chris

    #1095643

    Hey chrishilli,

    Please post us your login credentials (in the “private data” field), so we can take a look at your backend.

    1. Install and activate ” Temporary Login Without Password “.
    2. Go to ” Users > Temporary Logins ” on the left-side menu.
    3. Click ” Create New “.
    4. Add the email address for the account ( you can use (Email address hidden if logged out) ), as well as the ” Role ” making that the highest possible and the expiry about four days
      ( do be sure that we have enough time to debug ).
    5. Click ” Submit “.
    6. You’ll now have a temporary account. Please provide us here in the private section the URL, so we can login and help you out.

    When your issue is fixed, you can always remove the plugin!
    If you prefer to not use the plugin, you can manually create an admin user and post the login credentials in the “private data” field. 

    Best regards,
    Victoria

    #1095678

    Data in privat content reply.

    #1096812

    Hi chrishilli,

    Well, I see that href value is stripped out. Was it working in Enfold 4.5.5?

    Best regards,
    Victoria

    #1096815

    Yes, it was working with Enfold 4.5.5. It´s broken since the update. I have no idea why because in functions.php the href link is correct.

    #1097385

    Hi,

    With 4.5.6 we added for security reasons function esc_url(..) which WP uses to filters for valid protocols (see wp-includes\functions.php wp_allowed_protocols() ).

    And whatsapp is not a valid protocoll.

    You can use filter kses_allowed_protocols (see see wp-includes\functions.php line 5738) to add whatsapp.

    Best regards,
    Günter

    #1103959

    Sorry for the late reply!

    I did some tests with kses_allowed_protocols but finally i must have missed something.
    I added following to the child themes functions.php

    function custom_add_more_protocols( $protocols ){
    	$protocols[] = 'whatsapp';
    	return $protocols;
    }
    add_filter( 'kses_allowed_protocols' , 'custom_add_more_protocols' );

    The link is now visible and also there is a sharing function. But the url is missing and not send. Only the title.

    Can you give me a hint to solve that.

    #1104522

    Hey chrishilli,

    This worked for me:

    /*Add items on the social share section*/
    add_filter('avia_social_share_link_arguments', 'avia_add_social_share_link_arguments', 10, 1);
    function avia_add_social_share_link_arguments($args)
    {
    	$args['whatsapp'] = array("encode"=>true, "encode_urls"=>false, "pattern" => "whatsapp://send?text=[permalink]", 'label' => __("Deel via WhatsApp",'avia_framework'));
    	return $args;
    }
    #1104527

    but is only working on mob if it must work on desktop the code has to be:

    add_filter('avia_social_share_link_arguments', 'avia_add_social_share_link_arguments', 10, 1);
    function avia_add_social_share_link_arguments($args)
    {
    	$args['whatsapp'] = array("encode"=>true, "encode_urls"=>false, "pattern" => "https://web.whatsapp.com/send?text=[permalink]", 'label' => __("Deel via WhatsApp",'avia_framework'));
    	return $args;
    }

    Is there a way to combine this?

    #1104543

    Thank you Tim!

    “Is there a way to combine this?”

    This is the question. It doesn´t make sense to offer a whatsapp share button and it only works on mobile or desktop. If there is a button it should work in any case.

    #1105318

    Hi,

    Thank you for the update.

    You can use the wp_is_mobile function to load the appropriate URL pattern for desktop and mobile device.

    // set whatsapp url pattern
    add_filter('avia_social_share_link_arguments', 'avia_social_share_link_arguments_mod', 10, 1);
    function avia_social_share_link_arguments_mod($args)
    {
        $pattern = 'https://web.whatsapp.com/send?text=[permalink]';
    
        if ( wp_is_mobile() ) {
            $pattern = 'whatsapp://send?text=[permalink]';
        } 
    
    	$args['whatsapp'] = array("encode"=>true, "encode_urls"=>false, "pattern" => $pattern, 'label' => __("Deel via WhatsApp",'avia_framework'));
    	return $args;
    }

    Best regards,
    Ismael

    #1105669

    I’m also looking to add the whatsapp icon, can you share the latest code (all of it including fixes) to include in functions.php that worked for you please?

    #1106225

    Hi allaith,

    Did you try the code Ismael posted?

    Best regards,
    Rikard

    #1107427

    Hi allaith!

    This is the code i use now and which is working.
    All the whatsapp relevant parts

    // Register new icon as a theme icon
    add_filter('avf_default_icons','avia_add_custom_icon', 10, 1);
    function avia_add_custom_icon($icons) {
    	$icons['whatsapp']	 = array( 'font' =>'whatsapp-font-icon', 'icon' => 'ue800');
    	return $icons;
    }
    
    //Adjust icons
    add_filter('avia_filter_social_icons', 'avia_filter_social_icons_mod', 10, 1);
    function avia_filter_social_icons_mod($icons) {
    	$icons['Whatsapp'] = 'whatsapp';
    	return $icons;
    }
    
    // set whatsapp url pattern
    add_filter('avia_social_share_link_arguments', 'avia_social_share_link_arguments_mod', 10, 1);
    function avia_social_share_link_arguments_mod($args)
    {
        $pattern = 'https://web.whatsapp.com/send?text=[permalink]';
    
        if ( wp_is_mobile() ) {
            $pattern = 'whatsapp://send?text=[permalink]';
        } 
    
    	$args['whatsapp'] = array("encode"=>true, "encode_urls"=>false, "pattern" => $pattern, 'label' => __("Deel via WhatsApp",'avia_framework'));
    	return $args;
    }
    
    function custom_add_more_protocols( $protocols ){
    	$protocols[] = 'whatsapp';
    	return $protocols;
    }
    add_filter( 'kses_allowed_protocols' , 'custom_add_more_protocols' );

    And use this in quick-css to style the whatsapp button.

    /* Whatsapp button color */
    #top #wrap_all .av-social-link-whatsapp:hover a {
    color: #ffffff;
    background-color: #3bb528;
    }
    #1107550

    Hi chrishilli,

    Thank you for sharing! :)

    @allaith Please let us know if you got it working with the solution posted above.

    If you need further assistance please let us know.
    Best regards,
    Victoria

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.