globalis/wp-cubi-helpers

WordPress 的 wp-cubi 函数集合

1.0.5 2023-01-26 16:04 UTC

README

Build Status Latest Stable Version License

WordPress 的 wp-cubi 函数集合

wp-cubi

需求

  • PHP 8.0, 8.1 或 8.2

安装

  • composer require globalis/wp-cubi-helpers

可用函数

缓存

  • flush_cache_all()
  • flush_cache_wpdb()
  • flush_cache_object()
  • get_size_cache_wpdb(): int
  • get_size_cache_object(): int
  • reset_cache_wpdb(int $size)
  • reset_cache_object(int $size)
  • pop_cache_wpdb()
  • pop_cache_object()
  • savequeries_enabled(): bool

调试

  • mysql_enable_nocache_mod()
  • mysql_disable_nocache_mod()
  • query_set_nocache(string $query): string
  • time_start(string $timer = 'default'): float
  • time_elapsed(string $timer = 'default', bool $human = true)
  • memory_get_usage_kb(bool $human = true, bool $real_usage = false)
  • memory_get_usage_mb(bool $human = true, bool $real_usage = false)
  • memory_get_peak_usage_kb(bool $human = true, bool $real_usage = false)
  • memory_get_peak_usage_mb(bool $human = true, bool $real_usage = false)
  • memory_usage_format(float $usage, string $unit, bool $human)

过滤器

  • add_filter(string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1)
  • add_action(string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1)
  • remove_filter_anonymous_object(string $tag, string $class_name, string $method_name, int $priority = 10): bool

邮件

  • wp_mail_html($to, string $subject, string $message, $headers = [], $attachments = []): bool

永久链接

  • get_permalink_by_template(string $template, $default = false)

模板化

  • include_template_part($file, $data = [], $return = false)

URLs

  • get_current_url(bool $remove_query_args = false): string
  • current_url_starts_with(string $search, bool $remove_query_args = false): bool
  • current_url_ends_with(string $search, bool $remove_query_args = false): bool

Utils

  • str_starts_with(string $string, string $search): bool
  • str_ends_with(string $string, string $search): bool
  • trigger_404(\WP_Query $query = null)
  • override_php_limits(int $time_limit = 604800, string $memory_limit = '512M')

开发

在提交 pull requests 之前,请使用 ./vendor/bin/phpcs . 和/或 ./vendor/bin/phpcbf . 检查并应用项目编码规范。