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 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.

novashare_mobile_networks

The novashare_mobile_networks filter allows you to force specific networks to only show on mobile devices.

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_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_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;
});

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_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;
});

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_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_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_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_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_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_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;
});
Was this article helpful?

Related Articles