PluginProbe
QuadMenu – Mega Menu / 1.8.9
QuadMenu – Mega Menu v1.8.9
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / lib / redux / icons / field_icons.php

field_icons.php in QuadMenu – Mega Menu 1.8.9, at lib/redux/icons/field_icons.php

222 lines 11.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5
6 if (!class_exists('ReduxFramework_icons')) {
7
8 add_action('admin_footer', array('ReduxFramework_icons', 'modal'));
9
10 class ReduxFramework_icons {
11
12 public $_extension_url;
13 public $_extension_dir;
14
15 function __construct($field = array(), $value = '', $parent) {
16 $this->parent = $parent;
17 $this->field = $field;
18 $this->value = $value;
19
20 if (empty(self::$_extension_dir)) {
21 $this->_extension_dir = trailingslashit(str_replace('\\', '/', dirname(__FILE__)));
22 $this->_extension_url = site_url(str_replace(trailingslashit(str_replace('\\', '/', ABSPATH)), '', $this->_extension_dir));
23 }
24 }
25
26 static public function modal($icons = '') {
27 ?>
28 <!-- Modal Icon -->
29 <div id="modal_icons" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal_iconsLabel" aria-hidden="true">
30 <div class="modal-dialog">
31 <div class="modal-content">
32 <div class="modal-body">
33 <div class="quadmenu-setting-icon">
34 <div class="quadmenu-icons-search">
35 <span class="button-icon button-secondary" class="button"><i class="<?php //echo esc_html($value); ?>"></i><?php echo _QuadMenu()->selected_icons()->name; ?></span>
36 <input type="hidden" class="menu-item-icon" value="<?php //echo esc_html($value); ?>"/>
37 <input type="search" value="" placeholder="<?php _e('Search icon', 'quadmenu') ?>"/>
38 </div>
39 <div class="quadmenu-icons-scroll">
40 <?php foreach (explode(',', _QuadMenu()->selected_icons()->iconmap) as $icon) : ?>
41 <a style="display: block;" class="icon _<?php echo esc_attr(str_replace(' ', '_', trim($icon))); ?>"><i class="<?php echo esc_attr($icon); ?>"></i></a>
42 <?php endforeach; ?>
43 <div class="clearfix"></div>
44 </div>
45 </div>
46 </div>
47 <div class="modal-footer">
48 <button type="button" class="button button-secondary" data-dismiss="modal"><?php _e('Close', 'quadmenu') ?></button>
49 <button type="button" class="button button-primary save"><?php _e('Save', 'quadmenu') ?></button>
50 </div>
51 </div>
52 </div>
53 </div>
54 <!-- /Modal Icon -->
55 <?php
56 }
57
58 public function render() {
59
60 $defaults = array(
61 'show' => array(
62 'title' => true,
63 'icon' => true,
64 //'key' => false,
65 'description' => true,
66 'url' => true,
67 'upload' => true,
68 ),
69 'content_title' => __('Slide', 'redux-framework')
70 );
71
72 $this->field = wp_parse_args($this->field, $defaults);
73
74 echo '<div class="redux-icons-accordion" data-new-content-title="' . esc_attr(sprintf(__('New %s', 'redux-framework'), $this->field['content_title'])) . '">';
75
76 $x = 0;
77
78 $multi = ( isset($this->field['multi']) && $this->field['multi'] ) ? ' multiple="multiple"' : "";
79
80 if (isset($this->value) && is_array($this->value) && !empty($this->value)) {
81
82 $icons = $this->value;
83
84 foreach ($icons as $slide) {
85
86 if (empty($slide)) {
87 continue;
88 }
89
90 $defaults = array(
91 'title' => '',
92 'icon' => '',
93 'description' => '',
94 'sort' => '',
95 'url' => '',
96 'image' => '',
97 'thumb' => '',
98 'attachment_id' => '',
99 'height' => '',
100 'width' => '',
101 'upload' => '',
102 'select' => array(),
103 );
104 $slide = wp_parse_args($slide, $defaults);
105
106 if (empty($slide['thumb']) && !empty($slide['attachment_id'])) {
107 $img = wp_get_attachment_image_src($slide['attachment_id'], 'full');
108 $slide['image'] = $img[0];
109 $slide['width'] = $img[1];
110 $slide['height'] = $img[2];
111 }
112
113 echo '<div class="redux-icons-accordion-group"><fieldset class="redux-field" data-id="' . $this->field['id'] . '"><h3><i id="' . $this->field['id'] . '-icon_' . $x . '_replace" class="' . $slide['icon'] . '"></i><span class="redux-icons-header">' . $slide['title'] . '</span></h3><div>';
114
115 if ($this->field['show']['upload']) {
116
117 $hide = '';
118
119 if (empty($slide['image'])) {
120 $hide = ' hidden';
121 }
122
123 echo '<div class="screenshot' . $hide . '">';
124 //echo '<a class="of-uploaded-image" href="' . $slide['image'] . '">';
125 echo '<img class="redux-option-image" id="image_image_id_' . $x . '" src="' . $slide['thumb'] . '" alt="" target="_blank" rel="external" />';
126 // echo '</a>';
127 echo '</div>';
128
129 echo '<div class="redux_icons_add_remove">';
130
131 echo '<span class="button media_upload_button" id="add_' . $x . '">' . __('Upload', 'redux-framework') . '</span>';
132
133 $hide = '';
134
135 if (empty($slide['image']) || $slide['image'] == '') {
136 $hide = ' hide';
137 }
138
139 echo '<span class="button remove-image' . $hide . '" id="reset_' . $x . '" rel="' . $slide['attachment_id'] . '">' . __('Remove', 'redux-framework') . '</span>';
140
141 echo '</div>' . "\n";
142 }
143
144 echo '<ul id="' . $this->field['id'] . '-ul" class="redux-icons-list">';
145
146 if ($this->field['show']['title']) {
147 $title_type = "text";
148 } else {
149 $title_type = "hidden";
150 }
151
152 $placeholder = ( isset($this->field['placeholder']['title']) ) ? esc_attr($this->field['placeholder']['title']) : __('Title', 'redux-framework');
153
154 echo '<li><input type="' . $title_type . '" id="' . $this->field['id'] . '-title_' . $x . '" name="' . $this->field['name'] . '[' . $x . '][title]' . $this->field['name_suffix'] . '" value="' . esc_attr($slide['title']) . '" placeholder="' . $placeholder . '" class="full-text slide-title" /></li>';
155
156 if ($this->field['show']['icon']) {
157 $placeholder = ( isset($this->field['placeholder']['icon']) ) ? esc_attr($this->field['placeholder']['icon']) : __('Icon', 'quadmenu');
158 echo '<li>';
159 echo '<a class="redux-icons-add-icon" name="' . $this->field['name'] . '[' . $x . '][icon]' . $this->field['name_suffix'] . '" href="#" data-quadmenu="modal" data-target="#modal_icons" data-backdrop="true" id="' . $this->field['id'] . '-icon_' . $x . '" value="' . esc_attr($slide['icon']) . '">' . __('+ Add Icon', 'quadmenu') . '</a>';
160 echo '<input type="text" name="' . $this->field['name'] . '[' . $x . '][icon]' . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '-icon_' . $x . '" placeholder="' . $placeholder . '" value="' . esc_attr($slide['icon']) . '" placeholder="' . $placeholder . '" class="large-text slide-icon"></input>';
161 echo '</li>';
162 }
163
164 if ($this->field['show']['description']) {
165 $placeholder = ( isset($this->field['placeholder']['description']) ) ? esc_attr($this->field['placeholder']['description']) : __('Description', 'redux-framework');
166 echo '<li><textarea name="' . $this->field['name'] . '[' . $x . '][description]' . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '-description_' . $x . '" placeholder="' . $placeholder . '" class="large-text" rows="6">' . esc_attr($slide['description']) . '</textarea></li>';
167 }
168
169 $placeholder = ( isset($this->field['placeholder']['url']) ) ? esc_attr($this->field['placeholder']['url']) : __('URL', 'redux-framework');
170 if ($this->field['show']['url']) {
171 $url_type = "text";
172 } else {
173 $url_type = "hidden";
174 }
175
176 echo '<li><input type="' . $url_type . '" id="' . $this->field['id'] . '-url_' . $x . '" name="' . $this->field['name'] . '[' . $x . '][url]' . $this->field['name_suffix'] . '" value="' . esc_attr($slide['url']) . '" class="full-text" placeholder="' . $placeholder . '" /></li>';
177 echo '<li><input type="hidden" class="slide-sort" name="' . $this->field['name'] . '[' . $x . '][sort]' . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '-sort_' . $x . '" value="' . $slide['sort'] . '" />';
178 echo '<li><input type="hidden" class="upload-id" name="' . $this->field['name'] . '[' . $x . '][attachment_id]' . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '-image_id_' . $x . '" value="' . $slide['attachment_id'] . '" />';
179 echo '<input type="hidden" class="upload-thumbnail" name="' . $this->field['name'] . '[' . $x . '][thumb]' . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '-thumb_url_' . $x . '" value="' . $slide['thumb'] . '" readonly="readonly" />';
180 echo '<input type="hidden" class="upload" name="' . $this->field['name'] . '[' . $x . '][image]' . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '-image_url_' . $x . '" value="' . $slide['image'] . '" readonly="readonly" />';
181 echo '<input type="hidden" class="upload-height" name="' . $this->field['name'] . '[' . $x . '][height]' . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '-image_height_' . $x . '" value="' . $slide['height'] . '" />';
182 echo '<input type="hidden" class="upload-width" name="' . $this->field['name'] . '[' . $x . '][width]' . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '-image_width_' . $x . '" value="' . $slide['width'] . '" /></li>';
183 //echo '<input type="text" name="' . $this->field['name'] . '[' . $x . '][key]' . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '-key_' . $x . '" value="' . esc_attr($slide['key'] ? $slide['key'] : $this->field['id'] . '-key_' . $x ) . '">';
184 echo '<li><a href="javascript:void(0);" class="button deletion redux-icons-remove">' . __('Delete', 'redux-framework') . '</a></li>';
185 echo '</ul></div></fieldset></div>';
186 $x ++;
187 }
188 }
189
190
191 echo '</div>';
192
193 echo '<a href="javascript:void(0);" class="redux-icons-accordion-group redux-icons-add " rel-id="' . $this->field['id'] . '-ul" rel-name="' . $this->field['name'] . '[title][]' . $this->field['name_suffix'] . '"><i class="dashicons dashicons-plus"></i></a>';
194 }
195
196 public function enqueue() {
197 if (function_exists('wp_enqueue_media')) {
198 wp_enqueue_media();
199 } else {
200 wp_enqueue_script('media-upload');
201 }
202
203 if ($this->parent->args['dev_mode']) {
204 wp_enqueue_style('redux-field-media-css');
205 }
206
207 wp_enqueue_style(
208 'redux-field-icons-css', $this->_extension_url . 'field_icons' . Redux_Functions::isMin() . '.css', array(), time(), 'all'
209 );
210
211 wp_enqueue_script(
212 'redux-field-media-js', ReduxFramework::$_url . 'assets/js/media/media' . Redux_Functions::isMin() . '.js', array('jquery', 'redux-js'), time(), true
213 );
214
215 wp_enqueue_script(
216 'redux-field-icons-js', $this->_extension_url . 'field_icons' . Redux_Functions::isMin() . '.js', array('jquery', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-sortable', 'redux-field-media-js'), time(), true
217 );
218 }
219
220 }
221
222 }