mu-plugins aren’t loading

The reason plugins in the mu-plugins folder can’t be activated in the plugins page is because that’s not how mu-plugins works. The mu stands for must use. Improtant things to know: mu-plugins load before plugins WP loads PHP files in the mu-plugins folder it does not search subfolders it does not look for plugin headers … Read more

Hide mu-plugins list

The solution to this request is filtering show_advanced_plugins. This filter is called twice, once for mustuse– and once for dropins-plugins. The filter accepts two parameters, the first one being the standard value (true), and the second one being the type of the advanced plugin (Must-Use and Drop-In). So returning false does the trick, if your … Read more

How to send user data in json format to another server when user register on wordpress site in PHP

Sending and receiving data in JSON format using POST method xhr = new XMLHttpRequest(); var url = “url”; xhr.open(“POST”, url, true); xhr.setRequestHeader(“Content-type”, “application/json”); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { var json = JSON.parse(xhr.responseText); console.log(json.email + “, ” + json.password) } } var data = JSON.stringify({“email”:”[email protected]”,”password”:”101010″}); xhr.send(data); Sending … Read more

wp_get_environment_type is undefined

It is a core WP function, but only after WordPress version 5.5.0. If you’re using an older version of WordPress, it won’t exist yet. Do this: add_action(‘admin_init’, function() { if ( ! function_exists( ‘wp_get_environment_type’ ) ) { return; } $environment = wp_get_environment_type(); //… Or, better still, make sure your WordPress installation is up to date.

POEdit with Custom mu-plugins code

I’m not 100% sure this is the only issue that was preventing POEdit from correctly parsing my code (I’m not sure it actually cares about the WordPress side of things), but fixing these (stupid) errors and re-running POEdit from the .pot file below seems to have generated the correct translation strings: define( ‘MY_TEXTDOMAIN’, ‘MY_TEXTDOMAIN’ ); … Read more

register_activation_hook in mu-plugin not triggering

MU plugins don’t ‘activate’, or ‘deactivate’. They’re just present or not present. So you’ll need a different approach. One option would be to just perform your activation functions on init, and store a record in the database to say whether or not it’s already been done: function activate_mjmc_core() { if ( ‘1’ === get_option( ‘mjmc_activated’ … Read more

Translation of plugin in MU-PLUGINS directory not working

You need to use another action when in a mu-plugins. add_action(‘muplugins_loaded’, ‘myplugin_muload_textdomain’); plugins_loaded action work only after active plugins and pluggable functions are loaded. mu-plugins are not regular plugins and will not be loaded like them. As you can see in the following link, mu-plugins are loaded before anything else. Actions Run During a Typical … Read more