I am new to WP, semi-new to PHP and new to OOP.
1) How can the WP function
add_action receive another function as its argument? I know this by itself is not possible. I deliberately broke some code and found that there is actually a native php function
but how did they make it so that their own function can have a function as its argument?
2) I am doing some plugin tutorial and working with WP_Query, and I just passed an argument directly to WP_Query, as if it was a method and not a class.
I did the following: $loop = new WP_Query( array( 'posts_per_page' => 3 ) );
I would understand if I first instantiated the class and THEN used its method, something like:
$loop = new WP_Query(); $loop->someMethod( array( 'posts_per_page' => 3, 'category__in' => $cats, 'orderby' => 'rand', 'post__not_in' => array($id) ) );
but how is this possible, that instantiating a class can act as a method as well? (this is more of a general OOP question I guess).