WordPress add_action() Class static method callback

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

class MyClass {
    static function my_init_method() {
        // do something here
    }
}

add_action( 'init', array( 'MyClass', 'my_init_method' ) );

Using a static method of a class to hook a set of instructions. With the init hook, the set of instructions will be executed right after wordpress has finished loading the necessary components.



Got any WordPress Question?