Drop this in your functions.php or a custom plugin.
function wpse_57621_alo_tidy()
{
if ( $page_id = get_option( 'alo_em_subsc_page' ) ) {
if ( ! is_page( $page_id ) )
remove_action( 'wp_head', 'alo_em_ajax_js' );
}
}
add_action( 'wp', 'wpse_57621_alo_tidy' );
It’s attached to the wp hook, which runs just after the request has been handled & queried.
We’re saying “if the ALO newsletter page setting exists, but we’re not currently on said page, unattach the script output hook”.
Related Posts:
- How do I call wp_get_current_user() in a plugin when plugins are loaded before pluggable.php?
- if plugin is active? check if plugin is enabled or not?
- How to Loop Plugin Option Field Set?
- Can we completely remove the WordPress Sitemaps (WordPress 5.5)?
- Saving Plugin settings to the database
- Change destination author link
- HELP: Integrating WP with raw PHP code once published button is hit
- How to redirect Old Post URL to new Post and keep Old post Comments?
- Modifying Footnote Plugin for Descriptive Title Attributes
- I would like to use create a function in my custom plugin to tell WP to use a different header
- New Plugin: Post update pushes a copy as a revision
- How to Replace Words with Hypertext Link But Ignore Previously Existed Links?
- bulk change of image setting “link to” to “link to: image url “
- Display a text message if the field is not found and not if found
- Scope for PHP Variables Assigned in functions.php or a plugin
- Add a plugin before main container
- Executing my function once on a specific time
- How to stop or remove an action being called inside a function of an extended class
- wordpress plugin is not activating from widget
- Date calculations from 2 custom fields
- How to enable specific plugin only based around shop manager role?
- Override Plugin Script Fucnction in WordPress
- Adding a new field to the address field type in gravity forms
- Replacing a plugin function with a custom renamed function doesn’t work
- Nested shortcode functions accessing variable
- How to call WordPress function other files
- Conditional attributes and logic per product category
- WP Query. Is there a maximum size?
- WordPress get_avatar function not correct working
- What is @Action in WordPress?
- Check if variable is set in filter
- Checking the count within a foreach loop
- JQuery prepend a function
- Why can’t I call a (member) function from within a foreach?
- Are there action hooks for comments?
- Help with WP Business Directory Manager Plugin?
- wp_dequeue_script for a Plugin
- Need to replace Currency Shortforms
- Return multiple values in a shortcode attribute
- get specific value of a array | PHP
- How to make a dynamic css class whose name changes every visit to confuse scraper
- Plugin onclick button activate other plugin
- Send email with list of active plugins upon activation/deactivation
- Using custom fields for image alt and title
- Add the_post_thumbnail_url to a shortcode in function.php
- Different registration form for different roles
- Adding a Tag Parameter / Filter to My Shortcode
- Can you echo PHP code from a variable?
- how to validate input field in wordpress generated with wpform plugin
- add_rewrite_rule to load different page, without changing URL in browser
- WordPress Custom Hook with Class method
- Allow a particular user to access a particular plugin?
- WP Function does not trigger on Webhook API Call
- Cookie value changes back to previous value after changing
- Post source link plugin – small modification
- Share my WordPress plugin for updating how?
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- How to create algorithm for ordering posts in WordPress?
- Submitting form to PHP
- Adding discount functionality to the cart
- Precheck fields when I add a new post
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- Get Shortcode output to database for static post_content
- working code, not working – Plugin Dev
- Block plugin update possibilities (but not by hiding notifications)
- Change custom rewrite rule when permalink is updated/changed
- Return function results within shortcode
- Configuring default woo commerce login with modal popup
- Soflyy WP All Import Custom File Download Issue
- register_activation_hook doesn’t fire at all
- Update (a function) post’s featured image as soon as $image_url changes
- My ajax request don´t work and return 0
- Populate select option with JSON file
- How to echo a plugin’s function into a template?
- Find all strings between an enclosing shortcode
- It possible to implement an adhoc php web application with wordpress?
- Create csv file in plugin
- Posting code inside the post instead of in the template file using shortcode
- Contact Form 7: custom validation [closed]
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- date function not correctly returning date
- Including a PHP file via a function that is part of a plugin?
- How to disable register and reset the password from WordPress admin panel?
- How use Dynamic hyperlink on each wordpress post?
- How to prevent page load on form submission
- How to tweak a plugin without preventing it from updating
- Integrate Razorpay quick payments plugin with contact form7 plugin
- WordPress: code structure
- PHP if url extension action=discussion condition use [closed]
- Adding a script & php to functions.php
- PHP Creating a formula from mysql db values and db stored math operator
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Option value not getting updated until page refresh in WordPress
- Make plugin admin page visible to other roles
- WordPress Convert queries to slashes using function.php
- Sort posts by Date (DESC) and by ACF: active_inactive (ASC)
- WordPress Custom Page Blog Template Pagination Problem (Pagination Not Displaying)
- stop resize button for wordpress media
- Mixed results with is_page() WordPress function, when using $this, or self
- Read page- or post-content across different builder-plugins