Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
CRAP | n/a |
0 / 0 |
|
| remove_fse_plugin | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * This is a feature to remove FSE plugin since it has been sunset for a while. |
| 4 | * |
| 5 | * @package automattic/jetpack-mu-wpcom |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Remove FSE plugin from the active_plugins list if the file doesn't exist. |
| 10 | * |
| 11 | * @param array<string> $plugins The list of the active plugins. |
| 12 | * @return array<string> The filtered active plugins. |
| 13 | */ |
| 14 | function remove_fse_plugin( $plugins ) { |
| 15 | if ( ! is_array( $plugins ) ) { |
| 16 | return $plugins; |
| 17 | } |
| 18 | |
| 19 | $fse_plugin = 'full-site-editing/full-site-editing-plugin.php'; |
| 20 | $fse_plugin_path = WP_PLUGIN_DIR . '/' . $fse_plugin; |
| 21 | |
| 22 | // Do nothing since the plugin file exists. |
| 23 | if ( file_exists( $fse_plugin_path ) && is_file( $fse_plugin_path ) ) { |
| 24 | return $plugins; |
| 25 | } |
| 26 | |
| 27 | // Remove the plugin from the list of active plugins as the file doesn't exist. |
| 28 | $fse_plugin_key = array_search( $fse_plugin, $plugins, true ); |
| 29 | if ( $fse_plugin_key !== false ) { |
| 30 | unset( $plugins[ $fse_plugin_key ] ); |
| 31 | } |
| 32 | |
| 33 | return $plugins; |
| 34 | } |
| 35 | add_filter( 'option_active_plugins', 'remove_fse_plugin' ); |