Use code NOVASHARE for an extra 10% off!
  1. Home
  2. Docs
  3. General
  4. Filters to further customize Novashare

Filters to further customize Novashare

Below is a list of all the filters and actions available in Novashare. These allow you to further customize the plugin. If you need an easy way to add a filter, we recommend the free Code Snippets plugin.

Filters

Actions

novashare_button_attributes

The novashare_button_attributes filter allows you to add custom attributes to the social button for a specific network.

Below is an example.

add_filter('novashare_button_attributes', function($attributes, $network, $location) {
    if($network == 'facebook') {
        $attributes['custom_att1'] = 'value1';
        $attributes['custom_att2'] = 'value2';
    }
    return $attributes;
}, 10, 3);

novashare_button_networks

The novashare_button_networks filter allows you to remove a specific network from inline social share buttons on a page or post type.

Below is an example where Flipboard is removed from the page post type.

add_filter('novashare_button_networks', function($networks, $location) {
    if($location == 'inline' && is_singular('page')) {
        if(($key = array_search('flipboard', $networks)) !== false) {
            unset($networks[$key]);
        }
    }
    return $networks;
}, 10, 2);

novashare_ctt_tweet

The novashare_ctt_tweet filter allows you to manipulate the Click to Tweet text immediately before the link is generated.

Below is an example if you wanted to allow shortcodes to be interpreted and pass to Twitter.

add_filter('novashare_ctt_tweet', 'do_shortcode');

novashare_filter_refresh_rates

The novashare_filter_refresh_rates filter allows you to override the Novashare plugin settings with your own share count refresh rates. Below is an example. See more details.

function novashare_custom_refresh_rates($rates) {
	return array(
		'max' => 10800, //3 hours in seconds
		'sets' => array(
			array(
				'modified' => 86400, //1 day in seconds
				'rate' => 3600 //1 hour in seconds
			),
			array(
				'modified' => 604800, //7 days in seconds
				'rate' => 7200 //2 hours in seconds
			)
		)
	);
}
add_filter('novashare_filter_refresh_rates', 'novashare_custom_refresh_rates');

novashare_floating

The novashare_floating filter allows you to manually control where floating buttons are printed. For example, perhaps you don’t want them to print if the current post doesn’t have a featured image set.

add_filter('novashare_floating', function($bool) {
    if(is_singular() && !has_post_thumbnail()) {
        return false;
    }
    return $bool;
});

The novashare_follow_network_link filter allows you to change the link you’re using for a follow button. For example, with LINE, it defaults to a profile link format, but you could change it to a business page format.

Below is an example.


add_filter('novashare_follow_network_link', function($link, $network) {
    if($network == 'line') {
        //do something with the link here
    }
    return $link;
}, 10, 2);

novashare_inline

The novashare_inline filter allows you to manually control where inline content share buttons are printed. For example, perhaps you don’t want them to print if the current post doesn’t have a featured image set.

add_filter('novashare_inline', function($bool) {
    if(!has_post_thumbnail()) {
        return false;
    }
    return $bool;
});

novashare_inline_cta

The novashare_inline_cta filter allows you to change the CTA text.

Below is an example on product posts.

add_filter('novashare_inline_cta', function($cta) {
if(is_singular('product')) {
$cta = 'Share this product with your friends!';
}
return $cta;
});

novashare_inline_excluded_filters

The novashare_inline_excluded_filters allows you to add any hook that you don’t want our inline content buttons to print on. This can be useful if you have a theme or plugin that triggers the_content outside of the primary content block.

Below is an example.


add_filter('novashare_inline_excluded_filters', function($filters) {
    $filters[] = 'custom_filter_hook';
    return $filters;
});

novashare_inline_position

The novashare_inline_position filter allows you to force inline social share buttons to only show on a page or post type.

Below is an example of forcing inline social share buttons to only show on the page post type.

add_filter('novashare_inline_position', function($position) {
    if(is_singular('page')) {
        $position = 'below';
    }
    return $position;
});

novashare_mobile_networks

The novashare_mobile_networks filter allows you to force specific networks to only show on mobile devices. Make sure you have separate mobile cache enabled on your site for this to function properly.

