PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.5.1
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.5.1
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / admin / menu / class-submenu-capability-normalize.php

class-submenu-capability-normalize.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.5.1, at admin/menu/class-submenu-capability-normalize.php

42 lines 1016 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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