<?php
 /**
 * Plugin Name: FoodBoxBooker
 * Plugin URI:
 * Description: FoodBoxBooker - Professional tiffin service management. FoodBoxBooker plugin for online book FoodBox, anytime, anywhere.FoodBox Booker is professional tiffin service management plugin.
 * Version: 1.0.5
 * Requires PHP: 7.4
 * Author: Themetechmount
 * Author URI: https://www.themetechmount.com
 * Text Domain: foodboxbooker
 * Domain Path: /languages
 * License: GPLv3
 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
 */
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}
define( 'FBBTTM_VERSION', '1.0.5' );
define( 'FBBTTM_DIR', trailingslashit( dirname( __FILE__ ) ) );
define( 'FBBTTM_TEMPLATE_DIR', FBBTTM_DIR.'templates/'  );
define( 'FBBTTM_URL', plugins_url( '', __FILE__ ) );
define( 'FBBTTM_PATH', plugin_dir_path( __FILE__ ) );

define( 'FBBTTM_HOME_URL', home_url() );
define( 'FBBTTM_MENU_URL', admin_url() . 'admin.php?page=fbbttm' );
define( 'FBBTTM_MAIN_FILE', plugin_basename(__FILE__) );

define( 'FBBTTM_CPT', 'fbbttm_fooditems' );
define( 'FBBTTM_CART', 'fbbttm_foodboxbooker_cart' );

global $fbbttm_ajaxurl;
$fbbttm_ajaxurl = admin_url('admin-ajax.php');

/*Load helper file*/
global $fbbttm_helperobj,$fbbttm_cartobj,$fbbttm_checkoutobj,$fbbttm_orderinfoobj,$availmethod,$emailtemp,$fbbttm_myaccountobj, $fbbttm_pageconfigobj,$fbbttm_tabledataobj,$fbbttm_emailobj;

if( file_exists(FBBTTM_DIR . '/main/foodboxbooker-main.php') ){
    require_once FBBTTM_DIR . '/main/foodboxbooker-main.php';
}

register_uninstall_hook(FBBTTM_URL, 'fbbttm_uninstall' );



if( file_exists(FBBTTM_DIR . '/helper/foodboxbooker-data.php') ){
	require_once FBBTTM_DIR . '/helper/foodboxbooker-data.php';
	$fbbttm_helperobj = new fbbttmData();	
}

if( file_exists(FBBTTM_DIR . '/helper/foodboxbooker-cart.php') ){
	require_once FBBTTM_DIR . '/helper/foodboxbooker-cart.php';
	$fbbttm_cartobj = new fbbttmCart();	
}

if( file_exists(FBBTTM_DIR . '/helper/foodboxbooker-checkout.php') ){
	require_once FBBTTM_DIR . '/helper/foodboxbooker-checkout.php';
	$fbbttm_checkoutobj = new fbbttmCheckout();	
}

if( file_exists(FBBTTM_DIR . '/helper/foodboxbooker-orderinfo.php') ){
	require_once FBBTTM_DIR . '/helper/foodboxbooker-orderinfo.php';
	$fbbttm_orderinfoobj = new fbbttmOrderinfo();	
}

if( file_exists(FBBTTM_DIR . '/helper/foodboxbooker-tabledata.php') ){
	require_once FBBTTM_DIR . '/helper/foodboxbooker-tabledata.php';
	$fbbttm_tabledataobj = new fbbttmTabledata();	
}

if( file_exists(FBBTTM_DIR . '/helper/foodboxbooker-emails.php') ){
	require_once FBBTTM_DIR . '/helper/foodboxbooker-emails.php';
	$fbbttm_emailobj = new fbbttmEmails();	
}

if( file_exists(FBBTTM_DIR . '/helper/foodboxbooker-myaccount.php') ){
	require_once FBBTTM_DIR . '/helper/foodboxbooker-myaccount.php';
	$fbbttm_myaccountobj = new fbbttmMyaccount();	
}

if( file_exists(FBBTTM_DIR . '/admin/config/foodboxbooker-pageconfig.php') ){
 	require_once FBBTTM_DIR . '/admin/config/foodboxbooker-pageconfig.php';
 	$fbbttm_pageconfigobj = new fbbttmPageconfig();	
}

if ( ! function_exists( 'is_plugin_active' ) ) {
    require_once ABSPATH . 'wp-admin/includes/plugin.php';
}

if ( is_plugin_active( 'foodboxbooker/foodboxbooker.php' ) ) {
	if( file_exists(FBBTTM_DIR . '/helper/foodboxbooker-defaultconfig.php') ){
		require_once FBBTTM_DIR . '/helper/foodboxbooker-defaultconfig.php';
	}
}

