Tagged: x
-
AuthorPosts
-
August 12, 2016 at 3:18 am #1128482
pcnordhaugParticipantIยดll just put that code in the function file in the child theme folder right?
See this is for the e-mail text. What about the mouse-over text on the buttons (icons)?
August 12, 2016 at 4:23 am #1128538
pcnordhaugParticipantBy the way the e-mail worked great. But do you also have the code for changing the text when mouse over?
August 12, 2016 at 12:30 pm #1128963
JadeModeratorHi there,
Please add this in the custom JS area in the customizer:
jQuery('.x-share-options a:nth-child(1)').attr('data-original-title', 'For FB'); jQuery('.x-share-options a:nth-child(2)').attr('data-original-title', 'For Twitter'); jQuery('.x-share-options a:nth-child(3)').attr('data-original-title', 'For Email');Kindly make sure to edit the values for FB, for twitter, for email to the correct text.
Hope this helps.
August 12, 2016 at 12:50 pm #1128984
pcnordhaugParticipantTried it and didn’t help. Still the same.
Got the code under her for changing the text in the mail that got generated when you hit the mail icon.
Isn’t there a code similar as this that can be put in the function file in the child theme? That worked perfect.
// Change Email text
// =============================================================================
function change_email_text($translated) {
$translated = str_ireplace(‘Hey, thought you might enjoy this! Check it out when you have a chance:’, ‘insert your translation here’, $translated);
return $translated;
}
add_filter(‘gettext’, ‘change_email_text’ );
// =============================================================================August 12, 2016 at 7:42 pm #1129355
Rue NelModeratorHello There,
To have a full control over the share element, you can insert this custom code in your child theme’s functions.php file
// Custom Share post element // ============================================================================= function custom_shortcode_share_posts( $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=\"{$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; } add_action('init', 'apply_custom_shortcode_recent_posts'); function apply_custom_shortcode_recent_posts() { remove_shortcode( 'x_share' ); add_shortcode( 'x_share', 'custom_shortcode_share_posts' ); } // =============================================================================Please copy the raw code here (http://pastebin.com/jzvfEfHL) to preserve the unicode html entities or data-x-icon values.
Please let us know how it goes.
August 13, 2016 at 2:44 am #1129709
pcnordhaugParticipantWhen this code are pasted in the function file the hole site goes blank. An yes, I use raw code from the link.
So… That didn’t helped!
Why did that other code work. The translation code for the email generated from this buttons? Isn’t there a similar code for these?
Anyway – is there a solution that really works for this. Now this thread has gone very long allready hehe:)
August 13, 2016 at 4:02 am #1129771
Rue NelModeratorHello There,
I am the staff who gave you the code. I have tested the code in my local server and made sure that it works with no issues. I am suspecting that you have other functions in your child theme that may have the same function. I will revised it and make use of this code instead:
// Custom Share post element // ============================================================================= function pcnordhaug_custom_shortcode_share_posts( $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=\"{$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; } add_action('init', 'pcnordhaug_apply_custom_shortcode_share_posts'); function pcnordhaug_apply_custom_shortcode_share_posts() { remove_shortcode( 'x_share' ); add_shortcode( 'x_share', 'pcnordhaug_custom_shortcode_share_posts' ); } // =============================================================================Again please copy the raw code here (http://pastebin.com/zVm6M1re) to preserve the unicode html entities or data-x-icon values. And please do not forget to add your translations as well.
Hope this helps. Kindly let us know.
August 13, 2016 at 4:10 am #1129775
pcnordhaugParticipantAh – forgot to remove the code given by “Jade” a few post over her. They were pasted into the cutomizer js.
Will try to remove this first and try again.
Will let you know how it goes ๐
August 13, 2016 at 4:18 am #1129778
Rue NelModeratorNo Problem.
Please let us know then.August 13, 2016 at 6:13 am #1129832
pcnordhaugParticipantThis reply has been marked as private.August 13, 2016 at 5:27 pm #1130194
RadModeratorHi there,
Please change this part,
add_action('init', 'pcnordhaug_apply_custom_shortcode_share_posts'); function pcnordhaug_apply_custom_shortcode_share_posts() { remove_shortcode( 'x_share' ); add_shortcode( 'x_share', 'pcnordhaug_custom_shortcode_share_posts' ); }to this,
add_action('init', 'pcnordhaug_apply_custom_shortcode_share_posts', 99999); function pcnordhaug_apply_custom_shortcode_share_posts() { remove_shortcode( 'share' ); remove_shortcode( 'x_share' ); remove_shortcode( 'cs_share' ); add_shortcode( 'share', 'pcnordhaug_custom_shortcode_share_posts' ); add_shortcode( 'x_share', 'pcnordhaug_custom_shortcode_share_posts' ); add_shortcode( 'cs_share', 'pcnordhaug_custom_shortcode_share_posts' ); }And before we continue, please update your theme to latest. You already updated your cornerstone to 1.3.0 but not the theme.
Thanks!
August 15, 2016 at 1:57 am #1131471
pcnordhaugParticipantThe theme is updated to the latest and the lines of code changes – and all now workes great! Thanx – thanx a lot ๐
August 15, 2016 at 2:32 am #1131502
ChristopherModeratorYou’re welcome.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1126775 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
