<?php
/**
 * @package The Business Blocks
 */

function the_business_blocks_customizer_add_defaults( $default_options) {
	$defaults = array(
		'the_business_blocks_excerpt_length'    => 30,
	);
	$updated_defaults = wp_parse_args( $defaults, $default_options );

	return $updated_defaults;
}
add_filter( 'the_business_blocks_customizer_defaults', 'the_business_blocks_customizer_add_defaults' );

function the_business_blocks_gtm( $option ) {
	$defaults = apply_filters( 'the_business_blocks_customizer_defaults', true );

	return isset( $defaults[ $option ] ) ? get_theme_mod( $option, $defaults[ $option ] ) : get_theme_mod( $option );
}

if ( ! function_exists( 'the_business_blocks_excerpt_length' ) ) :
	function the_business_blocks_excerpt_length( $length ) {
		if ( is_admin() ) {
			return $length;
		}

		$length	= the_business_blocks_gtm( 'the_business_blocks_excerpt_length' );

		return absint( $length );
	} 
endif;
add_filter( 'excerpt_length', 'the_business_blocks_excerpt_length', 999 );