__( 'Primary Menu', 'skylark' ),
) );
/**
* Add support for the Image, Gallery, and Video post formats
*/
add_theme_support( 'post-formats', array( 'image', 'gallery', 'video', ) );
}
endif; // skylark_setup
add_action( 'after_setup_theme', 'skylark_setup' );
/**
* Setup the WordPress core custom background feature.
*
* Hooks into the after_setup_theme action.
*
* @since Skylark 1.0.1
*/
function skylark_register_custom_background() {
add_theme_support( 'custom-background', apply_filters( 'skylark_custom_background_args', array(
'default-color' => 'ffffff',
) ) );
}
add_action( 'after_setup_theme', 'skylark_register_custom_background' );
/**
* Register widgetized area and update sidebar with default widgets
*
* @since Skylark 1.0
*/
function skylark_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'skylark' ),
'id' => 'sidebar-1',
'before_widget' => '',
'before_title' => '
',
) );
}
add_action( 'widgets_init', 'skylark_widgets_init' );
/**
* Enqueue scripts and styles
*/
function skylark_scripts() {
global $post;
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_script( 'small-menu', get_template_directory_uri() . '/js/small-menu.js', array( 'jquery' ), '20120206', true );
if ( is_page_template( 'page-showcase.php' ) ) {
wp_enqueue_script( 'jquery-cycle', get_template_directory_uri() . '/js/jquery.cycle.min.js', array( 'jquery' ), '20120419', true );
wp_enqueue_script( 'skylark-theme', get_template_directory_uri() . '/js/theme.js', array( 'jquery' ), '20120419', true );
}
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image( $post->ID ) ) {
wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
}
}
add_action( 'wp_enqueue_scripts', 'skylark_scripts' );
/**
* Background wrapper style for front-end when a custom background image or color is set
*/
function skylark_custom_background() {
// Set the default color.
$background_color = 'ffffff';
// If background color is specified use that color.
if ( '' != get_background_color() ) :
$background_color = get_background_color();
endif;
// If a background image is specified, use that image.
if ( '' != get_background_image() ) :
$background_image = get_background_image();
endif;
?>
query( array(
'post__in' => $sticky,
'posts_per_page' => 10,
'no_found_rows' => true,
'ignore_sticky_posts' => 1
) );
if ( ! $featured_posts )
return array();
global $post;
$featured = array();
foreach ( (array) $featured_posts as $post ) {
setup_postdata( $post );
// Featured posts are required to have a featured image.
if ( '' == get_the_post_thumbnail() )
continue;
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'skylark-featured-thumbnail' );
if ( ! isset( $image[1] ) )
continue;
if ( 500 > $image[1] )
continue;
$featured[] = $post;
}
wp_reset_postdata();
$featured_ids = wp_list_pluck( $featured, 'ID' );
return $featured;
}
/**
* Register Google fonts styles.
*
* @since Skylark 1.0.1
*/
function skylark_register_fonts() {
wp_register_style(
'open-sans',
"https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700",
array(),
'20120821'
);
}
add_action( 'init', 'skylark_register_fonts' );
/**
* Enqueue Google Fonts.
*
* @since Skylark 1.0.1
*/
function skylark_fonts() {
wp_enqueue_style( 'open-sans' );
}
add_action( 'wp_enqueue_scripts', 'skylark_fonts' );
/**
* Enqueue Google fonts style to admin screen for custom header display.
*
* @since Skylark 1.0.1
*/
function skylark_admin_fonts( $hook_suffix ) {
if ( 'appearance_page_custom-header' != $hook_suffix )
return;
wp_enqueue_style( 'open-sans' );
}
add_action( 'admin_enqueue_scripts', 'skylark_admin_fonts' );
/**
* Test to see if posts with featured images have images less than 280px wide. If so, we need to exclude them.
* We store the results of the loop in a transient, to prevent running this
* extra query on every page load. The results are an array of post ID's to exclude.
* This gives us a quick way to loop through the posts again without needing to query additional times.
*/
function skylark_not_portfolio_posts() {
if ( false === ( $nonportfolio_post_ids = get_transient( 'nonportfolio_post_ids' ) ) ) {
$nonportfolio_args = array(
'posts_per_page' => 100,
'post_status' => 'publish',
'meta_key' => '_thumbnail_id',
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array( 'post-format-image', 'post-format-video', 'post-format-gallery' ),
)
),
);
// The Portfolio Posts query
$nonportfolio = new WP_Query( $nonportfolio_args );
// Proceed only if published posts with thumbnails exist
if ( $nonportfolio->have_posts() ) {
while ( $nonportfolio->have_posts() ) {
$nonportfolio->the_post();
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $nonportfolio->ID ), 'skylark-portfolio-thumbnail' ); // get the thumbnail image
// If the thumbnail image is not at least as wide as our minimum featured image width, add it to the exclude array.
if ( $image[1] < 280 ) {
$nonportfolio_post_ids[] = $nonportfolio->post->ID;
}
}
set_transient( 'nonportfolio_post_ids', $nonportfolio_post_ids );
}
}
/*
* Return an array of post IDs that have post thumbnails that don't meet the >=280px size criteria
*/
return $nonportfolio_post_ids;
}
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/tweaks.php';
/**
* Custom Theme Options.
*/
require get_template_directory() . '/inc/theme-options/theme-options.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
if( class_exists( 'Jetpack' ) ) {
require get_template_directory() . '/inc/jetpack.php';
}