Version Description
- June 11th, 2016 =
- Refactored & improved initial v3.0.0 upgrade, fixing issues with upgrade process between v3.0.4 & v3.0.5.
- Now using
admin_url
function to generate redirect URLs in admin.
Download this release
Release Info
Developer | MatthewRuddy |
Plugin | Easing Slider |
Version | 3.0.6 |
Comparing to | |
See all releases |
Code changes from version 3.0.5 to 3.0.6
- bower.json +1 -1
- easing-slider.php +2 -2
- languages/easingslider.pot +1 -1
- package.json +1 -1
- readme.txt +5 -1
- src/Plugin/Admin/Actions/Settings.php +4 -1
- src/Plugin/Admin/Actions/Sliders.php +3 -1
- src/Plugin/Admin/Upgrades/SliderTransformers/v210.php +117 -0
- src/Plugin/Admin/Upgrades/SliderTransformers/v220.php +137 -0
- src/Plugin/Admin/Upgrades/UpgradeTo220.php +27 -145
- src/Plugin/Admin/Upgrades/UpgradeTo300.php +38 -251
- src/Plugin/Admin/Upgrades/{UpgradeTo305.php → UpgradeTo306.php} +21 -22
- src/Plugin/Admin/Upgrades/Upgrader.php +1 -1
bower.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
{
|
2 |
"name": "Easing Slider",
|
3 |
-
"version": "3.0.
|
4 |
"homepage": "https://github.com/easingslider/easing-slider",
|
5 |
"authors": [
|
6 |
"MatthewRuddy <info@matthewruddy.com>"
|
1 |
{
|
2 |
"name": "Easing Slider",
|
3 |
+
"version": "3.0.6",
|
4 |
"homepage": "https://github.com/easingslider/easing-slider",
|
5 |
"authors": [
|
6 |
"MatthewRuddy <info@matthewruddy.com>"
|
easing-slider.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Easing Slider
|
4 |
* Plugin URI: http://easingslider.com/
|
5 |
* Description: A simple WordPress plugin for creating beautiful sliders.
|
6 |
-
* Version: 3.0.
|
7 |
* Author: Matthew Ruddy
|
8 |
* Author URI: http://matthewruddy.com
|
9 |
* License: GPL2
|
@@ -25,7 +25,7 @@ if ( ! defined('ABSPATH')) {
|
|
25 |
/**
|
26 |
* Define constants
|
27 |
*/
|
28 |
-
define('EASINGSLIDER_VERSION', '3.0.
|
29 |
define('EASINGSLIDER_NAME', 'Easing Slider');
|
30 |
define('EASINGSLIDER_API_URL', 'http://easingslider.com/');
|
31 |
define('EASINGSLIDER_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
3 |
* Plugin Name: Easing Slider
|
4 |
* Plugin URI: http://easingslider.com/
|
5 |
* Description: A simple WordPress plugin for creating beautiful sliders.
|
6 |
+
* Version: 3.0.6
|
7 |
* Author: Matthew Ruddy
|
8 |
* Author URI: http://matthewruddy.com
|
9 |
* License: GPL2
|
25 |
/**
|
26 |
* Define constants
|
27 |
*/
|
28 |
+
define('EASINGSLIDER_VERSION', '3.0.6');
|
29 |
define('EASINGSLIDER_NAME', 'Easing Slider');
|
30 |
define('EASINGSLIDER_API_URL', 'http://easingslider.com/');
|
31 |
define('EASINGSLIDER_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
languages/easingslider.pot
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
# This file is distributed under the GPL2.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Easing Slider 3.0.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/easing-slider\n"
|
7 |
"POT-Creation-Date: 2016-06-08 01:05:08+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
2 |
# This file is distributed under the GPL2.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Easing Slider 3.0.6\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/easing-slider\n"
|
7 |
"POT-Creation-Date: 2016-06-08 01:05:08+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
{
|
2 |
"name": "easing-slider",
|
3 |
"title": "Easing Slider",
|
4 |
-
"version": "3.0.
|
5 |
"devDependencies": {
|
6 |
"grunt": "0.4.5",
|
7 |
"grunt-contrib-concat": "^0.5.1",
|
1 |
{
|
2 |
"name": "easing-slider",
|
3 |
"title": "Easing Slider",
|
4 |
+
"version": "3.0.6",
|
5 |
"devDependencies": {
|
6 |
"grunt": "0.4.5",
|
7 |
"grunt-contrib-concat": "^0.5.1",
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Contributors: MatthewRuddy
|
|
4 |
Tags: slider, wordpress slider, carousel, image slider, responsive slider, slide, slider, slideshow, wordpress slideshow, youtube slider, photo slider, banner rotator, best slider, content slider, fullwidth slider, gallery, hardware accelerate, mobile slider,post slider, swipe, touch slider, page slider, slider plugin, slider shortcode
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 4.6
|
7 |
-
Stable tag: 3.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -89,6 +89,10 @@ This is easy. When editing a slider in the "All Sliders" admin area, simply clic
|
|
89 |
|
90 |
== Changelog ==
|
91 |
|
|
|
|
|
|
|
|
|
92 |
= 3.0.5 - June 8th, 2016 =
|
93 |
* Improvements to upgrade process from versions 2.1 and 2.2. Process should now be much smoother.
|
94 |
* Added support for installing addons where FTP access is required.
|
4 |
Tags: slider, wordpress slider, carousel, image slider, responsive slider, slide, slider, slideshow, wordpress slideshow, youtube slider, photo slider, banner rotator, best slider, content slider, fullwidth slider, gallery, hardware accelerate, mobile slider,post slider, swipe, touch slider, page slider, slider plugin, slider shortcode
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 4.6
|
7 |
+
Stable tag: 3.0.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
89 |
|
90 |
== Changelog ==
|
91 |
|
92 |
+
= 3.0.6 - June 11th, 2016 =
|
93 |
+
* Refactored & improved initial v3.0.0 upgrade, fixing issues with upgrade process between v3.0.4 & v3.0.5.
|
94 |
+
* Now using `admin_url` function to generate redirect URLs in admin.
|
95 |
+
|
96 |
= 3.0.5 - June 8th, 2016 =
|
97 |
* Improvements to upgrade process from versions 2.1 and 2.2. Process should now be much smoother.
|
98 |
* Added support for installing addons where FTP access is required.
|
src/Plugin/Admin/Actions/Settings.php
CHANGED
@@ -80,8 +80,11 @@ class Settings extends Actions
|
|
80 |
// Run an activation
|
81 |
$this->activator->activate();
|
82 |
|
|
|
|
|
|
|
83 |
// Redirect back to settings page to avoid resetting the plugin again if the user refreshes the page.
|
84 |
-
wp_safe_redirect(
|
85 |
exit();
|
86 |
}
|
87 |
}
|
80 |
// Run an activation
|
81 |
$this->activator->activate();
|
82 |
|
83 |
+
// Get the redirect URL
|
84 |
+
$redirectUrl = admin_url('admin.php?page=easingslider-settings&easingslider_notice=reset_plugin');
|
85 |
+
|
86 |
// Redirect back to settings page to avoid resetting the plugin again if the user refreshes the page.
|
87 |
+
wp_safe_redirect($redirectUrl);
|
88 |
exit();
|
89 |
}
|
90 |
}
|
src/Plugin/Admin/Actions/Sliders.php
CHANGED
@@ -63,7 +63,9 @@ class Sliders extends ResourceActions
|
|
63 |
*/
|
64 |
protected function creationRedirect($id)
|
65 |
{
|
66 |
-
|
|
|
|
|
67 |
exit();
|
68 |
}
|
69 |
|
63 |
*/
|
64 |
protected function creationRedirect($id)
|
65 |
{
|
66 |
+
$redirectUrl = admin_url(sprintf('admin.php?page=easingslider&edit=%d&easingslider_notice=publish_slider', $id));
|
67 |
+
|
68 |
+
wp_safe_redirect($redirectUrl);
|
69 |
exit();
|
70 |
}
|
71 |
|
src/Plugin/Admin/Upgrades/SliderTransformers/v210.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace EasingSlider\Plugin\Admin\Upgrades\SliderTransformers;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Exit if accessed directly
|
7 |
+
*/
|
8 |
+
if ( ! defined('ABSPATH')) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
|
12 |
+
class v210
|
13 |
+
{
|
14 |
+
/**
|
15 |
+
* Gets the slider
|
16 |
+
*
|
17 |
+
* @return object|false
|
18 |
+
*/
|
19 |
+
protected function getSlider()
|
20 |
+
{
|
21 |
+
return get_option('easingsliderlite_slideshow', false);
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Gets an image attachment ID, if it exists in the Media Library
|
26 |
+
*
|
27 |
+
* @param object $slide
|
28 |
+
* @return int|false
|
29 |
+
*/
|
30 |
+
protected function getAttachmentId($slide)
|
31 |
+
{
|
32 |
+
global $wpdb;
|
33 |
+
|
34 |
+
if ( ! empty($slide->url)) {
|
35 |
+
|
36 |
+
$attachmentQuery = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE guid='%s'", $slide->url);
|
37 |
+
$attachmentId = $wpdb->get_var($attachmentQuery);
|
38 |
+
|
39 |
+
return $attachmentId;
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
return false;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Transforms an attribute
|
48 |
+
*
|
49 |
+
* @param object $slider
|
50 |
+
* @param string $attribute
|
51 |
+
* @return object
|
52 |
+
*/
|
53 |
+
protected function transformAttribute($slider, $attribute)
|
54 |
+
{
|
55 |
+
if (isset($slider->{$attribute})) {
|
56 |
+
return $slider->{$attribute};
|
57 |
+
} else {
|
58 |
+
return (object) array();
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Transforms our slides
|
64 |
+
*
|
65 |
+
* @param object $slider
|
66 |
+
* @return array
|
67 |
+
*/
|
68 |
+
protected function transformSlides($slider)
|
69 |
+
{
|
70 |
+
$newSlides = array();
|
71 |
+
|
72 |
+
if ( ! empty($slider->slides)) {
|
73 |
+
foreach ($slider->slides as $slide) {
|
74 |
+
$attachmentId = $this->getAttachmentId($slide);
|
75 |
+
|
76 |
+
$newSlides[] = (object) array(
|
77 |
+
'type' => 'image',
|
78 |
+
'id' => absint($slide->id),
|
79 |
+
'attachment_id' => ( ! empty($attachmentId)) ? absint($attachmentId) : null,
|
80 |
+
'alt' => ( ! empty($slide->alt)) ? sanitize_text_field($slide->alt) : '',
|
81 |
+
'link' => ( ! empty($slide->link)) ? 'custom' : 'none',
|
82 |
+
'linkUrl' => ( ! empty($slide->link)) ? sanitize_text_field($slide->link) : '',
|
83 |
+
'linkTargetBlank' => ( ! empty($slide->linkTarget) && '_blank' == $slide->linkTarget) ? true : false,
|
84 |
+
'title' => ( ! empty($slide->title)) ? sanitize_text_field($slide->title) : '',
|
85 |
+
'url' => ( ! $attachmentId && ! empty($slide->url)) ? sanitize_text_field($slide->url) : null
|
86 |
+
);
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
return $newSlides;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Transforms the data
|
95 |
+
*
|
96 |
+
* @return array
|
97 |
+
*/
|
98 |
+
public function transform()
|
99 |
+
{
|
100 |
+
$data = array();
|
101 |
+
|
102 |
+
// Get the slider
|
103 |
+
$slider = $this->getSlider();
|
104 |
+
|
105 |
+
// Transform settings if we have a slider
|
106 |
+
if ($slider) {
|
107 |
+
$data['slides'] = $this->transformSlides($slider, 'slides');
|
108 |
+
$data['general'] = $this->transformAttribute($slider, 'general');
|
109 |
+
$data['dimensions'] = $this->transformAttribute($slider, 'dimensions');
|
110 |
+
$data['transitions'] = $this->transformAttribute($slider, 'transitions');
|
111 |
+
$data['navigation'] = $this->transformAttribute($slider, 'navigation');
|
112 |
+
$data['playback'] = $this->transformAttribute($slider, 'playback');
|
113 |
+
}
|
114 |
+
|
115 |
+
return $data;
|
116 |
+
}
|
117 |
+
}
|
src/Plugin/Admin/Upgrades/SliderTransformers/v220.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace EasingSlider\Plugin\Admin\Upgrades\SliderTransformers;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Exit if accessed directly
|
7 |
+
*/
|
8 |
+
if ( ! defined('ABSPATH')) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
|
12 |
+
class v220
|
13 |
+
{
|
14 |
+
/**
|
15 |
+
* ID
|
16 |
+
*
|
17 |
+
* @var int
|
18 |
+
*/
|
19 |
+
protected $id;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Constructor
|
23 |
+
*
|
24 |
+
* @param int $id
|
25 |
+
* @return void
|
26 |
+
*/
|
27 |
+
public function __construct($id)
|
28 |
+
{
|
29 |
+
$this->id = $id;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Gets the slider
|
34 |
+
*
|
35 |
+
* @return object|false
|
36 |
+
*/
|
37 |
+
protected function getSlider()
|
38 |
+
{
|
39 |
+
$slider = get_post($this->id);
|
40 |
+
$slider->slides = get_post_meta($this->id, '_easingslider_slides', true);
|
41 |
+
$slider->general = get_post_meta($this->id, '_easingslider_general', true);
|
42 |
+
$slider->dimensions = get_post_meta($this->id, '_easingslider_dimensions', true);
|
43 |
+
$slider->transitions = get_post_meta($this->id, '_easingslider_transitions', true);
|
44 |
+
$slider->navigation = get_post_meta($this->id, '_easingslider_navigation', true);
|
45 |
+
$slider->playback = get_post_meta($this->id, '_easingslider_playback', true);
|
46 |
+
|
47 |
+
return $slider;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Sets a slider data attribute, only if the old slider value exists.
|
52 |
+
*
|
53 |
+
* @param array $data
|
54 |
+
* @param string $key
|
55 |
+
* @param object $slider
|
56 |
+
* @param string $section
|
57 |
+
* @param string $attribute
|
58 |
+
* @return array
|
59 |
+
*/
|
60 |
+
protected function transformAttributeIfExists($data, $key, $slider, $section, $attribute)
|
61 |
+
{
|
62 |
+
if (isset($slider->{$section}->{$attribute})) {
|
63 |
+
$data[$key] = $slider->{$section}->{$attribute};
|
64 |
+
}
|
65 |
+
|
66 |
+
return $data;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Transforms our slides
|
71 |
+
*
|
72 |
+
* @param object $slider
|
73 |
+
* @return array
|
74 |
+
*/
|
75 |
+
protected function transformSlides($slider)
|
76 |
+
{
|
77 |
+
$newSlides = array();
|
78 |
+
|
79 |
+
if ( ! empty($slider->slides)) {
|
80 |
+
foreach ($slider->slides as $slide) {
|
81 |
+
$newSlides[] = (object) array(
|
82 |
+
'type' => 'image',
|
83 |
+
'id' => absint($slide->id),
|
84 |
+
'attachment_id' => ( ! empty($slide->attachment_id)) ? absint($slide->attachment_id) : null,
|
85 |
+
'alt' => ( ! empty($slide->alt)) ? sanitize_text_field($slide->alt) : '',
|
86 |
+
'link' => ( ! empty($slide->link)) ? 'custom' : 'none',
|
87 |
+
'linkUrl' => ( ! empty($slide->link)) ? sanitize_text_field($slide->link) : '',
|
88 |
+
'linkTargetBlank' => ( ! empty($slide->linkTargetBlank)) ? true : false,
|
89 |
+
'title' => ( ! empty($slide->title)) ? sanitize_text_field($slide->title) : '',
|
90 |
+
'url' => ( ! $slide->attachment_id && ! empty($slide->url)) ? sanitize_text_field($slide->url) : null
|
91 |
+
);
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
return $newSlides;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Transforms the data
|
100 |
+
*
|
101 |
+
* @return array
|
102 |
+
*/
|
103 |
+
public function transform()
|
104 |
+
{
|
105 |
+
$data = array();
|
106 |
+
|
107 |
+
// Get the slider
|
108 |
+
$slider = $this->getSlider($this->id);
|
109 |
+
|
110 |
+
// Transform settings if we have a slider
|
111 |
+
if ($slider) {
|
112 |
+
$data['type'] = 'media';
|
113 |
+
$data['image_resizing'] = true;
|
114 |
+
$data['auto_height'] = false;
|
115 |
+
$data['lazy_loading'] = true;
|
116 |
+
$data['slides'] = $this->transformSlides($slider);
|
117 |
+
$data = $this->transformAttributeIfExists($data, 'randomize', $slider, 'general', 'randomize');
|
118 |
+
$data = $this->transformAttributeIfExists($data, 'width', $slider, 'dimensions', 'width');
|
119 |
+
$data = $this->transformAttributeIfExists($data, 'height', $slider, 'dimensions', 'height');
|
120 |
+
$data = $this->transformAttributeIfExists($data, 'full_width', $slider, 'dimensions', 'full_width');
|
121 |
+
$data = $this->transformAttributeIfExists($data, 'background_images', $slider, 'dimensions', 'background_images');
|
122 |
+
$data = $this->transformAttributeIfExists($data, 'transition_effect', $slider, 'transitions', 'effect');
|
123 |
+
$data = $this->transformAttributeIfExists($data, 'transition_duration', $slider, 'transitions', 'duration');
|
124 |
+
$data = $this->transformAttributeIfExists($data, 'arrows', $slider, 'navigation', 'arrows');
|
125 |
+
$data = $this->transformAttributeIfExists($data, 'arrows_hover', $slider, 'navigation', 'arrows_hover');
|
126 |
+
$data = $this->transformAttributeIfExists($data, 'arrows_position', $slider, 'navigation', 'arrows_position');
|
127 |
+
$data = $this->transformAttributeIfExists($data, 'pagination', $slider, 'navigation', 'pagination');
|
128 |
+
$data = $this->transformAttributeIfExists($data, 'pagination_hover', $slider, 'navigation', 'pagination_hover');
|
129 |
+
$data = $this->transformAttributeIfExists($data, 'pagination_position', $slider, 'navigation', 'pagination_position');
|
130 |
+
$data = $this->transformAttributeIfExists($data, 'pagination_location', $slider, 'navigation', 'pagination_location');
|
131 |
+
$data = $this->transformAttributeIfExists($data, 'playback_enabled', $slider, 'playback', 'enabled');
|
132 |
+
$data = $this->transformAttributeIfExists($data, 'playback_pause', $slider, 'playback', 'pause');
|
133 |
+
}
|
134 |
+
|
135 |
+
return $data;
|
136 |
+
}
|
137 |
+
}
|
src/Plugin/Admin/Upgrades/UpgradeTo220.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
namespace EasingSlider\Plugin\Admin\Upgrades;
|
4 |
|
5 |
use EasingSlider\Foundation\Admin\Upgrades\Upgrade;
|
|
|
6 |
|
7 |
/**
|
8 |
* Exit if accessed directly
|
@@ -27,13 +28,6 @@ class UpgradeTo220 extends Upgrade
|
|
27 |
*/
|
28 |
protected $upgradeTo = '2.2';
|
29 |
|
30 |
-
/**
|
31 |
-
* Possible option prefixes through v2.1.* Easing Slider "Lite" lifespan
|
32 |
-
*
|
33 |
-
* @var array
|
34 |
-
*/
|
35 |
-
protected $optionPrefixes = array('easingsliderlite', 'rivasliderlite');
|
36 |
-
|
37 |
/**
|
38 |
* Upgrade Flag
|
39 |
*
|
@@ -42,11 +36,11 @@ class UpgradeTo220 extends Upgrade
|
|
42 |
protected $upgradeFlag = 'easingslider_upgraded_from_lite';
|
43 |
|
44 |
/**
|
45 |
-
*
|
46 |
*
|
47 |
* @var string
|
48 |
*/
|
49 |
-
protected $
|
50 |
|
51 |
/**
|
52 |
* Checks if the provided version is eligible for an upgrade
|
@@ -63,7 +57,7 @@ class UpgradeTo220 extends Upgrade
|
|
63 |
return false;
|
64 |
}
|
65 |
|
66 |
-
if ($this->
|
67 |
return true;
|
68 |
}
|
69 |
|
@@ -75,10 +69,10 @@ class UpgradeTo220 extends Upgrade
|
|
75 |
*
|
76 |
* @return boolean
|
77 |
*/
|
78 |
-
protected function
|
79 |
{
|
80 |
// Hijack version with old version option
|
81 |
-
$version =
|
82 |
|
83 |
// Do the comparison and run the upgrade if version is eligible
|
84 |
if ($version) {
|
@@ -89,129 +83,41 @@ class UpgradeTo220 extends Upgrade
|
|
89 |
}
|
90 |
|
91 |
/**
|
92 |
-
*
|
93 |
*
|
94 |
-
* @
|
95 |
-
* @return void
|
96 |
-
*/
|
97 |
-
protected function deleteLiteOption($name)
|
98 |
-
{
|
99 |
-
foreach ($this->optionPrefixes as $prefix) {
|
100 |
-
delete_option("{$prefix}_{$name}");
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Gets an Easing Slider "Lite" option
|
106 |
-
*
|
107 |
-
* @param string $name
|
108 |
-
* @return mixed|false
|
109 |
*/
|
110 |
-
protected function
|
111 |
{
|
112 |
-
|
113 |
-
$value = get_option("{$prefix}_{$name}", false);
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
}
|
118 |
-
}
|
119 |
|
120 |
-
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Gets the "Easing Slider 'Lite'" slider
|
125 |
-
*
|
126 |
-
* @return object|false
|
127 |
-
*/
|
128 |
-
protected function getLiteSlider()
|
129 |
-
{
|
130 |
-
return $this->getLiteOption('slideshow');
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Creates the upgraded "Lite" slider
|
135 |
-
*
|
136 |
-
* @param object $liteSlider
|
137 |
-
* @return int
|
138 |
-
*/
|
139 |
-
protected function createUpgradedSlider($liteSlider)
|
140 |
-
{
|
141 |
-
// Create the post
|
142 |
$postId = wp_insert_post(array(
|
143 |
'post_type' => 'easingslider',
|
144 |
'post_title' => __('Easing Slider "Lite"', 'easingslider'),
|
145 |
'post_status' => 'publish',
|
146 |
));
|
147 |
|
148 |
-
// Add post
|
149 |
-
|
150 |
-
|
151 |
-
add_post_meta($postId, '_easingslider_dimensions', $liteSlider->dimensions);
|
152 |
-
add_post_meta($postId, '_easingslider_transitions', $liteSlider->transitions);
|
153 |
-
add_post_meta($postId, '_easingslider_navigation', $liteSlider->navigation);
|
154 |
-
add_post_meta($postId, '_easingslider_playback', $liteSlider->playback);
|
155 |
-
|
156 |
-
return $postId;
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Transforms our "Lite" slides into our new slide data structure
|
161 |
-
*
|
162 |
-
* @param array $liteSlides
|
163 |
-
* @return array
|
164 |
-
*/
|
165 |
-
protected function transformLiteSlides($liteSlides)
|
166 |
-
{
|
167 |
-
global $wpdb;
|
168 |
-
|
169 |
-
$slides = array();
|
170 |
-
|
171 |
-
// Transform each slide
|
172 |
-
foreach ($liteSlides as $liteSlide) {
|
173 |
-
|
174 |
-
// Query the guid
|
175 |
-
$attachmentQuery = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE guid='%s'", $liteSlide->url);
|
176 |
-
|
177 |
-
// Attempt to get the attachment of this image
|
178 |
-
$attachmentId = $wpdb->get_var($attachmentQuery);
|
179 |
-
|
180 |
-
// Populate the slide
|
181 |
-
$slide = (object) array(
|
182 |
-
'type' => 'image',
|
183 |
-
'id' => absint($liteSlide->id),
|
184 |
-
'attachment_id' => absint($attachmentId),
|
185 |
-
'alt' => sanitize_text_field($liteSlide->alt),
|
186 |
-
'link' => ($liteSlide->link) ? 'custom' : 'none',
|
187 |
-
'linkUrl' => sanitize_text_field($liteSlide->link),
|
188 |
-
'linkTargetBlank' => ('_blank' == $liteSlide->linkTarget) ? true : false,
|
189 |
-
'title' => sanitize_text_field($liteSlide->title),
|
190 |
-
'url' => null
|
191 |
-
);
|
192 |
-
|
193 |
-
// Add an image URL if we aren't using an attachment
|
194 |
-
if ( ! $attachmentId) {
|
195 |
-
$slide->url = sanitize_text_field($liteSlide->url);
|
196 |
-
}
|
197 |
-
|
198 |
-
// Add the slide
|
199 |
-
$slides[] = $slide;
|
200 |
-
|
201 |
}
|
202 |
|
203 |
-
return $
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
-
* Sets the
|
208 |
*
|
209 |
-
* @param
|
210 |
* @return void
|
211 |
*/
|
212 |
-
protected function
|
213 |
{
|
214 |
-
update_option($this->
|
215 |
}
|
216 |
|
217 |
/**
|
@@ -234,21 +140,6 @@ class UpgradeTo220 extends Upgrade
|
|
234 |
return get_option($this->upgradeFlag, false);
|
235 |
}
|
236 |
|
237 |
-
/**
|
238 |
-
* Deletes all "Easing Slider 'Lite'" options that are no longer used
|
239 |
-
*
|
240 |
-
* @return void
|
241 |
-
*/
|
242 |
-
protected function cleanupOptions()
|
243 |
-
{
|
244 |
-
$this->deleteLiteOption('customizations');
|
245 |
-
$this->deleteLiteOption('disable_welcome_panel');
|
246 |
-
$this->deleteLiteOption('major_upgrade');
|
247 |
-
$this->deleteLiteOption('settings');
|
248 |
-
$this->deleteLiteOption('slideshow');
|
249 |
-
$this->deleteLiteOption('version');
|
250 |
-
}
|
251 |
-
|
252 |
/**
|
253 |
* Upgrades the "Lite" slider
|
254 |
*
|
@@ -256,23 +147,14 @@ class UpgradeTo220 extends Upgrade
|
|
256 |
*/
|
257 |
public function upgradeSlider()
|
258 |
{
|
259 |
-
|
260 |
-
|
261 |
-
if ($liteSlider) {
|
262 |
-
|
263 |
-
// Create the upgraded slider
|
264 |
-
$sliderId = $this->createUpgradedSlider($liteSlider);
|
265 |
|
266 |
-
|
267 |
-
|
268 |
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
// Cleanup "Lite" plugin options as they are now redundant
|
273 |
-
// $this->cleanupOptions(); // Temporarily disabling this to allow users time to revert.
|
274 |
-
|
275 |
-
}
|
276 |
}
|
277 |
|
278 |
/**
|
3 |
namespace EasingSlider\Plugin\Admin\Upgrades;
|
4 |
|
5 |
use EasingSlider\Foundation\Admin\Upgrades\Upgrade;
|
6 |
+
use EasingSlider\Plugin\Admin\Upgrades\SliderTransformers\v210 as SliderTransformer;
|
7 |
|
8 |
/**
|
9 |
* Exit if accessed directly
|
28 |
*/
|
29 |
protected $upgradeTo = '2.2';
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
/**
|
32 |
* Upgrade Flag
|
33 |
*
|
36 |
protected $upgradeFlag = 'easingslider_upgraded_from_lite';
|
37 |
|
38 |
/**
|
39 |
+
* Lite Slider ID
|
40 |
*
|
41 |
* @var string
|
42 |
*/
|
43 |
+
protected $liteSliderId = 'easingslider_lite_slider_id';
|
44 |
|
45 |
/**
|
46 |
* Checks if the provided version is eligible for an upgrade
|
57 |
return false;
|
58 |
}
|
59 |
|
60 |
+
if ($this->versionIsEligible()) {
|
61 |
return true;
|
62 |
}
|
63 |
|
69 |
*
|
70 |
* @return boolean
|
71 |
*/
|
72 |
+
protected function versionIsEligible()
|
73 |
{
|
74 |
// Hijack version with old version option
|
75 |
+
$version = get_option('easingsliderlite_version');
|
76 |
|
77 |
// Do the comparison and run the upgrade if version is eligible
|
78 |
if ($version) {
|
83 |
}
|
84 |
|
85 |
/**
|
86 |
+
* Creates the new upgraded "Lite" slider
|
87 |
*
|
88 |
+
* @return int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
*/
|
90 |
+
protected function createNewSlider()
|
91 |
{
|
92 |
+
$transformer = new SliderTransformer();
|
|
|
93 |
|
94 |
+
// Get the transformed data
|
95 |
+
$data = $transformer->transform();
|
|
|
|
|
96 |
|
97 |
+
// Create the post (aka. slider)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
$postId = wp_insert_post(array(
|
99 |
'post_type' => 'easingslider',
|
100 |
'post_title' => __('Easing Slider "Lite"', 'easingslider'),
|
101 |
'post_status' => 'publish',
|
102 |
));
|
103 |
|
104 |
+
// Add post metadata
|
105 |
+
foreach ($data as $key => $value) {
|
106 |
+
add_post_meta($postId, "_easingslider_{$key}", $value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
}
|
108 |
|
109 |
+
return $postId;
|
110 |
}
|
111 |
|
112 |
/**
|
113 |
+
* Sets the Lite Slider ID (used to enable our old shortcode)
|
114 |
*
|
115 |
+
* @param int $id
|
116 |
* @return void
|
117 |
*/
|
118 |
+
protected function setLiteSliderId($id)
|
119 |
{
|
120 |
+
update_option($this->liteSliderId, $id);
|
121 |
}
|
122 |
|
123 |
/**
|
140 |
return get_option($this->upgradeFlag, false);
|
141 |
}
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
/**
|
144 |
* Upgrades the "Lite" slider
|
145 |
*
|
147 |
*/
|
148 |
public function upgradeSlider()
|
149 |
{
|
150 |
+
// Create the new upgraded slider
|
151 |
+
$sliderId = $this->createNewSlider();
|
|
|
|
|
|
|
|
|
152 |
|
153 |
+
// Set the reference ID so we can continue to use the `[easingsliderlite]` shortcode
|
154 |
+
$this->setLiteSliderId($sliderId);
|
155 |
|
156 |
+
// Mark the upgrade as complete so it doesn't occur again
|
157 |
+
$this->markAsUpgraded();
|
|
|
|
|
|
|
|
|
|
|
158 |
}
|
159 |
|
160 |
/**
|
src/Plugin/Admin/Upgrades/UpgradeTo300.php
CHANGED
@@ -5,10 +5,7 @@ namespace EasingSlider\Plugin\Admin\Upgrades;
|
|
5 |
use WP_Roles;
|
6 |
use WP_Query;
|
7 |
use EasingSlider\Foundation\Admin\Upgrades\Upgrade;
|
8 |
-
use EasingSlider\
|
9 |
-
use EasingSlider\Plugin\Contracts\Options\License;
|
10 |
-
use EasingSlider\Plugin\Contracts\Options\Settings;
|
11 |
-
|
12 |
|
13 |
/**
|
14 |
* Exit if accessed directly
|
@@ -19,27 +16,6 @@ if ( ! defined('ABSPATH')) {
|
|
19 |
|
20 |
class UpgradeTo300 extends Upgrade
|
21 |
{
|
22 |
-
/**
|
23 |
-
* Sliders
|
24 |
-
*
|
25 |
-
* @var \EasingSlider\Foundation\Contracts\Repositories\Repository
|
26 |
-
*/
|
27 |
-
protected $sliders;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Settings
|
31 |
-
*
|
32 |
-
* @var \EasingSlider\Plugin\Contracts\Options\Settings
|
33 |
-
*/
|
34 |
-
protected $settings;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* License
|
38 |
-
*
|
39 |
-
* @var \EasingSlider\Plugin\Contracts\Options\License
|
40 |
-
*/
|
41 |
-
protected $license;
|
42 |
-
|
43 |
/**
|
44 |
* The version we're upgrading from (or greater)
|
45 |
*
|
@@ -55,174 +31,34 @@ class UpgradeTo300 extends Upgrade
|
|
55 |
protected $upgradeTo = '3.0.0';
|
56 |
|
57 |
/**
|
58 |
-
*
|
59 |
*
|
60 |
-
* @
|
61 |
*/
|
62 |
-
protected
|
63 |
-
'slides' => '_easingslider_slides',
|
64 |
-
'general' => '_easingslider_general',
|
65 |
-
'dimensions' => '_easingslider_dimensions',
|
66 |
-
'transitions' => '_easingslider_transitions',
|
67 |
-
'navigation' => '_easingslider_navigation',
|
68 |
-
'playback' => '_easingslider_playback'
|
69 |
-
);
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Constructor
|
73 |
-
*
|
74 |
-
* @param \EasingSlider\Foundation\Contracts\Repositories\Repository $sliders
|
75 |
-
* @param \EasingSlider\Plugin\Contracts\Options\Settings $settings
|
76 |
-
* @param \EasingSlider\Plugin\Contracts\Options\License $license
|
77 |
-
* @return void
|
78 |
-
*/
|
79 |
-
public function __construct(Repository $sliders, Settings $settings, License $license)
|
80 |
{
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
84 |
}
|
85 |
|
86 |
/**
|
87 |
-
*
|
88 |
*
|
89 |
-
* @param
|
90 |
-
* @
|
91 |
-
* @param object $oldSlider
|
92 |
-
* @param string $oldSection
|
93 |
-
* @param string $oldKey
|
94 |
-
* @return array
|
95 |
-
*/
|
96 |
-
protected function setAttributeIfExists($slider, $key, $oldSlider, $oldSection, $oldValue)
|
97 |
-
{
|
98 |
-
if (isset($oldSlider->{$oldSection}->{$oldValue})) {
|
99 |
-
$slider[$key] = $oldSlider->{$oldSection}->{$oldValue};
|
100 |
-
}
|
101 |
-
|
102 |
-
return $slider;
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Transforms the old slider data into our new data structure
|
107 |
-
*
|
108 |
-
* @param object $oldSlider
|
109 |
-
* @return array
|
110 |
-
*/
|
111 |
-
protected function transformOldSliderData($oldSlider)
|
112 |
-
{
|
113 |
-
$data = array();
|
114 |
-
|
115 |
-
// Map linear values
|
116 |
-
$data['post_title'] = get_the_title($oldSlider->ID);
|
117 |
-
$data['type'] = 'media';
|
118 |
-
$data['image_resizing'] = true;
|
119 |
-
$data['auto_height'] = false;
|
120 |
-
$data['lazy_loading'] = true;
|
121 |
-
|
122 |
-
// Map dynamic values
|
123 |
-
$data = $this->setAttributeIfExists($data, 'randomize', $oldSlider, 'general', 'randomize');
|
124 |
-
$data = $this->setAttributeIfExists($data, 'width', $oldSlider, 'dimensions', 'width');
|
125 |
-
$data = $this->setAttributeIfExists($data, 'height', $oldSlider, 'dimensions', 'height');
|
126 |
-
$data = $this->setAttributeIfExists($data, 'full_width', $oldSlider, 'dimensions', 'full_width');
|
127 |
-
$data = $this->setAttributeIfExists($data, 'background_images', $oldSlider, 'dimensions', 'background_images');
|
128 |
-
$data = $this->setAttributeIfExists($data, 'transition_effect', $oldSlider, 'transitions', 'effect');
|
129 |
-
$data = $this->setAttributeIfExists($data, 'transition_duration', $oldSlider, 'transitions', 'duration');
|
130 |
-
$data = $this->setAttributeIfExists($data, 'arrows', $oldSlider, 'navigation', 'arrows');
|
131 |
-
$data = $this->setAttributeIfExists($data, 'arrows_hover', $oldSlider, 'navigation', 'arrows_hover');
|
132 |
-
$data = $this->setAttributeIfExists($data, 'arrows_position', $oldSlider, 'navigation', 'arrows_position');
|
133 |
-
$data = $this->setAttributeIfExists($data, 'pagination', $oldSlider, 'navigation', 'pagination');
|
134 |
-
$data = $this->setAttributeIfExists($data, 'pagination_hover', $oldSlider, 'navigation', 'pagination_hover');
|
135 |
-
$data = $this->setAttributeIfExists($data, 'pagination_position', $oldSlider, 'navigation', 'pagination_position');
|
136 |
-
$data = $this->setAttributeIfExists($data, 'pagination_location', $oldSlider, 'navigation', 'pagination_location');
|
137 |
-
$data = $this->setAttributeIfExists($data, 'playback_enabled', $oldSlider, 'playback', 'enabled');
|
138 |
-
$data = $this->setAttributeIfExists($data, 'playback_pause', $oldSlider, 'playback', 'pause');
|
139 |
-
|
140 |
-
// Transform old slides
|
141 |
-
$data['slides'] = $this->transformOldSlides($oldSlider->slides);
|
142 |
-
|
143 |
-
return $data;
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Transforms our old slides into our new slide data structure
|
148 |
-
*
|
149 |
-
* @param array $oldSlides
|
150 |
-
* @return array
|
151 |
*/
|
152 |
-
protected function
|
153 |
{
|
154 |
-
|
155 |
-
|
156 |
-
$slides = array();
|
157 |
-
|
158 |
-
// Transform each slide
|
159 |
-
foreach ($oldSlides as $oldSlide) {
|
160 |
-
|
161 |
-
// Populate the slide
|
162 |
-
$slide = (object) array(
|
163 |
-
'type' => 'image',
|
164 |
-
'id' => absint($oldSlide->id),
|
165 |
-
'attachment_id' => absint($oldSlide->attachment_id),
|
166 |
-
'alt' => sanitize_text_field($oldSlide->alt),
|
167 |
-
'link' => sanitize_text_field($oldSlide->link),
|
168 |
-
'linkUrl' => sanitize_text_field($oldSlide->linkUrl),
|
169 |
-
'linkTargetBlank' => (true == $oldSlide->linkTargetBlank) ? true : false,
|
170 |
-
'title' => sanitize_text_field($oldSlide->title),
|
171 |
-
'url' => null
|
172 |
-
);
|
173 |
|
174 |
-
|
175 |
-
|
176 |
-
$slide->url = $oldSlide->url;
|
177 |
-
}
|
178 |
-
|
179 |
-
// Add the slide
|
180 |
-
$slides[] = $slide;
|
181 |
-
|
182 |
-
}
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Gets the old sliders
|
189 |
-
*
|
190 |
-
* @return array
|
191 |
-
*/
|
192 |
-
protected function getOldSliders()
|
193 |
-
{
|
194 |
-
// Get sliders
|
195 |
-
$sliders = array();
|
196 |
-
|
197 |
-
// Query posts
|
198 |
-
$wpQuery = new WP_Query(array('post_type' => 'easingslider'));
|
199 |
-
|
200 |
-
// Loop through each post
|
201 |
-
if ($wpQuery->have_posts()) {
|
202 |
-
while($wpQuery->have_posts()) {
|
203 |
-
|
204 |
-
$wpQuery->the_post();
|
205 |
-
|
206 |
-
// Get post ID
|
207 |
-
$id = get_the_ID();
|
208 |
-
|
209 |
-
// Get slider
|
210 |
-
$slider = (object) array(
|
211 |
-
'ID' => $id
|
212 |
-
);
|
213 |
-
|
214 |
-
// Add metadata
|
215 |
-
foreach ($this->oldSliderMetaKeys as $settingsKey => $metaKey) {
|
216 |
-
$slider->{$settingsKey} = get_post_meta($id, $metaKey, true);
|
217 |
-
}
|
218 |
-
|
219 |
-
// Add to sliders
|
220 |
-
$sliders[] = $slider;
|
221 |
-
|
222 |
-
}
|
223 |
-
}
|
224 |
-
|
225 |
-
return $sliders;
|
226 |
}
|
227 |
|
228 |
/**
|
@@ -236,51 +72,6 @@ class UpgradeTo300 extends Upgrade
|
|
236 |
add_option('easingslider_upgraded_from_v2', true);
|
237 |
}
|
238 |
|
239 |
-
/**
|
240 |
-
* Migrates the license key
|
241 |
-
*
|
242 |
-
* @return void
|
243 |
-
*/
|
244 |
-
public function migrateLicense()
|
245 |
-
{
|
246 |
-
// Set the license key
|
247 |
-
$this->license['key'] = get_option('easingslider_license_key');
|
248 |
-
|
249 |
-
// Save it
|
250 |
-
$this->license->save();
|
251 |
-
|
252 |
-
// Delete old license key
|
253 |
-
delete_option('easingslider_license_key');
|
254 |
-
}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Upgrades the plugin settings
|
258 |
-
*
|
259 |
-
* @return void
|
260 |
-
*/
|
261 |
-
public function upgradeSettings()
|
262 |
-
{
|
263 |
-
// Get new settings array of defaults
|
264 |
-
$settings = $this->settings->getDefaults();
|
265 |
-
|
266 |
-
// Get the old settings
|
267 |
-
$oldSettings = (array) get_option('easingslider_settings');
|
268 |
-
|
269 |
-
// Convert "Load in Footer" option
|
270 |
-
if (isset($oldSettings['load_assets']) && 'footer' == $oldSettings['load_assets']) {
|
271 |
-
$settings['load_in_footer'] = true;
|
272 |
-
}
|
273 |
-
|
274 |
-
// Convert "Remove Data" option
|
275 |
-
$settings['remove_data'] = $oldSettings['remove_data'];
|
276 |
-
|
277 |
-
// Set the new settings
|
278 |
-
$this->settings->setValue($settings);
|
279 |
-
|
280 |
-
// Update the settings
|
281 |
-
$this->settings->save();
|
282 |
-
}
|
283 |
-
|
284 |
/**
|
285 |
* Upgrades the plugin capaiblities
|
286 |
*
|
@@ -297,14 +88,9 @@ class UpgradeTo300 extends Upgrade
|
|
297 |
}
|
298 |
}
|
299 |
|
300 |
-
|
301 |
-
* In this version (v2.3), we've also unprefixed the plugin capabilities.
|
302 |
-
* Let's reflect this.
|
303 |
-
*/
|
304 |
if (is_object($wp_roles) && ! empty($wp_roles->roles)) {
|
305 |
foreach ($wp_roles->roles as $role => $info) {
|
306 |
-
|
307 |
-
// Get the user role
|
308 |
$userRole = get_role($role);
|
309 |
|
310 |
// Map new capabilities
|
@@ -323,11 +109,26 @@ class UpgradeTo300 extends Upgrade
|
|
323 |
$userRole->remove_cap('easingslider_edit_settings');
|
324 |
$userRole->remove_cap('easingslider_discover_extensions');
|
325 |
$userRole->remove_cap('easingslider_manage_extensions');
|
326 |
-
|
327 |
}
|
328 |
}
|
329 |
}
|
330 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
/**
|
332 |
* Upgrades the plugin sliders
|
333 |
*
|
@@ -335,26 +136,14 @@ class UpgradeTo300 extends Upgrade
|
|
335 |
*/
|
336 |
public function upgradeSliders()
|
337 |
{
|
338 |
-
|
339 |
-
$oldSliders = $this->getOldSliders();
|
340 |
|
341 |
/**
|
342 |
* We're actually using the same post type as previous versions of Easing Slider,
|
343 |
* so instead of creating entirely new sliders, we're upgrading the old ones to our new metadata format.
|
344 |
*/
|
345 |
-
foreach ($
|
346 |
-
|
347 |
-
// Transform data
|
348 |
-
$data = $this->transformOldSliderData($oldSlider);
|
349 |
-
|
350 |
-
// Update the slider with new data
|
351 |
-
$this->sliders->update($oldSlider->ID, $data);
|
352 |
-
|
353 |
-
// Delete old slider meta data
|
354 |
-
// foreach ($this->oldSliderMetaKeys as $metaKey) {
|
355 |
-
// delete_post_meta($oldSlider->ID, $metaKey, true); // Temporarily disable this to allow users to revert back if they have issues.
|
356 |
-
// }
|
357 |
-
|
358 |
}
|
359 |
}
|
360 |
|
@@ -367,8 +156,6 @@ class UpgradeTo300 extends Upgrade
|
|
367 |
{
|
368 |
$this->setupUpgradeInfoNotice();
|
369 |
|
370 |
-
$this->migrateLicense();
|
371 |
-
|
372 |
$this->transferCapabilities();
|
373 |
|
374 |
$this->upgradeSettings();
|
5 |
use WP_Roles;
|
6 |
use WP_Query;
|
7 |
use EasingSlider\Foundation\Admin\Upgrades\Upgrade;
|
8 |
+
use EasingSlider\Plugin\Admin\Upgrades\SliderTransformers\v220 as SliderTransformer;
|
|
|
|
|
|
|
9 |
|
10 |
/**
|
11 |
* Exit if accessed directly
|
16 |
|
17 |
class UpgradeTo300 extends Upgrade
|
18 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
/**
|
20 |
* The version we're upgrading from (or greater)
|
21 |
*
|
31 |
protected $upgradeTo = '3.0.0';
|
32 |
|
33 |
/**
|
34 |
+
* Gets the sliders
|
35 |
*
|
36 |
+
* @return array
|
37 |
*/
|
38 |
+
protected function getSliders()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
{
|
40 |
+
return get_posts(array(
|
41 |
+
'post_type' => 'easingslider',
|
42 |
+
'post_status' => 'all',
|
43 |
+
'posts_per_page' => -1
|
44 |
+
));
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* Upgrades a slider
|
49 |
*
|
50 |
+
* @param int $id
|
51 |
+
* @return void
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
*/
|
53 |
+
protected function upgradeSlider($id)
|
54 |
{
|
55 |
+
$transformer = new SliderTransformer($id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
+
// Get the transformed data
|
58 |
+
$data = $transformer->transform();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
+
// Update the slider data
|
61 |
+
update_post_meta($id, '_easingslider', $data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
}
|
63 |
|
64 |
/**
|
72 |
add_option('easingslider_upgraded_from_v2', true);
|
73 |
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
/**
|
76 |
* Upgrades the plugin capaiblities
|
77 |
*
|
88 |
}
|
89 |
}
|
90 |
|
91 |
+
// If we have roles, map the capabilities
|
|
|
|
|
|
|
92 |
if (is_object($wp_roles) && ! empty($wp_roles->roles)) {
|
93 |
foreach ($wp_roles->roles as $role => $info) {
|
|
|
|
|
94 |
$userRole = get_role($role);
|
95 |
|
96 |
// Map new capabilities
|
109 |
$userRole->remove_cap('easingslider_edit_settings');
|
110 |
$userRole->remove_cap('easingslider_discover_extensions');
|
111 |
$userRole->remove_cap('easingslider_manage_extensions');
|
|
|
112 |
}
|
113 |
}
|
114 |
}
|
115 |
|
116 |
+
/**
|
117 |
+
* Upgrades the plugin settings
|
118 |
+
*
|
119 |
+
* @return void
|
120 |
+
*/
|
121 |
+
public function upgradeSettings()
|
122 |
+
{
|
123 |
+
$settings = (object) get_option('easingslider_settings');
|
124 |
+
|
125 |
+
// Only two settings option available in v3.0.0
|
126 |
+
update_option('easingslider_settings', array(
|
127 |
+
'load_in_footer' => ( ! empty($settings->load_assets) && 'footer' == $settings->load_assets) ? true : false,
|
128 |
+
'remove_data' => ( ! empty($settings->remove_data)) ? true : false
|
129 |
+
));
|
130 |
+
}
|
131 |
+
|
132 |
/**
|
133 |
* Upgrades the plugin sliders
|
134 |
*
|
136 |
*/
|
137 |
public function upgradeSliders()
|
138 |
{
|
139 |
+
$sliders = $this->getSliders();
|
|
|
140 |
|
141 |
/**
|
142 |
* We're actually using the same post type as previous versions of Easing Slider,
|
143 |
* so instead of creating entirely new sliders, we're upgrading the old ones to our new metadata format.
|
144 |
*/
|
145 |
+
foreach ($sliders as $slider) {
|
146 |
+
$this->upgradeSlider($slider->ID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
}
|
149 |
|
156 |
{
|
157 |
$this->setupUpgradeInfoNotice();
|
158 |
|
|
|
|
|
159 |
$this->transferCapabilities();
|
160 |
|
161 |
$this->upgradeSettings();
|
src/Plugin/Admin/Upgrades/{UpgradeTo305.php → UpgradeTo306.php}
RENAMED
@@ -2,8 +2,7 @@
|
|
2 |
|
3 |
namespace EasingSlider\Plugin\Admin\Upgrades;
|
4 |
|
5 |
-
use EasingSlider\
|
6 |
-
use EasingSlider\Foundation\Contracts\Plugin;
|
7 |
|
8 |
/**
|
9 |
* Exit if accessed directly
|
@@ -12,38 +11,34 @@ if ( ! defined('ABSPATH')) {
|
|
12 |
exit;
|
13 |
}
|
14 |
|
15 |
-
class
|
16 |
{
|
17 |
-
/**
|
18 |
-
* Plugin
|
19 |
-
*
|
20 |
-
* @var \EasingSlider\Foundation\Contracts\Plugin
|
21 |
-
*/
|
22 |
-
protected $plugin;
|
23 |
-
|
24 |
/**
|
25 |
* The version we're upgrading from (or greater)
|
26 |
*
|
27 |
* @var string
|
28 |
*/
|
29 |
-
protected $upgradeFrom = '3.0.
|
30 |
|
31 |
/**
|
32 |
* The version we're upgrading too
|
33 |
*
|
34 |
* @var string
|
35 |
*/
|
36 |
-
protected $upgradeTo = '3.0.
|
37 |
|
38 |
/**
|
39 |
-
*
|
40 |
*
|
41 |
-
* @param
|
42 |
-
* @return
|
43 |
*/
|
44 |
-
|
45 |
{
|
46 |
-
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
/**
|
@@ -56,11 +51,15 @@ class UpgradeTo305 extends Upgrade
|
|
56 |
*
|
57 |
* @return void
|
58 |
*/
|
59 |
-
public function
|
60 |
{
|
61 |
-
$
|
62 |
-
|
63 |
-
$
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
|
66 |
/**
|
@@ -70,6 +69,6 @@ class UpgradeTo305 extends Upgrade
|
|
70 |
*/
|
71 |
public function upgrade()
|
72 |
{
|
73 |
-
$this->
|
74 |
}
|
75 |
}
|
2 |
|
3 |
namespace EasingSlider\Plugin\Admin\Upgrades;
|
4 |
|
5 |
+
use EasingSlider\Plugin\Admin\Upgrades\UpgradeTo300;
|
|
|
6 |
|
7 |
/**
|
8 |
* Exit if accessed directly
|
11 |
exit;
|
12 |
}
|
13 |
|
14 |
+
class UpgradeTo306 extends UpgradeTo300
|
15 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
/**
|
17 |
* The version we're upgrading from (or greater)
|
18 |
*
|
19 |
* @var string
|
20 |
*/
|
21 |
+
protected $upgradeFrom = '3.0.0';
|
22 |
|
23 |
/**
|
24 |
* The version we're upgrading too
|
25 |
*
|
26 |
* @var string
|
27 |
*/
|
28 |
+
protected $upgradeTo = '3.0.6';
|
29 |
|
30 |
/**
|
31 |
+
* Checks if a slider is missing data
|
32 |
*
|
33 |
+
* @param int $id
|
34 |
+
* @return boolean
|
35 |
*/
|
36 |
+
protected function isMissingData($id)
|
37 |
{
|
38 |
+
// Check for post meta
|
39 |
+
$metadata = get_post_meta($id, '_easingslider', true);
|
40 |
+
|
41 |
+
return ( ! $metadata) ? true : false;
|
42 |
}
|
43 |
|
44 |
/**
|
51 |
*
|
52 |
* @return void
|
53 |
*/
|
54 |
+
public function fixBrokenSliders()
|
55 |
{
|
56 |
+
$sliders = $this->getSliders();
|
57 |
+
|
58 |
+
foreach ($sliders as $slider) {
|
59 |
+
if ($this->isMissingData($slider->ID)) {
|
60 |
+
$this->upgradeSlider($slider->ID);
|
61 |
+
}
|
62 |
+
}
|
63 |
}
|
64 |
|
65 |
/**
|
69 |
*/
|
70 |
public function upgrade()
|
71 |
{
|
72 |
+
$this->fixBrokenSliders();
|
73 |
}
|
74 |
}
|
src/Plugin/Admin/Upgrades/Upgrader.php
CHANGED
@@ -22,6 +22,6 @@ class Upgrader extends BaseUpgrader
|
|
22 |
{
|
23 |
$this->upgrades[] = $this->plugin->make('\EasingSlider\Plugin\Admin\Upgrades\UpgradeTo220');
|
24 |
$this->upgrades[] = $this->plugin->make('\EasingSlider\Plugin\Admin\Upgrades\UpgradeTo300');
|
25 |
-
$this->upgrades[] = $this->plugin->make('\EasingSlider\Plugin\Admin\Upgrades\
|
26 |
}
|
27 |
}
|
22 |
{
|
23 |
$this->upgrades[] = $this->plugin->make('\EasingSlider\Plugin\Admin\Upgrades\UpgradeTo220');
|
24 |
$this->upgrades[] = $this->plugin->make('\EasingSlider\Plugin\Admin\Upgrades\UpgradeTo300');
|
25 |
+
$this->upgrades[] = $this->plugin->make('\EasingSlider\Plugin\Admin\Upgrades\UpgradeTo306');
|
26 |
}
|
27 |
}
|