Skip to content

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

@mehulkaklotar

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.

Metadata

Metadata

Labels

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions