roots/soil

此包已被废弃,不再维护。作者建议使用 roots/acorn-prettify 包。

一款包含一系列模块的 WordPress 插件,用于应用主题无关的前端修改

资助包维护!
Patreon
roots.io/plugins/soil

安装数: 1,670,854

依赖者: 18

建议者: 0

安全性: 1

星标: 1,030

关注者: 89

分支: 181

开放问题: 23

类型:wordpress-plugin

4.1.1 2022-08-01 17:32 UTC

README

Packagist Packagist Downloads Build Status Project Status: Unsupported – The project has reached a stable, usable state but the author(s) have ceased all work on it.

一款包含一系列模块的 WordPress 插件,用于应用主题无关的前端修改。

注意

此插件不再维护。请使用 Acorn Prettify 代替。

要求

先决条件 如何检查 如何安装
PHP >= 5.6.x php -v php.net

安装

您可以通过命令行或 WordPress 管理面板安装此插件。

通过命令行

如果您正在使用 Composer 管理WordPress,将 Soil 添加到项目依赖中。

composer require roots/soil

然后通过 wp-cli 激活插件。

wp plugin activate soil

通过 WordPress 管理面板

  1. 下载此仓库的最新 zip 文件。
  2. 在您的 WordPress 管理面板中,导航到插件 -> 添加新插件
  3. 点击上传插件
  4. 上传您下载的 zip 文件。

模块

  • 更干净的 WordPress 标记
    add_theme_support('soil', 'clean-up');

  • 禁用 REST API
    add_theme_support('soil', 'disable-rest-api');

  • 禁用资源版本控制
    add_theme_support('soil', 'disable-asset-versioning');

  • 禁用评论跟踪
    add_theme_support('soil', 'disable-trackbacks');

  • 谷歌分析
    add_theme_support('soil', ['google-analytics' => 'UA-XXXXX-Y']);

  • 将所有 JS 移至页脚
    add_theme_support('soil', 'js-to-footer');

  • 更干净的导航菜单遍历器
    add_theme_support('soil', 'nav-walker');

  • 将搜索结果从 /?s=query 转换为 /search/query/
    add_theme_support('soil', 'nice-search');

  • 根相对 URL
    add_theme_support('soil', 'relative-urls');

并且以您可以复制并粘贴到主题的格式

/**
 * Enable features from Soil when plugin is activated
 * @link https://roots.io/plugins/soil/
 */
add_theme_support('soil', [
    'clean-up',
    'disable-rest-api',
    'disable-asset-versioning',
    'disable-trackbacks',
    'google-analytics' => 'UA-XXXXX-Y',
    'js-to-footer',
    'nav-walker',
    'nice-search',
    'relative-urls'
]);

模块选项

Soil 4 引入了对一些模块选项的支持。

功能和选项的完整注释列表
/**
 * Enable features from Soil when plugin is activated
 * @link https://roots.io/plugins/soil/
 */
add_theme_support('soil', [
    /**
     * Clean up WordPress
     */
    'clean-up' => [
        /**
         * Obscure and suppress WordPress information.
         */
        'wp_obscurity',

        /**
         * Disable WordPress emojis.
         */
        'disable_emojis',

        /**
         * Disable Gutenberg block library CSS.
         */
        'disable_gutenberg_block_css',

        /**
         * Disable extra RSS feeds.
         */
        'disable_extra_rss',

        /**
         * Disable recent comments CSS.
         */
        'disable_recent_comments_css',

        /**
         * Disable gallery CSS.
         */
        'disable_gallery_css',

        /**
         * Clean HTML5 markup.
         */
        'clean_html5_markup',
    ],

    /**
     * Disable WordPress REST API
     */
    'disable-rest-api',

    /**
     * Remove version query string from all styles and scripts
     */
    'disable-asset-versioning',

    /**
     * Disables trackbacks/pingbacks
     */
    'disable-trackbacks',

    /**
     * Google Analytics
     */
    'google-analytics' => [
        /**
         * This is to go live with GA.
         *
         * This should probably be false in non-production.
         */
        'should_load' => false,

        /**
         * Google Analytics ID
         *
         * This is also known as your "property ID" or "measurement ID"
         *
         * Format: UA-XXXXX-Y
         */
        'google_analytics_id' => null,

        /**
         * Optimize container ID
         *
         * Format: OPT-A1B2CD (previously: GTM-A1B2CD)
         *
         * @link https://support.google.com/optimize/answer/6262084
         */
        'optimize_id' => null,

        /**
         * Anonymize user IP addresses.
         *
         * This might be required depending on region.
         *
         * @link https://github.com/roots/soil/pull/206
         */
        'anonymize_ip',
    ],

    /**
     * Moves all scripts to wp_footer action
     */
    'js-to-footer',

    /**
     * Cleaner walker for wp_nav_menu()
     */
    'nav-walker',

    /**
     * Redirects search results from /?s=query to /search/query/, converts %20 to +
     *
     * @link http://txfx.net/wordpress-plugins/nice-search/
     */
    'nice-search',

    /**
     * Convert absolute URLs to relative URLs
     *
     * Inspired by {@link https://web.archive.org/web/20180529232418/http://www.456bereastreet.com/archive/201010/how_to_make_wordpress_urls_root_relative/}
     */
    'relative-urls',
]);

贡献

欢迎所有人的贡献。我们有 贡献指南 来帮助您开始。

社区

跟踪开发和社区新闻。