Wpcf7_Signature_Loader

Register all actions and filters for the plugin.

Defined (1)

The class is defined in the following location(s).

/includes/class-wpcf7-signature-loader.php  
  1. class Wpcf7_Signature_Loader { 
  2.  
  3. /** 
  4. * The array of actions registered with WordPress. 
  5. * @since 4.0.0 
  6. * @access protected 
  7. * @var array $actions The actions registered with WordPress to fire when the plugin loads. 
  8. */ 
  9. protected $actions; 
  10.  
  11. /** 
  12. * The array of filters registered with WordPress. 
  13. * @since 4.0.0 
  14. * @access protected 
  15. * @var array $filters The filters registered with WordPress to fire when the plugin loads. 
  16. */ 
  17. protected $filters; 
  18.  
  19. /** 
  20. * Initialize the collections used to maintain the actions and filters. 
  21. * @since 4.0.0 
  22. */ 
  23. public function __construct() { 
  24.  
  25. $this->actions = array(); 
  26. $this->filters = array(); 
  27.  
  28.  
  29. /** 
  30. * Add a new action to the collection to be registered with WordPress. 
  31. * @since 4.0.0 
  32. * @param string $hook The name of the WordPress action that is being registered. 
  33. * @param object $component A reference to the instance of the object on which the action is defined. 
  34. * @param string $callback The name of the function definition on the $component. 
  35. * @param int $priority Optional. he priority at which the function should be fired. Default is 10. 
  36. * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. 
  37. */ 
  38. public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 
  39. $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); 
  40.  
  41. /** 
  42. * Add a new filter to the collection to be registered with WordPress. 
  43. * @since 4.0.0 
  44. * @param string $hook The name of the WordPress filter that is being registered. 
  45. * @param object $component A reference to the instance of the object on which the filter is defined. 
  46. * @param string $callback The name of the function definition on the $component. 
  47. * @param int $priority Optional. he priority at which the function should be fired. Default is 10. 
  48. * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 
  49. */ 
  50. public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 
  51. $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); 
  52.  
  53. /** 
  54. * A utility function that is used to register the actions and hooks into a single 
  55. * collection. 
  56. * @since 4.0.0 
  57. * @access private 
  58. * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). 
  59. * @param string $hook The name of the WordPress filter that is being registered. 
  60. * @param object $component A reference to the instance of the object on which the filter is defined. 
  61. * @param string $callback The name of the function definition on the $component. 
  62. * @param int $priority The priority at which the function should be fired. 
  63. * @param int $accepted_args The number of arguments that should be passed to the $callback. 
  64. * @return array The collection of actions and filters registered with WordPress. 
  65. */ 
  66. private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { 
  67.  
  68. $hooks[] = array( 
  69. 'hook' => $hook,  
  70. 'component' => $component,  
  71. 'callback' => $callback,  
  72. 'priority' => $priority,  
  73. 'accepted_args' => $accepted_args 
  74. ); 
  75.  
  76. return $hooks; 
  77.  
  78.  
  79. /** 
  80. * Register the filters and actions with WordPress. 
  81. * @since 4.0.0 
  82. */ 
  83. public function run() { 
  84.  
  85. foreach ( $this->filters as $hook ) { 
  86. add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 
  87.  
  88. foreach ( $this->actions as $hook ) { 
  89. add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 
  90.  
  91.