@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @copyright Copyright 2014, Katz Web Services, Inc. |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'WPINC' ) ) { |
|
12 | +if (!defined('WPINC')) { |
|
13 | 13 | die; |
14 | 14 | } |
15 | 15 | |
@@ -84,30 +84,30 @@ discard block |
||
84 | 84 | */ |
85 | 85 | var $is_valid = NULL; |
86 | 86 | |
87 | - function __construct( GravityView_Edit_Entry $loader ) { |
|
87 | + function __construct(GravityView_Edit_Entry $loader) { |
|
88 | 88 | $this->loader = $loader; |
89 | 89 | } |
90 | 90 | |
91 | 91 | function load() { |
92 | 92 | |
93 | 93 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
94 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
94 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-approve-entries.php'); |
|
95 | 95 | |
96 | 96 | // Stop Gravity Forms processing what is ours! |
97 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
97 | + add_filter('wp', array($this, 'prevent_maybe_process_form'), 8); |
|
98 | 98 | |
99 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
99 | + add_filter('gravityview_is_edit_entry', array($this, 'is_edit_entry')); |
|
100 | 100 | |
101 | - add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
|
101 | + add_action('gravityview_edit_entry', array($this, 'init')); |
|
102 | 102 | |
103 | 103 | // Disable conditional logic if needed (since 1.9) |
104 | - add_filter( 'gform_has_conditional_logic', array( $this, 'manage_conditional_logic' ), 10, 2 ); |
|
104 | + add_filter('gform_has_conditional_logic', array($this, 'manage_conditional_logic'), 10, 2); |
|
105 | 105 | |
106 | 106 | // Make sure GF doesn't validate max files (since 1.9) |
107 | - add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
|
107 | + add_filter('gform_plupload_settings', array($this, 'modify_fileupload_settings'), 10, 3); |
|
108 | 108 | |
109 | 109 | // Add fields expected by GFFormDisplay::validate() |
110 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
110 | + add_filter('gform_pre_validation', array($this, 'gform_pre_validation')); |
|
111 | 111 | |
112 | 112 | } |
113 | 113 | |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | */ |
121 | 121 | function prevent_maybe_process_form() { |
122 | 122 | |
123 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
123 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html(print_r($_POST, true))); |
|
124 | 124 | |
125 | - if( $this->is_edit_entry_submission() && $this->verify_nonce() ) { |
|
126 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
125 | + if ($this->is_edit_entry_submission() && $this->verify_nonce()) { |
|
126 | + remove_action('wp', array('RGForms', 'maybe_process_form'), 9); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function is_edit_entry() { |
135 | 135 | |
136 | - $gf_page = ( 'entry' === RGForms::get( 'view' ) ); |
|
136 | + $gf_page = ('entry' === RGForms::get('view')); |
|
137 | 137 | |
138 | - return ( $gf_page && isset( $_GET['edit'] ) || RGForms::post( 'action' ) === 'update' ); |
|
138 | + return ($gf_page && isset($_GET['edit']) || RGForms::post('action') === 'update'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return boolean |
145 | 145 | */ |
146 | 146 | public function is_edit_entry_submission() { |
147 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
147 | + return !empty($_POST[self::$nonce_field]); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $this->form_id = $gravityview_view->getFormId(); |
163 | 163 | $this->view_id = $gravityview_view->getViewId(); |
164 | 164 | |
165 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
165 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key($this->view_id, $this->form_id, $this->entry['id']); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -174,20 +174,20 @@ discard block |
||
174 | 174 | * @param GravityView_View_Data $gv_data GravityView Data object |
175 | 175 | * @return void |
176 | 176 | */ |
177 | - function init( $gv_data ) { |
|
177 | + function init($gv_data) { |
|
178 | 178 | |
179 | - require_once( GFCommon::get_base_path() . '/form_display.php' ); |
|
180 | - require_once( GFCommon::get_base_path() . '/entry_detail.php' ); |
|
179 | + require_once(GFCommon::get_base_path().'/form_display.php'); |
|
180 | + require_once(GFCommon::get_base_path().'/entry_detail.php'); |
|
181 | 181 | |
182 | 182 | $this->setup_vars(); |
183 | 183 | |
184 | 184 | // Multiple Views embedded, don't proceed if nonce fails |
185 | - if( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
185 | + if ($gv_data->has_multiple_views() && !wp_verify_nonce($_GET['edit'], self::$nonce_key)) { |
|
186 | 186 | return; |
187 | 187 | } |
188 | 188 | |
189 | 189 | // Sorry, you're not allowed here. |
190 | - if( false === $this->user_can_edit_entry( true ) ) { |
|
190 | + if (false === $this->user_can_edit_entry(true)) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -207,12 +207,12 @@ discard block |
||
207 | 207 | function print_scripts() { |
208 | 208 | $gravityview_view = GravityView_View::getInstance(); |
209 | 209 | |
210 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
210 | + wp_register_script('gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array('jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view')); |
|
211 | 211 | |
212 | 212 | GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false); |
213 | 213 | |
214 | 214 | // Sack is required for images |
215 | - wp_print_scripts( array( 'sack', 'gform_gravityforms' ) ); |
|
215 | + wp_print_scripts(array('sack', 'gform_gravityforms')); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | |
@@ -221,32 +221,32 @@ discard block |
||
221 | 221 | */ |
222 | 222 | function process_save() { |
223 | 223 | |
224 | - if( empty( $_POST ) ) { |
|
224 | + if (empty($_POST)) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | 228 | // Make sure the entry, view, and form IDs are all correct |
229 | 229 | $valid = $this->verify_nonce(); |
230 | 230 | |
231 | - if( !$valid ) { |
|
232 | - do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); |
|
231 | + if (!$valid) { |
|
232 | + do_action('gravityview_log_error', __METHOD__.' Nonce validation failed.'); |
|
233 | 233 | return; |
234 | 234 | } |
235 | 235 | |
236 | - if( $this->entry['id'] !== $_POST['lid'] ) { |
|
237 | - do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); |
|
236 | + if ($this->entry['id'] !== $_POST['lid']) { |
|
237 | + do_action('gravityview_log_error', __METHOD__.' Entry ID did not match posted entry ID.'); |
|
238 | 238 | return; |
239 | 239 | } |
240 | 240 | |
241 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
241 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html(print_r($_POST, true))); |
|
242 | 242 | |
243 | - $this->process_save_process_files( $this->form_id ); |
|
243 | + $this->process_save_process_files($this->form_id); |
|
244 | 244 | |
245 | 245 | $this->validate(); |
246 | 246 | |
247 | - if( $this->is_valid ) { |
|
247 | + if ($this->is_valid) { |
|
248 | 248 | |
249 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' ); |
|
249 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.'); |
|
250 | 250 | |
251 | 251 | /** |
252 | 252 | * @hack This step is needed to unset the adminOnly from form fields |
@@ -256,13 +256,13 @@ discard block |
||
256 | 256 | /** |
257 | 257 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
258 | 258 | */ |
259 | - unset( $_GET['page'] ); |
|
259 | + unset($_GET['page']); |
|
260 | 260 | |
261 | - GFFormsModel::save_lead( $form, $this->entry ); |
|
261 | + GFFormsModel::save_lead($form, $this->entry); |
|
262 | 262 | |
263 | 263 | // If there's a post associated with the entry, process post fields |
264 | - if( !empty( $this->entry['post_id'] ) ) { |
|
265 | - $this->maybe_update_post_fields( $form ); |
|
264 | + if (!empty($this->entry['post_id'])) { |
|
265 | + $this->maybe_update_post_fields($form); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | // Perform actions normally performed after updating a lead |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @param array $form Gravity Forms form array |
274 | 274 | * @param string $entry_id Numeric ID of the entry that was updated |
275 | 275 | */ |
276 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] ); |
|
276 | + do_action('gravityview/edit_entry/after_update', $this->form, $this->entry['id']); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | } // process_save |
@@ -286,15 +286,15 @@ discard block |
||
286 | 286 | * |
287 | 287 | * @param int $form_id |
288 | 288 | */ |
289 | - function process_save_process_files( $form_id ) { |
|
289 | + function process_save_process_files($form_id) { |
|
290 | 290 | |
291 | 291 | //Loading files that have been uploaded to temp folder |
292 | - $files = GFCommon::json_decode( stripslashes( RGForms::post( 'gform_uploaded_files' ) ) ); |
|
293 | - if ( ! is_array( $files ) ) { |
|
292 | + $files = GFCommon::json_decode(stripslashes(RGForms::post('gform_uploaded_files'))); |
|
293 | + if (!is_array($files)) { |
|
294 | 294 | $files = array(); |
295 | 295 | } |
296 | 296 | |
297 | - RGFormsModel::$uploaded_files[ $form_id ] = $files; |
|
297 | + RGFormsModel::$uploaded_files[$form_id] = $files; |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | * @param $instance |
307 | 307 | * @return mixed |
308 | 308 | */ |
309 | - public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
|
310 | - if( ! $this->is_edit_entry() ) { |
|
309 | + public function modify_fileupload_settings($plupload_init, $form_id, $instance) { |
|
310 | + if (!$this->is_edit_entry()) { |
|
311 | 311 | return $plupload_init; |
312 | 312 | } |
313 | 313 | |
@@ -324,13 +324,13 @@ discard block |
||
324 | 324 | private function form_prepare_for_save() { |
325 | 325 | $form = $this->form; |
326 | 326 | |
327 | - foreach( $form['fields'] as &$field ) { |
|
327 | + foreach ($form['fields'] as &$field) { |
|
328 | 328 | |
329 | 329 | $field->adminOnly = false; |
330 | 330 | |
331 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
332 | - foreach( $field->inputs as $key => $input ) { |
|
333 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
331 | + if (isset($field->inputs) && is_array($field->inputs)) { |
|
332 | + foreach ($field->inputs as $key => $input) { |
|
333 | + $field->inputs[$key]['id'] = (string)$input['id']; |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | } |
@@ -346,39 +346,39 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @return void |
348 | 348 | */ |
349 | - function maybe_update_post_fields( $form ) { |
|
349 | + function maybe_update_post_fields($form) { |
|
350 | 350 | |
351 | 351 | $post_id = $this->entry['post_id']; |
352 | 352 | |
353 | 353 | // Security check |
354 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
355 | - do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id ); |
|
354 | + if (false === GVCommon::has_cap('edit_post', $post_id)) { |
|
355 | + do_action('gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id); |
|
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | 359 | $update_entry = false; |
360 | 360 | |
361 | - $updated_post = $original_post = get_post( $post_id ); |
|
361 | + $updated_post = $original_post = get_post($post_id); |
|
362 | 362 | |
363 | - foreach ( $this->entry as $field_id => $value ) { |
|
363 | + foreach ($this->entry as $field_id => $value) { |
|
364 | 364 | |
365 | 365 | //todo: only run through the edit entry configured fields |
366 | 366 | |
367 | - $field = RGFormsModel::get_field( $form, $field_id ); |
|
367 | + $field = RGFormsModel::get_field($form, $field_id); |
|
368 | 368 | |
369 | - if( class_exists('GF_Fields') ) { |
|
370 | - $field = GF_Fields::create( $field ); |
|
369 | + if (class_exists('GF_Fields')) { |
|
370 | + $field = GF_Fields::create($field); |
|
371 | 371 | } |
372 | 372 | |
373 | - if( GFCommon::is_post_field( $field ) ) { |
|
373 | + if (GFCommon::is_post_field($field)) { |
|
374 | 374 | |
375 | 375 | // Get the value of the field, including $_POSTed value |
376 | - $value = RGFormsModel::get_field_value( $field ); |
|
376 | + $value = RGFormsModel::get_field_value($field); |
|
377 | 377 | |
378 | 378 | // Convert the field object in 1.9 to an array for backward compatibility |
379 | - $field_array = GVCommon::get_field_array( $field ); |
|
379 | + $field_array = GVCommon::get_field_array($field); |
|
380 | 380 | |
381 | - switch( $field_array['type'] ) { |
|
381 | + switch ($field_array['type']) { |
|
382 | 382 | |
383 | 383 | case 'post_title': |
384 | 384 | case 'post_content': |
@@ -386,38 +386,38 @@ discard block |
||
386 | 386 | $updated_post->{$field_array['type']} = $value; |
387 | 387 | break; |
388 | 388 | case 'post_tags': |
389 | - wp_set_post_tags( $post_id, $value, false ); |
|
389 | + wp_set_post_tags($post_id, $value, false); |
|
390 | 390 | break; |
391 | 391 | case 'post_category': |
392 | 392 | |
393 | - $categories = is_array( $value ) ? array_values( $value ) : (array)$value; |
|
394 | - $categories = array_filter( $categories ); |
|
393 | + $categories = is_array($value) ? array_values($value) : (array)$value; |
|
394 | + $categories = array_filter($categories); |
|
395 | 395 | |
396 | - wp_set_post_categories( $post_id, $categories, false ); |
|
396 | + wp_set_post_categories($post_id, $categories, false); |
|
397 | 397 | |
398 | 398 | // prepare value to be saved in the entry |
399 | - $field = GFCommon::add_categories_as_choices( $field, '' ); |
|
399 | + $field = GFCommon::add_categories_as_choices($field, ''); |
|
400 | 400 | |
401 | 401 | // if post_category is type checkbox, then value is an array of inputs |
402 | - if( isset( $value[ strval( $field_id ) ] ) ) { |
|
403 | - foreach( $value as $input_id => $val ) { |
|
404 | - $input_name = 'input_' . str_replace( '.', '_', $input_id ); |
|
405 | - $this->entry[ strval( $input_id ) ] = RGFormsModel::prepare_value( $form, $field, $val, $input_name, $this->entry['id'] ); |
|
402 | + if (isset($value[strval($field_id)])) { |
|
403 | + foreach ($value as $input_id => $val) { |
|
404 | + $input_name = 'input_'.str_replace('.', '_', $input_id); |
|
405 | + $this->entry[strval($input_id)] = RGFormsModel::prepare_value($form, $field, $val, $input_name, $this->entry['id']); |
|
406 | 406 | } |
407 | 407 | } else { |
408 | - $input_name = 'input_' . str_replace( '.', '_', $field_id ); |
|
409 | - $this->entry[ strval( $field_id ) ] = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $this->entry['id'] ); |
|
408 | + $input_name = 'input_'.str_replace('.', '_', $field_id); |
|
409 | + $this->entry[strval($field_id)] = RGFormsModel::prepare_value($form, $field, $value, $input_name, $this->entry['id']); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | break; |
413 | 413 | case 'post_custom_field': |
414 | 414 | |
415 | - $input_type = RGFormsModel::get_input_type( $field ); |
|
415 | + $input_type = RGFormsModel::get_input_type($field); |
|
416 | 416 | $custom_field_name = $field_array['postCustomFieldName']; |
417 | 417 | |
418 | 418 | // Only certain custom field types are supported |
419 | - if( !in_array( $input_type, array( 'list', 'fileupload' ) ) ) { |
|
420 | - update_post_meta( $post_id, $custom_field_name, $value ); |
|
419 | + if (!in_array($input_type, array('list', 'fileupload'))) { |
|
420 | + update_post_meta($post_id, $custom_field_name, $value); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | break; |
@@ -430,13 +430,13 @@ discard block |
||
430 | 430 | } |
431 | 431 | |
432 | 432 | //ignore fields that have not changed |
433 | - if ( $value === rgget( (string) $field_id, $this->entry ) ) { |
|
433 | + if ($value === rgget((string)$field_id, $this->entry)) { |
|
434 | 434 | continue; |
435 | 435 | } |
436 | 436 | |
437 | 437 | // update entry |
438 | - if( 'post_category' !== $field->type ) { |
|
439 | - $this->entry[ strval( $field_id ) ] = $value; |
|
438 | + if ('post_category' !== $field->type) { |
|
439 | + $this->entry[strval($field_id)] = $value; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | $update_entry = true; |
@@ -445,24 +445,24 @@ discard block |
||
445 | 445 | |
446 | 446 | } |
447 | 447 | |
448 | - if( $update_entry ) { |
|
448 | + if ($update_entry) { |
|
449 | 449 | |
450 | - $return_entry = GFAPI::update_entry( $this->entry ); |
|
450 | + $return_entry = GFAPI::update_entry($this->entry); |
|
451 | 451 | |
452 | - if( is_wp_error( $return_entry ) ) { |
|
453 | - do_action( 'gravityview_log_error', 'Updating the entry post fields failed', $return_entry ); |
|
452 | + if (is_wp_error($return_entry)) { |
|
453 | + do_action('gravityview_log_error', 'Updating the entry post fields failed', $return_entry); |
|
454 | 454 | } else { |
455 | - do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' ); |
|
455 | + do_action('gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded'); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | } |
459 | 459 | |
460 | - $return_post = wp_update_post( $updated_post, true ); |
|
460 | + $return_post = wp_update_post($updated_post, true); |
|
461 | 461 | |
462 | - if( is_wp_error( $return_post ) ) { |
|
463 | - do_action( 'gravityview_log_error', 'Updating the post content failed', $return_post ); |
|
462 | + if (is_wp_error($return_post)) { |
|
463 | + do_action('gravityview_log_error', 'Updating the post content failed', $return_post); |
|
464 | 464 | } else { |
465 | - do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded' ); |
|
465 | + do_action('gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded'); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | } |
@@ -478,18 +478,18 @@ discard block |
||
478 | 478 | */ |
479 | 479 | function after_update() { |
480 | 480 | |
481 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'] ); |
|
482 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] ); |
|
481 | + do_action('gform_after_update_entry', $this->form, $this->entry['id']); |
|
482 | + do_action("gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id']); |
|
483 | 483 | |
484 | 484 | // Re-define the entry now that we've updated it. |
485 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
485 | + $entry = RGFormsModel::get_lead($this->entry['id']); |
|
486 | 486 | |
487 | - $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
|
487 | + $entry = GFFormsModel::set_entry_meta($entry, $this->form); |
|
488 | 488 | |
489 | 489 | // We need to clear the cache because Gravity Forms caches the field values, which |
490 | 490 | // we have just updated. |
491 | 491 | foreach ($this->form['fields'] as $key => $field) { |
492 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
492 | + GFFormsModel::refresh_lead_field_value($entry['id'], $field->id); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | $this->entry = $entry; |
@@ -503,19 +503,19 @@ discard block |
||
503 | 503 | */ |
504 | 504 | public function edit_entry_form() { |
505 | 505 | |
506 | - $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
|
506 | + $back_link = esc_url(remove_query_arg(array('page', 'view', 'edit'))); |
|
507 | 507 | |
508 | 508 | ?> |
509 | 509 | |
510 | 510 | <div class="gv-edit-entry-wrapper"><?php |
511 | 511 | |
512 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
512 | + $javascript = gravityview_ob_include(GravityView_Edit_Entry::$file.'/partials/inline-javascript.php', $this); |
|
513 | 513 | |
514 | 514 | /** |
515 | 515 | * Fixes weird wpautop() issue |
516 | 516 | * @see https://github.com/katzwebservices/GravityView/issues/451 |
517 | 517 | */ |
518 | - echo gravityview_strip_whitespace( $javascript ); |
|
518 | + echo gravityview_strip_whitespace($javascript); |
|
519 | 519 | |
520 | 520 | ?><h2 class="gv-edit-entry-title"> |
521 | 521 | <span><?php |
@@ -525,27 +525,27 @@ discard block |
||
525 | 525 | * @param string $edit_entry_title Modify the "Edit Entry" title |
526 | 526 | * @param GravityView_Edit_Entry_Render $this This object |
527 | 527 | */ |
528 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
528 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this); |
|
529 | 529 | |
530 | - echo esc_attr( $edit_entry_title ); |
|
530 | + echo esc_attr($edit_entry_title); |
|
531 | 531 | ?></span> |
532 | 532 | </h2> |
533 | 533 | |
534 | 534 | <?php |
535 | 535 | |
536 | 536 | // Display the success message |
537 | - if( rgpost('action') === 'update' ) { |
|
537 | + if (rgpost('action') === 'update') { |
|
538 | 538 | |
539 | - if( ! $this->is_valid ){ |
|
539 | + if (!$this->is_valid) { |
|
540 | 540 | |
541 | 541 | // Keeping this compatible with Gravity Forms. |
542 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
542 | + $validation_message = "<div class='validation_error'>".__('There was a problem with your submission.', 'gravityview')." ".__('Errors have been highlighted below.', 'gravityview')."</div>"; |
|
543 | 543 | $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
544 | 544 | |
545 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
545 | + echo GVCommon::generate_notice($message, 'gv-error'); |
|
546 | 546 | |
547 | 547 | } else { |
548 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
548 | + $entry_updated_message = sprintf(esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'.$back_link.'">', '</a>'); |
|
549 | 549 | |
550 | 550 | /** |
551 | 551 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -555,9 +555,9 @@ discard block |
||
555 | 555 | * @param array $entry Gravity Forms entry array |
556 | 556 | * @param string $back_link URL to return to the original entry. @since 1.6 |
557 | 557 | */ |
558 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
558 | + $message = apply_filters('gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link); |
|
559 | 559 | |
560 | - echo GVCommon::generate_notice( $message ); |
|
560 | + echo GVCommon::generate_notice($message); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | } |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | |
571 | 571 | <?php |
572 | 572 | |
573 | - wp_nonce_field( self::$nonce_key, self::$nonce_key ); |
|
573 | + wp_nonce_field(self::$nonce_key, self::$nonce_key); |
|
574 | 574 | |
575 | - wp_nonce_field( self::$nonce_field, self::$nonce_field, false ); |
|
575 | + wp_nonce_field(self::$nonce_field, self::$nonce_field, false); |
|
576 | 576 | |
577 | 577 | // Most of this is needed for GFFormDisplay::validate(), but `gform_unique_id` is needed for file cleanup. |
578 | 578 | |
@@ -612,13 +612,13 @@ discard block |
||
612 | 612 | */ |
613 | 613 | private function render_edit_form() { |
614 | 614 | |
615 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
616 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
617 | - add_filter( 'gform_disable_view_counter', '__return_true' ); |
|
618 | - add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
|
615 | + add_filter('gform_pre_render', array($this, 'filter_modify_form_fields'), 5000, 3); |
|
616 | + add_filter('gform_submit_button', array($this, 'render_form_buttons')); |
|
617 | + add_filter('gform_disable_view_counter', '__return_true'); |
|
618 | + add_filter('gform_field_input', array($this, 'modify_edit_field_input'), 10, 5); |
|
619 | 619 | |
620 | 620 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
621 | - unset( $_GET['page'] ); |
|
621 | + unset($_GET['page']); |
|
622 | 622 | |
623 | 623 | // TODO: Make sure validation isn't handled by GF |
624 | 624 | // TODO: Include CSS for file upload fields |
@@ -626,12 +626,12 @@ discard block |
||
626 | 626 | // TODO: Product fields are not editable |
627 | 627 | // TODO: Check Updated and Error messages |
628 | 628 | |
629 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
629 | + $html = GFFormDisplay::get_form($this->form['id'], false, false, true, $this->entry); |
|
630 | 630 | |
631 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
632 | - remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
633 | - remove_filter( 'gform_disable_view_counter', '__return_true' ); |
|
634 | - remove_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10 ); |
|
631 | + remove_filter('gform_pre_render', array($this, 'filter_modify_form_fields'), 5000); |
|
632 | + remove_filter('gform_submit_button', array($this, 'render_form_buttons')); |
|
633 | + remove_filter('gform_disable_view_counter', '__return_true'); |
|
634 | + remove_filter('gform_field_input', array($this, 'modify_edit_field_input'), 10); |
|
635 | 635 | |
636 | 636 | echo $html; |
637 | 637 | } |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * @return string |
643 | 643 | */ |
644 | 644 | public function render_form_buttons() { |
645 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
645 | + return gravityview_ob_include(GravityView_Edit_Entry::$file.'/partials/form-buttons.php', $this); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | |
@@ -659,20 +659,20 @@ discard block |
||
659 | 659 | * |
660 | 660 | * @return array Modified form array |
661 | 661 | */ |
662 | - public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
|
662 | + public function filter_modify_form_fields($form, $ajax = false, $field_values = '') { |
|
663 | 663 | |
664 | 664 | // In case we have validated the form, use it to inject the validation results into the form render |
665 | - if( isset( $this->form_after_validation ) ) { |
|
665 | + if (isset($this->form_after_validation)) { |
|
666 | 666 | $form = $this->form_after_validation; |
667 | 667 | } else { |
668 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
668 | + $form['fields'] = $this->get_configured_edit_fields($form, $this->view_id); |
|
669 | 669 | } |
670 | 670 | |
671 | - $form = $this->filter_conditional_logic( $form ); |
|
671 | + $form = $this->filter_conditional_logic($form); |
|
672 | 672 | |
673 | 673 | // for now we don't support Save and Continue feature. |
674 | - if( ! self::$supports_save_and_continue ) { |
|
675 | - unset( $form['save'] ); |
|
674 | + if (!self::$supports_save_and_continue) { |
|
675 | + unset($form['save']); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | return $form; |
@@ -691,19 +691,19 @@ discard block |
||
691 | 691 | * |
692 | 692 | * @return mixed |
693 | 693 | */ |
694 | - function modify_edit_field_input( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
|
694 | + function modify_edit_field_input($field_content = '', $field, $value, $lead_id = 0, $form_id) { |
|
695 | 695 | |
696 | 696 | // If the form has been submitted, then we don't need to pre-fill the values, |
697 | 697 | // Except for fileupload type - run always!! |
698 | - if( |
|
698 | + if ( |
|
699 | 699 | $this->is_edit_entry_submission() && 'fileupload' !== $field->type |
700 | - || GFCommon::is_product_field( $field->type ) // Prevent product fields from appearing editable |
|
700 | + || GFCommon::is_product_field($field->type) // Prevent product fields from appearing editable |
|
701 | 701 | ) { |
702 | 702 | return $field_content; |
703 | 703 | } |
704 | 704 | |
705 | 705 | // Turn on Admin-style display for file upload fields only |
706 | - if( 'fileupload' === $field->type ) { |
|
706 | + if ('fileupload' === $field->type) { |
|
707 | 707 | $_GET['page'] = 'gf_entries'; |
708 | 708 | } |
709 | 709 | |
@@ -711,8 +711,8 @@ discard block |
||
711 | 711 | $field->adminOnly = false; /** @see GFFormDisplay::get_counter_init_script() need to prevent adminOnly */ |
712 | 712 | |
713 | 713 | // add categories as choices for Post Category field |
714 | - if ( 'post_category' === $field->type ) { |
|
715 | - $field = GFCommon::add_categories_as_choices( $field, $value ); |
|
714 | + if ('post_category' === $field->type) { |
|
715 | + $field = GFCommon::add_categories_as_choices($field, $value); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | /** |
@@ -721,55 +721,55 @@ discard block |
||
721 | 721 | * @param $field GF_Field object Gravity Forms field object |
722 | 722 | * @since 1.13 |
723 | 723 | */ |
724 | - $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
|
724 | + $override_saved_value = apply_filters('gravityview/edit_entry/pre_populate/override', false, $field); |
|
725 | 725 | |
726 | 726 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
727 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
727 | + if (isset($field->inputs) && is_array($field->inputs) && !in_array($field->type, array('time', 'date'))) { |
|
728 | 728 | |
729 | 729 | $field_value = array(); |
730 | 730 | |
731 | 731 | // only accept pre-populated values if the field doesn't have any choice selected. |
732 | 732 | $allow_pre_populated = $field->allowsPrepopulate; |
733 | 733 | |
734 | - foreach ( (array)$field->inputs as $input ) { |
|
734 | + foreach ((array)$field->inputs as $input) { |
|
735 | 735 | |
736 | - $input_id = strval( $input['id'] ); |
|
736 | + $input_id = strval($input['id']); |
|
737 | 737 | |
738 | - if ( ! empty( $this->entry[ $input_id ] ) ) { |
|
739 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
738 | + if (!empty($this->entry[$input_id])) { |
|
739 | + $field_value[$input_id] = 'post_category' === $field->type ? GFCommon::format_post_category($this->entry[$input_id], true) : $this->entry[$input_id]; |
|
740 | 740 | $allow_pre_populated = false; |
741 | 741 | } |
742 | 742 | |
743 | 743 | } |
744 | 744 | |
745 | - $pre_value = $field->get_value_submission( array(), false ); |
|
745 | + $pre_value = $field->get_value_submission(array(), false); |
|
746 | 746 | |
747 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !empty( $pre_value ) ) ? $field_value : $pre_value; |
|
747 | + $field_value = !$allow_pre_populated && !($override_saved_value && !empty($pre_value)) ? $field_value : $pre_value; |
|
748 | 748 | |
749 | 749 | } else { |
750 | 750 | |
751 | - $id = intval( $field->id ); |
|
751 | + $id = intval($field->id); |
|
752 | 752 | |
753 | 753 | // get pre-populated value if exists |
754 | - $pre_value = $field->allowsPrepopulate ? GFFormsModel::get_parameter_value( $field->inputName, array(), $field ) : ''; |
|
754 | + $pre_value = $field->allowsPrepopulate ? GFFormsModel::get_parameter_value($field->inputName, array(), $field) : ''; |
|
755 | 755 | |
756 | 756 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
757 | 757 | // or pre-populated value if not empty and set to override saved value |
758 | - $field_value = !empty( $this->entry[ $id ] ) && ! ( $override_saved_value && !empty( $pre_value ) ) ? $this->entry[ $id ] : $pre_value; |
|
758 | + $field_value = !empty($this->entry[$id]) && !($override_saved_value && !empty($pre_value)) ? $this->entry[$id] : $pre_value; |
|
759 | 759 | |
760 | 760 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
761 | - if ( 'post_category' === $field->type && !empty( $field_value ) ) { |
|
761 | + if ('post_category' === $field->type && !empty($field_value)) { |
|
762 | 762 | $categories = array(); |
763 | - foreach ( explode( ',', $field_value ) as $cat_string ) { |
|
764 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
763 | + foreach (explode(',', $field_value) as $cat_string) { |
|
764 | + $categories[] = GFCommon::format_post_category($cat_string, true); |
|
765 | 765 | } |
766 | - $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
|
766 | + $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode('', $categories); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | } |
770 | 770 | |
771 | 771 | // if value is empty get the default value if defined |
772 | - $field_value = $field->get_value_default_if_empty( $field_value ); |
|
772 | + $field_value = $field->get_value_default_if_empty($field_value); |
|
773 | 773 | |
774 | 774 | /** |
775 | 775 | * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
@@ -777,18 +777,18 @@ discard block |
||
777 | 777 | * @param mixed $field_value field value used to populate the input |
778 | 778 | * @param object $field Gravity Forms field object ( Class GF_Field ) |
779 | 779 | */ |
780 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field ); |
|
780 | + $field_value = apply_filters('gravityview/edit_entry/field_value', $field_value, $field); |
|
781 | 781 | |
782 | 782 | // Prevent any PHP warnings, like undefined index |
783 | 783 | ob_start(); |
784 | 784 | |
785 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
785 | + $return = $field->get_field_input($this->form, $field_value, $this->entry); |
|
786 | 786 | |
787 | 787 | // If there was output, it's an error |
788 | 788 | $warnings = ob_get_clean(); |
789 | 789 | |
790 | - if( !empty( $warnings ) ) { |
|
791 | - do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value ); |
|
790 | + if (!empty($warnings)) { |
|
791 | + do_action('gravityview_log_error', __METHOD__.$warnings, $field_value); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | /** |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | * We need the fileupload html field to render with the proper id |
797 | 797 | * ( <li id="field_80_16" ... > ) |
798 | 798 | */ |
799 | - unset( $_GET['page'] ); |
|
799 | + unset($_GET['page']); |
|
800 | 800 | |
801 | 801 | return $return; |
802 | 802 | } |
@@ -812,14 +812,14 @@ discard block |
||
812 | 812 | * @param array $field Gravity Forms field array |
813 | 813 | * @return string [description] |
814 | 814 | */ |
815 | - public function get_field_value( $value, $lead, $field ) { |
|
815 | + public function get_field_value($value, $lead, $field) { |
|
816 | 816 | |
817 | 817 | // The form's not being edited; use the original value |
818 | - if( ! $this->is_edit_entry_submission() ) { |
|
818 | + if (!$this->is_edit_entry_submission()) { |
|
819 | 819 | return $value; |
820 | 820 | } |
821 | 821 | |
822 | - return GFFormsModel::get_field_value( $field, $lead, true ); |
|
822 | + return GFFormsModel::get_field_value($field, $lead, true); |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | |
@@ -834,19 +834,19 @@ discard block |
||
834 | 834 | * @param array $form GF Form |
835 | 835 | * @return array Modified GF Form |
836 | 836 | */ |
837 | - function gform_pre_validation( $form ) { |
|
837 | + function gform_pre_validation($form) { |
|
838 | 838 | |
839 | - if( ! $this->verify_nonce() ) { |
|
839 | + if (!$this->verify_nonce()) { |
|
840 | 840 | return $form; |
841 | 841 | } |
842 | 842 | |
843 | 843 | // Fix PHP warning regarding undefined index. |
844 | - foreach ( $form['fields'] as &$field) { |
|
844 | + foreach ($form['fields'] as &$field) { |
|
845 | 845 | |
846 | 846 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
847 | 847 | // expects certain field array items to be set. |
848 | - foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
|
849 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
848 | + foreach (array('noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions') as $key) { |
|
849 | + $field->{$key} = isset($field->{$key} ) ? $field->{$key} : NULL; |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | // unset emailConfirmEnabled for email type fields |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | $field['emailConfirmEnabled'] = ''; |
855 | 855 | }*/ |
856 | 856 | |
857 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
857 | + switch (RGFormsModel::get_input_type($field)) { |
|
858 | 858 | |
859 | 859 | /** |
860 | 860 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -875,49 +875,49 @@ discard block |
||
875 | 875 | $value = NULL; |
876 | 876 | |
877 | 877 | // Use the previous entry value as the default. |
878 | - if( isset( $entry[ $field->id ] ) ) { |
|
879 | - $value = $entry[ $field->id ]; |
|
878 | + if (isset($entry[$field->id])) { |
|
879 | + $value = $entry[$field->id]; |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | // If this is a single upload file |
883 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
884 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
883 | + if (!empty($_FILES[$input_name]) && !empty($_FILES[$input_name]['name'])) { |
|
884 | + $file_path = GFFormsModel::get_file_upload_path($form['id'], $_FILES[$input_name]['name']); |
|
885 | 885 | $value = $file_path['url']; |
886 | 886 | |
887 | 887 | } else { |
888 | 888 | |
889 | 889 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
890 | 890 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
891 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
891 | + $_FILES[$input_name] = array('name' => '', 'size' => ''); |
|
892 | 892 | |
893 | 893 | } |
894 | 894 | |
895 | - if( rgar($field, "multipleFiles") ) { |
|
895 | + if (rgar($field, "multipleFiles")) { |
|
896 | 896 | |
897 | 897 | // If there are fresh uploads, process and merge them. |
898 | 898 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
899 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
899 | + if (isset(GFFormsModel::$uploaded_files[$form_id][$input_name])) { |
|
900 | 900 | |
901 | - $value = empty( $value ) ? '[]' : $value; |
|
902 | - $value = stripslashes_deep( $value ); |
|
903 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
901 | + $value = empty($value) ? '[]' : $value; |
|
902 | + $value = stripslashes_deep($value); |
|
903 | + $value = GFFormsModel::prepare_value($form, $field, $value, $input_name, $entry['id'], array()); |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | } else { |
907 | 907 | |
908 | 908 | // A file already exists when editing an entry |
909 | 909 | // We set this to solve issue when file upload fields are required. |
910 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
910 | + GFFormsModel::$uploaded_files[$form_id][$input_name] = $value; |
|
911 | 911 | |
912 | 912 | } |
913 | 913 | |
914 | - $_POST[ $input_name ] = $value; |
|
914 | + $_POST[$input_name] = $value; |
|
915 | 915 | |
916 | 916 | break; |
917 | 917 | case 'number': |
918 | 918 | // Fix "undefined index" issue at line 1286 in form_display.php |
919 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
920 | - $_POST['input_'.$field->id ] = NULL; |
|
919 | + if (!isset($_POST['input_'.$field->id])) { |
|
920 | + $_POST['input_'.$field->id] = NULL; |
|
921 | 921 | } |
922 | 922 | break; |
923 | 923 | case 'captcha': |
@@ -943,8 +943,8 @@ discard block |
||
943 | 943 | function validate() { |
944 | 944 | |
945 | 945 | // If using GF User Registration Add-on, remove the validation step, otherwise generates error when updating the entry |
946 | - if ( class_exists( 'GFUser' ) ) { |
|
947 | - remove_filter( 'gform_validation', array( 'GFUser', 'user_registration_validation' ) ); |
|
946 | + if (class_exists('GFUser')) { |
|
947 | + remove_filter('gform_validation', array('GFUser', 'user_registration_validation')); |
|
948 | 948 | } |
949 | 949 | |
950 | 950 | /** |
@@ -952,22 +952,22 @@ discard block |
||
952 | 952 | * You can enter whatever you want! |
953 | 953 | * We try validating, and customize the results using `self::custom_validation()` |
954 | 954 | */ |
955 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
955 | + add_filter('gform_validation_'.$this->form_id, array($this, 'custom_validation'), 10, 4); |
|
956 | 956 | |
957 | 957 | // Needed by the validate funtion |
958 | 958 | $failed_validation_page = NULL; |
959 | - $field_values = RGForms::post( 'gform_field_values' ); |
|
959 | + $field_values = RGForms::post('gform_field_values'); |
|
960 | 960 | |
961 | 961 | // Prevent entry limit from running when editing an entry, also |
962 | 962 | // prevent form scheduling from preventing editing |
963 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
963 | + unset($this->form['limitEntries'], $this->form['scheduleForm']); |
|
964 | 964 | |
965 | 965 | // Hide fields depending on Edit Entry settings |
966 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
966 | + $this->form['fields'] = $this->get_configured_edit_fields($this->form, $this->view_id); |
|
967 | 967 | |
968 | - $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
|
968 | + $this->is_valid = GFFormDisplay::validate($this->form, $field_values, 1, $failed_validation_page); |
|
969 | 969 | |
970 | - remove_filter( 'gform_validation_'.$this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
970 | + remove_filter('gform_validation_'.$this->form_id, array($this, 'custom_validation'), 10); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | |
@@ -982,55 +982,55 @@ discard block |
||
982 | 982 | * @param [type] $validation_results [description] |
983 | 983 | * @return [type] [description] |
984 | 984 | */ |
985 | - function custom_validation( $validation_results ) { |
|
985 | + function custom_validation($validation_results) { |
|
986 | 986 | |
987 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); |
|
987 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results); |
|
988 | 988 | |
989 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
989 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html(print_r($_POST, true))); |
|
990 | 990 | |
991 | 991 | $gv_valid = true; |
992 | 992 | |
993 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
993 | + foreach ($validation_results['form']['fields'] as $key => &$field) { |
|
994 | 994 | |
995 | - $value = RGFormsModel::get_field_value( $field ); |
|
996 | - $field_type = RGFormsModel::get_input_type( $field ); |
|
995 | + $value = RGFormsModel::get_field_value($field); |
|
996 | + $field_type = RGFormsModel::get_input_type($field); |
|
997 | 997 | |
998 | 998 | // Validate always |
999 | - switch ( $field_type ) { |
|
999 | + switch ($field_type) { |
|
1000 | 1000 | |
1001 | 1001 | |
1002 | 1002 | case 'fileupload' : |
1003 | 1003 | |
1004 | 1004 | // in case nothing is uploaded but there are already files saved |
1005 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1005 | + if (!empty($field->failed_validation) && !empty($field->isRequired) && !empty($value)) { |
|
1006 | 1006 | $field->failed_validation = false; |
1007 | - unset( $field->validation_message ); |
|
1007 | + unset($field->validation_message); |
|
1008 | 1008 | } |
1009 | 1009 | |
1010 | 1010 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1011 | - if( rgar( $field, 'maxFiles') && rgar( $field, 'multipleFiles') ) { |
|
1011 | + if (rgar($field, 'maxFiles') && rgar($field, 'multipleFiles')) { |
|
1012 | 1012 | |
1013 | - $input_name = 'input_' . $field->id; |
|
1013 | + $input_name = 'input_'.$field->id; |
|
1014 | 1014 | //uploaded |
1015 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1015 | + $file_names = isset(GFFormsModel::$uploaded_files[$validation_results['form']['id']][$input_name]) ? GFFormsModel::$uploaded_files[$validation_results['form']['id']][$input_name] : array(); |
|
1016 | 1016 | |
1017 | 1017 | //existent |
1018 | 1018 | $entry = $this->get_entry(); |
1019 | 1019 | $value = NULL; |
1020 | - if( isset( $entry[ $field->id ] ) ) { |
|
1021 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1020 | + if (isset($entry[$field->id])) { |
|
1021 | + $value = json_decode($entry[$field->id], true); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | // count uploaded files and existent entry files |
1025 | - $count_files = count( $file_names ) + count( $value ); |
|
1025 | + $count_files = count($file_names) + count($value); |
|
1026 | 1026 | |
1027 | - if( $count_files > $field->maxFiles ) { |
|
1028 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1027 | + if ($count_files > $field->maxFiles) { |
|
1028 | + $field->validation_message = __('Maximum number of files reached', 'gravityview'); |
|
1029 | 1029 | $field->failed_validation = 1; |
1030 | 1030 | $gv_valid = false; |
1031 | 1031 | |
1032 | 1032 | // in case of error make sure the newest upload files are removed from the upload input |
1033 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1033 | + GFFormsModel::$uploaded_files[$validation_results['form']['id']] = null; |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | } |
@@ -1041,11 +1041,11 @@ discard block |
||
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | // This field has failed validation. |
1044 | - if( !empty( $field->failed_validation ) ) { |
|
1044 | + if (!empty($field->failed_validation)) { |
|
1045 | 1045 | |
1046 | - do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) ); |
|
1046 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array('field' => $field, 'value' => $value)); |
|
1047 | 1047 | |
1048 | - switch ( $field_type ) { |
|
1048 | + switch ($field_type) { |
|
1049 | 1049 | |
1050 | 1050 | // Captchas don't need to be re-entered. |
1051 | 1051 | case 'captcha': |
@@ -1053,39 +1053,39 @@ discard block |
||
1053 | 1053 | // Post Image fields aren't editable, so we un-fail them. |
1054 | 1054 | case 'post_image': |
1055 | 1055 | $field->failed_validation = false; |
1056 | - unset( $field->validation_message ); |
|
1056 | + unset($field->validation_message); |
|
1057 | 1057 | break; |
1058 | 1058 | |
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | // You can't continue inside a switch, so we do it after. |
1062 | - if( empty( $field->failed_validation ) ) { |
|
1062 | + if (empty($field->failed_validation)) { |
|
1063 | 1063 | continue; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | // checks if the No Duplicates option is not validating entry against itself, since |
1067 | 1067 | // we're editing a stored entry, it would also assume it's a duplicate. |
1068 | - if( !empty( $field->noDuplicates ) ) { |
|
1068 | + if (!empty($field->noDuplicates)) { |
|
1069 | 1069 | |
1070 | 1070 | $entry = $this->get_entry(); |
1071 | 1071 | |
1072 | 1072 | // If the value of the entry is the same as the stored value |
1073 | 1073 | // Then we can assume it's not a duplicate, it's the same. |
1074 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1074 | + if (!empty($entry) && $value == $entry[$field->id]) { |
|
1075 | 1075 | //if value submitted was not changed, then don't validate |
1076 | 1076 | $field->failed_validation = false; |
1077 | 1077 | |
1078 | - unset( $field->validation_message ); |
|
1078 | + unset($field->validation_message); |
|
1079 | 1079 | |
1080 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); |
|
1080 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry); |
|
1081 | 1081 | |
1082 | 1082 | continue; |
1083 | 1083 | } |
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1087 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1088 | - unset( $field->validation_message ); |
|
1087 | + if (GFFormDisplay::is_empty($field, $this->form_id) && empty($field->isRequired)) { |
|
1088 | + unset($field->validation_message); |
|
1089 | 1089 | $field->validation_message = false; |
1090 | 1090 | continue; |
1091 | 1091 | } |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | |
1099 | 1099 | $validation_results['is_valid'] = $gv_valid; |
1100 | 1100 | |
1101 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); |
|
1101 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results); |
|
1102 | 1102 | |
1103 | 1103 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1104 | 1104 | $this->form_after_validation = $validation_results['form']; |
@@ -1114,9 +1114,9 @@ discard block |
||
1114 | 1114 | */ |
1115 | 1115 | private function get_entry() { |
1116 | 1116 | |
1117 | - if( empty( $this->entry ) ) { |
|
1117 | + if (empty($this->entry)) { |
|
1118 | 1118 | // Get the database value of the entry that's being edited |
1119 | - $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
|
1119 | + $this->entry = gravityview_get_entry(GravityView_frontend::is_single_entry()); |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | return $this->entry; |
@@ -1135,22 +1135,22 @@ discard block |
||
1135 | 1135 | * |
1136 | 1136 | * @return array Array of fields that are configured in the Edit tab in the Admin |
1137 | 1137 | */ |
1138 | - private function get_configured_edit_fields( $form, $view_id ) { |
|
1138 | + private function get_configured_edit_fields($form, $view_id) { |
|
1139 | 1139 | |
1140 | 1140 | // Get all fields for form |
1141 | - $properties = GravityView_View_Data::getInstance()->get_fields( $view_id ); |
|
1141 | + $properties = GravityView_View_Data::getInstance()->get_fields($view_id); |
|
1142 | 1142 | |
1143 | 1143 | // If edit tab not yet configured, show all fields |
1144 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1144 | + $edit_fields = !empty($properties['edit_edit-fields']) ? $properties['edit_edit-fields'] : NULL; |
|
1145 | 1145 | |
1146 | 1146 | // Show hidden fields as text fields |
1147 | - $form = $this->fix_hidden_fields( $form ); |
|
1147 | + $form = $this->fix_hidden_fields($form); |
|
1148 | 1148 | |
1149 | 1149 | // Hide fields depending on admin settings |
1150 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1150 | + $fields = $this->filter_fields($form['fields'], $edit_fields); |
|
1151 | 1151 | |
1152 | 1152 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1153 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1153 | + $fields = $this->filter_admin_only_fields($fields, $edit_fields, $form, $view_id); |
|
1154 | 1154 | |
1155 | 1155 | return $fields; |
1156 | 1156 | } |
@@ -1162,14 +1162,14 @@ discard block |
||
1162 | 1162 | * |
1163 | 1163 | * @return mixed |
1164 | 1164 | */ |
1165 | - private function fix_hidden_fields( $form ) { |
|
1165 | + private function fix_hidden_fields($form) { |
|
1166 | 1166 | |
1167 | 1167 | /** @var GF_Field $field */ |
1168 | - foreach( $form['fields'] as $key => $field ) { |
|
1169 | - if( 'hidden' === $field->type ) { |
|
1170 | - $text_field = new GF_Field_Text( $field ); |
|
1168 | + foreach ($form['fields'] as $key => $field) { |
|
1169 | + if ('hidden' === $field->type) { |
|
1170 | + $text_field = new GF_Field_Text($field); |
|
1171 | 1171 | $text_field->type = 'text'; |
1172 | - $form['fields'][ $key ] = $text_field; |
|
1172 | + $form['fields'][$key] = $text_field; |
|
1173 | 1173 | } |
1174 | 1174 | } |
1175 | 1175 | |
@@ -1187,9 +1187,9 @@ discard block |
||
1187 | 1187 | * @since 1.5 |
1188 | 1188 | * @return array $fields |
1189 | 1189 | */ |
1190 | - private function filter_fields( $fields, $configured_fields ) { |
|
1190 | + private function filter_fields($fields, $configured_fields) { |
|
1191 | 1191 | |
1192 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1192 | + if (empty($fields) || !is_array($fields)) { |
|
1193 | 1193 | return $fields; |
1194 | 1194 | } |
1195 | 1195 | |
@@ -1204,9 +1204,9 @@ discard block |
||
1204 | 1204 | * @since 1.9.1 |
1205 | 1205 | * @param boolean $hide_product_fields Whether to hide product fields in the editor. Default: false |
1206 | 1206 | */ |
1207 | - $hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) ); |
|
1207 | + $hide_product_fields = apply_filters('gravityview/edit_entry/hide-product-fields', empty(self::$supports_product_fields)); |
|
1208 | 1208 | |
1209 | - if( $hide_product_fields ) { |
|
1209 | + if ($hide_product_fields) { |
|
1210 | 1210 | $field_type_blacklist[] = 'option'; |
1211 | 1211 | $field_type_blacklist[] = 'quantity'; |
1212 | 1212 | $field_type_blacklist[] = 'product'; |
@@ -1216,25 +1216,25 @@ discard block |
||
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | // First, remove blacklist |
1219 | - foreach ( $fields as $key => $field ) { |
|
1220 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1221 | - unset( $fields[ $key ] ); |
|
1219 | + foreach ($fields as $key => $field) { |
|
1220 | + if (in_array($field->type, $field_type_blacklist)) { |
|
1221 | + unset($fields[$key]); |
|
1222 | 1222 | } |
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | // The Edit tab has not been configured, so we return all fields by default. |
1226 | - if( empty( $configured_fields ) ) { |
|
1226 | + if (empty($configured_fields)) { |
|
1227 | 1227 | return $fields; |
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | // The edit tab has been configured, so we loop through to configured settings |
1231 | - foreach ( $configured_fields as $configured_field ) { |
|
1231 | + foreach ($configured_fields as $configured_field) { |
|
1232 | 1232 | |
1233 | 1233 | /** @var GF_Field $field */ |
1234 | - foreach ( $fields as $field ) { |
|
1234 | + foreach ($fields as $field) { |
|
1235 | 1235 | |
1236 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1237 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1236 | + if (intval($configured_field['id']) === intval($field->id) && $this->user_can_edit_field($configured_field, false)) { |
|
1237 | + $edit_fields[] = $this->merge_field_properties($field, $configured_field); |
|
1238 | 1238 | break; |
1239 | 1239 | } |
1240 | 1240 | |
@@ -1253,18 +1253,18 @@ discard block |
||
1253 | 1253 | * @since 1.5 |
1254 | 1254 | * @return array |
1255 | 1255 | */ |
1256 | - private function merge_field_properties( $field, $field_setting ) { |
|
1256 | + private function merge_field_properties($field, $field_setting) { |
|
1257 | 1257 | |
1258 | 1258 | $return_field = $field; |
1259 | 1259 | |
1260 | - if( empty( $field_setting['show_label'] ) ) { |
|
1260 | + if (empty($field_setting['show_label'])) { |
|
1261 | 1261 | $return_field->label = ''; |
1262 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1262 | + } elseif (!empty($field_setting['custom_label'])) { |
|
1263 | 1263 | $return_field->label = $field_setting['custom_label']; |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1267 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1266 | + if (!empty($field_setting['custom_class'])) { |
|
1267 | + $return_field->cssClass .= ' '.gravityview_sanitize_html_class($field_setting['custom_class']); |
|
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | /** |
@@ -1289,7 +1289,7 @@ discard block |
||
1289 | 1289 | * |
1290 | 1290 | * @return array Possibly modified form array |
1291 | 1291 | */ |
1292 | - function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
|
1292 | + function filter_admin_only_fields($fields = array(), $edit_fields = null, $form = array(), $view_id = 0) { |
|
1293 | 1293 | |
1294 | 1294 | /** |
1295 | 1295 | * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true |
@@ -1300,13 +1300,13 @@ discard block |
||
1300 | 1300 | * @param array $form GF Form array |
1301 | 1301 | * @param int $view_id View ID |
1302 | 1302 | */ |
1303 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1303 | + $use_gf_adminonly_setting = apply_filters('gravityview/edit_entry/use_gf_admin_only_setting', empty($edit_fields), $form, $view_id); |
|
1304 | 1304 | |
1305 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1305 | + if ($use_gf_adminonly_setting && false === GVCommon::has_cap('gravityforms_edit_entries', $this->entry['id'])) { |
|
1306 | 1306 | return $fields; |
1307 | 1307 | } |
1308 | 1308 | |
1309 | - foreach( $fields as &$field ) { |
|
1309 | + foreach ($fields as &$field) { |
|
1310 | 1310 | $field->adminOnly = false; |
1311 | 1311 | } |
1312 | 1312 | |
@@ -1323,7 +1323,7 @@ discard block |
||
1323 | 1323 | * @param array $form Gravity Forms form |
1324 | 1324 | * @return array Modified form, if not using Conditional Logic |
1325 | 1325 | */ |
1326 | - function filter_conditional_logic( $form ) { |
|
1326 | + function filter_conditional_logic($form) { |
|
1327 | 1327 | |
1328 | 1328 | /** |
1329 | 1329 | * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields? |
@@ -1331,18 +1331,18 @@ discard block |
||
1331 | 1331 | * @param bool $use_conditional_logic True: Gravity Forms will show/hide fields just like in the original form; False: conditional logic will be disabled and fields will be shown based on configuration. Default: true |
1332 | 1332 | * @param array $form Gravity Forms form |
1333 | 1333 | */ |
1334 | - $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
|
1334 | + $use_conditional_logic = apply_filters('gravityview/edit_entry/conditional_logic', true, $form); |
|
1335 | 1335 | |
1336 | - if( $use_conditional_logic ) { |
|
1336 | + if ($use_conditional_logic) { |
|
1337 | 1337 | return $form; |
1338 | 1338 | } |
1339 | 1339 | |
1340 | - foreach( $form['fields'] as &$field ) { |
|
1340 | + foreach ($form['fields'] as &$field) { |
|
1341 | 1341 | /* @var GF_Field $field */ |
1342 | 1342 | $field->conditionalLogic = null; |
1343 | 1343 | } |
1344 | 1344 | |
1345 | - unset( $form['button']['conditionalLogic'] ); |
|
1345 | + unset($form['button']['conditionalLogic']); |
|
1346 | 1346 | |
1347 | 1347 | return $form; |
1348 | 1348 | |
@@ -1357,13 +1357,13 @@ discard block |
||
1357 | 1357 | * @param $form |
1358 | 1358 | * @return mixed|void |
1359 | 1359 | */ |
1360 | - function manage_conditional_logic( $has_conditional_logic, $form ) { |
|
1360 | + function manage_conditional_logic($has_conditional_logic, $form) { |
|
1361 | 1361 | |
1362 | - if( ! $this->is_edit_entry() ) { |
|
1362 | + if (!$this->is_edit_entry()) { |
|
1363 | 1363 | return $has_conditional_logic; |
1364 | 1364 | } |
1365 | 1365 | |
1366 | - return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
|
1366 | + return apply_filters('gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form); |
|
1367 | 1367 | |
1368 | 1368 | } |
1369 | 1369 | |
@@ -1382,7 +1382,7 @@ discard block |
||
1382 | 1382 | * @param boolean $echo Show error messages in the form? |
1383 | 1383 | * @return boolean True: can edit form. False: nope. |
1384 | 1384 | */ |
1385 | - function user_can_edit_entry( $echo = false ) { |
|
1385 | + function user_can_edit_entry($echo = false) { |
|
1386 | 1386 | |
1387 | 1387 | $error = NULL; |
1388 | 1388 | |
@@ -1391,58 +1391,58 @@ discard block |
||
1391 | 1391 | * 2. There are two entries embedded using oEmbed |
1392 | 1392 | * 3. One of the entries has just been saved |
1393 | 1393 | */ |
1394 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
1394 | + if (!empty($_POST['lid']) && !empty($_GET['entry']) && ($_POST['lid'] !== $_GET['entry'])) { |
|
1395 | 1395 | |
1396 | 1396 | $error = true; |
1397 | 1397 | |
1398 | 1398 | } |
1399 | 1399 | |
1400 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
1400 | + if (!empty($_GET['entry']) && (string)$this->entry['id'] !== $_GET['entry']) { |
|
1401 | 1401 | |
1402 | 1402 | $error = true; |
1403 | 1403 | |
1404 | - } elseif( ! $this->verify_nonce() ) { |
|
1404 | + } elseif (!$this->verify_nonce()) { |
|
1405 | 1405 | |
1406 | 1406 | /** |
1407 | 1407 | * If the Entry is embedded, there may be two entries on the same page. |
1408 | 1408 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
1409 | 1409 | */ |
1410 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1410 | + if (GravityView_oEmbed::getInstance()->get_entry_id()) { |
|
1411 | 1411 | $error = true; |
1412 | 1412 | } else { |
1413 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1413 | + $error = __('The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1414 | 1414 | } |
1415 | 1415 | |
1416 | 1416 | } |
1417 | 1417 | |
1418 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1419 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
1418 | + if (!GravityView_Edit_Entry::check_user_cap_edit_entry($this->entry)) { |
|
1419 | + $error = __('You do not have permission to edit this entry.', 'gravityview'); |
|
1420 | 1420 | } |
1421 | 1421 | |
1422 | - if( $this->entry['status'] === 'trash' ) { |
|
1423 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1422 | + if ($this->entry['status'] === 'trash') { |
|
1423 | + $error = __('You cannot edit the entry; it is in the trash.', 'gravityview'); |
|
1424 | 1424 | } |
1425 | 1425 | |
1426 | 1426 | // No errors; everything's fine here! |
1427 | - if( empty( $error ) ) { |
|
1427 | + if (empty($error)) { |
|
1428 | 1428 | return true; |
1429 | 1429 | } |
1430 | 1430 | |
1431 | - if( $echo && $error !== true ) { |
|
1431 | + if ($echo && $error !== true) { |
|
1432 | 1432 | |
1433 | - $error = esc_html( $error ); |
|
1433 | + $error = esc_html($error); |
|
1434 | 1434 | |
1435 | 1435 | /** |
1436 | 1436 | * @since 1.9 |
1437 | 1437 | */ |
1438 | - if ( ! empty( $this->entry ) ) { |
|
1439 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1438 | + if (!empty($this->entry)) { |
|
1439 | + $error .= ' '.gravityview_get_link('#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview'), array('onclick' => "window.history.go(-1); return false;")); |
|
1440 | 1440 | } |
1441 | 1441 | |
1442 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
1442 | + echo GVCommon::generate_notice(wpautop($error), 'gv-error error'); |
|
1443 | 1443 | } |
1444 | 1444 | |
1445 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); |
|
1445 | + do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]'.$error); |
|
1446 | 1446 | |
1447 | 1447 | return false; |
1448 | 1448 | } |
@@ -1455,24 +1455,24 @@ discard block |
||
1455 | 1455 | * @param boolean $echo Whether to show error message telling user they aren't allowed |
1456 | 1456 | * @return boolean True: user can edit the current field; False: nope, they can't. |
1457 | 1457 | */ |
1458 | - private function user_can_edit_field( $field, $echo = false ) { |
|
1458 | + private function user_can_edit_field($field, $echo = false) { |
|
1459 | 1459 | |
1460 | 1460 | $error = NULL; |
1461 | 1461 | |
1462 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1463 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
1462 | + if (!$this->check_user_cap_edit_field($field)) { |
|
1463 | + $error = __('You do not have permission to edit this field.', 'gravityview'); |
|
1464 | 1464 | } |
1465 | 1465 | |
1466 | 1466 | // No errors; everything's fine here! |
1467 | - if( empty( $error ) ) { |
|
1467 | + if (empty($error)) { |
|
1468 | 1468 | return true; |
1469 | 1469 | } |
1470 | 1470 | |
1471 | - if( $echo ) { |
|
1472 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
1471 | + if ($echo) { |
|
1472 | + echo GVCommon::generate_notice(wpautop(esc_html($error)), 'gv-error error'); |
|
1473 | 1473 | } |
1474 | 1474 | |
1475 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); |
|
1475 | + do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]'.$error); |
|
1476 | 1476 | |
1477 | 1477 | return false; |
1478 | 1478 | |
@@ -1487,18 +1487,18 @@ discard block |
||
1487 | 1487 | * @param [type] $field [description] |
1488 | 1488 | * @return bool |
1489 | 1489 | */ |
1490 | - private function check_user_cap_edit_field( $field ) { |
|
1490 | + private function check_user_cap_edit_field($field) { |
|
1491 | 1491 | |
1492 | 1492 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
1493 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1493 | + if (GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_others_entries'))) { |
|
1494 | 1494 | return true; |
1495 | 1495 | } |
1496 | 1496 | |
1497 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
1497 | + $field_cap = isset($field['allow_edit_cap']) ? $field['allow_edit_cap'] : false; |
|
1498 | 1498 | |
1499 | 1499 | // If the field has custom editing capaibilities set, check those |
1500 | - if( $field_cap ) { |
|
1501 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
1500 | + if ($field_cap) { |
|
1501 | + return GVCommon::has_cap($field['allow_edit_cap']); |
|
1502 | 1502 | } |
1503 | 1503 | |
1504 | 1504 | return false; |
@@ -1512,17 +1512,17 @@ discard block |
||
1512 | 1512 | public function verify_nonce() { |
1513 | 1513 | |
1514 | 1514 | // Verify form submitted for editing single |
1515 | - if( $this->is_edit_entry_submission() ) { |
|
1516 | - $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
|
1515 | + if ($this->is_edit_entry_submission()) { |
|
1516 | + $valid = wp_verify_nonce($_POST[self::$nonce_field], self::$nonce_field); |
|
1517 | 1517 | } |
1518 | 1518 | |
1519 | 1519 | // Verify |
1520 | - else if( ! $this->is_edit_entry() ) { |
|
1520 | + else if (!$this->is_edit_entry()) { |
|
1521 | 1521 | $valid = false; |
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | else { |
1525 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
1525 | + $valid = wp_verify_nonce($_GET['edit'], self::$nonce_key); |
|
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | /** |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | * @param int|boolean $valid False if invalid; 1 or 2 when nonce was generated |
1532 | 1532 | * @param string $nonce_field Key used when validating submissions. Default: is_gv_edit_entry |
1533 | 1533 | */ |
1534 | - $valid = apply_filters( 'gravityview/edit_entry/verify_nonce', $valid, self::$nonce_field ); |
|
1534 | + $valid = apply_filters('gravityview/edit_entry/verify_nonce', $valid, self::$nonce_field); |
|
1535 | 1535 | |
1536 | 1536 | return $valid; |
1537 | 1537 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @copyright Copyright 2015, Katz Web Services, Inc. |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'WPINC' ) ) { |
|
13 | +if (!defined('WPINC')) { |
|
14 | 14 | die; |
15 | 15 | } |
16 | 16 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | private $_user_before_update = null; |
31 | 31 | |
32 | - function __construct( GravityView_Edit_Entry $loader ) { |
|
32 | + function __construct(GravityView_Edit_Entry $loader) { |
|
33 | 33 | $this->loader = $loader; |
34 | 34 | } |
35 | 35 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | * @since 1.11 |
44 | 44 | * @param boolean $boolean Whether to trigger update on user registration (default: true) |
45 | 45 | */ |
46 | - if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
47 | - add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
46 | + if (apply_filters('gravityview/edit_entry/user_registration/trigger_update', true)) { |
|
47 | + add_action('gravityview/edit_entry/after_update', array($this, 'update_user'), 10, 2); |
|
48 | 48 | |
49 | 49 | // last resort in case the current user display name don't match any of the defaults |
50 | - add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
|
50 | + add_action('gform_user_updated', array($this, 'restore_display_name'), 10, 4); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @param string $entry_id Gravity Forms entry ID |
61 | 61 | * @return void |
62 | 62 | */ |
63 | - public function update_user( $form = array(), $entry_id = 0 ) { |
|
63 | + public function update_user($form = array(), $entry_id = 0) { |
|
64 | 64 | |
65 | - if( !class_exists( 'GFAPI' ) || !class_exists( 'GFUser' ) || empty( $entry_id ) ) { |
|
65 | + if (!class_exists('GFAPI') || !class_exists('GFUser') || empty($entry_id)) { |
|
66 | 66 | return; |
67 | 67 | } |
68 | 68 | |
69 | - $entry = GFAPI::get_entry( $entry_id ); |
|
69 | + $entry = GFAPI::get_entry($entry_id); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | * @param array $entry Gravity Forms entry |
75 | 75 | * @param array $form Gravity Forms form |
76 | 76 | */ |
77 | - $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
77 | + $entry = apply_filters('gravityview/edit_entry/user_registration/entry', $entry, $form); |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @since 1.14 |
81 | 81 | */ |
82 | - $config = GFUser::get_active_config( $form, $entry ); |
|
82 | + $config = GFUser::get_active_config($form, $entry); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | * @param[in] array $form Gravity Forms form array |
90 | 90 | * @param[in] array $entry Gravity Forms entry being edited |
91 | 91 | */ |
92 | - $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
92 | + $preserve_role = apply_filters('gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry); |
|
93 | 93 | |
94 | - if( $preserve_role ) { |
|
94 | + if ($preserve_role) { |
|
95 | 95 | $config['meta']['role'] = 'gfur_preserve_role'; |
96 | 96 | } |
97 | 97 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * Make sure the current display name is not changed with the update user method. |
100 | 100 | * @since 1.15 |
101 | 101 | */ |
102 | - $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] ); |
|
102 | + $config['meta']['displayname'] = $this->match_current_display_name($entry['created_by']); |
|
103 | 103 | |
104 | 104 | |
105 | 105 | /** |
@@ -109,24 +109,24 @@ discard block |
||
109 | 109 | * @param[in] array $form Gravity Forms form array |
110 | 110 | * @param[in] array $entry Gravity Forms entry being edited |
111 | 111 | */ |
112 | - $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
112 | + $config = apply_filters('gravityview/edit_entry/user_registration/config', $config, $form, $entry); |
|
113 | 113 | |
114 | - $is_create_feed = ( $config && rgars( $config, 'meta/feed_type') === 'create' ); |
|
114 | + $is_create_feed = ($config && rgars($config, 'meta/feed_type') === 'create'); |
|
115 | 115 | |
116 | 116 | // Only update if it's a create feed |
117 | - if( ! $is_create_feed ) { |
|
117 | + if (!$is_create_feed) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // The priority is set to 3 so that default priority (10) will still override it |
122 | - add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
123 | - add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
122 | + add_filter('send_password_change_email', '__return_false', 3); |
|
123 | + add_filter('send_email_change_email', '__return_false', 3); |
|
124 | 124 | |
125 | 125 | // Trigger the User Registration update user method |
126 | - GFUser::update_user( $entry, $form, $config ); |
|
126 | + GFUser::update_user($entry, $form, $config); |
|
127 | 127 | |
128 | - remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
129 | - remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
128 | + remove_filter('send_password_change_email', '__return_false', 3); |
|
129 | + remove_filter('send_email_change_email', '__return_false', 3); |
|
130 | 130 | |
131 | 131 | } |
132 | 132 | |
@@ -138,17 +138,17 @@ discard block |
||
138 | 138 | * @param int $user_id WP User ID |
139 | 139 | * @return string Display name format as used inside Gravity Forms User Registration |
140 | 140 | */ |
141 | - public function match_current_display_name( $user_id ) { |
|
141 | + public function match_current_display_name($user_id) { |
|
142 | 142 | |
143 | - $user = get_userdata( $user_id ); |
|
143 | + $user = get_userdata($user_id); |
|
144 | 144 | |
145 | - $names = $this->generate_display_names( $user ); |
|
145 | + $names = $this->generate_display_names($user); |
|
146 | 146 | |
147 | - $format = array_search( $user->display_name, $names, true ); |
|
147 | + $format = array_search($user->display_name, $names, true); |
|
148 | 148 | |
149 | 149 | // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support) |
150 | 150 | // trigger last resort method at the 'gform_user_updated' hook |
151 | - if( false === $format || 'nickname' === $format ) { |
|
151 | + if (false === $format || 'nickname' === $format) { |
|
152 | 152 | $this->_user_before_update = $user; |
153 | 153 | $format = 'nickname'; |
154 | 154 | } |
@@ -165,25 +165,25 @@ discard block |
||
165 | 165 | * @param object $profileuser WP_User object |
166 | 166 | * @return array List all the possible display names for a certain User object |
167 | 167 | */ |
168 | - public function generate_display_names( $profileuser ) { |
|
168 | + public function generate_display_names($profileuser) { |
|
169 | 169 | |
170 | 170 | $public_display = array(); |
171 | 171 | $public_display['nickname'] = $profileuser->nickname; |
172 | 172 | $public_display['username'] = $profileuser->user_login; |
173 | 173 | |
174 | - if ( !empty($profileuser->first_name) ) |
|
174 | + if (!empty($profileuser->first_name)) |
|
175 | 175 | $public_display['firstname'] = $profileuser->first_name; |
176 | 176 | |
177 | - if ( !empty($profileuser->last_name) ) |
|
177 | + if (!empty($profileuser->last_name)) |
|
178 | 178 | $public_display['lastname'] = $profileuser->last_name; |
179 | 179 | |
180 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
181 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
182 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
180 | + if (!empty($profileuser->first_name) && !empty($profileuser->last_name)) { |
|
181 | + $public_display['firstlast'] = $profileuser->first_name.' '.$profileuser->last_name; |
|
182 | + $public_display['lastfirst'] = $profileuser->last_name.' '.$profileuser->first_name; |
|
183 | 183 | } |
184 | 184 | |
185 | - $public_display = array_map( 'trim', $public_display ); |
|
186 | - $public_display = array_unique( $public_display ); |
|
185 | + $public_display = array_map('trim', $public_display); |
|
186 | + $public_display = array_unique($public_display); |
|
187 | 187 | |
188 | 188 | return $public_display; |
189 | 189 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @param string $password User password |
200 | 200 | * @return void |
201 | 201 | */ |
202 | - public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
202 | + public function restore_display_name($user_id = 0, $config = array(), $entry = array(), $password = '') { |
|
203 | 203 | |
204 | 204 | /** |
205 | 205 | * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | * @since 1.14.4 |
208 | 208 | * @param boolean $restore_display_name Restore Display Name? Default: true |
209 | 209 | */ |
210 | - $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
210 | + $restore_display_name = apply_filters('gravityview/edit_entry/restore_display_name', true); |
|
211 | 211 | |
212 | - $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
212 | + $is_update_feed = ($config && rgars($config, 'meta/feed_type') === 'update'); |
|
213 | 213 | |
214 | 214 | /** |
215 | 215 | * Don't restore display name: |
@@ -218,11 +218,11 @@ discard block |
||
218 | 218 | * - or we don't need as we found the correct format before updating user. |
219 | 219 | * @since 1.14.4 |
220 | 220 | */ |
221 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
221 | + if (!$restore_display_name || $is_update_feed || is_null($this->_user_before_update)) { |
|
222 | 222 | return; |
223 | 223 | } |
224 | 224 | |
225 | - $user_after_update = get_userdata( $user_id ); |
|
225 | + $user_after_update = get_userdata($user_id); |
|
226 | 226 | |
227 | 227 | $restored_user = $user_after_update; |
228 | 228 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $restored_user->display_name = $this->_user_before_update->display_name; |
231 | 231 | |
232 | 232 | // Don't have WP update the password. |
233 | - unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
233 | + unset($restored_user->data->user_pass, $restored_user->user_pass); |
|
234 | 234 | |
235 | 235 | /** |
236 | 236 | * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
@@ -240,19 +240,19 @@ discard block |
||
240 | 240 | * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
241 | 241 | * @param array $entry The Gravity Forms entry that was just updated |
242 | 242 | */ |
243 | - $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
243 | + $restored_user = apply_filters('gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry); |
|
244 | 244 | |
245 | - $updated = wp_update_user( $restored_user ); |
|
245 | + $updated = wp_update_user($restored_user); |
|
246 | 246 | |
247 | - if( is_wp_error( $updated ) ) { |
|
248 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
247 | + if (is_wp_error($updated)) { |
|
248 | + do_action('gravityview_log_error', __METHOD__.sprintf(' - There was an error updating user #%d details', $user_id), $updated); |
|
249 | 249 | } else { |
250 | - do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
250 | + do_action('gravityview_log_debug', __METHOD__.sprintf(' - User #%d details restored', $user_id)); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | $this->_user_before_update = null; |
254 | 254 | |
255 | - unset( $updated, $restored_user, $user_after_update ); |
|
255 | + unset($updated, $restored_user, $user_after_update); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | } //end class |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @copyright Copyright 2014, Katz Web Services, Inc. |
12 | 12 | */ |
13 | 13 | |
14 | -if ( ! defined( 'WPINC' ) ) { |
|
14 | +if (!defined('WPINC')) { |
|
15 | 15 | die; |
16 | 16 | } |
17 | 17 | |
@@ -34,18 +34,18 @@ discard block |
||
34 | 34 | |
35 | 35 | function __construct() { |
36 | 36 | |
37 | - self::$file = plugin_dir_path( __FILE__ ); |
|
37 | + self::$file = plugin_dir_path(__FILE__); |
|
38 | 38 | |
39 | - if( is_admin() ) { |
|
40 | - $this->load_components( 'admin' ); |
|
39 | + if (is_admin()) { |
|
40 | + $this->load_components('admin'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | - $this->load_components( 'render' ); |
|
44 | + $this->load_components('render'); |
|
45 | 45 | |
46 | 46 | // If GF User Registration Add-on exists |
47 | - if( class_exists( 'GFUser' ) ) { |
|
48 | - $this->load_components( 'user-registration' ); |
|
47 | + if (class_exists('GFUser')) { |
|
48 | + $this->load_components('user-registration'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | $this->add_hooks(); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | static function getInstance() { |
59 | 59 | |
60 | - if( empty( self::$instance ) ) { |
|
60 | + if (empty(self::$instance)) { |
|
61 | 61 | self::$instance = new GravityView_Edit_Entry; |
62 | 62 | } |
63 | 63 | |
@@ -65,33 +65,33 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | - private function load_components( $component ) { |
|
68 | + private function load_components($component) { |
|
69 | 69 | |
70 | - $dir = trailingslashit( self::$file ); |
|
70 | + $dir = trailingslashit(self::$file); |
|
71 | 71 | |
72 | - $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
73 | - $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
72 | + $filename = $dir.'class-edit-entry-'.$component.'.php'; |
|
73 | + $classname = 'GravityView_Edit_Entry_'.str_replace(' ', '_', ucwords(str_replace('-', ' ', $component))); |
|
74 | 74 | |
75 | 75 | // Loads component and pass extension's instance so that component can |
76 | 76 | // talk each other. |
77 | 77 | require_once $filename; |
78 | - $this->instances[ $component ] = new $classname( $this ); |
|
79 | - $this->instances[ $component ]->load(); |
|
78 | + $this->instances[$component] = new $classname($this); |
|
79 | + $this->instances[$component]->load(); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | |
83 | 83 | private function add_hooks() { |
84 | 84 | |
85 | 85 | // Add front-end access to Gravity Forms delete file action |
86 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
86 | + add_action('wp_ajax_nopriv_rg_delete_file', array('RGForms', 'delete_file')); |
|
87 | 87 | |
88 | 88 | // Make sure this hook is run for non-admins |
89 | - add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
89 | + add_action('wp_ajax_rg_delete_file', array('RGForms', 'delete_file')); |
|
90 | 90 | |
91 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
91 | + add_filter('gravityview_blacklist_field_types', array($this, 'modify_field_blacklist'), 10, 2); |
|
92 | 92 | |
93 | 93 | // add template path to check for field |
94 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
94 | + add_filter('gravityview_template_paths', array($this, 'add_template_path')); |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | */ |
102 | 102 | private function addon_specific_hooks() { |
103 | 103 | |
104 | - if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
105 | - add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script')); |
|
104 | + if (class_exists('GFSignature') && is_callable(array('GFSignature', 'get_instance'))) { |
|
105 | + add_filter('gform_admin_pre_render', array(GFSignature::get_instance(), 'edit_lead_script')); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | } |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | * Include this extension templates path |
112 | 112 | * @param array $file_paths List of template paths ordered |
113 | 113 | */ |
114 | - public function add_template_path( $file_paths ) { |
|
114 | + public function add_template_path($file_paths) { |
|
115 | 115 | |
116 | 116 | // Index 100 is the default GravityView template path. |
117 | - $file_paths[ 110 ] = self::$file; |
|
117 | + $file_paths[110] = self::$file; |
|
118 | 118 | |
119 | 119 | return $file_paths; |
120 | 120 | } |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * @param $entry_id int Gravity Forms entry id |
129 | 129 | * @return string |
130 | 130 | */ |
131 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
132 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
131 | + public static function get_nonce_key($view_id, $form_id, $entry_id) { |
|
132 | + return sprintf('edit_%d_%d_%d', $view_id, $form_id, $entry_id); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -146,32 +146,32 @@ discard block |
||
146 | 146 | * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
149 | + public static function get_edit_link($entry, $view_id, $post_id = null, $field_values = '') { |
|
150 | 150 | |
151 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
151 | + $nonce_key = self::get_nonce_key($view_id, $entry['form_id'], $entry['id']); |
|
152 | 152 | |
153 | - $base = gv_entry_link( $entry, $post_id ); |
|
153 | + $base = gv_entry_link($entry, $post_id); |
|
154 | 154 | |
155 | - $url = add_query_arg( array( |
|
155 | + $url = add_query_arg(array( |
|
156 | 156 | 'page' => 'gf_entries', // Needed for GFForms::get_page() |
157 | 157 | 'view' => 'entry', // Needed for GFForms::get_page() |
158 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
159 | - ), $base ); |
|
158 | + 'edit' => wp_create_nonce($nonce_key) |
|
159 | + ), $base); |
|
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Allow passing params to dynamically populate entry with values |
163 | 163 | * @since 1.9.2 |
164 | 164 | */ |
165 | - if( !empty( $field_values ) ) { |
|
165 | + if (!empty($field_values)) { |
|
166 | 166 | |
167 | - if( is_array( $field_values ) ) { |
|
167 | + if (is_array($field_values)) { |
|
168 | 168 | // If already an array, no parse_str() needed |
169 | 169 | $params = $field_values; |
170 | 170 | } else { |
171 | - parse_str( $field_values, $params ); |
|
171 | + parse_str($field_values, $params); |
|
172 | 172 | } |
173 | 173 | |
174 | - $url = add_query_arg( $params, $url ); |
|
174 | + $url = add_query_arg($params, $url); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | return $url; |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | * @param string|null $context Context |
185 | 185 | * @return array If not edit context, original field blacklist. Otherwise, blacklist including post fields. |
186 | 186 | */ |
187 | - public function modify_field_blacklist( $fields = array(), $context = NULL ) { |
|
187 | + public function modify_field_blacklist($fields = array(), $context = NULL) { |
|
188 | 188 | |
189 | - if( empty( $context ) || $context !== 'edit' ) { |
|
189 | + if (empty($context) || $context !== 'edit') { |
|
190 | 190 | return $fields; |
191 | 191 | } |
192 | 192 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | // 'payment_method', This is editable in the admin, so allowing it here |
208 | 208 | ); |
209 | 209 | |
210 | - return array_merge( $fields, $add_fields ); |
|
210 | + return array_merge($fields, $add_fields); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2} |
221 | 221 | * @return bool |
222 | 222 | */ |
223 | - public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
223 | + public static function check_user_cap_edit_entry($entry, $view_id = 0) { |
|
224 | 224 | |
225 | 225 | // No permission by default |
226 | 226 | $user_can_edit = false; |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | // If they can edit any entries (as defined in Gravity Forms) |
229 | 229 | // Or if they can edit other people's entries |
230 | 230 | // Then we're good. |
231 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
231 | + if (GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_others_entries'), $entry['id'])) { |
|
232 | 232 | |
233 | - do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
233 | + do_action('gravityview_log_debug', __METHOD__.' - User has ability to edit all entries.'); |
|
234 | 234 | |
235 | 235 | $user_can_edit = true; |
236 | 236 | |
237 | - } else if( !isset( $entry['created_by'] ) ) { |
|
237 | + } else if (!isset($entry['created_by'])) { |
|
238 | 238 | |
239 | 239 | do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
240 | 240 | |
@@ -243,34 +243,34 @@ discard block |
||
243 | 243 | } else { |
244 | 244 | |
245 | 245 | // get user_edit setting |
246 | - if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
246 | + if (empty($view_id) || $view_id == GravityView_View::getInstance()->getViewId()) { |
|
247 | 247 | // if View ID not specified or is the current view |
248 | 248 | $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
249 | 249 | } else { |
250 | 250 | // in case is specified and not the current view |
251 | - $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
251 | + $user_edit = GVCommon::get_template_setting($view_id, 'user_edit'); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | $current_user = wp_get_current_user(); |
255 | 255 | |
256 | 256 | // User edit is disabled |
257 | - if( empty( $user_edit ) ) { |
|
257 | + if (empty($user_edit)) { |
|
258 | 258 | |
259 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
259 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.'); |
|
260 | 260 | |
261 | 261 | $user_can_edit = false; |
262 | 262 | } |
263 | 263 | |
264 | 264 | // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
265 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
265 | + else if (is_user_logged_in() && intval($current_user->ID) === intval($entry['created_by'])) { |
|
266 | 266 | |
267 | - do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
267 | + do_action('gravityview_log_debug', sprintf('GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID)); |
|
268 | 268 | |
269 | 269 | $user_can_edit = true; |
270 | 270 | |
271 | - } else if( ! is_user_logged_in() ) { |
|
271 | + } else if (!is_user_logged_in()) { |
|
272 | 272 | |
273 | - do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
|
273 | + do_action('gravityview_log_debug', __METHOD__.' No user defined; edit entry requires logged in user'); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
283 | 283 | * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
284 | 284 | */ |
285 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
285 | + $user_can_edit = apply_filters('gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id); |
|
286 | 286 | |
287 | 287 | return (bool)$user_can_edit; |
288 | 288 | } |
@@ -4,19 +4,19 @@ |
||
4 | 4 | |
5 | 5 | $view_id = $gravityview_view->getViewId(); |
6 | 6 | |
7 | -extract( $gravityview_view->getCurrentField() ); |
|
7 | +extract($gravityview_view->getCurrentField()); |
|
8 | 8 | |
9 | 9 | // Only show the link to logged-in users. |
10 | -if( !GravityView_Edit_Entry::check_user_cap_edit_entry( $entry ) ) { |
|
10 | +if (!GravityView_Edit_Entry::check_user_cap_edit_entry($entry)) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
14 | -$link_text = empty( $field_settings['edit_link'] ) ? __('Edit Entry', 'gravityview') : $field_settings['edit_link']; |
|
14 | +$link_text = empty($field_settings['edit_link']) ? __('Edit Entry', 'gravityview') : $field_settings['edit_link']; |
|
15 | 15 | |
16 | -$link_atts = empty( $field_settings['new_window'] ) ? '' : 'target="_blank"'; |
|
16 | +$link_atts = empty($field_settings['new_window']) ? '' : 'target="_blank"'; |
|
17 | 17 | |
18 | -$output = apply_filters( 'gravityview_entry_link', GravityView_API::replace_variables( $link_text, $form, $entry ) ); |
|
18 | +$output = apply_filters('gravityview_entry_link', GravityView_API::replace_variables($link_text, $form, $entry)); |
|
19 | 19 | |
20 | -$href = GravityView_Edit_Entry::get_edit_link( $entry, $view_id ); |
|
20 | +$href = GravityView_Edit_Entry::get_edit_link($entry, $view_id); |
|
21 | 21 | |
22 | -echo gravityview_get_link( $href, $output, $link_atts ); |
|
22 | +echo gravityview_get_link($href, $output, $link_atts); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @param array $entry The Gravity Forms entry |
16 | 16 | * @param int $view_id The current View ID |
17 | 17 | */ |
18 | - $back_link = apply_filters( 'gravityview/edit_entry/cancel_link', remove_query_arg( array( 'page', 'view', 'edit' ) ), $object->form, $object->entry, $object->view_id ); |
|
18 | + $back_link = apply_filters('gravityview/edit_entry/cancel_link', remove_query_arg(array('page', 'view', 'edit')), $object->form, $object->entry, $object->view_id); |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @action `gravityview/edit-entry/publishing-action/before` Triggered before the submit buttons in the Edit Entry screen, inside the `<div id="publishing-action">` container. |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | * @param array $entry The Gravity Forms entry |
25 | 25 | * @param int $view_id The current View ID |
26 | 26 | */ |
27 | - do_action( 'gravityview/edit-entry/publishing-action/before', $object->form, $object->entry, $object->view_id ); |
|
27 | + do_action('gravityview/edit-entry/publishing-action/before', $object->form, $object->entry, $object->view_id); |
|
28 | 28 | |
29 | 29 | ?> |
30 | - <input id="gform_submit_button_<?php echo esc_attr( $object->form['id'] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-update" type="submit" tabindex="4" value="<?php esc_attr_e( 'Update', 'gravityview'); ?>" name="save" /> |
|
30 | + <input id="gform_submit_button_<?php echo esc_attr($object->form['id']); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-update" type="submit" tabindex="4" value="<?php esc_attr_e('Update', 'gravityview'); ?>" name="save" /> |
|
31 | 31 | |
32 | - <a class="btn btn-sm button button-small gv-button-cancel" tabindex="5" href="<?php echo esc_url( $back_link ); ?>"><?php esc_attr_e( 'Cancel', 'gravityview' ); ?></a> |
|
32 | + <a class="btn btn-sm button button-small gv-button-cancel" tabindex="5" href="<?php echo esc_url($back_link); ?>"><?php esc_attr_e('Cancel', 'gravityview'); ?></a> |
|
33 | 33 | <?php |
34 | 34 | |
35 | 35 | /** |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | * @param array $entry The Gravity Forms entry |
40 | 40 | * @param int $view_id The current View ID |
41 | 41 | */ |
42 | - do_action( 'gravityview/edit-entry/publishing-action/after', $object->form, $object->entry, $object->view_id ); |
|
42 | + do_action('gravityview/edit-entry/publishing-action/after', $object->form, $object->entry, $object->view_id); |
|
43 | 43 | |
44 | 44 | ?> |
45 | 45 | <input type="hidden" name="action" value="update" /> |
46 | - <input type="hidden" name="lid" value="<?php echo esc_attr( $object->entry['id'] ); ?>" /> |
|
46 | + <input type="hidden" name="lid" value="<?php echo esc_attr($object->entry['id']); ?>" /> |
|
47 | 47 | </div> |
@@ -6,7 +6,7 @@ |
||
6 | 6 | ?><script type="text/javascript"> |
7 | 7 | |
8 | 8 | function DeleteFile(leadId, fieldId, deleteButton){ |
9 | - if(confirm('<?php echo esc_js( __("Would you like to permanently delete this file? 'Cancel' to stop. 'OK' to delete", 'gravityview') ); ?>')){ |
|
9 | + if(confirm('<?php echo esc_js(__("Would you like to permanently delete this file? 'Cancel' to stop. 'OK' to delete", 'gravityview')); ?>')){ |
|
10 | 10 | var fileIndex = jQuery(deleteButton).parent().index(); |
11 | 11 | var mysack = new sack("<?php echo admin_url("admin-ajax.php")?>"); |
12 | 12 | mysack.execute = 1; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | //set_site_transient( 'update_plugins', null ); |
5 | 5 | |
6 | 6 | // Exit if accessed directly |
7 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
7 | +if (!defined('ABSPATH')) exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Allows plugins to use their own update API. |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | * @param string $_plugin_file Path to the plugin file. |
30 | 30 | * @param array $_api_data Optional data to send with API calls. |
31 | 31 | */ |
32 | - function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
33 | - $this->api_url = trailingslashit( $_api_url ); |
|
32 | + function __construct($_api_url, $_plugin_file, $_api_data = null) { |
|
33 | + $this->api_url = trailingslashit($_api_url); |
|
34 | 34 | $this->api_data = $_api_data; |
35 | - $this->name = plugin_basename( $_plugin_file ); |
|
36 | - $this->slug = basename( $_plugin_file, '.php' ); |
|
35 | + $this->name = plugin_basename($_plugin_file); |
|
36 | + $this->slug = basename($_plugin_file, '.php'); |
|
37 | 37 | $this->version = $_api_data['version']; |
38 | 38 | |
39 | 39 | // Set up hooks. |
40 | 40 | $this->init(); |
41 | - add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
41 | + add_action('admin_init', array($this, 'show_changelog')); |
|
42 | 42 | |
43 | 43 | } |
44 | 44 | |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | * @return void |
51 | 51 | */ |
52 | 52 | public function init() { |
53 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
54 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
53 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
54 | + add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3); |
|
55 | 55 | |
56 | - remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10, 2 ); |
|
57 | - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
56 | + remove_action('after_plugin_row_'.$this->name, 'wp_plugin_update_row', 10, 2); |
|
57 | + add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -70,32 +70,32 @@ discard block |
||
70 | 70 | * @param array $_transient_data Update array build by WordPress. |
71 | 71 | * @return array Modified update array with custom plugin data. |
72 | 72 | */ |
73 | - function check_update( $_transient_data ) { |
|
73 | + function check_update($_transient_data) { |
|
74 | 74 | |
75 | 75 | global $pagenow; |
76 | 76 | |
77 | - if( ! is_object( $_transient_data ) ) { |
|
77 | + if (!is_object($_transient_data)) { |
|
78 | 78 | $_transient_data = new stdClass; |
79 | 79 | } |
80 | 80 | |
81 | - if( 'plugins.php' == $pagenow && is_multisite() ) { |
|
81 | + if ('plugins.php' == $pagenow && is_multisite()) { |
|
82 | 82 | return $_transient_data; |
83 | 83 | } |
84 | 84 | |
85 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
85 | + if (empty($_transient_data->response) || empty($_transient_data->response[$this->name])) { |
|
86 | 86 | |
87 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
87 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug)); |
|
88 | 88 | |
89 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
89 | + if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) { |
|
90 | 90 | |
91 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
91 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
92 | 92 | |
93 | - $_transient_data->response[ $this->name ] = $version_info; |
|
93 | + $_transient_data->response[$this->name] = $version_info; |
|
94 | 94 | |
95 | 95 | } |
96 | 96 | |
97 | 97 | $_transient_data->last_checked = time(); |
98 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
98 | + $_transient_data->checked[$this->name] = $this->version; |
|
99 | 99 | |
100 | 100 | } |
101 | 101 | |
@@ -110,86 +110,86 @@ discard block |
||
110 | 110 | * @param string $file |
111 | 111 | * @param array $plugin |
112 | 112 | */ |
113 | - public function show_update_notification( $file, $plugin ) { |
|
113 | + public function show_update_notification($file, $plugin) { |
|
114 | 114 | |
115 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
115 | + if (!current_user_can('update_plugins')) { |
|
116 | 116 | return; |
117 | 117 | } |
118 | 118 | |
119 | - if( ! is_multisite() ) { |
|
119 | + if (!is_multisite()) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
123 | - if ( $this->name != $file ) { |
|
123 | + if ($this->name != $file) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Remove our filter on the site transient |
128 | - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
128 | + remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10); |
|
129 | 129 | |
130 | - $update_cache = get_site_transient( 'update_plugins' ); |
|
130 | + $update_cache = get_site_transient('update_plugins'); |
|
131 | 131 | |
132 | - $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass(); |
|
132 | + $update_cache = is_object($update_cache) ? $update_cache : new stdClass(); |
|
133 | 133 | |
134 | - if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
134 | + if (empty($update_cache->response) || empty($update_cache->response[$this->name])) { |
|
135 | 135 | |
136 | - $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
137 | - $version_info = get_transient( $cache_key ); |
|
136 | + $cache_key = md5('edd_plugin_'.sanitize_key($this->name).'_version_info'); |
|
137 | + $version_info = get_transient($cache_key); |
|
138 | 138 | |
139 | - if( false === $version_info ) { |
|
139 | + if (false === $version_info) { |
|
140 | 140 | |
141 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
141 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug)); |
|
142 | 142 | |
143 | - set_transient( $cache_key, $version_info, 3600 ); |
|
143 | + set_transient($cache_key, $version_info, 3600); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
147 | - if( ! is_object( $version_info ) ) { |
|
147 | + if (!is_object($version_info)) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
151 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
151 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
152 | 152 | |
153 | - $update_cache->response[ $this->name ] = $version_info; |
|
153 | + $update_cache->response[$this->name] = $version_info; |
|
154 | 154 | |
155 | 155 | } |
156 | 156 | |
157 | 157 | $update_cache->last_checked = time(); |
158 | - $update_cache->checked[ $this->name ] = $this->version; |
|
158 | + $update_cache->checked[$this->name] = $this->version; |
|
159 | 159 | |
160 | - set_site_transient( 'update_plugins', $update_cache ); |
|
160 | + set_site_transient('update_plugins', $update_cache); |
|
161 | 161 | |
162 | 162 | } else { |
163 | 163 | |
164 | - $version_info = $update_cache->response[ $this->name ]; |
|
164 | + $version_info = $update_cache->response[$this->name]; |
|
165 | 165 | |
166 | 166 | } |
167 | 167 | |
168 | 168 | // Restore our filter |
169 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
169 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
170 | 170 | |
171 | - if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
171 | + if (!empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) { |
|
172 | 172 | |
173 | 173 | // build a plugin list row, with update notification |
174 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
175 | - echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
174 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
175 | + echo '<tr class="plugin-update-tr"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">'; |
|
176 | 176 | |
177 | - $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
177 | + $changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911'); |
|
178 | 178 | |
179 | - if ( empty( $version_info->download_link ) ) { |
|
179 | + if (empty($version_info->download_link)) { |
|
180 | 180 | printf( |
181 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'gravityview' ), |
|
182 | - esc_html( $version_info->name ), |
|
183 | - esc_url( $changelog_link ), |
|
184 | - esc_html( $version_info->new_version ) |
|
181 | + __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'gravityview'), |
|
182 | + esc_html($version_info->name), |
|
183 | + esc_url($changelog_link), |
|
184 | + esc_html($version_info->new_version) |
|
185 | 185 | ); |
186 | 186 | } else { |
187 | 187 | printf( |
188 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'gravityview' ), |
|
189 | - esc_html( $version_info->name ), |
|
190 | - esc_url( $changelog_link ), |
|
191 | - esc_html( $version_info->new_version ), |
|
192 | - esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
188 | + __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'gravityview'), |
|
189 | + esc_html($version_info->name), |
|
190 | + esc_url($changelog_link), |
|
191 | + esc_html($version_info->new_version), |
|
192 | + esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name)) |
|
193 | 193 | ); |
194 | 194 | } |
195 | 195 | |
@@ -208,16 +208,16 @@ discard block |
||
208 | 208 | * @param object $_args |
209 | 209 | * @return object $_data |
210 | 210 | */ |
211 | - function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
211 | + function plugins_api_filter($_data, $_action = '', $_args = null) { |
|
212 | 212 | |
213 | 213 | |
214 | - if ( $_action != 'plugin_information' ) { |
|
214 | + if ($_action != 'plugin_information') { |
|
215 | 215 | |
216 | 216 | return $_data; |
217 | 217 | |
218 | 218 | } |
219 | 219 | |
220 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
220 | + if (!isset($_args->slug) || ($_args->slug != $this->slug)) { |
|
221 | 221 | |
222 | 222 | return $_data; |
223 | 223 | |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | ) |
233 | 233 | ); |
234 | 234 | |
235 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
235 | + $api_response = $this->api_request('plugin_information', $to_send); |
|
236 | 236 | |
237 | - if ( false !== $api_response ) { |
|
237 | + if (false !== $api_response) { |
|
238 | 238 | $_data = $api_response; |
239 | 239 | } |
240 | 240 | |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | * @param string $url |
250 | 250 | * @return object $array |
251 | 251 | */ |
252 | - function http_request_args( $args, $url ) { |
|
252 | + function http_request_args($args, $url) { |
|
253 | 253 | // If it is an https request and we are performing a package download, disable ssl verification |
254 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
254 | + if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) { |
|
255 | 255 | $args['sslverify'] = false; |
256 | 256 | } |
257 | 257 | return $args; |
@@ -268,43 +268,43 @@ discard block |
||
268 | 268 | * @param array $_data Parameters for the API action. |
269 | 269 | * @return false|object |
270 | 270 | */ |
271 | - private function api_request( $_action, $_data ) { |
|
271 | + private function api_request($_action, $_data) { |
|
272 | 272 | |
273 | 273 | global $wp_version; |
274 | 274 | |
275 | - $data = array_merge( $this->api_data, $_data ); |
|
275 | + $data = array_merge($this->api_data, $_data); |
|
276 | 276 | |
277 | - if ( $data['slug'] != $this->slug ) { |
|
277 | + if ($data['slug'] != $this->slug) { |
|
278 | 278 | return; |
279 | 279 | } |
280 | 280 | |
281 | - if( $this->api_url == home_url() ) { |
|
281 | + if ($this->api_url == home_url()) { |
|
282 | 282 | return false; // Don't allow a plugin to ping itself |
283 | 283 | } |
284 | 284 | |
285 | 285 | $api_params = array( |
286 | 286 | 'edd_action' => 'get_version', |
287 | - 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
288 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
289 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
287 | + 'license' => !empty($data['license']) ? $data['license'] : '', |
|
288 | + 'item_name' => isset($data['item_name']) ? $data['item_name'] : false, |
|
289 | + 'item_id' => isset($data['item_id']) ? $data['item_id'] : false, |
|
290 | 290 | 'slug' => $data['slug'], |
291 | 291 | 'author' => $data['author'], |
292 | 292 | 'url' => home_url() |
293 | 293 | ); |
294 | 294 | |
295 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
295 | + $request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params)); |
|
296 | 296 | |
297 | - if ( ! is_wp_error( $request ) ) { |
|
298 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
297 | + if (!is_wp_error($request)) { |
|
298 | + $request = json_decode(wp_remote_retrieve_body($request)); |
|
299 | 299 | } |
300 | 300 | |
301 | - if ( $request ) { |
|
302 | - if( isset( $request->sections ) ) { |
|
303 | - $request->sections = maybe_unserialize( $request->sections ); |
|
301 | + if ($request) { |
|
302 | + if (isset($request->sections)) { |
|
303 | + $request->sections = maybe_unserialize($request->sections); |
|
304 | 304 | } |
305 | 305 | |
306 | - if( isset( $request->banners ) ) { |
|
307 | - $request->banners = (array)maybe_unserialize( $request->banners ); |
|
306 | + if (isset($request->banners)) { |
|
307 | + $request->banners = (array)maybe_unserialize($request->banners); |
|
308 | 308 | } |
309 | 309 | } else { |
310 | 310 | $request = false; |
@@ -316,26 +316,26 @@ discard block |
||
316 | 316 | public function show_changelog() { |
317 | 317 | |
318 | 318 | |
319 | - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
319 | + if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) { |
|
320 | 320 | return; |
321 | 321 | } |
322 | 322 | |
323 | - if( empty( $_REQUEST['plugin'] ) ) { |
|
323 | + if (empty($_REQUEST['plugin'])) { |
|
324 | 324 | return; |
325 | 325 | } |
326 | 326 | |
327 | - if( empty( $_REQUEST['slug'] ) ) { |
|
327 | + if (empty($_REQUEST['slug'])) { |
|
328 | 328 | return; |
329 | 329 | } |
330 | 330 | |
331 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
332 | - wp_die( __( 'You do not have permission to install plugin updates', 'gravityview' ), __( 'Error', 'gravityview' ), array( 'response' => 403 ) ); |
|
331 | + if (!current_user_can('update_plugins')) { |
|
332 | + wp_die(__('You do not have permission to install plugin updates', 'gravityview'), __('Error', 'gravityview'), array('response' => 403)); |
|
333 | 333 | } |
334 | 334 | |
335 | - $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
335 | + $response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug'])); |
|
336 | 336 | |
337 | - if( $response && isset( $response->sections['changelog'] ) ) { |
|
338 | - echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
337 | + if ($response && isset($response->sections['changelog'])) { |
|
338 | + echo '<div style="background:#fff;padding:10px;">'.$response->sections['changelog'].'</div>'; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return string |
78 | 78 | */ |
79 | - public function get_template_part( $slug, $name = null, $load = true ) { |
|
79 | + public function get_template_part($slug, $name = null, $load = true) { |
|
80 | 80 | // Execute code for this part |
81 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
81 | + do_action('get_template_part_'.$slug, $slug, $name); |
|
82 | 82 | |
83 | 83 | // Get files names of templates, for given slug and name. |
84 | - $templates = $this->get_template_file_names( $slug, $name ); |
|
84 | + $templates = $this->get_template_file_names($slug, $name); |
|
85 | 85 | |
86 | 86 | // Return the part that is found |
87 | - return $this->locate_template( $templates, $load, false ); |
|
87 | + return $this->locate_template($templates, $load, false); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return array |
99 | 99 | */ |
100 | - protected function get_template_file_names( $slug, $name ) { |
|
100 | + protected function get_template_file_names($slug, $name) { |
|
101 | 101 | $templates = array(); |
102 | - if ( isset( $name ) ) { |
|
103 | - $templates[] = $slug . '-' . $name . '.php'; |
|
102 | + if (isset($name)) { |
|
103 | + $templates[] = $slug.'-'.$name.'.php'; |
|
104 | 104 | } |
105 | - $templates[] = $slug . '.php'; |
|
105 | + $templates[] = $slug.'.php'; |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Allow template choices to be filtered. |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param string $slug Template slug. |
117 | 117 | * @param string $name Template name. |
118 | 118 | */ |
119 | - return apply_filters( $this->filter_prefix . '_get_template_part', $templates, $slug, $name ); |
|
119 | + return apply_filters($this->filter_prefix.'_get_template_part', $templates, $slug, $name); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -137,30 +137,30 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return string The template filename if one is located. |
139 | 139 | */ |
140 | - public function locate_template( $template_names, $load = false, $require_once = true ) { |
|
140 | + public function locate_template($template_names, $load = false, $require_once = true) { |
|
141 | 141 | // No file found yet |
142 | 142 | $located = false; |
143 | 143 | |
144 | 144 | // Remove empty entries |
145 | - $template_names = array_filter( (array) $template_names ); |
|
145 | + $template_names = array_filter((array)$template_names); |
|
146 | 146 | $template_paths = $this->get_template_paths(); |
147 | 147 | |
148 | 148 | // Try to find a template file |
149 | - foreach ( $template_names as $template_name ) { |
|
149 | + foreach ($template_names as $template_name) { |
|
150 | 150 | // Trim off any slashes from the template name |
151 | - $template_name = ltrim( $template_name, '/' ); |
|
151 | + $template_name = ltrim($template_name, '/'); |
|
152 | 152 | |
153 | 153 | // Try locating this template file by looping through the template paths |
154 | - foreach ( $template_paths as $template_path ) { |
|
155 | - if ( file_exists( $template_path . $template_name ) ) { |
|
156 | - $located = $template_path . $template_name; |
|
154 | + foreach ($template_paths as $template_path) { |
|
155 | + if (file_exists($template_path.$template_name)) { |
|
156 | + $located = $template_path.$template_name; |
|
157 | 157 | break 2; |
158 | 158 | } |
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - if ( $load && $located ) { |
|
163 | - load_template( $located, $require_once ); |
|
162 | + if ($load && $located) { |
|
163 | + load_template($located, $require_once); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | return $located; |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | * @return mixed|void |
179 | 179 | */ |
180 | 180 | protected function get_template_paths() { |
181 | - $theme_directory = trailingslashit( $this->theme_template_directory ); |
|
181 | + $theme_directory = trailingslashit($this->theme_template_directory); |
|
182 | 182 | |
183 | 183 | $file_paths = array( |
184 | - 10 => trailingslashit( get_template_directory() ) . $theme_directory, |
|
184 | + 10 => trailingslashit(get_template_directory()).$theme_directory, |
|
185 | 185 | 100 => $this->get_templates_dir() |
186 | 186 | ); |
187 | 187 | |
188 | 188 | // Only add this conditionally, so non-child themes don't redundantly check active theme twice. |
189 | - if ( is_child_theme() ) { |
|
190 | - $file_paths[1] = trailingslashit( get_stylesheet_directory() ) . $theme_directory; |
|
189 | + if (is_child_theme()) { |
|
190 | + $file_paths[1] = trailingslashit(get_stylesheet_directory()).$theme_directory; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -197,12 +197,12 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param array $var Default is directory in child theme at index 1, parent theme at 10, and plugin at 100. |
199 | 199 | */ |
200 | - $file_paths = apply_filters( $this->filter_prefix . '_template_paths', $file_paths ); |
|
200 | + $file_paths = apply_filters($this->filter_prefix.'_template_paths', $file_paths); |
|
201 | 201 | |
202 | 202 | // sort the file paths based on priority |
203 | - ksort( $file_paths, SORT_NUMERIC ); |
|
203 | + ksort($file_paths, SORT_NUMERIC); |
|
204 | 204 | |
205 | - return array_map( 'trailingslashit', $file_paths ); |
|
205 | + return array_map('trailingslashit', $file_paths); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -215,6 +215,6 @@ discard block |
||
215 | 215 | * @return string |
216 | 216 | */ |
217 | 217 | protected function get_templates_dir() { |
218 | - return trailingslashit( $this->plugin_directory ) . $this->plugin_template_directory; |
|
218 | + return trailingslashit($this->plugin_directory).$this->plugin_template_directory; |
|
219 | 219 | } |
220 | 220 | } |
@@ -10,42 +10,42 @@ discard block |
||
10 | 10 | * WordPress Importer class for managing parsing of WXR files. |
11 | 11 | */ |
12 | 12 | class WXR_Parser { |
13 | - function parse( $file ) { |
|
13 | + function parse($file) { |
|
14 | 14 | // Attempt to use proper XML parsers first |
15 | - if ( extension_loaded( 'simplexml' ) ) { |
|
15 | + if (extension_loaded('simplexml')) { |
|
16 | 16 | $parser = new WXR_Parser_SimpleXML; |
17 | - $result = $parser->parse( $file ); |
|
17 | + $result = $parser->parse($file); |
|
18 | 18 | |
19 | 19 | // If SimpleXML succeeds or this is an invalid WXR file then return the results |
20 | - if ( ! is_wp_error( $result ) || 'SimpleXML_parse_error' != $result->get_error_code() ) |
|
20 | + if (!is_wp_error($result) || 'SimpleXML_parse_error' != $result->get_error_code()) |
|
21 | 21 | return $result; |
22 | - } else if ( extension_loaded( 'xml' ) ) { |
|
22 | + } else if (extension_loaded('xml')) { |
|
23 | 23 | $parser = new WXR_Parser_XML; |
24 | - $result = $parser->parse( $file ); |
|
24 | + $result = $parser->parse($file); |
|
25 | 25 | |
26 | 26 | // If XMLParser succeeds or this is an invalid WXR file then return the results |
27 | - if ( ! is_wp_error( $result ) || 'XML_parse_error' != $result->get_error_code() ) |
|
27 | + if (!is_wp_error($result) || 'XML_parse_error' != $result->get_error_code()) |
|
28 | 28 | return $result; |
29 | 29 | } |
30 | 30 | |
31 | 31 | // We have a malformed XML file, so display the error and fallthrough to regex |
32 | - if ( isset($result) && defined('IMPORT_DEBUG') && IMPORT_DEBUG ) { |
|
32 | + if (isset($result) && defined('IMPORT_DEBUG') && IMPORT_DEBUG) { |
|
33 | 33 | echo '<pre>'; |
34 | - if ( 'SimpleXML_parse_error' == $result->get_error_code() ) { |
|
35 | - foreach ( $result->get_error_data() as $error ) |
|
36 | - echo $error->line . ':' . $error->column . ' ' . esc_html( $error->message ) . "\n"; |
|
37 | - } else if ( 'XML_parse_error' == $result->get_error_code() ) { |
|
34 | + if ('SimpleXML_parse_error' == $result->get_error_code()) { |
|
35 | + foreach ($result->get_error_data() as $error) |
|
36 | + echo $error->line.':'.$error->column.' '.esc_html($error->message)."\n"; |
|
37 | + } else if ('XML_parse_error' == $result->get_error_code()) { |
|
38 | 38 | $error = $result->get_error_data(); |
39 | - echo $error[0] . ':' . $error[1] . ' ' . esc_html( $error[2] ); |
|
39 | + echo $error[0].':'.$error[1].' '.esc_html($error[2]); |
|
40 | 40 | } |
41 | 41 | echo '</pre>'; |
42 | - echo '<p><strong>' . __( 'There was an error when reading this WXR file', 'wordpress-importer' ) . '</strong><br />'; |
|
43 | - echo __( 'Details are shown above. The importer will now try again with a different parser...', 'wordpress-importer' ) . '</p>'; |
|
42 | + echo '<p><strong>'.__('There was an error when reading this WXR file', 'wordpress-importer').'</strong><br />'; |
|
43 | + echo __('Details are shown above. The importer will now try again with a different parser...', 'wordpress-importer').'</p>'; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // use regular expressions if nothing else available or this is bad XML |
47 | 47 | $parser = new WXR_Parser_Regex; |
48 | - return $parser->parse( $file ); |
|
48 | + return $parser->parse($file); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
@@ -53,171 +53,171 @@ discard block |
||
53 | 53 | * WXR Parser that makes use of the SimpleXML PHP extension. |
54 | 54 | */ |
55 | 55 | class WXR_Parser_SimpleXML { |
56 | - function parse( $file ) { |
|
56 | + function parse($file) { |
|
57 | 57 | $authors = $posts = $categories = $tags = $terms = array(); |
58 | 58 | |
59 | 59 | $internal_errors = libxml_use_internal_errors(true); |
60 | 60 | |
61 | 61 | $dom = new DOMDocument; |
62 | 62 | $old_value = null; |
63 | - if ( function_exists( 'libxml_disable_entity_loader' ) ) { |
|
64 | - $old_value = libxml_disable_entity_loader( true ); |
|
63 | + if (function_exists('libxml_disable_entity_loader')) { |
|
64 | + $old_value = libxml_disable_entity_loader(true); |
|
65 | 65 | } |
66 | - $success = $dom->loadXML( file_get_contents( $file ) ); |
|
67 | - if ( ! is_null( $old_value ) ) { |
|
68 | - libxml_disable_entity_loader( $old_value ); |
|
66 | + $success = $dom->loadXML(file_get_contents($file)); |
|
67 | + if (!is_null($old_value)) { |
|
68 | + libxml_disable_entity_loader($old_value); |
|
69 | 69 | } |
70 | 70 | |
71 | - if ( ! $success || isset( $dom->doctype ) ) { |
|
72 | - return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() ); |
|
71 | + if (!$success || isset($dom->doctype)) { |
|
72 | + return new WP_Error('SimpleXML_parse_error', __('There was an error when reading this WXR file', 'wordpress-importer'), libxml_get_errors()); |
|
73 | 73 | } |
74 | 74 | |
75 | - $xml = simplexml_import_dom( $dom ); |
|
76 | - unset( $dom ); |
|
75 | + $xml = simplexml_import_dom($dom); |
|
76 | + unset($dom); |
|
77 | 77 | |
78 | 78 | // halt if loading produces an error |
79 | - if ( ! $xml ) |
|
80 | - return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() ); |
|
79 | + if (!$xml) |
|
80 | + return new WP_Error('SimpleXML_parse_error', __('There was an error when reading this WXR file', 'wordpress-importer'), libxml_get_errors()); |
|
81 | 81 | |
82 | 82 | $wxr_version = $xml->xpath('/rss/channel/wp:wxr_version'); |
83 | - if ( ! $wxr_version ) |
|
84 | - return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
83 | + if (!$wxr_version) |
|
84 | + return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer')); |
|
85 | 85 | |
86 | - $wxr_version = (string) trim( $wxr_version[0] ); |
|
86 | + $wxr_version = (string)trim($wxr_version[0]); |
|
87 | 87 | // confirm that we are dealing with the correct file format |
88 | - if ( ! preg_match( '/^\d+\.\d+$/', $wxr_version ) ) |
|
89 | - return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
88 | + if (!preg_match('/^\d+\.\d+$/', $wxr_version)) |
|
89 | + return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer')); |
|
90 | 90 | |
91 | 91 | $base_url = $xml->xpath('/rss/channel/wp:base_site_url'); |
92 | - $base_url = isset($base_url[0]) ? (string) trim( $base_url[0] ) : ''; // Modified by GravityView: Check if base_url exists; the GV import files may exclude them. |
|
92 | + $base_url = isset($base_url[0]) ? (string)trim($base_url[0]) : ''; // Modified by GravityView: Check if base_url exists; the GV import files may exclude them. |
|
93 | 93 | |
94 | 94 | $namespaces = $xml->getDocNamespaces(); |
95 | - if ( ! isset( $namespaces['wp'] ) ) |
|
95 | + if (!isset($namespaces['wp'])) |
|
96 | 96 | $namespaces['wp'] = 'http://wordpress.org/export/1.1/'; |
97 | - if ( ! isset( $namespaces['excerpt'] ) ) |
|
97 | + if (!isset($namespaces['excerpt'])) |
|
98 | 98 | $namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/'; |
99 | 99 | |
100 | 100 | // grab authors |
101 | - foreach ( $xml->xpath('/rss/channel/wp:author') as $author_arr ) { |
|
102 | - $a = $author_arr->children( $namespaces['wp'] ); |
|
103 | - $login = (string) $a->author_login; |
|
101 | + foreach ($xml->xpath('/rss/channel/wp:author') as $author_arr) { |
|
102 | + $a = $author_arr->children($namespaces['wp']); |
|
103 | + $login = (string)$a->author_login; |
|
104 | 104 | $authors[$login] = array( |
105 | - 'author_id' => (int) $a->author_id, |
|
105 | + 'author_id' => (int)$a->author_id, |
|
106 | 106 | 'author_login' => $login, |
107 | - 'author_email' => (string) $a->author_email, |
|
108 | - 'author_display_name' => (string) $a->author_display_name, |
|
109 | - 'author_first_name' => (string) $a->author_first_name, |
|
110 | - 'author_last_name' => (string) $a->author_last_name |
|
107 | + 'author_email' => (string)$a->author_email, |
|
108 | + 'author_display_name' => (string)$a->author_display_name, |
|
109 | + 'author_first_name' => (string)$a->author_first_name, |
|
110 | + 'author_last_name' => (string)$a->author_last_name |
|
111 | 111 | ); |
112 | 112 | } |
113 | 113 | |
114 | 114 | // grab cats, tags and terms |
115 | - foreach ( $xml->xpath('/rss/channel/wp:category') as $term_arr ) { |
|
116 | - $t = $term_arr->children( $namespaces['wp'] ); |
|
115 | + foreach ($xml->xpath('/rss/channel/wp:category') as $term_arr) { |
|
116 | + $t = $term_arr->children($namespaces['wp']); |
|
117 | 117 | $categories[] = array( |
118 | - 'term_id' => (int) $t->term_id, |
|
119 | - 'category_nicename' => (string) $t->category_nicename, |
|
120 | - 'category_parent' => (string) $t->category_parent, |
|
121 | - 'cat_name' => (string) $t->cat_name, |
|
122 | - 'category_description' => (string) $t->category_description |
|
118 | + 'term_id' => (int)$t->term_id, |
|
119 | + 'category_nicename' => (string)$t->category_nicename, |
|
120 | + 'category_parent' => (string)$t->category_parent, |
|
121 | + 'cat_name' => (string)$t->cat_name, |
|
122 | + 'category_description' => (string)$t->category_description |
|
123 | 123 | ); |
124 | 124 | } |
125 | 125 | |
126 | - foreach ( $xml->xpath('/rss/channel/wp:tag') as $term_arr ) { |
|
127 | - $t = $term_arr->children( $namespaces['wp'] ); |
|
126 | + foreach ($xml->xpath('/rss/channel/wp:tag') as $term_arr) { |
|
127 | + $t = $term_arr->children($namespaces['wp']); |
|
128 | 128 | $tags[] = array( |
129 | - 'term_id' => (int) $t->term_id, |
|
130 | - 'tag_slug' => (string) $t->tag_slug, |
|
131 | - 'tag_name' => (string) $t->tag_name, |
|
132 | - 'tag_description' => (string) $t->tag_description |
|
129 | + 'term_id' => (int)$t->term_id, |
|
130 | + 'tag_slug' => (string)$t->tag_slug, |
|
131 | + 'tag_name' => (string)$t->tag_name, |
|
132 | + 'tag_description' => (string)$t->tag_description |
|
133 | 133 | ); |
134 | 134 | } |
135 | 135 | |
136 | - foreach ( $xml->xpath('/rss/channel/wp:term') as $term_arr ) { |
|
137 | - $t = $term_arr->children( $namespaces['wp'] ); |
|
136 | + foreach ($xml->xpath('/rss/channel/wp:term') as $term_arr) { |
|
137 | + $t = $term_arr->children($namespaces['wp']); |
|
138 | 138 | $terms[] = array( |
139 | - 'term_id' => (int) $t->term_id, |
|
140 | - 'term_taxonomy' => (string) $t->term_taxonomy, |
|
141 | - 'slug' => (string) $t->term_slug, |
|
142 | - 'term_parent' => (string) $t->term_parent, |
|
143 | - 'term_name' => (string) $t->term_name, |
|
144 | - 'term_description' => (string) $t->term_description |
|
139 | + 'term_id' => (int)$t->term_id, |
|
140 | + 'term_taxonomy' => (string)$t->term_taxonomy, |
|
141 | + 'slug' => (string)$t->term_slug, |
|
142 | + 'term_parent' => (string)$t->term_parent, |
|
143 | + 'term_name' => (string)$t->term_name, |
|
144 | + 'term_description' => (string)$t->term_description |
|
145 | 145 | ); |
146 | 146 | } |
147 | 147 | |
148 | 148 | // grab posts |
149 | - foreach ( $xml->channel->item as $item ) { |
|
149 | + foreach ($xml->channel->item as $item) { |
|
150 | 150 | $post = array( |
151 | - 'post_title' => (string) $item->title, |
|
152 | - 'guid' => (string) $item->guid, |
|
151 | + 'post_title' => (string)$item->title, |
|
152 | + 'guid' => (string)$item->guid, |
|
153 | 153 | ); |
154 | 154 | |
155 | - $dc = $item->children( 'http://purl.org/dc/elements/1.1/' ); |
|
156 | - $post['post_author'] = (string) $dc->creator; |
|
157 | - |
|
158 | - $content = $item->children( 'http://purl.org/rss/1.0/modules/content/' ); |
|
159 | - $excerpt = $item->children( $namespaces['excerpt'] ); |
|
160 | - $post['post_content'] = (string) $content->encoded; |
|
161 | - $post['post_excerpt'] = (string) $excerpt->encoded; |
|
162 | - |
|
163 | - $wp = $item->children( $namespaces['wp'] ); |
|
164 | - $post['post_id'] = (int) $wp->post_id; |
|
165 | - $post['post_date'] = (string) $wp->post_date; |
|
166 | - $post['post_date_gmt'] = (string) $wp->post_date_gmt; |
|
167 | - $post['comment_status'] = (string) $wp->comment_status; |
|
168 | - $post['ping_status'] = (string) $wp->ping_status; |
|
169 | - $post['post_name'] = (string) $wp->post_name; |
|
170 | - $post['status'] = (string) $wp->status; |
|
171 | - $post['post_parent'] = (int) $wp->post_parent; |
|
172 | - $post['menu_order'] = (int) $wp->menu_order; |
|
173 | - $post['post_type'] = (string) $wp->post_type; |
|
174 | - $post['post_password'] = (string) $wp->post_password; |
|
175 | - $post['is_sticky'] = (int) $wp->is_sticky; |
|
176 | - |
|
177 | - if ( isset($wp->attachment_url) ) |
|
178 | - $post['attachment_url'] = (string) $wp->attachment_url; |
|
179 | - |
|
180 | - foreach ( $item->category as $c ) { |
|
155 | + $dc = $item->children('http://purl.org/dc/elements/1.1/'); |
|
156 | + $post['post_author'] = (string)$dc->creator; |
|
157 | + |
|
158 | + $content = $item->children('http://purl.org/rss/1.0/modules/content/'); |
|
159 | + $excerpt = $item->children($namespaces['excerpt']); |
|
160 | + $post['post_content'] = (string)$content->encoded; |
|
161 | + $post['post_excerpt'] = (string)$excerpt->encoded; |
|
162 | + |
|
163 | + $wp = $item->children($namespaces['wp']); |
|
164 | + $post['post_id'] = (int)$wp->post_id; |
|
165 | + $post['post_date'] = (string)$wp->post_date; |
|
166 | + $post['post_date_gmt'] = (string)$wp->post_date_gmt; |
|
167 | + $post['comment_status'] = (string)$wp->comment_status; |
|
168 | + $post['ping_status'] = (string)$wp->ping_status; |
|
169 | + $post['post_name'] = (string)$wp->post_name; |
|
170 | + $post['status'] = (string)$wp->status; |
|
171 | + $post['post_parent'] = (int)$wp->post_parent; |
|
172 | + $post['menu_order'] = (int)$wp->menu_order; |
|
173 | + $post['post_type'] = (string)$wp->post_type; |
|
174 | + $post['post_password'] = (string)$wp->post_password; |
|
175 | + $post['is_sticky'] = (int)$wp->is_sticky; |
|
176 | + |
|
177 | + if (isset($wp->attachment_url)) |
|
178 | + $post['attachment_url'] = (string)$wp->attachment_url; |
|
179 | + |
|
180 | + foreach ($item->category as $c) { |
|
181 | 181 | $att = $c->attributes(); |
182 | - if ( isset( $att['nicename'] ) ) |
|
182 | + if (isset($att['nicename'])) |
|
183 | 183 | $post['terms'][] = array( |
184 | - 'name' => (string) $c, |
|
185 | - 'slug' => (string) $att['nicename'], |
|
186 | - 'domain' => (string) $att['domain'] |
|
184 | + 'name' => (string)$c, |
|
185 | + 'slug' => (string)$att['nicename'], |
|
186 | + 'domain' => (string)$att['domain'] |
|
187 | 187 | ); |
188 | 188 | } |
189 | 189 | |
190 | - foreach ( $wp->postmeta as $meta ) { |
|
190 | + foreach ($wp->postmeta as $meta) { |
|
191 | 191 | $post['postmeta'][] = array( |
192 | - 'key' => (string) $meta->meta_key, |
|
193 | - 'value' => (string) $meta->meta_value |
|
192 | + 'key' => (string)$meta->meta_key, |
|
193 | + 'value' => (string)$meta->meta_value |
|
194 | 194 | ); |
195 | 195 | } |
196 | 196 | |
197 | - foreach ( $wp->comment as $comment ) { |
|
197 | + foreach ($wp->comment as $comment) { |
|
198 | 198 | $meta = array(); |
199 | - if ( isset( $comment->commentmeta ) ) { |
|
200 | - foreach ( $comment->commentmeta as $m ) { |
|
199 | + if (isset($comment->commentmeta)) { |
|
200 | + foreach ($comment->commentmeta as $m) { |
|
201 | 201 | $meta[] = array( |
202 | - 'key' => (string) $m->meta_key, |
|
203 | - 'value' => (string) $m->meta_value |
|
202 | + 'key' => (string)$m->meta_key, |
|
203 | + 'value' => (string)$m->meta_value |
|
204 | 204 | ); |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | 208 | $post['comments'][] = array( |
209 | - 'comment_id' => (int) $comment->comment_id, |
|
210 | - 'comment_author' => (string) $comment->comment_author, |
|
211 | - 'comment_author_email' => (string) $comment->comment_author_email, |
|
212 | - 'comment_author_IP' => (string) $comment->comment_author_IP, |
|
213 | - 'comment_author_url' => (string) $comment->comment_author_url, |
|
214 | - 'comment_date' => (string) $comment->comment_date, |
|
215 | - 'comment_date_gmt' => (string) $comment->comment_date_gmt, |
|
216 | - 'comment_content' => (string) $comment->comment_content, |
|
217 | - 'comment_approved' => (string) $comment->comment_approved, |
|
218 | - 'comment_type' => (string) $comment->comment_type, |
|
219 | - 'comment_parent' => (string) $comment->comment_parent, |
|
220 | - 'comment_user_id' => (int) $comment->comment_user_id, |
|
209 | + 'comment_id' => (int)$comment->comment_id, |
|
210 | + 'comment_author' => (string)$comment->comment_author, |
|
211 | + 'comment_author_email' => (string)$comment->comment_author_email, |
|
212 | + 'comment_author_IP' => (string)$comment->comment_author_IP, |
|
213 | + 'comment_author_url' => (string)$comment->comment_author_url, |
|
214 | + 'comment_date' => (string)$comment->comment_date, |
|
215 | + 'comment_date_gmt' => (string)$comment->comment_date_gmt, |
|
216 | + 'comment_content' => (string)$comment->comment_content, |
|
217 | + 'comment_approved' => (string)$comment->comment_approved, |
|
218 | + 'comment_type' => (string)$comment->comment_type, |
|
219 | + 'comment_parent' => (string)$comment->comment_parent, |
|
220 | + 'comment_user_id' => (int)$comment->comment_user_id, |
|
221 | 221 | 'commentmeta' => $meta, |
222 | 222 | ); |
223 | 223 | } |
@@ -251,32 +251,32 @@ discard block |
||
251 | 251 | ); |
252 | 252 | var $wp_sub_tags = array( |
253 | 253 | 'wp:comment_id', 'wp:comment_author', 'wp:comment_author_email', 'wp:comment_author_url', |
254 | - 'wp:comment_author_IP', 'wp:comment_date', 'wp:comment_date_gmt', 'wp:comment_content', |
|
254 | + 'wp:comment_author_IP', 'wp:comment_date', 'wp:comment_date_gmt', 'wp:comment_content', |
|
255 | 255 | 'wp:comment_approved', 'wp:comment_type', 'wp:comment_parent', 'wp:comment_user_id', |
256 | 256 | ); |
257 | 257 | |
258 | - function parse( $file ) { |
|
258 | + function parse($file) { |
|
259 | 259 | $this->wxr_version = $this->in_post = $this->cdata = $this->data = $this->sub_data = $this->in_tag = $this->in_sub_tag = false; |
260 | 260 | $this->authors = $this->posts = $this->term = $this->category = $this->tag = array(); |
261 | 261 | |
262 | - $xml = xml_parser_create( 'UTF-8' ); |
|
263 | - xml_parser_set_option( $xml, XML_OPTION_SKIP_WHITE, 1 ); |
|
264 | - xml_parser_set_option( $xml, XML_OPTION_CASE_FOLDING, 0 ); |
|
265 | - xml_set_object( $xml, $this ); |
|
266 | - xml_set_character_data_handler( $xml, 'cdata' ); |
|
267 | - xml_set_element_handler( $xml, 'tag_open', 'tag_close' ); |
|
268 | - |
|
269 | - if ( ! xml_parse( $xml, file_get_contents( $file ), true ) ) { |
|
270 | - $current_line = xml_get_current_line_number( $xml ); |
|
271 | - $current_column = xml_get_current_column_number( $xml ); |
|
272 | - $error_code = xml_get_error_code( $xml ); |
|
273 | - $error_string = xml_error_string( $error_code ); |
|
274 | - return new WP_Error( 'XML_parse_error', 'There was an error when reading this WXR file', array( $current_line, $current_column, $error_string ) ); |
|
262 | + $xml = xml_parser_create('UTF-8'); |
|
263 | + xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1); |
|
264 | + xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0); |
|
265 | + xml_set_object($xml, $this); |
|
266 | + xml_set_character_data_handler($xml, 'cdata'); |
|
267 | + xml_set_element_handler($xml, 'tag_open', 'tag_close'); |
|
268 | + |
|
269 | + if (!xml_parse($xml, file_get_contents($file), true)) { |
|
270 | + $current_line = xml_get_current_line_number($xml); |
|
271 | + $current_column = xml_get_current_column_number($xml); |
|
272 | + $error_code = xml_get_error_code($xml); |
|
273 | + $error_string = xml_error_string($error_code); |
|
274 | + return new WP_Error('XML_parse_error', 'There was an error when reading this WXR file', array($current_line, $current_column, $error_string)); |
|
275 | 275 | } |
276 | - xml_parser_free( $xml ); |
|
276 | + xml_parser_free($xml); |
|
277 | 277 | |
278 | - if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) ) |
|
279 | - return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
278 | + if (!preg_match('/^\d+\.\d+$/', $this->wxr_version)) |
|
279 | + return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer')); |
|
280 | 280 | |
281 | 281 | return array( |
282 | 282 | 'authors' => $this->authors, |
@@ -289,26 +289,26 @@ discard block |
||
289 | 289 | ); |
290 | 290 | } |
291 | 291 | |
292 | - function tag_open( $parse, $tag, $attr ) { |
|
293 | - if ( in_array( $tag, $this->wp_tags ) ) { |
|
294 | - $this->in_tag = substr( $tag, 3 ); |
|
292 | + function tag_open($parse, $tag, $attr) { |
|
293 | + if (in_array($tag, $this->wp_tags)) { |
|
294 | + $this->in_tag = substr($tag, 3); |
|
295 | 295 | return; |
296 | 296 | } |
297 | 297 | |
298 | - if ( in_array( $tag, $this->wp_sub_tags ) ) { |
|
299 | - $this->in_sub_tag = substr( $tag, 3 ); |
|
298 | + if (in_array($tag, $this->wp_sub_tags)) { |
|
299 | + $this->in_sub_tag = substr($tag, 3); |
|
300 | 300 | return; |
301 | 301 | } |
302 | 302 | |
303 | - switch ( $tag ) { |
|
303 | + switch ($tag) { |
|
304 | 304 | case 'category': |
305 | - if ( isset($attr['domain'], $attr['nicename']) ) { |
|
305 | + if (isset($attr['domain'], $attr['nicename'])) { |
|
306 | 306 | $this->sub_data['domain'] = $attr['domain']; |
307 | 307 | $this->sub_data['slug'] = $attr['nicename']; |
308 | 308 | } |
309 | 309 | break; |
310 | 310 | case 'item': $this->in_post = true; |
311 | - case 'title': if ( $this->in_post ) $this->in_tag = 'post_title'; break; |
|
311 | + case 'title': if ($this->in_post) $this->in_tag = 'post_title'; break; |
|
312 | 312 | case 'guid': $this->in_tag = 'guid'; break; |
313 | 313 | case 'dc:creator': $this->in_tag = 'post_author'; break; |
314 | 314 | case 'content:encoded': $this->in_tag = 'post_content'; break; |
@@ -320,18 +320,18 @@ discard block |
||
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | - function cdata( $parser, $cdata ) { |
|
324 | - if ( ! trim( $cdata ) ) |
|
323 | + function cdata($parser, $cdata) { |
|
324 | + if (!trim($cdata)) |
|
325 | 325 | return; |
326 | 326 | |
327 | - $this->cdata .= trim( $cdata ); |
|
327 | + $this->cdata .= trim($cdata); |
|
328 | 328 | } |
329 | 329 | |
330 | - function tag_close( $parser, $tag ) { |
|
331 | - switch ( $tag ) { |
|
330 | + function tag_close($parser, $tag) { |
|
331 | + switch ($tag) { |
|
332 | 332 | case 'wp:comment': |
333 | - unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data |
|
334 | - if ( ! empty( $this->sub_data ) ) |
|
333 | + unset($this->sub_data['key'], $this->sub_data['value']); // remove meta sub_data |
|
334 | + if (!empty($this->sub_data)) |
|
335 | 335 | $this->data['comments'][] = $this->sub_data; |
336 | 336 | $this->sub_data = false; |
337 | 337 | break; |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | ); |
343 | 343 | break; |
344 | 344 | case 'category': |
345 | - if ( ! empty( $this->sub_data ) ) { |
|
345 | + if (!empty($this->sub_data)) { |
|
346 | 346 | $this->sub_data['name'] = $this->cdata; |
347 | 347 | $this->data['terms'][] = $this->sub_data; |
348 | 348 | } |
349 | 349 | $this->sub_data = false; |
350 | 350 | break; |
351 | 351 | case 'wp:postmeta': |
352 | - if ( ! empty( $this->sub_data ) ) |
|
352 | + if (!empty($this->sub_data)) |
|
353 | 353 | $this->data['postmeta'][] = $this->sub_data; |
354 | 354 | $this->sub_data = false; |
355 | 355 | break; |
@@ -360,12 +360,12 @@ discard block |
||
360 | 360 | case 'wp:category': |
361 | 361 | case 'wp:tag': |
362 | 362 | case 'wp:term': |
363 | - $n = substr( $tag, 3 ); |
|
364 | - array_push( $this->$n, $this->data ); |
|
363 | + $n = substr($tag, 3); |
|
364 | + array_push($this->$n, $this->data); |
|
365 | 365 | $this->data = false; |
366 | 366 | break; |
367 | 367 | case 'wp:author': |
368 | - if ( ! empty($this->data['author_login']) ) |
|
368 | + if (!empty($this->data['author_login'])) |
|
369 | 369 | $this->authors[$this->data['author_login']] = $this->data; |
370 | 370 | $this->data = false; |
371 | 371 | break; |
@@ -377,11 +377,11 @@ discard block |
||
377 | 377 | break; |
378 | 378 | |
379 | 379 | default: |
380 | - if ( $this->in_sub_tag ) { |
|
381 | - $this->sub_data[$this->in_sub_tag] = ! empty( $this->cdata ) ? $this->cdata : ''; |
|
380 | + if ($this->in_sub_tag) { |
|
381 | + $this->sub_data[$this->in_sub_tag] = !empty($this->cdata) ? $this->cdata : ''; |
|
382 | 382 | $this->in_sub_tag = false; |
383 | - } else if ( $this->in_tag ) { |
|
384 | - $this->data[$this->in_tag] = ! empty( $this->cdata ) ? $this->cdata : ''; |
|
383 | + } else if ($this->in_tag) { |
|
384 | + $this->data[$this->in_tag] = !empty($this->cdata) ? $this->cdata : ''; |
|
385 | 385 | $this->in_tag = false; |
386 | 386 | } |
387 | 387 | } |
@@ -407,66 +407,66 @@ discard block |
||
407 | 407 | }*/ |
408 | 408 | |
409 | 409 | function __construct() { |
410 | - $this->has_gzip = is_callable( 'gzopen' ); |
|
410 | + $this->has_gzip = is_callable('gzopen'); |
|
411 | 411 | } |
412 | 412 | |
413 | - function parse( $file ) { |
|
413 | + function parse($file) { |
|
414 | 414 | $wxr_version = $in_post = false; |
415 | 415 | |
416 | - $fp = $this->fopen( $file, 'r' ); |
|
417 | - if ( $fp ) { |
|
418 | - while ( ! $this->feof( $fp ) ) { |
|
419 | - $importline = rtrim( $this->fgets( $fp ) ); |
|
416 | + $fp = $this->fopen($file, 'r'); |
|
417 | + if ($fp) { |
|
418 | + while (!$this->feof($fp)) { |
|
419 | + $importline = rtrim($this->fgets($fp)); |
|
420 | 420 | |
421 | - if ( ! $wxr_version && preg_match( '|<wp:wxr_version>(\d+\.\d+)</wp:wxr_version>|', $importline, $version ) ) |
|
421 | + if (!$wxr_version && preg_match('|<wp:wxr_version>(\d+\.\d+)</wp:wxr_version>|', $importline, $version)) |
|
422 | 422 | $wxr_version = $version[1]; |
423 | 423 | |
424 | - if ( false !== strpos( $importline, '<wp:base_site_url>' ) ) { |
|
425 | - preg_match( '|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url ); |
|
424 | + if (false !== strpos($importline, '<wp:base_site_url>')) { |
|
425 | + preg_match('|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url); |
|
426 | 426 | $this->base_url = $url[1]; |
427 | 427 | continue; |
428 | 428 | } |
429 | - if ( false !== strpos( $importline, '<wp:category>' ) ) { |
|
430 | - preg_match( '|<wp:category>(.*?)</wp:category>|is', $importline, $category ); |
|
431 | - $this->categories[] = $this->process_category( $category[1] ); |
|
429 | + if (false !== strpos($importline, '<wp:category>')) { |
|
430 | + preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category); |
|
431 | + $this->categories[] = $this->process_category($category[1]); |
|
432 | 432 | continue; |
433 | 433 | } |
434 | - if ( false !== strpos( $importline, '<wp:tag>' ) ) { |
|
435 | - preg_match( '|<wp:tag>(.*?)</wp:tag>|is', $importline, $tag ); |
|
436 | - $this->tags[] = $this->process_tag( $tag[1] ); |
|
434 | + if (false !== strpos($importline, '<wp:tag>')) { |
|
435 | + preg_match('|<wp:tag>(.*?)</wp:tag>|is', $importline, $tag); |
|
436 | + $this->tags[] = $this->process_tag($tag[1]); |
|
437 | 437 | continue; |
438 | 438 | } |
439 | - if ( false !== strpos( $importline, '<wp:term>' ) ) { |
|
440 | - preg_match( '|<wp:term>(.*?)</wp:term>|is', $importline, $term ); |
|
441 | - $this->terms[] = $this->process_term( $term[1] ); |
|
439 | + if (false !== strpos($importline, '<wp:term>')) { |
|
440 | + preg_match('|<wp:term>(.*?)</wp:term>|is', $importline, $term); |
|
441 | + $this->terms[] = $this->process_term($term[1]); |
|
442 | 442 | continue; |
443 | 443 | } |
444 | - if ( false !== strpos( $importline, '<wp:author>' ) ) { |
|
445 | - preg_match( '|<wp:author>(.*?)</wp:author>|is', $importline, $author ); |
|
446 | - $a = $this->process_author( $author[1] ); |
|
444 | + if (false !== strpos($importline, '<wp:author>')) { |
|
445 | + preg_match('|<wp:author>(.*?)</wp:author>|is', $importline, $author); |
|
446 | + $a = $this->process_author($author[1]); |
|
447 | 447 | $this->authors[$a['author_login']] = $a; |
448 | 448 | continue; |
449 | 449 | } |
450 | - if ( false !== strpos( $importline, '<item>' ) ) { |
|
450 | + if (false !== strpos($importline, '<item>')) { |
|
451 | 451 | $post = ''; |
452 | 452 | $in_post = true; |
453 | 453 | continue; |
454 | 454 | } |
455 | - if ( false !== strpos( $importline, '</item>' ) ) { |
|
455 | + if (false !== strpos($importline, '</item>')) { |
|
456 | 456 | $in_post = false; |
457 | - $this->posts[] = $this->process_post( $post ); |
|
457 | + $this->posts[] = $this->process_post($post); |
|
458 | 458 | continue; |
459 | 459 | } |
460 | - if ( $in_post ) { |
|
461 | - $post .= $importline . "\n"; |
|
460 | + if ($in_post) { |
|
461 | + $post .= $importline."\n"; |
|
462 | 462 | } |
463 | 463 | } |
464 | 464 | |
465 | 465 | $this->fclose($fp); |
466 | 466 | } |
467 | 467 | |
468 | - if ( ! $wxr_version ) |
|
469 | - return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
468 | + if (!$wxr_version) |
|
469 | + return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer')); |
|
470 | 470 | |
471 | 471 | return array( |
472 | 472 | 'authors' => $this->authors, |
@@ -479,17 +479,17 @@ discard block |
||
479 | 479 | ); |
480 | 480 | } |
481 | 481 | |
482 | - function get_tag( $string, $tag ) { |
|
483 | - preg_match( "|<$tag.*?>(.*?)</$tag>|is", $string, $return ); |
|
484 | - if ( isset( $return[1] ) ) { |
|
485 | - if ( substr( $return[1], 0, 9 ) == '<![CDATA[' ) { |
|
486 | - if ( strpos( $return[1], ']]]]><![CDATA[>' ) !== false ) { |
|
487 | - preg_match_all( '|<!\[CDATA\[(.*?)\]\]>|s', $return[1], $matches ); |
|
482 | + function get_tag($string, $tag) { |
|
483 | + preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return); |
|
484 | + if (isset($return[1])) { |
|
485 | + if (substr($return[1], 0, 9) == '<![CDATA[') { |
|
486 | + if (strpos($return[1], ']]]]><![CDATA[>') !== false) { |
|
487 | + preg_match_all('|<!\[CDATA\[(.*?)\]\]>|s', $return[1], $matches); |
|
488 | 488 | $return = ''; |
489 | - foreach( $matches[1] as $match ) |
|
489 | + foreach ($matches[1] as $match) |
|
490 | 490 | $return .= $match; |
491 | 491 | } else { |
492 | - $return = preg_replace( '|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1] ); |
|
492 | + $return = preg_replace('|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1]); |
|
493 | 493 | } |
494 | 494 | } else { |
495 | 495 | $return = $return[1]; |
@@ -500,166 +500,166 @@ discard block |
||
500 | 500 | return $return; |
501 | 501 | } |
502 | 502 | |
503 | - function process_category( $c ) { |
|
503 | + function process_category($c) { |
|
504 | 504 | return array( |
505 | - 'term_id' => $this->get_tag( $c, 'wp:term_id' ), |
|
506 | - 'cat_name' => $this->get_tag( $c, 'wp:cat_name' ), |
|
507 | - 'category_nicename' => $this->get_tag( $c, 'wp:category_nicename' ), |
|
508 | - 'category_parent' => $this->get_tag( $c, 'wp:category_parent' ), |
|
509 | - 'category_description' => $this->get_tag( $c, 'wp:category_description' ), |
|
505 | + 'term_id' => $this->get_tag($c, 'wp:term_id'), |
|
506 | + 'cat_name' => $this->get_tag($c, 'wp:cat_name'), |
|
507 | + 'category_nicename' => $this->get_tag($c, 'wp:category_nicename'), |
|
508 | + 'category_parent' => $this->get_tag($c, 'wp:category_parent'), |
|
509 | + 'category_description' => $this->get_tag($c, 'wp:category_description'), |
|
510 | 510 | ); |
511 | 511 | } |
512 | 512 | |
513 | - function process_tag( $t ) { |
|
513 | + function process_tag($t) { |
|
514 | 514 | return array( |
515 | - 'term_id' => $this->get_tag( $t, 'wp:term_id' ), |
|
516 | - 'tag_name' => $this->get_tag( $t, 'wp:tag_name' ), |
|
517 | - 'tag_slug' => $this->get_tag( $t, 'wp:tag_slug' ), |
|
518 | - 'tag_description' => $this->get_tag( $t, 'wp:tag_description' ), |
|
515 | + 'term_id' => $this->get_tag($t, 'wp:term_id'), |
|
516 | + 'tag_name' => $this->get_tag($t, 'wp:tag_name'), |
|
517 | + 'tag_slug' => $this->get_tag($t, 'wp:tag_slug'), |
|
518 | + 'tag_description' => $this->get_tag($t, 'wp:tag_description'), |
|
519 | 519 | ); |
520 | 520 | } |
521 | 521 | |
522 | - function process_term( $t ) { |
|
522 | + function process_term($t) { |
|
523 | 523 | return array( |
524 | - 'term_id' => $this->get_tag( $t, 'wp:term_id' ), |
|
525 | - 'term_taxonomy' => $this->get_tag( $t, 'wp:term_taxonomy' ), |
|
526 | - 'slug' => $this->get_tag( $t, 'wp:term_slug' ), |
|
527 | - 'term_parent' => $this->get_tag( $t, 'wp:term_parent' ), |
|
528 | - 'term_name' => $this->get_tag( $t, 'wp:term_name' ), |
|
529 | - 'term_description' => $this->get_tag( $t, 'wp:term_description' ), |
|
524 | + 'term_id' => $this->get_tag($t, 'wp:term_id'), |
|
525 | + 'term_taxonomy' => $this->get_tag($t, 'wp:term_taxonomy'), |
|
526 | + 'slug' => $this->get_tag($t, 'wp:term_slug'), |
|
527 | + 'term_parent' => $this->get_tag($t, 'wp:term_parent'), |
|
528 | + 'term_name' => $this->get_tag($t, 'wp:term_name'), |
|
529 | + 'term_description' => $this->get_tag($t, 'wp:term_description'), |
|
530 | 530 | ); |
531 | 531 | } |
532 | 532 | |
533 | - function process_author( $a ) { |
|
533 | + function process_author($a) { |
|
534 | 534 | return array( |
535 | - 'author_id' => $this->get_tag( $a, 'wp:author_id' ), |
|
536 | - 'author_login' => $this->get_tag( $a, 'wp:author_login' ), |
|
537 | - 'author_email' => $this->get_tag( $a, 'wp:author_email' ), |
|
538 | - 'author_display_name' => $this->get_tag( $a, 'wp:author_display_name' ), |
|
539 | - 'author_first_name' => $this->get_tag( $a, 'wp:author_first_name' ), |
|
540 | - 'author_last_name' => $this->get_tag( $a, 'wp:author_last_name' ), |
|
535 | + 'author_id' => $this->get_tag($a, 'wp:author_id'), |
|
536 | + 'author_login' => $this->get_tag($a, 'wp:author_login'), |
|
537 | + 'author_email' => $this->get_tag($a, 'wp:author_email'), |
|
538 | + 'author_display_name' => $this->get_tag($a, 'wp:author_display_name'), |
|
539 | + 'author_first_name' => $this->get_tag($a, 'wp:author_first_name'), |
|
540 | + 'author_last_name' => $this->get_tag($a, 'wp:author_last_name'), |
|
541 | 541 | ); |
542 | 542 | } |
543 | 543 | |
544 | - function process_post( $post ) { |
|
545 | - $post_id = $this->get_tag( $post, 'wp:post_id' ); |
|
546 | - $post_title = $this->get_tag( $post, 'title' ); |
|
547 | - $post_date = $this->get_tag( $post, 'wp:post_date' ); |
|
548 | - $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' ); |
|
549 | - $comment_status = $this->get_tag( $post, 'wp:comment_status' ); |
|
550 | - $ping_status = $this->get_tag( $post, 'wp:ping_status' ); |
|
551 | - $status = $this->get_tag( $post, 'wp:status' ); |
|
552 | - $post_name = $this->get_tag( $post, 'wp:post_name' ); |
|
553 | - $post_parent = $this->get_tag( $post, 'wp:post_parent' ); |
|
554 | - $menu_order = $this->get_tag( $post, 'wp:menu_order' ); |
|
555 | - $post_type = $this->get_tag( $post, 'wp:post_type' ); |
|
556 | - $post_password = $this->get_tag( $post, 'wp:post_password' ); |
|
557 | - $is_sticky = $this->get_tag( $post, 'wp:is_sticky' ); |
|
558 | - $guid = $this->get_tag( $post, 'guid' ); |
|
559 | - $post_author = $this->get_tag( $post, 'dc:creator' ); |
|
560 | - |
|
561 | - $post_excerpt = $this->get_tag( $post, 'excerpt:encoded' ); |
|
562 | - $post_excerpt = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_excerpt ); |
|
563 | - $post_excerpt = str_replace( '<br>', '<br />', $post_excerpt ); |
|
564 | - $post_excerpt = str_replace( '<hr>', '<hr />', $post_excerpt ); |
|
565 | - |
|
566 | - $post_content = $this->get_tag( $post, 'content:encoded' ); |
|
567 | - $post_content = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content ); |
|
568 | - $post_content = str_replace( '<br>', '<br />', $post_content ); |
|
569 | - $post_content = str_replace( '<hr>', '<hr />', $post_content ); |
|
570 | - |
|
571 | - $postdata = compact( 'post_id', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_excerpt', |
|
544 | + function process_post($post) { |
|
545 | + $post_id = $this->get_tag($post, 'wp:post_id'); |
|
546 | + $post_title = $this->get_tag($post, 'title'); |
|
547 | + $post_date = $this->get_tag($post, 'wp:post_date'); |
|
548 | + $post_date_gmt = $this->get_tag($post, 'wp:post_date_gmt'); |
|
549 | + $comment_status = $this->get_tag($post, 'wp:comment_status'); |
|
550 | + $ping_status = $this->get_tag($post, 'wp:ping_status'); |
|
551 | + $status = $this->get_tag($post, 'wp:status'); |
|
552 | + $post_name = $this->get_tag($post, 'wp:post_name'); |
|
553 | + $post_parent = $this->get_tag($post, 'wp:post_parent'); |
|
554 | + $menu_order = $this->get_tag($post, 'wp:menu_order'); |
|
555 | + $post_type = $this->get_tag($post, 'wp:post_type'); |
|
556 | + $post_password = $this->get_tag($post, 'wp:post_password'); |
|
557 | + $is_sticky = $this->get_tag($post, 'wp:is_sticky'); |
|
558 | + $guid = $this->get_tag($post, 'guid'); |
|
559 | + $post_author = $this->get_tag($post, 'dc:creator'); |
|
560 | + |
|
561 | + $post_excerpt = $this->get_tag($post, 'excerpt:encoded'); |
|
562 | + $post_excerpt = preg_replace_callback('|<(/?[A-Z]+)|', array(&$this, '_normalize_tag'), $post_excerpt); |
|
563 | + $post_excerpt = str_replace('<br>', '<br />', $post_excerpt); |
|
564 | + $post_excerpt = str_replace('<hr>', '<hr />', $post_excerpt); |
|
565 | + |
|
566 | + $post_content = $this->get_tag($post, 'content:encoded'); |
|
567 | + $post_content = preg_replace_callback('|<(/?[A-Z]+)|', array(&$this, '_normalize_tag'), $post_content); |
|
568 | + $post_content = str_replace('<br>', '<br />', $post_content); |
|
569 | + $post_content = str_replace('<hr>', '<hr />', $post_content); |
|
570 | + |
|
571 | + $postdata = compact('post_id', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_excerpt', |
|
572 | 572 | 'post_title', 'status', 'post_name', 'comment_status', 'ping_status', 'guid', 'post_parent', |
573 | 573 | 'menu_order', 'post_type', 'post_password', 'is_sticky' |
574 | 574 | ); |
575 | 575 | |
576 | - $attachment_url = $this->get_tag( $post, 'wp:attachment_url' ); |
|
577 | - if ( $attachment_url ) |
|
576 | + $attachment_url = $this->get_tag($post, 'wp:attachment_url'); |
|
577 | + if ($attachment_url) |
|
578 | 578 | $postdata['attachment_url'] = $attachment_url; |
579 | 579 | |
580 | - preg_match_all( '|<category domain="([^"]+?)" nicename="([^"]+?)">(.+?)</category>|is', $post, $terms, PREG_SET_ORDER ); |
|
581 | - foreach ( $terms as $t ) { |
|
580 | + preg_match_all('|<category domain="([^"]+?)" nicename="([^"]+?)">(.+?)</category>|is', $post, $terms, PREG_SET_ORDER); |
|
581 | + foreach ($terms as $t) { |
|
582 | 582 | $post_terms[] = array( |
583 | 583 | 'slug' => $t[2], |
584 | 584 | 'domain' => $t[1], |
585 | - 'name' => str_replace( array( '<![CDATA[', ']]>' ), '', $t[3] ), |
|
585 | + 'name' => str_replace(array('<![CDATA[', ']]>'), '', $t[3]), |
|
586 | 586 | ); |
587 | 587 | } |
588 | - if ( ! empty( $post_terms ) ) $postdata['terms'] = $post_terms; |
|
588 | + if (!empty($post_terms)) $postdata['terms'] = $post_terms; |
|
589 | 589 | |
590 | - preg_match_all( '|<wp:comment>(.+?)</wp:comment>|is', $post, $comments ); |
|
590 | + preg_match_all('|<wp:comment>(.+?)</wp:comment>|is', $post, $comments); |
|
591 | 591 | $comments = $comments[1]; |
592 | - if ( $comments ) { |
|
593 | - foreach ( $comments as $comment ) { |
|
594 | - preg_match_all( '|<wp:commentmeta>(.+?)</wp:commentmeta>|is', $comment, $commentmeta ); |
|
592 | + if ($comments) { |
|
593 | + foreach ($comments as $comment) { |
|
594 | + preg_match_all('|<wp:commentmeta>(.+?)</wp:commentmeta>|is', $comment, $commentmeta); |
|
595 | 595 | $commentmeta = $commentmeta[1]; |
596 | 596 | $c_meta = array(); |
597 | - foreach ( $commentmeta as $m ) { |
|
597 | + foreach ($commentmeta as $m) { |
|
598 | 598 | $c_meta[] = array( |
599 | - 'key' => $this->get_tag( $m, 'wp:meta_key' ), |
|
600 | - 'value' => $this->get_tag( $m, 'wp:meta_value' ), |
|
599 | + 'key' => $this->get_tag($m, 'wp:meta_key'), |
|
600 | + 'value' => $this->get_tag($m, 'wp:meta_value'), |
|
601 | 601 | ); |
602 | 602 | } |
603 | 603 | |
604 | 604 | $post_comments[] = array( |
605 | - 'comment_id' => $this->get_tag( $comment, 'wp:comment_id' ), |
|
606 | - 'comment_author' => $this->get_tag( $comment, 'wp:comment_author' ), |
|
607 | - 'comment_author_email' => $this->get_tag( $comment, 'wp:comment_author_email' ), |
|
608 | - 'comment_author_IP' => $this->get_tag( $comment, 'wp:comment_author_IP' ), |
|
609 | - 'comment_author_url' => $this->get_tag( $comment, 'wp:comment_author_url' ), |
|
610 | - 'comment_date' => $this->get_tag( $comment, 'wp:comment_date' ), |
|
611 | - 'comment_date_gmt' => $this->get_tag( $comment, 'wp:comment_date_gmt' ), |
|
612 | - 'comment_content' => $this->get_tag( $comment, 'wp:comment_content' ), |
|
613 | - 'comment_approved' => $this->get_tag( $comment, 'wp:comment_approved' ), |
|
614 | - 'comment_type' => $this->get_tag( $comment, 'wp:comment_type' ), |
|
615 | - 'comment_parent' => $this->get_tag( $comment, 'wp:comment_parent' ), |
|
616 | - 'comment_user_id' => $this->get_tag( $comment, 'wp:comment_user_id' ), |
|
605 | + 'comment_id' => $this->get_tag($comment, 'wp:comment_id'), |
|
606 | + 'comment_author' => $this->get_tag($comment, 'wp:comment_author'), |
|
607 | + 'comment_author_email' => $this->get_tag($comment, 'wp:comment_author_email'), |
|
608 | + 'comment_author_IP' => $this->get_tag($comment, 'wp:comment_author_IP'), |
|
609 | + 'comment_author_url' => $this->get_tag($comment, 'wp:comment_author_url'), |
|
610 | + 'comment_date' => $this->get_tag($comment, 'wp:comment_date'), |
|
611 | + 'comment_date_gmt' => $this->get_tag($comment, 'wp:comment_date_gmt'), |
|
612 | + 'comment_content' => $this->get_tag($comment, 'wp:comment_content'), |
|
613 | + 'comment_approved' => $this->get_tag($comment, 'wp:comment_approved'), |
|
614 | + 'comment_type' => $this->get_tag($comment, 'wp:comment_type'), |
|
615 | + 'comment_parent' => $this->get_tag($comment, 'wp:comment_parent'), |
|
616 | + 'comment_user_id' => $this->get_tag($comment, 'wp:comment_user_id'), |
|
617 | 617 | 'commentmeta' => $c_meta, |
618 | 618 | ); |
619 | 619 | } |
620 | 620 | } |
621 | - if ( ! empty( $post_comments ) ) $postdata['comments'] = $post_comments; |
|
621 | + if (!empty($post_comments)) $postdata['comments'] = $post_comments; |
|
622 | 622 | |
623 | - preg_match_all( '|<wp:postmeta>(.+?)</wp:postmeta>|is', $post, $postmeta ); |
|
623 | + preg_match_all('|<wp:postmeta>(.+?)</wp:postmeta>|is', $post, $postmeta); |
|
624 | 624 | $postmeta = $postmeta[1]; |
625 | - if ( $postmeta ) { |
|
626 | - foreach ( $postmeta as $p ) { |
|
625 | + if ($postmeta) { |
|
626 | + foreach ($postmeta as $p) { |
|
627 | 627 | $post_postmeta[] = array( |
628 | - 'key' => $this->get_tag( $p, 'wp:meta_key' ), |
|
629 | - 'value' => $this->get_tag( $p, 'wp:meta_value' ), |
|
628 | + 'key' => $this->get_tag($p, 'wp:meta_key'), |
|
629 | + 'value' => $this->get_tag($p, 'wp:meta_value'), |
|
630 | 630 | ); |
631 | 631 | } |
632 | 632 | } |
633 | - if ( ! empty( $post_postmeta ) ) $postdata['postmeta'] = $post_postmeta; |
|
633 | + if (!empty($post_postmeta)) $postdata['postmeta'] = $post_postmeta; |
|
634 | 634 | |
635 | 635 | return $postdata; |
636 | 636 | } |
637 | 637 | |
638 | - function _normalize_tag( $matches ) { |
|
639 | - return '<' . strtolower( $matches[1] ); |
|
638 | + function _normalize_tag($matches) { |
|
639 | + return '<'.strtolower($matches[1]); |
|
640 | 640 | } |
641 | 641 | |
642 | - function fopen( $filename, $mode = 'r' ) { |
|
643 | - if ( $this->has_gzip ) |
|
644 | - return gzopen( $filename, $mode ); |
|
645 | - return fopen( $filename, $mode ); |
|
642 | + function fopen($filename, $mode = 'r') { |
|
643 | + if ($this->has_gzip) |
|
644 | + return gzopen($filename, $mode); |
|
645 | + return fopen($filename, $mode); |
|
646 | 646 | } |
647 | 647 | |
648 | - function feof( $fp ) { |
|
649 | - if ( $this->has_gzip ) |
|
650 | - return gzeof( $fp ); |
|
651 | - return feof( $fp ); |
|
648 | + function feof($fp) { |
|
649 | + if ($this->has_gzip) |
|
650 | + return gzeof($fp); |
|
651 | + return feof($fp); |
|
652 | 652 | } |
653 | 653 | |
654 | - function fgets( $fp, $len = 8192 ) { |
|
655 | - if ( $this->has_gzip ) |
|
656 | - return gzgets( $fp, $len ); |
|
657 | - return fgets( $fp, $len ); |
|
654 | + function fgets($fp, $len = 8192) { |
|
655 | + if ($this->has_gzip) |
|
656 | + return gzgets($fp, $len); |
|
657 | + return fgets($fp, $len); |
|
658 | 658 | } |
659 | 659 | |
660 | - function fclose( $fp ) { |
|
661 | - if ( $this->has_gzip ) |
|
662 | - return gzclose( $fp ); |
|
663 | - return fclose( $fp ); |
|
660 | + function fclose($fp) { |
|
661 | + if ($this->has_gzip) |
|
662 | + return gzclose($fp); |
|
663 | + return fclose($fp); |
|
664 | 664 | } |
665 | 665 | } |