' . wp_kses( $message, $allowed_html ) . '
';
}
endif;
endforeach;
}
}
}
// delete bundled products after switch theme.
if ( ! function_exists( 'bsf_theme_deactivation' ) ) {
/**
* Delete transients while switching theme.
*
* @return void
*/
function bsf_theme_deactivation() {
update_option( 'bsf_force_check_extensions', false );
}
}
add_action( 'switch_theme', 'bsf_theme_deactivation' );
add_action( 'deactivated_plugin', 'bsf_theme_deactivation' );
if ( ! function_exists( 'bsf_get_free_menu_position' ) ) {
/**
* Get free theme position.
*
* @param int $start menu position priority index.
* @param float $increment increment number for menu position.
* @return int
*/
function bsf_get_free_menu_position( $start, $increment = 0.3 ) {
foreach ( $GLOBALS['menu'] as $key => $menu ) {
$menus_positions[] = $key;
}
if ( ! in_array( $start, $menus_positions, true ) ) {
return $start;
}
/* the position is already reserved find the closet one */
while ( in_array( $start, $menus_positions, true ) ) {
$start += $increment;
}
return $start;
}
}
if ( ! function_exists( 'bsf_get_option' ) ) {
/**
* Get free theme position.
*
* @param bool $request return complete option data OR a single variable.
* @return array
*/
function bsf_get_option( $request = false ) {
$bsf_options = get_option( 'bsf_options' );
if ( ! $request ) {
return $bsf_options;
} else {
return ( isset( $bsf_options[ $request ] ) ) ? $bsf_options[ $request ] : false;
}
}
}
if ( ! function_exists( 'bsf_update_option' ) ) {
/**
* Update bsf option with key and value.
*
* @param string $request variable key.
* @param string $value variable value.
* @return bool
*/
function bsf_update_option( $request, $value ) {
$bsf_options = get_option( 'bsf_options' );
$bsf_options[ $request ] = $value;
return update_option( 'bsf_options', $bsf_options );
}
}
if ( ! function_exists( 'bsf_sort' ) ) {
/**
* Sort array of objects.
*
* @param string $a The first string.
* @param string $b The second string.
* @return int
*/
function bsf_sort( $a, $b ) {
return strcmp( strtolower( $a->short_name ), strtolower( $b->short_name ) );
}
}