Astra_Update_Sidebar_Style::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-style.php

	public function execute( $args ) {
		if ( ! isset( $args['style'] ) ) {
			return Astra_Abilities_Response::error(
				__( 'Style is required.', 'astra' ),
				__( 'Please provide a style: unboxed or boxed.', 'astra' )
			);
		}

		$style        = sanitize_text_field( $args['style'] );
		$valid_styles = array( 'unboxed', 'boxed' );

		if ( ! in_array( $style, $valid_styles, true ) ) {
			return Astra_Abilities_Response::error(
				sprintf(
					/* translators: %s: style value */
					__( 'Invalid style: %s.', 'astra' ),
					$style
				),
				__( 'Valid options: unboxed, boxed', 'astra' )
			);
		}

		$style_labels = array(
			'unboxed' => 'Unboxed',
			'boxed'   => 'Boxed',
		);

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

		$message = sprintf(
			/* translators: %s: style label */
			__( 'Sidebar style set to %s.', 'astra' ),
			$style_labels[ $style ]
		);

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


User Contributed Notes

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