Skip to content

Instantly share code, notes, and snippets.

@idokd
Last active July 12, 2021 13:09
Show Gist options
  • Select an option

  • Save idokd/224dec722a22b664c59e8d6ec221d997 to your computer and use it in GitHub Desktop.

Select an option

Save idokd/224dec722a22b664c59e8d6ec221d997 to your computer and use it in GitHub Desktop.
WordPress Initialization MU-Plugin (Must Use Plugin)
<?php
/**
* Plugin Name: Initialization Plugin
* Plugin URI: https://gist.github.com/idokd/224dec722a22b664c59e8d6ec221d997
* Description: Plugin to hook and define necessary functions before other all other plugins
* Version: 1.0.0
* Author: Ido Kobelkowsky
* Author URI: https://github.com/idokd
*/
$thememuplugins = get_stylesheet_directory() . '/mu-plugins.php';
if ( file_exists( $thememuplugins ) ) require_once( $thememuplugins );
@idokd

idokd commented Jul 12, 2021

Copy link
Copy Markdown
Author

This is intended to when you require to override specific functions before all other plugins, and you wish to have those functions inside your theme folder so for example

you create a PHP file: /wp-content/themes/{{your-theme}}/mu-plugins.php

and inside you can override specific functions

<?php
function overriding_some_function() {
    // your code here
}

this is when plugins use function_exists() before declaring the function, so they basically allows overriding those functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment