bonnier/wp-bonnier-redirect

此包的最新版本(4.13.24)没有提供许可证信息。

Bonnier与自定义永久链接和Polylang集成的重定向

安装数: 7,531

依赖项: 1

建议者: 0

安全性: 0

星标: 0

关注者: 13

分支: 0

开放性问题: 2

类型:wordpress-plugin

4.13.24 2023-11-28 13:09 UTC

README

使用此插件的要求是自定义重定向

导入

要导入别名和重定向,必须运行以下命令

wp bonnier redirect import redirect GDS-path_redirect-20170814.csv

以及

wp bonnier redirect import alias GDS-url_alias-20170814.csv

过滤器

此插件公开以下过滤器

redirect/slug-is-live | Bonnier\WP\Redirect\WPBonnierRedirect::FILTER_SLUG_IS_LIVE:

自行验证URL是否有效。

/**
 * @param bool $isLive The plugins evaluation of whether the url is live or not
 * @param string $url The 'from'-url being saved
 * @param string $locale The locale of the redirect being saved
 * @param WP_Post|WP_Term|null $object The object found by the redirect plugin - null if $isLive == false
 *
 * @return bool
 */
add_filter('redirect/slug-is-live', function (bool $isLive, string $url, string $locale, $object) {
    return $isLive;
}, 10, 4);

动作

此插件公开以下动作

redirect/redirect-saved | Bonnier\WP\Redirect\WPBonnierRedirect::ACTION_REDIRECT_SAVED:

当保存新的重定向时注册动作。

/**
 * @param Redirect $redirect The newly created redirect
 */
add_filter('redirect/redirect-saved', function (Redirect $redirect) {
    // Do stuff with the newly created Redirect
}, 10);