forked from wp-plugins/slider-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslider.php
762 lines (649 loc) · 31.9 KB
/
slider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
<?php
/*
Plugin Name: Elegant Slider
Plugin URI: https://github.com/bryce13950/slider-image
Description: Axolotl slider is a convenient tool for organizing the images represented on your website into sliders. Each product on the slider is assigned with a relevant slider, which makes it easier for the customers to search and identify the needed images within the slider.
Version: 0.4.1
Author: http://axolotlinteractive.com
License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
/*
* Plugin origin
Plugin Name: Huge IT Slider
Plugin URI: http://huge-it.com/slider
Description: Huge IT slider is a convenient tool for organizing the images represented on your website into sliders. Each product on the slider is assigned with a relevant slider, which makes it easier for the customers to search and identify the needed images within the slider.
Version: 2.7.4
Author: http://huge-it.com/
License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
add_action('media_buttons_context', 'add_my_custom_button');
function add_my_custom_button($context) {
$img = plugins_url( '/images/post.button.png' , __FILE__ );
$container_id = 'huge_it_slider';
$title = 'Select Huge IT Slider to insert into post';
$context .= '<a class="button thickbox" title="Select slider to insert into post" href="?page=sliders_huge_it_slider&task=add_shortcode_post&TB_iframe=1&width=400&inlineId='.$container_id.'">
<span class="wp-media-buttons-icon" style="background: url('.$img.'); background-repeat: no-repeat; background-position: left bottom;"></span>
Add Slider
</a>';
return $context;
}
function remove_media_tab($strings) {
//unset($strings["insertFromUrlTitle"]);
return $strings;
}
add_filter('media_view_strings','remove_media_tab');
add_action('init', 'hugesl_do_output_buffer');
function hugesl_do_output_buffer() {
ob_start();
}
$ident = 1;
add_action('admin_head', 'huge_it_ajax_func');
function huge_it_ajax_func()
{
?>
<script>
var huge_it_ajax = '<?php echo admin_url("admin-ajax.php"); ?>';
</script>
<?php
}
function huge_it_slider_images_list_shotrcode($atts)
{
extract(shortcode_atts(array(
'id' => 'no huge_it slider',
), $atts));
return huge_it_cat_images_list($atts['id']);
}
function slider_after_search_results($query)
{
global $wpdb;
if (isset($_REQUEST['s']) && $_REQUEST['s']) {
$serch_word = htmlspecialchars(($_REQUEST['s']));
$query = str_replace($wpdb->prefix . "posts.post_content", gen_string_slider_search($serch_word, $wpdb->prefix . 'posts.post_content') . " " . $wpdb->prefix . "posts.post_content", $query);
}
return $query;
}
add_filter('posts_request', 'slider_after_search_results');
function gen_string_slider_search($serch_word, $wordpress_query_post)
{
$string_search = '';
global $wpdb;
if ($serch_word) {
$rows_slider = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "huge_itslider_sliders WHERE (description LIKE %s) OR (name LIKE %s)", '%' . $serch_word . '%', "%" . $serch_word . "%"));
$count_cat_rows = count($rows_slider);
for ($i = 0; $i < $count_cat_rows; $i++) {
$string_search .= $wordpress_query_post . ' LIKE \'%[huge_it_slider id="' . $rows_slider[$i]->id . '" details="1" %\' OR ' . $wordpress_query_post . ' LIKE \'%[huge_it_slider id="' . $rows_slider[$i]->id . '" details="1"%\' OR ';
}
$rows_slider = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "huge_itslider_sliders WHERE (name LIKE %s)","'%" . $serch_word . "%'"));
$count_cat_rows = count($rows_slider);
for ($i = 0; $i < $count_cat_rows; $i++) {
$string_search .= $wordpress_query_post . ' LIKE \'%[huge_it_slider id="' . $rows_slider[$i]->id . '" details="0"%\' OR ' . $wordpress_query_post . ' LIKE \'%[huge_it_slider id="' . $rows_slider[$i]->id . '" details="0"%\' OR ';
}
$rows_single = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "huge_itslider_images WHERE name LIKE %s","'%" . $serch_word . "%'"));
$count_sing_rows = count($rows_single);
if ($count_sing_rows) {
for ($i = 0; $i < $count_sing_rows; $i++) {
$string_search .= $wordpress_query_post . ' LIKE \'%[huge_it_slider_Product id="' . $rows_single[$i]->id . '"]%\' OR ';
}
}
}
return $string_search;
}
add_shortcode('elegant_slider', 'huge_it_slider_images_list_shotrcode');
//@Deprecated
add_shortcode('huge_it_slider', 'huge_it_slider_images_list_shotrcode');
function huge_it_cat_images_list($id)
{
require_once("slider_front_end.html.php");
require_once("slider_front_end.php");
if (isset($_GET['product_id'])) {
if (isset($_GET['view'])) {
if ($_GET['view'] == 'huge_itslider') {
return showPublishedimages_1($id);
} else {
return front_end_single_product($_GET['product_id']);
}
} else {
return front_end_single_product($_GET['product_id']);
}
} else {
return showPublishedimages_1($id);
}
}
function getSlider($id) {
global $wpdb;
$query = $wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders WHERE id = '%d';", $id);
$sliders = $wpdb->get_results($query);
$slider = null;
if(count($sliders)) {
$slider = $sliders[0];
$slider->images = getSliderImages($id);
}
return $slider;
}
function getSliders() {
global $wpdb;
$query = "SELECT * FROM " . $wpdb->prefix."huge_itslider_sliders";
$sliders = $wpdb->get_results($query, ARRAY_A);
return $sliders;
}
function getSliderImages($id) {
global $wpdb;
$query = $wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_images where slider_id = '%d' order by ordering ASC",$id);
$images = $wpdb->get_results($query);
return $images;
}
add_action('admin_menu', 'elegant_slider_options_panel');
function elegant_slider_options_panel()
{
$page_cat = add_menu_page('Theme page title', 'Elegant Slider', 'manage_options', 'sliders_huge_it_slider', 'sliders_huge_it_slider', 'dashicons-images-alt2', 4);
add_submenu_page('sliders_huge_it_slider', 'Sliders', 'Sliders', 'manage_options', 'sliders_huge_it_slider', 'sliders_huge_it_slider');
$page_option = add_submenu_page('sliders_huge_it_slider', 'General Options', 'General Options', 'manage_options', 'Options_slider_styles', 'Options_slider_styles');
add_action('admin_print_styles-' . $page_cat, 'huge_it_slider_admin_script');
add_action('admin_print_styles-' . $page_option, 'huge_it_slider_option_admin_script');
}
function huge_it_slider_admin_script() {
wp_enqueue_media();
wp_enqueue_style("jquery_ui", "http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css", ['jquery']);
wp_enqueue_script("simple_slider_js", plugins_url("js/simple-slider.js", __FILE__), FALSE);
wp_enqueue_style("simple_slider_css", plugins_url("style/simple-slider.css", __FILE__), FALSE);
wp_enqueue_style("admin_css", plugins_url("style/admin.style.css", __FILE__), FALSE);
wp_enqueue_script("admin_js", plugins_url("js/admin.js", __FILE__), FALSE);
wp_enqueue_script('param_block2', plugins_url("elements/jscolor/jscolor.js", __FILE__));
}
function huge_it_slider_option_admin_script() {
wp_enqueue_script("jquery_old", "http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js", FALSE);
if (!jQuery.ui)
{
// wp_enqueue_script("jquery_new", "http://code.jquery.com/jquery-1.10.2.js", FALSE);
wp_enqueue_script("jquery_ui_new", "http://code.jquery.com/ui/1.10.4/jquery-ui.js", FALSE);
}
wp_enqueue_script("simple_slider_js", plugins_url("js/simple-slider.js", __FILE__), FALSE);
wp_enqueue_style("simple_slider_css", plugins_url("style/simple-slider.css", __FILE__), FALSE);
wp_enqueue_style("admin_css", plugins_url("style/admin.style.css", __FILE__), FALSE);
wp_enqueue_script("admin_js", plugins_url("js/admin.js", __FILE__), FALSE);
wp_enqueue_script('param_block2', plugins_url("elements/jscolor/jscolor.js", __FILE__));
if (!jQuery.ui)
{
// wp_enqueue_script("jquery_new", "http://code.jquery.com/jquery-1.10.2.js", FALSE);
wp_enqueue_script("jquery_ui_new", "http://code.jquery.com/ui/1.10.4/jquery-ui.js", FALSE);
}
}
function sliders_huge_it_slider()
{
require_once("sliders.php");
require_once("sliders.html.php");
if (!function_exists('print_html_nav'))
require_once("slider_function/html_slider_func.php");
if (isset($_GET["task"]))
$task = $_GET["task"];
else
$task = '';
if (isset($_GET["id"]))
$id = $_GET["id"];
else
$id = 0;
global $wpdb;
switch ($task) {
case 'add_cat':
add_slider();
break;
case 'add_shortcode_post':
add_shortcode_post();
break;
case 'popup_posts':
if ($id)
popup_posts($id);
break;
case 'popup_video':
if ($id)
popup_video($id);
else {
$id = $wpdb->get_var("SELECT MAX( id ) FROM " . $wpdb->prefix . "huge_itslider_sliders");
popup_video($id);
}
break;
case 'edit_cat':
if ($id)
editslider($id);
else {
$id = $wpdb->get_var("SELECT MAX( id ) FROM " . $wpdb->prefix . "huge_itslider_sliders");
editslider($id);
}
break;
case 'save':
if ($id)
apply_cat($id);
case 'apply':
if ($id) {
apply_cat($id);
editslider($id);
}
break;
case 'remove_cat':
removeslider($id);
showslider();
break;
default:
showslider();
break;
}
}
function add_shortcode_post()
{
?>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#hugeitsliderinsert').on('click', function() {
jQuery('#save-buttom').click();
var id = jQuery('#huge_it_slider-select option:selected').val();
if(window.parent.tinyMCE && window.parent.tinyMCE.activeEditor)
{
window.parent.send_to_editor('[huge_it_slider id="'+id+'"]');
}
tb_remove();
})
});
</script>
<style>
#wpadminbar,.auto-fold #adminmenu, .auto-fold #adminmenu li.menu-top, .auto-fold #adminmenuback, .auto-fold #adminmenuwrap {
display: none;
}
#wpcontent {
margin-top: -55px;
}
.wp-core-ui .button {margin:0px 0px 0px 10px !important;}
#slider-unique-options-list li {
clear:both;
margin:10px 0px 5px 0px;
}
#slider-unique-options-list li label {width:130px;}
#save-buttom {display:none;}
h3 {
margin:30px 0px 15px 0px;
}
</style>
<div class="clear"></div>
<h3>Select the Slider</h3>
<div id="huge_it_slider">
<?php
global $wpdb;
$query="SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders";
$firstrow=$wpdb->get_row($query);
if(isset($_POST["hugeit_slider_id"])){
$id=$_POST["hugeit_slider_id"];
}
else{
$id=$firstrow->id;
}
if($_GET["htslider_id"] == $_POST["hugeit_slider_id"]){
if($_GET["hugeit_save"]==1){
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET sl_width = '%s' WHERE id = %d ", $_POST["sl_width"], $id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET sl_height = '%s' WHERE id = %d ", $_POST["sl_height"], $id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET pause_on_hover = '%s' WHERE id = %d ", $_POST["pause_on_hover"], $id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET slider_list_effects_s = '%s' WHERE id = %d ", $_POST["slider_effects_list"], $id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET description = '%s' WHERE id = %d ", $_POST["sl_pausetime"], $id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET param = '%s' WHERE id = %d ", $_POST["sl_changespeed"], $id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET sl_position = '%s' WHERE id = %d ", $_POST["sl_position"], $id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET sl_loading_icon = '%s' WHERE id = %d ", $_POST["sl_loading_icon"], $id));
}
}
$query="SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders order by id ASC";
$shortcodesliders=$wpdb->get_results($query);
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders WHERE id= %d", $id);
$row=$wpdb->get_row($query);
?>
<form action="?page=sliders_huge_it_slider&task=add_shortcode_post&TB_iframe=1&width=400&inlineId=<?php echo $container_id; ?>&hugeit_save=1&htslider_id=<?php echo $id; ?>" method="post" name="adminForm" id="adminForm">
<?php if (count($shortcodesliders)) {
echo "<select id='huge_it_slider-select' onchange='this.form.submit()' name='hugeit_slider_id'>";
foreach ($shortcodesliders as $shortcodeslider) {
$selected='';
if($shortcodeslider->id == $_POST["hugeit_slider_id"]){$selected='selected="selected"';}
echo "<option ".$selected." value='".$shortcodeslider->id."'>".$shortcodeslider->name."</option>";
}
echo "</select>";
echo "<button class='button primary' id='hugeitsliderinsert'>Insert Slider</button>";
} else {
echo "No slideshows found", "huge_it_slider";
}
$container_id = 'huge_it_slider';
?>
</div>
<div id="" class="meta-box-sortables ui-sortable">
<div id="slider-unique-options" class="">
<h3 class="hndle"><span>Current Slider Options</span></h3>
<ul id="slider-unique-options-list">
<li>
<label for="sl_width">Width</label>
<input type="text" name="sl_width" id="sl_width" value="<?php echo $row->sl_width; ?>" class="text_area" />
</li>
<li>
<label for="sl_height">Height</label>
<input type="text" name="sl_height" id="sl_height" value="<?php echo $row->sl_height; ?>" class="text_area" />
</li>
<li>
<label for="pause_on_hover">Pause on hover</label>
<input type="hidden" value="off" name="pause_on_hover" />
<input type="checkbox" name="pause_on_hover" value="on" id="pause_on_hover" <?php if($row->pause_on_hover == 'on'){ echo 'checked="checked"'; } ?> />
</li>
<li>
<label for="slider_effects_list">Effects</label>
<select name="slider_effects_list" id="slider_effects_list">
<option <?php if($row->slider_list_effects_s == 'none'){ echo 'selected'; } ?> value="none">None</option>
<option <?php if($row->slider_list_effects_s == 'cubeH'){ echo 'selected'; } ?> value="cubeH">Cube Horizontal</option>
<option <?php if($row->slider_list_effects_s == 'cubeV'){ echo 'selected'; } ?> value="cubeV">Cube Vertical</option>
<option <?php if($row->slider_list_effects_s == 'fade'){ echo 'selected'; } ?> value="fade">Fade</option>
<option <?php if($row->slider_list_effects_s == 'sliceH'){ echo 'selected'; } ?> value="sliceH">Slice Horizontal</option>
<option <?php if($row->slider_list_effects_s == 'sliceV'){ echo 'selected'; } ?> value="sliceV">Slice Vertical</option>
<option <?php if($row->slider_list_effects_s == 'slideH'){ echo 'selected'; } ?> value="slideH">Slide Horizontal</option>
<option <?php if($row->slider_list_effects_s == 'slideV'){ echo 'selected'; } ?> value="slideV">Slide Vertical</option>
<option <?php if($row->slider_list_effects_s == 'scaleOut'){ echo 'selected'; } ?> value="scaleOut">Scale Out</option>
<option <?php if($row->slider_list_effects_s == 'scaleIn'){ echo 'selected'; } ?> value="scaleIn">Scale In</option>
<option <?php if($row->slider_list_effects_s == 'blockScale'){ echo 'selected'; } ?> value="blockScale">Block Scale</option>
<option <?php if($row->slider_list_effects_s == 'kaleidoscope'){ echo 'selected'; } ?> value="kaleidoscope">Kaleidoscope</option>
<option <?php if($row->slider_list_effects_s == 'fan'){ echo 'selected'; } ?> value="fan">Fan</option>
<option <?php if($row->slider_list_effects_s == 'blindH'){ echo 'selected'; } ?> value="blindH">Blind Horizontal</option>
<option <?php if($row->slider_list_effects_s == 'blindV'){ echo 'selected'; } ?> value="blindV">Blind Vertical</option>
<option <?php if($row->slider_list_effects_s == 'slideCenter'){ echo 'selected'; } ?> value="blindV">Slide Center</option>
<option <?php if($row->slider_list_effects_s == 'random'){ echo 'selected'; } ?> value="random">Random</option>
</select>
</li>
<li>
<label for="sl_pausetime">Pause time</label>
<input type="text" name="sl_pausetime" id="sl_pausetime" value="<?php echo $row->description; ?>" class="text_area" />
</li>
<li>
<label for="sl_changespeed">Change speed</label>
<input type="text" name="sl_changespeed" id="sl_changespeed" value="<?php echo $row->param; ?>" class="text_area" />
</li>
<li>
<label for="slider_position">Slider Position</label>
<select name="sl_position" id="slider_position">
<option <?php if($row->sl_position == 'left'){ echo 'selected'; } ?> value="left">Left</option>
<option <?php if($row->sl_position == 'right'){ echo 'selected'; } ?> value="right">Right</option>
<option <?php if($row->sl_position == 'center'){ echo 'selected'; } ?> value="center">Center</option>
</select>
</li>
</ul>
<input type="submit" value="Save Slider" id="save-buttom" class="button button-primary button-large">
</div>
</div>
</form>
<?php
}
function Options_slider_styles()
{
require_once("slider_Options.php");
require_once("slider_Options.html.php");
if (isset($_GET['task']))
if ($_GET['task'] == 'save')
save_styles_options();
showStyles();
}
/**
* Huge IT Widget
*/
class Huge_it_Widget extends WP_Widget {
public function __construct() {
parent::__construct(
'Huge_it_Widget',
'Huge IT Slider',
array( 'description' => __( 'Huge IT Slider', 'huge_it_slider' ), )
);
}
public function widget( $args, $instance ) {
extract($args);
if (isset($instance['slider_id'])) {
$slider_id = $instance['slider_id'];
$title = apply_filters( 'widget_title', $instance['title'] );
echo $before_widget;
if ( ! empty( $title ) )
echo $before_title . $title . $after_title;
echo do_shortcode("[elegant_slider id={$slider_id}]");
echo $after_widget;
}
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['slider_id'] = strip_tags( $new_instance['slider_id'] );
$instance['title'] = strip_tags( $new_instance['title'] );
return $instance;
}
public function form( $instance ) {
$selected_slider = 0;
$title = "";
$sliders = false;
if (isset($instance['slider_id'])) {
$selected_slider = $instance['slider_id'];
}
if (isset($instance['title'])) {
$title = $instance['title'];
}
?>
<p>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<label for="<?php echo $this->get_field_id('slider_id'); ?>"><?php _e('Select Slider:', 'huge_it_slider'); ?></label>
<select id="<?php echo $this->get_field_id('slider_id'); ?>" name="<?php echo $this->get_field_name('slider_id'); ?>">
<?php
global $wpdb;
$query="SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders ";
$rowwidget=$wpdb->get_results($query);
foreach($rowwidget as $rowwidgetecho){
selected
?>
<option <?php if($rowwidgetecho->id == $instance['slider_id']){ echo 'selected'; } ?> value="<?php echo $rowwidgetecho->id; ?>"><?php echo $rowwidgetecho->name; ?></option>
<?php } ?>
</select>
</p>
<?php
}
}
add_action('widgets_init', 'register_Huge_it_Widget');
function register_Huge_it_Widget() {
register_widget('Huge_it_Widget');
}
function huge_it_slider_activate()
{
global $wpdb;
$sql_huge_itslider_params = "
CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . "huge_itslider_params`(
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50)
CHARACTER SET utf8 NOT NULL,
`title` varchar(200) CHARACTER SET utf8 NOT NULL,
`description` text CHARACTER SET utf8 NOT NULL,
`value` varchar(200) CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=89 ";
$sql_huge_itslider_images = "
CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . "huge_itslider_images` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`slider_id` varchar(200) ,
`description` text,
`image_url` text,
`sl_url` varchar(128) DEFAULT NULL,
`ordering` int(11) NOT NULL,
`published` tinyint(4) unsigned DEFAULT NULL,
`published_in_sl_width` tinyint(4) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5";
$sql_huge_itslider_sliders = "
CREATE TABLE IF NOT EXISTS `" . $wpdb->prefix . "huge_itslider_sliders` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(200) NOT NULL,
`sl_height` int(11) unsigned DEFAULT NULL,
`sl_width` int(11) unsigned DEFAULT NULL,
`autoplay` tinyint(1) unsigned DEFAULT 1,
`fancybox` tinyint(1) unsigned DEFAULT 0,
`default_fancybox` tinyint(1) unsigned DEFAULT 1,
`pause_on_hover` text,
`slider_list_effects_s` text,
`description` text,
`param` text,
`ordering` int(11) NOT NULL,
`published` text,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ";
$table_name = $wpdb->prefix . "huge_itslider_params";
$sql_1 = <<<query1
INSERT INTO `$table_name` (`name`, `title`,`description`, `value`) VALUES
( 'slider_crop_image', 'Slider crop image', 'Slider crop image', 'resize'),
( 'slider_title_color', 'Slider title color', 'Slider title color', '000000'),
( 'slider_title_font_size', 'Slider title font size', 'Slider title font size', '13'),
( 'slider_description_color', 'Slider description color', 'Slider description color', 'ffffff'),
( 'slider_description_font_size', 'Slider description font size', 'Slider description font size', '13'),
( 'slider_title_position', 'Slider title position', 'Slider title position', 'right-top'),
( 'slider_description_position', 'Slider description position', 'Slider description position', 'right-bottom'),
( 'slider_title_border_size', 'Slider Title border size', 'Slider Title border size', '0'),
( 'slider_title_border_color', 'Slider title border color', 'Slider title border color', 'ffffff'),
( 'slider_title_border_radius', 'Slider title border radius', 'Slider title border radius', '4'),
( 'slider_description_border_size', 'Slider description border size', 'Slider description border size', '0'),
( 'slider_description_border_color', 'Slider description border color', 'Slider description border color', 'ffffff'),
( 'slider_description_border_radius', 'Slider description border radius', 'Slider description border radius', '0'),
( 'slider_slideshow_border_size', 'Slider border size', 'Slider border size', '0'),
( 'slider_slideshow_border_color', 'Slider border color', 'Slider border color', 'ffffff'),
( 'slider_slideshow_border_radius', 'Slider border radius', 'Slider border radius', '0'),
( 'slider_navigation_type', 'Slider navigation type', 'Slider navigation type', '1'),
( 'slider_navigation_position', 'Slider navigation position', 'Slider navigation position', 'bottom'),
( 'slider_title_background_color', 'Slider title background color', 'Slider title background color', 'ffffff'),
( 'slider_description_background_color', 'Slider description background color', 'Slider description background color', '000000'),
( 'slider_title_transparent', 'Slider title has background', 'Slider title has background', 'on'),
( 'slider_description_transparent', 'Slider description has background', 'Slider description has background', 'on'),
( 'slider_slider_background_color', 'Slider slider background color', 'Slider slider background color', 'ffffff'),
( 'slider_dots_position', 'slider dots position', 'slider dots position', 'top'),
( 'slider_active_dot_color', 'slider active dot color', '', 'ffffff'),
( 'slider_dots_color', 'slider dots color', '', '000000');
query1;
$table_name = $wpdb->prefix . "huge_itslider_images";
$sql_2 = "
INSERT INTO
`" . $table_name . "` (`id`, `slider_id`, `name`, `description`, `image_url`, `sl_url`, `ordering`, `published`) VALUES
(1, '1', '', '', '" . plugins_url("Front_images/slides/slide1.jpg", __FILE__) . "', 'http://huge-it.com', 1, 1),
(2, '1', 'Simple Usage', '', '" . plugins_url("Front_images/slides/slide2.jpg", __FILE__) . "', 'http://huge-it.com', 2, 1),
(3, '1', 'Huge-IT Slider', 'The slider allows having unlimited amount of images with their titles and descriptions. The slider uses autogenerated shortcodes making it easier for the users to add it to the custom location.', '" . plugins_url("Front_images/slides/slide3.jpg", __FILE__) . "', 'http://huge-it.com', 3, 1)";
$table_name = $wpdb->prefix . "huge_itslider_sliders";
$sql_3 = "
INSERT INTO `$table_name` (`id`, `name`, `sl_height`, `sl_width`, `pause_on_hover`, `slider_list_effects_s`, `description`, `param`, `ordering`, `published`) VALUES
(1, 'My First Slider', '375', '600', 'on', 'random', '4000', '1000', '1', '300')";
$wpdb->query($sql_huge_itslider_params);
$wpdb->query($sql_huge_itslider_images);
$wpdb->query($sql_huge_itslider_sliders);
$wpdb->query($sql_huge_itslider_sliders_update);
if (!$wpdb->get_var("select count(*) from " . $wpdb->prefix . "huge_itslider_params")) {
$wpdb->query($sql_1);
}
if (!$wpdb->get_var("select count(*) from " . $wpdb->prefix . "huge_itslider_images")) {
$wpdb->query($sql_2);
}
if (!$wpdb->get_var("select count(*) from " . $wpdb->prefix . "huge_itslider_sliders")) {
$wpdb->query($sql_3);
}
$product = $wpdb->get_results("DESCRIBE " . $wpdb->prefix . "huge_itslider_sliders", ARRAY_A);
$isUpdate = 0;
foreach ($product as $prod) {
if ($prod['Field'] == 'published' && $prod['Type'] == 'tinyint(4) unsigned') {
$isUpdate = 1;
break;
}
}
if ($isUpdate) {
$wpdb->query("ALTER TABLE ".$wpdb->prefix."huge_itslider_sliders MODIFY `published` text");
$wpdb->query("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET published = '300' WHERE id = 1 ");
}
$product2 = $wpdb->get_results("DESCRIBE " . $wpdb->prefix . "huge_itslider_images", ARRAY_A);
$isUpdate2 = 0;
foreach ($product2 as $prod2) {
if($product2[6]['Field'] == 'sl_type')
{
echo '';
}
else
{
$query="SELECT * FROM ".$wpdb->prefix."huge_itslider_images order by id ASC";
$rowim=$wpdb->get_results($query);
foreach ($rowim as $key=>$rowimages){
// $wpdb->query("UPDATE ".$wpdb->prefix."huge_itslider_images SET ordering = '".$rowimages->id."' WHERE ID = ".$rowimages->id." ");
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_images SET ordering = '%s' WHERE id = %d ", $rowimages->id,$rowimages->id));
}
}
}
if($product2[6]['Field'] == 'sl_type')
{
echo '';
}
else
{
$wpdb->query("ALTER TABLE ".$wpdb->prefix."huge_itslider_images ADD `sl_type` TEXT NOT NULL AFTER `sl_url`");
$wpdb->query("UPDATE ".$wpdb->prefix."huge_itslider_images SET sl_type = 'image' ");
$wpdb->query("ALTER TABLE ".$wpdb->prefix."huge_itslider_images ADD `link_target` TEXT NOT NULL AFTER `sl_type`");
$wpdb->query("UPDATE ".$wpdb->prefix."huge_itslider_images SET link_target = 'on' ");
$table_name = $wpdb->prefix . "huge_itslider_params";
$sql_update2 = <<<query1
INSERT INTO `$table_name` (`name`, `title`,`description`, `value`) VALUES
( 'slider_description_width', 'Slider description width', 'Slider description width', '70'),
( 'slider_description_height', 'Slider description height', 'Slider description height', '50'),
( 'slider_description_background_transparency', 'slider description background transparency', 'slider description background transparency', '70'),
( 'slider_description_text_align', 'description text-align', 'description text-align', 'justify'),
( 'slider_title_width', 'slider title width', 'slider title width', '30'),
( 'slider_title_height', 'slider title height', 'slider title height', '50'),
( 'slider_title_background_transparency', 'slider title background transparency', 'slider title background transparency', '70'),
( 'slider_title_text_align', 'title text-align', 'title text-align', 'right');
query1;
$wpdb->query($sql_update2);
}
$product3 = $wpdb->get_results("DESCRIBE " . $wpdb->prefix . "huge_itslider_sliders", ARRAY_A);
if($product3[8]['Field'] == 'sl_position'){
echo '';
}
else
{
$wpdb->query("ALTER TABLE ".$wpdb->prefix."huge_itslider_sliders ADD `sl_position` TEXT NOT NULL AFTER `param`");
$wpdb->query("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET `sl_position` = 'center' ");
$table_name = $wpdb->prefix . "huge_itslider_params";
$sql_update3 = <<<query1
INSERT INTO `$table_name` (`name`, `title`,`description`, `value`) VALUES
( 'slider_title_has_margin', 'title has margin', 'title has margin', 'on'),
( 'slider_description_has_margin', 'description has margin', 'description has margin', 'on'),
( 'slider_show_arrows', 'Slider show left right arrows', 'Slider show left right arrows', 'on');
query1;
$wpdb->query($sql_update3);
}
$productSliders = $wpdb->get_results("DESCRIBE " . $wpdb->prefix . "huge_itslider_sliders", ARRAY_A);//get table fields
$isUpdate1 = 0;
foreach ($productSliders as $PSlider) {
if ($PSlider['Field'] == 'sl_loading_icon') {
$isUpdate1 = 1;
break;
}
}
if ($isUpdate1 == 0) {
$wpdb->query("ALTER TABLE " .$wpdb->prefix . "huge_itslider_sliders ADD `sl_loading_icon` text NOT NULL AFTER `published`");
$wpdb->query("UPDATE " . $wpdb->prefix ."huge_itslider_sliders SET `sl_loading_icon` = 'off' ");
}
$product4 = $wpdb->get_results("DESCRIBE " . $wpdb->prefix . "huge_itslider_images", ARRAY_A);
if($product4[8]['Field'] == 'sl_stitle'){
}
else
{
echo '';
$wpdb->query("ALTER TABLE ".$wpdb->prefix."huge_itslider_images ADD `sl_stitle` TEXT NOT NULL AFTER `link_target`");
$wpdb->query("ALTER TABLE ".$wpdb->prefix."huge_itslider_images ADD `sl_sdesc` TEXT NOT NULL AFTER `sl_stitle`");
$wpdb->query("ALTER TABLE ".$wpdb->prefix."huge_itslider_images ADD `sl_postlink` TEXT NOT NULL AFTER `sl_sdesc`");
}
$table_name = $wpdb->prefix . "huge_itslider_params";
$sql_update4 = <<<query2
INSERT INTO `$table_name` (`name`, `title`,`description`, `value`) VALUES
('loading_icon_type', 'Slider loading icon type', 'Slider loading icon type', '1');
query2;
$query3="SELECT name FROM ".$table_name;
$update_p3=$wpdb->get_results($query3);
if(end($update_p3)->name=='slider_show_arrows'){
$wpdb->query($sql_update4);
}
}
register_activation_hook(__FILE__, 'huge_it_slider_activate');