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

Version Description

  • Added a 'Duplicate Slider' facility so that sliders created can be duplicated or backed-up

=

Download this release

Release Info

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

Code changes from version 2.3.3 to 2.3.4

Files changed (3) hide show
  1. php/slide-anything-admin.php +89 -1
  2. readme.txt +7 -1
  3. slide-anything.php +1 -1
php/slide-anything-admin.php CHANGED
@@ -2528,7 +2528,7 @@ function cpt_slider_save_postdata() {
2528
  }
2529
  }
2530
 
2531
- // ##### FUNCTIONS CHECKS WHETHER SLIDE ANYTHING PRO IS REGISTERED - RETURNS TRUE OR FALSE #####
2532
  function validate_slide_anything_pro_registration() {
2533
  if (!function_exists('validate_slide_anything_pro_license_key')) {
2534
  return false;
@@ -2536,4 +2536,92 @@ function validate_slide_anything_pro_registration() {
2536
  $valid_key = validate_slide_anything_pro_license_key();
2537
  return $valid_key;
2538
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2539
  ?>
2528
  }
2529
  }
2530
 
2531
+ // ##### FUNCTION CHECKS WHETHER SLIDE ANYTHING PRO IS REGISTERED - RETURNS TRUE OR FALSE #####
2532
  function validate_slide_anything_pro_registration() {
2533
  if (!function_exists('validate_slide_anything_pro_license_key')) {
2534
  return false;
2536
  $valid_key = validate_slide_anything_pro_license_key();
2537
  return $valid_key;
2538
  }
2539
+
2540
+
2541
+
2542
+ // ########################################################################
2543
+ // ### FUNCTION DUPLICATES A 'SLIDE ANYTHING SLIDER' ('sa_slider') POST ###
2544
+ // ########################################################################
2545
+ function duplicate_sa_slider_post_as_draft() {
2546
+ global $wpdb;
2547
+
2548
+ if (!(isset($_GET['post']) || isset($_POST['post']) || (isset($_REQUEST['action']) && 'duplicate_sa_slider_post_as_draft' == $_REQUEST['action']))) {
2549
+ wp_die('No post ID parameter has been supplied!');
2550
+ }
2551
+
2552
+ // NONCE VERIFICATION
2553
+ if (!isset($_GET['duplicate_nonce']) || !wp_verify_nonce($_GET['duplicate_nonce'], basename(__FILE__))) {
2554
+ return;
2555
+ }
2556
+
2557
+ // GET THE ORIGINAL POST ID
2558
+ $post_id = (isset($_GET['post']) ? absint($_GET['post']) : absint($_POST['post']));
2559
+ // GET THE ORIGINAL POST DATA
2560
+ $post = get_post($post_id);
2561
+
2562
+ // SET THE CURRENT USER AS THE NEW POST AUTHOR
2563
+ $current_user = wp_get_current_user();
2564
+ $new_post_author = $current_user->ID;
2565
+
2566
+ // POST DATA EXISTS - CREATE THE POST DUPLICATE
2567
+ if (isset( $post ) && $post != null) {
2568
+ // NEW POST DATA ARRAY
2569
+ $args = array(
2570
+ 'comment_status' => $post->comment_status,
2571
+ 'ping_status' => $post->ping_status,
2572
+ 'post_author' => $new_post_author,
2573
+ 'post_content' => $post->post_content,
2574
+ 'post_excerpt' => $post->post_excerpt,
2575
+ 'post_name' => $post->post_name,
2576
+ 'post_parent' => $post->post_parent,
2577
+ 'post_password' => $post->post_password,
2578
+ 'post_status' => 'draft',
2579
+ 'post_title' => $post->post_title." COPY",
2580
+ 'post_type' => $post->post_type,
2581
+ 'to_ping' => $post->to_ping,
2582
+ 'menu_order' => $post->menu_order
2583
+ );
2584
+
2585
+ // INSERT THE NEW POST USING THE 'wp_insert_post()' FUNCTION
2586
+ $new_post_id = wp_insert_post($args);
2587
+
2588
+ // GET ALL THE CURRENT POST'S TERMS AND SET THEM TO THE NEW POST DRAFT
2589
+ $taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for post type
2590
+ foreach ($taxonomies as $taxonomy) {
2591
+ $post_terms = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'slugs'));
2592
+ wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
2593
+ }
2594
+
2595
+ // DUPLICATE ALL POST META USING JUST 2 SQL QUERIES
2596
+ $post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
2597
+ if (count($post_meta_infos)!=0) {
2598
+ $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
2599
+ foreach ($post_meta_infos as $meta_info) {
2600
+ $meta_key = $meta_info->meta_key;
2601
+ if ($meta_key == '_wp_old_slug') continue;
2602
+ $meta_value = addslashes($meta_info->meta_value);
2603
+ $sql_query_sel[]= "SELECT $new_post_id, '$meta_key', '$meta_value'";
2604
+ }
2605
+ $sql_query.= implode(" UNION ALL ", $sql_query_sel);
2606
+ $wpdb->query($sql_query);
2607
+ }
2608
+
2609
+ // REDIRECT TO THE 'SA Sliders' LIST SCREEN
2610
+ wp_redirect(admin_url('edit.php?post_type=sa_slider'));
2611
+ exit;
2612
+
2613
+ } else {
2614
+ wp_die('Duplicate post creation failed - could not find original post for ID: ' .$post_id);
2615
+ }
2616
+ }
2617
+ add_action('admin_action_duplicate_sa_slider_post_as_draft', 'duplicate_sa_slider_post_as_draft');
2618
+
2619
+ // ##### ADD THE DUPLICATE LINK TO THE ACTION LIST FOR SA SLIDER 'post_row_actions' #####
2620
+ function duplicate_sa_slider_post_link($actions, $post) {
2621
+ if (($post->post_type == 'sa_slider') && (current_user_can('edit_posts'))) {
2622
+ $actions['duplicate'] = '<a href="'.wp_nonce_url('admin.php?action=duplicate_sa_slider_post_as_draft&post='.$post->ID, basename(__FILE__), 'duplicate_nonce').'" title="Duplicate this Slider" rel="permalink">Duplicate Slider</a>';
2623
+ }
2624
+ return $actions;
2625
+ }
2626
+ add_filter('post_row_actions', 'duplicate_sa_slider_post_link', 10, 2);
2627
  ?>
