PHP code example of kerryrandolph / wp-hook-annotations

1. Go to this page and download the library: Download kerryrandolph/wp-hook-annotations library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kerryrandolph / wp-hook-annotations example snippets


/**
  * @Action(tag="wp_loaded",priority=10,accepted_args=1)
  */
public function doSomething(){
  // do something
}

/**
 * @Action(tag="the_hook_name", priority=1, accepted_args=1)
 * @Filter(tag="the_filter_name", priority=1, accepted_args=1)
 * @Shortcode(tag="the_shortcode_name")
 */

/**
  * @Filter(tag="some_wp_filter")
  * @Action(tag="some_wp_action")
  * @Filter(tag="another_wp_filter")
  */
public function updateSomeValue(string $value): string {
  return 'updated';
}

class MyWordpressHookClass {
  use HookAware;
  
  /**
    * @Action(tag="wp_loaded")
    */
  public function foo(){}
}

__construct( HookManager $hook_manager ) {
  $hook_manager->processHooks( $this );
}