Your problem is pretty simple. Your callback for this hook is not a simple function but some method of a class.
If you add action like this:
add_action('admin_notices', 'simple_notice');
you tell WP that there is some simple function called simple_notice and it should be called when hook admin_notices is processed. But… There is no such function anywhere in your code.
The function you want to call is method in your class, so you have to pass not only the name of function, but also object of given class, so WP is able to call this method. (And you’ve done it correctly in __construct).
This line works
add_action('admin_notices', array($this, 'simple_notice')); // This works
because the method is passed with full details – as an array describing object and it’s method to call.
Related Posts:
- ‘wp_login’ action hook not working with wp-login.php file
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- How can I edit post data before it is saved?
- How can I see all the actions attached to an “add_action” hook?
- How to only hook on Single.php after content?
- How to stop showing admin notice after close button has been clicked
- When can you get current page ID and initialize hooks right after?
- How can I log a user out of WordPress before the page loads?
- What is the ‘admin_action_’ . $_REQUEST[‘action’] hook used for?
- Using the ‘draft_to_publish’ hook (post status transition)
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- Use external link in the add sub menu
- do_action and hook methods
- Is it possible to add an action to the currently running action?
- How to filter content post only on save
- Filter or action hook to insert content on admin pages before tag
- Is it possible to remove this action? (as it’s added just before it’s called)
- WordPress Plugin Boilerplate – add_action hook in static “activate” function
- How to prevent action in ajax request, when in admin side?
- template_redirect not being called when using ajax
- Can I use a method from an existing plugin as an action hook?
- Plugin custom Action Hook not working
- What are the benefit in adding hook in the init() hook?
- add_action in functions.php, do_action in plugin?
- add action for displaying posts using a shortcode
- Where to hook my plugin’s action
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- WordPress filter that hook after each action/filter hook
- Any hook for pre-plugin-update -either bulk or single plugin update
- Insert new user with form submit ‘init’ hook
- How to get all of the activate_plugin action parameters?
- Calling plugin function inside custom plugin for onclick event
- Get Time Taken By Each Action Hook in WordPress
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- How to get post ID with hooks publish_post, new_to_publish, etc
- edit_user_profile and show_user_profile are not firing inside a class
- Add sub menu page in your plugin
- the_post hook is not firing for me
- Why do plugins often ask to add in to templates?
- Create a post builder skin in a plugin
- remove_action not removing add_action from constructor
- Plugin Development – Functions or Hooks?
- How to get menu location in wp_update_nav_menu hook
- How do I add some javascript validation to the admin interface form’s onsubmit?
- How to create Admin Notice from Plugin with argument? [duplicate]
- Hook for page Request?
- Display Plugin Panels Outside of Admin Areas
- Are there action hooks for comments?
- WooCommerce: after install hook
- How to remove a class function from a plugin by using remove_action()?
- Advanced WordPress plugin activation detection
- Add action to custom Function
- What hook can I use to modify custom post data before it is displayed on the page?
- How to hook into action/filter call
- I cannot include a file in my plugin settings page
- Change Dashboard URL from wp-admin to wp-admin/index.php
- Hook from plugin doesn’t fire up from external PHP script
- update_option_{$option} not working (do function after options are saved)
- Callback hooked to post_updated firing on new posts as well
- The function called on the wp head hook becomes null
- Hooking into the HTML header container
- Use action, filter, or hook to append HTML to WordPress plugin function
- Passing function into add_action always returns the first argument
- {status}_{post_type} does not run correctly?
- wordpress plugin translation not working
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- wp_login_form() ignoring login_form action hook
- Passing a parameter to filter and action functions
- Run only on plug-in activation instead of wp_head
- Plugin Hook: Get posts
- change output location of plugin function using a custom hook
- Which filters or actions involve with index page for plugin?
- OOP Plugin: Where should I place the action hooks in the class?
- add query string to all pages after user logged in
- How wordpress plugin hooks works? [duplicate]
- Hook automatic_updates_complete to autoupdate plugin
- Remove 3rd party plugin notices from within own plugin
- Edit plugin without hooks in functions.php
- Shortcode display outside the div
- How to add rewrite rules and pagination to retrieve attachments files?
- AddFilter option_active_plugins is executed 6 times. Why?
- How can I create a plugin installation link?
- How to pull code snippet from functionality plugin?
- Plugin upload to install
- Change the backend language of a single plugin
- Locked out of admin panel after installing HC Custom WP-Admin URL [closed]
- wp_ajax action responds with 0
- Custom CSS not being added by plugin
- Quick press publish post hook
- Activation flow of a plugin in a multisite environment
- force logged in user to stay in the dashboard
- How can I disable W3 Total Cache Image Lazy Load for Specific Post Type?
- Ajax call to php function doesn’t work PHP code
- Frontend AJAX Request causes Error: ‘Call to undefined function add_action’
- AJAX login without a plugin does not work. when add a action to function.php
- Plugin constructor called multiple times
- How to change value of $menu_class in ep_nav_menu?
- Stop the user if login from the cookies