PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4.1
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4.1
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
← All changes | Libs/adminify-framework/fields/image_select/image_select.php +49 -54 4.2.113.2.4.1 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,76 +5,70 @@
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( 'ADMINIFY_Field_image_select' ) ) {
11 - class ADMINIFY_Field_image_select extends ADMINIFY_Fields {
11 + class ADMINIFY_Field_image_select extends ADMINIFY_Fields {
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 + $args = wp_parse_args(
19 + $this->field,
20 + [
21 + 'multiple' => false,
22 + 'inline' => false,
23 + 'options' => [],
24 + ]
25 + );
18 26
19 - $args = wp_parse_args( $this->field, array(
20 - 'multiple' => false,
21 - 'inline' => false,
22 - 'options' => array(),
23 - ) );
27 + $inline = ( $args['inline'] ) ? ' adminify--inline-list' : '';
24 28
25 - $inline = ( $args['inline'] ) ? ' adminify--inline-list' : '';
29 + $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
26 30
27 - $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
31 + echo wp_kses_post( $this->field_before() );
28 32
29 - echo wp_kses_post( $this->field_before() );
33 + if ( ! empty( $args['options'] ) ) {
34 + echo '<div class="adminify-siblings adminify--image-group' . esc_attr( $inline ) . '" data-multiple="' . esc_attr( $args['multiple'] ) . '">';
30 35
31 - if ( ! empty( $args['options'] ) ) {
36 + $num = 1;
32 37
33 - echo '<div class="adminify-siblings adminify--image-group'. esc_attr( $inline ) .'" data-multiple="'. esc_attr( $args['multiple'] ) .'">';
38 + foreach ( $args['options'] as $key => $option ) {
39 + $type = ( $args['multiple'] ) ? 'checkbox' : 'radio';
40 + $extra = ( $args['multiple'] ) ? '[]' : '';
41 + $active = ( in_array( $key, $value ) ) ? ' adminify--active' : '';
42 + $checked = ( in_array( $key, $value ) ) ? ' checked' : '';
34 43
35 - $num = 1;
44 + echo '<div class="adminify--sibling adminify--image' . esc_attr( $active ) . '">';
45 + echo '<figure>';
46 + echo '<img src="' . esc_url( $option ) . '" alt="img-' . esc_attr( $num++ ) . '" />';
47 + 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 ) . '/>';
48 + echo '</figure>';
49 + echo '</div>';
50 + }
36 51
37 - foreach ( $args['options'] as $key => $option ) {
52 + echo '</div>';
53 + }
38 54
39 - $type = ( $args['multiple'] ) ? 'checkbox' : 'radio';
40 - $extra = ( $args['multiple'] ) ? '[]' : '';
41 - $active = ( in_array( $key, $value ) ) ? ' adminify--active' : '';
42 - $checked = ( in_array( $key, $value ) ) ? ' checked' : '';
55 + echo wp_kses_post( $this->field_after() );
56 + }
43 57
44 - echo '<div class="adminify--sibling adminify--image'. esc_attr( $active ) .'">';
45 - echo '<figure>';
46 - echo '<img src="'. esc_url( $option ) .'" alt="img-'. esc_attr( $num++ ) .'" />';
47 - echo '<input type="'. esc_attr( $type ) .'" name="'. esc_attr( $this->field_name( $extra ) ) .'" value="'. esc_attr( $key ) .'"'. $this->field_attributes() . esc_attr( $checked ) .'/>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- field_attributes() escapes each attribute via esc_attr()
48 - echo '</figure>';
49 - echo '</div>';
58 + public function output() {
59 + $output = '';
60 + $bg_image = [];
61 + $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
62 + $elements = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
50 63
51 - }
64 + if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
65 + $output = $elements . '{background-image:url(' . $this->value . ')' . $important . ';}';
66 + }
52 67
53 - echo '</div>';
68 + $this->parent->output_css .= $output;
54 69
55 - }
70 + return $output;
71 + }
56 72
57 - echo wp_kses_post( $this->field_after() );
58 -
59 - }
60 -
61 - public function output() {
62 -
63 - $output = '';
64 - $bg_image = array();
65 - $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
66 - $elements = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
67 -
68 - if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
69 - $output = $elements .'{background-image:url('. $this->value .')'. $important .';}';
70 - }
71 -
72 - $this->parent->output_css .= $output;
73 -
74 - return $output;
75 -
76 - }
77 -
78 - }
73 + }
79 74 }