| @@ -1,129 +1,129 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Register all actions and filters for the plugin | |
| 5 | - * | |
| 6 | - * @link https://ays-pro.com/ | |
| 7 | - * @since 1.0.0 | |
| 8 | - * | |
| 9 | - * @package Chart_Builder | |
| 10 | - * @subpackage Chart_Builder/includes | |
| 11 | - */ | |
| 12 | - | |
| 13 | -/** | |
| 14 | - * Register all actions and filters for the plugin. | |
| 15 | - * | |
| 16 | - * Maintain a list of all hooks that are registered throughout | |
| 17 | - * the plugin, and register them with the WordPress API. Call the | |
| 18 | - * run function to execute the list of actions and filters. | |
| 19 | - * | |
| 20 | - * @package Chart_Builder | |
| 21 | - * @subpackage Chart_Builder/includes | |
| 22 | - * @author Chart Builder Team <info@ays-pro.com> | |
| 23 | - */ | |
| 24 | -class Chart_Builder_Loader { | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * The array of actions registered with WordPress. | |
| 28 | - * | |
| 29 | - * @since 1.0.0 | |
| 30 | - * @access protected | |
| 31 | - * @var array $actions The actions registered with WordPress to fire when the plugin loads. | |
| 32 | - */ | |
| 33 | - protected $actions; | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * The array of filters registered with WordPress. | |
| 37 | - * | |
| 38 | - * @since 1.0.0 | |
| 39 | - * @access protected | |
| 40 | - * @var array $filters The filters registered with WordPress to fire when the plugin loads. | |
| 41 | - */ | |
| 42 | - protected $filters; | |
| 43 | - | |
| 44 | - /** | |
| 45 | - * Initialize the collections used to maintain the actions and filters. | |
| 46 | - * | |
| 47 | - * @since 1.0.0 | |
| 48 | - */ | |
| 49 | - public function __construct() { | |
| 50 | - | |
| 51 | - $this->actions = array(); | |
| 52 | - $this->filters = array(); | |
| 53 | - | |
| 54 | - } | |
| 55 | - | |
| 56 | - /** | |
| 57 | - * Add a new action to the collection to be registered with WordPress. | |
| 58 | - * | |
| 59 | - * @since 1.0.0 | |
| 60 | - * @param string $hook The name of the WordPress action that is being registered. | |
| 61 | - * @param object $component A reference to the instance of the object on which the action is defined. | |
| 62 | - * @param string $callback The name of the function definition on the $component. | |
| 63 | - * @param int $priority Optional. The priority at which the function should be fired. Default is 10. | |
| 64 | - * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. | |
| 65 | - */ | |
| 66 | - public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { | |
| 67 | - $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); | |
| 68 | - } | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * Add a new filter to the collection to be registered with WordPress. | |
| 72 | - * | |
| 73 | - * @since 1.0.0 | |
| 74 | - * @param string $hook The name of the WordPress filter that is being registered. | |
| 75 | - * @param object $component A reference to the instance of the object on which the filter is defined. | |
| 76 | - * @param string $callback The name of the function definition on the $component. | |
| 77 | - * @param int $priority Optional. The priority at which the function should be fired. Default is 10. | |
| 78 | - * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 | |
| 79 | - */ | |
| 80 | - public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { | |
| 81 | - $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); | |
| 82 | - } | |
| 83 | - | |
| 84 | - /** | |
| 85 | - * A utility function that is used to register the actions and hooks into a single | |
| 86 | - * collection. | |
| 87 | - * | |
| 88 | - * @since 1.0.0 | |
| 89 | - * @access private | |
| 90 | - * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). | |
| 91 | - * @param string $hook The name of the WordPress filter that is being registered. | |
| 92 | - * @param object $component A reference to the instance of the object on which the filter is defined. | |
| 93 | - * @param string $callback The name of the function definition on the $component. | |
| 94 | - * @param int $priority The priority at which the function should be fired. | |
| 95 | - * @param int $accepted_args The number of arguments that should be passed to the $callback. | |
| 96 | - * @return array The collection of actions and filters registered with WordPress. | |
| 97 | - */ | |
| 98 | - private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { | |
| 99 | - | |
| 100 | - $hooks[] = array( | |
| 101 | - 'hook' => $hook, | |
| 102 | - 'component' => $component, | |
| 103 | - 'callback' => $callback, | |
| 104 | - 'priority' => $priority, | |
| 105 | - 'accepted_args' => $accepted_args | |
| 106 | - ); | |
| 107 | - | |
| 108 | - return $hooks; | |
| 109 | - | |
| 110 | - } | |
| 111 | - | |
| 112 | - /** | |
| 113 | - * Register the filters and actions with WordPress. | |
| 114 | - * | |
| 115 | - * @since 1.0.0 | |
| 116 | - */ | |
| 117 | - public function run() { | |
| 118 | - | |
| 119 | - foreach ( $this->filters as $hook ) { | |
| 120 | - add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); | |
| 121 | - } | |
| 122 | - | |
| 123 | - foreach ( $this->actions as $hook ) { | |
| 124 | - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); | |
| 125 | - } | |
| 126 | - | |
| 127 | - } | |
| 128 | - | |
| 129 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Register all actions and filters for the plugin | |
| 5 | + * | |
| 6 | + * @link https://ays-pro.com/ | |
| 7 | + * @since 1.0.0 | |
| 8 | + * | |
| 9 | + * @package Chart_Builder | |
| 10 | + * @subpackage Chart_Builder/includes | |
| 11 | + */ | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * Register all actions and filters for the plugin. | |
| 15 | + * | |
| 16 | + * Maintain a list of all hooks that are registered throughout | |
| 17 | + * the plugin, and register them with the WordPress API. Call the | |
| 18 | + * run function to execute the list of actions and filters. | |
| 19 | + * | |
| 20 | + * @package Chart_Builder | |
| 21 | + * @subpackage Chart_Builder/includes | |
| 22 | + * @author Chart Builder Team <info@ays-pro.com> | |
| 23 | + */ | |
| 24 | +class Chart_Builder_Loader { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * The array of actions registered with WordPress. | |
| 28 | + * | |
| 29 | + * @since 1.0.0 | |
| 30 | + * @access protected | |
| 31 | + * @var array $actions The actions registered with WordPress to fire when the plugin loads. | |
| 32 | + */ | |
| 33 | + protected $actions; | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * The array of filters registered with WordPress. | |
| 37 | + * | |
| 38 | + * @since 1.0.0 | |
| 39 | + * @access protected | |
| 40 | + * @var array $filters The filters registered with WordPress to fire when the plugin loads. | |
| 41 | + */ | |
| 42 | + protected $filters; | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * Initialize the collections used to maintain the actions and filters. | |
| 46 | + * | |
| 47 | + * @since 1.0.0 | |
| 48 | + */ | |
| 49 | + public function __construct() { | |
| 50 | + | |
| 51 | + $this->actions = array(); | |
| 52 | + $this->filters = array(); | |
| 53 | + | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * Add a new action to the collection to be registered with WordPress. | |
| 58 | + * | |
| 59 | + * @since 1.0.0 | |
| 60 | + * @param string $hook The name of the WordPress action that is being registered. | |
| 61 | + * @param object $component A reference to the instance of the object on which the action is defined. | |
| 62 | + * @param string $callback The name of the function definition on the $component. | |
| 63 | + * @param int $priority Optional. The priority at which the function should be fired. Default is 10. | |
| 64 | + * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. | |
| 65 | + */ | |
| 66 | + public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { | |
| 67 | + $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); | |
| 68 | + } | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * Add a new filter to the collection to be registered with WordPress. | |
| 72 | + * | |
| 73 | + * @since 1.0.0 | |
| 74 | + * @param string $hook The name of the WordPress filter that is being registered. | |
| 75 | + * @param object $component A reference to the instance of the object on which the filter is defined. | |
| 76 | + * @param string $callback The name of the function definition on the $component. | |
| 77 | + * @param int $priority Optional. The priority at which the function should be fired. Default is 10. | |
| 78 | + * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 | |
| 79 | + */ | |
| 80 | + public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { | |
| 81 | + $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); | |
| 82 | + } | |
| 83 | + | |
| 84 | + /** | |
| 85 | + * A utility function that is used to register the actions and hooks into a single | |
| 86 | + * collection. | |
| 87 | + * | |
| 88 | + * @since 1.0.0 | |
| 89 | + * @access private | |
| 90 | + * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). | |
| 91 | + * @param string $hook The name of the WordPress filter that is being registered. | |
| 92 | + * @param object $component A reference to the instance of the object on which the filter is defined. | |
| 93 | + * @param string $callback The name of the function definition on the $component. | |
| 94 | + * @param int $priority The priority at which the function should be fired. | |
| 95 | + * @param int $accepted_args The number of arguments that should be passed to the $callback. | |
| 96 | + * @return array The collection of actions and filters registered with WordPress. | |
| 97 | + */ | |
| 98 | + private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { | |
| 99 | + | |
| 100 | + $hooks[] = array( | |
| 101 | + 'hook' => $hook, | |
| 102 | + 'component' => $component, | |
| 103 | + 'callback' => $callback, | |
| 104 | + 'priority' => $priority, | |
| 105 | + 'accepted_args' => $accepted_args | |
| 106 | + ); | |
| 107 | + | |
| 108 | + return $hooks; | |
| 109 | + | |
| 110 | + } | |
| 111 | + | |
| 112 | + /** | |
| 113 | + * Register the filters and actions with WordPress. | |
| 114 | + * | |
| 115 | + * @since 1.0.0 | |
| 116 | + */ | |
| 117 | + public function run() { | |
| 118 | + | |
| 119 | + foreach ( $this->filters as $hook ) { | |
| 120 | + add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); | |
| 121 | + } | |
| 122 | + | |
| 123 | + foreach ( $this->actions as $hook ) { | |
| 124 | + add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); | |
| 125 | + } | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | +} | |