File manager - Edit - /home/aresglob/public_html/wp/wp-includes/images/smilies/ajax.tar
Back
plugin.php 0000644 00000026144 15104004624 0006556 0 ustar 00 <?php /** * Plugin ajax actions. * * @package AiBuilder */ namespace AiBuilder\Inc\Ajax; // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } use AiBuilder\Inc\Classes\Importer\Ai_Builder_Error_Handler; use AiBuilder\Inc\Classes\Zipwp\Ai_Builder_ZipWP_Integration; use AiBuilder\Inc\Traits\Helper; use AiBuilder\Inc\Traits\Instance; use STImporter\Importer\ST_Importer; use STImporter\Importer\ST_Importer_Helper; /** * Class Flows. */ class Plugin extends AjaxBase { use Instance; /** * Ajax Instance * * @access private * @var object Class object. * @since 1.0.42 */ private static $ajax_instance = null; /** * Initiator * * @since 1.0.42 * @return object initialized object of class. */ public static function get_instance() { if ( null === self::$ajax_instance ) { self::$ajax_instance = new self(); } return self::$ajax_instance; } /** * Register_ajax_events. * * @return void */ public function register_ajax_events() { $ajax_events = array( 'required_plugins', 'required_plugin_activate', 'filesystem_permission', 'set_start_flag', 'download_image', 'report_error', 'activate_theme', 'site_language', ); $this->init_ajax_events( $ajax_events ); } /** * Required Plugins * * @since 2.0.0 * * @param array<int, array<string, string>> $required_plugins Required Plugins. * @param array<string, mixed> $options Site Options. * @param array<string, mixed> $enabled_extensions Enabled Extensions. * @return mixed */ public function required_plugins( $required_plugins = array(), $options = array(), $enabled_extensions = array() ) { Helper::required_plugins( $required_plugins, $options, $enabled_extensions ); } /** * Required Plugin Activate * * @since 2.0.0 Added parameters $init, $options & $enabled_extensions to add the WP CLI support. * @since 1.0.0 * @param string $init Plugin init file. * @param array<string, mixed> $options Site options. * @param array<string, mixed> $enabled_extensions Enabled extensions. * @return void */ public function required_plugin_activate( $init = '', $options = array(), $enabled_extensions = array() ) { Helper::required_plugin_activate( $init, $options, $enabled_extensions ); } /** * Get the status of file system permission of "/wp-content/uploads" directory. * * @return void */ public function filesystem_permission() { Helper::filesystem_permission(); } /** * Set a flag that indicates the import process has started. * * @return void */ public function set_start_flag() { if ( ! defined( 'WP_CLI' ) && wp_doing_ajax() ) { // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'customize' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } } $uuid = isset( $_POST['uuid'] ) ? sanitize_text_field( $_POST['uuid'] ) : ''; $template_type = isset( $_POST['template_type'] ) ? sanitize_text_field( $_POST['template_type'] ) : ''; if ( class_exists( 'STImporter\Importer\ST_Importer' ) ) { ST_Importer::set_import_process_start_flag( $template_type, $uuid ); wp_send_json_success(); } else { wp_send_json_error( __( 'Required function not found', 'astra-sites' ) ); } } /** * Download Images * * @since 4.1.0 * @return void */ public function download_image() { check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( array( 'data' => 'You do not have permission to do this action.', 'status' => false, ) ); } $index = isset( $_POST['index'] ) ? sanitize_text_field( wp_unslash( $_POST['index'] ) ) : ''; $images = Ai_Builder_ZipWP_Integration::get_business_details( 'images' ); if ( empty( $images ) || ! is_array( $images ) ) { wp_send_json_success( array( 'data' => 'No images selected to download!', 'status' => true, ) ); } $image = $images[ $index ]; if ( empty( $image ) || ! is_array( $image ) ) { wp_send_json_success( array( 'data' => 'No image to download!', 'status' => true, ) ); } $prepare_image = array( 'id' => $image['id'], 'url' => $image['url'], 'description' => isset( $image['description'] ) ? $image['description'] : '', ); $id = class_exists( 'STImporter\Importer\ST_Importer_Helper' ) ? ST_Importer_Helper::download_image( $prepare_image ) : 0; wp_send_json_success( array( 'data' => 'Image downloaded successfully!', 'status' => true, ) ); } /** * Report Error. * * @since 3.0.0 * @return void */ public function report_error() { check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( array( 'data' => 'You do not have permission to do this action.', 'status' => false, ) ); } $api_domain = class_exists( 'STImporter\Importer\ST_Importer_Helper' ) ? ST_Importer_Helper::get_api_domain() : ''; $api_url = add_query_arg( [], trailingslashit( $api_domain ) . 'wp-json/starter-templates/v2/import-error/' ); if ( ! astra_sites_is_valid_url( $api_url ) ) { wp_send_json_error( array( /* Translators: %s is URL. */ 'message' => sprintf( __( 'Invalid URL - %s', 'astra-sites' ), $api_url ), 'code' => 'Error', ) ); } $id = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : 0; $user_agent_string = isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ) : ''; $error = isset( $_POST['error'] ) ? json_decode( stripslashes( $_POST['error'] ), true ) : array(); $local_storage = isset( $_POST['local_storage'] ) ? json_decode( stripslashes( $_POST['local_storage'] ), true ) : array(); $ai_import_logger = get_option( 'ai_import_logger', array() ); $ai_import_logger = array( 'time' => current_time( 'mysql' ), 'data' => array( 'user_agent' => $user_agent_string, 'id' => $id, 'error' => $error, ), ); update_option( 'ai_import_logger', $ai_import_logger ); $api_args = array( 'timeout' => 3, 'blocking' => true, 'body' => array( 'url' => esc_url( site_url() ), 'err' => stripslashes( $_POST['error'] ), 'id' => $_POST['id'], 'logfile' => $this->get_log_file_path(), 'version' => AI_BUILDER_VER, 'abspath' => ABSPATH, 'user_agent' => $user_agent_string, 'server' => array( 'php_version' => Helper::get_php_version(), 'php_post_max_size' => ini_get( 'post_max_size' ), 'php_max_execution_time' => ini_get( 'max_execution_time' ), 'max_input_time' => ini_get( 'max_input_time' ), 'php_memory_limit' => ini_get( 'memory_limit' ), 'php_max_input_vars' => ini_get( 'max_input_vars' ), // phpcs:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound ), 'builder_type' => isset( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : '', 'page_builder' => isset( $_POST['page_builder'] ) ? sanitize_text_field( $_POST['page_builder'] ) : '', 'template_type' => isset( $_POST['template_type'] ) ? sanitize_text_field( $_POST['template_type'] ) : '', ), ); do_action( 'st_before_sending_error_report', $api_args['body'] ); $request = wp_safe_remote_post( $api_url, $api_args ); do_action( 'st_after_sending_error_report', $api_args['body'], $request ); $failed_sites = get_option( 'astra_sites_import_failed_sites', array() ); $last_import_site = get_option( 'zipwp_import_site_details', array() ); if ( ! is_array( $failed_sites ) ) { $failed_sites = array(); } $uuids = array_map( static function( $site ) { return $site['uuid']; }, $failed_sites ); if ( is_array( $last_import_site ) && ! in_array( $last_import_site['uuid'], $uuids, true ) ) { $last_import_site['template_id'] = $id; $last_import_site['local_storage'] = $local_storage; $failed_sites[] = $last_import_site; update_option( 'astra_sites_import_failed_sites', $failed_sites ); } if ( is_wp_error( $request ) ) { wp_send_json_error( $request ); } $code = (int) wp_remote_retrieve_response_code( $request ); $data = json_decode( wp_remote_retrieve_body( $request ), true ); if ( 200 === $code ) { wp_send_json_success( $data ); } wp_send_json_error( $data ); } /** * Get full path of the created log file. * * @return string File Path. * @since 3.0.25 */ public function get_log_file_path() { $log_file = get_option( 'astra_sites_recent_import_log_file', false ); if ( ! empty( $log_file ) && is_string( $log_file ) ) { return str_replace( ABSPATH, esc_url( site_url() ) . '/', $log_file ); } return ''; } /** * Activate theme * * @since 1.3.2 * @return void */ public function activate_theme() { // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'customize' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } Ai_Builder_Error_Handler::Instance()->start_error_handler(); switch_theme( 'astra' ); Ai_Builder_Error_Handler::Instance()->stop_error_handler(); /** * Fires after the theme activation. * * @param string $theme_slug The slug of the theme that was activated. * @since 1.2.29 */ do_action( 'astra_sites_after_theme_activation', 'astra' ); wp_send_json_success( array( 'success' => true, 'message' => __( 'Theme Activated', 'astra-sites' ), ) ); } /** * Set site language. * * @since 1.0.0 * @return void */ public function site_language() { if ( ! defined( 'WP_CLI' ) && wp_doing_ajax() ) { // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'customize' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } } if ( ! wp_doing_ajax() ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } $language = isset( $_POST['language'] ) ? sanitize_text_field( $_POST['language'] ) : 'en_US'; $result = $this->set_language( $language ); if ( ! $result ) { wp_send_json_error( __( 'Failed to set the site language.', 'astra-sites' ) ); } wp_send_json_success(); } /** * Set the site language. * * @since 1.0.0 * * @param string $language The language code. * @return bool */ public function set_language( $language = 'en_US' ) { require_once ABSPATH . 'wp-admin/includes/translation-install.php'; $locale_code = 'en_US' === $language ? '' : $language; if ( '' !== $locale_code && wp_can_install_language_pack() ) { $language = wp_download_language_pack( $locale_code ); } if ( ( '' === $locale_code ) || ( '' !== $locale_code && $language ) ) { update_option( 'WPLANG', $locale_code ); load_default_textdomain( $locale_code ); return switch_to_locale( $locale_code ); } return false; } } ajax-errors.php 0000644 00000002011 15104004624 0007500 0 ustar 00 <?php /** * Ai Builder Ajax Errors. * * @package Ai Builder */ namespace AiBuilder\Inc\Ajax; use AiBuilder\Inc\Traits\Instance; // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Class AjaxErrors */ class AjaxErrors { use Instance; /** * Errors * * @access private * @var array<string, string> Errors strings. * @since 1.0.0 */ private static $errors = array(); /** * Constructor * * @since 1.0.0 */ public function __construct() { self::$errors = array( 'permission' => __( 'Sorry, you are not allowed to do this operation.', 'astra-sites' ), 'nonce' => __( 'Nonce validation failed', 'astra-sites' ), 'default' => __( 'Sorry, something went wrong.', 'astra-sites' ), ); } /** * Get error message. * * @param string $type Message type. * @return string */ public function get_error_msg( $type ) { if ( ! isset( self::$errors[ $type ] ) ) { $type = 'default'; } return self::$errors[ $type ]; } } AjaxErrors::Instance(); ajax-init.php 0000644 00000002564 15104004624 0007144 0 ustar 00 <?php /** * AiBuilder Ajax Initialize. * * @package AiBuilder */ namespace AiBuilder\Inc\Ajax; use AiBuilder\Inc\Traits\Instance; // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Class Admin_Init. */ class AjaxInit { use Instance; /** * Ajax Instance * * @access private * @var object Class object. * @since 1.0.42 */ private static $ajax_instance = null; /** * Constructor * * @since 1.0.0 */ public function __construct() { $this->initialize_hooks(); } /** * Initiator * * @since 1.0.42 * @return object initialized object of class. */ public static function get_instance() { if ( null === self::$ajax_instance ) { self::$ajax_instance = new self(); } return self::$ajax_instance; } /** * Init Hooks. * * @since 1.0.0 * @return void */ public function initialize_hooks() { $this->register_all_ajax_events(); } /** * Register API routes. * * @return void */ public function register_all_ajax_events() { $controllers = array( 'AiBuilder\Inc\Ajax\Importer', 'AiBuilder\Inc\Ajax\Plugin', ); foreach ( $controllers as $controller ) { if ( class_exists( $controller ) && method_exists( $controller::get_instance(), 'register_ajax_events' ) ) { $controller::get_instance()->register_ajax_events(); // @phpstan-ignore-line } } } } AjaxInit::Instance(); importer.php 0000644 00000042217 15104004624 0007120 0 ustar 00 <?php /** * Import ajax actions. * * @package AiBuilder */ namespace AiBuilder\Inc\Ajax; // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } use AiBuilder\Inc\Classes\Ai_Builder_Importer_Log; use AiBuilder\Inc\Classes\Importer\Ai_Builder_Fse_Importer; use AiBuilder\Inc\Classes\Importer\Ai_Builder_Utils; use AiBuilder\Inc\Classes\Zipwp\Ai_Builder_ZipWP_Integration; use AiBuilder\Inc\Traits\Helper; use AiBuilder\Inc\Traits\Instance; use STImporter\Importer\Batch\ST_Batch_Processing_Elementor; use STImporter\Importer\Batch\ST_Batch_Processing_Gutenberg; use STImporter\Importer\Batch\ST_Batch_Processing_Misc; use STImporter\Importer\ST_Importer; use STImporter\Importer\ST_Importer_Helper; use STImporter\Resetter\ST_Resetter; /** * Class Flows. */ class Importer extends AjaxBase { use Instance; /** * Ajax Instance * * @access private * @var object Class object. * @since 1.0.42 */ private static $ajax_instance = null; /** * Constructor */ public function __construct() { add_action( 'astra_sites_import_complete', array( $this, 'update_required_options' ) ); } /** * Initiator * * @since 1.0.42 * @return object initialized object of class. */ public static function get_instance() { if ( null === self::$ajax_instance ) { self::$ajax_instance = new self(); } return self::$ajax_instance; } /** * Update options. * * @return void */ public function update_required_options() { update_option( 'astra_sites_import_complete', 'yes', false ); update_option( 'getting_started_is_setup_wizard_showing', true ); if ( 'ai' === get_option( 'astra_sites_current_import_template_type' ) ) { update_option( 'astra_sites_batch_process_complete', 'yes' ); delete_option( 'ai_import_logger' ); delete_option( 'astra_sites_import_failed_sites' ); } else { update_option( 'astra_sites_batch_process_complete', 'no' ); } delete_option( 'astra_sites_import_started' ); } /** * Register_ajax_events. * * @return void */ public function register_ajax_events() { $ajax_events = array( // Import Part 1 Start. 'backup_settings', 'reset_customizer_data', 'reset_site_options', 'reset_widgets_data', 'reset_terms_and_forms', 'get_deleted_post_ids', 'reset_posts', 'download_selected_image', 'import_customizer_settings', 'import_spectra_settings', 'import_surecart_settings', // Import Part 1 End. // Import Part 2 Start. 'import_options', 'import_widgets', 'page_builder_batch', 'image_replacement_batch', 'import_end', 'set_site_data', 'import_success', // Import Part 2 End. ); $this->init_ajax_events( $ajax_events ); } /** * Backup our existing settings. * * @return void */ public function backup_settings() { Helper::backup_settings(); } /** * Reset posts in chunks. * * @return void * * @since 3.0.8 */ public function reset_posts() { if ( wp_doing_ajax() ) { check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } } if ( class_exists( 'STImporter\Resetter\ST_Resetter' ) ) { ST_Resetter::reset_posts(); } if ( wp_doing_ajax() ) { wp_send_json_success(); } } /** * Import Success. * * @return void * * @since 1.2.15 */ public function import_success() { if ( wp_doing_ajax() ) { check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } } do_action( 'astra_sites_import_success' ); wp_send_json_success(); } /** * Reset customizer data * * @since 1.3.0 * @return void */ public function reset_customizer_data() { Helper::reset_customizer_data(); } /** * Reset site options * * @since 1.3.0 * @return void */ public function reset_site_options() { Helper::reset_site_options(); } /** * Reset widgets data * * @since 1.3.0 * @return void */ public function reset_widgets_data() { Helper::reset_widgets_data(); } /** * Reset terms and forms. * * @return void * * @since 3.0.3 */ public function reset_terms_and_forms() { if ( wp_doing_ajax() ) { check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } } if ( class_exists( 'STImporter\Resetter\ST_Resetter' ) ) { ST_Resetter::reset_terms_and_forms(); } if ( wp_doing_ajax() ) { wp_send_json_success(); } } /** * Get post IDs to be deleted. * * @return void */ public function get_deleted_post_ids() { if ( wp_doing_ajax() ) { check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } } wp_send_json_success( astra_sites_get_reset_post_data() ); } /** * Download Images * * @since 4.1.0 * @return void */ public function download_selected_image() { check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( array( 'data' => 'You do not have permission to do this action.', 'status' => false, ) ); } $index = isset( $_POST['index'] ) ? sanitize_text_field( wp_unslash( $_POST['index'] ) ) : ''; $images = Ai_Builder_ZipWP_Integration::get_business_details( 'images' ); if ( empty( $images ) || ! is_array( $images ) ) { wp_send_json_error( array( 'data' => 'Image not downloaded!', 'status' => true, ) ); } $image = $images[ $index ]; if ( empty( $image ) || ! is_array( $image ) ) { wp_send_json_error( array( 'data' => 'Image not downloaded!', 'status' => true, ) ); } $prepare_image = array( 'id' => $image['id'], 'url' => $image['url'], 'description' => $image['description'], ); Ai_Builder_Importer_Log::add( 'Downloading Image ' . $image['url'] ); if ( class_exists( 'STImporter\Importer\ST_Importer_Helper' ) ) { $id = ST_Importer_Helper::download_image( $prepare_image ); Ai_Builder_Importer_Log::add( 'Downloaded Image attachment id: ' . $id ); wp_send_json_success( array( 'data' => 'Image downloaded successfully!', 'status' => true, ) ); } wp_send_json_error( array( 'data' => 'Required function not found!', 'status' => false, ) ); } /** * Import Customizer Settings. * * @since 1.0.14 * @since 1.4.0 The `$customizer_data` was added. * * @return void */ public function import_customizer_settings() { Helper::import_customizer_settings(); } /** * Import Spectra Settings * * @since 3.1.16 * * @param string $url Spectra Settings JSON file URL. * @return void */ public function import_spectra_settings( $url = '' ) { check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'edit_posts' ) ) { wp_send_json_error( array( 'error' => __( 'Permission Denied!', 'astra-sites' ), ) ); } $settings = astra_get_site_data( 'astra-site-spectra-options' ); if ( class_exists( 'STImporter\Importer\ST_Importer' ) ) { $result = ST_Importer::import_spectra_settings( $settings ); if ( false === $result['status'] ) { if ( defined( 'WP_CLI' ) ) { \WP_CLI::line( $result['error'] ); } elseif ( wp_doing_ajax() ) { wp_send_json_error( $result['error'] ); } } if ( defined( 'WP_CLI' ) ) { \WP_CLI::line( 'Imported Spectra settings from ' . $url ); } elseif ( wp_doing_ajax() ) { wp_send_json_success( $url ); } } wp_send_json_error( __( 'There was an error importing the Spectra settings.', 'astra-sites' ) ); } /** * Import Surecart Settings * * @since 3.3.0 * @return void */ public function import_surecart_settings() { check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } $id = isset( $_POST['source_id'] ) ? base64_decode( sanitize_text_field( $_POST['source_id'] ) ) : ''; //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode if ( class_exists( 'STImporter\Importer\ST_Importer' ) ) { $result = ST_Importer::import_surecart_settings( $id ); if ( ! is_wp_error( $result ) ) { wp_send_json_success( 'success' ); } } wp_send_json_error( __( 'There was an error cloning the surecart store.', 'astra-sites' ) ); } /** * Import Options. * * @since 1.0.14 * @since 1.4.0 The `$options_data` was added. * * @return void */ public function import_options() { Helper::import_options(); } /** * Import Widgets. * * @since 1.0.14 * @since 1.4.0 The `$widgets_data` was added. * * @return void */ public function import_widgets() { Helper::import_widgets(); } /** * Processing GT batch. * * @since 1.0.14 * @return void */ public function page_builder_batch() { if ( ! defined( 'WP_CLI' ) && wp_doing_ajax() ) { // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'customize' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } } $required_plugins = (array) astra_get_site_data( 'required-plugins' ); $plugins_slug = array_column( $required_plugins, 'slug' ); $status = array( 'status' => false, 'msg' => __( 'Required function not found', 'astra-sites' ), ); if ( in_array( 'elementor', $plugins_slug, true ) ) { $status = class_exists( 'STImporter\Importer\Batch\ST_Batch_Processing_Elementor' ) ? ST_Batch_Processing_Elementor::get_instance()->import() : $status; } else { $status = class_exists( 'STImporter\Importer\Batch\ST_Batch_Processing_Gutenberg' ) ? ST_Batch_Processing_Gutenberg::get_instance()->import() : $status; } if ( wp_doing_ajax() ) { if ( $status['success'] ) { wp_send_json_success( $status['msg'] ); } else { wp_send_json_error( $status['msg'] ); } } } /** * Processing GT batch. * * @since 1.0.14 * @return void */ public function image_replacement_batch() { if ( ! defined( 'WP_CLI' ) && wp_doing_ajax() ) { // Verify Nonce. check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'customize' ) ) { wp_send_json_error( __( 'You are not allowed to perform this action', 'astra-sites' ) ); } } $status = class_exists( 'STImporter\Importer\Batch\ST_Batch_Processing_Misc' ) ? ST_Batch_Processing_Misc::get_instance()->import() : array( 'status' => false, 'msg' => __( 'Required function not found', 'astra-sites' ), ); if ( wp_doing_ajax() ) { if ( $status['success'] ) { wp_send_json_success( $status['msg'] ); } else { wp_send_json_error( $status['msg'] ); } } } /** * Import End. * * @since 1.0.14 * @return void */ public function import_end() { Helper::import_end(); } /** * Set site related data. * * @since 3.0.0-beta.1 * @return void */ public function set_site_data() { if ( 'spectra-one' === get_option( 'stylesheet', 'astra' ) ) { Ai_Builder_Fse_Importer::set_fse_site_data(); return; } check_ajax_referer( 'astra-sites', '_ajax_nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( array( 'success' => false, 'message' => __( 'You are not authorized to perform this action.', 'astra-sites' ), ) ); } $param = isset( $_POST['param'] ) ? sanitize_text_field( $_POST['param'] ) : ''; if ( empty( $param ) ) { wp_send_json_error( array( 'error' => __( 'Received empty parameters.', 'astra-sites' ), ) ); } switch ( $param ) { case 'site-title': $business_name = isset( $_POST['business-name'] ) ? sanitize_text_field( stripslashes( $_POST['business-name'] ) ) : ''; if ( ! empty( $business_name ) ) { update_option( 'blogname', $business_name ); } if ( isset( $_POST['show-site-title'] ) ) { // Get the value of the POST variable. $show_site_title = filter_var( $_POST['show-site-title'], FILTER_VALIDATE_BOOLEAN ); // Determine the array based on the value of the POST variable. $options_array = $show_site_title ? array( 'desktop' => true, 'tablet' => true, 'mobile' => true, ) : array( 'desktop' => false, 'tablet' => false, 'mobile' => false, ); // Update the option in the database. astra_update_option( 'display-site-title-responsive', $options_array ); astra_update_option( 'display-site-title', $show_site_title ); } break; case 'site-logo' === $param && function_exists( 'astra_get_option' ): $logo_id = isset( $_POST['logo'] ) ? intval( $_POST['logo'] ) : 0; $width_index = 'ast-header-responsive-logo-width'; set_theme_mod( 'custom_logo', $logo_id ); if ( ! empty( $logo_id ) ) { // Disable site title when logo is set. astra_update_option( 'display-site-title', false ); } // Set logo width. $logo_width = isset( $_POST['logo-width'] ) ? sanitize_text_field( $_POST['logo-width'] ) : ''; $option = astra_get_option( $width_index ); if ( isset( $option['desktop'] ) ) { $option['desktop'] = $logo_width; } astra_update_option( $width_index, $option ); // Check if transparent header is used in the demo. $transparent_header = astra_get_option( 'transparent-header-logo', false ); $inherit_desk_logo = astra_get_option( 'different-transparent-logo', false ); if ( '' !== $transparent_header && $inherit_desk_logo ) { astra_update_option( 'transparent-header-logo', wp_get_attachment_url( $logo_id ) ); $width_index = 'transparent-header-logo-width'; $option = astra_get_option( $width_index ); if ( isset( $option['desktop'] ) ) { $option['desktop'] = $logo_width; } astra_update_option( $width_index, $option ); } $retina_logo = astra_get_option( 'different-retina-logo', false ); if ( '' !== $retina_logo ) { astra_update_option( 'ast-header-retina-logo', wp_get_attachment_url( $logo_id ) ); } $transparent_retina_logo = astra_get_option( 'different-transparent-retina-logo', false ); if ( '' !== $transparent_retina_logo ) { astra_update_option( 'transparent-header-retina-logo', wp_get_attachment_url( $logo_id ) ); } break; case 'site-colors' === $param && function_exists( 'astra_get_option' ): $palette = isset( $_POST['palette'] ) ? (array) json_decode( stripslashes( $_POST['palette'] ) ) : array(); $colors = isset( $palette['colors'] ) ? (array) $palette['colors'] : array(); if ( ! empty( $colors ) ) { $global_palette = astra_get_option( 'global-color-palette' ); $color_palettes = get_option( 'astra-color-palettes', \Astra_Global_Palette::get_default_color_palette() ); if ( is_array( $color_palettes ) ) { foreach ( $colors as $key => $color ) { $global_palette['palette'][ $key ] = $color; $color_palettes['palettes']['palette_1'][ $key ] = $color; } } update_option( 'astra-color-palettes', $color_palettes ); astra_update_option( 'global-color-palette', $global_palette ); } break; case 'site-typography' === $param && function_exists( 'astra_get_option' ): $typography = isset( $_POST['typography'] ) ? (array) json_decode( stripslashes( $_POST['typography'] ) ) : ''; $font_size_body = isset( $typography['font-size-body'] ) ? (array) $typography['font-size-body'] : ''; if ( ! empty( $font_size_body ) && is_array( $font_size_body ) ) { astra_update_option( 'font-size-body', $font_size_body ); } if ( ! empty( $typography['body-font-family'] ) ) { astra_update_option( 'body-font-family', $typography['body-font-family'] ); } if ( ! empty( $typography['body-font-variant'] ) ) { astra_update_option( 'body-font-variant', $typography['body-font-variant'] ); } if ( ! empty( $typography['body-font-weight'] ) ) { astra_update_option( 'body-font-weight', $typography['body-font-weight'] ); } if ( ! empty( $typography['body-line-height'] ) ) { astra_update_option( 'body-line-height', $typography['body-line-height'] ); } if ( ! empty( $typography['headings-font-family'] ) ) { astra_update_option( 'headings-font-family', $typography['headings-font-family'] ); } if ( ! empty( $typography['headings-font-weight'] ) ) { astra_update_option( 'headings-font-weight', $typography['headings-font-weight'] ); } if ( ! empty( $typography['headings-line-height'] ) ) { astra_update_option( 'headings-line-height', $typography['headings-line-height'] ); } if ( ! empty( $typography['headings-font-variant'] ) ) { astra_update_option( 'headings-font-variant', $typography['headings-font-variant'] ); } break; } // Clearing Cache on hostinger, Cloudways. Ai_Builder_Utils::third_party_cache_plugins_clear_cache(); wp_send_json_success(); } } ajax-base.php 0000644 00000002140 15104004624 0007101 0 ustar 00 <?php /** * AiBuilder Ajax Base. * * @package AiBuilder */ namespace AiBuilder\Inc\Ajax; // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Class Admin_Menu. */ abstract class AjaxBase { /** * Ajax action prefix. * * @var string */ private $prefix = 'astra-sites'; /** * Constructor * * @since 1.0.0 */ public function __construct() { } /** * Register ajax events. * * @param array<int, string> $ajax_events Ajax events. * * @return void */ public function init_ajax_events( $ajax_events ) { if ( ! empty( $ajax_events ) ) { foreach ( $ajax_events as $ajax_event ) { add_action( 'wp_ajax_' . $this->prefix . '-' . $ajax_event, array( $this, $ajax_event ) ); // @phpstan-ignore-line } } } /** * Get ajax error message. * * @param string $type Message type. * @return string */ public function get_error_msg( $type ) { if ( class_exists( 'AiBuilder\Inc\Ajax\AjaxErrors' ) && method_exists( AjaxErrors::Instance(), 'get_error_msg' ) ) { return AjaxErrors::Instance()->get_error_msg( $type ); } return ''; } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings