Astra_Update_Heading_Font::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-heading-font.php
public function execute( $args ) {
$tag = 'h' . $this->level;
if ( isset( $args['font_family'] ) ) {
$font_family = sanitize_text_field( $args['font_family'] );
$formatted_font = "'" . $font_family . "', sans-serif";
astra_update_option( 'font-family-' . $tag, $formatted_font );
}
if ( isset( $args['font_weight'] ) ) {
astra_update_option( 'font-weight-' . $tag, sanitize_text_field( $args['font_weight'] ) );
}
if ( isset( $args['font_size'] ) && is_array( $args['font_size'] ) ) {
$existing = astra_get_option( 'font-size-' . $tag, array() );
$merged = array_merge( $existing, $args['font_size'] );
astra_update_option( 'font-size-' . $tag, Astra_Abilities_Helper::sanitize_responsive_typo( $merged ) );
}
Astra_Abilities_Helper::update_font_extras( $args, $tag . '-font-extras' );
return Astra_Abilities_Response::success(
/* translators: %s: heading tag */
sprintf( __( '%s font settings updated successfully.', 'astra' ), strtoupper( $tag ) ),
array(
'font_family' => astra_get_option( 'font-family-' . $tag, '' ),
'font_weight' => astra_get_option( 'font-weight-' . $tag, '' ),
'font_size' => astra_get_option( 'font-size-' . $tag, array() ),
'font_extras' => astra_get_option( $tag . '-font-extras', array() ),
)
);
}
Expand full source code Collapse full source code View on Trac