Slide Anything – Responsive Content / HTML Slider and Carousel - Version 1.5

Version Description

  • Bug Fix: Fixed issue with some HTML elements/attributes being stripped out when certain shortcodes are used within slide content - found an alternative to KSES sanitization for slide content.
  • Added a new dropdown option 'Background Position' for the slide background of each slide

=

Download this release

Release Info

Developer simonpedge
Plugin Icon 128x128 Slide Anything – Responsive Content / HTML Slider and Carousel
Version 1.5
Comparing to
See all releases

Code changes from version 1.4 to 1.5

css/slide-anything-admin.css CHANGED
@@ -169,8 +169,8 @@
169
  background-color:#f3f3f3;
170
  }
171
  .sa_slide_bg_wrapper .sa_slide_thumb > div {
172
- height:150px;
173
- width:150px;
174
  background-repeat:no-repeat;
175
  background-position:top left;
176
  background-size:100% auto;
@@ -196,10 +196,10 @@
196
  background-color:crimson;
197
  }
198
  .sa_slide_bg_wrapper .slide_image_add {
199
- margin:5px 0px 0px !important;
200
  }
201
  .sa_slide_bg_wrapper .slide_image_settings_line {
202
- margin:10px 0px 0px 177px;
203
  }
204
  .sa_slide_bg_wrapper .slide_image_settings_line span {
205
  display:inline-block;
169
  background-color:#f3f3f3;
170
  }
171
  .sa_slide_bg_wrapper .sa_slide_thumb > div {
172
+ height:170px;
173
+ width:170px;
174
  background-repeat:no-repeat;
175
  background-position:top left;
176
  background-size:100% auto;
196
  background-color:crimson;
197
  }
198
  .sa_slide_bg_wrapper .slide_image_add {
199
+ margin:3px 0px 0px !important;
200
  }
201
  .sa_slide_bg_wrapper .slide_image_settings_line {
202
+ margin:8px 0px 0px 197px;
203
  }
