PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / trunk
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar vtrunk
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 2.0.23 All 54 releases
booking-manager / core / wpbm.php

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

331 lines 14.3 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 Core
6 * @category Items
7 *
8 * @author wpdevelop
9 * @link https://oplugins.com/
10 * @email info@oplugins.com
11 *
12 * @modified 2014.07.29
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16
17
18 if ( ! class_exists( 'WPBM_Init' ) ) :
19
20
21 // General Init Class
22 final class WPBM_Init {
23
24 static private $instance = NULL;
25 public $admin_menu; // Define Menu items
26 public $js; // JS to load
27 public $css; // CSS to load
28
29
30 /** Get Single Instance of this Class and Init Plugin */
31 public static function init() {
32
33 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPBM_Init ) ) {
34
35 self::$instance = new WPBM_Init;
36 self::$instance->constants();
37 self::$instance->includes();
38 self::$instance->define_version();
39
40
41 if ( class_exists( 'WPBM_ItemInstall' ) ) { // Check if we need to run Install / Uninstal process.
42 new WPBM_ItemInstall();
43 }
44
45 // Currently transaltion is loading from hooks from this file ../core/wpbm-translation.php
46 // add_action('plugins_loaded', array(self::$instance, 'load_textdomain') ); // T r a n s l a t i o n // TODO: Finish here
47
48 $is_continue = self::$instance->start(); // Make Ajax, Response or Define item ClASS
49
50 if ( $is_continue ) { // Possible Load Admin or Front-End page
51
52 self::$instance->js = new WPBM_JS;
53 self::$instance->css = new WPBM_CSS;
54
55 if( is_admin() ) {
56
57 add_action( '_admin_menu', array( self::$instance, 'define_admin_menu') ); // Define Menu - _admin_menu - Fires before the administration menu loads in the admin.
58 add_action( 'admin_footer', 'wpbm_print_js', 50 ); // Load my Queued JavaScript Code at the footer of the Admin Panel page. Executed in ALL Admin Menu Pages
59
60 } else {
61
62 add_action( 'wp_enqueue_scripts', array(self::$instance->css, 'load'), 1000000001 ); // Load CSS at front-end side // Enqueue Scripts to All Client pages
63 add_action( 'wp_enqueue_scripts', array(self::$instance->js, 'load'), 1000000001 ); // Load JavaScript files and define JS varibales at forn-end side
64 add_action( 'wp_footer', 'wpbm_print_js', 50 ); // Load my Queued JavaScript Code at the footer of the page, if executed "wp_footer" hook at the Theme.
65 }
66 }
67
68 }
69 return self::$instance;
70 }
71
72
73 /** Define Admin Menu items */
74 public function define_admin_menu(){
75
76 $update_count = wpbm_get_number_new_items();
77
78 $title = 'oPlgns Panel'; //'&#223;<span style="font-size:0.75em;">&#920;&#920;</span>&kgreen;&imath;&eng;';
79 $title = 'oPlugins Panel';
80 if ( $update_count > 0 ){
81 $update_count_title = "<span class='update-plugins count-$update_count' title=''><span class='update-count bk-update-count'>" . number_format_i18n($update_count) . "</span></span>" ;
82 $title .= $update_count_title;
83 }
84
85
86 //global $menu;
87 //if ( current_user_can( ) ) {
88 //$menu[] = array( '', 'read', 'separator-wpbm', '', 'wp-menu-separator wpbm' );
89 //}
90 // debuge($menu);
91
92 $wpbm_menu_position = get_wpbm_option( 'wpbm_menu_position' );
93 switch ( $wpbm_menu_position ) {
94 case 'top':
95 $wpbm_menu_position = "3.15";
96 break;
97 case 'middle':
98 global $_wp_last_object_menu; // The index of the last top-level menu in the object menu group
99 $_wp_last_object_menu++;
100 $wpbm_menu_position = $_wp_last_object_menu; // 58.9;
101 break;
102 case 'bottom':
103 $wpbm_menu_position = "99.919";
104 break;
105 default:
106 $wpbm_menu_position = "3.15";
107 break;
108 }
109
110
111 self::$instance->admin_menu['master'] = new WPBM_Admin_Menus(
112 'oplugins' , array (
113 'in_menu' => 'root'
114 , 'mune_icon_url' => '/assets/img/icon-16x16.png'
115 , 'menu_title' => $title
116 , 'menu_title_second' => __('Manage', 'booking-manager') . ' .ics'
117 , 'page_header' => '...'
118 , 'browser_header' => __('Manage Data', 'booking-manager')
119 , 'user_role' => get_wpbm_option( 'wpbm_user_role_master' )
120 , 'position' => $wpbm_menu_position // 3.3 - top //( 58.9 ) // - middle
121 /*
122 (Optional). Positions for Core Menu Items
123 2 Dashboard
124 4 Separator
125 5 Posts
126 10 Media
127 15 Links
128 20 Pages
129 25 Comments
130 59 Separator
131 60 Appearance
132 65 Plugins
133 70 Users
134 75 Tools
135 80 Settings
136 99 Separator
137 */
138 )
139
140 );
141 if (0)
142 self::$instance->admin_menu['new'] = new WPBM_Admin_Menus(
143 'wpbm-new' , array (
144 'in_menu' => 'oplugins'
145 , 'menu_title' => ucwords( __('Add New', 'booking-manager') )
146 , 'page_header' => ucwords( __('Add New', 'booking-manager') )
147 , 'browser_header'=> ucwords( __('Files', 'booking-manager') )
148 , 'user_role' => get_wpbm_option( 'wpbm_user_role_addnew' )
149 )
150 );
151
152 if (0)
153 self::$instance->admin_menu['settings'] = new WPBM_Admin_Menus(
154 'wpbm-settings' , array (
155 'in_menu' => 'oplugins'
156 , 'menu_title' => __('Settings', 'booking-manager')
157 , 'page_header' => __('General Settings', 'booking-manager')
158 , 'browser_header'=> __('Settings', 'booking-manager')
159 , 'user_role' => get_wpbm_option( 'wpbm_user_role_settings' )
160 )
161 );
162
163 }
164
165
166
167 /** Get Menu Object
168 *
169 * @param type - menu type
170 * @return boolean
171 */
172 public function get_menu_object( $type ) {
173
174 if ( isset( self::$instance->admin_menu[ $type ] ) )
175 return self::$instance->admin_menu[ $type ];
176 else
177 return false;
178 }
179
180
181 // Define constants
182 private function constants() {
183 require_once WPBM_PLUGIN_DIR . '/core/wpbm-constants.php' ;
184 }
185
186
187 // Include Files
188 private function includes() {
189 require_once WPBM_PLUGIN_DIR . '/core/wpbm-include.php' ;
190 }
191
192
193 private function define_version() {
194
195 // GET VERSION NUMBER
196 $plugin_data = get_file_data_wpdev( WPBM_FILE , array( 'Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path' ) , 'plugin' );
197 if (!defined('WPBM_VERSION')) define('WPBM_VERSION', $plugin_data['Version'] );
198 }
199
200
201 /**
202 * Load Plugin Locale.
203 * Look firstly in Global folder: /wp-content/languages/plugin_name
204 * then in Local folder: /wp-content/plugins/plugin_name/languages/
205 * and afterwards load default : load_plugin_textdomain( ...
206 */
207 public function load_textdomain() {
208 // Set filter for plugin's languages directory
209 $plugin_lang_dir = WPBM_PLUGIN_DIR . '/languages/';
210 $plugin_lang_dir = apply_filters( 'wpbm~languages_directory', $plugin_lang_dir );
211
212 // Plugin locale filter
213 $locale = apply_filters( 'plugin_locale', get_locale() , 'booking-manager');
214 $mofile = sprintf( '%1$s-%2$s.mo', 'booking-manager', $locale );
215
216 // Setup paths to current locale file
217 $mofile_local = $plugin_lang_dir . $mofile;
218 $mofile_global = WP_LANG_DIR . '/booking-manager/' . $mofile;
219
220 if ( file_exists( $mofile_global ) ) {
221 // Look in global /wp-content/languages/plugin_name folder
222 load_textdomain( 'booking-manager', $mofile_global );
223
224 } elseif ( file_exists( $mofile_local ) ) {
225 // Look in local /wp-content/plugins/plugin_name/languages/ folder
226 load_textdomain( 'booking-manager', $mofile_local );
227
228 } else {
229 // Load the default language files
230 load_plugin_textdomain( 'booking-manager', false, $plugin_lang_dir );
231 }
232 }
233
234
235 // Cloning instances of the class is forbidden
236 public function __clone() {
237
238 _doing_it_wrong( __FUNCTION__, esc_html__( 'Action is not allowed!', 'booking-manager' ), '1.0' );
239 }
240
241
242 // Unserializing instances of the class is forbidden
243 public function __wakeup() {
244
245 _doing_it_wrong( __FUNCTION__, esc_html__( 'Action is not allowed!', 'booking-manager' ), '1.0' );
246 }
247
248
249 // Initialization
250 private function start(){
251
252 if ( ( defined( 'DOING_AJAX' ) ) && ( DOING_AJAX ) ){ // New A J A X R e s p o n d e r
253
254 require_once WPBM_PLUGIN_DIR . '/core/wpbm-ajax.php'; // Ajax
255
256 return false;
257 } else { // Usual Loading of plugin
258
259 // We are having Response, its executed in other file: wpbm-response.php
260 if ( WPBM_RESPONSE )
261 return false;
262
263 ////////////////////////////////////////////////////////////////////
264 }
265 return true;
266 }
267
268 }
269
270 else: // Its seems that some instance of Booking Manager still activted!!!
271
272
273 function wpbm_show_activation_error() {
274
275 $message_type = 'error';
276 $title = esc_html__( 'Error' , 'booking-manager') . '!';
277 $message = esc_html__( 'Please deactivate previous old version of' , 'booking-manager') . ' ' . 'booking-manager';
278
279 $wpbm_version_num = get_option( 'wpbm_version_num');
280 if ( ! empty( $wpbm_version_num ) )
281 $message .= ' <strong>' . $wpbm_version_num . '</strong>';
282
283
284 $is_delete_if_deactive = get_wpbm_option( 'wpbm_is_delete_if_deactive' ); // check
285
286 if ( $is_delete_if_deactive == 'On' ) {
287
288 $message .= '<br/><br/> <strong>Warning!</strong> ' . 'All plugin data will be deleted when plugin had deactivated.' . ' '
289 . sprintf( 'If you want to save your plugin data, please uncheck the %s"Delete plugin data"%s at the', '<strong>', '</strong>') . ' ' . esc_html__( 'Settings' , 'booking-manager') . '.';
290 }
291
292 $message_content = '';
293
294 $message_content .= '<div class="clear"></div>';
295
296 $message_content .= '<div class="updated wpbm-settings-notice notice-' . esc_attr( $message_type ) . ' ' . esc_attr( $message_type ) . '" style="text-align:left;padding:10px;">';
297
298 if ( ! empty( $title ) )
299 $message_content .= '<strong>' . esc_js( $title ) . '</strong> ';
300
301 $message_content .= html_entity_decode( esc_js( $message ) ,ENT_QUOTES) ;
302
303 $message_content .= '</div>';
304
305 $message_content .= '<div class="clear"></div>';
306
307 echo $message_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
308 }
309
310 add_action('admin_notices', 'wpbm_show_activation_error');
311
312 return; // Exit
313
314 endif;
315
316
317 /**
318 * The main function responsible for returning the one true Instance to functions everywhere.
319 *
320 * Example: <?php $wpbm = WPBM(); ?>
321 */
322 function WPBM() {
323 return WPBM_Init::init();
324 }
325
326
327
328 // Start
329 WPBM();
330
331