PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.0.2
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.0.2
2.1.21 2.1.20 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 trunk 1.1 2.0 2.0.1 2.0.10.2 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.2 2.0.20 2.0.21 2.0.22 All 55 releases
booking-manager / core / wpbm-activation.php

wpbm-activation.php in Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar 2.0.2, at core/wpbm-activation.php

209 lines 8.6 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 Manager
5 * @subpackage Activation / Deactivation
6 * @category Functions
7 * @author wpdevelop
8 *
9 * @web-site http://oplugins.com/
10 * @email info@oplugins.com
11 * @modified 2016-03-17
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
15
16
17 /** Activation & Deactivation of Booking Manager */
18 class WPBM_ItemInstall extends WPBM_Install {
19
20 /** Overload Booking Manager option names and some other parameters */
21 public function get_init_option_names() {
22
23 add_wpbm_action( 'wpbm_activate_user', array( $this, 'wpbm_activate') ); // Hook for MU User activation
24
25 return array(
26 'option-version_num' => 'wpbm_version_num'
27 , 'option-is_delete_if_deactive' => 'wpbm_is_delete_if_deactive'
28 , 'option-activation_process' => 'wpbm_activation_process'
29 , 'transient-wpbm_activation_redirect' => '_wpbm_activation_redirect'
30 , 'message-delete_data' => '<strong>' . __('Warning!', 'booking-manager') . '</strong> '
31 . __('All plugin data will be deleted when the plugin is deactivated.', 'booking-manager')
32 . '<br />'
33 . sprintf( __('If you want to save your plugin data, please uncheck the %s"Delete data"%s at the' , 'booking-manager')
34 , '<strong>', '</strong>')
35 . '<a href="' . esc_url( admin_url( add_query_arg( array( 'page' => 'oplugins', 'tab' => 'wpbm-settings' ), 'admin.php' ) ) )
36 . '#wpbm_general_settings_uninstall_metabox"> ' . __('settings page', 'booking-manager') . '.'
37 . ' </a>'
38 , 'link_settings' => '<a href="' . esc_url( admin_url( add_query_arg( array( 'page' => 'oplugins', 'tab' => 'wpbm-settings' ), 'admin.php' ) ) )
39 . '">'.__("Settings", 'booking-manager').'</a>'
40 , 'link_whats_new' => ''
41 );
42
43 }
44
45 /** Check if was updated from lower to high version */
46 public function is_update_from_lower_to_high_version() {
47
48 $is_make_activation = false;
49
50 //TODO: Set here correct Table Name about checking upgrade
51 //
52 // Check conditions for different version about Upgrade
53 if ( ( class_exists( 'wpbm_personal' ) ) && ( ! wpbm_is_table_exists( 'itemtypes' ) ) )
54 $is_make_activation = true;
55
56 return $is_make_activation;
57 }
58
59 }
60
61
62
63
64 ////////////////////////////////////////////////////////////////////////////////
65 // A c t i v a t e & D e a c t i v a t e
66 ////////////////////////////////////////////////////////////////////////////////
67
68 /** Activation */
69 function wpbm_activate() {
70
71 // Check for blank data install
72 $wpbm_secret_key = get_wpbm_option( 'wpbm_date_format' );
73 if ( empty( $wpbm_secret_key ) )
74 $is_first_time_install = true;
75 else
76 $is_first_time_install = false;
77
78
79 make_wpbm_action( 'wpbm_before_activation' );
80
81 wpbm_load_translation();
82
83 $version = get_wpbm_version();
84 $is_demo = wpbm_is_this_demo();
85
86 ////////////////////////////////////////////////////////////////////////////
87 // Options
88 ////////////////////////////////////////////////////////////////////////////
89 $default_options_to_add = wpbm_get_default_options();
90
91
92 foreach ( $default_options_to_add as $default_option_name => $default_option_value ) {
93
94 add_wpbm_option( $default_option_name, $default_option_value );
95 }
96
97
98 ////////////////////////////////////////////////////////////////////////////
99 // DB Tables
100 ////////////////////////////////////////////////////////////////////////////
101
102 ////////////////////////////////////////////////////////////////////////////
103 // Other versions Activation
104 ////////////////////////////////////////////////////////////////////////////
105 make_wpbm_action( 'wpbm_other_versions_activation' );
106
107 make_wpbm_action( 'wpbm_after_activation' );
108 }
109 add_wpbm_action( 'wpbm_activation', 'wpbm_activate' );
110
111
112
113 // Deactivate
114 function wpbm_deactivate() {
115
116 ////////////////////////////////////////////////////////////////////////////
117 // Options
118 ////////////////////////////////////////////////////////////////////////////
119
120 $default_options_to_add = wpbm_get_default_options();
121 foreach ( $default_options_to_add as $default_option_name => $default_option_value) {
122
123 delete_wpbm_option( $default_option_name );
124 }
125
126
127 ////////////////////////////////////////////////////////////////////////////
128 // Widgets
129 ////////////////////////////////////////////////////////////////////////////
130 delete_wpbm_option( 'wpbm_activation_redirect_for_version' );
131
132
133 ////////////////////////////////////////////////////////////////////////////
134 // DB Tables
135 ////////////////////////////////////////////////////////////////////////////
136 global $wpdb;
137 // $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wpbm" );
138
139 // Delete all users item windows states
140 if ( false === $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%wpbm_%'" ) ){ // All users data
141 debuge_error('Error during deleting user meta at DB',__FILE__,__LINE__);
142 die();
143 }
144
145 ////////////////////////////////////////////////////////////////////////////
146 // Other versions Deactivation
147 ////////////////////////////////////////////////////////////////////////////
148 make_wpbm_action('wpbm_other_versions_deactivation');
149 }
150 add_wpbm_action( 'wpbm_deactivation', 'wpbm_deactivate' );
151
152
153 /** Default Options
154 *
155 * $option_name = '';
156 * $options_for_delete = wpbm_get_default_options( $option_name, $is_get_multiuser_general_options );
157 */
158 function wpbm_get_default_options( $option_name = '' ) {
159
160 $is_demo = wpbm_is_this_demo();
161
162 $default_options = array();
163 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
164 // General Settings
165 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
166 // Miscellaneous
167 $default_options[ 'wpbm_start_day_weeek' ] = 0;
168 $default_options[ 'wpbm_date_format' ] = get_option( 'date_format' );
169 $default_options[ 'wpbm_time_format' ] = get_option( 'time_format' );
170 // Advanced
171 $default_options[ 'wpbm_is_not_load_bs_script_in_admin' ] = 'Off';
172 /**
173 $default_options[ 'wpbm_is_not_load_bs_script_in_client' ] = 'Off';
174 $default_options[ 'wpbm_is_load_js_css_on_specific_pages' ] = 'Off';
175 $default_options[ 'wpbm_pages_for_load_js_css' ] = '';
176 */
177
178 $default_options[ 'wpbm_menu_position' ] = ( $is_demo ) ? 'bottom' : 'bottom';
179 // User permissions
180 $default_options[ 'wpbm_user_role_master' ] = ( $is_demo ) ? 'subscriber' : 'editor';
181 //$default_options[ 'wpbm_user_role_addnew' ] = ( $is_demo ) ? 'subscriber' : 'editor';
182 //$default_options[ 'wpbm_user_role_settings' ] = ( $is_demo ) ? 'subscriber' : 'editor';
183 // Position
184
185 // Uninstall
186 $default_options[ 'wpbm_is_delete_if_deactive' ] = ($is_demo) ? 'On' : 'Off';
187
188 $default_options[ 'wpbm_listing_template' ] =
189 '<div class="wpbm-event">' . "\n"
190 . ' <div style="width:35%;float:left;margin-right:5%;">[DATES]</div>' . "\n"
191 . ' <div style="width:60%;float:left;">' . "\n"
192 . ' <h2>[SUMMARY]</h2> <span style="display:none;">[UID]</span>' . "\n"
193 . ' <p class="desciption">[DESCRIPTION]</p>' . "\n"
194 . ' </div>' . "\n"
195 . ' <div style="clear:both;"></div>' . "\n"
196 . '</div>' . "\n"
197 . '<hr />';
198
199 if ( ! empty( $option_name ) ) {
200
201 if ( isset( $default_options[ $option_name ] ) )
202 return $default_options[ $option_name ]; // Return 1 option
203 else
204 return false; // Option does NOT exist
205
206 } else {
207 return $default_options; // Return ALL
208 }
209 }