$item ) { if ( isset( $item[2] ) && $item[2] === 'adaire-blocks-welcome' ) { $welcome_item = $item; $welcome_key = $key; break; } } if ( $welcome_item === null ) return; unset( $submenu[ $parent ][ $welcome_key ] ); array_unshift( $submenu[ $parent ], $welcome_item ); } public static function create_starter_page() { check_ajax_referer( 'adaire_create_page', 'nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( array( 'message' => __( 'Insufficient permissions.', 'adaire-blocks' ) ) ); } $pattern_slug = sanitize_text_field( wp_unslash( $_POST['pattern'] ?? 'adaire-blocks/landing-page' ) ); $registry = WP_Block_Patterns_Registry::get_instance(); $pattern = $registry->get_registered( $pattern_slug ); if ( ! $pattern ) { wp_send_json_error( array( 'message' => __( 'Pattern not found.', 'adaire-blocks' ) ) ); } $page_id = wp_insert_post( array( 'post_type' => 'page', 'post_status' => 'draft', 'post_title' => $pattern['title'], 'post_content' => $pattern['content'], ), true ); if ( is_wp_error( $page_id ) || empty( $page_id ) ) { $message = is_wp_error( $page_id ) ? $page_id->get_error_message() : __( 'Failed to create page.', 'adaire-blocks' ); wp_send_json_error( array( 'message' => $message ) ); } $edit_url = get_edit_post_link( $page_id, 'raw' ); if ( empty( $edit_url ) ) { wp_send_json_error( array( 'message' => __( 'Page created but could not get edit URL.', 'adaire-blocks' ) ) ); } wp_send_json_success( array( 'edit_url' => $edit_url ) ); } public static function render() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'Unauthorized', 'adaire-blocks' ) ); } $nonce = wp_create_nonce( 'adaire_create_page' ); $ajax_url = admin_url( 'admin-ajax.php' ); $docs_url = 'https://adaire.digital/docs/'; $support_url = 'https://adaire.digital/support/'; $settings_url = admin_url( 'admin.php?page=adaire-blocks-settings' ); $migration_url = admin_url( 'admin.php?page=adaire-blocks-migration' ); $exit_url = admin_url(); $new_page_url = admin_url( 'post-new.php?post_type=page' ); $templates_json = wp_json_encode( array( array( 'slug' => 'adaire-blocks/landing-page', 'label' => 'Landing Page', 'desc' => 'Hero, features, testimonials & CTA', 'color' => '#C9463F', 'rec' => true ), array( 'slug' => 'adaire-blocks/about-page', 'label' => 'About Page', 'desc' => 'Story, timeline & testimonials', 'color' => '#3B82F6', 'rec' => false ), array( 'slug' => 'adaire-blocks/services-page', 'label' => 'Services Page', 'desc' => 'Hero, info grid & pricing table', 'color' => '#8B5CF6', 'rec' => false ), array( 'slug' => 'adaire-blocks/blog-landing', 'label' => 'Blog Landing', 'desc' => 'Hero with a posts grid', 'color' => '#10B981', 'rec' => false ), array( 'slug' => 'adaire-blocks/contact-page', 'label' => 'Contact Page', 'desc' => 'Hero with two-column contact layout', 'color' => '#F59E0B', 'rec' => false ), array( 'slug' => '', 'label' => 'Blank Canvas', 'desc' => 'Start from scratch', 'color' => '#64748B', 'rec' => false ), ) ); // Welcome images (shown in step 1 collage scene). $img_base = plugins_url( 'images/', __FILE__ ); $img_hero = file_exists( __DIR__ . '/images/welcome-hero.png' ) ? $img_base . 'welcome-hero.png' : ''; $img_showcase = file_exists( __DIR__ . '/images/welcome-showcase.png' ) ? $img_base . 'welcome-showcase.png' : ''; // Build Lottie URL map — only includes files that actually exist on disk. // Step 2 maps each option to {left, right} using name1.json / name2.json pairs. $lottie_base = plugins_url( 'lottie/', __FILE__ ); $lottie_dir = __DIR__ . '/lottie/'; $lottie_map = array(); // Step 1 — single file per option (overlay on scene). $step1_files = array( 'myself', 'business', 'client', 'exploring' ); foreach ( $step1_files as $idx => $slug ) { $f = $lottie_dir . 'step-1-who/' . $slug . '.json'; if ( file_exists( $f ) ) $lottie_map[0][ $idx ] = $lottie_base . 'step-1-who/' . $slug . '.json'; } // Step 2 — name1.json (left corner) + name2.json (right corner) per option. $step2_opts = array( 'business', 'store', 'company', 'blog', 'landing', 'portfolio', 'booking', 'other' ); foreach ( $step2_opts as $idx => $slug ) { $pair = array(); $f1 = $lottie_dir . 'step-2-topic/' . $slug . '1.json'; $f2 = $lottie_dir . 'step-2-topic/' . $slug . '2.json'; if ( file_exists( $f1 ) ) $pair['left'] = $lottie_base . 'step-2-topic/' . $slug . '1.json'; if ( file_exists( $f2 ) ) $pair['right'] = $lottie_base . 'step-2-topic/' . $slug . '2.json'; if ( ! empty( $pair ) ) $lottie_map[1][ $idx ] = $pair; } // Steps 3–5 — single file per option (overlay). $other_steps = array( 2 => array( 'dir' => 'step-3-experience', 'files' => array( 'beginner', 'intermediate', 'advanced' ) ), 3 => array( 'dir' => 'step-4-template', 'files' => array( 'landing-page', 'about-page', 'services-page', 'blog-landing', 'contact-page', 'blank-canvas' ) ), 4 => array( 'dir' => 'step-5-features', 'files' => array( 'testimonials', 'pricing-table', 'counter', 'flip-card', 'animation-scroll', 'mega-menu', 'modal-popup', 'video-hero' ) ), ); foreach ( $other_steps as $step_idx => $step ) { foreach ( $step['files'] as $opt_idx => $filename ) { $f = $lottie_dir . $step['dir'] . '/' . $filename . '.json'; if ( file_exists( $f ) ) $lottie_map[ $step_idx ][ $opt_idx ] = $lottie_base . $step['dir'] . '/' . $filename . '.json'; } } $version = defined( 'ADAIRE_BLOCKS_VERSION' ) ? ADAIRE_BLOCKS_VERSION : '1.0'; $brand_svg = ''; ?>