Take a look into this example:
add_filter('some_hook', $callback = function( $arg ) use ( $values ){
//Some calculation here
});
You can set arguments this way, and also use the predefined variables that exist outside the functions scope, by using the use()
term.
This way, you can unhook the function wherever you want, by doing this:
remove_filter('some_hook', $callback);
Related Posts:
- Where is the best place to use add_filter
- When can you get current page ID and initialize hooks right after?
- Using the ‘draft_to_publish’ hook (post status transition)
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- How can I limit functionality in one version of a plugin?
- Shortcode display outside the div
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- Can a plugin add to header/footer/body content?
- Is it possible to add an action to the currently running action?
- How to bulk send emails
- Action on post publish
- How to add inline css/js inside a shortcode
- How to call bind function in wordpress actions or hooks
- How to prevent action in ajax request, when in admin side?
- template_redirect not being called when using ajax
- WordPress plugin for mail subscriptions [closed]
- action-scheduler vs wp-background-processing
- add action wp_head not working
- What are the benefit in adding hook in the init() hook?
- add_action in functions.php, do_action in plugin?
- Check if email address exists front end with AJAX in a plugin
- add action for displaying posts using a shortcode
- ‘wp_login’ action hook not working with wp-login.php file
- Any hook for pre-plugin-update -either bulk or single plugin update
- wordpress plugin is not activating from widget
- When to load auto-login code?
- How to get all of the activate_plugin action parameters?
- How to check current user before all actions and filters?
- Get Time Taken By Each Action Hook in WordPress
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Custom plugin init action causing general slowness
- Inject HTML meta tag inside wordpress tag using add_shortcode
- Add action to fire when a published post is updated
- Submit Form data to another page via Ajax (WordPress Way)
- Does using `add_action( ‘init’…` cause performance issues?
- Hook for page Request?
- SMTP Error: Could not authenticate [closed]
- sending different email notification while registration based on user role
- Custom CSS not being added by plugin
- How to use add_action for multiple instances of the same class
- How to append new form elements in “Add New” form of Users in WordPress admin panel?
- I cannot include a file in my plugin settings page
- Why do actions with class and public method don’t fire __construct()
- The function called on the wp head hook becomes null
- I want to schedule email (date, time is in database->table) wp_schedule_event() not working
- Nested Actions and Filters
- Passing function into add_action always returns the first argument
- Get post content inside plugin class method
- Remove action added in plugin class from theme
- echo plugin results on pages
- Form tries to download a file on submit
- How to customize ‘recurrance’ of’ wp_schedule_event’?
- Plugin Hook: Get posts
- Is it possible to cancel a post status transition?
- How wordpress plugin hooks works? [duplicate]
- Send email notification when meet the condition
- WordPress isn’t sending welcome email with the password reset
- How can I find plugins’ slug?
- My custom made plugin has “a new version available” which links to unrelated plugin
- wp.media update options and force render on uploader
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- WordPress Plugin Development from Scratch. How? [closed]
- How to fetch serialized data from wordpress options
- Passing URL parameters to WordPress pages and pretty url
- WordPress network: set themes and plugins for new blog
- How to get the custom page get_permalink?
- Plugin translations problem
- Use external link in the add sub menu
- Advanced Custom Fields into functions.php
- How ( and mostly at what time ) can i prevent the alternate cron from running?
- WordPress register_activation_hook table creation not working
- nonces in custom oop plugin
- Wp die causing 500 Internal Server Error?
- Redirect to a welcome page after updating plugin
- link bbpress forum discussion to blogposts
- CampaignMonitor for WooCommerce – Move subscribe button [closed]
- How to inform the user that the save was not successful?
- php page not found for plugin options menu
- Class variables not correct on page
- Is it possible to send blog posts via email to subscribers?
- My custom plugin did not create db tables in database
- What is the WordPress approach to custom data?
- WordPress Fatal Errors [closed]
- Possible?? Pull Plugin Property Data to a Theme’s Custom Post Type
- How to rewrite URL and get the values?
- Disable plugin visibility at the plugin directory
- Plugin is creating posts twice
- How to overwrite the category template in a plugin
- Fixed: Console.log twice in the edit function
- show wc_add notices on particular page in woo commerce custom plugin development
- admin-ajax.php returning 0
- Why my multisite is this slow? (stats inside)
- How to use custom footer template in a site-plugin?
- trying to create simple plugin to filter categories from all authors
- Proper Failure of Plugin Activation
- How can I add the custom taxonomy categories to the posts and pages?
- How to create a page template using custom plugin
- WordPress 3,5 and Jquery version
- WooCommerce Order Status Displays Twice on Order Page
- WP can’t send newsletters