| 1 |
<?php |
| 2 |
/** |
| 3 |
* Extensible Site Editor experiment integration. |
| 4 |
* |
| 5 |
* @package gutenberg |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Redirect the Appearance > Design menu to the extensible site editor |
| 10 |
* when the experiment is enabled. |
| 11 |
* |
| 12 |
* @global array $submenu WordPress admin submenu array. |
| 13 |
*/ |
| 14 |
function gutenberg_redirect_to_extensible_site_editor() { |
| 15 |
// Only proceed if the experiment is enabled. |
| 16 |
if ( ! gutenberg_is_experiment_enabled( 'gutenberg-extensible-site-editor' ) ) { |
| 17 |
return; |
| 18 |
} |
| 19 |
|
| 20 |
// Update the Design submenu item to point to the extensible site editor. |
| 21 |
global $submenu; |
| 22 |
if ( $submenu && isset( $submenu['themes.php'] ) ) { |
| 23 |
foreach ( $submenu['themes.php'] as $key => $item ) { |
| 24 |
// Find the Design/site-editor menu item and update its URL. |
| 25 |
if ( isset( $item[2] ) && 'site-editor.php' === $item[2] ) { |
| 26 |
$submenu['themes.php'][ $key ][2] = 'admin.php?page=site-editor-v2'; |
| 27 |
break; |
| 28 |
} |
| 29 |
} |
| 30 |
} |
| 31 |
} |
| 32 |
add_action( 'admin_menu', 'gutenberg_redirect_to_extensible_site_editor', 100 ); |
| 33 |
|