id;
}
$choices = bgbn_get_choices( $setting );
$allowed_choices = array_keys( $choices );
if ( ! in_array( $value, $allowed_choices ) ) {
$value = bgbn_get_default( $setting );
}
return $value;
}
endif;
if ( ! function_exists( 'bgbn_get_choices' ) ) :
/**
* Return the available choices for a given setting
*
* @since 1.0.0.
*
* @param string|object $setting The setting to get options for.
* @return array The options for the setting.
*/
function bgbn_get_choices( $setting ) {
if ( is_object( $setting ) ) {
$setting = $setting->id;
}
$choices = array( 0 );
switch ( $setting ) {
case 'general-layout' :
$choices = array(
'full-width' => __( 'Full-width', 'bgbn' ),
'boxed' => __( 'Boxed', 'bgbn' )
);
break;
case 'layout-blog-featured-images' :
case 'layout-archive-featured-images' :
case 'layout-search-featured-images' :
case 'layout-post-featured-images' :
case 'layout-page-featured-images' :
$choices = array(
'post-header' => __( 'Post header', 'bgbn' ),
'thumbnail' => __( 'Thumbnail', 'bgbn' ),
'none' => __( 'None', 'bgbn' ),
);
break;
case 'layout-blog-post-date' :
case 'layout-archive-post-date' :
case 'layout-search-post-date' :
case 'layout-post-post-date' :
case 'layout-page-post-date' :
$week_ago = date( get_option( 'date_format' ), time() - WEEK_IN_SECONDS );
$choices = array(
'absolute' => sprintf( __( 'Absolute (%s)', 'bgbn' ), $week_ago ),
'relative' => __( 'Relative (1 week ago)', 'bgbn' ),
'none' => __( 'None', 'bgbn' ),
);
break;
case 'layout-blog-post-author' :
case 'layout-archive-post-author' :
case 'layout-search-post-author' :
case 'layout-post-post-author' :
case 'layout-page-post-author' :
$choices = array(
'avatar' => __( 'With avatar', 'bgbn' ),
'name' => __( 'Without avatar', 'bgbn' ),
'none' => __( 'None', 'bgbn' ),
);
break;
case 'header-background-repeat' :
case 'main-background-repeat' :
case 'footer-background-repeat' :
$choices = array(
'no-repeat' => __( 'No Repeat', 'bgbn' ),
'repeat' => __( 'Tile', 'bgbn' ),
'repeat-x' => __( 'Tile Horizontally', 'bgbn' ),
'repeat-y' => __( 'Tile Vertically', 'bgbn' )
);
break;
case 'header-background-position' :
case 'main-background-position' :
case 'footer-background-position' :
$choices = array(
'left' => __( 'Left', 'bgbn' ),
'center' => __( 'Center', 'bgbn' ),
'right' => __( 'Right', 'bgbn' )
);
break;
case 'background_size' :
case 'header-background-size' :
case 'main-background-size' :
case 'footer-background-size' :
$choices = array(
'auto' => __( 'Auto', 'bgbn' ),
'cover' => __( 'Cover', 'bgbn' ),
'contain' => __( 'Contain', 'bgbn' )
);
break;
case 'header-bar-content-layout' :
$choices = array(
'default' => __( 'Default', 'bgbn' ),
'flipped' => __( 'Flipped', 'bgbn' )
);
break;
case 'header-layout' :
$choices = array(
1 => __( 'Traditional', 'bgbn' ),
2 => __( 'Centered', 'bgbn' ),
3 => __( 'Navigation Below', 'bgbn' ),
);
break;
case 'header-branding-position' :
$choices = array(
'left' => __( 'Left', 'bgbn' ),
'right' => __( 'Right', 'bgbn' )
);
break;
case 'footer-widget-areas' :
$choices = array(
0 => _x( '0', 'footer widget area number', 'bgbn' ),
1 => _x( '1', 'footer widget area number', 'bgbn' ),
2 => _x( '2', 'footer widget area number', 'bgbn' ),
3 => _x( '3', 'footer widget area number', 'bgbn' ),
4 => _x( '4', 'footer widget area number', 'bgbn' )
);
break;
case 'footer-layout' :
$choices = array(
1 => __( 'Traditional', 'bgbn' ),
2 => __( 'Centered', 'bgbn' ),
);
break;
}
return apply_filters( 'bgbn_setting_choices', $choices, $setting );
}
endif;
if ( ! function_exists( 'bgbn_display_favicons' ) ) :
/**
* Write the favicons to the head to implement the options.
*
* @since 1.0.0.
*
* @return void
*/
function bgbn_display_favicons() {
$logo_favicon = get_theme_mod( 'logo-favicon', bgbn_get_default( 'logo-favicon' ) );
if ( ! empty( $logo_favicon ) ) : ?>
array(
'title' => 'Facebook',
'class' => 'fa-facebook',
),
'twitter' => array(
'title' => 'Twitter',
'class' => 'fa-twitter',
),
'google-plus-square' => array(
'title' => 'Google+',
'class' => 'fa-google-plus-square',
),
'linkedin' => array(
'title' => 'LinkedIn',
'class' => 'fa-linkedin',
),
'instagram' => array(
'title' => 'Instagram',
'class' => 'fa-instagram',
),
'flickr' => array(
'title' => 'Flickr',
'class' => 'fa-flickr',
),
'youtube' => array(
'title' => 'YouTube',
'class' => 'fa-youtube',
),
'vimeo-square' => array(
'title' => 'Vimeo',
'class' => 'fa-vimeo-square',
),
'pinterest' => array(
'title' => 'Pinterest',
'class' => 'fa-pinterest',
),
'email' => array(
'title' => __( 'Email', 'bgbn' ),
'class' => 'fa-envelope',
),
'rss' => array(
'title' => __( 'RSS', 'bgbn' ),
'class' => 'fa-rss',
),
);
// Set up the collector array
$services_with_links = array();
// Get the links for these services
foreach ( $default_services as $service => $details ) {
$url = get_theme_mod( 'social-' . $service, bgbn_get_default( 'social-' . $service ) );
if ( '' !== $url ) {
$services_with_links[ $service ] = array(
'title' => $details['title'],
'url' => $url,
'class' => $details['class'],
);
}
}
// Special handling for RSS
$hide_rss = (int) get_theme_mod( 'social-hide-rss', bgbn_get_default( 'social-hide-rss' ) );
if ( 0 === $hide_rss ) {
$custom_rss = get_theme_mod( 'social-custom-rss', bgbn_get_default( 'social-custom-rss' ) );
if ( ! empty( $custom_rss ) ) {
$services_with_links['rss']['url'] = $custom_rss;
} else {
$services_with_links['rss']['url'] = get_feed_link();
}
} else {
unset( $services_with_links['rss'] );
}
// Properly set the email
if ( isset( $services_with_links['email']['url'] ) ) {
$services_with_links['email']['url'] = esc_url( 'mailto:' . $services_with_links['email']['url'] );
}
return apply_filters( 'bgbn_social_links', $services_with_links );
}
endif;