Created
August 11, 2015 11:12
-
-
Save wbxpress/931882763b60379d9047 to your computer and use it in GitHub Desktop.
wbxpress-one theme's functions file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! isset( $content_width ) ) { | |
$content_width = 550; | |
} | |
if ( ! function_exists( 'wbxpressone_setup' ) ) { | |
function wbxpressone_setup() { | |
add_theme_support( 'title-tag' ); | |
add_theme_support( 'html5', array( | |
'search-form', 'comment-form', 'comment-list', 'caption' | |
) ); | |
register_nav_menus( array( | |
'primary' => __( 'Primary Navigation', 'wbxpress-one' ), | |
)); | |
} | |
} | |
add_action( 'after_setup_theme', 'wbxpressone_setup' ); | |
function wbxpressone_widgets_init() { | |
register_sidebar( array( | |
'name' => __( 'Sidebar', 'wbxpress-one' ), | |
'id' => 'sidebar', | |
'before_widget' => '<div id="%1$s" class="widget %2$s">', | |
'after_widget' => '</div>', | |
'before_title' => '<h4>', | |
'after_title' => '</h4>', | |
)); | |
register_sidebar( array( | |
'name' => __( 'Footer Left', 'wbxpress-one' ), | |
'id' => 'footer-left', | |
'before_widget' => '<div id="%1$s" class="widget %2$s">', | |
'after_widget' => '</div>', | |
'before_title' => '<h4>', | |
'after_title' => '</h4>', | |
)); | |
register_sidebar( array( | |
'name' => __( 'Footer Center', 'wbxpress-one' ), | |
'id' => 'footer-center', | |
'before_widget' => '<div id="%1$s" class="widget %2$s">', | |
'after_widget' => '</div>', | |
'before_title' => '<h4>', | |
'after_title' => '</h4>', | |
)); | |
register_sidebar( array( | |
'name' => __( 'Footer Right', 'wbxpress-one' ), | |
'id' => 'footer-right', | |
'before_widget' => '<div id="%1$s" class="widget %2$s">', | |
'after_widget' => '</div>', | |
'before_title' => '<h4>', | |
'after_title' => '</h4>', | |
)); | |
} | |
add_action( 'widgets_init', 'wbxpressone_widgets_init' ); | |
function wbxpressone_scripts() { | |
wp_enqueue_style( 'wbxpressone-style', get_stylesheet_uri(), array(), '1.0.0' ); | |
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { | |
wp_enqueue_script( 'comment-reply' ); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'wbxpressone_scripts' ); | |
// ---------------------------------------------- | |
if ( ! function_exists( '_wp_render_title_tag' ) ) { | |
function theme_slug_render_title() { | |
?> | |
<title><?php wp_title( '|', true, 'right' ); ?></title> | |
<?php | |
} | |
add_action( 'wp_head', 'theme_slug_render_title' ); | |
function wbxpressone_wp_title( $title, $sep ) { | |
global $paged, $page; | |
if ( is_feed() ) { | |
return $title; | |
} | |
// Add the site name. | |
$title .= get_bloginfo( 'name', 'display' ); | |
// 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', 'wbxpress-one' ), max( $paged, $page ) ); | |
} | |
return $title; | |
} | |
add_filter( 'wp_title', 'wbxpressone_wp_title', 10, 2 ); | |
} | |
if ( function_exists( 'the_posts_pagination' ) ) { | |
the_posts_pagination( array( | |
'prev_text' => __( 'Previous', 'wbxpress-one' ), | |
'next_text' => __( 'Next', 'wbxpress-one' ), | |
'before_page_number' => '', | |
) ); | |
} else { | |
function the_posts_pagination() { | |
?> | |
<div class="navigation"> | |
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'wbxpress-one' ) ); ?></div> | |
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'wbxpress-one' ) ); ?></div> | |
</div> | |
<?php | |
} | |
} | |
if ( function_exists( 'the_post_navigation' ) ) { | |
the_post_navigation( array( | |
'prev_text' => '%title', | |
'next_text' => '%title', | |
'screen_reader_text' => '', | |
) ); | |
} else { | |
function the_post_navigation() { | |
?> | |
<div class="navigation"> | |
<div class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . __( '←', 'wbxpress-one' ) . '</span> %title' ); ?></div> | |
<div class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . __( '→', 'wbxpress-one' ) . '</span>' ); ?></div> | |
</div><!-- #nav-below --> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment