PluginProbe
Visual Slider / trunk
Visual Slider vtrunk
visual-slider / visual-slider.php

visual-slider.php in Visual Slider trunk, at visual-slider.php

427 lines 15.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Visual Slider
4 * Description: Responsive Slider
5 * Version: 1.8
6 * Author: sdastan800
7 * Text Domain: visual-slider
8 * Domain Path: /languages/
9 * License:GPLv2 or later
10 * Requires at least: 6.0
11 * Requires PHP: 7.4.0
12 * License URI:https://www.gnu.org/licenses/gpl-2.0.html
13 /* Plugin Framework Version Check */
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit; // Exit if accessed directly.
16 }
17 if( !defined('VISUALSLIDER_PATH') ){
18 define( 'VISUALSLIDER_PATH', plugin_dir_path(__FILE__) );
19 }
20 if( !defined('VISUALSLIDER_DIR') ){
21 define( 'VISUALSLIDER_DIR', plugin_dir_url(__FILE__) );
22 }
23
24 if( ! function_exists( 'visualslider_constructor' ) ) {
25 function visualslider_constructor() {
26
27 if ( version_compare( $GLOBALS['wp_version'], '6.7', '<' ) ) {
28 load_plugin_textdomain( 'visual-builder' );
29 } else {
30 load_textdomain( 'visual-slider', plugin_dir_path(__FILE__) . 'languages/visual-slider-' . determine_locale() . '.mo' );
31 }
32
33 }
34 }
35 add_action( 'visualslider_init', 'visualslider_constructor' );
36
37
38 /*****************************************************************************************************************************************************
39 ******************************************************************************************************************************************************
40
41 Slider Install
42
43 */////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
44 if( ! function_exists( 'visualslider_install' ) ) {
45 function visualslider_install() {
46
47
48 do_action( 'visualslider_init' );
49 }
50
51 add_action( 'plugins_loaded', 'visualslider_install', 1 );
52 }
53
54
55 if( function_exists( 'visualslider_constructor' ) ) {
56
57 if( ! function_exists( 'visualslider_post_type' ) ) {
58 add_action( 'init', 'visualslider_post_type' );
59
60 function visualslider_post_type() {
61 $labels = array(
62 'name' => __('Slider','visual-slider'),
63 'singular_name' => __('Sliders','visual-slider'),
64 'add_new' => __('Add New','visual-slider'),
65 'add_new_item' =>__('Add New slider','visual-slider'),
66 'edit_item' => __('Edit Slider','visual-slider'),
67 'new_item' => __('New Slider','visual-slider'),
68 'view_item' => __('View Slider','visual-slider'),
69 'all_items' =>__('All Sliders','visual-slider'),
70 'search_items' => __('Search Sliders','visual-slider'),
71 'not_found' => __('Slider not found','visual-slider'),
72 'not_found_in_trash' => __('The slider was found in the trash','visual-slider'),
73 'parent_item_colon' => '',
74 'menu_name' => __('Visual Slider','visual-slider')
75 );
76
77 $args = array(
78 'labels' => $labels,
79 'public' => true,
80 'publicly_queryable' => true,
81 'show_ui' => true,
82 'show_in_menu' => true,
83 'query_var' => true,
84 'rewrite' => true,
85 'capability_type' => 'post',
86 'has_archive' => false,
87 'hierarchical' => false,
88 'menu_position' => null,
89 'supports' => array( 'title' )
90 );
91
92 register_post_type( 'visualslider', $args );
93 }
94 }
95
96 include_once VISUALSLIDER_PATH . 'inc/widget-visualslider.php';
97 include_once VISUALSLIDER_PATH . 'inc/vb-visualslider.php';
98 if ( !function_exists ( "visualslider_elementor_widgets" )){
99 function visualslider_elementor_widgets() {
100
101
102 require_once(VISUALSLIDER_PATH . 'inc/elementor-visualslider.php' );
103 // Register widget
104
105 \Elementor\Plugin::instance()->widgets_manager->register( new \visualslider_slider() );
106
107
108 }
109 add_action( 'elementor/widgets/register', 'visualslider_elementor_widgets' );
110 }
111
112 include_once VISUALSLIDER_PATH . 'inc/composer-visualslider.php';
113
114
115 }
116
117
118
119
120
121
122 if( ! function_exists( 'vs_layer_options_element' ) ) {
123 function vs_layer_options_element() {
124 global $vs_layer_options_element;
125
126 $slider=array();
127
128 if(has_filter('vs_layer_element_options')) {
129 $vs_layer_options_element = apply_filters('vs_layer_element_options', $slider);
130 }
131
132
133 }
134 add_action('init','vs_layer_options_element');
135 }
136
137
138
139 global $vs_fonticon_style;
140
141
142 if( ! function_exists( 'vs_icon_fontfamily' ) ) {
143 function vs_icon_fontfamily($value =false) {
144 if(!empty($value)){
145 global $vs_fonticon_style;
146 if(strpos($value,'fa-')!==false){
147 $vs_fonticon_style['FontAwesome']=true;
148 }
149 if(strpos($value,'flaticonarrow-')!==false){
150 $vs_fonticon_style['flaticonarrow']=true;
151 }
152 if(strpos($value,'flaticonmultimedia-')!==false){
153 $vs_fonticon_style['flaticonmultimedia']=true;
154 }
155
156 if(strpos($value,'flaticonbusiness-')!==false){
157 $vs_fonticon_style['flaticonbusiness']=true;
158 }
159
160 if(strpos($value,'flaticonoffice-')!==false){
161 $vs_fonticon_style['flaticonoffice']=true;
162 }
163 if(strpos($value,'flaticoninterface-')!==false){
164 $vs_fonticon_style['flaticoninterface']=true;
165 }
166
167 if(strpos($value,'flaticonessentialset-')!==false){
168 $vs_fonticon_style['flaticonessentialset']=true;
169 }
170 if(strpos($value,'flaticontechsupport-')!==false){
171 $vs_fonticon_style['flaticontechsupport']=true;
172 }
173 if(strpos($value,'flaticontech-')!==false){
174 $vs_fonticon_style['flaticontech']=true;
175 }
176 if(strpos($value,'flaticonstrategy-')!==false){
177 $vs_fonticon_style['flaticonstrategy']=true;
178 }
179 if(strpos($value,'flaticonhipster-')!==false){
180 $vs_fonticon_style['flaticonhipster']=true;
181 }
182 if(strpos($value,'flaticonfashion-')!==false){
183 $vs_fonticon_style['flaticonfashion']=true;
184 }
185 if(strpos($value,'flaticonwebdesign-')!==false){
186 $vs_fonticon_style['flaticonwebdesign']=true;
187 }
188 if(strpos($value,'flaticontravel-')!==false){
189 $vs_fonticon_style['flaticontravel']=true;
190 }
191 if(strpos($value,'flaticonnetwork-')!==false){
192 $vs_fonticon_style['flaticonnetwork']=true;
193 }
194
195 if(strpos($value,'metrizeicon-')!==false){
196 $vs_fonticon_style['metrizeicon']=true;
197 }
198 if(strpos($value,'typcn-')!==false){
199 $vs_fonticon_style['typcn']=true;
200 }
201 }
202
203 }
204 }
205 if( ! function_exists( 'vs_icon_enqueue' ) ) {
206 function vs_icon_enqueue($var=false,$true=false) {
207 global $vs_fonticon_style;
208
209 if(!empty($vs_fonticon_style['FontAwesome']) || !empty($true)) wp_enqueue_style('vs_fontawesome',VISUALSLIDER_DIR. 'assets/css/fonts/fontawesome.css','',$var);
210 if(!empty($vs_fonticon_style['flaticonarrow']) || !empty($true)) wp_enqueue_style('vs_flaticonarrow',VISUALSLIDER_DIR. 'assets/css/fonts/flaticonarrow.css','',$var);
211 if(!empty($vs_fonticon_style['flaticonmultimedia']) || !empty($true) ) wp_enqueue_style('vs_flaticonmultimedia',VISUALSLIDER_DIR. 'assets/css/fonts/flaticonmultimedia.css','',$var);
212 if(!empty($vs_fonticon_style['flaticonbusiness']) || !empty($true)) wp_enqueue_style('vs_flaticonbusiness',VISUALSLIDER_DIR. 'assets/css/fonts/flaticonbusiness.css','',$var);
213 if(!empty($vs_fonticon_style['flaticonoffice']) || !empty($true)) wp_enqueue_style('vs_flaticonoffice',VISUALSLIDER_DIR. 'assets/css/fonts/flaticonoffice.css','',$var);
214 if(!empty($vs_fonticon_style['flaticoninterface']) || !empty($true) ) wp_enqueue_style('vs_flaticoninterface',VISUALSLIDER_DIR. 'assets/css/fonts/flaticoninterface.css','',$var);
215 if(!empty($vs_fonticon_style['flaticonessentialset']) || !empty($true)) wp_enqueue_style('vs_flaticonessentialset',VISUALSLIDER_DIR. 'assets/css/fonts/flaticonessentialset.css','',$var);
216 if(!empty($vs_fonticon_style['flaticontechsupport']) || !empty($true)) wp_enqueue_style('vs_flaticontechsupport',VISUALSLIDER_DIR. 'assets/css/fonts/flaticontechsupport.css','',$var);
217 if(!empty($vs_fonticon_style['flaticontech']) || !empty($true)) wp_enqueue_style('vs_flaticontech',VISUALSLIDER_DIR. 'assets/css/fonts/flaticontech.css','',$var);
218 if(!empty($vs_fonticon_style['flaticonstrategy']) || !empty($true)) wp_enqueue_style('vs_flaticonstrategy',VISUALSLIDER_DIR. 'assets/css/fonts/flaticonstrategy.css','',$var);
219 if(!empty($vs_fonticon_style['flaticonhipster']) || !empty($true) ) wp_enqueue_style('vs_flaticonhipster',VISUALSLIDER_DIR. 'assets/css/fonts/flaticonhipster.css','',$var);
220 if(!empty($vs_fonticon_style['flaticonfashion']) || !empty($true) ) wp_enqueue_style('vs_flaticonfashion',VISUALSLIDER_DIR. 'assets/css/fonts/flaticonfashion.css','',$var);
221 if(!empty($vs_fonticon_style['flaticonwebdesign']) || !empty($true) ) wp_enqueue_style('vs_flaticonwebdesign',VISUALSLIDER_DIR. 'assets/css/fonts/flaticonwebdesign.css','',$var);
222 if(!empty($vs_fonticon_style['flaticontravel']) || !empty($true) ) wp_enqueue_style('vs_flaticontravel',VISUALSLIDER_DIR. 'assets/css/fonts/flaticontravel.css','',$var);
223 if(!empty($vs_fonticon_style['flaticonnetwork']) || !empty($true)) wp_enqueue_style('vs_flaticonnetwork',VISUALSLIDER_DIR. 'assets/css/fonts/flaticonnetwork.css','',$var);
224 if(!empty($vs_fonticon_style['metrizeicon']) || !empty($true)) wp_enqueue_style('vs_metrizeicon',VISUALSLIDER_DIR. 'assets/css/fonts/metrizeicon.css','',$var);
225 if(!empty($vs_fonticon_style['typcn']) || !empty($true)) wp_enqueue_style('vs_typcn',VISUALSLIDER_DIR. 'assets/css/fonts/typcn.css','',$var);
226 }
227 }
228
229
230
231 if( ! function_exists( 'vs_rtl_has' ) ) {
232 function vs_rtl_has($element =false) {
233
234 if(is_rtl() && strpos($element,'left')!==false){
235 return str_replace('left','right', $element);
236
237 }elseif(is_rtl() && strpos($element,'right')!==false){
238
239 return str_replace('right','left',$element);
240
241 } else{
242 return $element;
243
244 }
245 }
246 }
247 if ( ! function_exists( 'vs_kses' ) ) {
248 function vs_kses() {
249 $safe_attrs = [
250 'id', 'class', 'style', 'title', 'lang', 'dir', 'tabindex', 'hidden',
251 'draggable', 'contenteditable',
252 'data-*', 'aos-*',
253 'href', 'target', 'rel', 'src', 'alt', 'srcset', 'sizes', 'poster', 'preload', 'loading',
254 'width', 'height',
255 'role', 'aria-*',
256 ];
257
258 $safe_tags = [
259 'span', 'strong', 'b', 'em', 'i', 'u', 's', 'small', 'sub', 'sup', 'mark', 'del', 'ins', 'code',
260 'abbr', 'cite', 'q', 'var', 'dfn', 'br', 'p', 'div', 'section', 'article', 'aside', 'header',
261 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'li',
262 'table', 'thead', 'tbody', 'tfoot', 'tr', 'th', 'td', 'caption',
263 'img', 'picture', 'source',
264 'a', 'details', 'summary',
265 ];
266
267 $result = [];
268
269 foreach ($safe_tags as $tag) {
270 $result[$tag] = [];
271 foreach ($safe_attrs as $attr) {
272 $result[$tag][$attr] = true;
273 }
274 }
275
276 return $result;
277 }
278 }
279 if ( is_admin() ) {
280
281 include_once VISUALSLIDER_PATH . 'admin/index.php';
282
283 }
284
285 include_once VISUALSLIDER_PATH . 'inc/element-css.php';
286 include_once VISUALSLIDER_PATH . 'inc/post-functions.php';
287 include_once VISUALSLIDER_PATH . 'inc/var-element-css.php';
288
289
290
291 include_once VISUALSLIDER_PATH . 'inc/global-config.php';
292 include_once VISUALSLIDER_PATH . 'inc/global-slider-config.php';
293 include_once VISUALSLIDER_PATH . 'inc/global-glider-config.php';
294 include_once VISUALSLIDER_PATH . 'inc/global-single-config.php';
295
296 include_once VISUALSLIDER_PATH . 'inc/slide-config.php';
297 include_once VISUALSLIDER_PATH . 'inc/glide-config.php';
298 include_once VISUALSLIDER_PATH . 'inc/single-config.php';
299
300 include_once VISUALSLIDER_PATH . 'inc/layer-config.php';
301 include_once VISUALSLIDER_PATH . 'admin/includes/code.php';
302 include_once VISUALSLIDER_PATH . 'admin/includes/new-code.php';
303
304
305 include_once VISUALSLIDER_PATH . 'layer/text.php';
306 include_once VISUALSLIDER_PATH . 'layer/icon.php';
307 include_once VISUALSLIDER_PATH . 'layer/button.php';
308 include_once VISUALSLIDER_PATH . 'layer/image.php';
309 include_once VISUALSLIDER_PATH . 'layer/box.php';
310 /*****************************************************************************************************************************************************
311 ******************************************************************************************************************************************************
312
313 Slider Custom Template
314
315 */////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
316
317
318 if( ! function_exists( 'vs_enqueue' ) ) {
319 add_action('wp_enqueue_scripts', 'vs_enqueue');
320 function vs_enqueue($hook) {
321 $var ='1.7';
322
323 wp_enqueue_style( 'vs_glider',VISUALSLIDER_DIR .'assets/css/glider.css',array(),$var,false);
324 wp_enqueue_style( 'vs_slider',VISUALSLIDER_DIR .'assets/css/slider.css',array(),$var,false);
325 wp_enqueue_style( 'vs_layer',VISUALSLIDER_DIR .'assets/css/layer.css',array(),$var,false);
326
327 vs_icon_enqueue('1.0');
328
329
330 wp_enqueue_script( 'vs_slider', VISUALSLIDER_DIR .'assets/js/slider.js',array('jquery'),$var,false );
331 wp_enqueue_script( 'vs_script', VISUALSLIDER_DIR .'assets/js/script.js' ,array('jquery'),$var,false);
332
333
334 }
335 }
336 if( ! function_exists( 'vs_slider_config' ) ) {
337 function vs_slider_config($id) {
338
339 if(!empty($id)){
340
341
342 $setting_json = get_post_meta($id, 'vs_setting_json', true);
343 $setting= vs_options_array_row($setting_json,'st');
344
345
346
347 $slide_json = get_post_meta($id, 'vs_slide', true);
348 $slide= vs_options_array_row($slide_json,'sl');
349 vs_global_config($id, $setting,$slide);
350 }
351 }
352 }
353
354
355
356 /*****************************************************************************************************************************************************
357 ******************************************************************************************************************************************************
358
359 slider_elementor_widget_categories
360
361 */////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
362 if ( !function_exists ( "visualslider_shortcode" )){
363 function visualslider_shortcode($id) {
364 extract(shortcode_atts(array(
365 'id' => 'id'
366 ), $id));
367
368 // check what type user entered
369 return vs_slider_config($id);
370 }
371 add_shortcode('visualslider', 'visualslider_shortcode');
372 }
373
374
375 if ( !function_exists ( "visualslider_single_template" )){
376 add_filter( 'single_template', 'visualslider_single_template' );
377 function visualslider_single_template( $template ){
378 global $post;
379
380
381
382 if ( 'visualslider' === $post->post_type && locate_template( array( 'single-visualslider.php' ) ) !== $template ) {
383 /*
384 * This is a 'movie' post
385 * AND a 'single movie template' is not found on
386 * theme or child theme directories, so load it
387 * from our plugin directory.
388 */
389 return plugin_dir_path( __FILE__ ) . 'inc/single-visualslider.php';
390 }
391
392
393
394 return $template;
395 }
396 }
397 if ( !function_exists ( "visualslider_load_cpt_template" )){
398 function visualslider_load_cpt_template($template) {
399 global $post;
400
401 // Is this a "my-custom-post-type" post?
402 if ($post->post_type == "visualslider"){
403
404 //Your plugin path
405 $plugin_path = plugin_dir_path( __FILE__ );
406
407 // The name of custom post type single template
408 $template_name = 'single-visualslider.php';
409
410 // A specific single template for my custom post type exists in theme folder? Or it also doesn't exist in my plugin?
411 if($template === get_stylesheet_directory() . '/' . $template_name
412 || !file_exists($plugin_path . $template_name)) {
413
414 //Then return "single.php" or "single-my-custom-post-type.php" from theme directory.
415 return $template;
416 }
417
418 // If not, return my plugin custom post type template.
419 return $plugin_path . $template_name;
420 }
421
422 //This is not my custom post type, do nothing with $template
423 return $template;
424 }
425 add_filter('single_template', 'visualslider_load_cpt_template');
426 }
427