readme.txt CHANGED
@@ -304,6 +304,9 @@ Adding a SLIDE ANYTHING slider using the WordPress 5.0 'Block Editor' is pretty
304
  = 2.3.3 =
305
  * Added Slide Any Post promotional meta box & fixed a couple backend aesthetic issues
306
 
 
 
 
307
  == Upgrade Notice ==
308
 
309
  = 1.0 =
@@ -510,4 +513,7 @@ Adding a SLIDE ANYTHING slider using the WordPress 5.0 'Block Editor' is pretty
510
  * Bug Fix: Fixed 'undefined index' error that sometimes occurs on the WordPress backend when saving Showcase Carousel fields
511
 
512
  = 2.3.3 =
513
- * Added Slide Any Post promotional meta box & fixed a couple backend aesthetic issues
 
 
 
304
  = 2.3.3 =
305
  * Added Slide Any Post promotional meta box & fixed a couple backend aesthetic issues
306
 
307
+ = 2.3.4 =
308
+ * Added a 'Duplicate Slider' facility so that sliders created can be duplicated or backed-up
309
+
310
  == Upgrade Notice ==
311
 
312
  = 1.0 =
513
  * Bug Fix: Fixed 'undefined index' error that sometimes occurs on the WordPress backend when saving Showcase Carousel fields
514
 
515
  = 2.3.3 =
516
+ * Added Slide Any Post promotional meta box & fixed a couple backend aesthetic issues
517
+
518
+ = 2.3.4 =
519
+ * Added a 'Duplicate Slider' facility so that sliders created can be duplicated or backed-up
slide-anything.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: https://wordpress.org/plugins/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: 2.3.3
8
  * License: GPLv2 or later
9
  */
10
 
4
  * Plugin URI: https://wordpress.org/plugins/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: 2.3.4
8
  * License: GPLv2 or later
9
  */
10