What’s the earliest point I can get the queried object ID?

A more compact and WordPress-ish way, using url_to_postid(): function wpmp_switcher_exclusions_init() { $pid = url_to_postid( home_url( add_query_arg( array() ) ) ); if ( (int) $pid > 0 && get_post_meta( $pid, ‘_wp_page_template’, TRUE ) === ‘my-responsive-template.php’ ) { remove_action(‘init’, ‘wpmp_switcher_init’); remove_action(‘admin_menu’, ‘wpmp_switcher_admin_menu’); remove_action(‘wp_footer’, ‘wpmp_switcher_wp_footer’); remove_filter(‘stylesheet’, ‘wpmp_switcher_stylesheet’); remove_filter(‘template’, ‘wpmp_switcher_template’); remove_filter(‘option_home’, ‘wpmp_switcher_option_home_siteurl’); remove_filter(‘option_siteurl’, ‘wpmp_switcher_option_home_siteurl’); } } add_action( ‘setup_theme’, ‘wpmp_switcher_exclusions_init’ … 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

Detect a focus on wp_editor

You can pass an array of settings to the editor instance. For possible values please refer to the tinymce documentation, in your case ‘init_instance_callback’ might be helpful. https://www.tinymce.com/docs/configure/integration-and-setup/#init_instance_callback wp_editor(”, ‘sedemoeditor’, array( ‘tinymce’ => array( ‘init_instance_callback’ => ‘function(editor) { editor.on(“focus”, function(){ console.log(“Editor: ” + editor.id + ” focus.”); }); }’ ) ));

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!

How do I conditionally enqueue script for CPT single post type with plugin?

Make sure your code runs in wp_enqueue_scripts action hook. Also checkout your script handle ‘owl.carousel.js’. In wp_script_is(), it is not the same than in the 2 later functions in which you enter it as ‘owl.carousel.min.js’. add_action( ‘wp_enqueue_scripts’, ‘enqueue_properties_scripts’ ); function enqueue_properties_scripts() { if ( ‘properties’ === get_post_type() ) { if ( wp_script_is( ‘owl.carousel.min.js’, ‘enqueued’ ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)