@@ -733,9 +733,9 @@ |
||
| 733 | 733 | <td class="give-docs-link" colspan="2"> |
| 734 | 734 | <?php |
| 735 | 735 | echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
| 736 | - . '" target="_blank">' |
|
| 737 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
| 738 | - . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
| 736 | + . '" target="_blank">' |
|
| 737 | + . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
| 738 | + . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
| 739 | 739 | ?> |
| 740 | 740 | </td> |
| 741 | 741 | </tr><?php |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Admin_Settings' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Admin_Settings')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Admin_Settings Class. |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param array $settings Array of settings class object. |
| 74 | 74 | */ |
| 75 | - self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() ); |
|
| 75 | + self::$settings = apply_filters(self::$setting_filter_prefix.'_get_settings_pages', array()); |
|
| 76 | 76 | |
| 77 | 77 | return self::$settings; |
| 78 | 78 | } |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | public static function save() { |
| 87 | 87 | $current_tab = give_get_current_setting_tab(); |
| 88 | 88 | |
| 89 | - if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) { |
|
| 90 | - echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>'; |
|
| 89 | + if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) { |
|
| 90 | + echo '<div class="notice error"><p>'.__('Action failed. Please refresh the page and retry.', 'give').'</p></div>'; |
|
| 91 | 91 | die(); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @since 1.8 |
| 102 | 102 | */ |
| 103 | - do_action( self::$setting_filter_prefix . '_save_' . $current_tab ); |
|
| 103 | + do_action(self::$setting_filter_prefix.'_save_'.$current_tab); |
|
| 104 | 104 | |
| 105 | - self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) ); |
|
| 105 | + self::add_message('give-setting-updated', __('Your settings have been saved.', 'give')); |
|
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * Trigger Action. |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @since 1.8 |
| 115 | 115 | */ |
| 116 | - do_action( self::$setting_filter_prefix . '_saved' ); |
|
| 116 | + do_action(self::$setting_filter_prefix.'_saved'); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return void |
| 128 | 128 | */ |
| 129 | - public static function add_message( $code, $message ) { |
|
| 130 | - self::$messages[ $code ] = $message; |
|
| 129 | + public static function add_message($code, $message) { |
|
| 130 | + self::$messages[$code] = $message; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @return void |
| 142 | 142 | */ |
| 143 | - public static function add_error( $code, $message ) { |
|
| 144 | - self::$errors[ $code ] = $message; |
|
| 143 | + public static function add_error($code, $message) { |
|
| 144 | + self::$errors[$code] = $message; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -154,18 +154,18 @@ discard block |
||
| 154 | 154 | $notice_html = ''; |
| 155 | 155 | $classes = 'give-notice settings-error notice is-dismissible'; |
| 156 | 156 | |
| 157 | - self::$errors = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors ); |
|
| 158 | - self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages ); |
|
| 157 | + self::$errors = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors); |
|
| 158 | + self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages); |
|
| 159 | 159 | |
| 160 | - if ( 0 < count( self::$errors ) ) { |
|
| 161 | - foreach ( self::$errors as $code => $message ) { |
|
| 162 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' error"><p><strong>' . $message . '</strong></p></div>'; |
|
| 160 | + if (0 < count(self::$errors)) { |
|
| 161 | + foreach (self::$errors as $code => $message) { |
|
| 162 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' error"><p><strong>'.$message.'</strong></p></div>'; |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if ( 0 < count( self::$messages ) ) { |
|
| 167 | - foreach ( self::$messages as $code => $message ) { |
|
| 168 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' updated"><p><strong>' . $message . '</strong></p></div>'; |
|
| 166 | + if (0 < count(self::$messages)) { |
|
| 167 | + foreach (self::$messages as $code => $message) { |
|
| 168 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' updated"><p><strong>'.$message.'</strong></p></div>'; |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | self::$setting_filter_prefix = give_get_current_setting_page(); |
| 186 | 186 | |
| 187 | 187 | // Bailout: Exit if setting page is not defined. |
| 188 | - if ( empty( self::$setting_filter_prefix ) ) { |
|
| 188 | + if (empty(self::$setting_filter_prefix)) { |
|
| 189 | 189 | return false; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @since 1.8 |
| 200 | 200 | */ |
| 201 | - do_action( self::$setting_filter_prefix . '_start' ); |
|
| 201 | + do_action(self::$setting_filter_prefix.'_start'); |
|
| 202 | 202 | |
| 203 | 203 | $current_tab = give_get_current_setting_tab(); |
| 204 | 204 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | self::get_settings_pages(); |
| 207 | 207 | |
| 208 | 208 | // Save settings if data has been posted. |
| 209 | - if ( ! empty( $_POST ) ) { |
|
| 209 | + if ( ! empty($_POST)) { |
|
| 210 | 210 | self::save(); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @since 1.8 |
| 221 | 221 | */ |
| 222 | - $tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() ); |
|
| 222 | + $tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array()); |
|
| 223 | 223 | |
| 224 | 224 | include 'views/html-admin-settings.php'; |
| 225 | 225 | |
@@ -237,25 +237,25 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @return string|bool |
| 239 | 239 | */ |
| 240 | - public static function get_option( $option_name = '', $field_id = '', $default = false ) { |
|
| 240 | + public static function get_option($option_name = '', $field_id = '', $default = false) { |
|
| 241 | 241 | // Bailout. |
| 242 | - if ( empty( $option_name ) && empty( $field_id ) ) { |
|
| 242 | + if (empty($option_name) && empty($field_id)) { |
|
| 243 | 243 | return false; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if ( ! empty( $field_id ) && ! empty( $option_name ) ) { |
|
| 246 | + if ( ! empty($field_id) && ! empty($option_name)) { |
|
| 247 | 247 | // Get field value if any. |
| 248 | - $option_value = get_option( $option_name ); |
|
| 248 | + $option_value = get_option($option_name); |
|
| 249 | 249 | |
| 250 | - $option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) ) |
|
| 251 | - ? $option_value[ $field_id ] |
|
| 250 | + $option_value = (is_array($option_value) && array_key_exists($field_id, $option_value)) |
|
| 251 | + ? $option_value[$field_id] |
|
| 252 | 252 | : $default; |
| 253 | 253 | } else { |
| 254 | 254 | // If option name is empty but not field name then this means, setting is direct store to option table under there field name. |
| 255 | 255 | $option_name = ! $option_name ? $field_id : $option_name; |
| 256 | 256 | |
| 257 | 257 | // Get option value if any. |
| 258 | - $option_value = get_option( $option_name, $default ); |
|
| 258 | + $option_value = get_option($option_name, $default); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | return $option_value; |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @return void |
| 275 | 275 | */ |
| 276 | - public static function output_fields( $options, $option_name = '' ) { |
|
| 276 | + public static function output_fields($options, $option_name = '') { |
|
| 277 | 277 | $current_tab = give_get_current_setting_tab(); |
| 278 | 278 | |
| 279 | 279 | // Field Default values. |
@@ -286,52 +286,52 @@ discard block |
||
| 286 | 286 | 'table_html' => true, |
| 287 | 287 | ); |
| 288 | 288 | |
| 289 | - foreach ( $options as $value ) { |
|
| 290 | - if ( ! isset( $value['type'] ) ) { |
|
| 289 | + foreach ($options as $value) { |
|
| 290 | + if ( ! isset($value['type'])) { |
|
| 291 | 291 | continue; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | // Set title. |
| 295 | - $defaults['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
| 295 | + $defaults['title'] = isset($value['name']) ? $value['name'] : ''; |
|
| 296 | 296 | |
| 297 | 297 | // Set default setting. |
| 298 | - $value = wp_parse_args( $value, $defaults ); |
|
| 298 | + $value = wp_parse_args($value, $defaults); |
|
| 299 | 299 | |
| 300 | 300 | // Colorpicker field. |
| 301 | - $value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] ); |
|
| 302 | - $value['type'] = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] ); |
|
| 301 | + $value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']); |
|
| 302 | + $value['type'] = ('colorpicker' === $value['type'] ? 'text' : $value['type']); |
|
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | // Custom attribute handling. |
| 306 | 306 | $custom_attributes = array(); |
| 307 | 307 | |
| 308 | - if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) { |
|
| 309 | - foreach ( $value['attributes'] as $attribute => $attribute_value ) { |
|
| 310 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
| 308 | + if ( ! empty($value['attributes']) && is_array($value['attributes'])) { |
|
| 309 | + foreach ($value['attributes'] as $attribute => $attribute_value) { |
|
| 310 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | // Description handling. |
| 315 | - $description = self::get_field_description( $value ); |
|
| 315 | + $description = self::get_field_description($value); |
|
| 316 | 316 | |
| 317 | 317 | // Switch based on type. |
| 318 | - switch ( $value['type'] ) { |
|
| 318 | + switch ($value['type']) { |
|
| 319 | 319 | |
| 320 | 320 | // Section Titles |
| 321 | 321 | case 'title': |
| 322 | - if ( ! empty( $value['title'] ) ) { |
|
| 323 | - echo '<div class="give-setting-tab-header give-setting-tab-header-' . $current_tab . '"><h2>' . self::get_field_title( $value ) . '</h2><hr></div>'; |
|
| 322 | + if ( ! empty($value['title'])) { |
|
| 323 | + echo '<div class="give-setting-tab-header give-setting-tab-header-'.$current_tab.'"><h2>'.self::get_field_title($value).'</h2><hr></div>'; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if ( ! empty( $value['desc'] ) ) { |
|
| 327 | - echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); |
|
| 326 | + if ( ! empty($value['desc'])) { |
|
| 327 | + echo wpautop(wptexturize(wp_kses_post($value['desc']))); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if ( $value['table_html'] ) { |
|
| 331 | - echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n"; |
|
| 330 | + if ($value['table_html']) { |
|
| 331 | + echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n"; |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - if ( ! empty( $value['id'] ) ) { |
|
| 334 | + if ( ! empty($value['id'])) { |
|
| 335 | 335 | |
| 336 | 336 | /** |
| 337 | 337 | * Trigger Action. |
@@ -340,14 +340,14 @@ discard block |
||
| 340 | 340 | * |
| 341 | 341 | * @since 1.8 |
| 342 | 342 | */ |
| 343 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) ); |
|
| 343 | + do_action('give_settings_'.sanitize_title($value['id'])); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | break; |
| 347 | 347 | |
| 348 | 348 | // Section Ends. |
| 349 | 349 | case 'sectionend': |
| 350 | - if ( ! empty( $value['id'] ) ) { |
|
| 350 | + if ( ! empty($value['id'])) { |
|
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | 353 | * Trigger Action. |
@@ -356,14 +356,14 @@ discard block |
||
| 356 | 356 | * |
| 357 | 357 | * @since 1.8 |
| 358 | 358 | */ |
| 359 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
| 359 | + do_action('give_settings_'.sanitize_title($value['id']).'_end'); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - if ( $value['table_html'] ) { |
|
| 362 | + if ($value['table_html']) { |
|
| 363 | 363 | echo '</table>'; |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - if ( ! empty( $value['id'] ) ) { |
|
| 366 | + if ( ! empty($value['id'])) { |
|
| 367 | 367 | |
| 368 | 368 | /** |
| 369 | 369 | * Trigger Action. |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | * |
| 373 | 373 | * @since 1.8 |
| 374 | 374 | */ |
| 375 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
| 375 | + do_action('give_settings_'.sanitize_title($value['id']).'_after'); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | break; |
@@ -385,22 +385,22 @@ discard block |
||
| 385 | 385 | case 'password' : |
| 386 | 386 | |
| 387 | 387 | $type = $value['type']; |
| 388 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 388 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 389 | 389 | |
| 390 | 390 | ?> |
| 391 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 391 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 392 | 392 | <th scope="row" class="titledesc"> |
| 393 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 393 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 394 | 394 | </th> |
| 395 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 395 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 396 | 396 | <input |
| 397 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 398 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 399 | - type="<?php echo esc_attr( $type ); ?>" |
|
| 400 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 401 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
| 402 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
| 403 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 397 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 398 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 399 | + type="<?php echo esc_attr($type); ?>" |
|
| 400 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 401 | + value="<?php echo esc_attr($option_value); ?>" |
|
| 402 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
| 403 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 404 | 404 | /> <?php echo $description; ?> |
| 405 | 405 | </td> |
| 406 | 406 | </tr><?php |
@@ -409,23 +409,23 @@ discard block |
||
| 409 | 409 | // Textarea. |
| 410 | 410 | case 'textarea': |
| 411 | 411 | |
| 412 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 412 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 413 | 413 | |
| 414 | 414 | ?> |
| 415 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 415 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 416 | 416 | <th scope="row" class="titledesc"> |
| 417 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 417 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 418 | 418 | </th> |
| 419 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 419 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 420 | 420 | <textarea |
| 421 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 422 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 423 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 424 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 421 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 422 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 423 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 424 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 425 | 425 | rows="10" |
| 426 | 426 | cols="60" |
| 427 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 428 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
| 427 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 428 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
| 429 | 429 | <?php echo $description; ?> |
| 430 | 430 | </td> |
| 431 | 431 | </tr><?php |
@@ -435,35 +435,35 @@ discard block |
||
| 435 | 435 | case 'select' : |
| 436 | 436 | case 'multiselect' : |
| 437 | 437 | |
| 438 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 438 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 439 | 439 | |
| 440 | 440 | ?> |
| 441 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 441 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 442 | 442 | <th scope="row" class="titledesc"> |
| 443 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 443 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 444 | 444 | </th> |
| 445 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 445 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 446 | 446 | <select |
| 447 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) { |
|
| 447 | + name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') { |
|
| 448 | 448 | echo '[]'; |
| 449 | 449 | } ?>" |
| 450 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 451 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 452 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 453 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 454 | - <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?> |
|
| 450 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 451 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 452 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 453 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 454 | + <?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?> |
|
| 455 | 455 | > |
| 456 | 456 | |
| 457 | 457 | <?php |
| 458 | - if ( ! empty( $value['options'] ) ) { |
|
| 459 | - foreach ( $value['options'] as $key => $val ) { |
|
| 458 | + if ( ! empty($value['options'])) { |
|
| 459 | + foreach ($value['options'] as $key => $val) { |
|
| 460 | 460 | ?> |
| 461 | - <option value="<?php echo esc_attr( $key ); ?>" <?php |
|
| 461 | + <option value="<?php echo esc_attr($key); ?>" <?php |
|
| 462 | 462 | |
| 463 | - if ( is_array( $option_value ) ) { |
|
| 464 | - selected( in_array( $key, $option_value ), true ); |
|
| 463 | + if (is_array($option_value)) { |
|
| 464 | + selected(in_array($key, $option_value), true); |
|
| 465 | 465 | } else { |
| 466 | - selected( $option_value, $key ); |
|
| 466 | + selected($option_value, $key); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | ?>><?php echo $val ?></option> |
@@ -479,28 +479,28 @@ discard block |
||
| 479 | 479 | |
| 480 | 480 | // Radio inputs. |
| 481 | 481 | case 'radio_inline' : |
| 482 | - $value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline'; |
|
| 482 | + $value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline'; |
|
| 483 | 483 | case 'radio' : |
| 484 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 484 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 485 | 485 | ?> |
| 486 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 486 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 487 | 487 | <th scope="row" class="titledesc"> |
| 488 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 488 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 489 | 489 | </th> |
| 490 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
| 490 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
| 491 | 491 | <fieldset> |
| 492 | 492 | <ul> |
| 493 | 493 | <?php |
| 494 | - foreach ( $value['options'] as $key => $val ) { |
|
| 494 | + foreach ($value['options'] as $key => $val) { |
|
| 495 | 495 | ?> |
| 496 | 496 | <li> |
| 497 | 497 | <label><input |
| 498 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 498 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 499 | 499 | value="<?php echo $key; ?>" |
| 500 | 500 | type="radio" |
| 501 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 502 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 503 | - <?php checked( $key, $option_value ); ?> |
|
| 501 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 502 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 503 | + <?php checked($key, $option_value); ?> |
|
| 504 | 504 | /> <?php echo $val ?></label> |
| 505 | 505 | </li> |
| 506 | 506 | <?php |
@@ -514,21 +514,21 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | // Checkbox input. |
| 516 | 516 | case 'checkbox' : |
| 517 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 517 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 518 | 518 | ?> |
| 519 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 519 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 520 | 520 | <th scope="row" class="titledesc"> |
| 521 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 521 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 522 | 522 | </th> |
| 523 | 523 | <td class="give-forminp"> |
| 524 | 524 | <input |
| 525 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 526 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 525 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 526 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 527 | 527 | type="checkbox" |
| 528 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
| 528 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
| 529 | 529 | value="1" |
| 530 | - <?php checked( $option_value, 'on' ); ?> |
|
| 531 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 530 | + <?php checked($option_value, 'on'); ?> |
|
| 531 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 532 | 532 | /> |
| 533 | 533 | <?php echo $description; ?> |
| 534 | 534 | </td> |
@@ -538,28 +538,28 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | // Multi Checkbox input. |
| 540 | 540 | case 'multicheck' : |
| 541 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 542 | - $option_value = is_array( $option_value ) ? $option_value : array(); |
|
| 541 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 542 | + $option_value = is_array($option_value) ? $option_value : array(); |
|
| 543 | 543 | ?> |
| 544 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 544 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 545 | 545 | <th scope="row" class="titledesc"> |
| 546 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 546 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 547 | 547 | </th> |
| 548 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
| 548 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
| 549 | 549 | <fieldset> |
| 550 | 550 | <ul> |
| 551 | 551 | <?php |
| 552 | - foreach ( $value['options'] as $key => $val ) { |
|
| 552 | + foreach ($value['options'] as $key => $val) { |
|
| 553 | 553 | ?> |
| 554 | 554 | <li> |
| 555 | 555 | <label> |
| 556 | 556 | <input |
| 557 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
| 557 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
| 558 | 558 | value="<?php echo $key; ?>" |
| 559 | 559 | type="checkbox" |
| 560 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 561 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 562 | - <?php if ( in_array( $key, $option_value ) ) { |
|
| 560 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 561 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 562 | + <?php if (in_array($key, $option_value)) { |
|
| 563 | 563 | echo 'checked="checked"'; |
| 564 | 564 | } ?> |
| 565 | 565 | /> <?php echo $val ?> |
@@ -577,25 +577,25 @@ discard block |
||
| 577 | 577 | |
| 578 | 578 | // File input field. |
| 579 | 579 | case 'file' : |
| 580 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 580 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 581 | 581 | ?> |
| 582 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 582 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 583 | 583 | <th scope="row" class="titledesc"> |
| 584 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 584 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 585 | 585 | </th> |
| 586 | 586 | <td class="give-forminp"> |
| 587 | 587 | <div class="give-field-wrap"> |
| 588 | 588 | <label for="<?php echo $value['id'] ?>"> |
| 589 | 589 | <input |
| 590 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 591 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 590 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 591 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 592 | 592 | type="text" |
| 593 | - class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>" |
|
| 593 | + class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>" |
|
| 594 | 594 | value="<?php echo $option_value; ?>" |
| 595 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 596 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 595 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 596 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 597 | 597 | /> <input class="give-upload-button button" type="button" |
| 598 | - value="<?php echo esc_html__( 'Add or Upload File', 'give' ); ?>"> |
|
| 598 | + value="<?php echo esc_html__('Add or Upload File', 'give'); ?>"> |
|
| 599 | 599 | <?php echo $description ?> |
| 600 | 600 | <div class="give-image-thumb<?php echo ! $option_value ? ' give-hidden' : ''; ?>"> |
| 601 | 601 | <span class="give-delete-image-thumb dashicons dashicons-no-alt"></span> |
@@ -610,17 +610,17 @@ discard block |
||
| 610 | 610 | // WordPress Editor. |
| 611 | 611 | case 'wysiwyg' : |
| 612 | 612 | // Get option value. |
| 613 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 613 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 614 | 614 | |
| 615 | 615 | // Get editor settings. |
| 616 | - $editor_settings = ! empty( $value['options'] ) ? $value['options'] : array(); |
|
| 616 | + $editor_settings = ! empty($value['options']) ? $value['options'] : array(); |
|
| 617 | 617 | ?> |
| 618 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 618 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 619 | 619 | <th scope="row" class="titledesc"> |
| 620 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 620 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 621 | 621 | </th> |
| 622 | 622 | <td class="give-forminp"> |
| 623 | - <?php wp_editor( $option_value, $value['id'], $editor_settings ); ?> |
|
| 623 | + <?php wp_editor($option_value, $value['id'], $editor_settings); ?> |
|
| 624 | 624 | <?php echo $description; ?> |
| 625 | 625 | </td> |
| 626 | 626 | </tr><?php |
@@ -629,9 +629,9 @@ discard block |
||
| 629 | 629 | // Custom: System setting field. |
| 630 | 630 | case 'system_info' : |
| 631 | 631 | ?> |
| 632 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 632 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 633 | 633 | <th scope="row" class="titledesc"> |
| 634 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 634 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 635 | 635 | </th> |
| 636 | 636 | <td class="give-forminp"> |
| 637 | 637 | <?php give_system_info_callback(); ?> |
@@ -642,14 +642,14 @@ discard block |
||
| 642 | 642 | |
| 643 | 643 | // Custom: Default gateways setting field. |
| 644 | 644 | case 'default_gateway' : |
| 645 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 645 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 646 | 646 | ?> |
| 647 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 647 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 648 | 648 | <th scope="row" class="titledesc"> |
| 649 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 649 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 650 | 650 | </th> |
| 651 | 651 | <td class="give-forminp"> |
| 652 | - <?php give_default_gateway_callback( $value, $option_value ); ?> |
|
| 652 | + <?php give_default_gateway_callback($value, $option_value); ?> |
|
| 653 | 653 | <?php echo $description; ?> |
| 654 | 654 | </td> |
| 655 | 655 | </tr><?php |
@@ -657,14 +657,14 @@ discard block |
||
| 657 | 657 | |
| 658 | 658 | // Custom: Enable gateways setting field. |
| 659 | 659 | case 'enabled_gateways' : |
| 660 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 660 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 661 | 661 | ?> |
| 662 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 662 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 663 | 663 | <th scope="row" class="titledesc"> |
| 664 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 664 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 665 | 665 | </th> |
| 666 | 666 | <td class="give-forminp"> |
| 667 | - <?php give_enabled_gateways_callback( $value, $option_value ); ?> |
|
| 667 | + <?php give_enabled_gateways_callback($value, $option_value); ?> |
|
| 668 | 668 | <?php echo $description; ?> |
| 669 | 669 | </td> |
| 670 | 670 | </tr><?php |
@@ -673,9 +673,9 @@ discard block |
||
| 673 | 673 | // Custom: Email preview buttons field. |
| 674 | 674 | case 'email_preview_buttons' : |
| 675 | 675 | ?> |
| 676 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 676 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 677 | 677 | <th scope="row" class="titledesc"> |
| 678 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 678 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 679 | 679 | </th> |
| 680 | 680 | <td class="give-forminp"> |
| 681 | 681 | <?php give_email_preview_buttons_callback(); ?> |
@@ -692,22 +692,22 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | // Custom: Gateway API key. |
| 694 | 694 | case 'api_key' : |
| 695 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 696 | - $type = ! empty( $option_value ) ? 'password' : 'text'; |
|
| 695 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 696 | + $type = ! empty($option_value) ? 'password' : 'text'; |
|
| 697 | 697 | ?> |
| 698 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 698 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 699 | 699 | <th scope="row" class="titledesc"> |
| 700 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 700 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 701 | 701 | </th> |
| 702 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 702 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 703 | 703 | <input |
| 704 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 705 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 706 | - type="<?php echo esc_attr( $type ); ?>" |
|
| 707 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 708 | - value="<?php echo esc_attr( trim( $option_value ) ); ?>" |
|
| 709 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
| 710 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 704 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 705 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 706 | + type="<?php echo esc_attr($type); ?>" |
|
| 707 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 708 | + value="<?php echo esc_attr(trim($option_value)); ?>" |
|
| 709 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
| 710 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 711 | 711 | /> <?php echo $description; ?> |
| 712 | 712 | </td> |
| 713 | 713 | </tr><?php |
@@ -729,12 +729,12 @@ discard block |
||
| 729 | 729 | // Custom: Give Docs Link field type. |
| 730 | 730 | case 'give_docs_link' : |
| 731 | 731 | ?> |
| 732 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 732 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 733 | 733 | <td class="give-docs-link" colspan="2"> |
| 734 | 734 | <?php |
| 735 | - echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
|
| 735 | + echo '<p class="give-docs-link"><a href="'.esc_url($value['url']) |
|
| 736 | 736 | . '" target="_blank">' |
| 737 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
| 737 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $value['title']) |
|
| 738 | 738 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
| 739 | 739 | ?> |
| 740 | 740 | </td> |
@@ -745,8 +745,8 @@ discard block |
||
| 745 | 745 | // You can add or handle your custom field action. |
| 746 | 746 | default: |
| 747 | 747 | // Get option value. |
| 748 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 749 | - do_action( 'give_admin_field_' . $value['type'], $value, $option_value ); |
|
| 748 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 749 | + do_action('give_admin_field_'.$value['type'], $value, $option_value); |
|
| 750 | 750 | break; |
| 751 | 751 | } |
| 752 | 752 | } |
@@ -762,15 +762,15 @@ discard block |
||
| 762 | 762 | * |
| 763 | 763 | * @return string The HTML description of the field. |
| 764 | 764 | */ |
| 765 | - public static function get_field_description( $value ) { |
|
| 765 | + public static function get_field_description($value) { |
|
| 766 | 766 | $description = ''; |
| 767 | 767 | |
| 768 | 768 | // Support for both 'description' and 'desc' args. |
| 769 | - $description_key = isset( $value['description'] ) ? 'description' : 'desc'; |
|
| 770 | - $value = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : ''; |
|
| 769 | + $description_key = isset($value['description']) ? 'description' : 'desc'; |
|
| 770 | + $value = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : ''; |
|
| 771 | 771 | |
| 772 | - if ( ! empty( $value ) ) { |
|
| 773 | - $description = '<p class="give-field-description">' . wp_kses_post( $value ) . '</p>'; |
|
| 772 | + if ( ! empty($value)) { |
|
| 773 | + $description = '<p class="give-field-description">'.wp_kses_post($value).'</p>'; |
|
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | return $description; |
@@ -787,11 +787,11 @@ discard block |
||
| 787 | 787 | * |
| 788 | 788 | * @return array The description and tip as a 2 element array |
| 789 | 789 | */ |
| 790 | - public static function get_field_title( $value ) { |
|
| 791 | - $title = esc_html( $value['title'] ); |
|
| 790 | + public static function get_field_title($value) { |
|
| 791 | + $title = esc_html($value['title']); |
|
| 792 | 792 | |
| 793 | 793 | // If html tag detected then allow them to print. |
| 794 | - if ( strip_tags( $title ) ) { |
|
| 794 | + if (strip_tags($title)) { |
|
| 795 | 795 | $title = $value['title']; |
| 796 | 796 | } |
| 797 | 797 | |
@@ -810,8 +810,8 @@ discard block |
||
| 810 | 810 | * |
| 811 | 811 | * @return bool |
| 812 | 812 | */ |
| 813 | - public static function save_fields( $options, $option_name = '' ) { |
|
| 814 | - if ( empty( $_POST ) ) { |
|
| 813 | + public static function save_fields($options, $option_name = '') { |
|
| 814 | + if (empty($_POST)) { |
|
| 815 | 815 | return false; |
| 816 | 816 | } |
| 817 | 817 | |
@@ -819,37 +819,37 @@ discard block |
||
| 819 | 819 | $update_options = array(); |
| 820 | 820 | |
| 821 | 821 | // Loop options and get values to save. |
| 822 | - foreach ( $options as $option ) { |
|
| 823 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
| 822 | + foreach ($options as $option) { |
|
| 823 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
| 824 | 824 | continue; |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | // Get posted value. |
| 828 | - if ( strstr( $option['id'], '[' ) ) { |
|
| 829 | - parse_str( $option['id'], $option_name_array ); |
|
| 830 | - $field_option_name = current( array_keys( $option_name_array ) ); |
|
| 831 | - $setting_name = key( $option_name_array[ $field_option_name ] ); |
|
| 832 | - $raw_value = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null; |
|
| 828 | + if (strstr($option['id'], '[')) { |
|
| 829 | + parse_str($option['id'], $option_name_array); |
|
| 830 | + $field_option_name = current(array_keys($option_name_array)); |
|
| 831 | + $setting_name = key($option_name_array[$field_option_name]); |
|
| 832 | + $raw_value = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null; |
|
| 833 | 833 | } else { |
| 834 | 834 | $field_option_name = $option['id']; |
| 835 | 835 | $setting_name = ''; |
| 836 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
| 836 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | // Format the value based on option type. |
| 840 | - switch ( $option['type'] ) { |
|
| 840 | + switch ($option['type']) { |
|
| 841 | 841 | case 'checkbox' : |
| 842 | - $value = is_null( $raw_value ) ? '' : 'on'; |
|
| 842 | + $value = is_null($raw_value) ? '' : 'on'; |
|
| 843 | 843 | break; |
| 844 | 844 | case 'wysiwyg' : |
| 845 | 845 | case 'textarea' : |
| 846 | - $value = wp_kses_post( trim( $raw_value ) ); |
|
| 846 | + $value = wp_kses_post(trim($raw_value)); |
|
| 847 | 847 | break; |
| 848 | 848 | case 'multiselect' : |
| 849 | - $value = array_filter( array_map( 'give_clean', (array) $raw_value ) ); |
|
| 849 | + $value = array_filter(array_map('give_clean', (array) $raw_value)); |
|
| 850 | 850 | break; |
| 851 | 851 | default : |
| 852 | - $value = give_clean( $raw_value ); |
|
| 852 | + $value = give_clean($raw_value); |
|
| 853 | 853 | break; |
| 854 | 854 | } |
| 855 | 855 | |
@@ -858,37 +858,37 @@ discard block |
||
| 858 | 858 | * |
| 859 | 859 | * @since 1.8 |
| 860 | 860 | */ |
| 861 | - $value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value ); |
|
| 861 | + $value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value); |
|
| 862 | 862 | |
| 863 | 863 | /** |
| 864 | 864 | * Sanitize the value of an option by option name. |
| 865 | 865 | * |
| 866 | 866 | * @since 1.8 |
| 867 | 867 | */ |
| 868 | - $value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value ); |
|
| 868 | + $value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value); |
|
| 869 | 869 | |
| 870 | - if ( is_null( $value ) ) { |
|
| 870 | + if (is_null($value)) { |
|
| 871 | 871 | continue; |
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 874 | // Check if option is an array and handle that differently to single values. |
| 875 | - if ( $field_option_name && $setting_name ) { |
|
| 876 | - if ( ! isset( $update_options[ $field_option_name ] ) ) { |
|
| 877 | - $update_options[ $field_option_name ] = get_option( $field_option_name, array() ); |
|
| 875 | + if ($field_option_name && $setting_name) { |
|
| 876 | + if ( ! isset($update_options[$field_option_name])) { |
|
| 877 | + $update_options[$field_option_name] = get_option($field_option_name, array()); |
|
| 878 | 878 | } |
| 879 | - if ( ! is_array( $update_options[ $field_option_name ] ) ) { |
|
| 880 | - $update_options[ $field_option_name ] = array(); |
|
| 879 | + if ( ! is_array($update_options[$field_option_name])) { |
|
| 880 | + $update_options[$field_option_name] = array(); |
|
| 881 | 881 | } |
| 882 | - $update_options[ $field_option_name ][ $setting_name ] = $value; |
|
| 882 | + $update_options[$field_option_name][$setting_name] = $value; |
|
| 883 | 883 | } else { |
| 884 | - $update_options[ $field_option_name ] = $value; |
|
| 884 | + $update_options[$field_option_name] = $value; |
|
| 885 | 885 | } |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | 888 | // Save all options in our array or there own option name i.e. option id. |
| 889 | - if ( empty( $option_name ) ) { |
|
| 890 | - foreach ( $update_options as $name => $value ) { |
|
| 891 | - update_option( $name, $value ); |
|
| 889 | + if (empty($option_name)) { |
|
| 890 | + foreach ($update_options as $name => $value) { |
|
| 891 | + update_option($name, $value); |
|
| 892 | 892 | |
| 893 | 893 | /** |
| 894 | 894 | * Trigger action. |
@@ -897,13 +897,13 @@ discard block |
||
| 897 | 897 | * |
| 898 | 898 | * @since 1.8 |
| 899 | 899 | */ |
| 900 | - do_action( "give_save_option_{$name}", $value, $name ); |
|
| 900 | + do_action("give_save_option_{$name}", $value, $name); |
|
| 901 | 901 | } |
| 902 | 902 | } else { |
| 903 | - $old_options = ( $old_options = get_option( $option_name ) ) ? $old_options : array(); |
|
| 904 | - $update_options = array_merge( $old_options, $update_options ); |
|
| 903 | + $old_options = ($old_options = get_option($option_name)) ? $old_options : array(); |
|
| 904 | + $update_options = array_merge($old_options, $update_options); |
|
| 905 | 905 | |
| 906 | - update_option( $option_name, $update_options ); |
|
| 906 | + update_option($option_name, $update_options); |
|
| 907 | 907 | |
| 908 | 908 | /** |
| 909 | 909 | * Trigger action. |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | * |
| 913 | 913 | * @since 1.8 |
| 914 | 914 | */ |
| 915 | - do_action( "give_save_settings_{$option_name}", $update_options, $option_name ); |
|
| 915 | + do_action("give_save_settings_{$option_name}", $update_options, $option_name); |
|
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | return true; |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | type="radio" |
| 556 | 556 | style="' . esc_attr( $field['style'] ) . '" |
| 557 | 557 | ' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . ' ' |
| 558 | - . give_get_custom_attributes( $field ) . ' |
|
| 558 | + . give_get_custom_attributes( $field ) . ' |
|
| 559 | 559 | /> ' . esc_html( $value ) . '</label> |
| 560 | 560 | </li>'; |
| 561 | 561 | } |
@@ -704,9 +704,9 @@ discard block |
||
| 704 | 704 | $field['title'] = isset( $field['title'] ) ? $field['title'] : 'Documentation'; |
| 705 | 705 | |
| 706 | 706 | echo '<p class="give-docs-link"><a href="' . esc_url( $field['url'] ) |
| 707 | - . '" target="_blank">' |
|
| 708 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $field['title'] ) |
|
| 709 | - . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
| 707 | + . '" target="_blank">' |
|
| 708 | + . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $field['title'] ) |
|
| 709 | + . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | /** |
@@ -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 give_get_field_name( $field ); ?>"><?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 give_get_field_name($field); ?>"><?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 | |
@@ -617,33 +617,33 @@ discard block |
||
| 617 | 617 | * |
| 618 | 618 | * @param array $field |
| 619 | 619 | */ |
| 620 | -function give_media( $field ) { |
|
| 620 | +function give_media($field) { |
|
| 621 | 621 | global $thepostid, $post; |
| 622 | 622 | |
| 623 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 624 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 625 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 626 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 627 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
| 623 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 624 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 625 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 626 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 627 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
| 628 | 628 | $field['type'] = 'text'; |
| 629 | 629 | $field['attributes']['class'] = "{$field['attributes']['class']} give-text-medium"; |
| 630 | 630 | |
| 631 | 631 | // Allow developer to save attachment ID or attachment url as metadata. |
| 632 | - $field['fvalue'] = isset( $field['fvalue'] ) ? $field['fvalue'] : 'url'; |
|
| 632 | + $field['fvalue'] = isset($field['fvalue']) ? $field['fvalue'] : 'url'; |
|
| 633 | 633 | ?> |
| 634 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
| 635 | - <label for="<?php echo give_get_field_name( $field ) ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
| 634 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
| 635 | + <label for="<?php echo give_get_field_name($field) ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
| 636 | 636 | <input |
| 637 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 638 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
| 637 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 638 | + id="<?php echo esc_attr($field['id']); ?>" |
|
| 639 | 639 | type="text" |
| 640 | 640 | value="<?php echo $field['value']; ?>" |
| 641 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
| 641 | + style="<?php echo esc_attr($field['style']); ?>" |
|
| 642 | 642 | data-fvalue="<?php echo $field['fvalue']; ?>" |
| 643 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 643 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 644 | 644 | /> <input class="give-media-upload button" type="button" |
| 645 | - value="<?php echo esc_html__( 'Add or Upload File', 'give' ); ?>"> |
|
| 646 | - <?php echo give_get_field_description( $field ); ?> |
|
| 645 | + value="<?php echo esc_html__('Add or Upload File', 'give'); ?>"> |
|
| 646 | + <?php echo give_get_field_description($field); ?> |
|
| 647 | 647 | </p> |
| 648 | 648 | <?php |
| 649 | 649 | } |
@@ -657,27 +657,27 @@ discard block |
||
| 657 | 657 | * |
| 658 | 658 | * @return void |
| 659 | 659 | */ |
| 660 | -function give_default_gateway( $field ) { |
|
| 660 | +function give_default_gateway($field) { |
|
| 661 | 661 | global $thepostid, $post; |
| 662 | 662 | |
| 663 | 663 | // get all active payment gateways. |
| 664 | - $gateways = give_get_enabled_payment_gateways( $thepostid ); |
|
| 664 | + $gateways = give_get_enabled_payment_gateways($thepostid); |
|
| 665 | 665 | $field['options'] = array(); |
| 666 | 666 | |
| 667 | 667 | // Set field option value. |
| 668 | - if ( ! empty( $gateways ) ) { |
|
| 669 | - foreach ( $gateways as $key => $option ) { |
|
| 670 | - $field['options'][ $key ] = $option['admin_label']; |
|
| 668 | + if ( ! empty($gateways)) { |
|
| 669 | + foreach ($gateways as $key => $option) { |
|
| 670 | + $field['options'][$key] = $option['admin_label']; |
|
| 671 | 671 | } |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | // Add a field to the Give Form admin single post view of this field |
| 675 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
| 676 | - $field['options'] = array_merge( array( 'global' => esc_html__( 'Global Default', 'give' ) ), $field['options'] ); |
|
| 675 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
| 676 | + $field['options'] = array_merge(array('global' => esc_html__('Global Default', 'give')), $field['options']); |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | // Render select field. |
| 680 | - give_select( $field ); |
|
| 680 | + give_select($field); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | /** |
@@ -699,13 +699,13 @@ discard block |
||
| 699 | 699 | * @return void |
| 700 | 700 | */ |
| 701 | 701 | |
| 702 | -function give_docs_link( $field ) { |
|
| 703 | - $field['url'] = isset( $field['url'] ) ? $field['url'] : 'https://givewp.com/documentation'; |
|
| 704 | - $field['title'] = isset( $field['title'] ) ? $field['title'] : 'Documentation'; |
|
| 702 | +function give_docs_link($field) { |
|
| 703 | + $field['url'] = isset($field['url']) ? $field['url'] : 'https://givewp.com/documentation'; |
|
| 704 | + $field['title'] = isset($field['title']) ? $field['title'] : 'Documentation'; |
|
| 705 | 705 | |
| 706 | - echo '<p class="give-docs-link"><a href="' . esc_url( $field['url'] ) |
|
| 706 | + echo '<p class="give-docs-link"><a href="'.esc_url($field['url']) |
|
| 707 | 707 | . '" target="_blank">' |
| 708 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $field['title'] ) |
|
| 708 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $field['title']) |
|
| 709 | 709 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
| 710 | 710 | } |
| 711 | 711 | |
@@ -721,13 +721,13 @@ discard block |
||
| 721 | 721 | * |
| 722 | 722 | * @return mixed |
| 723 | 723 | */ |
| 724 | -function give_get_field_value( $field, $postid ) { |
|
| 725 | - if ( isset( $field['attributes']['value'] ) ) { |
|
| 724 | +function give_get_field_value($field, $postid) { |
|
| 725 | + if (isset($field['attributes']['value'])) { |
|
| 726 | 726 | return $field['attributes']['value']; |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | // Get value from db. |
| 730 | - $field_value = get_post_meta( $postid, $field['id'], true ); |
|
| 730 | + $field_value = get_post_meta($postid, $field['id'], true); |
|
| 731 | 731 | |
| 732 | 732 | /** |
| 733 | 733 | * Filter the field value before apply default value. |
@@ -736,10 +736,10 @@ discard block |
||
| 736 | 736 | * |
| 737 | 737 | * @param mixed $field_value Field value. |
| 738 | 738 | */ |
| 739 | - $field_value = apply_filters( "{$field['id']}_field_value", $field_value, $field, $postid ); |
|
| 739 | + $field_value = apply_filters("{$field['id']}_field_value", $field_value, $field, $postid); |
|
| 740 | 740 | |
| 741 | 741 | // Set default value if no any data saved to db. |
| 742 | - if ( ! $field_value && isset( $field['default'] ) ) { |
|
| 742 | + if ( ! $field_value && isset($field['default'])) { |
|
| 743 | 743 | $field_value = $field['default']; |
| 744 | 744 | } |
| 745 | 745 | |
@@ -756,10 +756,10 @@ discard block |
||
| 756 | 756 | * |
| 757 | 757 | * @return string |
| 758 | 758 | */ |
| 759 | -function give_get_field_description( $field ) { |
|
| 759 | +function give_get_field_description($field) { |
|
| 760 | 760 | $field_desc_html = ''; |
| 761 | - if ( ! empty( $field['description'] ) ) { |
|
| 762 | - $field_desc_html = '<span class="give-field-description">' . wp_kses_post( $field['description'] ) . '</span>'; |
|
| 761 | + if ( ! empty($field['description'])) { |
|
| 762 | + $field_desc_html = '<span class="give-field-description">'.wp_kses_post($field['description']).'</span>'; |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | return $field_desc_html; |
@@ -775,18 +775,18 @@ discard block |
||
| 775 | 775 | * |
| 776 | 776 | * @return string |
| 777 | 777 | */ |
| 778 | -function give_get_custom_attributes( $field ) { |
|
| 778 | +function give_get_custom_attributes($field) { |
|
| 779 | 779 | // Custom attribute handling |
| 780 | 780 | $custom_attributes = array(); |
| 781 | 781 | |
| 782 | - if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) { |
|
| 782 | + if ( ! empty($field['attributes']) && is_array($field['attributes'])) { |
|
| 783 | 783 | |
| 784 | - foreach ( $field['attributes'] as $attribute => $value ) { |
|
| 785 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; |
|
| 784 | + foreach ($field['attributes'] as $attribute => $value) { |
|
| 785 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"'; |
|
| 786 | 786 | } |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | - return implode( ' ', $custom_attributes ); |
|
| 789 | + return implode(' ', $custom_attributes); |
|
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | /** |
@@ -802,8 +802,8 @@ discard block |
||
| 802 | 802 | * |
| 803 | 803 | * @return string |
| 804 | 804 | */ |
| 805 | -function give_get_repeater_field_value( $field, $field_group, $fields ) { |
|
| 806 | - $field_value = ( isset( $field_group[ $field['id'] ] ) ? $field_group[ $field['id'] ] : '' ); |
|
| 805 | +function give_get_repeater_field_value($field, $field_group, $fields) { |
|
| 806 | + $field_value = (isset($field_group[$field['id']]) ? $field_group[$field['id']] : ''); |
|
| 807 | 807 | |
| 808 | 808 | /** |
| 809 | 809 | * Filter the specific repeater field value |
@@ -812,7 +812,7 @@ discard block |
||
| 812 | 812 | * |
| 813 | 813 | * @param string $field_id |
| 814 | 814 | */ |
| 815 | - $field_value = apply_filters( "give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields ); |
|
| 815 | + $field_value = apply_filters("give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields); |
|
| 816 | 816 | |
| 817 | 817 | /** |
| 818 | 818 | * Filter the repeater field value |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | * |
| 822 | 822 | * @param string $field_id |
| 823 | 823 | */ |
| 824 | - $field_value = apply_filters( 'give_get_repeater_field_value', $field_value, $field, $field_group, $fields ); |
|
| 824 | + $field_value = apply_filters('give_get_repeater_field_value', $field_value, $field, $field_group, $fields); |
|
| 825 | 825 | |
| 826 | 826 | return $field_value; |
| 827 | 827 | } |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | * |
| 840 | 840 | * @return string |
| 841 | 841 | */ |
| 842 | -function give_get_repeater_field_id( $field, $fields, $default = false ) { |
|
| 842 | +function give_get_repeater_field_id($field, $fields, $default = false) { |
|
| 843 | 843 | $row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}'; |
| 844 | 844 | |
| 845 | 845 | // Get field id. |
@@ -852,7 +852,7 @@ discard block |
||
| 852 | 852 | * |
| 853 | 853 | * @param string $field_id |
| 854 | 854 | */ |
| 855 | - $field_id = apply_filters( "give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default ); |
|
| 855 | + $field_id = apply_filters("give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default); |
|
| 856 | 856 | |
| 857 | 857 | /** |
| 858 | 858 | * Filter the repeater field id |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | * |
| 862 | 862 | * @param string $field_id |
| 863 | 863 | */ |
| 864 | - $field_id = apply_filters( 'give_get_repeater_field_id', $field_id, $field, $fields, $default ); |
|
| 864 | + $field_id = apply_filters('give_get_repeater_field_id', $field_id, $field, $fields, $default); |
|
| 865 | 865 | |
| 866 | 866 | return $field_id; |
| 867 | 867 | } |
@@ -876,8 +876,8 @@ discard block |
||
| 876 | 876 | * |
| 877 | 877 | * @return string |
| 878 | 878 | */ |
| 879 | -function give_get_field_name( $field ) { |
|
| 880 | - $field_name = esc_attr( empty( $field['repeat'] ) ? $field['id'] : $field['repeatable_field_id'] ); |
|
| 879 | +function give_get_field_name($field) { |
|
| 880 | + $field_name = esc_attr(empty($field['repeat']) ? $field['id'] : $field['repeatable_field_id']); |
|
| 881 | 881 | |
| 882 | 882 | /** |
| 883 | 883 | * Filter the field name. |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | * |
| 887 | 887 | * @param string $field_name |
| 888 | 888 | */ |
| 889 | - $field_name = apply_filters( 'give_get_field_name', $field_name, $field ); |
|
| 889 | + $field_name = apply_filters('give_get_field_name', $field_name, $field); |
|
| 890 | 890 | |
| 891 | 891 | return $field_name; |
| 892 | 892 | } |
@@ -903,39 +903,39 @@ discard block |
||
| 903 | 903 | * |
| 904 | 904 | * @return void |
| 905 | 905 | */ |
| 906 | -function _give_metabox_form_data_repeater_fields( $fields ) { |
|
| 906 | +function _give_metabox_form_data_repeater_fields($fields) { |
|
| 907 | 907 | global $thepostid, $post; |
| 908 | 908 | |
| 909 | 909 | // Bailout. |
| 910 | - if ( ! isset( $fields['fields'] ) || empty( $fields['fields'] ) ) { |
|
| 910 | + if ( ! isset($fields['fields']) || empty($fields['fields'])) { |
|
| 911 | 911 | return; |
| 912 | 912 | } |
| 913 | 913 | |
| 914 | - $group_numbering = isset( $fields['options']['group_numbering'] ) ? (int) $fields['options']['group_numbering'] : 0; |
|
| 915 | - $close_tabs = isset( $fields['options']['close_tabs'] ) ? (int) $fields['options']['close_tabs'] : 0; |
|
| 914 | + $group_numbering = isset($fields['options']['group_numbering']) ? (int) $fields['options']['group_numbering'] : 0; |
|
| 915 | + $close_tabs = isset($fields['options']['close_tabs']) ? (int) $fields['options']['close_tabs'] : 0; |
|
| 916 | 916 | ?> |
| 917 | 917 | <div class="give-repeatable-field-section" id="<?php echo "{$fields['id']}_field"; ?>" |
| 918 | 918 | data-group-numbering="<?php echo $group_numbering; ?>" data-close-tabs="<?php echo $close_tabs; ?>"> |
| 919 | - <?php if ( ! empty( $fields['name'] ) ) : ?> |
|
| 919 | + <?php if ( ! empty($fields['name'])) : ?> |
|
| 920 | 920 | <p class="give-repeater-field-name"><?php echo $fields['name']; ?></p> |
| 921 | 921 | <?php endif; ?> |
| 922 | 922 | |
| 923 | - <?php if ( ! empty( $fields['description'] ) ) : ?> |
|
| 923 | + <?php if ( ! empty($fields['description'])) : ?> |
|
| 924 | 924 | <p class="give-repeater-field-description"><?php echo $fields['description']; ?></p> |
| 925 | 925 | <?php endif; ?> |
| 926 | 926 | |
| 927 | 927 | <table class="give-repeatable-fields-section-wrapper" cellspacing="0"> |
| 928 | 928 | <?php |
| 929 | - $repeater_field_values = get_post_meta( $thepostid, $fields['id'], true ); |
|
| 930 | - $header_title = isset( $fields['options']['header_title'] ) |
|
| 929 | + $repeater_field_values = get_post_meta($thepostid, $fields['id'], true); |
|
| 930 | + $header_title = isset($fields['options']['header_title']) |
|
| 931 | 931 | ? $fields['options']['header_title'] |
| 932 | - : esc_attr__( 'Group', 'give' ); |
|
| 932 | + : esc_attr__('Group', 'give'); |
|
| 933 | 933 | |
| 934 | 934 | $add_default_donation_field = false; |
| 935 | 935 | |
| 936 | 936 | // Check if level is not created or we have to add default level. |
| 937 | - if ( is_array( $repeater_field_values ) && ( $fields_count = count( $repeater_field_values ) ) ) { |
|
| 938 | - $repeater_field_values = array_values( $repeater_field_values ); |
|
| 937 | + if (is_array($repeater_field_values) && ($fields_count = count($repeater_field_values))) { |
|
| 938 | + $repeater_field_values = array_values($repeater_field_values); |
|
| 939 | 939 | } else { |
| 940 | 940 | $fields_count = 1; |
| 941 | 941 | $add_default_donation_field = true; |
@@ -948,59 +948,59 @@ discard block |
||
| 948 | 948 | <div class="give-row-head give-move"> |
| 949 | 949 | <button type="button" class="handlediv button-link"><span class="toggle-indicator"></span> |
| 950 | 950 | </button> |
| 951 | - <span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-</span> |
|
| 951 | + <span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-</span> |
|
| 952 | 952 | <h2> |
| 953 | 953 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
| 954 | 954 | </h2> |
| 955 | 955 | </div> |
| 956 | 956 | <div class="give-row-body"> |
| 957 | - <?php foreach ( $fields['fields'] as $field ) : ?> |
|
| 958 | - <?php if ( ! give_is_field_callback_exist( $field ) ) { |
|
| 957 | + <?php foreach ($fields['fields'] as $field) : ?> |
|
| 958 | + <?php if ( ! give_is_field_callback_exist($field)) { |
|
| 959 | 959 | continue; |
| 960 | 960 | } ?> |
| 961 | 961 | <?php |
| 962 | 962 | $field['repeat'] = true; |
| 963 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields ); |
|
| 964 | - $field['id'] = str_replace( array( '[', ']' ), array( |
|
| 963 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields); |
|
| 964 | + $field['id'] = str_replace(array('[', ']'), array( |
|
| 965 | 965 | '_', |
| 966 | 966 | '', |
| 967 | - ), $field['repeatable_field_id'] ); |
|
| 967 | + ), $field['repeatable_field_id']); |
|
| 968 | 968 | ?> |
| 969 | - <?php give_render_field( $field ); ?> |
|
| 969 | + <?php give_render_field($field); ?> |
|
| 970 | 970 | <?php endforeach; ?> |
| 971 | 971 | </div> |
| 972 | 972 | </td> |
| 973 | 973 | </tr> |
| 974 | 974 | |
| 975 | - <?php if ( ! empty( $repeater_field_values ) ) : ?> |
|
| 975 | + <?php if ( ! empty($repeater_field_values)) : ?> |
|
| 976 | 976 | <!--Stored repeater field group--> |
| 977 | - <?php foreach ( $repeater_field_values as $index => $field_group ) : ?> |
|
| 977 | + <?php foreach ($repeater_field_values as $index => $field_group) : ?> |
|
| 978 | 978 | <tr class="give-row"> |
| 979 | 979 | <td class="give-repeater-field-wrap give-column" colspan="2"> |
| 980 | 980 | <div class="give-row-head give-move"> |
| 981 | 981 | <button type="button" class="handlediv button-link"> |
| 982 | 982 | <span class="toggle-indicator"></span></button> |
| 983 | - <sapn class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">- |
|
| 983 | + <sapn class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">- |
|
| 984 | 984 | </sapn> |
| 985 | 985 | <h2> |
| 986 | 986 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
| 987 | 987 | </h2> |
| 988 | 988 | </div> |
| 989 | 989 | <div class="give-row-body"> |
| 990 | - <?php foreach ( $fields['fields'] as $field ) : ?> |
|
| 991 | - <?php if ( ! give_is_field_callback_exist( $field ) ) { |
|
| 990 | + <?php foreach ($fields['fields'] as $field) : ?> |
|
| 991 | + <?php if ( ! give_is_field_callback_exist($field)) { |
|
| 992 | 992 | continue; |
| 993 | 993 | } ?> |
| 994 | 994 | <?php |
| 995 | 995 | $field['repeat'] = true; |
| 996 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, $index ); |
|
| 997 | - $field['attributes']['value'] = give_get_repeater_field_value( $field, $field_group, $fields ); |
|
| 998 | - $field['id'] = str_replace( array( '[', ']' ), array( |
|
| 996 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, $index); |
|
| 997 | + $field['attributes']['value'] = give_get_repeater_field_value($field, $field_group, $fields); |
|
| 998 | + $field['id'] = str_replace(array('[', ']'), array( |
|
| 999 | 999 | '_', |
| 1000 | 1000 | '', |
| 1001 | - ), $field['repeatable_field_id'] ); |
|
| 1001 | + ), $field['repeatable_field_id']); |
|
| 1002 | 1002 | ?> |
| 1003 | - <?php give_render_field( $field ); ?> |
|
| 1003 | + <?php give_render_field($field); ?> |
|
| 1004 | 1004 | <?php endforeach; ?> |
| 1005 | 1005 | </div> |
| 1006 | 1006 | </td> |
@@ -1008,14 +1008,14 @@ discard block |
||
| 1008 | 1008 | <?php endforeach; |
| 1009 | 1009 | ; ?> |
| 1010 | 1010 | |
| 1011 | - <?php elseif ( $add_default_donation_field ) : ?> |
|
| 1011 | + <?php elseif ($add_default_donation_field) : ?> |
|
| 1012 | 1012 | <!--Default repeater field group--> |
| 1013 | 1013 | <tr class="give-row"> |
| 1014 | 1014 | <td class="give-repeater-field-wrap give-column" colspan="2"> |
| 1015 | 1015 | <div class="give-row-head give-move"> |
| 1016 | 1016 | <button type="button" class="handlediv button-link"> |
| 1017 | 1017 | <span class="toggle-indicator"></span></button> |
| 1018 | - <sapn class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">- |
|
| 1018 | + <sapn class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">- |
|
| 1019 | 1019 | </sapn> |
| 1020 | 1020 | <h2> |
| 1021 | 1021 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
@@ -1023,19 +1023,19 @@ discard block |
||
| 1023 | 1023 | </div> |
| 1024 | 1024 | <div class="give-row-body"> |
| 1025 | 1025 | <?php |
| 1026 | - foreach ( $fields['fields'] as $field ) : |
|
| 1027 | - if ( ! give_is_field_callback_exist( $field ) ) { |
|
| 1026 | + foreach ($fields['fields'] as $field) : |
|
| 1027 | + if ( ! give_is_field_callback_exist($field)) { |
|
| 1028 | 1028 | continue; |
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | 1031 | $field['repeat'] = true; |
| 1032 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, 0 ); |
|
| 1033 | - $field['attributes']['value'] = apply_filters( "give_default_field_group_field_{$field['id']}_value", ( ! empty( $field['default'] ) ? $field['default'] : '' ), $field ); |
|
| 1034 | - $field['id'] = str_replace( array( '[', ']' ), array( |
|
| 1032 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, 0); |
|
| 1033 | + $field['attributes']['value'] = apply_filters("give_default_field_group_field_{$field['id']}_value", ( ! empty($field['default']) ? $field['default'] : ''), $field); |
|
| 1034 | + $field['id'] = str_replace(array('[', ']'), array( |
|
| 1035 | 1035 | '_', |
| 1036 | 1036 | '', |
| 1037 | - ), $field['repeatable_field_id'] ); |
|
| 1038 | - give_render_field( $field ); |
|
| 1037 | + ), $field['repeatable_field_id']); |
|
| 1038 | + give_render_field($field); |
|
| 1039 | 1039 | endforeach; |
| 1040 | 1040 | ?> |
| 1041 | 1041 | </div> |
@@ -1046,9 +1046,9 @@ discard block |
||
| 1046 | 1046 | <tfoot> |
| 1047 | 1047 | <tr> |
| 1048 | 1048 | <?php |
| 1049 | - $add_row_btn_title = isset( $fields['options']['add_button'] ) |
|
| 1049 | + $add_row_btn_title = isset($fields['options']['add_button']) |
|
| 1050 | 1050 | ? $add_row_btn_title = $fields['options']['add_button'] |
| 1051 | - : esc_html__( 'Add Row', 'give' ); |
|
| 1051 | + : esc_html__('Add Row', 'give'); |
|
| 1052 | 1052 | ?> |
| 1053 | 1053 | <td colspan="2" class="give-add-repeater-field-section-row-wrap"> |
| 1054 | 1054 | <span class="button button-primary give-add-repeater-field-section-row"><?php echo $add_row_btn_title; ?></span> |
@@ -1078,10 +1078,10 @@ discard block |
||
| 1078 | 1078 | * |
| 1079 | 1079 | * @param string |
| 1080 | 1080 | */ |
| 1081 | - $default_current_tab = apply_filters( "give_default_setting_tab_{$current_setting_page}", 'general' ); |
|
| 1081 | + $default_current_tab = apply_filters("give_default_setting_tab_{$current_setting_page}", 'general'); |
|
| 1082 | 1082 | |
| 1083 | 1083 | // Get current tab. |
| 1084 | - $current_tab = empty( $_GET['tab'] ) ? $default_current_tab : urldecode( $_GET['tab'] ); |
|
| 1084 | + $current_tab = empty($_GET['tab']) ? $default_current_tab : urldecode($_GET['tab']); |
|
| 1085 | 1085 | |
| 1086 | 1086 | // Output. |
| 1087 | 1087 | return $current_tab; |
@@ -1105,10 +1105,10 @@ discard block |
||
| 1105 | 1105 | * |
| 1106 | 1106 | * @param string |
| 1107 | 1107 | */ |
| 1108 | - $default_current_section = apply_filters( "give_default_setting_tab_section_{$current_tab}", '' ); |
|
| 1108 | + $default_current_section = apply_filters("give_default_setting_tab_section_{$current_tab}", ''); |
|
| 1109 | 1109 | |
| 1110 | 1110 | // Get current section. |
| 1111 | - $current_section = empty( $_REQUEST['section'] ) ? $default_current_section : urldecode( $_REQUEST['section'] ); |
|
| 1111 | + $current_section = empty($_REQUEST['section']) ? $default_current_section : urldecode($_REQUEST['section']); |
|
| 1112 | 1112 | |
| 1113 | 1113 | // Output. |
| 1114 | 1114 | return $current_section; |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | */ |
| 1123 | 1123 | function give_get_current_setting_page() { |
| 1124 | 1124 | // Get current page. |
| 1125 | - $setting_page = ! empty( $_GET['page'] ) ? urldecode( $_GET['page'] ) : ''; |
|
| 1125 | + $setting_page = ! empty($_GET['page']) ? urldecode($_GET['page']) : ''; |
|
| 1126 | 1126 | |
| 1127 | 1127 | // Output. |
| 1128 | 1128 | return $setting_page; |
@@ -1142,13 +1142,13 @@ discard block |
||
| 1142 | 1142 | * |
| 1143 | 1143 | * @return string |
| 1144 | 1144 | */ |
| 1145 | -function _give_display_content_field_value( $field_value, $field, $postid ) { |
|
| 1146 | - $show_content = get_post_meta( $postid, '_give_content_option', true ); |
|
| 1145 | +function _give_display_content_field_value($field_value, $field, $postid) { |
|
| 1146 | + $show_content = get_post_meta($postid, '_give_content_option', true); |
|
| 1147 | 1147 | |
| 1148 | 1148 | if ( |
| 1149 | - ! get_post_meta( $postid, '_give_display_content', true ) |
|
| 1149 | + ! get_post_meta($postid, '_give_display_content', true) |
|
| 1150 | 1150 | && $show_content |
| 1151 | - && ( 'none' !== $show_content ) |
|
| 1151 | + && ('none' !== $show_content) |
|
| 1152 | 1152 | ) { |
| 1153 | 1153 | $field_value = 'enabled'; |
| 1154 | 1154 | } |
@@ -1156,7 +1156,7 @@ discard block |
||
| 1156 | 1156 | return $field_value; |
| 1157 | 1157 | } |
| 1158 | 1158 | |
| 1159 | -add_filter( '_give_display_content_field_value', '_give_display_content_field_value', 10, 3 ); |
|
| 1159 | +add_filter('_give_display_content_field_value', '_give_display_content_field_value', 10, 3); |
|
| 1160 | 1160 | |
| 1161 | 1161 | |
| 1162 | 1162 | /** |
@@ -1173,12 +1173,12 @@ discard block |
||
| 1173 | 1173 | * |
| 1174 | 1174 | * @return string |
| 1175 | 1175 | */ |
| 1176 | -function _give_content_placement_field_value( $field_value, $field, $postid ) { |
|
| 1177 | - $show_content = get_post_meta( $postid, '_give_content_option', true ); |
|
| 1176 | +function _give_content_placement_field_value($field_value, $field, $postid) { |
|
| 1177 | + $show_content = get_post_meta($postid, '_give_content_option', true); |
|
| 1178 | 1178 | |
| 1179 | 1179 | if ( |
| 1180 | - ! get_post_meta( $postid, '_give_content_placement', true ) |
|
| 1181 | - && ( 'none' !== $show_content ) |
|
| 1180 | + ! get_post_meta($postid, '_give_content_placement', true) |
|
| 1181 | + && ('none' !== $show_content) |
|
| 1182 | 1182 | ) { |
| 1183 | 1183 | $field_value = $show_content; |
| 1184 | 1184 | } |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | return $field_value; |
| 1187 | 1187 | } |
| 1188 | 1188 | |
| 1189 | -add_filter( '_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3 ); |
|
| 1189 | +add_filter('_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3); |
|
| 1190 | 1190 | |
| 1191 | 1191 | |
| 1192 | 1192 | /** |
@@ -1202,17 +1202,17 @@ discard block |
||
| 1202 | 1202 | * |
| 1203 | 1203 | * @return string |
| 1204 | 1204 | */ |
| 1205 | -function _give_terms_option_field_value( $field_value, $field, $postid ) { |
|
| 1206 | - $term_option = get_post_meta( $postid, '_give_terms_option', true ); |
|
| 1205 | +function _give_terms_option_field_value($field_value, $field, $postid) { |
|
| 1206 | + $term_option = get_post_meta($postid, '_give_terms_option', true); |
|
| 1207 | 1207 | |
| 1208 | - if ( in_array( $term_option, array( 'none', 'yes' ) ) ) { |
|
| 1209 | - $field_value = ( 'yes' === $term_option ? 'enabled' : 'disabled' ); |
|
| 1208 | + if (in_array($term_option, array('none', 'yes'))) { |
|
| 1209 | + $field_value = ('yes' === $term_option ? 'enabled' : 'disabled'); |
|
| 1210 | 1210 | } |
| 1211 | 1211 | |
| 1212 | 1212 | return $field_value; |
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | -add_filter( '_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3 ); |
|
| 1215 | +add_filter('_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3); |
|
| 1216 | 1216 | |
| 1217 | 1217 | |
| 1218 | 1218 | /** |
@@ -1229,17 +1229,17 @@ discard block |
||
| 1229 | 1229 | * |
| 1230 | 1230 | * @return string |
| 1231 | 1231 | */ |
| 1232 | -function _give_offline_donation_enable_billing_fields_single_field_value( $field_value, $field, $postid ) { |
|
| 1233 | - $offline_donation = get_post_meta( $postid, '_give_offline_donation_enable_billing_fields_single', true ); |
|
| 1232 | +function _give_offline_donation_enable_billing_fields_single_field_value($field_value, $field, $postid) { |
|
| 1233 | + $offline_donation = get_post_meta($postid, '_give_offline_donation_enable_billing_fields_single', true); |
|
| 1234 | 1234 | |
| 1235 | - if ( 'on' === $offline_donation ) { |
|
| 1235 | + if ('on' === $offline_donation) { |
|
| 1236 | 1236 | $field_value = 'enabled'; |
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | 1239 | return $field_value; |
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | -add_filter( '_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3 ); |
|
| 1242 | +add_filter('_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3); |
|
| 1243 | 1243 | |
| 1244 | 1244 | |
| 1245 | 1245 | /** |
@@ -1255,17 +1255,17 @@ discard block |
||
| 1255 | 1255 | * |
| 1256 | 1256 | * @return string |
| 1257 | 1257 | */ |
| 1258 | -function _give_custom_amount_field_value( $field_value, $field, $postid ) { |
|
| 1259 | - $custom_amount = get_post_meta( $postid, '_give_custom_amount', true ); |
|
| 1258 | +function _give_custom_amount_field_value($field_value, $field, $postid) { |
|
| 1259 | + $custom_amount = get_post_meta($postid, '_give_custom_amount', true); |
|
| 1260 | 1260 | |
| 1261 | - if ( in_array( $custom_amount, array( 'yes', 'no' ) ) ) { |
|
| 1262 | - $field_value = ( 'yes' === $custom_amount ? 'enabled' : 'disabled' ); |
|
| 1261 | + if (in_array($custom_amount, array('yes', 'no'))) { |
|
| 1262 | + $field_value = ('yes' === $custom_amount ? 'enabled' : 'disabled'); |
|
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | 1265 | return $field_value; |
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | -add_filter( '_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3 ); |
|
| 1268 | +add_filter('_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3); |
|
| 1269 | 1269 | |
| 1270 | 1270 | |
| 1271 | 1271 | /** |
@@ -1281,17 +1281,17 @@ discard block |
||
| 1281 | 1281 | * |
| 1282 | 1282 | * @return string |
| 1283 | 1283 | */ |
| 1284 | -function _give_goal_option_field_value( $field_value, $field, $postid ) { |
|
| 1285 | - $goal_option = get_post_meta( $postid, '_give_goal_option', true ); |
|
| 1284 | +function _give_goal_option_field_value($field_value, $field, $postid) { |
|
| 1285 | + $goal_option = get_post_meta($postid, '_give_goal_option', true); |
|
| 1286 | 1286 | |
| 1287 | - if ( in_array( $goal_option, array( 'yes', 'no' ) ) ) { |
|
| 1288 | - $field_value = ( 'yes' === $goal_option ? 'enabled' : 'disabled' ); |
|
| 1287 | + if (in_array($goal_option, array('yes', 'no'))) { |
|
| 1288 | + $field_value = ('yes' === $goal_option ? 'enabled' : 'disabled'); |
|
| 1289 | 1289 | } |
| 1290 | 1290 | |
| 1291 | 1291 | return $field_value; |
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | -add_filter( '_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3 ); |
|
| 1294 | +add_filter('_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3); |
|
| 1295 | 1295 | |
| 1296 | 1296 | /** |
| 1297 | 1297 | * Set value for Donation Goal --> close Form. |
@@ -1307,17 +1307,17 @@ discard block |
||
| 1307 | 1307 | * |
| 1308 | 1308 | * @return string |
| 1309 | 1309 | */ |
| 1310 | -function _give_close_form_when_goal_achieved_value( $field_value, $field, $postid ) { |
|
| 1311 | - $close_form = get_post_meta( $postid, '_give_close_form_when_goal_achieved', true ); |
|
| 1310 | +function _give_close_form_when_goal_achieved_value($field_value, $field, $postid) { |
|
| 1311 | + $close_form = get_post_meta($postid, '_give_close_form_when_goal_achieved', true); |
|
| 1312 | 1312 | |
| 1313 | - if ( in_array( $close_form, array( 'yes', 'no' ) ) ) { |
|
| 1314 | - $field_value = ( 'yes' === $close_form ? 'enabled' : 'disabled' ); |
|
| 1313 | + if (in_array($close_form, array('yes', 'no'))) { |
|
| 1314 | + $field_value = ('yes' === $close_form ? 'enabled' : 'disabled'); |
|
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | 1317 | return $field_value; |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | -add_filter( '_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3 ); |
|
| 1320 | +add_filter('_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3); |
|
| 1321 | 1321 | |
| 1322 | 1322 | |
| 1323 | 1323 | /** |
@@ -1333,17 +1333,17 @@ discard block |
||
| 1333 | 1333 | * |
| 1334 | 1334 | * @return string |
| 1335 | 1335 | */ |
| 1336 | -function _give_logged_in_only_value( $field_value, $field, $postid ) { |
|
| 1337 | - $guest_donation = get_post_meta( $postid, '_give_logged_in_only', true ); |
|
| 1336 | +function _give_logged_in_only_value($field_value, $field, $postid) { |
|
| 1337 | + $guest_donation = get_post_meta($postid, '_give_logged_in_only', true); |
|
| 1338 | 1338 | |
| 1339 | - if ( in_array( $guest_donation, array( 'yes', 'no' ) ) ) { |
|
| 1340 | - $field_value = ( 'yes' === $guest_donation ? 'enabled' : 'disabled' ); |
|
| 1339 | + if (in_array($guest_donation, array('yes', 'no'))) { |
|
| 1340 | + $field_value = ('yes' === $guest_donation ? 'enabled' : 'disabled'); |
|
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | 1343 | return $field_value; |
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | -add_filter( '_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3 ); |
|
| 1346 | +add_filter('_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3); |
|
| 1347 | 1347 | |
| 1348 | 1348 | /** |
| 1349 | 1349 | * Set value for Offline Donations --> Offline Donations. |
@@ -1359,17 +1359,17 @@ discard block |
||
| 1359 | 1359 | * |
| 1360 | 1360 | * @return string |
| 1361 | 1361 | */ |
| 1362 | -function _give_customize_offline_donations_value( $field_value, $field, $postid ) { |
|
| 1363 | - $customize_offline_text = get_post_meta( $postid, '_give_customize_offline_donations', true ); |
|
| 1362 | +function _give_customize_offline_donations_value($field_value, $field, $postid) { |
|
| 1363 | + $customize_offline_text = get_post_meta($postid, '_give_customize_offline_donations', true); |
|
| 1364 | 1364 | |
| 1365 | - if ( in_array( $customize_offline_text, array( 'yes', 'no' ) ) ) { |
|
| 1366 | - $field_value = ( 'yes' === $customize_offline_text ? 'enabled' : 'disabled' ); |
|
| 1365 | + if (in_array($customize_offline_text, array('yes', 'no'))) { |
|
| 1366 | + $field_value = ('yes' === $customize_offline_text ? 'enabled' : 'disabled'); |
|
| 1367 | 1367 | } |
| 1368 | 1368 | |
| 1369 | 1369 | return $field_value; |
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | -add_filter( '_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3 ); |
|
| 1372 | +add_filter('_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3); |
|
| 1373 | 1373 | |
| 1374 | 1374 | |
| 1375 | 1375 | /** |
@@ -1384,14 +1384,14 @@ discard block |
||
| 1384 | 1384 | * |
| 1385 | 1385 | * @return mixed |
| 1386 | 1386 | */ |
| 1387 | -function _give_set_multi_level_repeater_field_id( $field_id, $field, $fields, $default ) { |
|
| 1387 | +function _give_set_multi_level_repeater_field_id($field_id, $field, $fields, $default) { |
|
| 1388 | 1388 | $row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}'; |
| 1389 | 1389 | $field_id = "{$fields['id']}[{$row_placeholder}][{$field['id']}][level_id]"; |
| 1390 | 1390 | |
| 1391 | 1391 | return $field_id; |
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | -add_filter( 'give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4 ); |
|
| 1394 | +add_filter('give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4); |
|
| 1395 | 1395 | |
| 1396 | 1396 | /** |
| 1397 | 1397 | * Set repeater field value for multi donation form. |
@@ -1405,13 +1405,13 @@ discard block |
||
| 1405 | 1405 | * |
| 1406 | 1406 | * @return mixed |
| 1407 | 1407 | */ |
| 1408 | -function _give_set_multi_level_repeater_field_value( $field_value, $field, $field_group, $fields ) { |
|
| 1409 | - $field_value = $field_group[ $field['id'] ]['level_id']; |
|
| 1408 | +function _give_set_multi_level_repeater_field_value($field_value, $field, $field_group, $fields) { |
|
| 1409 | + $field_value = $field_group[$field['id']]['level_id']; |
|
| 1410 | 1410 | |
| 1411 | 1411 | return $field_value; |
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | -add_filter( 'give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4 ); |
|
| 1414 | +add_filter('give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4); |
|
| 1415 | 1415 | |
| 1416 | 1416 | /** |
| 1417 | 1417 | * Set default value for _give_id field. |
@@ -1422,11 +1422,11 @@ discard block |
||
| 1422 | 1422 | * |
| 1423 | 1423 | * @return string |
| 1424 | 1424 | */ |
| 1425 | -function _give_set_field_give_id_default_value( $field ) { |
|
| 1425 | +function _give_set_field_give_id_default_value($field) { |
|
| 1426 | 1426 | return 0; |
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | -add_filter( 'give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value' ); |
|
| 1429 | +add_filter('give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value'); |
|
| 1430 | 1430 | |
| 1431 | 1431 | /** |
| 1432 | 1432 | * Set default value for _give_default field. |
@@ -1437,11 +1437,11 @@ discard block |
||
| 1437 | 1437 | * |
| 1438 | 1438 | * @return string |
| 1439 | 1439 | */ |
| 1440 | -function _give_set_field_give_default_default_value( $field ) { |
|
| 1440 | +function _give_set_field_give_default_default_value($field) { |
|
| 1441 | 1441 | return 'default'; |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | -add_filter( 'give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value' ); |
|
| 1444 | +add_filter('give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value'); |
|
| 1445 | 1445 | |
| 1446 | 1446 | /** |
| 1447 | 1447 | * Set repeater field editor id for field type wysiwyg. |
@@ -1453,12 +1453,12 @@ discard block |
||
| 1453 | 1453 | * |
| 1454 | 1454 | * @return string |
| 1455 | 1455 | */ |
| 1456 | -function give_repeater_field_set_editor_id( $field_name, $field ) { |
|
| 1457 | - if ( isset( $field['repeatable_field_id'] ) && 'wysiwyg' == $field['type'] ) { |
|
| 1458 | - $field_name = '_give_repeater_' . uniqid() . '_wysiwyg'; |
|
| 1456 | +function give_repeater_field_set_editor_id($field_name, $field) { |
|
| 1457 | + if (isset($field['repeatable_field_id']) && 'wysiwyg' == $field['type']) { |
|
| 1458 | + $field_name = '_give_repeater_'.uniqid().'_wysiwyg'; |
|
| 1459 | 1459 | } |
| 1460 | 1460 | |
| 1461 | 1461 | return $field_name; |
| 1462 | 1462 | } |
| 1463 | 1463 | |
| 1464 | -add_filter( 'give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2 ); |
|
| 1464 | +add_filter('give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2); |
|