@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; // Exit if accessed directly |
| 13 | 13 | } |
| 14 | 14 | |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @return bool|string |
| 24 | 24 | */ |
| 25 | -function give_is_field_callback_exist( $field ) { |
|
| 26 | - return ( give_get_field_callback( $field ) ? true : false ); |
|
| 25 | +function give_is_field_callback_exist($field) { |
|
| 26 | + return (give_get_field_callback($field) ? true : false); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @return bool|string |
| 37 | 37 | */ |
| 38 | -function give_get_field_callback( $field ) { |
|
| 38 | +function give_get_field_callback($field) { |
|
| 39 | 39 | $func_name_prefix = 'give'; |
| 40 | 40 | $func_name = ''; |
| 41 | 41 | |
| 42 | 42 | // Set callback function on basis of cmb2 field name. |
| 43 | - switch ( $field['type'] ) { |
|
| 43 | + switch ($field['type']) { |
|
| 44 | 44 | case 'radio_inline': |
| 45 | 45 | $func_name = "{$func_name_prefix}_radio"; |
| 46 | 46 | break; |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | default: |
| 77 | 77 | |
| 78 | 78 | if ( |
| 79 | - array_key_exists( 'callback', $field ) |
|
| 80 | - && ! empty( $field['callback'] ) |
|
| 79 | + array_key_exists('callback', $field) |
|
| 80 | + && ! empty($field['callback']) |
|
| 81 | 81 | ) { |
| 82 | 82 | $func_name = $field['callback']; |
| 83 | 83 | } else { |
@@ -90,15 +90,15 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @since 1.8 |
| 92 | 92 | */ |
| 93 | - $func_name = apply_filters( 'give_get_field_callback', $func_name, $field ); |
|
| 93 | + $func_name = apply_filters('give_get_field_callback', $func_name, $field); |
|
| 94 | 94 | |
| 95 | 95 | // Exit if not any function exist. |
| 96 | 96 | // Check if render callback exist or not. |
| 97 | - if ( empty( $func_name ) ) { |
|
| 97 | + if (empty($func_name)) { |
|
| 98 | 98 | return false; |
| 99 | - } elseif ( is_string( $func_name ) && ! function_exists( "$func_name" ) ) { |
|
| 99 | + } elseif (is_string($func_name) && ! function_exists("$func_name")) { |
|
| 100 | 100 | return false; |
| 101 | - } elseif ( is_array( $func_name ) && ! method_exists( $func_name[0], "$func_name[1]" ) ) { |
|
| 101 | + } elseif (is_array($func_name) && ! method_exists($func_name[0], "$func_name[1]")) { |
|
| 102 | 102 | return false; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -114,35 +114,35 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return bool |
| 116 | 116 | */ |
| 117 | -function give_render_field( $field ) { |
|
| 117 | +function give_render_field($field) { |
|
| 118 | 118 | |
| 119 | 119 | // Check if render callback exist or not. |
| 120 | - if ( ! ( $func_name = give_get_field_callback( $field ) ) ) { |
|
| 120 | + if ( ! ($func_name = give_get_field_callback($field))) { |
|
| 121 | 121 | return false; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | // CMB2 compatibility: Push all classes to attributes's class key |
| 125 | - if ( empty( $field['class'] ) ) { |
|
| 125 | + if (empty($field['class'])) { |
|
| 126 | 126 | $field['class'] = ''; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - if ( empty( $field['attributes']['class'] ) ) { |
|
| 129 | + if (empty($field['attributes']['class'])) { |
|
| 130 | 130 | $field['attributes']['class'] = ''; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $field['attributes']['class'] = trim( "give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}" ); |
|
| 134 | - unset( $field['class'] ); |
|
| 133 | + $field['attributes']['class'] = trim("give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}"); |
|
| 134 | + unset($field['class']); |
|
| 135 | 135 | |
| 136 | 136 | // CMB2 compatibility: Set wrapper class if any. |
| 137 | - if ( ! empty( $field['row_classes'] ) ) { |
|
| 137 | + if ( ! empty($field['row_classes'])) { |
|
| 138 | 138 | $field['wrapper_class'] = $field['row_classes']; |
| 139 | - unset( $field['row_classes'] ); |
|
| 139 | + unset($field['row_classes']); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | // Set field params on basis of cmb2 field name. |
| 143 | - switch ( $field['type'] ) { |
|
| 143 | + switch ($field['type']) { |
|
| 144 | 144 | case 'radio_inline': |
| 145 | - if ( empty( $field['wrapper_class'] ) ) { |
|
| 145 | + if (empty($field['wrapper_class'])) { |
|
| 146 | 146 | $field['wrapper_class'] = ''; |
| 147 | 147 | } |
| 148 | 148 | $field['wrapper_class'] .= ' give-inline-radio-fields'; |
@@ -155,15 +155,15 @@ discard block |
||
| 155 | 155 | case 'text-small' : |
| 156 | 156 | case 'text_small' : |
| 157 | 157 | // CMB2 compatibility: Set field type to text. |
| 158 | - $field['type'] = isset( $field['attributes']['type'] ) ? $field['attributes']['type'] : 'text'; |
|
| 158 | + $field['type'] = isset($field['attributes']['type']) ? $field['attributes']['type'] : 'text'; |
|
| 159 | 159 | |
| 160 | 160 | // CMB2 compatibility: Set data type to price. |
| 161 | 161 | if ( |
| 162 | - empty( $field['data_type'] ) |
|
| 163 | - && ! empty( $field['attributes']['class'] ) |
|
| 162 | + empty($field['data_type']) |
|
| 163 | + && ! empty($field['attributes']['class']) |
|
| 164 | 164 | && ( |
| 165 | - false !== strpos( $field['attributes']['class'], 'money' ) |
|
| 166 | - || false !== strpos( $field['attributes']['class'], 'amount' ) |
|
| 165 | + false !== strpos($field['attributes']['class'], 'money') |
|
| 166 | + || false !== strpos($field['attributes']['class'], 'amount') |
|
| 167 | 167 | ) |
| 168 | 168 | ) { |
| 169 | 169 | $field['data_type'] = 'decimal'; |
@@ -182,22 +182,22 @@ discard block |
||
| 182 | 182 | case 'give_default_radio_inline': |
| 183 | 183 | $field['type'] = 'radio'; |
| 184 | 184 | $field['options'] = array( |
| 185 | - 'default' => __( 'Default' ), |
|
| 185 | + 'default' => __('Default'), |
|
| 186 | 186 | ); |
| 187 | 187 | break; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // CMB2 compatibility: Add support to define field description by desc & description param. |
| 191 | 191 | // We encourage you to use description param. |
| 192 | - $field['description'] = ( ! empty( $field['description'] ) |
|
| 192 | + $field['description'] = ( ! empty($field['description']) |
|
| 193 | 193 | ? $field['description'] |
| 194 | - : ( ! empty( $field['desc'] ) ? $field['desc'] : '' ) ); |
|
| 194 | + : ( ! empty($field['desc']) ? $field['desc'] : '')); |
|
| 195 | 195 | |
| 196 | 196 | // Call render function. |
| 197 | - if ( is_array( $func_name ) ) { |
|
| 198 | - $func_name[0]->{$func_name[1]}( $field ); |
|
| 197 | + if (is_array($func_name)) { |
|
| 198 | + $func_name[0]->{$func_name[1]}($field); |
|
| 199 | 199 | } else { |
| 200 | - $func_name( $field ); |
|
| 200 | + $func_name($field); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | return true; |
@@ -227,29 +227,29 @@ discard block |
||
| 227 | 227 | * } |
| 228 | 228 | * @return void |
| 229 | 229 | */ |
| 230 | -function give_text_input( $field ) { |
|
| 230 | +function give_text_input($field) { |
|
| 231 | 231 | global $thepostid, $post; |
| 232 | 232 | |
| 233 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 234 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 235 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 236 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 237 | - $field['type'] = isset( $field['type'] ) ? $field['type'] : 'text'; |
|
| 233 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 234 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 235 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 236 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 237 | + $field['type'] = isset($field['type']) ? $field['type'] : 'text'; |
|
| 238 | 238 | $field['before_field'] = ''; |
| 239 | 239 | $field['after_field'] = ''; |
| 240 | - $data_type = empty( $field['data_type'] ) ? '' : $field['data_type']; |
|
| 240 | + $data_type = empty($field['data_type']) ? '' : $field['data_type']; |
|
| 241 | 241 | |
| 242 | - switch ( $data_type ) { |
|
| 242 | + switch ($data_type) { |
|
| 243 | 243 | case 'price' : |
| 244 | - $field['value'] = ( ! empty( $field['value'] ) ? give_format_amount( $field['value'] ) : $field['value'] ); |
|
| 244 | + $field['value'] = ( ! empty($field['value']) ? give_format_amount($field['value']) : $field['value']); |
|
| 245 | 245 | |
| 246 | - $field['before_field'] = ! empty( $field['before_field'] ) ? $field['before_field'] : ( give_get_option( 'currency_position', 'before' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '' ); |
|
| 247 | - $field['after_field'] = ! empty( $field['after_field'] ) ? $field['after_field'] : ( give_get_option( 'currency_position', 'before' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '' ); |
|
| 246 | + $field['before_field'] = ! empty($field['before_field']) ? $field['before_field'] : (give_get_option('currency_position', 'before') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">'.give_currency_symbol().'</span>' : ''); |
|
| 247 | + $field['after_field'] = ! empty($field['after_field']) ? $field['after_field'] : (give_get_option('currency_position', 'before') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">'.give_currency_symbol().'</span>' : ''); |
|
| 248 | 248 | break; |
| 249 | 249 | |
| 250 | 250 | case 'decimal' : |
| 251 | 251 | $field['attributes']['class'] .= ' give_input_decimal'; |
| 252 | - $field['value'] = ( ! empty( $field['value'] ) ? give_format_decimal( $field['value'] ) : $field['value'] ); |
|
| 252 | + $field['value'] = ( ! empty($field['value']) ? give_format_decimal($field['value']) : $field['value']); |
|
| 253 | 253 | break; |
| 254 | 254 | |
| 255 | 255 | default : |
@@ -257,20 +257,20 @@ discard block |
||
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | ?> |
| 260 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
| 261 | - <label for="<?php echo esc_attr( $field['id'] ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
| 260 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
| 261 | + <label for="<?php echo esc_attr($field['id']); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
| 262 | 262 | <?php echo $field['before_field']; ?> |
| 263 | 263 | <input |
| 264 | - type="<?php echo esc_attr( $field['type'] ); ?>" |
|
| 265 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
| 266 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 267 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
| 268 | - value="<?php echo esc_attr( $field['value'] ); ?>" |
|
| 269 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 264 | + type="<?php echo esc_attr($field['type']); ?>" |
|
| 265 | + style="<?php echo esc_attr($field['style']); ?>" |
|
| 266 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 267 | + id="<?php echo esc_attr($field['id']); ?>" |
|
| 268 | + value="<?php echo esc_attr($field['value']); ?>" |
|
| 269 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 270 | 270 | /> |
| 271 | 271 | <?php echo $field['after_field']; ?> |
| 272 | 272 | <?php |
| 273 | - echo give_get_field_description( $field ); |
|
| 273 | + echo give_get_field_description($field); |
|
| 274 | 274 | echo '</p>'; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -292,29 +292,29 @@ discard block |
||
| 292 | 292 | * } |
| 293 | 293 | * @return void |
| 294 | 294 | */ |
| 295 | -function give_hidden_input( $field ) { |
|
| 295 | +function give_hidden_input($field) { |
|
| 296 | 296 | global $thepostid, $post; |
| 297 | 297 | |
| 298 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 299 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 298 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 299 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 300 | 300 | |
| 301 | 301 | // Custom attribute handling |
| 302 | 302 | $custom_attributes = array(); |
| 303 | 303 | |
| 304 | - if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) { |
|
| 304 | + if ( ! empty($field['attributes']) && is_array($field['attributes'])) { |
|
| 305 | 305 | |
| 306 | - foreach ( $field['attributes'] as $attribute => $value ) { |
|
| 307 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; |
|
| 306 | + foreach ($field['attributes'] as $attribute => $value) { |
|
| 307 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"'; |
|
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | ?> |
| 311 | 311 | |
| 312 | 312 | <input |
| 313 | 313 | type="hidden" |
| 314 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 315 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
| 316 | - value="<?php echo esc_attr( $field['value'] ); ?>" |
|
| 317 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 314 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 315 | + id="<?php echo esc_attr($field['id']); ?>" |
|
| 316 | + value="<?php echo esc_attr($field['value']); ?>" |
|
| 317 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 318 | 318 | /> |
| 319 | 319 | <?php |
| 320 | 320 | } |
@@ -340,27 +340,27 @@ discard block |
||
| 340 | 340 | * } |
| 341 | 341 | * @return void |
| 342 | 342 | */ |
| 343 | -function give_textarea_input( $field ) { |
|
| 343 | +function give_textarea_input($field) { |
|
| 344 | 344 | global $thepostid, $post; |
| 345 | 345 | |
| 346 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 347 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 348 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 349 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 346 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 347 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 348 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 349 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 350 | 350 | |
| 351 | 351 | ?> |
| 352 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
| 353 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
| 352 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
| 353 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
| 354 | 354 | <textarea |
| 355 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
| 356 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 357 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
| 355 | + style="<?php echo esc_attr($field['style']); ?>" |
|
| 356 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 357 | + id="<?php echo esc_attr($field['id']); ?>" |
|
| 358 | 358 | rows="10" |
| 359 | 359 | cols="20" |
| 360 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 361 | - ><?php echo esc_textarea( $field['value'] ); ?></textarea> |
|
| 360 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 361 | + ><?php echo esc_textarea($field['value']); ?></textarea> |
|
| 362 | 362 | <?php |
| 363 | - echo give_get_field_description( $field ); |
|
| 363 | + echo give_get_field_description($field); |
|
| 364 | 364 | echo '</p>'; |
| 365 | 365 | } |
| 366 | 366 | |
@@ -384,29 +384,29 @@ discard block |
||
| 384 | 384 | * } |
| 385 | 385 | * @return void |
| 386 | 386 | */ |
| 387 | -function give_wysiwyg( $field ) { |
|
| 387 | +function give_wysiwyg($field) { |
|
| 388 | 388 | global $thepostid, $post; |
| 389 | 389 | |
| 390 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 391 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 392 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 393 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 390 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 391 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 392 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 393 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 394 | 394 | |
| 395 | - $field['unique_field_id'] = give_get_field_name( $field ); |
|
| 395 | + $field['unique_field_id'] = give_get_field_name($field); |
|
| 396 | 396 | $editor_attributes = array( |
| 397 | - 'textarea_name' => isset( $field['repeatable_field_id'] ) ? $field['repeatable_field_id'] : $field['id'], |
|
| 397 | + 'textarea_name' => isset($field['repeatable_field_id']) ? $field['repeatable_field_id'] : $field['id'], |
|
| 398 | 398 | 'textarea_rows' => '10', |
| 399 | - 'editor_css' => esc_attr( $field['style'] ), |
|
| 399 | + 'editor_css' => esc_attr($field['style']), |
|
| 400 | 400 | 'editor_class' => $field['attributes']['class'], |
| 401 | 401 | ); |
| 402 | - $data_wp_editor = ' data-wp-editor="' . base64_encode( json_encode( array( |
|
| 402 | + $data_wp_editor = ' data-wp-editor="'.base64_encode(json_encode(array( |
|
| 403 | 403 | $field['value'], |
| 404 | 404 | $field['unique_field_id'], |
| 405 | 405 | $editor_attributes, |
| 406 | - ) ) ) . '"'; |
|
| 407 | - $data_wp_editor = isset( $field['repeatable_field_id'] ) ? $data_wp_editor : ''; |
|
| 406 | + ))).'"'; |
|
| 407 | + $data_wp_editor = isset($field['repeatable_field_id']) ? $data_wp_editor : ''; |
|
| 408 | 408 | |
| 409 | - echo '<div class="give-field-wrap ' . $field['unique_field_id'] . '_field ' . esc_attr( $field['wrapper_class'] ) . '"' . $data_wp_editor . '><label for="' . $field['unique_field_id'] . '">' . wp_kses_post( $field['name'] ) . '</label>'; |
|
| 409 | + echo '<div class="give-field-wrap '.$field['unique_field_id'].'_field '.esc_attr($field['wrapper_class']).'"'.$data_wp_editor.'><label for="'.$field['unique_field_id'].'">'.wp_kses_post($field['name']).'</label>'; |
|
| 410 | 410 | |
| 411 | 411 | wp_editor( |
| 412 | 412 | $field['value'], |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | $editor_attributes |
| 415 | 415 | ); |
| 416 | 416 | |
| 417 | - echo give_get_field_description( $field ); |
|
| 417 | + echo give_get_field_description($field); |
|
| 418 | 418 | echo '</div>'; |
| 419 | 419 | } |
| 420 | 420 | |
@@ -439,29 +439,29 @@ discard block |
||
| 439 | 439 | * } |
| 440 | 440 | * @return void |
| 441 | 441 | */ |
| 442 | -function give_checkbox( $field ) { |
|
| 442 | +function give_checkbox($field) { |
|
| 443 | 443 | global $thepostid, $post; |
| 444 | 444 | |
| 445 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 446 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 447 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 448 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 449 | - $field['cbvalue'] = isset( $field['cbvalue'] ) ? $field['cbvalue'] : 'on'; |
|
| 450 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
| 445 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 446 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 447 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 448 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 449 | + $field['cbvalue'] = isset($field['cbvalue']) ? $field['cbvalue'] : 'on'; |
|
| 450 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
| 451 | 451 | ?> |
| 452 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
| 453 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
| 452 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
| 453 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
| 454 | 454 | <input |
| 455 | 455 | type="checkbox" |
| 456 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
| 457 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 458 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
| 459 | - value="<?php echo esc_attr( $field['cbvalue'] ); ?>" |
|
| 460 | - <?php echo checked( $field['value'], $field['cbvalue'], false ); ?> |
|
| 461 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 456 | + style="<?php echo esc_attr($field['style']); ?>" |
|
| 457 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 458 | + id="<?php echo esc_attr($field['id']); ?>" |
|
| 459 | + value="<?php echo esc_attr($field['cbvalue']); ?>" |
|
| 460 | + <?php echo checked($field['value'], $field['cbvalue'], false); ?> |
|
| 461 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 462 | 462 | /> |
| 463 | 463 | <?php |
| 464 | - echo give_get_field_description( $field ); |
|
| 464 | + echo give_get_field_description($field); |
|
| 465 | 465 | echo '</p>'; |
| 466 | 466 | } |
| 467 | 467 | |
@@ -487,29 +487,29 @@ discard block |
||
| 487 | 487 | * } |
| 488 | 488 | * @return void |
| 489 | 489 | */ |
| 490 | -function give_select( $field ) { |
|
| 490 | +function give_select($field) { |
|
| 491 | 491 | global $thepostid, $post; |
| 492 | 492 | |
| 493 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 494 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 495 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 496 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 497 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
| 493 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 494 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 495 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 496 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 497 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
| 498 | 498 | ?> |
| 499 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
| 500 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
| 499 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
| 500 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
| 501 | 501 | <select |
| 502 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
| 503 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 504 | - style="<?php echo esc_attr( $field['style'] ) ?>" |
|
| 505 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 502 | + id="<?php echo esc_attr($field['id']); ?>" |
|
| 503 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 504 | + style="<?php echo esc_attr($field['style']) ?>" |
|
| 505 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 506 | 506 | > |
| 507 | 507 | <?php |
| 508 | - foreach ( $field['options'] as $key => $value ) { |
|
| 509 | - echo '<option value="' . esc_attr( $key ) . '" ' . selected( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>'; |
|
| 508 | + foreach ($field['options'] as $key => $value) { |
|
| 509 | + echo '<option value="'.esc_attr($key).'" '.selected(esc_attr($field['value']), esc_attr($key), false).'>'.esc_html($value).'</option>'; |
|
| 510 | 510 | } |
| 511 | 511 | echo '</select>'; |
| 512 | - echo give_get_field_description( $field ); |
|
| 512 | + echo give_get_field_description($field); |
|
| 513 | 513 | echo '</p>'; |
| 514 | 514 | } |
| 515 | 515 | |
@@ -536,32 +536,32 @@ discard block |
||
| 536 | 536 | * } |
| 537 | 537 | * @return void |
| 538 | 538 | */ |
| 539 | -function give_radio( $field ) { |
|
| 539 | +function give_radio($field) { |
|
| 540 | 540 | global $thepostid, $post; |
| 541 | 541 | |
| 542 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 543 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 544 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 545 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 546 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
| 542 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 543 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 544 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 545 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 546 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
| 547 | 547 | |
| 548 | - echo '<fieldset class="give-field-wrap ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><span class="give-field-label">' . wp_kses_post( $field['name'] ) . '</span><legend class="screen-reader-text">' . wp_kses_post( $field['name'] ) . '</legend><ul class="give-radios">'; |
|
| 548 | + echo '<fieldset class="give-field-wrap '.esc_attr($field['id']).'_field '.esc_attr($field['wrapper_class']).'"><span class="give-field-label">'.wp_kses_post($field['name']).'</span><legend class="screen-reader-text">'.wp_kses_post($field['name']).'</legend><ul class="give-radios">'; |
|
| 549 | 549 | |
| 550 | - foreach ( $field['options'] as $key => $value ) { |
|
| 550 | + foreach ($field['options'] as $key => $value) { |
|
| 551 | 551 | |
| 552 | 552 | echo '<li><label><input |
| 553 | - name="' . give_get_field_name( $field ) . '" |
|
| 554 | - value="' . esc_attr( $key ) . '" |
|
| 553 | + name="' . give_get_field_name($field).'" |
|
| 554 | + value="' . esc_attr($key).'" |
|
| 555 | 555 | type="radio" |
| 556 | - style="' . esc_attr( $field['style'] ) . '" |
|
| 557 | - ' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . ' ' |
|
| 558 | - . give_get_custom_attributes( $field ) . ' |
|
| 559 | - /> ' . esc_html( $value ) . '</label> |
|
| 556 | + style="' . esc_attr($field['style']).'" |
|
| 557 | + ' . checked(esc_attr($field['value']), esc_attr($key), false).' ' |
|
| 558 | + . give_get_custom_attributes($field).' |
|
| 559 | + /> ' . esc_html($value).'</label> |
|
| 560 | 560 | </li>'; |
| 561 | 561 | } |
| 562 | 562 | echo '</ul>'; |
| 563 | 563 | |
| 564 | - echo give_get_field_description( $field ); |
|
| 564 | + echo give_get_field_description($field); |
|
| 565 | 565 | echo '</fieldset>'; |
| 566 | 566 | } |
| 567 | 567 | |
@@ -585,27 +585,27 @@ discard block |
||
| 585 | 585 | * } |
| 586 | 586 | * @return void |
| 587 | 587 | */ |
| 588 | -function give_colorpicker( $field ) { |
|
| 588 | +function give_colorpicker($field) { |
|
| 589 | 589 | global $thepostid, $post; |
| 590 | 590 | |
| 591 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 592 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 593 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 594 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 595 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
| 591 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 592 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 593 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 594 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 595 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
| 596 | 596 | $field['type'] = 'text'; |
| 597 | 597 | ?> |
| 598 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
| 599 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
| 598 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
| 599 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
| 600 | 600 | <input |
| 601 | - type="<?php echo esc_attr( $field['type'] ); ?>" |
|
| 602 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
| 603 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 604 | - id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr( $field['value'] ); ?>" |
|
| 605 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 601 | + type="<?php echo esc_attr($field['type']); ?>" |
|
| 602 | + style="<?php echo esc_attr($field['style']); ?>" |
|
| 603 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 604 | + id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr($field['value']); ?>" |
|
| 605 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 606 | 606 | /> |
| 607 | 607 | <?php |
| 608 | - echo give_get_field_description( $field ); |
|
| 608 | + echo give_get_field_description($field); |
|
| 609 | 609 | echo '</p>'; |
| 610 | 610 | } |
| 611 | 611 | |
@@ -616,8 +616,8 @@ discard block |
||
| 616 | 616 | * |
| 617 | 617 | * @param array $field |
| 618 | 618 | */ |
| 619 | -function give_file( $field ) { |
|
| 620 | - give_media( $field ); |
|
| 619 | +function give_file($field) { |
|
| 620 | + give_media($field); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | |
@@ -628,40 +628,40 @@ discard block |
||
| 628 | 628 | * |
| 629 | 629 | * @param array $field |
| 630 | 630 | */ |
| 631 | -function give_media( $field ) { |
|
| 631 | +function give_media($field) { |
|
| 632 | 632 | global $thepostid, $post; |
| 633 | 633 | |
| 634 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 635 | - $button_label = esc_html__( sprintf( 'Add or Upload %s', ( 'file' === $field['type'] ? 'File' : 'Image' ) ), 'give' ); |
|
| 634 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 635 | + $button_label = esc_html__(sprintf('Add or Upload %s', ('file' === $field['type'] ? 'File' : 'Image')), 'give'); |
|
| 636 | 636 | |
| 637 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 638 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 639 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 640 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
| 637 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 638 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 639 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 640 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
| 641 | 641 | $field['attributes']['class'] = "{$field['attributes']['class']} give-text-medium"; |
| 642 | 642 | |
| 643 | 643 | // Allow developer to save attachment ID or attachment url as metadata. |
| 644 | - $field['fvalue'] = isset( $field['fvalue'] ) ? $field['fvalue'] : 'url'; |
|
| 644 | + $field['fvalue'] = isset($field['fvalue']) ? $field['fvalue'] : 'url'; |
|
| 645 | 645 | |
| 646 | - $allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' ); |
|
| 647 | - $preview_image_src = $field['value'] ? ( 'id' === $field['fvalue'] ? wp_get_attachment_url( $field['value'] ) : $field['value'] ) : '#'; |
|
| 648 | - $preview_image_extension = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : ''; |
|
| 649 | - $is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags ); |
|
| 646 | + $allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico'); |
|
| 647 | + $preview_image_src = $field['value'] ? ('id' === $field['fvalue'] ? wp_get_attachment_url($field['value']) : $field['value']) : '#'; |
|
| 648 | + $preview_image_extension = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : ''; |
|
| 649 | + $is_show_preview = in_array($preview_image_extension, $allow_media_preview_tags); |
|
| 650 | 650 | ?> |
| 651 | - <fieldset class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
| 652 | - <label for="<?php echo give_get_field_name( $field ) ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
| 651 | + <fieldset class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
| 652 | + <label for="<?php echo give_get_field_name($field) ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
| 653 | 653 | <input |
| 654 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 655 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
| 654 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 655 | + id="<?php echo esc_attr($field['id']); ?>" |
|
| 656 | 656 | type="text" |
| 657 | 657 | value="<?php echo $field['value']; ?>" |
| 658 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
| 659 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 658 | + style="<?php echo esc_attr($field['style']); ?>" |
|
| 659 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 660 | 660 | /> <input class="give-upload-button button" type="button" value="<?php echo $button_label; ?>" data-fvalue="<?php echo $field['fvalue']; ?>" data-field-type="<?php echo $field['type']; ?>"> |
| 661 | - <?php echo give_get_field_description( $field ); ?> |
|
| 661 | + <?php echo give_get_field_description($field); ?> |
|
| 662 | 662 | <div class="give-image-thumb<?php echo ! $field['value'] || ! $is_show_preview ? ' give-hidden' : ''; ?>"> |
| 663 | 663 | <span class="give-delete-image-thumb dashicons dashicons-no-alt"></span> |
| 664 | - <img src="<?php echo $preview_image_src ; ?>" alt=""> |
|
| 664 | + <img src="<?php echo $preview_image_src; ?>" alt=""> |
|
| 665 | 665 | </div> |
| 666 | 666 | </fieldset> |
| 667 | 667 | <?php |
@@ -676,27 +676,27 @@ discard block |
||
| 676 | 676 | * |
| 677 | 677 | * @return void |
| 678 | 678 | */ |
| 679 | -function give_default_gateway( $field ) { |
|
| 679 | +function give_default_gateway($field) { |
|
| 680 | 680 | global $thepostid, $post; |
| 681 | 681 | |
| 682 | 682 | // get all active payment gateways. |
| 683 | - $gateways = give_get_enabled_payment_gateways( $thepostid ); |
|
| 683 | + $gateways = give_get_enabled_payment_gateways($thepostid); |
|
| 684 | 684 | $field['options'] = array(); |
| 685 | 685 | |
| 686 | 686 | // Set field option value. |
| 687 | - if ( ! empty( $gateways ) ) { |
|
| 688 | - foreach ( $gateways as $key => $option ) { |
|
| 689 | - $field['options'][ $key ] = $option['admin_label']; |
|
| 687 | + if ( ! empty($gateways)) { |
|
| 688 | + foreach ($gateways as $key => $option) { |
|
| 689 | + $field['options'][$key] = $option['admin_label']; |
|
| 690 | 690 | } |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | // Add a field to the Give Form admin single post view of this field |
| 694 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
| 695 | - $field['options'] = array_merge( array( 'global' => esc_html__( 'Global Default', 'give' ) ), $field['options'] ); |
|
| 694 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
| 695 | + $field['options'] = array_merge(array('global' => esc_html__('Global Default', 'give')), $field['options']); |
|
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | // Render select field. |
| 699 | - give_select( $field ); |
|
| 699 | + give_select($field); |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | /** |
@@ -718,13 +718,13 @@ discard block |
||
| 718 | 718 | * @return void |
| 719 | 719 | */ |
| 720 | 720 | |
| 721 | -function give_docs_link( $field ) { |
|
| 722 | - $field['url'] = isset( $field['url'] ) ? $field['url'] : 'https://givewp.com/documentation'; |
|
| 723 | - $field['title'] = isset( $field['title'] ) ? $field['title'] : 'Documentation'; |
|
| 721 | +function give_docs_link($field) { |
|
| 722 | + $field['url'] = isset($field['url']) ? $field['url'] : 'https://givewp.com/documentation'; |
|
| 723 | + $field['title'] = isset($field['title']) ? $field['title'] : 'Documentation'; |
|
| 724 | 724 | |
| 725 | - echo '<p class="give-docs-link"><a href="' . esc_url( $field['url'] ) |
|
| 725 | + echo '<p class="give-docs-link"><a href="'.esc_url($field['url']) |
|
| 726 | 726 | . '" target="_blank">' |
| 727 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $field['title'] ) |
|
| 727 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $field['title']) |
|
| 728 | 728 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
| 729 | 729 | } |
| 730 | 730 | |
@@ -740,13 +740,13 @@ discard block |
||
| 740 | 740 | * |
| 741 | 741 | * @return mixed |
| 742 | 742 | */ |
| 743 | -function give_get_field_value( $field, $postid ) { |
|
| 744 | - if ( isset( $field['attributes']['value'] ) ) { |
|
| 743 | +function give_get_field_value($field, $postid) { |
|
| 744 | + if (isset($field['attributes']['value'])) { |
|
| 745 | 745 | return $field['attributes']['value']; |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | // Get value from db. |
| 749 | - $field_value = give_get_meta( $postid, $field['id'], true ); |
|
| 749 | + $field_value = give_get_meta($postid, $field['id'], true); |
|
| 750 | 750 | |
| 751 | 751 | /** |
| 752 | 752 | * Filter the field value before apply default value. |
@@ -755,10 +755,10 @@ discard block |
||
| 755 | 755 | * |
| 756 | 756 | * @param mixed $field_value Field value. |
| 757 | 757 | */ |
| 758 | - $field_value = apply_filters( "{$field['id']}_field_value", $field_value, $field, $postid ); |
|
| 758 | + $field_value = apply_filters("{$field['id']}_field_value", $field_value, $field, $postid); |
|
| 759 | 759 | |
| 760 | 760 | // Set default value if no any data saved to db. |
| 761 | - if ( ! $field_value && isset( $field['default'] ) ) { |
|
| 761 | + if ( ! $field_value && isset($field['default'])) { |
|
| 762 | 762 | $field_value = $field['default']; |
| 763 | 763 | } |
| 764 | 764 | |
@@ -775,20 +775,20 @@ discard block |
||
| 775 | 775 | * |
| 776 | 776 | * @return string |
| 777 | 777 | */ |
| 778 | -function give_get_field_description( $field ) { |
|
| 778 | +function give_get_field_description($field) { |
|
| 779 | 779 | $field_desc_html = ''; |
| 780 | 780 | $description = ''; |
| 781 | 781 | |
| 782 | 782 | // Check for both `description` and `desc`. |
| 783 | - if ( isset( $field['description'] ) ) { |
|
| 783 | + if (isset($field['description'])) { |
|
| 784 | 784 | $description = $field['description']; |
| 785 | - } elseif ( isset( $field['desc'] ) ) { |
|
| 785 | + } elseif (isset($field['desc'])) { |
|
| 786 | 786 | $description = $field['desc']; |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | // Set if there is a description. |
| 790 | - if ( ! empty( $description ) ) { |
|
| 791 | - $field_desc_html = '<span class="give-field-description">' . wp_kses_post( $description ) . '</span>'; |
|
| 790 | + if ( ! empty($description)) { |
|
| 791 | + $field_desc_html = '<span class="give-field-description">'.wp_kses_post($description).'</span>'; |
|
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | return $field_desc_html; |
@@ -804,18 +804,18 @@ discard block |
||
| 804 | 804 | * |
| 805 | 805 | * @return string |
| 806 | 806 | */ |
| 807 | -function give_get_custom_attributes( $field ) { |
|
| 807 | +function give_get_custom_attributes($field) { |
|
| 808 | 808 | // Custom attribute handling |
| 809 | 809 | $custom_attributes = array(); |
| 810 | 810 | |
| 811 | - if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) { |
|
| 811 | + if ( ! empty($field['attributes']) && is_array($field['attributes'])) { |
|
| 812 | 812 | |
| 813 | - foreach ( $field['attributes'] as $attribute => $value ) { |
|
| 814 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; |
|
| 813 | + foreach ($field['attributes'] as $attribute => $value) { |
|
| 814 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"'; |
|
| 815 | 815 | } |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | - return implode( ' ', $custom_attributes ); |
|
| 818 | + return implode(' ', $custom_attributes); |
|
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | /** |
@@ -831,8 +831,8 @@ discard block |
||
| 831 | 831 | * |
| 832 | 832 | * @return string |
| 833 | 833 | */ |
| 834 | -function give_get_repeater_field_value( $field, $field_group, $fields ) { |
|
| 835 | - $field_value = ( isset( $field_group[ $field['id'] ] ) ? $field_group[ $field['id'] ] : '' ); |
|
| 834 | +function give_get_repeater_field_value($field, $field_group, $fields) { |
|
| 835 | + $field_value = (isset($field_group[$field['id']]) ? $field_group[$field['id']] : ''); |
|
| 836 | 836 | |
| 837 | 837 | /** |
| 838 | 838 | * Filter the specific repeater field value |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | * |
| 842 | 842 | * @param string $field_id |
| 843 | 843 | */ |
| 844 | - $field_value = apply_filters( "give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields ); |
|
| 844 | + $field_value = apply_filters("give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields); |
|
| 845 | 845 | |
| 846 | 846 | /** |
| 847 | 847 | * Filter the repeater field value |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | * |
| 851 | 851 | * @param string $field_id |
| 852 | 852 | */ |
| 853 | - $field_value = apply_filters( 'give_get_repeater_field_value', $field_value, $field, $field_group, $fields ); |
|
| 853 | + $field_value = apply_filters('give_get_repeater_field_value', $field_value, $field, $field_group, $fields); |
|
| 854 | 854 | |
| 855 | 855 | return $field_value; |
| 856 | 856 | } |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | * |
| 869 | 869 | * @return string |
| 870 | 870 | */ |
| 871 | -function give_get_repeater_field_id( $field, $fields, $default = false ) { |
|
| 871 | +function give_get_repeater_field_id($field, $fields, $default = false) { |
|
| 872 | 872 | $row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}'; |
| 873 | 873 | |
| 874 | 874 | // Get field id. |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | * |
| 882 | 882 | * @param string $field_id |
| 883 | 883 | */ |
| 884 | - $field_id = apply_filters( "give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default ); |
|
| 884 | + $field_id = apply_filters("give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default); |
|
| 885 | 885 | |
| 886 | 886 | /** |
| 887 | 887 | * Filter the repeater field id |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | * |
| 891 | 891 | * @param string $field_id |
| 892 | 892 | */ |
| 893 | - $field_id = apply_filters( 'give_get_repeater_field_id', $field_id, $field, $fields, $default ); |
|
| 893 | + $field_id = apply_filters('give_get_repeater_field_id', $field_id, $field, $fields, $default); |
|
| 894 | 894 | |
| 895 | 895 | return $field_id; |
| 896 | 896 | } |
@@ -905,8 +905,8 @@ discard block |
||
| 905 | 905 | * |
| 906 | 906 | * @return string |
| 907 | 907 | */ |
| 908 | -function give_get_field_name( $field ) { |
|
| 909 | - $field_name = esc_attr( empty( $field['repeat'] ) ? $field['id'] : $field['repeatable_field_id'] ); |
|
| 908 | +function give_get_field_name($field) { |
|
| 909 | + $field_name = esc_attr(empty($field['repeat']) ? $field['id'] : $field['repeatable_field_id']); |
|
| 910 | 910 | |
| 911 | 911 | /** |
| 912 | 912 | * Filter the field name. |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | * |
| 916 | 916 | * @param string $field_name |
| 917 | 917 | */ |
| 918 | - $field_name = apply_filters( 'give_get_field_name', $field_name, $field ); |
|
| 918 | + $field_name = apply_filters('give_get_field_name', $field_name, $field); |
|
| 919 | 919 | |
| 920 | 920 | return $field_name; |
| 921 | 921 | } |
@@ -932,39 +932,39 @@ discard block |
||
| 932 | 932 | * |
| 933 | 933 | * @return void |
| 934 | 934 | */ |
| 935 | -function _give_metabox_form_data_repeater_fields( $fields ) { |
|
| 935 | +function _give_metabox_form_data_repeater_fields($fields) { |
|
| 936 | 936 | global $thepostid, $post; |
| 937 | 937 | |
| 938 | 938 | // Bailout. |
| 939 | - if ( ! isset( $fields['fields'] ) || empty( $fields['fields'] ) ) { |
|
| 939 | + if ( ! isset($fields['fields']) || empty($fields['fields'])) { |
|
| 940 | 940 | return; |
| 941 | 941 | } |
| 942 | 942 | |
| 943 | - $group_numbering = isset( $fields['options']['group_numbering'] ) ? (int) $fields['options']['group_numbering'] : 0; |
|
| 944 | - $close_tabs = isset( $fields['options']['close_tabs'] ) ? (int) $fields['options']['close_tabs'] : 0; |
|
| 943 | + $group_numbering = isset($fields['options']['group_numbering']) ? (int) $fields['options']['group_numbering'] : 0; |
|
| 944 | + $close_tabs = isset($fields['options']['close_tabs']) ? (int) $fields['options']['close_tabs'] : 0; |
|
| 945 | 945 | ?> |
| 946 | 946 | <div class="give-repeatable-field-section" id="<?php echo "{$fields['id']}_field"; ?>" |
| 947 | 947 | data-group-numbering="<?php echo $group_numbering; ?>" data-close-tabs="<?php echo $close_tabs; ?>"> |
| 948 | - <?php if ( ! empty( $fields['name'] ) ) : ?> |
|
| 948 | + <?php if ( ! empty($fields['name'])) : ?> |
|
| 949 | 949 | <p class="give-repeater-field-name"><?php echo $fields['name']; ?></p> |
| 950 | 950 | <?php endif; ?> |
| 951 | 951 | |
| 952 | - <?php if ( ! empty( $fields['description'] ) ) : ?> |
|
| 952 | + <?php if ( ! empty($fields['description'])) : ?> |
|
| 953 | 953 | <p class="give-repeater-field-description"><?php echo $fields['description']; ?></p> |
| 954 | 954 | <?php endif; ?> |
| 955 | 955 | |
| 956 | 956 | <table class="give-repeatable-fields-section-wrapper" cellspacing="0"> |
| 957 | 957 | <?php |
| 958 | - $repeater_field_values = give_get_meta( $thepostid, $fields['id'], true ); |
|
| 959 | - $header_title = isset( $fields['options']['header_title'] ) |
|
| 958 | + $repeater_field_values = give_get_meta($thepostid, $fields['id'], true); |
|
| 959 | + $header_title = isset($fields['options']['header_title']) |
|
| 960 | 960 | ? $fields['options']['header_title'] |
| 961 | - : esc_attr__( 'Group', 'give' ); |
|
| 961 | + : esc_attr__('Group', 'give'); |
|
| 962 | 962 | |
| 963 | 963 | $add_default_donation_field = false; |
| 964 | 964 | |
| 965 | 965 | // Check if level is not created or we have to add default level. |
| 966 | - if ( is_array( $repeater_field_values ) && ( $fields_count = count( $repeater_field_values ) ) ) { |
|
| 967 | - $repeater_field_values = array_values( $repeater_field_values ); |
|
| 966 | + if (is_array($repeater_field_values) && ($fields_count = count($repeater_field_values))) { |
|
| 967 | + $repeater_field_values = array_values($repeater_field_values); |
|
| 968 | 968 | } else { |
| 969 | 969 | $fields_count = 1; |
| 970 | 970 | $add_default_donation_field = true; |
@@ -977,59 +977,59 @@ discard block |
||
| 977 | 977 | <div class="give-row-head give-move"> |
| 978 | 978 | <button type="button" class="handlediv button-link"><span class="toggle-indicator"></span> |
| 979 | 979 | </button> |
| 980 | - <span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-</span> |
|
| 980 | + <span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-</span> |
|
| 981 | 981 | <h2> |
| 982 | 982 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
| 983 | 983 | </h2> |
| 984 | 984 | </div> |
| 985 | 985 | <div class="give-row-body"> |
| 986 | - <?php foreach ( $fields['fields'] as $field ) : ?> |
|
| 987 | - <?php if ( ! give_is_field_callback_exist( $field ) ) { |
|
| 986 | + <?php foreach ($fields['fields'] as $field) : ?> |
|
| 987 | + <?php if ( ! give_is_field_callback_exist($field)) { |
|
| 988 | 988 | continue; |
| 989 | 989 | } ?> |
| 990 | 990 | <?php |
| 991 | 991 | $field['repeat'] = true; |
| 992 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields ); |
|
| 993 | - $field['id'] = str_replace( array( '[', ']' ), array( |
|
| 992 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields); |
|
| 993 | + $field['id'] = str_replace(array('[', ']'), array( |
|
| 994 | 994 | '_', |
| 995 | 995 | '', |
| 996 | - ), $field['repeatable_field_id'] ); |
|
| 996 | + ), $field['repeatable_field_id']); |
|
| 997 | 997 | ?> |
| 998 | - <?php give_render_field( $field ); ?> |
|
| 998 | + <?php give_render_field($field); ?> |
|
| 999 | 999 | <?php endforeach; ?> |
| 1000 | 1000 | </div> |
| 1001 | 1001 | </td> |
| 1002 | 1002 | </tr> |
| 1003 | 1003 | |
| 1004 | - <?php if ( ! empty( $repeater_field_values ) ) : ?> |
|
| 1004 | + <?php if ( ! empty($repeater_field_values)) : ?> |
|
| 1005 | 1005 | <!--Stored repeater field group--> |
| 1006 | - <?php foreach ( $repeater_field_values as $index => $field_group ) : ?> |
|
| 1006 | + <?php foreach ($repeater_field_values as $index => $field_group) : ?> |
|
| 1007 | 1007 | <tr class="give-row"> |
| 1008 | 1008 | <td class="give-repeater-field-wrap give-column" colspan="2"> |
| 1009 | 1009 | <div class="give-row-head give-move"> |
| 1010 | 1010 | <button type="button" class="handlediv button-link"> |
| 1011 | 1011 | <span class="toggle-indicator"></span></button> |
| 1012 | - <sapn class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">- |
|
| 1012 | + <sapn class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">- |
|
| 1013 | 1013 | </sapn> |
| 1014 | 1014 | <h2> |
| 1015 | 1015 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
| 1016 | 1016 | </h2> |
| 1017 | 1017 | </div> |
| 1018 | 1018 | <div class="give-row-body"> |
| 1019 | - <?php foreach ( $fields['fields'] as $field ) : ?> |
|
| 1020 | - <?php if ( ! give_is_field_callback_exist( $field ) ) { |
|
| 1019 | + <?php foreach ($fields['fields'] as $field) : ?> |
|
| 1020 | + <?php if ( ! give_is_field_callback_exist($field)) { |
|
| 1021 | 1021 | continue; |
| 1022 | 1022 | } ?> |
| 1023 | 1023 | <?php |
| 1024 | 1024 | $field['repeat'] = true; |
| 1025 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, $index ); |
|
| 1026 | - $field['attributes']['value'] = give_get_repeater_field_value( $field, $field_group, $fields ); |
|
| 1027 | - $field['id'] = str_replace( array( '[', ']' ), array( |
|
| 1025 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, $index); |
|
| 1026 | + $field['attributes']['value'] = give_get_repeater_field_value($field, $field_group, $fields); |
|
| 1027 | + $field['id'] = str_replace(array('[', ']'), array( |
|
| 1028 | 1028 | '_', |
| 1029 | 1029 | '', |
| 1030 | - ), $field['repeatable_field_id'] ); |
|
| 1030 | + ), $field['repeatable_field_id']); |
|
| 1031 | 1031 | ?> |
| 1032 | - <?php give_render_field( $field ); ?> |
|
| 1032 | + <?php give_render_field($field); ?> |
|
| 1033 | 1033 | <?php endforeach; ?> |
| 1034 | 1034 | </div> |
| 1035 | 1035 | </td> |
@@ -1037,14 +1037,14 @@ discard block |
||
| 1037 | 1037 | <?php endforeach; |
| 1038 | 1038 | ; ?> |
| 1039 | 1039 | |
| 1040 | - <?php elseif ( $add_default_donation_field ) : ?> |
|
| 1040 | + <?php elseif ($add_default_donation_field) : ?> |
|
| 1041 | 1041 | <!--Default repeater field group--> |
| 1042 | 1042 | <tr class="give-row"> |
| 1043 | 1043 | <td class="give-repeater-field-wrap give-column" colspan="2"> |
| 1044 | 1044 | <div class="give-row-head give-move"> |
| 1045 | 1045 | <button type="button" class="handlediv button-link"> |
| 1046 | 1046 | <span class="toggle-indicator"></span></button> |
| 1047 | - <sapn class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">- |
|
| 1047 | + <sapn class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">- |
|
| 1048 | 1048 | </sapn> |
| 1049 | 1049 | <h2> |
| 1050 | 1050 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
@@ -1052,19 +1052,19 @@ discard block |
||
| 1052 | 1052 | </div> |
| 1053 | 1053 | <div class="give-row-body"> |
| 1054 | 1054 | <?php |
| 1055 | - foreach ( $fields['fields'] as $field ) : |
|
| 1056 | - if ( ! give_is_field_callback_exist( $field ) ) { |
|
| 1055 | + foreach ($fields['fields'] as $field) : |
|
| 1056 | + if ( ! give_is_field_callback_exist($field)) { |
|
| 1057 | 1057 | continue; |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | $field['repeat'] = true; |
| 1061 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, 0 ); |
|
| 1062 | - $field['attributes']['value'] = apply_filters( "give_default_field_group_field_{$field['id']}_value", ( ! empty( $field['default'] ) ? $field['default'] : '' ), $field ); |
|
| 1063 | - $field['id'] = str_replace( array( '[', ']' ), array( |
|
| 1061 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, 0); |
|
| 1062 | + $field['attributes']['value'] = apply_filters("give_default_field_group_field_{$field['id']}_value", ( ! empty($field['default']) ? $field['default'] : ''), $field); |
|
| 1063 | + $field['id'] = str_replace(array('[', ']'), array( |
|
| 1064 | 1064 | '_', |
| 1065 | 1065 | '', |
| 1066 | - ), $field['repeatable_field_id'] ); |
|
| 1067 | - give_render_field( $field ); |
|
| 1066 | + ), $field['repeatable_field_id']); |
|
| 1067 | + give_render_field($field); |
|
| 1068 | 1068 | endforeach; |
| 1069 | 1069 | ?> |
| 1070 | 1070 | </div> |
@@ -1075,9 +1075,9 @@ discard block |
||
| 1075 | 1075 | <tfoot> |
| 1076 | 1076 | <tr> |
| 1077 | 1077 | <?php |
| 1078 | - $add_row_btn_title = isset( $fields['options']['add_button'] ) |
|
| 1078 | + $add_row_btn_title = isset($fields['options']['add_button']) |
|
| 1079 | 1079 | ? $add_row_btn_title = $fields['options']['add_button'] |
| 1080 | - : esc_html__( 'Add Row', 'give' ); |
|
| 1080 | + : esc_html__('Add Row', 'give'); |
|
| 1081 | 1081 | ?> |
| 1082 | 1082 | <td colspan="2" class="give-add-repeater-field-section-row-wrap"> |
| 1083 | 1083 | <span class="button button-primary give-add-repeater-field-section-row"><?php echo $add_row_btn_title; ?></span> |
@@ -1107,10 +1107,10 @@ discard block |
||
| 1107 | 1107 | * |
| 1108 | 1108 | * @param string |
| 1109 | 1109 | */ |
| 1110 | - $default_current_tab = apply_filters( "give_default_setting_tab_{$current_setting_page}", 'general' ); |
|
| 1110 | + $default_current_tab = apply_filters("give_default_setting_tab_{$current_setting_page}", 'general'); |
|
| 1111 | 1111 | |
| 1112 | 1112 | // Get current tab. |
| 1113 | - $current_tab = empty( $_GET['tab'] ) ? $default_current_tab : urldecode( $_GET['tab'] ); |
|
| 1113 | + $current_tab = empty($_GET['tab']) ? $default_current_tab : urldecode($_GET['tab']); |
|
| 1114 | 1114 | |
| 1115 | 1115 | // Output. |
| 1116 | 1116 | return $current_tab; |
@@ -1134,10 +1134,10 @@ discard block |
||
| 1134 | 1134 | * |
| 1135 | 1135 | * @param string |
| 1136 | 1136 | */ |
| 1137 | - $default_current_section = apply_filters( "give_default_setting_tab_section_{$current_tab}", '' ); |
|
| 1137 | + $default_current_section = apply_filters("give_default_setting_tab_section_{$current_tab}", ''); |
|
| 1138 | 1138 | |
| 1139 | 1139 | // Get current section. |
| 1140 | - $current_section = empty( $_REQUEST['section'] ) ? $default_current_section : urldecode( $_REQUEST['section'] ); |
|
| 1140 | + $current_section = empty($_REQUEST['section']) ? $default_current_section : urldecode($_REQUEST['section']); |
|
| 1141 | 1141 | |
| 1142 | 1142 | // Output. |
| 1143 | 1143 | return $current_section; |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | */ |
| 1152 | 1152 | function give_get_current_setting_page() { |
| 1153 | 1153 | // Get current page. |
| 1154 | - $setting_page = ! empty( $_GET['page'] ) ? urldecode( $_GET['page'] ) : ''; |
|
| 1154 | + $setting_page = ! empty($_GET['page']) ? urldecode($_GET['page']) : ''; |
|
| 1155 | 1155 | |
| 1156 | 1156 | // Output. |
| 1157 | 1157 | return $setting_page; |
@@ -1171,13 +1171,13 @@ discard block |
||
| 1171 | 1171 | * |
| 1172 | 1172 | * @return string |
| 1173 | 1173 | */ |
| 1174 | -function _give_display_content_field_value( $field_value, $field, $postid ) { |
|
| 1175 | - $show_content = give_get_meta( $postid, '_give_content_option', true ); |
|
| 1174 | +function _give_display_content_field_value($field_value, $field, $postid) { |
|
| 1175 | + $show_content = give_get_meta($postid, '_give_content_option', true); |
|
| 1176 | 1176 | |
| 1177 | 1177 | if ( |
| 1178 | - ! give_get_meta( $postid, '_give_display_content', true ) |
|
| 1178 | + ! give_get_meta($postid, '_give_display_content', true) |
|
| 1179 | 1179 | && $show_content |
| 1180 | - && ( 'none' !== $show_content ) |
|
| 1180 | + && ('none' !== $show_content) |
|
| 1181 | 1181 | ) { |
| 1182 | 1182 | $field_value = 'enabled'; |
| 1183 | 1183 | } |
@@ -1185,7 +1185,7 @@ discard block |
||
| 1185 | 1185 | return $field_value; |
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | -add_filter( '_give_display_content_field_value', '_give_display_content_field_value', 10, 3 ); |
|
| 1188 | +add_filter('_give_display_content_field_value', '_give_display_content_field_value', 10, 3); |
|
| 1189 | 1189 | |
| 1190 | 1190 | |
| 1191 | 1191 | /** |
@@ -1202,12 +1202,12 @@ discard block |
||
| 1202 | 1202 | * |
| 1203 | 1203 | * @return string |
| 1204 | 1204 | */ |
| 1205 | -function _give_content_placement_field_value( $field_value, $field, $postid ) { |
|
| 1206 | - $show_content = give_get_meta( $postid, '_give_content_option', true ); |
|
| 1205 | +function _give_content_placement_field_value($field_value, $field, $postid) { |
|
| 1206 | + $show_content = give_get_meta($postid, '_give_content_option', true); |
|
| 1207 | 1207 | |
| 1208 | 1208 | if ( |
| 1209 | - ! give_get_meta( $postid, '_give_content_placement', true ) |
|
| 1210 | - && ( 'none' !== $show_content ) |
|
| 1209 | + ! give_get_meta($postid, '_give_content_placement', true) |
|
| 1210 | + && ('none' !== $show_content) |
|
| 1211 | 1211 | ) { |
| 1212 | 1212 | $field_value = $show_content; |
| 1213 | 1213 | } |
@@ -1215,7 +1215,7 @@ discard block |
||
| 1215 | 1215 | return $field_value; |
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | -add_filter( '_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3 ); |
|
| 1218 | +add_filter('_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3); |
|
| 1219 | 1219 | |
| 1220 | 1220 | |
| 1221 | 1221 | /** |
@@ -1231,17 +1231,17 @@ discard block |
||
| 1231 | 1231 | * |
| 1232 | 1232 | * @return string |
| 1233 | 1233 | */ |
| 1234 | -function _give_terms_option_field_value( $field_value, $field, $postid ) { |
|
| 1235 | - $term_option = give_get_meta( $postid, '_give_terms_option', true ); |
|
| 1234 | +function _give_terms_option_field_value($field_value, $field, $postid) { |
|
| 1235 | + $term_option = give_get_meta($postid, '_give_terms_option', true); |
|
| 1236 | 1236 | |
| 1237 | - if ( in_array( $term_option, array( 'none', 'yes' ) ) ) { |
|
| 1238 | - $field_value = ( 'yes' === $term_option ? 'enabled' : 'disabled' ); |
|
| 1237 | + if (in_array($term_option, array('none', 'yes'))) { |
|
| 1238 | + $field_value = ('yes' === $term_option ? 'enabled' : 'disabled'); |
|
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | 1241 | return $field_value; |
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | -add_filter( '_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3 ); |
|
| 1244 | +add_filter('_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3); |
|
| 1245 | 1245 | |
| 1246 | 1246 | |
| 1247 | 1247 | /** |
@@ -1258,17 +1258,17 @@ discard block |
||
| 1258 | 1258 | * |
| 1259 | 1259 | * @return string |
| 1260 | 1260 | */ |
| 1261 | -function _give_offline_donation_enable_billing_fields_single_field_value( $field_value, $field, $postid ) { |
|
| 1262 | - $offline_donation = give_get_meta( $postid, '_give_offline_donation_enable_billing_fields_single', true ); |
|
| 1261 | +function _give_offline_donation_enable_billing_fields_single_field_value($field_value, $field, $postid) { |
|
| 1262 | + $offline_donation = give_get_meta($postid, '_give_offline_donation_enable_billing_fields_single', true); |
|
| 1263 | 1263 | |
| 1264 | - if ( 'on' === $offline_donation ) { |
|
| 1264 | + if ('on' === $offline_donation) { |
|
| 1265 | 1265 | $field_value = 'enabled'; |
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | return $field_value; |
| 1269 | 1269 | } |
| 1270 | 1270 | |
| 1271 | -add_filter( '_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3 ); |
|
| 1271 | +add_filter('_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3); |
|
| 1272 | 1272 | |
| 1273 | 1273 | |
| 1274 | 1274 | /** |
@@ -1284,17 +1284,17 @@ discard block |
||
| 1284 | 1284 | * |
| 1285 | 1285 | * @return string |
| 1286 | 1286 | */ |
| 1287 | -function _give_custom_amount_field_value( $field_value, $field, $postid ) { |
|
| 1288 | - $custom_amount = give_get_meta( $postid, '_give_custom_amount', true ); |
|
| 1287 | +function _give_custom_amount_field_value($field_value, $field, $postid) { |
|
| 1288 | + $custom_amount = give_get_meta($postid, '_give_custom_amount', true); |
|
| 1289 | 1289 | |
| 1290 | - if ( in_array( $custom_amount, array( 'yes', 'no' ) ) ) { |
|
| 1291 | - $field_value = ( 'yes' === $custom_amount ? 'enabled' : 'disabled' ); |
|
| 1290 | + if (in_array($custom_amount, array('yes', 'no'))) { |
|
| 1291 | + $field_value = ('yes' === $custom_amount ? 'enabled' : 'disabled'); |
|
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | 1294 | return $field_value; |
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | -add_filter( '_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3 ); |
|
| 1297 | +add_filter('_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3); |
|
| 1298 | 1298 | |
| 1299 | 1299 | |
| 1300 | 1300 | /** |
@@ -1310,17 +1310,17 @@ discard block |
||
| 1310 | 1310 | * |
| 1311 | 1311 | * @return string |
| 1312 | 1312 | */ |
| 1313 | -function _give_goal_option_field_value( $field_value, $field, $postid ) { |
|
| 1314 | - $goal_option = give_get_meta( $postid, '_give_goal_option', true ); |
|
| 1313 | +function _give_goal_option_field_value($field_value, $field, $postid) { |
|
| 1314 | + $goal_option = give_get_meta($postid, '_give_goal_option', true); |
|
| 1315 | 1315 | |
| 1316 | - if ( in_array( $goal_option, array( 'yes', 'no' ) ) ) { |
|
| 1317 | - $field_value = ( 'yes' === $goal_option ? 'enabled' : 'disabled' ); |
|
| 1316 | + if (in_array($goal_option, array('yes', 'no'))) { |
|
| 1317 | + $field_value = ('yes' === $goal_option ? 'enabled' : 'disabled'); |
|
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | return $field_value; |
| 1321 | 1321 | } |
| 1322 | 1322 | |
| 1323 | -add_filter( '_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3 ); |
|
| 1323 | +add_filter('_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3); |
|
| 1324 | 1324 | |
| 1325 | 1325 | /** |
| 1326 | 1326 | * Set value for Donation Goal --> close Form. |
@@ -1336,17 +1336,17 @@ discard block |
||
| 1336 | 1336 | * |
| 1337 | 1337 | * @return string |
| 1338 | 1338 | */ |
| 1339 | -function _give_close_form_when_goal_achieved_value( $field_value, $field, $postid ) { |
|
| 1340 | - $close_form = give_get_meta( $postid, '_give_close_form_when_goal_achieved', true ); |
|
| 1339 | +function _give_close_form_when_goal_achieved_value($field_value, $field, $postid) { |
|
| 1340 | + $close_form = give_get_meta($postid, '_give_close_form_when_goal_achieved', true); |
|
| 1341 | 1341 | |
| 1342 | - if ( in_array( $close_form, array( 'yes', 'no' ) ) ) { |
|
| 1343 | - $field_value = ( 'yes' === $close_form ? 'enabled' : 'disabled' ); |
|
| 1342 | + if (in_array($close_form, array('yes', 'no'))) { |
|
| 1343 | + $field_value = ('yes' === $close_form ? 'enabled' : 'disabled'); |
|
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | 1346 | return $field_value; |
| 1347 | 1347 | } |
| 1348 | 1348 | |
| 1349 | -add_filter( '_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3 ); |
|
| 1349 | +add_filter('_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3); |
|
| 1350 | 1350 | |
| 1351 | 1351 | |
| 1352 | 1352 | /** |
@@ -1362,17 +1362,17 @@ discard block |
||
| 1362 | 1362 | * |
| 1363 | 1363 | * @return string |
| 1364 | 1364 | */ |
| 1365 | -function _give_logged_in_only_value( $field_value, $field, $postid ) { |
|
| 1366 | - $guest_donation = give_get_meta( $postid, '_give_logged_in_only', true ); |
|
| 1365 | +function _give_logged_in_only_value($field_value, $field, $postid) { |
|
| 1366 | + $guest_donation = give_get_meta($postid, '_give_logged_in_only', true); |
|
| 1367 | 1367 | |
| 1368 | - if ( in_array( $guest_donation, array( 'yes', 'no' ) ) ) { |
|
| 1369 | - $field_value = ( 'yes' === $guest_donation ? 'enabled' : 'disabled' ); |
|
| 1368 | + if (in_array($guest_donation, array('yes', 'no'))) { |
|
| 1369 | + $field_value = ('yes' === $guest_donation ? 'enabled' : 'disabled'); |
|
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | 1372 | return $field_value; |
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | -add_filter( '_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3 ); |
|
| 1375 | +add_filter('_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3); |
|
| 1376 | 1376 | |
| 1377 | 1377 | /** |
| 1378 | 1378 | * Set value for Offline Donations --> Offline Donations. |
@@ -1388,17 +1388,17 @@ discard block |
||
| 1388 | 1388 | * |
| 1389 | 1389 | * @return string |
| 1390 | 1390 | */ |
| 1391 | -function _give_customize_offline_donations_value( $field_value, $field, $postid ) { |
|
| 1392 | - $customize_offline_text = give_get_meta( $postid, '_give_customize_offline_donations', true ); |
|
| 1391 | +function _give_customize_offline_donations_value($field_value, $field, $postid) { |
|
| 1392 | + $customize_offline_text = give_get_meta($postid, '_give_customize_offline_donations', true); |
|
| 1393 | 1393 | |
| 1394 | - if ( in_array( $customize_offline_text, array( 'yes', 'no' ) ) ) { |
|
| 1395 | - $field_value = ( 'yes' === $customize_offline_text ? 'enabled' : 'disabled' ); |
|
| 1394 | + if (in_array($customize_offline_text, array('yes', 'no'))) { |
|
| 1395 | + $field_value = ('yes' === $customize_offline_text ? 'enabled' : 'disabled'); |
|
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | 1398 | return $field_value; |
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | -add_filter( '_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3 ); |
|
| 1401 | +add_filter('_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3); |
|
| 1402 | 1402 | |
| 1403 | 1403 | |
| 1404 | 1404 | /** |
@@ -1413,14 +1413,14 @@ discard block |
||
| 1413 | 1413 | * |
| 1414 | 1414 | * @return mixed |
| 1415 | 1415 | */ |
| 1416 | -function _give_set_multi_level_repeater_field_id( $field_id, $field, $fields, $default ) { |
|
| 1416 | +function _give_set_multi_level_repeater_field_id($field_id, $field, $fields, $default) { |
|
| 1417 | 1417 | $row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}'; |
| 1418 | 1418 | $field_id = "{$fields['id']}[{$row_placeholder}][{$field['id']}][level_id]"; |
| 1419 | 1419 | |
| 1420 | 1420 | return $field_id; |
| 1421 | 1421 | } |
| 1422 | 1422 | |
| 1423 | -add_filter( 'give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4 ); |
|
| 1423 | +add_filter('give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4); |
|
| 1424 | 1424 | |
| 1425 | 1425 | /** |
| 1426 | 1426 | * Set repeater field value for multi donation form. |
@@ -1434,13 +1434,13 @@ discard block |
||
| 1434 | 1434 | * |
| 1435 | 1435 | * @return mixed |
| 1436 | 1436 | */ |
| 1437 | -function _give_set_multi_level_repeater_field_value( $field_value, $field, $field_group, $fields ) { |
|
| 1438 | - $field_value = $field_group[ $field['id'] ]['level_id']; |
|
| 1437 | +function _give_set_multi_level_repeater_field_value($field_value, $field, $field_group, $fields) { |
|
| 1438 | + $field_value = $field_group[$field['id']]['level_id']; |
|
| 1439 | 1439 | |
| 1440 | 1440 | return $field_value; |
| 1441 | 1441 | } |
| 1442 | 1442 | |
| 1443 | -add_filter( 'give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4 ); |
|
| 1443 | +add_filter('give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4); |
|
| 1444 | 1444 | |
| 1445 | 1445 | /** |
| 1446 | 1446 | * Set default value for _give_id field. |
@@ -1451,11 +1451,11 @@ discard block |
||
| 1451 | 1451 | * |
| 1452 | 1452 | * @return string |
| 1453 | 1453 | */ |
| 1454 | -function _give_set_field_give_id_default_value( $field ) { |
|
| 1454 | +function _give_set_field_give_id_default_value($field) { |
|
| 1455 | 1455 | return 0; |
| 1456 | 1456 | } |
| 1457 | 1457 | |
| 1458 | -add_filter( 'give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value' ); |
|
| 1458 | +add_filter('give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value'); |
|
| 1459 | 1459 | |
| 1460 | 1460 | /** |
| 1461 | 1461 | * Set default value for _give_default field. |
@@ -1466,11 +1466,11 @@ discard block |
||
| 1466 | 1466 | * |
| 1467 | 1467 | * @return string |
| 1468 | 1468 | */ |
| 1469 | -function _give_set_field_give_default_default_value( $field ) { |
|
| 1469 | +function _give_set_field_give_default_default_value($field) { |
|
| 1470 | 1470 | return 'default'; |
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | -add_filter( 'give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value' ); |
|
| 1473 | +add_filter('give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value'); |
|
| 1474 | 1474 | |
| 1475 | 1475 | /** |
| 1476 | 1476 | * Set repeater field editor id for field type wysiwyg. |
@@ -1482,12 +1482,12 @@ discard block |
||
| 1482 | 1482 | * |
| 1483 | 1483 | * @return string |
| 1484 | 1484 | */ |
| 1485 | -function give_repeater_field_set_editor_id( $field_name, $field ) { |
|
| 1486 | - if ( isset( $field['repeatable_field_id'] ) && 'wysiwyg' == $field['type'] ) { |
|
| 1487 | - $field_name = '_give_repeater_' . uniqid() . '_wysiwyg'; |
|
| 1485 | +function give_repeater_field_set_editor_id($field_name, $field) { |
|
| 1486 | + if (isset($field['repeatable_field_id']) && 'wysiwyg' == $field['type']) { |
|
| 1487 | + $field_name = '_give_repeater_'.uniqid().'_wysiwyg'; |
|
| 1488 | 1488 | } |
| 1489 | 1489 | |
| 1490 | 1490 | return $field_name; |
| 1491 | 1491 | } |
| 1492 | 1492 | |
| 1493 | -add_filter( 'give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2 ); |
|
| 1493 | +add_filter('give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2); |
|