PluginProbe
QuadMenu – Mega Menu / 1.8.8
QuadMenu – Mega Menu v1.8.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 / lib / ReduxCore / inc / fields / slides / field_slides.php

field_slides.php in QuadMenu – Mega Menu 1.8.8, at lib/ReduxCore/inc/fields/slides/field_slides.php

270 lines 15.5 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 ReduxFramework
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 ( 'ReduxFramework_slides' ) ) {
30
31 /**
32 * Main ReduxFramework_slides class
33 *
34 * @since 1.0.0
35 */
36 class ReduxFramework_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 ) {
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
118 echo '<div class="screenshot' . $hide . '">';
119 echo '<a class="of-uploaded-image" href="' . $slide[ 'image' ] . '">';
120 echo '<img class="redux-slides-image" id="image_image_id_' . $x . '" src="' . $slide[ 'thumb' ] . '" alt="" target="_blank" rel="external" />';
121 echo '</a>';
122 echo '</div>';
123
124 echo '<div class="redux_slides_add_remove">';
125
126 echo '<span class="button media_upload_button" id="add_' . $x . '">' . __ ( 'Upload', 'redux-framework' ) . '</span>';
127
128 $hide = '';
129 if ( empty ( $slide[ 'image' ] ) || $slide[ 'image' ] == '' ) {
130 $hide = ' hide';
131 }
132
133 echo '<span class="button remove-image' . $hide . '" id="reset_' . $x . '" rel="' . $slide[ 'attachment_id' ] . '">' . __ ( 'Remove', 'redux-framework' ) . '</span>';
134
135 echo '</div>' . "\n";
136
137 echo '<ul id="' . $this->field[ 'id' ] . '-ul" class="redux-slides-list">';
138
139 if ( $this->field[ 'show' ][ 'title' ] ) {
140 $title_type = "text";
141 } else {
142 $title_type = "hidden";
143 }
144
145 $placeholder = ( isset ( $this->field[ 'placeholder' ][ 'title' ] ) ) ? esc_attr ( $this->field[ 'placeholder' ][ 'title' ] ) : __ ( 'Title', 'redux-framework' );
146 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>';
147
148 if ( $this->field[ 'show' ][ 'description' ] ) {
149 $placeholder = ( isset ( $this->field[ 'placeholder' ][ 'description' ] ) ) ? esc_attr ( $this->field[ 'placeholder' ][ 'description' ] ) : __ ( 'Description', 'redux-framework' );
150 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>';
151 }
152
153 $placeholder = ( isset ( $this->field[ 'placeholder' ][ 'url' ] ) ) ? esc_attr ( $this->field[ 'placeholder' ][ 'url' ] ) : __ ( 'URL', 'redux-framework' );
154 if ( $this->field[ 'show' ][ 'url' ] ) {
155 $url_type = "text";
156 } else {
157 $url_type = "hidden";
158 }
159
160 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>';
161 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' ] . '" />';
162 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' ] . '" />';
163 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" />';
164 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" />';
165 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' ] . '" />';
166 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>';
167 echo '<li><a href="javascript:void(0);" class="button deletion redux-slides-remove">' . __ ( 'Delete', 'redux-framework' ) . '</a></li>';
168 echo '</ul></div></fieldset></div>';
169 $x ++;
170 }
171 }
172
173 if ( $x == 0 ) {
174 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>';
175
176 $hide = ' hide';
177
178 echo '<div class="screenshot' . $hide . '">';
179 echo '<a class="of-uploaded-image" href="">';
180 echo '<img class="redux-slides-image" id="image_image_id_' . $x . '" src="" alt="" target="_blank" rel="external" />';
181 echo '</a>';
182 echo '</div>';
183
184 //Upload controls DIV
185 echo '<div class="upload_button_div">';
186
187 //If the user has WP3.5+ show upload/remove button
188 echo '<span class="button media_upload_button" id="add_' . $x . '">' . __ ( 'Upload', 'redux-framework' ) . '</span>';
189
190 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>';
191
192 echo '</div>' . "\n";
193
194 echo '<ul id="' . $this->field[ 'id' ] . '-ul" class="redux-slides-list">';
195 if ( $this->field[ 'show' ][ 'title' ] ) {
196 $title_type = "text";
197 } else {
198 $title_type = "hidden";
199 }
200 $placeholder = ( isset ( $this->field[ 'placeholder' ][ 'title' ] ) ) ? esc_attr ( $this->field[ 'placeholder' ][ 'title' ] ) : __ ( 'Title', 'redux-framework' );
201 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>';
202
203 if ( $this->field[ 'show' ][ 'description' ] ) {
204 $placeholder = ( isset ( $this->field[ 'placeholder' ][ 'description' ] ) ) ? esc_attr ( $this->field[ 'placeholder' ][ 'description' ] ) : __ ( 'Description', 'redux-framework' );
205 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>';
206 }
207 $placeholder = ( isset ( $this->field[ 'placeholder' ][ 'url' ] ) ) ? esc_attr ( $this->field[ 'placeholder' ][ 'url' ] ) : __ ( 'URL', 'redux-framework' );
208 if ( $this->field[ 'show' ][ 'url' ] ) {
209 $url_type = "text";
210 } else {
211 $url_type = "hidden";
212 }
213 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>';
214 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 . '" />';
215 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="" />';
216 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" />';
217 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="" />';
218 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>';
219 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>';
220 echo '<li><a href="javascript:void(0);" class="button deletion redux-slides-remove">' . __ ( 'Delete', 'redux-framework' ) . '</a></li>';
221 echo '</ul></div></fieldset></div>';
222 }
223 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/>';
224 }
225
226 /**
227 * Enqueue Function.
228 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
229 *
230 * @since 1.0.0
231 * @access public
232 * @return void
233 */
234 public function enqueue () {
235 if ( function_exists( 'wp_enqueue_media' ) ) {
236 wp_enqueue_media();
237 } else {
238 wp_enqueue_script( 'media-upload' );
239 }
240
241 if ($this->parent->args['dev_mode']){
242 wp_enqueue_style ('redux-field-media-css');
243
244 wp_enqueue_style (
245 'redux-field-slides-css',
246 ReduxFramework::$_url . 'inc/fields/slides/field_slides.css',
247 array(),
248 time (),
249 'all'
250 );
251 }
252
253 wp_enqueue_script(
254 'redux-field-media-js',
255 ReduxFramework::$_url . 'assets/js/media/media' . Redux_Functions::isMin() . '.js',
256 array( 'jquery', 'redux-js' ),
257 time(),
258 true
259 );
260
261 wp_enqueue_script (
262 'redux-field-slides-js',
263 ReduxFramework::$_url . 'inc/fields/slides/field_slides' . Redux_Functions::isMin () . '.js',
264 array( 'jquery', 'jquery-ui-core', 'jquery-ui-accordion', 'jquery-ui-sortable', 'redux-field-media-js' ),
265 time (),
266 true
267 );
268 }
269 }
270 }