'product', 'post_status' => 'publish', 'numberposts' => 1, 'fields' => 'ids', 'meta_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- one product per program, tiny table. 'relation' => 'OR', ['key' => BOS_LESSONS_PROGRAM_META, 'value' => (string) $package_id], ['key' => BOS_LESSONS_LEGACY_PROGRAM_META[0], 'value' => (string) $package_id], ['key' => BOS_LESSONS_LEGACY_PROGRAM_META[1], 'value' => (string) $package_id], ], ]); return $ids ? wc_get_product($ids[0]) : null; } // Program page / program grid styles. Called while a shortcode renders; WordPress prints a late enqueue in the footer. function bos_lessons_page_styles() { wp_enqueue_style('bos-lessons-programs', plugin_dir_url(__DIR__) . 'assets/programs.css', [], BOS_LESSONS_VERSION); return ''; } // In the head when the page content itself holds one of the shortcodes, so the page does not flash unstyled. add_action('wp_enqueue_scripts', function () { $post = is_singular() ? get_post() : null; if ($post && (has_shortcode($post->post_content, 'bos_lessons_program') || has_shortcode($post->post_content, 'bos_lessons_programs'))) { bos_lessons_page_styles(); } }); // Price + Buy Now for programs whose page blocks are not filled yet (description or lesson list only). function bos_lessons_buy_box(array $package) { $product = bos_lessons_product_for_package($package['id']); if (!$product) { return ''; } $buy = bos_lessons_buy_url($product); return bos_lessons_page_styles() . '
' . esc_html($page['eyebrow']) . '
'; } $html .= '' . esc_html($page['subtitle']) . '
'; } if ($page['intro'] !== '') { $html .= '