@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * Don't exit if we're running test suite. |
37 | 37 | * @since 1.15 |
38 | 38 | */ |
39 | - if( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) { |
|
39 | + if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) { |
|
40 | 40 | return $mixed; |
41 | 41 | } |
42 | 42 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @return void |
51 | 51 | */ |
52 | 52 | function check_ajax_nonce() { |
53 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxviews' ) ) { |
|
53 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxviews' ) ) { |
|
54 | 54 | $this->_exit( false ); |
55 | 55 | } |
56 | 56 | } |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | //check nonce |
68 | 68 | $this->check_ajax_nonce(); |
69 | 69 | |
70 | - $context = isset($_POST['context']) ? esc_attr( $_POST['context'] ) : 'directory'; |
|
70 | + $context = isset( $_POST[ 'context' ] ) ? esc_attr( $_POST[ 'context' ] ) : 'directory'; |
|
71 | 71 | |
72 | 72 | // If Form was changed, JS sends form ID, if start fresh, JS sends template_id |
73 | - if( !empty( $_POST['form_id'] ) ) { |
|
74 | - do_action( 'gravityview_render_available_fields', (int) $_POST['form_id'], $context ); |
|
73 | + if ( ! empty( $_POST[ 'form_id' ] ) ) { |
|
74 | + do_action( 'gravityview_render_available_fields', (int)$_POST[ 'form_id' ], $context ); |
|
75 | 75 | $this->_exit(); |
76 | - } elseif( !empty( $_POST['template_id'] ) ) { |
|
77 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
76 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) ) { |
|
77 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
78 | 78 | do_action( 'gravityview_render_available_fields', $form, $context ); |
79 | 79 | $this->_exit(); |
80 | 80 | } |
@@ -94,17 +94,17 @@ discard block |
||
94 | 94 | function get_active_areas() { |
95 | 95 | $this->check_ajax_nonce(); |
96 | 96 | |
97 | - if( empty( $_POST['template_id'] ) ) { |
|
97 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
98 | 98 | $this->_exit( false ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | ob_start(); |
102 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true ); |
|
103 | - $response['directory'] = ob_get_clean(); |
|
102 | + do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'directory', '', true ); |
|
103 | + $response[ 'directory' ] = ob_get_clean(); |
|
104 | 104 | |
105 | 105 | ob_start(); |
106 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true ); |
|
107 | - $response['single'] = ob_get_clean(); |
|
106 | + do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'single', '', true ); |
|
107 | + $response[ 'single' ] = ob_get_clean(); |
|
108 | 108 | |
109 | 109 | $response = array_map( 'gravityview_strip_whitespace', $response ); |
110 | 110 | |
@@ -119,20 +119,20 @@ discard block |
||
119 | 119 | |
120 | 120 | $this->check_ajax_nonce(); |
121 | 121 | |
122 | - if( empty( $_POST['template_id'] ) ) { |
|
122 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
123 | 123 | $this->_exit( false ); |
124 | 124 | } |
125 | 125 | |
126 | 126 | // get the fields xml config file for this specific preset |
127 | - $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] ); |
|
127 | + $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST[ 'template_id' ] ); |
|
128 | 128 | // import fields |
129 | - if( !empty( $preset_fields_path ) ) { |
|
129 | + if ( ! empty( $preset_fields_path ) ) { |
|
130 | 130 | $presets = $this->import_fields( $preset_fields_path ); |
131 | 131 | } else { |
132 | 132 | $presets = array( 'widgets' => array(), 'fields' => array() ); |
133 | 133 | } |
134 | 134 | |
135 | - $template_id = esc_attr( $_POST['template_id'] ); |
|
135 | + $template_id = esc_attr( $_POST[ 'template_id' ] ); |
|
136 | 136 | |
137 | 137 | // template areas |
138 | 138 | $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); |
@@ -142,20 +142,20 @@ discard block |
||
142 | 142 | $default_widget_areas = GravityView_Plugin::get_default_widget_areas(); |
143 | 143 | |
144 | 144 | ob_start(); |
145 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] ); |
|
146 | - $response['header'] = ob_get_clean(); |
|
145 | + do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets[ 'widgets' ] ); |
|
146 | + $response[ 'header' ] = ob_get_clean(); |
|
147 | 147 | |
148 | 148 | ob_start(); |
149 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] ); |
|
150 | - $response['footer'] = ob_get_clean(); |
|
149 | + do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets[ 'widgets' ] ); |
|
150 | + $response[ 'footer' ] = ob_get_clean(); |
|
151 | 151 | |
152 | 152 | ob_start(); |
153 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] ); |
|
154 | - $response['directory'] = ob_get_clean(); |
|
153 | + do_action( 'gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets[ 'fields' ] ); |
|
154 | + $response[ 'directory' ] = ob_get_clean(); |
|
155 | 155 | |
156 | 156 | ob_start(); |
157 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] ); |
|
158 | - $response['single'] = ob_get_clean(); |
|
157 | + do_action( 'gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets[ 'fields' ] ); |
|
158 | + $response[ 'single' ] = ob_get_clean(); |
|
159 | 159 | |
160 | 160 | $response = array_map( 'gravityview_strip_whitespace', $response ); |
161 | 161 | |
@@ -173,26 +173,26 @@ discard block |
||
173 | 173 | |
174 | 174 | $this->check_ajax_nonce(); |
175 | 175 | |
176 | - if( empty( $_POST['template_id'] ) ) { |
|
176 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
177 | 177 | do_action( 'gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.' ); |
178 | 178 | $this->_exit( false ); |
179 | 179 | } |
180 | 180 | |
181 | 181 | // get the xml for this specific template_id |
182 | - $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] ); |
|
182 | + $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST[ 'template_id' ] ); |
|
183 | 183 | |
184 | 184 | // import form |
185 | 185 | $form = $this->import_form( $preset_form_xml_path ); |
186 | 186 | |
187 | 187 | // get the form ID |
188 | - if( false === $form ) { |
|
188 | + if ( false === $form ) { |
|
189 | 189 | // send error to user |
190 | - do_action( 'gravityview_log_error', '[create_preset_form] Error importing form for template id: ' . (int) $_POST['template_id'] ); |
|
190 | + do_action( 'gravityview_log_error', '[create_preset_form] Error importing form for template id: ' . (int)$_POST[ 'template_id' ] ); |
|
191 | 191 | |
192 | 192 | $this->_exit( false ); |
193 | 193 | } |
194 | 194 | |
195 | - $this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' ); |
|
195 | + $this->_exit( '<option value="' . esc_attr( $form[ 'id' ] ) . '" selected="selected">' . esc_html( $form[ 'title' ] ) . '</option>' ); |
|
196 | 196 | |
197 | 197 | } |
198 | 198 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | do_action( 'gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path ); |
208 | 208 | |
209 | - if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) { |
|
209 | + if ( empty( $xml_or_json_path ) || ! class_exists( 'GFExport' ) || ! file_exists( $xml_or_json_path ) ) { |
|
210 | 210 | do_action( 'gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path ); |
211 | 211 | return false; |
212 | 212 | } |
@@ -218,13 +218,13 @@ discard block |
||
218 | 218 | do_action( 'gravityview_log_debug', '[import_form] Importing form (Result)', $count ); |
219 | 219 | do_action( 'gravityview_log_debug', '[import_form] Importing form (Form) ', $forms ); |
220 | 220 | |
221 | - if( $count != 1 || empty( $forms[0]['id'] ) ) { |
|
221 | + if ( $count != 1 || empty( $forms[ 0 ][ 'id' ] ) ) { |
|
222 | 222 | do_action( 'gravityview_log_error', '[import_form] Form Import Failed!' ); |
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | |
226 | 226 | // import success - return form id |
227 | - return $forms[0]; |
|
227 | + return $forms[ 0 ]; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | function get_field_options() { |
239 | 239 | $this->check_ajax_nonce(); |
240 | 240 | |
241 | - if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) { |
|
241 | + if ( empty( $_POST[ 'template' ] ) || empty( $_POST[ 'area' ] ) || empty( $_POST[ 'field_id' ] ) || empty( $_POST[ 'field_type' ] ) ) { |
|
242 | 242 | do_action( 'gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. ' ); |
243 | 243 | $this->_exit( false ); |
244 | 244 | } |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | $_post = array_map( 'esc_attr', $_post ); |
251 | 251 | |
252 | 252 | // The GF type of field: `product`, `name`, `creditcard`, `id`, `text` |
253 | - $input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL; |
|
254 | - $context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL; |
|
253 | + $input_type = isset( $_post[ 'input_type' ] ) ? esc_attr( $_post[ 'input_type' ] ) : NULL; |
|
254 | + $context = isset( $_post[ 'context' ] ) ? esc_attr( $_post[ 'context' ] ) : NULL; |
|
255 | 255 | |
256 | - $response = GravityView_Render_Settings::render_field_options( $_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context ); |
|
256 | + $response = GravityView_Render_Settings::render_field_options( $_post[ 'field_type' ], $_post[ 'template' ], $_post[ 'field_id' ], $_post[ 'field_label' ], $_post[ 'area' ], $input_type, '', '', $context ); |
|
257 | 257 | |
258 | 258 | $response = gravityview_strip_whitespace( $response ); |
259 | 259 | |
@@ -274,15 +274,15 @@ discard block |
||
274 | 274 | $form = ''; |
275 | 275 | |
276 | 276 | // if form id is set, use it, else, get form from preset |
277 | - if( !empty( $_POST['form_id'] ) ) { |
|
277 | + if ( ! empty( $_POST[ 'form_id' ] ) ) { |
|
278 | 278 | |
279 | - $form = (int) $_POST['form_id']; |
|
279 | + $form = (int)$_POST[ 'form_id' ]; |
|
280 | 280 | |
281 | 281 | } |
282 | 282 | // get form from preset |
283 | - elseif( !empty( $_POST['template_id'] ) ) { |
|
283 | + elseif ( ! empty( $_POST[ 'template_id' ] ) ) { |
|
284 | 284 | |
285 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
285 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
286 | 286 | |
287 | 287 | } |
288 | 288 | |
@@ -298,27 +298,27 @@ discard block |
||
298 | 298 | * @param string $template_id Preset template |
299 | 299 | * |
300 | 300 | */ |
301 | - static function pre_get_form_fields( $template_id = '') { |
|
301 | + static function pre_get_form_fields( $template_id = '' ) { |
|
302 | 302 | |
303 | - if( empty( $template_id ) ) { |
|
303 | + if ( empty( $template_id ) ) { |
|
304 | 304 | do_action( 'gravityview_log_error', __METHOD__ . ' - Template ID not set.' ); |
305 | 305 | return false; |
306 | 306 | } else { |
307 | 307 | $form_file = apply_filters( 'gravityview_template_formxml', '', $template_id ); |
308 | - if( !file_exists( $form_file ) ) { |
|
309 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Importing Form Fields for preset ['. $template_id .']. File not found. file: ' . $form_file ); |
|
308 | + if ( ! file_exists( $form_file ) ) { |
|
309 | + do_action( 'gravityview_log_error', __METHOD__ . ' - Importing Form Fields for preset [' . $template_id . ']. File not found. file: ' . $form_file ); |
|
310 | 310 | return false; |
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | // Load xml parser (from GravityForms) |
315 | - if( class_exists( 'GFCommon' ) ) { |
|
315 | + if ( class_exists( 'GFCommon' ) ) { |
|
316 | 316 | $xml_parser = GFCommon::get_base_path() . '/xml.php'; |
317 | 317 | } else { |
318 | 318 | $xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php'; |
319 | 319 | } |
320 | 320 | |
321 | - if( file_exists( $xml_parser ) ) { |
|
321 | + if ( file_exists( $xml_parser ) ) { |
|
322 | 322 | require_once( $xml_parser ); |
323 | 323 | } else { |
324 | 324 | do_action( 'gravityview_log_debug', __METHOD__ . ' - Gravity Forms XML Parser not found.', $xml_parser ); |
@@ -329,37 +329,37 @@ discard block |
||
329 | 329 | $xmlstr = file_get_contents( $form_file ); |
330 | 330 | |
331 | 331 | $options = array( |
332 | - "page" => array("unserialize_as_array" => true), |
|
333 | - "form"=> array("unserialize_as_array" => true), |
|
334 | - "field"=> array("unserialize_as_array" => true), |
|
335 | - "rule"=> array("unserialize_as_array" => true), |
|
336 | - "choice"=> array("unserialize_as_array" => true), |
|
337 | - "input"=> array("unserialize_as_array" => true), |
|
338 | - "routing_item"=> array("unserialize_as_array" => true), |
|
339 | - "creditCard"=> array("unserialize_as_array" => true), |
|
340 | - "routin"=> array("unserialize_as_array" => true), |
|
341 | - "confirmation" => array("unserialize_as_array" => true), |
|
342 | - "notification" => array("unserialize_as_array" => true) |
|
332 | + "page" => array( "unserialize_as_array" => true ), |
|
333 | + "form"=> array( "unserialize_as_array" => true ), |
|
334 | + "field"=> array( "unserialize_as_array" => true ), |
|
335 | + "rule"=> array( "unserialize_as_array" => true ), |
|
336 | + "choice"=> array( "unserialize_as_array" => true ), |
|
337 | + "input"=> array( "unserialize_as_array" => true ), |
|
338 | + "routing_item"=> array( "unserialize_as_array" => true ), |
|
339 | + "creditCard"=> array( "unserialize_as_array" => true ), |
|
340 | + "routin"=> array( "unserialize_as_array" => true ), |
|
341 | + "confirmation" => array( "unserialize_as_array" => true ), |
|
342 | + "notification" => array( "unserialize_as_array" => true ) |
|
343 | 343 | ); |
344 | 344 | |
345 | - $xml = new RGXML($options); |
|
346 | - $forms = $xml->unserialize($xmlstr); |
|
345 | + $xml = new RGXML( $options ); |
|
346 | + $forms = $xml->unserialize( $xmlstr ); |
|
347 | 347 | |
348 | - if( !$forms ) { |
|
349 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file ); |
|
348 | + if ( ! $forms ) { |
|
349 | + do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset [' . $template_id . ']. Error importing file. (File)', $form_file ); |
|
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | |
353 | - if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
354 | - $form = $forms[0]; |
|
353 | + if ( ! empty( $forms[ 0 ] ) && is_array( $forms[ 0 ] ) ) { |
|
354 | + $form = $forms[ 0 ]; |
|
355 | 355 | } |
356 | 356 | |
357 | - if( empty( $form ) ) { |
|
357 | + if ( empty( $form ) ) { |
|
358 | 358 | do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); |
359 | 359 | return false; |
360 | 360 | } |
361 | 361 | |
362 | - do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form ); |
|
362 | + do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset [' . $template_id . ']. (Form)', $form ); |
|
363 | 363 | |
364 | 364 | return $form; |
365 | 365 | |
@@ -373,38 +373,38 @@ discard block |
||
373 | 373 | */ |
374 | 374 | function import_fields( $file ) { |
375 | 375 | |
376 | - if( empty( $file ) || !file_exists( $file ) ) { |
|
376 | + if ( empty( $file ) || ! file_exists( $file ) ) { |
|
377 | 377 | do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file ); |
378 | 378 | return false; |
379 | 379 | } |
380 | 380 | |
381 | - if( !class_exists('WXR_Parser') ) { |
|
381 | + if ( ! class_exists( 'WXR_Parser' ) ) { |
|
382 | 382 | include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php'; |
383 | 383 | } |
384 | 384 | |
385 | 385 | $parser = new WXR_Parser(); |
386 | 386 | $presets = $parser->parse( $file ); |
387 | 387 | |
388 | - if(is_wp_error( $presets )) { |
|
388 | + if ( is_wp_error( $presets ) ) { |
|
389 | 389 | do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets ); |
390 | 390 | return false; |
391 | 391 | } |
392 | 392 | |
393 | - if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) { |
|
393 | + if ( empty( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) && ! is_array( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) ) { |
|
394 | 394 | do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file ); |
395 | 395 | return false; |
396 | 396 | } |
397 | 397 | |
398 | - do_action( 'gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta'] ); |
|
398 | + do_action( 'gravityview_log_debug', '[import_fields] postmeta', $presets[ 'posts' ][ 0 ][ 'postmeta' ] ); |
|
399 | 399 | |
400 | 400 | $fields = $widgets = array(); |
401 | - foreach( $presets['posts'][0]['postmeta'] as $meta ) { |
|
402 | - switch ($meta['key']) { |
|
401 | + foreach ( $presets[ 'posts' ][ 0 ][ 'postmeta' ] as $meta ) { |
|
402 | + switch ( $meta[ 'key' ] ) { |
|
403 | 403 | case '_gravityview_directory_fields': |
404 | - $fields = maybe_unserialize( $meta['value'] ); |
|
404 | + $fields = maybe_unserialize( $meta[ 'value' ] ); |
|
405 | 405 | break; |
406 | 406 | case '_gravityview_directory_widgets': |
407 | - $widgets = maybe_unserialize( $meta['value'] ); |
|
407 | + $widgets = maybe_unserialize( $meta[ 'value' ] ); |
|
408 | 408 | break; |
409 | 409 | } |
410 | 410 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | parent::add_hooks(); |
58 | 58 | |
59 | - if( gravityview_is_admin_page() ) { |
|
59 | + if ( gravityview_is_admin_page() ) { |
|
60 | 60 | |
61 | 61 | // Make Yoast metabox go down to the bottom please. |
62 | 62 | add_filter( 'wpseo_metabox_prio', array( $this, '__return_low' ) ); |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | global $pagenow; |
84 | 84 | |
85 | 85 | // New View page |
86 | - if( $pagenow === 'post-new.php' ) { |
|
87 | - $options['hideeditbox-gravityview'] = true; |
|
86 | + if ( $pagenow === 'post-new.php' ) { |
|
87 | + $options[ 'hideeditbox-gravityview' ] = true; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | return $options; |
@@ -78,7 +78,7 @@ |
||
78 | 78 | $gv_page = gravityview_is_admin_page( '', 'single' ); |
79 | 79 | |
80 | 80 | // New View or Edit View page |
81 | - if( $gv_page && $pagenow === 'post-new.php' ) { |
|
81 | + if ( $gv_page && $pagenow === 'post-new.php' ) { |
|
82 | 82 | remove_meta_box( 'woothemes-settings', 'gravityview', 'normal' ); |
83 | 83 | } |
84 | 84 | } |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | * @return string Path to XML file |
194 | 194 | */ |
195 | 195 | public function assign_form_xml( $xml = '', $template = '' ) { |
196 | - if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_form'] ) && $this->template_id === $template ) { |
|
197 | - return $this->settings['preset_form']; |
|
196 | + if ( $this->settings[ 'type' ] === 'preset' && ! empty( $this->settings[ 'preset_form' ] ) && $this->template_id === $template ) { |
|
197 | + return $this->settings[ 'preset_form' ]; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | return $xml; |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | * @return string Path to XML file |
208 | 208 | */ |
209 | 209 | public function assign_fields_xml( $xml = '', $template = '' ) { |
210 | - if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_fields'] ) && $this->template_id === $template ) { |
|
211 | - return $this->settings['preset_fields']; |
|
210 | + if ( $this->settings[ 'type' ] === 'preset' && ! empty( $this->settings[ 'preset_fields' ] ) && $this->template_id === $template ) { |
|
211 | + return $this->settings[ 'preset_fields' ]; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | return $xml; |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function assign_view_slug( $default, $context ) { |
228 | 228 | |
229 | - if ( ! empty( $this->settings['slug'] ) ) { |
|
230 | - return $this->settings['slug']; |
|
229 | + if ( ! empty( $this->settings[ 'slug' ] ) ) { |
|
230 | + return $this->settings[ 'slug' ]; |
|
231 | 231 | } |
232 | 232 | if ( ! empty( $default ) ) { |
233 | 233 | return $default; |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @return void |
245 | 245 | */ |
246 | 246 | public function register_styles() { |
247 | - if ( ! empty( $this->settings['css_source'] ) ) { |
|
248 | - wp_register_style( 'gravityview_style_' . $this->template_id, $this->settings['css_source'], array(), GravityView_Plugin::version, 'all' ); |
|
247 | + if ( ! empty( $this->settings[ 'css_source' ] ) ) { |
|
248 | + wp_register_style( 'gravityview_style_' . $this->template_id, $this->settings[ 'css_source' ], array(), GravityView_Plugin::version, 'all' ); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | function init() { |
22 | 22 | |
23 | 23 | $icon = is_admin() ? '<i class="icon gv-icon-astronaut-head"></i> ' : NULL; |
24 | - $this->title( $icon . __('GravityView', 'gravityview') ); |
|
24 | + $this->title( $icon . __( 'GravityView', 'gravityview' ) ); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | function get_warnings() { |
28 | 28 | |
29 | - if( is_null( $this->warnings ) ) { |
|
29 | + if ( is_null( $this->warnings ) ) { |
|
30 | 30 | $this->warnings = GravityView_Logging::get_errors(); |
31 | 31 | } |
32 | 32 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | function get_notices() { |
37 | 37 | |
38 | - if( is_null( $this->notices ) ) { |
|
38 | + if ( is_null( $this->notices ) ) { |
|
39 | 39 | $this->notices = GravityView_Logging::get_notices(); |
40 | 40 | } |
41 | 41 | |
@@ -84,27 +84,27 @@ discard block |
||
84 | 84 | </style> |
85 | 85 | <div id='debug-bar-gravityview'>"; |
86 | 86 | |
87 | - $output .= '<img src="'.plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ).'" class="alignright" alt="" width="100" height="132" />'; |
|
87 | + $output .= '<img src="' . plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ) . '" class="alignright" alt="" width="100" height="132" />'; |
|
88 | 88 | |
89 | 89 | |
90 | 90 | $warnings = $this->get_warnings(); |
91 | 91 | $notices = $this->get_notices(); |
92 | 92 | |
93 | - if(count($warnings)) { |
|
94 | - $output .= '<h3><span>'.__('Warnings', 'gravityview').'</span></h3>'; |
|
93 | + if ( count( $warnings ) ) { |
|
94 | + $output .= '<h3><span>' . __( 'Warnings', 'gravityview' ) . '</span></h3>'; |
|
95 | 95 | $output .= '<ol>'; |
96 | - foreach ( $warnings as $key => $notice) { |
|
97 | - if(empty($notice['message'])) { continue; } |
|
98 | - $output .= '<li><a href="#'.sanitize_html_class( 'gv-warning-' . $key ).'">'.strip_tags($notice['message']).'</a></li>'; |
|
96 | + foreach ( $warnings as $key => $notice ) { |
|
97 | + if ( empty( $notice[ 'message' ] ) ) { continue; } |
|
98 | + $output .= '<li><a href="#' . sanitize_html_class( 'gv-warning-' . $key ) . '">' . strip_tags( $notice[ 'message' ] ) . '</a></li>'; |
|
99 | 99 | } |
100 | 100 | $output .= '</ol><hr />'; |
101 | 101 | } |
102 | - if(count($notices)) { |
|
103 | - $output .= '<h3><span>'.__('Logs', 'gravityview').'</span></h3>'; |
|
102 | + if ( count( $notices ) ) { |
|
103 | + $output .= '<h3><span>' . __( 'Logs', 'gravityview' ) . '</span></h3>'; |
|
104 | 104 | $output .= '<ol>'; |
105 | - foreach ( $notices as $key => $notice) { |
|
106 | - if(empty($notice['message'])) { continue; } |
|
107 | - $output .= '<li><a href="#'.sanitize_html_class( 'gv-notice-' . $key ).'">'.strip_tags($notice['message']).'</a></li>'; |
|
105 | + foreach ( $notices as $key => $notice ) { |
|
106 | + if ( empty( $notice[ 'message' ] ) ) { continue; } |
|
107 | + $output .= '<li><a href="#' . sanitize_html_class( 'gv-notice-' . $key ) . '">' . strip_tags( $notice[ 'message' ] ) . '</a></li>'; |
|
108 | 108 | } |
109 | 109 | $output .= '</ol><hr />'; |
110 | 110 | } |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | if ( count( $warnings ) ) { |
113 | 113 | $output .= '<h3>Warnings</h3>'; |
114 | 114 | $output .= '<ol class="debug-bar-php-list">'; |
115 | - foreach ( $warnings as $key => $notice) { $output .= $this->render_item( $notice, 'gv-warning-' . $key ); } |
|
115 | + foreach ( $warnings as $key => $notice ) { $output .= $this->render_item( $notice, 'gv-warning-' . $key ); } |
|
116 | 116 | $output .= '</ol>'; |
117 | 117 | } |
118 | 118 | |
119 | 119 | if ( count( $notices ) ) { |
120 | 120 | $output .= '<h3>Notices</h3>'; |
121 | 121 | $output .= '<ol class="debug-bar-php-list">'; |
122 | - foreach ( $notices as $key => $notice) { $output .= $this->render_item( $notice, 'gv-notice-' . $key ); } |
|
122 | + foreach ( $notices as $key => $notice ) { $output .= $this->render_item( $notice, 'gv-notice-' . $key ); } |
|
123 | 123 | $output .= '</ol>'; |
124 | 124 | } |
125 | 125 | |
@@ -133,17 +133,17 @@ discard block |
||
133 | 133 | * @param string|array $item Unescaped |
134 | 134 | * @return string Escaped HTML |
135 | 135 | */ |
136 | - function esc_html_recursive($item) { |
|
137 | - if(is_object($item)) { |
|
138 | - foreach($item as $key => $value) { |
|
139 | - $item->{$key} = $this->esc_html_recursive($value); |
|
136 | + function esc_html_recursive( $item ) { |
|
137 | + if ( is_object( $item ) ) { |
|
138 | + foreach ( $item as $key => $value ) { |
|
139 | + $item->{$key} = $this->esc_html_recursive( $value ); |
|
140 | 140 | } |
141 | - } else if(is_array($item)) { |
|
142 | - foreach($item as $key => $value) { |
|
143 | - $item[$key] = $this->esc_html_recursive($value); |
|
141 | + } else if ( is_array( $item ) ) { |
|
142 | + foreach ( $item as $key => $value ) { |
|
143 | + $item[ $key ] = $this->esc_html_recursive( $value ); |
|
144 | 144 | } |
145 | 145 | } else { |
146 | - $item = esc_html($item); |
|
146 | + $item = esc_html( $item ); |
|
147 | 147 | } |
148 | 148 | return $item; |
149 | 149 | } |
@@ -159,26 +159,26 @@ discard block |
||
159 | 159 | |
160 | 160 | $output = ''; |
161 | 161 | |
162 | - if(!empty($notice['message'])) { |
|
163 | - $output .= '<a id="'.sanitize_html_class( $anchor ).'"></a>'; |
|
162 | + if ( ! empty( $notice[ 'message' ] ) ) { |
|
163 | + $output .= '<a id="' . sanitize_html_class( $anchor ) . '"></a>'; |
|
164 | 164 | $output .= "<li class='debug-bar-php-notice'>"; |
165 | 165 | } |
166 | 166 | |
167 | 167 | $output .= '<div class="clear"></div>'; |
168 | 168 | |
169 | 169 | // Title |
170 | - $output .= '<div class="gravityview-debug-bar-title">'.esc_attr( $notice['message'] ).'</div>'; |
|
170 | + $output .= '<div class="gravityview-debug-bar-title">' . esc_attr( $notice[ 'message' ] ) . '</div>'; |
|
171 | 171 | |
172 | 172 | // Debugging Output |
173 | - if( empty( $notice['data'] ) ) { |
|
174 | - if( !is_null( $notice['data'] ) ) { |
|
175 | - $output .= '<em>'._x('Empty', 'Debugging output data is empty.', 'gravityview' ).'</em>'; |
|
173 | + if ( empty( $notice[ 'data' ] ) ) { |
|
174 | + if ( ! is_null( $notice[ 'data' ] ) ) { |
|
175 | + $output .= '<em>' . _x( 'Empty', 'Debugging output data is empty.', 'gravityview' ) . '</em>'; |
|
176 | 176 | } |
177 | 177 | } else { |
178 | - $output .= sprintf( '<pre>%s</pre>', print_r($this->esc_html_recursive( $notice['data'] ), true) ); |
|
178 | + $output .= sprintf( '<pre>%s</pre>', print_r( $this->esc_html_recursive( $notice[ 'data' ] ), true ) ); |
|
179 | 179 | } |
180 | 180 | |
181 | - if(!empty($notice['message'])) { |
|
181 | + if ( ! empty( $notice[ 'message' ] ) ) { |
|
182 | 182 | $output .= '</li>'; |
183 | 183 | } |
184 | 184 |
@@ -5,4 +5,4 @@ |
||
5 | 5 | * @deprecated 1.7.5 |
6 | 6 | */ |
7 | 7 | |
8 | -include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget.php' ); |
|
8 | +include_once( GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget.php' ); |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | |
26 | 26 | function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
27 | 27 | |
28 | - if( 'edit' === $context ) { |
|
28 | + if ( 'edit' === $context ) { |
|
29 | 29 | return $field_options; |
30 | 30 | } |
31 | 31 | |
32 | - $field_options['trim_words'] = array( |
|
32 | + $field_options[ 'trim_words' ] = array( |
|
33 | 33 | 'type' => 'number', |
34 | 34 | 'merge_tags' => false, |
35 | 35 | 'value' => null, |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'tooltip' => __( 'Enter the number of words to be shown. If specified it truncates the text. Leave it blank if you want to show the full text.', 'gravityview' ), |
38 | 38 | ); |
39 | 39 | |
40 | - $field_options['make_clickable'] = array( |
|
40 | + $field_options[ 'make_clickable' ] = array( |
|
41 | 41 | 'type' => 'checkbox', |
42 | 42 | 'merge_tags' => false, |
43 | 43 | 'value' => 0, |
@@ -27,7 +27,7 @@ |
||
27 | 27 | |
28 | 28 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
29 | 29 | |
30 | - unset ( $field_options['search_filter'], $field_options['show_as_link'] ); |
|
30 | + unset ( $field_options[ 'search_filter' ], $field_options[ 'show_as_link' ] ); |
|
31 | 31 | |
32 | 32 | return $field_options; |
33 | 33 | } |
@@ -28,17 +28,17 @@ |
||
28 | 28 | |
29 | 29 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
30 | 30 | |
31 | - $field_options['number_format'] = array( |
|
31 | + $field_options[ 'number_format' ] = array( |
|
32 | 32 | 'type' => 'checkbox', |
33 | 33 | 'label' => __( 'Format number?', 'gravityview' ), |
34 | - 'desc' => __('Display numbers with thousands separators.', 'gravityview'), |
|
34 | + 'desc' => __( 'Display numbers with thousands separators.', 'gravityview' ), |
|
35 | 35 | 'value' => false, |
36 | 36 | ); |
37 | 37 | |
38 | - $field_options['decimals'] = array( |
|
38 | + $field_options[ 'decimals' ] = array( |
|
39 | 39 | 'type' => 'number', |
40 | 40 | 'label' => __( 'Decimals', 'gravityview' ), |
41 | - 'desc' => __('Precision of the number of decimal places. Leave blank to use existing precision.', 'gravityview'), |
|
41 | + 'desc' => __( 'Precision of the number of decimal places. Leave blank to use existing precision.', 'gravityview' ), |
|
42 | 42 | 'value' => '', |
43 | 43 | 'merge_tags' => false, |
44 | 44 | ); |