Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1342791

    nbruell
    Participant

    Hi Themeco team,

    i need your help please. I try to implement the solution bye editing my function.php which is located at wp-content/themes/x-child.

    I add the code attached in my child theme, but it looks like this is not integrate or is load, as it does not change anything 🙁

    
    function x_shortcode_entry_share( $atts ) {
      extract( shortcode_atts( array(
        'id'          => '',
        'class'       => '',
        'style'       => '',
        'title'       => '',
        'facebook'    => '',
        'twitter'     => '',
        'google_plus' => '',
        'linkedin'    => '',
        'pinterest'   => '',
        'reddit'      => '',
        'email'       => ''
      ), $atts ) );
    
      $share_url        = urlencode( get_permalink() );
      $share_title      = urlencode( get_the_title() );
      $share_source     = urlencode( get_bloginfo( 'name' ) );
      $share_content    = urlencode( get_the_excerpt() );
      $share_media_info = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
      $share_media      = $share_media_info[0];
    
      $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', '__x__' );
      $facebook    = ( $facebook    == 'true' ) ? "<a href="#share" title=""><i class=\"x-icon-facebook-square\"></i></a>" : '';
      $twitter     = ( $twitter     == 'true' ) ? "<a href="#share" title=""><i class=\"x-icon-twitter-square\"></i></a>" : '';
      $google_plus = ( $google_plus == 'true' ) ? "<a href="#share" title=""><i class=\"x-icon-google-plus-square\"></i></a>" : '';
      $linkedin    = ( $linkedin    == 'true' ) ? "<a href="#share" title=""><i class=\"x-icon-linkedin-square\"></i></a>" : '';
      $pinterest   = ( $pinterest   == 'true' ) ? "<a href="#share" title=""><i class=\"x-icon-pinterest-square\"></i></a>" : '';
      $reddit      = ( $reddit      == 'true' ) ? "<a href="#share" title=""><i class=\"x-icon-reddit-square\"></i></a>" : '';
      $email       = ( $email       == 'true' ) ? "<a href="mailto:?subject=" title=""><span><i class=\"x-icon-envelope-square\"></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;
    }
    
    add_shortcode( 'share', 'x_shortcode_entry_share' ); 
    #1342812

    nbruell
    Participant

    seems like copy and past does not work: here my customized line 59:
    $email = ( $email == ‘true’ ) ? “<span><i class=\”x-icon-envelope-square\”></i></span>” : ”;

    #1342910

    Lely
    Moderator

    Hello There,

    Please try this code instead:

    function x_shortcode_entry_sharev2( $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() );
    
      if ( is_singular() ) {
        $share_url = urlencode( get_permalink() );
      } else {
        global $wp;
        $share_url = urlencode( home_url( ($wp->request) ? $wp->request : '' ) );
      }
    
      if ( is_singular() ) {
        $share_title = ( $share_title    != '' ) ? esc_attr( $share_title ) : urlencode( get_the_title() );
      } else {
        $share_title = ( $share_title    != '' ) ? esc_attr( $share_title ) : urlencode( apply_filters( 'the_title', get_page( get_option( 'page_for_posts' ) )->post_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\" {$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\" {$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\" {$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\" {$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\" {$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\" {$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=\"mailto:?subject=\" {$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;
    }
    
    add_action('wp_head', 'change_x_share_v2');
    
    function change_x_share_v2() {
      remove_shortcode( 'x_share' );
      add_shortcode( 'x_share', 'x_shortcode_entry_sharev2' );
    }

    Hope this helps.

    #1342993

    nbruell
    Participant

    Dear Lely,

    thanks for the quick help. it definitly changed something. Unfortunatly it crashed the layout. The hole side is scrambled now.

    I have add the function.php as zip to this post. Did I miss something with my cut and paste?

    The link is, where I have add the social buttons at the end of the post.
    http://new.bodega-stolberg.de/kiki-bragard/

    #1342998

    nbruell
    Participant

    that was the original layout

    #1343134

    Paul R
    Moderator

    Hi,

    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.

    #1343192

    nbruell
    Participant
    This reply has been marked as private.
    #1343196

    nbruell
    Participant
    This reply has been marked as private.
    #1343662

    nbruell
    Participant

    Howdy,

    just found some “other” description to solve this issue in this post: https://community.theme.co/forums/topic/hover-text/
    The problem is, I do not find this directory or can install this as x-addons? Is this changed with version 4.x of X-theme?

    thanks,
    Norbert

    #1343774

    Friech
    Moderator

    Hi Norbert,

    Thanks for the FTP credentials but it did not work, please confirm.

    You wrote: I only want to translate the text send for example to the email client and the text like “share by email” to “teilen per eMail”

    If that’s what you need then you don’t need the custom function. Social Share element or shortcode provides you a title, share title, and email subject option.

    [x_share title="Share this Post" share_title="TITLE THAT DISPLAYS WHEN YOU SHARE THE PAGE" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true" email_subject="WRITE SOME EMAIL SUBJECT HERE" class="my-social-share"]

    In the meantime, restore your child theme’s functions.php file to its original state to restore the layout of your website.

    Thanks.

    #1348236

    nbruell
    Participant

    Dear Friech,

    thanks for your help. I just could try your shortcodes mentioned above. Hat no time to work on my new side in the last days.
    I also reinstalled my child theme as I just did one update. So no big issue.
    The email subject did not realy work. I’m just checking if I build in a bug on this. Is there an overview of all the shortcodes I could use (want to change the hover text also).

    Thanks and nice weekend,
    Norbert

    #1348681

    Rue Nel
    Moderator

    Hey Norbert,

    Thanks for updating in! The color of the icons is the same as the colors of your site wide links. You can change the colors in the customizer. You may go to Appearance > Customize > Typography > Site Links and pick the colors in their respective color pickers.

    Hope this helps.

    #1348857

    nbruell
    Participant

    Dear Rue Nel,

    thanks for the information. Good to know, but I still do have my translation problem. I want to translate the hover text for the social share icons in german. Also the parameter for the email subject did not work (to create my own). Is there no complete documentation of all parameters and how to use them?
    Maybe it would help if I could have a look at the source code for the social sharing in blogs (to see which paramters I could give the the function). Problem is, in the forum is lot of stuff about the topic, but I did not find the source for my current X 4.6 and ethos. Maybe that changed with release 4.
    May you could help me the find the docu or the right source code (at leased I did not find the parameter mentioned above by Friech (email-subject) and it does not work in my installation.

    thanks for supporting me,
    Norbert

    #1349204

    Rue Nel
    Moderator

    Hello Norbert,

    Most of these keywords in Cornerstone is in cornerstone.pot which you can find in wp-content/plugins/cornerstone/lang/ folder. Please translate Cornerstone like any other WordPress plugin. Please check this: https://premium.wpmudev.org/blog/how-to-translate-a-wordpress-plugin/

    I also include the cornerstone.pot in the attachment.

    Hope this helps.

    #1357761

    nbruell
    Participant

    Dear Rue Nel,

    thanks again for all your support. I found the text I want to translate, so perfect for this. I also translated it using poedit and with the plugin loco-translate. Both work fine and create po and mo files with my changes. This are stored in plugin/conerstone/lang and include my translate.
    I also edit wp-config.php with my de_DE lang setting. I still have the problem that the language settings not active. That means my translaten is not shown as hover text on the share button or in the email subject. Any idea what I need to do, to ensure my translation is used by WP?

    Thanks Norbert