CWS_Google_Picasa_Pro_Loader

Register all actions and filters for the plugin.

Defined (2)

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

/includes/class-cws-google-picasa-pro-loader.php  
  1. class CWS_Google_Picasa_Pro_Loader { 
  2.  
  3. /** 
  4. * The array of actions registered with WordPress. 
  5. * @since 2.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 2.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 2.0.0 
  22. */ 
  23. public function __construct() { 
  24.  
  25. $this->actions = array(); 
  26. $this->filters = array(); 
  27.  
  28. /** 
  29. * Add a new action to the collection to be registered with WordPress. 
  30. * @since 2.0.0 
  31. * @param string $hook The name of the WordPress action that is being registered. 
  32. * @param object $component A reference to the instance of the object on which the action is defined. 
  33. * @param string $callback The name of the function definition on the $component. 
  34. * @param int Optional $priority The priority at which the function should be fired. 
  35. * @param int Optional $accepted_args The number of arguments that should be passed to the $callback. 
  36. */ 
  37. public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 
  38. $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); 
  39.  
  40. /** 
  41. * Add a new filter to the collection to be registered with WordPress. 
  42. * @since 2.0.0 
  43. * @param string $hook The name of the WordPress filter that is being registered. 
  44. * @param object $component A reference to the instance of the object on which the filter is defined. 
  45. * @param string $callback The name of the function definition on the $component. 
  46. * @param int Optional $priority The priority at which the function should be fired. 
  47. * @param int Optional $accepted_args The number of arguments that should be passed to the $callback. 
  48. */ 
  49. public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 
  50. $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); 
  51.  
  52. /** 
  53. * A utility function that is used to register the actions and hooks into a single 
  54. * collection. 
  55. * @since 2.0.0 
  56. * @access private 
  57. * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). 
  58. * @param string $hook The name of the WordPress filter that is being registered. 
  59. * @param object $component A reference to the instance of the object on which the filter is defined. 
  60. * @param string $callback The name of the function definition on the $component. 
  61. * @param int Optional $priority The priority at which the function should be fired. 
  62. * @param int Optional $accepted_args The number of arguments that should be passed to the $callback. 
  63. * @return type The collection of actions and filters registered with WordPress. 
  64. */ 
  65. private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { 
  66.  
  67. $hooks[] = array( 
  68. 'hook' => $hook,  
  69. 'component' => $component,  
  70. 'callback' => $callback,  
  71. 'priority' => $priority,  
  72. 'accepted_args' => $accepted_args 
  73. ); 
  74.  
  75. return $hooks; 
  76.  
  77. /** 
  78. * Register the filters and actions with WordPress. 
  79. * @since 2.0.0 
  80. */ 
  81. public function run() { 
  82.  
  83. foreach ( $this->filters as $hook ) { 
  84. add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 
  85.  
  86. foreach ( $this->actions as $hook ) { 
  87. add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 
  1. class CWS_Google_Picasa_Pro_Loader { 
  2.  
  3. /** 
  4. * The array of actions registered with WordPress. 
  5. * @since 2.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 2.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 2.0.0 
  22. */ 
  23. public function __construct() { 
  24.  
  25. $this->actions = array(); 
  26. $this->filters = array(); 
  27.  
  28. /** 
  29. * Add a new action to the collection to be registered with WordPress. 
  30. * @since 2.0.0 
  31. * @param string $hook The name of the WordPress action that is being registered. 
  32. * @param object $component A reference to the instance of the object on which the action is defined. 
  33. * @param string $callback The name of the function definition on the $component. 
  34. * @param int Optional $priority The priority at which the function should be fired. 
  35. * @param int Optional $accepted_args The number of arguments that should be passed to the $callback. 
  36. */ 
  37. public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 
  38. $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); 
  39.  
  40. /** 
  41. * Add a new filter to the collection to be registered with WordPress. 
  42. * @since 2.0.0 
  43. * @param string $hook The name of the WordPress filter that is being registered. 
  44. * @param object $component A reference to the instance of the object on which the filter is defined. 
  45. * @param string $callback The name of the function definition on the $component. 
  46. * @param int Optional $priority The priority at which the function should be fired. 
  47. * @param int Optional $accepted_args The number of arguments that should be passed to the $callback. 
  48. */ 
  49. public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 
  50. $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); 
  51.  
  52. /** 
  53. * A utility function that is used to register the actions and hooks into a single 
  54. * collection. 
  55. * @since 2.0.0 
  56. * @access private 
  57. * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). 
  58. * @param string $hook The name of the WordPress filter that is being registered. 
  59. * @param object $component A reference to the instance of the object on which the filter is defined. 
  60. * @param string $callback The name of the function definition on the $component. 
  61. * @param int Optional $priority The priority at which the function should be fired. 
  62. * @param int Optional $accepted_args The number of arguments that should be passed to the $callback. 
  63. * @return type The collection of actions and filters registered with WordPress. 
  64. */ 
  65. private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { 
  66.  
  67. $hooks[] = array( 
  68. 'hook' => $hook,  
  69. 'component' => $component,  
  70. 'callback' => $callback,  
  71. 'priority' => $priority,  
  72. 'accepted_args' => $accepted_args 
  73. ); 
  74.  
  75. return $hooks; 
  76.  
  77. /** 
  78. * Register the filters and actions with WordPress. 
  79. * @since 2.0.0 
  80. */ 
  81. public function run() { 
  82.  
  83. foreach ( $this->filters as $hook ) { 
  84. add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 
  85.  
  86. foreach ( $this->actions as $hook ) { 
  87. add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );