配置我的插件,效果更佳。

  • https://github.com/midoks/wp-cache-db

  • php7.2
  • opcache

wp-settings.php | load_default_textdomain

  • 多语言加载,前台可以不加载
    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    if (is_admin()) {
      load_default_textdomain();
      $locale      = get_locale();
      $locale_file = WP_LANG_DIR . "/$locale.php";
      if ((0 === validate_file($locale)) && is_readable($locale_file)) {
          require $locale_file;
      }
      unset($locale_file);
    }
    

l10n.php | translate

1
2
3
4
5
6
7
function translate($text, $domain = 'default') {
    if (!is_admin()) {
        return $text;
    }

...
}

l10n.php | translate_with_gettext_context

1
2
3
4
function translate_with_gettext_context($text, $context, $domain = 'default') {
    if (!is_admin()) {return $text;}
    ...
}

option.php | get_option

1
2
3
4
5
6
7
8
9
10
11
function get_option($option, $default = false) {
    // var_dump($option);
    global $cache_option;
    if (isset($cache_option[$option])) {
        return $cache_option[$option];
    }
    ...
    $v                     = apply_filters("option_{$option}", maybe_unserialize($value), $option);
    $cache_option[$option] = $v;
    return $v;
}

scripts-loader.php | wp_default_scripts

1
2
3
4
function wp_default_scripts($scripts) {
    if (!is_admin()) {return;}
    ...
}

blocks.php | register_block_type_from_metadata

1
2
3
4
function register_block_type_from_metadata($file_or_folder, $args = array()) {
    if (!is_admin()) {return;}
    ...
}

class-wp-query.php | get_posts | 可选

1
2
3
4
function get_posts()) {
    if (!is_admin()) {return;}
    ...
}