oc_inline_logo = sprintf( '%s', plugin_dir_url( __FILE__ ) . '/assets/images/one.com.black.svg', __( 'One.com', OC_VALIDATOR_DOMAIN ) ); } public function onecom_remove_menu() { remove_menu_page( 'onecom-vcache-plugin' ); remove_menu_page( 'onecom-wp-under-construction' ); remove_submenu_page( self::ONECOM_MENU_SLUG, self::ONECOM_MENU_SLUG ); } public function onecom_register_menu() { global $submenu; $plugin_menu = 'onecom-wp-plugins'; $theme_menu = 'onecom-wp-themes'; if ( is_plugin_active( 'onecom-vcache/vcaching.php' ) ) { add_submenu_page( self::ONECOM_MENU_SLUG, __( 'Performance Cache', OC_VALIDATOR_DOMAIN ), __( 'Performance Cache ', OC_VALIDATOR_DOMAIN ), 'manage_options', 'onecom-vcache-plugin', '', 2 ); } if ( is_plugin_active( 'onecom-under-construction/onecom-under-construction.php' ) ) { add_submenu_page( self::ONECOM_MENU_SLUG, __( 'Maintenance Mode', OC_VALIDATOR_DOMAIN ), __( 'Maintenance Mode', OC_VALIDATOR_DOMAIN ), 'manage_options', 'onecom-wp-under-construction', '', 2 ); } if ( $this->onecom_plugin_activated() && ( isset( $submenu[ self::ONECOM_MENU_SLUG ] ) ) ) { if ( ! ( in_array( $plugin_menu, wp_list_pluck( $submenu[ self::ONECOM_MENU_SLUG ], 2 ) ) || in_array( $theme_menu, wp_list_pluck( $submenu[ self::ONECOM_MENU_SLUG ], 2 ) ) ) ) { add_submenu_page( self::ONECOM_MENU_SLUG, __( 'Themes', OC_PLUGIN_DOMAIN ), '' . __( 'Themes', OC_PLUGIN_DOMAIN ) . '', 'manage_options', 'onecom-wp-themes', '', 14 ); add_submenu_page( self::ONECOM_MENU_SLUG, __( 'Plugins', OC_PLUGIN_DOMAIN ), '' . __( 'Plugins', OC_PLUGIN_DOMAIN ) . '', 'manage_options', 'onecom-wp-plugins', '', 15 ); } } if ( ! is_network_admin() && is_multisite() ) { return false; } if ( ! ( $this->onecom_plugin_activated() ) ) { $position = $this->onecom_get_free_menu_position( '2.1' ); add_menu_page( $page_title = __( 'One.com', OC_VALIDATOR_DOMAIN ), $menu_title = 'one.com', $capability = 'manage_options', $menu_slug = self::ONECOM_MENU_SLUG, $function = '', $icon_url = 'dashicons-admin-generic', $position ); } } public function add_onecom_branding_css() { echo ""; } public function onecom_plugin_activated(): bool { return ( is_plugin_active( 'onecom-themes-plugins/onecom-themes-plugins.php' ) ); } public function onecom_get_free_menu_position( $start, $increment = 0.3 ) { foreach ( $GLOBALS['menu'] as $key => $menu ) { $menus_positions[] = $key; } if ( ! in_array( $start, $menus_positions ) ) { return $start; } /* the position is already reserved find the closet one */ while ( in_array( $start, $menus_positions ) ) { $start += $increment; } return (string) $start; } } }