register_activation_hook in mu-plugin not triggering

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 … Read more

How to use a Must-Use plugin to hide a regular one and to hide itself?

When solving this issue ( Change admin language based on user (in single-site) ), I did a function so that the plugin would auto-hide from all users except one (me:). The flaw is that it only auto-hides when active. At first, it was a mu-plugin, but I had to enable/disable it manually. It really doesn’t … Read more

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__) ) . … Read more

Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php?

Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php? I have a mu-functions.php file in the mu-plugins folder. One function calls a javascript file (alerts.js) located in example.com/wp-content/mu-plugins/js/. How can I target the mu-plugins folder in my function? Currently, I am using get_site_url() . ‘/wp-content/mu-plugins/js/alerts.js’, Although not completely relevant to the … Read more

Namespacing WordPress project according to FIG standards

I am trying to wrap my head around the namespaces, autoloaders and FIG standards and most importantly how to achieve their integration to WordPress as close as possible. Here is my file structure, created with help of awesome roots/bedrock WordPress stack. |– /web | |– /app | | |– /mu-plugins | | | |– autoload.php … Read more

Must-use plugins autoloader: How to use get_plugins() correctly?

My autoloader class is responsible for loading must-use plugins that do not sit in the root of the mu-plugins folder. To locate them, I need to use the get_plugins() function. According to Codex, the function accepts one parameter: $plugin_folder (string) (optional): Relative path to single plugin folder. My file hierarchy looks like this: |– /mu-plugins … Read more

How do I activate an mu-plugin with WP-CLI?

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: +—————+———-+——–+———+ … Read more