leonstafford/static-html-output

WordPress 静态HTML输出插件。


README

CircleCI Packagist PHPStan

WordPress 插件,用于生成网站的静态副本并部署到 GitHub Pages、S3、Netlify 等。提高安全性、页面加载速度和托管选项。将 WordPress 集成到 CI/CD 工作流程中。

我维护的其他 WordPress SSG

WP-CLI 命令

  • wp statichtmloutput COMMAND

其中 COMMAND 可以是以下之一

  • 选项
  • generate
  • deploy
  • deploy_cache

通过添加 --help 获取任何命令的帮助

钩子

修改要爬取的初始 URL 列表

  • statichtmloutput_modify_initial_crawl_list
  • 过滤器钩子

签名

apply_filters(
    'statichtmloutput_modify_initial_crawl_list',
    $url_queue
);

示例用法

function add_additional_urls( $url_queue ) {
    $additional_urls = [
        'http://mydomain.com/custom_link_1/',
        'http://mydomain.com/custom_link_2/',
    ];

    $url_queue = array_merge(
        $url_queue,
        $additional_urls
    );

    return $url_queue;
}

add_filter( 'statichtmloutput_modify_initial_crawl_list', 'add_additional_urls' );

部署后钩子

  • statichtmloutput_post_deploy_trigger
  • 动作钩子

签名

do_action(
  'statichtmloutput_post_deploy_trigger',
  $archive
);

示例用法

function printArchiveInfo( $archive ) {
    error_log( print_r( $archive, true ) );
}

add_filter( 'statichtmloutput_post_deploy_trigger', 'printArchiveInfo' );

示例响应

Archive Object
(
    [settings] => Array
        (
            [selected_deployment_option] => github
            [baseUrl] => https://leonstafford.github.io/demo-site-wordpress-static-html-output/
            [wp_site_url] => http://example.test/
            [wp_site_path] => /srv/www/example.com/current/web/wp/
            [wp_uploads_path] => /srv/www/example.com/current/web/app/uploads
            [wp_uploads_url] => http://example.test/app/uploads
            [wp_active_theme] => /wp/wp-content/themes/twentyseventeen
            [wp_themes] => /srv/www/example.com/current/web/app/themes
            [wp_uploads] => /srv/www/example.com/current/web/app/uploads
            [wp_plugins] => /srv/www/example.com/current/web/app/plugins
            [wp_content] => /srv/www/example.com/current/web/app
            [wp_inc] => /wp-includes
            [crawl_increment] => 1
        )

    [path] => /srv/www/example.com/current/web/app/uploads/wp-static-html-output-1547668758/
    [name] => wp-static-html-output-1547668758
    [crawl_list] =>
    [export_log] =>
)

贡献 / 开发

非常欢迎贡献!请不要因为提交问题、创建 Pull Request 或发送电子邮件(Leon)me@ljs.dev 而感到害怕。

开发

  • git clone git@github.com:WP2Static/static-html-output.git
  • cd static-html-output
  • composer install
  • composer test
  • composer coverage(可选的覆盖率生成,需要 Xdebug

构建安装 .zip 文件

  • composer build INSTALLER_FILENAME

这将创建安装程序并将其放置在您的 $HOME/Downloads 目录中。

在 Windows 上,您需要可用的 zip 工具来构建安装程序。我建议使用 Git Bash shell,然后根据 这些说明 手动安装 zip 工具

本地化 / 翻译

插件中不支持本地化。如果您需要帮助翻译 UI,请使用浏览器扩展,或者您可以通过任何翻译服务运行我们的文档页面。

支持

请在这里在 GitHub 上或在该插件的 支持论坛提出问题