WordPress custom plugin gives error

It seems that your function wstock_variation not exists or is created in PHP file not include in your plugin… If you are using OOP, for example your code need to be like: add_submenu_page( ‘Elites-StockManager’, ‘Smart Stock Manager’, ‘export’, ‘administrator’, ‘wstock_variation’, array($this, ‘wstock_variation’) ); // remove number 8, method accept only 6 params $this is method … Read more

Finding the screen id of a page generated with add_menu_page

The function add_menu_page return the hook suffix that inform you about the current page. A simple example to get the hook suffix. public function add_menu_page() { $page_hook_suffix = add_menu_page( esc_html__( ‘Admin Page’, ‘translation-slug’ ), esc_html__( ‘Admin Page’, ‘translation-slug’ ), ‘read’, ‘My Name’, array( $this, ‘get_styles’ ) ); add_action( ‘admin_print_scripts-‘ . $page_hook_suffix, array( $this, ‘enqueue_assets’ ) … Read more

How is a widget supposed to reference what is added to custom submenu or addmenu fields?

The setting API, which its usage is being demonstrated in that code is meant to be use as a framework to create settings pages which result in update of values in options. Widget settings are is a somewhat more abstract level. They are stored in options, but there is no flexibility how they are stored, … Read more

add_menu_page include a php page from theme directory

The error tells you what the problem is… PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function … Your “callback” isn’t a function. It is a file. It doesn’t work that way. You will need a helper function to include a file. Something like: add_menu_page( ‘Private Messages’, ‘Private Messages’, ‘manage_options’, ‘message_admin’, ‘include_message_admin’, … Read more

Custom plugin settings link doesn’t append current class to menu item when visited? Why?

I noticed your apwb_settings_page() function is adding the “Postal Pricing Settings” submenu using add_options_page(), and the documentation stated that: (bold formatting added by me) This function is a simple wrapper for a call to add_submenu_page(), passing the received arguments and specifying ‘options-general.php‘ as the $parent_slug argument. This means the new options page will be added … Read more