mindkomm/theme-lib-environment-dev

本地WordPress主题开发环境的优化

1.1.0 2018-08-30 08:54 UTC

This package is auto-updated.

Last update: 2024-09-05 04:55:53 UTC


README

本地WordPress主题开发环境的优化。

安装

您可以通过Composer安装此包

composer require mindkomm/theme-lib-environment-dev

使用方法

默认情况下,开发环境

  • 禁用了心跳。
  • 添加了开发环境的自定义🚀favicon。

要激活此功能,请使用以下代码

functions.php

if ( is_dev() ) {
    $wpdev = new Theme\Environment\Development\WordPress();
    $wpdev->init();
}

开发favicon

为了使开发favicon功能正常工作,您需要通过render_theme_favicon()函数渲染您的favicon。开发favicon功能将取消钩子您的render_theme_favicon函数从wp_head并添加它自己的代码。

functions.php

/**
 * Add the theme favicon into theme head
 */
add_action( 'wp_head', 'render_theme_favicon' );

/**
 * Render favicons.
 *
 * This needs to be a separate function so that it can be unhooked.
 */
function render_theme_favicon() {
    Timber\Timber::render( 'favicons.twig', Timber\Timber::get_context() );
}

重定向邮件

将所有通过wp_mail发送的邮件重定向到特定的电子邮件地址。

if ( is_dev() ) {
    $wpdev = new Theme\Environment\Development\WordPress();
    $wpdev->redirect_emails( 'info@example.org' );
}

WooCommerce

set_email_recipient

过滤WooCommerce邮件的收件人电子邮件。

函数

if ( is_dev() ) {
    $woodev = Theme\Environment\Development\WooCommerce();
    $woodev->set_email_recipient( 'info@example.org' );
}

支持

这是一个我们在MIND开发WordPress主题时使用的库。您可以使用它,但当前我们不提供任何支持。