Which method is best to enqueue scripts

Always use the built-in versions. Don’t waste time with old WordPress installations – other plugins will break there too. See wp-includes/script-loader.php for the list of available files. Quite a lot. 🙂 And avoid remote resources. Some (Google) fail to send the scripts gzip compressed to all supporting browsers, others may not be reliable enough. There … Read more

Autogenerate wordpress shortcodes using array?

Auto-generate shortcodes from an array: You can try the following Shortcode Automat: /** * Setup the Shortcode Automat * */ function shortcode_automat_setup() { $settings = array( “get_address” => “mg_admin_address”, “get_phone” => “mg_admin_phone”, “get_fax” => “mg_admin_fax”, “get_email” => “mg_admin_email”, “get_hrs_mon” => “mg_work_hrs_mon_frd”, “get_hrs_sat” => “mg_work_hrs_sat” ); $sc = new ShortCodeAutomat( $settings ); $sc->generate(); } add_action( ‘wp_loaded’, … Read more

Deactivate plugins only for mobile devices

If you deactivate a plugin, the change is stored in database, so in all subsequent access the plugin is deactivated, no matter the device used to access the site. Filtering the option Active plugin in WordPress are retrieved using wp_get_active_and_valid_plugins() function. It uses the option “active_plugins” to get the currently active plugin. All options in … Read more

add_rewrite_rule, plugin activation and plugin deactivation

The problem with calling flush_rewrite_rules() is that the rules instantly get regenerated, while your plugin’s hooks are still active. What I usually do, because it’s the simplest route to success, is delete the rewrite_rules option on activation/deactivation. The rules will then get regenerated on the next pageload instead of the current one: register_deactivation_hook( __FILE__, ‘my_plugin_deactivation’); … Read more

Install an external plugin within the current plugin

This solution should do the job for you. http://tgmpluginactivation.com/ The solution is meant for theme developers to package to download, automatically install and activate multiple plugins that are either packaged with a theme, downloaded from the WordPress Plugin Repository or downloaded elsewhere on the internet (perhaps a private repository. The code of the solution can … Read more

What happens when two plugins have the same 3rd party class included into them?

I went ahead and namespaced Stripe. Everything worked just great. And now I don’t have to worry about any one else’s Stripe library messing up my stuff. Original: namespace Stripe; New: namespace MyRadNamespace\Stripe; If anyone is interested in seeing how it’s done, feel free to browse my repo: https://github.com/Spokane-Wordpress-Development/Freezy-Stripe Cheers!