MWDelaney / bootstrap-3-shortcodes

WordPress shortcodes for easier use of Bootstrap elements in your content.
https://wordpress.org/plugins/bootstrap-3-shortcodes/
MIT License
377 stars 118 forks source link

Allows user to define constant to disable scripts #79

Closed QWp6t closed 10 years ago

QWp6t commented 10 years ago

Setting LOAD_BS_SHORTCODES_SCRIPTS to false (or anything other than true) will cause the function that loads the scripts to exit without enqueuing the scripts.

This is useful when users concatenate and uglify their JS.

NOTE: scripts load fine when constant is not defined.

This PR is one of many ways this could be accomplished. It was just the fastest way I could think of that will have a very minimal impact on your plugin.

nextgenthemes commented 10 years ago

This makes no sense you can dequeue scripts with WP in native way without any special things added to plugins or themes.

MWDelaney commented 10 years ago

I agree, if the user needs to dequeue scripts he/she should do so in their theme or in another plugin.

nextgenthemes commented 10 years ago

@QWp6t its as easy as this btw (untested but should work)

add_action( 'wp_print_scripts', 'de_script' );

function de_script() {
    wp_dequeue_script( 'bootstrap-shortcodes-tooltip' );
    wp_dequeue_script( 'bootstrap-shortcodes-popover' );
}
QWp6t commented 10 years ago

I use this for my plugins so that developers don't have to unnecessarily fire the enqueue and then dequeue actions. It's more optimal to use a constant and it's not like it disrupts the functionality of the plugin.

I initially got the idea from this plugin: http://wordpress.org/plugins/wpsocialite/

Anyway, it's just my preference.