Astra_Flush_Local_Fonts::execute( array $args )

Execute the ability.


Description


Parameters

$args

(array) (Required) Input arguments.


Return

(array) Result array.


Source

File: inc/abilities/admin/settings/performance/class-astra-flush-local-fonts.php

	public function execute( $args ) {
		if ( ! defined( 'ASTRA_THEME_SETTINGS' ) ) {
			return Astra_Abilities_Response::error(
				__( 'Astra theme is not active.', 'astra' ),
				__( 'Please activate the Astra theme to use this feature.', 'astra' )
			);
		}

		if ( ! class_exists( 'Astra_API_Init' ) ) {
			return Astra_Abilities_Response::error(
				__( 'Astra API not available.', 'astra' ),
				__( 'Please ensure Astra theme is properly loaded.', 'astra' )
			);
		}

		$load_locally_enabled = Astra_API_Init::get_admin_settings_option( 'self_hosted_gfonts', false );

		if ( ! $load_locally_enabled ) {
			return Astra_Abilities_Response::error(
				__( 'Cannot flush local fonts cache.', 'astra' ),
				__( 'Load Google Fonts Locally must be enabled first.', 'astra' )
			);
		}

		$fonts_folder = $this->get_fonts_folder();

		if ( $fonts_folder && is_dir( $fonts_folder ) ) {
			$this->delete_fonts_folder( $fonts_folder );
		}

		do_action( 'astra_regenerate_fonts_folder' );

		return Astra_Abilities_Response::success(
			__( 'Local fonts cache flushed successfully.', 'astra' ),
			array(
				'flushed' => true,
			)
		);
	}


User Contributed Notes

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