PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.1.21
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.1.21
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.1.21, at core/wpbm-activation.php

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