if( file_exists(FBBTTM_DIR . '/main/config/foodboxbooker-page.php') ){
 	require_once FBBTTM_DIR . '/main/config/foodboxbooker-page.php';
}
if( file_exists(FBBTTM_DIR . '/main/foodboxbooker-functionality.php') ){
 	require_once FBBTTM_DIR .'/main/foodboxbooker-functionality.php';
}

/*Register custom post type which require for this plugin*/
 require_once FBBTTM_DIR . 'custom-post-types/foodboxbooker-fooditems.php';

/**
 *  Shortcodes 
 */
require_once FBBTTM_DIR . '/main/foodboxbooker-shortcodes.php';


function fbbttm_foodboxbooker_scripts_styles() {

	$screen = get_current_screen();
	wp_enqueue_script( 'foodboxbooker-custom', FBBTTM_URL . '/assets/js/foodboxbooker_custom.js', array( 'jquery' ),FBBTTM_VERSION);
	wp_enqueue_script('foodboxbooker-search-script', FBBTTM_URL . '/assets/js/foodboxbooker_custom_script.js', array('jquery'), FBBTTM_VERSION,true);
	wp_enqueue_script( 'bootstrap-foodboxbookerjs', FBBTTM_URL . '/assets/js/bootstrap.js', array( 'jquery' ) , FBBTTM_VERSION);
	wp_enqueue_style( 'foodboxbooker-css', FBBTTM_URL . '/assets/css/foodboxbooker_css.css', array(), FBBTTM_VERSION );
	wp_enqueue_style( 'foodboxbooker-variables', FBBTTM_URL . '/assets/css/foodboxbooker_variables.css', array(), FBBTTM_VERSION );
	wp_enqueue_style( 'animate', FBBTTM_URL . '/assets/css/animate.css', array(), FBBTTM_VERSION );
	wp_enqueue_style( 'bootstrap-foodboxbooker', FBBTTM_URL . '/assets/css/bootstrap.css', array(), FBBTTM_VERSION );
	wp_enqueue_style( ' add_google_fonts ', 'https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap', false );
	// iconset-fontawesome
	wp_enqueue_style( 'font-awesome', FBBTTM_URL .'/assets/font-awesome/css/font-awesome.min.css');
	wp_enqueue_style( 'adminfbbcss', FBBTTM_URL . '/assets/css/foodboxbooker_admincomman.css', array(), FBBTTM_VERSION );
	wp_localize_script('foodboxbooker-custom', 
	 	'ajax_object', array('ajax_url' => admin_url('admin-ajax.php'),
        'nonce'    => wp_create_nonce( 'fbbttm_nonce_action' ),
    	));
}

add_action( 'admin_enqueue_scripts', 'fbbttm_foodboxbooker_scripts_styles' );


function fbbttm_foodboxbooker_styles() {
	wp_enqueue_style( 'foodboxbooker-front', FBBTTM_URL . '/assets/css/foodboxbooker_front.css', array(), FBBTTM_VERSION );
	wp_enqueue_style( 'foodboxbooker-rtl-front', FBBTTM_URL . '/assets/css/foodboxbooker_front_rtl.css', array(), FBBTTM_VERSION );
	wp_enqueue_style( 'foodboxbooker-variables', FBBTTM_URL . '/assets/css/foodboxbooker_variables.css', array(), FBBTTM_VERSION );
	
	
	wp_enqueue_style( 'bootstrap-foodboxbooker', FBBTTM_URL . '/assets/css/bootstrap.css', array(), FBBTTM_VERSION );
	wp_enqueue_style( 'bootstrap-rtl-foodboxbooker', FBBTTM_URL . '/assets/css/bootstrap-rtl.css', array(), FBBTTM_VERSION );
	wp_enqueue_style( 'add_google_fonts', 'https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap', false );
	// fontawesome
	wp_enqueue_style( 'font-awesome', FBBTTM_URL .'/assets/font-awesome/css/font-awesome.min.css' );
	
	wp_enqueue_script( 'foodboxbooker-frontcustom', FBBTTM_URL . '/assets/js/foodboxbooker_frontcustom.js', array( 'jquery' ) );
	
	  wp_localize_script('foodboxbooker-frontcustom', 
	 	'ajax_object', array('ajax_url' => admin_url('admin-ajax.php'),
        'nonce'    => wp_create_nonce( 'fbbttm_nonce_action' ),
    	));

}

add_action('wp_enqueue_scripts', 'fbbttm_foodboxbooker_styles');