post_type === 'page' ) { $home_id = (int) $existing->ID; } else { $by_path = get_page_by_path( 'home', OBJECT, 'page' ); if ( $by_path ) { $home_id = (int) $by_path->ID; } } // 2) Create a fresh page if not found. if ( ! $home_id ) { $home_id = wp_insert_post( array( 'post_title' => $title, 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => '', // Elementor stores data in post meta. ) ); } if ( is_wp_error( $home_id ) || ! $home_id ) { update_option( 'bongoto_woocommerce_auto_home_done', 'error' ); return; } // 3) Load Elementor JSON from theme assets (if present). $json_file = trailingslashit( get_template_directory() ) . 'assets/elementor/bongoto-digital-marketplace-home.json'; if ( file_exists( $json_file ) && is_readable( $json_file ) ) { $json_raw = file_get_contents( $json_file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents $json_data = json_decode( $json_raw, true ); // Only proceed if JSON is valid. if ( is_array( $json_data ) ) { $encoded = wp_slash( wp_json_encode( $json_data ) ); update_post_meta( $home_id, '_elementor_edit_mode', 'builder' ); $ver = get_option( 'elementor_version' ); if ( ! $ver ) { $ver = '3.0.0'; } update_post_meta( $home_id, '_elementor_version', $ver ); update_post_meta( $home_id, '_elementor_data', $encoded ); // Use default template so theme header/footer show up. update_post_meta( $home_id, '_wp_page_template', 'default' ); } } // 4) Make it the static front page. update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', $home_id ); update_option( 'bongoto_woocommerce_auto_home_done', '1' ); } // Auto-home-on-activation disabled. Use Demo Import page to create Home.