[wordpress插件] Any Hostname任何主机名

wordpress 插件 文章 2020-02-19 06:10 727 0 全屏看文

AI助手支持GPT4.0

评分
100
描述

Any Hostname alters all WordPress-generated URLs according to the servers current hostname, so that they will always correspond to the actual hostname as entered by the user, as opposed to always using the URL specified in the WordPress options.

任何主机名都会根据服务器当前的主机名更改所有WordPress生成的URL,因此它们将始终与用户输入的实际主机名相对应,而不是始终使用WordPress选项中指定的URL。

The plugin is ideal for making a site available across multiple domains or running local development servers.

该插件是使站点可跨多个域访问或运行本地开发服务器的理想选择。

Known Issues

已知问题

This plugin will not be able to alter the contents of constants such as WP_CONTENT_URL and WP_PLUGIN_URL as these are (quite naturally) defined before any plugins are loaded.

此插件将无法更改诸如 WP_CONTENT_URL WP_PLUGIN_URL 之类的常量的内容,因为这些(自然而然)是在加载任何插件之前定义的。

Plugin developers should instead rely on either one of the plugins_url(), content_url() or get_option() functions, which will always return the filtered

插件开发人员应改为依赖 plugins_url() content_url() get_option()函数之一,这些函数将始终返回已过滤的

hostname.

主机名。

An example of this is the WPtouch plugin, in which case you can override WPtouch’s compat_get_wp_content_url function, as described by this Gist: https://gist.github.com/1401269.

WPtouch插件就是一个例子,在这种情况下,您可以覆盖WPtouch的 compat_get_wp_content_url 函数,如以下要点所述:https://gist.github.com/1401269。

Any Hostname might also obscure the value of WordPress and Site URL settings on the Options » General settings page, due to the fact that these values are retrieved using the get_option() function.

由于使用 get_option()函数检索这些值,因此任何主机名也可能会混淆“选项”»“常规设置”页面上WordPress和站点URL设置的值。

The values actually stored in WordPress’ database is in fact your site’s true URL.

实际上存储在WordPress数据库中的值实际上是您网站的真实URL。

From 1.0b2 up the plugin will deactivate the host filters on this page, which might cause some page resources to load from the default URL (potentially being unreachable).

从1.0b2开始,该插件将停用此页面上的主机过滤器,这可能会导致某些页面资源从默认URL加载(可能无法访问)。

Any Hostname will not work on WordPress Network sites (WPMU) due to the fact that the pages in a network install stores its URLs explicitily in the database.

由于网络安装中的页面将其URL明确存储在数据库中,因此任何主机名在WordPress网络站点(WPMU)上均不起作用。

Any ideas on how to circumvent this would be greatly appreciated.

任何有关如何避免这种情况的想法将不胜感激。

Due to a bug in the WordPress Settings API (https://core.trac.wordpress.org/ticket/9296) the plugin settings are located on the Privacy page on WordPress versions below 3.5.

由于WordPress设置API(https://core.trac.wordpress.org/ticket/9296)中的错误,插件设置位于WordPress版本低于3.5的“隐私”页面上。

From 3.5 and up the settings can be found on the Permalinks page.

从3.5及更高版本开始,可以在“永久链接”页面上找到设置。

Filters

过滤器

Any Hostname has two filters, allowing you to programatically override the filtered hostname or the list of allowed hostnames.

任何主机名都有两个过滤器,可让您以编程方式覆盖过滤后的主机名或允许的主机名列表。

These are described below.

这些在下面说明。

`any_hostname_host`

`any_hostname_host`

    • Arguments: $host (required)
    • 参数: $ host (必需)

    • Return value: $host (required)
    • 返回值: $ host (必需)

    Takes a host as argument, and returns a host that will be used when substituting the domain in URLs supplied by WordPress.

    以主机作为参数,并返回在将域替换为WordPress提供的URL时将使用的主机。

    This filter can be used to make the plugin use a specific host under certain circumstances.

    在某些情况下,可以使用此过滤器使插件使用特定的主机。

    `any_hostname_allowed_hosts`

    `any_hostname_allowed_hosts`

      • Arguments: $hosts (required)
      • 参数: $ hosts (必需)

      • Return value: $hosts (required)
      • 返回值: $ hosts (必需)

      Takes an array of allowed hosts as argument, and returns an array of hosts to be used when checking if the user specified host should be allowed.

      以允许的主机数组作为参数,并在检查是否应允许用户指定的主机时返回要使用的主机数组。

      Hosts should be treated as regular expression patterns.

      宿主应被视为正则表达式模式。

      Credits

      积分

安装步骤

This section describes how to install the plugin and get it working.

本节介绍如何安装插件并使其正常工作。

    1. Upload the any-hostname directory to the /wp-content/plugins/ directory
    2. any-hostname 目录上传到 / wp-content / plugins / 目录

    3. Activate the plugin through the ‘Plugins’ menu in WordPress
    4. 通过WordPress中的“插件”菜单激活插件

    5. Optionally edit the list of allowed hosts under ‘Options’ » ‘General’ (Privacy for WordPress versions below 3.5)
    6. (可选)在“选项”»“常规”(WordPress版本低于3.5的隐私权)下编辑允许的主机列表。

下载地址
https://downloads.wordpress.org/plugin/any-hostname.1.0.6.zip
-EOF-

AI助手支持GPT4.0