On this line:
add_action('admin_menu', array($this, 'create_menu_item'));
You are correctly passing the create_menu_item
method of the current class to callback argument of the add_action()
function. You just need to apply the same principle for the callbacks in the add_menu_page()
function:
add_menu_page(
$value->post_title,
$value->post_title,
'manage_options',
$value->post_name.'-admin-page.php',
array( $this, 'create_admin_page' ), // <-- Here
'dashicons-location-alt',
6
);
This will apply to any WordPress function that has a ‘callback’ as a parameter. You can read more about callbacks in PHP here.
Related Posts:
- add_action in namespace not working
- Does an activated plugin automatically mean its methods are available to other WP functions?
- Best way to extends core classes in theme?
- OOP Plugin Development. Including external object
- WP Plugin + OOP: Adding Menu Page doesn’t create required effect
- Initiate only latest version of a class
- How to do conditional publishing?
- Extend a class of a plugin
- Shortcode Inside Class Not Working
- How to get media objects
- Use object in template part
- database interactions using OOP
- Customizer – Prefix Class Extension
- Extending the WP_Widget_Text class
- Trying to get property of non-object “ wordpress ”
- How to prevent XSS alter custom global javascript object & methods in WordPress
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- Undefined method class::construct() when creating a plugin
- How can I access string value in an array?
- Need oop for wordpress theme? [duplicate]
- Usage of call back function of add_meta_box()
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- Cant register rest routs from class instance
- Check class_exists before class definition / Doxygen problem
- PHP Helper Class to create shortcodes
- Class property seems to lose scope, attached to save_post action?
- Get options from database using php class
- OOP PHP class extends TwentyTwenty_Customize in Child Theme
- add_action in namespace not working
- Call to “admin_notices” hook from a static method
- Use PHP Class in WordPress functions
- can I extend the WP_Query class to deal with ‘duplicate’ posts created by joining to wp_posts?
- Access variable from another class that was passed in constructor
- How to add typehints to function in functions.php when argument is an object?
- Proper use of Output Buffer for a whole php clas
- PHP calling function within a class
- What is wrong with assigning values to a WP_List_Table class?
- calling a function from a class in your template
- Property value of null when value is assigned inside a method hooked to the wp action hook
- How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?
- Issues separating my Plugin pages into different files
- $_html is empty when var dumped
- How to deprecate a function used in a plugin?
- Adding custom input for data attribute in insert media modal
- Make Google index the entire post if it is separated into several pages
- How to use wp_localize_script in a WordPress page other than functions.php?
- Check if widget has content
- Displaying post per day
- Php string not working in WordPress Functions.php [duplicate]
- Why isn’t my if/elseif/else working correctly here?
- Why is PHP Cookie via plugin only set when logged in as Admin and not regular users? and other questions
- Insert After Second Paragraph Without Tag?
- the_author() not working outside the loop
- Ajax $wpdb not returning table data
- woocommerce subscriptions – get expiration date [closed]
- Best practice for migration friendly images in posts/pages?
- Using WordPress gettext functions in a library outside plugin or theme scope
- mysql query from wordpress page using custom table
- How can I randomize a Nextgen Gallery Slideshow [closed]
- Where to put snarfer.php?
- wp search-replace on database returns PHP fatal error: Array and string offset access syntax with curly braces is no longer supported
- Best way to add more options to Gutenberg “More Rich” text controls drop down
- Connect WordPress with SharePoint [closed]
- Unique icons next to each WordPress menu item
- WooCommerce custom product dimensions
- How to edit php files in Child Theme?
- $Wpdb post meta query is not working with mutliple meta keys and values? [closed]
- Display an image if odd number of posts in grid
- Custom ajax call returns 0 [duplicate]
- How to use wordpress function wp_enqueue_script() in php?
- Create a package of products as one Item in woocommerce?
- How to set cookies
- Add a custom class to the body tag using custom fields
- how to edit a specific post slug using a php code?
- Display the video of a post_format Video
- Manually Create PHP Page For A Redirect
- Get All In One SEO Pack to use custom field instead of Content
- Display multi-select box choices in a bullet list [closed]
- Calling code from another plugin to custom profile field
- couldnt show short code atts in category
- “WARNING: Found @$ in the file __ Possible error suppression is being used
- Changing ALT-tag for logo in wordpress
- str_replace remove words from title
- Create form which redirects to site in network?
- Custom Plugin Develoment, Form Action
- Where is this admin page loaded from?
- Query category-specific, paginated posts and allow viewer to change sort order
- Changing 2011 theme header image based on user dropdown
- Add Column to Term Database
- Hide a nav menu item based on get_user_meta results
- How to change a specific character in a theme option value – replace a space with a plus sign
- Cookie not created in AJAX request
- on category page get name of category as a string
- WordPress categories not working throughout site
- Using PHP for background-image property [closed]
- Where is the POST response body generated in PHP? [closed]
- 404 after removing “category” base in wordpress
- Is there a way to get wp_editor (tinymce) content?
- How do you create a front end form that enables the editing of member-specific custom fields in WordPress?
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false