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 create a backend for a custom theme?
- How to make “upgrade safe” theme for a plugin?
- WordPress class, using add_action to call member function does not work
- Where do I put my add_action(… and add_filter(… and do I need to remove them?
- use of do_action() without any functions attached
- What happens when two or more plugins use the same hook?
- Does admin_print_scripts-$hook_suffix work for nested paths to individual files?
- What hook is the currently active theme’s functions.php file loaded on? [duplicate]
- Plugin uninstall function is not working
- Delete data from database using row action
- flush rewrite rules after plugin update?
- Plugin does not add action
- Remove an action by extending class and replacing it
- Add child pages to submenu automatically
- After plugin activation hook
- How to replace default comments with custom HTML?
- Odd map_meta_cap $args on post edit — sometimes integer, sometimes string
- Trying to get class to instantiate ONCE (or, “why do I keep punching myself in the head?”)
- How can I create a custom plugin that allows anonymous users to signup without registering?
- hook filter after the_content on a specific page
- Bind a function with its own argument to show something dynamically after every content
- How to get menu location in wp_update_nav_menu hook
- A question about add_action()
- Is there an admin hook that will let me read GET variable before it’s too late to set the header Location
- Are there any official or unofficial guidelines for the styling of a widget?
- Why enqueue styles on hook?
- What’s the hook for filtering every texts of site?
- making a plugin that moves other plugins wp_head actions to wp_footer
- Hook for page Request?
- Associate multiple email addresses with the same user account, so they can log in with either
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Run command “composer install” when activating wordpress plugin
- Update variable value via add_filter
- Add a check box in Menu Settings
- Custom filter not working
- hook update_option/updated_option empty $old_value and $value
- Configure WordPress to Generate Scheme-less Relative URLs
- Hide one specific woocoomerce product
- Include HTML (Bootstrap Modal Box) with a plugin into my header
- Get images / media attached to a page by page ID
- wordpress automatic update does not run
- Create fixed static pages
- Ajax +wordpress onClick link redirect to new page and create html content
- How to replace settings in WordPress plugin from a theme
- Redirect returning users to a certain page?
- How To Protect Plugin Display From Being Affected By Theme’s CSS
- Restrict certain actions to plugin-specific admin menu pages only
- How Can I Add Code To A Preexisting Function Without Editing it
- Adding tables to dashboard pages programmatically?
- Setting post_id for single.php based on URL without a redirect
- Displaying custom content from a plugin within the active theme
- Creating posts with links from a txt file
- Set the payment processor callbacks to a plugin
- How to do admin ajax request in a plugin for rest api