diff --git a/README.md b/README.md index ae2d1a6..38bf1ce 100755 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ #### Plugins from ClassicPress Directory now can be installed using the "Install CP Plugins" menu under "Plugins" menu. -#### Themes from ClassicPress Directory now can be installed using the "CP Themes" menu under "Appearance" menu. +#### Themes from ClassicPress Directory now can be installed using the "Install CP Themes" menu under "Appearance" menu. ## WP-CLI commands diff --git a/classes/PluginInstall.class.php b/classes/PluginInstall.class.php index 03ab988..eb6f290 100644 --- a/classes/PluginInstall.class.php +++ b/classes/PluginInstall.class.php @@ -15,10 +15,15 @@ class PluginInstall public function __construct() { // Add menu under plugins. - add_action('admin_menu', [$this, 'create_menu'], 100); + if (is_multisite()) { + add_action('network_admin_menu', [$this, 'create_menu'], 100); + add_action('network_admin_menu', [$this, 'rename_menu']); + } else { + add_action('admin_menu', [$this, 'create_menu'], 100); + add_action('admin_menu', [$this, 'rename_menu']); + } add_action('admin_enqueue_scripts', [$this, 'styles']); add_action('admin_enqueue_scripts', [$this, 'scripts']); - add_action('admin_menu', [$this, 'rename_menu']); } public function styles($hook) diff --git a/classes/ThemeInstall.class.php b/classes/ThemeInstall.class.php index e3dd6e2..9352130 100644 --- a/classes/ThemeInstall.class.php +++ b/classes/ThemeInstall.class.php @@ -15,8 +15,13 @@ class ThemeInstall public function __construct() { - // Add menu under Appearance. - add_action('admin_menu', [$this, 'create_menu'], 100); + // Add Menu Items. + if (is_multisite()) { + add_action('network_admin_menu', [$this, 'create_menu'], 100); + add_action('network_admin_menu', [$this, 'rename_menu']); + } else { + add_action('admin_menu', [$this, 'create_menu'], 100); + } add_action('admin_enqueue_scripts', [$this, 'styles']); add_action('admin_enqueue_scripts', [$this, 'scripts']); } @@ -47,7 +52,7 @@ public function create_menu() $this->page = add_submenu_page( 'themes.php', esc_html__('ClassicPress Themes', 'classicpress-directory-integration'), - esc_html__('CP Themes', 'classicpress-directory-integration'), + esc_html__('Install CP Themes', 'classicpress-directory-integration'), 'install_themes', 'classicpress-directory-integration-theme-install', [$this, 'render_menu'], @@ -58,6 +63,16 @@ public function create_menu() add_action('load-' . $this->page, [$this, 'install_action']); } + public function rename_menu() { + global $submenu; + foreach ( $submenu['themes.php'] as $key => $value ) { + if($value[2] !== 'theme-install.php') { + continue; + } + $submenu['themes.php'][$key][0] = esc_html__('Install WP Themes', 'classicpress-directory-integration'); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited + } + } + // Get all installed ClassicPress Themes // This function is different from the one in ThemeUpdate class // and considers a theme from the dir not only if it has UpdateURI diff --git a/classicpress-directory-integration.php b/classicpress-directory-integration.php index 04ed6b0..6ccc969 100755 --- a/classicpress-directory-integration.php +++ b/classicpress-directory-integration.php @@ -4,7 +4,7 @@ * ----------------------------------------------------------------------------- * Plugin Name: ClassicPress Directory Integration * Description: Install and update plugins from ClassicPress directory and keep ClassicPress themes updated. - * Version: 0.3.1 + * Version: 0.3.2 * Author: ClassicPress Contributors * Author URI: https://www.classicpress.net * Plugin URI: https://www.classicpress.net