';
}
else {
$out = $title ? '
' : $title;
}
return $out;
}
/**
* Enqueue scripts and styles
*/
function b3_enqueue_scripts() {
$src = ('cdn' == b3_option('bootstrap_src')) ?
'//netdna.bootstrapcdn.com/bootstrap/3.0.2' : B3_URI . '/bootstrap';
wp_enqueue_script('bootstrap', $src . '/js/bootstrap.min.js', array('jquery'), null, true );
wp_enqueue_script('b3', B3_URI . '/js/b3.js', array('jquery'), null, true );
if ( is_singular() && comments_open() && get_option('thread_comments') ) {
wp_enqueue_script('comment-reply');
}
if (is_singular() && wp_attachment_is_image()) {
wp_enqueue_script('b3-keyboard-image-navigation', B3_URI . '/js/keyboard-image-navigation.js', array('jquery'), '20120202');
}
}
add_action('wp_enqueue_scripts', 'b3_enqueue_scripts');
function b3_enqueue_styles() {
$src = ('cdn' == b3_option('bootstrap_src')) ?
'//netdna.bootstrapcdn.com/bootstrap/3.0.2' : B3_URI . '/bootstrap';
wp_enqueue_style('bootstrap', $src . '/css/bootstrap.min.css');
wp_enqueue_style('b3-style', B3_URI . '/style.css');
wp_add_inline_style('b3-style', b3_options_css());
// add_editor_style();
/*
the Bootstrap and custom theme css settings are not used in admin area
so adding editor style is moot point yet.
*/
}
add_action('wp_enqueue_scripts', 'b3_enqueue_styles');
function b3_admin_enqueue_scripts() {
wp_enqueue_script('wp-color-picker', '', array('jquery'));
wp_enqueue_script('b3-admin', B3_URI . '/js/b3-admin.js', array('wp-color-picker'), null, true);
wp_enqueue_style('wp-color-picker');
wp_enqueue_style('b3-admin', B3_URI . '/css/b3-admin.css');
}
add_action('admin_enqueue_scripts', 'b3_admin_enqueue_scripts');
function b3_options_css() {
$out = '';
if ('left' == b3_option('sidebar_main')) {
$out .= '#secondary {float: left;} #primary {float: right;} ';
}
if (($css = b3_option('text_color')) && $css != '#333333') {
$out .= 'body {color:'. $css . ';} ';
$out .= '.entry-meta {color:'. b3_option('text_color2') . ';} ';
}
if ($css = b3_option('headers_color')) {
$out .= 'h1,h2,h3,h4,h5,h6 {color:'. $css . ';} ';
}
if ($css = b3_option('link_color')) {
$out .= 'a, a:visited {color:'. $css . ';} ';
}
if ($css = b3_option('link_hover_color')) {
$out .= 'a:hover {color:'. $css . ';} ';
}
if (($css = b3_option('navbar_color')) && '#F8F8F8' != $css) {
$color2 = b3_option('navbar_color2');
$out .= '.navbar-b3 {background-color: '. $css .'; background-image: linear-gradient(to bottom, '
. $css . ' 0px, '. $color2 .' 100%); '
// . 'filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=' . $css. ',endColorstr=' . $color2 . ');'
// (dropdown menu in IE8 doesn't work with filter )
// .'-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=' . $css .',endColorstr=' . $color2 .')";'
.' border: ' . b3_option('navbar_border') .' solid 1px;}';
}
if (($css = b3_option('navbar_link_color')) && '#777777' != $css) {
$out .= '.navbar-nav > li > a, .navbar-nav > li > a:visited, a.navbar-brand {color:'. $css . ' !important;} ';
$out .= '.navbar-nav > li > a:hover, a.navbar-brand:hover {color:'. b3_option('navbar_link_color2') . ' !important;} ';
}
return $out;
}
add_filter('sanitize_option_b3_options', 'b3_sanitize_options');
function b3_sanitize_options($arr) {
$defaults = array(
'logo_enabled' => 'Y',
'site_title_enabled' => 'Y',
'site_description_enabled' => 'Y',
'navbar_brand' => 'Project Name',
'copyright' => date('Y ') . get_option('blogname'),
'show_home' => 'N',
'disable_comment_page' => 'N',
'sidebar_main' => 'right',
'sidebar_top' => 'Y',
'sidebar_bottom' => 'Y',
'panel_widget' => 'N',
'panel_post' => 'N',
'carousel' => 'demo',
'image_rounded' => 'N',
'credits' => 'Y',
'post_thumbnail' => 'Y',
'post_date' => 'Y',
'post_author' => 'Y',
'excerpt' => 'N',
'text_color' => '#333333',
'headers_color' => '',
'link_color' => '',
'link_hover_color' => '',
'navbar_color' => '',
'navbar_color2' => '',
'navbar_border' => '',
'navbar_link_color' => '',
'navbar_link_color2' => '',
'bootstrap_src' => 'local',
);
if ( !empty($_POST['b3_action_reset']) ) {
return $defaults;
}
elseif (!empty($_POST['b3_action_upload'])) {
if ( ($file = $_FILES['b3_upload_settings']) && !$file['error'] && $file['size']) {
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
$f = new WP_Filesystem_Direct('');
$content = $f->get_contents($file['tmp_name']);
// I can obtain it by one call file get contents but Theme-Check grumbles
$import = maybe_unserialize($content);
$f->delete($file['tmp_name']);
if (is_array($import)) {
$arr = array_merge($arr, $import);
}
}
}
$out = array();
foreach ($defaults as $key => $value) {
$out[$key] = isset($arr[$key]) ? $arr[$key] : $value;
if (strpos($key, 'color') && !preg_match('/^#[0-9a-f]{6,6}$/i', $out[$key])) {
$out[$key] = '';
}
}
if ($out['text_color']) {
$out['text_color2'] = b3_smudge_color($out['text_color'], 40);
}
else {
$out['text_color'] = $out['text_color2'] = '';
}
if ($out['link_color']) {
$out['link_hover_color'] = b3_darken($out['link_color'], 15);
}
else {
$out['link_color'] = $out['link_hover_color'] = '';
}
if ($out['navbar_color']) {
$out['navbar_color2'] = b3_lighten($out['navbar_color'], 75);
$out['navbar_border'] = b3_lighten($out['navbar_color'], 25);
}
else {
$out['navbar_color'] = $out['navbar_color2'] = $out['navbar_border'] = '';
}
if ($out['navbar_link_color']) {
$out['navbar_link_color2'] = b3_darken($out['navbar_link_color'], 40);
}
else {
$out['navbar_link_color'] = $out['navbar_link_color2'] = '';
}
$out['copyright'] = htmlspecialchars($out['copyright']);
$out['navbar_brand'] = htmlspecialchars($out['navbar_brand']);
return $out;
}
function b3_darken($color, $percent) {
$p = min(abs($percent), 100);
$ratio = 1 - $p*0.01;
$dec = hexdec(substr($color, 1));
$b = dechex(floor((0xFF & $dec) * $ratio));
if (strlen($b) == 1) $b = '0'.$b;
$g = dechex(floor(((0xFF00 & $dec) / 256) * $ratio));
if (strlen($g) == 1) $g = '0'.$g;
$r = dechex(floor(((0xFF0000 & $dec) / 65536) * $ratio));
if (strlen($r) == 1) $r = '0'.$r;
return "#$r$g$b";
}
function b3_lighten($color, $percent) {
$p = min(abs($percent), 100);
$ratio = 1 + $p*0.01;
$dec = hexdec(substr($color, 1));
$b = dechex(min( floor((0xFF & $dec) * $ratio), 255 ));
if (strlen($b) == 1) $b = '0'.$b;
$g = dechex(min( floor(((0xFF00 & $dec) / 256) * $ratio), 255 ));
if (strlen($g) == 1) $g = '0'.$g;
$r = dechex(min( floor(((0xFF0000 & $dec) / 65536) * $ratio), 255 ));
if (strlen($r) == 1) $r = '0'.$r;
return "#$r$g$b";
}
/*
*/
function b3_smudge($c, $r) {
$x = dechex(floor($c*(1-$r) + (255-$c)*$r));
if (strlen($x) == 1) $b = '0'.$x;
return $x;
}
function b3_smudge_color($color, $percent) {
$p = min(abs($percent), 100);
$ratio = $p*0.01;
$dec = hexdec(substr($color, 1));
$b = b3_smudge(0xFF & $dec, $ratio);
$g = b3_smudge((0xFF00 & $dec)/256, $ratio);
$r = b3_smudge((0xFF0000 & $dec)/65536, $ratio);
return "#$r$g$b";
}
function b3_comment_form_before() {
echo '
';
}
function b3_comment_form_after() {
echo '
';
}
function b3_post_class($classes) {
if ('Y'==b3_option('panel_post')) {
$classes[]= 'panel-body';
}
$classes[]= 'clearfix';
return $classes;
}
function b3_content_wrap_class() {
$classes = array();
if ('Y'==b3_option('panel_post')) {
$classes[]= 'panel';
}
if ($classes) {
echo 'class="' . implode(' ', $classes) . '"';
}
}
add_filter('post_class', 'b3_post_class');
add_action('comment_form_before', 'b3_comment_form_before');
add_action('comment_form_after', 'b3_comment_form_after');
function b3_carousel() {
$case = b3_option('carousel');
if ('N' == $case) {
return;
}
else {
if ('Y' == $case) {
$slides = get_posts(array('post_type' => 'b3_slide'));
}
else {
include B3_PATH . '/inc/demo-slides.php';
}
if ( $total = count($slides) ) {
?>
1 ) { ?>
';
} ?>
$slide ) {
if ('Y' == $case) {
$slide = (array)$slide;
$attachment_id = get_post_thumbnail_id($slide['ID']);
$img = wp_get_attachment_image_src($attachment_id, 'full');
$slide['src'] = $img[0];
$slide['alt'] = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
}
?>
' . apply_filters('the_title', $slide['post_content']) . '
';
if ('Y' == $case) {
echo '
';
edit_post_link( __('Edit', 'b3'), '', '');
echo '
';
}
?>
1) { ?>
';
printf( __('You have no slides yet. You can