admin管理员组

文章数量:1392098

How can I add a CSS id to the row that contains my custom plugin in the plugins list table i.e (/wp-admin/plugins.php)?

What I want to achieve is displaying an admin notice like this

<p>Enter your license <a href="#custom-plugin">here</a> to activate the plugin</p>

When user click on the link it should scroll to that particular plugin row.

How can I add a CSS id to the row that contains my custom plugin in the plugins list table i.e (/wp-admin/plugins.php)?

What I want to achieve is displaying an admin notice like this

<p>Enter your license <a href="#custom-plugin">here</a> to activate the plugin</p>

When user click on the link it should scroll to that particular plugin row.

Share Improve this question edited Feb 5, 2020 at 15:43 SkyRar asked Feb 5, 2020 at 11:56 SkyRarSkyRar 2122 silver badges9 bronze badges 1
  • Most licenses I've seen are entered on options pages instead of the plugins list page. Maybe you could add a options/settings page instead, so visitors can go straight to it without you having to add an ID? – WebElaine Commented Feb 5, 2020 at 16:42
Add a comment  | 

1 Answer 1

Reset to default 0

Updated answer on how to target with JS: since jQuery is included in wp-admin, you can still target the link with the row's existing data-slug.

Example of how to target all the links:

jQuery('tr[data-slug="my-plugin-slug"] a'.css('color', 'green');

(You can inspect the elements to work out a way to target just one specific link, if that's your goal, and of course you can change other properties besides the CSS link color.)

Original answer on how to target the CSS: You could accomplish the same goal by targeting the data-slug or data-plugin attribute:

tr[data-slug="my-plugin-slug"] {
    // your css here
}

The slug is the folder name your plugin is in; and the data-plugin attribute is the folder plus the filename.

本文标签: filtersIs it possible to assign a css id to a row in plugins list table