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
- Is there a way to use the WordPress users but without loading the entire WordPress core?
- How to make a image-size selected by default in Media upload – WP v3.5
- How to stop jQuery.migrate manually
- Hide main div if wp_nav_menu is empty
- Custom HTML structure in wp_list_categories
- 500 Internal server error after changing php version
- show limited tags in an article
- WordPress media upload “HTTP error”
- Theme Customizer – Dynamic CSS PHP File
- Javascript code inside “” in core WordPress files .php
- Exclude posts from homepage having a specified tag
- woocommerce – hide payment method in new order email
- Do my defines need to be unique?
- Change output based on text field value
- Function not working at one place
- How can I load a PHP page without using a Template?
- Where to place PHP code that inserts (or doesn’t insert) menu item?
- Where to find documentation for CPT block template? (PHP)
- Sort the result of the main Query in shop page by a custom taxonomy
- WP Post-Thumbnail
- Responsive Header for Phone
- Programmatic Login from 3rd Party site
- Media upload ERROR Message Showing in BOTTOM of the page wordpress
- Setting default category base on theme activation
- parts of url disappear when using # inside href=”” [closed]
- Help with Sub and Sub-Sub Navigation
- WordPress Woocommerce – Product Type [closed]
- WordPress installation permission errors
- Non-Closing PHP Query in WordPress Loop
- Display Youtube Time Automate from Key
- What is the best way to define constant options for a theme?
- An audio player that showcase a random song from playlist every 24h [closed]
- extract serialized array to use for wp-query
- PHP Contact form
- How to use `wp_insert_post()` and `get_permalink()` functions?
- Image Attachments of an Array into Flexslider
- get_template_part function and add images
- Need advice on theme customizer and child themes
- How to make sure relative URL works when site is not on root domain?
- xmlrpc how to check for errors
- How to hide a child category and show his parent category
- How to change PHP variables with AJAX request in WordPress
- If Statement is Ignored?
- Trying to get property ‘ID’ and ‘post_author’ of non-object error
- Split post or page content in two or more columns
- Allow specific user to edit a specific page
- Prepared DB Query from _POST array
- How to include non-users in wp-admin redirect?
- How do I routinely extract the thumbnail of the most recent post?
- Click to expand menu
- WP_Post is not from correct array
- Showing custom field contents without listing description
- If I define a variable in header.php, how do I make it available to templates?
- Find owner of coupon
- WordPress wp_remote_request() – How to do async await in wordpress php?
- How Create Automatically Image jpg.webp from image .jpg without delete or change original images upload
- Hot to show custom post type taxonomies on archive page
- wordpress-plugin (widget) that performs a Neaby-search on the openstreetmap-endpoint: around x find y