-
Because of backwards compatibility.
You can use the same callback for multiple filters. Inside of that callback you should use
current_filter()
to determine the context. But some plugins use the number of passed arguments instead. Changing that would break these plugins.That’s why you should always use the API (here:
current_filter()
) and not some made-up construct. -
Also, PHP will raise a warning when you pass more parameters to a native function than that function expects.
See Ticket #14671 Deprecate the “accepted args” argument in add_filter() and add_action()
Related Posts:
- How to use return in my custom function instead of echo
- add_action shortcut?
- Override a function defined in wp-includes/comment-template.php
- Is there a hook that I can use when a fatal error occurs?
- How to make a image-size selected by default in Media upload – WP v3.5
- Enforcing password complexity
- Apply class to every paragraph that holds image?
- Remove “Insert from URL” link in Media upload – WP 3.5
- static variable loop not working in WordPress
- adding a filter to a shortcode?
- Set media upload attachment link to none and hide it in WP v3.5
- How to set custom cookies before output
- Change the footer text on the login page
- add_filter to post-gallery and remove all ‘s?
- Can i check if user is doing any ajax request?
- How to overwrite youtube embed?
- Rewriting search and pagination base
- Check if page parent has certain template
- Change comments form title on a page by page basis
- Remove class that has been added by parent theme
- Hooking new functions to actions + passing parameters
- How do I know what variables are passed in a filter/action and what their meaning is?
- Find variables available at a given hook
- How to access function from outside of a class within this class in WP plugin?
- Run a filter when a walker runs
- Handling Body class based on Template
- Get_avatar filter?
- Adding Default Settings to Theme My Login plugin
- Add a class to the anchor tag on HTML5 gallery
- Is it acceptable to treat a filter like an action?
- How can I remove a function that has been added to wordpress with add_filter?
- How to control WordPress image metadata (using Imagick)?
- How do I add custom bulk actions to multiple custom post types?
- Add data attribute to each li in menu
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Removing “wpautop” (auto tags) only on certain pages?
- Print last modified date only on posts
- WordPress Gravatar filter is removing my custom attributes
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Unique icons next to each WordPress menu item
- Modify custom field input data before creating a new post
- Error call_user_func_array() expects parameter 1 to be a valid callback when using image_size_names_choose
- jQuery code not working when included in functions.php
- Alter required message using comment form api
- Add item to top of menu using a filter in functions.php
- How to make modifications only to certain elements of an HTML string on the server-side?
- Nested “do” and “add” Actions is possible?
- Filtering a function’ output for a new continued function
- Deleting Certain terms from appearing on the front end as links
- Content filter won’t work
- WordPress redirect redirecting too many times or not at all
- Warning: in_array() null given in PHP function
- Upload multiple files in randomly generated folder using wp_upload_bits
- Create page template via functions.php?
- Add meta tags to a custom header
- How to have different site identity logos on each page on Astra Theme [closed]
- Custom query vars filters problem with pagination
- Get the name of menu item with wp_nav_menu
- How to add aria role and schema markup to custom walker container
- Dynamically adding filters
- Must filter functions receive all arguments passed to them?
- How to pass hook variable to function?
- User filter posts by year
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- remove_action from parent theme using child theme functions.php
- Apply function.php filter only if url not has /amp/
- Change lost password url to a mailto URL in WordPress
- Remove span tags from WooCommerce Downloads page
- I want to hide “sold by” on certain pages with id page 43
- How to bind each “the_content” elements to a custom variables
- Reload page with a different shortcode when a user selects from a dropdown
- WordPress Ajax filter: Create two loops for different output styles?
- Hook into all password resets in WordPress and get password before hashing?
- Custom Bulk Actions handler not firing
- How to generate customized filtered output for the gallery
- remove_action() not working in page template – Genesis
- Unable to pass arguments to function used in add_action
- How to remove title tag with this filter
- str_replace not preserving whitespace
- Woocommerce Price Text
- Limit Taxonomy Parents
- WordPress HTML Helper
- Display a post based on its metabox selection
- Search box background on a different page template
- Highlight posts currently being edited on multiple editor site?
- Display a list of users with avatar filterable with alphabets
- How to add custom checkout field in user details mail template
- AJAX: WordPress filters inside $html do not work as intended
- Assign new post author IF another user in custom field on post transition
- Add attribute to featured image with filter (wp_get_attachment_image_attributes)
- Why a class property becomes empty?
- How to change wp-admin and wp-login urls
- How to add different menu items on different menus?
- How to pass value to add_filter wpcf7_form_tag from another function?
- Add text below WooCommerce short description if metabox value is true
- Show prices with tax in Woocommerce Mini Cart [closed]
- entire JS folder not loading in a WP theme
- Functions are causing errors
- Select All not working in a WordPress search filter
- Link to external page has wordpress blog-url inside