Closed NeaMitika closed 3 years ago
I have found the error while i was watching a video on YT,
Using the VS Code plugin "Wordpress Snippets" when i was tipying wp_add_dashboard_widget
it gave me all the attributes that must go inside.
For Example:
wp_add_dashboard_widget( $widget_id:string, $widget_name:string, $callback:callable, $control_callback:callable|null, $callback_args:array|null )
What i was doing wrong in the main code was the "$callback:callable" that must be an array not a string.
The correct code is this one:
wp_add_dashboard_widget(
'wp-dashboard-luciano', // Widget ID
'La Mia Dashboard', //Widget Name
array (
$this,
'wporg_dashboard_widget_render' // The callback functions to display text
),
);
Hello,
First of all thank you for creating this boilerplate it helps a lot by having a headstart in developing a plugin.
I am kinda noob so be patient, I want to create a new dashboard widget and i have added the following code:
to admin/class-plugin-name-admin.php
and to includes/class-plugin-name.php inside
private function define_admin_hooks()
$this->loader->add_action( 'wp_dashboard_setup', $plugin_admin, 'wporg_add_dashboard_widgets' );
The widget itself is visible inside the Dashboard but there is no content inside, its white. So i have activated debugmode and i get this error
Warning: call_user_func() expects parameter 1 to be a valid callback, function 'wporg_dashboard_widget_render' not found or invalid function name in /home/manoliui/wordpress.manoliu.it/wp-admin/includes/template.php on line 1389