admin管理员组文章数量:1122846
I was wondering if it was possible to add a custom filter to the Wordpress backend plugins page (/wp-admin/plugins.php
). To ensure I'm being totally clear about what I'm referring to, I'm talking about the filters in the header underneath the page title that look similar to these options:
All (86) | Active (43) | Inactive (43) | Recently Active (1) | Drop-ins (3) | Auto-updates Enabled (51) | Auto-updates Disabled (35)
We have a bunch of custom plugins we've developed in-house that I think it would be handy if we could group using a new custom filter for this page.
I was wondering if it was possible to add a custom filter to the Wordpress backend plugins page (/wp-admin/plugins.php
). To ensure I'm being totally clear about what I'm referring to, I'm talking about the filters in the header underneath the page title that look similar to these options:
All (86) | Active (43) | Inactive (43) | Recently Active (1) | Drop-ins (3) | Auto-updates Enabled (51) | Auto-updates Disabled (35)
We have a bunch of custom plugins we've developed in-house that I think it would be handy if we could group using a new custom filter for this page.
Share Improve this question asked Aug 26, 2024 at 17:20 Talk Nerdy To MeTalk Nerdy To Me 2852 silver badges10 bronze badges1 Answer
Reset to default 2you can do that with the help of 2 filters :
add_filter("plugins_list", function ($plugins) {
$filter_code = "with_b";
if ( isset($_GET["plugin_status"])
&& ($filter_code === $_GET["plugin_status"])
) {
$GLOBALS["status"] = $filter_code; // setting the filter to display in current page
}
// preparation of the plugins in the special category
$plugins[$filter_code] = array_filter($plugins["all"], function ($plugin) {
return FALSE !== strpos($plugin["Name"], "b");
});
return $plugins;
});
// preparation of the link to the special category
add_filter("views_plugins", function ($views) {
$filter_code = "with_b";
$nb = $GLOBALS["totals"][$filter_code];
$url = "plugins.php?plugin_status=$filter_code";
$html = "<a href=\"$url\"";
if ( $GLOBALS["status"] === $filter_code ) {
$html .= " class=\"current\" aria-current=\"page\"";
}
$html .= ">";
$html .= "Name that contains \"b\"";
$html .= "<span class=\"count\">($nb)</span>";
$html .= "</a>";
$views[$filter_code] = $html;
return $views;
});
本文标签: add custom filter to plugins page
版权声明:本文标题:add custom filter to plugins page? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736296621a1929836.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论