.
add_theme_support( 'automatic-feed-links' );
// This theme uses wp_nav_menu() in one location.
register_nav_menu( 'primary', __( 'Primary Menu', 'jetpack' ) );
// Add support for a variety of post formats
add_theme_support( 'post-formats', array( 'gallery' ) );
// Add support for custom backgrounds
if ( version_compare( $wp_version, '3.4', '>=' ) )
add_theme_support( 'custom-background' );
else
add_custom_background();
// Add support for post thumbnails
add_theme_support( 'post-thumbnails' );
}
endif; // minileven_setup
/**
* Enqueue scripts and styles
*/
function minileven_scripts() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_script( 'small-menu', get_template_directory_uri() . '/js/small-menu.js', array(), '20120206', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'minileven_scripts' );
/**
* Register our sidebars and widgetized areas.
* @since Minileven 1.0
*/
function minileven_widgets_init() {
register_sidebar( array(
'name' => __( 'Main Sidebar', 'jetpack' ),
'id' => 'sidebar-1',
'before_widget' => '",
'before_title' => '
',
'after_title' => '
',
) );
}
add_action( 'widgets_init', 'minileven_widgets_init' );
function minileven_posts_per_page() {
return 5;
}
add_filter('pre_option_posts_per_page', 'minileven_posts_per_page');
/**
* Determine the currently active theme.
*/
function minileven_actual_current_theme() {
$removed = remove_action( 'option_stylesheet', 'jetpack_mobile_stylesheet' );
$stylesheet = get_option( 'stylesheet' );
if ( $removed )
add_action( 'option_stylesheet', 'jetpack_mobile_stylesheet' );
return $stylesheet;
}
/* This function grabs the location of the custom menus from the current theme. If no menu is set in a location
* it will return a boolean "false". This function helps Minileven know which custom menu to display. */
function minileven_get_menu_location() {
$theme_slug = minileven_actual_current_theme();
$mods = get_option( "theme_mods_{$theme_slug}" );
if ( isset( $mods['nav_menu_locations'] ) && ! empty( $mods['nav_menu_locations'] ) )
return $mods['nav_menu_locations'];
return false;
}
/* This function grabs the custom background image from the user's current theme so that Minileven can display it. */
function minileven_get_background() {
$theme_slug = minileven_actual_current_theme();
$mods = get_option( "theme_mods_$theme_slug" );
if ( ! empty( $mods ) ) {
return array(
'color' => isset( $mods['background_color'] ) ? $mods['background_color'] : null,
'image' => isset( $mods['background_image'] ) ? $mods['background_image'] : null,
'repeat' => isset( $mods['background_repeat'] ) ? $mods['background_repeat'] : null,
'position' => isset( $mods['background_position_x'] ) ? $mods['background_position_x'] : null,
'attachment' => isset( $mods['attachment'] ) ? $mods['attachment'] : null,
);
}
return false;
}
/**
* If the user has set a static front page, show all posts on the front page, instead of a static page.
*/
if ( '1' == get_option( 'wp_mobile_static_front_page' ) )
add_filter( 'pre_option_page_on_front', '__return_zero' );
/**
* Retrieves the IDs for images in a gallery.
*
* @uses get_post_galleries() first, if available. Falls back to shortcode parsing,
* then as last option uses a get_posts() call.
*
* @return array List of image IDs from the post gallery.
*/
function minileven_get_gallery_images() {
$images = array();
if ( function_exists( 'get_post_galleries' ) ) {
$galleries = get_post_galleries( get_the_ID(), false );
if ( isset( $galleries[0]['ids'] ) )
$images = explode( ',', $galleries[0]['ids'] );
} else {
$pattern = get_shortcode_regex();
preg_match( "/$pattern/s", get_the_content(), $match );
$atts = shortcode_parse_atts( $match[3] );
if ( isset( $atts['ids'] ) )
$images = explode( ',', $atts['ids'] );
}
if ( ! $images ) {
$images = get_posts( array(
'fields' => 'ids',
'numberposts' => 999,
'order' => 'ASC',
'orderby' => 'menu_order',
'post_mime_type' => 'image',
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
) );
}
return $images;
}
/**
* Display navigation to next/previous pages when applicable
*/
function minileven_content_nav( $nav_id ) {
global $wp_query;
if ( $wp_query->max_num_pages > 1 ) : ?>
comment_type ) :
case 'pingback' :
case 'trackback' :
?>