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

Notice for users with expired licenses in the plugin section of their WP admin #5902

Closed
marija-nikolic opened this issue May 5, 2023 · 3 comments · Fixed by #5930
Closed
Assignees
Labels
effort: [M] 3-5 days of estimated development time module: user interface needs: documentation Issues which need to create or update a documentation priority: medium Issues which are important, but no one will go out of business. type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Milestone

Comments

@marija-nikolic
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
We are not displaying any notice to expired users when we have new major release when they visit the plugin section of their WP back-end.

Describe the solution you'd like
We would like to display not dismissible notice to expired users to inform them about new release and offer them to renew their license to access the latest updates.

Additional context
Text, links and all the details are listed in this doc (and in this Notion doc).
A design is provided in the Mocflow.

@piotrbak piotrbak added type: enhancement Improvements that slightly enhance existing functionality and are fast to implement priority: medium Issues which are important, but no one will go out of business. module: user interface labels May 6, 2023
@piotrbak
Copy link
Contributor

piotrbak commented May 6, 2023

Acceptance Criteria

  • When the license is expired and there's new major available (when comparing to the current customer's version), we'll display the banner in the Plugins section
  • We'll not display the banner for the minor releases
  • The banner won't be displayed for not expired users
  • The banner will show the latest major (if the customer is on 3.11, the 3.13 will be shown, not 3.12)
  • The banner will not be dismissable
  • There'll be a link to renew with specified express checkout
  • There'll be a link to the blgo post about this specifc version
  • Wording, links and additional data is present in the linked doc

@marija-nikolic Could you check if the list is complete?

@jeawhanlee jeawhanlee added GROOMING IN PROGRESS Use this label when the issue is currently being groomed. and removed needs: grooming labels May 16, 2023
@jeawhanlee
Copy link
Contributor

Scope a solution ✅

After some discussion with @engahmeds3ed

First we will create our view in Engine/Plugin/views
There we will create a new view - update-renewal-expired-notice.php where we will have the notice view in it:

<tr class="plugin-update-tr active" id="wp-rocket-update">
       <td class="plugin-update colspanchange" colspan="<?php echo esc_attr($colspan); ?>">
   	    <div class="update-message inline notice notice-error notice-alt">
                       <p>
                                 <?php
   			printf(
   				// translators: %1$s = <strong>, %2$s = </strong>.
   				esc_html__( ' %1$sWP Rocket %2$s%3$s is available. %4$sLearn more%5$s about the updates and enhancements of this major version. You need an active license to use them on your website, don’t miss out! %6$sRenew Now%7$s', 'rocket' ),
   				'<strong>',
                                         $data['version'],
   				'</strong>',
                                         '<a href="'.esc_url($data['learn_more_url']).'">',
                                         '</a>',
                                         '<a href="'.esc_url($data['renew_url']).'">',
                                         '</a>'
   			);
                       </p>
                   </div>
       </td>
   </tr>

We will create a new class Engine\Plugin::UpdaterRenewal to extend Abstract_Render
Then create 2 methods

  • Check for major version
public function is_major_version($version){
	  if (strpos($version, '.') !== false) {
	      $version = explode('.', $version);
	      
	      if (count($version) > 2) {
	          return false;
	      }
	  }
	  
	  return true;
}
  • Then display the notice
public function renewal_notice($data) {
    echo $this->generate( 'update-renewal-expired-notice', $data );
}

Add a new event - after_plugin_row_{$plugin_file} in

public static function get_subscribed_events() {

import Engine\License\API\User;
Add new method and bail out if:

  • User license is not expired ( ! $this->user->is_license_expired() ).
  • Version is not a major version - ! is_major_version($version).

We will get the major version by updating the get_latest_version_data method and adding $obj->stable_version = $match['stable_version']; after this line - https://github.com/wp-media/wp-rocket/blob/6a6d8d36f25cfaccfba3f999bc612ad58bd125f7/inc/Engine/Plugin/UpdaterSubscriber.php#LL347C41-L347C41

then in the method we will call get_latest_version_data method and validate the response
for cases where it returns NO_UPDATE {"success":false,"data":{"reason":"NO_UPDATE" we will save response in transient for 12 hours and do a check early for this transient before making remote request.

To display the notice we will get the view data

$data['version'] = $response->stable_version;
$data['learn_more_url'] = 'https://wp-rocket.me/blog/' . str_replace('.', '-', $response->stable_version);
$data['renew_url'] = $this->user->get_renewal_url();

Then call renewal_notice($data);

Update the ServiceProvider class also and add tests too.

Estimate the effort ✅
[M]

@jeawhanlee jeawhanlee added effort: [M] 3-5 days of estimated development time and removed GROOMING IN PROGRESS Use this label when the issue is currently being groomed. labels May 17, 2023
@Tabrisrp Tabrisrp self-assigned this May 18, 2023
@piotrbak
Copy link
Contributor

piotrbak commented Jun 1, 2023

@piotrbak piotrbak added the needs: documentation Issues which need to create or update a documentation label Jul 13, 2023
@piotrbak piotrbak added this to the 3.14.2 milestone Jul 13, 2023
github-merge-queue bot pushed a commit that referenced this issue Jul 17, 2023
…5930)

Co-authored-by: Vasilis Manthos <vmanthos@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: [M] 3-5 days of estimated development time module: user interface needs: documentation Issues which need to create or update a documentation priority: medium Issues which are important, but no one will go out of business. type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants