【问题标题】:Do not load the plugin for multiple occurrences in WordPress不要在 WordPress 中多次加载插件
【发布时间】:2022-01-16 07:00:11
【问题描述】:

我正在使用下面的代码来禁用特定 URL 路径的插件,但我还有更多路径要添加。例如,我喜欢禁用包含 /xxxx/、/xxxx1/、/xxxx2/、/xxxx3/、/xxxx4/ 的插件和 URL。

如何在下面的代码中包含所有其他 4 条路径?

// Do not load the plugin if the 404 URL starts with '/xxxx/'
add_filter('wp404arsp/init', 'my_404_no_init2', 10, 2);

function my_404_no_init2($init, $query){

    // Print $query array for more request context

    if (preg_match('#/xxxx/(.+?)/?$#i', $query['request']['url']))
        $init = false;

    return $init;
}

【问题讨论】:

    标签: php regex wordpress


    【解决方案1】:

    对于文件 1-4:
    preg_match 模式更改为:

    '#/xxxx{1-4}*/(.+?)/?$#i'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-22
      • 2018-07-20
      • 1970-01-01
      • 2013-08-21
      • 2021-02-14
      • 1970-01-01
      • 2023-03-07
      相关资源
      最近更新 更多