settings = $settings; } /** * Register the plugin hooks. Only called when WooCommerce is active. * * @return void */ public function register_hooks() { add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend' ) ); } /** * Enqueue the builder assets on variable product pages. * * @return void */ public function enqueue_frontend() { if ( ! function_exists( 'is_product' ) || ! is_product() ) { return; } if ( ! (bool) $this->settings->get( Settings::GROUP_GENERAL, 'enabled', true ) ) { return; } $product = wc_get_product( get_queried_object_id() ); if ( ! $product || ! $product->is_type( 'variable' ) ) { return; } $this->enqueue(); } /** * Register and enqueue the builder styles and script. * * Safe to call more than once and from anywhere in the request — the * shortcode uses it when the builder is not placed by a product template. * Late-enqueued styles are printed by WordPress in the footer. * * @return void */ public function enqueue() { wp_enqueue_style( self::STYLE_HANDLE, BULKORA_ASSETS_URL . 'css/bulkora.css', array(), Plugin::asset_version( 'css/bulkora.css' ) ); wp_enqueue_script( self::SCRIPT_HANDLE, BULKORA_ASSETS_URL . 'js/bulkora.js', array(), Plugin::asset_version( 'js/bulkora.js' ), true ); } }