at the coming soon screen should be shown. if ( self::$show_coming_soon ) { return true; } // Early exit if LYS feature is disabled. if ( ! Features::is_enabled( 'launch-your-store' ) ) { return false; } // Early exit if the user is logged in as administrator / shop manager. if ( current_user_can( 'manage_woocommerce' ) ) { return false; } // Do not show coming soon on 404 pages when applied to store pages only. if ( $this->coming_soon_helper->is_store_coming_soon() && is_404() ) { return false; } // Early exit if the current page doesn't need a coming soon screen. if ( ! $this->coming_soon_helper->is_current_page_coming_soon() ) { return false; } /** * Check if there is an exclusion. * * @since 9.1.0 * * @param bool $is_excluded If the request should be excluded from Coming soon mode. Defaults to false. */ if ( apply_filters( 'woocommerce_coming_soon_exclude', false ) ) { return false; } // Check if the private link option is enabled. if ( get_option( 'woocommerce_private_link' ) === 'yes' ) { // Exclude users with a private link. if ( isset( $_GET['woo-share'] ) && get_option( 'woocommerce_share_key' ) === $_GET['woo-share'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended // Persist the share link with a cookie for 90 days. setcookie( 'woo-share', sanitize_text_field( wp_unslash( $_GET['woo-share'] ) ), time() + 60 * 60 * 24 * 90, '/' ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended return false; } if ( isset( $_COOKIE['woo-share'] ) && get_option( 'woocommerce_share_key' ) === $_COOKIE['woo-share'] ) { return false; } } self::$show_coming_soon = true; return true; } /** * Filters the theme.json data to add the Inter and Cardo fonts when they don't exist. * * @param WP_Theme_JSON $theme_json The theme json object. */ public function experimental_filter_theme_json_theme( $theme_json ) { if ( ! Features::is_enabled( 'launch-your-store' ) ) { return $theme_json; } $theme_data = $theme_json->get_data(); $font_data = $theme_data['settings']['typography']['fontFamilies']['theme'] ?? array(); $fonts_to_add = array( array( 'fontFamily' => '"Inter", sans-serif', 'name' => 'Inter', 'slug' => 'inter', 'fontFace' => array( array( 'fontFamily' => 'Inter', 'fontStretch' => 'normal', 'fontStyle' => 'normal', 'fontWeight' => '300 900', 'src' => array( WC()->plugin_url() . '/assets/fonts/Inter-VariableFont_slnt,wght.woff2' ), ), ), ), array( 'fontFamily' => 'Cardo', 'name' => 'Cardo', 'slug' => 'cardo', 'fontFace' => array( array( 'fontFamily' => 'Cardo', 'fontStyle' => 'normal', 'fontWeight' => '400', 'src' => array( WC()->plugin_url() . '/assets/fonts/cardo_normal_400.woff2' ), ), ), ), ); // Loops through all existing fonts and append when the font's name is not found. foreach ( $fonts_to_add as $font_to_add ) { $found = false; foreach ( $font_data as $font ) { if ( isset( $font['name'] ) && $font['name'] === $font_to_add['name'] ) { $found = true; break; } } if ( ! $found ) { $font_data[] = $font_to_add; } } $new_data = array( 'version' => 1, 'settings' => array( 'typography' => array( 'fontFamilies' => array( 'theme' => $font_data, ), ), ), ); $theme_json->update_with( $new_data ); return $theme_json; } /** * Enqueues the coming soon banner styles. */ public function enqueue_styles() { // Early exit if the user is not logged in as administrator / shop manager. if ( ! current_user_can( 'manage_woocommerce' ) ) { return; } // Early exit if LYS feature is disabled. if ( ! Features::is_enabled( 'launch-your-store' ) ) { return; } if ( $this->coming_soon_helper->is_site_live() ) { return; } wp_enqueue_style( 'woocommerce-coming-soon', WC()->plugin_url() . '/assets/css/coming-soon' . ( is_rtl() ? '-rtl' : '' ) . '.css', array(), Constants::get_constant( 'WC_VERSION' ) ); } }