| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Admin\Menu |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Normalize submenu capabilities to `wpseo_manage_options`. |
| 10 |
*/ |
| 11 |
class WPSEO_Submenu_Capability_Normalize implements WPSEO_WordPress_Integration { |
| 12 |
|
| 13 |
/** |
| 14 |
* Registers all hooks to WordPress. |
| 15 |
* |
| 16 |
* @return void |
| 17 |
*/ |
| 18 |
public function register_hooks() { |
| 19 |
add_filter( 'wpseo_submenu_pages', [ $this, 'normalize_submenus_capability' ] ); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Normalizes any `manage_options` to `wpseo_manage_options`. |
| 24 |
* |
| 25 |
* This is needed as the module plugins are not updated with the new capabilities directly, |
| 26 |
* but they should not be shown as main menu items. |
| 27 |
* |
| 28 |
* @param array $submenu_pages List of subpages to convert. |
| 29 |
* |
| 30 |
* @return array Converted subpages. |
| 31 |
*/ |
| 32 |
public function normalize_submenus_capability( $submenu_pages ) { |
| 33 |
foreach ( $submenu_pages as $index => $submenu_page ) { |
| 34 |
if ( $submenu_page[3] === 'manage_options' ) { |
| 35 |
$submenu_pages[ $index ][3] = 'wpseo_manage_options'; |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
return $submenu_pages; |
| 40 |
} |
| 41 |
} |
| 42 |
|