| 1 |
<?php |
| 2 |
/** |
| 3 |
* Bootstraps the Content Guidelines page in wp-admin under Settings. |
| 4 |
* |
| 5 |
* @package gutenberg |
| 6 |
*/ |
| 7 |
|
| 8 |
add_action( 'admin_menu', 'gutenberg_register_content_guidelines_settings_submenu', 10 ); |
| 9 |
add_action( 'admin_enqueue_scripts', 'gutenberg_content_guidelines_enqueue_block_registry_scripts', 5 ); |
| 10 |
|
| 11 |
/** |
| 12 |
* Registers the Content Guidelines submenu item under Settings. |
| 13 |
* Uses the same layout/style as the Font Library admin page (wp-admin integrated). |
| 14 |
*/ |
| 15 |
function gutenberg_register_content_guidelines_settings_submenu() { |
| 16 |
add_submenu_page( |
| 17 |
'options-general.php', |
| 18 |
__( 'Guidelines', 'gutenberg' ), |
| 19 |
__( 'Guidelines', 'gutenberg' ), |
| 20 |
'manage_options', |
| 21 |
'guidelines-wp-admin', |
| 22 |
'gutenberg_guidelines_wp_admin_render_page' |
| 23 |
); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Enqueues wp-block-library on the Content Guidelines admin page so |
| 28 |
* registerCoreBlocks() is available when the app bootstraps the block |
| 29 |
* registry (Core blocks only) on the client. |
| 30 |
* |
| 31 |
* Priority 5 ensures this runs before the main asset enqueue (priority 10). |
| 32 |
*/ |
| 33 |
function gutenberg_content_guidelines_enqueue_block_registry_scripts( $hook_suffix ) { |
| 34 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 35 |
return; |
| 36 |
} |
| 37 |
|
| 38 |
if ( 'settings_page_guidelines-wp-admin' !== $hook_suffix ) { |
| 39 |
return; |
| 40 |
} |
| 41 |
|
| 42 |
wp_enqueue_script( 'wp-block-library' ); |
| 43 |
} |
| 44 |
|