Title: Problem when using simple sharing php code
Last modified: March 29, 2023

---

# Problem when using simple sharing php code

 *  Resolved [geoffjbaker](https://wordpress.org/support/users/geoffjbaker/)
 * (@geoffjbaker)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/problem-when-using-simple-sharing-php-code/)
 * Hi, I was looking for a lightweight solution to add an exit intent popup on my
   site. I tried a few code solutions but couldn’t get them to work. Tried your 
   plugin and seemed fine (albeit only on desktop). However, have now noticed it
   causes a duplication of my social sharing icons that are generated using this
   PHP in functions.php
 *     ```wp-block-code
       function social_sharing_buttons($content) {
   
           global $post;   
   
           if(get_post_type() === 'post'){
   
               // Get current page URL 
   
               $simplesharingURL = urlencode(get_permalink());
   
               // Get current page title
   
               $simplesharingTitle = htmlspecialchars(urlencode(html_entity_decode(get_the_title(), ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8');
   
               // $crunchifyTitle = str_replace( ' ', '%20', get_the_title());
   
               // Get Post Thumbnail for pinterest
   
               $simplesharingThumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
   
               // Construct sharing URL without using any script
   
               $twitterURL = 'https://twitter.com/intent/tweet?text='.$simplesharingTitle.'&amp;url='.$simplesharingURL.'&amp;via=simplesharing';
   
               $facebookURL = 'https://www.facebook.com/sharer/sharer.php?u='.$simplesharingURL;
   
               $whatsappURL = 'https://api.whatsapp.com/send?text='.$simplesharingTitle. ' ' .$simplesharingURL;       
   
               $linkedInURL = 'https://www.linkedin.com/shareArticle?mini=true&url='.$simplesharingURL.'&amp;title='.$simplesharingTitle;
   
               // Based on popular demand added Pinterest too
   
               $pinterestURL = 'https://pinterest.com/pin/create/button/?url='.$simplesharingURL.'&amp;media='.$simplesharingThumbnail[0].'&amp;description='.$simplesharingTitle;
   
               // Add sharing button at the end of page/page content
   
               $content .= '<div class="simplesharing-social">';
   
               $content .= '<p><b>SHARE ON</b></p> <a class="simplesharing-link simplesharing-twitter" href="'. $twitterURL .'" target="_blank">Twitter</a>';
   
               $content .= '<a class="simplesharing-link simplesharing-facebook" href="'.$facebookURL.'" target="_blank">Facebook</a>';
   
               if (wp_is_mobile()) {
   
               $content .= '<a class="simplesharing-link simplesharing-whatsapp" href="'.$whatsappURL.'" target="_blank">WhatsApp</a>';
   
               }
   
               $content .= '<a class="simplesharing-link simplesharing-linkedin" href="'.$linkedInURL.'" target="_blank">LinkedIn</a>';
   
               $content .= '<a class="simplesharing-link simplesharing-pinterest" href="'.$pinterestURL.'" data-pin-custom="true" target="_blank">Pin It</a>';
   
               $content .= '</div>';
   
               return $content;
   
           }else{
   
               // if not a post then don't include sharing button
   
               return $content;
   
           }
   
       };
   
       add_filter( 'the_content', 'social_sharing_buttons');
       ```
   
 * The popup is designed to show on all posts. If you scroll to the bottom of one
   of the posts you will see the sharing buttons shown twice. I’ve tried checking
   for the id of the popup and I’ve also given it a name and that didn’t work either.
   Any idea how I can detect the popup so the sharing buttons don’t get added?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fproblem-when-using-simple-sharing-php-code%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [tropicalista](https://wordpress.org/support/users/tropicalista/)
 * (@tropicalista)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/problem-when-using-simple-sharing-php-code/#post-16607096)
 * Hi,
 * I was able to replicate the error. I will update the code to solve your problem.
 * Please note that the update will work on WP 6.2 that will be released today.
 *  Thread Starter [geoffjbaker](https://wordpress.org/support/users/geoffjbaker/)
 * (@geoffjbaker)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/problem-when-using-simple-sharing-php-code/#post-16610287)
 * Hi, seems ok now. Many thanks!
 *  Plugin Author [tropicalista](https://wordpress.org/support/users/tropicalista/)
 * (@tropicalista)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/problem-when-using-simple-sharing-php-code/#post-16610904)
 * Ok, I will close. However for the next time please can you use the Popper support
   forum?
   Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problem when using simple sharing php code’ is closed to new replies.

 * ![](https://ps.w.org/formello/assets/icon-256x256.png?rev=2488085)
 * [Contact form builder for Gutenberg - Formello](https://wordpress.org/plugins/formello/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/formello/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/formello/)
 * [Active Topics](https://wordpress.org/support/plugin/formello/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/formello/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/formello/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [tropicalista](https://wordpress.org/support/users/tropicalista/)
 * Last activity: [3 years, 1 month ago](https://wordpress.org/support/topic/problem-when-using-simple-sharing-php-code/#post-16610904)
 * Status: resolved