It’s not possible to call a private method through an action or filter. When calling add_action
or add_filter
, WordPress adds the callback to a list of callbacks for that specific action or filter. Then, when do_action
or apply_filters
is called, WordPress uses call_user_func_array
to call the linked functions and methods. As call_user_func_array
is not called from within the class, it can’t call private methods of that class.
Furthermore, there’s no proper way to really keep the method private, even though you could add a separate (public) method to your class, add that as a callback to the action, and have that call the private method. In doing that, however, you lose the real concept of the method being private.
Related Posts:
- remove_action on after_setup_theme not working from child theme
- Remove Actions/Filters added via Anonymous Functions
- Trying to use add_action and do_action with parameters
- Check if post is being published for the first time, or is an already published post being updated
- How to use the do_action () with parameter
- Perform an action when post is updated/published
- WordPress Theme Update Action?
- Extract image from content and set it as the featured image
- Do WordPress’ cron’s clean up expired transients?
- add_action in a function, is it possible?
- Refresh page after form action
- How to restrict actions and filters “properly” by conditions
- How to count number of functions attached to an action hook?
- Add action hook conditionally – only when home.php in use
- Using add_filter() in Widgets
- How can I tell if I’m on a login page? [duplicate]
- Attach a private function at a hook?
- Change meta tags programatically
- Convert hyphen to underscore in permalinks
- Using get_terms for custom taxonomy in functions.php
- Fatal error: Call to undefined function add_action() – an untouched problem
- How to hook into the quick edit action?
- Reuse variable in hook callback
- display public excerpt for private post
- Call to undefined add_action() in theme’s functions.php
- WooCommerce add_action hook results in 500 error
- Automatically Add Specified Value to Attachment Metadata upon Upload
- Can’t Update function.php after writing short code
- How to update feed only 2-3 times a week (for Feedburner email)?
- How would go about if I just want a temporary function?
- Passing arguments to my function with do_action and add_action is not working
- Pass parameters to function through an action
- Accepted arguments value in hook functions
- How to select a page within admin?
- How to manage arrays from custom functions stored in functions.php?
- How do I pass arguments for multiple functions hooked to a single action?
- Which action hook to use for function?
- Custom HTML in specific category single page and its descendant categories
- Modify a function without editing template
- Don’t delete a page if it holds users
- How do I add Bootstrap and LESS to my migrated WordPress site?
- Which action does wp_update_user triggers?
- How can I get my Script to work on the Login page?
- Trigger a custom function when option are saved in admin area
- Using shortcode content with nested shortcode
- Is there an alternative to get_template_directory_uri()?
- Reuse variable in hook callback
- Wait a result before enqueue
- Redirect to another page if the user is logged in when pressing again the login button on menu bar
- Multiple Loops Meta Data
- Allowing users to view private posts (pending approval)
- Function added using `add_action()` not being called
- Difference b/w Simple function call & do_action call
- jQuery does not work
- Override the WordPress core function wp_referer_field
- How to return hook data when multiple parameters are present?
- Set Taxonomy based on post status
- Two functions with different arguments and add_actions, but identical code
- add_action template_redirect not working for home page
- I can’t seem to install Font Awesome locally [closed]
- AMP – Change rel=”canonical” from functions.php [closed]
- Scripts not loading when using the wp_enqueue_scripts action
- Is there a way to prevent a function/method from being called outside a specific hook?
- Auto-Tweet if Type is ‘Status’ using OAuth
- Missing argument for the function
- problem loading stylesheets to wp_head dynamically
- current_user_can comma list vs OR (||) list
- Adding code before post title with the_title produces weird results
- Add back in child theme what the parent theme removed with remove_action
- How to show only specific category post by user role without plugin and restrict all other cats
- Postback redirect through add_action is not triggered
- Warning and fatal error
- use add_action in a shortcode (gravity form – WordPress)
- wp_footer hook causing text to show on bottom of page
- Remove action hook from Class, understanding OOP
- How to change form action of wp-login page with a function
- Which method is more correct for removing WooCommerce Extensions menu item?
- WordPress hooks to call a function inside a construct
- True parameter but jquery register in header and not in the footer with wp_register_script
- Fatal error: Call to undefined function add_action() – an untouched problem
- Sending Messages Back to the Template After Processing?
- Pass arguments to function class with do_action()
- previous_post_link inside of a function?
- custom COOKIE on custom page
- What add_action reference should I be using or should I use do_action?
- Getting error while trying to use custom comment function
- Settings in functions.php used by a plugin
- function to return comma separated list of meta values
- Do something when user creates post (that’s pending)
- add variable to actions/functions across different files (woocommerce)
- HELP: Code To Check Status And Write Debug Entry
- delete_term is not working properly with add_action()
- How to get variable from other function inside class function using add_action for Ajax call
- Simple way to make most of my site private
- Function attached to cron job not running but will run if called manually
- Submit CF7 form programmatically with WP-Cron?
- disable a specefic sidebar when user is log out
- wp_update_post breaks my function
- is there a list of actions on WordPress
- Remove Actions/Filters added via Anonymous Functions