init_nav_menu( $active_tab ); } else { ?>
get_local_vars(); wp_localize_script( 'jquery', 'astraSitesVars', $data ); $file = INTELLIGENT_TEMPLATES_DIR . 'assets/dist/main.asset.php'; if ( ! file_exists( $file ) ) { return; } $asset = require_once $file; if ( ! isset( $asset ) ) { return; } wp_register_script( 'starter-templates-onboarding', INTELLIGENT_TEMPLATES_URI . 'assets/dist/main.js', array_merge( $asset['dependencies'] ), $asset['version'], true ); wp_localize_script( 'starter-templates-onboarding', 'wpApiSettings', array( 'root' => esc_url_raw( get_rest_url() ), 'nonce' => ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' ), ) ); wp_localize_script( 'starter-templates-onboarding', 'starterTemplates', $this->get_starter_templates_onboarding_localized_array() ); wp_enqueue_media(); wp_enqueue_script( 'starter-templates-onboarding' ); // Set the script translations. wp_set_script_translations( 'starter-templates-onboarding', 'astra-sites' ); wp_enqueue_style( 'starter-templates-onboarding', INTELLIGENT_TEMPLATES_URI . 'assets/dist/style-main.css', array(), $asset['version'] ); wp_style_add_data( 'starter-templates-onboarding', 'rtl', 'replace' ); // Load fonts from Google. wp_enqueue_style( 'starter-templates-onboarding-google-fonts', $this->google_fonts_url(), array( 'starter-templates-onboarding' ), 'all' ); } /** * Get localized array for starter templates. * * @return array */ private function get_starter_templates_onboarding_localized_array() { $current_user = wp_get_current_user(); $site_url = add_query_arg( array( 'preview-nonce' => wp_create_nonce( 'starter-templates-preview' ), ), site_url( '/' ) ); $spectraTheme = 'not-installed'; $themeStatus = Astra_Sites::get_instance()->get_theme_status(); // Theme installed and activate. if ( 'spectra-one' === get_option( 'stylesheet', 'astra' ) ) { $spectraTheme = 'installed-and-active'; $themeStatus = 'installed-and-active'; } $data = array( 'imageDir' => INTELLIGENT_TEMPLATES_URI . 'assets/images/', 'URI' => INTELLIGENT_TEMPLATES_URI, 'buildDir' => INTELLIGENT_TEMPLATES_URI . 'assets/dist/', 'previewUrl' => $site_url, 'adminUrl' => admin_url(), 'demoId' => 0, 'skipImport' => false, 'adminEmail' => $current_user->user_email, 'themeStatus' => $themeStatus, 'spectraTheme' => $spectraTheme, 'nonce' => wp_create_nonce( 'astra-sites-set-ai-site-data' ), 'restNonce' => wp_create_nonce( 'wp_rest' ), 'retryTimeOut' => 5000, // 10 Seconds. 'siteUrl' => get_site_url(), 'searchData' => Astra_Sites::get_instance()->get_api_domain() . 'wp-json/starter-templates/v1/ist-data', 'firstImportStatus' => get_option( 'astra_sites_import_complete', false ), 'supportLink' => 'https://wpastra.com/starter-templates-support/?ip=' . Astra_Sites_Helper::get_client_ip(), 'isBrizyEnabled'=> get_option( 'st-brizy-builder-flag'), 'isElementorDisabled'=> get_option( 'st-elementor-builder-flag'), 'analytics' => get_site_option( 'bsf_analytics_optin', false ), 'phpVersion' => PHP_VERSION, 'reportError' => $this->should_report_error(), ); return apply_filters( 'starter_templates_onboarding_localize_vars', $data ); } /** * Check if we should report error or not. * Skipping error reporting for a few hosting providers. */ public function should_report_error() { /** * Byassing error reporting for a few hosting providers. */ foreach( $this->hosting_providers as $provider ) { if ( strpos( ABSPATH, $provider ) !== false ) { return false; } } return true; } /** * Genereate and return the Google fonts url. * * @since 3.0.0-beta.1 * @return string */ public function google_fonts_url() { $fonts_url = ''; $font_families = array( 'Inter:400,500,600', ); $query_args = array( 'family' => rawurlencode( implode( '|', $font_families ) ), 'subset' => rawurlencode( 'latin,latin-ext' ), ); $fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' ); return $fonts_url; } /** * Register Enable Brizy templates flag. * * @return void */ public function st_brizy_flag_field() { register_setting( 'general', 'st-brizy-builder-flag', 'esc_attr' ); register_setting( 'general', 'st-elementor-builder-flag', 'esc_attr' ); add_settings_field('st-brizy-builder-flag', '' , array($this, 'st_brizy_flag') , 'general' ); } /** * Enable Brizy templates flag markup. * * @return void */ public function st_brizy_flag() { $value = get_option( 'st-brizy-builder-flag'); $elementor_value = get_option( 'st-elementor-builder-flag'); ob_start(); ?>