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
- $wpdb->insert writes a record twice for some reason, when my custom developed plugin calls my class function once
- Using OOP in WordPress Plugin Development
- How to update and save user metadata on page visits?
- Verify if a category is the child of another category
- How to remap one of the TinyMCE Advanced Editor button to open the wordpress media library?
- Simple AJAX notification when the new post is added to the database
- How to optimize update_post_meta?
- Warning: in_array() null given in PHP function
- Contact Form 7 – Replace database configured form template with a static file
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Why can’t I return a value from $wpdb->get var?
- How to get User Time Zone in WordPress?
- How to hook a logout funtion for specific usr role in wordpress?
- Redirection after submitting duplicate comment
- Convert code – not work
- Fix error Gravatar alt
- HTML Special Characters in URL string [closed]
- how to save checkbox data for custom setting?
- How to remove sidebar primary widget on Mobile on category page [closed]
- How to keep the capability of users and disable Gutenberg editor in WordPress?
- Upload multiple files in randomly generated folder using wp_upload_bits
- Is it possible to change content in my PHP file from WordPress dashboard
- ACF put a comma after the last repeater field value [closed]
- Create page template via functions.php?
- Loading two post layouts for the same post with different url
- Code snippet to show current php version inside “At a Glance” box in admin
- parsing nested blocks (in columns, etc) via PHP
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- getting url from variable that calls picture of current page, not working. Only displays everything instead of url
- How to upload WP user avatar on woocommerce account page [closed]
- Use post ID in functions.php file adminside
- How to show childs of certain custom post type in option list?
- Short code template + ajax
- str_replace with the_content is not working
- How do I populate custom field with current user role in Woocommerce [closed]
- WPML best page selector with php
- How to disable send e-mail notification new comments for some posts
- trying to put an active hover to my custom nav category buttons [closed]
- How to edit HTML of my website on WordPress? [closed]
- Redirect first comment (Thanks for comment) with show Autor name and beginning of the comment
- Large WordPress CRON job
- Fixing Deprecated: get_the_author_lastname
- WordPress query undefined offset in loop
- Referencing Images in javascript to display on wordpress page
- Most commented posts by time period (last 12h, last 24h and etc)
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- Divi change project category slug
- Add meta tags to a custom header
- Ajax filter button display all posts
- Check If Post Was Published More Than 6 Months Ago Using get_the_date
- Where are the src and srcset sizes coming from?
- What is the right way to add PHP code to a certain part of a page
- wp_remote_post empty $_POST
- register_setting & add_settings_error validation issues with multiple fields
- PHP code for displaying WordPress posts in a static page not working
- How to add PHP code in functions.php wordpress
- WordPress hit memory limit but not from the server
- How can I spin up a new website for a registered user automatically?