Reputation: 21
I have a scenario like this , since its a big code, I'm asking this in an easy way:
In a file called One.php
, I have something like this:
add_filter('eshopaddtocheckout','eshop_extras_checkout');
function eshop_extras_checkout($echo){
//blah blah..
}
In a file, Two.php
, I have something like this:
$echo = apply_filters('eshopaddtocheckout',$echo);
My doubts are:
I don't understood how Two.php
made a connection with the One.php
file? I didnt even find a line using something like include One.php
inside the Two.php
file (BUT the functionality is working perfectly between the 2 files)
what does apply_filters do?
Upvotes: 2
Views: 8615
Reputation: 75
As stated before, there is no PHP function called apply_filters nor do_action. These are Wordpress event driven hooks; specifically made for extensions.
For a better understanding, please refer to: https://wpshout.com/apply_filters-do_action/
Hope this helps.
Upvotes: 0
Reputation: 10031
You can register filters with WordPress, passing a name and a function to add_filter
. These can contain actions you want to perform on some data before it is used. apply_filters
calls these with arguments, $echo
in your example.
See the WordPress documentation on filters for more details.
Upvotes: 0
Reputation: 15199
There is no php function apply_filters
. It must be defined by some additional software you are using; perhaps wordpress? If so, there's an answer here that may help: What does apply_filters(...) actually do in WordPress?
Upvotes: 7