Astra_Update_Load_Google_Fonts_Locally::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-update-load-google-fonts-locally.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' )
			);
		}

		if ( ! isset( $args['enabled'] ) ) {
			return Astra_Abilities_Response::error(
				__( 'Enabled status is required.', 'astra' ),
				__( 'Please provide enabled as true or false.', 'astra' )
			);
		}

		$enabled = (bool) $args['enabled'];

		Astra_API_Init::update_admin_settings_option( 'self_hosted_gfonts', $enabled );

		/* translators: %s: enabled or disabled */
		$message = sprintf( __( 'Load Google Fonts Locally %s.', 'astra' ), $enabled ? 'enabled' : 'disabled' );

		return Astra_Abilities_Response::success(
			$message,
			array(
				'updated' => true,
				'enabled' => $enabled,
			)
		);
	}


User Contributed Notes

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