%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/friendstravel.al/wp-content/plugins/travel-booking/
Upload File :
Create Path :
Current File : /var/www/html/friendstravel.al/wp-content/plugins/travel-booking/travel-booking.php

<?php

/**
 * Plugin Name: Travel booking
 * Version: 1.0.9
 * Description: Option for Tour
 * Author: Physcode
 * Author URI: http://physcode.com/
 *  *
 * Text Domain: travel-booking
 * Domain Path: /languages/
 */
class TravelBookingPhyscode {
	private static $instance;

	public static function instance() {
		if ( ! self::$instance ) {
			include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
			if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
				self::$instance = new self();
				self::$instance->init();
				self::init_hook();
			} else {
				add_action( 'admin_notices', array( __CLASS__, 'show_note_errors_install_plugin_woocomerce' ) );
			}
		}

		return self::$instance;
	}

	public function __construct() {
		$this->plugin_defines();
		if ( is_admin() ) {
			add_action( 'admin_enqueue_scripts', array( $this, 'load_enqueue_scripts_on_admin' ) );
		} else {
			add_action( 'wp_enqueue_scripts', array( $this, 'load_enqueue_scripts_on_frontend' ) );
		}
	}

	protected function plugin_defines() {
		define( 'TOUR_BOOKING_PHYS_PATH', trailingslashit( WP_PLUGIN_DIR . '/' . str_replace( basename( __FILE__ ), "", plugin_basename( __FILE__ ) ) ) );
		define( 'TOUR_BOOKING_PHYS_URL', plugin_dir_url( __FILE__ ) );
		define( 'TB_PHYS_TEMPLATE_PATH_DEFAULT', TOUR_BOOKING_PHYS_PATH . 'templates' . DIRECTORY_SEPARATOR );
	}

	static function register_media_categories() {
		$args = array(
			'hierarchical'      => true,
			'labels'            => array(
				'name'          => __( 'Media Categories', 'travel-booking' ),
				'singular_name' => __( 'Media Category', 'travel-booking' ),
			),
			'show_ui'           => true,
			'show_admin_column' => true,
			'query_var'         => false,
		);
		register_taxonomy( 'media_category', array( 'attachment' ), $args );
	}

	protected function init() {
		// Set up localisation.
		$this->load_plugin_textdomain();
		// add product type Tour
		include_once( 'inc/product-type-tour.php' );

		// shortcode
		//include_once( 'inc/shortcode/register_shortcode.php' );

		// add Tour Tab to Woo settings
		include_once( 'inc/tour_tab_settings.php' );

		// widget
		include_once( 'inc/widgets.php' );

		// sidebar
		include_once( 'inc/sidebar.php' );

		// get template path
		include_once( 'inc/tb-get-template.php' );

		// get template loader
		include_once( 'inc/override-theme-woo.php' );

		if ( is_admin() ) {
			// add tab Booking
			include_once( 'inc/tab-booking.php' );

			// show booking date on order
			include_once( 'inc/show-booking-date-order.php' );
		} else {
			$this->load_template_tour_frontend();

			// ajax
			include_once( 'inc/ajax_frontend.php' );
			add_action( 'template_redirect', array( $this, 'do_tb_ajax' ), 0 );

			include_once( 'inc/tb_query_phys.php' );
		}

		include_once( 'inc/rewrite_url_tour.php' );
	}

	protected static function init_hook() {
		// Register Taxonomy
		add_action( 'after_setup_theme', array( __CLASS__, 'register_taxonomies' ), 20 );
		add_action( 'after_setup_theme', array( __CLASS__, 'register_media_categories' ), 20 );
	}

	public static function register_taxonomies() {
		$permalink_tour_category_base_option = get_option( 'permalink_tour_category_base' );
		$labels                              = array(
			'name'              => __( 'Tour Types', 'travel-booking' ),
			'singular_name'     => __( 'Tour Type', 'travel-booking' ),
			'search_items'      => __( 'Search Tour Types', 'travel-booking' ),
			'all_items'         => __( 'All Tour Types', 'travel-booking' ),
			'parent_item'       => __( 'Parent Tour Type', 'travel-booking' ),
			'parent_item_colon' => __( 'Parent Tour Type:', 'travel-booking' ),
			'edit_item'         => __( 'Edit Tour Type', 'travel-booking' ),
			'update_item'       => __( 'Update Tour Type', 'travel-booking' ),
			'add_new_item'      => __( 'Add New Tour Type', 'travel-booking' ),
			'new_item_name'     => __( 'New Tour Type Name', 'travel-booking' ),
			'menu_name'         => __( 'Tour Type', 'travel-booking' ),
		);

		$args = array(
			'hierarchical'      => true,
			'labels'            => $labels,
			'show_ui'           => true,
			'show_admin_column' => true,
			'query_var'         => true,
			'rewrite'           => array( 'slug' => $permalink_tour_category_base_option != '' ? $permalink_tour_category_base_option : 'tour-category' ),
		);

		register_taxonomy( 'tour_phys', array( 'product' ), $args );
	}

	/**
	 * Load Localisation files.
	 *
	 * Note: the first-loaded translation file overrides any following ones if the same translation is present.
	 */
	public function load_plugin_textdomain() {
		$locale = apply_filters( 'plugin_locale', get_locale(), 'travel-booking' );
		load_textdomain( 'travel-booking', WP_LANG_DIR . '/travel-booking/travel-booking-' . $locale . '.mo' );
		load_plugin_textdomain( 'travel-booking', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
	}

	function do_tb_ajax() {
		global $wp_query;
		if ( ! empty( $_GET['tb-ajax'] ) ) {
			$wp_query->set( 'tb-ajax', sanitize_text_field( $_GET['tb-ajax'] ) );
		}

		if ( $action = $wp_query->get( 'tb-ajax' ) ) {
			do_action( 'tb_ajax_' . sanitize_text_field( $action ) );
			die();
		}
	}

	function load_enqueue_scripts_on_admin() {
		// style
		wp_register_style( 'style-tour-booking-tab', TOUR_BOOKING_PHYS_URL . 'assets/css/admin/tab-booking.css' );
		wp_enqueue_style( 'style-tour-booking-tab' );

		// script
		wp_register_script( 'tour-booking-js', TOUR_BOOKING_PHYS_URL . 'assets/js/admin/booking.js' );
		wp_enqueue_script( 'tour-booking-js' );
	}

	function load_enqueue_scripts_on_frontend() {
		// style
		wp_enqueue_style( 'style-tour-booking-jq-ui-css', 'https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css' );
		wp_enqueue_style( 'style-tour-booking-css', TOUR_BOOKING_PHYS_URL . 'assets/css/frontend/booking.css' );

		// script
		if ( wp_script_is( 'jquery' ) ) {
			wp_enqueue_script( 'tour-booking-jquery-cookie', TOUR_BOOKING_PHYS_URL . 'assets/js/frontend/jquery.cookie.js' );
		} else {
			wp_enqueue_script( 'tour-booking-jquery', 'https://code.jquery.com/jquery-3.1.1.min.js' );
			wp_enqueue_script( 'tour-booking-jquery-cookie', TOUR_BOOKING_PHYS_URL . 'assets/js/frontend/jquery.cookie.js' );
		}
		wp_enqueue_script( 'tour-booking-jquery-ui', 'https://code.jquery.com/ui/1.12.1/jquery-ui.js' );
		wp_enqueue_script( 'tour-booking-js-frontend', TOUR_BOOKING_PHYS_URL . 'assets/js/frontend/booking.js', array(), false, true );
	}

	function load_template_tour_frontend() {
		add_action( 'tour_booking_single_title', 'tour_booking_single_title' );
		add_action( 'tour_booking_single_ratting', 'tour_booking_single_ratting' );
		add_action( 'tour_booking_single_code', 'tour_booking_single_code' );
		add_action( 'tour_booking_single_price', 'tour_booking_single_price' );
		add_action( 'tour_booking_single_booking', 'tour_booking_single_booking' );
		add_action( 'tour_booking_single_gallery', 'tour_booking_single_gallery' );
		add_action( 'tour_booking_default_product_tabs', 'tour_booking_default_product_tabs' );
		add_action( 'tour_booking_single_information', 'tour_booking_single_information' );
		add_action( 'tour_booking_single_related', 'tour_booking_single_related' );
	}

	public function show_note_errors_install_plugin_woocomerce() {
		?>
		<div class="notice notice-error is-dismissible">
			<p><?php _e( 'Please active plguin Woocomerce', 'travel-booking' ); ?></p>
		</div>
		<?php
	}
}

$travelBookingPhyscode = TravelBookingPhyscode::instance();

Zerion Mini Shell 1.0