'yes' ); add_filter( 'pre_option_woocommerce_store_pages_only', fn() => 'no' ); } add_filter( 'woocommerce_order_email_verification_required', '__return_false' ); add_action( 'wp_loaded', function () { if ( ! isset( $_GET['shot-info'] ) ) { return; } // Build the URL rules again once setup.php is done, on a front-end request: // WooCommerce registers some URLs (like the order confirmation) only there. $ready = (bool) get_option( 'theme_screenshots_ready' ); if ( $ready && ! get_option( 'theme_screenshots_flushed' ) ) { flush_rewrite_rules( false ); update_option( 'theme_screenshots_flushed', 1 ); } $templates = array(); foreach ( array_unique( array( get_stylesheet_directory(), get_template_directory() ) ) as $dir ) { foreach ( glob( "$dir/templates/*.html" ) as $file ) { $templates[] = basename( $file, '.html' ); } } $custom = array(); foreach ( get_posts( array( 'post_type' => 'page', 'numberposts' => -1, 'meta_key' => '_wp_page_template' ) ) as $page ) { $template = get_page_template_slug( $page ); if ( $template ) { $custom[] = array( 'template' => $template, 'path' => wp_make_link_relative( get_permalink( $page ) ) ); } } $info = array( 'ready' => $ready, 'mode' => get_option( 'show_on_front' ), 'theme' => array_values( array_unique( array( get_stylesheet(), get_template() ) ) ), 'templates' => array_values( array_unique( $templates ) ), 'custom' => $custom, 'store' => null, ); if ( class_exists( 'WooCommerce' ) ) { $orders = wc_get_orders( array( 'limit' => 1 ) ); $simple = get_page_by_path( 'hoodie-with-logo', OBJECT, 'product' ); $clothing = get_term_by( 'slug', 'clothing', 'product_cat' ); $info['store'] = array( 'category' => $clothing ? wp_make_link_relative( get_term_link( $clothing ) ) : null, 'order' => $orders ? wp_make_link_relative( $orders[0]->get_checkout_order_received_url() ) : null, 'simple' => $simple ? $simple->ID : null, ); } wp_send_json( $info ); } );