@@ -713,7 +713,7 @@ |
||
| 713 | 713 | * |
| 714 | 714 | * @param array $value The form field value array |
| 715 | 715 | * |
| 716 | - * @return array The description and tip as a 2 element array |
|
| 716 | + * @return string The description and tip as a 2 element array |
|
| 717 | 717 | */ |
| 718 | 718 | public static function get_field_description( $value ) { |
| 719 | 719 | $description = ''; |
@@ -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 | - die( __( 'Action failed. Please refresh the page and retry.', 'give' ) ); |
|
| 89 | + if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) { |
|
| 90 | + die(__('Action failed. Please refresh the page and retry.', 'give')); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @since 1.8 |
| 101 | 101 | */ |
| 102 | - do_action( self::$setting_filter_prefix . '_save_' . $current_tab ); |
|
| 102 | + do_action(self::$setting_filter_prefix.'_save_'.$current_tab); |
|
| 103 | 103 | |
| 104 | - self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) ); |
|
| 104 | + self::add_message('give-setting-updated', __('Your settings have been saved.', 'give')); |
|
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * Trigger Action. |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @since 1.8 |
| 114 | 114 | */ |
| 115 | - do_action( self::$setting_filter_prefix . '_saved' ); |
|
| 115 | + do_action(self::$setting_filter_prefix.'_saved'); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return void |
| 127 | 127 | */ |
| 128 | - public static function add_message( $code, $message ) { |
|
| 129 | - self::$messages[ $code ] = $message; |
|
| 128 | + public static function add_message($code, $message) { |
|
| 129 | + self::$messages[$code] = $message; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @return void |
| 141 | 141 | */ |
| 142 | - public static function add_error( $code, $message ) { |
|
| 143 | - self::$errors[ $code ] = $message; |
|
| 142 | + public static function add_error($code, $message) { |
|
| 143 | + self::$errors[$code] = $message; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -153,18 +153,18 @@ discard block |
||
| 153 | 153 | $notice_html = ''; |
| 154 | 154 | $classes = 'give-notice settings-error notice is-dismissible'; |
| 155 | 155 | |
| 156 | - self::$errors = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors ); |
|
| 157 | - self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages ); |
|
| 156 | + self::$errors = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors); |
|
| 157 | + self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages); |
|
| 158 | 158 | |
| 159 | - if ( 0 < count( self::$errors ) ) { |
|
| 160 | - foreach ( self::$errors as $code => $message ) { |
|
| 161 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' error"><p><strong>' . $message . '</strong></p></div>'; |
|
| 159 | + if (0 < count(self::$errors)) { |
|
| 160 | + foreach (self::$errors as $code => $message) { |
|
| 161 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' error"><p><strong>'.$message.'</strong></p></div>'; |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if ( 0 < count( self::$messages ) ) { |
|
| 166 | - foreach ( self::$messages as $code => $message ) { |
|
| 167 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' updated"><p><strong>' . $message . '</strong></p></div>'; |
|
| 165 | + if (0 < count(self::$messages)) { |
|
| 166 | + foreach (self::$messages as $code => $message) { |
|
| 167 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' updated"><p><strong>'.$message.'</strong></p></div>'; |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | self::$setting_filter_prefix = give_get_current_setting_page(); |
| 185 | 185 | |
| 186 | 186 | // Bailout: Exit if setting page is not defined. |
| 187 | - if ( empty( self::$setting_filter_prefix ) ) { |
|
| 187 | + if (empty(self::$setting_filter_prefix)) { |
|
| 188 | 188 | return false; |
| 189 | 189 | } |
| 190 | 190 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * |
| 198 | 198 | * @since 1.8 |
| 199 | 199 | */ |
| 200 | - do_action( self::$setting_filter_prefix . '_start' ); |
|
| 200 | + do_action(self::$setting_filter_prefix.'_start'); |
|
| 201 | 201 | |
| 202 | 202 | $current_tab = give_get_current_setting_tab(); |
| 203 | 203 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | self::get_settings_pages(); |
| 206 | 206 | |
| 207 | 207 | // Save settings if data has been posted. |
| 208 | - if ( ! empty( $_POST ) ) { |
|
| 208 | + if ( ! empty($_POST)) { |
|
| 209 | 209 | self::save(); |
| 210 | 210 | } |
| 211 | 211 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @since 1.8 |
| 220 | 220 | */ |
| 221 | - $tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() ); |
|
| 221 | + $tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array()); |
|
| 222 | 222 | |
| 223 | 223 | include 'views/html-admin-settings.php'; |
| 224 | 224 | |
@@ -236,25 +236,25 @@ discard block |
||
| 236 | 236 | * |
| 237 | 237 | * @return string|bool |
| 238 | 238 | */ |
| 239 | - public static function get_option( $option_name = '', $field_id = '', $default = false ) { |
|
| 239 | + public static function get_option($option_name = '', $field_id = '', $default = false) { |
|
| 240 | 240 | // Bailout. |
| 241 | - if ( empty( $option_name ) && empty( $field_id ) ) { |
|
| 241 | + if (empty($option_name) && empty($field_id)) { |
|
| 242 | 242 | return false; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if ( ! empty( $field_id ) && ! empty( $option_name ) ) { |
|
| 245 | + if ( ! empty($field_id) && ! empty($option_name)) { |
|
| 246 | 246 | // Get field value if any. |
| 247 | - $option_value = get_option( $option_name ); |
|
| 247 | + $option_value = get_option($option_name); |
|
| 248 | 248 | |
| 249 | - $option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) ) |
|
| 250 | - ? $option_value[ $field_id ] |
|
| 249 | + $option_value = (is_array($option_value) && array_key_exists($field_id, $option_value)) |
|
| 250 | + ? $option_value[$field_id] |
|
| 251 | 251 | : $default; |
| 252 | 252 | } else { |
| 253 | 253 | // If option name is empty but not field name then this means, setting is direct store to option table under there field name. |
| 254 | 254 | $option_name = ! $option_name ? $field_id : $option_name; |
| 255 | 255 | |
| 256 | 256 | // Get option value if any. |
| 257 | - $option_value = get_option( $option_name, $default ); |
|
| 257 | + $option_value = get_option($option_name, $default); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | return $option_value; |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * |
| 273 | 273 | * @return void |
| 274 | 274 | */ |
| 275 | - public static function output_fields( $options, $option_name = '' ) { |
|
| 275 | + public static function output_fields($options, $option_name = '') { |
|
| 276 | 276 | $current_tab = give_get_current_setting_tab(); |
| 277 | 277 | |
| 278 | 278 | // Field Default values. |
@@ -285,46 +285,46 @@ discard block |
||
| 285 | 285 | 'table_html' => true, |
| 286 | 286 | ); |
| 287 | 287 | |
| 288 | - foreach ( $options as $value ) { |
|
| 289 | - if ( ! isset( $value['type'] ) ) { |
|
| 288 | + foreach ($options as $value) { |
|
| 289 | + if ( ! isset($value['type'])) { |
|
| 290 | 290 | continue; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // Set title. |
| 294 | - $defaults['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
| 294 | + $defaults['title'] = isset($value['name']) ? $value['name'] : ''; |
|
| 295 | 295 | |
| 296 | - $value = wp_parse_args( $value, $defaults ); |
|
| 296 | + $value = wp_parse_args($value, $defaults); |
|
| 297 | 297 | |
| 298 | 298 | // Custom attribute handling. |
| 299 | 299 | $custom_attributes = array(); |
| 300 | 300 | |
| 301 | - if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) { |
|
| 302 | - foreach ( $value['attributes'] as $attribute => $attribute_value ) { |
|
| 303 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
| 301 | + if ( ! empty($value['attributes']) && is_array($value['attributes'])) { |
|
| 302 | + foreach ($value['attributes'] as $attribute => $attribute_value) { |
|
| 303 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | // Description handling. |
| 308 | - $description = self::get_field_description( $value ); |
|
| 308 | + $description = self::get_field_description($value); |
|
| 309 | 309 | |
| 310 | 310 | // Switch based on type. |
| 311 | - switch ( $value['type'] ) { |
|
| 311 | + switch ($value['type']) { |
|
| 312 | 312 | |
| 313 | 313 | // Section Titles |
| 314 | 314 | case 'title': |
| 315 | - if ( ! empty( $value['title'] ) ) { |
|
| 316 | - echo '<div class="give-setting-tab-header give-setting-tab-header-' . $current_tab . '"><h2>' . self::get_field_title( $value ) . '</h2><hr></div>'; |
|
| 315 | + if ( ! empty($value['title'])) { |
|
| 316 | + echo '<div class="give-setting-tab-header give-setting-tab-header-'.$current_tab.'"><h2>'.self::get_field_title($value).'</h2><hr></div>'; |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - if ( ! empty( $value['desc'] ) ) { |
|
| 320 | - echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); |
|
| 319 | + if ( ! empty($value['desc'])) { |
|
| 320 | + echo wpautop(wptexturize(wp_kses_post($value['desc']))); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - if ( $value['table_html'] ) { |
|
| 324 | - echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n"; |
|
| 323 | + if ($value['table_html']) { |
|
| 324 | + echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n"; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - if ( ! empty( $value['id'] ) ) { |
|
| 327 | + if ( ! empty($value['id'])) { |
|
| 328 | 328 | |
| 329 | 329 | /** |
| 330 | 330 | * Trigger Action. |
@@ -333,14 +333,14 @@ discard block |
||
| 333 | 333 | * |
| 334 | 334 | * @since 1.8 |
| 335 | 335 | */ |
| 336 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) ); |
|
| 336 | + do_action('give_settings_'.sanitize_title($value['id'])); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | break; |
| 340 | 340 | |
| 341 | 341 | // Section Ends. |
| 342 | 342 | case 'sectionend': |
| 343 | - if ( ! empty( $value['id'] ) ) { |
|
| 343 | + if ( ! empty($value['id'])) { |
|
| 344 | 344 | |
| 345 | 345 | /** |
| 346 | 346 | * Trigger Action. |
@@ -349,14 +349,14 @@ discard block |
||
| 349 | 349 | * |
| 350 | 350 | * @since 1.8 |
| 351 | 351 | */ |
| 352 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
| 352 | + do_action('give_settings_'.sanitize_title($value['id']).'_end'); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - if ( $value['table_html'] ) { |
|
| 355 | + if ($value['table_html']) { |
|
| 356 | 356 | echo '</table>'; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - if ( ! empty( $value['id'] ) ) { |
|
| 359 | + if ( ! empty($value['id'])) { |
|
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | 362 | * Trigger Action. |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * |
| 366 | 366 | * @since 1.8 |
| 367 | 367 | */ |
| 368 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
| 368 | + do_action('give_settings_'.sanitize_title($value['id']).'_after'); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | break; |
@@ -377,22 +377,22 @@ discard block |
||
| 377 | 377 | case 'password' : |
| 378 | 378 | |
| 379 | 379 | $type = $value['type']; |
| 380 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 380 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 381 | 381 | |
| 382 | 382 | ?> |
| 383 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 383 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 384 | 384 | <th scope="row" class="titledesc"> |
| 385 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 385 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 386 | 386 | </th> |
| 387 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 387 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 388 | 388 | <input |
| 389 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 390 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 391 | - type="<?php echo esc_attr( $type ); ?>" |
|
| 392 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 393 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
| 394 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
| 395 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 389 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 390 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 391 | + type="<?php echo esc_attr($type); ?>" |
|
| 392 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 393 | + value="<?php echo esc_attr($option_value); ?>" |
|
| 394 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
| 395 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 396 | 396 | /> <?php echo $description; ?> |
| 397 | 397 | </td> |
| 398 | 398 | </tr><?php |
@@ -401,23 +401,23 @@ discard block |
||
| 401 | 401 | // Textarea. |
| 402 | 402 | case 'textarea': |
| 403 | 403 | |
| 404 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 404 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 405 | 405 | |
| 406 | 406 | ?> |
| 407 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 407 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 408 | 408 | <th scope="row" class="titledesc"> |
| 409 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 409 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 410 | 410 | </th> |
| 411 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 411 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 412 | 412 | <textarea |
| 413 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 414 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 415 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 416 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 413 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 414 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 415 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 416 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 417 | 417 | rows="10" |
| 418 | 418 | cols="60" |
| 419 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 420 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
| 419 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 420 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
| 421 | 421 | <?php echo $description; ?> |
| 422 | 422 | </td> |
| 423 | 423 | </tr><?php |
@@ -427,35 +427,35 @@ discard block |
||
| 427 | 427 | case 'select' : |
| 428 | 428 | case 'multiselect' : |
| 429 | 429 | |
| 430 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 430 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 431 | 431 | |
| 432 | 432 | ?> |
| 433 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 433 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 434 | 434 | <th scope="row" class="titledesc"> |
| 435 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 435 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 436 | 436 | </th> |
| 437 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 437 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 438 | 438 | <select |
| 439 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) { |
|
| 439 | + name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') { |
|
| 440 | 440 | echo '[]'; |
| 441 | 441 | } ?>" |
| 442 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 443 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 444 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 445 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 446 | - <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?> |
|
| 442 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 443 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 444 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 445 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 446 | + <?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?> |
|
| 447 | 447 | > |
| 448 | 448 | |
| 449 | 449 | <?php |
| 450 | - if ( ! empty( $value['options'] ) ) { |
|
| 451 | - foreach ( $value['options'] as $key => $val ) { |
|
| 450 | + if ( ! empty($value['options'])) { |
|
| 451 | + foreach ($value['options'] as $key => $val) { |
|
| 452 | 452 | ?> |
| 453 | - <option value="<?php echo esc_attr( $key ); ?>" <?php |
|
| 453 | + <option value="<?php echo esc_attr($key); ?>" <?php |
|
| 454 | 454 | |
| 455 | - if ( is_array( $option_value ) ) { |
|
| 456 | - selected( in_array( $key, $option_value ), true ); |
|
| 455 | + if (is_array($option_value)) { |
|
| 456 | + selected(in_array($key, $option_value), true); |
|
| 457 | 457 | } else { |
| 458 | - selected( $option_value, $key ); |
|
| 458 | + selected($option_value, $key); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | ?>><?php echo $val ?></option> |
@@ -471,28 +471,28 @@ discard block |
||
| 471 | 471 | |
| 472 | 472 | // Radio inputs. |
| 473 | 473 | case 'radio_inline' : |
| 474 | - $value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline'; |
|
| 474 | + $value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline'; |
|
| 475 | 475 | case 'radio' : |
| 476 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 476 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 477 | 477 | ?> |
| 478 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 478 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 479 | 479 | <th scope="row" class="titledesc"> |
| 480 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 480 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 481 | 481 | </th> |
| 482 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
| 482 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
| 483 | 483 | <fieldset> |
| 484 | 484 | <ul> |
| 485 | 485 | <?php |
| 486 | - foreach ( $value['options'] as $key => $val ) { |
|
| 486 | + foreach ($value['options'] as $key => $val) { |
|
| 487 | 487 | ?> |
| 488 | 488 | <li> |
| 489 | 489 | <label><input |
| 490 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 490 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 491 | 491 | value="<?php echo $key; ?>" |
| 492 | 492 | type="radio" |
| 493 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 494 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 495 | - <?php checked( $key, $option_value ); ?> |
|
| 493 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 494 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 495 | + <?php checked($key, $option_value); ?> |
|
| 496 | 496 | /> <?php echo $val ?></label> |
| 497 | 497 | </li> |
| 498 | 498 | <?php |
@@ -506,21 +506,21 @@ discard block |
||
| 506 | 506 | |
| 507 | 507 | // Checkbox input. |
| 508 | 508 | case 'checkbox' : |
| 509 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 509 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 510 | 510 | ?> |
| 511 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 511 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 512 | 512 | <th scope="row" class="titledesc"> |
| 513 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 513 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 514 | 514 | </th> |
| 515 | 515 | <td class="give-forminp"> |
| 516 | 516 | <input |
| 517 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 518 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 517 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 518 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 519 | 519 | type="checkbox" |
| 520 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
| 520 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
| 521 | 521 | value="1" |
| 522 | - <?php checked( $option_value, 'on' ); ?> |
|
| 523 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 522 | + <?php checked($option_value, 'on'); ?> |
|
| 523 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 524 | 524 | /> |
| 525 | 525 | <?php echo $description; ?> |
| 526 | 526 | </td> |
@@ -530,28 +530,28 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | // Multi Checkbox input. |
| 532 | 532 | case 'multicheck' : |
| 533 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 534 | - $option_value = is_array( $option_value ) ? $option_value : array(); |
|
| 533 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 534 | + $option_value = is_array($option_value) ? $option_value : array(); |
|
| 535 | 535 | ?> |
| 536 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 536 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 537 | 537 | <th scope="row" class="titledesc"> |
| 538 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 538 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 539 | 539 | </th> |
| 540 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
| 540 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
| 541 | 541 | <fieldset> |
| 542 | 542 | <ul> |
| 543 | 543 | <?php |
| 544 | - foreach ( $value['options'] as $key => $val ) { |
|
| 544 | + foreach ($value['options'] as $key => $val) { |
|
| 545 | 545 | ?> |
| 546 | 546 | <li> |
| 547 | 547 | <label> |
| 548 | 548 | <input |
| 549 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
| 549 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
| 550 | 550 | value="<?php echo $key; ?>" |
| 551 | 551 | type="checkbox" |
| 552 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 553 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 554 | - <?php if ( in_array( $key, $option_value ) ) { |
|
| 552 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 553 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 554 | + <?php if (in_array($key, $option_value)) { |
|
| 555 | 555 | echo 'checked="checked"'; |
| 556 | 556 | } ?> |
| 557 | 557 | /> <?php echo $val ?> |
@@ -569,24 +569,24 @@ discard block |
||
| 569 | 569 | |
| 570 | 570 | // File input field. |
| 571 | 571 | case 'file' : |
| 572 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 572 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 573 | 573 | ?> |
| 574 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 574 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 575 | 575 | <th scope="row" class="titledesc"> |
| 576 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 576 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 577 | 577 | </th> |
| 578 | 578 | <td class="give-forminp"> |
| 579 | 579 | <div class="give-field-wrap"> |
| 580 | 580 | <label for="<?php echo $value['id'] ?>"> |
| 581 | 581 | <input |
| 582 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 583 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 582 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 583 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 584 | 584 | type="text" |
| 585 | - class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>" |
|
| 585 | + class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>" |
|
| 586 | 586 | value="<?php echo $option_value; ?>" |
| 587 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 588 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 589 | - /> <input class="give-upload-button button" type="button" value="<?php echo esc_html__( 'Add or Upload File', 'give' ); ?>"> |
|
| 587 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 588 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 589 | + /> <input class="give-upload-button button" type="button" value="<?php echo esc_html__('Add or Upload File', 'give'); ?>"> |
|
| 590 | 590 | <?php echo $description ?> |
| 591 | 591 | <div class="give-image-thumb<?php echo ! $option_value ? ' give-hidden' : ''; ?>"> |
| 592 | 592 | <span class="give-delete-image-thumb dashicons dashicons-no-alt"></span> |
@@ -601,17 +601,17 @@ discard block |
||
| 601 | 601 | // WordPress Editor. |
| 602 | 602 | case 'wysiwyg' : |
| 603 | 603 | // Get option value. |
| 604 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 604 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 605 | 605 | |
| 606 | 606 | // Get editor settings. |
| 607 | - $editor_settings = ! empty( $value['options'] ) ? $value['options'] : array(); |
|
| 607 | + $editor_settings = ! empty($value['options']) ? $value['options'] : array(); |
|
| 608 | 608 | ?> |
| 609 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 609 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 610 | 610 | <th scope="row" class="titledesc"> |
| 611 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 611 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 612 | 612 | </th> |
| 613 | 613 | <td class="give-forminp"> |
| 614 | - <?php wp_editor( $option_value, $value['id'], $editor_settings ); ?> |
|
| 614 | + <?php wp_editor($option_value, $value['id'], $editor_settings); ?> |
|
| 615 | 615 | <?php echo $description; ?> |
| 616 | 616 | </td> |
| 617 | 617 | </tr><?php |
@@ -620,9 +620,9 @@ discard block |
||
| 620 | 620 | // Custom: System setting field. |
| 621 | 621 | case 'system_info' : |
| 622 | 622 | ?> |
| 623 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 623 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 624 | 624 | <th scope="row" class="titledesc"> |
| 625 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 625 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 626 | 626 | </th> |
| 627 | 627 | <td class="give-forminp"> |
| 628 | 628 | <?php give_system_info_callback(); ?> |
@@ -633,14 +633,14 @@ discard block |
||
| 633 | 633 | |
| 634 | 634 | // Custom: Default gateways setting field. |
| 635 | 635 | case 'default_gateway' : |
| 636 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 636 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 637 | 637 | ?> |
| 638 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 638 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 639 | 639 | <th scope="row" class="titledesc"> |
| 640 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 640 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 641 | 641 | </th> |
| 642 | 642 | <td class="give-forminp"> |
| 643 | - <?php give_default_gateway_callback( $value, $option_value ); ?> |
|
| 643 | + <?php give_default_gateway_callback($value, $option_value); ?> |
|
| 644 | 644 | <?php echo $description; ?> |
| 645 | 645 | </td> |
| 646 | 646 | </tr><?php |
@@ -648,14 +648,14 @@ discard block |
||
| 648 | 648 | |
| 649 | 649 | // Custom: Enable gateways setting field. |
| 650 | 650 | case 'enabled_gateways' : |
| 651 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 651 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 652 | 652 | ?> |
| 653 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 653 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 654 | 654 | <th scope="row" class="titledesc"> |
| 655 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 655 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 656 | 656 | </th> |
| 657 | 657 | <td class="give-forminp"> |
| 658 | - <?php give_enabled_gateways_callback( $value, $option_value ); ?> |
|
| 658 | + <?php give_enabled_gateways_callback($value, $option_value); ?> |
|
| 659 | 659 | <?php echo $description; ?> |
| 660 | 660 | </td> |
| 661 | 661 | </tr><?php |
@@ -664,9 +664,9 @@ discard block |
||
| 664 | 664 | // Custom: Email preview buttons field. |
| 665 | 665 | case 'email_preview_buttons' : |
| 666 | 666 | ?> |
| 667 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 667 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 668 | 668 | <th scope="row" class="titledesc"> |
| 669 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
| 669 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
| 670 | 670 | </th> |
| 671 | 671 | <td class="give-forminp"> |
| 672 | 672 | <?php give_email_preview_buttons_callback(); ?> |
@@ -697,12 +697,12 @@ discard block |
||
| 697 | 697 | // Custom: Give Docs Link field type. |
| 698 | 698 | case 'give_docs_link' : |
| 699 | 699 | ?> |
| 700 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
| 700 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
| 701 | 701 | <td class="give-docs-link" colspan="2"> |
| 702 | 702 | <?php |
| 703 | - echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
|
| 703 | + echo '<p class="give-docs-link"><a href="'.esc_url($value['url']) |
|
| 704 | 704 | . '" target="_blank">' |
| 705 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"' ), $value['title'] ) |
|
| 705 | + . sprintf(esc_html__('Need Help? See docs on "%s"'), $value['title']) |
|
| 706 | 706 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
| 707 | 707 | ?> |
| 708 | 708 | </td> |
@@ -713,8 +713,8 @@ discard block |
||
| 713 | 713 | // You can add or handle your custom field action. |
| 714 | 714 | default: |
| 715 | 715 | // Get option value. |
| 716 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
| 717 | - do_action( 'give_admin_field_' . $value['type'], $value, $option_value ); |
|
| 716 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
| 717 | + do_action('give_admin_field_'.$value['type'], $value, $option_value); |
|
| 718 | 718 | break; |
| 719 | 719 | } |
| 720 | 720 | } |
@@ -730,11 +730,11 @@ discard block |
||
| 730 | 730 | * |
| 731 | 731 | * @return array The description and tip as a 2 element array |
| 732 | 732 | */ |
| 733 | - public static function get_field_description( $value ) { |
|
| 733 | + public static function get_field_description($value) { |
|
| 734 | 734 | $description = ''; |
| 735 | 735 | |
| 736 | - if ( ! empty( $value['desc'] ) ) { |
|
| 737 | - $description = '<p class="give-field-description">' . wp_kses_post( $value['desc'] ) . '</p>'; |
|
| 736 | + if ( ! empty($value['desc'])) { |
|
| 737 | + $description = '<p class="give-field-description">'.wp_kses_post($value['desc']).'</p>'; |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | return $description; |
@@ -751,11 +751,11 @@ discard block |
||
| 751 | 751 | * |
| 752 | 752 | * @return array The description and tip as a 2 element array |
| 753 | 753 | */ |
| 754 | - public static function get_field_title( $value ) { |
|
| 755 | - $title = esc_html( $value['title'] ); |
|
| 754 | + public static function get_field_title($value) { |
|
| 755 | + $title = esc_html($value['title']); |
|
| 756 | 756 | |
| 757 | 757 | // If html tag detected then allow them to print. |
| 758 | - if ( strip_tags( $title ) ) { |
|
| 758 | + if (strip_tags($title)) { |
|
| 759 | 759 | $title = $value['title']; |
| 760 | 760 | } |
| 761 | 761 | |
@@ -774,8 +774,8 @@ discard block |
||
| 774 | 774 | * |
| 775 | 775 | * @return bool |
| 776 | 776 | */ |
| 777 | - public static function save_fields( $options, $option_name = '' ) { |
|
| 778 | - if ( empty( $_POST ) ) { |
|
| 777 | + public static function save_fields($options, $option_name = '') { |
|
| 778 | + if (empty($_POST)) { |
|
| 779 | 779 | return false; |
| 780 | 780 | } |
| 781 | 781 | |
@@ -783,37 +783,37 @@ discard block |
||
| 783 | 783 | $update_options = array(); |
| 784 | 784 | |
| 785 | 785 | // Loop options and get values to save. |
| 786 | - foreach ( $options as $option ) { |
|
| 787 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
| 786 | + foreach ($options as $option) { |
|
| 787 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
| 788 | 788 | continue; |
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | // Get posted value. |
| 792 | - if ( strstr( $option['id'], '[' ) ) { |
|
| 793 | - parse_str( $option['id'], $option_name_array ); |
|
| 794 | - $field_option_name = current( array_keys( $option_name_array ) ); |
|
| 795 | - $setting_name = key( $option_name_array[ $field_option_name ] ); |
|
| 796 | - $raw_value = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null; |
|
| 792 | + if (strstr($option['id'], '[')) { |
|
| 793 | + parse_str($option['id'], $option_name_array); |
|
| 794 | + $field_option_name = current(array_keys($option_name_array)); |
|
| 795 | + $setting_name = key($option_name_array[$field_option_name]); |
|
| 796 | + $raw_value = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null; |
|
| 797 | 797 | } else { |
| 798 | 798 | $field_option_name = $option['id']; |
| 799 | 799 | $setting_name = ''; |
| 800 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
| 800 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | // Format the value based on option type. |
| 804 | - switch ( $option['type'] ) { |
|
| 804 | + switch ($option['type']) { |
|
| 805 | 805 | case 'checkbox' : |
| 806 | - $value = is_null( $raw_value ) ? '' : 'on'; |
|
| 806 | + $value = is_null($raw_value) ? '' : 'on'; |
|
| 807 | 807 | break; |
| 808 | 808 | case 'wysiwyg' : |
| 809 | 809 | case 'textarea' : |
| 810 | - $value = wp_kses_post( trim( $raw_value ) ); |
|
| 810 | + $value = wp_kses_post(trim($raw_value)); |
|
| 811 | 811 | break; |
| 812 | 812 | case 'multiselect' : |
| 813 | - $value = array_filter( array_map( 'give_clean', (array) $raw_value ) ); |
|
| 813 | + $value = array_filter(array_map('give_clean', (array) $raw_value)); |
|
| 814 | 814 | break; |
| 815 | 815 | default : |
| 816 | - $value = give_clean( $raw_value ); |
|
| 816 | + $value = give_clean($raw_value); |
|
| 817 | 817 | break; |
| 818 | 818 | } |
| 819 | 819 | |
@@ -822,37 +822,37 @@ discard block |
||
| 822 | 822 | * |
| 823 | 823 | * @since 1.8 |
| 824 | 824 | */ |
| 825 | - $value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value ); |
|
| 825 | + $value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value); |
|
| 826 | 826 | |
| 827 | 827 | /** |
| 828 | 828 | * Sanitize the value of an option by option name. |
| 829 | 829 | * |
| 830 | 830 | * @since 1.8 |
| 831 | 831 | */ |
| 832 | - $value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value ); |
|
| 832 | + $value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value); |
|
| 833 | 833 | |
| 834 | - if ( is_null( $value ) ) { |
|
| 834 | + if (is_null($value)) { |
|
| 835 | 835 | continue; |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | // Check if option is an array and handle that differently to single values. |
| 839 | - if ( $field_option_name && $setting_name ) { |
|
| 840 | - if ( ! isset( $update_options[ $field_option_name ] ) ) { |
|
| 841 | - $update_options[ $field_option_name ] = get_option( $field_option_name, array() ); |
|
| 839 | + if ($field_option_name && $setting_name) { |
|
| 840 | + if ( ! isset($update_options[$field_option_name])) { |
|
| 841 | + $update_options[$field_option_name] = get_option($field_option_name, array()); |
|
| 842 | 842 | } |
| 843 | - if ( ! is_array( $update_options[ $field_option_name ] ) ) { |
|
| 844 | - $update_options[ $field_option_name ] = array(); |
|
| 843 | + if ( ! is_array($update_options[$field_option_name])) { |
|
| 844 | + $update_options[$field_option_name] = array(); |
|
| 845 | 845 | } |
| 846 | - $update_options[ $field_option_name ][ $setting_name ] = $value; |
|
| 846 | + $update_options[$field_option_name][$setting_name] = $value; |
|
| 847 | 847 | } else { |
| 848 | - $update_options[ $field_option_name ] = $value; |
|
| 848 | + $update_options[$field_option_name] = $value; |
|
| 849 | 849 | } |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | // Save all options in our array or there own option name i.e. option id. |
| 853 | - if ( empty( $option_name ) ) { |
|
| 854 | - foreach ( $update_options as $name => $value ) { |
|
| 855 | - update_option( $name, $value ); |
|
| 853 | + if (empty($option_name)) { |
|
| 854 | + foreach ($update_options as $name => $value) { |
|
| 855 | + update_option($name, $value); |
|
| 856 | 856 | |
| 857 | 857 | /** |
| 858 | 858 | * Trigger action. |
@@ -861,13 +861,13 @@ discard block |
||
| 861 | 861 | * |
| 862 | 862 | * @since 1.8 |
| 863 | 863 | */ |
| 864 | - do_action( "give_save_option_{$name}", $value, $name ); |
|
| 864 | + do_action("give_save_option_{$name}", $value, $name); |
|
| 865 | 865 | } |
| 866 | 866 | } else { |
| 867 | - $old_options = ( $old_options = get_option( $option_name ) ) ? $old_options : array(); |
|
| 868 | - $update_options = array_merge( $old_options, $update_options ); |
|
| 867 | + $old_options = ($old_options = get_option($option_name)) ? $old_options : array(); |
|
| 868 | + $update_options = array_merge($old_options, $update_options); |
|
| 869 | 869 | |
| 870 | - update_option( $option_name, $update_options ); |
|
| 870 | + update_option($option_name, $update_options); |
|
| 871 | 871 | |
| 872 | 872 | /** |
| 873 | 873 | * Trigger action. |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | * |
| 877 | 877 | * @since 1.8 |
| 878 | 878 | */ |
| 879 | - do_action( "give_save_settings_{$option_name}", $update_options, $option_name ); |
|
| 879 | + do_action("give_save_settings_{$option_name}", $update_options, $option_name); |
|
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | return true; |
@@ -85,7 +85,7 @@ |
||
| 85 | 85 | * |
| 86 | 86 | * @since 1.8 |
| 87 | 87 | * |
| 88 | - * @param $setting_tab |
|
| 88 | + * @param string $setting_tab |
|
| 89 | 89 | * |
| 90 | 90 | * @return string |
| 91 | 91 | */ |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! class_exists( 'Give_CMB2_Settings_Loader' ) ) : |
|
| 12 | +if ( ! class_exists('Give_CMB2_Settings_Loader')) : |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * This class loads the cmb2 settings. |
@@ -52,30 +52,30 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | // Get current tab. |
| 54 | 54 | $this->current_tab = give_get_current_setting_tab(); |
| 55 | - $this->current_section = empty( $_REQUEST['section'] ) ? ( current( array_keys( $this->get_sections() ) ) ) : sanitize_title( $_REQUEST['section'] ); |
|
| 55 | + $this->current_section = empty($_REQUEST['section']) ? (current(array_keys($this->get_sections()))) : sanitize_title($_REQUEST['section']); |
|
| 56 | 56 | |
| 57 | 57 | // Tab ID. |
| 58 | 58 | $this->id = $this->current_tab; |
| 59 | 59 | |
| 60 | 60 | // Add addon tabs. |
| 61 | - add_filter( 'give-settings_tabs_array', array( $this, 'add_addon_settings_page' ), 999999 ); |
|
| 61 | + add_filter('give-settings_tabs_array', array($this, 'add_addon_settings_page'), 999999); |
|
| 62 | 62 | |
| 63 | 63 | // Add save hook to addons. |
| 64 | - add_action( 'give-settings_get_settings_pages', array( $this, 'setup_addon_save_hook' ), 999999 ); |
|
| 64 | + add_action('give-settings_get_settings_pages', array($this, 'setup_addon_save_hook'), 999999); |
|
| 65 | 65 | |
| 66 | 66 | // Add backward compatibility filters plugin settings. |
| 67 | - $setting_tabs = array( 'general', 'gateways', 'display', 'emails', 'addons', 'licenses' ); |
|
| 67 | + $setting_tabs = array('general', 'gateways', 'display', 'emails', 'addons', 'licenses'); |
|
| 68 | 68 | |
| 69 | 69 | // Filter Payment Gateways settings. |
| 70 | - if ( in_array( $this->current_tab, $setting_tabs ) ) { |
|
| 71 | - add_filter( "give_get_settings_{$this->current_tab}", array( |
|
| 70 | + if (in_array($this->current_tab, $setting_tabs)) { |
|
| 71 | + add_filter("give_get_settings_{$this->current_tab}", array( |
|
| 72 | 72 | $this, |
| 73 | 73 | 'get_filtered_addon_settings', |
| 74 | - ), 999999, 1 ); |
|
| 75 | - add_filter( "give_get_sections_{$this->current_tab}", array( |
|
| 74 | + ), 999999, 1); |
|
| 75 | + add_filter("give_get_sections_{$this->current_tab}", array( |
|
| 76 | 76 | $this, |
| 77 | 77 | 'get_filtered_addon_sections', |
| 78 | - ), 999999, 1 ); |
|
| 78 | + ), 999999, 1); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return string |
| 90 | 90 | */ |
| 91 | - function set_default_setting_tab( $setting_tab ) { |
|
| 91 | + function set_default_setting_tab($setting_tab) { |
|
| 92 | 92 | $default_tab = ''; |
| 93 | 93 | |
| 94 | 94 | // Set default tab to first setting tab. |
| 95 | - if ( $sections = array_keys( $this->get_sections() ) ) { |
|
| 96 | - $default_tab = current( $sections ); |
|
| 95 | + if ($sections = array_keys($this->get_sections())) { |
|
| 96 | + $default_tab = current($sections); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | return $default_tab; |
@@ -108,29 +108,29 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return mixed |
| 110 | 110 | */ |
| 111 | - function add_addon_settings_page( $pages ) { |
|
| 111 | + function add_addon_settings_page($pages) { |
|
| 112 | 112 | // Previous setting page. |
| 113 | 113 | $previous_pages = $this->prev_settings->give_get_settings_tabs(); |
| 114 | 114 | |
| 115 | 115 | // API and System Info setting tab merge to Tools setting tab, so remove them from tabs. |
| 116 | - unset( $previous_pages['api'] ); |
|
| 117 | - unset( $previous_pages['system_info'] ); |
|
| 116 | + unset($previous_pages['api']); |
|
| 117 | + unset($previous_pages['system_info']); |
|
| 118 | 118 | |
| 119 | 119 | // Tab is not register. |
| 120 | - $pages_diff = array_keys( array_diff( $previous_pages, $pages ) ); |
|
| 120 | + $pages_diff = array_keys(array_diff($previous_pages, $pages)); |
|
| 121 | 121 | |
| 122 | 122 | // Merge old settings with new settings. |
| 123 | - $pages = array_merge( $pages, $previous_pages ); |
|
| 123 | + $pages = array_merge($pages, $previous_pages); |
|
| 124 | 124 | |
| 125 | - if ( in_array( $this->current_tab, $pages_diff ) ) { |
|
| 125 | + if (in_array($this->current_tab, $pages_diff)) { |
|
| 126 | 126 | // Filter & actions. |
| 127 | - add_filter( "give_default_setting_tab_section_{$this->current_tab}", array( |
|
| 127 | + add_filter("give_default_setting_tab_section_{$this->current_tab}", array( |
|
| 128 | 128 | $this, |
| 129 | 129 | 'set_default_setting_tab', |
| 130 | - ), 10 ); |
|
| 131 | - add_action( "give-settings_sections_{$this->current_tab}_page", array( $this, 'output_sections' ) ); |
|
| 132 | - add_action( "give-settings_settings_{$this->current_tab}_page", array( $this, 'output' ), 10 ); |
|
| 133 | - add_action( "give-settings_save_{$this->current_tab}", array( $this, 'save' ) ); |
|
| 130 | + ), 10); |
|
| 131 | + add_action("give-settings_sections_{$this->current_tab}_page", array($this, 'output_sections')); |
|
| 132 | + add_action("give-settings_settings_{$this->current_tab}_page", array($this, 'output'), 10); |
|
| 133 | + add_action("give-settings_save_{$this->current_tab}", array($this, 'save')); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | return $pages; |
@@ -146,29 +146,29 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @return mixed |
| 148 | 148 | */ |
| 149 | - function setup_addon_save_hook( $pages ) { |
|
| 149 | + function setup_addon_save_hook($pages) { |
|
| 150 | 150 | $page_ids = array(); |
| 151 | 151 | |
| 152 | - foreach ( $pages as $page ) { |
|
| 153 | - $page_ids = $page->add_settings_page( $page_ids ); |
|
| 152 | + foreach ($pages as $page) { |
|
| 153 | + $page_ids = $page->add_settings_page($page_ids); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // Previous setting page. |
| 157 | 157 | $previous_pages = $this->prev_settings->give_get_settings_tabs(); |
| 158 | 158 | |
| 159 | 159 | // API and System Info setting tab merge to Tools setting tab, so remove them from tabs. |
| 160 | - unset( $previous_pages['api'] ); |
|
| 161 | - unset( $previous_pages['system_info'] ); |
|
| 160 | + unset($previous_pages['api']); |
|
| 161 | + unset($previous_pages['system_info']); |
|
| 162 | 162 | |
| 163 | 163 | // Tab is not register. |
| 164 | - $pages_diff = array_keys( array_diff( $previous_pages, $page_ids ) ); |
|
| 164 | + $pages_diff = array_keys(array_diff($previous_pages, $page_ids)); |
|
| 165 | 165 | |
| 166 | 166 | // Merge old settings with new settings. |
| 167 | - $pages = array_merge( $page_ids, $previous_pages ); |
|
| 167 | + $pages = array_merge($page_ids, $previous_pages); |
|
| 168 | 168 | |
| 169 | - if ( in_array( $this->current_tab, $pages_diff ) ) { |
|
| 169 | + if (in_array($this->current_tab, $pages_diff)) { |
|
| 170 | 170 | // Filter & actions. |
| 171 | - add_action( "give-settings_save_{$this->current_tab}", array( $this, 'save' ) ); |
|
| 171 | + add_action("give-settings_save_{$this->current_tab}", array($this, 'save')); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | return $pages; |
@@ -183,16 +183,16 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @return string |
| 185 | 185 | */ |
| 186 | - function get_section_name( $field_name ) { |
|
| 186 | + function get_section_name($field_name) { |
|
| 187 | 187 | // Bailout. |
| 188 | - if ( empty( $field_name ) ) { |
|
| 188 | + if (empty($field_name)) { |
|
| 189 | 189 | return $field_name; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - $section_name = explode( ' ', $field_name ); |
|
| 192 | + $section_name = explode(' ', $field_name); |
|
| 193 | 193 | |
| 194 | 194 | // Output. |
| 195 | - return strip_tags( implode( ' ', $section_name ) ); |
|
| 195 | + return strip_tags(implode(' ', $section_name)); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | |
@@ -205,39 +205,39 @@ discard block |
||
| 205 | 205 | * |
| 206 | 206 | * @return mixed |
| 207 | 207 | */ |
| 208 | - function get_filtered_addon_sections( $sections = array() ) { |
|
| 208 | + function get_filtered_addon_sections($sections = array()) { |
|
| 209 | 209 | // New sections. |
| 210 | 210 | $new_sections = array(); |
| 211 | - $sections_ID = array_keys( $sections ); |
|
| 211 | + $sections_ID = array_keys($sections); |
|
| 212 | 212 | |
| 213 | - if ( ( $setting_fields = $this->prev_settings->give_settings( $this->current_tab ) ) && ! empty( $setting_fields['fields'] ) ) { |
|
| 213 | + if (($setting_fields = $this->prev_settings->give_settings($this->current_tab)) && ! empty($setting_fields['fields'])) { |
|
| 214 | 214 | |
| 215 | - foreach ( $setting_fields['fields'] as $field ) { |
|
| 215 | + foreach ($setting_fields['fields'] as $field) { |
|
| 216 | 216 | // Section name. |
| 217 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : ''; |
|
| 218 | - $section_name = $this->get_section_name( $field['name'] ); |
|
| 217 | + $field['name'] = isset($field['name']) ? $field['name'] : ''; |
|
| 218 | + $section_name = $this->get_section_name($field['name']); |
|
| 219 | 219 | |
| 220 | 220 | // Check if section name exit and section title array is not empty. |
| 221 | - if ( ! empty( $sections ) && ! empty( $field['name'] ) ) { |
|
| 221 | + if ( ! empty($sections) && ! empty($field['name'])) { |
|
| 222 | 222 | |
| 223 | 223 | // Bailout: Do not load section if it is already exist. |
| 224 | 224 | if ( |
| 225 | - in_array( sanitize_title( $field['name'] ), $sections_ID ) // Check section id. |
|
| 226 | - || in_array( $section_name, $sections ) // Check section name. |
|
| 225 | + in_array(sanitize_title($field['name']), $sections_ID) // Check section id. |
|
| 226 | + || in_array($section_name, $sections) // Check section name. |
|
| 227 | 227 | ) { |
| 228 | 228 | continue; |
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // Collect new sections from addons. |
| 233 | - if ( 'give_title' == $field['type'] ) { |
|
| 234 | - $new_sections[ sanitize_title( $field['name'] ) ] = $section_name; |
|
| 233 | + if ('give_title' == $field['type']) { |
|
| 234 | + $new_sections[sanitize_title($field['name'])] = $section_name; |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | // Add new section. |
| 240 | - $sections = array_merge( $sections, $new_sections ); |
|
| 240 | + $sections = array_merge($sections, $new_sections); |
|
| 241 | 241 | |
| 242 | 242 | // Output. |
| 243 | 243 | return $sections; |
@@ -254,19 +254,19 @@ discard block |
||
| 254 | 254 | * |
| 255 | 255 | * @return array |
| 256 | 256 | */ |
| 257 | - function get_filtered_addon_settings( $settings, $setting_fields = array() ) { |
|
| 257 | + function get_filtered_addon_settings($settings, $setting_fields = array()) { |
|
| 258 | 258 | global $wp_filter; |
| 259 | 259 | |
| 260 | 260 | $new_setting_fields = array(); |
| 261 | 261 | |
| 262 | - if ( ! empty( $settings ) ) { |
|
| 262 | + if ( ! empty($settings)) { |
|
| 263 | 263 | // Bailout: If setting array contain first element of type title then it means it is already created with new setting api (skip this section ). |
| 264 | - if ( isset( $settings[0]['type'] ) && 'title' == $settings[0]['type'] ) { |
|
| 265 | - foreach ( $settings as $setting ) { |
|
| 264 | + if (isset($settings[0]['type']) && 'title' == $settings[0]['type']) { |
|
| 265 | + foreach ($settings as $setting) { |
|
| 266 | 266 | $new_setting_fields[] = $setting; |
| 267 | 267 | |
| 268 | 268 | // We need setting only till first section end. |
| 269 | - if ( 'sectionend' === $setting['type'] ) { |
|
| 269 | + if ('sectionend' === $setting['type']) { |
|
| 270 | 270 | break; |
| 271 | 271 | } |
| 272 | 272 | } |
@@ -278,24 +278,24 @@ discard block |
||
| 278 | 278 | $prev_title_field_id = ''; |
| 279 | 279 | |
| 280 | 280 | // Create new setting fields. |
| 281 | - foreach ( $settings as $index => $field ) { |
|
| 281 | + foreach ($settings as $index => $field) { |
|
| 282 | 282 | |
| 283 | 283 | // Bailout: Must need field type to process. |
| 284 | - if ( ! isset( $field['type'] ) ) { |
|
| 284 | + if ( ! isset($field['type'])) { |
|
| 285 | 285 | continue; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | // Set wrapper class if any. |
| 289 | - if ( ! empty( $field['row_classes'] ) ) { |
|
| 289 | + if ( ! empty($field['row_classes'])) { |
|
| 290 | 290 | $field['wrapper_class'] = $field['row_classes']; |
| 291 | - unset( $field['row_classes'] ); |
|
| 291 | + unset($field['row_classes']); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - $field['name'] = ! isset( $field['name'] ) ? '' : $field['name']; |
|
| 295 | - $field['desc'] = ! isset( $field['desc'] ) ? '' : $field['desc']; |
|
| 294 | + $field['name'] = ! isset($field['name']) ? '' : $field['name']; |
|
| 295 | + $field['desc'] = ! isset($field['desc']) ? '' : $field['desc']; |
|
| 296 | 296 | |
| 297 | 297 | // Modify cmb2 setting fields. |
| 298 | - switch ( $field['type'] ) { |
|
| 298 | + switch ($field['type']) { |
|
| 299 | 299 | case 'text' : |
| 300 | 300 | case 'file' : |
| 301 | 301 | $field['css'] = 'width:25em;'; |
@@ -319,18 +319,18 @@ discard block |
||
| 319 | 319 | $field['type'] = 'title'; |
| 320 | 320 | |
| 321 | 321 | // Since we are showing sections, so there now ned to show horizontal rules. |
| 322 | - if ( '<hr>' === $field['desc'] ) { |
|
| 322 | + if ('<hr>' === $field['desc']) { |
|
| 323 | 323 | $field['desc'] = ''; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | break; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if ( 'title' === $field['type'] ) { |
|
| 329 | + if ('title' === $field['type']) { |
|
| 330 | 330 | |
| 331 | 331 | // If we do not have first element as title then these field will be skip from frontend |
| 332 | 332 | // because there are not belong to any section, so put all abandon fields under first section. |
| 333 | - if ( $index && empty( $prev_title_field_id ) ) { |
|
| 333 | + if ($index && empty($prev_title_field_id)) { |
|
| 334 | 334 | array_unshift( |
| 335 | 335 | $new_setting_fields, |
| 336 | 336 | array( |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | $prev_title_field_id = $field['id']; |
| 345 | 345 | |
| 346 | 346 | continue; |
| 347 | - } elseif ( $index ) { |
|
| 347 | + } elseif ($index) { |
|
| 348 | 348 | // Section end. |
| 349 | 349 | $new_setting_fields[] = array( |
| 350 | 350 | 'type' => 'sectionend', |
@@ -376,52 +376,52 @@ discard block |
||
| 376 | 376 | |
| 377 | 377 | // Check if setting page has title section or not. |
| 378 | 378 | // If setting page does not have title section then add title section to it and fix section end array id. |
| 379 | - if ( 'title' !== $new_setting_fields[0]['type'] ) { |
|
| 379 | + if ('title' !== $new_setting_fields[0]['type']) { |
|
| 380 | 380 | array_unshift( |
| 381 | 381 | $new_setting_fields, |
| 382 | 382 | array( |
| 383 | - 'title' => ( isset( $settings['give_title'] ) ? $settings['give_title'] : '' ), |
|
| 383 | + 'title' => (isset($settings['give_title']) ? $settings['give_title'] : ''), |
|
| 384 | 384 | 'type' => 'title', |
| 385 | - 'desc' => ! empty( $setting_fields['desc'] ) ? $setting_fields['desc'] : '', |
|
| 386 | - 'id' => ( isset( $settings['id'] ) ? $settings['id'] : '' ), |
|
| 385 | + 'desc' => ! empty($setting_fields['desc']) ? $setting_fields['desc'] : '', |
|
| 386 | + 'id' => (isset($settings['id']) ? $settings['id'] : ''), |
|
| 387 | 387 | ) |
| 388 | 388 | ); |
| 389 | 389 | |
| 390 | 390 | // Update id in section end array if does not contain. |
| 391 | - if ( empty( $new_setting_fields[ count( $new_setting_fields ) - 1 ]['id'] ) ) { |
|
| 392 | - $new_setting_fields[ count( $new_setting_fields ) - 1 ]['id'] = ( isset( $settings['id'] ) ? $settings['id'] : '' ); |
|
| 391 | + if (empty($new_setting_fields[count($new_setting_fields) - 1]['id'])) { |
|
| 392 | + $new_setting_fields[count($new_setting_fields) - 1]['id'] = (isset($settings['id']) ? $settings['id'] : ''); |
|
| 393 | 393 | } |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | // Return only section related settings. |
| 397 | - if ( $sections = $this->get_filtered_addon_sections() ) { |
|
| 398 | - $new_setting_fields = $this->get_section_settings( $new_setting_fields ); |
|
| 397 | + if ($sections = $this->get_filtered_addon_sections()) { |
|
| 398 | + $new_setting_fields = $this->get_section_settings($new_setting_fields); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | // Third party plugin backward compatibility. |
| 402 | - $wp_filter_keys = array_keys( $wp_filter ); |
|
| 403 | - foreach ( $new_setting_fields as $index => $field ) { |
|
| 404 | - if ( ! isset( $field['type'] ) || in_array( $field['type'], array( 'title', 'sectionend' ) ) ) { |
|
| 402 | + $wp_filter_keys = array_keys($wp_filter); |
|
| 403 | + foreach ($new_setting_fields as $index => $field) { |
|
| 404 | + if ( ! isset($field['type']) || in_array($field['type'], array('title', 'sectionend'))) { |
|
| 405 | 405 | continue; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | $cmb2_filter_name = "cmb2_render_{$field['type']}"; |
| 409 | 409 | |
| 410 | - if ( in_array( $cmb2_filter_name, $wp_filter_keys ) ) { |
|
| 410 | + if (in_array($cmb2_filter_name, $wp_filter_keys)) { |
|
| 411 | 411 | |
| 412 | - if ( 0 >= version_compare( 4.7, get_bloginfo( 'version' ) ) && ! empty( $wp_filter[ $cmb2_filter_name ]->callbacks ) ) { |
|
| 413 | - $cmb2_filter_arr = current( $wp_filter[ $cmb2_filter_name ]->callbacks ); |
|
| 412 | + if (0 >= version_compare(4.7, get_bloginfo('version')) && ! empty($wp_filter[$cmb2_filter_name]->callbacks)) { |
|
| 413 | + $cmb2_filter_arr = current($wp_filter[$cmb2_filter_name]->callbacks); |
|
| 414 | 414 | } else { |
| 415 | - $cmb2_filter_arr = current( $wp_filter[ $cmb2_filter_name ] ); |
|
| 415 | + $cmb2_filter_arr = current($wp_filter[$cmb2_filter_name]); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - if ( ! empty( $cmb2_filter_arr ) ) { |
|
| 418 | + if ( ! empty($cmb2_filter_arr)) { |
|
| 419 | 419 | // Note: function can be called either globally or with class object, it depends on how developer invoke it. |
| 420 | - $new_setting_fields[ $index ]['func'] = current( $cmb2_filter_arr ); |
|
| 421 | - add_action( "give_admin_field_{$field['type']}", array( |
|
| 420 | + $new_setting_fields[$index]['func'] = current($cmb2_filter_arr); |
|
| 421 | + add_action("give_admin_field_{$field['type']}", array( |
|
| 422 | 422 | $this, |
| 423 | 423 | 'addon_setting_field', |
| 424 | - ), 10, 2 ); |
|
| 424 | + ), 10, 2); |
|
| 425 | 425 | } |
| 426 | 426 | } |
| 427 | 427 | } |
@@ -442,31 +442,31 @@ discard block |
||
| 442 | 442 | * |
| 443 | 443 | * @return array |
| 444 | 444 | */ |
| 445 | - function get_section_settings( $tab_settings ) { |
|
| 445 | + function get_section_settings($tab_settings) { |
|
| 446 | 446 | $current_section = give_get_current_setting_section(); |
| 447 | 447 | |
| 448 | 448 | // Note: If we are opening default tabe for addon setting then it is possible that we will get empty string as current section |
| 449 | 449 | // because default section filter added after save hook fire, so we will always get problem to save first section [default] or if there are only on section |
| 450 | 450 | // This is hack to fix this. |
| 451 | - if ( empty( $current_section ) ) { |
|
| 452 | - $current_section = $this->set_default_setting_tab( $current_section ); |
|
| 451 | + if (empty($current_section)) { |
|
| 452 | + $current_section = $this->set_default_setting_tab($current_section); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | $section_start = false; |
| 456 | 456 | $section_end = false; |
| 457 | 457 | $section_only_setting_fields = array(); |
| 458 | 458 | |
| 459 | - foreach ( $tab_settings as $field ) { |
|
| 460 | - if ( 'title' == $field['type'] && $current_section == sanitize_title( $field['title'] ) ) { |
|
| 459 | + foreach ($tab_settings as $field) { |
|
| 460 | + if ('title' == $field['type'] && $current_section == sanitize_title($field['title'])) { |
|
| 461 | 461 | $section_start = true; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - if ( ! $section_start || $section_end ) { |
|
| 464 | + if ( ! $section_start || $section_end) { |
|
| 465 | 465 | continue; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if ( $section_start && ! $section_end ) { |
|
| 469 | - if ( 'sectionend' == $field['type'] ) { |
|
| 468 | + if ($section_start && ! $section_end) { |
|
| 469 | + if ('sectionend' == $field['type']) { |
|
| 470 | 470 | $section_end = true; |
| 471 | 471 | } |
| 472 | 472 | $section_only_setting_fields[] = $field; |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | // Remove title from setting, pevent it from render in setting tab. |
| 477 | 477 | $section_only_setting_fields[0]['title'] = ''; |
| 478 | 478 | |
| 479 | - return apply_filters( "give_get_settings_{$this->current_tab}_{$current_section}", $section_only_setting_fields, $tab_settings ); |
|
| 479 | + return apply_filters("give_get_settings_{$this->current_tab}_{$current_section}", $section_only_setting_fields, $tab_settings); |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | |
@@ -490,17 +490,17 @@ discard block |
||
| 490 | 490 | * |
| 491 | 491 | * @return void |
| 492 | 492 | */ |
| 493 | - function addon_setting_field( $field, $saved_value ) { |
|
| 493 | + function addon_setting_field($field, $saved_value) { |
|
| 494 | 494 | // Create object for cmb2 function callback backward compatibility. |
| 495 | 495 | // Note: Do not call any cmb2 function on these objects |
| 496 | - $field_obj = (object) array( 'args' => $field ); |
|
| 497 | - $field_type_obj = (object) array( 'field' => $field_obj ); |
|
| 496 | + $field_obj = (object) array('args' => $field); |
|
| 497 | + $field_type_obj = (object) array('field' => $field_obj); |
|
| 498 | 498 | |
| 499 | - switch ( $this->current_tab ) : |
|
| 499 | + switch ($this->current_tab) : |
|
| 500 | 500 | case 'licenses': |
| 501 | 501 | ?> |
| 502 | 502 | <div class="give-settings-wrap give-settings-wrap-<?php echo $this->current_tab; ?>"> |
| 503 | - <?php $field['func']['function']( $field_obj, $saved_value, '', '', $field_type_obj ); ?> |
|
| 503 | + <?php $field['func']['function']($field_obj, $saved_value, '', '', $field_type_obj); ?> |
|
| 504 | 504 | </div> |
| 505 | 505 | <?php break; |
| 506 | 506 | |
@@ -508,19 +508,19 @@ discard block |
||
| 508 | 508 | $colspan = 'colspan="2"'; |
| 509 | 509 | ?> |
| 510 | 510 | <tr valign="top"> |
| 511 | - <?php if ( ! empty( $field['name'] ) && ! in_array( $field['name'], array( ' ' ) ) ) : ?> |
|
| 511 | + <?php if ( ! empty($field['name']) && ! in_array($field['name'], array(' '))) : ?> |
|
| 512 | 512 | <th scope="row" class="titledesc"> |
| 513 | 513 | <label |
| 514 | - for="<?php echo esc_attr( $field['name'] ); ?>"><?php echo $field['title']; ?></label> |
|
| 514 | + for="<?php echo esc_attr($field['name']); ?>"><?php echo $field['title']; ?></label> |
|
| 515 | 515 | </th> |
| 516 | 516 | <?php $colspan = ''; ?> |
| 517 | 517 | <?php endif; ?> |
| 518 | 518 | <td class="give-forminp" <?php echo $colspan; ?>> |
| 519 | 519 | <?php |
| 520 | - if ( is_array( $field['func']['function'] ) ) { |
|
| 521 | - $field['func']['function'][0]->$field['func']['function'][1]( $field_obj, $saved_value, '', '', $field_type_obj ); |
|
| 520 | + if (is_array($field['func']['function'])) { |
|
| 521 | + $field['func']['function'][0]->$field['func']['function'][1]($field_obj, $saved_value, '', '', $field_type_obj); |
|
| 522 | 522 | } else { |
| 523 | - $field['func']['function']( $field_obj, $saved_value, '', '', $field_type_obj ); |
|
| 523 | + $field['func']['function']($field_obj, $saved_value, '', '', $field_type_obj); |
|
| 524 | 524 | } |
| 525 | 525 | ?> |
| 526 | 526 | </td> |
@@ -538,10 +538,10 @@ discard block |
||
| 538 | 538 | public function get_sections() { |
| 539 | 539 | $sections = array(); |
| 540 | 540 | |
| 541 | - if ( ( $setting_fields = $this->prev_settings->give_settings( $this->current_tab ) ) && ! empty( $setting_fields['fields'] ) ) { |
|
| 542 | - foreach ( $setting_fields['fields'] as $field ) { |
|
| 543 | - if ( 'give_title' == $field['type'] ) { |
|
| 544 | - $sections[ sanitize_title( $field['name'] ) ] = $this->get_section_name( $field['name'] ); |
|
| 541 | + if (($setting_fields = $this->prev_settings->give_settings($this->current_tab)) && ! empty($setting_fields['fields'])) { |
|
| 542 | + foreach ($setting_fields['fields'] as $field) { |
|
| 543 | + if ('give_title' == $field['type']) { |
|
| 544 | + $sections[sanitize_title($field['name'])] = $this->get_section_name($field['name']); |
|
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | 547 | } |
@@ -561,16 +561,16 @@ discard block |
||
| 561 | 561 | |
| 562 | 562 | $new_setting_fields = array(); |
| 563 | 563 | |
| 564 | - if ( $setting_fields = $this->prev_settings->give_settings( $this->current_tab ) ) { |
|
| 565 | - if ( isset( $setting_fields['fields'] ) ) { |
|
| 564 | + if ($setting_fields = $this->prev_settings->give_settings($this->current_tab)) { |
|
| 565 | + if (isset($setting_fields['fields'])) { |
|
| 566 | 566 | |
| 567 | 567 | $tab_data = array( |
| 568 | 568 | 'id' => $setting_fields['id'], |
| 569 | 569 | 'give_title' => $setting_fields['give_title'], |
| 570 | - 'desc' => ( isset( $setting_fields['desc'] ) ? $setting_fields['desc'] : '' ), |
|
| 570 | + 'desc' => (isset($setting_fields['desc']) ? $setting_fields['desc'] : ''), |
|
| 571 | 571 | ); |
| 572 | 572 | |
| 573 | - $new_setting_fields = $this->get_filtered_addon_settings( $setting_fields['fields'], $tab_data ); |
|
| 573 | + $new_setting_fields = $this->get_filtered_addon_settings($setting_fields['fields'], $tab_data); |
|
| 574 | 574 | } |
| 575 | 575 | } |
| 576 | 576 | |
@@ -587,24 +587,24 @@ discard block |
||
| 587 | 587 | $sections = $this->get_sections(); |
| 588 | 588 | |
| 589 | 589 | // Show section settings only if setting section exist. |
| 590 | - if ( $this->current_section && ! in_array( $this->current_section, array_keys( $sections ) ) ) { |
|
| 591 | - echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; |
|
| 590 | + if ($this->current_section && ! in_array($this->current_section, array_keys($sections))) { |
|
| 591 | + echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; |
|
| 592 | 592 | $GLOBALS['give_hide_save_button'] = true; |
| 593 | 593 | |
| 594 | 594 | return; |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | // Bailout. |
| 598 | - if ( empty( $sections ) ) { |
|
| 598 | + if (empty($sections)) { |
|
| 599 | 599 | return; |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | echo '<ul class="subsubsub">'; |
| 603 | 603 | |
| 604 | - $array_keys = array_keys( $sections ); |
|
| 604 | + $array_keys = array_keys($sections); |
|
| 605 | 605 | |
| 606 | - foreach ( $sections as $id => $label ) { |
|
| 607 | - echo '<li><a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=' . $this->current_tab . '§ion=' . sanitize_title( $id ) ) . '" class="' . ( $this->current_section == $id ? 'current' : '' ) . '">' . strip_tags( $label ) . '</a> ' . ( end( $array_keys ) == $id ? '' : '|' ) . ' </li>'; |
|
| 606 | + foreach ($sections as $id => $label) { |
|
| 607 | + echo '<li><a href="'.admin_url('edit.php?post_type=give_forms&page=give-settings&tab='.$this->current_tab.'§ion='.sanitize_title($id)).'" class="'.($this->current_section == $id ? 'current' : '').'">'.strip_tags($label).'</a> '.(end($array_keys) == $id ? '' : '|').' </li>'; |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | echo '</ul><br class="clear" /><hr>'; |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | public function output() { |
| 620 | 620 | $settings = $this->get_settings(); |
| 621 | 621 | |
| 622 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
| 622 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | /** |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | public function save() { |
| 632 | 632 | $settings = $this->get_settings(); |
| 633 | 633 | |
| 634 | - Give_Admin_Settings::save_fields( $settings, 'give_settings' ); |
|
| 634 | + Give_Admin_Settings::save_fields($settings, 'give_settings'); |
|
| 635 | 635 | } |
| 636 | 636 | } |
| 637 | 637 | endif; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @return string |
| 22 | 22 | */ |
| 23 | 23 | function give_get_templates_dir() { |
| 24 | - return GIVE_PLUGIN_DIR . 'templates'; |
|
| 24 | + return GIVE_PLUGIN_DIR.'templates'; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | 33 | function give_get_templates_url() { |
| 34 | - return GIVE_PLUGIN_URL . 'templates'; |
|
| 34 | + return GIVE_PLUGIN_URL.'templates'; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -44,23 +44,23 @@ discard block |
||
| 44 | 44 | * @param string $template_path Template file path. Default is empty. |
| 45 | 45 | * @param string $default_path Default path. Default is empty. |
| 46 | 46 | */ |
| 47 | -function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 48 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
| 49 | - extract( $args ); |
|
| 47 | +function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 48 | + if ( ! empty($args) && is_array($args)) { |
|
| 49 | + extract($args); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - $template_names = array( $template_name . '.php' ); |
|
| 52 | + $template_names = array($template_name.'.php'); |
|
| 53 | 53 | |
| 54 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
| 54 | + $located = give_locate_template($template_names, $template_path, $default_path); |
|
| 55 | 55 | |
| 56 | - if ( ! file_exists( $located ) ) { |
|
| 56 | + if ( ! file_exists($located)) { |
|
| 57 | 57 | /* translators: %s: the template */ |
| 58 | - give_output_error( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true ); |
|
| 58 | + give_output_error(sprintf(__('The %s template was not found.', 'give'), $located), true); |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // Allow 3rd party plugin filter template file from their plugin. |
| 63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 63 | + $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * Fires in give template, before the file is included. |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | * @param string $located Template file filter by 3rd party plugin. |
| 75 | 75 | * @param array $args Passed arguments. |
| 76 | 76 | */ |
| 77 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 77 | + do_action('give_before_template_part', $template_name, $template_path, $located, $args); |
|
| 78 | 78 | |
| 79 | - include( $located ); |
|
| 79 | + include($located); |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Fires in give template, after the file is included. |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param string $located Template file filter by 3rd party plugin. |
| 91 | 91 | * @param array $args Passed arguments. |
| 92 | 92 | */ |
| 93 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 93 | + do_action('give_after_template_part', $template_name, $template_path, $located, $args); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @return string |
| 108 | 108 | */ |
| 109 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
| 109 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * Fires in give template part, before the template part is retrieved. |
@@ -118,20 +118,20 @@ discard block |
||
| 118 | 118 | * @param string $slug Template part file slug {slug}.php. |
| 119 | 119 | * @param string $name Template part file name {slug}-{name}.php. |
| 120 | 120 | */ |
| 121 | - do_action( "get_template_part_{$slug}", $slug, $name ); |
|
| 121 | + do_action("get_template_part_{$slug}", $slug, $name); |
|
| 122 | 122 | |
| 123 | 123 | // Setup possible parts |
| 124 | 124 | $templates = array(); |
| 125 | - if ( isset( $name ) ) { |
|
| 126 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 125 | + if (isset($name)) { |
|
| 126 | + $templates[] = $slug.'-'.$name.'.php'; |
|
| 127 | 127 | } |
| 128 | - $templates[] = $slug . '.php'; |
|
| 128 | + $templates[] = $slug.'.php'; |
|
| 129 | 129 | |
| 130 | 130 | // Allow template parts to be filtered |
| 131 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
| 131 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
| 132 | 132 | |
| 133 | 133 | // Return the part that is found |
| 134 | - return give_locate_template( $templates, $load, false ); |
|
| 134 | + return give_locate_template($templates, $load, false); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -152,37 +152,37 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return string The template filename if one is located. |
| 154 | 154 | */ |
| 155 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
| 155 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
| 156 | 156 | // No file found yet |
| 157 | 157 | $located = false; |
| 158 | 158 | |
| 159 | 159 | // Try to find a template file |
| 160 | - foreach ( (array) $template_names as $template_name ) { |
|
| 160 | + foreach ((array) $template_names as $template_name) { |
|
| 161 | 161 | |
| 162 | 162 | // Continue if template is empty |
| 163 | - if ( empty( $template_name ) ) { |
|
| 163 | + if (empty($template_name)) { |
|
| 164 | 164 | continue; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // Trim off any slashes from the template name |
| 168 | - $template_name = ltrim( $template_name, '/' ); |
|
| 168 | + $template_name = ltrim($template_name, '/'); |
|
| 169 | 169 | |
| 170 | 170 | // try locating this template file by looping through the template paths |
| 171 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
| 171 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
| 172 | 172 | |
| 173 | - if ( file_exists( $template_path . $template_name ) ) { |
|
| 174 | - $located = $template_path . $template_name; |
|
| 173 | + if (file_exists($template_path.$template_name)) { |
|
| 174 | + $located = $template_path.$template_name; |
|
| 175 | 175 | break; |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( $located ) { |
|
| 179 | + if ($located) { |
|
| 180 | 180 | break; |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 185 | - load_template( $located, $require_once ); |
|
| 184 | + if ((true == $load) && ! empty($located)) { |
|
| 185 | + load_template($located, $require_once); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | return $located; |
@@ -199,17 +199,17 @@ discard block |
||
| 199 | 199 | $template_dir = give_get_theme_template_dir_name(); |
| 200 | 200 | |
| 201 | 201 | $file_paths = array( |
| 202 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 203 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 202 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
| 203 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
| 204 | 204 | 100 => give_get_templates_dir() |
| 205 | 205 | ); |
| 206 | 206 | |
| 207 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
| 207 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
| 208 | 208 | |
| 209 | 209 | // sort the file paths based on priority |
| 210 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 210 | + ksort($file_paths, SORT_NUMERIC); |
|
| 211 | 211 | |
| 212 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 212 | + return array_map('trailingslashit', $file_paths); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @return string |
| 222 | 222 | */ |
| 223 | 223 | function give_get_theme_template_dir_name() { |
| 224 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
| 224 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -231,10 +231,10 @@ discard block |
||
| 231 | 231 | * @return void |
| 232 | 232 | */ |
| 233 | 233 | function give_version_in_header() { |
| 234 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
| 234 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
| 237 | +add_action('wp_head', 'give_version_in_header'); |
|
| 238 | 238 | |
| 239 | 239 | /** |
| 240 | 240 | * Determines if we're currently on the Donations History page. |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | function give_is_donation_history_page() { |
| 246 | 246 | |
| 247 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
| 247 | + $ret = is_page(give_get_option('history_page')); |
|
| 248 | 248 | |
| 249 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
| 249 | + return apply_filters('give_is_donation_history_page', $ret); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -258,25 +258,25 @@ discard block |
||
| 258 | 258 | * |
| 259 | 259 | * @return array Modified array of classes |
| 260 | 260 | */ |
| 261 | -function give_add_body_classes( $class ) { |
|
| 261 | +function give_add_body_classes($class) { |
|
| 262 | 262 | $classes = (array) $class; |
| 263 | 263 | |
| 264 | - if ( give_is_success_page() ) { |
|
| 264 | + if (give_is_success_page()) { |
|
| 265 | 265 | $classes[] = 'give-success'; |
| 266 | 266 | $classes[] = 'give-page'; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - if ( give_is_failed_transaction_page() ) { |
|
| 269 | + if (give_is_failed_transaction_page()) { |
|
| 270 | 270 | $classes[] = 'give-failed-transaction'; |
| 271 | 271 | $classes[] = 'give-page'; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if ( give_is_donation_history_page() ) { |
|
| 274 | + if (give_is_donation_history_page()) { |
|
| 275 | 275 | $classes[] = 'give-donation-history'; |
| 276 | 276 | $classes[] = 'give-page'; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - if ( give_is_test_mode() ) { |
|
| 279 | + if (give_is_test_mode()) { |
|
| 280 | 280 | $classes[] = 'give-test-mode'; |
| 281 | 281 | $classes[] = 'give-page'; |
| 282 | 282 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | //Theme-specific Classes used to prevent conflicts via CSS |
| 285 | 285 | $current_theme = wp_get_theme(); |
| 286 | 286 | |
| 287 | - switch ( $current_theme->template ) { |
|
| 287 | + switch ($current_theme->template) { |
|
| 288 | 288 | |
| 289 | 289 | case 'Divi': |
| 290 | 290 | $classes[] = 'give-divi'; |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - return array_unique( $classes ); |
|
| 301 | + return array_unique($classes); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
| 304 | +add_filter('body_class', 'give_add_body_classes'); |
|
| 305 | 305 | |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -317,22 +317,22 @@ discard block |
||
| 317 | 317 | * |
| 318 | 318 | * @return array |
| 319 | 319 | */ |
| 320 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
| 321 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
| 320 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
| 321 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
| 322 | 322 | return $classes; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
| 326 | 326 | |
| 327 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
| 328 | - unset( $classes[ $key ] ); |
|
| 327 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
| 328 | + unset($classes[$key]); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | return $classes; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | |
| 335 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
| 335 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
| 336 | 336 | |
| 337 | 337 | /** |
| 338 | 338 | * Get the placeholder image URL for forms etc |
@@ -342,84 +342,84 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | function give_get_placeholder_img_src() { |
| 344 | 344 | |
| 345 | - $placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
| 345 | + $placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
| 346 | 346 | |
| 347 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
| 347 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * Global |
| 353 | 353 | */ |
| 354 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
| 354 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
| 355 | 355 | |
| 356 | 356 | /** |
| 357 | 357 | * Output the start of the page wrapper. |
| 358 | 358 | */ |
| 359 | 359 | function give_output_content_wrapper() { |
| 360 | - give_get_template_part( 'global/wrapper-start' ); |
|
| 360 | + give_get_template_part('global/wrapper-start'); |
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
| 363 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
| 364 | 364 | |
| 365 | 365 | /** |
| 366 | 366 | * Output the end of the page wrapper. |
| 367 | 367 | */ |
| 368 | 368 | function give_output_content_wrapper_end() { |
| 369 | - give_get_template_part( 'global/wrapper-end' ); |
|
| 369 | + give_get_template_part('global/wrapper-end'); |
|
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
| 374 | 374 | * Single Give Form |
| 375 | 375 | */ |
| 376 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
| 376 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
| 377 | 377 | function give_left_sidebar_pre_wrap() { |
| 378 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
| 378 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
| 382 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
| 383 | 383 | function give_left_sidebar_post_wrap() { |
| 384 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
| 384 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
| 388 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
| 389 | 389 | function give_get_forms_sidebar() { |
| 390 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
| 390 | + give_get_template_part('single-give-form/sidebar'); |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
| 394 | +if ( ! function_exists('give_show_form_images')) { |
|
| 395 | 395 | |
| 396 | 396 | /** |
| 397 | 397 | * Output the donation form featured image. |
| 398 | 398 | */ |
| 399 | 399 | function give_show_form_images() { |
| 400 | - if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
| 401 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
| 400 | + if (give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
| 401 | + give_get_template_part('single-give-form/featured-image'); |
|
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
| 406 | +if ( ! function_exists('give_template_single_title')) { |
|
| 407 | 407 | |
| 408 | 408 | /** |
| 409 | 409 | * Output the form title. |
| 410 | 410 | */ |
| 411 | 411 | function give_template_single_title() { |
| 412 | - give_get_template_part( 'single-give-form/title' ); |
|
| 412 | + give_get_template_part('single-give-form/title'); |
|
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | -if ( ! function_exists( 'give_show_avatars' ) ) { |
|
| 416 | +if ( ! function_exists('give_show_avatars')) { |
|
| 417 | 417 | |
| 418 | 418 | /** |
| 419 | 419 | * Output the product title. |
| 420 | 420 | */ |
| 421 | 421 | function give_show_avatars() { |
| 422 | - echo do_shortcode( '[give_donors_gravatars]' ); |
|
| 422 | + echo do_shortcode('[give_donors_gravatars]'); |
|
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | 425 | |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | * Conditional Functions |
| 428 | 428 | */ |
| 429 | 429 | |
| 430 | -if ( ! function_exists( 'is_give_form' ) ) { |
|
| 430 | +if ( ! function_exists('is_give_form')) { |
|
| 431 | 431 | |
| 432 | 432 | /** |
| 433 | 433 | * is_give_form |
@@ -439,11 +439,11 @@ discard block |
||
| 439 | 439 | * @return bool |
| 440 | 440 | */ |
| 441 | 441 | function is_give_form() { |
| 442 | - return is_singular( array( 'give_form' ) ); |
|
| 442 | + return is_singular(array('give_form')); |
|
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | -if ( ! function_exists( 'is_give_category' ) ) { |
|
| 446 | +if ( ! function_exists('is_give_category')) { |
|
| 447 | 447 | |
| 448 | 448 | /** |
| 449 | 449 | * is_give_category |
@@ -458,12 +458,12 @@ discard block |
||
| 458 | 458 | * |
| 459 | 459 | * @return bool |
| 460 | 460 | */ |
| 461 | - function is_give_category( $term = '' ) { |
|
| 462 | - return is_tax( 'give_forms_category', $term ); |
|
| 461 | + function is_give_category($term = '') { |
|
| 462 | + return is_tax('give_forms_category', $term); |
|
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | -if ( ! function_exists( 'is_give_tag' ) ) { |
|
| 466 | +if ( ! function_exists('is_give_tag')) { |
|
| 467 | 467 | |
| 468 | 468 | /** |
| 469 | 469 | * is_give_tag |
@@ -478,12 +478,12 @@ discard block |
||
| 478 | 478 | * |
| 479 | 479 | * @return bool |
| 480 | 480 | */ |
| 481 | - function is_give_tag( $term = '' ) { |
|
| 482 | - return is_tax( 'give_forms_tag', $term ); |
|
| 481 | + function is_give_tag($term = '') { |
|
| 482 | + return is_tax('give_forms_tag', $term); |
|
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | -if ( ! function_exists( 'is_give_taxonomy' ) ) { |
|
| 486 | +if ( ! function_exists('is_give_taxonomy')) { |
|
| 487 | 487 | |
| 488 | 488 | /** |
| 489 | 489 | * is_give_taxonomy |
@@ -495,6 +495,6 @@ discard block |
||
| 495 | 495 | * @return bool |
| 496 | 496 | */ |
| 497 | 497 | function is_give_taxonomy() { |
| 498 | - return is_tax( get_object_taxonomies( 'give_form' ) ); |
|
| 498 | + return is_tax(get_object_taxonomies('give_form')); |
|
| 499 | 499 | } |
| 500 | 500 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) {
|
|
| 13 | +if ( ! defined('ABSPATH')) {
|
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -36,29 +36,29 @@ discard block |
||
| 36 | 36 | /** |
| 37 | 37 | * Templates |
| 38 | 38 | */ |
| 39 | - add_filter( 'template_include', array( __CLASS__, 'template_loader' ) ); |
|
| 39 | + add_filter('template_include', array(__CLASS__, 'template_loader'));
|
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * Content Wrappers |
| 43 | 43 | */ |
| 44 | - add_action( 'give_before_main_content', 'give_output_content_wrapper', 10 ); |
|
| 45 | - add_action( 'give_after_main_content', 'give_output_content_wrapper_end', 10 ); |
|
| 44 | + add_action('give_before_main_content', 'give_output_content_wrapper', 10);
|
|
| 45 | + add_action('give_after_main_content', 'give_output_content_wrapper_end', 10);
|
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Entry Summary Classes |
| 49 | 49 | */ |
| 50 | - add_filter( 'give_forms_single_summary_classes', array( $this, 'give_set_single_summary_classes' ) ); |
|
| 50 | + add_filter('give_forms_single_summary_classes', array($this, 'give_set_single_summary_classes'));
|
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Sidebar |
| 54 | 54 | */ |
| 55 | - add_action( 'give_before_single_form_summary', array( $this, 'give_output_sidebar_option' ), 1 ); |
|
| 55 | + add_action('give_before_single_form_summary', array($this, 'give_output_sidebar_option'), 1);
|
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Single Forms Summary Box |
| 59 | 59 | */ |
| 60 | - add_action( 'give_single_form_summary', 'give_template_single_title', 5 ); |
|
| 61 | - add_action( 'give_single_form_summary', 'give_get_donation_form', 10 ); |
|
| 60 | + add_action('give_single_form_summary', 'give_template_single_title', 5);
|
|
| 61 | + add_action('give_single_form_summary', 'give_get_donation_form', 10);
|
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return string $classes List of space separated class names. |
| 75 | 75 | */ |
| 76 | - public function give_set_single_summary_classes( $classes ) {
|
|
| 76 | + public function give_set_single_summary_classes($classes) {
|
|
| 77 | 77 | |
| 78 | 78 | //Add full width class when feature image is disabled AND no widgets are present |
| 79 | - if ( ! give_is_setting_enabled( give_get_option( 'form_sidebar' ) ) ) {
|
|
| 79 | + if ( ! give_is_setting_enabled(give_get_option('form_sidebar'))) {
|
|
| 80 | 80 | $classes .= ' give-full-width'; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | public function give_output_sidebar_option() {
|
| 98 | 98 | |
| 99 | 99 | //Add full width class when feature image is disabled AND no widgets are present |
| 100 | - if ( give_is_setting_enabled( give_get_option( 'form_sidebar' ) ) ) {
|
|
| 101 | - add_action( 'give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5 ); |
|
| 102 | - add_action( 'give_before_single_form_summary', 'give_show_form_images', 10 ); |
|
| 103 | - add_action( 'give_before_single_form_summary', 'give_get_forms_sidebar', 20 ); |
|
| 104 | - add_action( 'give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30 ); |
|
| 100 | + if (give_is_setting_enabled(give_get_option('form_sidebar'))) {
|
|
| 101 | + add_action('give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5);
|
|
| 102 | + add_action('give_before_single_form_summary', 'give_show_form_images', 10);
|
|
| 103 | + add_action('give_before_single_form_summary', 'give_get_forms_sidebar', 20);
|
|
| 104 | + add_action('give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30);
|
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | } |
@@ -123,20 +123,20 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return string $template |
| 125 | 125 | */ |
| 126 | - public static function template_loader( $template ) {
|
|
| 127 | - $find = array( 'give.php' ); |
|
| 126 | + public static function template_loader($template) {
|
|
| 127 | + $find = array('give.php');
|
|
| 128 | 128 | $file = ''; |
| 129 | 129 | |
| 130 | - if ( is_single() && get_post_type() == 'give_forms' ) {
|
|
| 130 | + if (is_single() && get_post_type() == 'give_forms') {
|
|
| 131 | 131 | $file = 'single-give-form.php'; |
| 132 | 132 | $find[] = $file; |
| 133 | - $find[] = apply_filters( 'give_template_path', 'give/' ) . $file; |
|
| 133 | + $find[] = apply_filters('give_template_path', 'give/').$file;
|
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if ( $file ) {
|
|
| 137 | - $template = locate_template( array_unique( $find ) ); |
|
| 138 | - if ( ! $template ) {
|
|
| 139 | - $template = GIVE_PLUGIN_DIR . '/templates/' . $file; |
|
| 136 | + if ($file) {
|
|
| 137 | + $template = locate_template(array_unique($find)); |
|
| 138 | + if ( ! $template) {
|
|
| 139 | + $template = GIVE_PLUGIN_DIR.'/templates/'.$file; |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | function give_tools_recount_stats_display() { |
| 24 | 24 | |
| 25 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 25 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 26 | 26 | return; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -31,27 +31,27 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @since 1.5 |
| 33 | 33 | */ |
| 34 | - do_action( 'give_tools_recount_stats_before' ); |
|
| 34 | + do_action('give_tools_recount_stats_before'); |
|
| 35 | 35 | ?> |
| 36 | 36 | <div id="poststuff"> |
| 37 | 37 | <div class="postbox"> |
| 38 | 38 | |
| 39 | - <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e( 'Recount Stats', 'give' ); ?></span></h2> |
|
| 39 | + <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e('Recount Stats', 'give'); ?></span></h2> |
|
| 40 | 40 | |
| 41 | 41 | <div class="inside recount-stats-controls"> |
| 42 | - <p><?php esc_html_e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p> |
|
| 42 | + <p><?php esc_html_e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?></p> |
|
| 43 | 43 | <form method="post" id="give-tools-recount-form" class="give-export-form"> |
| 44 | 44 | |
| 45 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
| 45 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
| 46 | 46 | |
| 47 | 47 | <select name="give-export-class" id="recount-stats-type"> |
| 48 | - <option value="0" selected="selected" disabled="disabled"><?php esc_html_e( 'Please select an option', 'give' ); ?></option> |
|
| 49 | - <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option> |
|
| 50 | - <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for a Form', 'give' ); ?></option> |
|
| 51 | - <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for All Forms', 'give' ); ?></option> |
|
| 52 | - <option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php esc_html_e( 'Recalculate Donor Statistics', 'give' ); ?></option> |
|
| 53 | - <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e( 'Delete Test Transactions', 'give' ); ?></option> |
|
| 54 | - <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e( 'Delete All Data', 'give' ); ?></option> |
|
| 48 | + <option value="0" selected="selected" disabled="disabled"><?php esc_html_e('Please select an option', 'give'); ?></option> |
|
| 49 | + <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e('Recalculate Total Donation Income Amount', 'give'); ?></option> |
|
| 50 | + <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?></option> |
|
| 51 | + <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?></option> |
|
| 52 | + <option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php esc_html_e('Recalculate Donor Statistics', 'give'); ?></option> |
|
| 53 | + <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e('Delete Test Transactions', 'give'); ?></option> |
|
| 54 | + <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e('Delete All Data', 'give'); ?></option> |
|
| 55 | 55 | <?php |
| 56 | 56 | /** |
| 57 | 57 | * Fires in the recount stats selectbox. |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @since 1.5 |
| 62 | 62 | */ |
| 63 | - do_action( 'give_recount_tool_options' ); |
|
| 63 | + do_action('give_recount_tool_options'); |
|
| 64 | 64 | ?> |
| 65 | 65 | </select> |
| 66 | 66 | |
@@ -68,22 +68,22 @@ discard block |
||
| 68 | 68 | <?php |
| 69 | 69 | $args = array( |
| 70 | 70 | 'name' => 'form_id', |
| 71 | - 'number' => - 1, |
|
| 71 | + 'number' => -1, |
|
| 72 | 72 | 'chosen' => true, |
| 73 | 73 | ); |
| 74 | - echo Give()->html->forms_dropdown( $args ); |
|
| 74 | + echo Give()->html->forms_dropdown($args); |
|
| 75 | 75 | ?> |
| 76 | 76 | </span> |
| 77 | 77 | |
| 78 | - <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e( 'Submit', 'give' ); ?>" class="button-secondary"/> |
|
| 78 | + <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e('Submit', 'give'); ?>" class="button-secondary"/> |
|
| 79 | 79 | |
| 80 | 80 | <br/> |
| 81 | 81 | |
| 82 | 82 | <span class="give-recount-stats-descriptions"> |
| 83 | - <span id="recount-stats"><?php esc_html_e( 'Recalculates the overall donation income amount.', 'give' ); ?></span> |
|
| 84 | - <span id="recount-form"><?php esc_html_e( 'Recalculates the donation and income stats for a specific form.', 'give' ); ?></span> |
|
| 85 | - <span id="recount-all"><?php esc_html_e( 'Recalculates the earnings and sales stats for all forms.', 'give' ); ?></span> |
|
| 86 | - <span id="recount-customer-stats"><?php esc_html_e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span> |
|
| 83 | + <span id="recount-stats"><?php esc_html_e('Recalculates the overall donation income amount.', 'give'); ?></span> |
|
| 84 | + <span id="recount-form"><?php esc_html_e('Recalculates the donation and income stats for a specific form.', 'give'); ?></span> |
|
| 85 | + <span id="recount-all"><?php esc_html_e('Recalculates the earnings and sales stats for all forms.', 'give'); ?></span> |
|
| 86 | + <span id="recount-customer-stats"><?php esc_html_e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span> |
|
| 87 | 87 | <?php |
| 88 | 88 | /** |
| 89 | 89 | * Fires in the recount stats description area. |
@@ -92,10 +92,10 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @since 1.5 |
| 94 | 94 | */ |
| 95 | - do_action( 'give_recount_tool_descriptions' ); |
|
| 95 | + do_action('give_recount_tool_descriptions'); |
|
| 96 | 96 | ?> |
| 97 | - <span id="delete-test-transactions"><?php _e( '<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give' ); ?></span> |
|
| 98 | - <span id="reset-stats"><?php _e( '<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give' ); ?></span> |
|
| 97 | + <span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give'); ?></span> |
|
| 98 | + <span id="reset-stats"><?php _e('<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give'); ?></span> |
|
| 99 | 99 | </span> |
| 100 | 100 | |
| 101 | 101 | <span class="spinner"></span> |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @since 1.5 |
| 111 | 111 | */ |
| 112 | - do_action( 'give_tools_recount_forms' ); |
|
| 112 | + do_action('give_tools_recount_forms'); |
|
| 113 | 113 | ?> |
| 114 | 114 | </div><!-- .inside --> |
| 115 | 115 | </div><!-- .postbox --> |
@@ -120,5 +120,5 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @since 1.5 |
| 122 | 122 | */ |
| 123 | - do_action( 'give_tools_recount_stats_after' ); |
|
| 123 | + do_action('give_tools_recount_stats_after'); |
|
| 124 | 124 | } |
| 125 | 125 | \ No newline at end of file |
@@ -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; // Exit if accessed directly |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Settings_API' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Settings_API')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Settings_API. |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function __construct() { |
| 45 | 45 | $this->id = 'api'; |
| 46 | - $this->label = esc_html__( 'API', 'give' ); |
|
| 46 | + $this->label = esc_html__('API', 'give'); |
|
| 47 | 47 | |
| 48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
| 49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
| 48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
| 49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | * @param array $pages Lst of pages. |
| 57 | 57 | * @return array |
| 58 | 58 | */ |
| 59 | - public function add_settings_page( $pages ) { |
|
| 60 | - $pages[ $this->id ] = $this->label; |
|
| 59 | + public function add_settings_page($pages) { |
|
| 60 | + $pages[$this->id] = $this->label; |
|
| 61 | 61 | |
| 62 | 62 | return $pages; |
| 63 | 63 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $GLOBALS['give_hide_save_button'] = true; |
| 74 | 74 | |
| 75 | 75 | // Get settings. |
| 76 | - $settings = apply_filters( 'give_settings_system', array( |
|
| 76 | + $settings = apply_filters('give_settings_system', array( |
|
| 77 | 77 | array( |
| 78 | 78 | 'id' => 'give_tools_api', |
| 79 | 79 | 'type' => 'title', |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | ), |
| 82 | 82 | array( |
| 83 | 83 | 'id' => 'api', |
| 84 | - 'name' => esc_html__( 'API', 'give' ), |
|
| 84 | + 'name' => esc_html__('API', 'give'), |
|
| 85 | 85 | 'type' => 'api', |
| 86 | 86 | ), |
| 87 | 87 | array( |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @since 1.8 |
| 98 | 98 | * @param array $settings |
| 99 | 99 | */ |
| 100 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
| 100 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
| 101 | 101 | |
| 102 | 102 | // Output. |
| 103 | 103 | return $settings; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | public function output() { |
| 113 | 113 | $settings = $this->get_settings(); |
| 114 | 114 | |
| 115 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
| 115 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
@@ -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; // Exit if accessed directly |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Settings_Data' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Settings_Data')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Settings_Data. |
@@ -43,15 +43,15 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function __construct() { |
| 45 | 45 | $this->id = 'data'; |
| 46 | - $this->label = esc_html__( 'Data', 'give' ); |
|
| 46 | + $this->label = esc_html__('Data', 'give'); |
|
| 47 | 47 | |
| 48 | - add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
| 49 | - add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
| 48 | + add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20); |
|
| 49 | + add_action("give-tools_settings_{$this->id}_page", array($this, 'output')); |
|
| 50 | 50 | |
| 51 | 51 | // Do not use main form for this tab. |
| 52 | - if( give_get_current_setting_tab() === $this->id ) { |
|
| 53 | - add_action( "give-tools_open_form", '__return_empty_string' ); |
|
| 54 | - add_action( "give-tools_close_form", '__return_empty_string' ); |
|
| 52 | + if (give_get_current_setting_tab() === $this->id) { |
|
| 53 | + add_action("give-tools_open_form", '__return_empty_string'); |
|
| 54 | + add_action("give-tools_close_form", '__return_empty_string'); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | * @param array $pages Lst of pages. |
| 63 | 63 | * @return array |
| 64 | 64 | */ |
| 65 | - public function add_settings_page( $pages ) { |
|
| 66 | - $pages[ $this->id ] = $this->label; |
|
| 65 | + public function add_settings_page($pages) { |
|
| 66 | + $pages[$this->id] = $this->label; |
|
| 67 | 67 | |
| 68 | 68 | return $pages; |
| 69 | 69 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $GLOBALS['give_hide_save_button'] = true; |
| 80 | 80 | |
| 81 | 81 | // Get settings. |
| 82 | - $settings = apply_filters( 'give_settings_system', array( |
|
| 82 | + $settings = apply_filters('give_settings_system', array( |
|
| 83 | 83 | array( |
| 84 | 84 | 'id' => 'give_tools_tools', |
| 85 | 85 | 'type' => 'title', |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | ), |
| 88 | 88 | array( |
| 89 | 89 | 'id' => 'api', |
| 90 | - 'name' => esc_html__( 'Tools', 'give' ), |
|
| 90 | + 'name' => esc_html__('Tools', 'give'), |
|
| 91 | 91 | 'type' => 'data', |
| 92 | 92 | ), |
| 93 | 93 | array( |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @since 1.8 |
| 104 | 104 | * @param array $settings |
| 105 | 105 | */ |
| 106 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
| 106 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
| 107 | 107 | |
| 108 | 108 | // Output. |
| 109 | 109 | return $settings; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | public function output() { |
| 119 | 119 | $settings = $this->get_settings(); |
| 120 | 120 | |
| 121 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
| 121 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
@@ -1283,7 +1283,7 @@ |
||
| 1283 | 1283 | * |
| 1284 | 1284 | * @param $field |
| 1285 | 1285 | * |
| 1286 | - * @return string |
|
| 1286 | + * @return integer |
|
| 1287 | 1287 | */ |
| 1288 | 1288 | function _give_set_field_give_id_default_value( $field ) { |
| 1289 | 1289 | return 0; |
@@ -645,20 +645,20 @@ |
||
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | /** |
| 648 | - * Output the documentation link. |
|
| 649 | - * |
|
| 650 | - * @since 1.8 |
|
| 651 | - * @param array $field { |
|
| 652 | - * Optional. Array of customizable link attributes. |
|
| 653 | - * |
|
| 654 | - * @type string $name Name of input field. Default ''. |
|
| 655 | - * @type string $type Type of input field. Default 'text'. |
|
| 656 | - * @type string $url Value to be passed as a link. Default 'https://givewp.com/documentation'. |
|
| 657 | - * @type string $title Value to be passed as text of link. Default 'Documentation'. |
|
| 658 | - * @type array $attributes List of attributes of input field. Default array(). |
|
| 659 | - * for example: 'attributes' => array( 'placeholder' => '*****', 'class' => '****' ) |
|
| 660 | - * } |
|
| 661 | - * @return void |
|
| 648 | + * Output the documentation link. |
|
| 649 | + * |
|
| 650 | + * @since 1.8 |
|
| 651 | + * @param array $field { |
|
| 652 | + * Optional. Array of customizable link attributes. |
|
| 653 | + * |
|
| 654 | + * @type string $name Name of input field. Default ''. |
|
| 655 | + * @type string $type Type of input field. Default 'text'. |
|
| 656 | + * @type string $url Value to be passed as a link. Default 'https://givewp.com/documentation'. |
|
| 657 | + * @type string $title Value to be passed as text of link. Default 'Documentation'. |
|
| 658 | + * @type array $attributes List of attributes of input field. Default array(). |
|
| 659 | + * for example: 'attributes' => array( 'placeholder' => '*****', 'class' => '****' ) |
|
| 660 | + * } |
|
| 661 | + * @return void |
|
| 662 | 662 | */ |
| 663 | 663 | |
| 664 | 664 | function give_docs_link($field) { |
@@ -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; |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | default: |
| 78 | 78 | |
| 79 | 79 | if ( |
| 80 | - array_key_exists( 'callback', $field ) |
|
| 81 | - && ! empty( $field['callback'] ) |
|
| 80 | + array_key_exists('callback', $field) |
|
| 81 | + && ! empty($field['callback']) |
|
| 82 | 82 | ) { |
| 83 | 83 | $func_name = $field['callback']; |
| 84 | 84 | } else { |
@@ -91,15 +91,15 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @since 1.8 |
| 93 | 93 | */ |
| 94 | - $func_name = apply_filters( 'give_get_field_callback', $func_name, $field ); |
|
| 94 | + $func_name = apply_filters('give_get_field_callback', $func_name, $field); |
|
| 95 | 95 | |
| 96 | 96 | // Exit if not any function exist. |
| 97 | 97 | // Check if render callback exist or not. |
| 98 | - if ( empty( $func_name ) ) { |
|
| 98 | + if (empty($func_name)) { |
|
| 99 | 99 | return false; |
| 100 | - } elseif ( is_string( $func_name ) && ! function_exists( "$func_name" ) ) { |
|
| 100 | + } elseif (is_string($func_name) && ! function_exists("$func_name")) { |
|
| 101 | 101 | return false; |
| 102 | - } elseif ( is_array( $func_name ) && ! method_exists( $func_name[0], "$func_name[1]" ) ) { |
|
| 102 | + } elseif (is_array($func_name) && ! method_exists($func_name[0], "$func_name[1]")) { |
|
| 103 | 103 | return false; |
| 104 | 104 | } |
| 105 | 105 | |
@@ -115,36 +115,36 @@ discard block |
||
| 115 | 115 | * |
| 116 | 116 | * @return bool |
| 117 | 117 | */ |
| 118 | -function give_render_field( $field ) { |
|
| 118 | +function give_render_field($field) { |
|
| 119 | 119 | |
| 120 | 120 | // Check if render callback exist or not. |
| 121 | - if ( ! ( $func_name = give_get_field_callback( $field ) ) ) { |
|
| 121 | + if ( ! ($func_name = give_get_field_callback($field))) { |
|
| 122 | 122 | return false; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | // CMB2 compatibility: Push all classes to attributes's class key |
| 126 | - if ( empty( $field['class'] ) ) { |
|
| 126 | + if (empty($field['class'])) { |
|
| 127 | 127 | $field['class'] = ''; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( empty( $field['attributes']['class'] ) ) { |
|
| 130 | + if (empty($field['attributes']['class'])) { |
|
| 131 | 131 | $field['attributes']['class'] = ''; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - $field['attributes']['class'] = trim( "give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}" ); |
|
| 135 | - unset( $field['class'] ); |
|
| 134 | + $field['attributes']['class'] = trim("give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}"); |
|
| 135 | + unset($field['class']); |
|
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | // CMB2 compatibility: Set wrapper class if any. |
| 139 | - if ( ! empty( $field['row_classes'] ) ) { |
|
| 139 | + if ( ! empty($field['row_classes'])) { |
|
| 140 | 140 | $field['wrapper_class'] = $field['row_classes']; |
| 141 | - unset( $field['row_classes'] ); |
|
| 141 | + unset($field['row_classes']); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // Set field params on basis of cmb2 field name. |
| 145 | - switch ( $field['type'] ) { |
|
| 145 | + switch ($field['type']) { |
|
| 146 | 146 | case 'radio_inline': |
| 147 | - if ( empty( $field['wrapper_class'] ) ) { |
|
| 147 | + if (empty($field['wrapper_class'])) { |
|
| 148 | 148 | $field['wrapper_class'] = ''; |
| 149 | 149 | } |
| 150 | 150 | $field['wrapper_class'] .= ' give-inline-radio-fields'; |
@@ -157,15 +157,15 @@ discard block |
||
| 157 | 157 | case 'text-small' : |
| 158 | 158 | case 'text_small' : |
| 159 | 159 | // CMB2 compatibility: Set field type to text. |
| 160 | - $field['type'] = isset( $field['attributes']['type'] ) ? $field['attributes']['type'] : 'text'; |
|
| 160 | + $field['type'] = isset($field['attributes']['type']) ? $field['attributes']['type'] : 'text'; |
|
| 161 | 161 | |
| 162 | 162 | // CMB2 compatibility: Set data type to price. |
| 163 | 163 | if ( |
| 164 | - empty( $field['data_type'] ) |
|
| 165 | - && ! empty( $field['attributes']['class'] ) |
|
| 164 | + empty($field['data_type']) |
|
| 165 | + && ! empty($field['attributes']['class']) |
|
| 166 | 166 | && ( |
| 167 | - false !== strpos( $field['attributes']['class'], 'money' ) |
|
| 168 | - || false !== strpos( $field['attributes']['class'], 'amount' ) |
|
| 167 | + false !== strpos($field['attributes']['class'], 'money') |
|
| 168 | + || false !== strpos($field['attributes']['class'], 'amount') |
|
| 169 | 169 | ) |
| 170 | 170 | ) { |
| 171 | 171 | $field['data_type'] = 'decimal'; |
@@ -184,22 +184,22 @@ discard block |
||
| 184 | 184 | case 'give_default_radio_inline': |
| 185 | 185 | $field['type'] = 'radio'; |
| 186 | 186 | $field['options'] = array( |
| 187 | - 'default' => __( 'Default' ), |
|
| 187 | + 'default' => __('Default'), |
|
| 188 | 188 | ); |
| 189 | 189 | break; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // CMB2 compatibility: Add support to define field description by desc & description param. |
| 193 | 193 | // We encourage you to use description param. |
| 194 | - $field['description'] = ( ! empty( $field['description'] ) |
|
| 194 | + $field['description'] = ( ! empty($field['description']) |
|
| 195 | 195 | ? $field['description'] |
| 196 | - : ( ! empty( $field['desc'] ) ? $field['desc'] : '' ) ); |
|
| 196 | + : ( ! empty($field['desc']) ? $field['desc'] : '')); |
|
| 197 | 197 | |
| 198 | 198 | // Call render function. |
| 199 | - if ( is_array( $func_name ) ) { |
|
| 200 | - $func_name[0]->$func_name[1]( $field ); |
|
| 199 | + if (is_array($func_name)) { |
|
| 200 | + $func_name[0]->$func_name[1]($field); |
|
| 201 | 201 | } else { |
| 202 | - $func_name( $field ); |
|
| 202 | + $func_name($field); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | 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 | |
@@ -290,29 +290,29 @@ discard block |
||
| 290 | 290 | * } |
| 291 | 291 | * @return void |
| 292 | 292 | */ |
| 293 | -function give_hidden_input( $field ) { |
|
| 293 | +function give_hidden_input($field) { |
|
| 294 | 294 | global $thepostid, $post; |
| 295 | 295 | |
| 296 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 297 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 296 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 297 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 298 | 298 | |
| 299 | 299 | // Custom attribute handling |
| 300 | 300 | $custom_attributes = array(); |
| 301 | 301 | |
| 302 | - if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) { |
|
| 302 | + if ( ! empty($field['attributes']) && is_array($field['attributes'])) { |
|
| 303 | 303 | |
| 304 | - foreach ( $field['attributes'] as $attribute => $value ) { |
|
| 305 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; |
|
| 304 | + foreach ($field['attributes'] as $attribute => $value) { |
|
| 305 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"'; |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | ?> |
| 309 | 309 | |
| 310 | 310 | <input |
| 311 | 311 | type="hidden" |
| 312 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 313 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
| 314 | - value="<?php echo esc_attr( $field['value'] ); ?>" |
|
| 315 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 312 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 313 | + id="<?php echo esc_attr($field['id']); ?>" |
|
| 314 | + value="<?php echo esc_attr($field['value']); ?>" |
|
| 315 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 316 | 316 | /> |
| 317 | 317 | <?php |
| 318 | 318 | } |
@@ -336,27 +336,27 @@ discard block |
||
| 336 | 336 | * } |
| 337 | 337 | * @return void |
| 338 | 338 | */ |
| 339 | -function give_textarea_input( $field ) { |
|
| 339 | +function give_textarea_input($field) { |
|
| 340 | 340 | global $thepostid, $post; |
| 341 | 341 | |
| 342 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 343 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 344 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 345 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 342 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 343 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 344 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 345 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 346 | 346 | |
| 347 | 347 | ?> |
| 348 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
| 349 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
| 348 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
| 349 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
| 350 | 350 | <textarea |
| 351 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
| 352 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 353 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
| 351 | + style="<?php echo esc_attr($field['style']); ?>" |
|
| 352 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 353 | + id="<?php echo esc_attr($field['id']); ?>" |
|
| 354 | 354 | rows="10" |
| 355 | 355 | cols="20" |
| 356 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 357 | - ><?php echo esc_textarea( $field['value'] ); ?></textarea> |
|
| 356 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 357 | + ><?php echo esc_textarea($field['value']); ?></textarea> |
|
| 358 | 358 | <?php |
| 359 | - echo give_get_field_description( $field ); |
|
| 359 | + echo give_get_field_description($field); |
|
| 360 | 360 | echo '</p>'; |
| 361 | 361 | } |
| 362 | 362 | |
@@ -378,24 +378,24 @@ discard block |
||
| 378 | 378 | * } |
| 379 | 379 | * @return void |
| 380 | 380 | */ |
| 381 | -function give_wysiwyg( $field ) { |
|
| 381 | +function give_wysiwyg($field) { |
|
| 382 | 382 | global $thepostid, $post; |
| 383 | 383 | |
| 384 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 385 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 386 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 387 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 388 | - $field['unique_field_id'] = give_get_field_name( $field ); |
|
| 384 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 385 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 386 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 387 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 388 | + $field['unique_field_id'] = give_get_field_name($field); |
|
| 389 | 389 | $editor_attributes = array( |
| 390 | - 'textarea_name' => isset( $field['repeatable_field_id'] ) ? $field['repeatable_field_id'] : $field['id'], |
|
| 390 | + 'textarea_name' => isset($field['repeatable_field_id']) ? $field['repeatable_field_id'] : $field['id'], |
|
| 391 | 391 | 'textarea_rows' => '10', |
| 392 | - 'editor_css' => esc_attr( $field['style'] ), |
|
| 392 | + 'editor_css' => esc_attr($field['style']), |
|
| 393 | 393 | 'editor_class' => $field['attributes']['class'] |
| 394 | 394 | ); |
| 395 | - $data_wp_editor = ' data-wp-editor="'. base64_encode( json_encode( array( $field['value'], $field['unique_field_id'],$editor_attributes ) ) ) .'"'; |
|
| 396 | - $data_wp_editor = isset( $field['repeatable_field_id'] ) ? $data_wp_editor : ''; |
|
| 395 | + $data_wp_editor = ' data-wp-editor="'.base64_encode(json_encode(array($field['value'], $field['unique_field_id'], $editor_attributes))).'"'; |
|
| 396 | + $data_wp_editor = isset($field['repeatable_field_id']) ? $data_wp_editor : ''; |
|
| 397 | 397 | |
| 398 | - 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>'; |
|
| 398 | + 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>'; |
|
| 399 | 399 | |
| 400 | 400 | wp_editor( |
| 401 | 401 | $field['value'], |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | $editor_attributes |
| 404 | 404 | ); |
| 405 | 405 | |
| 406 | - echo give_get_field_description( $field ); |
|
| 406 | + echo give_get_field_description($field); |
|
| 407 | 407 | echo '</div>'; |
| 408 | 408 | } |
| 409 | 409 | |
@@ -426,29 +426,29 @@ discard block |
||
| 426 | 426 | * } |
| 427 | 427 | * @return void |
| 428 | 428 | */ |
| 429 | -function give_checkbox( $field ) { |
|
| 429 | +function give_checkbox($field) { |
|
| 430 | 430 | global $thepostid, $post; |
| 431 | 431 | |
| 432 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 433 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 434 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 435 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 436 | - $field['cbvalue'] = isset( $field['cbvalue'] ) ? $field['cbvalue'] : 'on'; |
|
| 437 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
| 432 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 433 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 434 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 435 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 436 | + $field['cbvalue'] = isset($field['cbvalue']) ? $field['cbvalue'] : 'on'; |
|
| 437 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
| 438 | 438 | ?> |
| 439 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
| 440 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
| 439 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
| 440 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
| 441 | 441 | <input |
| 442 | 442 | type="checkbox" |
| 443 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
| 444 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 445 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
| 446 | - value="<?php echo esc_attr( $field['cbvalue'] ); ?>" |
|
| 447 | - <?php echo checked( $field['value'], $field['cbvalue'], false ); ?> |
|
| 448 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 443 | + style="<?php echo esc_attr($field['style']); ?>" |
|
| 444 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 445 | + id="<?php echo esc_attr($field['id']); ?>" |
|
| 446 | + value="<?php echo esc_attr($field['cbvalue']); ?>" |
|
| 447 | + <?php echo checked($field['value'], $field['cbvalue'], false); ?> |
|
| 448 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 449 | 449 | /> |
| 450 | 450 | <?php |
| 451 | - echo give_get_field_description( $field ); |
|
| 451 | + echo give_get_field_description($field); |
|
| 452 | 452 | echo '</p>'; |
| 453 | 453 | } |
| 454 | 454 | |
@@ -472,29 +472,29 @@ discard block |
||
| 472 | 472 | * } |
| 473 | 473 | * @return void |
| 474 | 474 | */ |
| 475 | -function give_select( $field ) { |
|
| 475 | +function give_select($field) { |
|
| 476 | 476 | global $thepostid, $post; |
| 477 | 477 | |
| 478 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 479 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 480 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 481 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 482 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
| 478 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 479 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 480 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 481 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 482 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
| 483 | 483 | ?> |
| 484 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
| 485 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
| 484 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
| 485 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
| 486 | 486 | <select |
| 487 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
| 488 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 489 | - style="<?php echo esc_attr( $field['style'] ) ?>" |
|
| 490 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 487 | + id="<?php echo esc_attr($field['id']); ?>" |
|
| 488 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 489 | + style="<?php echo esc_attr($field['style']) ?>" |
|
| 490 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 491 | 491 | > |
| 492 | 492 | <?php |
| 493 | - foreach ( $field['options'] as $key => $value ) { |
|
| 494 | - echo '<option value="' . esc_attr( $key ) . '" ' . selected( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>'; |
|
| 493 | + foreach ($field['options'] as $key => $value) { |
|
| 494 | + echo '<option value="'.esc_attr($key).'" '.selected(esc_attr($field['value']), esc_attr($key), false).'>'.esc_html($value).'</option>'; |
|
| 495 | 495 | } |
| 496 | 496 | echo '</select>'; |
| 497 | - echo give_get_field_description( $field ); |
|
| 497 | + echo give_get_field_description($field); |
|
| 498 | 498 | echo '</p>'; |
| 499 | 499 | } |
| 500 | 500 | |
@@ -518,32 +518,32 @@ discard block |
||
| 518 | 518 | * } |
| 519 | 519 | * @return void |
| 520 | 520 | */ |
| 521 | -function give_radio( $field ) { |
|
| 521 | +function give_radio($field) { |
|
| 522 | 522 | global $thepostid, $post; |
| 523 | 523 | |
| 524 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 525 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 526 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 527 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 528 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
| 524 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 525 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 526 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 527 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 528 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
| 529 | 529 | |
| 530 | - 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">'; |
|
| 530 | + 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">'; |
|
| 531 | 531 | |
| 532 | - foreach ( $field['options'] as $key => $value ) { |
|
| 532 | + foreach ($field['options'] as $key => $value) { |
|
| 533 | 533 | |
| 534 | 534 | echo '<li><label><input |
| 535 | - name="' . give_get_field_name( $field ) . '" |
|
| 536 | - value="' . esc_attr( $key ) . '" |
|
| 535 | + name="' . give_get_field_name($field).'" |
|
| 536 | + value="' . esc_attr($key).'" |
|
| 537 | 537 | type="radio" |
| 538 | - style="' . esc_attr( $field['style'] ) . '" |
|
| 539 | - ' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . ' ' |
|
| 540 | - . give_get_custom_attributes( $field ) . ' |
|
| 541 | - /> ' . esc_html( $value ) . '</label> |
|
| 538 | + style="' . esc_attr($field['style']).'" |
|
| 539 | + ' . checked(esc_attr($field['value']), esc_attr($key), false).' ' |
|
| 540 | + . give_get_custom_attributes($field).' |
|
| 541 | + /> ' . esc_html($value).'</label> |
|
| 542 | 542 | </li>'; |
| 543 | 543 | } |
| 544 | 544 | echo '</ul>'; |
| 545 | 545 | |
| 546 | - echo give_get_field_description( $field ); |
|
| 546 | + echo give_get_field_description($field); |
|
| 547 | 547 | echo '</fieldset>'; |
| 548 | 548 | } |
| 549 | 549 | |
@@ -565,27 +565,27 @@ discard block |
||
| 565 | 565 | * } |
| 566 | 566 | * @return void |
| 567 | 567 | */ |
| 568 | -function give_colorpicker( $field ) { |
|
| 568 | +function give_colorpicker($field) { |
|
| 569 | 569 | global $thepostid, $post; |
| 570 | 570 | |
| 571 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 572 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 573 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 574 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 575 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
| 571 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 572 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 573 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 574 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 575 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
| 576 | 576 | $field['type'] = 'text'; |
| 577 | 577 | ?> |
| 578 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
| 579 | - <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
| 578 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
| 579 | + <label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
| 580 | 580 | <input |
| 581 | - type="<?php echo esc_attr( $field['type'] ); ?>" |
|
| 582 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
| 583 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 584 | - id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr( $field['value'] ); ?>" |
|
| 585 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 581 | + type="<?php echo esc_attr($field['type']); ?>" |
|
| 582 | + style="<?php echo esc_attr($field['style']); ?>" |
|
| 583 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 584 | + id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr($field['value']); ?>" |
|
| 585 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 586 | 586 | /> |
| 587 | 587 | <?php |
| 588 | - echo give_get_field_description( $field ); |
|
| 588 | + echo give_get_field_description($field); |
|
| 589 | 589 | echo '</p>'; |
| 590 | 590 | } |
| 591 | 591 | |
@@ -598,32 +598,32 @@ discard block |
||
| 598 | 598 | * @param array $field |
| 599 | 599 | * |
| 600 | 600 | */ |
| 601 | -function give_media( $field ) { |
|
| 601 | +function give_media($field) { |
|
| 602 | 602 | global $thepostid, $post; |
| 603 | 603 | |
| 604 | - $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; |
|
| 605 | - $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; |
|
| 606 | - $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; |
|
| 607 | - $field['value'] = give_get_field_value( $field, $thepostid ); |
|
| 608 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; |
|
| 604 | + $thepostid = empty($thepostid) ? $post->ID : $thepostid; |
|
| 605 | + $field['style'] = isset($field['style']) ? $field['style'] : ''; |
|
| 606 | + $field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : ''; |
|
| 607 | + $field['value'] = give_get_field_value($field, $thepostid); |
|
| 608 | + $field['name'] = isset($field['name']) ? $field['name'] : $field['id']; |
|
| 609 | 609 | $field['type'] = 'text'; |
| 610 | 610 | $field['attributes']['class'] = "{$field['attributes']['class']} give-text-medium"; |
| 611 | 611 | |
| 612 | 612 | // Allow developer to save attachment ID or attachment url as metadata. |
| 613 | - $field['fvalue'] = isset( $field['fvalue'] ) ? $field['fvalue'] : 'url'; |
|
| 613 | + $field['fvalue'] = isset($field['fvalue']) ? $field['fvalue'] : 'url'; |
|
| 614 | 614 | ?> |
| 615 | - <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>"> |
|
| 616 | - <label for="<?php echo give_get_field_name( $field ) ?>"><?php echo wp_kses_post( $field['name'] ); ?></label> |
|
| 615 | + <p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>"> |
|
| 616 | + <label for="<?php echo give_get_field_name($field) ?>"><?php echo wp_kses_post($field['name']); ?></label> |
|
| 617 | 617 | <input |
| 618 | - name="<?php echo give_get_field_name( $field ); ?>" |
|
| 619 | - id="<?php echo esc_attr( $field['id'] ); ?>" |
|
| 618 | + name="<?php echo give_get_field_name($field); ?>" |
|
| 619 | + id="<?php echo esc_attr($field['id']); ?>" |
|
| 620 | 620 | type="text" |
| 621 | 621 | value="<?php echo $field['value']; ?>" |
| 622 | - style="<?php echo esc_attr( $field['style'] ); ?>" |
|
| 622 | + style="<?php echo esc_attr($field['style']); ?>" |
|
| 623 | 623 | data-fvalue="<?php echo $field['fvalue']; ?>" |
| 624 | - <?php echo give_get_custom_attributes( $field ); ?> |
|
| 625 | - /> <input class="give-media-upload button" type="button" value="<?php echo esc_html__( 'Add or Upload File', 'give' ); ?>"> |
|
| 626 | - <?php echo give_get_field_description( $field ); ?> |
|
| 624 | + <?php echo give_get_custom_attributes($field); ?> |
|
| 625 | + /> <input class="give-media-upload button" type="button" value="<?php echo esc_html__('Add or Upload File', 'give'); ?>"> |
|
| 626 | + <?php echo give_get_field_description($field); ?> |
|
| 627 | 627 | </p> |
| 628 | 628 | <?php |
| 629 | 629 | } |
@@ -637,27 +637,27 @@ discard block |
||
| 637 | 637 | * |
| 638 | 638 | * @return void |
| 639 | 639 | */ |
| 640 | -function give_default_gateway( $field ) { |
|
| 640 | +function give_default_gateway($field) { |
|
| 641 | 641 | global $thepostid, $post; |
| 642 | 642 | |
| 643 | 643 | // get all active payment gateways. |
| 644 | - $gateways = give_get_enabled_payment_gateways( $thepostid ); |
|
| 644 | + $gateways = give_get_enabled_payment_gateways($thepostid); |
|
| 645 | 645 | $field['options'] = array(); |
| 646 | 646 | |
| 647 | 647 | // Set field option value. |
| 648 | - if( ! empty( $gateways ) ) { |
|
| 649 | - foreach ( $gateways as $key => $option ) { |
|
| 650 | - $field['options'][ $key ] = $option['admin_label']; |
|
| 648 | + if ( ! empty($gateways)) { |
|
| 649 | + foreach ($gateways as $key => $option) { |
|
| 650 | + $field['options'][$key] = $option['admin_label']; |
|
| 651 | 651 | } |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | //Add a field to the Give Form admin single post view of this field |
| 655 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
| 656 | - $field['options'] = array_merge( array( 'global' => esc_html__( 'Global Default', 'give' ) ), $field['options'] ); |
|
| 655 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
| 656 | + $field['options'] = array_merge(array('global' => esc_html__('Global Default', 'give')), $field['options']); |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | // Render select field. |
| 660 | - give_select( $field ); |
|
| 660 | + give_select($field); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | /** |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | $field['url'] = isset($field['url']) ? $field['url'] : 'https://givewp.com/documentation'; |
| 682 | 682 | $field['title'] = isset($field['title']) ? $field['title'] : 'Documentation'; |
| 683 | 683 | |
| 684 | - echo '<p class="give-docs-link"><a href="' . esc_url($field['url']) |
|
| 684 | + echo '<p class="give-docs-link"><a href="'.esc_url($field['url']) |
|
| 685 | 685 | . '" target="_blank">' |
| 686 | 686 | . sprintf(esc_html__('Need Help? See docs on "%s"'), $field['title']) |
| 687 | 687 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
@@ -699,13 +699,13 @@ discard block |
||
| 699 | 699 | * |
| 700 | 700 | * @return mixed |
| 701 | 701 | */ |
| 702 | -function give_get_field_value( $field, $postid ) { |
|
| 703 | - if ( isset( $field['attributes']['value'] ) ) { |
|
| 702 | +function give_get_field_value($field, $postid) { |
|
| 703 | + if (isset($field['attributes']['value'])) { |
|
| 704 | 704 | return $field['attributes']['value']; |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | // Get value from db. |
| 708 | - $field_value = get_post_meta( $postid, $field['id'], true ); |
|
| 708 | + $field_value = get_post_meta($postid, $field['id'], true); |
|
| 709 | 709 | |
| 710 | 710 | /** |
| 711 | 711 | * Filter the field value before apply default value. |
@@ -714,11 +714,11 @@ discard block |
||
| 714 | 714 | * |
| 715 | 715 | * @param mixed $field_value Field value. |
| 716 | 716 | */ |
| 717 | - $field_value = apply_filters( "{$field['id']}_field_value", $field_value, $field, $postid ); |
|
| 717 | + $field_value = apply_filters("{$field['id']}_field_value", $field_value, $field, $postid); |
|
| 718 | 718 | |
| 719 | 719 | |
| 720 | 720 | // Set default value if no any data saved to db. |
| 721 | - if ( ! $field_value && isset( $field['default'] ) ) { |
|
| 721 | + if ( ! $field_value && isset($field['default'])) { |
|
| 722 | 722 | $field_value = $field['default']; |
| 723 | 723 | } |
| 724 | 724 | |
@@ -734,10 +734,10 @@ discard block |
||
| 734 | 734 | * |
| 735 | 735 | * @return string |
| 736 | 736 | */ |
| 737 | -function give_get_field_description( $field ) { |
|
| 737 | +function give_get_field_description($field) { |
|
| 738 | 738 | $field_desc_html = ''; |
| 739 | - if ( ! empty( $field['description'] ) ) { |
|
| 740 | - $field_desc_html = '<span class="give-field-description">' . wp_kses_post( $field['description'] ) . '</span>'; |
|
| 739 | + if ( ! empty($field['description'])) { |
|
| 740 | + $field_desc_html = '<span class="give-field-description">'.wp_kses_post($field['description']).'</span>'; |
|
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | return $field_desc_html; |
@@ -752,18 +752,18 @@ discard block |
||
| 752 | 752 | * |
| 753 | 753 | * @return string |
| 754 | 754 | */ |
| 755 | -function give_get_custom_attributes( $field ) { |
|
| 755 | +function give_get_custom_attributes($field) { |
|
| 756 | 756 | // Custom attribute handling |
| 757 | 757 | $custom_attributes = array(); |
| 758 | 758 | |
| 759 | - if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) { |
|
| 759 | + if ( ! empty($field['attributes']) && is_array($field['attributes'])) { |
|
| 760 | 760 | |
| 761 | - foreach ( $field['attributes'] as $attribute => $value ) { |
|
| 762 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; |
|
| 761 | + foreach ($field['attributes'] as $attribute => $value) { |
|
| 762 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"'; |
|
| 763 | 763 | } |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - return implode( ' ', $custom_attributes ); |
|
| 766 | + return implode(' ', $custom_attributes); |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | /** |
@@ -779,8 +779,8 @@ discard block |
||
| 779 | 779 | * |
| 780 | 780 | * @return string |
| 781 | 781 | */ |
| 782 | -function give_get_repeater_field_value( $field, $field_group, $fields ) { |
|
| 783 | - $field_value = ( isset( $field_group[ $field['id'] ] ) ? $field_group[ $field['id'] ] : '' ); |
|
| 782 | +function give_get_repeater_field_value($field, $field_group, $fields) { |
|
| 783 | + $field_value = (isset($field_group[$field['id']]) ? $field_group[$field['id']] : ''); |
|
| 784 | 784 | |
| 785 | 785 | /** |
| 786 | 786 | * Filter the specific repeater field value |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | * |
| 790 | 790 | * @param string $field_id |
| 791 | 791 | */ |
| 792 | - $field_value = apply_filters( "give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields ); |
|
| 792 | + $field_value = apply_filters("give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields); |
|
| 793 | 793 | |
| 794 | 794 | /** |
| 795 | 795 | * Filter the repeater field value |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | * |
| 799 | 799 | * @param string $field_id |
| 800 | 800 | */ |
| 801 | - $field_value = apply_filters( 'give_get_repeater_field_value', $field_value, $field, $field_group, $fields ); |
|
| 801 | + $field_value = apply_filters('give_get_repeater_field_value', $field_value, $field, $field_group, $fields); |
|
| 802 | 802 | |
| 803 | 803 | return $field_value; |
| 804 | 804 | } |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | * |
| 817 | 817 | * @return string |
| 818 | 818 | */ |
| 819 | -function give_get_repeater_field_id( $field, $fields, $default = false ) { |
|
| 819 | +function give_get_repeater_field_id($field, $fields, $default = false) { |
|
| 820 | 820 | $row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}'; |
| 821 | 821 | |
| 822 | 822 | // Get field id. |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | * |
| 830 | 830 | * @param string $field_id |
| 831 | 831 | */ |
| 832 | - $field_id = apply_filters( "give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default ); |
|
| 832 | + $field_id = apply_filters("give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default); |
|
| 833 | 833 | |
| 834 | 834 | |
| 835 | 835 | /** |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | * |
| 840 | 840 | * @param string $field_id |
| 841 | 841 | */ |
| 842 | - $field_id = apply_filters( 'give_get_repeater_field_id', $field_id, $field, $fields, $default ); |
|
| 842 | + $field_id = apply_filters('give_get_repeater_field_id', $field_id, $field, $fields, $default); |
|
| 843 | 843 | |
| 844 | 844 | return $field_id; |
| 845 | 845 | } |
@@ -854,8 +854,8 @@ discard block |
||
| 854 | 854 | * |
| 855 | 855 | * @return string |
| 856 | 856 | */ |
| 857 | -function give_get_field_name( $field ) { |
|
| 858 | - $field_name = esc_attr( empty( $field['repeat'] ) ? $field['id'] : $field['repeatable_field_id'] ); |
|
| 857 | +function give_get_field_name($field) { |
|
| 858 | + $field_name = esc_attr(empty($field['repeat']) ? $field['id'] : $field['repeatable_field_id']); |
|
| 859 | 859 | |
| 860 | 860 | /** |
| 861 | 861 | * Filter the field name. |
@@ -864,7 +864,7 @@ discard block |
||
| 864 | 864 | * |
| 865 | 865 | * @param string $field_name |
| 866 | 866 | */ |
| 867 | - $field_name = apply_filters( 'give_get_field_name', $field_name, $field ); |
|
| 867 | + $field_name = apply_filters('give_get_field_name', $field_name, $field); |
|
| 868 | 868 | |
| 869 | 869 | return $field_name; |
| 870 | 870 | } |
@@ -880,38 +880,38 @@ discard block |
||
| 880 | 880 | * |
| 881 | 881 | * @return void |
| 882 | 882 | */ |
| 883 | -function _give_metabox_form_data_repeater_fields( $fields ) { |
|
| 883 | +function _give_metabox_form_data_repeater_fields($fields) { |
|
| 884 | 884 | global $thepostid, $post; |
| 885 | 885 | |
| 886 | 886 | // Bailout. |
| 887 | - if ( ! isset( $fields['fields'] ) || empty( $fields['fields'] ) ) { |
|
| 887 | + if ( ! isset($fields['fields']) || empty($fields['fields'])) { |
|
| 888 | 888 | return; |
| 889 | 889 | } |
| 890 | 890 | |
| 891 | - $group_numbering = isset( $fields['options']['group_numbering'] ) ? (int) $fields['options']['group_numbering'] : 0; |
|
| 892 | - $close_tabs = isset( $fields['options']['close_tabs'] ) ? (int) $fields['options']['close_tabs'] : 0; |
|
| 891 | + $group_numbering = isset($fields['options']['group_numbering']) ? (int) $fields['options']['group_numbering'] : 0; |
|
| 892 | + $close_tabs = isset($fields['options']['close_tabs']) ? (int) $fields['options']['close_tabs'] : 0; |
|
| 893 | 893 | ?> |
| 894 | 894 | <div class="give-repeatable-field-section" id="<?php echo "{$fields['id']}_field"; ?>" data-group-numbering="<?php echo $group_numbering; ?>" data-close-tabs="<?php echo $close_tabs; ?>"> |
| 895 | - <?php if ( ! empty( $fields['name'] ) ) : ?> |
|
| 895 | + <?php if ( ! empty($fields['name'])) : ?> |
|
| 896 | 896 | <p class="give-repeater-field-name"><?php echo $fields['name']; ?></p> |
| 897 | 897 | <?php endif; ?> |
| 898 | 898 | |
| 899 | - <?php if ( ! empty( $fields['description'] ) ) : ?> |
|
| 899 | + <?php if ( ! empty($fields['description'])) : ?> |
|
| 900 | 900 | <p class="give-repeater-field-description"><?php echo $fields['description']; ?></p> |
| 901 | 901 | <?php endif; ?> |
| 902 | 902 | |
| 903 | 903 | <table class="give-repeatable-fields-section-wrapper" cellspacing="0"> |
| 904 | 904 | <?php |
| 905 | - $repeater_field_values = get_post_meta( $thepostid, $fields['id'], true ); |
|
| 906 | - $header_title = isset( $fields['options']['header_title'] ) |
|
| 905 | + $repeater_field_values = get_post_meta($thepostid, $fields['id'], true); |
|
| 906 | + $header_title = isset($fields['options']['header_title']) |
|
| 907 | 907 | ? $fields['options']['header_title'] |
| 908 | - : esc_attr__( 'Group', 'give' ); |
|
| 908 | + : esc_attr__('Group', 'give'); |
|
| 909 | 909 | |
| 910 | 910 | $add_default_donation_field = false; |
| 911 | 911 | |
| 912 | 912 | // Check if level is not created or we have to add default level. |
| 913 | - if ( is_array( $repeater_field_values ) && ( $fields_count = count( $repeater_field_values ) ) ) { |
|
| 914 | - $repeater_field_values = array_values( $repeater_field_values ); |
|
| 913 | + if (is_array($repeater_field_values) && ($fields_count = count($repeater_field_values))) { |
|
| 914 | + $repeater_field_values = array_values($repeater_field_values); |
|
| 915 | 915 | } else { |
| 916 | 916 | $fields_count = 1; |
| 917 | 917 | $add_default_donation_field = true; |
@@ -924,73 +924,73 @@ discard block |
||
| 924 | 924 | <div class="give-row-head give-move"> |
| 925 | 925 | <button type="button" class="handlediv button-link"><span class="toggle-indicator"></span> |
| 926 | 926 | </button> |
| 927 | - <span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-</span> |
|
| 927 | + <span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-</span> |
|
| 928 | 928 | <h2> |
| 929 | 929 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
| 930 | 930 | </h2> |
| 931 | 931 | </div> |
| 932 | 932 | <div class="give-row-body"> |
| 933 | - <?php foreach ( $fields['fields'] as $field ) : ?> |
|
| 934 | - <?php if ( ! give_is_field_callback_exist( $field ) ) { |
|
| 933 | + <?php foreach ($fields['fields'] as $field) : ?> |
|
| 934 | + <?php if ( ! give_is_field_callback_exist($field)) { |
|
| 935 | 935 | continue; |
| 936 | 936 | } ?> |
| 937 | 937 | <?php |
| 938 | 938 | $field['repeat'] = true; |
| 939 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields ); |
|
| 940 | - $field['id'] = str_replace( array( '[', ']' ), array( |
|
| 939 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields); |
|
| 940 | + $field['id'] = str_replace(array('[', ']'), array( |
|
| 941 | 941 | '_', |
| 942 | 942 | '', |
| 943 | - ), $field['repeatable_field_id'] ); |
|
| 943 | + ), $field['repeatable_field_id']); |
|
| 944 | 944 | ?> |
| 945 | - <?php give_render_field( $field ); ?> |
|
| 945 | + <?php give_render_field($field); ?> |
|
| 946 | 946 | <?php endforeach; ?> |
| 947 | 947 | </div> |
| 948 | 948 | </td> |
| 949 | 949 | </tr> |
| 950 | 950 | |
| 951 | - <?php if ( ! empty( $repeater_field_values ) ) : ?> |
|
| 951 | + <?php if ( ! empty($repeater_field_values)) : ?> |
|
| 952 | 952 | <!--Stored repeater field group--> |
| 953 | - <?php foreach ( $repeater_field_values as $index => $field_group ) : ?> |
|
| 953 | + <?php foreach ($repeater_field_values as $index => $field_group) : ?> |
|
| 954 | 954 | <tr class="give-row"> |
| 955 | 955 | <td class="give-repeater-field-wrap give-column" colspan="2"> |
| 956 | 956 | <div class="give-row-head give-move"> |
| 957 | 957 | <button type="button" class="handlediv button-link"> |
| 958 | 958 | <span class="toggle-indicator"></span></button> |
| 959 | - <sapn class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">- |
|
| 959 | + <sapn class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">- |
|
| 960 | 960 | </sapn> |
| 961 | 961 | <h2> |
| 962 | 962 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
| 963 | 963 | </h2> |
| 964 | 964 | </div> |
| 965 | 965 | <div class="give-row-body"> |
| 966 | - <?php foreach ( $fields['fields'] as $field ) : ?> |
|
| 967 | - <?php if ( ! give_is_field_callback_exist( $field ) ) { |
|
| 966 | + <?php foreach ($fields['fields'] as $field) : ?> |
|
| 967 | + <?php if ( ! give_is_field_callback_exist($field)) { |
|
| 968 | 968 | continue; |
| 969 | 969 | } ?> |
| 970 | 970 | <?php |
| 971 | 971 | $field['repeat'] = true; |
| 972 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, $index ); |
|
| 973 | - $field['attributes']['value'] = give_get_repeater_field_value( $field, $field_group, $fields ); |
|
| 974 | - $field['id'] = str_replace( array( '[', ']' ), array( |
|
| 972 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, $index); |
|
| 973 | + $field['attributes']['value'] = give_get_repeater_field_value($field, $field_group, $fields); |
|
| 974 | + $field['id'] = str_replace(array('[', ']'), array( |
|
| 975 | 975 | '_', |
| 976 | 976 | '', |
| 977 | - ), $field['repeatable_field_id'] ); |
|
| 977 | + ), $field['repeatable_field_id']); |
|
| 978 | 978 | ?> |
| 979 | - <?php give_render_field( $field ); ?> |
|
| 979 | + <?php give_render_field($field); ?> |
|
| 980 | 980 | <?php endforeach; ?> |
| 981 | 981 | </div> |
| 982 | 982 | </td> |
| 983 | 983 | </tr> |
| 984 | - <?php endforeach;; ?> |
|
| 984 | + <?php endforeach; ; ?> |
|
| 985 | 985 | |
| 986 | - <?php elseif ( $add_default_donation_field ) : ?> |
|
| 986 | + <?php elseif ($add_default_donation_field) : ?> |
|
| 987 | 987 | <!--Default repeater field group--> |
| 988 | 988 | <tr class="give-row"> |
| 989 | 989 | <td class="give-repeater-field-wrap give-column" colspan="2"> |
| 990 | 990 | <div class="give-row-head give-move"> |
| 991 | 991 | <button type="button" class="handlediv button-link"> |
| 992 | 992 | <span class="toggle-indicator"></span></button> |
| 993 | - <sapn class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">- |
|
| 993 | + <sapn class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">- |
|
| 994 | 994 | </sapn> |
| 995 | 995 | <h2> |
| 996 | 996 | <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span> |
@@ -998,19 +998,19 @@ discard block |
||
| 998 | 998 | </div> |
| 999 | 999 | <div class="give-row-body"> |
| 1000 | 1000 | <?php |
| 1001 | - foreach ( $fields['fields'] as $field ) : |
|
| 1002 | - if ( ! give_is_field_callback_exist( $field ) ) { |
|
| 1001 | + foreach ($fields['fields'] as $field) : |
|
| 1002 | + if ( ! give_is_field_callback_exist($field)) { |
|
| 1003 | 1003 | continue; |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | $field['repeat'] = true; |
| 1007 | - $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, 0 ); |
|
| 1008 | - $field['attributes']['value'] = apply_filters( "give_default_field_group_field_{$field['id']}_value", ( ! empty( $field['default'] ) ? $field['default'] : '' ), $field ); |
|
| 1009 | - $field['id'] = str_replace( array( '[', ']' ), array( |
|
| 1007 | + $field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, 0); |
|
| 1008 | + $field['attributes']['value'] = apply_filters("give_default_field_group_field_{$field['id']}_value", ( ! empty($field['default']) ? $field['default'] : ''), $field); |
|
| 1009 | + $field['id'] = str_replace(array('[', ']'), array( |
|
| 1010 | 1010 | '_', |
| 1011 | 1011 | '', |
| 1012 | - ), $field['repeatable_field_id'] ); |
|
| 1013 | - give_render_field( $field ); |
|
| 1012 | + ), $field['repeatable_field_id']); |
|
| 1013 | + give_render_field($field); |
|
| 1014 | 1014 | endforeach; |
| 1015 | 1015 | ?> |
| 1016 | 1016 | </div> |
@@ -1021,9 +1021,9 @@ discard block |
||
| 1021 | 1021 | <tfoot> |
| 1022 | 1022 | <tr> |
| 1023 | 1023 | <?php |
| 1024 | - $add_row_btn_title = isset( $fields['options']['add_button'] ) |
|
| 1024 | + $add_row_btn_title = isset($fields['options']['add_button']) |
|
| 1025 | 1025 | ? $add_row_btn_title = $fields['options']['add_button'] |
| 1026 | - : esc_html__( 'Add Row', 'give' ); |
|
| 1026 | + : esc_html__('Add Row', 'give'); |
|
| 1027 | 1027 | ?> |
| 1028 | 1028 | <td colspan="2" class="give-add-repeater-field-section-row-wrap"> |
| 1029 | 1029 | <span class="button button-primary give-add-repeater-field-section-row"><?php echo $add_row_btn_title; ?></span> |
@@ -1053,10 +1053,10 @@ discard block |
||
| 1053 | 1053 | * |
| 1054 | 1054 | * @param string |
| 1055 | 1055 | */ |
| 1056 | - $default_current_tab = apply_filters( "give_default_setting_tab_{$current_setting_page}", 'general' ); |
|
| 1056 | + $default_current_tab = apply_filters("give_default_setting_tab_{$current_setting_page}", 'general'); |
|
| 1057 | 1057 | |
| 1058 | 1058 | // Get current tab. |
| 1059 | - $current_tab = empty( $_GET['tab'] ) ? $default_current_tab : urldecode( $_GET['tab'] ); |
|
| 1059 | + $current_tab = empty($_GET['tab']) ? $default_current_tab : urldecode($_GET['tab']); |
|
| 1060 | 1060 | |
| 1061 | 1061 | // Output. |
| 1062 | 1062 | return $current_tab; |
@@ -1080,10 +1080,10 @@ discard block |
||
| 1080 | 1080 | * |
| 1081 | 1081 | * @param string |
| 1082 | 1082 | */ |
| 1083 | - $default_current_section = apply_filters( "give_default_setting_tab_section_{$current_tab}", '' ); |
|
| 1083 | + $default_current_section = apply_filters("give_default_setting_tab_section_{$current_tab}", ''); |
|
| 1084 | 1084 | |
| 1085 | 1085 | // Get current section. |
| 1086 | - $current_section = empty( $_REQUEST['section'] ) ? $default_current_section : urldecode( $_REQUEST['section'] ); |
|
| 1086 | + $current_section = empty($_REQUEST['section']) ? $default_current_section : urldecode($_REQUEST['section']); |
|
| 1087 | 1087 | |
| 1088 | 1088 | //Output. |
| 1089 | 1089 | return $current_section; |
@@ -1097,7 +1097,7 @@ discard block |
||
| 1097 | 1097 | */ |
| 1098 | 1098 | function give_get_current_setting_page() { |
| 1099 | 1099 | // Get current page. |
| 1100 | - $setting_page = ! empty( $_GET['page'] ) ? urldecode( $_GET['page'] ) : ''; |
|
| 1100 | + $setting_page = ! empty($_GET['page']) ? urldecode($_GET['page']) : ''; |
|
| 1101 | 1101 | |
| 1102 | 1102 | //Output. |
| 1103 | 1103 | return $setting_page; |
@@ -1116,13 +1116,13 @@ discard block |
||
| 1116 | 1116 | * |
| 1117 | 1117 | * @return string |
| 1118 | 1118 | */ |
| 1119 | -function _give_display_content_field_value( $field_value, $field, $postid ) { |
|
| 1120 | - $show_content = get_post_meta( $postid, '_give_content_option', true ); |
|
| 1119 | +function _give_display_content_field_value($field_value, $field, $postid) { |
|
| 1120 | + $show_content = get_post_meta($postid, '_give_content_option', true); |
|
| 1121 | 1121 | |
| 1122 | 1122 | if ( |
| 1123 | - ! get_post_meta( $postid, '_give_display_content', true ) |
|
| 1123 | + ! get_post_meta($postid, '_give_display_content', true) |
|
| 1124 | 1124 | && $show_content |
| 1125 | - && ( 'none' !== $show_content ) |
|
| 1125 | + && ('none' !== $show_content) |
|
| 1126 | 1126 | ) { |
| 1127 | 1127 | $field_value = 'enabled'; |
| 1128 | 1128 | } |
@@ -1130,7 +1130,7 @@ discard block |
||
| 1130 | 1130 | return $field_value; |
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | -add_filter( '_give_display_content_field_value', '_give_display_content_field_value', 10, 3 ); |
|
| 1133 | +add_filter('_give_display_content_field_value', '_give_display_content_field_value', 10, 3); |
|
| 1134 | 1134 | |
| 1135 | 1135 | |
| 1136 | 1136 | /** |
@@ -1146,12 +1146,12 @@ discard block |
||
| 1146 | 1146 | * |
| 1147 | 1147 | * @return string |
| 1148 | 1148 | */ |
| 1149 | -function _give_content_placement_field_value( $field_value, $field, $postid ) { |
|
| 1150 | - $show_content = get_post_meta( $postid, '_give_content_option', true ); |
|
| 1149 | +function _give_content_placement_field_value($field_value, $field, $postid) { |
|
| 1150 | + $show_content = get_post_meta($postid, '_give_content_option', true); |
|
| 1151 | 1151 | |
| 1152 | 1152 | if ( |
| 1153 | - ! get_post_meta( $postid, '_give_content_placement', true ) |
|
| 1154 | - && ( 'none' !== $show_content ) |
|
| 1153 | + ! get_post_meta($postid, '_give_content_placement', true) |
|
| 1154 | + && ('none' !== $show_content) |
|
| 1155 | 1155 | ) { |
| 1156 | 1156 | $field_value = $show_content; |
| 1157 | 1157 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | return $field_value; |
| 1160 | 1160 | } |
| 1161 | 1161 | |
| 1162 | -add_filter( '_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3 ); |
|
| 1162 | +add_filter('_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3); |
|
| 1163 | 1163 | |
| 1164 | 1164 | |
| 1165 | 1165 | /** |
@@ -1175,17 +1175,17 @@ discard block |
||
| 1175 | 1175 | * |
| 1176 | 1176 | * @return string |
| 1177 | 1177 | */ |
| 1178 | -function _give_terms_option_field_value( $field_value, $field, $postid ) { |
|
| 1179 | - $term_option = get_post_meta( $postid, '_give_terms_option', true ); |
|
| 1178 | +function _give_terms_option_field_value($field_value, $field, $postid) { |
|
| 1179 | + $term_option = get_post_meta($postid, '_give_terms_option', true); |
|
| 1180 | 1180 | |
| 1181 | - if ( in_array( $term_option, array( 'none', 'yes' ) ) ) { |
|
| 1182 | - $field_value = ( 'yes' === $term_option ? 'enabled' : 'disabled' ); |
|
| 1181 | + if (in_array($term_option, array('none', 'yes'))) { |
|
| 1182 | + $field_value = ('yes' === $term_option ? 'enabled' : 'disabled'); |
|
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | return $field_value; |
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | -add_filter( '_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3 ); |
|
| 1188 | +add_filter('_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3); |
|
| 1189 | 1189 | |
| 1190 | 1190 | |
| 1191 | 1191 | /** |
@@ -1201,17 +1201,17 @@ discard block |
||
| 1201 | 1201 | * |
| 1202 | 1202 | * @return string |
| 1203 | 1203 | */ |
| 1204 | -function _give_offline_donation_enable_billing_fields_single_field_value( $field_value, $field, $postid ) { |
|
| 1205 | - $offline_donation = get_post_meta( $postid, '_give_offline_donation_enable_billing_fields_single', true ); |
|
| 1204 | +function _give_offline_donation_enable_billing_fields_single_field_value($field_value, $field, $postid) { |
|
| 1205 | + $offline_donation = get_post_meta($postid, '_give_offline_donation_enable_billing_fields_single', true); |
|
| 1206 | 1206 | |
| 1207 | - if ( 'on' === $offline_donation ) { |
|
| 1207 | + if ('on' === $offline_donation) { |
|
| 1208 | 1208 | $field_value = 'enabled'; |
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | 1211 | return $field_value; |
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | -add_filter( '_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3 ); |
|
| 1214 | +add_filter('_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3); |
|
| 1215 | 1215 | |
| 1216 | 1216 | |
| 1217 | 1217 | /** |
@@ -1227,17 +1227,17 @@ discard block |
||
| 1227 | 1227 | * |
| 1228 | 1228 | * @return string |
| 1229 | 1229 | */ |
| 1230 | -function _give_custom_amount_field_value( $field_value, $field, $postid ) { |
|
| 1231 | - $custom_amount = get_post_meta( $postid, '_give_custom_amount', true ); |
|
| 1230 | +function _give_custom_amount_field_value($field_value, $field, $postid) { |
|
| 1231 | + $custom_amount = get_post_meta($postid, '_give_custom_amount', true); |
|
| 1232 | 1232 | |
| 1233 | - if ( in_array( $custom_amount, array( 'yes', 'no' ) ) ) { |
|
| 1234 | - $field_value = ( 'yes' === $custom_amount ? 'enabled' : 'disabled' ); |
|
| 1233 | + if (in_array($custom_amount, array('yes', 'no'))) { |
|
| 1234 | + $field_value = ('yes' === $custom_amount ? 'enabled' : 'disabled'); |
|
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | 1237 | return $field_value; |
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | -add_filter( '_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3 ); |
|
| 1240 | +add_filter('_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3); |
|
| 1241 | 1241 | |
| 1242 | 1242 | |
| 1243 | 1243 | /** |
@@ -1253,17 +1253,17 @@ discard block |
||
| 1253 | 1253 | * |
| 1254 | 1254 | * @return string |
| 1255 | 1255 | */ |
| 1256 | -function _give_goal_option_field_value( $field_value, $field, $postid ) { |
|
| 1257 | - $goal_option = get_post_meta( $postid, '_give_goal_option', true ); |
|
| 1256 | +function _give_goal_option_field_value($field_value, $field, $postid) { |
|
| 1257 | + $goal_option = get_post_meta($postid, '_give_goal_option', true); |
|
| 1258 | 1258 | |
| 1259 | - if ( in_array( $goal_option, array( 'yes', 'no' ) ) ) { |
|
| 1260 | - $field_value = ( 'yes' === $goal_option ? 'enabled' : 'disabled' ); |
|
| 1259 | + if (in_array($goal_option, array('yes', 'no'))) { |
|
| 1260 | + $field_value = ('yes' === $goal_option ? 'enabled' : 'disabled'); |
|
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | 1263 | return $field_value; |
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | -add_filter( '_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3 ); |
|
| 1266 | +add_filter('_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3); |
|
| 1267 | 1267 | |
| 1268 | 1268 | /** |
| 1269 | 1269 | * Set value for Donation Goal --> close Form. |
@@ -1278,17 +1278,17 @@ discard block |
||
| 1278 | 1278 | * |
| 1279 | 1279 | * @return string |
| 1280 | 1280 | */ |
| 1281 | -function _give_close_form_when_goal_achieved_value( $field_value, $field, $postid ) { |
|
| 1282 | - $close_form = get_post_meta( $postid, '_give_close_form_when_goal_achieved', true ); |
|
| 1281 | +function _give_close_form_when_goal_achieved_value($field_value, $field, $postid) { |
|
| 1282 | + $close_form = get_post_meta($postid, '_give_close_form_when_goal_achieved', true); |
|
| 1283 | 1283 | |
| 1284 | - if ( in_array( $close_form, array( 'yes', 'no' ) ) ) { |
|
| 1285 | - $field_value = ( 'yes' === $close_form ? 'enabled' : 'disabled' ); |
|
| 1284 | + if (in_array($close_form, array('yes', 'no'))) { |
|
| 1285 | + $field_value = ('yes' === $close_form ? 'enabled' : 'disabled'); |
|
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | return $field_value; |
| 1289 | 1289 | } |
| 1290 | 1290 | |
| 1291 | -add_filter( '_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3 ); |
|
| 1291 | +add_filter('_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3); |
|
| 1292 | 1292 | |
| 1293 | 1293 | |
| 1294 | 1294 | /** |
@@ -1304,17 +1304,17 @@ discard block |
||
| 1304 | 1304 | * |
| 1305 | 1305 | * @return string |
| 1306 | 1306 | */ |
| 1307 | -function _give_logged_in_only_value( $field_value, $field, $postid ) { |
|
| 1308 | - $guest_donation = get_post_meta( $postid, '_give_logged_in_only', true ); |
|
| 1307 | +function _give_logged_in_only_value($field_value, $field, $postid) { |
|
| 1308 | + $guest_donation = get_post_meta($postid, '_give_logged_in_only', true); |
|
| 1309 | 1309 | |
| 1310 | - if ( in_array( $guest_donation, array( 'yes', 'no' ) ) ) { |
|
| 1311 | - $field_value = ( 'yes' === $guest_donation ? 'enabled' : 'disabled' ); |
|
| 1310 | + if (in_array($guest_donation, array('yes', 'no'))) { |
|
| 1311 | + $field_value = ('yes' === $guest_donation ? 'enabled' : 'disabled'); |
|
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | 1314 | return $field_value; |
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | -add_filter( '_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3 ); |
|
| 1317 | +add_filter('_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3); |
|
| 1318 | 1318 | |
| 1319 | 1319 | /** |
| 1320 | 1320 | * Set value for Offline Donations --> Offline Donations. |
@@ -1329,17 +1329,17 @@ discard block |
||
| 1329 | 1329 | * |
| 1330 | 1330 | * @return string |
| 1331 | 1331 | */ |
| 1332 | -function _give_customize_offline_donations_value( $field_value, $field, $postid ) { |
|
| 1333 | - $customize_offline_text = get_post_meta( $postid, '_give_customize_offline_donations', true ); |
|
| 1332 | +function _give_customize_offline_donations_value($field_value, $field, $postid) { |
|
| 1333 | + $customize_offline_text = get_post_meta($postid, '_give_customize_offline_donations', true); |
|
| 1334 | 1334 | |
| 1335 | - if ( in_array( $customize_offline_text, array( 'yes', 'no' ) ) ) { |
|
| 1336 | - $field_value = ( 'yes' === $customize_offline_text ? 'enabled' : 'disabled' ); |
|
| 1335 | + if (in_array($customize_offline_text, array('yes', 'no'))) { |
|
| 1336 | + $field_value = ('yes' === $customize_offline_text ? 'enabled' : 'disabled'); |
|
| 1337 | 1337 | } |
| 1338 | 1338 | |
| 1339 | 1339 | return $field_value; |
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | -add_filter( '_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3 ); |
|
| 1342 | +add_filter('_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3); |
|
| 1343 | 1343 | |
| 1344 | 1344 | |
| 1345 | 1345 | /** |
@@ -1354,14 +1354,14 @@ discard block |
||
| 1354 | 1354 | * |
| 1355 | 1355 | * @return mixed |
| 1356 | 1356 | */ |
| 1357 | -function _give_set_multi_level_repeater_field_id( $field_id, $field, $fields, $default ) { |
|
| 1357 | +function _give_set_multi_level_repeater_field_id($field_id, $field, $fields, $default) { |
|
| 1358 | 1358 | $row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}'; |
| 1359 | 1359 | $field_id = "{$fields['id']}[{$row_placeholder}][{$field['id']}][level_id]"; |
| 1360 | 1360 | |
| 1361 | 1361 | return $field_id; |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | -add_filter( 'give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4 ); |
|
| 1364 | +add_filter('give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4); |
|
| 1365 | 1365 | |
| 1366 | 1366 | /** |
| 1367 | 1367 | * Set repeater field value for multi donation form. |
@@ -1375,13 +1375,13 @@ discard block |
||
| 1375 | 1375 | * |
| 1376 | 1376 | * @return mixed |
| 1377 | 1377 | */ |
| 1378 | -function _give_set_multi_level_repeater_field_value( $field_value, $field, $field_group, $fields ) { |
|
| 1379 | - $field_value = $field_group[ $field['id'] ]['level_id']; |
|
| 1378 | +function _give_set_multi_level_repeater_field_value($field_value, $field, $field_group, $fields) { |
|
| 1379 | + $field_value = $field_group[$field['id']]['level_id']; |
|
| 1380 | 1380 | |
| 1381 | 1381 | return $field_value; |
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | -add_filter( 'give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4 ); |
|
| 1384 | +add_filter('give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4); |
|
| 1385 | 1385 | |
| 1386 | 1386 | /** |
| 1387 | 1387 | * Set default value for _give_id field. |
@@ -1392,11 +1392,11 @@ discard block |
||
| 1392 | 1392 | * |
| 1393 | 1393 | * @return string |
| 1394 | 1394 | */ |
| 1395 | -function _give_set_field_give_id_default_value( $field ) { |
|
| 1395 | +function _give_set_field_give_id_default_value($field) { |
|
| 1396 | 1396 | return 0; |
| 1397 | 1397 | } |
| 1398 | 1398 | |
| 1399 | -add_filter( 'give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value' ); |
|
| 1399 | +add_filter('give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value'); |
|
| 1400 | 1400 | |
| 1401 | 1401 | /** |
| 1402 | 1402 | * Set default value for _give_default field. |
@@ -1407,11 +1407,11 @@ discard block |
||
| 1407 | 1407 | * |
| 1408 | 1408 | * @return string |
| 1409 | 1409 | */ |
| 1410 | -function _give_set_field_give_default_default_value( $field ) { |
|
| 1410 | +function _give_set_field_give_default_default_value($field) { |
|
| 1411 | 1411 | return 'default'; |
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | -add_filter( 'give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value' ); |
|
| 1414 | +add_filter('give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value'); |
|
| 1415 | 1415 | |
| 1416 | 1416 | /** |
| 1417 | 1417 | * Set repeater field editor id for field type wysiwyg. |
@@ -1423,11 +1423,11 @@ discard block |
||
| 1423 | 1423 | * |
| 1424 | 1424 | * @return string |
| 1425 | 1425 | */ |
| 1426 | -function give_repeater_field_set_editor_id( $field_name, $field ) { |
|
| 1427 | - if ( isset( $field['repeatable_field_id'] ) && 'wysiwyg' == $field['type'] ) { |
|
| 1428 | - $field_name = '_give_repeater_' . uniqid() . '_wysiwyg'; |
|
| 1426 | +function give_repeater_field_set_editor_id($field_name, $field) { |
|
| 1427 | + if (isset($field['repeatable_field_id']) && 'wysiwyg' == $field['type']) { |
|
| 1428 | + $field_name = '_give_repeater_'.uniqid().'_wysiwyg'; |
|
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | 1431 | return $field_name; |
| 1432 | 1432 | } |
| 1433 | -add_filter( 'give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2 ); |
|
| 1434 | 1433 | \ No newline at end of file |
| 1434 | +add_filter('give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2); |
|
| 1435 | 1435 | \ No newline at end of file |
@@ -113,7 +113,7 @@ |
||
| 113 | 113 | /** |
| 114 | 114 | * Adds the "Donation Form" button above the TinyMCE Editor on add/edit screens. |
| 115 | 115 | * |
| 116 | - * @return string|bool |
|
| 116 | + * @return false|null |
|
| 117 | 117 | * |
| 118 | 118 | * @since 1.0 |
| 119 | 119 | */ |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly. |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function __construct() { |
| 35 | 35 | |
| 36 | - if ( is_admin() ) { |
|
| 37 | - add_filter( 'mce_external_plugins', array( $this, 'mce_external_plugins' ), 15 ); |
|
| 36 | + if (is_admin()) { |
|
| 37 | + add_filter('mce_external_plugins', array($this, 'mce_external_plugins'), 15); |
|
| 38 | 38 | |
| 39 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_assets' ) ); |
|
| 40 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_localize_scripts' ), 13 ); |
|
| 41 | - add_action( 'media_buttons', array( $this, 'shortcode_button' ) ); |
|
| 39 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_assets')); |
|
| 40 | + add_action('admin_enqueue_scripts', array($this, 'admin_localize_scripts'), 13); |
|
| 41 | + add_action('media_buttons', array($this, 'shortcode_button')); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - add_action( "wp_ajax_give_shortcode", array( $this, 'shortcode_ajax' ) ); |
|
| 45 | - add_action( "wp_ajax_nopriv_give_shortcode", array( $this, 'shortcode_ajax' ) ); |
|
| 44 | + add_action("wp_ajax_give_shortcode", array($this, 'shortcode_ajax')); |
|
| 45 | + add_action("wp_ajax_nopriv_give_shortcode", array($this, 'shortcode_ajax')); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -54,15 +54,15 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @since 1.0 |
| 56 | 56 | */ |
| 57 | - public function mce_external_plugins( $plugin_array ) { |
|
| 57 | + public function mce_external_plugins($plugin_array) { |
|
| 58 | 58 | |
| 59 | - if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) { |
|
| 59 | + if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages')) { |
|
| 60 | 60 | return false; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 63 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 64 | 64 | |
| 65 | - $plugin_array['give_shortcode'] = GIVE_PLUGIN_URL . 'assets/js/admin/tinymce/mce-plugin' . $suffix . '.js'; |
|
| 65 | + $plugin_array['give_shortcode'] = GIVE_PLUGIN_URL.'assets/js/admin/tinymce/mce-plugin'.$suffix.'.js'; |
|
| 66 | 66 | |
| 67 | 67 | return $plugin_array; |
| 68 | 68 | } |
@@ -76,12 +76,12 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function admin_enqueue_assets() { |
| 78 | 78 | |
| 79 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 79 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 80 | 80 | |
| 81 | 81 | wp_enqueue_script( |
| 82 | 82 | 'give_shortcode', |
| 83 | - GIVE_PLUGIN_URL . 'assets/js/admin/admin-shortcodes' . $suffix . '.js', |
|
| 84 | - array( 'jquery' ), |
|
| 83 | + GIVE_PLUGIN_URL.'assets/js/admin/admin-shortcodes'.$suffix.'.js', |
|
| 84 | + array('jquery'), |
|
| 85 | 85 | GIVE_VERSION, |
| 86 | 86 | true |
| 87 | 87 | ); |
@@ -96,17 +96,17 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function admin_localize_scripts() { |
| 98 | 98 | |
| 99 | - if ( ! empty( self::$shortcodes ) ) { |
|
| 99 | + if ( ! empty(self::$shortcodes)) { |
|
| 100 | 100 | |
| 101 | 101 | $variables = array(); |
| 102 | 102 | |
| 103 | - foreach ( self::$shortcodes as $shortcode => $values ) { |
|
| 104 | - if ( ! empty( $values['required'] ) ) { |
|
| 105 | - $variables[ $shortcode ] = $values['required']; |
|
| 103 | + foreach (self::$shortcodes as $shortcode => $values) { |
|
| 104 | + if ( ! empty($values['required'])) { |
|
| 105 | + $variables[$shortcode] = $values['required']; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - wp_localize_script( 'give_shortcode', 'scShortcodes', $variables ); |
|
| 109 | + wp_localize_script('give_shortcode', 'scShortcodes', $variables); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
@@ -123,37 +123,37 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | // If we load wp editor by ajax then $screen will be empty which generate notice if we treat $screen as WP_Screen object. |
| 125 | 125 | // For example we are loading wp editor by ajax in repeater field. |
| 126 | - if ( ! ( $screen instanceof WP_Screen ) ) { |
|
| 126 | + if ( ! ($screen instanceof WP_Screen)) { |
|
| 127 | 127 | return false; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $shortcode_button_pages = apply_filters( 'give_shortcode_button_pages', array( |
|
| 130 | + $shortcode_button_pages = apply_filters('give_shortcode_button_pages', array( |
|
| 131 | 131 | 'post.php', |
| 132 | 132 | 'page.php', |
| 133 | 133 | 'post-new.php', |
| 134 | 134 | 'post-edit.php', |
| 135 | 135 | 'edit.php', |
| 136 | 136 | 'edit.php?post_type=page', |
| 137 | - ) ); |
|
| 137 | + )); |
|
| 138 | 138 | |
| 139 | 139 | // Only run in admin post/page creation and edit screens |
| 140 | - if ( in_array( $screen->parent_file, $shortcode_button_pages ) |
|
| 141 | - && apply_filters( 'give_shortcode_button_condition', true ) |
|
| 142 | - && ! empty( self::$shortcodes ) |
|
| 140 | + if (in_array($screen->parent_file, $shortcode_button_pages) |
|
| 141 | + && apply_filters('give_shortcode_button_condition', true) |
|
| 142 | + && ! empty(self::$shortcodes) |
|
| 143 | 143 | ) { |
| 144 | 144 | |
| 145 | 145 | $shortcodes = array(); |
| 146 | 146 | |
| 147 | - foreach ( self::$shortcodes as $shortcode => $values ) { |
|
| 147 | + foreach (self::$shortcodes as $shortcode => $values) { |
|
| 148 | 148 | |
| 149 | 149 | /** |
| 150 | 150 | * Filters the condition for including the current shortcode |
| 151 | 151 | * |
| 152 | 152 | * @since 1.0 |
| 153 | 153 | */ |
| 154 | - if ( apply_filters( sanitize_title( $shortcode ) . '_condition', true ) ) { |
|
| 154 | + if (apply_filters(sanitize_title($shortcode).'_condition', true)) { |
|
| 155 | 155 | |
| 156 | - $shortcodes[ $shortcode ] = sprintf( |
|
| 156 | + $shortcodes[$shortcode] = sprintf( |
|
| 157 | 157 | '<div class="sc-shortcode mce-menu-item give-shortcode-item-%1$s" data-shortcode="%s">%s</div>', |
| 158 | 158 | $shortcode, |
| 159 | 159 | $values['label'], |
@@ -162,37 +162,37 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if ( ! empty( $shortcodes ) ) { |
|
| 165 | + if ( ! empty($shortcodes)) { |
|
| 166 | 166 | |
| 167 | 167 | // check current WP version |
| 168 | - $img = ( version_compare( get_bloginfo( 'version' ), '3.5', '<' ) ) |
|
| 169 | - ? '<img src="' . GIVE_PLUGIN_URL . 'assets/images/give-media.png" />' |
|
| 170 | - : '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url(' . give_svg_icons( 'give_grey' ) . ');"></span>'; |
|
| 168 | + $img = (version_compare(get_bloginfo('version'), '3.5', '<')) |
|
| 169 | + ? '<img src="'.GIVE_PLUGIN_URL.'assets/images/give-media.png" />' |
|
| 170 | + : '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url('.give_svg_icons('give_grey').');"></span>'; |
|
| 171 | 171 | |
| 172 | - reset( $shortcodes ); |
|
| 172 | + reset($shortcodes); |
|
| 173 | 173 | |
| 174 | - if ( count( $shortcodes ) == 1 ) { |
|
| 174 | + if (count($shortcodes) == 1) { |
|
| 175 | 175 | |
| 176 | - $shortcode = key( $shortcodes ); |
|
| 176 | + $shortcode = key($shortcodes); |
|
| 177 | 177 | |
| 178 | 178 | printf( |
| 179 | 179 | '<button class="button sc-shortcode" data-shortcode="%s">%s</button>', |
| 180 | 180 | $shortcode, |
| 181 | - sprintf( '%s %s %s', |
|
| 181 | + sprintf('%s %s %s', |
|
| 182 | 182 | $img, |
| 183 | - esc_html__( 'Insert', 'give' ), |
|
| 184 | - self::$shortcodes[ $shortcode ]['label'] |
|
| 183 | + esc_html__('Insert', 'give'), |
|
| 184 | + self::$shortcodes[$shortcode]['label'] |
|
| 185 | 185 | ) |
| 186 | 186 | ); |
| 187 | 187 | } else { |
| 188 | 188 | printf( |
| 189 | - '<div class="sc-wrap">' . |
|
| 190 | - '<button class="button sc-button">%s %s</button>' . |
|
| 191 | - '<div class="sc-menu mce-menu">%s</div>' . |
|
| 189 | + '<div class="sc-wrap">'. |
|
| 190 | + '<button class="button sc-button">%s %s</button>'. |
|
| 191 | + '<div class="sc-menu mce-menu">%s</div>'. |
|
| 192 | 192 | '</div>', |
| 193 | 193 | $img, |
| 194 | - esc_html__( 'Give Shortcodes', 'give' ), |
|
| 195 | - implode( '', array_values( $shortcodes ) ) |
|
| 194 | + esc_html__('Give Shortcodes', 'give'), |
|
| 195 | + implode('', array_values($shortcodes)) |
|
| 196 | 196 | ); |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -208,15 +208,15 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public function shortcode_ajax() { |
| 210 | 210 | |
| 211 | - $shortcode = isset( $_POST['shortcode'] ) ? $_POST['shortcode'] : false; |
|
| 211 | + $shortcode = isset($_POST['shortcode']) ? $_POST['shortcode'] : false; |
|
| 212 | 212 | $response = false; |
| 213 | 213 | |
| 214 | - if ( $shortcode && array_key_exists( $shortcode, self::$shortcodes ) ) { |
|
| 214 | + if ($shortcode && array_key_exists($shortcode, self::$shortcodes)) { |
|
| 215 | 215 | |
| 216 | - $data = self::$shortcodes[ $shortcode ]; |
|
| 216 | + $data = self::$shortcodes[$shortcode]; |
|
| 217 | 217 | |
| 218 | - if ( ! empty( $data['errors'] ) ) { |
|
| 219 | - $data['btn_okay'] = array( esc_html__( 'Okay', 'give' ) ); |
|
| 218 | + if ( ! empty($data['errors'])) { |
|
| 219 | + $data['btn_okay'] = array(esc_html__('Okay', 'give')); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | $response = array( |
@@ -228,10 +228,10 @@ discard block |
||
| 228 | 228 | ); |
| 229 | 229 | } else { |
| 230 | 230 | // todo: handle error |
| 231 | - error_log( print_r( 'AJAX error!', 1 ) ); |
|
| 231 | + error_log(print_r('AJAX error!', 1)); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - wp_send_json( $response ); |
|
| 234 | + wp_send_json($response); |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | |
@@ -138,8 +138,8 @@ |
||
| 138 | 138 | |
| 139 | 139 | // Only run in admin post/page creation and edit screens |
| 140 | 140 | if ( in_array( $screen->parent_file, $shortcode_button_pages ) |
| 141 | - && apply_filters( 'give_shortcode_button_condition', true ) |
|
| 142 | - && ! empty( self::$shortcodes ) |
|
| 141 | + && apply_filters( 'give_shortcode_button_condition', true ) |
|
| 142 | + && ! empty( self::$shortcodes ) |
|
| 143 | 143 | ) { |
| 144 | 144 | |
| 145 | 145 | $shortcodes = array(); |