php 除某些页面外,禁用Contact Form 7插件。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 除某些页面外,禁用Contact Form 7插件。相关的知识,希望对你有一定的参考价值。
<?php
/*
Plugin Name: Disable CF7 plugin
Plugin URI: http://www.damiencarbery.com
Description: Disable Contact Form 7 plugin except for certain pages.
Author: Damien Carbery
Version: $Revision: $
$Id: $
*/
add_filter( 'option_active_plugins', 'disable_plugins_per_page' );
function disable_plugins_per_page( $plugin_list ) {
// Quit immediately if in admin area.
if ( is_admin() ) {
return $plugin_list;
}
$disable_plugins = array (
// Plugin Name => Urls *not* to disable on.
'contact-form-7/wp-contact-form-7.php' => array( '/wp-json/contact-form-7/', '/contact-us/', '/contact-us-fr/', '/kontakt/' ), // /wp-json url needed to send messages
'advanced-custom-fields-pro/acf.php' => array( '/page-one/', '/page-two/', '/page-three/' ),
);
$plugins_to_disable = array();
foreach ( $plugin_list as $plugin ) {
if (true == array_key_exists( $plugin, $disable_plugins ) ) {
//error_log( "Found $plugin in list of active plugins." );
if ( false === array_search( $_SERVER['REQUEST_URI'], $disable_plugins[ $plugin ] ) ) {
//error_log( "Disable $plugin on ".$_SERVER['REQUEST_URI']."." );
$plugins_to_disable[] = $plugin;
}
}
}
// If there are plugins to disable then remove them from the list,
// otherwise return the original list.
if ( count( $plugins_to_disable ) ) {
$new_list = array_diff( $plugin_list, $plugins_to_disable );
return $new_list;
}
else {
return $plugin_list;
}
}
以上是关于php 除某些页面外,禁用Contact Form 7插件。的主要内容,如果未能解决你的问题,请参考以下文章
php 联系表单7插件:在使用Contact Form 7短代码的页面,帖子和CPT上加载Javascript和CSS。
php 联系表单7插件:在使用Contact Form 7短代码的页面,帖子和CPT上加载Javascript和CSS。
WooCommerce Quote or Enquiry Contact Form 7怎么使用
Wordpress:在jQuery按钮上,单击Contact Form 7菜单中的预选择选项
禁用某些页面的 HTTP GET php
php 通过Contact Form 7中的变量传递值