Highlight and Share Logo

Highlight and Share

Highlight to Share Demonstration

Inline Highlighting
Highlighting Text and Sharing

Click to Tweet Block Demonstration

Click to Tweet Block
Click to Tweet Block
Try out the block yourself. Just click it.

Inline Highlight Demonstration

Inline Highlight
Inline Highlight

Take a spin for yourself. This is Highlight and Share and I’m trying out inline highlighting. #WordPress #Plugins

For you Coders

Highlight and Share comes with several options out of the box, but you coders can fine-tune it. Some add-ons are planned to be released for this plugin to help with some common scenarios.

Here are some common actions and filters.

//Example filter usage for highlight and share //https://github.com/ronalfy/highlight-and-share /* The following filters take and return booleans (true, false)*/ /* Call WordPress functions __return_false or __return_true */ add_filter( 'has_show_facebook', '__return_true' ); //Disable or enable facebook sharing add_filter( 'has_show_twitter', '__return_true' ); //Disable or enable twitter sharing add_filter( 'has_load_css', '__return_true' ); //Disable or enable plugin's CSS - Use your own add_filter( 'has_enable_content', '__return_true' ); //Disable or enable main post content add_filter( 'has_enable_excerpt', '__return_true' ); //Disable or enable excerpt content add_filter( 'has_enable_mobile', '__return_true' ); //Disable or enable on mobile devices /* Override the Facebook share text (default is Share) */ add_filter( 'has_facebook_text', 'has_override_facebook_text' ); function has_override_facebook_text( $default ) { return 'Facebook'; } /* Override the Twitter share text (default is Tweet) */ add_filter( 'has_twitter_text', 'has_override_twitter_text' ); function has_override_twitter_text( $default ) { return 'Twitter'; } /* Override the JavaScript classes (assuming jQuery class format with no periods) */ add_filter( 'has_js_classes', 'has_override_js_classes' ); function has_override_js_classes( $content ) { return 'entry-content,type-page,type-post'; } /* Add JS IDs */ add_filter( 'has_js_ids', 'has_override_js_ids' ); function has_override_js_ids( $content = array() ) { if ( !is_array( $content ) ) $content = array(); $new_arr = array( 'content', 'comments' ); $content = array_merge( $content, $new_arr ); return $content; } /* Add JS elements */ add_filter( 'has_js_elements', 'has_override_js_elements' ); function has_override_js_elements( $content = array() ) { if ( !is_array( $content ) ) $content = array(); $new_arr = array( 'blockquote' ); $content = array_merge( $content, $new_arr ); return $content; } /* Override the Twitter username (no @ symbol needed) */ add_filter( 'has_twitter_username', 'has_override_twitter_username' ); function has_override_twitter_username( $username ) { return 'wordpress'; }
Code language: PHP (php)

Disable on Front Page

add_action( 'wp', function() { if ( is_front_page() ) { add_filter( 'has_show_facebook', '__return_false' ); add_filter( 'has_show_twitter', '__return_false' ); } } );
Code language: PHP (php)

Modify the Content URL

add_filter( 'has_content_url', function( $url, $post_id ) { return 'https://wordpress.org'; }, 10, 2 );
Code language: PHP (php)

Modifying jQuery Selectors

//Demonstrates how to select paragraph text only add_filter( 'has_js_selectors', 'hs_custom_selectors', 10, 5 ); function hs_custom_selectors( $selectors, $content = array(), $classes = array(), $ids = array(), $elements = array() ) { //With $content, $classes, $ids, $elements, you can build your own selectors //Or just override $selectors (a string) with your own custom ones return '.has-content-area p, .has-excerpt-area p'; }
Code language: PHP (php)

Ronald Huereca
MediaRon - Ronald Huereca

Ronald created MediaRon in 2011 and has more than fifteen years of releasing free and paid WordPress plugins.