@@ -1,93 +1,93 @@ |
||
1 | 1 | <div class="padding"> |
2 | 2 | <?php esc_html_e( |
3 | - 'If you want to integrate with Event Espresso or participate in building code, then you are in the right place. The following resources can help you get started.', |
|
4 | - 'event_espresso' |
|
5 | - ); ?> |
|
3 | + 'If you want to integrate with Event Espresso or participate in building code, then you are in the right place. The following resources can help you get started.', |
|
4 | + 'event_espresso' |
|
5 | + ); ?> |
|
6 | 6 | <h2><?php esc_html_e('Developer Resources', 'event_espresso'); ?></h2> |
7 | 7 | <ul> |
8 | 8 | <li> |
9 | 9 | <?php printf( |
10 | - esc_html__('%1$sEvent Espresso 4 Developer Documentation%2$s', 'event_espresso'), |
|
11 | - '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs#getting-started-with-the-ee-developer-docs" target="_blank" rel="noopener noreferrer">', |
|
12 | - '</a>' |
|
13 | - ); ?></li> |
|
10 | + esc_html__('%1$sEvent Espresso 4 Developer Documentation%2$s', 'event_espresso'), |
|
11 | + '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs#getting-started-with-the-ee-developer-docs" target="_blank" rel="noopener noreferrer">', |
|
12 | + '</a>' |
|
13 | + ); ?></li> |
|
14 | 14 | <li> |
15 | 15 | <?php printf( |
16 | - esc_html__('%1$sEvent Espresso 4 Developer News%2$s', 'event_espresso'), |
|
17 | - '<a href="http://developer.eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
18 | - '</a>' |
|
19 | - ); ?></li> |
|
16 | + esc_html__('%1$sEvent Espresso 4 Developer News%2$s', 'event_espresso'), |
|
17 | + '<a href="http://developer.eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
18 | + '</a>' |
|
19 | + ); ?></li> |
|
20 | 20 | <li> |
21 | 21 | <?php printf( |
22 | - esc_html__('%1$sApply%2$s to be listed as an %3$sEvent Espresso Professional%2$s', 'event_espresso'), |
|
23 | - '<a href="https://eventespresso.com/developers/event-espresso-pros-application/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
24 | - '</a>', |
|
25 | - '<a href="https://eventespresso.com/developers/event-espresso-pros/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">' |
|
26 | - ); ?></li> |
|
22 | + esc_html__('%1$sApply%2$s to be listed as an %3$sEvent Espresso Professional%2$s', 'event_espresso'), |
|
23 | + '<a href="https://eventespresso.com/developers/event-espresso-pros-application/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
24 | + '</a>', |
|
25 | + '<a href="https://eventespresso.com/developers/event-espresso-pros/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">' |
|
26 | + ); ?></li> |
|
27 | 27 | </ul> |
28 | 28 | |
29 | 29 | <h2><?php esc_html_e('Event Espresso 4 Articles for Developers', 'event_espresso'); ?></h2> |
30 | 30 | <ul> |
31 | 31 | <li> |
32 | 32 | <?php printf( |
33 | - esc_html__('%1$sCustom Post Types Usage%2$s', 'event_espresso'), |
|
34 | - '<a href="https://eventespresso.com/2014/02/epsresso-brewery-custom-post-types-event-espresso/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
35 | - '</a>' |
|
36 | - ); ?></li> |
|
33 | + esc_html__('%1$sCustom Post Types Usage%2$s', 'event_espresso'), |
|
34 | + '<a href="https://eventespresso.com/2014/02/epsresso-brewery-custom-post-types-event-espresso/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
35 | + '</a>' |
|
36 | + ); ?></li> |
|
37 | 37 | <li> |
38 | 38 | <?php printf( |
39 | - esc_html__('%1$sTheme Development%2$s', 'event_espresso'), |
|
40 | - '<a href="https://eventespresso.com/2014/02/developers-corner-theming-event-espresso-4/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
41 | - '</a>' |
|
42 | - ); ?></li> |
|
39 | + esc_html__('%1$sTheme Development%2$s', 'event_espresso'), |
|
40 | + '<a href="https://eventespresso.com/2014/02/developers-corner-theming-event-espresso-4/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
41 | + '</a>' |
|
42 | + ); ?></li> |
|
43 | 43 | <li> |
44 | 44 | <?php printf( |
45 | - esc_html__('%1$sCapability System%2$s', 'event_espresso'), |
|
46 | - '<a href="http://developer.eventespresso.com/docs/ee-capability-system-overview/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
47 | - '</a>' |
|
48 | - ); ?></li> |
|
45 | + esc_html__('%1$sCapability System%2$s', 'event_espresso'), |
|
46 | + '<a href="http://developer.eventespresso.com/docs/ee-capability-system-overview/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
47 | + '</a>' |
|
48 | + ); ?></li> |
|
49 | 49 | <li> |
50 | 50 | <?php printf( |
51 | - esc_html__('%1$sPayment Method Development%2$s', 'event_espresso'), |
|
52 | - '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/L--Payment-Methods-and-Gateways/creating-a-payment-method.md" target="_blank" rel="noopener noreferrer">', |
|
53 | - '</a>' |
|
54 | - ); ?></li> |
|
51 | + esc_html__('%1$sPayment Method Development%2$s', 'event_espresso'), |
|
52 | + '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/L--Payment-Methods-and-Gateways/creating-a-payment-method.md" target="_blank" rel="noopener noreferrer">', |
|
53 | + '</a>' |
|
54 | + ); ?></li> |
|
55 | 55 | <li> |
56 | 56 | <?php printf( |
57 | - esc_html__('%1$sMessages System in Event Espresso 4%2$s', 'event_espresso'), |
|
58 | - '<a href="https://eventespresso.com/2014/03/messages-systemyour-tool-getting-word/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
59 | - '</a>' |
|
60 | - ); ?></li> |
|
57 | + esc_html__('%1$sMessages System in Event Espresso 4%2$s', 'event_espresso'), |
|
58 | + '<a href="https://eventespresso.com/2014/03/messages-systemyour-tool-getting-word/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
59 | + '</a>' |
|
60 | + ); ?></li> |
|
61 | 61 | <li> |
62 | 62 | <?php printf( |
63 | - esc_html__( |
|
64 | - '%1$sDatabase Model System%2$s (used for interfacing with EE4 data via WordPress plugins and server side querying)', |
|
65 | - 'event_espresso' |
|
66 | - ), |
|
67 | - '<a href="http://developer.eventespresso.com/docs/using-ee4-model-objects/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
68 | - '</a>' |
|
69 | - ); ?></li> |
|
63 | + esc_html__( |
|
64 | + '%1$sDatabase Model System%2$s (used for interfacing with EE4 data via WordPress plugins and server side querying)', |
|
65 | + 'event_espresso' |
|
66 | + ), |
|
67 | + '<a href="http://developer.eventespresso.com/docs/using-ee4-model-objects/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=ee_support_page&utm_content=developers_tab" target="_blank">', |
|
68 | + '</a>' |
|
69 | + ); ?></li> |
|
70 | 70 | </ul> |
71 | 71 | |
72 | 72 | <h2><?php esc_html_e('REST API Resources', 'event_espresso'); ?></h2> |
73 | 73 | <ul> |
74 | 74 | <li> |
75 | 75 | <?php printf( |
76 | - esc_html__('%1$sREST API: Introduction%2$s', 'event_espresso'), |
|
77 | - '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-introduction.md" target="_blank" rel="noopener noreferrer">', |
|
78 | - '</a>' |
|
79 | - ); ?></li> |
|
76 | + esc_html__('%1$sREST API: Introduction%2$s', 'event_espresso'), |
|
77 | + '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-introduction.md" target="_blank" rel="noopener noreferrer">', |
|
78 | + '</a>' |
|
79 | + ); ?></li> |
|
80 | 80 | <li> |
81 | 81 | <?php printf( |
82 | - esc_html__('%1$sREST API: Reading Data%2$s', 'event_espresso'), |
|
83 | - '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-reading-data.md" target="_blank" rel="noopener noreferrer">', |
|
84 | - '</a>' |
|
85 | - ); ?></li> |
|
82 | + esc_html__('%1$sREST API: Reading Data%2$s', 'event_espresso'), |
|
83 | + '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/C--REST-API/ee4-rest-api-reading-data.md" target="_blank" rel="noopener noreferrer">', |
|
84 | + '</a>' |
|
85 | + ); ?></li> |
|
86 | 86 | <li> |
87 | 87 | <?php printf( |
88 | - esc_html__('%1$sBuilding an EE4 Add-on Using the REST API%2$s', 'event_espresso'), |
|
89 | - '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/T--Tutorials/building-an-ee4-addon-that-uses-angular-js-and-the-ee4-json-rest-api.md" target="_blank" rel="noopener noreferrer">', |
|
90 | - '</a>' |
|
91 | - ); ?></li> |
|
88 | + esc_html__('%1$sBuilding an EE4 Add-on Using the REST API%2$s', 'event_espresso'), |
|
89 | + '<a href="https://github.com/eventespresso/event-espresso-core/blob/master/docs/T--Tutorials/building-an-ee4-addon-that-uses-angular-js-and-the-ee4-json-rest-api.md" target="_blank" rel="noopener noreferrer">', |
|
90 | + '</a>' |
|
91 | + ); ?></li> |
|
92 | 92 | </ul> |
93 | 93 | </div> |
94 | 94 | \ No newline at end of file |
@@ -11,20 +11,20 @@ discard block |
||
11 | 11 | </th> |
12 | 12 | <td> |
13 | 13 | <?php echo EEH_Form_Fields::select_input( |
14 | - 'use_google_maps', |
|
15 | - $values, |
|
16 | - $map_settings->use_google_maps, |
|
17 | - 'id="ee-display-map-no-shortcodes"' |
|
18 | - ); ?> |
|
14 | + 'use_google_maps', |
|
15 | + $values, |
|
16 | + $map_settings->use_google_maps, |
|
17 | + 'id="ee-display-map-no-shortcodes"' |
|
18 | + ); ?> |
|
19 | 19 | <p class="description"> |
20 | 20 | <?php esc_html_e( |
21 | - 'Turn Google maps on or off site wide for Event Espresso.', |
|
22 | - 'event_espresso' |
|
23 | - ); ?></p> |
|
21 | + 'Turn Google maps on or off site wide for Event Espresso.', |
|
22 | + 'event_espresso' |
|
23 | + ); ?></p> |
|
24 | 24 | </td> |
25 | 25 | </tr> |
26 | 26 | <?php |
27 | - if (apply_filters('FHEE__google_map__show_api_key_input', true)) { ?> |
|
27 | + if (apply_filters('FHEE__google_map__show_api_key_input', true)) { ?> |
|
28 | 28 | <tr> |
29 | 29 | <th> |
30 | 30 | <label for="ee-google-map-api-key"> |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | value="<?php echo $map_settings->google_map_api_key; ?>"/> |
37 | 37 | <p class="description"> |
38 | 38 | <?php |
39 | - printf( |
|
40 | - __( |
|
41 | - 'An API key is now required to use the Google Maps API: %1$sclick here to get an API key%2$s', |
|
42 | - 'event_espresso' |
|
43 | - ), |
|
44 | - '<a href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend,geocoding_backend,directions_backend,distance_matrix_backend,elevation_backend,static_maps_backend&keyType=CLIENT_SIDE&reusekey=true" target="_blank" rel="noopener noreferrer">', |
|
45 | - '</a>' |
|
46 | - ); |
|
47 | - ?> |
|
39 | + printf( |
|
40 | + __( |
|
41 | + 'An API key is now required to use the Google Maps API: %1$sclick here to get an API key%2$s', |
|
42 | + 'event_espresso' |
|
43 | + ), |
|
44 | + '<a href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend,geocoding_backend,directions_backend,distance_matrix_backend,elevation_backend,static_maps_backend&keyType=CLIENT_SIDE&reusekey=true" target="_blank" rel="noopener noreferrer">', |
|
45 | + '</a>' |
|
46 | + ); |
|
47 | + ?> |
|
48 | 48 | </p> |
49 | 49 | </td> |
50 | 50 | </tr> |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | </th> |
106 | 106 | <td> |
107 | 107 | <?php echo EEH_Form_Fields::select_input( |
108 | - 'event_details_display_nav', |
|
109 | - $values, |
|
110 | - $map_settings->event_details_display_nav, |
|
111 | - 'id="event_details_display_nav" ' |
|
112 | - ); ?> |
|
108 | + 'event_details_display_nav', |
|
109 | + $values, |
|
110 | + $map_settings->event_details_display_nav, |
|
111 | + 'id="event_details_display_nav" ' |
|
112 | + ); ?> |
|
113 | 113 | </td> |
114 | 114 | </tr> |
115 | 115 | |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | </th> |
122 | 122 | <td> |
123 | 123 | <?php echo EEH_Form_Fields::select_input( |
124 | - 'event_details_nav_size', |
|
125 | - $values, |
|
126 | - $map_settings->event_details_nav_size, |
|
127 | - 'id="event_details_nav_size"' |
|
128 | - ); ?> |
|
124 | + 'event_details_nav_size', |
|
125 | + $values, |
|
126 | + $map_settings->event_details_nav_size, |
|
127 | + 'id="event_details_nav_size"' |
|
128 | + ); ?> |
|
129 | 129 | </td> |
130 | 130 | </tr> |
131 | 131 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | <td> |
137 | 137 | <label for="event_details_control_type-default" class="ee-admin-radio-lbl"> |
138 | 138 | <?php $checked = $map_settings->event_details_control_type == 'default' ? 'checked="checked"' |
139 | - : ''; ?> |
|
139 | + : ''; ?> |
|
140 | 140 | <input id="event_details_control_type-default" type="radio" name="event_details_control_type" |
141 | 141 | value="default"<?php echo $checked; ?>/> |
142 | 142 | <?php esc_html_e(' Default', 'event_espresso') ?> |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | <label for="event_details_control_type-horizontal" class="ee-admin-radio-lbl"> |
146 | 146 | <?php $checked = $map_settings->event_details_control_type == 'horizontal' ? 'checked="checked"' |
147 | - : ''; ?> |
|
147 | + : ''; ?> |
|
148 | 148 | <input id="event_details_control_type-horizontal" type="radio" name="event_details_control_type" |
149 | 149 | value="horizontal"<?php echo $checked; ?>/> |
150 | 150 | <?php esc_html_e(' Horizontal', 'event_espresso') ?> |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | <label for="event_details_control_type-dropdown" class="ee-admin-radio-lbl"> |
154 | 154 | <?php $checked = $map_settings->event_details_control_type == 'dropdown' ? 'checked="checked"' |
155 | - : ''; ?> |
|
155 | + : ''; ?> |
|
156 | 156 | <input id="event_details_control_type-dropdown" type="radio" name="event_details_control_type" |
157 | 157 | value="dropdown"<?php echo $checked; ?>/> |
158 | 158 | <?php esc_html_e(' Dropdown', 'event_espresso') ?> |
@@ -246,11 +246,11 @@ discard block |
||
246 | 246 | </th> |
247 | 247 | <td> |
248 | 248 | <?php echo EEH_Form_Fields::select_input( |
249 | - 'event_list_display_nav', |
|
250 | - $values, |
|
251 | - $map_settings->event_list_display_nav, |
|
252 | - 'id="event_list_display_nav"' |
|
253 | - ); ?> |
|
249 | + 'event_list_display_nav', |
|
250 | + $values, |
|
251 | + $map_settings->event_list_display_nav, |
|
252 | + 'id="event_list_display_nav"' |
|
253 | + ); ?> |
|
254 | 254 | </td> |
255 | 255 | </tr> |
256 | 256 | |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | </th> |
263 | 263 | <td> |
264 | 264 | <?php echo EEH_Form_Fields::select_input( |
265 | - 'event_list_nav_size', |
|
266 | - $values, |
|
267 | - $map_settings->event_list_nav_size, |
|
268 | - 'id="event_list_nav_size"' |
|
269 | - ); ?> |
|
265 | + 'event_list_nav_size', |
|
266 | + $values, |
|
267 | + $map_settings->event_list_nav_size, |
|
268 | + 'id="event_list_nav_size"' |
|
269 | + ); ?> |
|
270 | 270 | </td> |
271 | 271 | </tr> |
272 | 272 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | <label for="event_list_control_type-horizontal" class="ee-admin-radio-lbl"> |
286 | 286 | <?php $checked = $map_settings->event_list_control_type == 'horizontal' ? 'checked="checked"' |
287 | - : ''; ?> |
|
287 | + : ''; ?> |
|
288 | 288 | <input id="event_list_control_type-horizontal" type="radio" name="event_list_control_type" |
289 | 289 | value="horizontal"<?php echo $checked; ?>/> |
290 | 290 | <?php esc_html_e(' Horizontal', 'event_espresso') ?> |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function isStrangeFilesArray($files_data) |
116 | 116 | { |
117 | - if (!is_array($files_data)) { |
|
117 | + if ( ! is_array($files_data)) { |
|
118 | 118 | throw new UnexpectedValueException( |
119 | 119 | sprintf( |
120 | 120 | esc_html__( |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | ); |
127 | 127 | } |
128 | 128 | $first_value = reset($files_data); |
129 | - if (!is_array($first_value)) { |
|
129 | + if ( ! is_array($first_value)) { |
|
130 | 130 | throw new UnexpectedValueException( |
131 | 131 | sprintf( |
132 | 132 | esc_html__( |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | $sane_files_array = []; |
161 | 161 | foreach ($files_data as $top_level_name => $top_level_children) { |
162 | 162 | $sub_array = []; |
163 | - $sane_files_array[ $top_level_name ] = []; |
|
163 | + $sane_files_array[$top_level_name] = []; |
|
164 | 164 | foreach ($top_level_children as $file_data_part => $second_level_children) { |
165 | 165 | foreach ($second_level_children as $next_level_name => $sub_values) { |
166 | - $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part); |
|
166 | + $sub_array[$next_level_name] = $this->organizeFilesData($sub_values, $file_data_part); |
|
167 | 167 | } |
168 | - $sane_files_array[ $top_level_name ] = array_replace_recursive( |
|
168 | + $sane_files_array[$top_level_name] = array_replace_recursive( |
|
169 | 169 | $sub_array, |
170 | - $sane_files_array[ $top_level_name ] |
|
170 | + $sane_files_array[$top_level_name] |
|
171 | 171 | ); |
172 | 172 | } |
173 | 173 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | protected function organizeFilesData($data, $type) |
186 | 186 | { |
187 | - if (! is_array($data)) { |
|
187 | + if ( ! is_array($data)) { |
|
188 | 188 | return [ |
189 | 189 | $type => $data |
190 | 190 | ]; |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | $organized_data = []; |
193 | 193 | foreach ($data as $input_name_part => $sub_inputs_or_value) { |
194 | 194 | if (is_array($sub_inputs_or_value)) { |
195 | - $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type); |
|
195 | + $organized_data[$input_name_part] = $this->organizeFilesData($sub_inputs_or_value, $type); |
|
196 | 196 | } else { |
197 | - $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value; |
|
197 | + $organized_data[$input_name_part][$type] = $sub_inputs_or_value; |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | return $organized_data; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | protected function createFileObjects($organized_files, $name_parts_so_far = []) |
214 | 214 | { |
215 | - if (!is_array($organized_files)) { |
|
215 | + if ( ! is_array($organized_files)) { |
|
216 | 216 | throw new UnexpectedValueException( |
217 | 217 | sprintf( |
218 | 218 | esc_html__( |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | protected function inputNameFromParts($parts) |
257 | 257 | { |
258 | - if (!is_array($parts)) { |
|
258 | + if ( ! is_array($parts)) { |
|
259 | 259 | throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso')); |
260 | 260 | } |
261 | 261 | $generated_string = ''; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | if ($generated_string === '') { |
264 | 264 | $generated_string = (string) $part; |
265 | 265 | } else { |
266 | - $generated_string .= '[' . (string) $part . ']'; |
|
266 | + $generated_string .= '['.(string) $part.']'; |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | return $generated_string; |
@@ -38,264 +38,264 @@ |
||
38 | 38 | */ |
39 | 39 | class FilesDataHandler |
40 | 40 | { |
41 | - /** |
|
42 | - * @var Request |
|
43 | - */ |
|
44 | - protected $request; |
|
41 | + /** |
|
42 | + * @var Request |
|
43 | + */ |
|
44 | + protected $request; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @var CollectionInterface | FileSubmissionInterface[] |
|
48 | - */ |
|
49 | - protected $file_objects; |
|
46 | + /** |
|
47 | + * @var CollectionInterface | FileSubmissionInterface[] |
|
48 | + */ |
|
49 | + protected $file_objects; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var bool |
|
53 | - */ |
|
54 | - protected $initialized = false; |
|
51 | + /** |
|
52 | + * @var bool |
|
53 | + */ |
|
54 | + protected $initialized = false; |
|
55 | 55 | |
56 | - /** |
|
57 | - * FilesDataHandler constructor. |
|
58 | - * @param Request $request |
|
59 | - */ |
|
60 | - public function __construct(Request $request) |
|
61 | - { |
|
62 | - $this->request = $request; |
|
63 | - } |
|
56 | + /** |
|
57 | + * FilesDataHandler constructor. |
|
58 | + * @param Request $request |
|
59 | + */ |
|
60 | + public function __construct(Request $request) |
|
61 | + { |
|
62 | + $this->request = $request; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @since 4.9.80.p |
|
67 | - * @return CollectionInterface | FileSubmissionInterface[] |
|
68 | - * @throws UnexpectedValueException |
|
69 | - * @throws InvalidArgumentException |
|
70 | - */ |
|
71 | - protected function getFileObjects() |
|
72 | - { |
|
73 | - $this->initialize(); |
|
74 | - return $this->file_objects; |
|
75 | - } |
|
65 | + /** |
|
66 | + * @since 4.9.80.p |
|
67 | + * @return CollectionInterface | FileSubmissionInterface[] |
|
68 | + * @throws UnexpectedValueException |
|
69 | + * @throws InvalidArgumentException |
|
70 | + */ |
|
71 | + protected function getFileObjects() |
|
72 | + { |
|
73 | + $this->initialize(); |
|
74 | + return $this->file_objects; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Sets up the file objects from the request's $_FILES data. |
|
79 | - * @since 4.9.80.p |
|
80 | - * @throws UnexpectedValueException |
|
81 | - * @throws InvalidArgumentException |
|
82 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
83 | - */ |
|
84 | - protected function initialize() |
|
85 | - { |
|
86 | - if ($this->initialized) { |
|
87 | - return; |
|
88 | - } |
|
89 | - $this->file_objects = new Collection( |
|
90 | - // collection interface |
|
91 | - 'EventEspresso\core\services\request\files\FileSubmissionInterface', |
|
92 | - // collection name |
|
93 | - 'submitted_files' |
|
94 | - ); |
|
95 | - $files_raw_data = $this->request->filesParams(); |
|
96 | - if (empty($files_raw_data)) { |
|
97 | - return; |
|
98 | - } |
|
99 | - if ($this->isStrangeFilesArray($files_raw_data)) { |
|
100 | - $data = $this->fixFilesDataArray($files_raw_data); |
|
101 | - } else { |
|
102 | - $data = $files_raw_data; |
|
103 | - } |
|
104 | - $this->createFileObjects($data); |
|
105 | - $this->initialized = true; |
|
106 | - } |
|
77 | + /** |
|
78 | + * Sets up the file objects from the request's $_FILES data. |
|
79 | + * @since 4.9.80.p |
|
80 | + * @throws UnexpectedValueException |
|
81 | + * @throws InvalidArgumentException |
|
82 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
83 | + */ |
|
84 | + protected function initialize() |
|
85 | + { |
|
86 | + if ($this->initialized) { |
|
87 | + return; |
|
88 | + } |
|
89 | + $this->file_objects = new Collection( |
|
90 | + // collection interface |
|
91 | + 'EventEspresso\core\services\request\files\FileSubmissionInterface', |
|
92 | + // collection name |
|
93 | + 'submitted_files' |
|
94 | + ); |
|
95 | + $files_raw_data = $this->request->filesParams(); |
|
96 | + if (empty($files_raw_data)) { |
|
97 | + return; |
|
98 | + } |
|
99 | + if ($this->isStrangeFilesArray($files_raw_data)) { |
|
100 | + $data = $this->fixFilesDataArray($files_raw_data); |
|
101 | + } else { |
|
102 | + $data = $files_raw_data; |
|
103 | + } |
|
104 | + $this->createFileObjects($data); |
|
105 | + $this->initialized = true; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not. |
|
110 | - * @since 4.9.80.p |
|
111 | - * @param $files_data |
|
112 | - * @return bool |
|
113 | - * @throws UnexpectedValueException |
|
114 | - */ |
|
115 | - protected function isStrangeFilesArray($files_data) |
|
116 | - { |
|
117 | - if (!is_array($files_data)) { |
|
118 | - throw new UnexpectedValueException( |
|
119 | - sprintf( |
|
120 | - esc_html__( |
|
121 | - 'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.', |
|
122 | - 'event_espresso' |
|
123 | - ), |
|
124 | - (string) $files_data |
|
125 | - ) |
|
126 | - ); |
|
127 | - } |
|
128 | - $first_value = reset($files_data); |
|
129 | - if (!is_array($first_value)) { |
|
130 | - throw new UnexpectedValueException( |
|
131 | - sprintf( |
|
132 | - esc_html__( |
|
133 | - 'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.', |
|
134 | - 'event_espresso' |
|
135 | - ), |
|
136 | - (string) $first_value |
|
137 | - ) |
|
138 | - ); |
|
139 | - } |
|
140 | - $first_sub_array_item = reset($first_value); |
|
141 | - if (is_array($first_sub_array_item)) { |
|
142 | - // not just a 2d array |
|
143 | - return true; |
|
144 | - } |
|
145 | - // yep, just 2d array |
|
146 | - return false; |
|
147 | - } |
|
108 | + /** |
|
109 | + * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not. |
|
110 | + * @since 4.9.80.p |
|
111 | + * @param $files_data |
|
112 | + * @return bool |
|
113 | + * @throws UnexpectedValueException |
|
114 | + */ |
|
115 | + protected function isStrangeFilesArray($files_data) |
|
116 | + { |
|
117 | + if (!is_array($files_data)) { |
|
118 | + throw new UnexpectedValueException( |
|
119 | + sprintf( |
|
120 | + esc_html__( |
|
121 | + 'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.', |
|
122 | + 'event_espresso' |
|
123 | + ), |
|
124 | + (string) $files_data |
|
125 | + ) |
|
126 | + ); |
|
127 | + } |
|
128 | + $first_value = reset($files_data); |
|
129 | + if (!is_array($first_value)) { |
|
130 | + throw new UnexpectedValueException( |
|
131 | + sprintf( |
|
132 | + esc_html__( |
|
133 | + 'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.', |
|
134 | + 'event_espresso' |
|
135 | + ), |
|
136 | + (string) $first_value |
|
137 | + ) |
|
138 | + ); |
|
139 | + } |
|
140 | + $first_sub_array_item = reset($first_value); |
|
141 | + if (is_array($first_sub_array_item)) { |
|
142 | + // not just a 2d array |
|
143 | + return true; |
|
144 | + } |
|
145 | + // yep, just 2d array |
|
146 | + return false; |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file" |
|
151 | - * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with |
|
152 | - * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]", |
|
153 | - * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird. |
|
154 | - * @since 4.9.80.p |
|
155 | - * @param $files_data |
|
156 | - * @return array |
|
157 | - */ |
|
158 | - protected function fixFilesDataArray($files_data) |
|
159 | - { |
|
160 | - $sane_files_array = []; |
|
161 | - foreach ($files_data as $top_level_name => $top_level_children) { |
|
162 | - $sub_array = []; |
|
163 | - $sane_files_array[ $top_level_name ] = []; |
|
164 | - foreach ($top_level_children as $file_data_part => $second_level_children) { |
|
165 | - foreach ($second_level_children as $next_level_name => $sub_values) { |
|
166 | - $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part); |
|
167 | - } |
|
168 | - $sane_files_array[ $top_level_name ] = array_replace_recursive( |
|
169 | - $sub_array, |
|
170 | - $sane_files_array[ $top_level_name ] |
|
171 | - ); |
|
172 | - } |
|
173 | - } |
|
174 | - return $sane_files_array; |
|
175 | - } |
|
149 | + /** |
|
150 | + * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file" |
|
151 | + * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with |
|
152 | + * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]", |
|
153 | + * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird. |
|
154 | + * @since 4.9.80.p |
|
155 | + * @param $files_data |
|
156 | + * @return array |
|
157 | + */ |
|
158 | + protected function fixFilesDataArray($files_data) |
|
159 | + { |
|
160 | + $sane_files_array = []; |
|
161 | + foreach ($files_data as $top_level_name => $top_level_children) { |
|
162 | + $sub_array = []; |
|
163 | + $sane_files_array[ $top_level_name ] = []; |
|
164 | + foreach ($top_level_children as $file_data_part => $second_level_children) { |
|
165 | + foreach ($second_level_children as $next_level_name => $sub_values) { |
|
166 | + $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part); |
|
167 | + } |
|
168 | + $sane_files_array[ $top_level_name ] = array_replace_recursive( |
|
169 | + $sub_array, |
|
170 | + $sane_files_array[ $top_level_name ] |
|
171 | + ); |
|
172 | + } |
|
173 | + } |
|
174 | + return $sane_files_array; |
|
175 | + } |
|
176 | 176 | |
177 | - /** |
|
178 | - * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it. |
|
179 | - * @since 4.9.80.p |
|
180 | - * @param $data array|string |
|
181 | - * @param $type 'name', 'tmp_name', 'size', or 'error' |
|
182 | - * @param $name string |
|
183 | - * @return array|string |
|
184 | - */ |
|
185 | - protected function organizeFilesData($data, $type) |
|
186 | - { |
|
187 | - if (! is_array($data)) { |
|
188 | - return [ |
|
189 | - $type => $data |
|
190 | - ]; |
|
191 | - } |
|
192 | - $organized_data = []; |
|
193 | - foreach ($data as $input_name_part => $sub_inputs_or_value) { |
|
194 | - if (is_array($sub_inputs_or_value)) { |
|
195 | - $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type); |
|
196 | - } else { |
|
197 | - $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value; |
|
198 | - } |
|
199 | - } |
|
200 | - return $organized_data; |
|
201 | - } |
|
177 | + /** |
|
178 | + * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it. |
|
179 | + * @since 4.9.80.p |
|
180 | + * @param $data array|string |
|
181 | + * @param $type 'name', 'tmp_name', 'size', or 'error' |
|
182 | + * @param $name string |
|
183 | + * @return array|string |
|
184 | + */ |
|
185 | + protected function organizeFilesData($data, $type) |
|
186 | + { |
|
187 | + if (! is_array($data)) { |
|
188 | + return [ |
|
189 | + $type => $data |
|
190 | + ]; |
|
191 | + } |
|
192 | + $organized_data = []; |
|
193 | + foreach ($data as $input_name_part => $sub_inputs_or_value) { |
|
194 | + if (is_array($sub_inputs_or_value)) { |
|
195 | + $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type); |
|
196 | + } else { |
|
197 | + $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value; |
|
198 | + } |
|
199 | + } |
|
200 | + return $organized_data; |
|
201 | + } |
|
202 | 202 | |
203 | - /** |
|
204 | - * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input |
|
205 | - * to be in $_GET or $_POST, with all the file's data located side-by-side in an array) and creates a |
|
206 | - * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`. |
|
207 | - * @since 4.9.80.p |
|
208 | - * @param array $organized_files $_FILES but organized like $_POST |
|
209 | - * @param array $name_parts_so_far for multidimensional HTML form names, |
|
210 | - * @throws UnexpectedValueException |
|
211 | - * @throws InvalidArgumentException |
|
212 | - */ |
|
213 | - protected function createFileObjects($organized_files, $name_parts_so_far = []) |
|
214 | - { |
|
215 | - if (!is_array($organized_files)) { |
|
216 | - throw new UnexpectedValueException( |
|
217 | - sprintf( |
|
218 | - esc_html__( |
|
219 | - 'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.', |
|
220 | - 'event_espresso' |
|
221 | - ), |
|
222 | - (string) $organized_files |
|
223 | - ) |
|
224 | - ); |
|
225 | - } |
|
226 | - foreach ($organized_files as $key => $value) { |
|
227 | - $this_input_name_parts = $name_parts_so_far; |
|
228 | - array_push( |
|
229 | - $this_input_name_parts, |
|
230 | - $key |
|
231 | - ); |
|
232 | - if (isset($value['name'], $value['tmp_name'], $value['size'])) { |
|
233 | - $html_name = $this->inputNameFromParts($this_input_name_parts); |
|
234 | - $this->file_objects->add( |
|
235 | - new FileSubmission( |
|
236 | - $value['name'], |
|
237 | - $value['tmp_name'], |
|
238 | - $value['size'], |
|
239 | - $value['error'] |
|
240 | - ), |
|
241 | - $html_name |
|
242 | - ); |
|
243 | - } else { |
|
244 | - $this->createFileObjects($value, $this_input_name_parts); |
|
245 | - } |
|
246 | - } |
|
247 | - } |
|
203 | + /** |
|
204 | + * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input |
|
205 | + * to be in $_GET or $_POST, with all the file's data located side-by-side in an array) and creates a |
|
206 | + * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`. |
|
207 | + * @since 4.9.80.p |
|
208 | + * @param array $organized_files $_FILES but organized like $_POST |
|
209 | + * @param array $name_parts_so_far for multidimensional HTML form names, |
|
210 | + * @throws UnexpectedValueException |
|
211 | + * @throws InvalidArgumentException |
|
212 | + */ |
|
213 | + protected function createFileObjects($organized_files, $name_parts_so_far = []) |
|
214 | + { |
|
215 | + if (!is_array($organized_files)) { |
|
216 | + throw new UnexpectedValueException( |
|
217 | + sprintf( |
|
218 | + esc_html__( |
|
219 | + 'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.', |
|
220 | + 'event_espresso' |
|
221 | + ), |
|
222 | + (string) $organized_files |
|
223 | + ) |
|
224 | + ); |
|
225 | + } |
|
226 | + foreach ($organized_files as $key => $value) { |
|
227 | + $this_input_name_parts = $name_parts_so_far; |
|
228 | + array_push( |
|
229 | + $this_input_name_parts, |
|
230 | + $key |
|
231 | + ); |
|
232 | + if (isset($value['name'], $value['tmp_name'], $value['size'])) { |
|
233 | + $html_name = $this->inputNameFromParts($this_input_name_parts); |
|
234 | + $this->file_objects->add( |
|
235 | + new FileSubmission( |
|
236 | + $value['name'], |
|
237 | + $value['tmp_name'], |
|
238 | + $value['size'], |
|
239 | + $value['error'] |
|
240 | + ), |
|
241 | + $html_name |
|
242 | + ); |
|
243 | + } else { |
|
244 | + $this->createFileObjects($value, $this_input_name_parts); |
|
245 | + } |
|
246 | + } |
|
247 | + } |
|
248 | 248 | |
249 | - /** |
|
250 | - * Takes the input name parts, like `['my', 'great', 'file', 'input1']` |
|
251 | - * and returns the HTML name for it, "my[great][file][input1]" |
|
252 | - * @since 4.9.80.p |
|
253 | - * @param $parts |
|
254 | - * @throws UnexpectedValueException |
|
255 | - */ |
|
256 | - protected function inputNameFromParts($parts) |
|
257 | - { |
|
258 | - if (!is_array($parts)) { |
|
259 | - throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso')); |
|
260 | - } |
|
261 | - $generated_string = ''; |
|
262 | - foreach ($parts as $part) { |
|
263 | - if ($generated_string === '') { |
|
264 | - $generated_string = (string) $part; |
|
265 | - } else { |
|
266 | - $generated_string .= '[' . (string) $part . ']'; |
|
267 | - } |
|
268 | - } |
|
269 | - return $generated_string; |
|
270 | - } |
|
249 | + /** |
|
250 | + * Takes the input name parts, like `['my', 'great', 'file', 'input1']` |
|
251 | + * and returns the HTML name for it, "my[great][file][input1]" |
|
252 | + * @since 4.9.80.p |
|
253 | + * @param $parts |
|
254 | + * @throws UnexpectedValueException |
|
255 | + */ |
|
256 | + protected function inputNameFromParts($parts) |
|
257 | + { |
|
258 | + if (!is_array($parts)) { |
|
259 | + throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso')); |
|
260 | + } |
|
261 | + $generated_string = ''; |
|
262 | + foreach ($parts as $part) { |
|
263 | + if ($generated_string === '') { |
|
264 | + $generated_string = (string) $part; |
|
265 | + } else { |
|
266 | + $generated_string .= '[' . (string) $part . ']'; |
|
267 | + } |
|
268 | + } |
|
269 | + return $generated_string; |
|
270 | + } |
|
271 | 271 | |
272 | - /** |
|
273 | - * Gets the input by the indicated $name_parts. |
|
274 | - * Eg if you're looking for an input named "my[great][file][input1]", $name_parts |
|
275 | - * should be `['my', 'great', 'file', 'input1']`. |
|
276 | - * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');` |
|
277 | - * @since 4.9.80.p |
|
278 | - * @param $name_parts |
|
279 | - * @throws UnexpectedValueException |
|
280 | - * @return FileSubmissionInterface |
|
281 | - */ |
|
282 | - public function getFileObjectFromNameParts($name_parts) |
|
283 | - { |
|
284 | - return $this->getFileObjects()->get($this->inputNameFromParts($name_parts)); |
|
285 | - } |
|
272 | + /** |
|
273 | + * Gets the input by the indicated $name_parts. |
|
274 | + * Eg if you're looking for an input named "my[great][file][input1]", $name_parts |
|
275 | + * should be `['my', 'great', 'file', 'input1']`. |
|
276 | + * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');` |
|
277 | + * @since 4.9.80.p |
|
278 | + * @param $name_parts |
|
279 | + * @throws UnexpectedValueException |
|
280 | + * @return FileSubmissionInterface |
|
281 | + */ |
|
282 | + public function getFileObjectFromNameParts($name_parts) |
|
283 | + { |
|
284 | + return $this->getFileObjects()->get($this->inputNameFromParts($name_parts)); |
|
285 | + } |
|
286 | 286 | |
287 | - /** |
|
288 | - * Gets the FileSubmissionInterface corresponding to the HTML name provided. |
|
289 | - * @since 4.9.80.p |
|
290 | - * @param $html_name |
|
291 | - * @return mixed |
|
292 | - * @throws InvalidArgumentException |
|
293 | - * @throws UnexpectedValueException |
|
294 | - */ |
|
295 | - public function getFileObject($html_name) |
|
296 | - { |
|
297 | - return $this->getFileObjects()->get($html_name); |
|
298 | - } |
|
287 | + /** |
|
288 | + * Gets the FileSubmissionInterface corresponding to the HTML name provided. |
|
289 | + * @since 4.9.80.p |
|
290 | + * @param $html_name |
|
291 | + * @return mixed |
|
292 | + * @throws InvalidArgumentException |
|
293 | + * @throws UnexpectedValueException |
|
294 | + */ |
|
295 | + public function getFileObject($html_name) |
|
296 | + { |
|
297 | + return $this->getFileObjects()->get($html_name); |
|
298 | + } |
|
299 | 299 | } |
300 | 300 | // End of file FilesDataHandler.php |
301 | 301 | // Location: EventEspresso\core\services\request\files/FilesDataHandler.php |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getType() |
95 | 95 | { |
96 | - if (!$this->type) { |
|
96 | + if ( ! $this->type) { |
|
97 | 97 | $this->type = $this->determineType(); |
98 | 98 | } |
99 | 99 | return $this->type; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function determineType() |
107 | 107 | { |
108 | - if (!$this->getTmpFile()) { |
|
108 | + if ( ! $this->getTmpFile()) { |
|
109 | 109 | return ''; |
110 | 110 | } |
111 | 111 | $finfo = new finfo(FILEINFO_MIME_TYPE); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function getExtension() |
121 | 121 | { |
122 | - if (!$this->extension) { |
|
122 | + if ( ! $this->extension) { |
|
123 | 123 | $this->extension = $this->determineExtension(); |
124 | 124 | } |
125 | 125 | return $this->extension; |
@@ -19,164 +19,164 @@ |
||
19 | 19 | */ |
20 | 20 | class FileSubmission implements FileSubmissionInterface |
21 | 21 | { |
22 | - /** |
|
23 | - * @var string original name on the client machine |
|
24 | - */ |
|
25 | - protected $name; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var string mime type |
|
29 | - */ |
|
30 | - protected $type; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string file extension |
|
34 | - */ |
|
35 | - protected $extension; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var int in bytes |
|
39 | - */ |
|
40 | - protected $size; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var string local filepath to the temporary file |
|
44 | - */ |
|
45 | - protected $tmp_file; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values |
|
49 | - * although those aren't expected. |
|
50 | - */ |
|
51 | - protected $error_code; |
|
52 | - |
|
53 | - /** |
|
54 | - * FileSubmission constructor. |
|
55 | - * @param $name |
|
56 | - * @param $tmp_file |
|
57 | - * @param $size |
|
58 | - * @param null $error_code |
|
59 | - * @throws InvalidArgumentException |
|
60 | - */ |
|
61 | - public function __construct($name, $tmp_file, $size, $error_code = null) |
|
62 | - { |
|
63 | - $this->name = basename($name); |
|
64 | - $scheme = parse_url($tmp_file, PHP_URL_SCHEME); |
|
65 | - if (in_array($scheme, ['http', 'https'])) { |
|
66 | - // Wait a minute- just local filepaths please, no URL schemes allowed! |
|
67 | - throw new InvalidArgumentException( |
|
68 | - sprintf( |
|
69 | - // @codingStandardsIgnoreStart |
|
70 | - esc_html__('The scheme ("%1$s") on the temporary file ("%2$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'), |
|
71 | - // @codingStandardsIgnoreEnd |
|
72 | - $scheme, |
|
73 | - $tmp_file |
|
74 | - ) |
|
75 | - ); |
|
76 | - } |
|
77 | - $this->tmp_file = (string) $tmp_file; |
|
78 | - $this->size = (int) $size; |
|
79 | - $this->error_code = (int) $error_code; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function getName() |
|
86 | - { |
|
87 | - return $this->name; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Gets the file's mime type |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function getType() |
|
95 | - { |
|
96 | - if (!$this->type) { |
|
97 | - $this->type = $this->determineType(); |
|
98 | - } |
|
99 | - return $this->type; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @since 4.9.80.p |
|
104 | - * @return string |
|
105 | - */ |
|
106 | - protected function determineType() |
|
107 | - { |
|
108 | - if (!$this->getTmpFile()) { |
|
109 | - return ''; |
|
110 | - } |
|
111 | - $finfo = new finfo(FILEINFO_MIME_TYPE); |
|
112 | - return $finfo->file($this->getTmpFile()); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Gets the file's extension. |
|
117 | - * @since 4.9.80.p |
|
118 | - * @return string |
|
119 | - */ |
|
120 | - public function getExtension() |
|
121 | - { |
|
122 | - if (!$this->extension) { |
|
123 | - $this->extension = $this->determineExtension(); |
|
124 | - } |
|
125 | - return $this->extension; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * Determine's the file's extension given the temporary file. |
|
130 | - * @since 4.9.80.p |
|
131 | - * @return string |
|
132 | - */ |
|
133 | - protected function determineExtension() |
|
134 | - { |
|
135 | - $position_of_period = strrpos($this->getName(), '.'); |
|
136 | - if ($position_of_period === false) { |
|
137 | - return ''; |
|
138 | - } |
|
139 | - return mb_substr( |
|
140 | - $this->getName(), |
|
141 | - $position_of_period + 1 |
|
142 | - ); |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Gets the size of the file |
|
147 | - * @return int |
|
148 | - */ |
|
149 | - public function getSize() |
|
150 | - { |
|
151 | - return $this->size; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Gets the path to the temporary file which was uploaded. |
|
156 | - * @return string |
|
157 | - */ |
|
158 | - public function getTmpFile() |
|
159 | - { |
|
160 | - return $this->tmp_file; |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * @since 4.9.80.p |
|
165 | - * @return string |
|
166 | - */ |
|
167 | - public function __toString() |
|
168 | - { |
|
169 | - return $this->getName(); |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Gets the error code PHP reported for the file upload. |
|
174 | - * @return string |
|
175 | - */ |
|
176 | - public function getErrorCode() |
|
177 | - { |
|
178 | - return $this->error_code; |
|
179 | - } |
|
22 | + /** |
|
23 | + * @var string original name on the client machine |
|
24 | + */ |
|
25 | + protected $name; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var string mime type |
|
29 | + */ |
|
30 | + protected $type; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string file extension |
|
34 | + */ |
|
35 | + protected $extension; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var int in bytes |
|
39 | + */ |
|
40 | + protected $size; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var string local filepath to the temporary file |
|
44 | + */ |
|
45 | + protected $tmp_file; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values |
|
49 | + * although those aren't expected. |
|
50 | + */ |
|
51 | + protected $error_code; |
|
52 | + |
|
53 | + /** |
|
54 | + * FileSubmission constructor. |
|
55 | + * @param $name |
|
56 | + * @param $tmp_file |
|
57 | + * @param $size |
|
58 | + * @param null $error_code |
|
59 | + * @throws InvalidArgumentException |
|
60 | + */ |
|
61 | + public function __construct($name, $tmp_file, $size, $error_code = null) |
|
62 | + { |
|
63 | + $this->name = basename($name); |
|
64 | + $scheme = parse_url($tmp_file, PHP_URL_SCHEME); |
|
65 | + if (in_array($scheme, ['http', 'https'])) { |
|
66 | + // Wait a minute- just local filepaths please, no URL schemes allowed! |
|
67 | + throw new InvalidArgumentException( |
|
68 | + sprintf( |
|
69 | + // @codingStandardsIgnoreStart |
|
70 | + esc_html__('The scheme ("%1$s") on the temporary file ("%2$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'), |
|
71 | + // @codingStandardsIgnoreEnd |
|
72 | + $scheme, |
|
73 | + $tmp_file |
|
74 | + ) |
|
75 | + ); |
|
76 | + } |
|
77 | + $this->tmp_file = (string) $tmp_file; |
|
78 | + $this->size = (int) $size; |
|
79 | + $this->error_code = (int) $error_code; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function getName() |
|
86 | + { |
|
87 | + return $this->name; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Gets the file's mime type |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function getType() |
|
95 | + { |
|
96 | + if (!$this->type) { |
|
97 | + $this->type = $this->determineType(); |
|
98 | + } |
|
99 | + return $this->type; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @since 4.9.80.p |
|
104 | + * @return string |
|
105 | + */ |
|
106 | + protected function determineType() |
|
107 | + { |
|
108 | + if (!$this->getTmpFile()) { |
|
109 | + return ''; |
|
110 | + } |
|
111 | + $finfo = new finfo(FILEINFO_MIME_TYPE); |
|
112 | + return $finfo->file($this->getTmpFile()); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Gets the file's extension. |
|
117 | + * @since 4.9.80.p |
|
118 | + * @return string |
|
119 | + */ |
|
120 | + public function getExtension() |
|
121 | + { |
|
122 | + if (!$this->extension) { |
|
123 | + $this->extension = $this->determineExtension(); |
|
124 | + } |
|
125 | + return $this->extension; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * Determine's the file's extension given the temporary file. |
|
130 | + * @since 4.9.80.p |
|
131 | + * @return string |
|
132 | + */ |
|
133 | + protected function determineExtension() |
|
134 | + { |
|
135 | + $position_of_period = strrpos($this->getName(), '.'); |
|
136 | + if ($position_of_period === false) { |
|
137 | + return ''; |
|
138 | + } |
|
139 | + return mb_substr( |
|
140 | + $this->getName(), |
|
141 | + $position_of_period + 1 |
|
142 | + ); |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Gets the size of the file |
|
147 | + * @return int |
|
148 | + */ |
|
149 | + public function getSize() |
|
150 | + { |
|
151 | + return $this->size; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Gets the path to the temporary file which was uploaded. |
|
156 | + * @return string |
|
157 | + */ |
|
158 | + public function getTmpFile() |
|
159 | + { |
|
160 | + return $this->tmp_file; |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * @since 4.9.80.p |
|
165 | + * @return string |
|
166 | + */ |
|
167 | + public function __toString() |
|
168 | + { |
|
169 | + return $this->getName(); |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Gets the error code PHP reported for the file upload. |
|
174 | + * @return string |
|
175 | + */ |
|
176 | + public function getErrorCode() |
|
177 | + { |
|
178 | + return $this->error_code; |
|
179 | + } |
|
180 | 180 | } |
181 | 181 | // End of file FileSubmission.php |
182 | 182 | // Location: EventEspresso\core\services\request\files/FileSubmission.php |
@@ -5,38 +5,38 @@ |
||
5 | 5 | |
6 | 6 | <?php |
7 | 7 | $settings_array = array( |
8 | - 'max_registrants' => '<p> |
|
8 | + 'max_registrants' => '<p> |
|
9 | 9 | <label for="max-registrants">' |
10 | - . esc_html__( |
|
11 | - 'Maximum number of tickets allowed per order for this event: ', |
|
12 | - 'event_espresso' |
|
13 | - ) . '</label> |
|
10 | + . esc_html__( |
|
11 | + 'Maximum number of tickets allowed per order for this event: ', |
|
12 | + 'event_espresso' |
|
13 | + ) . '</label> |
|
14 | 14 | <input class="ee-numeric" type="text" id="max-registrants" name="additional_limit" value="' . $additional_limit . '" size="4" /> |
15 | 15 | </p>', |
16 | - 'additional_registration_options' => $additional_registration_options, |
|
17 | - 'display_ticket_selector' => '<p> |
|
16 | + 'additional_registration_options' => $additional_registration_options, |
|
17 | + 'display_ticket_selector' => '<p> |
|
18 | 18 | <label>' . esc_html__('Display Ticket Selector', 'event_espresso') . '</label>' . $display_ticket_selector . '</p>', |
19 | - 'alternative_registration_page' => '<p> |
|
19 | + 'alternative_registration_page' => '<p> |
|
20 | 20 | <label>' . esc_html__('Alternative Registration Page', 'event_espresso') . '</label> |
21 | 21 | <input name="externalURL" size="20" type="text" value="' . $_event->external_url() . '"> |
22 | 22 | </p>', |
23 | - 'event_phone_number' => '<p> |
|
23 | + 'event_phone_number' => '<p> |
|
24 | 24 | <label>' . esc_html__('Event Phone Number', 'event_espresso') . '</label> |
25 | 25 | <input name="event_phone" size="20" type="text" value="' . $_event->phone() . '"> |
26 | 26 | </p>', |
27 | - 'default_registration_status' => '<p> |
|
27 | + 'default_registration_status' => '<p> |
|
28 | 28 | <label>' |
29 | - . esc_html__( |
|
30 | - 'Default Registration Status', |
|
31 | - 'event_espresso' |
|
32 | - ) . '</label>' |
|
33 | - . EEH_Template::get_help_tab_link('event_editor_event_registration_options_help_tab') |
|
34 | - . $EVT_default_registration_status . '</p>', |
|
29 | + . esc_html__( |
|
30 | + 'Default Registration Status', |
|
31 | + 'event_espresso' |
|
32 | + ) . '</label>' |
|
33 | + . EEH_Template::get_help_tab_link('event_editor_event_registration_options_help_tab') |
|
34 | + . $EVT_default_registration_status . '</p>', |
|
35 | 35 | ); |
36 | 36 | // filter |
37 | 37 | $settings_array = apply_filters('FHEE__caffeinated_event_registration_options__template__settings', $settings_array); |
38 | 38 | |
39 | 39 | // echo |
40 | 40 | foreach ($settings_array as $item) { |
41 | - echo $item; |
|
41 | + echo $item; |
|
42 | 42 | } |
@@ -10,28 +10,28 @@ |
||
10 | 10 | . esc_html__( |
11 | 11 | 'Maximum number of tickets allowed per order for this event: ', |
12 | 12 | 'event_espresso' |
13 | - ) . '</label> |
|
14 | - <input class="ee-numeric" type="text" id="max-registrants" name="additional_limit" value="' . $additional_limit . '" size="4" /> |
|
13 | + ).'</label> |
|
14 | + <input class="ee-numeric" type="text" id="max-registrants" name="additional_limit" value="' . $additional_limit.'" size="4" /> |
|
15 | 15 | </p>', |
16 | 16 | 'additional_registration_options' => $additional_registration_options, |
17 | 17 | 'display_ticket_selector' => '<p> |
18 | - <label>' . esc_html__('Display Ticket Selector', 'event_espresso') . '</label>' . $display_ticket_selector . '</p>', |
|
18 | + <label>' . esc_html__('Display Ticket Selector', 'event_espresso').'</label>'.$display_ticket_selector.'</p>', |
|
19 | 19 | 'alternative_registration_page' => '<p> |
20 | - <label>' . esc_html__('Alternative Registration Page', 'event_espresso') . '</label> |
|
21 | - <input name="externalURL" size="20" type="text" value="' . $_event->external_url() . '"> |
|
20 | + <label>' . esc_html__('Alternative Registration Page', 'event_espresso').'</label> |
|
21 | + <input name="externalURL" size="20" type="text" value="' . $_event->external_url().'"> |
|
22 | 22 | </p>', |
23 | 23 | 'event_phone_number' => '<p> |
24 | - <label>' . esc_html__('Event Phone Number', 'event_espresso') . '</label> |
|
25 | - <input name="event_phone" size="20" type="text" value="' . $_event->phone() . '"> |
|
24 | + <label>' . esc_html__('Event Phone Number', 'event_espresso').'</label> |
|
25 | + <input name="event_phone" size="20" type="text" value="' . $_event->phone().'"> |
|
26 | 26 | </p>', |
27 | 27 | 'default_registration_status' => '<p> |
28 | 28 | <label>' |
29 | 29 | . esc_html__( |
30 | 30 | 'Default Registration Status', |
31 | 31 | 'event_espresso' |
32 | - ) . '</label>' |
|
32 | + ).'</label>' |
|
33 | 33 | . EEH_Template::get_help_tab_link('event_editor_event_registration_options_help_tab') |
34 | - . $EVT_default_registration_status . '</p>', |
|
34 | + . $EVT_default_registration_status.'</p>', |
|
35 | 35 | ); |
36 | 36 | // filter |
37 | 37 | $settings_array = apply_filters('FHEE__caffeinated_event_registration_options__template__settings', $settings_array); |
@@ -57,38 +57,38 @@ |
||
57 | 57 | <div> |
58 | 58 | <strong><?php echo EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'); ?></strong><br /> |
59 | 59 | <?php printf( |
60 | - esc_html__( |
|
61 | - /* translators: Approved Registration status */ |
|
62 | - 'A status of %s means that a registration has been accepted as complete. The registration will count towards the registration limit, remaining tickets, and calculations for available seats. Payments (if necessary) can also be made by primary registrants with this status.', |
|
63 | - 'event_espresso' |
|
64 | - ), |
|
65 | - EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') |
|
60 | + esc_html__( |
|
61 | + /* translators: Approved Registration status */ |
|
62 | + 'A status of %s means that a registration has been accepted as complete. The registration will count towards the registration limit, remaining tickets, and calculations for available seats. Payments (if necessary) can also be made by primary registrants with this status.', |
|
63 | + 'event_espresso' |
|
64 | + ), |
|
65 | + EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') |
|
66 | 66 | ); ?> |
67 | 67 | </div> |
68 | 68 | <div> |
69 | 69 | <strong><?php echo EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'); ?></strong><br /> |
70 | 70 | <?php printf( |
71 | - esc_html__( |
|
72 | - /* translators: 1: Pending Payment, 2: Pending Payment, 3: Approved */ |
|
73 | - 'A status of %1$s means that a registration has not paid but they ARE able to make payments (if necessary). %2$s registrations do NOT count towards registration limits, remaining tickets, and calculations for available seats. If registration for a free event occurs, then registrations are automatically set to %3$s. For paid tickets, %1$s registrations are set to %3$s when full payment is recorded.', |
|
74 | - 'event_espresso' |
|
75 | - ), |
|
76 | - EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
77 | - EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
78 | - EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') |
|
71 | + esc_html__( |
|
72 | + /* translators: 1: Pending Payment, 2: Pending Payment, 3: Approved */ |
|
73 | + 'A status of %1$s means that a registration has not paid but they ARE able to make payments (if necessary). %2$s registrations do NOT count towards registration limits, remaining tickets, and calculations for available seats. If registration for a free event occurs, then registrations are automatically set to %3$s. For paid tickets, %1$s registrations are set to %3$s when full payment is recorded.', |
|
74 | + 'event_espresso' |
|
75 | + ), |
|
76 | + EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
77 | + EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
78 | + EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') |
|
79 | 79 | ); ?> |
80 | 80 | </div> |
81 | 81 | <div> |
82 | 82 | <strong><?php echo EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'); ?></strong><br /> |
83 | 83 | <?php printf( |
84 | - esc_html__( |
|
85 | - /* translators: 1: Not Approved, 2: Pending Payment, 3: Approved */ |
|
86 | - 'A status of %1$s means that a registration has not paid and they cannot make payments for towards an event. Un-approved registrations do NOT count towards registration limits, remaining tickets, and calculations for available seats. This setting differs from the "%2$s" default in that free ticket registrations and paid in full ticket registrations do NOT automatically switch the Registration to %3$s. Instead, the event admin must manually set the registration to either "%2$s" for registrations requiring payments, or "%3$s" for free events.', |
|
87 | - 'event_espresso' |
|
88 | - ), |
|
89 | - EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
90 | - EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'upper'), |
|
91 | - EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'upper') |
|
84 | + esc_html__( |
|
85 | + /* translators: 1: Not Approved, 2: Pending Payment, 3: Approved */ |
|
86 | + 'A status of %1$s means that a registration has not paid and they cannot make payments for towards an event. Un-approved registrations do NOT count towards registration limits, remaining tickets, and calculations for available seats. This setting differs from the "%2$s" default in that free ticket registrations and paid in full ticket registrations do NOT automatically switch the Registration to %3$s. Instead, the event admin must manually set the registration to either "%2$s" for registrations requiring payments, or "%3$s" for free events.', |
|
87 | + 'event_espresso' |
|
88 | + ), |
|
89 | + EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
90 | + EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'upper'), |
|
91 | + EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'upper') |
|
92 | 92 | ); ?> |
93 | 93 | </div> |
94 | 94 | </li> |
@@ -15,80 +15,80 @@ |
||
15 | 15 | class EE_Select2_Display_Strategy extends EE_Select_Display_Strategy |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Arguments that will be passed into the select2 javascript constructor |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $_select2_js_args = array(); |
|
18 | + /** |
|
19 | + * Arguments that will be passed into the select2 javascript constructor |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $_select2_js_args = array(); |
|
23 | 23 | |
24 | - /** |
|
25 | - * |
|
26 | - * @param array $select2_js_args pass in the EXACT array of JS arguments you want |
|
27 | - * to pass into the select2 js/html input. See https://select2.github.io |
|
28 | - */ |
|
29 | - public function __construct($select2_js_args = array()) |
|
30 | - { |
|
31 | - $this->_select2_js_args = $select2_js_args; |
|
32 | - parent::__construct(); |
|
33 | - } |
|
24 | + /** |
|
25 | + * |
|
26 | + * @param array $select2_js_args pass in the EXACT array of JS arguments you want |
|
27 | + * to pass into the select2 js/html input. See https://select2.github.io |
|
28 | + */ |
|
29 | + public function __construct($select2_js_args = array()) |
|
30 | + { |
|
31 | + $this->_select2_js_args = $select2_js_args; |
|
32 | + parent::__construct(); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * enqueues the select2 initializing js (which depends on the select2 js) and |
|
37 | - * the select2 css |
|
38 | - */ |
|
39 | - public function enqueue_js() |
|
40 | - { |
|
41 | - // need to first deregister the select2 script in case some other plugin **cough cough Toolset Types cough** |
|
42 | - // is carelessly registering an older version of Select2 on admin pages that don't even belong to them |
|
43 | - wp_deregister_script('select2'); |
|
44 | - wp_deregister_style('select2'); |
|
45 | - wp_register_script('select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true); |
|
46 | - wp_register_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
47 | - wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true); |
|
48 | - wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
49 | - } |
|
35 | + /** |
|
36 | + * enqueues the select2 initializing js (which depends on the select2 js) and |
|
37 | + * the select2 css |
|
38 | + */ |
|
39 | + public function enqueue_js() |
|
40 | + { |
|
41 | + // need to first deregister the select2 script in case some other plugin **cough cough Toolset Types cough** |
|
42 | + // is carelessly registering an older version of Select2 on admin pages that don't even belong to them |
|
43 | + wp_deregister_script('select2'); |
|
44 | + wp_deregister_style('select2'); |
|
45 | + wp_register_script('select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true); |
|
46 | + wp_register_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
47 | + wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true); |
|
48 | + wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Gets the javascript args which will be localized and passed into the select2 js/html input |
|
53 | - * @return array |
|
54 | - */ |
|
55 | - public function get_js_args() |
|
56 | - { |
|
57 | - return $this->_select2_js_args; |
|
58 | - } |
|
51 | + /** |
|
52 | + * Gets the javascript args which will be localized and passed into the select2 js/html input |
|
53 | + * @return array |
|
54 | + */ |
|
55 | + public function get_js_args() |
|
56 | + { |
|
57 | + return $this->_select2_js_args; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Sets the exact js args which will be passed into the select2 js/html input |
|
62 | - * @param array $js_args |
|
63 | - */ |
|
64 | - public function set_js_args($js_args) |
|
65 | - { |
|
66 | - $this->_select2_js_args = $js_args; |
|
67 | - } |
|
60 | + /** |
|
61 | + * Sets the exact js args which will be passed into the select2 js/html input |
|
62 | + * @param array $js_args |
|
63 | + */ |
|
64 | + public function set_js_args($js_args) |
|
65 | + { |
|
66 | + $this->_select2_js_args = $js_args; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Adds select2 data for localization |
|
71 | - * @param array $other_js_data |
|
72 | - * @return array |
|
73 | - */ |
|
74 | - public function get_other_js_data($other_js_data = array()) |
|
75 | - { |
|
76 | - $other_js_data = parent::get_other_js_data($other_js_data); |
|
77 | - if (! isset($other_js_data['select2s'])) { |
|
78 | - $other_js_data['select2s'] = array(); |
|
79 | - } |
|
80 | - $other_js_data['select2s'][ $this->_input->html_id() ] = $this->get_js_args(); |
|
81 | - return $other_js_data; |
|
82 | - } |
|
69 | + /** |
|
70 | + * Adds select2 data for localization |
|
71 | + * @param array $other_js_data |
|
72 | + * @return array |
|
73 | + */ |
|
74 | + public function get_other_js_data($other_js_data = array()) |
|
75 | + { |
|
76 | + $other_js_data = parent::get_other_js_data($other_js_data); |
|
77 | + if (! isset($other_js_data['select2s'])) { |
|
78 | + $other_js_data['select2s'] = array(); |
|
79 | + } |
|
80 | + $other_js_data['select2s'][ $this->_input->html_id() ] = $this->get_js_args(); |
|
81 | + return $other_js_data; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Overrides standard attributes array to add the CSS class "ee-select2" |
|
86 | - * @return array |
|
87 | - */ |
|
88 | - protected function _standard_attributes_array() |
|
89 | - { |
|
90 | - $standard_attributes = parent::_standard_attributes_array(); |
|
91 | - $standard_attributes['class'] .= ' ee-select2'; |
|
92 | - return $standard_attributes; |
|
93 | - } |
|
84 | + /** |
|
85 | + * Overrides standard attributes array to add the CSS class "ee-select2" |
|
86 | + * @return array |
|
87 | + */ |
|
88 | + protected function _standard_attributes_array() |
|
89 | + { |
|
90 | + $standard_attributes = parent::_standard_attributes_array(); |
|
91 | + $standard_attributes['class'] .= ' ee-select2'; |
|
92 | + return $standard_attributes; |
|
93 | + } |
|
94 | 94 | } |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | // is carelessly registering an older version of Select2 on admin pages that don't even belong to them |
43 | 43 | wp_deregister_script('select2'); |
44 | 44 | wp_deregister_style('select2'); |
45 | - wp_register_script('select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true); |
|
46 | - wp_register_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
47 | - wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true); |
|
48 | - wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all'); |
|
45 | + wp_register_script('select2', EE_GLOBAL_ASSETS_URL.'scripts/select2.min.js', array(), '4.0.2', true); |
|
46 | + wp_register_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all'); |
|
47 | + wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL.'scripts/form_section_select2_init.js', array('select2'), '1.0.0', true); |
|
48 | + wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | public function get_other_js_data($other_js_data = array()) |
75 | 75 | { |
76 | 76 | $other_js_data = parent::get_other_js_data($other_js_data); |
77 | - if (! isset($other_js_data['select2s'])) { |
|
77 | + if ( ! isset($other_js_data['select2s'])) { |
|
78 | 78 | $other_js_data['select2s'] = array(); |
79 | 79 | } |
80 | - $other_js_data['select2s'][ $this->_input->html_id() ] = $this->get_js_args(); |
|
80 | + $other_js_data['select2s'][$this->_input->html_id()] = $this->get_js_args(); |
|
81 | 81 | return $other_js_data; |
82 | 82 | } |
83 | 83 |
@@ -25,215 +25,215 @@ |
||
25 | 25 | */ |
26 | 26 | class BatchRequestProcessor |
27 | 27 | { |
28 | - // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore |
|
29 | - // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
|
30 | - /** |
|
31 | - * Current job's ID (if assigned) |
|
32 | - * |
|
33 | - * @var string|null |
|
34 | - */ |
|
35 | - protected $_job_id; |
|
28 | + // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore |
|
29 | + // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
|
30 | + /** |
|
31 | + * Current job's ID (if assigned) |
|
32 | + * |
|
33 | + * @var string|null |
|
34 | + */ |
|
35 | + protected $_job_id; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Current job's parameters |
|
39 | - * |
|
40 | - * @var JobParameters|null |
|
41 | - */ |
|
42 | - protected $_job_parameters; |
|
43 | - /** |
|
44 | - * @var LoaderInterface |
|
45 | - */ |
|
46 | - private $loader; |
|
37 | + /** |
|
38 | + * Current job's parameters |
|
39 | + * |
|
40 | + * @var JobParameters|null |
|
41 | + */ |
|
42 | + protected $_job_parameters; |
|
43 | + /** |
|
44 | + * @var LoaderInterface |
|
45 | + */ |
|
46 | + private $loader; |
|
47 | 47 | |
48 | - /** |
|
49 | - * BatchRequestProcessor constructor. |
|
50 | - * @param LoaderInterface $loader |
|
51 | - */ |
|
52 | - public function __construct(LoaderInterface $loader) |
|
53 | - { |
|
54 | - $this->loader = $loader; |
|
55 | - } |
|
56 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
57 | - /** |
|
58 | - * Creates a job for the specified batch handler class (which should be autoloaded) |
|
59 | - * and the specified request data |
|
60 | - * |
|
61 | - * @param string $batch_job_handler_class of an auto-loaded class implementing JobHandlerInterface |
|
62 | - * @param array $request_data to be used by the batch job handler |
|
63 | - * @return JobStepResponse |
|
64 | - */ |
|
65 | - public function create_job($batch_job_handler_class, $request_data) |
|
66 | - { |
|
67 | - try { |
|
68 | - $this->_job_id = wp_generate_password(15, false); |
|
69 | - $obj = $this->instantiate_batch_job_handler_from_classname($batch_job_handler_class); |
|
70 | - $this->_job_parameters = new JobParameters($this->_job_id, $batch_job_handler_class, $request_data); |
|
71 | - $response = $obj->create_job($this->_job_parameters); |
|
72 | - if (! $response instanceof JobStepResponse) { |
|
73 | - throw new BatchRequestException( |
|
74 | - sprintf( |
|
75 | - __( |
|
76 | - 'The class implementing JobHandlerInterface did not return a JobStepResponse when create_job was called with %1$s. It needs to return one or throw an Exception', |
|
77 | - 'event_espresso' |
|
78 | - ), |
|
79 | - wp_json_encode($request_data) |
|
80 | - ) |
|
81 | - ); |
|
82 | - } |
|
83 | - $success = $this->_job_parameters->save(true); |
|
84 | - if (! $success) { |
|
85 | - throw new BatchRequestException( |
|
86 | - sprintf( |
|
87 | - __( |
|
88 | - 'Could not save job %1$s to the Wordpress Options table. These were the arguments used: %2$s', |
|
89 | - 'event_espresso' |
|
90 | - ), |
|
91 | - $this->_job_id, |
|
92 | - wp_json_encode($request_data) |
|
93 | - ) |
|
94 | - ); |
|
95 | - } |
|
96 | - } catch (\Exception $e) { |
|
97 | - $response = $this->_get_error_response($e, 'create_job'); |
|
98 | - } |
|
99 | - return $response; |
|
100 | - } |
|
48 | + /** |
|
49 | + * BatchRequestProcessor constructor. |
|
50 | + * @param LoaderInterface $loader |
|
51 | + */ |
|
52 | + public function __construct(LoaderInterface $loader) |
|
53 | + { |
|
54 | + $this->loader = $loader; |
|
55 | + } |
|
56 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
57 | + /** |
|
58 | + * Creates a job for the specified batch handler class (which should be autoloaded) |
|
59 | + * and the specified request data |
|
60 | + * |
|
61 | + * @param string $batch_job_handler_class of an auto-loaded class implementing JobHandlerInterface |
|
62 | + * @param array $request_data to be used by the batch job handler |
|
63 | + * @return JobStepResponse |
|
64 | + */ |
|
65 | + public function create_job($batch_job_handler_class, $request_data) |
|
66 | + { |
|
67 | + try { |
|
68 | + $this->_job_id = wp_generate_password(15, false); |
|
69 | + $obj = $this->instantiate_batch_job_handler_from_classname($batch_job_handler_class); |
|
70 | + $this->_job_parameters = new JobParameters($this->_job_id, $batch_job_handler_class, $request_data); |
|
71 | + $response = $obj->create_job($this->_job_parameters); |
|
72 | + if (! $response instanceof JobStepResponse) { |
|
73 | + throw new BatchRequestException( |
|
74 | + sprintf( |
|
75 | + __( |
|
76 | + 'The class implementing JobHandlerInterface did not return a JobStepResponse when create_job was called with %1$s. It needs to return one or throw an Exception', |
|
77 | + 'event_espresso' |
|
78 | + ), |
|
79 | + wp_json_encode($request_data) |
|
80 | + ) |
|
81 | + ); |
|
82 | + } |
|
83 | + $success = $this->_job_parameters->save(true); |
|
84 | + if (! $success) { |
|
85 | + throw new BatchRequestException( |
|
86 | + sprintf( |
|
87 | + __( |
|
88 | + 'Could not save job %1$s to the Wordpress Options table. These were the arguments used: %2$s', |
|
89 | + 'event_espresso' |
|
90 | + ), |
|
91 | + $this->_job_id, |
|
92 | + wp_json_encode($request_data) |
|
93 | + ) |
|
94 | + ); |
|
95 | + } |
|
96 | + } catch (\Exception $e) { |
|
97 | + $response = $this->_get_error_response($e, 'create_job'); |
|
98 | + } |
|
99 | + return $response; |
|
100 | + } |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * Retrieves the job's arguments |
|
105 | - * |
|
106 | - * @param string $job_id |
|
107 | - * @param int $batch_size |
|
108 | - * @return JobStepResponse |
|
109 | - */ |
|
110 | - public function continue_job($job_id, $batch_size = 50) |
|
111 | - { |
|
112 | - try { |
|
113 | - $this->_job_id = $job_id; |
|
114 | - $batch_size = defined('EE_BATCHRUNNER_BATCH_SIZE') ? EE_BATCHRUNNER_BATCH_SIZE : $batch_size; |
|
115 | - // get the corresponding WordPress option for the job |
|
116 | - $this->_job_parameters = JobParameters::load($this->_job_id); |
|
117 | - $handler_obj = $this->instantiate_batch_job_handler_from_classname($this->_job_parameters->classname()); |
|
118 | - // continue it |
|
119 | - $response = $handler_obj->continue_job($this->_job_parameters, $batch_size); |
|
120 | - if (! $response instanceof JobStepResponse) { |
|
121 | - throw new BatchRequestException( |
|
122 | - sprintf( |
|
123 | - __( |
|
124 | - 'The class implementing JobHandlerInterface did not return a JobStepResponse when continue_job was called with job %1$s. It needs to return one or throw an Exception', |
|
125 | - 'event_espresso' |
|
126 | - ), |
|
127 | - $this->_job_id |
|
128 | - ) |
|
129 | - ); |
|
130 | - } |
|
131 | - $this->_job_parameters->save(); |
|
132 | - } catch (\Exception $e) { |
|
133 | - $response = $this->_get_error_response($e, 'continue_job'); |
|
134 | - } |
|
135 | - return $response; |
|
136 | - } |
|
103 | + /** |
|
104 | + * Retrieves the job's arguments |
|
105 | + * |
|
106 | + * @param string $job_id |
|
107 | + * @param int $batch_size |
|
108 | + * @return JobStepResponse |
|
109 | + */ |
|
110 | + public function continue_job($job_id, $batch_size = 50) |
|
111 | + { |
|
112 | + try { |
|
113 | + $this->_job_id = $job_id; |
|
114 | + $batch_size = defined('EE_BATCHRUNNER_BATCH_SIZE') ? EE_BATCHRUNNER_BATCH_SIZE : $batch_size; |
|
115 | + // get the corresponding WordPress option for the job |
|
116 | + $this->_job_parameters = JobParameters::load($this->_job_id); |
|
117 | + $handler_obj = $this->instantiate_batch_job_handler_from_classname($this->_job_parameters->classname()); |
|
118 | + // continue it |
|
119 | + $response = $handler_obj->continue_job($this->_job_parameters, $batch_size); |
|
120 | + if (! $response instanceof JobStepResponse) { |
|
121 | + throw new BatchRequestException( |
|
122 | + sprintf( |
|
123 | + __( |
|
124 | + 'The class implementing JobHandlerInterface did not return a JobStepResponse when continue_job was called with job %1$s. It needs to return one or throw an Exception', |
|
125 | + 'event_espresso' |
|
126 | + ), |
|
127 | + $this->_job_id |
|
128 | + ) |
|
129 | + ); |
|
130 | + } |
|
131 | + $this->_job_parameters->save(); |
|
132 | + } catch (\Exception $e) { |
|
133 | + $response = $this->_get_error_response($e, 'continue_job'); |
|
134 | + } |
|
135 | + return $response; |
|
136 | + } |
|
137 | 137 | |
138 | 138 | |
139 | - /** |
|
140 | - * Instantiates an object of type $classname, which implements |
|
141 | - * JobHandlerInterface |
|
142 | - * |
|
143 | - * @param string $classname |
|
144 | - * @return JobHandlerInterface |
|
145 | - * @throws BatchRequestException |
|
146 | - */ |
|
147 | - public function instantiate_batch_job_handler_from_classname($classname) |
|
148 | - { |
|
149 | - if (! class_exists($classname)) { |
|
150 | - throw new BatchRequestException( |
|
151 | - sprintf( |
|
152 | - __( |
|
153 | - 'The class %1$s does not exist, and so could not be used for running a job. It should implement JobHandlerInterface.', |
|
154 | - 'event_espresso' |
|
155 | - ), |
|
156 | - $classname |
|
157 | - ) |
|
158 | - ); |
|
159 | - } |
|
160 | - $obj = $this->loader->getNew($classname); |
|
161 | - if (! $obj instanceof JobHandlerInterface) { |
|
162 | - throw new BatchRequestException( |
|
163 | - sprintf( |
|
164 | - __( |
|
165 | - 'The class %1$s does not implement JobHandlerInterface and so could not be used for running a job', |
|
166 | - 'event_espresso' |
|
167 | - ), |
|
168 | - $classname |
|
169 | - ) |
|
170 | - ); |
|
171 | - } |
|
172 | - return $obj; |
|
173 | - } |
|
139 | + /** |
|
140 | + * Instantiates an object of type $classname, which implements |
|
141 | + * JobHandlerInterface |
|
142 | + * |
|
143 | + * @param string $classname |
|
144 | + * @return JobHandlerInterface |
|
145 | + * @throws BatchRequestException |
|
146 | + */ |
|
147 | + public function instantiate_batch_job_handler_from_classname($classname) |
|
148 | + { |
|
149 | + if (! class_exists($classname)) { |
|
150 | + throw new BatchRequestException( |
|
151 | + sprintf( |
|
152 | + __( |
|
153 | + 'The class %1$s does not exist, and so could not be used for running a job. It should implement JobHandlerInterface.', |
|
154 | + 'event_espresso' |
|
155 | + ), |
|
156 | + $classname |
|
157 | + ) |
|
158 | + ); |
|
159 | + } |
|
160 | + $obj = $this->loader->getNew($classname); |
|
161 | + if (! $obj instanceof JobHandlerInterface) { |
|
162 | + throw new BatchRequestException( |
|
163 | + sprintf( |
|
164 | + __( |
|
165 | + 'The class %1$s does not implement JobHandlerInterface and so could not be used for running a job', |
|
166 | + 'event_espresso' |
|
167 | + ), |
|
168 | + $classname |
|
169 | + ) |
|
170 | + ); |
|
171 | + } |
|
172 | + return $obj; |
|
173 | + } |
|
174 | 174 | |
175 | 175 | |
176 | - /** |
|
177 | - * Forces a job to be cleaned up |
|
178 | - * |
|
179 | - * @param string $job_id |
|
180 | - * @return JobStepResponse |
|
181 | - * @throws BatchRequestException |
|
182 | - */ |
|
183 | - public function cleanup_job($job_id) |
|
184 | - { |
|
185 | - try { |
|
186 | - $this->_job_id = $job_id; |
|
187 | - $job_parameters = JobParameters::load($this->_job_id); |
|
188 | - $handler_obj = $this->instantiate_batch_job_handler_from_classname($job_parameters->classname()); |
|
189 | - // continue it |
|
190 | - $response = $handler_obj->cleanup_job($job_parameters); |
|
191 | - if (! $response instanceof JobStepResponse) { |
|
192 | - throw new BatchRequestException( |
|
193 | - sprintf( |
|
194 | - __( |
|
195 | - 'The class implementing JobHandlerInterface did not return a JobStepResponse when cleanup_job was called with job %1$s. It needs to return one or throw an Exception', |
|
196 | - 'event_espresso' |
|
197 | - ), |
|
198 | - $this->_job_id |
|
199 | - ) |
|
200 | - ); |
|
201 | - } |
|
202 | - $job_parameters->set_status(JobParameters::status_cleaned_up); |
|
203 | - $job_parameters->delete(); |
|
204 | - return $response; |
|
205 | - } catch (\Exception $e) { |
|
206 | - $response = $this->_get_error_response($e, 'cleanup_job'); |
|
207 | - } |
|
208 | - return $response; |
|
209 | - } |
|
176 | + /** |
|
177 | + * Forces a job to be cleaned up |
|
178 | + * |
|
179 | + * @param string $job_id |
|
180 | + * @return JobStepResponse |
|
181 | + * @throws BatchRequestException |
|
182 | + */ |
|
183 | + public function cleanup_job($job_id) |
|
184 | + { |
|
185 | + try { |
|
186 | + $this->_job_id = $job_id; |
|
187 | + $job_parameters = JobParameters::load($this->_job_id); |
|
188 | + $handler_obj = $this->instantiate_batch_job_handler_from_classname($job_parameters->classname()); |
|
189 | + // continue it |
|
190 | + $response = $handler_obj->cleanup_job($job_parameters); |
|
191 | + if (! $response instanceof JobStepResponse) { |
|
192 | + throw new BatchRequestException( |
|
193 | + sprintf( |
|
194 | + __( |
|
195 | + 'The class implementing JobHandlerInterface did not return a JobStepResponse when cleanup_job was called with job %1$s. It needs to return one or throw an Exception', |
|
196 | + 'event_espresso' |
|
197 | + ), |
|
198 | + $this->_job_id |
|
199 | + ) |
|
200 | + ); |
|
201 | + } |
|
202 | + $job_parameters->set_status(JobParameters::status_cleaned_up); |
|
203 | + $job_parameters->delete(); |
|
204 | + return $response; |
|
205 | + } catch (\Exception $e) { |
|
206 | + $response = $this->_get_error_response($e, 'cleanup_job'); |
|
207 | + } |
|
208 | + return $response; |
|
209 | + } |
|
210 | 210 | |
211 | 211 | |
212 | - /** |
|
213 | - * Creates a valid JobStepResponse object from an exception and method name. |
|
214 | - * |
|
215 | - * @param \Exception $exception |
|
216 | - * @param string $method_name |
|
217 | - * @return JobStepResponse |
|
218 | - */ |
|
219 | - protected function _get_error_response(\Exception $exception, $method_name) |
|
220 | - { |
|
221 | - if (! $this->_job_parameters instanceof JobParameters) { |
|
222 | - $this->_job_parameters = new JobParameters($this->_job_id, __('__Unknown__', 'event_espresso'), array()); |
|
223 | - } |
|
224 | - $this->_job_parameters->set_status(JobParameters::status_error); |
|
225 | - return new JobStepResponse( |
|
226 | - $this->_job_parameters, |
|
227 | - sprintf( |
|
228 | - __( |
|
229 | - 'An exception of type %1$s occurred while running %2$s. Its message was %3$s and had trace %4$s', |
|
230 | - 'event_espresso' |
|
231 | - ), |
|
232 | - get_class($exception), |
|
233 | - 'BatchRunner::' . $method_name . '()', |
|
234 | - $exception->getMessage(), |
|
235 | - $exception->getTraceAsString() |
|
236 | - ) |
|
237 | - ); |
|
238 | - } |
|
212 | + /** |
|
213 | + * Creates a valid JobStepResponse object from an exception and method name. |
|
214 | + * |
|
215 | + * @param \Exception $exception |
|
216 | + * @param string $method_name |
|
217 | + * @return JobStepResponse |
|
218 | + */ |
|
219 | + protected function _get_error_response(\Exception $exception, $method_name) |
|
220 | + { |
|
221 | + if (! $this->_job_parameters instanceof JobParameters) { |
|
222 | + $this->_job_parameters = new JobParameters($this->_job_id, __('__Unknown__', 'event_espresso'), array()); |
|
223 | + } |
|
224 | + $this->_job_parameters->set_status(JobParameters::status_error); |
|
225 | + return new JobStepResponse( |
|
226 | + $this->_job_parameters, |
|
227 | + sprintf( |
|
228 | + __( |
|
229 | + 'An exception of type %1$s occurred while running %2$s. Its message was %3$s and had trace %4$s', |
|
230 | + 'event_espresso' |
|
231 | + ), |
|
232 | + get_class($exception), |
|
233 | + 'BatchRunner::' . $method_name . '()', |
|
234 | + $exception->getMessage(), |
|
235 | + $exception->getTraceAsString() |
|
236 | + ) |
|
237 | + ); |
|
238 | + } |
|
239 | 239 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $obj = $this->instantiate_batch_job_handler_from_classname($batch_job_handler_class); |
70 | 70 | $this->_job_parameters = new JobParameters($this->_job_id, $batch_job_handler_class, $request_data); |
71 | 71 | $response = $obj->create_job($this->_job_parameters); |
72 | - if (! $response instanceof JobStepResponse) { |
|
72 | + if ( ! $response instanceof JobStepResponse) { |
|
73 | 73 | throw new BatchRequestException( |
74 | 74 | sprintf( |
75 | 75 | __( |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ); |
82 | 82 | } |
83 | 83 | $success = $this->_job_parameters->save(true); |
84 | - if (! $success) { |
|
84 | + if ( ! $success) { |
|
85 | 85 | throw new BatchRequestException( |
86 | 86 | sprintf( |
87 | 87 | __( |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $handler_obj = $this->instantiate_batch_job_handler_from_classname($this->_job_parameters->classname()); |
118 | 118 | // continue it |
119 | 119 | $response = $handler_obj->continue_job($this->_job_parameters, $batch_size); |
120 | - if (! $response instanceof JobStepResponse) { |
|
120 | + if ( ! $response instanceof JobStepResponse) { |
|
121 | 121 | throw new BatchRequestException( |
122 | 122 | sprintf( |
123 | 123 | __( |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function instantiate_batch_job_handler_from_classname($classname) |
148 | 148 | { |
149 | - if (! class_exists($classname)) { |
|
149 | + if ( ! class_exists($classname)) { |
|
150 | 150 | throw new BatchRequestException( |
151 | 151 | sprintf( |
152 | 152 | __( |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | ); |
159 | 159 | } |
160 | 160 | $obj = $this->loader->getNew($classname); |
161 | - if (! $obj instanceof JobHandlerInterface) { |
|
161 | + if ( ! $obj instanceof JobHandlerInterface) { |
|
162 | 162 | throw new BatchRequestException( |
163 | 163 | sprintf( |
164 | 164 | __( |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $handler_obj = $this->instantiate_batch_job_handler_from_classname($job_parameters->classname()); |
189 | 189 | // continue it |
190 | 190 | $response = $handler_obj->cleanup_job($job_parameters); |
191 | - if (! $response instanceof JobStepResponse) { |
|
191 | + if ( ! $response instanceof JobStepResponse) { |
|
192 | 192 | throw new BatchRequestException( |
193 | 193 | sprintf( |
194 | 194 | __( |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | */ |
219 | 219 | protected function _get_error_response(\Exception $exception, $method_name) |
220 | 220 | { |
221 | - if (! $this->_job_parameters instanceof JobParameters) { |
|
221 | + if ( ! $this->_job_parameters instanceof JobParameters) { |
|
222 | 222 | $this->_job_parameters = new JobParameters($this->_job_id, __('__Unknown__', 'event_espresso'), array()); |
223 | 223 | } |
224 | 224 | $this->_job_parameters->set_status(JobParameters::status_error); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | 'event_espresso' |
231 | 231 | ), |
232 | 232 | get_class($exception), |
233 | - 'BatchRunner::' . $method_name . '()', |
|
233 | + 'BatchRunner::'.$method_name.'()', |
|
234 | 234 | $exception->getMessage(), |
235 | 235 | $exception->getTraceAsString() |
236 | 236 | ) |
@@ -10,11 +10,11 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_File_Input_Display_Strategy extends EE_Text_Input_Display_Strategy |
12 | 12 | { |
13 | - /** |
|
14 | - * Override's parent to just set the type. May someday support other arguments. |
|
15 | - */ |
|
16 | - public function __construct() |
|
17 | - { |
|
18 | - parent::__construct('file'); |
|
19 | - } |
|
13 | + /** |
|
14 | + * Override's parent to just set the type. May someday support other arguments. |
|
15 | + */ |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + parent::__construct('file'); |
|
19 | + } |
|
20 | 20 | } |