PluginProbe
Booking Calendar / 10.1.3
Booking Calendar v10.1.3
11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 All 203 releases
booking / core / any / activation.php

activation.php in Booking Calendar 10.1.3, at core/any/activation.php

294 lines 11.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version 1.0
4 * @package Booking Calendar
5 * @category Installation
6 * @author wpdevelop
7 *
8 * @web-site https://wpbookingcalendar.com/
9 * @email info@wpbookingcalendar.com
10 *
11 * @modified 2015-04-09, 2016-03-17
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
15
16
17 /**
18 * Activation | Deactivation Class
19 */
20 abstract class WPBC_Install {
21
22 private $init_option;
23
24 function __construct() {
25
26 $default_init_option_names = array(
27 'option-version_num' => 'booking_version_num'
28 , 'option-is_delete_if_deactive' => 'booking_is_delete_if_deactive'
29 , 'option-activation_process' => 'booking_activation_process'
30 , 'transient-wpbc_activation_redirect' => '_booking_activation_redirect'
31 , 'message-delete_data' => '<strong>Warning!</strong> ' . 'All plugin data will be deleted when plugin had deactivated.' . '<br />'
32 . sprintf( 'If you want to save your plugin data, please uncheck the %s"Delete plugin data"%s at the', '<strong>', '</strong>')
33 , 'link_settings' => '<a href="">Settings</a>'
34 , 'link_whats_new' => '<a href="">Whats New</a>'
35 );
36
37 $init_option = $this->get_init_option_names();
38
39 $this->init_option = wp_parse_args( $init_option, $default_init_option_names );
40
41
42 register_activation_hook( WPBC_FILE, array( $this, 'wpbc_activate_initial' ) ); // WordPress > Plugins > "Activate" link.
43
44 register_deactivation_hook( WPBC_FILE, array( $this, 'wpbc_deactivate' ) ); // WordPress > Plugins > "Deactivate" link.
45
46 add_filter('upgrader_post_install', array( $this, 'wpbc_install_in_bulk_upgrade' ), 10, 2 ); // Upgrade during bulk upgrade of plugins
47
48 // Settings link at the plugin page
49 add_filter('plugin_action_links', array( $this, 'plugin_links'), 10, 2 );
50 // Warning message in plugin info
51 add_filter('plugin_row_meta', array( $this, 'plugin_row_meta'), 10, 4 );
52
53 $this->check_if_need_to_update(); // Check upgrade, if was no activation process
54 }
55
56
57 /**
58 * Must be overloaded in child CLASS
59 *
60 * * Important! for correct loading of trasnaltions later, we must do not use here loacale of plugin. So here will be untranslated strings!!!
61 *
62 * Exmaple:
63 * return array(
64 'option-version_num' => 'booking_version_num'
65 , 'option-is_delete_if_deactive' => 'booking_is_delete_if_deactive'
66 , 'option-activation_process' => 'booking_activation_process'
67 , 'transient-wpbc_activation_redirect' => '_booking_activation_redirect'
68 , 'message-delete_data' => '<strong>Warning !!!</strong> ' . 'All plugin data will be deleted when plugin had deactivated.' . '<br />'
69 . sprintf( 'If you want to save your plugin data, please uncheck the %s"Delete plugin data"%s at the settings page.', '<strong>', '</strong>')
70 , 'link_settings' => '<a href="">Settings</a>'
71 , 'link_whats_new' => '<a href="">Whats New</a>'
72 );
73 */
74 abstract function get_init_option_names();
75
76
77 /**
78 * Must be overloaded in child CLASS
79 * Exmaple:
80 *
81 return false
82 */
83 abstract function is_update_from_lower_to_high_version();
84
85
86 ////////////////////////////////////////////////////////////////////////////
87
88
89 // <editor-fold defaultstate="collapsed" desc=" Update info of plugin at the plugins section ">
90
91 /** Update info of plugin at the plugins section */
92 function plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $context ) {
93
94 $this_plugin = plugin_basename( WPBC_FILE );
95
96 if ($plugin_file == $this_plugin ) {
97
98 $is_delete_if_deactive = get_bk_option( $this->init_option['option-is_delete_if_deactive'] ); // check
99
100 if ($is_delete_if_deactive == 'On') { ?>
101 <div class="plugin-update-tr">
102 <div class="update-message notice inline notice-warning notice-altNO" style="font-size: 1em;line-height: 2em;margin:0 5px 10px;border-left: 3px solid #dd7000;"><?php
103 echo $this->init_option['message-delete_data']; ?></div>
104 </div>
105 <?php
106 }
107
108 /*
109 [$plugin_meta] => Array
110 (
111 [0] => Version 2.8.35
112 [1] => By wpdevelop
113 [2] => Visit plugin site
114 )
115
116 [$plugin_file] => booking/WPBC.php
117 [$plugin_data] => Array
118 (
119 [Name] => Booking Calendar
120 [PluginURI] => https://wpbookingcalendar.com/demo/
121 [Version] => 2.8.35
122 [Description] => Online booking and availability checking service for your site.
123 [Author] => wpdevelop
124 [AuthorURI] => https://wpbookingcalendar.com/
125 [TextDomain] =>
126 [DomainPath] =>
127 [Network] =>
128 [Title] => Booking Calendar
129 [AuthorName] => wpdevelop
130 )
131
132 [$context] => all
133 /**/
134
135 // Echo plugin description here
136 return $plugin_meta;
137
138 } else
139 return $plugin_meta;
140 }
141
142
143 // Adds Settings link to plugins settings
144 function plugin_links($links, $file) {
145
146 $this_plugin = plugin_basename( WPBC_FILE );
147
148 if ( $file == $this_plugin ) {
149
150 array_unshift( $links, $this->init_option['link_settings'] );
151
152 //array_unshift( $links, $this->init_option['link_whats_new'] );
153 array_unshift( $links, $this->init_option['link_faq'] );
154 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
155 array_unshift( $links, $this->init_option['link_up'] );
156 } else {
157 if ( ! class_exists( 'wpdev_bk_multiuser' ) ) {
158 array_unshift( $links, $this->init_option['link_upgrade'] );
159 }
160 }
161
162 }
163 return $links;
164 }
165
166 // </editor-fold>
167
168
169 ////////////////////////////////////////////////////////////////////////////
170
171
172 // Check about ability to upgrade, if was no activation process
173 private function check_if_need_to_update() {
174
175 if( is_admin() ) {
176
177 $wpbc_version_num = get_option( $this->init_option['option-version_num'] );
178
179 if ($wpbc_version_num === false )
180 $wpbc_version_num = '0';
181
182 $is_make_activation = false;
183
184 if ( version_compare( WP_BK_VERSION_NUM, $wpbc_version_num) > 0 ) {
185
186 $is_make_activation = true;
187
188 } else {
189
190 // Check if we was update from free to paid or from lower to higher versions,
191 // and do not make normal activation. In this case we need to make update.
192 $is_make_activation = $this->is_update_from_lower_to_high_version();
193
194 }
195
196 // Add hook for initial activation.
197 if ( $is_make_activation ) {
198 add_action( 'plugins_loaded', array( $this, 'wpbc_activate_initial' ) , 1030 );
199 }
200 }
201 }
202
203
204 /**
205 * Upgrade during bulk upgrade of plugins
206 *
207 * @param type $return
208 * @param type $hook_extra
209 * @return type
210 */
211 public function wpbc_install_in_bulk_upgrade( $return, $hook_extra ){
212
213 if ( is_wp_error( $return ) )
214 return $return;
215
216 if ( isset( $hook_extra ) )
217 if ( isset( $hook_extra['plugin'] ) ) {
218 $file_name = basename( WPBC_FILE );
219 $pos = strpos( $hook_extra['plugin'], trim( $file_name ) );
220 if ( $pos !== false ) {
221 $this->wpbc_activate();
222 }
223 }
224 return $return;
225 }
226
227
228 /**
229 * User clicked on "Activate" link at Plugins Menu.
230 *
231 * @return type
232 */
233 public function wpbc_activate_initial(){
234
235 // Activate the plugin
236 $this->wpbc_activate();
237
238 // Bail if this demo or activating from network, or bulk
239 if ( is_network_admin() || isset( $_GET['activate-multi'] ) || wpbc_is_this_demo() )
240 return;
241
242 // Add the transient to redirect - Showing Welcome screen
243 set_transient( $this->init_option['transient-wpbc_activation_redirect'], true, 30 );
244 }
245
246
247 ////////////////////////////////////////////////////////////////////////////
248
249
250 /** Run Activate */
251 public function wpbc_activate() {
252
253 //FixIn: 8.4.7.24
254 if ( function_exists( 'set_time_limit' ) ) {
255 set_time_limit( 900 );
256 }
257
258 ini_set('memory_limit','256M'); //FixIn:6.1.1.15
259 ini_set('max_execution_time', 300); //FixIn: 7.0.1.57
260
261 update_bk_option( $this->init_option['option-activation_process'], 'On' );
262
263 make_bk_action( 'wpbc_activation' ); // S T A R T
264
265 update_bk_option( $this->init_option['option-version_num'], WP_BK_VERSION_NUM );
266
267 update_bk_option( $this->init_option['option-activation_process'], 'Off');
268 }
269
270
271 /** Run Deactivate */
272 public function wpbc_deactivate() {
273
274 //FixIn: 8.4.7.24
275 if ( function_exists( 'set_time_limit' ) ) {
276 set_time_limit( 900 );
277 }
278
279 ini_set('memory_limit','256M'); //FixIn:6.1.1.15
280 ini_set('max_execution_time', 300); //FixIn: 7.0.1.57
281
282 $is_delete_if_deactive = get_bk_option( $this->init_option['option-is_delete_if_deactive'] ); // check
283
284 if ( $is_delete_if_deactive == 'On' ) {
285
286 make_bk_action( 'wpbc_deactivation' ); // F I N I S H
287
288 delete_bk_option( $this->init_option['option-version_num'] );
289
290 delete_bk_option( $this->init_option['option-activation_process'] );
291 }
292 }
293
294 }