Avisos
Vaciar todo

[Resuelto] Evitar la carga del plugin Contact form 7 en todas las paginas - Advertencias

3 Respuestas
2 Usuarios
0 Reactions
14 Visitas
Respuestas: 59
Trusted Member
Topic starter
 

Hola, buenas tardes.

Recientemente, siguiendo las recomendaciones de optimizaciones de WP center, hemos incluido en funtions.php del tema hijo el siguiente código:

...............................

// Evitar la carga del plugin Contact form 7 en todas las paginas
add_filter( ‘wpcf7_load_js’, ‘__return_false’ );
add_filter( ‘wpcf7_load_css’, ‘__return_false’ );

function we_carga_contactform7(){
if ( is_page(‘contacto, partners’) ) {
if ( function_exists( ‘wpcf7_enqueue_scripts’ ) ) {
wpcf7_enqueue_scripts();
}
if ( function_exists( ‘wpcf7_enqueue_styles’ ) ) {
wpcf7_enqueue_styles();
}
}
}
add_action( ‘wp_enqueue_scripts’, ‘we_carga_contactform7’ );

...............................

Luego de hacer una serie de optimizaciones, he solicitado una revisión de la cuenta para ver si se detectaban errores y aparecen las siguientes advertencias:

...............................

[06-Aug-2021 15:15:03 UTC] PHP Warning: Use of undefined constant ‘wpcf7_load_js’ - assumed '‘wpcf7_load_js’' (this will throw an Error in a future version of PHP) in /home2/fieitoco/public_html/fieito.com/wp-content/themes/shopkeeper-child/functions.php on line 94
[06-Aug-2021 15:15:03 UTC] PHP Warning: Use of undefined constant ‘__return_false’ - assumed '‘__return_false’' (this will throw an Error in a future version of PHP) in /home2/fieitoco/public_html/fieito.com/wp-content/themes/shopkeeper-child/functions.php on line 94
[06-Aug-2021 15:15:03 UTC] PHP Warning: Use of undefined constant ‘wpcf7_load_css’ - assumed '‘wpcf7_load_css’' (this will throw an Error in a future version of PHP) in /home2/fieitoco/public_html/fieito.com/wp-content/themes/shopkeeper-child/functions.php on line 95
[06-Aug-2021 15:15:03 UTC] PHP Warning: Use of undefined constant ‘__return_false’ - assumed '‘__return_false’' (this will throw an Error in a future version of PHP) in /home2/fieitoco/public_html/fieito.com/wp-content/themes/shopkeeper-child/functions.php on line 95
[06-Aug-2021 15:15:03 UTC] PHP Warning: Use of undefined constant ‘wp_enqueue_scripts’ - assumed '‘wp_enqueue_scripts’' (this will throw an Error in a future version of PHP) in /home2/fieitoco/public_html/fieito.com/wp-content/themes/shopkeeper-child/functions.php on line 107
[06-Aug-2021 15:15:03 UTC] PHP Warning: Use of undefined constant ‘we_carga_contactform7’ - assumed '‘we_carga_contactform7’' (this will throw an Error in a future version of PHP) in /home2/fieitoco/public_html/fieito.com/wp-content/themes/shopkeeper-child/functions.php on line 107

...............................

Parece que están relacionadas con el código mencionado.

Me han comentado los compañeros de soporte que consulte esto en el foro para ver si alguien me puede ayudar.

Quedo pendiente.

Muchas gracias.

Un saludo.

Contenido solo visible a usuarios registrados


 
Respondido : 06/08/2021 4:05 pm
Tags del tema
Bruno
Respuestas: 6487
Illustrious Member Moderator
 

Que tal María,

Primero que nada vamos a validar el código de referencia

add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_load_css', '__return_false' );

function we_enqueue_scripts_cf7(){
if ( is_page('contacto, partners') ){
if ( function_exists( 'wpcf7_enqueue_scripts' ) ) wpcf7_enqueue_scripts();
if ( function_exists( 'wpcf7_enqueue_styles' ) ) wpcf7_enqueue_styles();
}
}

add_action( 'wp_enqueue_scripts', 'we_enqueue_scripts_cf7' );

Si el problema persiste puedes retirar el codigo y validar si es el causante de los errores, para mayor informacion puedes consultar el siguiente articulo https://www.webempresa.com/blog/evitar-carga-contact-form-7-en-todas-las-paginas.html

Saludos!


 
Respondido : 06/08/2021 4:18 pm
Respuestas: 59
Trusted Member
Topic starter
 

Hola Bruno,

Muchas gracias por tu respuesta.

He probado con el código que me facilitas y las advertencias han desaparecido.

Mil gracias.

Un saludo.


 
Respondido : 07/08/2021 10:12 am