PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.1.0
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.1.0
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / classes / class-cartflows-rollback.php

class-cartflows-rollback.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.1.0, at classes/class-cartflows-rollback.php

190 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * CartFlows Rollback.
4 *
5 * @package CartFlows
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * CartFlows Rollback.
14 *
15 * CartFlows Rollback. handler class is responsible for rolling back UAG to
16 * previous version.
17 *
18 * @since 2.1.6
19 */
20 class Cartflows_Rollback {
21
22 /**
23 * Package URL.
24 *
25 * Holds the package URL.
26 *
27 * @since 2.1.6
28 * @access protected
29 *
30 * @var string Package URL.
31 */
32 protected $package_url;
33
34 /**
35 * Version.
36 *
37 * Holds the version.
38 *
39 * @since 2.1.6
40 * @access protected
41 *
42 * @var string Package URL.
43 */
44 protected $version;
45
46 /**
47 * Plugin name.
48 *
49 * Holds the plugin name.
50 *
51 * @since 2.1.6
52 * @access protected
53 *
54 * @var string Plugin name.
55 */
56 protected $plugin_name;
57
58 /**
59 * Plugin slug.
60 *
61 * Holds the plugin slug.
62 *
63 * @since 2.1.6
64 * @access protected
65 *
66 * @var string Plugin slug.
67 */
68 protected $plugin_slug;
69
70 /**
71 * CartFlows Rollback constructor.
72 *
73 * Initializing CartFlows Rollback.
74 *
75 * @since 2.1.6
76 * @access public
77 *
78 * @param array $args Optional. CartFlows Rollback arguments. Default is an empty array.
79 */
80 public function __construct( $args = array() ) {
81 foreach ( $args as $key => $value ) {
82 $this->{$key} = $value;
83 }
84 }
85
86 /**
87 * Print inline style.
88 *
89 * Add an inline CSS to the CartFlows Rollback page.
90 *
91 * @since 2.1.6
92 * @access private
93 * @return void
94 */
95 private function print_inline_style() {
96 ?>
97 <style>
98 .wrap {
99 overflow: hidden;
100 max-width: 850px;
101 margin: auto;
102 font-family: Courier, monospace;
103 }
104
105 h1 {
106 background: #f16334;
107 text-align: center;
108 color: #fff !important;
109 padding: 70px !important;
110 text-transform: uppercase;
111 letter-spacing: 1px;
112 }
113
114 h1 img {
115 max-width: 300px;
116 display: block;
117 margin: auto auto 50px;
118 }
119 </style>
120 <?php
121 }
122
123 /**
124 * Apply package.
125 *
126 * Change the plugin data when WordPress checks for updates. This method
127 * modifies package data to update the plugin from a specific URL containing
128 * the version package.
129 *
130 * @since 2.1.6
131 * @access protected
132 * @return void
133 */
134 protected function apply_package() {
135 $update_plugins = get_site_transient( 'update_plugins' );
136 if ( ! is_object( $update_plugins ) ) {
137 $update_plugins = new \stdClass();
138 }
139
140 $plugin_info = new \stdClass();
141 $plugin_info->new_version = $this->version;
142 $plugin_info->slug = $this->plugin_slug;
143 $plugin_info->package = $this->package_url;
144 $plugin_info->url = 'https://cartflows.com/';
145 $update_plugins->response[ $this->plugin_name ] = $plugin_info;
146
147 set_site_transient( 'update_plugins', $update_plugins );
148 }
149
150 /**
151 * Upgrade.
152 *
153 * Run WordPress upgrade to CartFlows Rollback to previous version.
154 *
155 * @since 2.1.6
156 * @access protected
157 * @return void
158 */
159 protected function upgrade() {
160
161 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
162
163 $upgrader_args = array(
164 'url' => 'update.php?action=upgrade-plugin&plugin=' . rawurlencode( $this->plugin_name ),
165 'plugin' => $this->plugin_name,
166 'nonce' => 'upgrade-plugin_' . $this->plugin_name,
167 'title' => __( 'CartFlows <p>Rollback to Previous Version</p>', 'cartflows' ),
168 );
169
170 $this->print_inline_style();
171
172 $upgrader = new \Plugin_Upgrader( new \Plugin_Upgrader_Skin( $upgrader_args ) );
173 $upgrader->upgrade( $this->plugin_name );
174 }
175
176 /**
177 * Run.
178 *
179 * Rollback CartFlows to previous versions.
180 *
181 * @since 2.1.6
182 * @access public
183 * @return void
184 */
185 public function run() {
186 $this->apply_package();
187 $this->upgrade();
188 }
189 }
190