Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1409895
    necxelos
    Participant

    Hello

    I am using Ethos stack in localhost. I am also using this piece of code from Your Support-Hero Rad to create properly working Social Sharing Buttons:

    //add_action('the_content', 'sharing_buttons', 99999);
    //add_action('the_excerpt', 'sharing_buttons', 99999);
    
    function sharing_buttons( $content ) {
    
    return $content.do_shortcode('[share_custom title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" email="true"]');
    
    }
    add_shortcode( 'share_custom', 'share_custom' );
    
    function share_custom ( $atts ) {
    
     extract( shortcode_atts( array(
        'id'          => '',
        'class'       => '',
        'style'       => '',
        'title'       => '',
        'share_title' => '',
        'facebook'    => '',
        'twitter'     => '',
        'google_plus' => '',
        'linkedin'    => '',
        'pinterest'   => '',
        'reddit'      => '',
        'email'       => '',
        'email_subject' => ''
      ), $atts, 'x_share' ) );
    
      $share_url        = urlencode( get_permalink() );
      $share_url2       = get_permalink();
    
      $share_title = ( $share_title    != '' ) ? esc_attr( $share_title ) : urlencode( get_the_title() );
    
      $share_source     = urlencode( get_bloginfo( 'name' ) );
      $share_image_info = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
      $share_image      = ( function_exists( 'x_get_featured_image_with_fallback_url' ) ) ? urlencode( x_get_featured_image_with_fallback_url() ) : urlencode( $share_image_info[0] );
    
      if ( $linkedin    == 'true' ) {
        $share_content    = urlencode( cs_get_raw_excerpt() );
      }
    
      $tooltip_attr = cs_generate_data_attributes_extra( 'tooltip', 'hover', 'bottom' );
    
      $id          = ( $id          != ''     ) ? 'id="' . esc_attr( $id ) . '"' : '';
      $class       = ( $class       != ''     ) ? 'x-entry-share ' . esc_attr( $class ) : 'x-entry-share';
      $style       = ( $style       != ''     ) ? 'style="' . $style . '"' : '';
      $title       = ( $title       != ''     ) ? $title : __( 'Share this Post', 'cornerstone' );
      $facebook    = ( $facebook    == 'true' ) ? "<a href=\"{$share_url2}\" {$tooltip_attr} class=\"x-share\" title=\"" . __( 'Share on Facebook', 'cornerstone' ) . "\" onclick=\"window.open('http://www.facebook.com/sharer.php?u={$share_url}&t={$share_title}', 'popupFacebook', 'width=650, height=270, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-facebook-square\" data-x-icon=\"\"></i></a>" : '';
      $twitter     = ( $twitter     == 'true' ) ? "<a href=\"{$share_url2}\" {$tooltip_attr} class=\"x-share\" title=\"" . __( 'Share on Twitter', 'cornerstone' ) . "\" onclick=\"window.open('https://twitter.com/intent/tweet?text={$share_title}&url={$share_url}', 'popupTwitter', 'width=500, height=370, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-twitter-square\" data-x-icon=\"\"></i></a>" : '';
      $google_plus = ( $google_plus == 'true' ) ? "<a href=\"{$share_url2}\" {$tooltip_attr} class=\"x-share\" title=\"" . __( 'Share on Google+', 'cornerstone' ) . "\" onclick=\"window.open('https://plus.google.com/share?url={$share_url}', 'popupGooglePlus', 'width=650, height=226, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-google-plus-square\" data-x-icon=\"\"></i></a>" : '';
      $linkedin    = ( $linkedin    == 'true' ) ? "<a href=\"{$share_url2}\" {$tooltip_attr} class=\"x-share\" title=\"" . __( 'Share on LinkedIn', 'cornerstone' ) . "\" onclick=\"window.open('http://www.linkedin.com/shareArticle?mini=true&url={$share_url}&title={$share_title}&summary={$share_content}&source={$share_source}', 'popupLinkedIn', 'width=610, height=480, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-linkedin-square\" data-x-icon=\"\"></i></a>" : '';
      $pinterest   = ( $pinterest   == 'true' ) ? "<a href=\"{$share_url2}\" {$tooltip_attr} class=\"x-share\" title=\"" . __( 'Share on Pinterest', 'cornerstone' ) . "\" onclick=\"window.open('http://pinterest.com/pin/create/button/?url={$share_url}&media={$share_image}&description={$share_title}', 'popupPinterest', 'width=750, height=265, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-pinterest-square\" data-x-icon=\"\"></i></a>" : '';
      $reddit      = ( $reddit      == 'true' ) ? "<a href=\"{$share_url2}\" {$tooltip_attr} class=\"x-share\" title=\"" . __( 'Share on Reddit', 'cornerstone' ) . "\" onclick=\"window.open('http://www.reddit.com/submit?url={$share_url}', 'popupReddit', 'width=875, height=450, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0'); return false;\"><i class=\"x-icon-reddit-square\" data-x-icon=\"\"></i></a>" : '';
      $email_subject = ( $email_subject != '' ) ? esc_attr( $email_subject ) : __( 'Hey, thought you might enjoy this! Check it out when you have a chance:', 'cornerstone' );
      $mail_to     = esc_url( "mailto:?subject=" . get_the_title() . "&body=" . $email_subject . " " . get_permalink() . "" );
      $email       = ( $email       == 'true' ) ? "<a href=\"{$mail_to}\" {$tooltip_attr} class=\"x-share email\" title=\"" . __( 'Share via Email', 'cornerstone' ) . "\"><span><i class=\"x-icon-envelope-square\" data-x-icon=\"\"></i></span></a>" : '';
    
      $output = "<div {$id} class=\"{$class}\" {$style}>"
                . '<p>' . $title . '</p>'
                . '<div class="x-share-options">'
                  . $facebook . $twitter . $google_plus . $linkedin . $pinterest . $reddit . $email
                . '</div>'
              . '</div>';
    
      return $output;
    
    }

    It is in functions php and this line goes in content.php whenever I want those buttons to appear:

    <?php echo do_shortcode('[share_custom title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true"]'); ?>

    The problem is it stopped working for some unknown reason (time and updates during that time might be a reason – I came back to making my site for the first time since several months ago). What I get is an error visible in front end of site:

    Fatal error: Uncaught Error: Call to undefined function cs_get_raw_excerpt() in C:\xampp7015\htdocs\gas_rc_01\wp-content\themes\x-child\functions.php:150 Stack trace: #0 C:\xampp7015\htdocs\gas_rc_01\wp-includes\shortcodes.php(345): share_custom(Array, '', 'share_custom') #1 [internal function]: do_shortcode_tag(Array) #2 C:\xampp7015\htdocs\gas_rc_01\wp-includes\shortcodes.php(223): preg_replace_callback('/\\[(\\[?)(share_...', 'do_shortcode_ta...', '[share_custom t...') #3 C:\xampp7015\htdocs\gas_rc_01\wp-content\themes\x-child\framework\views\ethos\content.php(39): do_shortcode('[share_custom t...') #4 C:\xampp7015\htdocs\gas_rc_01\wp-includes\template.php(686): require('C:\\xampp7015\\ht...') #5 C:\xampp7015\htdocs\gas_rc_01\wp-includes\template.php(643): load_template('C:\\xampp7015\\ht...', false) #6 C:\xampp7015\htdocs\gas_rc_01\wp-includes\general-template.php(167): locate_template(Array, true, false) #7 C:\xampp7015\htdocs\gas_rc_01\wp-content\themes\x\framework\functions\global\helper.php(38): get_template_part( in C:\xampp7015\htdocs\gas_rc_01\wp-content\themes\x-child\functions.php on line 150

    Thanks in advance for help.

    #1410480
    Rad
    Moderator

    Hi there,

    Thanks for writing in.

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    Thanks!

    #1410970
    necxelos
    Participant

    I will quote myself on this one:

    I am using Ethos stack in localhost.

    So no, not really 😉

    #1411199
    Jade
    Moderator

    Hi there,

    Is there a chance that you could upload a copy of your site online where we could access it because it would be difficult for us to troubleshoot if we are not able to check your current setup.

    Thank you.

    #1411300
    necxelos
    Participant

    Absolutely no chance.

    I’m not having domain yet. I’m tinkering with the site in my free time (so far it’s well over half a year and it’s still not done) so there’s no way I would pay for hosting till then, not to mention I don’t want half-baked site online.

    I posted entire code responsible for generating social sharing buttons in my initial post (code created by Rad in older topic – link below if that’s any helpful):
    https://community.theme.co/forums/topic/entrysocial-share-on-post-and-post-archive-with-correct-link/

    I have only this and Your plugins, nothing else. My suspicion is that some WP / X THEME updates over that half a year changed the name of some underlying function (the one from error probably). But that’s as far as intuition can get me.

    Important thing: it worked before just as I posted it in the first post. And it still does on my archival installation of XAMPP with unupdated WP and unupdated X THEME. It doesn’t work in fresh install with fresh WP and fresh X THEME though. So nothing changed except for half year of updates.

    [EDIT] I pinpointed the error to those lines of code:

    if ( $linkedin    == 'true' ) {
        $share_content    = urlencode( cs_get_raw_excerpt() );
      }
    
      $tooltip_attr = cs_generate_data_attributes_extra( 'tooltip', 'hover', 'bottom' );

    No idea what they are doing, but it looks like those 2 functions (cs_generate… and cs_get_raw…) were changed in some update, that’s why they generate error now. This is still my suspicion though, not the englightened truth by any means 😉

    Thanks in advance 🙂

    #1411871
    Rue Nel
    Moderator

    Hello There,

    Thanks for updating in! I have tested the given code by Rad in my local testing server. I also edited content.php and added that shortcode line in my child theme. Regretfully I could not replicate the issue. No error what so ever is appearing. Is it possible that you can upload your child theme is a staging server somewhere so that we can test your child theme? Or maybe you can just zip your child theme and attached it in your next reply so that we can test it.

    By the way, if you want to know how to create a staging server, please check out these articles:
    http://www.wpbeginner.com/wp-tutorials/how-to-create-staging-environment-for-a-wordpress-site/
    https://maintainn.com/2015/02/how-to-create-a-staging-site-for-wordpress/

    #1412189
    necxelos
    Participant

    After Your response I started testing for any conflicts between… well between basically anything.

    I made fresh install and copypasted every piece of custom code, one by one. I did the same with plugin installations, one by one. And it was working just as You said. Than I decided to compare to the setup I had issue on and… it seems that for some strange reason Cornerstone deactivated itself. It was the reason why code stopped working 🙁

    I’m genuinely sorry for inconvenience, I don’t know how I managed to miss such an obvious thing 🙁

    Have a nice day, topic to be closed 🙂

    #1412611
    Christian
    Moderator

    Glad you’ve sorted it out.

  • <script> jQuery(function($){ $("#no-reply-1409895 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>