Skip to content

Instantly share code, notes, and snippets.

@wpsmith wpsmith/dt-addthis.php Secret
Created Feb 23, 2014

Embed
What would you like to do?
Addthis Plugin Extension in folder named dt-addthis
<?php
/**
* DT AddThis Extension Plugin
*
* @package DT_AddThis
* @author Travis Smith <t@wpsmith.net>
* @license GPL-2.0+
* @copyright 2014 Travis Smith
*
* @wordpress-plugin
* Plugin Name: AddThis Social Bookmarking Widget - Daniels Trading Extension
* Plugin URI: http://www.wpsmith.net
* Description: Extends AddThis Social Bookmarking Widget
* Version: 1.0.0
* Author: Travis Smith
* Author URI: http://www.wpsmith.net
* Text Domain: dt-addthis
* Domain Path: /languages
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
add_action( 'update_option_active_sitewide_plugins', 'dtat_deactivate_self', 10, 2 );
add_action( 'update_option_active_plugins', 'dtat_deactivate_self', 10, 2 );
/**
* Deactivate ourself if Addthis is deactivated.
*/
function dtat_deactivate_self( $plugin, $network_deactivating ) {
if ( !is_plugin_active( 'addthis/addthis_social_widget.php' ) ) {
deactivate_plugins( 'dt-addthis/dt-addthis.php', true );
}
}
add_filter( 'addthis_post_exclude', 'dtat_addthis_post_exclude_filter' );
/**
* Remove AddThis from specific custom post types.
*
* Remove AddThis from facts, offers, tips, webinars, videos, and testimonials.
*
* @param bool $display
* @return bool Return false if one of a specific CPT.
*/
function dtat_addthis_post_exclude_filter( $display ) {
if ( in_array( get_post_type(), array( 'fact', 'offer', 'tip', 'webinar', 'video', 'testimonial', ) ) ) {
$display = false;
}
return $display;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.