Astra_Update_Paragraph_Margin::execute( array $args )

Execute the ability.


Description


Parameters

$args

(array) (Required) Input arguments.


Return

(array) Result array.


Source

File: inc/abilities/customizer/globals/typography/class-astra-update-paragraph-margin.php

	public function execute( $args ) {
		if ( ! isset( $args['margin_bottom'] ) ) {
			return Astra_Abilities_Response::error(
				__( 'Margin bottom is required.', 'astra' ),
				''
			);
		}

		$margin_bottom = floatval( $args['margin_bottom'] );

		// Validate range.
		if ( $margin_bottom < 0.5 || $margin_bottom > 5 ) {
			return Astra_Abilities_Response::error(
				__( 'Invalid margin value.', 'astra' ),
				__( 'Margin bottom must be between 0.5 and 5 em.', 'astra' )
			);
		}

		astra_update_option( 'para-margin-bottom', $margin_bottom );

		return Astra_Abilities_Response::success(
			/* translators: %s: margin bottom value */
			sprintf( __( 'Paragraph margin bottom updated to %s em.', 'astra' ), $margin_bottom ),
			array(
				'margin_bottom' => $margin_bottom,
			)
		);
	}


User Contributed Notes

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