public static function run() { $instance = self::get_instance(); //register style add_action('wp_enqueue_scripts', function () { if (is_single()) { wp_register_style('qhshop_woocommerce_prettyPhoto', QH_SHOP_PLUGIN_URL . 'scripts/css/woocommerce/prettyPhoto.css'); wp_enqueue_style('qhshop_woocommerce_prettyPhoto'); } wp_register_style('qhshop_woocommerce_layout', QH_SHOP_PLUGIN_URL . 'scripts/css/woocommerce/woocommerce-layout.css'); wp_register_style('qhshop_woocommerce_smallscreen', QH_SHOP_PLUGIN_URL . 'scripts/css/woocommerce/woocommerce-smallscreen.css'); wp_register_style('qhshop_woocommerce', QH_SHOP_PLUGIN_URL . 'scripts/css/woocommerce/woocommerce.css', array('qhshop_woocommerce_layout', 'qhshop_woocommerce_smallscreen')); wp_enqueue_style('qhshop_woocommerce'); wp_register_script('qhshop_js', QH_SHOP_PLUGIN_URL . 'scripts/js/functions.js', array('jquery')); wp_localize_script('qhshop_js', 'qhshop', array('url' => admin_url('admin-ajax.php'))); wp_enqueue_script('qhshop_js'); }); //can thiep body class add_filter('body_class', function ($classes) { $classes[] = 'woocommerce'; $classes[] = 'woocommerce-page'; return $classes; }); add_filter('query_vars', function ($vars) { $vars[] = 'orderby'; return $vars; }); //can thiep single template cua WP add_filter('single_template', function ($single) { global $post; if ($post->post_type == 'product') { if (file_exists(QH_SHOP_PLUGIN_DIR . 'views/frontend/product-single.php')) { return QH_SHOP_PLUGIN_DIR . 'views/frontend/product-single.php'; } } return $single; }); $option = get_option('qhshop_setting'); //shortcode api add_shortcode('qhshop', array($instance, 'shop')); add_shortcode('qhshop-checkout', array($instance, 'checkout')); add_action('template_redirect', function () { self::$errors = self::is_validate(); if (empty(self::$errors) || self::$errors == true) { self::save_order(); } }); return $instance; }
public static function run() { $instance = self::get_instance(); //start session QHShopSession::run(); //start qhshop proudct QHShopProduct::run(); //start shortcode QHShopShortCode::run(); //start setting QHShopSetting::run(); //run widget cart QHShopWidgetCart::run(); //khoi dong order QHShopOrder::run(); //run widget category QHShopWidgetCategory::run(); return $instance; }