The function needs to be public, but it can also be static.
For example, from the Akismet plugin:
In the plugin file:
register_activation_hook( __FILE__, array( 'Akismet', 'plugin_activation' ) );
In the Akismet class file:
public static function plugin_activation() {
...
}
Related Posts:
- Why do some hooks not work inside class context?
- __NAMESPACE__ with register_activation_hook
- Wp_update_post: Infinite loop even with remove_action solution, OOP
- Hooks are not executing
- Create hooks based on an array of hook names?
- How to properly setup an activation hook
- admin_notices action doesn’t trigger within save_post action
- Object oriented programming, add_action in constructor not firing
- How to know what functions are hooked to an action/filter?
- How do I implement the WordPress Iris picker into my plugin on the front-end?
- What is “all” in isset($wp_filter[‘all’])
- Please explain how these hooks work
- Hook ‘wp_enqueue_scripts’ priority has no effect
- Hook *after* user password change?
- Does anyone have a visual breakdown of core hooks and when they are fired?
- The ‘user_has_cap’ hook seems to take two page loads to trigger
- WordPress Admin Tooltip hooks
- RSS Feed Custom Title?
- Detect type of post status transition
- hook for lostpassword form
- How and why can a hook call itself without causing recursion?
- Is This A Correct Example Usage Of current_filter()?
- Seeking Hook Whenever a Custom Taxonomy Term Has Been Added
- How can i trigger an action manually?
- Can I trigger the publish_post hook by using wp_insert_post?
- WooCommerce New customer email Hook? [closed]
- admin_notices not working in post editor
- How to detect when a user changes their name?
- How to check what kind of saving it is?
- Override wp_delete_post and move to trash instead for custom post type
- How do I grab specific posts (by post id) and display the title, featured image, and excerpt?
- Hook all http requests
- Setting Cookie with init hook causes ‘header already sent’
- How To Make Sure That My Action Hook Executes Last
- Does update_comment_meta hook exists?
- how to determine how many and what kind of arguments are passed to hooks
- Can not set custom title on some WordPress setups
- BuddyPress User Profile Menu
- Checking post format during xmlrpc_publish_post
- Hook for when a page template is changed
- Append a code when at the current page in wp_list_pages()
- Footer.php being inserted before article closing tag?
- Get all posts with a duplicate name
- Save acf field data via acf/save_post before post is saved
- Above-the-fold inline styles from SASS generated stylesheet
- Redirect in form handler causing form to be submitted twice
- Checking login status before wp_get_current_user is initialised
- Add media library tab
- Conditional hook [closed]
- Add_menu_page() error message -> “You do not have sufficient permissions to access this page”
- Where is the right place to register/enqueue scripts & styles
- Displaying list of cities according to the selected state. Using the WordPress hook
- Removing parent theme action on pluggable function not working
- Removing a Filter
- Which action hook should I use to intercept a form upon submission?
- Would there be anything stopping me from removing both wp_head and wp_footer?
- Where Are Hooks?
- WordPress wp_loaded action hook
- Check if `do_action()` in WordPress returns any result
- Combining several CSS files into one for optimization
- How to cancel an action hooked to untrash_post? or any hook
- add_action hook for publish_post not working
- How to perform action when plugin/theme editor is used?
- How to run hooks one by one manually?
- What is the proper hook to use for recording a post view?
- How to load this code on function.php
- Where is publish_post hook fired?
- A good hook to check authorization and redirect?
- Bloginfo hook – can it be more precise?
- Custom posts and get_post_meta in {$post_status}_{$post_type}
- Hooking custom PHP output into WP: how to do it, parse_request almost works but not quite
- Print on screen during shutdown hook – error during saving in theme-editor.php
- How to stop execution of a function via add_action hook?
- changing genesis_before_while in new theme framework
- Moving Javascript from footer to header
- Adding a new hidden field based on a condition in Ninja Forms
- Forcing WooCommerce customers to create account before checking out
- Store user ID on wp_term_taxonomy when new term inserted
- Make multiple URLs behave as home page
- Transition_Post_Status hook not working properly
- Wodpress XML Import hooks
- Does &$this is really disallowed to use anywhere?
- How to get user profile information before update?
- Why is pre_get_posts hook invoked multiple times?
- Undefined fieldId in gform.addFilter for limiting dates in datepicker – Gravity Forms
- Get First Post content and edit it using pre_get_posts (or similar?!)
- Are there Hooks for featured image popup?
- WordPress sending data with add_action
- How to hide / remove attachment “alt” or “caption” field in Admin?
- Why does get_post() not return anything?
- Hourly events don’t get triggered
- WordPress save_post hook not firing when checking if _GET[‘post’] is set
- Access post meta just after publishing
- Which hook runs first(init,… or ???) [duplicate]
- Which hook should I use for this scenario regarding the registration process and account/profile update?
- Redirect back to origin page after using get_delete_post_link()
- Is there any Reference of WordPress hook and hacks? [closed]
- Thesis Theme -> hooks not working for custom function
- Can I display text that’s generated by a hook in another place in the HTML?
- Get post ID before add_theme_support