The problem is that you’re trying to callback the process_action_heb
method from $this
(aka class A) and it’s not a method of the A class – it’s a method of B.
I’d use dependency injection to solve this, though you could use a method like you’re using.
//* plugin.php
include_once PATH_TO . '/classA.php';
include_once PATH_TO . '/classB.php';
$classB = new classB();
$classA = new classA( $classB );
add_action( 'hookA', [ $classA, 'some_method' ], 20 );
//* class-a.php
class A {
protected $classB;
public function __construct( $classB ) {
$this->classB = $classB;
}
public function some_method() {
//* Do something
//* And add action to classB::some_method
add_action( 'hookB', [ $this->classB, 'some_method' ] );
}
}
//* class-b.php
class B {
public function some_method() {
//* This code will run on the hookB hook
}
}
Related Posts:
- Difference between add_filter and apply_filters
- Is it possible to define a template for a custom post type within a plugin independent of the active theme?
- Loading external page template and enqueue script from plugin causes 403 forbidden error
- How can I mass-update/save all WordPress posts and pages?
- Create plugin with 3rd party MIT license code
- Notice: wp_get_http is deprecated since version 4.4.0!
- How to check plugins for malicious code?
- How to properly secure my WordPress installation?
- How to add usermeta to “Notice of Email Change” email message
- How to create a Page alias in WordPress
- Is it necessary to translate WordPress key terms when localizing a plugin
- Remove from Google Tags with less than 2 posts
- Adding dynamic section to WordPress
- woocommerce product attributes
- Add Fields with Sub-Fields to WP Job Manager
- How to edit/delete single row items in a table on my own menu page
- WordPress login with Phone Number [closed]
- Disable wp_enqueue_styles action for specific page
- How to create custom embed block in gutenberg wordpress
- How to add css class to a specific set of images?
- Getting RGBA colour from gutenberg colourpicker
- WooCommerce E-Check payment gateway disappeared when site switched to multi-site
- Disable multisite-wide plugins on specific sites
- Facebook plugin shows existing comments
- How to trigger $_GET request within admin plugin page?
- Wp favorite posts get user favorites in profile using buddypress [closed]
- How to configure two SMTP Server for wordpress
- Preferred way of cacheing a value in php
- Internationalization autocomplete JS variable
- Override global query results without hooks
- Rotating background images with admin options
- Howto accurately position images with maximum flexibility?
- Using a post-signup hook to get user details
- How to merge two .PO language files?
- wp_remote_get() returns 403 while file_get_contents() does not
- How to set add question capability for author role in wp pro quiz plugin
- Which widget to use for display category post with view more? [closed]
- AFNetworking incorrectly interpreted WP_Error
- polylang + category/tag custom language link
- Unable to delete custom post types, confusion around capabilities
- How to create multiple database tables on plugin activation?
- What’s causing this error? “Warning: Invalid argument”
- Is it possible to remove subscription box from Jetpack stats page? [closed]
- How to create a post with next buttons
- How to display terms and conditions in post area?
- How to notify wordpress instalation about my plugin update?
- Moving FB comments at the end of page
- Mutliple users editing single document in wordspress
- Plugin: connect to external database without showing password
- wp_insert_post() inside save_post(): force WP to not update global post object?
- WordPress truncate posts question (plugin related)
- Microsoft Word documents to WordPress pages adding paragraph tags
- Filtered content appears in the excerpt
- My plugin does not install correctly if a previous version is still installed
- How to disable Wp-PageNavi at the top of the page
- Why aren’t my Follow Me links working?
- WordPress ping spam issue with Ping services?
- 404 errors when updating options in admin dashboard
- Hook from plugin doesn’t fire up from external PHP script
- Custom User Registration Form not showing
- Drag and drop widget always inserts image
- Slideout submenu in mobile
- What database state changes happen after a post is manually “updated” with no changes?
- Display posts by alphabetical order
- wp_insert_post not inserting post from XML
- Admin Custom Plugin List Files in admin Table
- custom fields not displaying on wordpress site
- Overriding a function in a WordPress plugin
- after logout session not destroy from server/website side
- Website always load twice on start
- How to update a database entry with a wordpress plugin?
- Change Woo Custom Endpoint Titles from a Plugin
- Is there a way to display multiple authors on a post?
- custom sidebar plugin issue
- White blank screen while adding or editing pages in wordpress
- How can I store user preferences in WordPress and retreive them later?
- Plugin debugging with errors in activation routine
- one admin for 2 wordpress websites
- DB Sync Media Files extension [closed]
- Disqus comment system – change comments number before “load more” button
- What Are the Advantages of Using an mu-plugin
- Disable default posts (Posts,Pages,Comments and Media) in wp-admin
- W3 Total Cache Can’t Really Detect Things
- Is it right way to create shortcode?
- Storing values in Post Meta vs new tables
- Determine if get_the_image has image on Get the image Plugin
- How to show author’s avatar in the post meta data with plugin `user-avatar`
- Translate Woosidebars plugin strings
- How to add different CSS for galleries
- How do I add php to all links automatically?
- Why my site loads too Slow? [closed]
- Plugin Links to page not working
- How should I force WordPress to give proper name for the uploading images?
- plugin how to find code and edit it in a template file?
- how do I solve Installation failed: There has been a critical error on your website
- WooCommerce product prices not showing up correctly [closed]
- Allow manage_options capability for specific user only for specific plugin?
- I want to allow certain file types on dokan upload files
- How to create different woocommerce single_product.php pages for each product? [closed]
- ShipHub for WordPress