__( 'Widget Area for left sidebar', 'birdtips' ),
'id' => 'widget-area-left',
'description' => __( 'Widget Area for left sidebar', 'birdtips' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array (
'name' => __( 'Widget Area for right sidebar', 'birdtips' ),
'id' => 'widget-area-right',
'description' => __( 'Widget Area for right sidebar', 'birdtips' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
) );
}
}
add_action( 'widgets_init', 'birdtips_widgets_init' );
//////////////////////////////////////////////////////
// Pagenation
function birdtips_the_pagenation() {
global $wp_query, $paged;
$birdtips_big = 999999999;
$birdtips_pages = $wp_query -> max_num_pages;
if ( empty( $paged ) ) $paged = 1;
if ( 1 < $birdtips_pages ) {
echo ' ' ."\n";
echo paginate_links( array(
'base' => str_replace( $birdtips_big, '%#%', get_pagenum_link( $birdtips_big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var( 'paged' ) ),
'total' => $wp_query -> max_num_pages,
'mid_size' => 3,
'prev_text' => __( 'Previous', 'birdtips' ),
'next_text' => __( 'Next', 'birdtips' )
) );
echo '
' ."\n";
}
}
//////////////////////////////////////////////////////
// Copyright Year
function birdtips_get_copyright_year() {
$birdtips_copyright_year = date( "Y" );
$birdtips_first_year = $birdtips_copyright_year;
$args = array(
'numberposts' => 1,
'orderby' => 'post_date',
'order' => 'ASC',
);
$posts = get_posts( $args );
foreach ( $posts as $post ) {
$birdtips_first_year = mysql2date( 'Y', $post->post_date, true );
}
if( $birdtips_copyright_year <> $birdtips_first_year ){
$birdtips_copyright_year = $birdtips_first_year .' - ' .$birdtips_copyright_year;
}
return $birdtips_copyright_year;
}
//////////////////////////////////////////
// Archive PageTitle
function birdtips_the_archivetitle() {
if(is_category()) {
printf( __( 'Category Archives: %s', 'birdtips'), single_cat_title('', false ) );
}
elseif( is_tag() ) {
printf( __( 'Tag Archives: %s', 'birdtips' ), single_tag_title( '', false ) );
}
elseif (is_day()) {
printf( __('Daily Archives: %s', 'birdtips'), get_post_time( get_option('date_format' ) ) );
}
elseif ( is_month() ) {
printf( __( 'Monthly Archives: %s', 'birdtips'), get_post_time( __( 'F, Y', 'birdtips' ) ) );
}
elseif (is_year()) {
printf( __( 'Yearly Archives: %s', 'birdtips' ), get_post_time( __( 'Y', 'birdtips' ) ) );
}
elseif ( is_author() ) {
printf( __('Author Archives: %s', 'birdtips' ), get_the_author_meta( 'display_name', get_query_var( 'author' ) ) );
}
elseif ( isset($_GET['paged'] ) && !empty( $_GET['paged'] ) ) {
_e( 'Blog Archives', 'birdtips' );
}
}
//////////////////////////////////////////////////////
// Date
function birdtips_the_date() {
$birdtips_html = '';
$birdtips_posted = date( __( 'M. j, Y', 'birdtips' ), strtotime( get_the_time( "Y-m-d") ) );
$birdtips_date = explode( ' ', $birdtips_posted );
foreach( $birdtips_date as $birdtips_d ){
$birdtips_html .= '' .$birdtips_d .'';
}
echo $birdtips_html;
}
//////////////////////////////////////////////////////
// Header Style
function birdtips_header_style() {
?>
'F5F5F5',
) );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => __( 'Primary Navigation', 'birdtips' ),
) );
// Add support for title tag.
add_theme_support( 'title-tag' );
// Add support for custom headers.
add_theme_support( 'custom-header', array(
'default-text-color' => 'CCC',
'default-image' => '%s/images/headers/green.jpg',
'width' => 1075,
'height' => 200,
'random-default' => true,
'wp-head-callback' => 'birdtips_header_style',
) );
register_default_headers( array(
'green' => array(
'url' => '%s/images/headers/green.jpg',
'thumbnail_url' => '%s/images/headers/green-thumbnail.jpg',
'description' => 'Green'
),
'blue' => array(
'url' => '%s/images/headers/blue.jpg',
'thumbnail_url' => '%s/images/headers/blue-thumbnail.jpg',
'description' => 'Blue'
),
'yellow' => array(
'url' => '%s/images/headers/yellow.jpg',
'thumbnail_url' => '%s/images/headers/yellow-thumbnail.jpg',
'description' => 'Yellow'
),
'red' => array(
'url' => '%s/images/headers/red.jpg',
'thumbnail_url' => '%s/images/headers/red-thumbnail.jpg',
'description' => 'Red'
),
'white' => array(
'url' => '%s/images/headers/white.jpg',
'thumbnail_url' => '%s/images/headers/white-thumbnail.jpg',
'description' => 'White'
),
'orange' => array(
'url' => '%s/images/headers/orange.jpg',
'thumbnail_url' => '%s/images/headers/orange-thumbnail.jpg',
'description' => 'Orange'
),
'pink' => array(
'url' => '%s/images/headers/pink.jpg',
'thumbnail_url' => '%s/images/headers/pink-thumbnail.jpg',
'description' => 'Pink'
),
'purple' => array(
'url' => '%s/images/headers/purple.jpg',
'thumbnail_url' => '%s/images/headers/purple-thumbnail.jpg',
'description' => 'Purple'
),
) );
}
add_action( 'after_setup_theme', 'birdtips_setup' );
//////////////////////////////////////////////////////
// Document Title
function birdtips_title( $title ) {
global $page, $paged;
$title .= get_bloginfo( 'name' );
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title .= " | $site_description";
if ( $paged >= 2 || $page >= 2 )
$title .= ' | ' . sprintf( __( 'Page %s', 'birdtips' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'birdtips_title' );
//////////////////////////////////////////////////////
// Title Tag Backwards Compatibility
function birdtips_slug_render_title() {
?>' . __( 'Continue reading', 'birdtips' ) .'';
}
add_filter('excerpt_more', 'birdtips_excerpt_more' );
//////////////////////////////////////////////////////
// Theme Customizer
function birdtips_customize($wp_customize) {
// Text Color
$wp_customize->add_setting( 'birdtips_text_color', array(
'default' => '#555',
'sanitize_callback' => 'maybe_hash_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'birdtips_text_color', array(
'label' => __( 'Text Color', 'birdtips' ),
'section' => 'colors',
'settings' => 'birdtips_text_color',
) ) );
// Link Color
$wp_customize->add_setting( 'birdtips_link_color', array(
'default' => '#06A',
'sanitize_callback' => 'maybe_hash_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'birdtips_link_color', array(
'label' => __( 'Link Color', 'birdtips' ),
'section' => 'colors',
'settings' => 'birdtips_link_color',
) ) );
// Aticle Titler Color
$wp_customize->add_setting( 'birdtips_article_title_color', array(
'default' => '#D63',
'sanitize_callback' => 'maybe_hash_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'birdtips_article_title_color', array(
'label' => __( 'Article Title Color', 'birdtips' ),
'section' => 'colors',
'settings' => 'birdtips_article_title_color',
) ) );
// Navigation Text Color
$wp_customize->add_setting( 'birdtips_navigation_color', array(
'default' => '#DDD',
'sanitize_callback' => 'maybe_hash_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'birdtips_navigation_color', array(
'label' => __( 'Navigation Text Color', 'birdtips' ),
'section' => 'colors',
'settings' => 'birdtips_navigation_color',
) ) );
// Footer Section
$wp_customize->add_section( 'birdtips_footer', array(
'title' => __( 'Footer', 'birdtips' ),
'priority' => 999,
) );
// Display Copyright
$wp_customize->add_setting( 'birdtips_copyright', array(
'default' => true,
'sanitize_callback' => 'birdtips_sanitize_checkbox',
) );
$wp_customize->add_control( 'birdtips_copyright', array(
'label' => __( 'Display Copyright', 'birdtips' ),
'section' => 'birdtips_footer',
'type' => 'checkbox',
'settings' => 'birdtips_copyright',
) );
// Display Credit
$wp_customize->add_setting( 'birdtips_credit', array(
'default' => true,
'sanitize_callback' => 'birdtips_sanitize_checkbox',
) );
$wp_customize->add_control( 'birdtips_credit', array(
'label' => __( 'Display Credit', 'birdtips' ),
'section' => 'birdtips_footer',
'type' => 'checkbox',
'settings' => 'birdtips_credit',
) );
}
add_action('customize_register', 'birdtips_customize');
//////////////////////////////////////////////////////
// Santize a checkbox
function birdtips_sanitize_checkbox( $input ) {
if ( $input == true ) {
return true;
} else {
return false;
}
}
//////////////////////////////////////////////////////
// Removing the default gallery style
function birdtips_gallery_atts( $out, $pairs, $atts ) {
$atts = shortcode_atts( array( 'size' => 'medium', ), $atts );
$out['size'] = $atts['size'];
return $out;
}
add_filter( 'shortcode_atts_gallery', 'birdtips_gallery_atts', 10, 3 );
add_filter( 'use_default_gallery_style', '__return_false' );