logo-antonella-framework-blancologo-antonella-framework-blanco
  • Documentation
  • Support
  • Repositorie
  • Videos
  • Language: English
    • Español Español
    • English English
logo-antonella-framework-blanco
logo-antonella-framework-blanco

Problema al cargar una funcion con add_action init

Home Preguntas Problema al cargar una funcion con add_action init
Soporte › Categoría: Questions › Problema al cargar una funcion con add_action init
0 Votar Buena Votar Mala
Yrlen Perez ha preguntado hace 3 years

Buen día, cree una función en un controlador y quiero llamarla en el add_action pero reviso el siguiente error cuando instalo el plugin:

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method TG\RemoveController::remove_post_type_support() should not be called statically in /srv/www/gallery/public_html/wp-includes/class-wp-hook.php on line 284

El objetivo de la función es es remover el editor del post type previamente creado.

Mi código del config.php:

public $add_action=[
[‘init’,’TG\RemoveController::remove_post_type_support’],
];

 
El código del controlador:
 

<?php
namespace TG;
 
class RemoveController
{
 
public function__construct()
{
 
}
public function remove_post_type_support() {
remove_post_type_support( ‘post’, ‘editor’ );
}
}

 

Agradecería cualquier ayuda y de antemano gracias.

Etiquetas de la pregunta: Error al cargar una función con add_action init
1 respuestas
1 Votar Buena Votar Mala
Carlos Herrera Staff ha respondido hace 3 years

en ves de

public function remove_post_type_support()

Usa

public static function remove_post_type_support()

Ya que lo estas llamando de forma estática debes crear la función estática. esto es para las versiones de php 7.2 en adelante.
Si quieres que sea dinámica entonces en config deberías llamarla así

public $add_action=[
['init',['TG\RemoveController','remove_post_type_support’],10,2],
];

Saludos!!

Tu respuesta

Powered by Carlos Herrera

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.