204
  .sa_slide_bg_wrapper .slide_image_settings_line span {
205
  display:inline-block;
js/slide-anything-admin.js CHANGED
@@ -393,6 +393,15 @@ function remove_slide_bg_image(slide_no) {
393
 
394
 
395
 
 
 
 
 
 
 
 
 
 
396
  // ##### CHANGE EVENT HANDLER - BACKGROUND SIZE DROPDOWN FOR ALL SLIDES #####
397
  function change_slide_image_size(slide_no) {
398
  var background_size = document.getElementById("sa_slide" + slide_no + "_image_size").value;
@@ -402,7 +411,7 @@ function change_slide_image_size(slide_no) {
402
 
403
 
404
 
405
- // ##### CHANGE EVENT HANDLER - BACKGROUND SIZE DROPDOWN FOR ALL SLIDES #####
406
  function change_slide_image_repeat(slide_no) {
407
  var background_repeat = document.getElementById("sa_slide" + slide_no + "_image_repeat").value;
408
  var thumb_preview = "#slide" + slide_no + "_thumb div";
393
 
394
 
395
 
396
+ // ##### CHANGE EVENT HANDLER - BACKGROUND POSITION DROPDOWN FOR ALL SLIDES #####
397
+ function change_slide_image_pos(slide_no) {
398
+ var background_pos = document.getElementById("sa_slide" + slide_no + "_image_pos").value;
399
+ var thumb_preview = "#slide" + slide_no + "_thumb div";
400
+ jQuery(thumb_preview).css('background-position', background_pos);
401
+ }
402
+
403
+
404
+
405
  // ##### CHANGE EVENT HANDLER - BACKGROUND SIZE DROPDOWN FOR ALL SLIDES #####
406
  function change_slide_image_size(slide_no) {
407
  var background_size = document.getElementById("sa_slide" + slide_no + "_image_size").value;
411
 
412
 
413
 
414
+ // ##### CHANGE EVENT HANDLER - BACKGROUND REPEAT DROPDOWN FOR ALL SLIDES #####
415
  function change_slide_image_repeat(slide_no) {
416
  var background_repeat = document.getElementById("sa_slide" + slide_no + "_image_repeat").value;
417
  var thumb_preview = "#slide" + slide_no + "_thumb div";
php/slide-anything-admin.php CHANGED
@@ -48,6 +48,7 @@ function cpt_slider_plugin_activation() {
48
  $content .= "</div>\n";
49
  update_post_meta($cpt_id, "sa_slide".$i."_content", $content);
50
  update_post_meta($cpt_id, "sa_slide".$i."_image_id", "");
 
51
  update_post_meta($cpt_id, "sa_slide".$i."_image_size", "contain");
52
  update_post_meta($cpt_id, "sa_slide".$i."_image_repeat", "no-repeat");
53
  update_post_meta($cpt_id, "sa_slide".$i."_image_color", $color);
@@ -487,6 +488,7 @@ function cpt_slider_slides_content($post) {
487
  $slide_data[0]['image_id'] = "sa_slide1_image_id";
488
  $slide_data[0]['thumb'] = "slide1_thumb";
489
  $slide_data[0]['image_del'] = "slide1_image_del";
 
490
  $slide_data[0]['image_size'] = "sa_slide1_image_size";
491
  $slide_data[0]['image_repeat'] = "sa_slide1_image_repeat";
492
  $slide_data[0]['image_color'] = "sa_slide1_image_color";
@@ -497,6 +499,7 @@ function cpt_slider_slides_content($post) {
497
  $slide_data[1]['image_id'] = "sa_slide2_image_id";
498
  $slide_data[1]['thumb'] = "slide2_thumb";
499
  $slide_data[1]['image_del'] = "slide2_image_del";
 
500
  $slide_data[1]['image_size'] = "sa_slide2_image_size";
501
  $slide_data[1]['image_repeat'] = "sa_slide2_image_repeat";
502
  $slide_data[1]['image_color'] = "sa_slide2_image_color";
@@ -507,6 +510,7 @@ function cpt_slider_slides_content($post) {
507
  $slide_data[2]['image_id'] = "sa_slide3_image_id";
508
  $slide_data[2]['thumb'] = "slide3_thumb";
509
  $slide_data[2]['image_del'] = "slide3_image_del";
 
510
  $slide_data[2]['image_size'] = "sa_slide3_image_size";
511
  $slide_data[2]['image_repeat'] = "sa_slide3_image_repeat";
512
  $slide_data[2]['image_color'] = "sa_slide3_image_color";
@@ -518,12 +522,15 @@ function cpt_slider_slides_content($post) {
518
  $count = 0;
519
  for ($i = 1; $i <= $num_slides; $i++) {
520
  $slide_edit_id = "sa_slide".$i."_content";
 
521
  $slide_data[$count]['edit_id'] = $slide_edit_id;
522
  $slide_data[$count]['content'] = get_post_meta($post->ID, $slide_edit_id, true);
 
523
  $slide_data[$count]['del_id'] = "sa_slide".$i."_delete";
524
  $slide_data[$count]['image_id'] = "sa_slide".$i."_image_id";
525
  $slide_data[$count]['thumb'] = "slide".$i."_thumb";
526
  $slide_data[$count]['image_del'] = "slide".$i."_image_del";
 
527
  $slide_data[$count]['image_size'] = "sa_slide".$i."_image_size";
528
  $slide_data[$count]['image_repeat'] = "sa_slide".$i."_image_repeat";
529
  $slide_data[$count]['image_color'] = "sa_slide".$i."_image_color";
@@ -539,11 +546,16 @@ function cpt_slider_slides_content($post) {
539
  echo "<div>\n";
540
 
541
  // ### DISPLAY THE SLIDE CONTENT EDITOR (textarea field) ###
542
- wp_editor($slide_data[$i]['content'], wp_kses_post($slide_data[$i]['edit_id']), $editor_args);
 
543
 
544
  // ### BACKGROUND COLOR/IMAGE FIELDS ###
545
- // GET BACKGROUND IMAGE DATA FOR THIS SLIDE (image id, size, repeat and color)
546
  $slide_image_id = get_post_meta($post->ID, $slide_data[$i]['image_id'], true);
 
 
 
 
547
  $slide_image_size = get_post_meta($post->ID, $slide_data[$i]['image_size'], true);
548
  if ($slide_image_size == '') {
549
  $slide_image_size = 'contain';
@@ -570,12 +582,14 @@ function cpt_slider_slides_content($post) {
570
  echo "<div id='".$slide_data[$i]['thumb']."' class='sa_slide_thumb'>\n";
571
  if ($image_exists) {
572
  echo "<div style='background-image:url(\"".esc_attr($slide_image_src[0])."\"); background-size:".esc_attr($slide_image_size)."; ";
573
- echo "background-repeat:".esc_attr($slide_image_repeat)."; background-color:".esc_attr($slide_image_color).";'></div>\n";
 
574
  echo "<span id='".esc_attr($slide_data[$i]['image_del'])."' onClick='remove_slide_bg_image(\"".esc_attr($slide_data[$i]['slide_no'])."\");' title='Delete the background image for this slide'>X</span>\n";
575
  echo "</div>\n";
576
  } else {
577
  echo "<div style='background-color:#ffffff; background-size:".esc_attr($slide_image_size)."; ";
578
- echo "background-repeat:".esc_attr($slide_image_repeat)."; background-color:".esc_attr($slide_image_color).";'></div>\n";
 
579
  echo "<span id='".esc_attr($slide_data[$i]['image_del'])."' class='sa_hidden' onClick='remove_slide_bg_image(\"".esc_attr($slide_data[$i]['slide_no'])."\");' title='Delete the background image for this slide'>X</span>\n";
580
  echo "</div>\n";
581
  }
@@ -584,6 +598,30 @@ function cpt_slider_slides_content($post) {
584
  // slide background image - image id text field
585
  echo "<input type='hidden' id='".esc_attr($slide_data[$i]['image_id'])."' name='".esc_attr($slide_data[$i]['image_id'])."' value='".esc_attr($slide_image_id)."'/>\n";
586
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
587
  // SLIDE BACKGROUND IMAGE - BACKGROUND SIZE (dropdown box)
588
  echo "<div class='slide_image_settings_line'>";
589
  echo "<span>Background Size:</span>";
@@ -924,11 +962,14 @@ function cpt_slider_save_postdata() {
924
  for ($i = 1; $i <= $total_slides; $i++) {
925
  $slide_edit_id = "sa_slide".$i."_content";
926
  $slide_image_id = "sa_slide".$i."_image_id";
 
927
  $slide_image_size = "sa_slide".$i."_image_size";
928
  $slide_image_repeat = "sa_slide".$i."_image_repeat";
929
  $slide_image_color = "sa_slide".$i."_image_color";
930
- $slide_content = wp_kses_post($_POST[$slide_edit_id]); // SANATIZE (slide 'wp_editor' content to contain valid HTML tags)
 
931
  $slide_image_id_val = abs(intval($_POST[$slide_image_id])); // SANATIZE (slide BG image ID is a valid integer)
 
932
  $slide_image_size_val = sanitize_text_field($_POST[$slide_image_size]); // SANATIZE (BG image size is a valid text-input string)
933
  $slide_image_repeat_val = sanitize_text_field($_POST[$slide_image_repeat]); // SANATIZE (BG image repeat is a valid text-input string)
934
  $slide_image_color_val = sanitize_text_field($_POST[$slide_image_color]); // SANATIZE (BG color is a valid text-input string)
@@ -946,11 +987,13 @@ function cpt_slider_save_postdata() {
946
  $slides_saved++;
947
  $slide_edit_id_save = "sa_slide".$slides_saved."_content";
948
  $slide_image_id_saved = "sa_slide".$slides_saved."_image_id";
 
949
  $slide_image_size_saved = "sa_slide".$slides_saved."_image_size";
950
  $slide_image_repeat_saved = "sa_slide".$slides_saved."_image_repeat";
951
  $slide_image_color_saved = "sa_slide".$slides_saved."_image_color";
952
  update_post_meta($post->ID, $slide_edit_id_save, $slide_content);
953
  update_post_meta($post->ID, $slide_image_id_saved, $slide_image_id_val);
 
954
  update_post_meta($post->ID, $slide_image_size_saved, $slide_image_size_val);
955
  update_post_meta($post->ID, $slide_image_repeat_saved, $slide_image_repeat_val);
956
  update_post_meta($post->ID, $slide_image_color_saved, $slide_image_color_val);
@@ -960,11 +1003,13 @@ function cpt_slider_save_postdata() {
960
  $slides_saved++;
961
  $slide_edit_id_save = "sa_slide".$slides_saved."_content";
962
  $slide_image_id_saved = "sa_slide".$slides_saved."_image_id";
 
963
  $slide_image_size_saved = "sa_slide".$slides_saved."_image_size";
964
  $slide_image_repeat_saved = "sa_slide".$slides_saved."_image_repeat";
965
  $slide_image_color_saved = "sa_slide".$slides_saved."_image_color";
966
  update_post_meta($post->ID, $slide_edit_id_save, $slide_content);
967
  update_post_meta($post->ID, $slide_image_id_saved, $slide_image_id_val);
 
968
  update_post_meta($post->ID, $slide_image_size_saved, $slide_image_size_val);
969
  update_post_meta($post->ID, $slide_image_repeat_saved, $slide_image_repeat_val);
970
  update_post_meta($post->ID, $slide_image_color_saved, $slide_image_color_val);
@@ -976,27 +1021,41 @@ function cpt_slider_save_postdata() {
976
  // A SLIDE NEEDS TO BE MOVED (TWO SLIDES ARE SWAPPED)
977
  $slide2 = $move_slide_up;
978
  $slide1 = intval($move_slide_up) - 1;
979
- $slide1_content = wp_kses_post($_POST["sa_slide".$slide1."_content"]); // SANATIZE (slide 'wp_editor' content to contain valid HTML tags)
 
980
  $slide1_image_id = abs(intval($_POST["sa_slide".$slide1."_image_id"])); // SANATIZE (slide BG image ID is a valid integer)
 
981
  $slide1_image_size = sanitize_text_field($_POST["sa_slide".$slide1."_image_size"]); // SANATIZE (BG image size is a valid text-input string)
982
  $slide1_image_repeat = sanitize_text_field($_POST["sa_slide".$slide1."_image_repeat"]); // SANATIZE (BG image repeat is a valid text-input string)
983
  $slide1_image_color = sanitize_text_field($_POST["sa_slide".$slide1."_image_color"]); // SANATIZE (BG color is a valid text-input string)
984
- $slide2_content = wp_kses_post($_POST["sa_slide".$slide2."_content"]); // SANATIZE (slide 'wp_editor' content to contain valid HTML tags)
 
985
  $slide2_image_id = abs(intval($_POST["sa_slide".$slide2."_image_id"])); // SANATIZE (slide BG image ID is a valid integer)
 
986
  $slide2_image_size = sanitize_text_field($_POST["sa_slide".$slide2."_image_size"]); // SANATIZE (BG image size is a valid text-input string)
987
  $slide2_image_repeat = sanitize_text_field($_POST["sa_slide".$slide2."_image_repeat"]); // SANATIZE (BG image repeat is a valid text-input string)
988
  $slide2_image_color = sanitize_text_field($_POST["sa_slide".$slide2."_image_color"]); // SANATIZE (BG color is a valid text-input string)
989
  update_post_meta($post->ID, "sa_slide".$slide2."_content", $slide1_content);
990
  update_post_meta($post->ID, "sa_slide".$slide2."_image_id", $slide1_image_id);
 
991
  update_post_meta($post->ID, "sa_slide".$slide2."_image_size", $slide1_image_size);
992
  update_post_meta($post->ID, "sa_slide".$slide2."_image_repeat", $slide1_image_repeat);
993
  update_post_meta($post->ID, "sa_slide".$slide2."_image_color", $slide1_image_color);
994
  update_post_meta($post->ID, "sa_slide".$slide1."_content", $slide2_content);
995
  update_post_meta($post->ID, "sa_slide".$slide1."_image_id", $slide2_image_id);
 
996
  update_post_meta($post->ID, "sa_slide".$slide1."_image_size", $slide2_image_size);
997
  update_post_meta($post->ID, "sa_slide".$slide1."_image_repeat", $slide2_image_repeat);
998
  update_post_meta($post->ID, "sa_slide".$slide1."_image_color", $slide2_image_color);
999
  }
 
 
 
 
 
 
 
 
1000
 
1001
  // UPDATE SLIDER SETTINGS
1002
  update_post_meta($post->ID, 'sa_disable_visual_editor', abs(intval($_POST['sa_disable_visual_editor']))); // SANATIZE (valid integer value)
48
  $content .= "</div>\n";
49
  update_post_meta($cpt_id, "sa_slide".$i."_content", $content);
50
  update_post_meta($cpt_id, "sa_slide".$i."_image_id", "");
51
+ update_post_meta($cpt_id, "sa_slide".$i."_image_pos", "left top");
52
  update_post_meta($cpt_id, "sa_slide".$i."_image_size", "contain");
53
  update_post_meta($cpt_id, "sa_slide".$i."_image_repeat", "no-repeat");
54
  update_post_meta($cpt_id, "sa_slide".$i."_image_color", $color);
488
  $slide_data[0]['image_id'] = "sa_slide1_image_id";
489
  $slide_data[0]['thumb'] = "slide1_thumb";
490
  $slide_data[0]['image_del'] = "slide1_image_del";
491
+ $slide_data[0]['image_pos'] = "sa_slide1_image_pos";
492
  $slide_data[0]['image_size'] = "sa_slide1_image_size";
493
  $slide_data[0]['image_repeat'] = "sa_slide1_image_repeat";
494
  $slide_data[0]['image_color'] = "sa_slide1_image_color";
499
  $slide_data[1]['image_id'] = "sa_slide2_image_id";
500
  $slide_data[1]['thumb'] = "slide2_thumb";
501
  $slide_data[1]['image_del'] = "slide2_image_del";
502
+ $slide_data[1]['image_pos'] = "sa_slide2_image_pos";
503
  $slide_data[1]['image_size'] = "sa_slide2_image_size";
504
  $slide_data[1]['image_repeat'] = "sa_slide2_image_repeat";
505
  $slide_data[1]['image_color'] = "sa_slide2_image_color";
510
  $slide_data[2]['image_id'] = "sa_slide3_image_id";
511
  $slide_data[2]['thumb'] = "slide3_thumb";
512
  $slide_data[2]['image_del'] = "slide3_image_del";
513
+ $slide_data[2]['image_pos'] = "sa_slide3_image_pos";
514
  $slide_data[2]['image_size'] = "sa_slide3_image_size";
515
  $slide_data[2]['image_repeat'] = "sa_slide3_image_repeat";
516
  $slide_data[2]['image_color'] = "sa_slide3_image_color";
522
  $count = 0;
523
  for ($i = 1; $i <= $num_slides; $i++) {
524
  $slide_edit_id = "sa_slide".$i."_content";
525
+ $slide_char_count = "sa_slide".$i."_char_count";
526
  $slide_data[$count]['edit_id'] = $slide_edit_id;
527
  $slide_data[$count]['content'] = get_post_meta($post->ID, $slide_edit_id, true);
528
+ $slide_data[$count]['char_count'] = get_post_meta($post->ID, $slide_char_count, true);
529
  $slide_data[$count]['del_id'] = "sa_slide".$i."_delete";
530
  $slide_data[$count]['image_id'] = "sa_slide".$i."_image_id";
531
  $slide_data[$count]['thumb'] = "slide".$i."_thumb";
532
  $slide_data[$count]['image_del'] = "slide".$i."_image_del";
533
+ $slide_data[$count]['image_pos'] = "sa_slide".$i."_image_pos";
534
  $slide_data[$count]['image_size'] = "sa_slide".$i."_image_size";
535
  $slide_data[$count]['image_repeat'] = "sa_slide".$i."_image_repeat";
536
  $slide_data[$count]['image_color'] = "sa_slide".$i."_image_color";
546
  echo "<div>\n";
547
 
548
  // ### DISPLAY THE SLIDE CONTENT EDITOR (textarea field) ###
549
+ //wp_editor($slide_data[$i]['content'], wp_kses_post($slide_data[$i]['edit_id']), $editor_args);
550
+ wp_editor($slide_data[$i]['content'], $slide_data[$i]['edit_id'], $editor_args);
551
 
552
  // ### BACKGROUND COLOR/IMAGE FIELDS ###
553
+ // GET BACKGROUND IMAGE DATA FOR THIS SLIDE (image id, position, size, repeat and color)
554
  $slide_image_id = get_post_meta($post->ID, $slide_data[$i]['image_id'], true);
555
+ $slide_image_pos = get_post_meta($post->ID, $slide_data[$i]['image_pos'], true);
556
+ if ($slide_image_pos == '') {
557
+ $slide_image_pos = 'left top';
558
+ }
559
  $slide_image_size = get_post_meta($post->ID, $slide_data[$i]['image_size'], true);
560
  if ($slide_image_size == '') {
561
  $slide_image_size = 'contain';
582
  echo "<div id='".$slide_data[$i]['thumb']."' class='sa_slide_thumb'>\n";
583
  if ($image_exists) {
584
  echo "<div style='background-image:url(\"".esc_attr($slide_image_src[0])."\"); background-size:".esc_attr($slide_image_size)."; ";
585
+ echo "background-repeat:".esc_attr($slide_image_repeat)."; background-color:".esc_attr($slide_image_color)."; ";
586
+ echo "background-position:".esc_attr($slide_image_pos).";'></div>\n";
587
  echo "<span id='".esc_attr($slide_data[$i]['image_del'])."' onClick='remove_slide_bg_image(\"".esc_attr($slide_data[$i]['slide_no'])."\");' title='Delete the background image for this slide'>X</span>\n";
588
  echo "</div>\n";
589
  } else {
590
  echo "<div style='background-color:#ffffff; background-size:".esc_attr($slide_image_size)."; ";
591
+ echo "background-repeat:".esc_attr($slide_image_repeat)."; background-color:".esc_attr($slide_image_color)."; ";
592
+ echo "background-position:".esc_attr($slide_image_pos).";'></div>\n";
593
  echo "<span id='".esc_attr($slide_data[$i]['image_del'])."' class='sa_hidden' onClick='remove_slide_bg_image(\"".esc_attr($slide_data[$i]['slide_no'])."\");' title='Delete the background image for this slide'>X</span>\n";
594
  echo "</div>\n";
595
  }
598
  // slide background image - image id text field
599
  echo "<input type='hidden' id='".esc_attr($slide_data[$i]['image_id'])."' name='".esc_attr($slide_data[$i]['image_id'])."' value='".esc_attr($slide_image_id)."'/>\n";
600
 
601
+ // SLIDE BACKGROUND IMAGE - BACKGROUND POSITION (dropdown box)
602
+ echo "<div class='slide_image_settings_line'>";
603
+ echo "<span>Background Position:</span>";
604
+ $option_arr = array();
605
+ $option_arr[0]['desc'] = 'Top Left'; $option_arr[0]['value'] = 'left top';
606
+ $option_arr[1]['desc'] = 'Top Center'; $option_arr[1]['value'] = 'center top';
607
+ $option_arr[2]['desc'] = 'Top Right'; $option_arr[2]['value'] = 'right top';
608
+ $option_arr[3]['desc'] = 'Center Left'; $option_arr[3]['value'] = 'left center';
609
+ $option_arr[4]['desc'] = 'Center'; $option_arr[4]['value'] = 'center center';
610
+ $option_arr[5]['desc'] = 'Center Right'; $option_arr[5]['value'] = 'right center';
611
+ $option_arr[6]['desc'] = 'Bottom Left'; $option_arr[6]['value'] = 'left bottom';
612
+ $option_arr[7]['desc'] = 'Bottom Center'; $option_arr[7]['value'] = 'center bottom';
613
+ $option_arr[8]['desc'] = 'Bottom Right'; $option_arr[8]['value'] = 'right bottom';
614
+ echo "<select id='".esc_attr($slide_data[$i]['image_pos'])."' name='".esc_attr($slide_data[$i]['image_pos'])."' onChange='change_slide_image_pos(".esc_attr($slide_data[$i]['slide_no']).");'>";
615
+ for ($j = 0; $j < count($option_arr); $j++) {
616
+ if ($slide_image_pos == $option_arr[$j]['value']) {
617
+ echo "<option value='".esc_attr($option_arr[$j]['value'])."' selected>".esc_html($option_arr[$j]['desc'])."</option>";
618
+ } else {
619
+ echo "<option value='".esc_attr($option_arr[$j]['value'])."'>".esc_html($option_arr[$j]['desc'])."</option>";
620
+ }
621
+ }
622
+ echo "</select>";
623
+ echo "</div>\n";
624
+
625
  // SLIDE BACKGROUND IMAGE - BACKGROUND SIZE (dropdown box)
626
  echo "<div class='slide_image_settings_line'>";
627
  echo "<span>Background Size:</span>";
962
  for ($i = 1; $i <= $total_slides; $i++) {
963
  $slide_edit_id = "sa_slide".$i."_content";
964
  $slide_image_id = "sa_slide".$i."_image_id";
965
+ $slide_image_pos = "sa_slide".$i."_image_pos";
966
  $slide_image_size = "sa_slide".$i."_image_size";
967
  $slide_image_repeat = "sa_slide".$i."_image_repeat";
968
  $slide_image_color = "sa_slide".$i."_image_color";
969
+ //$slide_content = wp_kses_post($_POST[$slide_edit_id]); // SANATIZE (slide 'wp_editor' content to contain valid HTML tags)
970
+ $slide_content = $_POST[$slide_edit_id];
971
  $slide_image_id_val = abs(intval($_POST[$slide_image_id])); // SANATIZE (slide BG image ID is a valid integer)
972
+ $slide_image_pos_val = sanitize_text_field($_POST[$slide_image_pos]); // SANATIZE (BG image position is a valid text-input string)
973
  $slide_image_size_val = sanitize_text_field($_POST[$slide_image_size]); // SANATIZE (BG image size is a valid text-input string)
974
  $slide_image_repeat_val = sanitize_text_field($_POST[$slide_image_repeat]); // SANATIZE (BG image repeat is a valid text-input string)
975
  $slide_image_color_val = sanitize_text_field($_POST[$slide_image_color]); // SANATIZE (BG color is a valid text-input string)
987
  $slides_saved++;
988
  $slide_edit_id_save = "sa_slide".$slides_saved."_content";
989
  $slide_image_id_saved = "sa_slide".$slides_saved."_image_id";
990
+ $slide_image_pos_saved = "sa_slide".$slides_saved."_image_pos";
991
  $slide_image_size_saved = "sa_slide".$slides_saved."_image_size";
992
  $slide_image_repeat_saved = "sa_slide".$slides_saved."_image_repeat";
993
  $slide_image_color_saved = "sa_slide".$slides_saved."_image_color";
994
  update_post_meta($post->ID, $slide_edit_id_save, $slide_content);
995
  update_post_meta($post->ID, $slide_image_id_saved, $slide_image_id_val);
996
+ update_post_meta($post->ID, $slide_image_pos_saved, $slide_image_pos_val);
997
  update_post_meta($post->ID, $slide_image_size_saved, $slide_image_size_val);
998
  update_post_meta($post->ID, $slide_image_repeat_saved, $slide_image_repeat_val);
999
  update_post_meta($post->ID, $slide_image_color_saved, $slide_image_color_val);
1003
  $slides_saved++;
1004
  $slide_edit_id_save = "sa_slide".$slides_saved."_content";
1005
  $slide_image_id_saved = "sa_slide".$slides_saved."_image_id";
1006
+ $slide_image_pos_saved = "sa_slide".$slides_saved."_image_pos";
1007
  $slide_image_size_saved = "sa_slide".$slides_saved."_image_size";
1008
  $slide_image_repeat_saved = "sa_slide".$slides_saved."_image_repeat";
1009
  $slide_image_color_saved = "sa_slide".$slides_saved."_image_color";
1010
  update_post_meta($post->ID, $slide_edit_id_save, $slide_content);
1011
  update_post_meta($post->ID, $slide_image_id_saved, $slide_image_id_val);
1012
+ update_post_meta($post->ID, $slide_image_pos_saved, $slide_image_pos_val);
1013
  update_post_meta($post->ID, $slide_image_size_saved, $slide_image_size_val);
1014
  update_post_meta($post->ID, $slide_image_repeat_saved, $slide_image_repeat_val);
1015
  update_post_meta($post->ID, $slide_image_color_saved, $slide_image_color_val);
1021
  // A SLIDE NEEDS TO BE MOVED (TWO SLIDES ARE SWAPPED)
1022
  $slide2 = $move_slide_up;
1023
  $slide1 = intval($move_slide_up) - 1;
1024
+ //$slide1_content = wp_kses_post($_POST["sa_slide".$slide1."_content"]); // SANATIZE (slide 'wp_editor' content to contain valid HTML tags)
1025
+ $slide1_content = $_POST["sa_slide".$slide1."_content"];
1026
  $slide1_image_id = abs(intval($_POST["sa_slide".$slide1."_image_id"])); // SANATIZE (slide BG image ID is a valid integer)
1027
+ $slide1_image_pos = sanitize_text_field($_POST["sa_slide".$slide1."_image_pos"]); // SANATIZE (BG image position is a valid text-input string)
1028
  $slide1_image_size = sanitize_text_field($_POST["sa_slide".$slide1."_image_size"]); // SANATIZE (BG image size is a valid text-input string)
1029
  $slide1_image_repeat = sanitize_text_field($_POST["sa_slide".$slide1."_image_repeat"]); // SANATIZE (BG image repeat is a valid text-input string)
1030
  $slide1_image_color = sanitize_text_field($_POST["sa_slide".$slide1."_image_color"]); // SANATIZE (BG color is a valid text-input string)
1031
+ //$slide2_content = wp_kses_post($_POST["sa_slide".$slide2."_content"]); // SANATIZE (slide 'wp_editor' content to contain valid HTML tags)
1032
+ $slide2_content = $_POST["sa_slide".$slide2."_content"];
1033
  $slide2_image_id = abs(intval($_POST["sa_slide".$slide2."_image_id"])); // SANATIZE (slide BG image ID is a valid integer)
1034
+ $slide2_image_pos = sanitize_text_field($_POST["sa_slide".$slide2."_image_pos"]); // SANATIZE (BG image position is a valid text-input string)
1035
  $slide2_image_size = sanitize_text_field($_POST["sa_slide".$slide2."_image_size"]); // SANATIZE (BG image size is a valid text-input string)
1036
  $slide2_image_repeat = sanitize_text_field($_POST["sa_slide".$slide2."_image_repeat"]); // SANATIZE (BG image repeat is a valid text-input string)
1037
  $slide2_image_color = sanitize_text_field($_POST["sa_slide".$slide2."_image_color"]); // SANATIZE (BG color is a valid text-input string)
1038
  update_post_meta($post->ID, "sa_slide".$slide2."_content", $slide1_content);
1039
  update_post_meta($post->ID, "sa_slide".$slide2."_image_id", $slide1_image_id);
1040
+ update_post_meta($post->ID, "sa_slide".$slide2."_image_pos", $slide1_image_pos);
1041
  update_post_meta($post->ID, "sa_slide".$slide2."_image_size", $slide1_image_size);
1042
  update_post_meta($post->ID, "sa_slide".$slide2."_image_repeat", $slide1_image_repeat);
1043
  update_post_meta($post->ID, "sa_slide".$slide2."_image_color", $slide1_image_color);
1044
  update_post_meta($post->ID, "sa_slide".$slide1."_content", $slide2_content);
1045
  update_post_meta($post->ID, "sa_slide".$slide1."_image_id", $slide2_image_id);
1046
+ update_post_meta($post->ID, "sa_slide".$slide1."_image_pos", $slide2_image_pos);
1047
  update_post_meta($post->ID, "sa_slide".$slide1."_image_size", $slide2_image_size);
1048
  update_post_meta($post->ID, "sa_slide".$slide1."_image_repeat", $slide2_image_repeat);
1049
  update_post_meta($post->ID, "sa_slide".$slide1."_image_color", $slide2_image_color);
1050
  }
1051
+
1052
+ // UPDATE SLIDE CONTENT CHARACTER COUNT
1053
+ $total_slides = get_post_meta($post->ID, 'sa_num_slides', true);
1054
+ for ($i = 1; $i <= $total_slides; $i++) {
1055
+ $slide_content = get_post_meta($post->ID, "sa_slide".$i."_content", true);
1056
+ $char_count = strlen($slide_content);
1057
+ update_post_meta($post->ID, "sa_slide".$i."_char_count", $char_count);
1058
+ }
1059
 
1060
  // UPDATE SLIDER SETTINGS
1061
  update_post_meta($post->ID, 'sa_disable_visual_editor', abs(intval($_POST['sa_disable_visual_editor']))); // SANATIZE (valid integer value)
php/slide-anything-frontend.php CHANGED
@@ -41,6 +41,13 @@ function slide_anything_shortcode($atts) {
41
  $slide_data['shortcodes'] = 'false';
42
  }
43
  for ($i = 1; $i <= $slide_data['num_slides']; $i++) {
 
 
 
 
 
 
 
44
  // apply 'the_content' filter to slide content to process any shortcodes
45
  if ($slide_data['shortcodes'] == 'true') {
46
  $slide_data["slide".$i."_content"] = apply_filters('the_content', $metadata["sa_slide".$i."_content"][0]);
@@ -48,6 +55,7 @@ function slide_anything_shortcode($atts) {
48
  $slide_data["slide".$i."_content"] = $metadata["sa_slide".$i."_content"][0];
49
  }
50
  $slide_data["slide".$i."_image_id"] = $metadata["sa_slide".$i."_image_id"][0];
 
51
  $slide_data["slide".$i."_image_size"] = $metadata["sa_slide".$i."_image_size"][0];
52
  $slide_data["slide".$i."_image_repeat"] = $metadata["sa_slide".$i."_image_repeat"][0];
53
  $slide_data["slide".$i."_image_color"] = $metadata["sa_slide".$i."_image_color"][0];
@@ -122,6 +130,7 @@ function slide_anything_shortcode($atts) {
122
  for ($i = 1; $i <= $slide_data['num_slides']; $i++) {
123
  $reorder_arr[$i-1]['content'] = $slide_data["slide".$i."_content"];
124
  $reorder_arr[$i-1]['image_id'] = $slide_data["slide".$i."_image_id"];
 
125
  $reorder_arr[$i-1]['image_size'] = $slide_data["slide".$i."_image_size"];
126
  $reorder_arr[$i-1]['image_repeat'] = $slide_data["slide".$i."_image_repeat"];
127
  $reorder_arr[$i-1]['image_color'] = $slide_data["slide".$i."_image_color"];
@@ -130,6 +139,7 @@ function slide_anything_shortcode($atts) {
130
  for ($i = 1; $i <= $slide_data['num_slides']; $i++) {
131
  $slide_data["slide".$i."_content"] = $reorder_arr[$i-1]['content'];
132
  $slide_data["slide".$i."_image_id"] = $reorder_arr[$i-1]['image_id'];
 
133
  $slide_data["slide".$i."_image_size"] = $reorder_arr[$i-1]['image_size'];
134
  $slide_data["slide".$i."_image_repeat"] = $reorder_arr[$i-1]['image_repeat'];
135
  $slide_data["slide".$i."_image_color"] = $reorder_arr[$i-1]['image_color'];
@@ -159,19 +169,27 @@ function slide_anything_shortcode($atts) {
159
  }
160
  }
161
  for ($i = 1; $i <= $slide_data['num_slides']; $i++) {
162
- $slide_content = $slide_data["slide".$i."_content"];
163
- $slide_image_src = wp_get_attachment_image_src($slide_data["slide".$i."_image_id"], 'full');
164
- $slide_image_size = $slide_data["slide".$i."_image_size"];
165
- $slide_image_repeat = $slide_data["slide".$i."_image_repeat"];
166
- $slide_image_color = $slide_data["slide".$i."_image_color"];
167
- $slide_style = "padding:".$slide_data['slide_padding_tb']."% ".$slide_data['slide_padding_lr']."%; ";
168
- $slide_style .= "margin:0px ".$slide_data['slide_margin_lr']."%; ";
169
- $slide_style .= "min-height:".$slide_data['slide_min_height']."px; ";
170
- $slide_style .= "background-image:url(\"".$slide_image_src[0]."\"); ";
171
- $slide_style .= "background-size:".$slide_image_size."; ";
172
- $slide_style .= "background-repeat:".$slide_image_repeat."; ";
173
- $slide_style .= "background-color:".$slide_image_color."; ";
174
- $output .= "<div style='".esc_attr($slide_style)."'>".wp_kses_post($slide_content)."</div>\n";
 
 
 
 
 
 
 
 
175
  }
176
  $output .= "</div>\n";
177
  $output .= "</div>\n";
41
  $slide_data['shortcodes'] = 'false';
42
  }
43
  for ($i = 1; $i <= $slide_data['num_slides']; $i++) {
44
+ // get the valid content character count and the actual content character count
45
+ $slide_data["slide".$i."_valid_char_count"] = $metadata["sa_slide".$i."_char_count"][0];
46
+ if ($slide_data["slide".$i."_valid_char_count"] == 0) {
47
+ $slide_data["slide".$i."_actual_char_count"] = 0; // valid character count does not exist so set actual count to matching zero
48
+ } else {
49
+ $slide_data["slide".$i."_actual_char_count"] = strlen($metadata["sa_slide".$i."_content"][0]);
50
+ }
51
  // apply 'the_content' filter to slide content to process any shortcodes
52
  if ($slide_data['shortcodes'] == 'true') {
53
  $slide_data["slide".$i."_content"] = apply_filters('the_content', $metadata["sa_slide".$i."_content"][0]);
55
  $slide_data["slide".$i."_content"] = $metadata["sa_slide".$i."_content"][0];
56
  }
57
  $slide_data["slide".$i."_image_id"] = $metadata["sa_slide".$i."_image_id"][0];
58
+ $slide_data["slide".$i."_image_pos"] = $metadata["sa_slide".$i."_image_pos"][0];
59
  $slide_data["slide".$i."_image_size"] = $metadata["sa_slide".$i."_image_size"][0];
60
  $slide_data["slide".$i."_image_repeat"] = $metadata["sa_slide".$i."_image_repeat"][0];
61
  $slide_data["slide".$i."_image_color"] = $metadata["sa_slide".$i."_image_color"][0];
130
  for ($i = 1; $i <= $slide_data['num_slides']; $i++) {
131
  $reorder_arr[$i-1]['content'] = $slide_data["slide".$i."_content"];
132
  $reorder_arr[$i-1]['image_id'] = $slide_data["slide".$i."_image_id"];
133
+ $reorder_arr[$i-1]['image_pos'] = $slide_data["slide".$i."_image_pos"];
134
  $reorder_arr[$i-1]['image_size'] = $slide_data["slide".$i."_image_size"];
135
  $reorder_arr[$i-1]['image_repeat'] = $slide_data["slide".$i."_image_repeat"];
136
  $reorder_arr[$i-1]['image_color'] = $slide_data["slide".$i."_image_color"];
139
  for ($i = 1; $i <= $slide_data['num_slides']; $i++) {
140
  $slide_data["slide".$i."_content"] = $reorder_arr[$i-1]['content'];
141
  $slide_data["slide".$i."_image_id"] = $reorder_arr[$i-1]['image_id'];
142
+ $slide_data["slide".$i."_image_pos"] = $reorder_arr[$i-1]['image_pos'];
143
  $slide_data["slide".$i."_image_size"] = $reorder_arr[$i-1]['image_size'];
144
  $slide_data["slide".$i."_image_repeat"] = $reorder_arr[$i-1]['image_repeat'];
145
  $slide_data["slide".$i."_image_color"] = $reorder_arr[$i-1]['image_color'];
169
  }
170
  }
171
  for ($i = 1; $i <= $slide_data['num_slides']; $i++) {
172
+ $valid_char_count = $slide_data["slide".$i."_valid_char_count"];
173
+ $actual_char_count = $slide_data["slide".$i."_actual_char_count"];
174
+ // validate that slide content contains the correct number of characters, otherwise do not display slide
175
+ // {to prevent malicious content being inserted into slides)
176
+ if ($valid_char_count == $actual_char_count) {
177
+ $slide_content = $slide_data["slide".$i."_content"];
178
+ $slide_image_src = wp_get_attachment_image_src($slide_data["slide".$i."_image_id"], 'full');
179
+ $slide_image_size = $slide_data["slide".$i."_image_size"];
180
+ $slide_image_pos = $slide_data["slide".$i."_image_pos"];
181
+ $slide_image_repeat = $slide_data["slide".$i."_image_repeat"];
182
+ $slide_image_color = $slide_data["slide".$i."_image_color"];
183
+ $slide_style = "padding:".$slide_data['slide_padding_tb']."% ".$slide_data['slide_padding_lr']."%; ";
184
+ $slide_style .= "margin:0px ".$slide_data['slide_margin_lr']."%; ";
185
+ $slide_style .= "min-height:".$slide_data['slide_min_height']."px; ";
186
+ $slide_style .= "background-image:url(\"".$slide_image_src[0]."\"); ";
187
+ $slide_style .= "background-position:".$slide_image_pos."; ";
188
+ $slide_style .= "background-size:".$slide_image_size."; ";
189
+ $slide_style .= "background-repeat:".$slide_image_repeat."; ";
190
+ $slide_style .= "background-color:".$slide_image_color."; ";
191
+ $output .= "<div style='".esc_attr($slide_style)."'>".wp_kses_post($slide_content)."</div>\n";
192
+ }
193
  }
194
  $output .= "</div>\n";
195
  $output .= "</div>\n";
readme.txt CHANGED
@@ -87,6 +87,10 @@ The `SLIDE STYLE` settings are the style settings for each individual slide with
87
  * Added a new `Items Displayed` setting to set the number of slides to be displayed on screen resolutions over 1400 pixels
88
  * Added a new `Autohide Arrows` setting to enable/displayed the autohide feature for slider navigation arrows
89
 
 
 
 
 
90
  == Upgrade Notice ==
91
 
92
  = 1.0 =
@@ -106,3 +110,7 @@ The `SLIDE STYLE` settings are the style settings for each individual slide with
106
  * Bug Fix: Added `Allow Shortcodes` setting. Running shortcodes within `Slide Anything` may cause issues with some Wordpress Page Builders, and disable this setting will resolve this issue if it occurs.
107
  * Added a new `Items Displayed` setting to set the number of slides to be displayed on screen resolutions over 1400 pixels
108
  * Added a new `Autohide Arrows` setting to enable/displayed the autohide feature for slider navigation arrows
 
 
 
 
87
  * Added a new `Items Displayed` setting to set the number of slides to be displayed on screen resolutions over 1400 pixels
88
  * Added a new `Autohide Arrows` setting to enable/displayed the autohide feature for slider navigation arrows
89
 
90
+ = 1.5 =
91
+ * Bug Fix: Fixed issue with some HTML elements/attributes being stripped out when certain shortcodes are used within slide content - found an alternative to KSES sanitization for slide content.
92
+ * Added a new dropdown option 'Background Position' for the slide background of each slide
93
+
94
  == Upgrade Notice ==
95
 
96
  = 1.0 =
110
  * Bug Fix: Added `Allow Shortcodes` setting. Running shortcodes within `Slide Anything` may cause issues with some Wordpress Page Builders, and disable this setting will resolve this issue if it occurs.
111
  * Added a new `Items Displayed` setting to set the number of slides to be displayed on screen resolutions over 1400 pixels
112
  * Added a new `Autohide Arrows` setting to enable/displayed the autohide feature for slider navigation arrows
113
+
114
+ = 1.5 =
115
+ * Bug Fix: Fixed issue with some HTML elements/attributes being stripped out when certain shortcodes are used within slide content - found an alternative to KSES sanitization for slide content.
116
+ * Added a new dropdown option 'Background Position' for the slide background of each slide
slide-anything.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: https://wordpress.org/support/plugin/slide-anything
5
  * Description: Slide Anything allows you to create a carousel/slider where the content for each slide can be anything you want - images, text, HTML, and even shortcodes. This plugin uses the Owl Carousel jQuery plugin, and lets you create beautiful, touch enabled, responsive carousels and sliders.
6
  * Author: Simon Edge
7
- * Version: 1.4
8
  * License: GPLv2 or later
9
  */
10
 
4
  * Plugin URI: https://wordpress.org/support/plugin/slide-anything
5
  * Description: Slide Anything allows you to create a carousel/slider where the content for each slide can be anything you want - images, text, HTML, and even shortcodes. This plugin uses the Owl Carousel jQuery plugin, and lets you create beautiful, touch enabled, responsive carousels and sliders.
6
  * Author: Simon Edge
7
+ * Version: 1.5
8
  * License: GPLv2 or later
9
  */
10