Add a network

To add a network to the mobile-only list, you can specify them with the following filter. In this example, we added twitter, facebook, and pinterest.

//add network(s) to mobile only list
add_filter('novashare_mobile_networks', function($networks) {
	array_push($networks, 'twitter', 'facebook', 'pinterest');
	return $networks;	
});

novashare_networks

The novashare_networks filter allows you to change the name of a network.

Below is an example.

add_filter('novashare_networks', function($networks) {
$networks['sms']['name'] = 'Text';
return $networks;
});

The novashare_network_link filter allows you to modify the final link for a specific network.

Below is an example.

add_filter('novashare_network_link', function($link, $network) {
if($network == 'pinterest') {
//do something with the link here
}
return $link;
}, 10, 2);

novashare_opengraph_meta_tags

The novashare_opengraph_meta_tags filter allows you to edit or add to opengraph output.

Below is an example.

add_filter('novashare_opengraph_meta_tags', function($output) {

     //do things here

     return $output;
});

The novashare_permalink filter allows you to modify the final permalink before it’s added to the network link.

Below is an example of using it to add the integration with AffiliateWP.

add_filter('novashare_permalink', function($link, $network) {

    //make sure affiliate wp is available
    if(function_exists('affwp_is_affiliate')) {

        //check that user is affiliate
        if(is_user_logged_in() && affwp_is_affiliate()) {

            //add query arg to link
            $link = add_query_arg(affiliate_wp()->tracking->get_referral_var(), affwp_get_affiliate_id(), $link);
        }
    }

    return $link;
}, 10, 2);

novashare_pin_button_text

The novashare_pin_button_text filter allows you to change the text that is displayed on the image pin button.

Below is an example.

add_filter('novashare_pin_button_text', function($text) {
	return 'pin me already!';
});

novashare_pinterest_image_excluded

The novashare_pinterest_image_excluded filter essentially turns the excluded box into a whitelist box instead. This can be used if you want to add Pinterest image pins to a few specific images, instead of across your entire site.

add_filter('novashare_pinterest_image_excluded', function($excluded) {
    return !$excluded;
});

novashare_pinterest_image_excluded_attributes

The novashare_pinterest_image_excluded_attributes filter allows you to exclude specific images from getting Pinterest pins applied with an attribute string, such as a class or image file name.

Below is an example.

add_filter('novashare_pinterest_image_excluded_attributes', function($attributes) {

    //add excluded attributes
    $attributes[] = 'class="example-class"';
    $attributes[] = 'example-image.png';

    return $attributes;
});

novashare_pinterest_image_minimum_dimension

The novashare_pinterest_image_minimum_dimension filter allows you to change the minimum dimension required (in pixels) for the Pinterest Image hover buttons to be applied to an image. This applies to both width and height. If either dimension falls below the minimum, the image will be excluded.

Below is an example.

add_filter('novashare_pinterest_image_minimum_dimension', function() {
	return 500;
});

The novashare_short_link_url filter allows you to override what short link is generated and returned before it’s saved in the database. For example, you could filter the full URL and return a short link on your own if you don’t want to use Bitly’s API.

add_filter('novashare_short_link_url', function($short_url, $long_url, $network) {

    //process $long_url into new $short_url

    return $short_url;
}, 10, 3);

novashare_total_share_count_text_plural

The novashare_total_share_count_text_plural filter allows you to change the “Shares” text (plural form) to whatever you want.

Below is an example.


add_filter('novashare_total_share_count_text_plural', function($text) {
    return 'shares';
});

novashare_total_share_count_text_singular

The novashare_total_share_count_text_singular filter allows you to change the “Share” text (singular form) to whatever you want.

Below is an example.

add_filter('novashare_total_share_count_text_singular', function($text) {
    return 'share';
});

The novashare_bitly_link_generated action allows you to run your own custom code after a bitly link has been generated for a post.

Below is an example.

add_action('novashare_bitly_link_generated', function($url, $post_id, $network) {

     //do things here

}, 10, 3);
Was this article helpful?

Related Articles