Skip to content

Instantly share code, notes, and snippets.

@Benunc
Last active July 6, 2018 20:51
Show Gist options
  • Select an option

  • Save Benunc/1219d22254ccb39496c47d7f94a5436d to your computer and use it in GitHub Desktop.

Select an option

Save Benunc/1219d22254ccb39496c47d7f94a5436d to your computer and use it in GitHub Desktop.
Removes the css completely for version 5.0 and up of Better Click To Tweet.
<?php
/*
* ALERT: THIS FUNCTION ONLY WORKS ON VERSION 5.0+ OF BETTER CLICK TO TWEET
*
* This function sets an option in your WordPress Options table (default wp_options), so adding this function
* and refreshing the page even one time will disable the Better Click To Tweet Stylesheet until the option is removed.
*
* Note that uninstalling the core Better Click To Tweet plugin from the dashboard will remove the option automatically.
*
* To remove the option (and thus re-register and enqueue the defaultCSS) without deleting the core plugin,
* you'll need to uncomment the commented out function (remove the // from each line), and then do one page refresh
* before deleting this snippet entirely.
*/
//function my_bctt_remove_css_option() {
// return delete_option( 'bctt_disable_css' );
//}
function my_bctt_set_a_dequeue_option() {
if ( !function_exists( 'my_bctt_remove_css_option' ) ) {
add_option( 'bctt_disable_css', 'yes' );
} else {
my_bctt_remove_css_option();
}
}
add_action( 'plugins_loaded', 'my_bctt_set_a_dequeue_option' );
@elvismdev
Copy link

WordPress already has built-in mechanisms to remove stylesheets and Javascript files added by plugins. If I'd like to remove the default BCTT stylesheet an snippet like this on functions.php does the job, no need to reinvent the wheel for that task.

function my_scripts() {
  // Remove default stylesheet from Better Click To Tweet
  wp_dequeue_style( 'bcct_style' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment