| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) { |
| 2 |
die; } // Cannot access directly. |
| 3 |
/** |
| 4 |
* |
| 5 |
* Field: palette |
| 6 |
* |
| 7 |
* @since 1.0.0 |
| 8 |
* @version 1.0.0 |
| 9 |
*/ |
| 10 |
if ( ! class_exists( 'DRK_LITE_Field_palette' ) ) { |
| 11 |
class DRK_LITE_Field_palette extends DRK_LITE_Fields { |
| 12 |
|
| 13 |
public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) { |
| 14 |
parent::__construct( $field, $value, $unique, $where, $parent ); |
| 15 |
} |
| 16 |
|
| 17 |
public function render() { |
| 18 |
|
| 19 |
$palette = ( ! empty( $this->field['options'] ) ) ? $this->field['options'] : array(); |
| 20 |
|
| 21 |
echo wp_kses_post( $this->field_before() ); |
| 22 |
|
| 23 |
if ( ! empty( $palette ) ) { |
| 24 |
|
| 25 |
echo '<div class="drk_lite-siblings drk_lite--palettes">'; |
| 26 |
|
| 27 |
foreach ( $palette as $key => $colors ) { |
| 28 |
|
| 29 |
$active = ( $key === $this->value ) ? ' drk_lite--active' : ''; |
| 30 |
$checked = ( $key === $this->value ) ? ' checked' : ''; |
| 31 |
|
| 32 |
echo '<div class="drk_lite--sibling drk_lite--palette' . esc_attr( $active ) . '">'; |
| 33 |
|
| 34 |
if ( ! empty( $colors ) ) { |
| 35 |
|
| 36 |
foreach ( $colors as $color ) { |
| 37 |
|
| 38 |
echo '<span style="background-color: ' . esc_attr( $color ) . ';"></span>'; |
| 39 |
|
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
echo '<input type="radio" name="' . esc_attr( $this->field_name() ) . '" value="' . esc_attr( $key ) . '"' . wp_kses_post( $this->field_attributes() ) . esc_attr( $checked ) . '/>'; |
| 44 |
echo '</div>'; |
| 45 |
|
| 46 |
} |
| 47 |
|
| 48 |
echo '</div>'; |
| 49 |
|
| 50 |
} |
| 51 |
|
| 52 |
echo wp_kses_post( $this->field_after() ); |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
|