is_main_query() )
return $query;
// Home only gets 3 posts
$query->query_vars['posts_per_page'] = 3;
return $query;
}
add_action( 'pre_get_posts', 'depo_limit_home_posts_per_page' );
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) )
$content_width = 604;
/**
* Set $themecolors array.
*/
$themecolors = array(
'bg' => 'FFFFFF',
'text' => '000000',
'link' => '990000',
'border' => 'CCCCCC',
'url' => 'CC0000',
);
/**
* Feeds.
*/
add_theme_support( 'automatic-feed-links' );
/**
* Add Custom Background.
*/
add_theme_support( 'custom-background' );
add_theme_support( 'print-style' );
/**
* Enqueue scripts and styles
*/
function depo_scripts() {
global $wp_styles;
wp_enqueue_style( 'depo', get_stylesheet_uri() );
wp_enqueue_style( 'depo-ie', get_template_directory_uri() . '/ie.css', array( 'depo' ) );
$wp_styles->add_data( 'depo-ie', 'conditional', 'lte IE 8' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
}
add_action( 'wp_enqueue_scripts', 'depo_scripts' );
function depo_custom_background() {
if ( '' != get_background_color() || '' != get_background_image() ) { ?>
__( 'Primary Navigation', 'depo-masthead' )
) );
/**
* Custom Excerpt.
*/
function depomasthead_continue_reading_excerpt() {
$text = get_the_excerpt();
$text = apply_filters( 'the_content', $text);
$text = str_replace( ']]>', ']]>', $text);
$text = strip_tags($text, '
' );
$excerpt_length = 50;
$words = explode( ' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, ' ... '.__( 'Continue reading →' ).'' );
$text = implode( ' ', $words);
}
echo $text;
}
/**
* Register Widget Areas and Custom Widgets.
*/
function depo_widgets_init() {
register_sidebar( array(
'name' => 'Right',
'before_widget' => '
',
'after_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => 'Middle',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => 'Left',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
) );
wp_register_sidebar_widget( 'search' , __( 'DePo Search', 'depo-masthead' ), 'depo_search_widget' );
wp_register_sidebar_widget( 'depo-about', __( 'DePo About', 'depo-masthead' ), 'depo_about_widget' );
wp_register_sidebar_widget( 'depo-archives-categories', __( 'DePo Archives & Categories', 'depo-masthead' ), 'depo_archives_widget' );
wp_register_sidebar_widget( 'rss-link', __( 'DePo RSS Link', 'depo-masthead' ), 'depo_rss_widget' );
}
add_action( 'widgets_init', 'depo_widgets_init' );
/**
* Include Custom Widgets.
*/
require_once( get_template_directory() . '/lib/widgets.php' );
/**
* Admin Theme Page.
*/
add_action( 'admin_menu', 'depo_add_theme_page' );
function depo_add_theme_page() {
if ( isset( $_GET['page'] ) && 'theme_options' == $_GET['page'] ) {
if ( isset( $_POST['action'] ) && 'save' == $_POST['action'] ) {
if(isset($_POST['author-name'])) {
check_admin_referer( 'depo-name' );
if ( '' == $_POST['author-name'] ) {
delete_option( 'depo-author-name' );
} else {
update_option( 'depo-author-name', esc_attr( $_POST['author-name'] ) );
}
wp_redirect( "themes.php?page=theme_options&saved=true" );
exit();
}
}
}
add_theme_page( __( 'Theme Options', 'depo-masthead' ), __( 'Theme Options', 'depo-masthead' ), 'edit_theme_options', 'theme_options', 'depo_theme_page' );
}
function depo_theme_page() {
if ( isset( $_REQUEST['saved'] ) ) echo ''.__( 'Option saved.', 'depo-masthead' ).'
';
?>
id="comment-">
tag based on what is being viewed.
*
* @since DePo Masthead 1.0.2
*/
function depo_masthead_wp_title( $title, $sep ) {
global $page, $paged;
if ( is_feed() )
return $title;
// Add the blog name
$title .= get_bloginfo( 'name' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title .= " $sep $site_description";
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
$title .= " $sep " . sprintf( __( 'Page %s', 'depo-masthead' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'depo_masthead_wp_title', 10, 2 );
/**
* Moving from header.php to functions.php for a proper enqueue
* Resizes the front page columns such that they always match heights
*/
function depo_script() {
wp_enqueue_script( 'depo-script', get_template_directory_uri() . '/scripts/script.js', array( 'jquery' ) );
// Enqueue jQuery directly, since the theme has inline jQuery scripts.
wp_enqueue_script( 'jquery' );
}
add_action( 'wp_enqueue_scripts', 'depo_script' );
/**
* Adds the adjusted stylesheet to resize the site title
*/
function depo_site_title_styles() {
// Don't proceed if Custom Fonts are active on the site title
if ( class_exists( 'TypekitData' ) && class_exists( 'CustomDesign' ) ) {
if ( CustomDesign::is_upgrade_active() ) {
$customfonts = TypekitData::get( 'families' );
if ( $customfonts ) {
$site_title = $customfonts['site-title'];
if ( $site_title['id'] )
return;
}
}
}
$title = get_bloginfo( 'name' );
$title_length = strlen( $title );
if ( 0 != $title_length ) : //avoid empty title ?>