Skip to content

Introduce a “Check this plugin” link in the Plugins list table #36

Closed

Description

@mehulkaklotar

Description

The plugin will add a new “Check this plugin” link to the WP Admin > Plugins list table. The link will go to the new Tools page introduced by the plugin. The link will have a plugin file (e.g., akismet/akismet.php) as a request parameter so that the Plugin Check can recognize from the request that it needs to start checks on it.

All the processes after the link have been recognized will be the same as when the user clicks on the “Check it!” link as outlined in the AJAX functionality.

Acceptance Criteria

  • filter_plugin_action_links() method should exist in the Admin_Page class (see this class details on Create Tools page #32 )

  • Add plugin_action_links filter in the add_hooks() and append the filter_plugin_action_links() method in that hook. like below:

    add_filter( 'plugin_action_links', array( $this, 'filter_plugin_action_links' ), 10, 2 );

  • filter_plugin_action_links() method should take two arguments, $actions and $plugin_file.

  • Based on the $plugin_file's argument, it will return the anchor (<a>) link tag with query the string page=plugin-check&plugin=$plugin_file to point to the tools page.

  • The link text will be Check this plugin, so the end code of the filter_plugin_action_links() method will look something like below:

    public function filter_plugin_action_links( $actions, $plugin_file ) {
    
     	$actions[] = '<a href="' . esc_url( admin_url() . 'tools.php?page=plugin-check&plugin=' . $plugin_file ) . '">'.esc_html__( 'Check this plugin' , 'plugin-check').'</a>';
    
     	return $actions;
     }
    
  • Once the user lands on the Plugin Check page, the plugin's dropdown should be populated based on the plugin param of the query string.

Test Coverage

Automated Tests:

  • Write a test case to check whether the plugin_action_links filter is registering.
  • Write a test case for the filter_plugin_action_links() method that it is generating the proper URL or not.

Manual Tests:

  • Login to the admin area, go to the plugin list and check if the Check this plugin link is available.
  • Click on any plugin's Check this plugin link and check the user redirecting to the Plugin Check page and populating the plugin list dropdown with the proper plugin name.

Activity

  1. moved this from Backlog to Definition in Plugin Checkon Dec 13, 2022
  2. moved this from Definition to AC Review in Plugin Checkon Dec 13, 2022
  3. vishalkakadiya commented on Jan 24, 2023

    @vishalkakadiya

    @jjgrainger Updated AC's details here. Let me know if any changes are needed here. Thank you! 🙂

  4. jjgrainger commented on Jan 25, 2023

    @jjgrainger
    Contributor

    Thanks @vishalkakadiya

    Looks good, a couple of questions/thoughts:

    1. Can we not use the plugin_action_links filter? This will prevent having to loop over all plugins.
    2. "Track the URL parameter on the tools page and starts checking the plugin" - I don't think we should automatically run the plugin check process right away. We should autofill the plugin using the URL parameter in the dropdown but the user should trigger the checking process manually.
    3. We should go into details and include what the link text will be in the AC's ('Check this plugin').
    4. Test coverage usually implies unit test, but in the case I can see this as more manual QA. If thats the case we should add a note for clarity that these tests should be done manually.

    While updating the AC's if you find parts of the description do not apply please update this.

    Let me know if you have any questions. Thanks!

  5. felixarntz commented on Jan 25, 2023

    @felixarntz
    Member

    @vishalkakadiya A bit of follow up feedback:

    • plugin_action_links_ filter should be used to add each plugin's check link using get_plugins

    This should rather say plugin_action_links, and no need to mention get_plugins, since this filter is for a single plugin, where the $plugin_file parameter is already provided.

    • Link should have plugin file name as URL parameter

    Can you include a name for the query parameter here? E.g. simply plugin (that's also what core uses in a few places).

    • Track the URL parameter on the tools page and starts checking the plugin

    How should that work? We haven't implemented the actual checking logic in WP Admin yet, so I would suggest for the scope of this issue we keep it simple: We can simply, based on the URL query parameter, select the right plugin in the dropdown, so that the user only has to click the CTA button.

    In the future we can separately consider iterating on that further.

    Last but not least: Can you please outline in which class that should be implemented? We can probably use the one from #32, since this link ties directly to the admin page there.

  6. 3 remaining items

  7. felixarntz commented on Jan 26, 2023

    @felixarntz
    Member

    @vishalkakadiya ACs almost good to go, just a suggested name change: The name plugin_check_link() is missing a verb again, so that's not a good method name. Since it is directly a filter callback for the plugin_action_links filter, we should probably use something like filter_plugin_action_links().

  8. vishalkakadiya commented on Jan 27, 2023

    @vishalkakadiya

    @jjgrainger @felixarntz Updated the description as per your suggestions. Thank you! 🙌

  9. felixarntz commented on Jan 27, 2023

    @felixarntz
    Member

    @vishalkakadiya Thanks, ACs LGTM!

    For the future, no need to include code snippets, it's best for the ACs to be just a description without actual code in it. But no need to change it here either 👍 Just something to keep in mind for the future :)

  10. moved this from AC Review to To Do in Plugin Checkon Jan 27, 2023
  11. vishalkakadiya commented on Jan 30, 2023

    @vishalkakadiya

    Thank you! @felixarntz @jjgrainger 🙌

  12. added this to the Sprint 5 milestone on Feb 10, 2023
  13. moved this from To Do to Code Review in Plugin Checkon Feb 23, 2023
  14. moved this from Code Review to Done in Plugin Checkon Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

WP AdminIssues for the WP Admin screen[Type] EnhancementA suggestion for improvement of an existing feature

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions