-
AuthorPosts
-
December 13, 2015 at 5:50 am #704690
Hi there,
Add following code in child theme’s functions.php file and translate those strings :
// Output Portfolio Item Social // ============================================================================= function x_portfolio_item_social() { $share_project_title = x_get_option( 'x_portfolio_share_project_title' ); $enable_facebook = x_get_option( 'x_portfolio_enable_facebook_sharing' ); $enable_twitter = x_get_option( 'x_portfolio_enable_twitter_sharing' ); $enable_google_plus = x_get_option( 'x_portfolio_enable_google_plus_sharing' ); $enable_linkedin = x_get_option( 'x_portfolio_enable_linkedin_sharing' ); $enable_pinterest = x_get_option( 'x_portfolio_enable_pinterest_sharing' ); $enable_reddit = x_get_option( 'x_portfolio_enable_reddit_sharing' ); $enable_email = x_get_option( 'x_portfolio_enable_email_sharing' ); $share_url = urlencode( get_permalink() ); $share_title = urlencode( get_the_title() ); $share_source = urlencode( get_bloginfo( 'name' ) ); $share_content = urlencode( get_the_excerpt() ); $share_image = urlencode( x_get_featured_image_with_fallback_url() ); $facebook = ( $enable_facebook == '1' ) ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __( 'Share on Facebook', '__x__' ) . "\" 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 = ( $enable_twitter == '1' ) ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __( 'Share on Twitter', '__x__' ) . "\" 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 = ( $enable_google_plus == '1' ) ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __( 'Share on Google+', '__x__' ) . "\" 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 = ( $enable_linkedin == '1' ) ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __( 'Share on LinkedIn', '__x__' ) . "\" 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 = ( $enable_pinterest == '1' ) ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __( 'Share on Pinterest', '__x__' ) . "\" 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 = ( $enable_reddit == '1' ) ? "<a href=\"#share\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share\" title=\"" . __( 'Share on Reddit', '__x__' ) . "\" 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 = ( $enable_email == '1' ) ? "<a href=\"mailto:?subject=" . get_the_title() . "&body=" . __( 'Hey, thought you might enjoy this! Check it out when you have a chance:', '__x__' ) . " " . get_permalink() . "\" data-toggle=\"tooltip\" data-placement=\"bottom\" data-trigger=\"hover\" class=\"x-share email\" title=\"" . __( 'Share via Email', '__x__' ) . "\"><span><i class=\"x-icon-envelope-square\" data-x-icon=\"\"></i></span></a>" : ''; if ( $enable_facebook == '1' || $enable_twitter == '1' || $enable_google_plus == '1' || $enable_linkedin == '1' || $enable_pinterest == '1' || $enable_reddit == '1' || $enable_email == '1' ) : ?> <div class="x-entry-share man"> <div class="x-share-options"> <p><?php echo $share_project_title; ?></p> <?php echo $facebook . $twitter . $google_plus . $linkedin . $pinterest . $reddit . $email; ?> </div> </div> <?php endif; }
Hope it helps.
December 13, 2015 at 6:08 am #704702I just added the code but there must something wrong into it as it breaks my site.
Blank page, no site showing with the code …
December 13, 2015 at 8:48 am #704809Hi there,
Please remove the code and add this in Customize -> Custom -> JavaScript :
jQuery(".x-share-options a:last-child").attr("data-original-title","Partager via");
Hope it helps.
December 13, 2015 at 9:26 am #704841This last piece of code does not seem to give any results.
I have now the Share buttons set so that they appear on pages that I have created.
These pages can be normal page that I create, page for a news, or page for portfolio. On all these 3 type of pages I do now have the Share buttons.And looking carrefully at these buttons, most of them are texted with “Share on …” and one is labelled with “Share via Email”. What I’d like to have is instead to have the text “Share” replaced by “Partager” (french translation of Share). So, would you hae a simple code which convert the “Share” into “Partager”? for all these Share buttons?
Here an example:
December 13, 2015 at 9:45 am #704853So it is the tooltip text of the Share button that I want to change. Replacing the word “Share on” by “Partager sur” and “Share via” by “Partager via”.
December 13, 2015 at 2:58 pm #705115Hi Pierre,
Those string should be translatable through functions.php, instead of doing the above, please add this code at your child theme’s functions.php
add_filter('gettext', 'translate_social_labels', 20, 3); function translate_social_labels ( $translated_text, $text, $domain ) { $translations = array ( 'Share on Facebook' => 'your translation here', 'Share on Twitter' => 'your translation here', 'Share on Google+' => 'your translation here', 'Share on LinkedIn' => 'your translation here', 'Share on Pinterest' => 'your translation here', 'Share via Email' => 'your translation here' ); $string = $translations [ $text ]; return !empty( $string ) ? $string : ( !empty( $translated_text ) ? $translated_text : $text ); }
That should do it, and if your site goes blank, then please set WP_DEBUG to true at your site’s wp-config.php and refresh your page. Please provide the error you’ll get, or perhaps provide your FTP login credentials.
Thanks!
December 13, 2015 at 11:57 pm #705546I knew you could make it easy for me 😉
It works perfectly of course because you are a TOP support guys.Thank you so much for this.
December 14, 2015 at 12:11 am #705560You’re welcome.
-
AuthorPosts