Skip to content

Commit

Permalink
Fix setup link in plugin links and notice.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Sep 5, 2024
1 parent fa5bc37 commit b44da16
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion includes/Classifai/Admin/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Classifai\Features\DescriptiveTextGenerator;
use Classifai\Features\Classification;
use function Classifai\should_use_legacy_settings_panel;

class Notifications {

Expand Down Expand Up @@ -84,6 +85,11 @@ public function render_activation_notice() {
return;
}

$setup_url = admin_url( 'tools.php?page=classifai#/classifai_setup' );
if ( should_use_legacy_settings_panel() ) {
$setup_url = admin_url( 'admin.php?page=classifai_setup' );
}

// Prevent showing the default WordPress "Plugin Activated" notice.
unset( $_GET['activate'] ); // phpcs:ignore WordPress.Security.NonceVerification
?>
Expand All @@ -96,7 +102,7 @@ public function render_activation_notice() {
<h3 class="classifai-activation-message">
<?php esc_html_e( 'Congratulations, the ClassifAI plugin is now activated.', 'classifai' ); ?>
</h3>
<a class="classifai-button" href="<?php echo esc_url( admin_url( 'admin.php?page=classifai_setup' ) ); ?>">
<a class="classifai-button" href="<?php echo esc_url( $setup_url ); ?>">
<?php esc_html_e( 'Start setup', 'classifai' ); ?>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion includes/Classifai/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function render_settings_page() {
* @param string $hook_suffix The current admin page.
*/
public function admin_enqueue_scripts( $hook_suffix ) {
if ( ! in_array( $hook_suffix, array( 'admin_page_classifai_setup', 'tools_page_classifai' ), true ) ) {
if ( ! in_array( $hook_suffix, array( 'tools_page_classifai' ), true ) ) {
return;
}

Expand Down
7 changes: 6 additions & 1 deletion includes/Classifai/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,16 @@ public function filter_plugin_action_links( $links ): array {
return $links;
}

$setup_url = admin_url( 'tools.php?page=classifai#/classifai_setup' );
if ( should_use_legacy_settings_panel() ) {
$setup_url = admin_url( 'admin.php?page=classifai_setup' );
}

return array_merge(
array(
'setup' => sprintf(
'<a href="%s"> %s </a>',
esc_url( admin_url( 'admin.php?page=classifai_setup' ) ),
esc_url( $setup_url ),
esc_html__( 'Set up', 'classifai' )
),
'settings' => sprintf(
Expand Down

0 comments on commit b44da16

Please sign in to comment.