Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notice for version compatibility. #2450

Merged
merged 4 commits into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions includes/Admin/Notices/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ private function init_hooks() {
add_filter( 'dokan_admin_notices', [ $this, 'show_permalink_setting_notice' ] );
add_filter( 'dokan_admin_notices', [ $this, 'show_admin_logo_update_notice' ] );
add_action( 'wp_ajax_dismiss_dokan_admin_logo_update_notice', [ $this, 'dismiss_dokan_admin_logo_update_notice' ] );
add_filter( 'dokan_admin_notices', [ $this, 'show_admin_plugin_update_notice' ] );
}

/**
Expand Down Expand Up @@ -189,4 +190,39 @@ private function dismiss_notice( string $option_name ) {
update_option( $option_name, 'yes' );
wp_send_json_success();
}

/**
* Show admin notice if dokan lite is updated to v3.14.0 and dokan pro is not updated to minimum v3.14.0.
*
* @since DOKAN_SINCE
*
* @param $notices
*
* @return mixed
*/
Comment on lines +194 to +202
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Update PHPDoc block with proper version and types

The PHPDoc block needs improvements:

  1. Replace DOKAN_SINCE with actual version number
  2. Add proper parameter and return type documentation
     /**
      * Show admin notice if dokan lite is updated to v3.14.0 and dokan pro is not updated to minimum v3.14.0.
      *
-     * @since DOKAN_SINCE
+     * @since 3.14.0
      *
-     * @param $notices
+     * @param array $notices Array of admin notices
      *
-     * @return mixed
+     * @return array Modified array of admin notices
      */
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Show admin notice if dokan lite is updated to v3.14.0 and dokan pro is not updated to minimum v3.14.0.
*
* @since DOKAN_SINCE
*
* @param $notices
*
* @return mixed
*/
/**
* Show admin notice if dokan lite is updated to v3.14.0 and dokan pro is not updated to minimum v3.14.0.
*
* @since 3.14.0
*
* @param array $notices Array of admin notices
*
* @return array Modified array of admin notices
*/

public function show_admin_plugin_update_notice( $notices ) {
if (
version_compare( DOKAN_PLUGIN_VERSION, '3.14.0', '>=' ) &&
defined( 'DOKAN_PRO_PLUGIN_VERSION' ) &&
version_compare( DOKAN_PRO_PLUGIN_VERSION, '3.14.0', '<' )
) {
$notices[] = [
'priority' => 1,
'show_close_button' => false,
'type' => 'alert',
'scope' => 'global',
'title' => __( 'Dokan Update Required', 'dokan-lite' ),
'description' => __( 'To ensure all the feature compatibility and accessibility, Dokan Pro minimum v3.14.0 is required.', 'dokan-lite' ),
'actions' => [
[
'type' => 'primary',
'text' => __( 'Update Now', 'dokan-lite' ),
'action' => admin_url( 'plugins.php' ),
],
],
];
}

return $notices;
}
}
Loading