PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.3.2
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.3.2
2.1.3 2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 trunk 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 All 57 releases
← All changes | src/Admin/Framework/fields/image_select/image_select.php +48 -58 1.5.51.3.2 View file →
@@ -1,5 +1,6 @@
1 -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
1 +<?php if ( ! defined( 'ABSPATH' ) ) {
2 + die; } // Cannot access directly.
2 3 /**
3 4 *
4 5 * Field: image_select
5 6 *
@@ -4,86 +5,75 @@
4 5 * Field: image_select
5 6 *
6 7 * @since 1.0.0
7 8 * @version 1.0.0
8 - *
9 9 */
10 10 if ( ! class_exists( 'DarkifyField_image_select' ) ) {
11 - class DarkifyField_image_select extends DarkifyFields {
11 + class DarkifyField_image_select extends DarkifyFields {
12 12
13 - public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 - parent::__construct( $field, $value, $unique, $where, $parent );
15 - }
13 + public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 + parent::__construct( $field, $value, $unique, $where, $parent );
15 + }
16 16
17 - public function render() {
17 + public function render() {
18 18
19 - $args = wp_parse_args( $this->field, array(
20 - 'multiple' => false,
21 - 'inline' => false,
22 - 'options' => array(),
23 - ) );
19 + $args = wp_parse_args(
20 + $this->field,
21 + array(
22 + 'multiple' => false,
23 + 'inline' => false,
24 + 'options' => array(),
25 + )
26 + );
24 27
25 - $inline = ( $args['inline'] ) ? ' darkify--inline-list' : '';
28 + $inline = ( $args['inline'] ) ? ' darkify--inline-list' : '';
26 29
27 - $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
30 + $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
28 31
29 - echo wp_kses_post($this->field_before());
32 + echo wp_kses_post( $this->field_before() );
30 33
31 - if ( ! empty( $args['options'] ) ) {
34 + if ( ! empty( $args['options'] ) ) {
32 35
33 - echo '<div class="darkify-siblings darkify--image-group'. esc_attr( $inline ) .'" data-multiple="'. esc_attr( $args['multiple'] ) .'">';
36 + echo '<div class="darkify-siblings darkify--image-group' . esc_attr( $inline ) . '" data-multiple="' . esc_attr( $args['multiple'] ) . '">';
34 37
35 - $num = 1;
38 + $num = 1;
36 39
37 - foreach ( $args['options'] as $key => $option ) {
40 + foreach ( $args['options'] as $key => $option ) {
38 41
39 - $type = ( $args['multiple'] ) ? 'checkbox' : 'radio';
40 - $extra = ( $args['multiple'] ) ? '[]' : '';
41 - $active = ( in_array( $key, $value ) ) ? ' darkify--active' : '';
42 - $checked = ( in_array( $key, $value ) ) ? ' checked' : '';
43 - $pro_only = isset($option['pro_only']) ? ' disabled' : '';
44 - $darkify_pro_only_class = isset($option['pro_only']) ? ' darkify-pro-only' : '';
42 + $type = ( $args['multiple'] ) ? 'checkbox' : 'radio';
43 + $extra = ( $args['multiple'] ) ? '[]' : '';
44 + $active = ( in_array( $key, $value ) ) ? ' darkify--active' : '';
45 + $checked = ( in_array( $key, $value ) ) ? ' checked' : '';
45 46
46 - echo '<div class="darkify--sibling darkify--image' . esc_attr($active) . esc_attr($darkify_pro_only_class) . '">';
47 - echo '<figure>';
48 - echo '<img src="' . esc_url($option['image']) . '" alt="' . esc_attr($option['text']) . '" />';
49 - echo '</figure>';
50 - echo '<input ' . esc_attr($pro_only) . ' type="' . esc_attr($type) . '" name="' . esc_attr($this->field_name($extra)) . '" value="' . esc_attr($key) . '"' . wp_kses_post($this->field_attributes()) . esc_attr($checked) . '/>';
51 -
52 - echo '<p class="darkify-image-title">' . esc_html($option['text']);
53 -
54 - if (! empty($option['option_demo_url'])) {
55 - echo ' <a href="' . esc_url($option['option_demo_url']) . '" tooltip="' . esc_html__('Demo', 'darkify') . '" class="darkify-live-demo-icon" target="_blank"><i class="icofont-external-link"></i></a>';
56 - }
57 - echo '</p>';
58 -
47 + echo '<div class="darkify--sibling darkify--image' . esc_attr( $active ) . '">';
48 + echo '<figure>';
49 + echo '<img src="' . esc_url( $option ) . '" alt="img-' . esc_attr( $num++ ) . '" />';
50 + echo '<input type="' . esc_attr( $type ) . '" name="' . esc_attr( $this->field_name( $extra ) ) . '" value="' . esc_attr( $key ) . '"' . wp_kses_post( $this->field_attributes() ) . esc_attr( $checked ) . '/>';
51 + echo '</figure>';
59 52 echo '</div>';
60 53
61 - }
54 + }
62 55
63 - echo '</div>';
56 + echo '</div>';
64 57
65 - }
66 - echo '<div class="clear"></div>';
67 - echo wp_kses_post($this->field_after());
58 + }
68 59
69 - }
60 + echo wp_kses_post( $this->field_after() );
61 + }
70 62
71 - public function output() {
63 + public function output() {
72 64
73 - $output = '';
74 - $bg_image = array();
75 - $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
76 - $elements = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
65 + $output = '';
66 + $bg_image = array();
67 + $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
68 + $elements = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
77 69
78 - if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
79 - $output = $elements .'{background-image:url('. wp_kses_post($this->value) .')'. $important .';}';
80 - }
70 + if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
71 + $output = $elements . '{background-image:url(' . $this->value . ')' . $important . ';}';
72 + }
81 73
82 - $this->parent->output_css .= $output;
74 + $this->parent->output_css .= $output;
83 75
84 - return $output;
85 -
86 - }
87 -
88 - }
76 + return $output;
77 + }
78 + }
89 79 }