@@ -15,128 +15,128 @@ |
||
| 15 | 15 | * @subpackage Core |
| 16 | 16 | */ |
| 17 | 17 | class Loader implements LoaderContract { |
| 18 | - /** |
|
| 19 | - * Array of action hooks to attach. |
|
| 20 | - * |
|
| 21 | - * @var array[] |
|
| 22 | - */ |
|
| 23 | - protected $actions = array(); |
|
| 18 | + /** |
|
| 19 | + * Array of action hooks to attach. |
|
| 20 | + * |
|
| 21 | + * @var array[] |
|
| 22 | + */ |
|
| 23 | + protected $actions = array(); |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Array of filter hooks to attach. |
|
| 27 | - * |
|
| 28 | - * @var array[] |
|
| 29 | - */ |
|
| 30 | - protected $filters = array(); |
|
| 25 | + /** |
|
| 26 | + * Array of filter hooks to attach. |
|
| 27 | + * |
|
| 28 | + * @var array[] |
|
| 29 | + */ |
|
| 30 | + protected $filters = array(); |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * {@inheritDoc} |
|
| 34 | - */ |
|
| 35 | - public function run() { |
|
| 36 | - foreach ( $this->actions as $action ) { |
|
| 37 | - add_action( |
|
| 38 | - $action['hook'], |
|
| 39 | - array( $action['service'], $action['method'] ), |
|
| 40 | - $action['priority'], |
|
| 41 | - $action['args'] |
|
| 42 | - ); |
|
| 43 | - } |
|
| 32 | + /** |
|
| 33 | + * {@inheritDoc} |
|
| 34 | + */ |
|
| 35 | + public function run() { |
|
| 36 | + foreach ( $this->actions as $action ) { |
|
| 37 | + add_action( |
|
| 38 | + $action['hook'], |
|
| 39 | + array( $action['service'], $action['method'] ), |
|
| 40 | + $action['priority'], |
|
| 41 | + $action['args'] |
|
| 42 | + ); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - foreach ( $this->filters as $filter ) { |
|
| 46 | - add_filter( |
|
| 47 | - $filter['hook'], |
|
| 48 | - array( $filter['service'], $filter['method'] ), |
|
| 49 | - $filter['priority'], |
|
| 50 | - $filter['args'] |
|
| 51 | - ); |
|
| 52 | - } |
|
| 53 | - } |
|
| 45 | + foreach ( $this->filters as $filter ) { |
|
| 46 | + add_filter( |
|
| 47 | + $filter['hook'], |
|
| 48 | + array( $filter['service'], $filter['method'] ), |
|
| 49 | + $filter['priority'], |
|
| 50 | + $filter['args'] |
|
| 51 | + ); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Register a service with the loader. |
|
| 57 | - * |
|
| 58 | - * @param mixed $service |
|
| 59 | - */ |
|
| 60 | - public function register( $service ) { |
|
| 61 | - if ( $service instanceof HasActions ) { |
|
| 62 | - $this->register_actions( $service ); |
|
| 63 | - } |
|
| 55 | + /** |
|
| 56 | + * Register a service with the loader. |
|
| 57 | + * |
|
| 58 | + * @param mixed $service |
|
| 59 | + */ |
|
| 60 | + public function register( $service ) { |
|
| 61 | + if ( $service instanceof HasActions ) { |
|
| 62 | + $this->register_actions( $service ); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - if ( $service instanceof HasFilters ) { |
|
| 66 | - $this->register_filters( $service ); |
|
| 67 | - } |
|
| 65 | + if ( $service instanceof HasFilters ) { |
|
| 66 | + $this->register_filters( $service ); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - if ( $service instanceof HasShortcode ) { |
|
| 70 | - $this->register_shortcode( $service ); |
|
| 71 | - } |
|
| 72 | - } |
|
| 69 | + if ( $service instanceof HasShortcode ) { |
|
| 70 | + $this->register_shortcode( $service ); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * {@inheritDoc} |
|
| 76 | - * |
|
| 77 | - * @param HasActions $service |
|
| 78 | - */ |
|
| 79 | - public function register_actions( HasActions $service ) { |
|
| 80 | - foreach ( $service->action_hooks() as $action ) { |
|
| 81 | - $this->actions = $this->add( |
|
| 82 | - $this->actions, |
|
| 83 | - $action['hook'], |
|
| 84 | - $service, |
|
| 85 | - $action['method'], |
|
| 86 | - isset( $action['priority'] ) ? $action['priority'] : 10, |
|
| 87 | - isset( $action['args'] ) ? $action['args'] : 1 |
|
| 88 | - ); |
|
| 89 | - } |
|
| 90 | - } |
|
| 74 | + /** |
|
| 75 | + * {@inheritDoc} |
|
| 76 | + * |
|
| 77 | + * @param HasActions $service |
|
| 78 | + */ |
|
| 79 | + public function register_actions( HasActions $service ) { |
|
| 80 | + foreach ( $service->action_hooks() as $action ) { |
|
| 81 | + $this->actions = $this->add( |
|
| 82 | + $this->actions, |
|
| 83 | + $action['hook'], |
|
| 84 | + $service, |
|
| 85 | + $action['method'], |
|
| 86 | + isset( $action['priority'] ) ? $action['priority'] : 10, |
|
| 87 | + isset( $action['args'] ) ? $action['args'] : 1 |
|
| 88 | + ); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * {@inheritDoc} |
|
| 94 | - * |
|
| 95 | - * @param HasFilters $service |
|
| 96 | - */ |
|
| 97 | - public function register_filters( HasFilters $service ) { |
|
| 98 | - foreach ( $service->filter_hooks() as $filter ) { |
|
| 99 | - $this->filters = $this->add( |
|
| 100 | - $this->filters, |
|
| 101 | - $filter['hook'], |
|
| 102 | - $service, |
|
| 103 | - $filter['method'], |
|
| 104 | - isset( $filter['priority'] ) ? $filter['priority'] : 10, |
|
| 105 | - isset( $filter['args'] ) ? $filter['args'] : 1 |
|
| 106 | - ); |
|
| 107 | - } |
|
| 108 | - } |
|
| 92 | + /** |
|
| 93 | + * {@inheritDoc} |
|
| 94 | + * |
|
| 95 | + * @param HasFilters $service |
|
| 96 | + */ |
|
| 97 | + public function register_filters( HasFilters $service ) { |
|
| 98 | + foreach ( $service->filter_hooks() as $filter ) { |
|
| 99 | + $this->filters = $this->add( |
|
| 100 | + $this->filters, |
|
| 101 | + $filter['hook'], |
|
| 102 | + $service, |
|
| 103 | + $filter['method'], |
|
| 104 | + isset( $filter['priority'] ) ? $filter['priority'] : 10, |
|
| 105 | + isset( $filter['args'] ) ? $filter['args'] : 1 |
|
| 106 | + ); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * {@inheritDoc} |
|
| 112 | - * |
|
| 113 | - * @param HasShortcode $service |
|
| 114 | - */ |
|
| 115 | - public function register_shortcode( HasShortcode $service ) { |
|
| 116 | - add_shortcode( $service->shortcode_name(), array( $service, 'do_shortcode' ) ); |
|
| 117 | - } |
|
| 110 | + /** |
|
| 111 | + * {@inheritDoc} |
|
| 112 | + * |
|
| 113 | + * @param HasShortcode $service |
|
| 114 | + */ |
|
| 115 | + public function register_shortcode( HasShortcode $service ) { |
|
| 116 | + add_shortcode( $service->shortcode_name(), array( $service, 'do_shortcode' ) ); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Utility to register the actions and hooks into a single collection. |
|
| 121 | - * |
|
| 122 | - * @param array $hooks |
|
| 123 | - * @param string $hook |
|
| 124 | - * @param object $service |
|
| 125 | - * @param string $method |
|
| 126 | - * @param int $priority |
|
| 127 | - * @param int $accepted_args |
|
| 128 | - * |
|
| 129 | - * @return array |
|
| 130 | - */ |
|
| 131 | - protected function add( $hooks, $hook, $service, $method, $priority, $accepted_args ) { |
|
| 132 | - $hooks[] = array( |
|
| 133 | - 'hook' => $hook, |
|
| 134 | - 'service' => $service, |
|
| 135 | - 'method' => $method, |
|
| 136 | - 'priority' => $priority, |
|
| 137 | - 'args' => $accepted_args, |
|
| 138 | - ); |
|
| 119 | + /** |
|
| 120 | + * Utility to register the actions and hooks into a single collection. |
|
| 121 | + * |
|
| 122 | + * @param array $hooks |
|
| 123 | + * @param string $hook |
|
| 124 | + * @param object $service |
|
| 125 | + * @param string $method |
|
| 126 | + * @param int $priority |
|
| 127 | + * @param int $accepted_args |
|
| 128 | + * |
|
| 129 | + * @return array |
|
| 130 | + */ |
|
| 131 | + protected function add( $hooks, $hook, $service, $method, $priority, $accepted_args ) { |
|
| 132 | + $hooks[] = array( |
|
| 133 | + 'hook' => $hook, |
|
| 134 | + 'service' => $service, |
|
| 135 | + 'method' => $method, |
|
| 136 | + 'priority' => $priority, |
|
| 137 | + 'args' => $accepted_args, |
|
| 138 | + ); |
|
| 139 | 139 | |
| 140 | - return $hooks; |
|
| 141 | - } |
|
| 140 | + return $hooks; |
|
| 141 | + } |
|
| 142 | 142 | } |