PluginProbe
QuadMenu – Mega Menu / 3.3.8
QuadMenu – Mega Menu v3.3.8
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 / redux / ReduxCore / inc / fields / slides / field_slides.php

field_slides.php in QuadMenu – Mega Menu 3.3.8, at redux/ReduxCore/inc/fields/slides/field_slides.php

270 lines 13.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Redux Framework is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * any later version.
8 * Redux Framework is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
14 *
15 * @package ReduxFrameworkLegacy
16 * @subpackage Field_slides
17 * @author Luciano "WebCaos" Ubertini
18 * @author Daniel J Griffiths (Ghost1227)
19 * @author Dovy Paukstys
20 * @version 3.0.0
21 */
22
23 // Exit if accessed directly
24 if ( ! defined( 'ABSPATH' ) ) {
25 exit;
26 }
27
28 // Don't duplicate me!
29 if ( ! class_exists( 'ReduxFrameworkLegacy_slides' ) ) {
30
31 /**
32 * Main ReduxFrameworkLegacy_slides class
33 *
34 * @since 1.0.0
35 */
36 class ReduxFrameworkLegacy_slides {
37
38 /**
39 * Field Constructor.
40 * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
41 *
42 * @since 1.0.0
43 * @access public
44 * @return void
45 */
46 function __construct( $field = array(), $value = '', $parent = null ) {
47 $this->parent = $parent;
48 $this->field = $field;
49 $this->value = $value;
50 }
51
52 /**
53 * Field Render Function.
54 * Takes the vars and outputs the HTML for the field in the settings
55 *
56 * @since 1.0.0
57 * @access public
58 * @return void
59 */
60 public function render() {
61
62 $defaults = array(
63 'show' => array(
64 'title' => true,
65 'description' => true,
66 'url' => true,
67 ),
68 'content_title' => __( 'Slide', 'redux-framework' ),
69 );
70
71 $this->field = wp_parse_args( $this->field, $defaults );
72
73 echo '<div class="redux-slides-accordion" data-new-content-title="' . esc_attr( sprintf( __( 'New %s', 'redux-framework' ), $this->field['content_title'] ) ) . '">';
74
75 $x = 0;
76
77 $multi = ( isset( $this->field['multi'] ) && $this->field['multi'] ) ? ' multiple="multiple"' : '';
78
79 if ( isset( $this->value ) && is_array( $this->value ) && ! empty( $this->value ) ) {
80
81 $slides = $this->value;
82
83 foreach ( $slides as $slide ) {
84
85 if ( empty( $slide ) ) {
86 continue;
87 }
88
89 $defaults = array(
90 'title' => '',
91 'description' => '',
92 'sort' => '',
93 'url' => '',
94 'image' => '',
95 'thumb' => '',
96 'attachment_id' => '',
97 'height' => '',
98 'width' => '',
99 'select' => array(),
100 );
101 $slide = wp_parse_args( $slide, $defaults );
102
103 if ( empty( $slide['thumb'] ) && ! empty( $slide['attachment_id'] ) ) {
104 $img = wp_get_attachment_image_src( $slide['attachment_id'], 'full' );
105 $slide['image'] = $img[0];
106 $slide['width'] = $img[1];
107 $slide['height'] = $img[2];
108 }
109
110 echo '<div class="redux-slides-accordion-group"><fieldset class="redux-field" data-id="' . $this->field['id'] . '"><h3><span class="redux-slides-header">' . $slide['title'] . '</span></h3><div>';
111
112 $hide = '';
113 if ( empty( $slide['image'] ) ) {
114 $hide = ' hide';
115 }
116
117 echo '<div class="screenshot' . $hide . '">';
118 echo '<a class="of-uploaded-image" href="' . $slide['image'] . '">';
119 echo '<img class="redux-slides-image" id="image_image_id_' . $x . '" src="' . $slide['thumb'] . '" alt="" target="_blank" rel="external" />';
120 echo '</a>';
121 echo '</div>';
122
123 echo '<div class="redux_slides_add_remove">';
124
125 echo '<span class="button media_upload_button" id="add_' . $x . '">' . __( 'Upload', 'redux-framework' ) . '</span>';
126
127 $hide = '';
128 if ( empty( $slide['image'] ) || $slide['image'] == '' ) {
129 $hide = ' hide';
130 }
131
132 echo '<span class="button remove-image' . $hide . '" id="reset_' . $x . '" rel="' . $slide['attachment_id'] . '">' . __( 'Remove', 'redux-framework' ) . '</span>';
133
134 echo '</div>' . "\n";
135
136 echo '<ul id="' . $this->field['id'] . '-ul" class="redux-slides-list">';
137
138 if ( $this->field['show']['title'] ) {
139 $title_type = 'text';
140 } else {
141 $title_type = 'hidden';
142 }
143
144 $placeholder = ( isset( $this->field['placeholder']['title'] ) ) ? esc_attr( $this->field['placeholder']['title'] ) : __( 'Title', 'redux-framework' );
145 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>';
146
147 if ( $this->field['show']['description'] ) {
148 $placeholder = ( isset( $this->field['placeholder']['description'] ) ) ? esc_attr( $this->field['placeholder']['description'] ) : __( 'Description', 'redux-framework' );
149 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>';
150 }
151
152 $placeholder = ( isset( $this->field['placeholder']['url'] ) ) ? esc_attr( $this->field['placeholder']['url'] ) : __( 'URL', 'redux-framework' );
153 if ( $this->field['show']['url'] ) {
154 $url_type = 'text';
155 } else {
156 $url_type = 'hidden';
157 }
158
159 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>';
160 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'] . '" />';
161 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'] . '" />';
162 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" />';
163 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" />';
164 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'] . '" />';
165 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>';
166 echo '<li><a href="javascript:void(0);" class="button deletion redux-slides-remove">' . __( 'Delete', 'redux-framework' ) . '</a></li>';
167 echo '</ul></div></fieldset></div>';
168 ++$x;
169 }
170 }
171
172 if ( $x == 0 ) {
173 echo '<div class="redux-slides-accordion-group"><fieldset class="redux-field" data-id="' . $this->field['id'] . '"><h3><span class="redux-slides-header">' . esc_attr( sprintf( __( 'New %s', 'redux-framework' ), $this->field['content_title'] ) ) . '</span></h3><div>';
174
175 $hide = ' hide';
176
177 echo '<div class="screenshot' . $hide . '">';
178 echo '<a class="of-uploaded-image" href="">';
179 echo '<img class="redux-slides-image" id="image_image_id_' . $x . '" src="" alt="" target="_blank" rel="external" />';
180 echo '</a>';
181 echo '</div>';
182
183 // Upload controls DIV
184 echo '<div class="upload_button_div">';
185
186 // If the user has WP3.5+ show upload/remove button
187 echo '<span class="button media_upload_button" id="add_' . $x . '">' . __( 'Upload', 'redux-framework' ) . '</span>';
188
189 echo '<span class="button remove-image' . $hide . '" id="reset_' . $x . '" rel="' . $this->parent->args['opt_name'] . '[' . $this->field['id'] . '][attachment_id]">' . __( 'Remove', 'redux-framework' ) . '</span>';
190
191 echo '</div>' . "\n";
192
193 echo '<ul id="' . $this->field['id'] . '-ul" class="redux-slides-list">';
194 if ( $this->field['show']['title'] ) {
195 $title_type = 'text';
196 } else {
197 $title_type = 'hidden';
198 }
199 $placeholder = ( isset( $this->field['placeholder']['title'] ) ) ? esc_attr( $this->field['placeholder']['title'] ) : __( 'Title', 'redux-framework' );
200 echo '<li><input type="' . $title_type . '" id="' . $this->field['id'] . '-title_' . $x . '" name="' . $this->field['name'] . '[' . $x . '][title]' . $this->field['name_suffix'] . '" value="" placeholder="' . $placeholder . '" class="full-text slide-title" /></li>';
201
202 if ( $this->field['show']['description'] ) {
203 $placeholder = ( isset( $this->field['placeholder']['description'] ) ) ? esc_attr( $this->field['placeholder']['description'] ) : __( 'Description', 'redux-framework' );
204 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"></textarea></li>';
205 }
206 $placeholder = ( isset( $this->field['placeholder']['url'] ) ) ? esc_attr( $this->field['placeholder']['url'] ) : __( 'URL', 'redux-framework' );
207 if ( $this->field['show']['url'] ) {
208 $url_type = 'text';
209 } else {
210 $url_type = 'hidden';
211 }
212 echo '<li><input type="' . $url_type . '" id="' . $this->field['id'] . '-url_' . $x . '" name="' . $this->field['name'] . '[' . $x . '][url]' . $this->field['name_suffix'] . '" value="" class="full-text" placeholder="' . $placeholder . '" /></li>';
213 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="' . $x . '" />';
214 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="" />';
215 echo '<input type="hidden" class="upload" name="' . $this->field['name'] . '[' . $x . '][image]' . $this->field['name_suffix'] . '" id="' . $this->field['id'] . '-image_url_' . $x . '" value="" readonly="readonly" />';
216 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="" />';
217 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="" /></li>';
218 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="" /></li>';
219 echo '<li><a href="javascript:void(0);" class="button deletion redux-slides-remove">' . __( 'Delete', 'redux-framework' ) . '</a></li>';
220 echo '</ul></div></fieldset></div>';
221 }
222 echo '</div><a href="javascript:void(0);" class="button redux-slides-add button-primary" rel-id="' . $this->field['id'] . '-ul" rel-name="' . $this->field['name'] . '[title][]' . $this->field['name_suffix'] . '">' . sprintf( __( 'Add %s', 'redux-framework' ), $this->field['content_title'] ) . '</a><br/>';
223 }
224
225 /**
226 * Enqueue Function.
227 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
228 *
229 * @since 1.0.0
230 * @access public
231 * @return void
232 */
233 public function enqueue() {
234 if ( function_exists( 'wp_enqueue_media' ) ) {
235 wp_enqueue_media();
236 } else {
237 wp_enqueue_script( 'media-upload' );
238 }
239
240 if ( $this->parent->args['dev_mode'] ) {
241 wp_enqueue_style( 'redux-field-media-css' );
242
243 wp_enqueue_style(
244 'redux-field-slides-css',
245 ReduxFrameworkLegacy::$_url . 'inc/fields/slides/field_slides.css',
246 array(),
247 time(),
248 'all'
249 );
250 }
251
252 wp_enqueue_script(
253 'redux-field-media-js',
254 ReduxFrameworkLegacy::$_url . 'assets/js/media/media' . ReduxLegacy_Functions::isMin() . '.js',
255 array( 'jquery', 'redux-js' ),
256 time(),
257 true
258 );
259
260 wp_enqueue_script(
261 'redux-field-slides-js',
262 ReduxFrameworkLegacy::$_url . 'inc/fields/slides/field_slides' . ReduxLegacy_Functions::isMin() . '.js',
263 array( 'jquery', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-sortable', 'redux-field-media-js' ),
264 time(),
265 true
266 );
267 }
268 }
269 }
270