version ); if ( ! class_exists( 'woocommerce' ) ) { add_action( 'admin_notices', array( $this, 'install_woocommerce_admin_notice' ) ); return false; } if ( is_admin() ) { include_once 'includes/admin-side.php'; } $this->update_14_version(); add_filter( 'woocommerce_locate_template', array( $this, 'woocommerce_locate_template' ), 30, 3 ); $this->adjust_hooks(); add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) ); add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); include_once 'includes/class-wmsc-compatibilities.php'; } /** * Modify the default WooCommerce hooks */ public function adjust_hooks() { // Remove login messages. remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 ); remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); // Split the `Order` and the `Payment` tabs. remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 ); remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 ); add_action( 'wpmc-woocommerce_order_review', 'woocommerce_order_review', 20 ); add_action( 'wpmc-woocommerce_checkout_payment', 'woocommerce_checkout_payment', 10 ); // Split the `woocommerce_before_checkout_form`. remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 ); remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); add_action( 'wpmc-woocommerce_checkout_login_form', 'woocommerce_checkout_login_form', 10 ); add_action( 'wpmc-woocommerce_checkout_coupon_form', 'woocommerce_checkout_coupon_form', 10 ); // Add the content functions to the steps. add_action( 'wmsc_step_content_login', 'wmsc_step_content_login', 10 ); add_action( 'wmsc_step_content_shipping', 'wmsc_step_content_shipping', 10 ); add_action( 'wmsc_step_content_billing', 'wmsc_step_content_billing', 10 ); } /** * Load the form-checkout.php template from this plugin. * * @param string $template Template name. * @param string $template_name Template name. * @param string $template_path Template path. (default: ''). * @return string */ public function woocommerce_locate_template( $template, $template_name, $template_path ) { if ( 'checkout/form-checkout.php' !== $template_name ) { return $template; } $template = plugin_dir_path( __FILE__ ) . 'includes/form-checkout.php'; return $template; } /** * Enqueue the JS and CSS assets */ public function wp_enqueue_scripts() { if ( ! is_checkout() ) { return; } $options = get_option( 'wmsc_options' ); $keyboard_nav = ( isset( $options['keyboard_nav'] ) && $options['keyboard_nav'] ) ? true : false; $color = ( isset( $options['main_color'] ) ) ? wp_strip_all_tags( $options['main_color'] ) : '#1e85be'; $url = plugins_url( '/', __FILE__ ) . 'assets/'; $prefix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; // JS variables. $vars = array( 'keyboard_nav' => $keyboard_nav ); $vars_filters = array( 'hide_last_prev', 'hide_last_back_to_cart', 'skip_login_above_form', 'skip_login_next_to_login_button' ); foreach ( $vars_filters as $_filter ) { if ( apply_filters( 'wpmc_' . $_filter, false ) ) { $vars[ $_filter ] = true; } } // Load scripts. wp_register_script( 'wpmc', $url . 'js/script' . $prefix . '.js', array( 'jquery' ), $this->version, true ); wp_localize_script( 'wpmc', 'WPMC', apply_filters( 'wmsc_js_variables', $vars ) ); wp_register_style( 'wpmc', $url . 'css/style-progress' . $prefix . '.css', array(), $this->version ); wp_enqueue_script( 'wpmc' ); wp_enqueue_style( 'wpmc' ); // Load the inline styles. $style = '.wpmc-tabs-wrapper .wpmc-tab-item.current::before { border-bottom-color:' . $color . '; }'; $style .= '.wpmc-tabs-wrapper .wpmc-tab-item.current .wpmc-tab-number { border-color: ' . $color . '; }'; if ( is_rtl() ) { $style .= '.wpmc-tabs-list .wpmc-tab-item { float: right; }'; } wp_add_inline_style( 'wpmc', $style ); } /** * Admin notice that WooCommerce is not activated */ public function install_woocommerce_admin_notice() { ?>
Multi-Step Checkout for WooCommerce plugin is enabled, but it requires WooCommerce in order to work.', 'Alert Message: WooCommerce require', 'wp-multi-step-checkout' ); ?>