__( 'Footer A', 'bilbo' ),
'id' => 'footer-one',
'description' => __( 'Widgets in this area will be shown in the first column in the footer.', 'bilbo' ),
'before_title' => '
',
'after_title' => '
',
'before_widget' => '
',
'after_widget' => '
'
));
register_sidebar(array(
'name' => __( 'Footer B', 'bilbo' ),
'id' => 'footer-two',
'description' => __( 'Widgets in this area will be shown in the second column in the footer.', 'bilbo' ),
'before_title' => '
',
'after_title' => '
',
'before_widget' => '
',
'after_widget' => '
'
));
register_sidebar(array(
'name' => __( 'Footer C', 'bilbo' ),
'id' => 'footer-three',
'description' => __( 'Widgets in this area will be shown in the third column in the footer.', 'bilbo' ),
'before_title' => '
',
'after_title' => '
',
'before_widget' => '
',
'after_widget' => '
'
));
}
// Set content-width
if ( ! isset( $content_width ) ) $content_width = 766;
// Add Title Tag Support
add_theme_support( 'title-tag' );
// Check whether the browser supports javascript
function bilbo_html_js_class() {
echo ''. "\n";
}
add_action( 'wp_head', 'bilbo_html_js_class', 1 );
// Custom title function
function bilbo_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() )
return $title;
// Add the site name.
$title .= get_bloginfo( 'name' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title = "$title $sep $site_description";
// Add a page number if necessary.
if ( $paged >= 2 || $page >= 2 )
$title = "$title $sep " . sprintf( __( 'Page %s', 'bilbo' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'bilbo_wp_title', 10, 2 );
// Add classes to next_posts_link and previous_posts_link
add_filter('next_posts_link_attributes', 'bilbo_posts_link_attributes_1');
add_filter('previous_posts_link_attributes', 'bilbo_posts_link_attributes_2');
function bilbo_posts_link_attributes_1() {
return 'class="post-nav-older"';
}
function bilbo_posts_link_attributes_2() {
return 'class="post-nav-newer"';
}
// Menu walker adding "has-children" class to menu li's with children menu items
class bilbo_nav_walker extends Walker_Nav_Menu {
function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
$id_field = $this->db_fields['id'];
if ( !empty( $children_elements[ $element->$id_field ] ) ) {
$element->classes[] = 'has-children';
}
Walker_Nav_Menu::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}
}
// Add class to body if the post/page has a featured image
add_action('body_class', 'bilbo_if_featured_image_class' );
function bilbo_if_featured_image_class($classes) {
if ( has_post_thumbnail() ) {
array_push($classes, 'has-featured-image');
}
return $classes;
}
// Custom more-link text
add_filter( 'the_content_more_link', 'bilbo_custom_more_link', 10, 2 );
function bilbo_custom_more_link( $more_link, $more_link_text ) {
return str_replace( $more_link_text, __('Continue reading', 'bilbo'), $more_link );
}
// Flexslider-ify function for format-gallery
function bilbo_flexslider($size = thumbnail) {
if ( is_page()) :
$attachment_parent = $post->ID;
else :
$attachment_parent = get_the_ID();
endif;
if($images = get_posts(array(
'post_parent' => $attachment_parent,
'post_type' => 'attachment',
'numberposts' => -1, // show all
'post_status' => null,
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC',
))) { ?>
add_section( 'bilbo_options',
array(
'title' => __( 'Options for bilbo', 'bilbo' ), //Visible title of section
'priority' => 35, //Determines what order this appears in
'capability' => 'edit_theme_options', //Capability needed to tweak
'description' => __('Allows you to customize theme settings for bilbo.', 'bilbo'), //Descriptive tooltip
)
);
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'accent_color', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#2980b9', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_setting( 'bilbo_logo',
array(
'sanitize_callback' => 'esc_url_raw'
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'bilbo_accent_color', //Set a unique ID for the control
array(
'label' => __( 'Accent Color', 'bilbo' ), //Admin-visible name of the control
'section' => 'colors', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'accent_color', //Which setting to load and manipulate (serialized is okay)
'priority' => 10, //Determines the order this control appears in for the specified section
)
) );
//4. We can also change built-in settings by modifying properties. For instance, let's make some stuff use live preview JS...
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
}
public static function bilbo_header_output() {
?>