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' );
Related Posts:
- Difference Between Filter and Action Hooks?
- Which hook should be used to add an action containing a redirect?
- How do you use the plugin boilerplate loader class to hook actions and filters?
- How Do I Load My Action Earlier Enough?
- Does WP fire delete_post when trashed posts are automatically deleted?
- How do I Make a Theme “plugin-ready”?
- Using a Theme inside a Plugin directory
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Is it possible to create an action hook using do_action() within add_action()?
- How can I hook into existing WordPress Bulk actions?
- Programmatically Selecting Theme Based on URL
- Define a function outside a class and call the function using action or filter hook
- Create a plugin to change the action to which a function is hooked
- Modifying values with add_action to be sent to db
- Woocommerce – Hide a Column in Cart Table
- Hook into theme-switching later than `setup_theme`
- Hook to get image filename when it is uploaded
- add_action in functions.php, do_action in plugin?
- Which are the hooks run before/after when a category’s deletion?
- Should action callbacks start with a verb?
- Execute Hook on the footer or header after activating a plugin
- Namespaced action and filter tags
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- I have 2 plugins using the same wp_login action hook and one is not working
- How dynamic action login_form_{action} is working
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- How to get all queries’s results after they have executed?
- Bug: Post needs to be updated twice when adding action for save_post hook
- When does save_post hook fire on post save/update
- Hook add_attachment error
- Call to undefined function is_home() or any conditional tags
- How to find list of all functions bind to a particular hook from my plugin?
- Can I Hook Into the TinyMCE Insert/Edit Link Button to Use Shortlink For Post?
- Using init hook for register_taxonomy is causing invalid_taxonomy in wp_insert_term()
- Action / Hook when a new plugin is added
- apply_filters() and call_user_func() to define and call a function outside a class
- Getting Post ID at “stylesheet” and “template” hooks
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- remove different admin menu for specific users
- add_option_{$option} action hook not being called
- Does WordPress have something like timer hook?
- How can I set a dynamic value for post_updated_messages based on return value of post_updated?
- Insert plugin html content to a specific spot in the frontpage
- Apply function on all action hooks?
- Ninja Forms: Front-End Forms, Post ID?
- How to override existing plugin action with new action
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- Using Primary Color in Plugin Block
- A Post is saved twice or more during add_action(save_post)
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- Actions or filters fired when data is saved in a custom table
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- Plugin development, hooks, generate content
- Odd behaviour with submenu link creation
- Hook event for upload image in the menu
- Help with callback using do_action_ref_array
- Fully automated theme install and activation via a plugin
- Is it possible to add an action to the currently running action?
- How to prevent action in ajax request, when in admin side?
- Calling plugins API within a theme
- How to redirect to action on custom page within admin section
- What are the benefit in adding hook in the init() hook?
- Which action is triggered when a theme was modified?
- Why is my javascript not invoked in my hooks except wp_head?
- What filter should I use to insert a button inside on Media>Add New
- How to use a hook to override an update_post_meta call in a plugin?
- External Authentication, session_tokens not destroyed on logout
- Any hook for pre-plugin-update -either bulk or single plugin update
- How to Debug: My Plugin Interferes With My Theme
- How to get all of the activate_plugin action parameters?
- Get Time Taken By Each Action Hook in WordPress
- WordPress custom taxonomy check box to dropdown
- load_plugin_textdomain doestn’t work with add_action plugins_loaded
- Force HTTPS 301 redirect with hook
- How to make “upgrade safe” theme for a plugin?
- What hook is the currently active theme’s functions.php file loaded on? [duplicate]
- Remove an action by extending class and replacing it
- Trying to get class to instantiate ONCE (or, “why do I keep punching myself in the head?”)
- How to get menu location in wp_update_nav_menu hook
- making a plugin that moves other plugins wp_head actions to wp_footer
- How To Protect Plugin Display From Being Affected By Theme’s CSS
- Restrict certain actions to plugin-specific admin menu pages only
- Adding tables to dashboard pages programmatically?
- How to enhance a self developed plugin by its own plugin architecture
- How to update global variables in plugin activation callback?
- `registration_errors` filter doesn’t seem to be called
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- How to hide/remvoe unnecessary field/section in post edit section ( Dashboard )
- Hook for validating and rejecting frontend image upload
- How do I remove an action hook inside a class that is called by another class?
- Adding and handling custom settings tab to fusion element
- WordPress Reset password Strength set to medium
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- plugin modal/popup integration best practice
- Create and style menu
- Get user logged in status from within a plugin. $current_user not defined
- How wordpress plugin hooks works? [duplicate]
- Send Webhook when post-status is publish or trash
- Using “add_image_size” to register custom image sizes inside plugins not working