set_api_url(); $this->includes(); add_action( 'plugin_action_links_' . ASTRA_SITES_BASE, array( $this, 'action_links' ) ); add_action( 'init', array( $this, 'load_textdomain' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ), 99 ); add_action( 'elementor/editor/footer', array( $this, 'insert_templates' ) ); add_action( 'admin_footer', array( $this, 'insert_image_templates' ) ); add_action( 'customize_controls_print_footer_scripts', array( $this, 'insert_image_templates' ) ); add_action( 'wp_footer', array( $this, 'insert_image_templates_bb_and_brizy' ) ); add_action( 'elementor/editor/footer', array( $this, 'register_widget_scripts' ), 99 ); add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'popup_styles' ) ); add_action( 'elementor/preview/enqueue_styles', array( $this, 'popup_styles' ) ); add_action( 'astra_sites_after_plugin_activation', array( $this, 'disable_wp_forms_redirect' ) ); add_action( 'astra_notice_before_markup', array( $this, 'notice_assets' ) ); add_action( 'load-index.php', array( $this, 'admin_dashboard_notices' ) ); add_action( 'admin_notices', array( $this, 'check_filesystem_access_notice' ) ); add_filter( 'ai_builder_textdomain', array( $this, 'updat_ai_builder_textdomain' ), 10, 1 ); add_filter( 'ai_builder_languages_directory', array( $this, 'change_languages_directory' ), 10, 1 ); // AJAX. $this->ajax = array( 'astra-sites-create-template' => 'create_template', 'astra-sites-create-image' => 'create_image', 'astra-sites-search-images' => 'search_images', 'astra-sites-getting-started-notice' => 'getting_started_notice', 'astra-sites-favorite' => 'add_to_favorite', 'astra-sites-api-request' => 'api_request', 'astra-sites-elementor-api-request' => 'elementor_api_request', 'astra-sites-elementor-flush-request' => 'elementor_flush_request', 'astra-page-elementor-insert-page' => 'elementor_process_import_for_page', 'astra-sites-update-subscription' => 'update_subscription', 'astra-sites-update-analytics' => 'update_analytics', 'astra-sites-generate-analytics-lead' => 'push_to_import_analytics', ); foreach ( $this->ajax as $ajax_hook => $ajax_callback ) { add_action( 'wp_ajax_' . $ajax_hook, array( $this, $ajax_callback ) ); } add_action( 'delete_attachment', array( $this, 'delete_astra_images' ) ); add_filter( 'heartbeat_received', array( $this, 'search_push' ), 10, 2 ); add_filter( 'status_header', array( $this, 'status_header' ), 10, 4 ); add_filter( 'wp_php_error_message', array( $this, 'php_error_message' ), 10, 2 ); add_filter( 'wp_import_post_data_processed', array( $this, 'wp_slash_after_xml_import' ), 99, 2 ); add_filter( 'ast_block_templates_authorization_url_param', array( $this, 'add_auth_url_param' ) ); add_action( 'admin_head', array( $this, 'add_custom_admin_css' ) ); add_filter( 'zip_ai_modules', array( $this, 'enable_zip_ai_copilot' ), 20, 1 ); add_action( 'astra_sites_after_theme_activation', array( $this, 'theme_activation_utm_event' ) ); add_action( 'astra_sites_after_plugin_activation', array( $this, 'plugin_activation_utm_event' ), 10, 2 ); add_filter( 'plugins_api_args', array( $this, 'raise_memory_for_plugins_install' ), 1, 1 ); add_filter( 'bsf_core_stats', array( $this, 'add_astra_sites_analytics_data' ), 10, 1 ); } /** * Set ai builder textdomain. * * @param string $textdomain Textdomain. * @return string * @since 4.3.8 */ public function updat_ai_builder_textdomain( $textdomain ) { return 'astra-sites'; } /** * Change languages directory. * * @param string $lang_dir languages directory. * * @return string * @since 4.3.9 */ public function change_languages_directory( $lang_dir ) { return ASTRA_SITES_DIR . 'languages'; } /** * Display notice if XML Class Reader is not Available. * * @return void */ public function xml_reader_notice() { $plugin_name = defined( 'ASTRA_PRO_SITES_NAME' ) ? 'Premium Starter Templates' : 'Starter Templates'; ?>
WordPress debug mode is currently enabled on your website. This has interrupted the import process..
Kindly disable debug mode and try importing Starter Template again.
You can add the following code into the wp-config.php file to disable debug mode.
define(\'WP_DEBUG\', false);
We are facing a temporary issue in importing this template.
Read article to resolve the issue and continue importing template.
', 'astra-sites' ), esc_url( 'https://wpastra.com/docs/fix-starter-template-importing-issues/' ) ), /* translators: %s is a documentation link. */ 'importFailedRequiredPluginsMessage' => sprintf( __( 'We are facing a temporary issue in installing the required plugins for this template.
Read article to resolve the issue and continue importing template.
', 'astra-sites' ), esc_url( 'https://wpastra.com/docs/plugin-installation-failed-multisite/' ) ), 'strings' => array( /* translators: %s are white label strings. */ 'warningBeforeCloseWindow' => sprintf( __( 'Warning! %1$s Import process is not complete. Don\'t close the window until import process complete. Do you still want to leave the window?', 'astra-sites' ), Astra_Sites_White_Label::get_instance()->get_white_label_name() ), 'viewSite' => __( 'Done! View Site', 'astra-sites' ), 'syncCompleteMessage' => self::get_instance()->get_sync_complete_message(), /* translators: %s is a template name */ 'importSingleTemplate' => __( 'Import "%s" Template', 'astra-sites' ), ), 'log' => array( 'bulkInstall' => __( 'Installing Required Plugins..', 'astra-sites' ), /* translators: %s are white label strings. */ 'themeInstall' => sprintf( __( 'Installing %1$s Theme..', 'astra-sites' ), Astra_Sites_White_Label::get_instance()->get_option( 'astra', 'name', 'Astra' ) ), ), 'default_page_builder' => $default_page_builder, 'default_page_builder_data' => Astra_Sites_Page::get_instance()->get_default_page_builder(), 'default_page_builder_sites' => Astra_Sites_Page::get_instance()->get_sites_by_page_builder( $default_page_builder ), 'sites' => astra_sites_get_api_params(), 'categories' => array(), 'page-builders' => array(), 'all_sites' => $this->get_all_sites(), 'all_site_categories' => Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-sites-all-site-categories.json' ), 'all_site_categories_and_tags' => Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-sites-all-site-categories-and-tags.json' ), 'license_status' => $license_status, 'license_page_builder' => get_option( 'astra-sites-license-page-builder', '' ), 'ApiDomain' => $this->api_domain, 'ApiURL' => $this->api_url, 'stored_data' => $stored_data, 'favorite_data' => $favorite_data, 'category_slug' => 'astra-sites-site-category', 'page_builder' => 'astra-site-page-builder', 'cpt_slug' => 'astra-sites', 'parent_category' => '', 'compatibilities' => $this->get_compatibilities(), 'compatibilities_data' => $this->get_compatibilities_data(), 'dismiss' => __( 'Dismiss this notice.', 'astra-sites' ), 'headings' => array( 'subscription' => esc_html__( 'One Last Step..', 'astra-sites' ), 'site_import' => esc_html__( 'Your Selected Website is Being Imported.', 'astra-sites' ), 'page_import' => esc_html__( 'Your Selected Template is Being Imported.', 'astra-sites' ), ), 'subscriptionSuccessMessage' => esc_html__( 'We have sent you a surprise gift on your email address! Please check your inbox!', 'astra-sites' ), 'first_import_complete' => get_option( 'astra_sites_import_complete' ), 'server_import_primary_error' => __( 'Looks like the template you are importing is temporarily not available.', 'astra-sites' ), 'client_import_primary_error' => __( 'We could not start the import process and this is the message from WordPress:', 'astra-sites' ), 'cloudflare_import_primary_error' => __( 'There was an error connecting to the Starter Templates API.', 'astra-sites' ), 'xml_import_interrupted_primary' => __( 'There was an error while importing the content.', 'astra-sites' ), 'xml_import_interrupted_secondary' => __( 'To import content, WordPress needs to store XML file in /wp-content/ folder. Please get in touch with your hosting provider.', 'astra-sites' ), 'xml_import_interrupted_error' => __( 'Looks like your host probably could not store XML file in /wp-content/ folder.', 'astra-sites' ), /* translators: %s HTML tags */ 'ajax_request_failed_primary' => sprintf( __( '%1$sWe could not start the import process due to failed AJAX request and this is the message from WordPress:%2$s', 'astra-sites' ), '', '
' ), /* translators: %s URL to document. */ 'ajax_request_failed_secondary' => sprintf( __( '%1$sRead article to resolve the issue and continue importing template.%3$s', 'astra-sites' ), '', esc_url( 'https://wpastra.com/docs/internal-server-error-starter-templates/' ), '
' ), 'cta_links' => $this->get_cta_links(), 'cta_quick_corner_links' => $this->get_cta_links( 'quick-links-corner' ), 'cta_premium_popup_links' => $this->get_cta_links( 'get-premium-access-popup' ), 'cta_link' => $this->get_cta_link(), 'cta_quick_corner_link' => $this->get_cta_link( 'quick-links-corner' ), 'cta_premium_popup_link' => $this->get_cta_link( 'get-premium-access-popup' ), /* translators: %s URL to document. */ 'process_failed_primary' => sprintf( __( '%1$sWe could not complete the import process due to failed AJAX request and this is the message:%2$s', 'astra-sites' ), '', '
' ), /* translators: %s URL to document. */ 'process_failed_secondary' => sprintf( __( '%1$sPlease report this here.%3$s', 'astra-sites' ), '', esc_url( 'https://wpastra.com/starter-templates-support/?url=#DEMO_URL#&subject=#SUBJECT#' ), '
' ), 'st_page_url' => admin_url( 'themes.php?page=starter-templates' ), 'staging_connected' => apply_filters( 'astra_sites_staging_connected', '' ), 'isRTLEnabled' => is_rtl(), /* translators: %s Anchor link to support URL. */ 'support_text' => sprintf( __( 'Please report this error%1$s here %2$s, so we can fix it.', 'astra-sites' ), '', '' ), 'surecart_store_exists' => isset( $surecart_store_exist ) ? $surecart_store_exist : false, 'default_ai_categories' => $this->get_default_ai_categories(), 'block_color_palette' => $this->get_block_palette_colors(), 'page_color_palette' => $this->get_page_palette_colors(), 'rest_api_nonce' => ( current_user_can( 'manage_options' ) ) ? wp_create_nonce( 'wp_rest' ) : '', 'zip_token_exists' => Astra_Sites_ZipWP_Helper::get_token() !== '' ? true : false, 'zip_plans' => ( $plans && isset( $plans['data'] ) ) ? $plans['data'] : array(), 'dashboard_url' => admin_url(), 'placeholder_images' => Helper::get_image_placeholders(), 'get_more_credits_url' => $credit_purchase_url, 'dismiss_ai_notice' => Astra_Sites_Page::get_instance()->get_setting( 'dismiss_ai_promotion' ), 'showClassicTemplates' => apply_filters( 'astra_sites_show_classic_templates', true ), 'bgSyncInProgress' => 'in-process' === get_site_option( 'astra-sites-batch-status', '' ), ) ); return $data; } /** * Get palette colors * * @since 4.0.0 * * @return mixed */ public function get_page_palette_colors() { $default_palette_color = array( '#046bd2', '#045cb4', '#1e293b', '#334155', '#f9fafb', '#FFFFFF', '#e2e8f0', '#cbd5e1', '#94a3b8', ); if ( class_exists( 'Astra_Global_Palette' ) ) { $astra_palette_colors = astra_get_palette_colors(); $default_palette_color = $astra_palette_colors['palettes'][ $astra_palette_colors['currentPalette'] ]; } $palette_one = $default_palette_color; $palette_two = array( $default_palette_color[0], $default_palette_color[1], $default_palette_color[5], $default_palette_color[4], $default_palette_color[3], $default_palette_color[2], $default_palette_color[6], $default_palette_color[7], $default_palette_color[8], ); $color_palettes = array( 'style-1' => array( 'slug' => 'style-1', 'title' => 'Light', 'default_color' => $default_palette_color[4], 'colors' => $palette_one, ), 'style-2' => array( 'slug' => 'style-2', 'title' => 'Dark', 'default_color' => '#1E293B', 'colors' => $palette_two, ), ); return $color_palettes; } /** * Get default AI categories. * * @since 2.0.0 * * @return array */ public function get_default_ai_categories() { return array( 'business' => 'Business', 'person' => 'Person', 'organisation' => 'Organisation', 'restaurant' => 'Restaurant', 'product' => 'Product', 'event' => 'Event', 'landing-page' => 'Landing Page', 'medical' => 'Medical', ); } /** * Get palette colors * * @since 4.0.0 * * @return mixed */ public function get_block_palette_colors() { $default_palette_color = array( '#046bd2', '#045cb4', '#1e293b', '#334155', '#f9fafb', '#FFFFFF', '#e2e8f0', '#cbd5e1', '#94a3b8', ); if ( class_exists( 'Astra_Global_Palette' ) ) { $astra_palette_colors = astra_get_palette_colors(); $default_palette_color = $astra_palette_colors['palettes'][ $astra_palette_colors['currentPalette'] ]; } $palette_one = array( $default_palette_color[0], $default_palette_color[1], $default_palette_color[2], $default_palette_color[3], $default_palette_color[5], $default_palette_color[5], $default_palette_color[6], $default_palette_color[7], $default_palette_color[8], ); $palette_two = $default_palette_color; $palette_three = array( $default_palette_color[3], $default_palette_color[2], $default_palette_color[5], $default_palette_color[4], $default_palette_color[0], $default_palette_color[1], $default_palette_color[6], $default_palette_color[7], $default_palette_color[8], ); $color_palettes = array( 'style-1' => array( 'slug' => 'style-1', 'title' => 'Light', 'default_color' => $default_palette_color[5], 'colors' => $palette_one, ), 'style-2' => array( 'slug' => 'style-2', 'title' => 'Dark', 'default_color' => $default_palette_color[4], 'colors' => $palette_two, ), 'style-3' => array( 'slug' => 'style-3', 'title' => 'Highlight', 'default_color' => $default_palette_color[0], 'colors' => $palette_three, ), ); return $color_palettes; } /** * Display subscription form * * @since 2.6.1 * * @return boolean */ public function should_display_subscription_form() { $subscription = apply_filters( 'astra_sites_should_display_subscription_form', null ); if ( null !== $subscription ) { return $subscription; } // Is WhiteLabel enabled? if ( Astra_Sites_White_Label::get_instance()->is_white_labeled() ) { return false; } // Is Premium Starter Templates pluign? if ( defined( 'ASTRA_PRO_SITES_NAME' ) ) { return false; } // User already subscribed? $subscribed = get_user_meta( get_current_user_ID(), 'astra-sites-subscribed', true ); if ( $subscribed ) { return false; } return true; } /** * Import Compatibility Errors * * @since 2.0.0 * @return mixed */ public function get_compatibilities_data() { return array( 'xmlreader' => array( 'title' => esc_html__( 'XMLReader Support Missing', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '' . esc_html__( 'You\'re close to importing the template. To complete the process, enable XMLReader support on your website..', 'astra-sites' ) . '
' . sprintf( __( 'Read an article here to resolve the issue.', 'astra-sites' ), 'https://wpastra.com/docs/xmlreader-missing/' ) . '
', ), 'curl' => array( 'title' => esc_html__( 'cURL Support Missing', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '' . esc_html__( 'To run a smooth import, kindly enable cURL support on your website.', 'astra-sites' ) . '
' . sprintf( __( 'Read an article here to resolve the issue.', 'astra-sites' ), 'https://wpastra.com/docs/curl-support-missing/' ) . '
', ), 'wp-debug' => array( 'title' => esc_html__( 'Disable Debug Mode', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '' . esc_html__( 'WordPress debug mode is currently enabled on your website. With this, any errors from third-party plugins might affect the import process.', 'astra-sites' ) . '
' . esc_html__( 'Kindly disable it to continue importing the Starter Template. To do so, you can add the following code into the wp-config.php file.', 'astra-sites' ) . '
define(\'WP_DEBUG\', false);
' . sprintf( __( 'Read an article here to resolve the issue.', 'astra-sites' ), 'https://wpastra.com/docs/disable-debug-mode/' ) . '
', ), 'update-available' => array( 'title' => esc_html__( 'Update Plugin', 'astra-sites' ), /* translators: %s update page link. */ 'tooltip' => '' . esc_html__( 'Updates are available for plugins used in this starter template.', 'astra-sites' ) . '
##LIST##' . sprintf( __( 'Kindly update them for a successful import. Skipping this step might break the template design/feature.', 'astra-sites' ), esc_url( network_admin_url( 'update-core.php' ) ) ) . '
', ), 'third-party-required' => array( 'title' => esc_html__( 'Required Plugins Missing', 'astra-sites' ), 'tooltip' => '' . esc_html__( 'This starter template requires premium plugins. As these are third party premium plugins, you\'ll need to purchase, install and activate them first.', 'astra-sites' ) . '
', ), 'dynamic-page' => array( 'title' => esc_html__( 'Dynamic Page', 'astra-sites' ), 'tooltip' => '' . esc_html__( 'The page template you are about to import contains a dynamic widget/module. Please note this dynamic data will not be available with the imported page.', 'astra-sites' ) . '
' . esc_html__( 'You will need to add it manually on the page.', 'astra-sites' ) . '
' . esc_html__( 'This dynamic content will be available when you import the entire site.', 'astra-sites' ) . '
', ), 'flexbox-container' => array( 'title' => esc_html__( 'Enable Flexbox Container from Elementor', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '' . esc_html__( 'The Flexbox Container widget is disabled on your website. With this disabled, the import process will be affected. Kindly enable it to continue importing the Starter Template.', 'astra-sites' ) . '
' . sprintf( __( 'Read an article here to resolve the issue.', 'astra-sites' ), 'https://wpastra.com/docs/enable-flexbox-container-from-elementor' ) . '
', ), 'install-plugin-permission' => array( 'title' => esc_html__( 'Missing plugin installation permission', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '' . esc_html__( 'You do not have permission to install the required plugin. You must have install permissions to proceed with the required plugin.', 'astra-sites' ) . '
', ), 'activate-plugin-permission' => array( 'title' => esc_html__( 'Missing plugin activation permission', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '' . esc_html__( 'You do not have permission to activate the required plugin. You must have activate permissions to proceed with the required plugin.', 'astra-sites' ) . '
', ), 'wp-memory-limit' => array( 'title' => esc_html__( 'Insufficient Memory Limit', 'astra-sites' ), /* translators: %s doc link. */ 'tooltip' => '' . esc_html__( 'The memory limit of your site is below the recommended 256MB. While you can proceed, increasing the memory limit is advised for a seamless import experience.', 'astra-sites' ) . '
', ), ); } /** * Get all compatibilities * * @since 2.0.0 * * @return array */ public function get_compatibilities() { $data = $this->get_compatibilities_data(); $compatibilities = array( 'errors' => array(), 'warnings' => array(), ); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { $compatibilities['warnings']['wp-debug'] = $data['wp-debug']; } if ( ! class_exists( 'XMLReader' ) ) { $compatibilities['errors']['xmlreader'] = $data['xmlreader']; } if ( ! function_exists( 'curl_version' ) ) { $compatibilities['errors']['curl'] = $data['curl']; } $flexbox_container = get_option( 'elementor_experiment-container' ); // Check if the value is 'inactive'. if ( 'inactive' === $flexbox_container ) { $compatibilities['warnings']['flexbox-container'] = $data['flexbox-container']; } $memory_limit = $this->get_original_memory_limit(); // Convert memory limit to bytes for comparison. $memory_limit_in_bytes = wp_convert_hr_to_bytes( $memory_limit ); // 256MB in bytes. $required_memory_limit = 256 * 1024 * 1024; if ( $memory_limit_in_bytes < $required_memory_limit ) { $compatibilities['warnings']['wp-memory-limit'] = $data['wp-memory-limit']; } if ( ! current_user_can( 'install_plugins' ) ) { $compatibilities['errors']['install-plugin-permission'] = $data['install-plugin-permission']; } if ( ! current_user_can( 'activate_plugins' ) ) { $compatibilities['errors']['activate-plugin-permission'] = $data['activate-plugin-permission']; } return $compatibilities; } /** * Retrieves the original memory limit from the PHP configuration (php.ini) file. * * This is necessary because WordPress automatically increases the memory limit for admin requests, * so we need to fetch the original value from the PHP configuration file to check if it's sufficient. * * @since 4.4.16 */ public function get_original_memory_limit() { // This will fetch the original memory_limit from the server (php.ini). $memory_limit = get_cfg_var( 'memory_limit' ); // If get_cfg_var() fails, try accessing PHP configuration directly. if ( ! $memory_limit ) { $memory_limit = ini_get( 'memory_limit' ); } return $memory_limit; } /** * Register module required js on elementor's action. * * @since 2.0.0 */ public function register_widget_scripts() { $page_builders = self::get_instance()->get_page_builders(); $has_elementor = false; // Use this filter to remove the Starter Templates button from Elementor Editor. $elementor_add_ast_site_button = apply_filters( 'starter_templates_hide_elementor_button', false ); foreach ( $page_builders as $page_builder ) { if ( 'elementor' === $page_builder['slug'] ) { $has_elementor = true; } } if ( ! $has_elementor ) { return; } if ( $elementor_add_ast_site_button ) { return; } wp_enqueue_script( 'astra-sites-helper', ASTRA_SITES_URI . 'inc/assets/js/helper.js', array( 'jquery' ), ASTRA_SITES_VER, true ); wp_enqueue_script( 'masonry' ); wp_enqueue_script( 'imagesloaded' ); wp_enqueue_script( 'astra-sites-elementor-admin-page', ASTRA_SITES_URI . 'inc/assets/js/elementor-admin-page.js', array( 'jquery', 'wp-util', 'updates', 'masonry', 'imagesloaded' ), ASTRA_SITES_VER, true ); wp_add_inline_script( 'astra-sites-elementor-admin-page', sprintf( 'var pagenow = "%s";', ASTRA_SITES_NAME ), 'after' ); wp_enqueue_style( 'astra-sites-admin', ASTRA_SITES_URI . 'inc/assets/css/admin.css', ASTRA_SITES_VER, true ); wp_style_add_data( 'astra-sites-admin', 'rtl', 'replace' ); $license_status = false; if ( is_callable( 'BSF_License_Manager::bsf_is_active_license' ) ) { $license_status = BSF_License_Manager::bsf_is_active_license( 'astra-pro-sites' ); } /* translators: %s are link. */ $license_msg = sprintf( __( 'This is a premium template available with Essential and Business Toolkits. you can purchase it from here.', 'astra-sites' ), 'https://wpastra.com/starter-templates-plans/' ); if ( defined( 'ASTRA_PRO_SITES_NAME' ) ) { /* translators: %s are link. */ $license_msg = sprintf( __( 'This is a premium template available with Essential and Business Toolkits. Validate Your License Key to import this template.', 'astra-sites' ), esc_url( admin_url( 'plugins.php?bsf-inline-license-form=astra-pro-sites' ) ) ); } $last_viewed_block_data = array(); // Retrieve the value of the 'blockID' parameter using filter_input(). $id = filter_input( INPUT_GET, 'blockID', FILTER_SANITIZE_STRING ); if ( ! empty( $id ) ) { $last_viewed_block_data = get_option( 'astra_sites_import_elementor_data_' . $id ) !== false ? get_option( 'astra_sites_import_elementor_data_' . $id ) : array(); } $data = apply_filters( 'astra_sites_render_localize_vars', array( 'plugin_name' => Astra_Sites_White_Label::get_instance()->get_white_label_name(), 'sites' => astra_sites_get_api_params(), 'version' => ASTRA_SITES_VER, 'settings' => array(), 'page-builders' => array(), 'categories' => array(), 'default_page_builder' => 'elementor', 'astra_blocks' => $this->get_all_blocks(), 'license_status' => $license_status, 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), 'default_page_builder_sites' => Astra_Sites_Page::get_instance()->get_sites_by_page_builder( 'elementor' ), 'ApiURL' => $this->api_url, '_ajax_nonce' => current_user_can( 'edit_posts' ) ? wp_create_nonce( 'astra-sites' ) : '', 'isPro' => defined( 'ASTRA_PRO_SITES_NAME' ) ? true : false, 'license_msg' => $license_msg, 'isWhiteLabeled' => Astra_Sites_White_Label::get_instance()->is_white_labeled(), 'getProText' => __( 'Get Access!', 'astra-sites' ), 'getProURL' => esc_url( 'https://wpastra.com/starter-templates-plans/?utm_source=demo-import-panel&utm_campaign=astra-sites&utm_medium=wp-dashboard' ), 'astra_block_categories' => Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-blocks-categories.json' ), 'siteURL' => site_url(), 'template' => esc_html__( 'Template', 'astra-sites' ), 'block' => esc_html__( 'Block', 'astra-sites' ), 'dismiss_text' => esc_html__( 'Dismiss', 'astra-sites' ), 'install_plugin_text' => esc_html__( 'Install Required Plugins', 'astra-sites' ), 'syncCompleteMessage' => self::get_instance()->get_sync_complete_message(), /* translators: %s are link. */ 'page_settings' => array( 'message' => __( 'You can locate Starter Templates Settings under the Page Settings of the Style Tab.', 'astra-sites' ), 'url' => '#', 'url_text' => __( 'Read More →', 'astra-sites' ), ), 'last_viewed_block_data' => $last_viewed_block_data, ) ); wp_localize_script( 'astra-sites-elementor-admin-page', 'astraElementorSites', $data ); } /** * Register module required js on elementor's action. * * @since 2.0.0 */ public function popup_styles() { wp_enqueue_style( 'astra-sites-elementor-admin-page', ASTRA_SITES_URI . 'inc/assets/css/elementor-admin.css', ASTRA_SITES_VER, true ); wp_enqueue_style( 'astra-sites-elementor-admin-page-dark', ASTRA_SITES_URI . 'inc/assets/css/elementor-admin-dark.css', ASTRA_SITES_VER, true ); wp_style_add_data( 'astra-sites-elementor-admin-page', 'rtl', 'replace' ); } /** * Get all sites * * @since 2.0.0 * @return array All sites. */ public function get_all_sites() { $sites_and_pages = array(); $total_requests = (int) Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-sites-requests.json' ); for ( $page = 1; $page <= $total_requests; $page++ ) { $current_page_data = Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-sites-and-pages-page-' . $page . '.json' ); if ( ! empty( $current_page_data ) ) { foreach ( $current_page_data as $page_id => $page_data ) { $sites_and_pages[ $page_id ] = $page_data; } } } return $sites_and_pages; } /** * Get all sites * * @since 2.2.4 * @param string $option Site options name. * @return mixed Site Option value. */ public function get_api_option( $option ) { return get_site_option( $option, array() ); } /** * Get all blocks * * @since 2.0.0 * @return array All Elementor Blocks. */ public function get_all_blocks() { $blocks = array(); $total_requests = (int) Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-blocks-requests.json' ); for ( $page = 1; $page <= $total_requests; $page++ ) { $current_page_data = Astra_Sites_File_System::get_instance()->get_json_file_content( 'astra-blocks-' . $page . '.json' ); if ( ! empty( $current_page_data ) ) { foreach ( $current_page_data as $page_id => $page_data ) { $blocks[ $page_id ] = $page_data; } } } return $blocks; } /** * Load all the required files in the importer. * * @since 1.0.0 */ private function includes() { require_once ASTRA_SITES_DIR . 'inc/classes/functions.php'; require_once ASTRA_SITES_DIR . 'inc/classes/compatibility/class-astra-sites-compatibility.php'; // classes 'inc/classes/class-astra-sites-'. require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-update.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-utils.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-error-handler.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-white-label.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-page.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-elementor-pages.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-elementor-images.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-importer.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-wp-cli.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-file-system.php'; require_once ASTRA_SITES_DIR . 'inc/classes/class-astra-sites-nps-notice.php'; // libraries 'inc/lib/class-astra-sites-'. require_once ASTRA_SITES_DIR . 'inc/lib/onboarding/class-onboarding.php'; require_once ASTRA_SITES_DIR . 'inc/lib/class-astra-sites-ast-block-templates.php'; require_once ASTRA_SITES_DIR . 'inc/lib/class-astra-sites-zip-ai.php'; require_once ASTRA_SITES_DIR . 'inc/lib/class-astra-sites-zipwp-images.php'; require_once ASTRA_SITES_DIR . 'inc/lib/class-astra-sites-nps-survey.php'; } /** * After Plugin Activate * * @since 2.0.0 * * @param string $plugin_init Plugin Init File. * @param array $options Site Options. * @param array $enabled_extensions Enabled Extensions. * @return void */ public function after_plugin_activate( $plugin_init = '', $options = array(), $enabled_extensions = array() ) { $data = array( 'astra_site_options' => $options, 'enabled_extensions' => $enabled_extensions, ); do_action( 'astra_sites_after_plugin_activation', $plugin_init, $data ); } /** * Has Pro Version Support? * And * Is Pro Version Installed? * * Check Pro plugin version exist of requested plugin lite version. * * Eg. If plugin 'BB Lite Version' required to import demo. Then we check the 'BB Agency Version' is exist? * If yes then we only 'Activate' Agency Version. [We couldn't install agency version.] * Else we 'Activate' or 'Install' Lite Version. * * @since 1.0.1 * * @param string $lite_version Lite version init file. * @return mixed Return false if not installed or not supported by us * else return 'Pro' version details. */ public function pro_plugin_exist( $lite_version = '' ) { // Lite init => Pro init. $plugins = apply_filters( 'astra_sites_pro_plugin_exist', array( 'beaver-builder-lite-version/fl-builder.php' => array( 'slug' => 'bb-plugin', 'init' => 'bb-plugin/fl-builder.php', 'name' => 'Beaver Builder Plugin', ), 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' => array( 'slug' => 'bb-ultimate-addon', 'init' => 'bb-ultimate-addon/bb-ultimate-addon.php', 'name' => 'Ultimate Addon for Beaver Builder', ), 'wpforms-lite/wpforms.php' => array( 'slug' => 'wpforms', 'init' => 'wpforms/wpforms.php', 'name' => 'WPForms', ), ), $lite_version ); if ( isset( $plugins[ $lite_version ] ) ) { // Pro plugin directory exist? if ( file_exists( WP_PLUGIN_DIR . '/' . $plugins[ $lite_version ]['init'] ) ) { return $plugins[ $lite_version ]; } } return false; } /** * Get Default Page Builders * * @since 2.0.0 * @return array */ public function get_default_page_builders() { return array( array( 'id' => 42, 'slug' => 'gutenberg', 'name' => 'Gutenberg', ), array( 'id' => 33, 'slug' => 'elementor', 'name' => 'Elementor', ), array( 'id' => 34, 'slug' => 'beaver-builder', 'name' => 'Beaver Builder', ), array( 'id' => 41, 'slug' => 'brizy', 'name' => 'Brizy', ), ); } /** * Get Page Builders * * @since 2.0.0 * @return array */ public function get_page_builders() { return $this->get_default_page_builders(); } /** * Get Page Builder Filed * * @since 2.0.0 * @param string $page_builder Page Bulider. * @param string $field Field name. * @return mixed */ public function get_page_builder_field( $page_builder = '', $field = '' ) { if ( empty( $page_builder ) ) { return ''; } $page_builders = self::get_instance()->get_page_builders(); if ( empty( $page_builders ) ) { return ''; } foreach ( $page_builders as $key => $current_page_builder ) { if ( $page_builder === $current_page_builder['slug'] ) { if ( isset( $current_page_builder[ $field ] ) ) { return $current_page_builder[ $field ]; } } } return ''; } /** * Get License Key * * @since 2.0.0 * @return string */ public function get_license_key() { if ( class_exists( 'BSF_License_Manager' ) ) { if ( BSF_License_Manager::bsf_is_active_license( 'astra-pro-sites' ) ) { return BSF_License_Manager::instance()->bsf_get_product_info( 'astra-pro-sites', 'purchase_key' ); } } return ''; } /** * Get Sync Complete Message * * @since 2.0.0 * @param boolean $echo Echo the message. * @return mixed */ public function get_sync_complete_message( $echo = false ) { $message = __( 'Template library refreshed!', 'astra-sites' ); if ( $echo ) { echo esc_html( $message ); } else { return esc_html( $message ); } } /** * Get an instance of WP_Filesystem_Direct. * * @since 2.0.0 * @return mixed A WP_Filesystem_Direct instance. */ public static function get_filesystem() { global $wp_filesystem; require_once ABSPATH . '/wp-admin/includes/file.php'; WP_Filesystem(); return $wp_filesystem; } /** * Disable WP-Forms redirect. * * @return void. */ public function disable_wp_forms_redirect() { $wp_forms_redirect = get_transient( 'wpforms_activation_redirect' ); if ( ! empty( $wp_forms_redirect ) && '' !== $wp_forms_redirect ) { delete_transient( 'wpforms_activation_redirect' ); } } /** * Admin Dashboard Notices. * * @since 3.1.17 * @return void */ public function admin_dashboard_notices() { if ( defined( 'ASTRA_SITES_VER' ) ) { add_action( 'admin_notices', array( $this, 'admin_welcome_notices' ) ); } elseif ( defined( 'ASTRA_PRO_SITES_VER' ) ) { add_action( 'admin_notices', array( $this, 'admin_welcome_notices' ) ); } } /** * Admin Welcome Notice. * * @since 3.1.17 * @return void */ public function admin_welcome_notices() { $first_import_status = get_option( 'astra_sites_import_complete', false ); Astra_Notices::add_notice( array( 'id' => 'astra-sites-welcome-notice', 'type' => 'notice', 'class' => 'astra-sites-welcome', 'show_if' => ( false === Astra_Sites_White_Label::get_instance()->is_white_labeled() && empty( $first_import_status ) ), /* translators: %1$s white label plugin name and %2$s deactivation link */ 'message' => sprintf( '' . __( 'Say goodbye to the days of spending weeks designing and building your website.
You can now create professional-grade websites in minutes.', 'astra-sites' ) . '
' . esc_html__( 'Required WP_Filesystem Permissions to import the templates from Starter Templates are missing.', 'astra-sites' ) . '