Disabling drift plugin from homepage

You can see that the plugin embeds the Drift code by hooking wp_head: // Add the Drift Javascript add_action(‘wp_head’, ‘add_drift’); So all you need to do is remove_action( ‘wp_head’, ‘add_drift’ ); when you’re on the homepage, e.g. in an if (is_home()) or if (is_front_page()) block (they’re more or less equivalent here) in your theme, which … Read more

Add external javascript to post template

Add The following code (in your theme’s functions.php) will register your script, and set jQuery as a dependency. So when you enqueue it, jQuery will also be enqueued. function my_scripts_method() { // register your script location, dependencies and version wp_register_script(‘my_custom_script’, get_template_directory_uri() . ‘/js/custom_script.js’, array(‘jquery’), ‘1.0’ ); } add_action(‘wp_enqueue_scripts’, ‘my_scripts_method’); You can then enqueue your script … Read more

Conditionally load public and admin code with AJAX working on both sides

I managed to resolve this issue by also checking for public interface. I created new function isPublic() to check if it is public. So here is my final code: if ($this->isPublic()) { require_once(plugin_dir_path(dirname(__FILE__)) . ‘public/class-public.php’); $this->Public = new Public(); } elseif ($this->isAdmin()) { require_once(plugin_dir_path(dirname(__FILE__)) . ‘admin/class-admin.php’); $this->Admin = new Admin(); } and here are helper … Read more

Remove metatag from a particular page

That would be: <php if (!is_page(‘slug-of-your-page’)) echo ‘<meta name=”viewport” content=”width=device-width, initial-scale=1″ />’ ?> Beware that if you change the theme files, your changes will be lost if the theme gets updated.

Allow editor user to full permission to access plugin settings

This is a problem with the original plugin. They obviously never actually tested this filter. They have used the mc4wp_admin_required_capability to control whether the admin page is accessible, but WordPress still prevents you saving settings unless this filter is also used: https://developer.wordpress.org/reference/hooks/option_page_capability_option_page You should contact the plugin author and ask them to fix this, but … Read more