Astra_Update_Sidebar_Width::execute( array $args )

Execute the ability.


Description


Parameters

$args

(array) (Required) Input arguments.


Return

(array) Result array.


Source

File: inc/abilities/customizer/general/sidebar/class-astra-update-sidebar-width.php

	public function execute( $args ) {
		if ( ! isset( $args['width'] ) ) {
			return Astra_Abilities_Response::error(
				__( 'Width is required.', 'astra' ),
				__( 'Please provide a width value between 15 and 50.', 'astra' )
			);
		}

		$width = absint( $args['width'] );

		if ( $width < 15 || $width > 50 ) {
			return Astra_Abilities_Response::error(
				sprintf(
					/* translators: %d: width value */
					__( 'Invalid width: %d.', 'astra' ),
					$width
				),
				__( 'Width must be between 15 and 50 percent.', 'astra' )
			);
		}

		astra_update_option( 'site-sidebar-width', $width );

		$message = sprintf(
			/* translators: %d: width percentage */
			__( 'Sidebar width set to %d%%.', 'astra' ),
			$width
		);

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


User Contributed Notes

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