-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace mu-plugin with a format consistent with pantheon-systems/pant…
…heon-mu-plugin This update aligns the Pantheon mu-plugin format to our standalone repository (https://github.com/pantheon-systems/pantheon-mu-plugin), and will allow for the mu-plugin to receive updates from that repo whenever an updated version of WordPress is released. For more information, see https://pantheon.io/docs/start-states/wordpress#2022-11-01
- Loading branch information
1 parent
842aca1
commit bf18d9e
Showing
12 changed files
with
103 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Pantheon MU Plugin Loader | ||
* Description: Loads the MU plugins required to run the site | ||
* Author: Pantheon Systems | ||
* Author URI: https://pantheon.io | ||
* Version: 1.0 | ||
*/ | ||
|
||
if ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) { | ||
return; | ||
} | ||
|
||
// Add mu-plugins here. | ||
$pantheon_mu_plugins = [ | ||
'pantheon-mu-plugin/pantheon.php', | ||
]; | ||
|
||
foreach ( $pantheon_mu_plugins as $file ) { | ||
require_once WPMU_PLUGIN_DIR . '/' . $file; | ||
} | ||
unset( $file ); | ||
|
||
add_action( 'pre_current_active_plugins', function () use ( $pantheon_mu_plugins ) { | ||
global $plugins, $wp_list_table; | ||
|
||
// Add our own mu-plugins to the page. | ||
foreach ( $pantheon_mu_plugins as $plugin_file ) { | ||
// Do not apply markup/translate as it'll be cached. | ||
$plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); | ||
|
||
if ( empty( $plugin_data['Name'] ) ) { | ||
$plugin_data['Name'] = $plugin_file; | ||
} | ||
|
||
$plugins['mustuse'][ $plugin_file ] = $plugin_data; | ||
} | ||
|
||
// Recount totals. | ||
$GLOBALS['totals']['mustuse'] = count( $plugins['mustuse'] ); | ||
|
||
// Only apply the rest if we're actually looking at the page. | ||
if ( $GLOBALS['status'] !== 'mustuse' ) { | ||
return; | ||
} | ||
|
||
// Reset the list table's data. | ||
$wp_list_table->items = $plugins['mustuse']; | ||
foreach ( $wp_list_table->items as $plugin_file => $plugin_data ) { | ||
$wp_list_table->items[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true ); | ||
} | ||
|
||
$total_this_page = $GLOBALS['totals']['mustuse']; | ||
|
||
if ( $GLOBALS['orderby'] ) { | ||
uasort( $wp_list_table->items, [ $wp_list_table, '_order_callback' ] ); | ||
} | ||
|
||
// Force showing all plugins. | ||
// See https://core.trac.wordpress.org/ticket/27110. | ||
$plugins_per_page = $total_this_page; | ||
|
||
$wp_list_table->set_pagination_args( [ | ||
'total_items' => $total_this_page, | ||
'per_page' => $plugins_per_page, | ||
] ); | ||
}); | ||
|
||
add_filter( 'network_admin_plugin_action_links', function ( $actions, $plugin_file, $plugin_data, $context ) use ( $pantheon_mu_plugins ) { | ||
if ( $context !== 'mustuse' || ! in_array( $plugin_file, $hm_mu_plugins, true ) ) { | ||
return $actions; | ||
} | ||
|
||
$actions[] = sprintf( '<span style="color:#333">File: <code>%s</code></span>', $plugin_file ); | ||
return $actions; | ||
}, 10, 4 ); |
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.