From 3ddcd4ce8e52e993aa74e11f97980046c5e74a31 Mon Sep 17 00:00:00 2001 From: reygcalantaol Date: Sun, 26 Jun 2022 08:22:28 +0800 Subject: [PATCH 1/2] #251 - Add Licenses button to the settings top nav Resolves #251 @polevaultweb --- includes/wpum-admin/class-wpum-options-panel.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/includes/wpum-admin/class-wpum-options-panel.php b/includes/wpum-admin/class-wpum-options-panel.php index 5aef21f9..75e95401 100644 --- a/includes/wpum-admin/class-wpum-options-panel.php +++ b/includes/wpum-admin/class-wpum-options-panel.php @@ -68,6 +68,13 @@ private function register_action_buttons() { 'url' => 'https://docs.wpusermanager.com/?utm_source=WP%20User%20Manager&utm_medium=insideplugin&utm_campaign=WP%20User%20Manager&utm_content=settings-header', ) ); + + $this->panel->add_action_button( + array( + 'title' => __( 'Licenses', 'wp-user-manager' ), + 'url' => admin_url( 'options-general.php?page=wpum-licenses' ), + ) + ); } /** From b76941fe1537c06089c86cab9711ce5257a25105 Mon Sep 17 00:00:00 2001 From: Rey C Date: Sat, 22 Nov 2025 13:07:00 +0800 Subject: [PATCH 2/2] Show Licenses button only when an addon is installed --- .../wpum-admin/class-wpum-options-panel.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/includes/wpum-admin/class-wpum-options-panel.php b/includes/wpum-admin/class-wpum-options-panel.php index 75e95401..de4822f1 100644 --- a/includes/wpum-admin/class-wpum-options-panel.php +++ b/includes/wpum-admin/class-wpum-options-panel.php @@ -37,8 +37,8 @@ public function init() { // Add a logo to the options panel. $this->panel->add_image( WPUM_PLUGIN_URL . 'assets/images/logo.svg' ); - // Register action buttons for the header. - $this->register_action_buttons(); + // Register action buttons for the header on admin init to wait for the addons to load. + add_action( 'admin_init', array( $this, 'register_action_buttons' ) ); // Setup the options panel menu. add_filter( 'wpum_menu', [ $this, 'setup_menu' ] ); @@ -54,7 +54,7 @@ public function init() { /** * Register action buttons for the options panel. */ - private function register_action_buttons() { + public function register_action_buttons() { $this->panel->add_action_button( array( 'title' => __( 'View Addons', 'wp-user-manager' ), @@ -69,12 +69,15 @@ private function register_action_buttons() { ) ); - $this->panel->add_action_button( - array( - 'title' => __( 'Licenses', 'wp-user-manager' ), - 'url' => admin_url( 'options-general.php?page=wpum-licenses' ), - ) - ); + // Check for the extension activation class; if present, one of the WPUM addon is installed. + if ( class_exists( 'WPUM_Extension_Activation' ) ) { + $this->panel->add_action_button( + array( + 'title' => __( 'Licenses', 'wp-user-manager' ), + 'url' => admin_url( 'options-general.php?page=wpum-licenses' ), + ) + ); + } } /**