@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * @see RGFormsModel::update_lead_property() Trigger when any entry property changes |
| 83 | 83 | */ |
| 84 | - foreach( $this->lead_db_columns as $column ) { |
|
| 84 | + foreach ( $this->lead_db_columns as $column ) { |
|
| 85 | 85 | add_action( 'gform_update_' . $column, array( $this, 'entry_status_changed' ), 10, 3 ); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | return; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - do_action( 'gravityview_log_debug', __METHOD__ . ' adding form ' . $entry['form_id'] . ' to blacklist because entry #' . $lead_id . ' was deleted', array( 'value' => $property_value, 'previous' => $previous_value ) ); |
|
| 117 | + do_action( 'gravityview_log_debug', __METHOD__ . ' adding form ' . $entry[ 'form_id' ] . ' to blacklist because entry #' . $lead_id . ' was deleted', array( 'value' => $property_value, 'previous' => $previous_value ) ); |
|
| 118 | 118 | |
| 119 | - $this->blacklist_add( $entry['form_id'] ); |
|
| 119 | + $this->blacklist_add( $entry[ 'form_id' ] ); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function entry_updated( $form, $lead_id ) { |
| 131 | 131 | |
| 132 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form ' . $form['id'] . ' to blacklist because entry #' . $lead_id . ' was updated' ); |
|
| 132 | + do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form ' . $form[ 'id' ] . ' to blacklist because entry #' . $lead_id . ' was updated' ); |
|
| 133 | 133 | |
| 134 | - $this->blacklist_add( $form['id'] ); |
|
| 134 | + $this->blacklist_add( $form[ 'id' ] ); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function entry_created( $entry, $form ) { |
| 148 | 148 | |
| 149 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_created] adding form ' . $form['id'] . ' to blacklist because entry #' . $entry['id'] . ' was created' ); |
|
| 149 | + do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_created] adding form ' . $form[ 'id' ] . ' to blacklist because entry #' . $entry[ 'id' ] . ' was created' ); |
|
| 150 | 150 | |
| 151 | - $this->blacklist_add( $form['id'] ); |
|
| 151 | + $this->blacklist_add( $form[ 'id' ] ); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -164,9 +164,9 @@ discard block |
||
| 164 | 164 | return; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_added] adding form ' . $form['id'] . ' to blacklist because entry #' . $entry['id'] . ' was added' ); |
|
| 167 | + do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_added] adding form ' . $form[ 'id' ] . ' to blacklist because entry #' . $entry[ 'id' ] . ' was added' ); |
|
| 168 | 168 | |
| 169 | - $this->blacklist_add( $form['id'] ); |
|
| 169 | + $this->blacklist_add( $form[ 'id' ] ); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | // Normally just one form, but supports multiple forms |
| 186 | 186 | // |
| 187 | 187 | // Array of IDs 12, 5, 14 would result in `f-12f-5f-14` |
| 188 | - $forms = 'f:' . implode( '&f:', (array) $form_ids ); |
|
| 188 | + $forms = 'f:' . implode( '&f:', (array)$form_ids ); |
|
| 189 | 189 | |
| 190 | 190 | // Prefix for transient keys |
| 191 | 191 | // Now the prefix would be: `gv-cache-f-12f-5f-14` |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | ) ); |
| 243 | 243 | |
| 244 | 244 | // Add the passed form IDs |
| 245 | - $blacklist = array_merge( (array) $blacklist, $form_ids ); |
|
| 245 | + $blacklist = array_merge( (array)$blacklist, $form_ids ); |
|
| 246 | 246 | |
| 247 | 247 | // Don't duplicate |
| 248 | 248 | $blacklist = array_unique( $blacklist ); |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | $blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() ); |
| 264 | 264 | |
| 265 | - $updated_list = array_diff( $blacklist, (array) $form_ids ); |
|
| 265 | + $updated_list = array_diff( $blacklist, (array)$form_ids ); |
|
| 266 | 266 | |
| 267 | 267 | do_action( 'gravityview_log_debug', 'GravityView_Cache[blacklist_remove] Removing form IDs from cache blacklist', array( |
| 268 | 268 | '$form_ids' => $form_ids, |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | return false; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - foreach ( (array) $form_ids as $form_id ) { |
|
| 298 | + foreach ( (array)$form_ids as $form_id ) { |
|
| 299 | 299 | |
| 300 | 300 | if ( in_array( $form_id, $blacklist ) ) { |
| 301 | 301 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | * @filter `gravityview_cache_time_{$filter_name}` Modify the cache time for a type of cache |
| 368 | 368 | * @param int $time_in_seconds Default: `DAY_IN_SECONDS` |
| 369 | 369 | */ |
| 370 | - $cache_time = (int) apply_filters( 'gravityview_cache_time_' . $filter_name, DAY_IN_SECONDS ); |
|
| 370 | + $cache_time = (int)apply_filters( 'gravityview_cache_time_' . $filter_name, DAY_IN_SECONDS ); |
|
| 371 | 371 | |
| 372 | 372 | do_action( 'gravityview_log_debug', 'GravityView_Cache[set] Setting cache with transient key ' . $this->key . ' for ' . $cache_time . ' seconds' ); |
| 373 | 373 | |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | return; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - foreach ( (array) $form_ids as $form_id ) { |
|
| 406 | + foreach ( (array)$form_ids as $form_id ) { |
|
| 407 | 407 | |
| 408 | 408 | $key = $this->get_cache_key_prefix( $form_id ); |
| 409 | 409 | |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | |
| 518 | 518 | if ( GVCommon::has_cap( 'edit_gravityviews' ) ) { |
| 519 | 519 | |
| 520 | - if ( isset( $_GET['cache'] ) || isset( $_GET['nocache'] ) ) { |
|
| 520 | + if ( isset( $_GET[ 'cache' ] ) || isset( $_GET[ 'nocache' ] ) ) { |
|
| 521 | 521 | |
| 522 | 522 | do_action( 'gravityview_log_debug', 'GravityView_Cache[use_cache] Not using cache: ?cache or ?nocache is in the URL' ); |
| 523 | 523 | |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | */ |
| 547 | 547 | $use_cache = apply_filters( 'gravityview_use_cache', $use_cache, $this ); |
| 548 | 548 | |
| 549 | - return (boolean) $use_cache; |
|
| 549 | + return (boolean)$use_cache; |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | public static function process_modifiers( $value, $merge_tag, $modifier, $field, $raw_value ) { |
| 46 | 46 | |
| 47 | 47 | // No modifier was set or the raw value was empty |
| 48 | - if( 'all_fields' === $merge_tag || '' === $modifier || ! is_string( $raw_value ) || '' === $raw_value ) { |
|
| 48 | + if ( 'all_fields' === $merge_tag || '' === $modifier || ! is_string( $raw_value ) || '' === $raw_value ) { |
|
| 49 | 49 | return $value; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | foreach ( $gv_modifiers as $gv_modifier => $method ) { |
| 62 | 62 | |
| 63 | 63 | // Only match the regex if it's the first modifer; this allows us to enforce our own modifier structure |
| 64 | - preg_match( '/^' . $gv_modifier .'/ism', $modifier, $matches ); |
|
| 64 | + preg_match( '/^' . $gv_modifier . '/ism', $modifier, $matches ); |
|
| 65 | 65 | |
| 66 | - if( ! empty( $matches ) ) { |
|
| 66 | + if ( ! empty( $matches ) ) { |
|
| 67 | 67 | // The called method is passed the raw value and the full matches array |
| 68 | 68 | $return = self::$method( $raw_value, $matches ); |
| 69 | 69 | break; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | private static function modifier_timestamp( $raw_value, $matches ) { |
| 89 | 89 | |
| 90 | - if( empty( $matches[0] ) ) { |
|
| 90 | + if ( empty( $matches[ 0 ] ) ) { |
|
| 91 | 91 | return $raw_value; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | private static function modifier_wpautop( $raw_value, $matches ) { |
| 113 | 113 | |
| 114 | - if( empty( $matches[0] ) || ! function_exists( 'wpautop' ) ) { |
|
| 114 | + if ( empty( $matches[ 0 ] ) || ! function_exists( 'wpautop' ) ) { |
|
| 115 | 115 | return $raw_value; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | private static function modifier_maxwords( $raw_value, $matches ) { |
| 137 | 137 | |
| 138 | - if( ! is_string( $raw_value ) || empty( $matches[1] ) || ! function_exists( 'wp_trim_words' ) ) { |
|
| 138 | + if ( ! is_string( $raw_value ) || empty( $matches[ 1 ] ) || ! function_exists( 'wp_trim_words' ) ) { |
|
| 139 | 139 | return $raw_value; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - $max = intval( $matches[1] ); |
|
| 142 | + $max = intval( $matches[ 1 ] ); |
|
| 143 | 143 | |
| 144 | 144 | $more_placeholder = '[GVMORE]'; |
| 145 | 145 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param bool $esc_html Pass return value through `esc_html()` |
| 172 | 172 | * @return string Text with variables maybe replaced |
| 173 | 173 | */ |
| 174 | - public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true ) { |
|
| 174 | + public static function replace_variables( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true ) { |
|
| 175 | 175 | |
| 176 | 176 | // TODO: This needs to be fixed in `/future/` branch |
| 177 | 177 | if ( is_a( $form, '\GV\Form' ) ) { |
@@ -202,9 +202,9 @@ discard block |
||
| 202 | 202 | * @internal Fixed $form['title'] in Gravity Forms |
| 203 | 203 | * @see https://github.com/gravityforms/gravityforms/pull/27/files |
| 204 | 204 | */ |
| 205 | - $form['title'] = isset( $form['title'] ) ? $form['title'] : ''; |
|
| 206 | - $form['id'] = isset( $form['id'] ) ? $form['id'] : ''; |
|
| 207 | - $form['fields'] = isset( $form['fields'] ) ? $form['fields'] : array(); |
|
| 205 | + $form[ 'title' ] = isset( $form[ 'title' ] ) ? $form[ 'title' ] : ''; |
|
| 206 | + $form[ 'id' ] = isset( $form[ 'id' ] ) ? $form[ 'id' ] : ''; |
|
| 207 | + $form[ 'fields' ] = isset( $form[ 'fields' ] ) ? $form[ 'fields' ] : array(); |
|
| 208 | 208 | |
| 209 | 209 | return GFCommon::replace_variables( $text, $form, $entry, $url_encode, $esc_html ); |
| 210 | 210 | } |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * |
| 225 | 225 | * @return mixed |
| 226 | 226 | */ |
| 227 | - public static function replace_gv_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
| 227 | + public static function replace_gv_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
| 228 | 228 | |
| 229 | 229 | /** |
| 230 | 230 | * This prevents the gform_replace_merge_tags filter from being called twice, as defined in: |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | * @see GFCommon::replace_variables_prepopulate() |
| 233 | 233 | * @todo Remove eventually: Gravity Forms fixed this issue in 1.9.14 |
| 234 | 234 | */ |
| 235 | - if( false === $form ) { |
|
| 235 | + if ( false === $form ) { |
|
| 236 | 236 | return $text; |
| 237 | 237 | } |
| 238 | 238 | |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | 'diff' => in_array( 'diff', $exploded ), // {date_created:diff} |
| 265 | 265 | 'raw' => in_array( 'raw', $exploded ), // {date_created:raw} |
| 266 | 266 | 'timestamp' => in_array( 'timestamp', $exploded ), // {date_created:timestamp} |
| 267 | - 'time' => in_array( 'time', $exploded ), // {date_created:time} |
|
| 267 | + 'time' => in_array( 'time', $exploded ), // {date_created:time} |
|
| 268 | 268 | ); |
| 269 | 269 | |
| 270 | 270 | $formatted_date = GVCommon::format_date( $date_created, $atts ); |
@@ -327,14 +327,14 @@ discard block |
||
| 327 | 327 | preg_match_all( "/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER ); |
| 328 | 328 | |
| 329 | 329 | // If there are no matches OR the Entry `created_by` isn't set or is 0 (no user) |
| 330 | - if( empty( $matches ) ) { |
|
| 330 | + if ( empty( $matches ) ) { |
|
| 331 | 331 | return $text; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | foreach ( $matches as $match ) { |
| 335 | 335 | |
| 336 | - $full_tag = $match[0]; |
|
| 337 | - $property = $match[1]; |
|
| 336 | + $full_tag = $match[ 0 ]; |
|
| 337 | + $property = $match[ 1 ]; |
|
| 338 | 338 | |
| 339 | 339 | $value = stripslashes_deep( rgget( $property ) ); |
| 340 | 340 | |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | * @since 1.15 |
| 359 | 359 | * @param bool $esc_html Whether to esc_html() the value. Default: `true` |
| 360 | 360 | */ |
| 361 | - $esc_html = apply_filters('gravityview/merge_tags/get/esc_html/' . $property, true ); |
|
| 361 | + $esc_html = apply_filters( 'gravityview/merge_tags/get/esc_html/' . $property, true ); |
|
| 362 | 362 | |
| 363 | 363 | $value = $esc_html ? esc_html( $value ) : $value; |
| 364 | 364 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | * @param[in] array $form Gravity Forms form array |
| 370 | 370 | * @param[in] array $entry Entry array |
| 371 | 371 | */ |
| 372 | - $value = apply_filters('gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry ); |
|
| 372 | + $value = apply_filters( 'gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry ); |
|
| 373 | 373 | |
| 374 | 374 | $text = str_replace( $full_tag, $value, $text ); |
| 375 | 375 | } |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | private function __construct() {} |
| 86 | 86 | |
| 87 | 87 | private function initialize() { |
| 88 | - add_action( 'wp', array( $this, 'parse_content'), 11 ); |
|
| 88 | + add_action( 'wp', array( $this, 'parse_content' ), 11 ); |
|
| 89 | 89 | add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 ); |
| 90 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
| 90 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 ); |
|
| 91 | 91 | |
| 92 | 92 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
| 93 | 93 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
@@ -237,12 +237,12 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | $this->context_view_id = $view_id; |
| 239 | 239 | |
| 240 | - } elseif ( isset( $_GET['gvid'] ) && $multiple_views ) { |
|
| 240 | + } elseif ( isset( $_GET[ 'gvid' ] ) && $multiple_views ) { |
|
| 241 | 241 | /** |
| 242 | 242 | * used on a has_multiple_views context |
| 243 | 243 | * @see GravityView_API::entry_link |
| 244 | 244 | */ |
| 245 | - $this->context_view_id = $_GET['gvid']; |
|
| 245 | + $this->context_view_id = $_GET[ 'gvid' ]; |
|
| 246 | 246 | |
| 247 | 247 | } elseif ( ! $multiple_views ) { |
| 248 | 248 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
@@ -285,24 +285,24 @@ discard block |
||
| 285 | 285 | global $wp_rewrite; |
| 286 | 286 | |
| 287 | 287 | $is_front_page = ( $query->is_home || $query->is_page ); |
| 288 | - $show_on_front = ( 'page' === get_option('show_on_front') ); |
|
| 289 | - $front_page_id = get_option('page_on_front'); |
|
| 288 | + $show_on_front = ( 'page' === get_option( 'show_on_front' ) ); |
|
| 289 | + $front_page_id = get_option( 'page_on_front' ); |
|
| 290 | 290 | |
| 291 | - if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
| 291 | + if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
| 292 | 292 | |
| 293 | 293 | // Force to be an array, potentially a query string ( entry=16 ) |
| 294 | 294 | $_query = wp_parse_args( $query->query ); |
| 295 | 295 | |
| 296 | 296 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. |
| 297 | - if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { |
|
| 298 | - unset( $_query['pagename'] ); |
|
| 297 | + if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) { |
|
| 298 | + unset( $_query[ 'pagename' ] ); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | // this is where will break from core wordpress |
| 302 | 302 | $ignore = array( 'preview', 'page', 'paged', 'cpage' ); |
| 303 | 303 | $endpoints = rgobj( $wp_rewrite, 'endpoints' ); |
| 304 | - foreach ( (array) $endpoints as $endpoint ) { |
|
| 305 | - $ignore[] = $endpoint[1]; |
|
| 304 | + foreach ( (array)$endpoints as $endpoint ) { |
|
| 305 | + $ignore[ ] = $endpoint[ 1 ]; |
|
| 306 | 306 | } |
| 307 | 307 | unset( $endpoints ); |
| 308 | 308 | |
@@ -312,21 +312,21 @@ discard block |
||
| 312 | 312 | // - The query includes keys that are associated with registered endpoints. `entry`, for example. |
| 313 | 313 | if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) { |
| 314 | 314 | |
| 315 | - $qv =& $query->query_vars; |
|
| 315 | + $qv = & $query->query_vars; |
|
| 316 | 316 | |
| 317 | 317 | // Prevent redirect when on the single entry endpoint |
| 318 | - if( self::is_single_entry() ) { |
|
| 318 | + if ( self::is_single_entry() ) { |
|
| 319 | 319 | add_filter( 'redirect_canonical', '__return_false' ); |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | $query->is_page = true; |
| 323 | 323 | $query->is_home = false; |
| 324 | - $qv['page_id'] = $front_page_id; |
|
| 324 | + $qv[ 'page_id' ] = $front_page_id; |
|
| 325 | 325 | |
| 326 | 326 | // Correct <!--nextpage--> for page_on_front |
| 327 | - if ( ! empty( $qv['paged'] ) ) { |
|
| 328 | - $qv['page'] = $qv['paged']; |
|
| 329 | - unset( $qv['paged'] ); |
|
| 327 | + if ( ! empty( $qv[ 'paged' ] ) ) { |
|
| 328 | + $qv[ 'page' ] = $qv[ 'paged' ]; |
|
| 329 | + unset( $qv[ 'paged' ] ); |
|
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
| 361 | 361 | |
| 362 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
| 362 | + $post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null ); |
|
| 363 | 363 | $this->setPostId( $post_id ); |
| 364 | 364 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
| 365 | 365 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | |
| 396 | 396 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method(); |
| 397 | 397 | |
| 398 | - if( 'post' === $search_method ) { |
|
| 398 | + if ( 'post' === $search_method ) { |
|
| 399 | 399 | $get = $_POST; |
| 400 | 400 | } else { |
| 401 | 401 | $get = $_GET; |
@@ -451,20 +451,20 @@ discard block |
||
| 451 | 451 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop |
| 452 | 452 | * @param array $entry Current entry |
| 453 | 453 | */ |
| 454 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry ); |
|
| 454 | + $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry ); |
|
| 455 | 455 | |
| 456 | 456 | if ( ! $apply_outside_loop ) { |
| 457 | 457 | return $title; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | // User reported WooCommerce doesn't pass two args. |
| 461 | - if ( empty( $passed_post_id ) ) { |
|
| 461 | + if ( empty( $passed_post_id ) ) { |
|
| 462 | 462 | return $title; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | // Don't modify the title for anything other than the current view/post. |
| 466 | 466 | // This is true for embedded shortcodes and Views. |
| 467 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
| 467 | + if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { |
|
| 468 | 468 | return $title; |
| 469 | 469 | } |
| 470 | 470 | |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | } else { |
| 488 | 488 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
| 489 | 489 | foreach ( gravityview()->views->all() as $_view ) { |
| 490 | - if ( intval( $_view->form->ID ) === intval( $entry['form_id'] ) ) { |
|
| 490 | + if ( intval( $_view->form->ID ) === intval( $entry[ 'form_id' ] ) ) { |
|
| 491 | 491 | $view = $_view; |
| 492 | 492 | break; |
| 493 | 493 | } |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | } else { |
| 500 | 500 | /** Deprecated. Use gravityview()->views->all() or gravityview()->request->all() */ |
| 501 | 501 | foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
| 502 | - if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { |
|
| 502 | + if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) { |
|
| 503 | 503 | $view_meta = $view_data; |
| 504 | 504 | break; |
| 505 | 505 | } |
@@ -514,12 +514,12 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | } else { |
| 516 | 516 | /** Deprecated stuff in the future. See the branch above. */ |
| 517 | - if ( ! empty( $view_meta['atts']['single_title'] ) ) { |
|
| 517 | + if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) { |
|
| 518 | 518 | |
| 519 | - $title = $view_meta['atts']['single_title']; |
|
| 519 | + $title = $view_meta[ 'atts' ][ 'single_title' ]; |
|
| 520 | 520 | |
| 521 | 521 | // We are allowing HTML in the fields, so no escaping the output |
| 522 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry ); |
|
| 522 | + $title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry ); |
|
| 523 | 523 | |
| 524 | 524 | $title = do_shortcode( $title ); |
| 525 | 525 | } |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | // Only render in the loop. Fixes issues with the_content filter being applied in places like the sidebar |
| 560 | - if( ! in_the_loop() ) { |
|
| 560 | + if ( ! in_the_loop() ) { |
|
| 561 | 561 | return $content; |
| 562 | 562 | } |
| 563 | 563 | |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | |
| 633 | 633 | $context = GravityView_View::getInstance()->getContext(); |
| 634 | 634 | |
| 635 | - switch( $context ) { |
|
| 635 | + switch ( $context ) { |
|
| 636 | 636 | case 'directory': |
| 637 | 637 | $tab = __( 'Multiple Entries', 'gravityview' ); |
| 638 | 638 | break; |
@@ -646,12 +646,12 @@ discard block |
||
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | |
| 649 | - $title = sprintf( esc_html_x('The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
| 649 | + $title = sprintf( esc_html_x( 'The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
| 650 | 650 | $edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $view_id, $context ) ); |
| 651 | - $action_text = sprintf( esc_html__('Add fields to %s', 'gravityview' ), $tab ); |
|
| 651 | + $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab ); |
|
| 652 | 652 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
| 653 | 653 | |
| 654 | - $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url(plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
| 654 | + $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
| 655 | 655 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message ); |
| 656 | 656 | |
| 657 | 657 | echo GVCommon::generate_notice( $output . $image, 'gv-error error', 'edit_gravityview', $view_id ); |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | public function render_view( $passed_args ) { |
| 683 | 683 | |
| 684 | 684 | // validate attributes |
| 685 | - if ( empty( $passed_args['id'] ) ) { |
|
| 685 | + if ( empty( $passed_args[ 'id' ] ) ) { |
|
| 686 | 686 | do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args ); |
| 687 | 687 | return null; |
| 688 | 688 | } |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | return null; |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | - $view_id = $passed_args['id']; |
|
| 707 | + $view_id = $passed_args[ 'id' ]; |
|
| 708 | 708 | |
| 709 | 709 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
| 710 | 710 | $view = gravityview()->views->get( $view_id ); |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | $passed_args = array_filter( $passed_args, 'strlen' ); |
| 730 | 730 | |
| 731 | 731 | //Override shortcode args over View template settings |
| 732 | - $atts = wp_parse_args( $passed_args, $view_data['atts'] ); |
|
| 732 | + $atts = wp_parse_args( $passed_args, $view_data[ 'atts' ] ); |
|
| 733 | 733 | |
| 734 | 734 | do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts ); |
| 735 | 735 | } |
@@ -753,14 +753,14 @@ discard block |
||
| 753 | 753 | * @since 1.15 |
| 754 | 754 | * @since 1.17.2 Added check for if a user has no caps but is logged in (member of multisite, but not any site). Treat as if logged-out. |
| 755 | 755 | */ |
| 756 | - if( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 756 | + if ( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 757 | 757 | |
| 758 | 758 | do_action( 'gravityview_log_debug', sprintf( '%s Returning: View %d is not visible by current user.', __METHOD__, $view_id ) ); |
| 759 | 759 | |
| 760 | 760 | return null; |
| 761 | 761 | } |
| 762 | 762 | |
| 763 | - if( $this->isGravityviewPostType() ) { |
|
| 763 | + if ( $this->isGravityviewPostType() ) { |
|
| 764 | 764 | |
| 765 | 765 | /** |
| 766 | 766 | * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode? |
@@ -776,10 +776,10 @@ discard block |
||
| 776 | 776 | $embed_only = $view->settings->get( 'embed_only' ); |
| 777 | 777 | } else { |
| 778 | 778 | /** Deprecated. View attributes moved to \GV\View::$settings. */ |
| 779 | - $embed_only = ! empty( $atts['embed_only'] ); |
|
| 779 | + $embed_only = ! empty( $atts[ 'embed_only' ] ); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
| 782 | + if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
| 783 | 783 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 784 | 784 | } |
| 785 | 785 | } |
@@ -795,13 +795,13 @@ discard block |
||
| 795 | 795 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
| 796 | 796 | $view_data = $view->as_data(); |
| 797 | 797 | $gravityview_view = new GravityView_View( $view_data ); |
| 798 | - $post_id = intval( $view->settings->get( 'post_id' ) ? : get_the_ID() ); |
|
| 798 | + $post_id = intval( $view->settings->get( 'post_id' ) ?: get_the_ID() ); |
|
| 799 | 799 | $template_id = $view->template ? $view->template->ID : null; |
| 800 | 800 | } else { |
| 801 | 801 | /** These constructs are deprecated. Use the new gravityview() wrapper. */ |
| 802 | 802 | $gravityview_view = new GravityView_View( $view_data ); |
| 803 | - $post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : get_the_ID(); |
|
| 804 | - $template_id = $view_data['template_id']; |
|
| 803 | + $post_id = ! empty( $atts[ 'post_id' ] ) ? intval( $atts[ 'post_id' ] ) : get_the_ID(); |
|
| 804 | + $template_id = $view_data[ 'template_id' ]; |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | $gravityview_view->setPostId( $post_id ); |
@@ -812,20 +812,20 @@ discard block |
||
| 812 | 812 | do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' ); |
| 813 | 813 | |
| 814 | 814 | //fetch template and slug |
| 815 | - $view_slug = apply_filters( 'gravityview_template_slug_'. $template_id, 'table', 'directory' ); |
|
| 815 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $template_id, 'table', 'directory' ); |
|
| 816 | 816 | |
| 817 | 817 | do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug ); |
| 818 | 818 | |
| 819 | 819 | /** |
| 820 | 820 | * Disable fetching initial entries for views that don't need it (DataTables) |
| 821 | 821 | */ |
| 822 | - $get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true ); |
|
| 822 | + $get_entries = apply_filters( 'gravityview_get_view_entries_' . $view_slug, true ); |
|
| 823 | 823 | |
| 824 | 824 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
| 825 | 825 | $hide_until_searched = $view->settings->get( 'hide_until_searched' ); |
| 826 | 826 | } else { |
| 827 | 827 | /** $atts is deprecated, use \GV\View:$settings */ |
| 828 | - $hide_until_searched = ! empty( $atts['hide_until_searched'] ); |
|
| 828 | + $hide_until_searched = ! empty( $atts[ 'hide_until_searched' ] ); |
|
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | /** |
@@ -843,12 +843,12 @@ discard block |
||
| 843 | 843 | $sort_columns = $view->settings->get( 'sort_columns' ); |
| 844 | 844 | } else { |
| 845 | 845 | /** $atts is deprecated, use \GV\View:$settings */ |
| 846 | - $sort_columns = ! empty( $atts['sort_columns'] ); |
|
| 846 | + $sort_columns = ! empty( $atts[ 'sort_columns' ] ); |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | if ( $sort_columns ) { |
| 850 | 850 | // add filter to enable column sorting |
| 851 | - add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 ); |
|
| 851 | + add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ), 100, 3 ); |
|
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
@@ -856,19 +856,19 @@ discard block |
||
| 856 | 856 | } else { |
| 857 | 857 | /** $atts is deprecated, use \GV\View:$settings */ |
| 858 | 858 | /** $view_data is depreacted, use \GV\View properties */ |
| 859 | - $view_entries = self::get_view_entries( $atts, $view_data['form_id'] ); |
|
| 859 | + $view_entries = self::get_view_entries( $atts, $view_data[ 'form_id' ] ); |
|
| 860 | 860 | } |
| 861 | 861 | |
| 862 | - do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) ); |
|
| 862 | + do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries[ 'count' ], sizeof( $view_entries[ 'entries' ] ) ) ); |
|
| 863 | 863 | |
| 864 | 864 | } else { |
| 865 | 865 | |
| 866 | 866 | $view_entries = array( 'count' => null, 'entries' => null, 'paging' => null ); |
| 867 | 867 | |
| 868 | - do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' ); |
|
| 868 | + do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_' . $view_slug . '` is false' ); |
|
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - $gravityview_view->setPaging( $view_entries['paging'] ); |
|
| 871 | + $gravityview_view->setPaging( $view_entries[ 'paging' ] ); |
|
| 872 | 872 | $gravityview_view->setContext( 'directory' ); |
| 873 | 873 | $sections = array( 'header', 'body', 'footer' ); |
| 874 | 874 | |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | do_action( 'gravityview_render_entry_' . $view->ID ); |
| 886 | 886 | } else { |
| 887 | 887 | /** $view_data is depreacted, use \GV\View properties */ |
| 888 | - do_action( 'gravityview_render_entry_'.$view_data['id'] ); |
|
| 888 | + do_action( 'gravityview_render_entry_' . $view_data[ 'id' ] ); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | $entry = $this->getEntry(); |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | do_action( 'gravityview_log_debug', '[render_view] Entry does not exist. This may be because of View filters limiting access.' ); |
| 897 | 897 | |
| 898 | 898 | // Only display warning once when multiple Views are embedded |
| 899 | - if( $view_id !== (int) GravityView_frontend::get_context_view_id() ) { |
|
| 899 | + if ( $view_id !== (int)GravityView_frontend::get_context_view_id() ) { |
|
| 900 | 900 | ob_end_clean(); |
| 901 | 901 | return null; |
| 902 | 902 | } |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | // important: do not remove this as it prevents fake attempts of displaying entries from other views/forms |
| 922 | 922 | $multiple_views = defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? gravityview()->views->count() > 1 : $this->getGvOutputData()->has_multiple_views(); |
| 923 | 923 | if ( $multiple_views && $view_id != $this->get_context_view_id() ) { |
| 924 | - do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '. $view_id ); |
|
| 924 | + do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: ' . $view_id ); |
|
| 925 | 925 | ob_end_clean(); |
| 926 | 926 | return null; |
| 927 | 927 | } |
@@ -931,14 +931,14 @@ discard block |
||
| 931 | 931 | do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug ); |
| 932 | 932 | |
| 933 | 933 | //fetch entry detail |
| 934 | - $view_entries['count'] = 1; |
|
| 935 | - $view_entries['entries'][] = $entry; |
|
| 936 | - do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] ); |
|
| 934 | + $view_entries[ 'count' ] = 1; |
|
| 935 | + $view_entries[ 'entries' ][ ] = $entry; |
|
| 936 | + do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries[ 'entries' ] ); |
|
| 937 | 937 | |
| 938 | 938 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { |
| 939 | 939 | $back_link_label = $view->settings->get( 'back_link_label', null ); |
| 940 | 940 | } else { |
| 941 | - $back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null; |
|
| 941 | + $back_link_label = isset( $atts[ 'back_link_label' ] ) ? $atts[ 'back_link_label' ] : null; |
|
| 942 | 942 | } |
| 943 | 943 | |
| 944 | 944 | // set back link label |
@@ -952,8 +952,8 @@ discard block |
||
| 952 | 952 | self::add_style( $template_id ); |
| 953 | 953 | |
| 954 | 954 | // Prepare to render view and set vars |
| 955 | - $gravityview_view->setEntries( $view_entries['entries'] ); |
|
| 956 | - $gravityview_view->setTotalEntries( $view_entries['count'] ); |
|
| 955 | + $gravityview_view->setEntries( $view_entries[ 'entries' ] ); |
|
| 956 | + $gravityview_view->setTotalEntries( $view_entries[ 'count' ] ); |
|
| 957 | 957 | |
| 958 | 958 | // If Edit |
| 959 | 959 | if ( 'edit' === gravityview_get_context() ) { |
@@ -970,7 +970,7 @@ discard block |
||
| 970 | 970 | |
| 971 | 971 | do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections ); |
| 972 | 972 | foreach ( $sections as $section ) { |
| 973 | - do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' ); |
|
| 973 | + do_action( 'gravityview_log_debug', '[render_view] Rendering ' . $section . ' section.' ); |
|
| 974 | 974 | $gravityview_view->render( $view_slug, $section, false ); |
| 975 | 975 | } |
| 976 | 976 | } |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | $datetime_format = 'Y-m-d H:i:s'; |
| 1025 | 1025 | $search_is_outside_view_bounds = false; |
| 1026 | 1026 | |
| 1027 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
| 1027 | + if ( ! empty( $search_criteria[ $key ] ) ) { |
|
| 1028 | 1028 | |
| 1029 | 1029 | $search_date = strtotime( $search_criteria[ $key ] ); |
| 1030 | 1030 | |
@@ -1052,14 +1052,14 @@ discard block |
||
| 1052 | 1052 | if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
| 1053 | 1053 | |
| 1054 | 1054 | // Then we override the search and re-set the start date |
| 1055 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
| 1055 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true ); |
|
| 1056 | 1056 | } |
| 1057 | 1057 | } |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
| 1060 | + if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { |
|
| 1061 | 1061 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
| 1062 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
| 1062 | + if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { |
|
| 1063 | 1063 | do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria ); |
| 1064 | 1064 | } |
| 1065 | 1065 | } |
@@ -1078,19 +1078,19 @@ discard block |
||
| 1078 | 1078 | public static function process_search_only_approved( $args, $search_criteria ) { |
| 1079 | 1079 | |
| 1080 | 1080 | /** @since 1.19 */ |
| 1081 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
| 1081 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
| 1082 | 1082 | do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries; showing all approval statuses' ); |
| 1083 | 1083 | return $search_criteria; |
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
| 1086 | + if ( ! empty( $args[ 'show_only_approved' ] ) ) { |
|
| 1087 | 1087 | |
| 1088 | - $search_criteria['field_filters'][] = array( |
|
| 1088 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 1089 | 1089 | 'key' => GravityView_Entry_Approval::meta_key, |
| 1090 | 1090 | 'value' => GravityView_Entry_Approval_Status::APPROVED |
| 1091 | 1091 | ); |
| 1092 | 1092 | |
| 1093 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
|
| 1093 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met |
|
| 1094 | 1094 | |
| 1095 | 1095 | do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria ); |
| 1096 | 1096 | } |
@@ -1117,18 +1117,18 @@ discard block |
||
| 1117 | 1117 | */ |
| 1118 | 1118 | public static function is_entry_approved( $entry, $args = array() ) { |
| 1119 | 1119 | |
| 1120 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
| 1120 | + if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { |
|
| 1121 | 1121 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
| 1122 | 1122 | return true; |
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | 1125 | /** @since 1.19 */ |
| 1126 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
| 1126 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
| 1127 | 1127 | do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries, so entry is approved for viewing' ); |
| 1128 | 1128 | return true; |
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | - $is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key ); |
|
| 1131 | + $is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key ); |
|
| 1132 | 1132 | |
| 1133 | 1133 | return GravityView_Entry_Approval_Status::is_approved( $is_approved ); |
| 1134 | 1134 | } |
@@ -1162,26 +1162,26 @@ discard block |
||
| 1162 | 1162 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria ); |
| 1163 | 1163 | |
| 1164 | 1164 | // implicity search |
| 1165 | - if ( ! empty( $args['search_value'] ) ) { |
|
| 1165 | + if ( ! empty( $args[ 'search_value' ] ) ) { |
|
| 1166 | 1166 | |
| 1167 | 1167 | // Search operator options. Options: `is` or `contains` |
| 1168 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
| 1168 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains'; |
|
| 1169 | 1169 | |
| 1170 | - $search_criteria['field_filters'][] = array( |
|
| 1170 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 1171 | 1171 | 'key' => rgget( 'search_field', $args ), // The field ID to search |
| 1172 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes. |
|
| 1172 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes. |
|
| 1173 | 1173 | 'operator' => $operator, |
| 1174 | 1174 | ); |
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | - if( $search_criteria !== $original_search_criteria ) { |
|
| 1177 | + if ( $search_criteria !== $original_search_criteria ) { |
|
| 1178 | 1178 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria ); |
| 1179 | 1179 | } |
| 1180 | 1180 | |
| 1181 | 1181 | // Handle setting date range |
| 1182 | 1182 | $search_criteria = self::process_search_dates( $args, $search_criteria ); |
| 1183 | 1183 | |
| 1184 | - if( $search_criteria !== $original_search_criteria ) { |
|
| 1184 | + if ( $search_criteria !== $original_search_criteria ) { |
|
| 1185 | 1185 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria ); |
| 1186 | 1186 | } |
| 1187 | 1187 | |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
| 1193 | 1193 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
| 1194 | 1194 | */ |
| 1195 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
| 1195 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args ); |
|
| 1196 | 1196 | |
| 1197 | 1197 | return $search_criteria; |
| 1198 | 1198 | } |
@@ -1308,7 +1308,7 @@ discard block |
||
| 1308 | 1308 | 'search_criteria' => $search_criteria, |
| 1309 | 1309 | 'sorting' => self::updateViewSorting( $args, $form_id ), |
| 1310 | 1310 | 'paging' => $paging, |
| 1311 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
| 1311 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true, |
|
| 1312 | 1312 | ); |
| 1313 | 1313 | |
| 1314 | 1314 | /** |
@@ -1333,7 +1333,7 @@ discard block |
||
| 1333 | 1333 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
| 1334 | 1334 | * @param array $args View configuration args. |
| 1335 | 1335 | */ |
| 1336 | - $parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id ); |
|
| 1336 | + $parameters = apply_filters( 'gravityview_get_entries_' . $args[ 'id' ], $parameters, $args, $form_id ); |
|
| 1337 | 1337 | |
| 1338 | 1338 | do_action( 'gravityview_log_debug', __METHOD__ . ': $parameters passed to gravityview_get_entries(): ', $parameters ); |
| 1339 | 1339 | |
@@ -1358,17 +1358,17 @@ discard block |
||
| 1358 | 1358 | $default_page_size = apply_filters( 'gravityview_default_page_size', 25 ); |
| 1359 | 1359 | |
| 1360 | 1360 | // Paging & offset |
| 1361 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : $default_page_size; |
|
| 1361 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : $default_page_size; |
|
| 1362 | 1362 | |
| 1363 | 1363 | if ( -1 === $page_size ) { |
| 1364 | 1364 | $page_size = PHP_INT_MAX; |
| 1365 | 1365 | } |
| 1366 | 1366 | |
| 1367 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
| 1367 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] ); |
|
| 1368 | 1368 | $offset = ( $curr_page - 1 ) * $page_size; |
| 1369 | 1369 | |
| 1370 | - if ( ! empty( $args['offset'] ) ) { |
|
| 1371 | - $offset += intval( $args['offset'] ); |
|
| 1370 | + if ( ! empty( $args[ 'offset' ] ) ) { |
|
| 1371 | + $offset += intval( $args[ 'offset' ] ); |
|
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | 1374 | $paging = array( |
@@ -1392,8 +1392,8 @@ discard block |
||
| 1392 | 1392 | */ |
| 1393 | 1393 | public static function updateViewSorting( $args, $form_id ) { |
| 1394 | 1394 | $sorting = array(); |
| 1395 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' ); |
|
| 1396 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' ); |
|
| 1395 | + $sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : rgar( $args, 'sort_field' ); |
|
| 1396 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : rgar( $args, 'sort_direction' ); |
|
| 1397 | 1397 | |
| 1398 | 1398 | $sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id ); |
| 1399 | 1399 | |
@@ -1433,11 +1433,11 @@ discard block |
||
| 1433 | 1433 | |
| 1434 | 1434 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
| 1435 | 1435 | |
| 1436 | - if( ! $sort_field ) { |
|
| 1436 | + if ( ! $sort_field ) { |
|
| 1437 | 1437 | return $sort_field_id; |
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | - switch ( $sort_field['type'] ) { |
|
| 1440 | + switch ( $sort_field[ 'type' ] ) { |
|
| 1441 | 1441 | |
| 1442 | 1442 | case 'address': |
| 1443 | 1443 | // Sorting by full address |
@@ -1454,7 +1454,7 @@ discard block |
||
| 1454 | 1454 | */ |
| 1455 | 1455 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
| 1456 | 1456 | |
| 1457 | - switch( strtolower( $address_part ) ){ |
|
| 1457 | + switch ( strtolower( $address_part ) ) { |
|
| 1458 | 1458 | case 'street': |
| 1459 | 1459 | $sort_field_id .= '.1'; |
| 1460 | 1460 | break; |
@@ -1539,7 +1539,7 @@ discard block |
||
| 1539 | 1539 | */ |
| 1540 | 1540 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
| 1541 | 1541 | |
| 1542 | - if ( empty( $single_entry ) ){ |
|
| 1542 | + if ( empty( $single_entry ) ) { |
|
| 1543 | 1543 | return false; |
| 1544 | 1544 | } else { |
| 1545 | 1545 | return $single_entry; |
@@ -1572,14 +1572,14 @@ discard block |
||
| 1572 | 1572 | $template_id = $view->template ? $view->template->ID : null; |
| 1573 | 1573 | $data = $view->as_data(); |
| 1574 | 1574 | } else { |
| 1575 | - $template_id = $data['template_id']; |
|
| 1575 | + $template_id = $data[ 'template_id' ]; |
|
| 1576 | 1576 | } |
| 1577 | 1577 | |
| 1578 | 1578 | /** |
| 1579 | 1579 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
| 1580 | 1580 | * @since 1.15 |
| 1581 | 1581 | */ |
| 1582 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 1582 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 1583 | 1583 | continue; |
| 1584 | 1584 | } |
| 1585 | 1585 | |
@@ -1591,7 +1591,7 @@ discard block |
||
| 1591 | 1591 | $lightbox = $view->settings->get( 'lightbox' ); |
| 1592 | 1592 | } else { |
| 1593 | 1593 | /** View data attributes are now stored in \GV\View::$settings */ |
| 1594 | - $lightbox = ! empty( $data['atts']['lightbox'] ); |
|
| 1594 | + $lightbox = ! empty( $data[ 'atts' ][ 'lightbox' ] ); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | // If the thickbox is enqueued, add dependencies |
@@ -1601,13 +1601,13 @@ discard block |
||
| 1601 | 1601 | * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox` |
| 1602 | 1602 | * @param string $script_slug If you want to use a different lightbox script, return the name of it here. |
| 1603 | 1603 | */ |
| 1604 | - $js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
| 1604 | + $js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
| 1605 | 1605 | |
| 1606 | 1606 | /** |
| 1607 | 1607 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox` |
| 1608 | 1608 | * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here. |
| 1609 | 1609 | */ |
| 1610 | - $css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
| 1610 | + $css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | 1613 | /** |
@@ -1615,19 +1615,19 @@ discard block |
||
| 1615 | 1615 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
| 1616 | 1616 | * @since 1.15 |
| 1617 | 1617 | */ |
| 1618 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
| 1619 | - $css_dependencies[] = 'dashicons'; |
|
| 1618 | + if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { |
|
| 1619 | + $css_dependencies[ ] = 'dashicons'; |
|
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | 1622 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
| 1623 | 1623 | |
| 1624 | 1624 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 1625 | 1625 | |
| 1626 | - wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true ); |
|
| 1626 | + wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ), GravityView_Plugin::version, true ); |
|
| 1627 | 1627 | |
| 1628 | 1628 | wp_enqueue_script( 'gravityview-fe-view' ); |
| 1629 | 1629 | |
| 1630 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
| 1630 | + if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { |
|
| 1631 | 1631 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
| 1632 | 1632 | } |
| 1633 | 1633 | |
@@ -1695,7 +1695,7 @@ discard block |
||
| 1695 | 1695 | } elseif ( empty( $template_id ) ) { |
| 1696 | 1696 | do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' ); |
| 1697 | 1697 | } else { |
| 1698 | - do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) ); |
|
| 1698 | + do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_' . $template_id ) ); |
|
| 1699 | 1699 | } |
| 1700 | 1700 | |
| 1701 | 1701 | } |
@@ -1720,11 +1720,11 @@ discard block |
||
| 1720 | 1720 | * Not a table-based template; don't add sort icons |
| 1721 | 1721 | * @since 1.12 |
| 1722 | 1722 | */ |
| 1723 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
| 1723 | + if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
| 1724 | 1724 | return $label; |
| 1725 | 1725 | } |
| 1726 | 1726 | |
| 1727 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
| 1727 | + if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { |
|
| 1728 | 1728 | return $label; |
| 1729 | 1729 | } |
| 1730 | 1730 | |
@@ -1732,29 +1732,29 @@ discard block |
||
| 1732 | 1732 | |
| 1733 | 1733 | $class = 'gv-sort'; |
| 1734 | 1734 | |
| 1735 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
| 1735 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] ); |
|
| 1736 | 1736 | |
| 1737 | 1737 | $sort_args = array( |
| 1738 | - 'sort' => $field['id'], |
|
| 1738 | + 'sort' => $field[ 'id' ], |
|
| 1739 | 1739 | 'dir' => 'asc', |
| 1740 | 1740 | ); |
| 1741 | 1741 | |
| 1742 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
| 1742 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
| 1743 | 1743 | //toggle sorting direction. |
| 1744 | - if ( 'asc' === $sorting['direction'] ) { |
|
| 1745 | - $sort_args['dir'] = 'desc'; |
|
| 1744 | + if ( 'asc' === $sorting[ 'direction' ] ) { |
|
| 1745 | + $sort_args[ 'dir' ] = 'desc'; |
|
| 1746 | 1746 | $class .= ' gv-icon-sort-desc'; |
| 1747 | 1747 | } else { |
| 1748 | - $sort_args['dir'] = 'asc'; |
|
| 1748 | + $sort_args[ 'dir' ] = 'asc'; |
|
| 1749 | 1749 | $class .= ' gv-icon-sort-asc'; |
| 1750 | 1750 | } |
| 1751 | 1751 | } else { |
| 1752 | 1752 | $class .= ' gv-icon-caret-up-down'; |
| 1753 | 1753 | } |
| 1754 | 1754 | |
| 1755 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
| 1755 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) ); |
|
| 1756 | 1756 | |
| 1757 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
| 1757 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label; |
|
| 1758 | 1758 | |
| 1759 | 1759 | } |
| 1760 | 1760 | |
@@ -1772,7 +1772,7 @@ discard block |
||
| 1772 | 1772 | |
| 1773 | 1773 | $field_type = $field_id; |
| 1774 | 1774 | |
| 1775 | - if( is_numeric( $field_id ) ) { |
|
| 1775 | + if ( is_numeric( $field_id ) ) { |
|
| 1776 | 1776 | $field = GFFormsModel::get_field( $form, $field_id ); |
| 1777 | 1777 | $field_type = $field->type; |
| 1778 | 1778 | } |
@@ -1795,7 +1795,7 @@ discard block |
||
| 1795 | 1795 | return false; |
| 1796 | 1796 | } |
| 1797 | 1797 | |
| 1798 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
| 1798 | + return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
| 1799 | 1799 | |
| 1800 | 1800 | } |
| 1801 | 1801 | |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $form = false; |
| 128 | 128 | |
| 129 | - if( $entry ) { |
|
| 130 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
| 129 | + if ( $entry ) { |
|
| 130 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | return $form; |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | $has_transaction_data = rgar( $entry, $meta, false ); |
| 195 | 195 | |
| 196 | - if( ! empty( $has_transaction_data ) ) { |
|
| 196 | + if ( ! empty( $has_transaction_data ) ) { |
|
| 197 | 197 | break; |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - return (bool) $has_transaction_data; |
|
| 201 | + return (bool)$has_transaction_data; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
| 238 | 238 | |
| 239 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
| 239 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
| 240 | 240 | |
| 241 | 241 | return $result; |
| 242 | 242 | } |
@@ -253,10 +253,10 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
| 255 | 255 | */ |
| 256 | - public static function get_forms( $active = true, $trash = false ) { |
|
| 256 | + public static function get_forms( $active = true, $trash = false ) { |
|
| 257 | 257 | $forms = array(); |
| 258 | 258 | if ( class_exists( 'GFAPI' ) ) { |
| 259 | - if( 'any' === $active ) { |
|
| 259 | + if ( 'any' === $active ) { |
|
| 260 | 260 | $active_forms = GFAPI::get_forms( true, $trash ); |
| 261 | 261 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
| 262 | 262 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -287,9 +287,9 @@ discard block |
||
| 287 | 287 | $has_post_fields = false; |
| 288 | 288 | |
| 289 | 289 | if ( $form ) { |
| 290 | - foreach ( $form['fields'] as $field ) { |
|
| 291 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
| 292 | - $fields["{$field['id']}"] = array( |
|
| 290 | + foreach ( $form[ 'fields' ] as $field ) { |
|
| 291 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
| 292 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
| 293 | 293 | 'label' => rgar( $field, 'label' ), |
| 294 | 294 | 'parent' => null, |
| 295 | 295 | 'type' => rgar( $field, 'type' ), |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | ); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
| 302 | - foreach ( $field['inputs'] as $input ) { |
|
| 301 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
| 302 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
| 303 | 303 | |
| 304 | - if( ! empty( $input['isHidden'] ) ) { |
|
| 304 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
| 305 | 305 | continue; |
| 306 | 306 | } |
| 307 | 307 | |
@@ -309,10 +309,10 @@ discard block |
||
| 309 | 309 | * @hack |
| 310 | 310 | * In case of email/email confirmation, the input for email has the same id as the parent field |
| 311 | 311 | */ |
| 312 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
| 312 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
| 313 | 313 | continue; |
| 314 | 314 | } |
| 315 | - $fields["{$input['id']}"] = array( |
|
| 315 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
| 316 | 316 | 'label' => rgar( $input, 'label' ), |
| 317 | 317 | 'customLabel' => rgar( $input, 'customLabel' ), |
| 318 | 318 | 'parent' => $field, |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
| 327 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
| 327 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
| 328 | 328 | $has_product_fields = true; |
| 329 | 329 | } |
| 330 | 330 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | * @since 1.7 |
| 339 | 339 | */ |
| 340 | 340 | if ( $has_post_fields ) { |
| 341 | - $fields['post_id'] = array( |
|
| 341 | + $fields[ 'post_id' ] = array( |
|
| 342 | 342 | 'label' => __( 'Post ID', 'gravityview' ), |
| 343 | 343 | 'type' => 'post_id', |
| 344 | 344 | ); |
@@ -351,11 +351,11 @@ discard block |
||
| 351 | 351 | foreach ( $payment_fields as $payment_field ) { |
| 352 | 352 | |
| 353 | 353 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
| 354 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
| 354 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
| 355 | 355 | continue; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - $fields["{$payment_field->name}"] = array( |
|
| 358 | + $fields[ "{$payment_field->name}" ] = array( |
|
| 359 | 359 | 'label' => $payment_field->label, |
| 360 | 360 | 'desc' => $payment_field->description, |
| 361 | 361 | 'type' => $payment_field->name, |
@@ -387,9 +387,9 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | $fields = array(); |
| 389 | 389 | |
| 390 | - foreach ( $extra_fields as $key => $field ){ |
|
| 391 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
| 392 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
| 390 | + foreach ( $extra_fields as $key => $field ) { |
|
| 391 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
| 392 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
| 393 | 393 | } |
| 394 | 394 | } |
| 395 | 395 | |
@@ -429,32 +429,32 @@ discard block |
||
| 429 | 429 | 'search_criteria' => null, |
| 430 | 430 | 'sorting' => null, |
| 431 | 431 | 'paging' => null, |
| 432 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
| 432 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
| 433 | 433 | ); |
| 434 | 434 | |
| 435 | 435 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
| 436 | 436 | |
| 437 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
| 438 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
| 437 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 438 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
| 439 | 439 | |
| 440 | 440 | if ( ! is_array( $filter ) ) { |
| 441 | 441 | continue; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | // By default, we want searches to be wildcard for each field. |
| 445 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
| 445 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
| 446 | 446 | |
| 447 | 447 | /** |
| 448 | 448 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
| 449 | 449 | * @param string $operator Existing search operator |
| 450 | 450 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
| 451 | 451 | */ |
| 452 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
| 452 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | // don't send just the [mode] without any field filter. |
| 456 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
| 457 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
| 456 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 457 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | } |
@@ -465,21 +465,21 @@ discard block |
||
| 465 | 465 | * Prepare date formats to be in Gravity Forms DB format; |
| 466 | 466 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
| 467 | 467 | */ |
| 468 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
| 468 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
| 469 | 469 | |
| 470 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
| 470 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
| 471 | 471 | |
| 472 | 472 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
| 473 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
| 473 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 474 | 474 | |
| 475 | 475 | if ( $date ) { |
| 476 | 476 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
| 477 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 477 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 478 | 478 | } else { |
| 479 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
| 479 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] ); |
|
| 480 | 480 | |
| 481 | 481 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
| 482 | - unset( $criteria['search_criteria'][ $key ] ); |
|
| 482 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | } |
@@ -498,14 +498,14 @@ discard block |
||
| 498 | 498 | |
| 499 | 499 | // Calculate the context view id and send it to the advanced filter |
| 500 | 500 | if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
| 501 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 501 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 502 | 502 | } elseif ( $multiple_original ) { |
| 503 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 503 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
| 504 | 504 | } elseif ( 'delete' === GFForms::get( 'action' ) ) { |
| 505 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
| 506 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
| 505 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
| 506 | + } elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { |
|
| 507 | 507 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
| 508 | - $criteria['context_view_id'] = null; |
|
| 508 | + $criteria[ 'context_view_id' ] = null; |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | /** |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | * @param array $form_ids Forms to search |
| 515 | 515 | * @param int $view_id ID of the view being used to search |
| 516 | 516 | */ |
| 517 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
| 517 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
| 518 | 518 | |
| 519 | 519 | return (array)$criteria; |
| 520 | 520 | } |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | /** Reduce # of database calls */ |
| 545 | 545 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
| 546 | 546 | |
| 547 | - if ( ! empty( $criteria['cache'] ) ) { |
|
| 547 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
| 548 | 548 | |
| 549 | 549 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
| 550 | 550 | |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | |
| 553 | 553 | // Still update the total count when using cached results |
| 554 | 554 | if ( ! is_null( $total ) ) { |
| 555 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
| 555 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | $return = $entries; |
@@ -572,9 +572,9 @@ discard block |
||
| 572 | 572 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
| 573 | 573 | |
| 574 | 574 | // No entries returned from gravityview_before_get_entries |
| 575 | - if( is_null( $entries ) ) { |
|
| 575 | + if ( is_null( $entries ) ) { |
|
| 576 | 576 | |
| 577 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
| 577 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
| 578 | 578 | |
| 579 | 579 | if ( is_wp_error( $entries ) ) { |
| 580 | 580 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
| 586 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
| 587 | 587 | |
| 588 | 588 | // Cache results |
| 589 | 589 | $Cache->set( $entries, 'entries' ); |
@@ -688,12 +688,12 @@ discard block |
||
| 688 | 688 | */ |
| 689 | 689 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
| 690 | 690 | |
| 691 | - if( $check_entry_display ) { |
|
| 691 | + if ( $check_entry_display ) { |
|
| 692 | 692 | // Is the entry allowed |
| 693 | 693 | $entry = self::check_entry_display( $entry ); |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | - if( is_wp_error( $entry ) ) { |
|
| 696 | + if ( is_wp_error( $entry ) ) { |
|
| 697 | 697 | do_action( 'gravityview_log_error', __METHOD__ . ': ' . $entry->get_error_message() ); |
| 698 | 698 | return false; |
| 699 | 699 | } |
@@ -725,12 +725,12 @@ discard block |
||
| 725 | 725 | |
| 726 | 726 | $value = false; |
| 727 | 727 | |
| 728 | - if( 'context' === $val1 ) { |
|
| 728 | + if ( 'context' === $val1 ) { |
|
| 729 | 729 | |
| 730 | 730 | $matching_contexts = array( $val2 ); |
| 731 | 731 | |
| 732 | 732 | // We allow for non-standard contexts. |
| 733 | - switch( $val2 ) { |
|
| 733 | + switch ( $val2 ) { |
|
| 734 | 734 | // Check for either single or edit |
| 735 | 735 | case 'singular': |
| 736 | 736 | $matching_contexts = array( 'single', 'edit' ); |
@@ -786,76 +786,76 @@ discard block |
||
| 786 | 786 | public static function check_entry_display( $entry ) { |
| 787 | 787 | |
| 788 | 788 | if ( ! $entry || is_wp_error( $entry ) ) { |
| 789 | - return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); |
|
| 789 | + return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry ); |
|
| 790 | 790 | } |
| 791 | 791 | |
| 792 | - if ( empty( $entry['form_id'] ) ) { |
|
| 792 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
| 793 | 793 | return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | $criteria = self::calculate_get_entries_criteria(); |
| 797 | 797 | |
| 798 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
| 798 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
| 799 | 799 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
| 800 | 800 | return $entry; |
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | // Make sure the current View is connected to the same form as the Entry |
| 804 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
| 805 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
| 804 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
| 805 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
| 806 | 806 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
| 807 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
| 808 | - return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
| 807 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
| 808 | + return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
| 809 | 809 | } |
| 810 | 810 | } |
| 811 | 811 | |
| 812 | - $search_criteria = $criteria['search_criteria']; |
|
| 812 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
| 813 | 813 | |
| 814 | 814 | // check entry status |
| 815 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
| 816 | - return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
| 815 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
| 816 | + return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | // check entry date |
| 820 | 820 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
| 821 | 821 | |
| 822 | 822 | // field_filters |
| 823 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
| 823 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
| 824 | 824 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
| 825 | 825 | return $entry; |
| 826 | 826 | } |
| 827 | 827 | |
| 828 | - $filters = $search_criteria['field_filters']; |
|
| 828 | + $filters = $search_criteria[ 'field_filters' ]; |
|
| 829 | 829 | |
| 830 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
| 830 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
| 831 | 831 | |
| 832 | 832 | // Prevent the mode from being processed below |
| 833 | - unset( $filters['mode'] ); |
|
| 833 | + unset( $filters[ 'mode' ] ); |
|
| 834 | 834 | |
| 835 | - $form = self::get_form( $entry['form_id'] ); |
|
| 835 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
| 836 | 836 | |
| 837 | 837 | foreach ( $filters as $filter ) { |
| 838 | 838 | |
| 839 | - if ( ! isset( $filter['key'] ) ) { |
|
| 839 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
| 840 | 840 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Filter key not set', $filter ); |
| 841 | 841 | continue; |
| 842 | 842 | } |
| 843 | 843 | |
| 844 | - $k = $filter['key']; |
|
| 844 | + $k = $filter[ 'key' ]; |
|
| 845 | 845 | |
| 846 | 846 | $field = self::get_field( $form, $k ); |
| 847 | 847 | |
| 848 | 848 | if ( is_null( $field ) ) { |
| 849 | 849 | $field_value = isset( $entry[ $k ] ) ? $entry[ $k ] : null; |
| 850 | 850 | } else { |
| 851 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 851 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 852 | 852 | // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it |
| 853 | 853 | $field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? rgar( $field_value, $k ) : $field_value; |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
| 856 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
| 857 | 857 | |
| 858 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
| 858 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
| 859 | 859 | |
| 860 | 860 | // Any match is all we need to know |
| 861 | 861 | if ( $is_value_match && 'any' === $mode ) { |
@@ -864,7 +864,7 @@ discard block |
||
| 864 | 864 | |
| 865 | 865 | // Any failed match is a total fail |
| 866 | 866 | if ( ! $is_value_match && 'all' === $mode ) { |
| 867 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
| 867 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved: all conditions were met' ); |
| 875 | 875 | return $entry; |
| 876 | 876 | } else { |
| 877 | - return new WP_Error('failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
| 877 | + return new WP_Error( 'failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | } |
@@ -915,18 +915,18 @@ discard block |
||
| 915 | 915 | * Gravity Forms code to adjust date to locally-configured Time Zone |
| 916 | 916 | * @see GFCommon::format_date() for original code |
| 917 | 917 | */ |
| 918 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 918 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 919 | 919 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
| 920 | 920 | |
| 921 | - $format = rgar( $atts, 'format' ); |
|
| 922 | - $is_human = ! empty( $atts['human'] ); |
|
| 923 | - $is_diff = ! empty( $atts['diff'] ); |
|
| 924 | - $is_raw = ! empty( $atts['raw'] ); |
|
| 925 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
| 926 | - $include_time = ! empty( $atts['time'] ); |
|
| 921 | + $format = rgar( $atts, 'format' ); |
|
| 922 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
| 923 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
| 924 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
| 925 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
| 926 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
| 927 | 927 | |
| 928 | 928 | // If we're using time diff, we want to have a different default format |
| 929 | - if( empty( $format ) ) { |
|
| 929 | + if ( empty( $format ) ) { |
|
| 930 | 930 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
| 931 | 931 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
| 932 | 932 | } |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | // If raw was specified, don't modify the stored value |
| 935 | 935 | if ( $is_raw ) { |
| 936 | 936 | $formatted_date = $date_string; |
| 937 | - } elseif( $is_timestamp ) { |
|
| 937 | + } elseif ( $is_timestamp ) { |
|
| 938 | 938 | $formatted_date = $date_local_timestamp; |
| 939 | 939 | } elseif ( $is_diff ) { |
| 940 | 940 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | |
| 969 | 969 | $label = rgar( $field, 'label' ); |
| 970 | 970 | |
| 971 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 971 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
| 972 | 972 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
| 973 | 973 | } |
| 974 | 974 | |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | $form = GFAPI::get_form( $form ); |
| 997 | 997 | } |
| 998 | 998 | |
| 999 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
| 999 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
| 1000 | 1000 | return GFFormsModel::get_field( $form, $field_id ); |
| 1001 | 1001 | } else { |
| 1002 | 1002 | return null; |
@@ -1043,19 +1043,19 @@ discard block |
||
| 1043 | 1043 | $shortcodes = array(); |
| 1044 | 1044 | |
| 1045 | 1045 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
| 1046 | - if ( empty( $matches ) ){ |
|
| 1046 | + if ( empty( $matches ) ) { |
|
| 1047 | 1047 | return false; |
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | 1050 | foreach ( $matches as $shortcode ) { |
| 1051 | - if ( $tag === $shortcode[2] ) { |
|
| 1051 | + if ( $tag === $shortcode[ 2 ] ) { |
|
| 1052 | 1052 | |
| 1053 | 1053 | // Changed this to $shortcode instead of true so we get the parsed atts. |
| 1054 | - $shortcodes[] = $shortcode; |
|
| 1054 | + $shortcodes[ ] = $shortcode; |
|
| 1055 | 1055 | |
| 1056 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
| 1057 | - foreach( $results as $result ) { |
|
| 1058 | - $shortcodes[] = $result; |
|
| 1056 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
| 1057 | + foreach ( $results as $result ) { |
|
| 1058 | + $shortcodes[ ] = $result; |
|
| 1059 | 1059 | } |
| 1060 | 1060 | } |
| 1061 | 1061 | } |
@@ -1199,7 +1199,7 @@ discard block |
||
| 1199 | 1199 | public static function get_directory_fields( $post_id, $apply_filter = true ) { |
| 1200 | 1200 | $fields = get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
| 1201 | 1201 | |
| 1202 | - if( $apply_filter ) { |
|
| 1202 | + if ( $apply_filter ) { |
|
| 1203 | 1203 | /** |
| 1204 | 1204 | * @filter `gravityview/configuration/fields` Filter the View fields' configuration array |
| 1205 | 1205 | * @since 1.6.5 |
@@ -1222,7 +1222,7 @@ discard block |
||
| 1222 | 1222 | * @return string html |
| 1223 | 1223 | */ |
| 1224 | 1224 | public static function get_sortable_fields( $formid, $current = '' ) { |
| 1225 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
| 1225 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
| 1226 | 1226 | |
| 1227 | 1227 | if ( empty( $formid ) ) { |
| 1228 | 1228 | return $output; |
@@ -1235,11 +1235,11 @@ discard block |
||
| 1235 | 1235 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
| 1236 | 1236 | |
| 1237 | 1237 | foreach ( $fields as $id => $field ) { |
| 1238 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1238 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1239 | 1239 | continue; |
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
| 1242 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
| 1243 | 1243 | } |
| 1244 | 1244 | } |
| 1245 | 1245 | |
@@ -1274,9 +1274,9 @@ discard block |
||
| 1274 | 1274 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1275 | 1275 | |
| 1276 | 1276 | // TODO: Convert to using array_filter |
| 1277 | - foreach( $fields as $id => $field ) { |
|
| 1277 | + foreach ( $fields as $id => $field ) { |
|
| 1278 | 1278 | |
| 1279 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1279 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 1280 | 1280 | unset( $fields[ $id ] ); |
| 1281 | 1281 | } |
| 1282 | 1282 | } |
@@ -1317,14 +1317,14 @@ discard block |
||
| 1317 | 1317 | * @param int|array $field field key or field array |
| 1318 | 1318 | * @return boolean |
| 1319 | 1319 | */ |
| 1320 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1320 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1321 | 1321 | |
| 1322 | 1322 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
| 1323 | 1323 | $form = self::get_form( $form ); |
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | 1326 | // If entry meta, it's a string. Otherwise, numeric |
| 1327 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1327 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1328 | 1328 | $type = $field; |
| 1329 | 1329 | } else { |
| 1330 | 1330 | $type = self::get_field_type( $form, $field ); |
@@ -1338,9 +1338,9 @@ discard block |
||
| 1338 | 1338 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
| 1339 | 1339 | |
| 1340 | 1340 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
| 1341 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1342 | - if( true === $gv_field->is_numeric ) { |
|
| 1343 | - $numeric_types[] = $gv_field->is_numeric; |
|
| 1341 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1342 | + if ( true === $gv_field->is_numeric ) { |
|
| 1343 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
| 1344 | 1344 | } |
| 1345 | 1345 | } |
| 1346 | 1346 | |
@@ -1490,18 +1490,18 @@ discard block |
||
| 1490 | 1490 | $final_atts = array_filter( $final_atts ); |
| 1491 | 1491 | |
| 1492 | 1492 | // If the href wasn't passed as an attribute, use the value passed to the function |
| 1493 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
| 1494 | - $final_atts['href'] = $href; |
|
| 1493 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
| 1494 | + $final_atts[ 'href' ] = $href; |
|
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | - $final_atts['href'] = esc_url_raw( $href ); |
|
| 1497 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
| 1498 | 1498 | |
| 1499 | 1499 | /** |
| 1500 | 1500 | * Fix potential security issue with target=_blank |
| 1501 | 1501 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
| 1502 | 1502 | */ |
| 1503 | - if( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
| 1504 | - $final_atts['rel'] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1503 | + if ( '_blank' === rgar( $final_atts, 'target' ) ) { |
|
| 1504 | + $final_atts[ 'rel' ] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
| 1505 | 1505 | } |
| 1506 | 1506 | |
| 1507 | 1507 | // Sort the attributes alphabetically, to help testing |
@@ -1513,7 +1513,7 @@ discard block |
||
| 1513 | 1513 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | - if( '' !== $output ) { |
|
| 1516 | + if ( '' !== $output ) { |
|
| 1517 | 1517 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
| 1518 | 1518 | } |
| 1519 | 1519 | |
@@ -1540,7 +1540,7 @@ discard block |
||
| 1540 | 1540 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
| 1541 | 1541 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
| 1542 | 1542 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
| 1543 | - $merged[] = $value; |
|
| 1543 | + $merged[ ] = $value; |
|
| 1544 | 1544 | } else { |
| 1545 | 1545 | $merged[ $key ] = $value; |
| 1546 | 1546 | } |
@@ -1573,7 +1573,7 @@ discard block |
||
| 1573 | 1573 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
| 1574 | 1574 | * @param array $settings Settings array, with `number` key defining the # of users to display |
| 1575 | 1575 | */ |
| 1576 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1576 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1577 | 1577 | |
| 1578 | 1578 | return get_users( $get_users_settings ); |
| 1579 | 1579 | } |
@@ -1593,11 +1593,11 @@ discard block |
||
| 1593 | 1593 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
| 1594 | 1594 | |
| 1595 | 1595 | // If $cap is defined, only show notice if user has capability |
| 1596 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1596 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
| 1597 | 1597 | return ''; |
| 1598 | 1598 | } |
| 1599 | 1599 | |
| 1600 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1600 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
| 1601 | 1601 | } |
| 1602 | 1602 | |
| 1603 | 1603 | /** |