codelight-eu/codelight-wp-cleanup
Composer 安装命令:
composer require codelight-eu/codelight-wp-cleanup
包简介
Remove various unneeded functionality from your WP installation.
关键字:
README 文档
README
Wordpress comes with a bunch of features that are rarely needed when WP is used more as a content management system instead of a blogging platform. This can lead to broken archive pages, admin dashboard bloat and even a couple of small security concerns.
This plugin provides an easy way to selectively disable most of the stuff I've found to be useless in a CMS context.
Note that this plugin has not been tested thoroughly - patches and issues are welcome.
Todo:
- Review and fix removing Comments;
- Remove comments icon from admin bar;
- Allow moving Menus to a separate top-level menu item (i.e. instead of Appearance);
- Allow bulk registering options (instead of a ton of separate add_theme_support() calls);
- Remove 'widgets' link from admin bar;
- Refactor architecture;
- Refactor to use PSR-2.
Summary
The plugin provides filters to easily:
- Disable specific widgets;
- Disable Categories, Tags and specific archive pages (e.g. Author, Date, Attachment)
You can also enable the following:
- Remove admin bar and restrict dashboard access for users without the 'edit_posts' capability;
- Remove comment support from 'post' and 'page' post types; remove all (most?) comment-related stuff from admin;
- Disable feeds;
- Disable the search functionality.
And by default, the plugin:
- Restricts TinyMCE styles dropdown to <p>, <h2>, <h3>, <h4>;
- Disables XML-RPC;
- Hides update notifications for non-admin users;
- Removes Quick Press dashboard widget;
- Removes "Tools" from the dashboard menu for non-admin users;
- Removes Appearance > [Themes, Customize, Header, Background] from the dashboard menu for non-admin users;
- Removes a bunch of useless widgets;
- Limits post revisions to 5 (unless explicitly defined elsewhere);
- Adds the X-UA-Compatible http request header.
Configuration
Everything below goes into your theme's functions.php
To enable the plugin:
add_theme_support('cl-wp-cleanup');
Without this, the plugin does nothing.
Disable customizer
add_theme_support('cl-disable-customizer');
Disable categories / tags / archives
Even if date / author / attachment archive templates do not exist, Wordpress will still render those pages using the default template, which can result in those pages being visually broken. These broken or simply unused pages may be indexed by search engines.
To disable specific archives:
add_filter('cl_remove_archives', function($types) {
return array('author', 'date', 'attachment');
});
Valid arguments are:
- 'archive' to remove all Archives and also Category and Tag taxonomies (basically everything below);
- 'category' to remove Category archives and the Category taxonomy;
- 'tag' to remove Tag archives and the Tag taxonomy;
- 'author' to remove the Author archives;
- 'date' to remove the Date archives;
- 'attachment' to redirect all attachment pages to their parent pages, or to the front page when the attachment is not attached to any specific page.
By default, nothing is removed.
Disable search
Remove all search-related functionality.
add_theme_support('cl-remove-search');
Disable widgets
To clean up some of the less useful default widgets:
add_filter('cl_remove_widgets', function($widgets) {
return array('misc', 'blog');
});
Valid arguments are:
- 'all' to completely remove the Widgets page from WP Admin;
- 'misc' to remove Pages, Calendar, Links, Meta, Tag Cloud widgets;
- 'blog' to remove blog-related widgets: Archives, Categories, Recent Posts, RSS;
- or an array of specific widget class names - the full list is available in the Codex
By default, 'misc' widgets are removed.
Restrict dashboard access
For users who don't have 'edit_posts' capability, redirects dashboard to front page, disables the admin bar and redirects to front page after login.
To enable:
add_theme_support('cl-restricted-dashboard-access');
Remove comments
Removes comment support from Posts and Pages, hides Comments from the menu, removes Comments from admin bar and removes the Recent Comments dashboard widget.
To enable:
add_theme_support('cl-remove-comments');
Admin cleanup
For all non-admin users, this feature:
- Hides update notifications
- Removes the following pages from admin:
- Appearance > Themes
- Appearance > Header
- Appearance > Background
- Removes Quick Press dashboard widget
This is just a small cleanup to the admin interface.
Note that non-admin users do not have access to the Appearance menu item by default anyway. This feature is useful when the client has a role other than Administrator but still requires access to Widgets and Menus.
To disable admin cleanup:
add_theme_support('cl-disable-admin-cleanup');
Remove feeds
Disables feeds. Note that it doesn't remove various feed links from the head - this needs to be done manually.
add_theme_support('cl-remove-feeds');
Remove Tools menu item
The Tools menu item is hidden by default.
To re-enable Tools:
add_theme_support('cl-enable-tools');
Clean up TinyMCE
Restrict the TinyMCE styles dropdown to only have <p>, <h2>, <h3> and <h4>.
To disable:
add_theme_support('cl-disable-tinymce-cleanup');
XML-RPC
Disabled by default, as it's a potential attack vector. To enable:
add_theme_support('cl-enable-xmlrpc');
Post revisions
To reduce database bloat, the number of post revisions is set to 5, unless explicitly defined. To set a custom number, simply override WP_POST_REVISIONS.
X-UA-Compatible header
Sets the X-UA-Compatible header to force IE to not use compatibility mode. Read more in this stackoverflow thread
Disable plugin update checks
To speed up the load of plugins page, disable plugin update checks. This is useful if you're using a composer-based setup anyway.
add_theme_support('cl-disable-plugin-update-check');
codelight-eu/codelight-wp-cleanup 适用场景与选型建议
codelight-eu/codelight-wp-cleanup 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 287 次下载、GitHub Stars 达 16, 最近一次更新时间为 2018 年 09 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「wordpress」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 codelight-eu/codelight-wp-cleanup 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codelight-eu/codelight-wp-cleanup 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 codelight-eu/codelight-wp-cleanup 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Plugin for YOURLS. Default tools to use in some laemmi plugins
Must-use plugin integrating WordPress with the Upsun platform: environment awareness, router-cache friendliness, safe preview clones, deploy migrations, Site Health checks, and a wp upsun CLI command.
Allows polling user for event dates and times.
Support swipe touch gestures to navigate in paginated lists and on Tidypics image pages.
Add a postscript to every email notification sent out to users.
统计信息
- 总下载量: 287
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 16
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: The
- 更新时间: 2018-09-20