| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Admin Menu file. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @package automattic/jetpack | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | namespace Automattic\Jetpack\Dashboard_Customizations; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Automattic\Jetpack\Redirect; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | require_once __DIR__ . '/class-base-admin-menu.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * Class Admin_Menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | class Admin_Menu extends Base_Admin_Menu { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 	 * Create the desired menu output. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 	public function reregister_menu_items() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 		// Constant is not defined until parse_request. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 		if ( ! $this->is_api_request ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 			$this->is_api_request = defined( 'REST_REQUEST' ) && REST_REQUEST; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 		/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 		 * Whether links should point to Calypso or wp-admin. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 		 * Options: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 		 * false - Calypso (Default). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 		 * true  - wp-admin. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 		$wp_admin = $this->should_link_to_wp_admin(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 		// Remove separators. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		remove_menu_page( 'separator1' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		$this->add_stats_menu(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 		$this->add_upgrades_menu(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		$this->add_posts_menu( $wp_admin ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 		$this->add_media_menu( $wp_admin ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 		$this->add_page_menu( $wp_admin ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 		$this->add_testimonials_menu( $wp_admin ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 		$this->add_portfolio_menu( $wp_admin ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 		$this->add_comments_menu( $wp_admin ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 		// Whether Themes/Customize links should point to Calypso (false) or wp-admin (true). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 		$wp_admin_themes    = $wp_admin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		$wp_admin_customize = $wp_admin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		$this->add_appearance_menu( $wp_admin_themes, $wp_admin_customize ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 		$this->add_plugins_menu( $wp_admin ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		$this->add_users_menu( $wp_admin ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		// Whether Import/Export links should point to Calypso (false) or wp-admin (true). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 		$wp_admin_import = $wp_admin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 		$wp_admin_export = $wp_admin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		$this->add_tools_menu( $wp_admin_import, $wp_admin_export ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 		$this->add_options_menu( $wp_admin ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 		$this->add_jetpack_menu(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 		$this->add_gutenberg_menus( $wp_admin ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 		// Remove Links Manager menu since its usage is discouraged. https://github.com/Automattic/wp-calypso/issues/51188. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 		// @see https://core.trac.wordpress.org/ticket/21307#comment:73. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 		if ( $this->should_disable_links_manager() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 			remove_menu_page( 'link-manager.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		ksort( $GLOBALS['menu'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 	 * Check if Links Manager is being used. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 	public function should_disable_links_manager() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 		// The max ID number of the auto-generated links. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 		// See /wp-content/mu-plugins/wpcom-wp-install-defaults.php in WP.com. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 		$max_default_id = 10; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 		$link_manager_links = get_bookmarks( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 			array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 				'orderby' => 'link_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 				'order'   => 'DESC', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 				'limit'   => $max_default_id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 		// Ordered links by ID descending, check if the first ID is more than $max_default_id. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 		if ( count( $link_manager_links ) > 0 && $link_manager_links[0]->link_id > $max_default_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 		return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 	 * Adds My Home menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 	public function add_my_home_menu() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 		$this->update_menu( 'index.php', 'https://wordpress.com/home/' . $this->domain, __( 'My Home', 'jetpack' ), 'manage_options', 'dashicons-admin-home' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 	 * Adds Stats menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 	public function add_stats_menu() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 		add_menu_page( __( 'Stats', 'jetpack' ), __( 'Stats', 'jetpack' ), 'view_stats', 'https://wordpress.com/stats/day/' . $this->domain, null, 'dashicons-chart-bar', 3 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 	 * Adds Upgrades menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 	public function add_upgrades_menu() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 		global $menu; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 		$menu_exists = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 		foreach ( $menu as $item ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 			if ( 'paid-upgrades.php' === $item[2] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 				$menu_exists = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 				break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 		if ( ! $menu_exists ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 			add_menu_page( __( 'Upgrades', 'jetpack' ), __( 'Upgrades', 'jetpack' ), 'manage_options', 'paid-upgrades.php', null, 'dashicons-cart', 4 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 		add_submenu_page( 'paid-upgrades.php', __( 'Plans', 'jetpack' ), __( 'Plans', 'jetpack' ), 'manage_options', 'https://wordpress.com/plans/' . $this->domain, null, 5 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 		add_submenu_page( 'paid-upgrades.php', __( 'Purchases', 'jetpack' ), __( 'Purchases', 'jetpack' ), 'manage_options', 'https://wordpress.com/purchases/subscriptions/' . $this->domain, null, 15 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 		if ( ! $menu_exists ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 			// Remove the submenu auto-created by Core. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 			remove_submenu_page( 'paid-upgrades.php', 'paid-upgrades.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 	 * Adds Posts menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 	 * @param bool $wp_admin Optional. Whether links should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 	public function add_posts_menu( $wp_admin = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 		if ( $wp_admin ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 		$submenus_to_update = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 			'edit.php'     => 'https://wordpress.com/posts/' . $this->domain, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 			'post-new.php' => 'https://wordpress.com/post/' . $this->domain, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 		$this->update_submenus( 'edit.php', $submenus_to_update ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 	 * Adds Media menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 	 * @param bool $wp_admin Optional. Whether links should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 160 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  | 	public function add_media_menu( $wp_admin = false ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  | 		if ( $wp_admin ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 163 |  |  | 			return; | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  | 		remove_submenu_page( 'upload.php', 'media-new.php' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 168 |  |  | 		$this->update_menu( 'upload.php', 'https://wordpress.com/media/' . $this->domain ); | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 	 * Adds Page menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 	 * @param bool $wp_admin Optional. Whether links should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 	public function add_page_menu( $wp_admin = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 		if ( $wp_admin ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 		$submenus_to_update = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 			'edit.php?post_type=page'     => 'https://wordpress.com/pages/' . $this->domain, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 			'post-new.php?post_type=page' => 'https://wordpress.com/page/' . $this->domain, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 		$this->update_submenus( 'edit.php?post_type=page', $submenus_to_update ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 	 * Adds Testimonials menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 	 * @param bool $wp_admin Optional. Whether links should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 	public function add_testimonials_menu( $wp_admin = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 		$this->add_custom_post_type_menu( 'jetpack-testimonial', $wp_admin ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 	 * Adds Portfolio menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 	 * @param bool $wp_admin Optional. Whether links should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 	public function add_portfolio_menu( $wp_admin = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 		$this->add_custom_post_type_menu( 'jetpack-portfolio', $wp_admin ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 	 * Adds a custom post type menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 	 * @param string $post_type Custom post type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 	 * @param bool   $wp_admin Optional. Whether links should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 	public function add_custom_post_type_menu( $post_type, $wp_admin = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 		if ( $wp_admin ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 		$submenus_to_update = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 			'edit.php?post_type=' . $post_type     => 'https://wordpress.com/types/' . $post_type . '/' . $this->domain, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 			'post-new.php?post_type=' . $post_type => 'https://wordpress.com/edit/' . $post_type . '/' . $this->domain, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 		$this->update_submenus( 'edit.php?post_type=' . $post_type, $submenus_to_update ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 	 * Adds Comments menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 	 * @param bool $wp_admin Optional. Whether links should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | 	public function add_comments_menu( $wp_admin = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 		if ( $wp_admin ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 		$this->update_menu( 'edit-comments.php', 'https://wordpress.com/comments/all/' . $this->domain ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 	 * Adds Appearance menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 	 * @param bool $wp_admin_themes Optional. Whether Themes link should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 	 * @param bool $wp_admin_customize Optional. Whether Customize link should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 	 * @return string The Customizer URL. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 	public function add_appearance_menu( $wp_admin_themes = false, $wp_admin_customize = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 		$request_uri                     = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 		$default_customize_slug          = add_query_arg( 'return', rawurlencode( remove_query_arg( wp_removable_query_args(), $request_uri ) ), 'customize.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 		$default_customize_header_slug_1 = add_query_arg( array( 'autofocus' => array( 'control' => 'header_image' ) ), $default_customize_slug ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 		// TODO: Remove WPCom_Theme_Customizer::modify_header_menu_links() and WPcom_Custom_Header::modify_admin_menu_links(). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 		$default_customize_header_slug_2     = admin_url( 'themes.php?page=custom-header' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 		$default_customize_background_slug_1 = add_query_arg( array( 'autofocus' => array( 'control' => 'background_image' ) ), $default_customize_slug ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 		// TODO: Remove Colors_Manager::modify_header_menu_links() and Colors_Manager_Common::modify_header_menu_links(). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 		$default_customize_background_slug_2 = add_query_arg( array( 'autofocus' => array( 'section' => 'colors_manager_tool' ) ), admin_url( 'customize.php' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 		if ( ! $wp_admin_customize ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 			$customize_url = 'https://wordpress.com/customize/' . $this->domain; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 		} elseif ( $this->is_api_request ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 			// In case this is an api request we will have to add the 'return' querystring via JS. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 			$customize_url = 'customize.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 			$customize_url = $default_customize_slug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 		$submenus_to_update = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 			$default_customize_slug              => $customize_url, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 			$default_customize_header_slug_1     => add_query_arg( array( 'autofocus' => array( 'control' => 'header_image' ) ), $customize_url ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 			$default_customize_header_slug_2     => add_query_arg( array( 'autofocus' => array( 'control' => 'header_image' ) ), $customize_url ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 			$default_customize_background_slug_1 => add_query_arg( array( 'autofocus' => array( 'section' => 'colors_manager_tool' ) ), $customize_url ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 			$default_customize_background_slug_2 => add_query_arg( array( 'autofocus' => array( 'section' => 'colors_manager_tool' ) ), $customize_url ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 		if ( ! $wp_admin_themes ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 			$submenus_to_update['themes.php'] = 'https://wordpress.com/themes/' . $this->domain; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 		if ( ! $wp_admin_customize ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 			$submenus_to_update['widgets.php']       = add_query_arg( array( 'autofocus' => array( 'panel' => 'widgets' ) ), $customize_url ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 			$submenus_to_update['gutenberg-widgets'] = add_query_arg( array( 'autofocus' => array( 'panel' => 'widgets' ) ), $customize_url ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 			$submenus_to_update['nav-menus.php']     = add_query_arg( array( 'autofocus' => array( 'panel' => 'nav_menus' ) ), $customize_url ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 		$this->update_submenus( 'themes.php', $submenus_to_update ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 		remove_submenu_page( 'themes.php', 'custom-header' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 		remove_submenu_page( 'themes.php', 'custom-background' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 		return $customize_url; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 	 * Adds Plugins menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 	 * @param bool $wp_admin Optional. Whether links should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 	public function add_plugins_menu( $wp_admin = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 		if ( $wp_admin ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 		remove_submenu_page( 'plugins.php', 'plugin-install.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 		remove_submenu_page( 'plugins.php', 'plugin-editor.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 		$this->update_menu( 'plugins.php', 'https://wordpress.com/plugins/' . $this->domain ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 	 * Adds Users menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 	 * @param bool $wp_admin Optional. Whether links should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 	public function add_users_menu( $wp_admin = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 		if ( current_user_can( 'list_users' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 			// We shall add the Calypso user management & add new user screens at all cases ( Calypso & Atomic ). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 			$submenus_to_update = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 				'user-new.php' => 'https://wordpress.com/people/new/' . $this->domain, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 				'users.php'    => 'https://wordpress.com/people/team/' . $this->domain, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 			if ( ! $wp_admin ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 				$submenus_to_update['profile.php'] = 'https://wordpress.com/me'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 			$this->update_submenus( 'users.php', $submenus_to_update ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 			add_submenu_page( 'users.php', esc_attr__( 'Account Settings', 'jetpack' ), __( 'Account Settings', 'jetpack' ), 'read', 'https://wordpress.com/me/account' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 			if ( ! $wp_admin ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 				$submenus_to_update = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 					'user-new.php' => 'https://wordpress.com/people/new/' . $this->domain, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 					'profile.php'  => 'https://wordpress.com/me', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 				$this->update_submenus( 'profile.php', $submenus_to_update ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 			add_submenu_page( 'profile.php', esc_attr__( 'Account Settings', 'jetpack' ), __( 'Account Settings', 'jetpack' ), 'read', 'https://wordpress.com/me/account' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 	 * Adds Tools menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 	 * @param bool $wp_admin_import Optional. Whether Import link should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  | 	 * @param bool $wp_admin_export Optional. Whether Export link should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 	public function add_tools_menu( $wp_admin_import = false, $wp_admin_export = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 		$submenus_to_update = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 		if ( ! $wp_admin_import ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 			$submenus_to_update['import.php'] = 'https://wordpress.com/import/' . $this->domain; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 		if ( ! $wp_admin_export ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 			$submenus_to_update['export.php'] = 'https://wordpress.com/export/' . $this->domain; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 		$this->update_submenus( 'tools.php', $submenus_to_update ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 		remove_submenu_page( 'tools.php', 'tools.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 		remove_submenu_page( 'tools.php', 'delete-blog' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 		add_submenu_page( 'tools.php', esc_attr__( 'Marketing', 'jetpack' ), __( 'Marketing', 'jetpack' ), 'publish_posts', 'https://wordpress.com/marketing/tools/' . $this->domain, null, 0 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 		add_submenu_page( 'tools.php', esc_attr__( 'Earn', 'jetpack' ), __( 'Earn', 'jetpack' ), 'manage_options', 'https://wordpress.com/earn/' . $this->domain, null, 1 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  | 	 * Adds Settings menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 	 * @param bool $wp_admin Optional. Whether links should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 	public function add_options_menu( $wp_admin = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 		if ( $wp_admin ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 		$this->update_submenus( 'options-general.php', array( 'options-general.php' => 'https://wordpress.com/settings/general/' . $this->domain ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 		remove_submenu_page( 'options-general.php', 'options-discussion.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | 		remove_submenu_page( 'options-general.php', 'options-writing.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 	 * Adds Jetpack menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 	public function add_jetpack_menu() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 		$this->add_admin_menu_separator( 50, 'manage_options' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 		// TODO: Replace with proper SVG data url. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 		$icon = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 32 32' %3E%3Cpath fill='%23a0a5aa' d='M16,0C7.2,0,0,7.2,0,16s7.2,16,16,16s16-7.2,16-16S24.8,0,16,0z'%3E%3C/path%3E%3Cpolygon fill='%23fff' points='15,19 7,19 15,3 '%3E%3C/polygon%3E%3Cpolygon fill='%23fff' points='17,29 17,13 25,13 '%3E%3C/polygon%3E%3C/svg%3E"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 		$is_menu_updated = $this->update_menu( 'jetpack', null, null, null, $icon, 51 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 		if ( ! $is_menu_updated ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 			add_menu_page( esc_attr__( 'Jetpack', 'jetpack' ), __( 'Jetpack', 'jetpack' ), 'manage_options', 'jetpack', null, $icon, 51 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 		add_submenu_page( 'jetpack', esc_attr__( 'Activity Log', 'jetpack' ), __( 'Activity Log', 'jetpack' ), 'manage_options', 'https://wordpress.com/activity-log/' . $this->domain, null, 2 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 		add_submenu_page( 'jetpack', esc_attr__( 'Backup', 'jetpack' ), __( 'Backup', 'jetpack' ), 'manage_options', 'https://wordpress.com/backup/' . $this->domain, null, 3 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | 		/* translators: Jetpack sidebar menu item. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 		add_submenu_page( 'jetpack', esc_attr__( 'Search', 'jetpack' ), __( 'Search', 'jetpack' ), 'read', 'https://wordpress.com/jetpack-search/' . $this->domain, null, 4 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 		remove_submenu_page( 'jetpack', 'stats' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 		remove_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'calypso-backups' ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 		remove_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'calypso-scanner' ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 		if ( ! $is_menu_updated ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | 			// Remove the submenu auto-created by Core. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 			remove_submenu_page( 'jetpack', 'jetpack' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 	 * Re-adds the Site Editor menu without the (beta) tag, and where we want it. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 	 * @param bool $wp_admin Optional. Whether links should point to Calypso or wp-admin. Default false (Calypso). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 	public function add_gutenberg_menus( $wp_admin = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 		// We can bail if we don't meet the conditions of the Site Editor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 		if ( ! ( function_exists( 'gutenberg_is_fse_theme' ) && gutenberg_is_fse_theme() ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 		// Core Gutenberg registers without an explicit position, and we don't want the (beta) tag. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 		remove_menu_page( 'gutenberg-edit-site' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 		// Core Gutenberg tries to manage its position, foiling our best laid plans. Unfoil. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 		remove_filter( 'menu_order', 'gutenberg_menu_order' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 		$link = $wp_admin ? 'gutenberg-edit-site' : 'https://wordpress.com/site-editor/' . $this->domain; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 		add_menu_page( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 			__( 'Site Editor', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 			__( 'Site Editor', 'jetpack' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  | 			'edit_theme_options', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 			$link, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 			$wp_admin ? 'gutenberg_edit_site_page' : null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 			'dashicons-layout', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 			61 // Just under Appearance. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 	 * Whether to use wp-admin pages rather than Calypso. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 	 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 	public function should_link_to_wp_admin() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 		return get_user_option( 'jetpack_admin_menu_link_destination' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 440 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 441 |  |  |  |