-
-
Save wpsmith/26c2e07370ee8b4c3e3f to your computer and use it in GitHub Desktop.
Addthis Plugin Extension in folder named dt-addthis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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