@@ -30,29 +30,29 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | $label = ''; |
| 32 | 32 | |
| 33 | - if( !empty( $field['show_label'] ) || $force_show_label ) { |
|
| 33 | + if ( ! empty( $field[ 'show_label' ] ) || $force_show_label ) { |
|
| 34 | 34 | |
| 35 | - $label = $field['label']; |
|
| 35 | + $label = $field[ 'label' ]; |
|
| 36 | 36 | |
| 37 | 37 | // Support Gravity Forms 1.9+ |
| 38 | - if( class_exists( 'GF_Field' ) ) { |
|
| 38 | + if ( class_exists( 'GF_Field' ) ) { |
|
| 39 | 39 | |
| 40 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
| 40 | + $field_object = RGFormsModel::get_field( $form, $field[ 'id' ] ); |
|
| 41 | 41 | |
| 42 | - if( $field_object ) { |
|
| 42 | + if ( $field_object ) { |
|
| 43 | 43 | |
| 44 | - $input = GFFormsModel::get_input( $field_object, $field['id'] ); |
|
| 44 | + $input = GFFormsModel::get_input( $field_object, $field[ 'id' ] ); |
|
| 45 | 45 | |
| 46 | 46 | // This is a complex field, with labels on a per-input basis |
| 47 | - if( $input ) { |
|
| 47 | + if ( $input ) { |
|
| 48 | 48 | |
| 49 | 49 | // Does the input have a custom label on a per-input basis? Otherwise, default label. |
| 50 | - $label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label']; |
|
| 50 | + $label = ! empty( $input[ 'customLabel' ] ) ? $input[ 'customLabel' ] : $input[ 'label' ]; |
|
| 51 | 51 | |
| 52 | 52 | } else { |
| 53 | 53 | |
| 54 | 54 | // This is a field with one label |
| 55 | - $label = $field_object->get_field_label( true, $field['label'] ); |
|
| 55 | + $label = $field_object->get_field_label( true, $field[ 'label' ] ); |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
| 64 | - if ( !empty( $field['custom_label'] ) ) { |
|
| 64 | + if ( ! empty( $field[ 'custom_label' ] ) ) { |
|
| 65 | 65 | |
| 66 | - $label = self::replace_variables( $field['custom_label'], $form, $entry ); |
|
| 66 | + $label = self::replace_variables( $field[ 'custom_label' ], $form, $entry ); |
|
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | $width = NULL; |
| 119 | 119 | |
| 120 | - if( !empty( $field['width'] ) ) { |
|
| 121 | - $width = absint( $field['width'] ); |
|
| 120 | + if ( ! empty( $field[ 'width' ] ) ) { |
|
| 121 | + $width = absint( $field[ 'width' ] ); |
|
| 122 | 122 | |
| 123 | 123 | // If using percentages, limit to 100% |
| 124 | - if( '%d%%' === $format && $width > 100 ) { |
|
| 124 | + if ( '%d%%' === $format && $width > 100 ) { |
|
| 125 | 125 | $width = 100; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -144,39 +144,39 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $classes = array(); |
| 146 | 146 | |
| 147 | - if( !empty( $field['custom_class'] ) ) { |
|
| 147 | + if ( ! empty( $field[ 'custom_class' ] ) ) { |
|
| 148 | 148 | |
| 149 | - $custom_class = $field['custom_class']; |
|
| 149 | + $custom_class = $field[ 'custom_class' ]; |
|
| 150 | 150 | |
| 151 | - if( !empty( $entry ) ) { |
|
| 151 | + if ( ! empty( $entry ) ) { |
|
| 152 | 152 | |
| 153 | 153 | // We want the merge tag to be formatted as a class. The merge tag may be |
| 154 | 154 | // replaced by a multiple-word value that should be output as a single class. |
| 155 | 155 | // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
| 156 | - add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 156 | + add_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
| 157 | 157 | |
| 158 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
| 158 | + $custom_class = self::replace_variables( $custom_class, $form, $entry ); |
|
| 159 | 159 | |
| 160 | 160 | // And then we want life to return to normal |
| 161 | - remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 161 | + remove_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // And now we want the spaces to be handled nicely. |
| 165 | - $classes[] = gravityview_sanitize_html_class( $custom_class ); |
|
| 165 | + $classes[ ] = gravityview_sanitize_html_class( $custom_class ); |
|
| 166 | 166 | |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if(!empty($field['id'])) { |
|
| 170 | - if( !empty( $form ) && !empty( $form['id'] ) ) { |
|
| 171 | - $form_id = '-'.$form['id']; |
|
| 169 | + if ( ! empty( $field[ 'id' ] ) ) { |
|
| 170 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
| 171 | + $form_id = '-' . $form[ 'id' ]; |
|
| 172 | 172 | } else { |
| 173 | - $form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : ''; |
|
| 173 | + $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $classes[] = 'gv-field'.$form_id.'-'.$field['id']; |
|
| 176 | + $classes[ ] = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - return esc_attr(implode(' ', $classes)); |
|
| 179 | + return esc_attr( implode( ' ', $classes ) ); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -193,16 +193,16 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public static function field_html_attr_id( $field, $form = array(), $entry = array() ) { |
| 195 | 195 | $gravityview_view = GravityView_View::getInstance(); |
| 196 | - $id = $field['id']; |
|
| 196 | + $id = $field[ 'id' ]; |
|
| 197 | 197 | |
| 198 | 198 | if ( ! empty( $id ) ) { |
| 199 | - if ( ! empty( $form ) && ! empty( $form['id'] ) ) { |
|
| 200 | - $form_id = '-' . $form['id']; |
|
| 199 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
| 200 | + $form_id = '-' . $form[ 'id' ]; |
|
| 201 | 201 | } else { |
| 202 | 202 | $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - $id = 'gv-field' . $form_id . '-' . $field['id']; |
|
| 205 | + $id = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | return esc_attr( $id ); |
@@ -219,13 +219,13 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public static function field_value( $entry, $field_settings, $format = 'html' ) { |
| 221 | 221 | |
| 222 | - if( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) { |
|
| 222 | + if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) { |
|
| 223 | 223 | return NULL; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | $gravityview_view = GravityView_View::getInstance(); |
| 227 | 227 | |
| 228 | - if( class_exists( 'GFCache' ) ) { |
|
| 228 | + if ( class_exists( 'GFCache' ) ) { |
|
| 229 | 229 | /** |
| 230 | 230 | * Gravity Forms' GFCache function was thrashing the database, causing double the amount of time for the field_value() method to run. |
| 231 | 231 | * |
@@ -240,46 +240,46 @@ discard block |
||
| 240 | 240 | * @param boolean false Tell Gravity Forms not to store this as a transient |
| 241 | 241 | * @param int 0 Time to store the value. 0 is maximum amount of time possible. |
| 242 | 242 | */ |
| 243 | - GFCache::set( "GFFormsModel::get_lead_field_value_" . $entry["id"] . "_" . $field_settings["id"], false, false, 0 ); |
|
| 243 | + GFCache::set( "GFFormsModel::get_lead_field_value_" . $entry[ "id" ] . "_" . $field_settings[ "id" ], false, false, 0 ); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $field_id = $field_settings['id']; |
|
| 246 | + $field_id = $field_settings[ 'id' ]; |
|
| 247 | 247 | |
| 248 | 248 | $form = $gravityview_view->getForm(); |
| 249 | 249 | |
| 250 | 250 | $field = gravityview_get_field( $form, $field_id ); |
| 251 | 251 | |
| 252 | - $field_type = RGFormsModel::get_input_type($field); |
|
| 252 | + $field_type = RGFormsModel::get_input_type( $field ); |
|
| 253 | 253 | |
| 254 | - if( $field_type ) { |
|
| 255 | - $field_type = $field['type']; |
|
| 256 | - $value = RGFormsModel::get_lead_field_value($entry, $field); |
|
| 254 | + if ( $field_type ) { |
|
| 255 | + $field_type = $field[ 'type' ]; |
|
| 256 | + $value = RGFormsModel::get_lead_field_value( $entry, $field ); |
|
| 257 | 257 | } else { |
| 258 | 258 | // For non-integer field types (`id`, `date_created`, etc.) |
| 259 | 259 | $field_type = $field_id; |
| 260 | - $field['type'] = $field_id; |
|
| 261 | - $value = isset($entry[$field_type]) ? $entry[$field_type] : NULL; |
|
| 260 | + $field[ 'type' ] = $field_id; |
|
| 261 | + $value = isset( $entry[ $field_type ] ) ? $entry[ $field_type ] : NULL; |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | // Prevent any PHP warnings that may be generated |
| 265 | 265 | ob_start(); |
| 266 | 266 | |
| 267 | - $display_value = GFCommon::get_lead_field_display($field, $value, $entry["currency"], false, $format); |
|
| 267 | + $display_value = GFCommon::get_lead_field_display( $field, $value, $entry[ "currency" ], false, $format ); |
|
| 268 | 268 | |
| 269 | - if( $errors = ob_get_clean() ) { |
|
| 269 | + if ( $errors = ob_get_clean() ) { |
|
| 270 | 270 | do_action( 'gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors ); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $entry, $form); |
|
| 273 | + $display_value = apply_filters( "gform_entry_field_value", $display_value, $field, $entry, $form ); |
|
| 274 | 274 | |
| 275 | 275 | // prevent the use of merge_tags for non-admin fields |
| 276 | - if( !empty( $field['adminOnly'] ) ) { |
|
| 276 | + if ( ! empty( $field[ 'adminOnly' ] ) ) { |
|
| 277 | 277 | $display_value = self::replace_variables( $display_value, $form, $entry ); |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // Check whether the field exists in /includes/fields/{$field_type}.php |
| 281 | 281 | // This can be overridden by user template files. |
| 282 | - $field_path = $gravityview_view->locate_template("fields/{$field_type}.php"); |
|
| 282 | + $field_path = $gravityview_view->locate_template( "fields/{$field_type}.php" ); |
|
| 283 | 283 | |
| 284 | 284 | // Set the field data to be available in the templates |
| 285 | 285 | $gravityview_view->setCurrentField( array( |
@@ -293,11 +293,11 @@ discard block |
||
| 293 | 293 | 'entry' => $entry, |
| 294 | 294 | 'field_type' => $field_type, /** {@since 1.6} */ |
| 295 | 295 | 'field_path' => $field_path, /** {@since 1.16} */ |
| 296 | - )); |
|
| 296 | + ) ); |
|
| 297 | 297 | |
| 298 | - if( ! empty( $field_path ) ) { |
|
| 298 | + if ( ! empty( $field_path ) ) { |
|
| 299 | 299 | |
| 300 | - do_action( 'gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path ) ); |
|
| 300 | + do_action( 'gravityview_log_debug', sprintf( '[field_value] Rendering %s', $field_path ) ); |
|
| 301 | 301 | |
| 302 | 302 | ob_start(); |
| 303 | 303 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $field_settings = $gravityview_view->getCurrentField('field_settings'); |
|
| 315 | + $field_settings = $gravityview_view->getCurrentField( 'field_settings' ); |
|
| 316 | 316 | |
| 317 | 317 | /** |
| 318 | 318 | * @filter `gravityview_field_entry_value_{$field_type}_pre_link` Modify the field value output for a field type before Show As Link setting is applied. Example: `gravityview_field_entry_value_number_pre_link` |
@@ -330,9 +330,9 @@ discard block |
||
| 330 | 330 | * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example. |
| 331 | 331 | * |
| 332 | 332 | */ |
| 333 | - if( !empty( $field_settings['show_as_link'] ) && ! gv_empty( $output, false, false ) ) { |
|
| 333 | + if ( ! empty( $field_settings[ 'show_as_link' ] ) && ! gv_empty( $output, false, false ) ) { |
|
| 334 | 334 | |
| 335 | - $link_atts = empty( $field_settings['new_window'] ) ? array() : array( 'target' => '_blank' ); |
|
| 335 | + $link_atts = empty( $field_settings[ 'new_window' ] ) ? array() : array( 'target' => '_blank' ); |
|
| 336 | 336 | |
| 337 | 337 | $output = self::entry_link_html( $entry, $output, $link_atts, $field_settings ); |
| 338 | 338 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | * @param array $field_settings Settings for the particular GV field |
| 347 | 347 | * @param array $field Current field being displayed |
| 348 | 348 | */ |
| 349 | - $output = apply_filters( 'gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
| 349 | + $output = apply_filters( 'gravityview_field_entry_value_' . $field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * @filter `gravityview_field_entry_value` Modify the field value output for all field types |
@@ -375,14 +375,14 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array() ) { |
| 377 | 377 | |
| 378 | - if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) { |
|
| 378 | + if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry[ 'id' ] ) ) { |
|
| 379 | 379 | do_action( 'gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry ); |
| 380 | 380 | return NULL; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | $href = self::entry_link( $entry ); |
| 384 | 384 | |
| 385 | - if( '' === $href ) { |
|
| 385 | + if ( '' === $href ) { |
|
| 386 | 386 | return NULL; |
| 387 | 387 | } |
| 388 | 388 | |
@@ -405,19 +405,19 @@ discard block |
||
| 405 | 405 | * @param boolean $wpautop Apply wpautop() to the output? |
| 406 | 406 | * @return string HTML of "no results" text |
| 407 | 407 | */ |
| 408 | - public static function no_results($wpautop = true) { |
|
| 408 | + public static function no_results( $wpautop = true ) { |
|
| 409 | 409 | $gravityview_view = GravityView_View::getInstance(); |
| 410 | 410 | |
| 411 | 411 | $is_search = false; |
| 412 | 412 | |
| 413 | - if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
| 413 | + if ( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
| 414 | 414 | $is_search = true; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - if($is_search) { |
|
| 418 | - $output = __('This search returned no results.', 'gravityview'); |
|
| 417 | + if ( $is_search ) { |
|
| 418 | + $output = __( 'This search returned no results.', 'gravityview' ); |
|
| 419 | 419 | } else { |
| 420 | - $output = __('No entries match your request.', 'gravityview'); |
|
| 420 | + $output = __( 'No entries match your request.', 'gravityview' ); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | /** |
@@ -425,9 +425,9 @@ discard block |
||
| 425 | 425 | * @param string $output The existing "No Entries" text |
| 426 | 426 | * @param boolean $is_search Is the current page a search result, or just a multiple entries screen? |
| 427 | 427 | */ |
| 428 | - $output = apply_filters( 'gravitview_no_entries_text', $output, $is_search); |
|
| 428 | + $output = apply_filters( 'gravitview_no_entries_text', $output, $is_search ); |
|
| 429 | 429 | |
| 430 | - return $wpautop ? wpautop($output) : $output; |
|
| 430 | + return $wpautop ? wpautop( $output ) : $output; |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -444,37 +444,37 @@ discard block |
||
| 444 | 444 | |
| 445 | 445 | $gravityview_view = GravityView_View::getInstance(); |
| 446 | 446 | |
| 447 | - if( empty( $post_id ) ) { |
|
| 447 | + if ( empty( $post_id ) ) { |
|
| 448 | 448 | |
| 449 | 449 | $post_id = false; |
| 450 | 450 | |
| 451 | 451 | // DataTables passes the Post ID |
| 452 | - if( defined('DOING_AJAX') && DOING_AJAX ) { |
|
| 452 | + if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 453 | 453 | |
| 454 | - $post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : false; |
|
| 454 | + $post_id = isset( $_POST[ 'post_id' ] ) ? (int)$_POST[ 'post_id' ] : false; |
|
| 455 | 455 | |
| 456 | 456 | } else { |
| 457 | 457 | |
| 458 | 458 | // The Post ID has been passed via the shortcode |
| 459 | - if( !empty( $gravityview_view ) && $gravityview_view->getPostId() ) { |
|
| 459 | + if ( ! empty( $gravityview_view ) && $gravityview_view->getPostId() ) { |
|
| 460 | 460 | |
| 461 | 461 | $post_id = $gravityview_view->getPostId(); |
| 462 | 462 | |
| 463 | 463 | } else { |
| 464 | 464 | |
| 465 | 465 | // This is a GravityView post type |
| 466 | - if( GravityView_frontend::getInstance()->isGravityviewPostType() ) { |
|
| 466 | + if ( GravityView_frontend::getInstance()->isGravityviewPostType() ) { |
|
| 467 | 467 | |
| 468 | 468 | $post_id = isset( $gravityview_view ) ? $gravityview_view->getViewId() : $post->ID; |
| 469 | 469 | |
| 470 | 470 | } else { |
| 471 | 471 | |
| 472 | 472 | // This is an embedded GravityView; use the embedded post's ID as the base. |
| 473 | - if( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) { |
|
| 473 | + if ( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) { |
|
| 474 | 474 | |
| 475 | 475 | $post_id = $post->ID; |
| 476 | 476 | |
| 477 | - } elseif( $gravityview_view->getViewId() ) { |
|
| 477 | + } elseif ( $gravityview_view->getViewId() ) { |
|
| 478 | 478 | |
| 479 | 479 | // The GravityView has been embedded in a widget or in a template, and |
| 480 | 480 | // is not in the current content. Thus, we defer to the View's own ID. |
@@ -489,36 +489,36 @@ discard block |
||
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | // No post ID, get outta here. |
| 492 | - if( empty( $post_id ) ) { |
|
| 492 | + if ( empty( $post_id ) ) { |
|
| 493 | 493 | return NULL; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | // If we've saved the permalink in memory, use it |
| 497 | 497 | // @since 1.3 |
| 498 | - $link = wp_cache_get( 'gv_directory_link_'.$post_id ); |
|
| 498 | + $link = wp_cache_get( 'gv_directory_link_' . $post_id ); |
|
| 499 | 499 | |
| 500 | - if( empty( $link ) ) { |
|
| 500 | + if ( empty( $link ) ) { |
|
| 501 | 501 | |
| 502 | 502 | $link = get_permalink( $post_id ); |
| 503 | 503 | |
| 504 | 504 | // If not yet saved, cache the permalink. |
| 505 | 505 | // @since 1.3 |
| 506 | - wp_cache_set( 'gv_directory_link_'.$post_id, $link ); |
|
| 506 | + wp_cache_set( 'gv_directory_link_' . $post_id, $link ); |
|
| 507 | 507 | |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | // Deal with returning to proper pagination for embedded views |
| 511 | - if( $link && $add_query_args ) { |
|
| 511 | + if ( $link && $add_query_args ) { |
|
| 512 | 512 | |
| 513 | 513 | $args = array(); |
| 514 | 514 | |
| 515 | - if( $pagenum = rgget('pagenum') ) { |
|
| 516 | - $args['pagenum'] = intval( $pagenum ); |
|
| 515 | + if ( $pagenum = rgget( 'pagenum' ) ) { |
|
| 516 | + $args[ 'pagenum' ] = intval( $pagenum ); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - if( $sort = rgget('sort') ) { |
|
| 520 | - $args['sort'] = $sort; |
|
| 521 | - $args['dir'] = rgget('dir'); |
|
| 519 | + if ( $sort = rgget( 'sort' ) ) { |
|
| 520 | + $args[ 'sort' ] = $sort; |
|
| 521 | + $args[ 'dir' ] = rgget( 'dir' ); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | $link = add_query_arg( $args, $link ); |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | private static function get_custom_entry_slug( $id, $entry = array() ) { |
| 542 | 542 | |
| 543 | 543 | // Generate an unique hash to use as the default value |
| 544 | - $slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 ); |
|
| 544 | + $slug = substr( wp_hash( $id, 'gravityview' . $id ), 0, 8 ); |
|
| 545 | 545 | |
| 546 | 546 | /** |
| 547 | 547 | * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}` |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | $slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry ); |
| 553 | 553 | |
| 554 | 554 | // Make sure we have something - use the original ID as backup. |
| 555 | - if( empty( $slug ) ) { |
|
| 555 | + if ( empty( $slug ) ) { |
|
| 556 | 556 | $slug = $id; |
| 557 | 557 | } |
| 558 | 558 | |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
| 582 | 582 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
| 583 | 583 | */ |
| 584 | - $custom = apply_filters('gravityview_custom_entry_slug', false ); |
|
| 584 | + $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
| 585 | 585 | |
| 586 | 586 | // If we're using custom slug... |
| 587 | 587 | if ( $custom ) { |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | // If it does have a hash set, and the hash is expected, use it. |
| 596 | 596 | // This check allows users to change the hash structure using the |
| 597 | 597 | // gravityview_entry_hash filter and have the old hashes expire. |
| 598 | - if( empty( $value ) || $value !== $hash ) { |
|
| 598 | + if ( empty( $value ) || $value !== $hash ) { |
|
| 599 | 599 | |
| 600 | 600 | gform_update_meta( $id_or_string, 'gravityview_unique_id', $hash ); |
| 601 | 601 | |
@@ -623,12 +623,12 @@ discard block |
||
| 623 | 623 | * @param boolean $custom Should we process the custom entry slug? |
| 624 | 624 | */ |
| 625 | 625 | $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
| 626 | - if( $custom ) { |
|
| 626 | + if ( $custom ) { |
|
| 627 | 627 | // create the gravityview_unique_id and save it |
| 628 | 628 | |
| 629 | 629 | // Get the entry hash |
| 630 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
| 631 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash ); |
|
| 630 | + $hash = self::get_custom_entry_slug( $entry[ 'id' ], $entry ); |
|
| 631 | + gform_update_meta( $entry[ 'id' ], 'gravityview_unique_id', $hash ); |
|
| 632 | 632 | |
| 633 | 633 | } |
| 634 | 634 | } |
@@ -645,14 +645,14 @@ discard block |
||
| 645 | 645 | */ |
| 646 | 646 | public static function entry_link( $entry, $post_id = NULL, $add_directory_args = true ) { |
| 647 | 647 | |
| 648 | - if( ! empty( $entry ) && ! is_array( $entry ) ) { |
|
| 648 | + if ( ! empty( $entry ) && ! is_array( $entry ) ) { |
|
| 649 | 649 | $entry = GVCommon::get_entry( $entry ); |
| 650 | - } else if( empty( $entry ) ) { |
|
| 650 | + } else if ( empty( $entry ) ) { |
|
| 651 | 651 | $entry = GravityView_frontend::getInstance()->getEntry(); |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | // Second parameter used to be passed as $field; this makes sure it's not an array |
| 655 | - if( !is_numeric( $post_id ) ) { |
|
| 655 | + if ( ! is_numeric( $post_id ) ) { |
|
| 656 | 656 | $post_id = NULL; |
| 657 | 657 | } |
| 658 | 658 | |
@@ -660,19 +660,19 @@ discard block |
||
| 660 | 660 | $directory_link = self::directory_link( $post_id, false ); |
| 661 | 661 | |
| 662 | 662 | // No post ID? Get outta here. |
| 663 | - if( empty( $directory_link ) ) { |
|
| 663 | + if ( empty( $directory_link ) ) { |
|
| 664 | 664 | return ''; |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | $query_arg_name = GravityView_Post_Types::get_entry_var_name(); |
| 668 | 668 | |
| 669 | - $entry_slug = self::get_entry_slug( $entry['id'], $entry ); |
|
| 669 | + $entry_slug = self::get_entry_slug( $entry[ 'id' ], $entry ); |
|
| 670 | 670 | |
| 671 | - if( get_option('permalink_structure') && !is_preview() ) { |
|
| 671 | + if ( get_option( 'permalink_structure' ) && ! is_preview() ) { |
|
| 672 | 672 | |
| 673 | 673 | $args = array(); |
| 674 | 674 | |
| 675 | - $directory_link = trailingslashit( $directory_link ) . $query_arg_name . '/'. $entry_slug .'/'; |
|
| 675 | + $directory_link = trailingslashit( $directory_link ) . $query_arg_name . '/' . $entry_slug . '/'; |
|
| 676 | 676 | |
| 677 | 677 | } else { |
| 678 | 678 | |
@@ -682,18 +682,18 @@ discard block |
||
| 682 | 682 | /** |
| 683 | 683 | * @since 1.7.3 |
| 684 | 684 | */ |
| 685 | - if( $add_directory_args ) { |
|
| 685 | + if ( $add_directory_args ) { |
|
| 686 | 686 | |
| 687 | - if( !empty( $_GET['pagenum'] ) ) { |
|
| 688 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
| 687 | + if ( ! empty( $_GET[ 'pagenum' ] ) ) { |
|
| 688 | + $args[ 'pagenum' ] = intval( $_GET[ 'pagenum' ] ); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | /** |
| 692 | 692 | * @since 1.7 |
| 693 | 693 | */ |
| 694 | - if( $sort = rgget('sort') ) { |
|
| 695 | - $args['sort'] = $sort; |
|
| 696 | - $args['dir'] = rgget('dir'); |
|
| 694 | + if ( $sort = rgget( 'sort' ) ) { |
|
| 695 | + $args[ 'sort' ] = $sort; |
|
| 696 | + $args[ 'dir' ] = rgget( 'dir' ); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | } |
@@ -703,8 +703,8 @@ discard block |
||
| 703 | 703 | * has the view id so that Advanced Filters can be applied correctly when rendering the single view |
| 704 | 704 | * @see GravityView_frontend::get_context_view_id() |
| 705 | 705 | */ |
| 706 | - if( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
|
| 707 | - $args['gvid'] = gravityview_get_view_id(); |
|
| 706 | + if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
|
| 707 | + $args[ 'gvid' ] = gravityview_get_view_id(); |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | return add_query_arg( $args, $directory_link ); |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | function gv_class( $field, $form = NULL, $entry = array() ) { |
| 725 | - return GravityView_API::field_class( $field, $form, $entry ); |
|
| 725 | + return GravityView_API::field_class( $field, $form, $entry ); |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | /** |
@@ -744,11 +744,11 @@ discard block |
||
| 744 | 744 | |
| 745 | 745 | $default_css_class = ! empty( $view_id ) ? sprintf( 'gv-container gv-container-%d', $view_id ) : 'gv-container'; |
| 746 | 746 | |
| 747 | - if( GravityView_View::getInstance()->isHideUntilSearched() ) { |
|
| 747 | + if ( GravityView_View::getInstance()->isHideUntilSearched() ) { |
|
| 748 | 748 | $default_css_class .= ' hidden'; |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | - $css_class = trim( $passed_css_class . ' '. $default_css_class ); |
|
| 751 | + $css_class = trim( $passed_css_class . ' ' . $default_css_class ); |
|
| 752 | 752 | |
| 753 | 753 | /** |
| 754 | 754 | * @filter `gravityview/render/container/class` Modify the CSS class to be added to the wrapper <div> of a View |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | |
| 760 | 760 | $css_class = gravityview_sanitize_html_class( $css_class ); |
| 761 | 761 | |
| 762 | - if( $echo ) { |
|
| 762 | + if ( $echo ) { |
|
| 763 | 763 | echo $css_class; |
| 764 | 764 | } |
| 765 | 765 | |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | |
| 771 | 771 | $value = GravityView_API::field_value( $entry, $field ); |
| 772 | 772 | |
| 773 | - if( $value === '') { |
|
| 773 | + if ( $value === '' ) { |
|
| 774 | 774 | /** |
| 775 | 775 | * @filter `gravityview_empty_value` What to display when a field is empty |
| 776 | 776 | * @param string $value (empty string) |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | return GravityView_API::entry_link( $entry, $post_id ); |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | -function gv_no_results($wpautop = true) { |
|
| 792 | +function gv_no_results( $wpautop = true ) { |
|
| 793 | 793 | return GravityView_API::no_results( $wpautop ); |
| 794 | 794 | } |
| 795 | 795 | |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | |
| 803 | 803 | $href = gv_directory_link(); |
| 804 | 804 | |
| 805 | - if( empty( $href ) ) { return NULL; } |
|
| 805 | + if ( empty( $href ) ) { return NULL; } |
|
| 806 | 806 | |
| 807 | 807 | // calculate link label |
| 808 | 808 | $gravityview_view = GravityView_View::getInstance(); |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | $link = gravityview_get_link( $href, esc_html( $label ), array( |
| 820 | 820 | 'data-viewid' => $gravityview_view->getViewId() |
| 821 | - )); |
|
| 821 | + ) ); |
|
| 822 | 822 | |
| 823 | 823 | return $link; |
| 824 | 824 | } |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | */ |
| 838 | 838 | function gravityview_get_field_value( $entry, $field_id, $display_value ) { |
| 839 | 839 | |
| 840 | - if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
| 840 | + if ( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
| 841 | 841 | |
| 842 | 842 | // For the complete field value as generated by Gravity Forms |
| 843 | 843 | return $display_value; |
@@ -867,16 +867,16 @@ discard block |
||
| 867 | 867 | |
| 868 | 868 | $terms = explode( ', ', $value ); |
| 869 | 869 | |
| 870 | - foreach ($terms as $term_name ) { |
|
| 870 | + foreach ( $terms as $term_name ) { |
|
| 871 | 871 | |
| 872 | 872 | // If we're processing a category, |
| 873 | - if( $taxonomy === 'category' ) { |
|
| 873 | + if ( $taxonomy === 'category' ) { |
|
| 874 | 874 | |
| 875 | 875 | // Use rgexplode to prevent errors if : doesn't exist |
| 876 | 876 | list( $term_name, $term_id ) = rgexplode( ':', $value, 2 ); |
| 877 | 877 | |
| 878 | 878 | // The explode was succesful; we have the category ID |
| 879 | - if( !empty( $term_id )) { |
|
| 879 | + if ( ! empty( $term_id ) ) { |
|
| 880 | 880 | $term = get_term_by( 'id', $term_id, $taxonomy ); |
| 881 | 881 | } else { |
| 882 | 882 | // We have to fall back to the name |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | // There's still a tag/category here. |
| 892 | - if( $term ) { |
|
| 892 | + if ( $term ) { |
|
| 893 | 893 | |
| 894 | 894 | $term_link = get_term_link( $term, $taxonomy ); |
| 895 | 895 | |
@@ -898,11 +898,11 @@ discard block |
||
| 898 | 898 | continue; |
| 899 | 899 | } |
| 900 | 900 | |
| 901 | - $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
| 901 | + $output[ ] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
| 902 | 902 | } |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | - return implode(', ', $output ); |
|
| 905 | + return implode( ', ', $output ); |
|
| 906 | 906 | } |
| 907 | 907 | |
| 908 | 908 | /** |
@@ -916,8 +916,8 @@ discard block |
||
| 916 | 916 | |
| 917 | 917 | $output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' ); |
| 918 | 918 | |
| 919 | - if( empty( $link ) ) { |
|
| 920 | - return strip_tags( $output); |
|
| 919 | + if ( empty( $link ) ) { |
|
| 920 | + return strip_tags( $output ); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | return $output; |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | $fe = GravityView_frontend::getInstance(); |
| 937 | 937 | |
| 938 | 938 | // Solve problem when loading content via admin-ajax.php |
| 939 | - if( ! $fe->getGvOutputData() ) { |
|
| 939 | + if ( ! $fe->getGvOutputData() ) { |
|
| 940 | 940 | |
| 941 | 941 | do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.' ); |
| 942 | 942 | |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | } |
| 945 | 945 | |
| 946 | 946 | // Make 100% sure that we're dealing with a properly called situation |
| 947 | - if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
| 947 | + if ( ! is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
| 948 | 948 | |
| 949 | 949 | do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData() ); |
| 950 | 950 | |
@@ -964,10 +964,10 @@ discard block |
||
| 964 | 964 | |
| 965 | 965 | $fe = GravityView_frontend::getInstance(); |
| 966 | 966 | |
| 967 | - if( ! $fe->getGvOutputData() ) { return array(); } |
|
| 967 | + if ( ! $fe->getGvOutputData() ) { return array(); } |
|
| 968 | 968 | |
| 969 | 969 | // If not set, grab the current view ID |
| 970 | - if( empty( $view_id ) ) { |
|
| 970 | + if ( empty( $view_id ) ) { |
|
| 971 | 971 | $view_id = $fe->get_context_view_id(); |
| 972 | 972 | } |
| 973 | 973 | |
@@ -1032,11 +1032,11 @@ discard block |
||
| 1032 | 1032 | */ |
| 1033 | 1033 | $is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false ); |
| 1034 | 1034 | |
| 1035 | - if( $is_edit_entry ) { |
|
| 1035 | + if ( $is_edit_entry ) { |
|
| 1036 | 1036 | $context = 'edit'; |
| 1037 | - } else if( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) { |
|
| 1037 | + } else if ( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) { |
|
| 1038 | 1038 | $context = 'single'; |
| 1039 | - } else if( class_exists( 'GravityView_View' ) ) { |
|
| 1039 | + } else if ( class_exists( 'GravityView_View' ) ) { |
|
| 1040 | 1040 | $context = GravityView_View::getInstance()->getContext(); |
| 1041 | 1041 | } |
| 1042 | 1042 | |
@@ -1064,12 +1064,12 @@ discard block |
||
| 1064 | 1064 | function gravityview_get_files_array( $value, $gv_class = '' ) { |
| 1065 | 1065 | /** @define "GRAVITYVIEW_DIR" "../" */ |
| 1066 | 1066 | |
| 1067 | - if( !class_exists( 'GravityView_Field' ) ) { |
|
| 1068 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' ); |
|
| 1067 | + if ( ! class_exists( 'GravityView_Field' ) ) { |
|
| 1068 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' ); |
|
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | - if( !class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
| 1072 | - include_once( GRAVITYVIEW_DIR .'includes/fields/fileupload.php' ); |
|
| 1071 | + if ( ! class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
| 1072 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/fileupload.php' ); |
|
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | 1075 | return GravityView_Field_FileUpload::get_files_array( $value, $gv_class ); |
@@ -1147,12 +1147,12 @@ discard block |
||
| 1147 | 1147 | $args = apply_filters( 'gravityview/field_output/args', $args, $passed_args ); |
| 1148 | 1148 | |
| 1149 | 1149 | // Required fields. |
| 1150 | - if ( empty( $args['field'] ) || empty( $args['form'] ) ) { |
|
| 1150 | + if ( empty( $args[ 'field' ] ) || empty( $args[ 'form' ] ) ) { |
|
| 1151 | 1151 | do_action( 'gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args ); |
| 1152 | 1152 | return ''; |
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | - $entry = empty( $args['entry'] ) ? array() : $args['entry']; |
|
| 1155 | + $entry = empty( $args[ 'entry' ] ) ? array() : $args[ 'entry' ]; |
|
| 1156 | 1156 | |
| 1157 | 1157 | /** |
| 1158 | 1158 | * Create the content variables for replacing. |
@@ -1168,37 +1168,37 @@ discard block |
||
| 1168 | 1168 | 'field_id' => '', |
| 1169 | 1169 | ); |
| 1170 | 1170 | |
| 1171 | - $context['value'] = gv_value( $entry, $args['field'] ); |
|
| 1171 | + $context[ 'value' ] = gv_value( $entry, $args[ 'field' ] ); |
|
| 1172 | 1172 | |
| 1173 | 1173 | // If the value is empty and we're hiding empty, return empty. |
| 1174 | - if ( $context['value'] === '' && ! empty( $args['hide_empty'] ) ) { |
|
| 1174 | + if ( $context[ 'value' ] === '' && ! empty( $args[ 'hide_empty' ] ) ) { |
|
| 1175 | 1175 | return ''; |
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | - if ( $context['value'] !== '' && ! empty( $args['wpautop'] ) ) { |
|
| 1179 | - $context['value'] = wpautop( $context['value'] ); |
|
| 1178 | + if ( $context[ 'value' ] !== '' && ! empty( $args[ 'wpautop' ] ) ) { |
|
| 1179 | + $context[ 'value' ] = wpautop( $context[ 'value' ] ); |
|
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | // Get width setting, if exists |
| 1183 | - $context['width'] = GravityView_API::field_width( $args['field'] ); |
|
| 1183 | + $context[ 'width' ] = GravityView_API::field_width( $args[ 'field' ] ); |
|
| 1184 | 1184 | |
| 1185 | 1185 | // If replacing with CSS inline formatting, let's do it. |
| 1186 | - $context['width:style'] = GravityView_API::field_width( $args['field'], 'width:' . $context['width'] . '%;' ); |
|
| 1186 | + $context[ 'width:style' ] = GravityView_API::field_width( $args[ 'field' ], 'width:' . $context[ 'width' ] . '%;' ); |
|
| 1187 | 1187 | |
| 1188 | 1188 | // Grab the Class using `gv_class` |
| 1189 | - $context['class'] = gv_class( $args['field'], $args['form'], $entry ); |
|
| 1190 | - $context['field_id'] = GravityView_API::field_html_attr_id( $args['field'], $args['form'], $entry ); |
|
| 1189 | + $context[ 'class' ] = gv_class( $args[ 'field' ], $args[ 'form' ], $entry ); |
|
| 1190 | + $context[ 'field_id' ] = GravityView_API::field_html_attr_id( $args[ 'field' ], $args[ 'form' ], $entry ); |
|
| 1191 | 1191 | |
| 1192 | 1192 | // Get field label if needed |
| 1193 | - if ( ! empty( $args['label_markup'] ) && ! empty( $args['field']['show_label'] ) ) { |
|
| 1194 | - $context['label'] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup'] ); |
|
| 1193 | + if ( ! empty( $args[ 'label_markup' ] ) && ! empty( $args[ 'field' ][ 'show_label' ] ) ) { |
|
| 1194 | + $context[ 'label' ] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args[ 'label_markup' ] ); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | // Default Label value |
| 1198 | - $context['label_value'] = gv_label( $args['field'], $entry ); |
|
| 1198 | + $context[ 'label_value' ] = gv_label( $args[ 'field' ], $entry ); |
|
| 1199 | 1199 | |
| 1200 | - if ( empty( $context['label'] ) && ! empty( $context['label_value'] ) ){ |
|
| 1201 | - $context['label'] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
| 1200 | + if ( empty( $context[ 'label' ] ) && ! empty( $context[ 'label_value' ] ) ) { |
|
| 1201 | + $context[ 'label' ] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | /** |
@@ -1207,7 +1207,7 @@ discard block |
||
| 1207 | 1207 | * @param string $markup The HTML for the markup |
| 1208 | 1208 | * @param array $args All args for the field output |
| 1209 | 1209 | */ |
| 1210 | - $html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args ); |
|
| 1210 | + $html = apply_filters( 'gravityview/field_output/pre_html', $args[ 'markup' ], $args ); |
|
| 1211 | 1211 | |
| 1212 | 1212 | /** |
| 1213 | 1213 | * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders |
@@ -1230,7 +1230,7 @@ discard block |
||
| 1230 | 1230 | foreach ( $context as $tag => $value ) { |
| 1231 | 1231 | |
| 1232 | 1232 | // If the tag doesn't exist just skip it |
| 1233 | - if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){ |
|
| 1233 | + if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ) { |
|
| 1234 | 1234 | continue; |
| 1235 | 1235 | } |
| 1236 | 1236 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $entry = self::get_entry( $entry_slug, true ); |
| 126 | 126 | |
| 127 | - $form = self::get_form( $entry['form_id'] ); |
|
| 127 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
| 128 | 128 | |
| 129 | 129 | return $form; |
| 130 | 130 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | $results = GFAPI::get_entries( 0, $search_criteria, null, $paging ); |
| 177 | 177 | |
| 178 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
| 178 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
| 179 | 179 | |
| 180 | 180 | return $result; |
| 181 | 181 | } |
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | if ( class_exists( 'GFAPI' ) ) { |
| 194 | 194 | $gf_forms = GFAPI::get_forms(); |
| 195 | 195 | foreach ( $gf_forms as $form ) { |
| 196 | - $forms[] = array( |
|
| 197 | - 'id' => $form['id'], |
|
| 198 | - 'title' => $form['title'], |
|
| 196 | + $forms[ ] = array( |
|
| 197 | + 'id' => $form[ 'id' ], |
|
| 198 | + 'title' => $form[ 'title' ], |
|
| 199 | 199 | ); |
| 200 | 200 | } |
| 201 | 201 | } |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | if ( $form ) { |
| 230 | - foreach ( $form['fields'] as $field ) { |
|
| 231 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
| 232 | - $fields[ $field['id'] ] = array( |
|
| 230 | + foreach ( $form[ 'fields' ] as $field ) { |
|
| 231 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
| 232 | + $fields[ $field[ 'id' ] ] = array( |
|
| 233 | 233 | 'label' => rgar( $field, 'label' ), |
| 234 | 234 | 'parent' => null, |
| 235 | 235 | 'type' => rgar( $field, 'type' ), |
@@ -238,16 +238,16 @@ discard block |
||
| 238 | 238 | ); |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
| 242 | - foreach ( $field['inputs'] as $input ) { |
|
| 241 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
| 242 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
| 243 | 243 | /** |
| 244 | 244 | * @hack |
| 245 | 245 | * In case of email/email confirmation, the input for email has the same id as the parent field |
| 246 | 246 | */ |
| 247 | - if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
| 247 | + if ( 'email' == rgar( $field, 'type' ) && false === strpos( $input[ 'id' ], '.' ) ) { |
|
| 248 | 248 | continue; |
| 249 | 249 | } |
| 250 | - $fields[ (string)$input['id'] ] = array( |
|
| 250 | + $fields[ (string)$input[ 'id' ] ] = array( |
|
| 251 | 251 | 'label' => rgar( $input, 'label' ), |
| 252 | 252 | 'customLabel' => rgar( $input, 'customLabel' ), |
| 253 | 253 | 'parent' => $field, |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** @since 1.14 */ |
| 262 | - if( 'list' === $field['type'] && !empty( $field['enableColumns'] ) ) { |
|
| 262 | + if ( 'list' === $field[ 'type' ] && ! empty( $field[ 'enableColumns' ] ) ) { |
|
| 263 | 263 | |
| 264 | - foreach ( (array)$field['choices'] as $key => $input ) { |
|
| 264 | + foreach ( (array)$field[ 'choices' ] as $key => $input ) { |
|
| 265 | 265 | |
| 266 | - $input_id = sprintf( '%d.%d', $field['id'], $key ); // {field_id}.{column_key} |
|
| 266 | + $input_id = sprintf( '%d.%d', $field[ 'id' ], $key ); // {field_id}.{column_key} |
|
| 267 | 267 | |
| 268 | 268 | $fields[ $input_id ] = array( |
| 269 | 269 | 'label' => rgar( $input, 'text' ), |
@@ -279,25 +279,25 @@ discard block |
||
| 279 | 279 | /** |
| 280 | 280 | * @since 1.8 |
| 281 | 281 | */ |
| 282 | - if( 'quiz' === $field['type'] ) { |
|
| 282 | + if ( 'quiz' === $field[ 'type' ] ) { |
|
| 283 | 283 | $has_quiz_fields = true; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
| 287 | 287 | * @since 1.8 |
| 288 | 288 | */ |
| 289 | - if( 'poll' === $field['type'] ) { |
|
| 289 | + if ( 'poll' === $field[ 'type' ] ) { |
|
| 290 | 290 | $has_poll_fields = true; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
| 293 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
| 294 | 294 | $has_product_fields = true; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
| 298 | 298 | * @hack Version 1.9 |
| 299 | 299 | */ |
| 300 | - $field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object) $field : (array) $field; |
|
| 300 | + $field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object)$field : (array)$field; |
|
| 301 | 301 | |
| 302 | 302 | if ( GFCommon::is_post_field( $field_for_is_post_field ) ) { |
| 303 | 303 | $has_post_fields = true; |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * @since 1.7 |
| 310 | 310 | */ |
| 311 | 311 | if ( $has_post_fields ) { |
| 312 | - $fields['post_id'] = array( |
|
| 312 | + $fields[ 'post_id' ] = array( |
|
| 313 | 313 | 'label' => __( 'Post ID', 'gravityview' ), |
| 314 | 314 | 'type' => 'post_id', |
| 315 | 315 | ); |
@@ -320,10 +320,10 @@ discard block |
||
| 320 | 320 | $payment_fields = GravityView_Fields::get_all( 'pricing' ); |
| 321 | 321 | |
| 322 | 322 | foreach ( $payment_fields as $payment_field ) { |
| 323 | - if( isset( $fields["{$payment_field->name}"] ) ) { |
|
| 323 | + if ( isset( $fields[ "{$payment_field->name}" ] ) ) { |
|
| 324 | 324 | continue; |
| 325 | 325 | } |
| 326 | - $fields["{$payment_field->name}"] = array( |
|
| 326 | + $fields[ "{$payment_field->name}" ] = array( |
|
| 327 | 327 | 'label' => $payment_field->label, |
| 328 | 328 | 'desc' => $payment_field->description, |
| 329 | 329 | 'type' => $payment_field->name, |
@@ -334,24 +334,24 @@ discard block |
||
| 334 | 334 | /** |
| 335 | 335 | * @since 1.8 |
| 336 | 336 | */ |
| 337 | - if( $has_quiz_fields ) { |
|
| 337 | + if ( $has_quiz_fields ) { |
|
| 338 | 338 | |
| 339 | - $fields['gquiz_score'] = array( |
|
| 339 | + $fields[ 'gquiz_score' ] = array( |
|
| 340 | 340 | 'label' => __( 'Quiz Score Total', 'gravityview' ), |
| 341 | 341 | 'type' => 'quiz_score', |
| 342 | 342 | 'desc' => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ), |
| 343 | 343 | ); |
| 344 | - $fields['gquiz_percent'] = array( |
|
| 344 | + $fields[ 'gquiz_percent' ] = array( |
|
| 345 | 345 | 'label' => __( 'Quiz Percentage Grade', 'gravityview' ), |
| 346 | 346 | 'type' => 'quiz_percent', |
| 347 | 347 | 'desc' => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ), |
| 348 | 348 | ); |
| 349 | - $fields['gquiz_grade'] = array( |
|
| 349 | + $fields[ 'gquiz_grade' ] = array( |
|
| 350 | 350 | 'label' => __( 'Quiz Letter Grade', 'gravityview' ), |
| 351 | 351 | 'type' => 'quiz_grade', |
| 352 | 352 | 'desc' => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ), |
| 353 | 353 | ); |
| 354 | - $fields['gquiz_is_pass'] = array( |
|
| 354 | + $fields[ 'gquiz_is_pass' ] = array( |
|
| 355 | 355 | 'label' => __( 'Quiz Pass/Fail', 'gravityview' ), |
| 356 | 356 | 'type' => 'quiz_is_pass', |
| 357 | 357 | 'desc' => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ), |
@@ -373,9 +373,9 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | $fields = array(); |
| 375 | 375 | |
| 376 | - foreach ( $extra_fields as $key => $field ){ |
|
| 377 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
| 378 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
| 376 | + foreach ( $extra_fields as $key => $field ) { |
|
| 377 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
| 378 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | 381 | |
@@ -415,32 +415,32 @@ discard block |
||
| 415 | 415 | 'search_criteria' => null, |
| 416 | 416 | 'sorting' => null, |
| 417 | 417 | 'paging' => null, |
| 418 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true), |
|
| 418 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? $passed_criteria[ 'cache' ] : true ), |
|
| 419 | 419 | ); |
| 420 | 420 | |
| 421 | 421 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
| 422 | 422 | |
| 423 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
| 424 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
| 423 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 424 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
| 425 | 425 | |
| 426 | 426 | if ( ! is_array( $filter ) ) { |
| 427 | 427 | continue; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // By default, we want searches to be wildcard for each field. |
| 431 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
| 431 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
| 432 | 432 | |
| 433 | 433 | /** |
| 434 | 434 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
| 435 | 435 | * @param string $operator Existing search operator |
| 436 | 436 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
| 437 | 437 | */ |
| 438 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
| 438 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | // don't send just the [mode] without any field filter. |
| 442 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
| 443 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
| 442 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 443 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | } |
@@ -451,21 +451,21 @@ discard block |
||
| 451 | 451 | * Prepare date formats to be in Gravity Forms DB format; |
| 452 | 452 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
| 453 | 453 | */ |
| 454 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
| 454 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
| 455 | 455 | |
| 456 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
| 456 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
| 457 | 457 | |
| 458 | 458 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
| 459 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
| 459 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 460 | 460 | |
| 461 | 461 | if ( $date ) { |
| 462 | 462 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
| 463 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 463 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 464 | 464 | } else { |
| 465 | 465 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
| 466 | - unset( $criteria['search_criteria'][ $key ] ); |
|
| 466 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 467 | 467 | |
| 468 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
| 468 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] ); |
|
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | } |
@@ -473,12 +473,12 @@ discard block |
||
| 473 | 473 | |
| 474 | 474 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter |
| 475 | 475 | if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) { |
| 476 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 476 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 477 | 477 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
| 478 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null; |
|
| 479 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
| 478 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? $_GET[ 'view_id' ] : null; |
|
| 479 | + } elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { |
|
| 480 | 480 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
| 481 | - $criteria['context_view_id'] = null; |
|
| 481 | + $criteria[ 'context_view_id' ] = null; |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | /** |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | * @param array $form_ids Forms to search |
| 488 | 488 | * @param int $view_id ID of the view being used to search |
| 489 | 489 | */ |
| 490 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
| 490 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
| 491 | 491 | |
| 492 | 492 | return (array)$criteria; |
| 493 | 493 | |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | /** Reduce # of database calls */ |
| 519 | 519 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
| 520 | 520 | |
| 521 | - if ( ! empty( $criteria['cache'] ) ) { |
|
| 521 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
| 522 | 522 | |
| 523 | 523 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
| 524 | 524 | |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | |
| 527 | 527 | // Still update the total count when using cached results |
| 528 | 528 | if ( ! is_null( $total ) ) { |
| 529 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
| 529 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | $return = $entries; |
@@ -546,9 +546,9 @@ discard block |
||
| 546 | 546 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
| 547 | 547 | |
| 548 | 548 | // No entries returned from gravityview_before_get_entries |
| 549 | - if( is_null( $entries ) ) { |
|
| 549 | + if ( is_null( $entries ) ) { |
|
| 550 | 550 | |
| 551 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
| 551 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
| 552 | 552 | |
| 553 | 553 | if ( is_wp_error( $entries ) ) { |
| 554 | 554 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | } |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
| 560 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
| 561 | 561 | |
| 562 | 562 | // Cache results |
| 563 | 563 | $Cache->set( $entries, 'entries' ); |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | */ |
| 645 | 645 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
| 646 | 646 | |
| 647 | - if( $check_entry_display ) { |
|
| 647 | + if ( $check_entry_display ) { |
|
| 648 | 648 | // Is the entry allowed |
| 649 | 649 | $entry = self::check_entry_display( $entry ); |
| 650 | 650 | } |
@@ -677,12 +677,12 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | $value = false; |
| 679 | 679 | |
| 680 | - if( 'context' === $val1 ) { |
|
| 680 | + if ( 'context' === $val1 ) { |
|
| 681 | 681 | |
| 682 | 682 | $matching_contexts = array( $val2 ); |
| 683 | 683 | |
| 684 | 684 | // We allow for non-standard contexts. |
| 685 | - switch( $val2 ) { |
|
| 685 | + switch ( $val2 ) { |
|
| 686 | 686 | // Check for either single or edit |
| 687 | 687 | case 'singular': |
| 688 | 688 | $matching_contexts = array( 'single', 'edit' ); |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | return false; |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | - if ( empty( $entry['form_id'] ) ) { |
|
| 745 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
| 746 | 746 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
| 747 | 747 | return false; |
| 748 | 748 | } |
@@ -750,26 +750,26 @@ discard block |
||
| 750 | 750 | $criteria = self::calculate_get_entries_criteria(); |
| 751 | 751 | |
| 752 | 752 | // Make sure the current View is connected to the same form as the Entry |
| 753 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
| 754 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
| 753 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
| 754 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
| 755 | 755 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
| 756 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
| 757 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
| 756 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
| 757 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
| 758 | 758 | return false; |
| 759 | 759 | } |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
| 762 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
| 763 | 763 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
| 764 | 764 | return $entry; |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | - $search_criteria = $criteria['search_criteria']; |
|
| 767 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
| 768 | 768 | unset( $criteria ); |
| 769 | 769 | |
| 770 | 770 | // check entry status |
| 771 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
| 772 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
| 771 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
| 772 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
| 773 | 773 | return false; |
| 774 | 774 | } |
| 775 | 775 | |
@@ -777,37 +777,37 @@ discard block |
||
| 777 | 777 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
| 778 | 778 | |
| 779 | 779 | // field_filters |
| 780 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
| 780 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
| 781 | 781 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
| 782 | 782 | return $entry; |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | - $filters = $search_criteria['field_filters']; |
|
| 785 | + $filters = $search_criteria[ 'field_filters' ]; |
|
| 786 | 786 | unset( $search_criteria ); |
| 787 | 787 | |
| 788 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
| 789 | - unset( $filters['mode'] ); |
|
| 788 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
| 789 | + unset( $filters[ 'mode' ] ); |
|
| 790 | 790 | |
| 791 | - $form = self::get_form( $entry['form_id'] ); |
|
| 791 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
| 792 | 792 | |
| 793 | 793 | foreach ( $filters as $filter ) { |
| 794 | 794 | |
| 795 | - if ( ! isset( $filter['key'] ) ) { |
|
| 795 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
| 796 | 796 | continue; |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | - $k = $filter['key']; |
|
| 799 | + $k = $filter[ 'key' ]; |
|
| 800 | 800 | |
| 801 | 801 | if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
| 802 | 802 | $field_value = $entry[ $k ]; |
| 803 | 803 | $field = null; |
| 804 | 804 | } else { |
| 805 | 805 | $field = self::get_field( $form, $k ); |
| 806 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 806 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
| 810 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
| 809 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
| 810 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
| 811 | 811 | |
| 812 | 812 | // verify if we are already free to go! |
| 813 | 813 | if ( ! $is_value_match && 'all' === $mode ) { |
@@ -865,25 +865,25 @@ discard block |
||
| 865 | 865 | * Gravity Forms code to adjust date to locally-configured Time Zone |
| 866 | 866 | * @see GFCommon::format_date() for original code |
| 867 | 867 | */ |
| 868 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 868 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 869 | 869 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
| 870 | 870 | |
| 871 | - $format = rgar( $atts, 'format' ); |
|
| 872 | - $is_human = ! empty( $atts['human'] ); |
|
| 873 | - $is_diff = ! empty( $atts['diff'] ); |
|
| 874 | - $is_raw = ! empty( $atts['raw'] ); |
|
| 875 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
| 876 | - $include_time = ! empty( $atts['time'] ); |
|
| 871 | + $format = rgar( $atts, 'format' ); |
|
| 872 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
| 873 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
| 874 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
| 875 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
| 876 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
| 877 | 877 | |
| 878 | 878 | // If we're using time diff, we want to have a different default format |
| 879 | - if( empty( $format ) ) { |
|
| 879 | + if ( empty( $format ) ) { |
|
| 880 | 880 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | 883 | // If raw was specified, don't modify the stored value |
| 884 | 884 | if ( $is_raw ) { |
| 885 | 885 | $formatted_date = $date_string; |
| 886 | - } elseif( $is_timestamp ) { |
|
| 886 | + } elseif ( $is_timestamp ) { |
|
| 887 | 887 | $formatted_date = $date_local_timestamp; |
| 888 | 888 | } elseif ( $is_diff ) { |
| 889 | 889 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | $field = self::get_field( $form, $field_id ); |
| 914 | - return isset( $field['label'] ) ? $field['label'] : ''; |
|
| 914 | + return isset( $field[ 'label' ] ) ? $field[ 'label' ] : ''; |
|
| 915 | 915 | |
| 916 | 916 | } |
| 917 | 917 | |
@@ -929,7 +929,7 @@ discard block |
||
| 929 | 929 | * @return array|null Array: Gravity Forms field array; NULL: Gravity Forms GFFormsModel does not exist |
| 930 | 930 | */ |
| 931 | 931 | public static function get_field( $form, $field_id ) { |
| 932 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
| 932 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
| 933 | 933 | return GFFormsModel::get_field( $form, $field_id ); |
| 934 | 934 | } else { |
| 935 | 935 | return null; |
@@ -976,17 +976,17 @@ discard block |
||
| 976 | 976 | $shortcodes = array(); |
| 977 | 977 | |
| 978 | 978 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
| 979 | - if ( empty( $matches ) ){ |
|
| 979 | + if ( empty( $matches ) ) { |
|
| 980 | 980 | return false; |
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | foreach ( $matches as $shortcode ) { |
| 984 | - if ( $tag === $shortcode[2] ) { |
|
| 984 | + if ( $tag === $shortcode[ 2 ] ) { |
|
| 985 | 985 | |
| 986 | 986 | // Changed this to $shortcode instead of true so we get the parsed atts. |
| 987 | - $shortcodes[] = $shortcode; |
|
| 987 | + $shortcodes[ ] = $shortcode; |
|
| 988 | 988 | |
| 989 | - } else if ( isset( $shortcode[5] ) && $result = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
| 989 | + } else if ( isset( $shortcode[ 5 ] ) && $result = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
| 990 | 990 | $shortcodes = $result; |
| 991 | 991 | } |
| 992 | 992 | } |
@@ -1137,7 +1137,7 @@ discard block |
||
| 1137 | 1137 | * @return string html |
| 1138 | 1138 | */ |
| 1139 | 1139 | public static function get_sortable_fields( $formid, $current = '' ) { |
| 1140 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
| 1140 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
| 1141 | 1141 | |
| 1142 | 1142 | if ( empty( $formid ) ) { |
| 1143 | 1143 | return $output; |
@@ -1150,11 +1150,11 @@ discard block |
||
| 1150 | 1150 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
| 1151 | 1151 | |
| 1152 | 1152 | foreach ( $fields as $id => $field ) { |
| 1153 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1153 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1154 | 1154 | continue; |
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
| 1157 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
| 1158 | 1158 | } |
| 1159 | 1159 | } |
| 1160 | 1160 | |
@@ -1189,9 +1189,9 @@ discard block |
||
| 1189 | 1189 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1190 | 1190 | |
| 1191 | 1191 | // TODO: Convert to using array_filter |
| 1192 | - foreach( $fields as $id => $field ) { |
|
| 1192 | + foreach ( $fields as $id => $field ) { |
|
| 1193 | 1193 | |
| 1194 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1194 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1195 | 1195 | unset( $fields[ $id ] ); |
| 1196 | 1196 | } |
| 1197 | 1197 | } |
@@ -1232,14 +1232,14 @@ discard block |
||
| 1232 | 1232 | * @param int|array $field field key or field array |
| 1233 | 1233 | * @return boolean |
| 1234 | 1234 | */ |
| 1235 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1235 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1236 | 1236 | |
| 1237 | 1237 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
| 1238 | 1238 | $form = self::get_form( $form ); |
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | 1241 | // If entry meta, it's a string. Otherwise, numeric |
| 1242 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1242 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1243 | 1243 | $type = $field; |
| 1244 | 1244 | } else { |
| 1245 | 1245 | $type = self::get_field_type( $form, $field ); |
@@ -1253,9 +1253,9 @@ discard block |
||
| 1253 | 1253 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
| 1254 | 1254 | |
| 1255 | 1255 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
| 1256 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1257 | - if( true === $gv_field->is_numeric ) { |
|
| 1258 | - $numeric_types[] = $gv_field->is_numeric; |
|
| 1256 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1257 | + if ( true === $gv_field->is_numeric ) { |
|
| 1258 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
| 1259 | 1259 | } |
| 1260 | 1260 | } |
| 1261 | 1261 | |
@@ -1405,11 +1405,11 @@ discard block |
||
| 1405 | 1405 | $final_atts = array_filter( $final_atts ); |
| 1406 | 1406 | |
| 1407 | 1407 | // If the href wasn't passed as an attribute, use the value passed to the function |
| 1408 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
| 1409 | - $final_atts['href'] = $href; |
|
| 1408 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
| 1409 | + $final_atts[ 'href' ] = $href; |
|
| 1410 | 1410 | } |
| 1411 | 1411 | |
| 1412 | - $final_atts['href'] = esc_url_raw( $href ); |
|
| 1412 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
| 1413 | 1413 | |
| 1414 | 1414 | // Sort the attributes alphabetically, to help testing |
| 1415 | 1415 | ksort( $final_atts ); |
@@ -1420,7 +1420,7 @@ discard block |
||
| 1420 | 1420 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
| 1421 | 1421 | } |
| 1422 | 1422 | |
| 1423 | - if( '' !== $output ) { |
|
| 1423 | + if ( '' !== $output ) { |
|
| 1424 | 1424 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
| 1425 | 1425 | } |
| 1426 | 1426 | |
@@ -1444,7 +1444,7 @@ discard block |
||
| 1444 | 1444 | public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) { |
| 1445 | 1445 | $merged = $array1; |
| 1446 | 1446 | |
| 1447 | - foreach ( $array2 as $key => &$value ) { |
|
| 1447 | + foreach ( $array2 as $key => &$value ) { |
|
| 1448 | 1448 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
| 1449 | 1449 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
| 1450 | 1450 | } else { |
@@ -1479,7 +1479,7 @@ discard block |
||
| 1479 | 1479 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
| 1480 | 1480 | * @param array $settings Settings array, with `number` key defining the # of users to display |
| 1481 | 1481 | */ |
| 1482 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1482 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1483 | 1483 | |
| 1484 | 1484 | return get_users( $get_users_settings ); |
| 1485 | 1485 | } |
@@ -1494,7 +1494,7 @@ discard block |
||
| 1494 | 1494 | * @return string |
| 1495 | 1495 | */ |
| 1496 | 1496 | public static function generate_notice( $notice, $class = '' ) { |
| 1497 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1497 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
| 1498 | 1498 | } |
| 1499 | 1499 | |
| 1500 | 1500 | |
@@ -34,19 +34,19 @@ discard block |
||
| 34 | 34 | /** gf_entries page - entries table screen */ |
| 35 | 35 | |
| 36 | 36 | // capture bulk actions |
| 37 | - add_action( 'init', array( $this, 'process_bulk_action') ); |
|
| 37 | + add_action( 'init', array( $this, 'process_bulk_action' ) ); |
|
| 38 | 38 | // add hidden field with approve status |
| 39 | 39 | add_action( 'gform_entries_first_column', array( $this, 'add_entry_approved_hidden_input' ), 1, 5 ); |
| 40 | 40 | // process ajax approve entry requests |
| 41 | - add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved')); |
|
| 41 | + add_action( 'wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved' ) ); |
|
| 42 | 42 | |
| 43 | 43 | // in case entry is edited (on admin or frontend) |
| 44 | - add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2); |
|
| 44 | + add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2 ); |
|
| 45 | 45 | |
| 46 | 46 | add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) ); |
| 47 | 47 | |
| 48 | 48 | // adding styles and scripts |
| 49 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') ); |
|
| 49 | + add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ) ); |
|
| 50 | 50 | // bypass Gravity Forms no-conflict mode |
| 51 | 51 | add_filter( 'gform_noconflict_scripts', array( $this, 'register_gform_noconflict_script' ) ); |
| 52 | 52 | add_filter( 'gform_noconflict_styles', array( $this, 'register_gform_noconflict_style' ) ); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | function tooltips( $tooltips ) { |
| 63 | 63 | |
| 64 | - $tooltips['form_gravityview_fields'] = array( |
|
| 65 | - 'title' => __('GravityView Fields', 'gravityview'), |
|
| 66 | - 'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview'), |
|
| 64 | + $tooltips[ 'form_gravityview_fields' ] = array( |
|
| 65 | + 'title' => __( 'GravityView Fields', 'gravityview' ), |
|
| 66 | + 'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview' ), |
|
| 67 | 67 | ); |
| 68 | 68 | |
| 69 | 69 | return $tooltips; |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | // gforms_update_note is sent when bulk editing entry notes. We don't want to process then. |
| 181 | - if ( 'bulk' === RGForms::post( 'action' ) && empty( $_POST['gforms_update_note'] ) ) { |
|
| 181 | + if ( 'bulk' === RGForms::post( 'action' ) && empty( $_POST[ 'gforms_update_note' ] ) ) { |
|
| 182 | 182 | |
| 183 | 183 | check_admin_referer( 'gforms_entry_list', 'gforms_entry_list' ); |
| 184 | 184 | |
| 185 | 185 | // The action is formatted like: approve-16 or disapprove-16, where the first word is the name of the action and the second is the ID of the form. Bulk action 2 is the bottom bulk action select form. |
| 186 | - $bulk_action = ! empty( $_POST['bulk_action'] ) ? $_POST['bulk_action'] : $_POST['bulk_action2']; |
|
| 186 | + $bulk_action = ! empty( $_POST[ 'bulk_action' ] ) ? $_POST[ 'bulk_action' ] : $_POST[ 'bulk_action2' ]; |
|
| 187 | 187 | |
| 188 | 188 | /** |
| 189 | 189 | * The extra '-' is to make sure that there are at *least* two items in array. |
@@ -199,13 +199,13 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | // All entries are set to be updated, not just the visible ones |
| 202 | - if ( ! empty( $_POST['all_entries'] ) ) { |
|
| 202 | + if ( ! empty( $_POST[ 'all_entries' ] ) ) { |
|
| 203 | 203 | |
| 204 | 204 | // Convert the current entry search into GF-formatted search criteria |
| 205 | 205 | $search = array( |
| 206 | - 'search_field' => isset( $_POST['f'] ) ? $_POST['f'][0] : 0, |
|
| 207 | - 'search_value' => isset( $_POST['v'][0] ) ? $_POST['v'][0] : '', |
|
| 208 | - 'search_operator' => isset( $_POST['o'][0] ) ? $_POST['o'][0] : 'contains', |
|
| 206 | + 'search_field' => isset( $_POST[ 'f' ] ) ? $_POST[ 'f' ][ 0 ] : 0, |
|
| 207 | + 'search_value' => isset( $_POST[ 'v' ][ 0 ] ) ? $_POST[ 'v' ][ 0 ] : '', |
|
| 208 | + 'search_operator' => isset( $_POST[ 'o' ][ 0 ] ) ? $_POST[ 'o' ][ 0 ] : 'contains', |
|
| 209 | 209 | ); |
| 210 | 210 | |
| 211 | 211 | $search_criteria = GravityView_frontend::get_search_criteria( $search, $form_id ); |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | } else { |
| 217 | 217 | |
| 218 | - $entries = $_POST['lead']; |
|
| 218 | + $entries = $_POST[ 'lead' ]; |
|
| 219 | 219 | |
| 220 | 220 | } |
| 221 | 221 | |
@@ -256,12 +256,12 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | private static function update_bulk( $entries, $approved, $form_id ) { |
| 258 | 258 | |
| 259 | - if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) { |
|
| 259 | + if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) { |
|
| 260 | 260 | do_action( 'gravityview_log_error', __METHOD__ . ' Entries were empty or malformed.', $entries ); |
| 261 | 261 | return false; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
| 264 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
| 265 | 265 | do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
| 266 | 266 | return false; |
| 267 | 267 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | // calculate approved field id |
| 272 | 272 | $approved_column_id = self::get_approved_column( $form_id ); |
| 273 | 273 | |
| 274 | - foreach( $entries as $entry_id ) { |
|
| 274 | + foreach ( $entries as $entry_id ) { |
|
| 275 | 275 | self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
| 276 | 276 | } |
| 277 | 277 | } |
@@ -290,14 +290,14 @@ discard block |
||
| 290 | 290 | * @param int $approvedcolumn (default: 0) |
| 291 | 291 | * @return boolean True: It worked; False: it failed |
| 292 | 292 | */ |
| 293 | - public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { |
|
| 293 | + public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0 ) { |
|
| 294 | 294 | |
| 295 | - if( !class_exists( 'GFAPI' ) ) { |
|
| 295 | + if ( ! class_exists( 'GFAPI' ) ) { |
|
| 296 | 296 | do_action( 'gravityview_log_error', __METHOD__ . 'GFAPI does not exist' ); |
| 297 | 297 | return false; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - if( empty( $approvedcolumn ) ) { |
|
| 300 | + if ( empty( $approvedcolumn ) ) { |
|
| 301 | 301 | $approvedcolumn = self::get_approved_column( $form_id ); |
| 302 | 302 | } |
| 303 | 303 | |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | self::update_approved_meta( $entry_id, $approved ); |
| 317 | 317 | |
| 318 | 318 | // add note to entry |
| 319 | - if( $result === true ) { |
|
| 319 | + if ( $result === true ) { |
|
| 320 | 320 | $note = empty( $approved ) ? __( 'Disapproved the Entry for GravityView', 'gravityview' ) : __( 'Approved the Entry for GravityView', 'gravityview' ); |
| 321 | 321 | |
| 322 | - if( class_exists( 'GravityView_Entry_Notes' ) ){ |
|
| 322 | + if ( class_exists( 'GravityView_Entry_Notes' ) ) { |
|
| 323 | 323 | global $current_user; |
| 324 | 324 | get_currentuserinfo(); |
| 325 | 325 | GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $current_user->display_name, $note ); |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | do_action( 'gravityview_clear_form_cache', $form_id ); |
| 334 | 334 | |
| 335 | - } else if( is_wp_error( $result ) ) { |
|
| 335 | + } else if ( is_wp_error( $result ) ) { |
|
| 336 | 336 | |
| 337 | 337 | do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - Entry approval not updated: %s', $result->get_error_message() ) ); |
| 338 | 338 | |
@@ -354,12 +354,12 @@ discard block |
||
| 354 | 354 | */ |
| 355 | 355 | public static function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
| 356 | 356 | |
| 357 | - $approvedcolumn = self::get_approved_column( $form['id'] ); |
|
| 357 | + $approvedcolumn = self::get_approved_column( $form[ 'id' ] ); |
|
| 358 | 358 | |
| 359 | 359 | /** |
| 360 | 360 | * If the form doesn't contain the approve field, don't assume anything. |
| 361 | 361 | */ |
| 362 | - if( empty( $approvedcolumn ) ) { |
|
| 362 | + if ( empty( $approvedcolumn ) ) { |
|
| 363 | 363 | return; |
| 364 | 364 | } |
| 365 | 365 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | private static function update_approved_meta( $entry_id, $is_approved ) { |
| 382 | 382 | |
| 383 | 383 | // update entry meta |
| 384 | - if( function_exists('gform_update_meta') ) { |
|
| 384 | + if ( function_exists( 'gform_update_meta' ) ) { |
|
| 385 | 385 | |
| 386 | 386 | gform_update_meta( $entry_id, 'is_approved', $is_approved ); |
| 387 | 387 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | do_action( 'gravityview/approve_entries/updated', $entry_id, $is_approved ); |
| 395 | 395 | |
| 396 | - if( empty( $is_approved ) ) { |
|
| 396 | + if ( empty( $is_approved ) ) { |
|
| 397 | 397 | |
| 398 | 398 | /** |
| 399 | 399 | * @action `gravityview/approve_entries/disapproved` Triggered when an entry is rejected |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | |
| 416 | 416 | } else { |
| 417 | 417 | |
| 418 | - do_action('gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
| 418 | + do_action( 'gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
| 419 | 419 | |
| 420 | 420 | } |
| 421 | 421 | } |
@@ -427,21 +427,21 @@ discard block |
||
| 427 | 427 | */ |
| 428 | 428 | public function ajax_update_approved() { |
| 429 | 429 | |
| 430 | - if( empty( $_POST['entry_id'] ) || empty( $_POST['form_id'] ) ) { |
|
| 430 | + if ( empty( $_POST[ 'entry_id' ] ) || empty( $_POST[ 'form_id' ] ) ) { |
|
| 431 | 431 | |
| 432 | 432 | do_action( 'gravityview_log_error', __METHOD__ . ' entry_id or form_id are empty.', $_POST ); |
| 433 | 433 | |
| 434 | 434 | $result = false; |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - else if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxgfentries' ) ) { |
|
| 437 | + else if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxgfentries' ) ) { |
|
| 438 | 438 | |
| 439 | 439 | do_action( 'gravityview_log_error', __METHOD__ . ' Security check failed.', $_POST ); |
| 440 | 440 | |
| 441 | 441 | $result = false; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - else if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $_POST['entry_id'] ) ) { |
|
| 444 | + else if ( ! GVCommon::has_cap( 'gravityview_moderate_entries', $_POST[ 'entry_id' ] ) ) { |
|
| 445 | 445 | |
| 446 | 446 | do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
| 447 | 447 | |
@@ -450,11 +450,11 @@ discard block |
||
| 450 | 450 | |
| 451 | 451 | else { |
| 452 | 452 | |
| 453 | - $result = self::update_approved( $_POST['entry_id'], $_POST['approved'], $_POST['form_id'] ); |
|
| 453 | + $result = self::update_approved( $_POST[ 'entry_id' ], $_POST[ 'approved' ], $_POST[ 'form_id' ] ); |
|
| 454 | 454 | |
| 455 | - if( is_wp_error( $result ) ) { |
|
| 455 | + if ( is_wp_error( $result ) ) { |
|
| 456 | 456 | /** @var WP_Error $result */ |
| 457 | - do_action( 'gravityview_log_error', __METHOD__ .' Error updating approval: ' . $result->get_error_message() ); |
|
| 457 | + do_action( 'gravityview_log_error', __METHOD__ . ' Error updating approval: ' . $result->get_error_message() ); |
|
| 458 | 458 | $result = false; |
| 459 | 459 | } |
| 460 | 460 | |
@@ -474,29 +474,29 @@ discard block |
||
| 474 | 474 | */ |
| 475 | 475 | static public function get_approved_column( $form ) { |
| 476 | 476 | |
| 477 | - if( empty( $form ) ) { |
|
| 477 | + if ( empty( $form ) ) { |
|
| 478 | 478 | return null; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - if( !is_array( $form ) ) { |
|
| 481 | + if ( ! is_array( $form ) ) { |
|
| 482 | 482 | $form = GVCommon::get_form( $form ); |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - foreach( $form['fields'] as $key => $field ) { |
|
| 485 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
| 486 | 486 | |
| 487 | - $field = (array) $field; |
|
| 487 | + $field = (array)$field; |
|
| 488 | 488 | |
| 489 | - if( !empty( $field['gravityview_approved'] ) ) { |
|
| 490 | - if( !empty($field['inputs'][0]['id']) ) { |
|
| 491 | - return $field['inputs'][0]['id']; |
|
| 489 | + if ( ! empty( $field[ 'gravityview_approved' ] ) ) { |
|
| 490 | + if ( ! empty( $field[ 'inputs' ][ 0 ][ 'id' ] ) ) { |
|
| 491 | + return $field[ 'inputs' ][ 0 ][ 'id' ]; |
|
| 492 | 492 | } |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
| 496 | - if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
| 497 | - foreach ( $field['inputs'] as $key2 => $input ) { |
|
| 498 | - if ( strtolower( $input['label'] ) == 'approved' ) { |
|
| 499 | - return $input['id']; |
|
| 496 | + if ( 'checkbox' == $field[ 'type' ] && isset( $field[ 'inputs' ] ) && is_array( $field[ 'inputs' ] ) ) { |
|
| 497 | + foreach ( $field[ 'inputs' ] as $key2 => $input ) { |
|
| 498 | + if ( strtolower( $input[ 'label' ] ) == 'approved' ) { |
|
| 499 | + return $input[ 'id' ]; |
|
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | 502 | } |
@@ -507,18 +507,18 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | |
| 509 | 509 | |
| 510 | - static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) { |
|
| 510 | + static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) { |
|
| 511 | 511 | |
| 512 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry['id'] ) ) { |
|
| 512 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry[ 'id' ] ) ) { |
|
| 513 | 513 | return; |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - if( empty( $entry['id'] ) ) { |
|
| 516 | + if ( empty( $entry[ 'id' ] ) ) { |
|
| 517 | 517 | return; |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - if( gform_get_meta( $entry['id'], 'is_approved' ) ) { |
|
| 521 | - echo '<input type="hidden" class="entry_approved" id="entry_approved_'. $entry['id'] .'" value="true" />'; |
|
| 520 | + if ( gform_get_meta( $entry[ 'id' ], 'is_approved' ) ) { |
|
| 521 | + echo '<input type="hidden" class="entry_approved" id="entry_approved_' . $entry[ 'id' ] . '" value="true" />'; |
|
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | 524 | |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | function add_scripts_and_styles( $hook ) { |
| 529 | 529 | |
| 530 | - if( !class_exists( 'RGForms' ) ) { |
|
| 530 | + if ( ! class_exists( 'RGForms' ) ) { |
|
| 531 | 531 | |
| 532 | 532 | do_action( 'gravityview_log_error', 'GravityView_Admin_ApproveEntries[add_scripts_and_styles] RGForms does not exist.' ); |
| 533 | 533 | |
@@ -536,39 +536,39 @@ discard block |
||
| 536 | 536 | |
| 537 | 537 | // enqueue styles & scripts gf_entries |
| 538 | 538 | // But only if we're on the main Entries page, not on reports pages |
| 539 | - if( RGForms::get_page() === 'entry_list' ) { |
|
| 539 | + if ( RGForms::get_page() === 'entry_list' ) { |
|
| 540 | 540 | |
| 541 | - $form_id = RGForms::get('id'); |
|
| 541 | + $form_id = RGForms::get( 'id' ); |
|
| 542 | 542 | |
| 543 | 543 | // If there are no forms identified, use the first form. That's how GF does it. |
| 544 | - if( empty( $form_id ) && class_exists('RGFormsModel') ) { |
|
| 544 | + if ( empty( $form_id ) && class_exists( 'RGFormsModel' ) ) { |
|
| 545 | 545 | $forms = gravityview_get_forms(); |
| 546 | - if( !empty( $forms ) ) { |
|
| 547 | - $form_id = $forms[0]['id']; |
|
| 546 | + if ( ! empty( $forms ) ) { |
|
| 547 | + $form_id = $forms[ 0 ][ 'id' ]; |
|
| 548 | 548 | } |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | $approvedcolumn = self::get_approved_column( $form_id ); |
| 552 | 552 | |
| 553 | - wp_register_style( 'gravityview_entries_list', plugins_url('assets/css/admin-entries-list.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
| 553 | + wp_register_style( 'gravityview_entries_list', plugins_url( 'assets/css/admin-entries-list.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
|
| 554 | 554 | wp_enqueue_style( 'gravityview_entries_list' ); |
| 555 | 555 | |
| 556 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 556 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 557 | 557 | |
| 558 | - wp_register_script( 'gravityview_gf_entries_scripts', plugins_url('assets/js/admin-entries-list'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version ); |
|
| 558 | + wp_register_script( 'gravityview_gf_entries_scripts', plugins_url( 'assets/js/admin-entries-list' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version ); |
|
| 559 | 559 | wp_enqueue_script( 'gravityview_gf_entries_scripts' ); |
| 560 | 560 | |
| 561 | 561 | wp_localize_script( 'gravityview_gf_entries_scripts', 'gvGlobals', array( |
| 562 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxgfentries'), |
|
| 562 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxgfentries' ), |
|
| 563 | 563 | 'form_id' => $form_id, |
| 564 | 564 | 'show_column' => (int)$this->show_approve_entry_column( $form_id ), |
| 565 | 565 | 'add_bulk_action' => (int)GVCommon::has_cap( 'gravityview_moderate_entries' ), |
| 566 | 566 | 'bulk_actions' => $this->get_bulk_actions( $form_id ), |
| 567 | 567 | 'bulk_message' => $this->bulk_update_message, |
| 568 | - 'approve_title' => __( 'Entry not approved for directory viewing. Click to approve this entry.', 'gravityview'), |
|
| 569 | - 'unapprove_title' => __( 'Entry approved for directory viewing. Click to disapprove this entry.', 'gravityview'), |
|
| 570 | - 'column_title' => __( 'Show entry in directory view?', 'gravityview'), |
|
| 571 | - 'column_link' => esc_url( add_query_arg( array('sort' => $approvedcolumn) ) ), |
|
| 568 | + 'approve_title' => __( 'Entry not approved for directory viewing. Click to approve this entry.', 'gravityview' ), |
|
| 569 | + 'unapprove_title' => __( 'Entry approved for directory viewing. Click to disapprove this entry.', 'gravityview' ), |
|
| 570 | + 'column_title' => __( 'Show entry in directory view?', 'gravityview' ), |
|
| 571 | + 'column_link' => esc_url( add_query_arg( array( 'sort' => $approvedcolumn ) ) ), |
|
| 572 | 572 | ) ); |
| 573 | 573 | |
| 574 | 574 | } |
@@ -611,8 +611,8 @@ discard block |
||
| 611 | 611 | // Sanitize the values, just to be sure. |
| 612 | 612 | foreach ( $bulk_actions as $key => $group ) { |
| 613 | 613 | foreach ( $group as $i => $action ) { |
| 614 | - $bulk_actions[ $key ][ $i ]['label'] = esc_html( $bulk_actions[ $key ][ $i ]['label'] ); |
|
| 615 | - $bulk_actions[ $key ][ $i ]['value'] = esc_attr( $bulk_actions[ $key ][ $i ]['value'] ); |
|
| 614 | + $bulk_actions[ $key ][ $i ][ 'label' ] = esc_html( $bulk_actions[ $key ][ $i ][ 'label' ] ); |
|
| 615 | + $bulk_actions[ $key ][ $i ][ 'value' ] = esc_attr( $bulk_actions[ $key ][ $i ][ 'value' ] ); |
|
| 616 | 616 | } |
| 617 | 617 | } |
| 618 | 618 | |
@@ -637,13 +637,13 @@ discard block |
||
| 637 | 637 | * @since 1.7.2 |
| 638 | 638 | * @param boolean $hide_if_no_connections |
| 639 | 639 | */ |
| 640 | - $hide_if_no_connections = apply_filters('gravityview/approve_entries/hide-if-no-connections', false ); |
|
| 640 | + $hide_if_no_connections = apply_filters( 'gravityview/approve_entries/hide-if-no-connections', false ); |
|
| 641 | 641 | |
| 642 | - if( $hide_if_no_connections ) { |
|
| 642 | + if ( $hide_if_no_connections ) { |
|
| 643 | 643 | |
| 644 | 644 | $connected_views = gravityview_get_connected_views( $form_id ); |
| 645 | 645 | |
| 646 | - if( empty( $connected_views ) ) { |
|
| 646 | + if ( empty( $connected_views ) ) { |
|
| 647 | 647 | $show_approve_column = false; |
| 648 | 648 | } |
| 649 | 649 | } |
@@ -653,18 +653,18 @@ discard block |
||
| 653 | 653 | * @param boolean $show_approve_column Whether the column will be shown |
| 654 | 654 | * @param int $form_id The ID of the Gravity Forms form for which entries are being shown |
| 655 | 655 | */ |
| 656 | - $show_approve_column = apply_filters('gravityview/approve_entries/show-column', $show_approve_column, $form_id ); |
|
| 656 | + $show_approve_column = apply_filters( 'gravityview/approve_entries/show-column', $show_approve_column, $form_id ); |
|
| 657 | 657 | |
| 658 | 658 | return $show_approve_column; |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | function register_gform_noconflict_script( $scripts ) { |
| 662 | - $scripts[] = 'gravityview_gf_entries_scripts'; |
|
| 662 | + $scripts[ ] = 'gravityview_gf_entries_scripts'; |
|
| 663 | 663 | return $scripts; |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | function register_gform_noconflict_style( $styles ) { |
| 667 | - $styles[] = 'gravityview_entries_list'; |
|
| 667 | + $styles[ ] = 'gravityview_entries_list'; |
|
| 668 | 668 | return $styles; |
| 669 | 669 | } |
| 670 | 670 | |