forked from wp-plugins/slider-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsliders.php
613 lines (502 loc) · 26.9 KB
/
sliders.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
<?php
if(function_exists('current_user_can'))
if(!current_user_can('manage_options')) {
die('Access Denied');
}
if(!function_exists('current_user_can')){
die('Access Denied');
}
function showslider()
{
global $wpdb;
if(isset($_POST['search_events_by_title']))
$_POST['search_events_by_title']=esc_html(stripslashes($_POST['search_events_by_title']));
if(isset($_POST['asc_or_desc']))
$_POST['asc_or_desc']=esc_js($_POST['asc_or_desc']);
if(isset($_POST['order_by']))
$_POST['order_by']=esc_js($_POST['order_by']);
$where='';
$sort["custom_style"] ="manage-column column-autor sortable desc";
$sort["default_style"]="manage-column column-autor sortable desc";
$sort["sortid_by"]='id';
$sort["1_or_2"]=1;
$order='';
if(isset($_POST['page_number']))
{
if($_POST['asc_or_desc'])
{
$sort["sortid_by"]=$_POST['order_by'];
if($_POST['asc_or_desc']==1)
{
$sort["custom_style"]="manage-column column-title sorted asc";
$sort["1_or_2"]="2";
$order="ORDER BY ".$sort["sortid_by"]." ASC";
}
else
{
$sort["custom_style"]="manage-column column-title sorted desc";
$sort["1_or_2"]="1";
$order="ORDER BY ".$sort["sortid_by"]." DESC";
}
}
if($_POST['page_number'])
{
$limit=($_POST['page_number']-1)*20;
}
else
{
$limit=0;
}
}
else
{
$limit=0;
}
if(isset($_POST['search_events_by_title'])){
$search_tag=esc_html(stripslashes($_POST['search_events_by_title']));
}
else
{
$search_tag="";
}
if(isset($_GET["catid"])){
$cat_id=$_GET["catid"];
}
else
{
if(isset($_POST['cat_search'])){
$cat_id=$_POST['cat_search'];
}else{
$cat_id=0;}
}
if ( $search_tag ) {
$where= " WHERE name LIKE '%".$search_tag."%' ";
}
if($where){
if($cat_id){
$where.=" AND sl_width=" .$cat_id;
}
}
else{
if($cat_id){
$where.=" WHERE sl_width=" .$cat_id;
}
}
$cat_row_query="SELECT id,name FROM ".$wpdb->prefix."huge_itslider_sliders WHERE sl_width=0";
$cat_row=$wpdb->get_results($cat_row_query);
$query = "SELECT COUNT(*) FROM ".$wpdb->prefix."huge_itslider_sliders". $where;
$total = $wpdb->get_var($query);
$pageNav['total'] =$total;
$pageNav['limit'] = $limit/20+1;
if($cat_id){
$query ="SELECT a.* , COUNT(b.id) AS count, g.par_name AS par_name FROM ".$wpdb->prefix."huge_itslider_sliders AS a LEFT JOIN ".$wpdb->prefix."huge_itslider_sliders AS b ON a.id = b.sl_width LEFT JOIN (SELECT ".$wpdb->prefix."huge_itslider_sliders.ordering as ordering,".$wpdb->prefix."huge_itslider_sliders.id AS id, COUNT( ".$wpdb->prefix."huge_itslider_images.slider_id ) AS prod_count
FROM ".$wpdb->prefix."huge_itslider_images, ".$wpdb->prefix."huge_itslider_sliders
WHERE ".$wpdb->prefix."huge_itslider_images.slider_id = ".$wpdb->prefix."huge_itslider_sliders.id
GROUP BY ".$wpdb->prefix."huge_itslider_images.slider_id) AS c ON c.id = a.id LEFT JOIN
(SELECT ".$wpdb->prefix."huge_itslider_sliders.name AS par_name,".$wpdb->prefix."huge_itslider_sliders.id FROM ".$wpdb->prefix."huge_itslider_sliders) AS g
ON a.sl_width=g.id WHERE a.name LIKE '%".$search_tag."%' group by a.id ". $order ." "." LIMIT ".$limit.",20" ;
}
else{
$query ="SELECT a.* , COUNT(b.id) AS count, g.par_name AS par_name FROM ".$wpdb->prefix."huge_itslider_sliders AS a LEFT JOIN ".$wpdb->prefix."huge_itslider_sliders AS b ON a.id = b.sl_width LEFT JOIN (SELECT ".$wpdb->prefix."huge_itslider_sliders.ordering as ordering,".$wpdb->prefix."huge_itslider_sliders.id AS id, COUNT( ".$wpdb->prefix."huge_itslider_images.slider_id ) AS prod_count
FROM ".$wpdb->prefix."huge_itslider_images, ".$wpdb->prefix."huge_itslider_sliders
WHERE ".$wpdb->prefix."huge_itslider_images.slider_id = ".$wpdb->prefix."huge_itslider_sliders.id
GROUP BY ".$wpdb->prefix."huge_itslider_images.slider_id) AS c ON c.id = a.id LEFT JOIN
(SELECT ".$wpdb->prefix."huge_itslider_sliders.name AS par_name,".$wpdb->prefix."huge_itslider_sliders.id FROM ".$wpdb->prefix."huge_itslider_sliders) AS g
ON a.sl_width=g.id WHERE a.name LIKE '%".$search_tag."%' group by a.id ". $order ." "." LIMIT ".$limit.",20" ;
}
$rows = $wpdb->get_results($query);
global $glob_ordering_in_cat;
if(isset($sort["sortid_by"]))
{
if($sort["sortid_by"]=='ordering'){
if($_POST['asc_or_desc']==1){
$glob_ordering_in_cat=" ORDER BY ordering ASC";
}
else{
$glob_ordering_in_cat=" ORDER BY ordering DESC";
}
}
}
$rows=open_cat_in_tree($rows);
$query ="SELECT ".$wpdb->prefix."huge_itslider_sliders.ordering,".$wpdb->prefix."huge_itslider_sliders.id, COUNT( ".$wpdb->prefix."huge_itslider_images.slider_id ) AS prod_count
FROM ".$wpdb->prefix."huge_itslider_images, ".$wpdb->prefix."huge_itslider_sliders
WHERE ".$wpdb->prefix."huge_itslider_images.slider_id = ".$wpdb->prefix."huge_itslider_sliders.id
GROUP BY ".$wpdb->prefix."huge_itslider_images.slider_id " ;
$prod_rows = $wpdb->get_results($query);
foreach($rows as $row)
{
foreach($prod_rows as $row_1)
{
if ($row->id == $row_1->id)
{
$row->ordering = $row_1->ordering;
$row->prod_count = $row_1->prod_count;
}
}
}
$cat_row=open_cat_in_tree($cat_row);
html_showsliders( $rows, $pageNav,$sort,$cat_row);
}
function open_cat_in_tree($catt,$tree_problem='',$hihiih=1){
global $wpdb;
global $glob_ordering_in_cat;
static $trr_cat=array();
if(!isset($search_tag))
$search_tag='';
if($hihiih)
$trr_cat=array();
foreach($catt as $local_cat){
$local_cat->name=$tree_problem.$local_cat->name;
array_push($trr_cat,$local_cat);
$new_cat_query= "SELECT a.* , COUNT(b.id) AS count, g.par_name AS par_name FROM ".$wpdb->prefix."huge_itslider_sliders AS a LEFT JOIN ".$wpdb->prefix."huge_itslider_sliders AS b ON a.id = b.sl_width LEFT JOIN (SELECT ".$wpdb->prefix."huge_itslider_sliders.ordering as ordering,".$wpdb->prefix."huge_itslider_sliders.id AS id, COUNT( ".$wpdb->prefix."huge_itslider_images.slider_id ) AS prod_count
FROM ".$wpdb->prefix."huge_itslider_images, ".$wpdb->prefix."huge_itslider_sliders
WHERE ".$wpdb->prefix."huge_itslider_images.slider_id = ".$wpdb->prefix."huge_itslider_sliders.id
GROUP BY ".$wpdb->prefix."huge_itslider_images.slider_id) AS c ON c.id = a.id LEFT JOIN
(SELECT ".$wpdb->prefix."huge_itslider_sliders.name AS par_name,".$wpdb->prefix."huge_itslider_sliders.id FROM ".$wpdb->prefix."huge_itslider_sliders) AS g
ON a.sl_width=g.id WHERE a.name LIKE '%".$search_tag."%' AND a.sl_width=".$local_cat->id." group by a.id ".$glob_ordering_in_cat;
$new_cat=$wpdb->get_results($new_cat_query);
open_cat_in_tree($new_cat,$tree_problem. "— ",0);
}
return $trr_cat;
}
function editslider($id)
{
global $wpdb;
if(isset($_GET["removeslide"])){
if($_GET["removeslide"] != ''){
$wpdb->query($wpdb->prepare("DELETE FROM ".$wpdb->prefix."huge_itslider_images WHERE id = %d ", $_GET["removeslide"]));
// $wpdb->query("DELETE FROM ".$wpdb->prefix."huge_itslider_images WHERE id = ".$_GET["removeslide"]." ");
}
}
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders WHERE id= %d",$id);
$row=$wpdb->get_row($query);
if(!isset($row->slider_list_effects_s))
return 'id not found';
$images=explode(";;;",$row->slider_list_effects_s);
$par=explode(' ',$row->param);
$count_ord=count($images);
$cat_row=$wpdb->get_results("SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders WHERE id!=" .$id." and sl_width=0");
$cat_row=open_cat_in_tree($cat_row);
$query=$wpdb->prepare("SELECT name,ordering FROM ".$wpdb->prefix."huge_itslider_sliders WHERE sl_width=%d ORDER BY `ordering` ",$row->sl_width);
$ord_elem=$wpdb->get_results($query);
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_images where slider_id = %d order by ordering ASC ",$row->id);
$rowim=$wpdb->get_results($query);
if(isset($_GET["addslide"])){
if($_GET["addslide"] == 1){
$table_name = $wpdb->prefix . "huge_itslider_images";
// $sql_2 = "
//INSERT INTO
//
//`" . $table_name . "` ( `name`, `slider_id`, `description`, `image_url`, `sl_url`, `ordering`, `published`, `published_in_sl_width`) VALUES
//( '', '".$row->id."', '', '', '', 'par_TV', 2, '1' )";
$wpdb->query($sql_huge_itslider_images);
// $wpdb->query($sql_2);
}
}
$query="SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders order by id ASC";
$rowsld=$wpdb->get_results($query);
$query = "SELECT * from " . $wpdb->prefix . "huge_itslider_params ";
$rowspar = $wpdb->get_results($query);
$paramssld = array();
foreach ($rowspar as $rowpar) {
$key = $rowpar->name;
$value = $rowpar->value;
$paramssld[$key] = $value;
}
$query="SELECT * FROM ".$wpdb->prefix."posts where post_type = 'post' and post_status = 'publish' order by id ASC";
$rowsposts=$wpdb->get_results($query);
$rowsposts8 = '';
$postsbycat = '';
if(isset($_POST["iframecatid"])){
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."term_relationships where term_taxonomy_id = %d order by object_id ASC",$_POST["iframecatid"]);
$rowsposts8=$wpdb->get_results($query);
foreach($rowsposts8 as $rowsposts13){
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."posts where post_type = 'post' and post_status = 'publish' and ID = %d order by ID ASC",$rowsposts13->object_id);
$rowsposts1=$wpdb->get_results($query);
$postsbycat = $rowsposts1;
}
}
Html_editslider($ord_elem, $count_ord, $images, $row, $cat_row, $rowim, $rowsld, $paramssld, $rowsposts, $rowsposts8, $postsbycat);
}
function add_slider()
{
global $wpdb;
$table_name = $wpdb->prefix . "huge_itslider_sliders";
$sql_2 = "
INSERT INTO
`" . $table_name . "` ( `name`, `sl_height`, `sl_width`, `pause_on_hover`, `slider_list_effects_s`, `description`, `param`, `sl_position`, `ordering`, `published`,`sl_loading_icon`) VALUES
( 'New slider', '375', '600', 'on', 'cubeH', '4000', '1000', 'center', '1', '300','off')";
$wpdb->query($sql_2);
$query="SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders order by id ASC";
$rowsldcc=$wpdb->get_results($query);
$last_key = key( array_slice( $rowsldcc, -1, 1, TRUE ) );
foreach($rowsldcc as $key=>$rowsldccs){
if($last_key == $key){
header('Location: admin.php?page=sliders_huge_it_slider&id='.$rowsldccs->id.'&task=apply');
}
}
}
function popup_posts($id)
{
global $wpdb;
if(isset($_GET["removeslide"])){
if($_GET["removeslide"] != ''){
$wpdb->query($wpdb->prepare("DELETE FROM ".$wpdb->prefix."huge_itslider_images WHERE id = %d ", $_GET["removeslide"]));
// $wpdb->query("DELETE FROM ".$wpdb->prefix."huge_itslider_images WHERE id = ".$_GET["removeslide"]." ");
}
}
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders WHERE id= %d",$id);
$row=$wpdb->get_row($query);
if(!isset($row->slider_list_effects_s))
return 'id not found';
$images=explode(";;;",$row->slider_list_effects_s);
$par=explode(' ',$row->param);
$count_ord=count($images);
$cat_row=$wpdb->get_results("SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders WHERE id!=" .$id." and sl_width=0");
$cat_row=open_cat_in_tree($cat_row);
$query=$wpdb->prepare("SELECT name,ordering FROM ".$wpdb->prefix."huge_itslider_sliders WHERE sl_width=%d ORDER BY `ordering` ",$row->sl_width);
$ord_elem=$wpdb->get_results($query);
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_images where slider_id = %d order by id ASC ",$row->id);
$rowim=$wpdb->get_results($query);
if(isset($_GET["addslide"])){
if($_GET["addslide"] == 1){
$table_name = $wpdb->prefix . "huge_itslider_images";
// $sql_2 = "
//INSERT INTO
//
//`" . $table_name . "` ( `name`, `slider_id`, `description`, `image_url`, `sl_url`, `ordering`, `published`, `published_in_sl_width`) VALUES
//( '', '".$row->id."', '', '', '', 'par_TV', 2, '1' )";
$wpdb->query($sql_huge_itslider_images);
// $wpdb->query($sql_2);
}
}
$query="SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders order by id ASC";
$rowsld=$wpdb->get_results($query);
$query = "SELECT * from " . $wpdb->prefix . "huge_itslider_params ";
$rowspar = $wpdb->get_results($query);
$paramssld = array();
foreach ($rowspar as $rowpar) {
$key = $rowpar->name;
$value = $rowpar->value;
$paramssld[$key] = $value;
}
$query="SELECT * FROM ".$wpdb->prefix."posts where post_type = 'post' and post_status = 'publish' order by id ASC";
$rowsposts=$wpdb->get_results($query);
$categories = get_categories( );
if(isset($_POST["iframecatid"])){
$iframecatid = $_POST["iframecatid"];
}
else
{
$iframecatid = $categories[0]->cat_ID;
}
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."term_relationships where term_taxonomy_id = %d order by object_id ASC",$iframecatid);
$rowsposts8=$wpdb->get_results($query);
foreach($rowsposts8 as $rowsposts13){
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."posts where post_type = 'post' and post_status = 'publish' and ID = %d order by ID ASC",$rowsposts13->object_id);
$rowsposts1=$wpdb->get_results($query);
$postsbycat = $rowsposts1;
}
global $wpdb;
if(isset($_GET["closepop"])){
if($_GET["closepop"] == 1){
if($_POST["popupposts"] != 'none' and $_POST["popupposts"] != ''){
$popuppostsposts = explode(";", $_POST["popupposts"]);
array_pop($popuppostsposts);
foreach($popuppostsposts as $popuppostsposts1){
$my_id = $popuppostsposts1;
$post_id_1 = get_post($my_id);
$post_image = wp_get_attachment_url( get_post_thumbnail_id($popuppostsposts1) );
$posturl=get_permalink($popuppostsposts1);
$table_name = $wpdb->prefix . "huge_itslider_images";
$descnohtmlnoq=strip_tags($post_id_1->post_content);
$descnohtmlnoq1 = html_entity_decode($descnohtmlnoq);
$descnohtmlnoq1 = htmlentities($descnohtmlnoq1, ENT_QUOTES, "UTF-8");
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_images where slider_id = %d order by id ASC", $row->id);
$rowplusorder=$wpdb->get_results($query);
foreach ($rowplusorder as $key=>$rowplusorders){
$rowplusorderspl=$rowplusorders->ordering+1;
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_images SET ordering = '".$rowplusorderspl."' WHERE id = %d ", $rowplusorders->id));
}
}
}
if(!($_POST["lastposts"])){
$wpdb->query("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET published = '".$_POST["posthuge-it-description-length"]."' WHERE id = '".$_GET['id']."' ");
}
}
}
if(isset($_POST["lastposts"])){
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."posts where post_type = 'post' and post_status = 'publish' order by id DESC LIMIT 0, ".$_POST["lastposts"]."");
$rowspostslast=$wpdb->get_results($query);
foreach($rowspostslast as $rowspostslastfor){
$my_id = $rowspostslastfor;
$post_id_1 = get_post($my_id);
$post_image = wp_get_attachment_url( get_post_thumbnail_id($rowspostslastfor) );
$posturl=get_permalink($rowspostslastfor);
$table_name = $wpdb->prefix . "huge_itslider_images";
$descnohtmlno=strip_tags($post_id_1->post_content);
$descnohtmlno1 = html_entity_decode($descnohtmlno);
$lengthtextpost = '300';
$descnohtmlno2 = substr_replace($descnohtmlno1, "", $lengthtextpost);
$descnohtmlno3 = htmlentities($descnohtmlno2, ENT_QUOTES, "UTF-8");
$posttitle = htmlentities($post_id_1->post_title, ENT_QUOTES, "UTF-8");
$posturl2 = htmlentities($posturl, ENT_QUOTES, "UTF-8");
$wpdb->query($wpdb->prepare("INSERT INTO `" . $table_name . "` ( `name`, `slider_id`, `description`, `image_url`, `sl_url`, `ordering`, `published`, `published_in_sl_width` ) VALUES ( '%s', '%s', '%s', '%s', '%s', '0', 2, '1' )", $posttitle, $row->id, $descnohtmlno3, $post_image, $posturl ));
// $sql_lastposts = "INSERT INTO
//`" . $table_name . "` ( `name`, `slider_id`, `description`, `image_url`, `sl_url`, `ordering`, `published`, `published_in_sl_width`) VALUES
//( '".$posttitle."', '".$row->id."', '".$descnohtmlno3."', '".$post_image ."', '".$posturl."', '0', 2, '1' )";
$wpdb->query($sql_huge_itslider_images);
// $wpdb->query($sql_lastposts);
}
}
if(isset($_POST["addlastposts"])){
if($_POST["addlastposts"]=='addlastposts'){
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_images where slider_id = %d order by id ASC", $row->id);
$rowplusorder=$wpdb->get_results($query);
foreach ($rowplusorder as $key=>$rowplusorders){
$rowplusorderspl=$rowplusorders->ordering+1;
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_images SET ordering = '".$rowplusorderspl."' WHERE id = %d ", $rowplusorders->id));
}
$table_name = $wpdb->prefix . "huge_itslider_images";
$sql_addlastposts = $wpdb->query($wpdb->prepare("INSERT INTO `" . $table_name . "` ( `name`, `slider_id`, `description`, `image_url`, `sl_url`, `sl_type`, `link_target`, `sl_stitle`, `sl_sdesc`, `sl_postlink`, `ordering`, `published`, `published_in_sl_width` ) VALUES"
. "( '%s', '%s', '%s', '', '%s', 'last_posts', '%s', '%s', '%s', '%s', '0', '2', '1' )", $_POST["titleimage"], $row->id, $_POST["im_description"], $_POST["sl_url"], $_POST["sl_link_target"], $_POST["sl_stitle"], $_POST["sl_sdesc"], $_POST["sl_postlink"] ));
//$sql_addlastposts = " INSERT INTO
//`" . $table_name . "` ( `name`, `slider_id`, `description`, `image_url`, `sl_url`, `sl_type`, `link_target`, `sl_stitle`, `sl_sdesc`, `sl_postlink`, `ordering`, `published`, `published_in_sl_width`) VALUES
//( '".$_POST["titleimage"]."', '".$row->id."', '".$_POST["im_description"]."', '', '".$_POST["sl_url"]."', 'last_posts', '".$_POST["sl_link_target"]."', '".$_POST["sl_stitle"]."', '".$_POST["sl_sdesc"]."', '".$_POST["sl_postlink"]."', '0', '2', '1' )";
//$wpdb->query($sql_addlastposts);
}
}
Html_popup_posts($ord_elem, $count_ord, $images, $row, $cat_row, $rowim, $rowsld, $paramssld, $rowsposts, $rowsposts8, $postsbycat);
}
function last_posts($id)
{
global $wpdb;
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders WHERE id= %d",$id);
$row=$wpdb->get_row($query);
$test = 'test';
if(isset($_POST['sel_categ'])){
$table_name = $wpdb->prefix . "huge_itslider_images";
$sql_lastposts = $wpdb->query($wpdb->prepare("INSERT INTO `" . $table_name . "` ( `name`, `slider_id`, `description`, `image_url`, `sl_url`, `sl_type`, `link_target`, `ordering`, `published`, `published_in_sl_width` )"
. "VALUES ( '%s', '%s', '300', '', '%s', 'last_posts', 'on', '0', 1, '0' )", $_POST['sel_categ'], $row->id, $_POST['count_posts'] ));
// $sql_lastposts = "
// INSERT INTO
// `" . $table_name . "` ( `name`, `slider_id`, `description`, `image_url`, `sl_url`, `sl_type`, `link_target`, `ordering`, `published`, `published_in_sl_width`) VALUES
// ( '".$_POST['sel_categ']."', '".$row->id."', '300', '', '".$_POST['count_posts']."', 'last_posts', 'on', '0', 1, '0' )";
// $wpdb->query($sql_lastposts);
}
Html_last_posts($test);
}
function popup_video($id)
{
Html_popup_video();
}
function removeslider($id)
{
global $wpdb;
$sql_remov_tag=$wpdb->prepare("DELETE FROM ".$wpdb->prefix."huge_itslider_sliders WHERE id = %d", $id);
if(!$wpdb->query($sql_remov_tag))
{
?>
<div id="message" class="error"><p>slider Not Deleted</p></div>
<?php
}
else{
?>
<div class="updated"><p><strong><?php _e('Item Deleted.' ); ?></strong></p></div>
<?php
}
}
function apply_cat($id)
{
global $wpdb;
if(!is_numeric($id)){
echo 'insert numerc id';
return '';
}
if(!(isset($_POST['sl_width']) && isset($_POST["name"]) ))
{
return '';
}
$cat_row=$wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders WHERE id!= %d ", $id));
$corent_ord=$wpdb->get_var($wpdb->prepare('SELECT `ordering` FROM '.$wpdb->prefix.'huge_itslider_sliders WHERE id = %d AND sl_width=%d',$id,$_POST['sl_width']));
$max_ord=$wpdb->get_var('SELECT MAX(ordering) FROM '.$wpdb->prefix.'huge_itslider_sliders');
$query=$wpdb->prepare("SELECT sl_width FROM ".$wpdb->prefix."huge_itslider_sliders WHERE id = %d", $id);
$id_bef=$wpdb->get_var($query);
if(isset($_POST["content"])){
$script_cat = preg_replace('#<script(.*?)>(.*?)</script>#is', '', stripslashes($_POST["content"]));
}
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET autoplay = '%d' WHERE ID = %d ", isset($_POST["autoplay"]) && $_POST["autoplay"] == "on" ? 1 : 0 , $id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET fancybox = '%d' WHERE ID = %d ", isset($_POST["fancybox"]) && $_POST["fancybox"] == "on" ? 1 : 0 , $id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET default_fancybox = '%d' WHERE ID = %d ", isset($_POST["default_fancybox"]) && $_POST["default_fancybox"] == "on" ? 1 : 0 , $id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET name = '%s' WHERE ID = %d ", $_POST["name"], $id));
$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 ordering = '1' WHERE ID = %d ", $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 )); /*add*/
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_sliders WHERE id = %d", $id);
$row=$wpdb->get_row($query);
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_images where slider_id = %d order by id ASC", $row->id);
$rowim=$wpdb->get_results($query);
foreach ($rowim as $key=>$rowimages){
if(isset($_POST["order_by_".$rowimages->id.""])){
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_images SET ordering = '".$_POST["order_by_".$rowimages->id.""]."' WHERE ID = %d ", $rowimages->id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_images SET link_target = '".$_POST["sl_link_target".$rowimages->id.""]."' WHERE ID = %d ", $rowimages->id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_images SET sl_url = '".$_POST["sl_url".$rowimages->id.""]."' WHERE ID = %d ", $rowimages->id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_images SET name = '".$_POST["titleimage".$rowimages->id.""]."' WHERE ID = %d ", $rowimages->id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_images SET description = '".$_POST["im_description".$rowimages->id.""]."' WHERE ID = %d ", $rowimages->id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_images SET image_url = '".$_POST["imagess".$rowimages->id.""]."' WHERE ID = %d ", $rowimages->id));
}
/////////////////update///////////////////////////
if(isset($_POST["sl_stitle".$rowimages->id.""])){
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_images SET sl_stitle = '".$_POST["sl_stitle".$rowimages->id.""]."' WHERE ID = %d ", $rowimages->id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_images SET sl_sdesc = '".$_POST["sl_sdesc".$rowimages->id.""]."' WHERE ID = %d ", $rowimages->id));
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_images SET sl_postlink = '".$_POST["sl_postlink".$rowimages->id.""]."' WHERE ID = %d ", $rowimages->id));
}
////////////////update///////////////////////////
}
if (isset($_POST['params'])) {
$params = $_POST['params'];
foreach ($params as $key => $value) {
$wpdb->update($wpdb->prefix . 'huge_itslider_params',
array('value' => $value),
array('name' => $key),
array('%s')
);
}
}
if($_POST["imagess"] != ''){
$query=$wpdb->prepare("SELECT * FROM ".$wpdb->prefix."huge_itslider_images where slider_id = %d order by id ASC", $row->id);
$rowim=$wpdb->get_results($query);
foreach ($rowim as $key=>$rowimages){
$orderingplus = $rowimages->ordering+1;
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_images SET ordering = %d WHERE ID = %d ", $orderingplus, $rowimages->id));
}
$table_name = $wpdb->prefix . "huge_itslider_images";
$imagesnewuploader = explode(";;;", $_POST["imagess"]);
array_pop($imagesnewuploader);
foreach($imagesnewuploader as $imagesnewupload){
$sql_2 = $wpdb->query($wpdb->prepare("INSERT INTO `" . $table_name . "` ( `name`, `slider_id`, `description`, `image_url`, `sl_url`, `ordering`, `published`, `published_in_sl_width` )"
. "VALUES ( '', '%s', '', '%s', '', 'par_TV', '2', '1' )", $row->id, $imagesnewupload ));
// $sql_2 = "
//INSERT INTO
//
//`" . $table_name . "` ( `name`, `slider_id`, `description`, `image_url`, `sl_url`, `ordering`, `published`, `published_in_sl_width`) VALUES
//( '', '".$row->id."', '', '".$imagesnewupload."', '', 'par_TV', 2, '1' )";
//
// $wpdb->query($sql_2);
}
}
if(isset($_POST["posthuge-it-description-length"])){
$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."huge_itslider_sliders SET published = %d WHERE id = %d ", $_POST["posthuge-it-description-length"], $_GET['id']));
}
?>
<div class="updated"><p><strong><?php _e('Item Saved'); ?></strong></p></div>
<?php
return true;
}
?>