@@ -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 | } |
@@ -33,19 +33,19 @@ discard block |
||
33 | 33 | * {@inheritDoc} |
34 | 34 | */ |
35 | 35 | public function run() { |
36 | - foreach ( $this->actions as $action ) { |
|
36 | + foreach ($this->actions as $action) { |
|
37 | 37 | add_action( |
38 | 38 | $action['hook'], |
39 | - array( $action['service'], $action['method'] ), |
|
39 | + array($action['service'], $action['method']), |
|
40 | 40 | $action['priority'], |
41 | 41 | $action['args'] |
42 | 42 | ); |
43 | 43 | } |
44 | 44 | |
45 | - foreach ( $this->filters as $filter ) { |
|
45 | + foreach ($this->filters as $filter) { |
|
46 | 46 | add_filter( |
47 | 47 | $filter['hook'], |
48 | - array( $filter['service'], $filter['method'] ), |
|
48 | + array($filter['service'], $filter['method']), |
|
49 | 49 | $filter['priority'], |
50 | 50 | $filter['args'] |
51 | 51 | ); |
@@ -57,17 +57,17 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @param mixed $service |
59 | 59 | */ |
60 | - public function register( $service ) { |
|
61 | - if ( $service instanceof HasActions ) { |
|
62 | - $this->register_actions( $service ); |
|
60 | + public function register($service) { |
|
61 | + if ($service instanceof HasActions) { |
|
62 | + $this->register_actions($service); |
|
63 | 63 | } |
64 | 64 | |
65 | - if ( $service instanceof HasFilters ) { |
|
66 | - $this->register_filters( $service ); |
|
65 | + if ($service instanceof HasFilters) { |
|
66 | + $this->register_filters($service); |
|
67 | 67 | } |
68 | 68 | |
69 | - if ( $service instanceof HasShortcode ) { |
|
70 | - $this->register_shortcode( $service ); |
|
69 | + if ($service instanceof HasShortcode) { |
|
70 | + $this->register_shortcode($service); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @param HasActions $service |
78 | 78 | */ |
79 | - public function register_actions( HasActions $service ) { |
|
80 | - foreach ( $service->action_hooks() as $action ) { |
|
79 | + public function register_actions(HasActions $service) { |
|
80 | + foreach ($service->action_hooks() as $action) { |
|
81 | 81 | $this->actions = $this->add( |
82 | 82 | $this->actions, |
83 | 83 | $action['hook'], |
84 | 84 | $service, |
85 | 85 | $action['method'], |
86 | - isset( $action['priority'] ) ? $action['priority'] : 10, |
|
87 | - isset( $action['args'] ) ? $action['args'] : 1 |
|
86 | + isset($action['priority']) ? $action['priority'] : 10, |
|
87 | + isset($action['args']) ? $action['args'] : 1 |
|
88 | 88 | ); |
89 | 89 | } |
90 | 90 | } |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @param HasFilters $service |
96 | 96 | */ |
97 | - public function register_filters( HasFilters $service ) { |
|
98 | - foreach ( $service->filter_hooks() as $filter ) { |
|
97 | + public function register_filters(HasFilters $service) { |
|
98 | + foreach ($service->filter_hooks() as $filter) { |
|
99 | 99 | $this->filters = $this->add( |
100 | 100 | $this->filters, |
101 | 101 | $filter['hook'], |
102 | 102 | $service, |
103 | 103 | $filter['method'], |
104 | - isset( $filter['priority'] ) ? $filter['priority'] : 10, |
|
105 | - isset( $filter['args'] ) ? $filter['args'] : 1 |
|
104 | + isset($filter['priority']) ? $filter['priority'] : 10, |
|
105 | + isset($filter['args']) ? $filter['args'] : 1 |
|
106 | 106 | ); |
107 | 107 | } |
108 | 108 | } |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @param HasShortcode $service |
114 | 114 | */ |
115 | - public function register_shortcode( HasShortcode $service ) { |
|
116 | - add_shortcode( $service->shortcode_name(), array( $service, 'do_shortcode' ) ); |
|
115 | + public function register_shortcode(HasShortcode $service) { |
|
116 | + add_shortcode($service->shortcode_name(), array($service, 'do_shortcode')); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return array |
130 | 130 | */ |
131 | - protected function add( $hooks, $hook, $service, $method, $priority, $accepted_args ) { |
|
131 | + protected function add($hooks, $hook, $service, $method, $priority, $accepted_args) { |
|
132 | 132 | $hooks[] = array( |
133 | 133 | 'hook' => $hook, |
134 | 134 | 'service' => $service, |