constants();
self::$instance->includes();
self::$instance->define_version();
if ( class_exists( 'WPBM_ItemInstall' ) ) { // Check if we need to run Install / Uninstal process.
new WPBM_ItemInstall();
}
// Currently transaltion is loading from hooks from this file ../core/wpbm-translation.php
// add_action('plugins_loaded', array(self::$instance, 'load_textdomain') ); // T r a n s l a t i o n // TODO: Finish here
$is_continue = self::$instance->start(); // Make Ajax, Response or Define item ClASS
if ( $is_continue ) { // Possible Load Admin or Front-End page
self::$instance->js = new WPBM_JS;
self::$instance->css = new WPBM_CSS;
if( is_admin() ) {
add_action( '_admin_menu', array( self::$instance, 'define_admin_menu') ); // Define Menu - _admin_menu - Fires before the administration menu loads in the admin.
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
} else {
add_action( 'wp_enqueue_scripts', array(self::$instance->css, 'load'), 1000000001 ); // Load CSS at front-end side // Enqueue Scripts to All Client pages
add_action( 'wp_enqueue_scripts', array(self::$instance->js, 'load'), 1000000001 ); // Load JavaScript files and define JS varibales at forn-end side
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.
}
}
}
return self::$instance;
}
/** Define Admin Menu items */
public function define_admin_menu(){
$update_count = wpbm_get_number_new_items();
$title = 'oPlgns Panel'; //'ßΘΘĸıŋ';
$title = 'oPlugins Panel';
if ( $update_count > 0 ){
$update_count_title = "" . number_format_i18n($update_count) . "" ;
$title .= $update_count_title;
}
//global $menu;
//if ( current_user_can( ) ) {
//$menu[] = array( '', 'read', 'separator-wpbm', '', 'wp-menu-separator wpbm' );
//}
// debuge($menu);
$wpbm_menu_position = get_wpbm_option( 'wpbm_menu_position' );
switch ( $wpbm_menu_position ) {
case 'top':
$wpbm_menu_position = "3.15";
break;
case 'middle':
global $_wp_last_object_menu; // The index of the last top-level menu in the object menu group
$_wp_last_object_menu++;
$wpbm_menu_position = $_wp_last_object_menu; // 58.9;
break;
case 'bottom':
$wpbm_menu_position = "99.919";
break;
default:
$wpbm_menu_position = "3.15";
break;
}
self::$instance->admin_menu['master'] = new WPBM_Admin_Menus(
'oplugins' , array (
'in_menu' => 'root'
, 'mune_icon_url' => '/assets/img/icon-16x16.png'
, 'menu_title' => $title
, 'menu_title_second' => __('Manage', 'booking-manager') . ' .ics'
, 'page_header' => '...'
, 'browser_header' => __('Manage Data', 'booking-manager')
, 'user_role' => get_wpbm_option( 'wpbm_user_role_master' )
, 'position' => $wpbm_menu_position // 3.3 - top //( 58.9 ) // - middle
/*
(Optional). Positions for Core Menu Items
2 Dashboard
4 Separator
5 Posts
10 Media
15 Links
20 Pages
25 Comments
59 Separator
60 Appearance
65 Plugins
70 Users
75 Tools
80 Settings
99 Separator
*/
)
);
if (0)
self::$instance->admin_menu['new'] = new WPBM_Admin_Menus(
'wpbm-new' , array (
'in_menu' => 'oplugins'
, 'menu_title' => ucwords( __('Add New', 'booking-manager') )
, 'page_header' => ucwords( __('Add New', 'booking-manager') )
, 'browser_header'=> ucwords( __('Files', 'booking-manager') )
, 'user_role' => get_wpbm_option( 'wpbm_user_role_addnew' )
)
);
if (0)
self::$instance->admin_menu['settings'] = new WPBM_Admin_Menus(
'wpbm-settings' , array (
'in_menu' => 'oplugins'
, 'menu_title' => __('Settings', 'booking-manager')
, 'page_header' => __('General Settings', 'booking-manager')
, 'browser_header'=> __('Settings', 'booking-manager')
, 'user_role' => get_wpbm_option( 'wpbm_user_role_settings' )
)
);
}
/** Get Menu Object
*
* @param type - menu type
* @return boolean
*/
public function get_menu_object( $type ) {
if ( isset( self::$instance->admin_menu[ $type ] ) )
return self::$instance->admin_menu[ $type ];
else
return false;
}
// Define constants
private function constants() {
require_once WPBM_PLUGIN_DIR . '/core/wpbm-constants.php' ;
}
// Include Files
private function includes() {
require_once WPBM_PLUGIN_DIR . '/core/wpbm-include.php' ;
}
private function define_version() {
// GET VERSION NUMBER
$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' );
if (!defined('WPBM_VERSION')) define('WPBM_VERSION', $plugin_data['Version'] );
}
/**
* Load Plugin Locale.
* Look firstly in Global folder: /wp-content/languages/plugin_name
* then in Local folder: /wp-content/plugins/plugin_name/languages/
* and afterwards load default : load_plugin_textdomain( ...
*/
public function load_textdomain() {
// Set filter for plugin's languages directory
$plugin_lang_dir = WPBM_PLUGIN_DIR . '/languages/';
$plugin_lang_dir = apply_filters( 'wpbm~languages_directory', $plugin_lang_dir );
// Plugin locale filter
$locale = apply_filters( 'plugin_locale', get_locale() , 'booking-manager');
$mofile = sprintf( '%1$s-%2$s.mo', 'booking-manager', $locale );
// Setup paths to current locale file
$mofile_local = $plugin_lang_dir . $mofile;
$mofile_global = WP_LANG_DIR . '/booking-manager/' . $mofile;
if ( file_exists( $mofile_global ) ) {
// Look in global /wp-content/languages/plugin_name folder
load_textdomain( 'booking-manager', $mofile_global );
} elseif ( file_exists( $mofile_local ) ) {
// Look in local /wp-content/plugins/plugin_name/languages/ folder
load_textdomain( 'booking-manager', $mofile_local );
} else {
// Load the default language files
load_plugin_textdomain( 'booking-manager', false, $plugin_lang_dir );
}
}
// Cloning instances of the class is forbidden
public function __clone() {
_doing_it_wrong( __FUNCTION__, __( 'Action is not allowed!' ), '1.0' );
}
// Unserializing instances of the class is forbidden
public function __wakeup() {
_doing_it_wrong( __FUNCTION__, __( 'Action is not allowed!' ), '1.0' );
}
// Initialization
private function start(){
if ( ( defined( 'DOING_AJAX' ) ) && ( DOING_AJAX ) ){ // New A J A X R e s p o n d e r
require_once WPBM_PLUGIN_DIR . '/core/wpbm-ajax.php'; // Ajax
return false;
} else { // Usual Loading of plugin
// We are having Response, its executed in other file: wpbm-response.php
if ( WPBM_RESPONSE )
return false;
////////////////////////////////////////////////////////////////////
}
return true;
}
}
else: // Its seems that some instance of Booking Manager still activted!!!
function wpbm_show_activation_error() {
$message_type = 'error';
$title = __( 'Error' , 'booking-manager') . '!';
$message = __( 'Please deactivate previous old version of' , 'booking-manager') . ' ' . 'booking-manager';
$wpbm_version_num = get_option( 'wpbm_version_num');
if ( ! empty( $wpbm_version_num ) )
$message .= ' ' . $wpbm_version_num . '';
$is_delete_if_deactive = get_wpbm_option( 'wpbm_is_delete_if_deactive' ); // check
if ( $is_delete_if_deactive == 'On' ) {
$message .= '
Warning! ' . 'All plugin data will be deleted when plugin had deactivated.' . ' '
. sprintf( 'If you want to save your plugin data, please uncheck the %s"Delete plugin data"%s at the', '', '') . ' ' . __( 'Settings' , 'booking-manager') . '.';
}
$message_content = '';
$message_content .= '
';
$qq_kk = 0;
$total_time = 0;
$total_num = 0;
foreach ( $wpdb->queries as $qq_k => $qq ) {
if (
( strpos( $qq[0], 'booking-manager') !== false )
) {
if ( $qq[1] > 0.002 ) { echo ''; }
debuge($qq_kk++, $qq);
$total_time += $qq[1];
$total_num++;
if ( $qq[1] > 0.002 ) { echo ''; }
}
}
echo '[' . $total_num . '/' . $total_time . '] WPBM Requests TOTAL TIME
';
echo '';
echo '' . get_num_queries(). '/' . timer_stop(0, 3) . 'qps
';
echo '';
echo "";
?>