Hi,
Well, there is no option, but it could be doable, programatically. Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
add_filter( 'asl_stop_loading', 'asl_stop_loading_condition', 10, 1 );
function asl_stop_loading_condition( $stop ) {
if ( !DOING_AJAX ) {
if ( get_the_ID() != 1234 ) {
$stop = true;
}
}
return $stop;
}
Whenever this funtion returns true, the plugin stops loading. In this example, if the current page ID is not 1234, the plugin does not load further.
You can use this to check the current page ID or whatever condition you want.
Best,
Ernest M.
-
This reply was modified 3 years, 9 months ago by wpdreams. Reason: fixed code
Sorry,
doesn’t work…
All JS and CSS files of your plugin are loaded in every page of my site 🙁
Maybe a different variation, but the previous should work as well.
add_filter('asl_stop_loading', 'asl_stop_loading_on_pages', 10, 1);
function asl_stop_loading_on_pages($return) {
// Page IDs where the plugin should be loaded
$pages_to_load_on = array(1, 2, 3);
// -- Don't change anything below this --
$url = home_url(add_query_arg(array()));
$current_page = url_to_postid($url);
if ( wp_doing_ajax() || $current_page === false ) {
return false;
} else {
return !in_array($current_page, $pages_to_load_on);
}
}
Change the $pages_to_load_on variable to the page IDs, where the plugin assets should be loaded.
Make sure to clear the site cache as well, otherwise it may have no effect whatsoever.
Best,
Ernest M.
Thanks a lot.
Now it’s ok! 🙂
I had to add a “is_admin()” at line 9, elsewhere no plugin options/settings appears in administrative backend:
if ( wp_doing_ajax() || $current_page === false || is_admin()) {
Thank you for the feedback 🙂
I would have the intention to buy the PRO version …
Do these changes also work on the PRO version of your plugin?
Moderator
Yui
(@fierevere)
永子
Please ask all PRO related questions using plugin vendor contacts directly.
This includes:
* Pre-sale questions
* PRO support
* Refunds
closing thread.