| 1 |
<?php |
| 2 |
/** |
| 3 |
* WordPress 6.6 compatibility functions. |
| 4 |
* |
| 5 |
* @package gutenberg |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Change the Patterns submenu link and remove the Template Parts submenu for |
| 10 |
* the Classic theme. This function should not be backported to core, and should be |
| 11 |
* removed when the required WP core version for Gutenberg is >= 6.6.0. |
| 12 |
* |
| 13 |
* @global array $submenu |
| 14 |
*/ |
| 15 |
function gutenberg_change_patterns_link_and_remove_template_parts_submenu_item() { |
| 16 |
if ( ! wp_is_block_theme() ) { |
| 17 |
global $submenu; |
| 18 |
|
| 19 |
if ( empty( $submenu['themes.php'] ) ) { |
| 20 |
return; |
| 21 |
} |
| 22 |
|
| 23 |
foreach ( $submenu['themes.php'] as $key => $item ) { |
| 24 |
if ( 'edit.php?post_type=wp_block' === $item[2] ) { |
| 25 |
$submenu['themes.php'][ $key ][2] = 'site-editor.php?path=/patterns'; |
| 26 |
} elseif ( 'site-editor.php?path=/wp_template_part/all' === $item[2] ) { |
| 27 |
unset( $submenu['themes.php'][ $key ] ); |
| 28 |
} |
| 29 |
} |
| 30 |
} |
| 31 |
} |
| 32 |
add_action( 'admin_init', 'gutenberg_change_patterns_link_and_remove_template_parts_submenu_item' ); |
| 33 |
|