Astra_Customizer::logo_svg_icons()

Handles the AJAX request for logo SVG icons.


Description

The main purpose of handling this via AJAX is to improve Customizer performance.


Return

(array) The array of logo SVG icons.


Source

File: inc/customizer/class-astra-customizer.php

		public function logo_svg_icons() {
			// Check if the current user has the capability to edit theme options.
			if ( ! current_user_can( 'edit_theme_options' ) ) {
				wp_send_json_error( __( 'You are not allowed to access this resource.', 'astra' ) );
			}

			// Check if the current request is an AJAX request and if it is being done in the Customizer screen.
			if ( ! is_admin() || ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
				wp_send_json_error( __( 'This request is only allowed in the Customizer screen.', 'astra' ) );
			}

			wp_send_json_success(
				array(
					'icons' => function_exists( 'astra_get_logo_svg_icons_array' ) ? astra_get_logo_svg_icons_array() : array(),
				)
			);
		}

User Contributed Notes

You must log in before being able to contribute a note or feedback.