@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | // Add the list columns |
63 | 63 | foreach ( $list_fields as $list_field ) { |
64 | 64 | |
65 | - if( empty( $list_field->enableColumns ) ) { |
|
65 | + if ( empty( $list_field->enableColumns ) ) { |
|
66 | 66 | continue; |
67 | 67 | } |
68 | 68 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | // If there are columns, add them under the parent field |
86 | - if( ! empty( $list_columns ) ) { |
|
86 | + if ( ! empty( $list_columns ) ) { |
|
87 | 87 | |
88 | 88 | $index = array_search( $list_field->id, array_keys( $fields ) ) + 1; |
89 | 89 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * Merge the $list_columns into the $fields array at $index |
92 | 92 | * @see https://stackoverflow.com/a/1783125 |
93 | 93 | */ |
94 | - $fields = array_slice( $fields, 0, $index, true) + $list_columns + array_slice( $fields, $index, null, true); |
|
94 | + $fields = array_slice( $fields, 0, $index, true ) + $list_columns + array_slice( $fields, $index, null, true ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | unset( $list_columns, $index, $input_id ); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | $list_rows = maybe_unserialize( $field_value ); |
120 | 120 | |
121 | - if( ! is_array( $list_rows ) ) { |
|
121 | + if ( ! is_array( $list_rows ) ) { |
|
122 | 122 | do_action( 'gravityview_log_error', __METHOD__ . ' - $field_value did not unserialize', $field_value ); |
123 | 123 | return null; |
124 | 124 | } |
@@ -131,15 +131,15 @@ discard block |
||
131 | 131 | foreach ( $list_row as $column_key => $column_value ) { |
132 | 132 | |
133 | 133 | // If the label of the column matches $column_id, or the numeric key value matches, add the value |
134 | - if( (string)$column_key === (string)$column_id || ( is_numeric( $column_id ) && (int)$column_id === $current_column ) ) { |
|
135 | - $column_values[] = $column_value; |
|
134 | + if ( (string)$column_key === (string)$column_id || ( is_numeric( $column_id ) && (int)$column_id === $current_column ) ) { |
|
135 | + $column_values[ ] = $column_value; |
|
136 | 136 | } |
137 | 137 | $current_column++; |
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | 141 | // Return the array of values |
142 | - if( 'raw' === $format ) { |
|
142 | + if ( 'raw' === $format ) { |
|
143 | 143 | return $column_values; |
144 | 144 | } |
145 | 145 | // Return the Gravity Forms Field output |
@@ -162,22 +162,22 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function _filter_field_label( $label, $field, $form, $entry ) { |
164 | 164 | |
165 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
165 | + $field_object = RGFormsModel::get_field( $form, $field[ 'id' ] ); |
|
166 | 166 | |
167 | 167 | // Not a list field |
168 | - if( ! $field_object || 'list' !== $field_object->type ) { |
|
168 | + if ( ! $field_object || 'list' !== $field_object->type ) { |
|
169 | 169 | return $label; |
170 | 170 | } |
171 | 171 | |
172 | 172 | // Custom label is defined, so use it |
173 | - if( ! empty( $field['custom_label'] ) ) { |
|
173 | + if ( ! empty( $field[ 'custom_label' ] ) ) { |
|
174 | 174 | return $label; |
175 | 175 | } |
176 | 176 | |
177 | - $column_id = gravityview_get_input_id_from_id( $field['id'] ); |
|
177 | + $column_id = gravityview_get_input_id_from_id( $field[ 'id' ] ); |
|
178 | 178 | |
179 | 179 | // Parent field, not column field |
180 | - if( false === $column_id ) { |
|
180 | + if ( false === $column_id ) { |
|
181 | 181 | return $label; |
182 | 182 | } |
183 | 183 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | public static function get_column_label( GF_Field_List $field, $column_id, $backup_label = '' ) { |
199 | 199 | |
200 | 200 | // Doesn't have columns enabled |
201 | - if( ! isset( $field->choices ) || ! $field->enableColumns ) { |
|
201 | + if ( ! isset( $field->choices ) || ! $field->enableColumns ) { |
|
202 | 202 | return $backup_label; |
203 | 203 | } |
204 | 204 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return GV_License_Handler |
41 | 41 | */ |
42 | 42 | public static function get_instance( GravityView_Settings $GFAddOn ) { |
43 | - if( empty( self::$instance ) ) { |
|
43 | + if ( empty( self::$instance ) ) { |
|
44 | 44 | self::$instance = new self( $GFAddOn ); |
45 | 45 | } |
46 | 46 | return self::$instance; |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | public function refresh_license_status() { |
71 | 71 | |
72 | 72 | // Only perform on GravityView pages |
73 | - if( ! gravityview_is_admin_page() ) { |
|
73 | + if ( ! gravityview_is_admin_page() ) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
77 | 77 | // The transient is fresh; don't fetch. |
78 | - if( $status = get_transient( self::status_transient_key ) ) { |
|
78 | + if ( $status = get_transient( self::status_transient_key ) ) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
@@ -100,37 +100,37 @@ discard block |
||
100 | 100 | $status = trim( $this->Addon->get_app_setting( 'license_key_status' ) ); |
101 | 101 | $key = trim( $this->Addon->get_app_setting( 'license_key' ) ); |
102 | 102 | |
103 | - if( !empty( $key ) ) { |
|
103 | + if ( ! empty( $key ) ) { |
|
104 | 104 | $response = $this->Addon->get_app_setting( 'license_key_response' ); |
105 | - $response = is_array( $response ) ? (object) $response : json_decode( $response ); |
|
105 | + $response = is_array( $response ) ? (object)$response : json_decode( $response ); |
|
106 | 106 | } else { |
107 | 107 | $response = array(); |
108 | 108 | } |
109 | 109 | |
110 | 110 | wp_localize_script( 'gv-admin-edd-license', 'GVGlobals', array( |
111 | 111 | 'license_box' => $this->get_license_message( $response ) |
112 | - )); |
|
112 | + ) ); |
|
113 | 113 | |
114 | 114 | |
115 | 115 | $fields = array( |
116 | 116 | array( |
117 | 117 | 'name' => 'edd-activate', |
118 | - 'value' => __('Activate License', 'gravityview'), |
|
119 | - 'data-pending_text' => __('Verifying license…', 'gravityview'), |
|
118 | + 'value' => __( 'Activate License', 'gravityview' ), |
|
119 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ), |
|
120 | 120 | 'data-edd_action' => 'activate_license', |
121 | 121 | 'class' => 'button-primary', |
122 | 122 | ), |
123 | 123 | array( |
124 | 124 | 'name' => 'edd-deactivate', |
125 | - 'value' => __('Deactivate License', 'gravityview'), |
|
126 | - 'data-pending_text' => __('Deactivating license…', 'gravityview'), |
|
125 | + 'value' => __( 'Deactivate License', 'gravityview' ), |
|
126 | + 'data-pending_text' => __( 'Deactivating license…', 'gravityview' ), |
|
127 | 127 | 'data-edd_action' => 'deactivate_license', |
128 | 128 | 'class' => ( empty( $status ) ? 'button-primary hide' : 'button-primary' ), |
129 | 129 | ), |
130 | 130 | array( |
131 | 131 | 'name' => 'edd-check', |
132 | - 'value' => __('Check License', 'gravityview'), |
|
133 | - 'data-pending_text' => __('Verifying license…', 'gravityview'), |
|
132 | + 'value' => __( 'Check License', 'gravityview' ), |
|
133 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ), |
|
134 | 134 | 'title' => 'Check the license before saving it', |
135 | 135 | 'data-edd_action' => 'check_license', |
136 | 136 | 'class' => 'button-secondary', |
@@ -140,17 +140,17 @@ discard block |
||
140 | 140 | |
141 | 141 | $class = 'button gv-edd-action'; |
142 | 142 | |
143 | - $class .= ( !empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
143 | + $class .= ( ! empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
144 | 144 | |
145 | 145 | $disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled'; |
146 | 146 | |
147 | 147 | $submit = '<div class="gv-edd-button-wrapper">'; |
148 | 148 | foreach ( $fields as $field ) { |
149 | - $field['type'] = 'button'; |
|
150 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class; |
|
151 | - $field['style'] = 'margin-left: 10px;'; |
|
152 | - if( $disabled_attribute ) { |
|
153 | - $field['disabled'] = $disabled_attribute; |
|
149 | + $field[ 'type' ] = 'button'; |
|
150 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] . ' ' . $class : $class; |
|
151 | + $field[ 'style' ] = 'margin-left: 10px;'; |
|
152 | + if ( $disabled_attribute ) { |
|
153 | + $field[ 'disabled' ] = $disabled_attribute; |
|
154 | 154 | } |
155 | 155 | $submit .= $this->Addon->settings_submit( $field, $echo ); |
156 | 156 | } |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | */ |
167 | 167 | private function setup_edd() { |
168 | 168 | |
169 | - if( !class_exists('EDD_SL_Plugin_Updater') ) { |
|
170 | - require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php'); |
|
169 | + if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
170 | + require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php' ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // setup the updater |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | 'url' => home_url(), |
205 | 205 | ); |
206 | 206 | |
207 | - if( !empty( $action ) ) { |
|
208 | - $settings['edd_action'] = esc_attr( $action ); |
|
207 | + if ( ! empty( $action ) ) { |
|
208 | + $settings[ 'edd_action' ] = esc_attr( $action ); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | $settings = array_map( 'urlencode', $settings ); |
@@ -219,14 +219,14 @@ discard block |
||
219 | 219 | */ |
220 | 220 | private function _license_get_remote_response( $data, $license = '' ) { |
221 | 221 | |
222 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license ); |
|
222 | + $api_params = $this->_get_edd_settings( $data[ 'edd_action' ], $license ); |
|
223 | 223 | |
224 | 224 | $url = add_query_arg( $api_params, self::url ); |
225 | 225 | |
226 | 226 | $response = wp_remote_get( $url, array( |
227 | 227 | 'timeout' => 15, |
228 | 228 | 'sslverify' => false, |
229 | - )); |
|
229 | + ) ); |
|
230 | 230 | |
231 | 231 | if ( is_wp_error( $response ) ) { |
232 | 232 | return array(); |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | */ |
260 | 260 | function get_license_message( $license_data ) { |
261 | 261 | |
262 | - if( empty( $license_data ) ) { |
|
262 | + if ( empty( $license_data ) ) { |
|
263 | 263 | $message = ''; |
264 | 264 | } else { |
265 | 265 | |
266 | - if( ! empty( $license_data->error ) ) { |
|
266 | + if ( ! empty( $license_data->error ) ) { |
|
267 | 267 | $class = 'error'; |
268 | 268 | $string_key = $license_data->error; |
269 | 269 | } else { |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $string_key = $license_data->license; |
272 | 272 | } |
273 | 273 | |
274 | - $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings( $string_key, $license_data ) ); |
|
274 | + $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings( 'status' ), $this->strings( $string_key, $license_data ) ); |
|
275 | 275 | |
276 | 276 | $message = $this->generate_license_box( $message, $class ); |
277 | 277 | } |
@@ -308,15 +308,15 @@ discard block |
||
308 | 308 | */ |
309 | 309 | public function license_details( $response = array() ) { |
310 | 310 | |
311 | - $response = (array) $response; |
|
311 | + $response = (array)$response; |
|
312 | 312 | |
313 | 313 | $return = ''; |
314 | 314 | $return .= '<span class="gv-license-details" aria-live="polite" aria-busy="false">'; |
315 | 315 | $return .= '<h3>' . esc_html__( 'License Details:', 'gravityview' ) . '</h3>'; |
316 | 316 | |
317 | - if( in_array( rgar( $response, 'license' ), array( 'invalid', 'deactivated' ) ) ) { |
|
318 | - $return .= $this->strings( $response['license'], $response ); |
|
319 | - } elseif( ! empty( $response['license_name'] ) ) { |
|
317 | + if ( in_array( rgar( $response, 'license' ), array( 'invalid', 'deactivated' ) ) ) { |
|
318 | + $return .= $this->strings( $response[ 'license' ], $response ); |
|
319 | + } elseif ( ! empty( $response[ 'license_name' ] ) ) { |
|
320 | 320 | |
321 | 321 | $response_keys = array( |
322 | 322 | 'license_name' => '', |
@@ -331,19 +331,19 @@ discard block |
||
331 | 331 | // Make sure all the keys are set |
332 | 332 | $response = wp_parse_args( $response, $response_keys ); |
333 | 333 | |
334 | - $login_link = sprintf( '<a href="%s" class="howto" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response['customer_email'] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
335 | - $local_text = ( ! empty( $response['is_local'] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
334 | + $login_link = sprintf( '<a href="%s" class="howto" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response[ 'customer_email' ] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
335 | + $local_text = ( ! empty( $response[ 'is_local' ] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
336 | 336 | $details = array( |
337 | - 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response['license_name'] ), esc_html( $response['license_limit'] ) ), |
|
338 | - 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), esc_html__( $response['customer_name'], 'gravityview' ), esc_html__( $response['customer_email'], 'gravityview' ) ) . $login_link, |
|
339 | - 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response['site_count'] ), esc_html( $response['license_limit'] ) ) . $local_text, |
|
340 | - 'expires' => sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response['expires'] ) - DAY_IN_SECONDS ) ), |
|
341 | - 'upgrade' => $this->get_upgrade_html( $response['upgrades'] ), |
|
337 | + 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response[ 'license_name' ] ), esc_html( $response[ 'license_limit' ] ) ), |
|
338 | + 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), esc_html__( $response[ 'customer_name' ], 'gravityview' ), esc_html__( $response[ 'customer_email' ], 'gravityview' ) ) . $login_link, |
|
339 | + 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response[ 'site_count' ] ), esc_html( $response[ 'license_limit' ] ) ) . $local_text, |
|
340 | + 'expires' => sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response[ 'expires' ] ) - DAY_IN_SECONDS ) ), |
|
341 | + 'upgrade' => $this->get_upgrade_html( $response[ 'upgrades' ] ), |
|
342 | 342 | ); |
343 | 343 | |
344 | - if ( ! empty( $response['error'] ) && 'expired' === $response['error'] ) { |
|
345 | - unset( $details['upgrade'] ); |
|
346 | - $details['expires'] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
344 | + if ( ! empty( $response[ 'error' ] ) && 'expired' === $response[ 'error' ] ) { |
|
345 | + unset( $details[ 'upgrade' ] ); |
|
346 | + $details[ 'expires' ] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | $return .= '<ul><li>' . implode( '</li><li>', array_filter( $details ) ) . '</li></ul>'; |
@@ -367,11 +367,11 @@ discard block |
||
367 | 367 | |
368 | 368 | $output = ''; |
369 | 369 | |
370 | - if( ! empty( $upgrades ) ) { |
|
370 | + if ( ! empty( $upgrades ) ) { |
|
371 | 371 | |
372 | 372 | $locale_parts = explode( '_', get_locale() ); |
373 | 373 | |
374 | - $is_english = ( 'en' === $locale_parts[0] ); |
|
374 | + $is_english = ( 'en' === $locale_parts[ 0 ] ); |
|
375 | 375 | |
376 | 376 | $output .= '<h4>' . esc_html__( 'Upgrades available:', 'gravityview' ) . '</h4>'; |
377 | 377 | |
@@ -379,14 +379,14 @@ discard block |
||
379 | 379 | |
380 | 380 | foreach ( $upgrades as $upgrade_id => $upgrade ) { |
381 | 381 | |
382 | - $upgrade = (object) $upgrade; |
|
382 | + $upgrade = (object)$upgrade; |
|
383 | 383 | |
384 | 384 | $anchor_text = sprintf( esc_html_x( 'Upgrade to %1$s for %2$s', '1: GravityView upgrade name, 2: Cost of upgrade', 'gravityview' ), esc_attr( $upgrade->name ), esc_attr( $upgrade->price ) ); |
385 | 385 | |
386 | - if( $is_english && isset( $upgrade->description ) ) { |
|
386 | + if ( $is_english && isset( $upgrade->description ) ) { |
|
387 | 387 | $message = esc_html( $upgrade->description ); |
388 | 388 | } else { |
389 | - switch( $upgrade->price_id ) { |
|
389 | + switch ( $upgrade->price_id ) { |
|
390 | 390 | // Interstellar |
391 | 391 | case 1: |
392 | 392 | default: |
@@ -424,16 +424,16 @@ discard block |
||
424 | 424 | */ |
425 | 425 | public function license_call( $array = array() ) { |
426 | 426 | |
427 | - $is_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); |
|
428 | - $data = empty( $array ) ? $_POST['data'] : $array; |
|
427 | + $is_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
428 | + $data = empty( $array ) ? $_POST[ 'data' ] : $array; |
|
429 | 429 | $has_cap = GVCommon::has_cap( 'gravityview_edit_settings' ); |
430 | 430 | |
431 | - if ( $is_ajax && empty( $data['license'] ) ) { |
|
432 | - die( - 1 ); |
|
431 | + if ( $is_ajax && empty( $data[ 'license' ] ) ) { |
|
432 | + die( -1 ); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | // If the user isn't allowed to edit settings, show an error message |
436 | - if( ! $has_cap ) { |
|
436 | + if ( ! $has_cap ) { |
|
437 | 437 | $license_data = new stdClass(); |
438 | 438 | $license_data->error = 'capability'; |
439 | 439 | $license_data->message = $this->get_license_message( $license_data ); |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | |
458 | 458 | $json = json_encode( $license_data ); |
459 | 459 | |
460 | - $update_license = ( ! isset( $data['update'] ) || ! empty( $data['update'] ) ); |
|
460 | + $update_license = ( ! isset( $data[ 'update' ] ) || ! empty( $data[ 'update' ] ) ); |
|
461 | 461 | |
462 | - $is_check_action_button = ( 'check_license' === $data['edd_action'] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
462 | + $is_check_action_button = ( 'check_license' === $data[ 'edd_action' ] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
463 | 463 | |
464 | 464 | // Failed is the response from trying to de-activate a license and it didn't work. |
465 | 465 | // This likely happened because people entered in a different key and clicked "Deactivate", |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | // most likely a mistake. |
468 | 468 | if ( $license_data->license !== 'failed' && ! $is_check_action_button && $update_license ) { |
469 | 469 | |
470 | - if ( ! empty( $data['field_id'] ) ) { |
|
470 | + if ( ! empty( $data[ 'field_id' ] ) ) { |
|
471 | 471 | set_transient( self::status_transient_key, $license_data, DAY_IN_SECONDS ); |
472 | 472 | } |
473 | 473 | |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | if ( $is_ajax ) { |
479 | 479 | exit( $json ); |
480 | 480 | } else { // Non-ajax call |
481 | - return ( rgget('format', $data ) === 'object' ) ? $license_data : $json; |
|
481 | + return ( rgget( 'format', $data ) === 'object' ) ? $license_data : $json; |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
@@ -492,9 +492,9 @@ discard block |
||
492 | 492 | // Update option with passed data license |
493 | 493 | $settings = $this->Addon->get_app_settings(); |
494 | 494 | |
495 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
496 | - $settings['license_key_status'] = $license_data->license; |
|
497 | - $settings['license_key_response'] = (array)$license_data; |
|
495 | + $settings[ 'license_key' ] = $license_data->license_key = trim( $data[ 'license' ] ); |
|
496 | + $settings[ 'license_key_status' ] = $license_data->license; |
|
497 | + $settings[ 'license_key_response' ] = (array)$license_data; |
|
498 | 498 | |
499 | 499 | $this->Addon->update_app_settings( $settings ); |
500 | 500 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | */ |
508 | 508 | private function get_license_renewal_url( $license_data ) { |
509 | 509 | $license_data = is_array( $license_data ) ? (object)$license_data : $license_data; |
510 | - $renew_license_url = ( ! empty( $license_data ) && !empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation&force_login=1', $license_data->license_key ) : 'https://gravityview.co/account/'; |
|
510 | + $renew_license_url = ( ! empty( $license_data ) && ! empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation&force_login=1', $license_data->license_key ) : 'https://gravityview.co/account/'; |
|
511 | 511 | return $renew_license_url; |
512 | 512 | } |
513 | 513 | |
@@ -522,31 +522,31 @@ discard block |
||
522 | 522 | |
523 | 523 | |
524 | 524 | $strings = array( |
525 | - 'status' => esc_html__('Status', 'gravityview'), |
|
526 | - 'error' => esc_html__('There was an error processing the request.', 'gravityview'), |
|
527 | - 'failed' => esc_html__('Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview'), |
|
528 | - 'site_inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
|
529 | - 'inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
|
530 | - 'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview') . ' ' . sprintf( esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
531 | - 'deactivated' => esc_html__('The license has been deactivated.', 'gravityview'), |
|
532 | - 'valid' => esc_html__('The license key is valid and active.', 'gravityview'), |
|
533 | - 'invalid' => esc_html__('The license key entered is invalid.', 'gravityview'), |
|
534 | - 'missing' => esc_html__('Invalid license key.', 'gravityview'), |
|
535 | - 'revoked' => esc_html__('This license key has been revoked.', 'gravityview'), |
|
536 | - 'expired' => sprintf( esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ), |
|
525 | + 'status' => esc_html__( 'Status', 'gravityview' ), |
|
526 | + 'error' => esc_html__( 'There was an error processing the request.', 'gravityview' ), |
|
527 | + 'failed' => esc_html__( 'Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview' ), |
|
528 | + 'site_inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ), |
|
529 | + 'inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ), |
|
530 | + 'no_activations_left' => esc_html__( 'Invalid: this license has reached its activation limit.', 'gravityview' ) . ' ' . sprintf( esc_html__( 'You can manage license activations %son your GravityView account page%s.', 'gravityview' ), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
531 | + 'deactivated' => esc_html__( 'The license has been deactivated.', 'gravityview' ), |
|
532 | + 'valid' => esc_html__( 'The license key is valid and active.', 'gravityview' ), |
|
533 | + 'invalid' => esc_html__( 'The license key entered is invalid.', 'gravityview' ), |
|
534 | + 'missing' => esc_html__( 'Invalid license key.', 'gravityview' ), |
|
535 | + 'revoked' => esc_html__( 'This license key has been revoked.', 'gravityview' ), |
|
536 | + 'expired' => sprintf( esc_html__( 'This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview' ), '<a href="' . esc_url( $this->get_license_renewal_url( $license_data ) ) . '">', '</a>' ), |
|
537 | 537 | 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ), |
538 | 538 | |
539 | - 'verifying_license' => esc_html__('Verifying license…', 'gravityview'), |
|
540 | - 'activate_license' => esc_html__('Activate License', 'gravityview'), |
|
541 | - 'deactivate_license' => esc_html__('Deactivate License', 'gravityview'), |
|
542 | - 'check_license' => esc_html__('Verify License', 'gravityview'), |
|
539 | + 'verifying_license' => esc_html__( 'Verifying license…', 'gravityview' ), |
|
540 | + 'activate_license' => esc_html__( 'Activate License', 'gravityview' ), |
|
541 | + 'deactivate_license' => esc_html__( 'Deactivate License', 'gravityview' ), |
|
542 | + 'check_license' => esc_html__( 'Verify License', 'gravityview' ), |
|
543 | 543 | ); |
544 | 544 | |
545 | - if( empty( $status ) ) { |
|
545 | + if ( empty( $status ) ) { |
|
546 | 546 | return $strings; |
547 | 547 | } |
548 | 548 | |
549 | - if( isset( $strings[ $status ] ) ) { |
|
549 | + if ( isset( $strings[ $status ] ) ) { |
|
550 | 550 | return $strings[ $status ]; |
551 | 551 | } |
552 | 552 |
@@ -25,18 +25,18 @@ discard block |
||
25 | 25 | |
26 | 26 | $post_data = self::get_post_fields( $form, $entry ); |
27 | 27 | |
28 | - $media = get_attached_media( 'image', $entry['post_id'] ); |
|
28 | + $media = get_attached_media( 'image', $entry[ 'post_id' ] ); |
|
29 | 29 | |
30 | 30 | $post_images = array(); |
31 | 31 | |
32 | 32 | foreach ( $media as $media_item ) { |
33 | - foreach( (array) $post_data['images'] as $post_data_item ) { |
|
34 | - if( |
|
33 | + foreach ( (array)$post_data[ 'images' ] as $post_data_item ) { |
|
34 | + if ( |
|
35 | 35 | rgar( $post_data_item, 'title' ) === $media_item->post_title && |
36 | 36 | rgar( $post_data_item, 'description' ) === $media_item->post_content && |
37 | 37 | rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
38 | 38 | ) { |
39 | - $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
39 | + $post_images[ "{$post_data_item[ 'field_id' ]}" ] = $media_item->ID; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * If the method changes to public, use Gravity Forms' method |
65 | 65 | * @todo: If/when the method is public, remove the unneeded copied code. |
66 | 66 | */ |
67 | - if( $reflection->isPublic() ) { |
|
67 | + if ( $reflection->isPublic() ) { |
|
68 | 68 | return parent::get_post_fields( $form, $entry ); |
69 | 69 | } |
70 | 70 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * If the method changes to public, use Gravity Forms' method |
92 | 92 | * @todo: If/when the method is public, remove the unneeded copied code. |
93 | 93 | */ |
94 | - if( $reflection->isPublic() ) { |
|
94 | + if ( $reflection->isPublic() ) { |
|
95 | 95 | return parent::copy_post_image( $url, $post_id ); |
96 | 96 | } |
97 | 97 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * If the method changes to public, use Gravity Forms' method |
127 | 127 | * @todo: If/when the method is public, remove the unneeded copied code. |
128 | 128 | */ |
129 | - if( $reflection->isPublic() ) { |
|
129 | + if ( $reflection->isPublic() ) { |
|
130 | 130 | return parent::media_handle_upload( $url, $post_id, $post_data ); |
131 | 131 | } |
132 | 132 |
@@ -47,7 +47,7 @@ |
||
47 | 47 | function edit_entry_fix_hidden_fields( $fields ) { |
48 | 48 | |
49 | 49 | /** @var GF_Field $field */ |
50 | - foreach( $fields as &$field ) { |
|
50 | + foreach ( $fields as &$field ) { |
|
51 | 51 | if ( 'hidden' === $field->type ) { |
52 | 52 | |
53 | 53 | // Replace GF_Field_Hidden with GF_Field_Text, copying all the data from $field |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return void |
31 | 31 | */ |
32 | 32 | private function add_hooks() { |
33 | - add_filter( 'gravityview/edit_entry/field_value_post_custom_field', array( $this, 'edit_entry_field_value'), 10, 2 ); |
|
33 | + add_filter( 'gravityview/edit_entry/field_value_post_custom_field', array( $this, 'edit_entry_field_value' ), 10, 2 ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function edit_entry_field_value( $field_value, $field ) { |
47 | 47 | |
48 | - if( 'list' === $field->inputType ) { |
|
48 | + if ( 'list' === $field->inputType ) { |
|
49 | 49 | $field_value = is_string( $field_value ) ? json_decode( $field_value, true ) : $field_value; |
50 | 50 | |
51 | 51 | if ( ! is_array( $field_value ) ) { |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | var $name = 'post_category'; |
11 | 11 | |
12 | - var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains'); |
|
12 | + var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' ); |
|
13 | 13 | |
14 | 14 | var $_gf_field_class_name = 'GF_Field_Post_Category'; |
15 | 15 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $entry = GFAPI::get_entry( $entry_id ); |
43 | 43 | $post_id = rgar( $entry, 'post_id' ); |
44 | 44 | |
45 | - if( empty( $post_id ) ) { |
|
45 | + if ( empty( $post_id ) ) { |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | $post_category_fields = GFAPI::get_fields_by_type( $form, 'post_category' ); |
52 | 52 | |
53 | - if( $post_category_fields ) { |
|
53 | + if ( $post_category_fields ) { |
|
54 | 54 | |
55 | 55 | $updated_categories = array(); |
56 | 56 | |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @return mixed |
119 | 119 | */ |
120 | - function edit_entry_post_category_choices( $choices, $field, $form_id ) { |
|
120 | + function edit_entry_post_category_choices( $choices, $field, $form_id ) { |
|
121 | 121 | |
122 | - $entry = GravityView_Edit_Entry::getInstance()->instances['render']->get_entry(); |
|
122 | + $entry = GravityView_Edit_Entry::getInstance()->instances[ 'render' ]->get_entry(); |
|
123 | 123 | |
124 | 124 | // $entry['post_id'] should always be set, but we check to make sure. |
125 | - if( $entry && isset( $entry['post_id'] ) && $post_id = $entry['post_id'] ) { |
|
125 | + if ( $entry && isset( $entry[ 'post_id' ] ) && $post_id = $entry[ 'post_id' ] ) { |
|
126 | 126 | |
127 | 127 | $post_categories = wp_get_post_categories( $post_id, array( 'fields' => 'ids' ) ); |
128 | 128 | |
129 | 129 | // Always use the live value |
130 | 130 | foreach ( $choices as &$choice ) { |
131 | - $choice['isSelected'] = in_array( $choice['value'], array_values( $post_categories ) ); |
|
131 | + $choice[ 'isSelected' ] = in_array( $choice[ 'value' ], array_values( $post_categories ) ); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | |
138 | 138 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
139 | 139 | |
140 | - if( 'edit' === $context ) { |
|
140 | + if ( 'edit' === $context ) { |
|
141 | 141 | return $field_options; |
142 | 142 | } |
143 | 143 | |
144 | - $this->add_field_support('dynamic_data', $field_options ); |
|
145 | - $this->add_field_support('link_to_term', $field_options ); |
|
144 | + $this->add_field_support( 'dynamic_data', $field_options ); |
|
145 | + $this->add_field_support( 'link_to_term', $field_options ); |
|
146 | 146 | |
147 | 147 | return $field_options; |
148 | 148 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | var $name = 'checkbox'; |
11 | 11 | |
12 | - var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains'); |
|
12 | + var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' ); |
|
13 | 13 | |
14 | 14 | var $_gf_field_class_name = 'GF_Field_Checkbox'; |
15 | 15 | |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type ); |
40 | 40 | |
41 | 41 | // It's not the parent field; it's an input |
42 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
42 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
43 | 43 | |
44 | - if( $this->is_choice_value_enabled() ) { |
|
44 | + if ( $this->is_choice_value_enabled() ) { |
|
45 | 45 | |
46 | 46 | $desc = esc_html__( 'This input has a label and a value. What should be displayed?', 'gravityview' ); |
47 | 47 | $default = 'value'; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ); |
60 | 60 | } |
61 | 61 | |
62 | - $field_options['choice_display'] = array( |
|
62 | + $field_options[ 'choice_display' ] = array( |
|
63 | 63 | 'type' => 'radio', |
64 | 64 | 'class' => 'vertical', |
65 | 65 | 'label' => __( 'What should be displayed:', 'gravityview' ), |
@@ -63,18 +63,18 @@ discard block |
||
63 | 63 | |
64 | 64 | add_shortcode( 'gv_note_add', array( 'GravityView_Field_Notes', 'get_add_note_part' ) ); |
65 | 65 | |
66 | - add_action( 'wp', array( $this, 'maybe_delete_notes'), 1000 ); |
|
67 | - add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes') ); |
|
68 | - add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes') ); |
|
66 | + add_action( 'wp', array( $this, 'maybe_delete_notes' ), 1000 ); |
|
67 | + add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes' ) ); |
|
68 | + add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes' ) ); |
|
69 | 69 | |
70 | - add_action( 'wp', array( $this, 'maybe_add_note'), 1000 ); |
|
71 | - add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note') ); |
|
72 | - add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note') ); |
|
70 | + add_action( 'wp', array( $this, 'maybe_add_note' ), 1000 ); |
|
71 | + add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note' ) ); |
|
72 | + add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note' ) ); |
|
73 | 73 | |
74 | 74 | // add template path to check for field |
75 | 75 | add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
76 | 76 | |
77 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
77 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
78 | 78 | add_action( 'gravityview/field/notes/scripts', array( $this, 'enqueue_scripts' ) ); |
79 | 79 | |
80 | 80 | add_filter( 'gravityview_entry_default_fields', array( $this, 'add_entry_default_field' ), 10, 3 ); |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function add_entry_default_field( $entry_default_fields, $form, $zone ) { |
98 | 98 | |
99 | - if( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
100 | - $entry_default_fields['notes'] = array( |
|
99 | + if ( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
100 | + $entry_default_fields[ 'notes' ] = array( |
|
101 | 101 | 'label' => __( 'Entry Notes', 'gravityview' ), |
102 | 102 | 'type' => 'notes', |
103 | 103 | 'desc' => __( 'Display, add, and delete notes for an entry.', 'gravityview' ), |
@@ -130,23 +130,23 @@ discard block |
||
130 | 130 | public function enqueue_scripts() { |
131 | 131 | global $wp_actions; |
132 | 132 | |
133 | - if( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
133 | + if ( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
134 | 134 | wp_enqueue_style( 'gravityview-notes' ); |
135 | 135 | wp_enqueue_script( 'gravityview-notes' ); |
136 | 136 | } |
137 | 137 | |
138 | - if( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
138 | + if ( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
139 | 139 | |
140 | 140 | $strings = self::strings(); |
141 | 141 | |
142 | 142 | wp_localize_script( 'gravityview-notes', 'GVNotes', array( |
143 | 143 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
144 | 144 | 'text' => array( |
145 | - 'processing' => $strings['processing'], |
|
146 | - 'delete_confirm' => $strings['delete-confirm'], |
|
147 | - 'note_added' => $strings['added-note'], |
|
148 | - 'error_invalid' => $strings['error-invalid'], |
|
149 | - 'error_empty_note' => $strings['error-empty-note'], |
|
145 | + 'processing' => $strings[ 'processing' ], |
|
146 | + 'delete_confirm' => $strings[ 'delete-confirm' ], |
|
147 | + 'note_added' => $strings[ 'added-note' ], |
|
148 | + 'error_invalid' => $strings[ 'error-invalid' ], |
|
149 | + 'error_empty_note' => $strings[ 'error-empty-note' ], |
|
150 | 150 | ), |
151 | 151 | ) ); |
152 | 152 | } |
@@ -163,22 +163,22 @@ discard block |
||
163 | 163 | */ |
164 | 164 | function maybe_add_note() { |
165 | 165 | |
166 | - if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
166 | + if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
167 | 167 | do_action( 'gravityview_log_error', __METHOD__ . ': The user isnt allowed to add entry notes.' ); |
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | - if( 'gv_note_add' === rgpost('action') ) { |
|
171 | + if ( 'gv_note_add' === rgpost( 'action' ) ) { |
|
172 | 172 | |
173 | 173 | $post = wp_unslash( $_POST ); |
174 | 174 | |
175 | - if( $this->doing_ajax ) { |
|
176 | - parse_str( $post['data'], $data ); |
|
175 | + if ( $this->doing_ajax ) { |
|
176 | + parse_str( $post[ 'data' ], $data ); |
|
177 | 177 | } else { |
178 | 178 | $data = $post; |
179 | 179 | } |
180 | 180 | |
181 | - $this->process_add_note( (array) $data ); |
|
181 | + $this->process_add_note( (array)$data ); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
@@ -205,23 +205,23 @@ discard block |
||
205 | 205 | $error = false; |
206 | 206 | $success = false; |
207 | 207 | |
208 | - if( empty( $data['entry-slug'] ) ) { |
|
208 | + if ( empty( $data[ 'entry-slug' ] ) ) { |
|
209 | 209 | |
210 | - $error = self::strings('error-invalid'); |
|
210 | + $error = self::strings( 'error-invalid' ); |
|
211 | 211 | do_action( 'gravityview_log_error', __METHOD__ . ': The note is missing an Entry ID.' ); |
212 | 212 | |
213 | 213 | } else { |
214 | 214 | |
215 | - $valid = wp_verify_nonce( $data['gv_note_add'], 'gv_note_add_' . $data['entry-slug'] ); |
|
215 | + $valid = wp_verify_nonce( $data[ 'gv_note_add' ], 'gv_note_add_' . $data[ 'entry-slug' ] ); |
|
216 | 216 | |
217 | 217 | $has_cap = GVCommon::has_cap( 'gravityview_add_entry_notes' ); |
218 | 218 | |
219 | - if( ! $has_cap ) { |
|
219 | + if ( ! $has_cap ) { |
|
220 | 220 | $error = self::strings( 'error-cap-add' ); |
221 | 221 | do_action( 'gravityview_log_error', __METHOD__ . ': Adding a note failed: the user does not have the "gravityview_add_entry_notes" capability.' ); |
222 | 222 | } elseif ( $valid ) { |
223 | 223 | |
224 | - $entry = gravityview_get_entry( $data['entry-slug'], true, false ); |
|
224 | + $entry = gravityview_get_entry( $data[ 'entry-slug' ], true, false ); |
|
225 | 225 | |
226 | 226 | $added = $this->add_note( $entry, $data ); |
227 | 227 | |
@@ -239,22 +239,22 @@ discard block |
||
239 | 239 | $this->maybe_send_entry_notes( $note, $entry, $data ); |
240 | 240 | |
241 | 241 | if ( $note ) { |
242 | - $success = self::display_note( $note, ! empty( $data['show-delete'] ) ); |
|
243 | - do_action( 'gravityview_log_debug', __METHOD__ . ': The note was successfully created', compact('note', 'data') ); |
|
242 | + $success = self::display_note( $note, ! empty( $data[ 'show-delete' ] ) ); |
|
243 | + do_action( 'gravityview_log_debug', __METHOD__ . ': The note was successfully created', compact( 'note', 'data' ) ); |
|
244 | 244 | } else { |
245 | - $error = self::strings('error-add-note'); |
|
246 | - do_action( 'gravityview_log_error', __METHOD__ . ': The note was not successfully created', compact('note', 'data') ); |
|
245 | + $error = self::strings( 'error-add-note' ); |
|
246 | + do_action( 'gravityview_log_error', __METHOD__ . ': The note was not successfully created', compact( 'note', 'data' ) ); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } else { |
250 | - $error = self::strings('error-invalid'); |
|
250 | + $error = self::strings( 'error-invalid' ); |
|
251 | 251 | do_action( 'gravityview_log_error', __METHOD__ . ': Nonce validation failed; the note was not created' ); |
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | |
256 | - if( $this->doing_ajax ) { |
|
257 | - if( $success ) { |
|
256 | + if ( $this->doing_ajax ) { |
|
257 | + if ( $success ) { |
|
258 | 258 | wp_send_json_success( array( 'html' => $success ) ); |
259 | 259 | } else { |
260 | 260 | $error = $error ? $error : self::strings( 'error-invalid' ); |
@@ -280,11 +280,11 @@ discard block |
||
280 | 280 | return; |
281 | 281 | } |
282 | 282 | |
283 | - if ( isset( $_POST['action'] ) && 'gv_delete_notes' === $_POST['action'] ) { |
|
283 | + if ( isset( $_POST[ 'action' ] ) && 'gv_delete_notes' === $_POST[ 'action' ] ) { |
|
284 | 284 | |
285 | 285 | $post = wp_unslash( $_POST ); |
286 | 286 | if ( $this->doing_ajax ) { |
287 | - parse_str( $post['data'], $data ); |
|
287 | + parse_str( $post[ 'data' ], $data ); |
|
288 | 288 | } else { |
289 | 289 | $data = $post; |
290 | 290 | } |
@@ -315,18 +315,18 @@ discard block |
||
315 | 315 | */ |
316 | 316 | function process_delete_notes( $data ) { |
317 | 317 | |
318 | - $valid = wp_verify_nonce( $data['gv_delete_notes'], 'gv_delete_notes_' . $data['entry-slug'] ); |
|
318 | + $valid = wp_verify_nonce( $data[ 'gv_delete_notes' ], 'gv_delete_notes_' . $data[ 'entry-slug' ] ); |
|
319 | 319 | $has_cap = GVCommon::has_cap( 'gravityview_delete_entry_notes' ); |
320 | 320 | $success = false; |
321 | 321 | |
322 | 322 | if ( $valid && $has_cap ) { |
323 | - GravityView_Entry_Notes::delete_notes( $data['note'] ); |
|
323 | + GravityView_Entry_Notes::delete_notes( $data[ 'note' ] ); |
|
324 | 324 | $success = true; |
325 | 325 | } |
326 | 326 | |
327 | - if( $this->doing_ajax ) { |
|
327 | + if ( $this->doing_ajax ) { |
|
328 | 328 | |
329 | - if( $success ) { |
|
329 | + if ( $success ) { |
|
330 | 330 | wp_send_json_success(); |
331 | 331 | } else { |
332 | 332 | if ( ! $valid ) { |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | |
360 | 360 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
361 | 361 | |
362 | - unset( $field_options['show_as_link'] ); |
|
362 | + unset( $field_options[ 'show_as_link' ] ); |
|
363 | 363 | |
364 | 364 | $notes_options = array( |
365 | 365 | 'notes' => array( |
366 | 366 | 'type' => 'checkboxes', |
367 | - 'label' => __('Note Settings', 'gravityview'), |
|
368 | - 'desc' => sprintf( _x('Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ), |
|
367 | + 'label' => __( 'Note Settings', 'gravityview' ), |
|
368 | + 'desc' => sprintf( _x( 'Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ), |
|
369 | 369 | 'options' => array( |
370 | 370 | 'view' => array( |
371 | 371 | 'label' => __( 'Display notes?', 'gravityview' ), |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | 'processing' => __( 'Processing…', 'gravityview' ), |
418 | 418 | 'other-email' => __( 'Other email address', 'gravityview' ), |
419 | 419 | 'email-label' => __( 'Email address', 'gravityview' ), |
420 | - 'email-placeholder' => _x('[email protected]', 'Example email address used as a placeholder', 'gravityview'), |
|
420 | + 'email-placeholder' => _x( '[email protected]', 'Example email address used as a placeholder', 'gravityview' ), |
|
421 | 421 | 'subject-label' => __( 'Subject', 'gravityview' ), |
422 | 422 | 'subject' => __( 'Email subject', 'gravityview' ), |
423 | 423 | 'default-email-subject' => __( 'New entry note', 'gravityview' ), |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | */ |
437 | 437 | $strings = gv_map_deep( apply_filters( 'gravityview/field/notes/strings', $strings ), 'esc_html' ); |
438 | 438 | |
439 | - if( $key ) { |
|
439 | + if ( $key ) { |
|
440 | 440 | return isset( $strings[ $key ] ) ? $strings[ $key ] : ''; |
441 | 441 | } |
442 | 442 | |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | */ |
456 | 456 | static public function display_note( $note, $show_delete = false ) { |
457 | 457 | |
458 | - if( ! is_object( $note ) ) { |
|
458 | + if ( ! is_object( $note ) ) { |
|
459 | 459 | return ''; |
460 | 460 | } |
461 | 461 | |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | $note_row = ob_get_clean(); |
497 | 497 | |
498 | 498 | $replacements = array( |
499 | - '{note_id}' => $note_content['note_id'], |
|
499 | + '{note_id}' => $note_content[ 'note_id' ], |
|
500 | 500 | '{row_class}' => 'gv-note', |
501 | 501 | '{note_detail}' => $note_detail_html |
502 | 502 | ); |
@@ -528,13 +528,13 @@ discard block |
||
528 | 528 | |
529 | 529 | $user_data = get_userdata( $current_user->ID ); |
530 | 530 | |
531 | - $note_content = trim( $data['gv-note-content'] ); |
|
531 | + $note_content = trim( $data[ 'gv-note-content' ] ); |
|
532 | 532 | |
533 | - if( empty( $note_content ) ) { |
|
533 | + if ( empty( $note_content ) ) { |
|
534 | 534 | return new WP_Error( 'gv-add-note-empty', __( 'The note is empty.', 'gravityview' ) ); |
535 | 535 | } |
536 | 536 | |
537 | - $return = GravityView_Entry_Notes::add_note( $entry['id'], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
537 | + $return = GravityView_Entry_Notes::add_note( $entry[ 'id' ], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
538 | 538 | |
539 | 539 | return $return; |
540 | 540 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | */ |
551 | 551 | public static function get_add_note_part() { |
552 | 552 | |
553 | - if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
553 | + if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
554 | 554 | do_action( 'gravityview_log_error', __METHOD__ . ': User does not have permission to add entry notes ("gravityview_add_entry_notes").' ); |
555 | 555 | return ''; |
556 | 556 | } |
@@ -563,19 +563,19 @@ discard block |
||
563 | 563 | |
564 | 564 | $visibility_settings = $gravityview_view->getCurrentFieldSetting( 'notes' ); |
565 | 565 | $entry = $gravityview_view->getCurrentEntry(); |
566 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
566 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
567 | 567 | $nonce_field = wp_nonce_field( 'gv_note_add_' . $entry_slug, 'gv_note_add', false, false ); |
568 | 568 | |
569 | 569 | // Only generate the dropdown if the field settings allow it |
570 | 570 | $email_fields = ''; |
571 | - if( ! empty( $visibility_settings['email'] ) ) { |
|
571 | + if ( ! empty( $visibility_settings[ 'email' ] ) ) { |
|
572 | 572 | $email_fields = self::get_note_email_fields( $entry_slug ); |
573 | 573 | } |
574 | 574 | |
575 | 575 | $add_note_html = str_replace( '{entry_slug}', $entry_slug, $add_note_html ); |
576 | 576 | $add_note_html = str_replace( '{nonce_field}', $nonce_field, $add_note_html ); |
577 | - $add_note_html = str_replace( '{show_delete}', intval( $visibility_settings['delete'] ), $add_note_html ); |
|
578 | - $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
577 | + $add_note_html = str_replace( '{show_delete}', intval( $visibility_settings[ 'delete' ] ), $add_note_html ); |
|
578 | + $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
579 | 579 | |
580 | 580 | return $add_note_html; |
581 | 581 | } |
@@ -599,8 +599,8 @@ discard block |
||
599 | 599 | $note_emails = array(); |
600 | 600 | |
601 | 601 | foreach ( $email_fields as $email_field ) { |
602 | - if ( ! empty( $entry["{$email_field->id}"] ) && is_email( $entry["{$email_field->id}"] ) ) { |
|
603 | - $note_emails[] = $entry["{$email_field->id}"]; |
|
602 | + if ( ! empty( $entry[ "{$email_field->id}" ] ) && is_email( $entry[ "{$email_field->id}" ] ) ) { |
|
603 | + $note_emails[ ] = $entry[ "{$email_field->id}" ]; |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 | |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | */ |
613 | 613 | $note_emails = apply_filters( 'gravityview/field/notes/emails', $note_emails, $entry ); |
614 | 614 | |
615 | - return (array) $note_emails; |
|
615 | + return (array)$note_emails; |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | /** |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | */ |
629 | 629 | private static function get_note_email_fields( $entry_slug = '' ) { |
630 | 630 | |
631 | - if( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
631 | + if ( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
632 | 632 | do_action( 'gravityview_log_error', __METHOD__ . ': User does not have permission to email entry notes ("gravityview_email_entry_notes").' ); |
633 | 633 | return ''; |
634 | 634 | } |
@@ -650,27 +650,27 @@ discard block |
||
650 | 650 | |
651 | 651 | if ( ! empty( $note_emails ) || $include_custom ) { ?> |
652 | 652 | <div class="gv-note-email-container"> |
653 | - <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings['also-email']; ?></label> |
|
653 | + <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings[ 'also-email' ]; ?></label> |
|
654 | 654 | <select class="gv-note-email-to" name="gv-note-to" id="gv-note-email-to-<?php echo $entry_slug_esc; ?>"> |
655 | - <option value=""><?php echo $strings['also-email']; ?></option> |
|
655 | + <option value=""><?php echo $strings[ 'also-email' ]; ?></option> |
|
656 | 656 | <?php foreach ( $note_emails as $email ) { |
657 | 657 | ?> |
658 | 658 | <option value="<?php echo esc_attr( $email ); ?>"><?php echo esc_html( $email ); ?></option> |
659 | 659 | <?php } |
660 | - if( $include_custom ) { ?> |
|
661 | - <option value="custom"><?php echo self::strings('other-email'); ?></option> |
|
660 | + if ( $include_custom ) { ?> |
|
661 | + <option value="custom"><?php echo self::strings( 'other-email' ); ?></option> |
|
662 | 662 | <?php } ?> |
663 | 663 | </select> |
664 | 664 | <fieldset class="gv-note-to-container"> |
665 | - <?php if( $include_custom ) { ?> |
|
665 | + <?php if ( $include_custom ) { ?> |
|
666 | 666 | <div class='gv-note-to-custom-container'> |
667 | - <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings['email-label']; ?></label> |
|
668 | - <input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings['email-placeholder']; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" /> |
|
667 | + <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'email-label' ]; ?></label> |
|
668 | + <input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings[ 'email-placeholder' ]; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" /> |
|
669 | 669 | </div> |
670 | 670 | <?php } ?> |
671 | 671 | <div class='gv-note-subject-container'> |
672 | - <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings['subject-label']; ?></label> |
|
673 | - <input type="text" name="gv-note-subject" placeholder="<?php echo $strings['subject']; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
672 | + <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'subject-label' ]; ?></label> |
|
673 | + <input type="text" name="gv-note-subject" placeholder="<?php echo $strings[ 'subject' ]; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
674 | 674 | </div> |
675 | 675 | </fieldset> |
676 | 676 | </div> |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | */ |
694 | 694 | private function maybe_send_entry_notes( $note = false, $entry, $data ) { |
695 | 695 | |
696 | - if( ! $note || ! GVCommon::has_cap('gravityview_email_entry_notes') ) { |
|
696 | + if ( ! $note || ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
697 | 697 | do_action( 'gravityview_log_debug', __METHOD__ . ': User doesnt have "gravityview_email_entry_notes" cap, or $note is empty', $note ); |
698 | 698 | return; |
699 | 699 | } |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | do_action( 'gravityview_log_debug', __METHOD__ . ': $data', $data ); |
702 | 702 | |
703 | 703 | //emailing notes if configured |
704 | - if ( ! empty( $data['gv-note-to'] ) ) { |
|
704 | + if ( ! empty( $data[ 'gv-note-to' ] ) ) { |
|
705 | 705 | |
706 | 706 | $default_data = array( |
707 | 707 | 'gv-note-to' => '', |
@@ -710,11 +710,11 @@ discard block |
||
710 | 710 | 'gv-note-content' => '', |
711 | 711 | ); |
712 | 712 | |
713 | - $current_user = wp_get_current_user(); |
|
713 | + $current_user = wp_get_current_user(); |
|
714 | 714 | $email_data = wp_parse_args( $data, $default_data ); |
715 | 715 | |
716 | - $from = $current_user->user_email; |
|
717 | - $to = $email_data['gv-note-to']; |
|
716 | + $from = $current_user->user_email; |
|
717 | + $to = $email_data[ 'gv-note-to' ]; |
|
718 | 718 | |
719 | 719 | /** |
720 | 720 | * Documented in get_note_email_fields |
@@ -722,8 +722,8 @@ discard block |
||
722 | 722 | */ |
723 | 723 | $include_custom = apply_filters( 'gravityview/field/notes/custom-email', true ); |
724 | 724 | |
725 | - if( 'custom' === $to && $include_custom ) { |
|
726 | - $to = $email_data['gv-note-to-custom']; |
|
725 | + if ( 'custom' === $to && $include_custom ) { |
|
726 | + $to = $email_data[ 'gv-note-to-custom' ]; |
|
727 | 727 | do_action( 'gravityview_log_debug', __METHOD__ . ': Sending note to a custom email address: ' . $to ); |
728 | 728 | } |
729 | 729 | |
@@ -734,12 +734,12 @@ discard block |
||
734 | 734 | |
735 | 735 | $bcc = false; |
736 | 736 | $reply_to = $from; |
737 | - $subject = trim( $email_data['gv-note-subject'] ); |
|
737 | + $subject = trim( $email_data[ 'gv-note-subject' ] ); |
|
738 | 738 | |
739 | 739 | // We use empty() here because GF uses empty to check against, too. `0` isn't a valid subject to GF |
740 | 740 | $subject = empty( $subject ) ? self::strings( 'default-email-subject' ) : $subject; |
741 | - $message = $email_data['gv-note-content']; |
|
742 | - $from_name = $current_user->display_name; |
|
741 | + $message = $email_data[ 'gv-note-content' ]; |
|
742 | + $from_name = $current_user->display_name; |
|
743 | 743 | $message_format = 'html'; |
744 | 744 | |
745 | 745 | /** |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | |
755 | 755 | GVCommon::send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name, $message_format, '', $entry, false ); |
756 | 756 | |
757 | - $form = isset( $entry['form_id'] ) ? GFAPI::get_form( $entry['form_id'] ) : array(); |
|
757 | + $form = isset( $entry[ 'form_id' ] ) ? GFAPI::get_form( $entry[ 'form_id' ] ) : array(); |
|
758 | 758 | |
759 | 759 | /** |
760 | 760 | * @see https://www.gravityhelp.com/documentation/article/10146-2/ It's here for compatibility with Gravity Forms |
@@ -30,29 +30,29 @@ discard block |
||
30 | 30 | |
31 | 31 | $label = ''; |
32 | 32 | |
33 | - if( !empty( $field['show_label'] ) || $force_show_label ) { |
|
33 | + if ( ! empty( $field[ 'show_label' ] ) || $force_show_label ) { |
|
34 | 34 | |
35 | - $label = $field['label']; |
|
35 | + $label = $field[ 'label' ]; |
|
36 | 36 | |
37 | 37 | // Support Gravity Forms 1.9+ |
38 | - if( class_exists( 'GF_Field' ) ) { |
|
38 | + if ( class_exists( 'GF_Field' ) ) { |
|
39 | 39 | |
40 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
40 | + $field_object = RGFormsModel::get_field( $form, $field[ 'id' ] ); |
|
41 | 41 | |
42 | - if( $field_object ) { |
|
42 | + if ( $field_object ) { |
|
43 | 43 | |
44 | - $input = GFFormsModel::get_input( $field_object, $field['id'] ); |
|
44 | + $input = GFFormsModel::get_input( $field_object, $field[ 'id' ] ); |
|
45 | 45 | |
46 | 46 | // This is a complex field, with labels on a per-input basis |
47 | - if( $input ) { |
|
47 | + if ( $input ) { |
|
48 | 48 | |
49 | 49 | // Does the input have a custom label on a per-input basis? Otherwise, default label. |
50 | - $label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label']; |
|
50 | + $label = ! empty( $input[ 'customLabel' ] ) ? $input[ 'customLabel' ] : $input[ 'label' ]; |
|
51 | 51 | |
52 | 52 | } else { |
53 | 53 | |
54 | 54 | // This is a field with one label |
55 | - $label = $field_object->get_field_label( true, $field['label'] ); |
|
55 | + $label = $field_object->get_field_label( true, $field[ 'label' ] ); |
|
56 | 56 | |
57 | 57 | } |
58 | 58 | |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
64 | - if ( !empty( $field['custom_label'] ) ) { |
|
64 | + if ( ! empty( $field[ 'custom_label' ] ) ) { |
|
65 | 65 | |
66 | - $label = self::replace_variables( $field['custom_label'], $form, $entry ); |
|
66 | + $label = self::replace_variables( $field[ 'custom_label' ], $form, $entry ); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | |
118 | 118 | $width = NULL; |
119 | 119 | |
120 | - if( !empty( $field['width'] ) ) { |
|
121 | - $width = absint( $field['width'] ); |
|
120 | + if ( ! empty( $field[ 'width' ] ) ) { |
|
121 | + $width = absint( $field[ 'width' ] ); |
|
122 | 122 | |
123 | 123 | // If using percentages, limit to 100% |
124 | - if( '%d%%' === $format && $width > 100 ) { |
|
124 | + if ( '%d%%' === $format && $width > 100 ) { |
|
125 | 125 | $width = 100; |
126 | 126 | } |
127 | 127 | |
@@ -144,39 +144,39 @@ discard block |
||
144 | 144 | |
145 | 145 | $classes = array(); |
146 | 146 | |
147 | - if( !empty( $field['custom_class'] ) ) { |
|
147 | + if ( ! empty( $field[ 'custom_class' ] ) ) { |
|
148 | 148 | |
149 | - $custom_class = $field['custom_class']; |
|
149 | + $custom_class = $field[ 'custom_class' ]; |
|
150 | 150 | |
151 | - if( !empty( $entry ) ) { |
|
151 | + if ( ! empty( $entry ) ) { |
|
152 | 152 | |
153 | 153 | // We want the merge tag to be formatted as a class. The merge tag may be |
154 | 154 | // replaced by a multiple-word value that should be output as a single class. |
155 | 155 | // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
156 | - add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
156 | + add_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
157 | 157 | |
158 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
158 | + $custom_class = self::replace_variables( $custom_class, $form, $entry ); |
|
159 | 159 | |
160 | 160 | // And then we want life to return to normal |
161 | - remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
161 | + remove_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // And now we want the spaces to be handled nicely. |
165 | - $classes[] = gravityview_sanitize_html_class( $custom_class ); |
|
165 | + $classes[ ] = gravityview_sanitize_html_class( $custom_class ); |
|
166 | 166 | |
167 | 167 | } |
168 | 168 | |
169 | - if(!empty($field['id'])) { |
|
170 | - if( !empty( $form ) && !empty( $form['id'] ) ) { |
|
171 | - $form_id = '-'.$form['id']; |
|
169 | + if ( ! empty( $field[ 'id' ] ) ) { |
|
170 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
171 | + $form_id = '-' . $form[ 'id' ]; |
|
172 | 172 | } else { |
173 | - $form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : ''; |
|
173 | + $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
|
174 | 174 | } |
175 | 175 | |
176 | - $classes[] = 'gv-field'.$form_id.'-'.$field['id']; |
|
176 | + $classes[ ] = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
177 | 177 | } |
178 | 178 | |
179 | - return esc_attr(implode(' ', $classes)); |
|
179 | + return esc_attr( implode( ' ', $classes ) ); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -193,16 +193,16 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public static function field_html_attr_id( $field, $form = array(), $entry = array() ) { |
195 | 195 | $gravityview_view = GravityView_View::getInstance(); |
196 | - $id = $field['id']; |
|
196 | + $id = $field[ 'id' ]; |
|
197 | 197 | |
198 | 198 | if ( ! empty( $id ) ) { |
199 | - if ( ! empty( $form ) && ! empty( $form['id'] ) ) { |
|
200 | - $form_id = '-' . $form['id']; |
|
199 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
200 | + $form_id = '-' . $form[ 'id' ]; |
|
201 | 201 | } else { |
202 | 202 | $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
203 | 203 | } |
204 | 204 | |
205 | - $id = 'gv-field' . $form_id . '-' . $field['id']; |
|
205 | + $id = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | return esc_attr( $id ); |
@@ -219,17 +219,17 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public static function field_value( $entry, $field_settings, $format = 'html' ) { |
221 | 221 | |
222 | - if( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) { |
|
222 | + if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) { |
|
223 | 223 | return NULL; |
224 | 224 | } |
225 | 225 | |
226 | 226 | $gravityview_view = GravityView_View::getInstance(); |
227 | 227 | |
228 | - $field_id = $field_settings['id']; |
|
228 | + $field_id = $field_settings[ 'id' ]; |
|
229 | 229 | $form = $gravityview_view->getForm(); |
230 | 230 | $field = gravityview_get_field( $form, $field_id ); |
231 | 231 | |
232 | - if( $field && is_numeric( $field_id ) ) { |
|
232 | + if ( $field && is_numeric( $field_id ) ) { |
|
233 | 233 | // Used as file name of field template in GV. |
234 | 234 | // Don't use RGFormsModel::get_input_type( $field ); we don't care if it's a radio input; we want to know it's a 'quiz' field |
235 | 235 | $field_type = $field->type; |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | // If a Gravity Forms Field is found, get the field display |
243 | - if( $field ) { |
|
243 | + if ( $field ) { |
|
244 | 244 | |
245 | 245 | // Prevent any PHP warnings that may be generated |
246 | 246 | ob_start(); |
247 | 247 | |
248 | - $display_value = GFCommon::get_lead_field_display( $field, $value, $entry["currency"], false, $format ); |
|
248 | + $display_value = GFCommon::get_lead_field_display( $field, $value, $entry[ "currency" ], false, $format ); |
|
249 | 249 | |
250 | 250 | if ( $errors = ob_get_clean() ) { |
251 | 251 | do_action( 'gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors ); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $display_value = apply_filters( "gform_entry_field_value", $display_value, $field, $entry, $form ); |
255 | 255 | |
256 | 256 | // prevent the use of merge_tags for non-admin fields |
257 | - if( !empty( $field->adminOnly ) ) { |
|
257 | + if ( ! empty( $field->adminOnly ) ) { |
|
258 | 258 | $display_value = self::replace_variables( $display_value, $form, $entry ); |
259 | 259 | } |
260 | 260 | } else { |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | |
265 | 265 | // Check whether the field exists in /includes/fields/{$field_type}.php |
266 | 266 | // This can be overridden by user template files. |
267 | - $field_path = $gravityview_view->locate_template("fields/{$field_type}.php"); |
|
267 | + $field_path = $gravityview_view->locate_template( "fields/{$field_type}.php" ); |
|
268 | 268 | |
269 | 269 | // Set the field data to be available in the templates |
270 | 270 | $gravityview_view->setCurrentField( array( |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | 'entry' => $entry, |
279 | 279 | 'field_type' => $field_type, /** {@since 1.6} */ |
280 | 280 | 'field_path' => $field_path, /** {@since 1.16} */ |
281 | - )); |
|
281 | + ) ); |
|
282 | 282 | |
283 | - if( ! empty( $field_path ) ) { |
|
283 | + if ( ! empty( $field_path ) ) { |
|
284 | 284 | |
285 | - do_action( 'gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path ) ); |
|
285 | + do_action( 'gravityview_log_debug', sprintf( '[field_value] Rendering %s', $field_path ) ); |
|
286 | 286 | |
287 | 287 | ob_start(); |
288 | 288 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | } |
299 | 299 | |
300 | 300 | // Get the field settings again so that the field template can override the settings |
301 | - $field_settings = $gravityview_view->getCurrentField('field_settings'); |
|
301 | + $field_settings = $gravityview_view->getCurrentField( 'field_settings' ); |
|
302 | 302 | |
303 | 303 | /** |
304 | 304 | * @filter `gravityview_field_entry_value_{$field_type}_pre_link` Modify the field value output for a field type before Show As Link setting is applied. Example: `gravityview_field_entry_value_number_pre_link` |
@@ -316,9 +316,9 @@ discard block |
||
316 | 316 | * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example. |
317 | 317 | * |
318 | 318 | */ |
319 | - if( !empty( $field_settings['show_as_link'] ) && ! gv_empty( $output, false, false ) ) { |
|
319 | + if ( ! empty( $field_settings[ 'show_as_link' ] ) && ! gv_empty( $output, false, false ) ) { |
|
320 | 320 | |
321 | - $link_atts = empty( $field_settings['new_window'] ) ? array() : array( 'target' => '_blank' ); |
|
321 | + $link_atts = empty( $field_settings[ 'new_window' ] ) ? array() : array( 'target' => '_blank' ); |
|
322 | 322 | |
323 | 323 | $output = self::entry_link_html( $entry, $output, $link_atts, $field_settings ); |
324 | 324 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @param array $field_settings Settings for the particular GV field |
333 | 333 | * @param array $field Current field being displayed |
334 | 334 | */ |
335 | - $output = apply_filters( 'gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
335 | + $output = apply_filters( 'gravityview_field_entry_value_' . $field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * @filter `gravityview_field_entry_value` Modify the field value output for all field types |
@@ -361,14 +361,14 @@ discard block |
||
361 | 361 | */ |
362 | 362 | public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array() ) { |
363 | 363 | |
364 | - if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) { |
|
364 | + if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry[ 'id' ] ) ) { |
|
365 | 365 | do_action( 'gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry ); |
366 | 366 | return NULL; |
367 | 367 | } |
368 | 368 | |
369 | 369 | $href = self::entry_link( $entry ); |
370 | 370 | |
371 | - if( '' === $href ) { |
|
371 | + if ( '' === $href ) { |
|
372 | 372 | return NULL; |
373 | 373 | } |
374 | 374 | |
@@ -391,19 +391,19 @@ discard block |
||
391 | 391 | * @param boolean $wpautop Apply wpautop() to the output? |
392 | 392 | * @return string HTML of "no results" text |
393 | 393 | */ |
394 | - public static function no_results($wpautop = true) { |
|
394 | + public static function no_results( $wpautop = true ) { |
|
395 | 395 | $gravityview_view = GravityView_View::getInstance(); |
396 | 396 | |
397 | 397 | $is_search = false; |
398 | 398 | |
399 | - if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
399 | + if ( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
400 | 400 | $is_search = true; |
401 | 401 | } |
402 | 402 | |
403 | - if($is_search) { |
|
404 | - $output = __('This search returned no results.', 'gravityview'); |
|
403 | + if ( $is_search ) { |
|
404 | + $output = __( 'This search returned no results.', 'gravityview' ); |
|
405 | 405 | } else { |
406 | - $output = __('No entries match your request.', 'gravityview'); |
|
406 | + $output = __( 'No entries match your request.', 'gravityview' ); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -411,9 +411,9 @@ discard block |
||
411 | 411 | * @param string $output The existing "No Entries" text |
412 | 412 | * @param boolean $is_search Is the current page a search result, or just a multiple entries screen? |
413 | 413 | */ |
414 | - $output = apply_filters( 'gravitview_no_entries_text', $output, $is_search); |
|
414 | + $output = apply_filters( 'gravitview_no_entries_text', $output, $is_search ); |
|
415 | 415 | |
416 | - return $wpautop ? wpautop($output) : $output; |
|
416 | + return $wpautop ? wpautop( $output ) : $output; |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | /** |
@@ -430,37 +430,37 @@ discard block |
||
430 | 430 | |
431 | 431 | $gravityview_view = GravityView_View::getInstance(); |
432 | 432 | |
433 | - if( empty( $post_id ) ) { |
|
433 | + if ( empty( $post_id ) ) { |
|
434 | 434 | |
435 | 435 | $post_id = false; |
436 | 436 | |
437 | 437 | // DataTables passes the Post ID |
438 | - if( defined('DOING_AJAX') && DOING_AJAX ) { |
|
438 | + if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
439 | 439 | |
440 | - $post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : false; |
|
440 | + $post_id = isset( $_POST[ 'post_id' ] ) ? (int)$_POST[ 'post_id' ] : false; |
|
441 | 441 | |
442 | 442 | } else { |
443 | 443 | |
444 | 444 | // The Post ID has been passed via the shortcode |
445 | - if( !empty( $gravityview_view ) && $gravityview_view->getPostId() ) { |
|
445 | + if ( ! empty( $gravityview_view ) && $gravityview_view->getPostId() ) { |
|
446 | 446 | |
447 | 447 | $post_id = $gravityview_view->getPostId(); |
448 | 448 | |
449 | 449 | } else { |
450 | 450 | |
451 | 451 | // This is a GravityView post type |
452 | - if( GravityView_frontend::getInstance()->isGravityviewPostType() ) { |
|
452 | + if ( GravityView_frontend::getInstance()->isGravityviewPostType() ) { |
|
453 | 453 | |
454 | 454 | $post_id = isset( $gravityview_view ) ? $gravityview_view->getViewId() : $post->ID; |
455 | 455 | |
456 | 456 | } else { |
457 | 457 | |
458 | 458 | // This is an embedded GravityView; use the embedded post's ID as the base. |
459 | - if( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) { |
|
459 | + if ( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) { |
|
460 | 460 | |
461 | 461 | $post_id = $post->ID; |
462 | 462 | |
463 | - } elseif( $gravityview_view->getViewId() ) { |
|
463 | + } elseif ( $gravityview_view->getViewId() ) { |
|
464 | 464 | |
465 | 465 | // The GravityView has been embedded in a widget or in a template, and |
466 | 466 | // is not in the current content. Thus, we defer to the View's own ID. |
@@ -475,36 +475,36 @@ discard block |
||
475 | 475 | } |
476 | 476 | |
477 | 477 | // No post ID, get outta here. |
478 | - if( empty( $post_id ) ) { |
|
478 | + if ( empty( $post_id ) ) { |
|
479 | 479 | return NULL; |
480 | 480 | } |
481 | 481 | |
482 | 482 | // If we've saved the permalink in memory, use it |
483 | 483 | // @since 1.3 |
484 | - $link = wp_cache_get( 'gv_directory_link_'.$post_id ); |
|
484 | + $link = wp_cache_get( 'gv_directory_link_' . $post_id ); |
|
485 | 485 | |
486 | - if( empty( $link ) ) { |
|
486 | + if ( empty( $link ) ) { |
|
487 | 487 | |
488 | 488 | $link = get_permalink( $post_id ); |
489 | 489 | |
490 | 490 | // If not yet saved, cache the permalink. |
491 | 491 | // @since 1.3 |
492 | - wp_cache_set( 'gv_directory_link_'.$post_id, $link ); |
|
492 | + wp_cache_set( 'gv_directory_link_' . $post_id, $link ); |
|
493 | 493 | |
494 | 494 | } |
495 | 495 | |
496 | 496 | // Deal with returning to proper pagination for embedded views |
497 | - if( $link && $add_query_args ) { |
|
497 | + if ( $link && $add_query_args ) { |
|
498 | 498 | |
499 | 499 | $args = array(); |
500 | 500 | |
501 | - if( $pagenum = rgget('pagenum') ) { |
|
502 | - $args['pagenum'] = intval( $pagenum ); |
|
501 | + if ( $pagenum = rgget( 'pagenum' ) ) { |
|
502 | + $args[ 'pagenum' ] = intval( $pagenum ); |
|
503 | 503 | } |
504 | 504 | |
505 | - if( $sort = rgget('sort') ) { |
|
506 | - $args['sort'] = $sort; |
|
507 | - $args['dir'] = rgget('dir'); |
|
505 | + if ( $sort = rgget( 'sort' ) ) { |
|
506 | + $args[ 'sort' ] = $sort; |
|
507 | + $args[ 'dir' ] = rgget( 'dir' ); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | $link = add_query_arg( $args, $link ); |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | private static function get_custom_entry_slug( $id, $entry = array() ) { |
528 | 528 | |
529 | 529 | // Generate an unique hash to use as the default value |
530 | - $slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 ); |
|
530 | + $slug = substr( wp_hash( $id, 'gravityview' . $id ), 0, 8 ); |
|
531 | 531 | |
532 | 532 | /** |
533 | 533 | * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}` |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | $slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry ); |
539 | 539 | |
540 | 540 | // Make sure we have something - use the original ID as backup. |
541 | - if( empty( $slug ) ) { |
|
541 | + if ( empty( $slug ) ) { |
|
542 | 542 | $slug = $id; |
543 | 543 | } |
544 | 544 | |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
568 | 568 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
569 | 569 | */ |
570 | - $custom = apply_filters('gravityview_custom_entry_slug', false ); |
|
570 | + $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
571 | 571 | |
572 | 572 | // If we're using custom slug... |
573 | 573 | if ( $custom ) { |
@@ -581,8 +581,8 @@ discard block |
||
581 | 581 | // If it does have a hash set, and the hash is expected, use it. |
582 | 582 | // This check allows users to change the hash structure using the |
583 | 583 | // gravityview_entry_hash filter and have the old hashes expire. |
584 | - if( empty( $value ) || $value !== $hash ) { |
|
585 | - do_action( 'gravityview_log_debug', __METHOD__ . ' - Setting hash for entry "'.$id_or_string.'": ' . $hash ); |
|
584 | + if ( empty( $value ) || $value !== $hash ) { |
|
585 | + do_action( 'gravityview_log_debug', __METHOD__ . ' - Setting hash for entry "' . $id_or_string . '": ' . $hash ); |
|
586 | 586 | gform_update_meta( $id_or_string, 'gravityview_unique_id', $hash, rgar( $entry, 'form_id' ) ); |
587 | 587 | } |
588 | 588 | |
@@ -608,15 +608,15 @@ discard block |
||
608 | 608 | * @param boolean $custom Should we process the custom entry slug? |
609 | 609 | */ |
610 | 610 | $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
611 | - if( $custom ) { |
|
611 | + if ( $custom ) { |
|
612 | 612 | // create the gravityview_unique_id and save it |
613 | 613 | |
614 | 614 | // Get the entry hash |
615 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
615 | + $hash = self::get_custom_entry_slug( $entry[ 'id' ], $entry ); |
|
616 | 616 | |
617 | - do_action( 'gravityview_log_debug', __METHOD__ . ' - Setting hash for entry "'.$entry['id'].'": ' . $hash ); |
|
617 | + do_action( 'gravityview_log_debug', __METHOD__ . ' - Setting hash for entry "' . $entry[ 'id' ] . '": ' . $hash ); |
|
618 | 618 | |
619 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash, rgar( $entry, 'form_id' ) ); |
|
619 | + gform_update_meta( $entry[ 'id' ], 'gravityview_unique_id', $hash, rgar( $entry, 'form_id' ) ); |
|
620 | 620 | |
621 | 621 | } |
622 | 622 | } |
@@ -633,14 +633,14 @@ discard block |
||
633 | 633 | */ |
634 | 634 | public static function entry_link( $entry, $post_id = NULL, $add_directory_args = true ) { |
635 | 635 | |
636 | - if( ! empty( $entry ) && ! is_array( $entry ) ) { |
|
636 | + if ( ! empty( $entry ) && ! is_array( $entry ) ) { |
|
637 | 637 | $entry = GVCommon::get_entry( $entry ); |
638 | - } else if( empty( $entry ) ) { |
|
638 | + } else if ( empty( $entry ) ) { |
|
639 | 639 | $entry = GravityView_frontend::getInstance()->getEntry(); |
640 | 640 | } |
641 | 641 | |
642 | 642 | // Second parameter used to be passed as $field; this makes sure it's not an array |
643 | - if( !is_numeric( $post_id ) ) { |
|
643 | + if ( ! is_numeric( $post_id ) ) { |
|
644 | 644 | $post_id = NULL; |
645 | 645 | } |
646 | 646 | |
@@ -648,15 +648,15 @@ discard block |
||
648 | 648 | $directory_link = self::directory_link( $post_id, false ); |
649 | 649 | |
650 | 650 | // No post ID? Get outta here. |
651 | - if( empty( $directory_link ) ) { |
|
651 | + if ( empty( $directory_link ) ) { |
|
652 | 652 | return ''; |
653 | 653 | } |
654 | 654 | |
655 | 655 | $query_arg_name = GravityView_Post_Types::get_entry_var_name(); |
656 | 656 | |
657 | - $entry_slug = self::get_entry_slug( $entry['id'], $entry ); |
|
657 | + $entry_slug = self::get_entry_slug( $entry[ 'id' ], $entry ); |
|
658 | 658 | |
659 | - if( get_option('permalink_structure') && !is_preview() ) { |
|
659 | + if ( get_option( 'permalink_structure' ) && ! is_preview() ) { |
|
660 | 660 | |
661 | 661 | $args = array(); |
662 | 662 | |
@@ -666,9 +666,9 @@ discard block |
||
666 | 666 | */ |
667 | 667 | $link_parts = explode( '?', $directory_link ); |
668 | 668 | |
669 | - $query = !empty( $link_parts[1] ) ? '?'.$link_parts[1] : ''; |
|
669 | + $query = ! empty( $link_parts[ 1 ] ) ? '?' . $link_parts[ 1 ] : ''; |
|
670 | 670 | |
671 | - $directory_link = trailingslashit( $link_parts[0] ) . $query_arg_name . '/'. $entry_slug .'/' . $query; |
|
671 | + $directory_link = trailingslashit( $link_parts[ 0 ] ) . $query_arg_name . '/' . $entry_slug . '/' . $query; |
|
672 | 672 | |
673 | 673 | } else { |
674 | 674 | |
@@ -678,18 +678,18 @@ discard block |
||
678 | 678 | /** |
679 | 679 | * @since 1.7.3 |
680 | 680 | */ |
681 | - if( $add_directory_args ) { |
|
681 | + if ( $add_directory_args ) { |
|
682 | 682 | |
683 | - if( !empty( $_GET['pagenum'] ) ) { |
|
684 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
683 | + if ( ! empty( $_GET[ 'pagenum' ] ) ) { |
|
684 | + $args[ 'pagenum' ] = intval( $_GET[ 'pagenum' ] ); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | /** |
688 | 688 | * @since 1.7 |
689 | 689 | */ |
690 | - if( $sort = rgget('sort') ) { |
|
691 | - $args['sort'] = $sort; |
|
692 | - $args['dir'] = rgget('dir'); |
|
690 | + if ( $sort = rgget( 'sort' ) ) { |
|
691 | + $args[ 'sort' ] = $sort; |
|
692 | + $args[ 'dir' ] = rgget( 'dir' ); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | } |
@@ -699,8 +699,8 @@ discard block |
||
699 | 699 | * has the view id so that Advanced Filters can be applied correctly when rendering the single view |
700 | 700 | * @see GravityView_frontend::get_context_view_id() |
701 | 701 | */ |
702 | - if( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
|
703 | - $args['gvid'] = gravityview_get_view_id(); |
|
702 | + if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
|
703 | + $args[ 'gvid' ] = gravityview_get_view_id(); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | return add_query_arg( $args, $directory_link ); |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | } |
719 | 719 | |
720 | 720 | function gv_class( $field, $form = NULL, $entry = array() ) { |
721 | - return GravityView_API::field_class( $field, $form, $entry ); |
|
721 | + return GravityView_API::field_class( $field, $form, $entry ); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | /** |
@@ -740,15 +740,15 @@ discard block |
||
740 | 740 | |
741 | 741 | $default_css_class = ! empty( $view_id ) ? sprintf( 'gv-container gv-container-%d', $view_id ) : 'gv-container'; |
742 | 742 | |
743 | - if( GravityView_View::getInstance()->isHideUntilSearched() ) { |
|
743 | + if ( GravityView_View::getInstance()->isHideUntilSearched() ) { |
|
744 | 744 | $default_css_class .= ' hidden'; |
745 | 745 | } |
746 | 746 | |
747 | - if( 0 === GravityView_View::getInstance()->getTotalEntries() ) { |
|
747 | + if ( 0 === GravityView_View::getInstance()->getTotalEntries() ) { |
|
748 | 748 | $default_css_class .= ' gv-container-no-results'; |
749 | 749 | } |
750 | 750 | |
751 | - $css_class = trim( $passed_css_class . ' '. $default_css_class ); |
|
751 | + $css_class = trim( $passed_css_class . ' ' . $default_css_class ); |
|
752 | 752 | |
753 | 753 | /** |
754 | 754 | * @filter `gravityview/render/container/class` Modify the CSS class to be added to the wrapper <div> of a View |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | |
760 | 760 | $css_class = gravityview_sanitize_html_class( $css_class ); |
761 | 761 | |
762 | - if( $echo ) { |
|
762 | + if ( $echo ) { |
|
763 | 763 | echo $css_class; |
764 | 764 | } |
765 | 765 | |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | |
771 | 771 | $value = GravityView_API::field_value( $entry, $field ); |
772 | 772 | |
773 | - if( $value === '' ) { |
|
773 | + if ( $value === '' ) { |
|
774 | 774 | /** |
775 | 775 | * @filter `gravityview_empty_value` What to display when a field is empty |
776 | 776 | * @param string $value (empty string) |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | return GravityView_API::entry_link( $entry, $post_id ); |
790 | 790 | } |
791 | 791 | |
792 | -function gv_no_results($wpautop = true) { |
|
792 | +function gv_no_results( $wpautop = true ) { |
|
793 | 793 | return GravityView_API::no_results( $wpautop ); |
794 | 794 | } |
795 | 795 | |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | |
803 | 803 | $href = gv_directory_link(); |
804 | 804 | |
805 | - if( empty( $href ) ) { return NULL; } |
|
805 | + if ( empty( $href ) ) { return NULL; } |
|
806 | 806 | |
807 | 807 | // calculate link label |
808 | 808 | $gravityview_view = GravityView_View::getInstance(); |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | |
819 | 819 | $link = gravityview_get_link( $href, esc_html( $label ), array( |
820 | 820 | 'data-viewid' => $gravityview_view->getViewId() |
821 | - )); |
|
821 | + ) ); |
|
822 | 822 | |
823 | 823 | return $link; |
824 | 824 | } |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | */ |
838 | 838 | function gravityview_get_field_value( $entry, $field_id, $display_value ) { |
839 | 839 | |
840 | - if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
840 | + if ( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
841 | 841 | |
842 | 842 | // For the complete field value as generated by Gravity Forms |
843 | 843 | return $display_value; |
@@ -867,16 +867,16 @@ discard block |
||
867 | 867 | |
868 | 868 | $terms = explode( ', ', $value ); |
869 | 869 | |
870 | - foreach ($terms as $term_name ) { |
|
870 | + foreach ( $terms as $term_name ) { |
|
871 | 871 | |
872 | 872 | // If we're processing a category, |
873 | - if( $taxonomy === 'category' ) { |
|
873 | + if ( $taxonomy === 'category' ) { |
|
874 | 874 | |
875 | 875 | // Use rgexplode to prevent errors if : doesn't exist |
876 | 876 | list( $term_name, $term_id ) = rgexplode( ':', $value, 2 ); |
877 | 877 | |
878 | 878 | // The explode was succesful; we have the category ID |
879 | - if( !empty( $term_id )) { |
|
879 | + if ( ! empty( $term_id ) ) { |
|
880 | 880 | $term = get_term_by( 'id', $term_id, $taxonomy ); |
881 | 881 | } else { |
882 | 882 | // We have to fall back to the name |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | } |
890 | 890 | |
891 | 891 | // There's still a tag/category here. |
892 | - if( $term ) { |
|
892 | + if ( $term ) { |
|
893 | 893 | |
894 | 894 | $term_link = get_term_link( $term, $taxonomy ); |
895 | 895 | |
@@ -898,11 +898,11 @@ discard block |
||
898 | 898 | continue; |
899 | 899 | } |
900 | 900 | |
901 | - $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
901 | + $output[ ] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
902 | 902 | } |
903 | 903 | } |
904 | 904 | |
905 | - return implode(', ', $output ); |
|
905 | + return implode( ', ', $output ); |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | /** |
@@ -916,8 +916,8 @@ discard block |
||
916 | 916 | |
917 | 917 | $output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' ); |
918 | 918 | |
919 | - if( empty( $link ) ) { |
|
920 | - return strip_tags( $output); |
|
919 | + if ( empty( $link ) ) { |
|
920 | + return strip_tags( $output ); |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | return $output; |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | $fe = GravityView_frontend::getInstance(); |
937 | 937 | |
938 | 938 | // Solve problem when loading content via admin-ajax.php |
939 | - if( ! $fe->getGvOutputData() ) { |
|
939 | + if ( ! $fe->getGvOutputData() ) { |
|
940 | 940 | |
941 | 941 | do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.' ); |
942 | 942 | |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | } |
945 | 945 | |
946 | 946 | // Make 100% sure that we're dealing with a properly called situation |
947 | - if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
947 | + if ( ! is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
948 | 948 | |
949 | 949 | do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData() ); |
950 | 950 | |
@@ -964,10 +964,10 @@ discard block |
||
964 | 964 | |
965 | 965 | $fe = GravityView_frontend::getInstance(); |
966 | 966 | |
967 | - if( ! $fe->getGvOutputData() ) { return array(); } |
|
967 | + if ( ! $fe->getGvOutputData() ) { return array(); } |
|
968 | 968 | |
969 | 969 | // If not set, grab the current view ID |
970 | - if( empty( $view_id ) ) { |
|
970 | + if ( empty( $view_id ) ) { |
|
971 | 971 | $view_id = $fe->get_context_view_id(); |
972 | 972 | } |
973 | 973 | |
@@ -1032,11 +1032,11 @@ discard block |
||
1032 | 1032 | */ |
1033 | 1033 | $is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false ); |
1034 | 1034 | |
1035 | - if( $is_edit_entry ) { |
|
1035 | + if ( $is_edit_entry ) { |
|
1036 | 1036 | $context = 'edit'; |
1037 | - } else if( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) { |
|
1037 | + } else if ( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) { |
|
1038 | 1038 | $context = 'single'; |
1039 | - } else if( class_exists( 'GravityView_View' ) ) { |
|
1039 | + } else if ( class_exists( 'GravityView_View' ) ) { |
|
1040 | 1040 | $context = GravityView_View::getInstance()->getContext(); |
1041 | 1041 | } |
1042 | 1042 | |
@@ -1064,12 +1064,12 @@ discard block |
||
1064 | 1064 | function gravityview_get_files_array( $value, $gv_class = '' ) { |
1065 | 1065 | /** @define "GRAVITYVIEW_DIR" "../" */ |
1066 | 1066 | |
1067 | - if( !class_exists( 'GravityView_Field' ) ) { |
|
1068 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' ); |
|
1067 | + if ( ! class_exists( 'GravityView_Field' ) ) { |
|
1068 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' ); |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | - if( !class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
1072 | - include_once( GRAVITYVIEW_DIR .'includes/fields/fileupload.php' ); |
|
1071 | + if ( ! class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
1072 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/fileupload.php' ); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | return GravityView_Field_FileUpload::get_files_array( $value, $gv_class ); |
@@ -1147,12 +1147,12 @@ discard block |
||
1147 | 1147 | $args = apply_filters( 'gravityview/field_output/args', $args, $passed_args ); |
1148 | 1148 | |
1149 | 1149 | // Required fields. |
1150 | - if ( empty( $args['field'] ) || empty( $args['form'] ) ) { |
|
1150 | + if ( empty( $args[ 'field' ] ) || empty( $args[ 'form' ] ) ) { |
|
1151 | 1151 | do_action( 'gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args ); |
1152 | 1152 | return ''; |
1153 | 1153 | } |
1154 | 1154 | |
1155 | - $entry = empty( $args['entry'] ) ? array() : $args['entry']; |
|
1155 | + $entry = empty( $args[ 'entry' ] ) ? array() : $args[ 'entry' ]; |
|
1156 | 1156 | |
1157 | 1157 | /** |
1158 | 1158 | * Create the content variables for replacing. |
@@ -1168,37 +1168,37 @@ discard block |
||
1168 | 1168 | 'field_id' => '', |
1169 | 1169 | ); |
1170 | 1170 | |
1171 | - $context['value'] = gv_value( $entry, $args['field'] ); |
|
1171 | + $context[ 'value' ] = gv_value( $entry, $args[ 'field' ] ); |
|
1172 | 1172 | |
1173 | 1173 | // If the value is empty and we're hiding empty, return empty. |
1174 | - if ( $context['value'] === '' && ! empty( $args['hide_empty'] ) ) { |
|
1174 | + if ( $context[ 'value' ] === '' && ! empty( $args[ 'hide_empty' ] ) ) { |
|
1175 | 1175 | return ''; |
1176 | 1176 | } |
1177 | 1177 | |
1178 | - if ( $context['value'] !== '' && ! empty( $args['wpautop'] ) ) { |
|
1179 | - $context['value'] = wpautop( $context['value'] ); |
|
1178 | + if ( $context[ 'value' ] !== '' && ! empty( $args[ 'wpautop' ] ) ) { |
|
1179 | + $context[ 'value' ] = wpautop( $context[ 'value' ] ); |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | // Get width setting, if exists |
1183 | - $context['width'] = GravityView_API::field_width( $args['field'] ); |
|
1183 | + $context[ 'width' ] = GravityView_API::field_width( $args[ 'field' ] ); |
|
1184 | 1184 | |
1185 | 1185 | // If replacing with CSS inline formatting, let's do it. |
1186 | - $context['width:style'] = GravityView_API::field_width( $args['field'], 'width:' . $context['width'] . '%;' ); |
|
1186 | + $context[ 'width:style' ] = GravityView_API::field_width( $args[ 'field' ], 'width:' . $context[ 'width' ] . '%;' ); |
|
1187 | 1187 | |
1188 | 1188 | // Grab the Class using `gv_class` |
1189 | - $context['class'] = gv_class( $args['field'], $args['form'], $entry ); |
|
1190 | - $context['field_id'] = GravityView_API::field_html_attr_id( $args['field'], $args['form'], $entry ); |
|
1189 | + $context[ 'class' ] = gv_class( $args[ 'field' ], $args[ 'form' ], $entry ); |
|
1190 | + $context[ 'field_id' ] = GravityView_API::field_html_attr_id( $args[ 'field' ], $args[ 'form' ], $entry ); |
|
1191 | 1191 | |
1192 | 1192 | // Get field label if needed |
1193 | - if ( ! empty( $args['label_markup'] ) && ! empty( $args['field']['show_label'] ) ) { |
|
1194 | - $context['label'] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup'] ); |
|
1193 | + if ( ! empty( $args[ 'label_markup' ] ) && ! empty( $args[ 'field' ][ 'show_label' ] ) ) { |
|
1194 | + $context[ 'label' ] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args[ 'label_markup' ] ); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | // Default Label value |
1198 | - $context['label_value'] = gv_label( $args['field'], $entry ); |
|
1198 | + $context[ 'label_value' ] = gv_label( $args[ 'field' ], $entry ); |
|
1199 | 1199 | |
1200 | - if ( empty( $context['label'] ) && ! empty( $context['label_value'] ) ){ |
|
1201 | - $context['label'] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
1200 | + if ( empty( $context[ 'label' ] ) && ! empty( $context[ 'label_value' ] ) ) { |
|
1201 | + $context[ 'label' ] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
1202 | 1202 | } |
1203 | 1203 | |
1204 | 1204 | /** |
@@ -1207,7 +1207,7 @@ discard block |
||
1207 | 1207 | * @param string $markup The HTML for the markup |
1208 | 1208 | * @param array $args All args for the field output |
1209 | 1209 | */ |
1210 | - $html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args ); |
|
1210 | + $html = apply_filters( 'gravityview/field_output/pre_html', $args[ 'markup' ], $args ); |
|
1211 | 1211 | |
1212 | 1212 | /** |
1213 | 1213 | * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | foreach ( $context as $tag => $value ) { |
1231 | 1231 | |
1232 | 1232 | // If the tag doesn't exist just skip it |
1233 | - if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){ |
|
1233 | + if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ) { |
|
1234 | 1234 | continue; |
1235 | 1235 | } |
1236 | 1236 |