PluginProbe
Document Embedder – let visitors read files without downloading / 1.8.6
Document Embedder – let visitors read files without downloading v1.8.6
2.3.1 2.3.0 2.2.1 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.3 1.7.4 1.7.6 1.7.9 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 2.0.0 2.0.1 2.0.2 All 30 releases
document-emberdder / admin / framework / fields / image_select / image_select.php

image_select.php in Document Embedder – let visitors read files without downloading 1.8.6, at admin/framework/fields/image_select/image_select.php

80 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 /**
3 *
4 * Field: image_select
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'CSF_Field_image_select' ) ) {
11 class CSF_Field_image_select extends CSF_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 $args = wp_parse_args( $this->field, array(
20 'multiple' => false,
21 'inline' => false,
22 'options' => array(),
23 ) );
24
25 $inline = ( $args['inline'] ) ? ' csf--inline-list' : '';
26
27 $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
28
29 echo $this->field_before();
30
31 if ( ! empty( $args['options'] ) ) {
32
33 echo '<div class="csf-siblings csf--image-group'. esc_attr( $inline ) .'" data-multiple="'. esc_attr( $args['multiple'] ) .'">';
34
35 $num = 1;
36
37 foreach ( $args['options'] as $key => $option ) {
38
39 $type = ( $args['multiple'] ) ? 'checkbox' : 'radio';
40 $extra = ( $args['multiple'] ) ? '[]' : '';
41 $active = ( in_array( $key, $value ) ) ? ' csf--active' : '';
42 $checked = ( in_array( $key, $value ) ) ? ' checked' : '';
43
44 echo '<div class="csf--sibling csf--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 ) .'/>';
48 echo '</figure>';
49 echo '</div>';
50
51 }
52
53 echo '</div>';
54
55 }
56
57 echo $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 }
79 }
80