@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public static function get_instance() { |
96 | 96 | |
97 | - if( empty( self::$instance ) ) { |
|
97 | + if ( empty( self::$instance ) ) { |
|
98 | 98 | self::$instance = new self; |
99 | 99 | } |
100 | 100 | |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | |
129 | 129 | $operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS ); |
130 | 130 | |
131 | - if( $with_values ) { |
|
131 | + if ( $with_values ) { |
|
132 | 132 | $operators_with_values = array(); |
133 | - foreach( $operators as $key ) { |
|
133 | + foreach ( $operators as $key ) { |
|
134 | 134 | $operators_with_values[ $key ] = ''; |
135 | 135 | } |
136 | 136 | return $operators_with_values; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | $operators = $this->get_operators( false ); |
151 | 151 | |
152 | - if( !in_array( $operation, $operators ) ) { |
|
152 | + if ( ! in_array( $operation, $operators ) ) { |
|
153 | 153 | gravityview()->log->debug( ' Attempted to add invalid operation type. {operation}', array( 'operation' => $operation ) ); |
154 | 154 | return false; |
155 | 155 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | return null; |
202 | 202 | } |
203 | 203 | |
204 | - if( empty( $atts ) ) { |
|
204 | + if ( empty( $atts ) ) { |
|
205 | 205 | gravityview()->log->error( '$atts are empty.', array( 'data' => $atts ) ); |
206 | 206 | return null; |
207 | 207 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $setup = $this->setup_operation_and_comparison(); |
226 | 226 | |
227 | 227 | // We need an operation and comparison value |
228 | - if( ! $setup ) { |
|
228 | + if ( ! $setup ) { |
|
229 | 229 | gravityview()->log->error( 'No valid operators were passed.', array( 'data' => $this->atts ) ); |
230 | 230 | return null; |
231 | 231 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $logged_in_match = ! $this->logged_in ^ is_user_logged_in(); // XNOR |
278 | 278 | |
279 | 279 | // Only logged-in match |
280 | - if( 1 === sizeof( $this->passed_atts ) ) { |
|
280 | + if ( 1 === sizeof( $this->passed_atts ) ) { |
|
281 | 281 | $this->is_match = $logged_in_match; |
282 | 282 | } else { |
283 | 283 | $this->is_match = $logged_in_match && $comparison_match; |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | private function get_output() { |
293 | 293 | |
294 | - if( $this->is_match ) { |
|
294 | + if ( $this->is_match ) { |
|
295 | 295 | $output = $this->content; |
296 | 296 | } else { |
297 | 297 | $output = $this->else_content; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @param string $output HTML/text output |
310 | 310 | * @param GVLogic_Shortcode $this This class |
311 | 311 | */ |
312 | - $output = apply_filters('gravityview/gvlogic/output', $output, $this ); |
|
312 | + $output = apply_filters( 'gravityview/gvlogic/output', $output, $this ); |
|
313 | 313 | |
314 | 314 | gravityview()->log->debug( 'Output: ', array( 'data' => $output ) ); |
315 | 315 | |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | list( $before_else, $after_else ) = array_pad( explode( '[else]', $passed_content ), 2, NULL ); |
330 | 330 | list( $before_else_if, $after_else_if ) = array_pad( explode( '[else', $passed_content ), 2, NULL ); |
331 | 331 | |
332 | - $else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL; |
|
332 | + $else_attr = isset( $this->atts[ 'else' ] ) ? $this->atts[ 'else' ] : NULL; |
|
333 | 333 | $else_content = isset( $after_else ) ? $after_else : $else_attr; |
334 | 334 | |
335 | 335 | // The content is everything OTHER than the [else] |
336 | 336 | $this->content = $before_else_if; |
337 | 337 | |
338 | 338 | if ( ! $this->is_match ) { |
339 | - if( $elseif_content = $this->process_elseif( $before_else ) ) { |
|
339 | + if ( $elseif_content = $this->process_elseif( $before_else ) ) { |
|
340 | 340 | $this->else_content = $elseif_content; |
341 | 341 | } else { |
342 | 342 | $this->else_content = $else_content; |
@@ -364,16 +364,16 @@ discard block |
||
364 | 364 | foreach ( $else_if_matches as $key => $else_if_match ) { |
365 | 365 | |
366 | 366 | // If $else_if_match[5] exists and has content, check for more shortcodes |
367 | - preg_match_all( '/' . $regex . '/', $else_if_match[5] . '[/else]', $recursive_matches, PREG_SET_ORDER ); |
|
367 | + preg_match_all( '/' . $regex . '/', $else_if_match[ 5 ] . '[/else]', $recursive_matches, PREG_SET_ORDER ); |
|
368 | 368 | |
369 | 369 | // If the logic passes, this is the value that should be used for $this->else_content |
370 | - $else_if_value = $else_if_match[5]; |
|
371 | - $check_elseif_match = $else_if_match[0]; |
|
370 | + $else_if_value = $else_if_match[ 5 ]; |
|
371 | + $check_elseif_match = $else_if_match[ 0 ]; |
|
372 | 372 | |
373 | 373 | // Retrieve the value of the match that is currently being checked, without any other [else] tags |
374 | - if( ! empty( $recursive_matches[0][0] ) ) { |
|
375 | - $else_if_value = str_replace( $recursive_matches[0][0], '', $else_if_value ); |
|
376 | - $check_elseif_match = str_replace( $recursive_matches[0][0], '', $check_elseif_match ); |
|
374 | + if ( ! empty( $recursive_matches[ 0 ][ 0 ] ) ) { |
|
375 | + $else_if_value = str_replace( $recursive_matches[ 0 ][ 0 ], '', $else_if_value ); |
|
376 | + $check_elseif_match = str_replace( $recursive_matches[ 0 ][ 0 ], '', $check_elseif_match ); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | $check_elseif_match = str_replace( '[else', '[gvlogicelse', $check_elseif_match ); |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | } |
391 | 391 | |
392 | 392 | // Process any remaining [else] tags |
393 | - return $this->process_elseif( $else_if_match[5] ); |
|
393 | + return $this->process_elseif( $else_if_match[ 5 ] ); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | return false; |
@@ -417,11 +417,11 @@ discard block |
||
417 | 417 | $this->atts = array_intersect_key( $this->passed_atts, $this->atts ); |
418 | 418 | |
419 | 419 | // Strip whitespace if it's not default false |
420 | - $this->if = ( isset( $this->atts['if'] ) && is_string( $this->atts['if'] ) ) ? trim( $this->atts['if'] ) : false; |
|
420 | + $this->if = ( isset( $this->atts[ 'if' ] ) && is_string( $this->atts[ 'if' ] ) ) ? trim( $this->atts[ 'if' ] ) : false; |
|
421 | 421 | |
422 | - if ( isset( $this->atts['logged_in'] ) ) { |
|
422 | + if ( isset( $this->atts[ 'logged_in' ] ) ) { |
|
423 | 423 | // Truthy |
424 | - if ( in_array( strtolower( $this->atts['logged_in'] ), array( '0', 'false', 'no' ) ) ) { |
|
424 | + if ( in_array( strtolower( $this->atts[ 'logged_in' ] ), array( '0', 'false', 'no' ) ) ) { |
|
425 | 425 | $this->logged_in = false; |
426 | 426 | } else { |
427 | 427 | $this->logged_in = true; |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | do_action( 'gravityview/gvlogic/parse_atts/after', $this ); |
438 | 438 | |
439 | 439 | // Make sure the "if" isn't processed in self::setup_operation_and_comparison() |
440 | - unset( $this->atts['if'] ); |
|
440 | + unset( $this->atts[ 'if' ] ); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | |
61 | 61 | if ( 'address' === \GV\Utils::get( $search_field, 'type' ) ) { |
62 | 62 | |
63 | - $field_id = intval( floor( $search_field['key'] ) ); |
|
64 | - $input_id = gravityview_get_input_id_from_id( $search_field['key'] ); |
|
63 | + $field_id = intval( floor( $search_field[ 'key' ] ) ); |
|
64 | + $input_id = gravityview_get_input_id_from_id( $search_field[ 'key' ] ); |
|
65 | 65 | $form = GravityView_View::getInstance()->getForm(); |
66 | 66 | |
67 | 67 | /** @var GF_Field_Address $address_field */ |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $choices = array(); |
71 | 71 | |
72 | 72 | $method_name = 'get_choices_' . self::get_input_type_from_input_id( $input_id ); |
73 | - if( method_exists( $this, $method_name ) ) { |
|
73 | + if ( method_exists( $this, $method_name ) ) { |
|
74 | 74 | /** |
75 | 75 | * @uses GravityView_Field_Address::get_choices_country() |
76 | 76 | * @uses GravityView_Field_Address::get_choices_state() |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $choices = $this->{$method_name}( $address_field, $form ); |
79 | 79 | } |
80 | 80 | |
81 | - if( ! empty( $choices ) ) { |
|
82 | - $search_field['choices'] = $choices; |
|
83 | - $search_field['type'] = \GV\Utils::get( $search_field, 'input'); |
|
81 | + if ( ! empty( $choices ) ) { |
|
82 | + $search_field[ 'choices' ] = $choices; |
|
83 | + $search_field[ 'type' ] = \GV\Utils::get( $search_field, 'input' ); |
|
84 | 84 | } else { |
85 | - $search_field['type'] = 'text'; |
|
86 | - $search_field['input'] = 'input_text'; |
|
85 | + $search_field[ 'type' ] = 'text'; |
|
86 | + $search_field[ 'input' ] = 'input_text'; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $country_choices = array(); |
110 | 110 | |
111 | 111 | foreach ( $countries as $key => $country ) { |
112 | - $country_choices[] = array( |
|
112 | + $country_choices[ ] = array( |
|
113 | 113 | 'value' => $country, |
114 | 114 | 'text' => $country, |
115 | 115 | ); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | private function get_choices_state( $address_field, $form ) { |
136 | 136 | |
137 | - $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form['id'] ) : $address_field->addressType; |
|
137 | + $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form[ 'id' ] ) : $address_field->addressType; |
|
138 | 138 | |
139 | 139 | $state_choices = array(); |
140 | 140 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | $states = GFCommon::get_canadian_provinces(); |
147 | 147 | break; |
148 | 148 | default: |
149 | - $address_types = $address_field->get_address_types( $form['id'] ); |
|
150 | - $states = empty( $address_types[ $address_type ]['states'] ) ? array() : $address_types[ $address_type ]['states']; |
|
149 | + $address_types = $address_field->get_address_types( $form[ 'id' ] ); |
|
150 | + $states = empty( $address_types[ $address_type ][ 'states' ] ) ? array() : $address_types[ $address_type ][ 'states' ]; |
|
151 | 151 | break; |
152 | 152 | } |
153 | 153 | |
@@ -156,19 +156,19 @@ discard block |
||
156 | 156 | $state_subchoices = array(); |
157 | 157 | |
158 | 158 | foreach ( $state as $key => $substate ) { |
159 | - $state_subchoices[] = array( |
|
159 | + $state_subchoices[ ] = array( |
|
160 | 160 | 'value' => is_numeric( $key ) ? $substate : $key, |
161 | 161 | 'text' => $substate, |
162 | 162 | ); |
163 | 163 | } |
164 | 164 | |
165 | - $state_choices[] = array( |
|
165 | + $state_choices[ ] = array( |
|
166 | 166 | 'text' => $key, |
167 | 167 | 'value' => $state_subchoices, |
168 | 168 | ); |
169 | 169 | |
170 | 170 | } else { |
171 | - $state_choices[] = array( |
|
171 | + $state_choices[ ] = array( |
|
172 | 172 | 'value' => is_numeric( $key ) ? $state : $key, |
173 | 173 | 'text' => $state, |
174 | 174 | ); |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | // Use the same inputs as the "text" input type allows |
193 | 193 | $text_inputs = \GV\Utils::get( $input_types, 'text' ); |
194 | 194 | |
195 | - $input_types['street'] = $text_inputs; |
|
196 | - $input_types['street2'] = $text_inputs; |
|
197 | - $input_types['city'] = $text_inputs; |
|
195 | + $input_types[ 'street' ] = $text_inputs; |
|
196 | + $input_types[ 'street2' ] = $text_inputs; |
|
197 | + $input_types[ 'city' ] = $text_inputs; |
|
198 | 198 | |
199 | - $input_types['state'] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
200 | - $input_types['zip'] = array( 'input_text' ); |
|
201 | - $input_types['country'] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
199 | + $input_types[ 'state' ] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
200 | + $input_types[ 'zip' ] = array( 'input_text' ); |
|
201 | + $input_types[ 'country' ] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
202 | 202 | |
203 | 203 | return $input_types; |
204 | 204 | } |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | // Is this search field for an input (eg: 4.2) or the whole address field (eg: 4)? |
220 | 220 | $input_id = gravityview_get_input_id_from_id( $field_id ); |
221 | 221 | |
222 | - if( 'address' === $field_type && $input_id ) { |
|
222 | + if ( 'address' === $field_type && $input_id ) { |
|
223 | 223 | |
224 | 224 | // If the input ID matches an expected address input, set to that. Otherwise, keep existing input type. |
225 | - if( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { |
|
225 | + if ( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { |
|
226 | 226 | $input_type = $address_field_name; |
227 | 227 | } |
228 | 228 | } |
@@ -271,20 +271,20 @@ discard block |
||
271 | 271 | function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
272 | 272 | |
273 | 273 | // If this is NOT the full address field, return default options. |
274 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
274 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
275 | 275 | return $field_options; |
276 | 276 | } |
277 | 277 | |
278 | - if( 'edit' === $context ) { |
|
278 | + if ( 'edit' === $context ) { |
|
279 | 279 | return $field_options; |
280 | 280 | } |
281 | 281 | |
282 | 282 | $add_options = array(); |
283 | 283 | |
284 | - $add_options['show_map_link'] = array( |
|
284 | + $add_options[ 'show_map_link' ] = array( |
|
285 | 285 | 'type' => 'checkbox', |
286 | 286 | 'label' => __( 'Show Map Link:', 'gravityview' ), |
287 | - 'desc' => __('Display a "Map It" link below the address', 'gravityview'), |
|
287 | + 'desc' => __( 'Display a "Map It" link below the address', 'gravityview' ), |
|
288 | 288 | 'value' => true, |
289 | 289 | 'merge_tags' => false, |
290 | 290 | ); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | $this->label = esc_attr__( 'Approve Entries', 'gravityview' ); |
26 | 26 | |
27 | - $this->description = esc_attr__( 'Approve and reject entries from the View.', 'gravityview' ); |
|
27 | + $this->description = esc_attr__( 'Approve and reject entries from the View.', 'gravityview' ); |
|
28 | 28 | |
29 | 29 | $this->add_hooks(); |
30 | 30 | |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
48 | 48 | |
49 | - unset( $field_options['only_loggedin'] ); |
|
49 | + unset( $field_options[ 'only_loggedin' ] ); |
|
50 | 50 | |
51 | - unset( $field_options['new_window'] ); |
|
51 | + unset( $field_options[ 'new_window' ] ); |
|
52 | 52 | |
53 | - unset( $field_options['show_as_link'] ); |
|
53 | + unset( $field_options[ 'show_as_link' ] ); |
|
54 | 54 | |
55 | 55 | return $field_options; |
56 | 56 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | add_action( 'gravityview/field/approval/load_scripts', array( $this, 'enqueue_and_localize_script' ) ); |
72 | 72 | |
73 | - add_action( 'gravityview_datatables_scripts_styles', array( $this, 'enqueue_and_localize_script' ) ); |
|
73 | + add_action( 'gravityview_datatables_scripts_styles', array( $this, 'enqueue_and_localize_script' ) ); |
|
74 | 74 | |
75 | 75 | add_filter( 'gravityview_get_entries', array( $this, 'modify_search_parameters' ), 1000 ); |
76 | 76 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public function maybe_prevent_field_render( $html, $args ) { |
93 | 93 | |
94 | 94 | // If the field is `entry_approval` type but the user doesn't have the moderate entries cap, don't render. |
95 | - if( $this->name === \GV\Utils::get( $args['field'], 'id' ) && ! GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
95 | + if ( $this->name === \GV\Utils::get( $args[ 'field' ], 'id' ) && ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
96 | 96 | return ''; |
97 | 97 | } |
98 | 98 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | public function modify_search_parameters( $parameters ) { |
123 | 123 | |
124 | 124 | if ( $this->name === \GV\Utils::get( $parameters, 'sorting/key' ) ) { |
125 | - $parameters['sorting']['key'] = 'is_approved'; |
|
125 | + $parameters[ 'sorting' ][ 'key' ] = 'is_approved'; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | return $parameters; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | function register_scripts_and_styles() { |
139 | 139 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
140 | 140 | |
141 | - wp_register_script( 'gravityview-field-approval', GRAVITYVIEW_URL . 'assets/js/field-approval'.$script_debug.'.js', array( 'jquery' ), GravityView_Plugin::version, true ); |
|
141 | + wp_register_script( 'gravityview-field-approval', GRAVITYVIEW_URL . 'assets/js/field-approval' . $script_debug . '.js', array( 'jquery' ), GravityView_Plugin::version, true ); |
|
142 | 142 | |
143 | 143 | wp_register_script( 'gravityview-field-approval-popper', GRAVITYVIEW_URL . 'assets/lib/tippy/popper.min.js', array(), GravityView_Plugin::version, true ); |
144 | 144 | wp_register_script( 'gravityview-field-approval-tippy', GRAVITYVIEW_URL . 'assets/lib/tippy/tippy.min.js', array(), GravityView_Plugin::version, true ); |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | |
147 | 147 | $style_path = GRAVITYVIEW_DIR . 'templates/css/field-approval.css'; |
148 | 148 | |
149 | - if( class_exists( 'GravityView_View' ) ) { |
|
149 | + if ( class_exists( 'GravityView_View' ) ) { |
|
150 | 150 | /** |
151 | 151 | * Override CSS file by placing in your theme's /gravityview/css/ sub-directory. |
152 | 152 | */ |
153 | 153 | $style_path = GravityView_View::getInstance()->locate_template( 'css/field-approval.css', false ); |
154 | 154 | } |
155 | 155 | |
156 | - $style_url = plugins_url( 'css/field-approval.css', trailingslashit( dirname( $style_path ) ) ); |
|
156 | + $style_url = plugins_url( 'css/field-approval.css', trailingslashit( dirname( $style_path ) ) ); |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * @filter `gravityview/field/approval/css_url` URL to the Approval field CSS file. |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | $style_url = apply_filters( 'gravityview/field/approval/css_url', $style_url ); |
164 | 164 | |
165 | - if( ! empty( $style_url ) ) { |
|
165 | + if ( ! empty( $style_url ) ) { |
|
166 | 166 | wp_register_style( 'gravityview-field-approval', $style_url, array( 'dashicons' ), GravityView_Plugin::version, 'screen' ); |
167 | 167 | } |
168 | 168 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | public function enqueue_and_localize_script() { |
178 | 178 | |
179 | 179 | // The script is already registered and enqueued |
180 | - if( wp_script_is( 'gravityview-field-approval', 'enqueued' ) ) { |
|
180 | + if ( wp_script_is( 'gravityview-field-approval', 'enqueued' ) ) { |
|
181 | 181 | return; |
182 | 182 | } |
183 | 183 | |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | |
191 | 191 | wp_localize_script( 'gravityview-field-approval', 'gvApproval', array( |
192 | 192 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
193 | - 'nonce' => wp_create_nonce('gravityview_entry_approval'), |
|
193 | + 'nonce' => wp_create_nonce( 'gravityview_entry_approval' ), |
|
194 | 194 | 'status' => GravityView_Entry_Approval_Status::get_all(), |
195 | 195 | 'status_popover_template' => GravityView_Entry_Approval::get_popover_template(), |
196 | 196 | 'status_popover_placement' => GravityView_Entry_Approval::get_popover_placement(), |
197 | - )); |
|
197 | + ) ); |
|
198 | 198 | |
199 | 199 | } |
200 | 200 | |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function filter_gravityview_entry_default_field( $entry_default_fields, $form, $context ) { |
213 | 213 | |
214 | - if ( ! isset( $entry_default_fields["{$this->name}"] ) && 'edit' !== $context ) { |
|
215 | - $entry_default_fields["{$this->name}"] = array( |
|
214 | + if ( ! isset( $entry_default_fields[ "{$this->name}" ] ) && 'edit' !== $context ) { |
|
215 | + $entry_default_fields[ "{$this->name}" ] = array( |
|
216 | 216 | 'label' => $this->label, |
217 | 217 | 'desc' => $this->description, |
218 | 218 | 'type' => $this->name, |
@@ -5,243 +5,243 @@ |
||
5 | 5 | */ |
6 | 6 | class GravityView_Change_Entry_Creator { |
7 | 7 | |
8 | - function __construct() { |
|
9 | - |
|
10 | - /** |
|
11 | - * @since 1.5.1 |
|
12 | - */ |
|
13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
14 | - |
|
15 | - // ONLY ADMIN FROM HERE ON. |
|
16 | - if( !is_admin() ) { return; } |
|
17 | - |
|
18 | - /** |
|
19 | - * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
|
20 | - * @since 1.7.4 |
|
21 | - * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
|
22 | - */ |
|
23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
24 | - return; |
|
25 | - } |
|
26 | - |
|
27 | - /** |
|
28 | - * Use `init` to fix bbPress warning |
|
29 | - * @see https://bbpress.trac.wordpress.org/ticket/2309 |
|
30 | - */ |
|
31 | - add_action('init', array( $this, 'load'), 100 ); |
|
32 | - |
|
33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
34 | - |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * When an user is created using the User Registration add-on, assign the entry to them |
|
39 | - * |
|
40 | - * @since 1.5.1 |
|
41 | - * @uses RGFormsModel::update_lead_property() Modify the entry `created_by` field |
|
42 | - * @param int $user_id WordPress User ID |
|
43 | - * @param array $config User registration feed configuration |
|
44 | - * @param array $entry GF Entry array |
|
45 | - * @param string $password User password |
|
46 | - * @return void |
|
47 | - */ |
|
48 | - function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) { |
|
49 | - |
|
50 | - /** |
|
51 | - * Disable assigning the new user to the entry by returning false. |
|
52 | - * @param int $user_id WordPress User ID |
|
53 | - * @param array $config User registration feed configuration |
|
54 | - * @param array $entry GF Entry array |
|
55 | - */ |
|
56 | - $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
|
57 | - |
|
58 | - // If filter returns false, do not process |
|
59 | - if( empty( $assign_to_lead ) ) { |
|
60 | - return; |
|
61 | - } |
|
62 | - |
|
63 | - // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
|
64 | - $result = RGFormsModel::update_entry_property( (int) $entry['id'], 'created_by', (int) $user_id, false, true ); |
|
65 | - |
|
66 | - if ( false === $result ) { |
|
67 | - $status = __('Error', 'gravityview'); |
|
68 | - global $wpdb; |
|
69 | - $note = sprintf( '%s: Failed to assign User ID #%d as the entry creator (Last database error: "%s")', $status, $user_id, $wpdb->last_error ); |
|
70 | - } else { |
|
71 | - $status = __('Success', 'gravityview'); |
|
72 | - $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
73 | - } |
|
74 | - |
|
75 | - gravityview()->log->debug( 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - {note}', array( 'note' => $note ) ); |
|
76 | - |
|
77 | - /** |
|
78 | - * @filter `gravityview_disable_change_entry_creator_note` Disable adding a note when changing the entry creator |
|
79 | - * @since 1.21.5 |
|
80 | - * @param boolean $disable Disable the Change Entry Creator note. Default: false. |
|
81 | - */ |
|
82 | - if( apply_filters('gravityview_disable_change_entry_creator_note', false ) ) { |
|
83 | - return; |
|
84 | - } |
|
85 | - |
|
86 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
87 | - |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Disable previous functionality; use this one as the canonical. |
|
92 | - * @return void |
|
93 | - */ |
|
94 | - function prevent_conflicts() { |
|
95 | - |
|
96 | - // Plugin that was provided here: |
|
97 | - // @link https://gravityview.co/support/documentation/201991205/ |
|
98 | - remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
99 | - remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
100 | - |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * @since 3.6.3 |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - function load() { |
|
108 | - |
|
109 | - // Does GF exist? |
|
110 | - if( !class_exists('GFCommon') ) { |
|
111 | - return; |
|
112 | - } |
|
113 | - |
|
114 | - // Can the user edit entries? |
|
115 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
116 | - return; |
|
117 | - } |
|
118 | - |
|
119 | - // If screen mode isn't set, then we're in the wrong place. |
|
120 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
121 | - return; |
|
122 | - } |
|
123 | - |
|
124 | - // Now, no validation is required in the methods; let's hook in. |
|
125 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
126 | - |
|
127 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
128 | - |
|
129 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
130 | - |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Allows for edit links to work with a link instead of a form (GET instead of POST) |
|
135 | - * @return void |
|
136 | - */ |
|
137 | - function set_screen_mode() { |
|
138 | - |
|
139 | - if( 'view' === \GV\Utils::_POST( 'screen_mode' ) ) { |
|
140 | - return; |
|
141 | - } |
|
142 | - |
|
143 | - // If $_GET['screen_mode'] is set to edit, set $_POST value |
|
144 | - if( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
145 | - $_POST["screen_mode"] = 'edit'; |
|
146 | - } |
|
147 | - |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * When the entry creator is changed, add a note to the entry |
|
152 | - * @param array $form GF entry array |
|
153 | - * @param int $entry_id Entry ID |
|
154 | - * @return void |
|
155 | - */ |
|
156 | - function update_entry_creator($form, $entry_id) { |
|
157 | - global $current_user; |
|
8 | + function __construct() { |
|
9 | + |
|
10 | + /** |
|
11 | + * @since 1.5.1 |
|
12 | + */ |
|
13 | + add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
14 | + |
|
15 | + // ONLY ADMIN FROM HERE ON. |
|
16 | + if( !is_admin() ) { return; } |
|
17 | + |
|
18 | + /** |
|
19 | + * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
|
20 | + * @since 1.7.4 |
|
21 | + * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
|
22 | + */ |
|
23 | + if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
24 | + return; |
|
25 | + } |
|
26 | + |
|
27 | + /** |
|
28 | + * Use `init` to fix bbPress warning |
|
29 | + * @see https://bbpress.trac.wordpress.org/ticket/2309 |
|
30 | + */ |
|
31 | + add_action('init', array( $this, 'load'), 100 ); |
|
32 | + |
|
33 | + add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
34 | + |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * When an user is created using the User Registration add-on, assign the entry to them |
|
39 | + * |
|
40 | + * @since 1.5.1 |
|
41 | + * @uses RGFormsModel::update_lead_property() Modify the entry `created_by` field |
|
42 | + * @param int $user_id WordPress User ID |
|
43 | + * @param array $config User registration feed configuration |
|
44 | + * @param array $entry GF Entry array |
|
45 | + * @param string $password User password |
|
46 | + * @return void |
|
47 | + */ |
|
48 | + function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) { |
|
49 | + |
|
50 | + /** |
|
51 | + * Disable assigning the new user to the entry by returning false. |
|
52 | + * @param int $user_id WordPress User ID |
|
53 | + * @param array $config User registration feed configuration |
|
54 | + * @param array $entry GF Entry array |
|
55 | + */ |
|
56 | + $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
|
57 | + |
|
58 | + // If filter returns false, do not process |
|
59 | + if( empty( $assign_to_lead ) ) { |
|
60 | + return; |
|
61 | + } |
|
62 | + |
|
63 | + // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
|
64 | + $result = RGFormsModel::update_entry_property( (int) $entry['id'], 'created_by', (int) $user_id, false, true ); |
|
65 | + |
|
66 | + if ( false === $result ) { |
|
67 | + $status = __('Error', 'gravityview'); |
|
68 | + global $wpdb; |
|
69 | + $note = sprintf( '%s: Failed to assign User ID #%d as the entry creator (Last database error: "%s")', $status, $user_id, $wpdb->last_error ); |
|
70 | + } else { |
|
71 | + $status = __('Success', 'gravityview'); |
|
72 | + $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
73 | + } |
|
74 | + |
|
75 | + gravityview()->log->debug( 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - {note}', array( 'note' => $note ) ); |
|
76 | + |
|
77 | + /** |
|
78 | + * @filter `gravityview_disable_change_entry_creator_note` Disable adding a note when changing the entry creator |
|
79 | + * @since 1.21.5 |
|
80 | + * @param boolean $disable Disable the Change Entry Creator note. Default: false. |
|
81 | + */ |
|
82 | + if( apply_filters('gravityview_disable_change_entry_creator_note', false ) ) { |
|
83 | + return; |
|
84 | + } |
|
85 | + |
|
86 | + GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
87 | + |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Disable previous functionality; use this one as the canonical. |
|
92 | + * @return void |
|
93 | + */ |
|
94 | + function prevent_conflicts() { |
|
95 | + |
|
96 | + // Plugin that was provided here: |
|
97 | + // @link https://gravityview.co/support/documentation/201991205/ |
|
98 | + remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
99 | + remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
100 | + |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * @since 3.6.3 |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + function load() { |
|
108 | + |
|
109 | + // Does GF exist? |
|
110 | + if( !class_exists('GFCommon') ) { |
|
111 | + return; |
|
112 | + } |
|
113 | + |
|
114 | + // Can the user edit entries? |
|
115 | + if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
116 | + return; |
|
117 | + } |
|
118 | + |
|
119 | + // If screen mode isn't set, then we're in the wrong place. |
|
120 | + if( empty( $_REQUEST['screen_mode'] ) ) { |
|
121 | + return; |
|
122 | + } |
|
123 | + |
|
124 | + // Now, no validation is required in the methods; let's hook in. |
|
125 | + add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
126 | + |
|
127 | + add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
128 | + |
|
129 | + add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
130 | + |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Allows for edit links to work with a link instead of a form (GET instead of POST) |
|
135 | + * @return void |
|
136 | + */ |
|
137 | + function set_screen_mode() { |
|
138 | + |
|
139 | + if( 'view' === \GV\Utils::_POST( 'screen_mode' ) ) { |
|
140 | + return; |
|
141 | + } |
|
142 | + |
|
143 | + // If $_GET['screen_mode'] is set to edit, set $_POST value |
|
144 | + if( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
145 | + $_POST["screen_mode"] = 'edit'; |
|
146 | + } |
|
147 | + |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * When the entry creator is changed, add a note to the entry |
|
152 | + * @param array $form GF entry array |
|
153 | + * @param int $entry_id Entry ID |
|
154 | + * @return void |
|
155 | + */ |
|
156 | + function update_entry_creator($form, $entry_id) { |
|
157 | + global $current_user; |
|
158 | 158 | |
159 | - // Update the entry |
|
160 | - $created_by = absint( \GV\Utils::_POST( 'created_by') ); |
|
159 | + // Update the entry |
|
160 | + $created_by = absint( \GV\Utils::_POST( 'created_by') ); |
|
161 | 161 | |
162 | - RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
|
162 | + RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
|
163 | 163 | |
164 | - // If the creator has changed, let's add a note about who it used to be. |
|
165 | - $originally_created_by = \GV\Utils::_POST( 'originally_created_by' ); |
|
164 | + // If the creator has changed, let's add a note about who it used to be. |
|
165 | + $originally_created_by = \GV\Utils::_POST( 'originally_created_by' ); |
|
166 | 166 | |
167 | - // If there's no owner and there didn't used to be, keep going |
|
168 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
169 | - return; |
|
170 | - } |
|
167 | + // If there's no owner and there didn't used to be, keep going |
|
168 | + if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
169 | + return; |
|
170 | + } |
|
171 | 171 | |
172 | - // If the values have changed |
|
173 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
172 | + // If the values have changed |
|
173 | + if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
174 | 174 | |
175 | - $user_data = get_userdata($current_user->ID); |
|
175 | + $user_data = get_userdata($current_user->ID); |
|
176 | 176 | |
177 | - $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
177 | + $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
178 | 178 | |
179 | - $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
179 | + $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
180 | 180 | |
181 | - if( !empty( $originally_created_by ) ) { |
|
182 | - $originally_created_by_user_data = get_userdata($originally_created_by); |
|
183 | - $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
|
184 | - } |
|
181 | + if( !empty( $originally_created_by ) ) { |
|
182 | + $originally_created_by_user_data = get_userdata($originally_created_by); |
|
183 | + $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
|
184 | + } |
|
185 | 185 | |
186 | - if( !empty( $created_by ) ) { |
|
187 | - $created_by_user_data = get_userdata($created_by); |
|
188 | - $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
|
189 | - } |
|
186 | + if( !empty( $created_by ) ) { |
|
187 | + $created_by_user_data = get_userdata($created_by); |
|
188 | + $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
|
189 | + } |
|
190 | 190 | |
191 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
192 | - } |
|
191 | + GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
192 | + } |
|
193 | 193 | |
194 | - } |
|
194 | + } |
|
195 | 195 | |
196 | - /** |
|
197 | - * Output the select to change the entry creator |
|
198 | - * @param int $form_id GF Form ID |
|
199 | - * @param array $entry GF entry array |
|
200 | - * @return void |
|
201 | - */ |
|
202 | - function add_select($form_id, $entry ) { |
|
196 | + /** |
|
197 | + * Output the select to change the entry creator |
|
198 | + * @param int $form_id GF Form ID |
|
199 | + * @param array $entry GF entry array |
|
200 | + * @return void |
|
201 | + */ |
|
202 | + function add_select($form_id, $entry ) { |
|
203 | 203 | |
204 | - if( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
205 | - return; |
|
206 | - } |
|
204 | + if( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
205 | + return; |
|
206 | + } |
|
207 | 207 | |
208 | - $created_by_id = \GV\Utils::get( $entry, 'created_by' ); |
|
208 | + $created_by_id = \GV\Utils::get( $entry, 'created_by' ); |
|
209 | 209 | |
210 | - $users = GVCommon::get_users( 'change_entry_creator' ); |
|
210 | + $users = GVCommon::get_users( 'change_entry_creator' ); |
|
211 | 211 | |
212 | - $is_created_by_in_users = wp_list_filter( $users, array( 'ID' => $created_by_id ) ); |
|
212 | + $is_created_by_in_users = wp_list_filter( $users, array( 'ID' => $created_by_id ) ); |
|
213 | 213 | |
214 | - // Make sure that the entry creator is included in the users list. If not, add them. |
|
215 | - if ( ! empty( $created_by_id ) && empty( $is_created_by_in_users ) ) { |
|
214 | + // Make sure that the entry creator is included in the users list. If not, add them. |
|
215 | + if ( ! empty( $created_by_id ) && empty( $is_created_by_in_users ) ) { |
|
216 | 216 | |
217 | - if ( $created_by_user = GVCommon::get_users( 'change_entry_creator', array( 'include' => $created_by_id ) ) ) { |
|
218 | - $users = array_merge( $users, $created_by_user ); |
|
219 | - } |
|
220 | - } |
|
217 | + if ( $created_by_user = GVCommon::get_users( 'change_entry_creator', array( 'include' => $created_by_id ) ) ) { |
|
218 | + $users = array_merge( $users, $created_by_user ); |
|
219 | + } |
|
220 | + } |
|
221 | 221 | |
222 | - $output = '<label for="change_created_by">'; |
|
223 | - $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
224 | - $output .= '</label>'; |
|
222 | + $output = '<label for="change_created_by">'; |
|
223 | + $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
224 | + $output .= '</label>'; |
|
225 | 225 | |
226 | - // If there are users who are not being shown, show a warning. |
|
227 | - // TODO: Use AJAX instead of <select> |
|
228 | - $count_users = count_users(); |
|
229 | - if( sizeof( $users ) < $count_users['total_users'] ) { |
|
230 | - $output .= '<p><i class="dashicons dashicons-warning"></i> ' . sprintf( esc_html__( 'The displayed list of users has been trimmed due to the large number of users. %sLearn how to remove this limit%s.', 'gravityview' ), '<a href="https://docs.gravityview.co/article/251-i-only-see-some-users-in-the-change-entry-creator-dropdown" rel="external">', '</a>' ) . '</p>'; |
|
231 | - } |
|
226 | + // If there are users who are not being shown, show a warning. |
|
227 | + // TODO: Use AJAX instead of <select> |
|
228 | + $count_users = count_users(); |
|
229 | + if( sizeof( $users ) < $count_users['total_users'] ) { |
|
230 | + $output .= '<p><i class="dashicons dashicons-warning"></i> ' . sprintf( esc_html__( 'The displayed list of users has been trimmed due to the large number of users. %sLearn how to remove this limit%s.', 'gravityview' ), '<a href="https://docs.gravityview.co/article/251-i-only-see-some-users-in-the-change-entry-creator-dropdown" rel="external">', '</a>' ) . '</p>'; |
|
231 | + } |
|
232 | 232 | |
233 | - $output .= '<select name="created_by" id="change_created_by" class="widefat">'; |
|
234 | - $output .= '<option value="' . selected( $entry['created_by'], '0', false ) . '"> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
235 | - foreach($users as $user) { |
|
236 | - $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
237 | - } |
|
238 | - $output .= '</select>'; |
|
239 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
233 | + $output .= '<select name="created_by" id="change_created_by" class="widefat">'; |
|
234 | + $output .= '<option value="' . selected( $entry['created_by'], '0', false ) . '"> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
235 | + foreach($users as $user) { |
|
236 | + $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
237 | + } |
|
238 | + $output .= '</select>'; |
|
239 | + $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
240 | 240 | |
241 | - unset( $is_created_by_in_users, $created_by_user, $users, $created_by_id, $count_users ); |
|
241 | + unset( $is_created_by_in_users, $created_by_user, $users, $created_by_id, $count_users ); |
|
242 | 242 | |
243 | - echo $output; |
|
244 | - } |
|
243 | + echo $output; |
|
244 | + } |
|
245 | 245 | |
246 | 246 | } |
247 | 247 |
@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * @since 1.5.1 |
12 | 12 | */ |
13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
13 | + add_action( 'gform_user_registered', array( $this, 'assign_new_user_to_lead' ), 10, 4 ); |
|
14 | 14 | |
15 | 15 | // ONLY ADMIN FROM HERE ON. |
16 | - if( !is_admin() ) { return; } |
|
16 | + if ( ! is_admin() ) { return; } |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
20 | 20 | * @since 1.7.4 |
21 | 21 | * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
22 | 22 | */ |
23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
23 | + if ( apply_filters( 'gravityview_disable_change_entry_creator', false ) ) { |
|
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * Use `init` to fix bbPress warning |
29 | 29 | * @see https://bbpress.trac.wordpress.org/ticket/2309 |
30 | 30 | */ |
31 | - add_action('init', array( $this, 'load'), 100 ); |
|
31 | + add_action( 'init', array( $this, 'load' ), 100 ); |
|
32 | 32 | |
33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
33 | + add_action( 'plugins_loaded', array( $this, 'prevent_conflicts' ) ); |
|
34 | 34 | |
35 | 35 | } |
36 | 36 | |
@@ -56,20 +56,20 @@ discard block |
||
56 | 56 | $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
57 | 57 | |
58 | 58 | // If filter returns false, do not process |
59 | - if( empty( $assign_to_lead ) ) { |
|
59 | + if ( empty( $assign_to_lead ) ) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
64 | - $result = RGFormsModel::update_entry_property( (int) $entry['id'], 'created_by', (int) $user_id, false, true ); |
|
64 | + $result = RGFormsModel::update_entry_property( (int)$entry[ 'id' ], 'created_by', (int)$user_id, false, true ); |
|
65 | 65 | |
66 | 66 | if ( false === $result ) { |
67 | - $status = __('Error', 'gravityview'); |
|
67 | + $status = __( 'Error', 'gravityview' ); |
|
68 | 68 | global $wpdb; |
69 | 69 | $note = sprintf( '%s: Failed to assign User ID #%d as the entry creator (Last database error: "%s")', $status, $user_id, $wpdb->last_error ); |
70 | 70 | } else { |
71 | - $status = __('Success', 'gravityview'); |
|
72 | - $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
71 | + $status = __( 'Success', 'gravityview' ); |
|
72 | + $note = sprintf( _x( '%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview' ), $status, $user_id ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | gravityview()->log->debug( 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - {note}', array( 'note' => $note ) ); |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | * @since 1.21.5 |
80 | 80 | * @param boolean $disable Disable the Change Entry Creator note. Default: false. |
81 | 81 | */ |
82 | - if( apply_filters('gravityview_disable_change_entry_creator_note', false ) ) { |
|
82 | + if ( apply_filters( 'gravityview_disable_change_entry_creator_note', false ) ) { |
|
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
86 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
86 | + GravityView_Entry_Notes::add_note( $entry[ 'id' ], -1, 'GravityView', $note, 'gravityview' ); |
|
87 | 87 | |
88 | 88 | } |
89 | 89 | |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | |
96 | 96 | // Plugin that was provided here: |
97 | 97 | // @link https://gravityview.co/support/documentation/201991205/ |
98 | - remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
99 | - remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
98 | + remove_action( "gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
99 | + remove_action( "gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | |
@@ -107,26 +107,26 @@ discard block |
||
107 | 107 | function load() { |
108 | 108 | |
109 | 109 | // Does GF exist? |
110 | - if( !class_exists('GFCommon') ) { |
|
110 | + if ( ! class_exists( 'GFCommon' ) ) { |
|
111 | 111 | return; |
112 | 112 | } |
113 | 113 | |
114 | 114 | // Can the user edit entries? |
115 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
115 | + if ( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
116 | 116 | return; |
117 | 117 | } |
118 | 118 | |
119 | 119 | // If screen mode isn't set, then we're in the wrong place. |
120 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
120 | + if ( empty( $_REQUEST[ 'screen_mode' ] ) ) { |
|
121 | 121 | return; |
122 | 122 | } |
123 | 123 | |
124 | 124 | // Now, no validation is required in the methods; let's hook in. |
125 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
125 | + add_action( 'admin_init', array( &$this, 'set_screen_mode' ) ); |
|
126 | 126 | |
127 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
127 | + add_action( "gform_entry_info", array( &$this, 'add_select' ), 10, 2 ); |
|
128 | 128 | |
129 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
129 | + add_action( "gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2 ); |
|
130 | 130 | |
131 | 131 | } |
132 | 132 | |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | */ |
137 | 137 | function set_screen_mode() { |
138 | 138 | |
139 | - if( 'view' === \GV\Utils::_POST( 'screen_mode' ) ) { |
|
139 | + if ( 'view' === \GV\Utils::_POST( 'screen_mode' ) ) { |
|
140 | 140 | return; |
141 | 141 | } |
142 | 142 | |
143 | 143 | // If $_GET['screen_mode'] is set to edit, set $_POST value |
144 | - if( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
145 | - $_POST["screen_mode"] = 'edit'; |
|
144 | + if ( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
145 | + $_POST[ "screen_mode" ] = 'edit'; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | } |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | * @param int $entry_id Entry ID |
154 | 154 | * @return void |
155 | 155 | */ |
156 | - function update_entry_creator($form, $entry_id) { |
|
156 | + function update_entry_creator( $form, $entry_id ) { |
|
157 | 157 | global $current_user; |
158 | 158 | |
159 | 159 | // Update the entry |
160 | - $created_by = absint( \GV\Utils::_POST( 'created_by') ); |
|
160 | + $created_by = absint( \GV\Utils::_POST( 'created_by' ) ); |
|
161 | 161 | |
162 | 162 | RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
163 | 163 | |
@@ -165,30 +165,30 @@ discard block |
||
165 | 165 | $originally_created_by = \GV\Utils::_POST( 'originally_created_by' ); |
166 | 166 | |
167 | 167 | // If there's no owner and there didn't used to be, keep going |
168 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
168 | + if ( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
169 | 169 | return; |
170 | 170 | } |
171 | 171 | |
172 | 172 | // If the values have changed |
173 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
173 | + if ( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
174 | 174 | |
175 | - $user_data = get_userdata($current_user->ID); |
|
175 | + $user_data = get_userdata( $current_user->ID ); |
|
176 | 176 | |
177 | - $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
177 | + $user_format = _x( '%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview' ); |
|
178 | 178 | |
179 | - $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
179 | + $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview' ); |
|
180 | 180 | |
181 | - if( !empty( $originally_created_by ) ) { |
|
182 | - $originally_created_by_user_data = get_userdata($originally_created_by); |
|
181 | + if ( ! empty( $originally_created_by ) ) { |
|
182 | + $originally_created_by_user_data = get_userdata( $originally_created_by ); |
|
183 | 183 | $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
184 | 184 | } |
185 | 185 | |
186 | - if( !empty( $created_by ) ) { |
|
187 | - $created_by_user_data = get_userdata($created_by); |
|
186 | + if ( ! empty( $created_by ) ) { |
|
187 | + $created_by_user_data = get_userdata( $created_by ); |
|
188 | 188 | $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
189 | 189 | } |
190 | 190 | |
191 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
191 | + GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __( 'Changed entry creator from %s to %s', 'gravityview' ), $original_name, $created_by_name ), 'note' ); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | * @param array $entry GF entry array |
200 | 200 | * @return void |
201 | 201 | */ |
202 | - function add_select($form_id, $entry ) { |
|
202 | + function add_select( $form_id, $entry ) { |
|
203 | 203 | |
204 | - if( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
204 | + if ( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
@@ -220,23 +220,23 @@ discard block |
||
220 | 220 | } |
221 | 221 | |
222 | 222 | $output = '<label for="change_created_by">'; |
223 | - $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
223 | + $output .= esc_html__( 'Change Entry Creator:', 'gravityview' ); |
|
224 | 224 | $output .= '</label>'; |
225 | 225 | |
226 | 226 | // If there are users who are not being shown, show a warning. |
227 | 227 | // TODO: Use AJAX instead of <select> |
228 | 228 | $count_users = count_users(); |
229 | - if( sizeof( $users ) < $count_users['total_users'] ) { |
|
229 | + if ( sizeof( $users ) < $count_users[ 'total_users' ] ) { |
|
230 | 230 | $output .= '<p><i class="dashicons dashicons-warning"></i> ' . sprintf( esc_html__( 'The displayed list of users has been trimmed due to the large number of users. %sLearn how to remove this limit%s.', 'gravityview' ), '<a href="https://docs.gravityview.co/article/251-i-only-see-some-users-in-the-change-entry-creator-dropdown" rel="external">', '</a>' ) . '</p>'; |
231 | 231 | } |
232 | 232 | |
233 | 233 | $output .= '<select name="created_by" id="change_created_by" class="widefat">'; |
234 | - $output .= '<option value="' . selected( $entry['created_by'], '0', false ) . '"> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
235 | - foreach($users as $user) { |
|
236 | - $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
234 | + $output .= '<option value="' . selected( $entry[ 'created_by' ], '0', false ) . '"> — ' . esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview' ) . ' — </option>'; |
|
235 | + foreach ( $users as $user ) { |
|
236 | + $output .= '<option value="' . $user->ID . '"' . selected( $entry[ 'created_by' ], $user->ID, false ) . '>' . esc_attr( $user->display_name . ' (' . $user->user_nicename . ')' ) . '</option>'; |
|
237 | 237 | } |
238 | 238 | $output .= '</select>'; |
239 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
239 | + $output .= '<input name="originally_created_by" value="' . esc_attr( $entry[ 'created_by' ] ) . '" type="hidden" />'; |
|
240 | 240 | |
241 | 241 | unset( $is_created_by_in_users, $created_by_user, $users, $created_by_id, $count_users ); |
242 | 242 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | $this->label = esc_html__( 'Number Sequence', 'gravityview' ); |
40 | 40 | |
41 | - add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'field_tooltips') ); |
|
41 | + add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'field_tooltips' ) ); |
|
42 | 42 | |
43 | 43 | parent::__construct(); |
44 | 44 | } |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | |
53 | 53 | $return = $tooltips; |
54 | 54 | |
55 | - $return['reverse_sequence'] = array( |
|
56 | - 'title' => __('Reverse the order of the result numbers', 'gravityview'), |
|
57 | - 'value' => __('Output the number sequence in descending order. If enabled, numbers will count down from high to low.', 'gravityview'), |
|
55 | + $return[ 'reverse_sequence' ] = array( |
|
56 | + 'title' => __( 'Reverse the order of the result numbers', 'gravityview' ), |
|
57 | + 'value' => __( 'Output the number sequence in descending order. If enabled, numbers will count down from high to low.', 'gravityview' ), |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | return $return; |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | |
63 | 63 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
64 | 64 | |
65 | - unset ( $field_options['search_filter'] ); |
|
65 | + unset ( $field_options[ 'search_filter' ] ); |
|
66 | 66 | |
67 | 67 | $new_fields = array( |
68 | 68 | 'start' => array( |
69 | 69 | 'type' => 'number', |
70 | 70 | 'label' => __( 'First Number in the Sequence', 'gravityview' ), |
71 | - 'desc' => __('For each entry, the displayed number will increase by one. When displaying ten entries, the first entry will display "1", and the last entry will show "10".', 'gravityview'), |
|
71 | + 'desc' => __( 'For each entry, the displayed number will increase by one. When displaying ten entries, the first entry will display "1", and the last entry will show "10".', 'gravityview' ), |
|
72 | 72 | 'value' => '1', |
73 | 73 | 'merge_tags' => false, |
74 | 74 | ), |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | $return = $text; |
125 | 125 | |
126 | 126 | $context = new \GV\Template_Context(); |
127 | - $context->view = \GV\View::by_id( $view_data['view_id'] ); |
|
127 | + $context->view = \GV\View::by_id( $view_data[ 'view_id' ] ); |
|
128 | 128 | $context->entry = \GV\GF_Entry::from_entry( $entry ); |
129 | 129 | |
130 | 130 | $gv_field = \GV\Internal_Field::by_id( 'sequence' ); |
131 | 131 | $merge_tag_context = \GV\Utils::get( $legacy_field, 'UID' ); |
132 | - $merge_tag_context = $entry['id'] . "/{$merge_tag_context}"; |
|
132 | + $merge_tag_context = $entry[ 'id' ] . "/{$merge_tag_context}"; |
|
133 | 133 | |
134 | 134 | foreach ( $matches as $match ) { |
135 | 135 | |
136 | - $full_tag = $match[0]; |
|
137 | - $property = $match[1]; |
|
136 | + $full_tag = $match[ 0 ]; |
|
137 | + $property = $match[ 1 ]; |
|
138 | 138 | |
139 | 139 | $gv_field->reverse = false; |
140 | 140 | $gv_field->start = 1; |
@@ -153,12 +153,12 @@ discard block |
||
153 | 153 | |
154 | 154 | // If there is a field with the ID of the start number, the merge tag won't work. |
155 | 155 | // In that case, you can use "=" instead: `{sequence start=10}` |
156 | - if( 1 === sizeof( $maybe_start ) ) { |
|
156 | + if ( 1 === sizeof( $maybe_start ) ) { |
|
157 | 157 | $maybe_start = explode( '=', $modifier ); |
158 | 158 | } |
159 | 159 | |
160 | 160 | if ( 'start' === rgar( $maybe_start, 0 ) && is_numeric( rgar( $maybe_start, 1 ) ) ) { |
161 | - $gv_field->start = (int) rgar( $maybe_start, 1 ); |
|
161 | + $gv_field->start = (int)rgar( $maybe_start, 1 ); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $merge_tag_context_modifiers = $merge_tag_context . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start; |
170 | 170 | |
171 | 171 | if ( ! isset( $merge_tag_sequences[ $merge_tag_context_modifiers ] ) ) { |
172 | - $gv_field->UID = $legacy_field['UID'] . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start; |
|
172 | + $gv_field->UID = $legacy_field[ 'UID' ] . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start; |
|
173 | 173 | $context->field = $gv_field; |
174 | 174 | $sequence = $merge_tag_sequences[ $merge_tag_context_modifiers ] = $this->get_sequence( $context ); |
175 | 175 | } else { |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $total = $context->view->get_entries()->total(); |
215 | 215 | remove_filter( 'gform_gf_query_sql', $callback ); |
216 | 216 | |
217 | - unset( $sql_query['paginate'] ); |
|
217 | + unset( $sql_query[ 'paginate' ] ); |
|
218 | 218 | |
219 | 219 | global $wpdb; |
220 | 220 |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return \GV\Field The field implementation from configuration (\GV\GF_Field, \GV\Internal_Field). |
167 | 167 | */ |
168 | 168 | public static function from_configuration( $configuration ) { |
169 | - if ( empty( $configuration['id'] ) ) { |
|
169 | + if ( empty( $configuration[ 'id' ] ) ) { |
|
170 | 170 | $field = new self(); |
171 | 171 | gravityview()->log->error( 'Trying to get field from configuration without a field ID.', array( 'data' => $configuration ) ); |
172 | 172 | $field->update_configuration( $configuration ); |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | } else { |
180 | 180 | $trace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); |
181 | 181 | } |
182 | - $trace = $trace[1]; |
|
183 | - if ( $trace['function'] == 'from_configuration' && $trace['class'] == __CLASS__ ) { |
|
182 | + $trace = $trace[ 1 ]; |
|
183 | + if ( $trace[ 'function' ] == 'from_configuration' && $trace[ 'class' ] == __CLASS__ ) { |
|
184 | 184 | $field = new self(); |
185 | 185 | gravityview()->log->error( 'Infinite loop protection tripped. Returning default class here.' ); |
186 | 186 | $field->update_configuration( $configuration ); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | /** @var \GV\GF_Field|\GV\Internal_Field $field_class Determine the field implementation to use, and try to use. */ |
191 | - $field_class = is_numeric( $configuration['id'] ) ? '\GV\GF_Field' : '\GV\Internal_Field'; |
|
191 | + $field_class = is_numeric( $configuration[ 'id' ] ) ? '\GV\GF_Field' : '\GV\Internal_Field'; |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * @filter `gravityview/field/class` Filter the field class about to be created from the configuration. |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | public function update_configuration( $configuration ) { |
228 | 228 | $configuration = wp_parse_args( $configuration, $this->as_configuration() ); |
229 | 229 | |
230 | - if ( $this->ID != $configuration['id'] ) { |
|
230 | + if ( $this->ID != $configuration[ 'id' ] ) { |
|
231 | 231 | /** Smelling trouble here... */ |
232 | 232 | gravityview()->log->warning( 'ID is being changed for {field_class} instance, but implementation is not. Use ::from_configuration instead', array( 'field_class', __CLASS__ ) ); |
233 | 233 | } |
234 | 234 | |
235 | - $this->ID = $configuration['id']; |
|
236 | - $this->label = $configuration['label']; |
|
237 | - $this->show_label = $configuration['show_label'] == '1'; |
|
238 | - $this->custom_label = $configuration['custom_label']; |
|
239 | - $this->custom_class = $configuration['custom_class']; |
|
240 | - $this->cap = $configuration['only_loggedin'] == '1' ? $configuration['only_loggedin_cap'] : ''; |
|
241 | - $this->search_filter = $configuration['search_filter'] == '1'; |
|
242 | - $this->show_as_link = $configuration['show_as_link'] == '1'; |
|
235 | + $this->ID = $configuration[ 'id' ]; |
|
236 | + $this->label = $configuration[ 'label' ]; |
|
237 | + $this->show_label = $configuration[ 'show_label' ] == '1'; |
|
238 | + $this->custom_label = $configuration[ 'custom_label' ]; |
|
239 | + $this->custom_class = $configuration[ 'custom_class' ]; |
|
240 | + $this->cap = $configuration[ 'only_loggedin' ] == '1' ? $configuration[ 'only_loggedin_cap' ] : ''; |
|
241 | + $this->search_filter = $configuration[ 'search_filter' ] == '1'; |
|
242 | + $this->show_as_link = $configuration[ 'show_as_link' ] == '1'; |
|
243 | 243 | |
244 | 244 | /** Shared among all field types (sort of). */ |
245 | 245 | $shared_configuration_keys = array( |
246 | 246 | 'id', 'label', 'show_label', 'custom_label', 'custom_class', |
247 | - 'only_loggedin' ,'only_loggedin_cap', 'search_filter', 'show_as_link', |
|
247 | + 'only_loggedin', 'only_loggedin_cap', 'search_filter', 'show_as_link', |
|
248 | 248 | ); |
249 | 249 | |
250 | 250 | /** Everything else goes into the properties for now. @todo subclasses! */ |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | |
274 | 274 | /** A custom label is available. */ |
275 | 275 | if ( ! empty( $this->custom_label ) ) { |
276 | - return \GravityView_API::replace_variables( $this->custom_label, $source ? $source->form ? : null : null, $entry ? $entry->as_entry() : null ); |
|
276 | + return \GravityView_API::replace_variables( $this->custom_label, $source ? $source->form ?: null : null, $entry ? $entry->as_entry() : null ); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | return ''; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @return mixed|null The value for the given configuration key, null if doesn't exist. |
351 | 351 | */ |
352 | 352 | public function __get( $key ) { |
353 | - switch( $key ) { |
|
353 | + switch ( $key ) { |
|
354 | 354 | default: |
355 | 355 | if ( isset( $this->configuration[ $key ] ) ) { |
356 | 356 | return $this->configuration[ $key ]; |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @return boolean Whether this $key is set or not. |
369 | 369 | */ |
370 | 370 | public function __isset( $key ) { |
371 | - switch( $key ) { |
|
371 | + switch ( $key ) { |
|
372 | 372 | default: |
373 | 373 | return isset( $this->configuration[ $key ] ); |
374 | 374 | } |