1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
<?php
if( ! class_exists( 'bkap_dokan_class' ) ) {
class bkap_dokan_class {
function __construct() {
self::bkap_dokan_include_dependencies();
add_filter( 'dokan_get_dashboard_nav', array( &$this, 'bkap_dokan_add_booking_nav' ) );
add_filter( 'dokan_query_var_filter', array( &$this, 'bkap_dokan_query_var_filter' ) );
add_action( 'dokan_rewrite_rules_loaded', array( $this, 'bkap_add_rewrite_rules' ) );
add_action( 'dokan_load_custom_template', array( &$this, 'bkap_dokan_include_template' ), 10, 1 );
add_action( 'admin_init', array( &$this, 'bkap_remove_menu' ) );
}
public function bkap_remove_menu() {
if ( current_user_can( 'seller' ) ) {
remove_menu_page( 'edit.php?post_type=bkap_booking' );
}
}
public static function bkap_dokan_include_dependencies() {
include_once( BKAP_VENDORS_INCLUDES_PATH . 'dokan/class-bkap-dokan-products.php' );
include_once( BKAP_VENDORS_INCLUDES_PATH . 'dokan/class-bkap-dokan-orders.php' );
include_once( BKAP_VENDORS_INCLUDES_PATH . 'dokan/class-bkap-dokan-calendar.php' );
}
function bkap_dokan_add_booking_nav( $urls ) {
$urls['bkap_dokan_booking'] = array(
'title' => __( 'Booking', 'woocommerce-booking'),
'icon' => '<i class="wp-menu-image dashicons-before dashicons-calendar-alt"></i>',
'url' => dokan_get_navigation_url( 'bkap_dokan_booking' ),
'pos' => '51'
);
return $urls;
}
public function bkap_dokan_query_var_filter( $url_array ) {
$url_array[] = 'bkap_dokan_booking';
return $url_array;
}
public function bkap_add_rewrite_rules() {
flush_rewrite_rules( true );
}
public function bkap_dokan_include_template( $query_vars ) {
if ( isset( $query_vars['bkap_dokan_booking'] ) ) {
wc_get_template(
'dokan/bkap-dokan-booking.php',
array( ),
'woocommerce-booking/',
BKAP_VENDORS_TEMPLATE_PATH );
}
}
}
}
return new bkap_dokan_class();