I have my local WordPress setup I create folder named mu-plugins in wp-content/plugins/mu-plugins and in mu-plugins directory I create one file and write a simple code for test my mu-plugins not work it give no response. Any One know what shouuld ? (it work fine in live hosting setup)
I am writing a plugin that needs to disable another plugin on specific pages of the site. I know how to do this using the option_active_plugins filter, but that filter only works from an MU plugin. So is it possible to programatically install a MU plugin from my main plugin so that I can run this filter? Or is there another way to tackle this?
I have successfully translated a child theme, but not the same result in mu-plugins folder. The name of the plugin is "mu-functions.php". In this file I have added the "Text Domain: mu-functions" in the header and then I have loaded the textdomain: add_action( 'plugins_loaded', 'myplugin_muload_textdomain' ); function myplugin_muload_textdomain() { load_muplugin_textdomain( 'mu-functions', basename( dirname(__FILE__) ) . '/inc/languages' ); } The structure of the plugin that I have created in the mu-plugins directory is the following: In the same directory I have …
I want to disable specific plugins on specific frontpages, but not "disable" them in the backend, i.e. really disable them in the DB. Just NOT load them, as if they weren't installed. Did this via mu-plugin very early in the code: function strposa($haystack, $needles=array(), $offset=0) { // Like strpos for an Array of needles foreach($needles as $needle) { if(strpos($haystack, $needle, $offset) !== false) return true; } return false; } add_filter('option_active_plugins', function ($plugins) { if(!wp_doing_ajax() && !wp_doing_cron() && !is_admin()) { $remove_plugins_frontpage …
So I've been messing with this for a while now and I don't understand how I'm unable to pull in my style file properly by registering and calling it at all. Here is my method: public static function register_styles() { add_action('wp_enqueue_scripts', function() { global $post; if (is_page('foodies')) { var_dump('Hello!'); //Adding stylesheets wp_register_style('profile-style', '/Users/smajlovs/Sites/newsacfoodies/htdocs/wp-content/mu-plugins/sacfoodies/styles/style.css'); //Enqueue the style wp_enqueue_style('profile-style', '/Users/smajlovs/Sites/newsacfoodies/htdocs/wp-content/mu-plugins/sacfoodies/styles/style.css'); } if ($post->post_type == 'profile') { echo 'Hello! I am the register_styles method on the profile custom post type page'; } return; …
This is what I've done in my custom functions mu-plugin: function jsdisabled() { print '<noscript> <div style="margin:auto; display:table; text-align:center"> <div style="margin:auto; display:table; width:70%"> <h1>Title</h1> <h2>Some text. </h2> <p> <img src="/noscriptimage.jpg"/> </p> </div> </div> </noscript>'; } add_action('wp_head', 'jsdisabled', 0); This code adds noscript tags to wordpress header, but when I test the page with browser javascript disabled, what happens is that the noscript message and image will show, but the entire page content will show too, in other words, noscript is …
I can't manage to load the text domain of my plugins and it's slowly but surely driving me nuts; especially cuz all the error feedback I get is: false. What I've tried so far (adding the following code in my main plugin file): According to some forum answers: add_action( 'init', function() { load_muplugin_textdomain( 'my-mu-plugin', 'my-mu-plugin/languages' ); } ); This results in an error when a page is loaded in the default language (load_muplugin_textdomain() returns false), and fails to localize dynamic …
I'm getting a Notice: Uninitialized string offset: 0 This is a mu-plugin that is supposed to show social sharing buttons and the only problem is happening with pinterest. Since it's not connected to my own database, I don't know why it's returning that error. My full code: <?php // Source: https://wpvkp.com/add-social-media-sharing-buttons-to-wordpress-without-plugin/ // Function to handle the thumbnail request function get_the_post_thumbnail_src($img) { return (preg_match('~\bsrc="([^"]++)"~', $img, $matches)) ? $matches[1] : ''; } function wpvkp_social_buttons($content) { //global $wp; $current_url = home_url(add_query_arg(array() //, $wp->request …
A while back, I had someone here help me craft a custom mu-plugin (aka: "must use" plugin) that was designed to specially handle 404 server responses. Here is that thread for context, complete with the specific code I'm referencing: Question about repurposing WordPress 404 handler I'm just now revisiting this project and trying to resume development on it, but am running in to some issues with using the "get_template_part" method within the mu-plugin file .. trying to pull in specific …
I've looked at other posts regarding mu-plugins but I don't understand yet. Here's the situation: My site is hosted by a service that automatically sets up 2 caching plugins. Cloudflare and OP Cache. They were originally installed in the mu-plugins folder. I'm not sure what happened, as there are multiple people working on this site, but they all disappeared. I reinstalled them but can't activate them. I got the error Fatal error: Cannot redeclare class OPcache_dashboard in oursite/www/wp-content/plugins/opcache/opcache.php on line …
I don't understand wordpress, why is this wp_get_environment_type function undefined? Isn't this a "native" wordpress function? How can I make it defined? Here is my code inside of a MU-Plugin file: add_action('admin_init', function() { $environment = wp_get_environment_type(); //...
Do I need some extra WP-CLI bundle to activate mu-plugins via command line? I can't find anything about that in the docs. Are mu-plugins treated differently by WP-CLI? I created /wp-content/mu-plugins/my-plugin.php containing: <?php /* Plugin Name: My Plugin Description: Provide must-use code. Version: 1.0 */ When I do: $ wp plugin list I get: +---------------+----------+--------+---------+ | name | status | update | version | +---------------+----------+--------+---------+ | akismet | inactive | none | 4.0.8 | | hello | active | none …
I'm trying to load plugins automatically by putting the plugins into mu-plugins folder. But if the plugin is put in a folder, it isn't loaded. I tried some popular plugins such as W3 Total Cache, WordPress SEO By Yoast, but all of them are not loaded. Does WordPress only loads plugins which are just single files in mu-plugins?
I'm going through a tutorial which says that creating new post_types is best handled by creating a new mu-plugin (as opposed to adding it to the functions.php). I understand why, but what I don't understand is how to include this mu-plugin as a dependency of my theme. I want to be able to have my friend upload my theme and have it work right away, without having to tell them to copy the mu-plugin file into their WordPress mu-plugins folder.
So this is how I have my structure setup to attempt to create a mu-plugin for my page. Here is what I'm using: - Genesis Framework - Genesis FrameWork Child Theme Please let me know if the mu-plugins directory should be there or moved inside the child theme, also to create just a simple mu plugin that echos 'Hello', where would I begin? Learning as I'm doing this. Here is my current structure:
I have a class setup to run some database scripts on my mu-plugin. function activate_mjmc_core() { require_once plugin_dir_path( __FILE__ ) . 'includes/class-mjmc-core-activator.php'; Mjmc_Core_Activator::activate(); Mjmc_Core_Activator::mjmc_database_version(); Mjmc_Core_Activator::mjmc_companies_table(); Mjmc_Core_Activator::mjmc_locations_table(); Mjmc_Core_Activator::mjmc_companies_insert(); } register_activation_hook( __FILE__, 'activate_mjmc_core' ); Now these work just fine when i use this as a normal plugin where i have to activate it. But when i use this in my mu-plugins, all the other plugin functions work, it just doenst run the database functions listed above on activate. Is there something else …
I have a must use plugin that uses register_theme_directory() but no matter what path I pass in, it always returns false. For some background I am using domain based database switching in the wp-config to manage multiple distinct sites with one install, (i am not using a network install because each site needs it own unique users database). I have some themes I want to only be available to one specific site, so I put it in a special directory …
I think i'm probably doing something daft here. Every time i try to include this as a mu-plugin it takes down the test site though. <?php if( is_plugin_active( '/public_html/wp-content/plugins/wordfence.php' ) ) { require_once('wp-load.php'); $to = ‘[email protected]’; $subject = ‘Wordfence is down’; $message = ‘Wordfence is not active’; $headers = array('Content-Type: text/html; charset=UTF-8'); wp_mail( $to, $subject, $message, $headers ); } Any ideas where i'm going wrong would be very much appreciated :)
I am creating a custom MU plugin to run on a multi-site network. I am working on a function that will dynamically include files containing additional action and filter hooks based on the active plugins for the current website being processed. The problem is, my function is not called when I visit a child site. Only the main site fires this event. How can I get it to execute the function regardless of the site I am on? function my_plugin_autoload_plugin_hooks() …
I've searched through WordPress Development and couldn't find the answer, so I either didn't search very well or I couldn't figure out the actual term I needed to search for... I am trying to create a simple mu-plugin to remove update notices, nags and other random notifications created by many of the plugins I use across a lot of sites for clients. The plugin removes the notices for all except a single user. The code below works, but I know …