← All changes
|
includes/admin/views/settings/multi-checkbox.php
+29
-23
1.6.60
→
1.8.13
View file →
| @@ -1,56 +1,62 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 3 | +// Exit if accessed directly. | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; | |
| 6 | +} | |
| 7 | + | |
| 2 | 8 | /** |
| 3 | 9 | * Display a series of checkboxes. |
| 4 | 10 | * |
| 5 | - * @author Eric Daams | |
| 11 | + * @author David Bisset | |
| 6 | 12 | * @package Charitable/Admin View/Settings |
| 7 | - * @copyright Copyright (c) 2022, Studio 164a | |
| 13 | + * @copyright Copyright (c) 2023, WP Charitable LLC | |
| 8 | 14 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | 15 | * @since 1.0.0 |
| 10 | - * @version 1.6.45 | |
| 16 | + * @version 1.8.8.6 | |
| 11 | 17 | */ |
| 12 | 18 | |
| 13 | -$value = charitable_get_option( $view_args['key'], array() ); | |
| 19 | +$charitable_value = charitable_get_option( $view_args['key'], array() ); | |
| 14 | 20 | |
| 15 | -if ( empty( $value ) ) : | |
| 16 | - $value = isset( $view_args['default'] ) ? (array) $view_args['default'] : array(); | |
| 21 | +if ( empty( $charitable_value ) ) : | |
| 22 | + $charitable_value = isset( $view_args['default'] ) ? (array) $view_args['default'] : array(); | |
| 17 | 23 | endif; |
| 18 | 24 | |
| 19 | -if ( ! is_array( $value ) ) { | |
| 20 | - $value = (array) $value; | |
| 25 | +if ( ! is_array( $charitable_value ) ) { | |
| 26 | + $charitable_value = (array) $charitable_value; | |
| 21 | 27 | } |
| 22 | 28 | |
| 23 | -$setting_attributes = ''; | |
| 29 | +$charitable_setting_attributes = ''; | |
| 24 | 30 | |
| 25 | 31 | if ( array_key_exists( 'attrs', $view_args ) ) { |
| 26 | - $setting_attributes_keys = array( 'data-trigger-key', 'data-trigger-change-type', 'data-trigger-value' ); | |
| 32 | + $charitable_setting_attributes_keys = array( 'data-trigger-key', 'data-trigger-change-type', 'data-trigger-value' ); | |
| 27 | 33 | |
| 28 | - foreach ( $setting_attributes_keys as $key ) { | |
| 29 | - if ( ! array_key_exists( $key, $view_args['attrs'] ) ) { | |
| 34 | + foreach ( $charitable_setting_attributes_keys as $charitable_key ) { | |
| 35 | + if ( ! array_key_exists( $charitable_key, $view_args['attrs'] ) ) { | |
| 30 | 36 | continue; |
| 31 | 37 | } |
| 32 | 38 | |
| 33 | - $setting_attributes .= sprintf( ' %s="%s"', $key, esc_attr( $view_args['attrs'][ $key ] ) ); | |
| 39 | + $charitable_setting_attributes .= sprintf( ' %s="%s"', $charitable_key, esc_attr( $view_args['attrs'][ $charitable_key ] ) ); | |
| 34 | 40 | |
| 35 | - unset( $view_args['attrs'][ $key ] ); | |
| 41 | + unset( $view_args['attrs'][ $charitable_key ] ); | |
| 36 | 42 | } |
| 37 | 43 | } |
| 38 | 44 | |
| 39 | 45 | ?> |
| 40 | -<ul class="charitable-checkbox-list <?php echo esc_attr( $view_args['classes'] ); ?>" <?php echo $setting_attributes; ?>> | |
| 41 | - <?php foreach ( $view_args['options'] as $option => $label ) : ?> | |
| 46 | +<ul class="charitable-checkbox-list <?php echo esc_attr( $view_args['classes'] ); ?>" <?php echo wp_kses_post( $charitable_setting_attributes ); ?>> | |
| 47 | + <?php foreach ( $view_args['options'] as $charitable_option => $charitable_label ) : ?> | |
| 42 | 48 | <li><input type="checkbox" |
| 43 | - id="<?php printf( 'charitable_settings_%s_%s', implode( '_', $view_args['key'] ), $option ); ?>" | |
| 44 | - name="<?php printf( 'charitable_settings[%s][]', $view_args['name'] ); ?>" | |
| 45 | - value="<?php echo esc_attr( $option ); ?>" | |
| 46 | - <?php checked( in_array( $option, $value, true ) ); ?> | |
| 47 | - <?php echo charitable_get_arbitrary_attributes( $view_args ); ?> | |
| 49 | + id="<?php printf( 'charitable_settings_%s_%s', esc_attr( implode( '_', $view_args['key'] ) ), esc_attr( $charitable_option ) ); ?>" | |
| 50 | + name="<?php printf( 'charitable_settings[%s][]', esc_attr( $view_args['name'] ) ); ?>" | |
| 51 | + value="<?php echo esc_attr( $charitable_option ); ?>" | |
| 52 | + <?php checked( in_array( $charitable_option, $charitable_value, true ) ); ?> | |
| 53 | + <?php echo esc_attr( charitable_get_arbitrary_attributes( $view_args ) ); ?> | |
| 48 | 54 | /> |
| 49 | - <?php echo $label; ?> | |
| 55 | + <?php echo ( $charitable_label ); // phpcs:ignore ?> | |
| 50 | 56 | </li> |
| 51 | 57 | <?php endforeach ?> |
| 52 | 58 | </ul> |
| 53 | 59 | <?php if ( isset( $view_args['help'] ) ) : ?> |
| 54 | - <div class="charitable-help"><?php echo $view_args['help']; ?></div> | |
| 60 | + <div class="charitable-help"><?php echo wp_kses_post( $view_args['help'] ); ?></div> | |
| 55 | 61 | <?php |
| 56 | 62 | endif; |