@@ -7,11 +7,11 @@ |
||
7 | 7 | * @since 2.1.0 |
8 | 8 | */ |
9 | 9 | |
10 | -add_action( 'init', 'wordpoints_ranks_admin_register_scripts' ); |
|
10 | +add_action('init', 'wordpoints_ranks_admin_register_scripts'); |
|
11 | 11 | |
12 | -add_action( 'admin_menu', 'wordpoints_ranks_admin_menu' ); |
|
12 | +add_action('admin_menu', 'wordpoints_ranks_admin_menu'); |
|
13 | 13 | |
14 | -add_action( 'load-wordpoints_page_wordpoints_ranks', 'wordpoints_ranks_admin_screen_load' ); |
|
14 | +add_action('load-wordpoints_page_wordpoints_ranks', 'wordpoints_ranks_admin_screen_load'); |
|
15 | 15 | |
16 | 16 | |
17 | 17 | // EOF |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | wp_register_style( |
25 | 25 | 'wordpoints-ranks-admin' |
26 | 26 | , "{$assets_url}/css/ranks-screen{$suffix}.css" |
27 | - , array( 'dashicons', 'wp-jquery-ui-dialog' ) |
|
27 | + , array('dashicons', 'wp-jquery-ui-dialog') |
|
28 | 28 | , WORDPOINTS_VERSION |
29 | 29 | ); |
30 | 30 | |
31 | 31 | $styles = wp_styles(); |
32 | - $styles->add_data( 'wordpoints-ranks-admin', 'rtl', 'replace' ); |
|
32 | + $styles->add_data('wordpoints-ranks-admin', 'rtl', 'replace'); |
|
33 | 33 | |
34 | - if ( $suffix ) { |
|
35 | - $styles->add_data( 'wordpoints-ranks-admin', 'suffix', $suffix ); |
|
34 | + if ($suffix) { |
|
35 | + $styles->add_data('wordpoints-ranks-admin', 'suffix', $suffix); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // JS |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | wp_register_script( |
41 | 41 | 'wordpoints-ranks-admin' |
42 | 42 | , "{$assets_url}/js/ranks-screen{$suffix}.js" |
43 | - , array( 'backbone', 'jquery-ui-dialog', 'wp-util' ) |
|
43 | + , array('backbone', 'jquery-ui-dialog', 'wp-util') |
|
44 | 44 | , WORDPOINTS_VERSION |
45 | 45 | ); |
46 | 46 | |
@@ -48,20 +48,20 @@ discard block |
||
48 | 48 | 'wordpoints-ranks-admin' |
49 | 49 | , 'WordPointsRanksAdminL10n' |
50 | 50 | , array( |
51 | - 'unexpectedError' => __( 'There was an unexpected error. Try reloading the page.', 'wordpoints' ), |
|
52 | - 'changesSaved' => __( 'Your changes have been saved.', 'wordpoints' ), |
|
53 | - 'emptyName' => __( 'A rank title cannot be empty.', 'wordpoints' ), |
|
54 | - 'confirmDelete' => __( 'Are you sure that you want to delete this rank? This action cannot be undone.', 'wordpoints' ), |
|
55 | - 'confirmTitle' => __( 'Are you sure?', 'wordpoints' ), |
|
56 | - 'deleteText' => __( 'Delete', 'wordpoints' ), |
|
57 | - 'cancelText' => __( 'Cancel', 'wordpoints' ), |
|
51 | + 'unexpectedError' => __('There was an unexpected error. Try reloading the page.', 'wordpoints'), |
|
52 | + 'changesSaved' => __('Your changes have been saved.', 'wordpoints'), |
|
53 | + 'emptyName' => __('A rank title cannot be empty.', 'wordpoints'), |
|
54 | + 'confirmDelete' => __('Are you sure that you want to delete this rank? This action cannot be undone.', 'wordpoints'), |
|
55 | + 'confirmTitle' => __('Are you sure?', 'wordpoints'), |
|
56 | + 'deleteText' => __('Delete', 'wordpoints'), |
|
57 | + 'cancelText' => __('Cancel', 'wordpoints'), |
|
58 | 58 | ) |
59 | 59 | ); |
60 | 60 | |
61 | 61 | wp_localize_script( |
62 | 62 | 'wordpoints-ranks-admin' |
63 | 63 | , 'WordPointsRanksAdminData' |
64 | - , array( 'ranks' => WordPoints_Ranks_Admin_Screen_Ajax::prepare_all_ranks() ) |
|
64 | + , array('ranks' => WordPoints_Ranks_Admin_Screen_Ajax::prepare_all_ranks()) |
|
65 | 65 | ); |
66 | 66 | } |
67 | 67 | |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | // Ranks screen. |
80 | 80 | add_submenu_page( |
81 | 81 | $wordpoints_menu |
82 | - ,__( 'WordPoints — Ranks', 'wordpoints' ) |
|
83 | - ,esc_html__( 'Ranks', 'wordpoints' ) |
|
82 | + ,__('WordPoints — Ranks', 'wordpoints') |
|
83 | + ,esc_html__('Ranks', 'wordpoints') |
|
84 | 84 | ,'manage_options' |
85 | 85 | ,'wordpoints_ranks' |
86 | 86 | ,'wordpoints_ranks_admin_screen' |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | */ |
97 | 97 | function wordpoints_ranks_admin_screen_load() { |
98 | 98 | |
99 | - wp_enqueue_style( 'wordpoints-ranks-admin' ); |
|
100 | - wp_enqueue_script( 'wordpoints-ranks-admin' ); |
|
99 | + wp_enqueue_style('wordpoints-ranks-admin'); |
|
100 | + wp_enqueue_script('wordpoints-ranks-admin'); |
|
101 | 101 | |
102 | 102 | // Add help and screen options tabs. |
103 | 103 | $screen = get_current_screen(); |
@@ -105,37 +105,37 @@ discard block |
||
105 | 105 | $screen->add_help_tab( |
106 | 106 | array( |
107 | 107 | 'id' => 'overview', |
108 | - 'title' => esc_html__( 'Overview', 'wordpoints' ), |
|
108 | + 'title' => esc_html__('Overview', 'wordpoints'), |
|
109 | 109 | 'content' => |
110 | - '<p>' . esc_html__( 'Ranks are titles assigned to users. A set of ranks are organized into a hierarchy. The user starts at the bottom, but can work his way up to higher ranks. Each rank has requirements that a user must meet before he can move up to that rank. For example, the user may need to have a certain number of points to reach a given rank.', 'wordpoints' ) . '</p> |
|
111 | - <p>' . esc_html__( 'More than one rank hierarchy may be available. For example, if you have multiple types of points, you will have a group of ranks for each points type. Each rank group is managed separately, on a different tab on this screen.', 'wordpoints' ) . '</p>', |
|
110 | + '<p>' . esc_html__('Ranks are titles assigned to users. A set of ranks are organized into a hierarchy. The user starts at the bottom, but can work his way up to higher ranks. Each rank has requirements that a user must meet before he can move up to that rank. For example, the user may need to have a certain number of points to reach a given rank.', 'wordpoints') . '</p> |
|
111 | + <p>' . esc_html__('More than one rank hierarchy may be available. For example, if you have multiple types of points, you will have a group of ranks for each points type. Each rank group is managed separately, on a different tab on this screen.', 'wordpoints') . '</p>', |
|
112 | 112 | ) |
113 | 113 | ); |
114 | 114 | |
115 | 115 | $screen->add_help_tab( |
116 | 116 | array( |
117 | 117 | 'id' => 'adding-editing', |
118 | - 'title' => esc_html__( 'Adding and Editing', 'wordpoints' ), |
|
118 | + 'title' => esc_html__('Adding and Editing', 'wordpoints'), |
|
119 | 119 | 'content' => |
120 | - '<p>' . esc_html__( 'To add a new rank to the rank group, click the Add Rank button. A new rank will appear with its settings form open. Fill out its settings and click the save button. If you have changed your mind, you can remove the new rank without saving it by clicking the Cancel button.', 'wordpoints' ) . '</p> |
|
121 | - <p>' . esc_html__( 'To edit an existing rank’s settings, click on the Edit link in its title bar. The settings form for that rank will open. You can close the settings form again by clicking the Close link.', 'wordpoints' ) . '</p> |
|
122 | - <p>' . esc_html__( 'Once you have modified the rank’s settings as desired, you can save your changes by clicking the Save button. Keep in mind that your changes will take effect immediately, and it is wise to double check that you have all of the settings just as you want them. If you decide that you don’t want to save your changes, click the Cancel button instead, which will reset the form to the rank’s current settings.', 'wordpoints' ) . '</p>', |
|
120 | + '<p>' . esc_html__('To add a new rank to the rank group, click the Add Rank button. A new rank will appear with its settings form open. Fill out its settings and click the save button. If you have changed your mind, you can remove the new rank without saving it by clicking the Cancel button.', 'wordpoints') . '</p> |
|
121 | + <p>' . esc_html__('To edit an existing rank’s settings, click on the Edit link in its title bar. The settings form for that rank will open. You can close the settings form again by clicking the Close link.', 'wordpoints') . '</p> |
|
122 | + <p>' . esc_html__('Once you have modified the rank’s settings as desired, you can save your changes by clicking the Save button. Keep in mind that your changes will take effect immediately, and it is wise to double check that you have all of the settings just as you want them. If you decide that you don’t want to save your changes, click the Cancel button instead, which will reset the form to the rank’s current settings.', 'wordpoints') . '</p>', |
|
123 | 123 | ) |
124 | 124 | ); |
125 | 125 | |
126 | 126 | $screen->add_help_tab( |
127 | 127 | array( |
128 | 128 | 'id' => 'deleting', |
129 | - 'title' => esc_html__( 'Deleting', 'wordpoints' ), |
|
129 | + 'title' => esc_html__('Deleting', 'wordpoints'), |
|
130 | 130 | 'content' => |
131 | - '<p>' . esc_html__( 'If you would like to delete a rank, open its settings form, then click the Delete button. You will be asked to confirm that you want to delete the rank. If you are not sure, click the Cancel button in the confirmation dialog. Once you delete the rank, it is gone!', 'wordpoints' ) . '</p>', |
|
131 | + '<p>' . esc_html__('If you would like to delete a rank, open its settings form, then click the Delete button. You will be asked to confirm that you want to delete the rank. If you are not sure, click the Cancel button in the confirmation dialog. Once you delete the rank, it is gone!', 'wordpoints') . '</p>', |
|
132 | 132 | ) |
133 | 133 | ); |
134 | 134 | |
135 | 135 | $screen->set_help_sidebar( |
136 | - '<p><strong>' . esc_html__( 'For more information:', 'wordpoints' ) . '</strong></p> |
|
137 | - <p><a href="https://wordpoints.org/user-guide/ranks/">' . esc_html__( 'Documentation on Ranks', 'wordpoints' ) . '</a></p> |
|
138 | - <p><a href="https://wordpress.org/support/plugin/wordpoints">' . esc_html__( 'Support Forums', 'wordpoints' ) . '</a></p>' |
|
136 | + '<p><strong>' . esc_html__('For more information:', 'wordpoints') . '</strong></p> |
|
137 | + <p><a href="https://wordpoints.org/user-guide/ranks/">' . esc_html__('Documentation on Ranks', 'wordpoints') . '</a></p> |
|
138 | + <p><a href="https://wordpress.org/support/plugin/wordpoints">' . esc_html__('Support Forums', 'wordpoints') . '</a></p>' |
|
139 | 139 | ); |
140 | 140 | } |
141 | 141 |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | |
41 | 41 | $this->backup['original_blog_id'] = get_current_blog_id(); |
42 | 42 | |
43 | - if ( isset( $GLOBALS['_wp_switched_stack'] ) ) { |
|
43 | + if (isset($GLOBALS['_wp_switched_stack'])) { |
|
44 | 44 | $this->backup['switched_stack'] = $GLOBALS['_wp_switched_stack']; |
45 | 45 | } |
46 | 46 | |
47 | - if ( isset( $GLOBALS['switched'] ) ) { |
|
47 | + if (isset($GLOBALS['switched'])) { |
|
48 | 48 | $this->backup['switched'] = $GLOBALS['switched']; |
49 | 49 | } |
50 | 50 | |
@@ -62,18 +62,18 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function restore() { |
64 | 64 | |
65 | - switch_to_blog( $this->backup['original_blog_id'] ); |
|
65 | + switch_to_blog($this->backup['original_blog_id']); |
|
66 | 66 | |
67 | - if ( isset( $this->backup['switched_stack'] ) ) { |
|
67 | + if (isset($this->backup['switched_stack'])) { |
|
68 | 68 | $GLOBALS['_wp_switched_stack'] = $this->backup['switched_stack']; |
69 | 69 | } else { |
70 | - unset( $GLOBALS['_wp_switched_stack'] ); |
|
70 | + unset($GLOBALS['_wp_switched_stack']); |
|
71 | 71 | } |
72 | 72 | |
73 | - if ( isset( $this->backup['switched'] ) ) { |
|
73 | + if (isset($this->backup['switched'])) { |
|
74 | 74 | $GLOBALS['switched'] = $this->backup['switched']; |
75 | 75 | } else { |
76 | - unset( $GLOBALS['switched'] ); |
|
76 | + unset($GLOBALS['switched']); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | return $this->backup['original_blog_id']; |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * @since 2.1.0 |
96 | 96 | */ |
97 | - public function __construct( $slug, $parent = null ) { |
|
97 | + public function __construct($slug, $parent = null) { |
|
98 | 98 | |
99 | 99 | $this->slug = $slug; |
100 | 100 | $this->full_slug = $slug; |
101 | 101 | |
102 | - if ( $parent instanceof WordPoints_App ) { |
|
102 | + if ($parent instanceof WordPoints_App) { |
|
103 | 103 | $this->parent = $parent; |
104 | 104 | |
105 | - if ( 'apps' !== $this->parent->full_slug ) { |
|
105 | + if ('apps' !== $this->parent->full_slug) { |
|
106 | 106 | $this->full_slug = $this->parent->full_slug . '-' . $this->full_slug; |
107 | 107 | } |
108 | 108 | } |
@@ -122,21 +122,21 @@ discard block |
||
122 | 122 | * @return null|object|WordPoints_App|WordPoints_Class_RegistryI|WordPoints_Class_Registry_ChildrenI|WordPoints_Class_Registry_DeepI |
123 | 123 | * The sub app, or null if not found. |
124 | 124 | */ |
125 | - public function get_sub_app( $slug ) { |
|
125 | + public function get_sub_app($slug) { |
|
126 | 126 | |
127 | - $sub_app = $this->sub_apps->get( $slug, array( $this ) ); |
|
127 | + $sub_app = $this->sub_apps->get($slug, array($this)); |
|
128 | 128 | |
129 | - if ( ! $sub_app ) { |
|
129 | + if ( ! $sub_app) { |
|
130 | 130 | return null; |
131 | 131 | } |
132 | 132 | |
133 | 133 | if ( |
134 | - empty( $this->did_init[ $slug ] ) |
|
134 | + empty($this->did_init[$slug]) |
|
135 | 135 | && ! self::$main->silent |
136 | - && $this->should_do_registry_init( $sub_app ) |
|
136 | + && $this->should_do_registry_init($sub_app) |
|
137 | 137 | ) { |
138 | 138 | |
139 | - $this->did_init[ $slug ] = true; |
|
139 | + $this->did_init[$slug] = true; |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * Initialization of an app registry. |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param WordPoints_Class_RegistryI|WordPoints_Class_Registry_ChildrenI |
147 | 147 | * $registry The registry object. |
148 | 148 | */ |
149 | - do_action( "wordpoints_init_app_registry-{$this->full_slug}-{$slug}", $sub_app ); |
|
149 | + do_action("wordpoints_init_app_registry-{$this->full_slug}-{$slug}", $sub_app); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | return $sub_app; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return bool Whether to call the init action or not. |
174 | 174 | */ |
175 | - protected function should_do_registry_init( $registry ) { |
|
175 | + protected function should_do_registry_init($registry) { |
|
176 | 176 | return ( |
177 | 177 | $registry instanceof WordPoints_Class_RegistryI |
178 | 178 | || $registry instanceof WordPoints_Class_Registry_ChildrenI |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param WordPoints_App $app The app object. |
199 | 199 | */ |
200 | - do_action( "wordpoints_init_app-{$this->full_slug}", $this ); |
|
200 | + do_action("wordpoints_init_app-{$this->full_slug}", $this); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | protected function init() { |
41 | 41 | |
42 | 42 | $sub_apps = $this->sub_apps; |
43 | - $sub_apps->register( 'router', 'WordPoints_Hook_Router' ); |
|
44 | - $sub_apps->register( 'actions', 'WordPoints_Hook_Actions' ); |
|
45 | - $sub_apps->register( 'events', 'WordPoints_Hook_Events' ); |
|
46 | - $sub_apps->register( 'reactors', 'WordPoints_Class_Registry_Persistent' ); |
|
47 | - $sub_apps->register( 'reaction_stores', 'WordPoints_Class_Registry_Children' ); |
|
48 | - $sub_apps->register( 'extensions', 'WordPoints_Class_Registry_Persistent' ); |
|
49 | - $sub_apps->register( 'conditions', 'WordPoints_Class_Registry_Children' ); |
|
43 | + $sub_apps->register('router', 'WordPoints_Hook_Router'); |
|
44 | + $sub_apps->register('actions', 'WordPoints_Hook_Actions'); |
|
45 | + $sub_apps->register('events', 'WordPoints_Hook_Events'); |
|
46 | + $sub_apps->register('reactors', 'WordPoints_Class_Registry_Persistent'); |
|
47 | + $sub_apps->register('reaction_stores', 'WordPoints_Class_Registry_Children'); |
|
48 | + $sub_apps->register('extensions', 'WordPoints_Class_Registry_Persistent'); |
|
49 | + $sub_apps->register('conditions', 'WordPoints_Class_Registry_Children'); |
|
50 | 50 | |
51 | 51 | parent::init(); |
52 | 52 | } |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function get_current_mode() { |
71 | 71 | |
72 | - if ( ! isset( $this->current_mode ) ) { |
|
73 | - $this->current_mode = ( wordpoints_is_network_context() ? 'network' : 'standard' ); |
|
72 | + if ( ! isset($this->current_mode)) { |
|
73 | + $this->current_mode = (wordpoints_is_network_context() ? 'network' : 'standard'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | return $this->current_mode; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @param string $mode The slug of the mode to set as the current mode. |
90 | 90 | */ |
91 | - public function set_current_mode( $mode ) { |
|
91 | + public function set_current_mode($mode) { |
|
92 | 92 | $this->current_mode = $mode; |
93 | 93 | } |
94 | 94 | |
@@ -101,19 +101,19 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return WordPoints_Hook_Reaction_StoreI|false The reaction storage object. |
103 | 103 | */ |
104 | - public function get_reaction_store( $slug ) { |
|
104 | + public function get_reaction_store($slug) { |
|
105 | 105 | |
106 | - $reaction_store = $this->get_sub_app( 'reaction_stores' )->get( |
|
106 | + $reaction_store = $this->get_sub_app('reaction_stores')->get( |
|
107 | 107 | $this->get_current_mode() |
108 | 108 | , $slug |
109 | 109 | ); |
110 | 110 | |
111 | - if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) { |
|
111 | + if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) { |
|
112 | 112 | return false; |
113 | 113 | } |
114 | 114 | |
115 | 115 | // Allowing access to stores out-of-context would lead to strange behavior. |
116 | - if ( false === $reaction_store->get_context_id() ) { |
|
116 | + if (false === $reaction_store->get_context_id()) { |
|
117 | 117 | return false; |
118 | 118 | } |
119 | 119 | |
@@ -129,30 +129,30 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return WordPoints_Hook_Reaction_StoreI[] The reaction stores with this slug. |
131 | 131 | */ |
132 | - public function get_reaction_stores( $slug ) { |
|
132 | + public function get_reaction_stores($slug) { |
|
133 | 133 | |
134 | - $reaction_stores = $this->get_sub_app( 'reaction_stores' ); |
|
134 | + $reaction_stores = $this->get_sub_app('reaction_stores'); |
|
135 | 135 | |
136 | 136 | $stores = array(); |
137 | 137 | |
138 | - foreach ( $reaction_stores->get_all_slugs() as $mode => $slugs ) { |
|
138 | + foreach ($reaction_stores->get_all_slugs() as $mode => $slugs) { |
|
139 | 139 | |
140 | - if ( ! in_array( $slug, $slugs ) ) { |
|
140 | + if ( ! in_array($slug, $slugs)) { |
|
141 | 141 | continue; |
142 | 142 | } |
143 | 143 | |
144 | - $store = $reaction_stores->get( $mode, $slug, array( $mode ) ); |
|
144 | + $store = $reaction_stores->get($mode, $slug, array($mode)); |
|
145 | 145 | |
146 | - if ( ! $store instanceof WordPoints_Hook_Reaction_StoreI ) { |
|
146 | + if ( ! $store instanceof WordPoints_Hook_Reaction_StoreI) { |
|
147 | 147 | continue; |
148 | 148 | } |
149 | 149 | |
150 | 150 | // Allowing access to stores out-of-context would lead to strange behavior. |
151 | - if ( false === $store->get_context_id() ) { |
|
151 | + if (false === $store->get_context_id()) { |
|
152 | 152 | continue; |
153 | 153 | } |
154 | 154 | |
155 | - $stores[ $mode ] = $store; |
|
155 | + $stores[$mode] = $store; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | return $stores; |
@@ -174,19 +174,19 @@ discard block |
||
174 | 174 | $action_type |
175 | 175 | ) { |
176 | 176 | |
177 | - foreach ( $this->get_sub_app( 'reaction_stores' )->get_all() as $reaction_stores ) { |
|
178 | - foreach ( $reaction_stores as $reaction_store ) { |
|
177 | + foreach ($this->get_sub_app('reaction_stores')->get_all() as $reaction_stores) { |
|
178 | + foreach ($reaction_stores as $reaction_store) { |
|
179 | 179 | |
180 | - if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI ) { |
|
180 | + if ( ! $reaction_store instanceof WordPoints_Hook_Reaction_StoreI) { |
|
181 | 181 | continue; |
182 | 182 | } |
183 | 183 | |
184 | 184 | // Allowing access to stores out-of-context would lead to strange behavior. |
185 | - if ( false === $reaction_store->get_context_id() ) { |
|
185 | + if (false === $reaction_store->get_context_id()) { |
|
186 | 186 | continue; |
187 | 187 | } |
188 | 188 | |
189 | - foreach ( $reaction_store->get_reactions_to_event( $event_slug ) as $reaction ) { |
|
189 | + foreach ($reaction_store->get_reactions_to_event($event_slug) as $reaction) { |
|
190 | 190 | |
191 | 191 | $fire = new WordPoints_Hook_Fire( |
192 | 192 | $event_args |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | , $action_type |
195 | 195 | ); |
196 | 196 | |
197 | - $this->fire_reaction( $fire ); |
|
197 | + $this->fire_reaction($fire); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | } |
@@ -207,32 +207,32 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param WordPoints_Hook_Fire $fire The hook fire object. |
209 | 209 | */ |
210 | - protected function fire_reaction( $fire ) { |
|
210 | + protected function fire_reaction($fire) { |
|
211 | 211 | |
212 | 212 | /** @var WordPoints_Hook_ReactorI $reactor */ |
213 | - $reactor = $this->get_sub_app( 'reactors' )->get( $fire->reaction->get_reactor_slug() ); |
|
213 | + $reactor = $this->get_sub_app('reactors')->get($fire->reaction->get_reactor_slug()); |
|
214 | 214 | |
215 | - if ( ! in_array( $fire->action_type, $reactor->get_action_types(), true ) ) { |
|
215 | + if ( ! in_array($fire->action_type, $reactor->get_action_types(), true)) { |
|
216 | 216 | return; |
217 | 217 | } |
218 | 218 | |
219 | - $validator = new WordPoints_Hook_Reaction_Validator( $fire->reaction, true ); |
|
219 | + $validator = new WordPoints_Hook_Reaction_Validator($fire->reaction, true); |
|
220 | 220 | $validator->validate(); |
221 | 221 | |
222 | - if ( $validator->had_errors() ) { |
|
222 | + if ($validator->had_errors()) { |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | |
226 | - unset( $validator ); |
|
226 | + unset($validator); |
|
227 | 227 | |
228 | 228 | /** @var WordPoints_Hook_ExtensionI[] $extensions */ |
229 | - $extensions = $this->get_sub_app( 'extensions' )->get_all(); |
|
229 | + $extensions = $this->get_sub_app('extensions')->get_all(); |
|
230 | 230 | |
231 | - foreach ( $extensions as $extension ) { |
|
232 | - if ( ! $extension->should_hit( $fire ) ) { |
|
233 | - foreach ( $extensions as $ext ) { |
|
234 | - if ( $ext instanceof WordPoints_Hook_Extension_Miss_ListenerI ) { |
|
235 | - $ext->after_miss( $fire ); |
|
231 | + foreach ($extensions as $extension) { |
|
232 | + if ( ! $extension->should_hit($fire)) { |
|
233 | + foreach ($extensions as $ext) { |
|
234 | + if ($ext instanceof WordPoints_Hook_Extension_Miss_ListenerI) { |
|
235 | + $ext->after_miss($fire); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | |
243 | 243 | $fire->hit(); |
244 | 244 | |
245 | - $reactor->hit( $fire ); |
|
245 | + $reactor->hit($fire); |
|
246 | 246 | |
247 | - foreach ( $extensions as $extension ) { |
|
248 | - if ( $extension instanceof WordPoints_Hook_Extension_Hit_ListenerI ) { |
|
249 | - $extension->after_hit( $fire ); |
|
247 | + foreach ($extensions as $extension) { |
|
248 | + if ($extension instanceof WordPoints_Hook_Extension_Hit_ListenerI) { |
|
249 | + $extension->after_hit($fire); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
@@ -62,24 +62,24 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param string $dir The full path of the directory. |
64 | 64 | */ |
65 | - public static function register_dir( $dir ) { |
|
65 | + public static function register_dir($dir) { |
|
66 | 66 | |
67 | - if ( ! isset( self::$spl_enabled ) ) { |
|
67 | + if ( ! isset(self::$spl_enabled)) { |
|
68 | 68 | |
69 | - self::$spl_enabled = function_exists( 'spl_autoload_register' ); |
|
69 | + self::$spl_enabled = function_exists('spl_autoload_register'); |
|
70 | 70 | |
71 | - if ( self::$spl_enabled ) { |
|
72 | - spl_autoload_register( __CLASS__ . '::load_class' ); |
|
71 | + if (self::$spl_enabled) { |
|
72 | + spl_autoload_register(__CLASS__ . '::load_class'); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - $dir = trailingslashit( $dir ); |
|
76 | + $dir = trailingslashit($dir); |
|
77 | 77 | |
78 | - self::$dirs[ $dir ] = require( $dir . '/index.php' ); |
|
78 | + self::$dirs[$dir] = require($dir . '/index.php'); |
|
79 | 79 | |
80 | - if ( ! self::$spl_enabled ) { |
|
81 | - foreach ( self::$dirs[ $dir ] as $file ) { |
|
82 | - require_once( $dir . $file ); |
|
80 | + if ( ! self::$spl_enabled) { |
|
81 | + foreach (self::$dirs[$dir] as $file) { |
|
82 | + require_once($dir . $file); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @param string $class_name The name fo the class to load. |
93 | 93 | */ |
94 | - public static function load_class( $class_name ) { |
|
94 | + public static function load_class($class_name) { |
|
95 | 95 | |
96 | - $class_name = strtolower( $class_name ); |
|
96 | + $class_name = strtolower($class_name); |
|
97 | 97 | |
98 | - foreach ( self::$dirs as $dir => $map ) { |
|
99 | - if ( isset( $map[ $class_name ] ) ) { |
|
100 | - require_once( $dir . $map[ $class_name ] ); |
|
98 | + foreach (self::$dirs as $dir => $map) { |
|
99 | + if (isset($map[$class_name])) { |
|
100 | + require_once($dir . $map[$class_name]); |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return object[] The child objects, indexed by slug. |
30 | 30 | */ |
31 | - public function get_children( array $parent_slugs = array() ); |
|
31 | + public function get_children(array $parent_slugs = array()); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Get the slugs of all of the direct children of a certain parent. |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return string[] The child slugs. |
41 | 41 | */ |
42 | - public function get_children_slugs( array $parent_slugs = array() ); |
|
42 | + public function get_children_slugs(array $parent_slugs = array()); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Get an object by its slug. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return false|object The object or false on failure. |
54 | 54 | */ |
55 | - public function get( $slug, array $parent_slugs = array() ); |
|
55 | + public function get($slug, array $parent_slugs = array()); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Register a type of object. |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return bool Whether the class was registered successfully. |
68 | 68 | */ |
69 | - public function register( $slug, array $parent_slugs, $class, array $args = array() ); |
|
69 | + public function register($slug, array $parent_slugs, $class, array $args = array()); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Deregister a type of object. |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param string[] $parent_slugs The slug(s) of the class's parent(s) in the |
78 | 78 | * hierarchy. |
79 | 79 | */ |
80 | - public function deregister( $slug, array $parent_slugs = array() ); |
|
80 | + public function deregister($slug, array $parent_slugs = array()); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Deregister all children of a particular parent in the hierarchy. |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param string[] $parent_slugs The hierarchy of the parent. |
88 | 88 | */ |
89 | - public function deregister_children( array $parent_slugs = array() ); |
|
89 | + public function deregister_children(array $parent_slugs = array()); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Check if a type of object is registered by its slug. |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return bool Whether the class is registered. |
103 | 103 | */ |
104 | - public function is_registered( $slug, array $parent_slugs = array() ); |
|
104 | + public function is_registered($slug, array $parent_slugs = array()); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | // EOF |
@@ -76,6 +76,7 @@ discard block |
||
76 | 76 | * @param string $slug The slug of the class to deregister. |
77 | 77 | * @param string[] $parent_slugs The slug(s) of the class's parent(s) in the |
78 | 78 | * hierarchy. |
79 | + * @return void |
|
79 | 80 | */ |
80 | 81 | public function deregister( $slug, array $parent_slugs = array() ); |
81 | 82 | |
@@ -85,6 +86,7 @@ discard block |
||
85 | 86 | * @since 2.2.0 |
86 | 87 | * |
87 | 88 | * @param string[] $parent_slugs The hierarchy of the parent. |
89 | + * @return void |
|
88 | 90 | */ |
89 | 91 | public function deregister_children( array $parent_slugs = array() ); |
90 | 92 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return object[] The child objects, indexed by slug. |
48 | 48 | */ |
49 | - public function get_children( $parent_slug ); |
|
49 | + public function get_children($parent_slug); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Get the slugs of all of the classes that are children of a certain parent. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return string[] The child slugs. |
59 | 59 | */ |
60 | - public function get_children_slugs( $parent_slug ); |
|
60 | + public function get_children_slugs($parent_slug); |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Get an object by its slug. |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return object|false The object or false on failure. |
71 | 71 | */ |
72 | - public function get( $parent_slug, $slug ); |
|
72 | + public function get($parent_slug, $slug); |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * Register a type of object. |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return bool Whether the class was registered successfully. |
85 | 85 | */ |
86 | - public function register( $parent_slug, $slug, $class, array $args = array() ); |
|
86 | + public function register($parent_slug, $slug, $class, array $args = array()); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Deregister a type of object. |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $parent_slug The group slug. |
94 | 94 | * @param string $slug The slug of the class to deregister. |
95 | 95 | */ |
96 | - public function deregister( $parent_slug, $slug ); |
|
96 | + public function deregister($parent_slug, $slug); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Deregister all children of a particular parent. |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @param string $parent_slug The group slug. |
104 | 104 | */ |
105 | - public function deregister_children( $parent_slug ); |
|
105 | + public function deregister_children($parent_slug); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Check if a type of object is registered by its slug. |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @return bool Whether the class is registered. |
119 | 119 | */ |
120 | - public function is_registered( $parent_slug, $slug = null ); |
|
120 | + public function is_registered($parent_slug, $slug = null); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // EOF |
@@ -92,6 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @param string $parent_slug The group slug. |
94 | 94 | * @param string $slug The slug of the class to deregister. |
95 | + * @return void |
|
95 | 96 | */ |
96 | 97 | public function deregister( $parent_slug, $slug ); |
97 | 98 | |
@@ -101,6 +102,7 @@ discard block |
||
101 | 102 | * @since 2.1.0 |
102 | 103 | * |
103 | 104 | * @param string $parent_slug The group slug. |
105 | + * @return void |
|
104 | 106 | */ |
105 | 107 | public function deregister_children( $parent_slug ); |
106 | 108 |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * @since 2.1.0 |
52 | 52 | */ |
53 | - public function get_all( array $args = array() ) { |
|
53 | + public function get_all(array $args = array()) { |
|
54 | 54 | |
55 | 55 | $items = array(); |
56 | 56 | |
57 | - if ( $this->settings['pass_slugs'] ) { |
|
58 | - array_unshift( $args, null ); |
|
57 | + if ($this->settings['pass_slugs']) { |
|
58 | + array_unshift($args, null); |
|
59 | 59 | } |
60 | 60 | |
61 | - foreach ( $this->classes as $parent_slug => $classes ) { |
|
62 | - $items[ $parent_slug ] = WordPoints_Class_Registry::construct_with_args( |
|
61 | + foreach ($this->classes as $parent_slug => $classes) { |
|
62 | + $items[$parent_slug] = WordPoints_Class_Registry::construct_with_args( |
|
63 | 63 | $classes |
64 | - , $this->settings['pass_slugs'] ? array( $parent_slug ) + $args : $args |
|
64 | + , $this->settings['pass_slugs'] ? array($parent_slug) + $args : $args |
|
65 | 65 | , $this->settings |
66 | 66 | ); |
67 | 67 | } |
@@ -73,24 +73,24 @@ discard block |
||
73 | 73 | * @since 2.1.0 |
74 | 74 | */ |
75 | 75 | public function get_all_slugs() { |
76 | - return array_map( 'array_keys', $this->classes ); |
|
76 | + return array_map('array_keys', $this->classes); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @since 2.1.0 |
81 | 81 | */ |
82 | - public function get_children( $parent_slug, array $args = array() ) { |
|
82 | + public function get_children($parent_slug, array $args = array()) { |
|
83 | 83 | |
84 | 84 | $items = array(); |
85 | 85 | |
86 | - if ( isset( $this->classes[ $parent_slug ] ) ) { |
|
86 | + if (isset($this->classes[$parent_slug])) { |
|
87 | 87 | |
88 | - if ( $this->settings['pass_slugs'] ) { |
|
89 | - array_unshift( $args, $parent_slug ); |
|
88 | + if ($this->settings['pass_slugs']) { |
|
89 | + array_unshift($args, $parent_slug); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | $items = WordPoints_Class_Registry::construct_with_args( |
93 | - $this->classes[ $parent_slug ] |
|
93 | + $this->classes[$parent_slug] |
|
94 | 94 | , $args |
95 | 95 | , $this->settings |
96 | 96 | ); |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | /** |
103 | 103 | * @since 2.1.0 |
104 | 104 | */ |
105 | - public function get_children_slugs( $parent_slug ) { |
|
105 | + public function get_children_slugs($parent_slug) { |
|
106 | 106 | |
107 | 107 | $slugs = array(); |
108 | 108 | |
109 | - if ( isset( $this->classes[ $parent_slug ] ) ) { |
|
110 | - $slugs = array_keys( $this->classes[ $parent_slug ] ); |
|
109 | + if (isset($this->classes[$parent_slug])) { |
|
110 | + $slugs = array_keys($this->classes[$parent_slug]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $slugs; |
@@ -116,38 +116,38 @@ discard block |
||
116 | 116 | /** |
117 | 117 | * @since 2.1.0 |
118 | 118 | */ |
119 | - public function get( $parent_slug, $slug, array $args = array() ) { |
|
119 | + public function get($parent_slug, $slug, array $args = array()) { |
|
120 | 120 | |
121 | - if ( ! isset( $this->classes[ $parent_slug ][ $slug ] ) ) { |
|
121 | + if ( ! isset($this->classes[$parent_slug][$slug])) { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | 124 | |
125 | - $class = $this->classes[ $parent_slug ][ $slug ]; |
|
125 | + $class = $this->classes[$parent_slug][$slug]; |
|
126 | 126 | |
127 | - if ( empty( $args ) ) { |
|
127 | + if (empty($args)) { |
|
128 | 128 | |
129 | - if ( $this->settings['pass_slugs'] ) { |
|
130 | - return new $class( $slug, $parent_slug ); |
|
129 | + if ($this->settings['pass_slugs']) { |
|
130 | + return new $class($slug, $parent_slug); |
|
131 | 131 | } else { |
132 | 132 | return new $class(); |
133 | 133 | } |
134 | 134 | |
135 | 135 | } else { |
136 | 136 | |
137 | - if ( $this->settings['pass_slugs'] ) { |
|
138 | - array_unshift( $args, $slug, $parent_slug ); |
|
137 | + if ($this->settings['pass_slugs']) { |
|
138 | + array_unshift($args, $slug, $parent_slug); |
|
139 | 139 | } |
140 | 140 | |
141 | - return wordpoints_construct_class_with_args( $class, $args ); |
|
141 | + return wordpoints_construct_class_with_args($class, $args); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @since 2.1.0 |
147 | 147 | */ |
148 | - public function register( $parent_slug, $slug, $class, array $args = array() ) { |
|
148 | + public function register($parent_slug, $slug, $class, array $args = array()) { |
|
149 | 149 | |
150 | - $this->classes[ $parent_slug ][ $slug ] = $class; |
|
150 | + $this->classes[$parent_slug][$slug] = $class; |
|
151 | 151 | |
152 | 152 | return true; |
153 | 153 | } |
@@ -155,26 +155,26 @@ discard block |
||
155 | 155 | /** |
156 | 156 | * @since 2.1.0 |
157 | 157 | */ |
158 | - public function deregister( $parent_slug, $slug ) { |
|
159 | - unset( $this->classes[ $parent_slug ][ $slug ] ); |
|
158 | + public function deregister($parent_slug, $slug) { |
|
159 | + unset($this->classes[$parent_slug][$slug]); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | 163 | * @since 2.1.0 |
164 | 164 | */ |
165 | - public function deregister_children( $parent_slug ) { |
|
166 | - unset( $this->classes[ $parent_slug ] ); |
|
165 | + public function deregister_children($parent_slug) { |
|
166 | + unset($this->classes[$parent_slug]); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
170 | 170 | * @since 2.1.0 |
171 | 171 | */ |
172 | - public function is_registered( $parent_slug, $slug = null ) { |
|
172 | + public function is_registered($parent_slug, $slug = null) { |
|
173 | 173 | |
174 | - if ( isset( $slug ) ) { |
|
175 | - return isset( $this->classes[ $parent_slug ][ $slug ] ); |
|
174 | + if (isset($slug)) { |
|
175 | + return isset($this->classes[$parent_slug][$slug]); |
|
176 | 176 | } else { |
177 | - return isset( $this->classes[ $parent_slug ] ); |
|
177 | + return isset($this->classes[$parent_slug]); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | } |