@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | protected function log( $level, $message, $context ) { |
| 29 | 29 | |
| 30 | 30 | $backtrace = debug_backtrace(); |
| 31 | - $location = $this->interpolate( "{class}{type}{function}", $backtrace[2] ); |
|
| 31 | + $location = $this->interpolate( "{class}{type}{function}", $backtrace[ 2 ] ); |
|
| 32 | 32 | |
| 33 | 33 | $message = $this->interpolate( "[$level, $location] $message", $context ); |
| 34 | 34 | |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | do_action( |
| 53 | 53 | sprintf( 'gravityview_log_%s_test', $action ), |
| 54 | 54 | $this->interpolate( $message, $context ), |
| 55 | - empty( $context['data'] ) ? array() : $context['data'] |
|
| 55 | + empty( $context[ 'data' ] ) ? array() : $context[ 'data' ] |
|
| 56 | 56 | ); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | do_action( |
| 60 | 60 | sprintf( 'gravityview_log_%s', $action ), |
| 61 | 61 | $this->interpolate( $message, $context ), |
| 62 | - empty( $context['data'] ) ? array() : $context['data'] |
|
| 62 | + empty( $context[ 'data' ] ) ? array() : $context[ 'data' ] |
|
| 63 | 63 | ); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return void |
| 38 | 38 | */ |
| 39 | - public function emergency($message, array $context = array()) |
|
| 39 | + public function emergency( $message, array $context = array() ) |
|
| 40 | 40 | { |
| 41 | - $this->log(LogLevel::EMERGENCY, $message, $context); |
|
| 41 | + $this->log( LogLevel::EMERGENCY, $message, $context ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return void |
| 54 | 54 | */ |
| 55 | - public function alert($message, array $context = array()) |
|
| 55 | + public function alert( $message, array $context = array() ) |
|
| 56 | 56 | { |
| 57 | - $this->log(LogLevel::ALERT, $message, $context); |
|
| 57 | + $this->log( LogLevel::ALERT, $message, $context ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return void |
| 69 | 69 | */ |
| 70 | - public function critical($message, array $context = array()) |
|
| 70 | + public function critical( $message, array $context = array() ) |
|
| 71 | 71 | { |
| 72 | - $this->log(LogLevel::CRITICAL, $message, $context); |
|
| 72 | + $this->log( LogLevel::CRITICAL, $message, $context ); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | * |
| 82 | 82 | * @return void |
| 83 | 83 | */ |
| 84 | - public function error($message, array $context = array()) |
|
| 84 | + public function error( $message, array $context = array() ) |
|
| 85 | 85 | { |
| 86 | - $this->log(LogLevel::ERROR, $message, $context); |
|
| 86 | + $this->log( LogLevel::ERROR, $message, $context ); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return void |
| 99 | 99 | */ |
| 100 | - public function warning($message, array $context = array()) |
|
| 100 | + public function warning( $message, array $context = array() ) |
|
| 101 | 101 | { |
| 102 | - $this->log(LogLevel::WARNING, $message, $context); |
|
| 102 | + $this->log( LogLevel::WARNING, $message, $context ); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return void |
| 112 | 112 | */ |
| 113 | - public function notice($message, array $context = array()) |
|
| 113 | + public function notice( $message, array $context = array() ) |
|
| 114 | 114 | { |
| 115 | - $this->log(LogLevel::NOTICE, $message, $context); |
|
| 115 | + $this->log( LogLevel::NOTICE, $message, $context ); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return void |
| 127 | 127 | */ |
| 128 | - public function info($message, array $context = array()) |
|
| 128 | + public function info( $message, array $context = array() ) |
|
| 129 | 129 | { |
| 130 | - $this->log(LogLevel::INFO, $message, $context); |
|
| 130 | + $this->log( LogLevel::INFO, $message, $context ); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @return void |
| 140 | 140 | */ |
| 141 | - public function debug($message, array $context = array()) |
|
| 141 | + public function debug( $message, array $context = array() ) |
|
| 142 | 142 | { |
| 143 | - $this->log(LogLevel::DEBUG, $message, $context); |
|
| 143 | + $this->log( LogLevel::DEBUG, $message, $context ); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return void |
| 32 | 32 | */ |
| 33 | 33 | public function __set( $key, $value ) { |
| 34 | - $this->_context[$key] = $value; |
|
| 34 | + $this->_context[ $key ] = $value; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @return mixed|null |
| 46 | 46 | */ |
| 47 | 47 | public function __get( $key ) { |
| 48 | - return isset( $this->_context[$key] ) ? $this->_context[$key] : null; |
|
| 48 | + return isset( $this->_context[ $key ] ) ? $this->_context[ $key ] : null; |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
@@ -55,10 +55,10 @@ |
||
| 55 | 55 | $search_criteria[ $key ] = $field_filters; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if ( ! empty( $b[ $key ]['mode'] ) ) { |
|
| 59 | - $search_criteria[ $key ]['mode' ] = $b[ $key ]['mode']; |
|
| 60 | - } else if ( ! empty( $a[ $key ]['mode'] ) ) { |
|
| 61 | - $search_criteria[ $key ]['mode' ] = $a[ $key ]['mode']; |
|
| 58 | + if ( ! empty( $b[ $key ][ 'mode' ] ) ) { |
|
| 59 | + $search_criteria[ $key ][ 'mode' ] = $b[ $key ][ 'mode' ]; |
|
| 60 | + } else if ( ! empty( $a[ $key ][ 'mode' ] ) ) { |
|
| 61 | + $search_criteria[ $key ][ 'mode' ] = $a[ $key ][ 'mode' ]; |
|
| 62 | 62 | } |
| 63 | 63 | break; |
| 64 | 64 | case 'start_date': |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @return void |
| 27 | 27 | */ |
| 28 | 28 | public function set( $key, $value ) { |
| 29 | - $this->settings[$key] = $value; |
|
| 29 | + $this->settings[ $key ] = $value; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @return mixed|null |
| 41 | 41 | */ |
| 42 | 42 | public function get( $key, $default = null ) { |
| 43 | - return isset( $this->settings[$key] ) ? $this->settings[$key] : $default; |
|
| 43 | + return isset( $this->settings[ $key ] ) ? $this->settings[ $key ] : $default; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -144,19 +144,19 @@ |
||
| 144 | 144 | public function from_configuration( $configuration ) { |
| 145 | 145 | $configuration = wp_parse_args( $configuration, $this->as_configuration() ); |
| 146 | 146 | |
| 147 | - $this->ID = $configuration['id']; |
|
| 148 | - $this->label = $configuration['label']; |
|
| 149 | - $this->show_label = $configuration['show_label'] == '1'; |
|
| 150 | - $this->custom_label = $configuration['custom_label']; |
|
| 151 | - $this->custom_class = $configuration['custom_class']; |
|
| 152 | - $this->cap = $configuration['only_loggedin'] == '1' ? $configuration['only_loggedin_cap'] : ''; |
|
| 153 | - $this->search_filter = $configuration['search_filter'] == '1'; |
|
| 154 | - $this->show_as_link = $configuration['show_as_link'] == '1'; |
|
| 147 | + $this->ID = $configuration[ 'id' ]; |
|
| 148 | + $this->label = $configuration[ 'label' ]; |
|
| 149 | + $this->show_label = $configuration[ 'show_label' ] == '1'; |
|
| 150 | + $this->custom_label = $configuration[ 'custom_label' ]; |
|
| 151 | + $this->custom_class = $configuration[ 'custom_class' ]; |
|
| 152 | + $this->cap = $configuration[ 'only_loggedin' ] == '1' ? $configuration[ 'only_loggedin_cap' ] : ''; |
|
| 153 | + $this->search_filter = $configuration[ 'search_filter' ] == '1'; |
|
| 154 | + $this->show_as_link = $configuration[ 'show_as_link' ] == '1'; |
|
| 155 | 155 | |
| 156 | 156 | /** Shared among all field types (sort of). */ |
| 157 | 157 | $shared_configuration_keys = array( |
| 158 | 158 | 'id', 'label', 'show_label', 'custom_label', 'custom_class', |
| 159 | - 'only_loggedin' ,'only_loggedin_cap', 'search_filter', 'show_as_link', |
|
| 159 | + 'only_loggedin', 'only_loggedin_cap', 'search_filter', 'show_as_link', |
|
| 160 | 160 | ); |
| 161 | 161 | |
| 162 | 162 | /** Everything else goes into the properties for now. @todo subclasses! */ |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | public function set_template_data( array $data, $var_name = 'data' ) { |
| 118 | 118 | global $wp_query; |
| 119 | 119 | |
| 120 | - $wp_query->query_vars[ $var_name ] = (object) $data; |
|
| 120 | + $wp_query->query_vars[ $var_name ] = (object)$data; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -130,8 +130,8 @@ discard block |
||
| 130 | 130 | public function unset_template_data() { |
| 131 | 131 | global $wp_query; |
| 132 | 132 | |
| 133 | - if ( isset( $wp_query->query_vars['data'] ) ) { |
|
| 134 | - unset( $wp_query->query_vars['data'] ); |
|
| 133 | + if ( isset( $wp_query->query_vars[ 'data' ] ) ) { |
|
| 134 | + unset( $wp_query->query_vars[ 'data' ] ); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | protected function get_template_file_names( $slug, $name ) { |
| 149 | 149 | $templates = array(); |
| 150 | 150 | if ( isset( $name ) ) { |
| 151 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 151 | + $templates[ ] = $slug . '-' . $name . '.php'; |
|
| 152 | 152 | } |
| 153 | - $templates[] = $slug . '.php'; |
|
| 153 | + $templates[ ] = $slug . '.php'; |
|
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | 156 | * Allow template choices to be filtered. |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $located = false; |
| 189 | 189 | |
| 190 | 190 | // Remove empty entries. |
| 191 | - $template_names = array_filter( (array) $template_names ); |
|
| 191 | + $template_names = array_filter( (array)$template_names ); |
|
| 192 | 192 | $template_paths = $this->get_template_paths(); |
| 193 | 193 | |
| 194 | 194 | // Try to find a template file. |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | // Only add this conditionally, so non-child themes don't redundantly check active theme twice. |
| 235 | 235 | if ( is_child_theme() ) { |
| 236 | - $file_paths[1] = trailingslashit( get_stylesheet_directory() ) . $theme_directory; |
|
| 236 | + $file_paths[ 1 ] = trailingslashit( get_stylesheet_directory() ) . $theme_directory; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -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 | } |
@@ -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 | /** |