Menu e pagina Uncaught TypeError: call_user_func_array()
-
Sto iniziando ha creare un plugin iniziando con il menu in admin
<?php
namespace ex;
require_once EX_PLUGIN_PATH.'/include/class-info.php';
class Starter_plugin{
private $versione;
private $prefix;
function __construct()
{
$this->versione=Info::VERSIONE;
$this->prefix=Info::PREFIX;
//inserire gli hook
add_action('admin_menu', array($this, 'ex_menu'));
}
public function ex_menu (){
global $dati_menu, $submenu;
//dashicon
// add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $icon_url = '', $position = null )
$dati_menu =array(
'menu_title' => 'Exalunni-mt', //obligatorio
'page_title' => 'Exalunni.php',//obbigatorio
'capability' => 'manage_options', //obbligatorio e specifico non personalizato
'menu_slug' => 'ex',
'callback'=>'all_ex',
'icon_url'=>'dashicons-database',
'position'=>25
);
add_menu_page(
$dati_menu['page_title'], $dati_menu['menu_title'], $dati_menu['capability'],
$dati_menu['menu_slug'], $dati_menu['callback'],
$dati_menu['icon_url'], $dati_menu['position']
);
//add_submenu_page( string $parent_slug, string $page_title, string $menu_title, string $capability, string $menu_slug, callable $callback = ”, int|float $position = null ): string|false
add_submenu_page(
$parent_slug = 'ex',
$page_title = 'Exalunni',
$menu_title = 'ex1',
$capability = 'read',
$menu_slug = 'ex', //per rinominare la prima voce stesso slug del menu_page
$function = 'all_ex',
$position = 0
);
add_submenu_page(
$parent_slug = 'ex',
$page_title = 'ex',
$menu_title = 'ex2',
$capability = 'read',
$menu_slug = 'impostazioni-del-tema',
$function = 'ekw_settings1',
$position = 1
);
}
public function all_ex()
{
echo 'ex';
}
}
?>Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function "all_ex" not found or invalid function name in /var/www/html/wordpress/wp-includes/class-wp-hook.php:324 Stack trace: #0 /var/www/html/wordpress/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #1 /var/www/html/wordpress/wp-includes/plugin.php(517): WP_Hook->do_action() #2 /var/www/html/wordpress/wp-admin/admin.php(259): do_action() #3 {main} thrown in /var/www/html/wordpress/wp-includes/class-wp-hook.php on line 324
Stai visualizzando 1 risposte (di 1 totali)
Stai visualizzando 1 risposte (di 1 totali)
- Devi essere collegato per rispondere a questo topic.