Articles of mu plugins

Must use Plugin not updating HTML code in head

I am trying to insert code in head tag through MU Plugin. I don’t know why head tag and init is not updating by using add_action(‘wp_head’, ‘my_function’) and add_action(‘init’, ‘my_function2’). My code example as following: <?php class some_code { public function __construct() { add_action(‘init’, ‘change_url’); add_action(‘wp_head’, ‘print_header_scripts’); } function change_url() { $domain_name = $_SERVER[‘SERVER_NAME’]; $country_code […]

Are mu-plugins plugins still deployed via wordpress.org/plugins?

I’m getting ready to publish my first plugin. I’ve decided to put it in mu-plugin, because if you removed it, it would break other code dependent on it. (It’s a developer tool for logging variables to a text file.) So, do can I submit this to wp.o? Or do they only accept plugins that go […]

Certain functions are undefined when called form mu-plugins

I have a correctly formatted php functions file in my mu-plugins/ directory. When trying to use wp_is_mobile() or current_user_can(), I get an undefined function error. Fatal error: Call to undefined function wp_is_mobile() in /var/www/dev.example.com/public/wp-content/mu-plugins/multisite-functions.php on line 147 Are certain core functions defined after the mu-plugins? How do I fix or avoid this? Can I simply […]

Code Executing Too Late?

I created an mu-plugins folder with this block of code in it: if ( $_SERVER[“HTTP_HOST”] === “domain1.com” ) { $sitetype = one; } if ( $_SERVER[“HTTP_HOST”] === “domain2.com” ) { $sitetype = two; } if ( $_SERVER[“HTTP_HOST”] === “domain3.com” ) { $sitetype = three; } Basically, what I want to do is assign a $sitetype […]

No first_name or user_firstname property in WP_User object

I’m writing a basic plugin. Here’s my code: $new_user = get_userdata($user_id); $first_name1 = $new_user->user_firstname; $last_name1 = $new_user->user_lastname; echo “<” . $first_name1 . $last_name1 . “>”; //returns: <> $first_name2 = $new_user-first_name; $last_name2 = $new_user->last_name; echo “<” . $first_name2 . $last_name2 . “>”; //returns: <> According to the codex, this should work, but when I echo $first_name […]

How can woocommerce be used in mu-plugins folder?

I don’t want clients to deactivate woocommerce plugin even by mistake. And I have recently come across a concept called must use plugins in wordpress. (http://codex.wordpress.org/Must_Use_Plugins) Just want to know if there is possibility to use woocommerce as a must use plugin.

mu-plugins is there something special I need to do to make it work?

I created a mu-plugins directory in wp-content As long as it is empty, I have no issue, but the moment I put a file in there, even if the file is like this: filename: somecode.php filecontent: <?php ?> and that be all, no blank spaces or lines after the closing php tag, or after the […]

Translation of plugin in MU-PLUGINS directory not working

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__) ) . […]

How the mu-plugins Folder Works in a Multisite Installation?

I’m a little confused about when I should be placing plugin files into mu-plugins. I know it’s Must-Use plugins and I know that they are automatically enabled. In the network setting, though, does this force the plugin file to be enabled in all child blogs? Makes sense that it would, so is that the only […]

Using WP_Query within an mu-plugin

I’m trying to create a list of parent IDs for a custom post type for use within a “must use” plugin I’m developing on a project. Here’s the code I’m using to generate the query: $cpt_parents = new WP_Query( array ( ‘post_type’ => ‘cpt’, ‘posts_per_page’ => -1, // Get them all ‘post_parent’ => 0, // […]