PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.1
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.1
3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 2.8.17 2.8.18 All 259 releases
wpfunnels / includes / utils / class-wpfnl-rollback.php

class-wpfnl-rollback.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.13.1, at includes/utils/class-wpfnl-rollback.php

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