esc_html__( 'Header Menu', 'natural-lite' ),
'social-menu' => esc_html__( 'Social Menu', 'natural-lite' ),
));
/*
* Enable support for custom logo.
*/
add_theme_support( 'custom-logo', array(
'height' => 180,
'width' => 400,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title' ),
) );
/*
* Enable support for custom header.
*/
register_default_headers( array(
'default' => array(
'url' => get_template_directory_uri() . '/images/default-header.jpg',
'thumbnail_url' => get_template_directory_uri() . '/images/default-header.jpg',
'description' => esc_html__( 'Default Custom Header', 'natural-lite' ),
),
));
$defaults = array(
'width' => 1600,
'height' => 480,
'default-image' => get_template_directory_uri() . '/images/default-header.jpg',
'flex-height' => true,
'flex-width' => true,
'header-text' => false,
'uploads' => true,
);
add_theme_support( 'custom-header', $defaults );
/*
* Enable support for custom background.
*/
$defaults = array(
'default-color' => '827768',
'default-image' => get_template_directory_uri() . '/images/default-pattern.png',
'wp-head-callback' => '_custom_background_cb',
'admin-head-callback' => '',
'admin-preview-callback' => '',
);
add_theme_support( 'custom-background', $defaults );
/*
* Enable support for HTML5 output.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
/*
* Enable support for starter content.
*/
add_theme_support( 'starter-content', array(
// Starter theme options.
'theme_mods' => array(
'natural_lite_page_left' => '{{about}}',
'natural_lite_page_mid' => '{{services}}',
'natural_lite_page_right' => '{{contact}}',
),
// Static front page set to Home, posts page set to Blog.
'options' => array(
'custom_logo' => '{{logo}}',
'show_on_front' => 'page',
'page_on_front' => '{{home}}',
'page_for_posts' => '{{blog}}',
'blogdescription' => __( 'My Awesome Organic Themes
Website', 'natural-lite' ),
),
// Starter pages to include.
'posts' => array(
'home' => array(
'template' => 'template-home.php',
),
'about' => array(
'thumbnail' => '{{image-about}}',
),
'services' => array(
'post_type' => 'page',
'post_title' => __( 'Services', 'natural-lite' ),
'post_content' => __( '
This is an example services page. You may want to write about the various services your business provides.
', 'natural-lite' ),
'thumbnail' => '{{image-services}}',
),
'blog',
'contact' => array(
'thumbnail' => '{{image-contact}}',
),
),
// Starter attachments for default images.
'attachments' => array(
'logo' => array(
'post_title' => __( 'Logo', 'natural-lite' ),
'file' => 'images/logo.png',
),
'image-about' => array(
'post_title' => __( 'About Image', 'natural-lite' ),
'file' => 'images/image-about.jpg',
),
'image-services' => array(
'post_title' => __( 'Services Image', 'natural-lite' ),
'file' => 'images/image-services.jpg',
),
'image-contact' => array(
'post_title' => __( 'Contact Image', 'natural-lite' ),
'file' => 'images/image-contact.jpg',
),
),
// Add pages to primary navigation menu.
'nav_menus' => array(
'header-menu' => array(
'name' => __( 'Primary Navigation', 'natural-lite' ),
'items' => array(
'page_home',
'page_about',
'page_services' => array(
'type' => 'post_type',
'object' => 'page',
'object_id' => '{{services}}',
),
'page_blog',
'page_contact',
),
)
),
// Add test widgets to footer.
'widgets' => array(
'footer' => array(
'text_business_info',
'meta',
'recent-posts',
'text_about',
)
)
) );
}
endif; // End natural_lite_setup.
add_action( 'after_setup_theme', 'natural_lite_setup' );
/*
-------------------------------------------------------------------------------------------------------
Admin Notice
-------------------------------------------------------------------------------------------------------
*/
function natural_lite_theme_notice() {
global $current_user;
$user_id = $current_user->ID;
if ( ! get_user_meta( $user_id, 'natural_lite_theme_notice_ignore') ) {
echo ''. __( 'Enjoying the Natural Lite theme? Consider upgrading to the premium version for more customization options, page templates and support.', 'natural-lite' ) .'
';
}
}
add_action( 'admin_notices', 'natural_lite_theme_notice' );
function natural_lite_theme_notice_ignore() {
global $current_user;
$user_id = $current_user->ID;
if ( isset( $_GET['natural-lite-ignore-notice'] ) ) {
add_user_meta( $user_id, 'natural_lite_theme_notice_ignore', 'true', true );
}
}
add_action( 'admin_init', 'natural_lite_theme_notice_ignore' );
/*
-------------------------------------------------------------------------------------------------------
Category ID to Name
-------------------------------------------------------------------------------------------------------
*/
function natural_lite_cat_id_to_name( $id ) {
$term = get_term( $id, 'category' );
if ( is_wp_error( $term ) ) {
return false; }
return $name = $term->name;
}
/*
------------------------------------------------------------------------------------------------------
Pagination Fix For Home Page Query
------------------------------------------------------------------------------------------------------
*/
function natural_lite_home_post_count_queries( $news ) {
if ( ! is_admin() && $news->is_main_query() ) {
if ( is_page_template( 'template-home.php' ) ) {
$news->set( 'posts_per_page', 1 );
}
}
}
add_action( 'pre_get_posts', 'natural_lite_home_post_count_queries' );
/*
-------------------------------------------------------------------------------------------------------
Register Scripts
-------------------------------------------------------------------------------------------------------
*/
if ( ! function_exists( 'natural_lite_enqueue_scripts' ) ) {
function natural_lite_enqueue_scripts() {
// Enqueue Styles.
wp_enqueue_style( 'natural-style', get_stylesheet_uri() );
wp_enqueue_style( 'natural-style-mobile', get_template_directory_uri() . '/css/style-mobile.css', array( 'natural-style' ), '1.0' );
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.css', array( 'natural-style' ), '1.0' );
// Resgister Scripts.
wp_register_script( 'fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', array( 'jquery' ), '20130729' );
wp_register_script( 'hover', get_template_directory_uri() . '/js/hoverIntent.js', array( 'jquery' ), '20130729' );
wp_register_script( 'superfish', get_template_directory_uri() . '/js/superfish.js', array( 'jquery', 'hover' ), '20130729' );
// Enqueue Scripts.
wp_enqueue_script( 'natural-custom', get_template_directory_uri() . '/js/jquery.custom.js', array( 'jquery', 'superfish', 'fitvids' ), '20130729', true );
wp_enqueue_script( 'natural-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20130729', true );
// Load Flexslider on front page and slideshow page template.
if ( is_page_template( 'template-home.php' ) ) {
wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/js/jquery.flexslider.js', array( 'jquery' ), '20130729' );
}
// Load single scripts only on single pages.
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'natural_lite_enqueue_scripts' );
}
/*
-------------------------------------------------------------------------------------------------------
Register Sidebars
-------------------------------------------------------------------------------------------------------
*/
function natural_lite_widgets_init() {
register_sidebar(array(
'name' => esc_html__( 'Default Sidebar', 'natural-lite' ),
'id' => 'sidebar-1',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(array(
'name' => esc_html__( 'Left Sidebar', 'natural-lite' ),
'id' => 'left-sidebar',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(array(
'name' => esc_html__( 'Footer Widgets', 'natural-lite' ),
'id' => 'footer',
'before_widget' => '',
'before_title' => '',
));
}
add_action( 'widgets_init', 'natural_lite_widgets_init' );
/*
------------------------------------------------------------------------------------------------------
Content Width
------------------------------------------------------------------------------------------------------
*/
if ( ! isset( $content_width ) ) {
$content_width = 640; }
/**
* Adjust content_width value based on the presence of widgets
*/
function natural_lite_content_width() {
if ( ! is_active_sidebar( 'sidebar-1' ) || is_active_sidebar( 'sidebar-1' ) || is_active_sidebar( 'sidebar-1' ) ) {
global $content_width;
$content_width = 960;
}
}
add_action( 'template_redirect', 'natural_lite_content_width' );
/*
-------------------------------------------------------------------------------------------------------
Comments Function
-------------------------------------------------------------------------------------------------------
*/
if ( ! function_exists( 'natural_lite_comment' ) ) :
function natural_lite_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>
', '' ); ?>
id="">
= $limit ) {
array_pop( $excerpt );
$excerpt = implode( ' ',$excerpt ).'...';
} else {
$excerpt = implode( ' ',$excerpt );
}
$excerpt = preg_replace( '`[[^]]*]`','',$excerpt );
return $excerpt;
}
function natural_lite_content( $limit ) {
$content = explode( ' ', get_the_content(), $limit );
if ( count( $content ) >= $limit ) {
array_pop( $content );
$content = implode( ' ',$content ).'...';
} else {
$content = implode( ' ',$content );
}
$content = preg_replace( '/[.+]/','', $content );
$content = apply_filters( 'the_content', $content );
$content = str_replace( ']]>', ']]>', $content );
return $content;
}
/*
-------------------------------------------------------------------------------------------------------
Pagination Function
-------------------------------------------------------------------------------------------------------
*/
function natural_lite_get_pagination_links() {
global $wp_query;
$big = 999999999;
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var( 'paged' ) ),
'prev_text' => esc_html__( '«', 'natural-lite' ),
'next_text' => esc_html__( '»', 'natural-lite' ),
'total' => $wp_query->max_num_pages,
) );
}
/*
-------------------------------------------------------------------------------------------------------
Custom Page Links
-------------------------------------------------------------------------------------------------------
*/
function natural_lite_wp_link_pages_args_prevnext_add( $args ) {
global $page, $numpages, $more, $pagenow;
if ( ! $args['next_or_number'] == 'next_and_number' ) {
return $args; }
$args['next_or_number'] = 'number'; // Keep numbering for the main part.
if ( ! $more ) {
return $args; }
if ( $page -1 ) { // There is a previous page.
$args['before'] .= _wp_link_page( $page -1 )
. $args['link_before']. $args['previouspagelink'] . $args['link_after'] . ''; }
if ( $page < $numpages ) { // There is a next page.
$args['after'] = _wp_link_page( $page + 1 )
. $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . ''
. $args['after']; }
return $args;
}
add_filter( 'wp_link_pages_args', 'natural_lite_wp_link_pages_args_prevnext_add' );
/*
-------------------------------------------------------------------------------------------------------
Body Class
-------------------------------------------------------------------------------------------------------
*/
function natural_lite_body_class( $classes ) {
$header_image = get_header_image();
if ( ! empty( $header_image ) ) {
$classes[] = 'natural-header-active';
} else {
$classes[] = 'natural-header-inactive';
}
if ( empty( $header_image ) ) {
$classes[] = 'natural-header-inactive'; }
if ( is_singular() ) {
$classes[] = 'natural-singular'; }
if ( is_active_sidebar( 'right-sidebar' ) ) {
$classes[] = 'natural-right-sidebar'; }
if ( '' != get_theme_mod( 'background_image' ) ) {
// This class will render when a background image is set
// regardless of whether the user has set a color as well.
$classes[] = 'natural-background-image';
} else if ( ! in_array( get_background_color(), array( '', get_theme_support( 'custom-background', 'default-color' ) ) ) ) {
// This class will render when a background color is set
// but no image is set. In the case the content text will
// Adjust relative to the background color.
$classes[] = 'natural-relative-text';
}
return $classes;
}
add_action( 'body_class', 'natural_lite_body_class' );
/*
-------------------------------------------------------------------------------------------------------
First Featured Video
-------------------------------------------------------------------------------------------------------
*/
function natural_lite_first_embed_media() {
global $post, $posts;
$first_vid = '';
$content = do_shortcode( apply_filters( 'the_content', $post->post_content ) );
$embeds = get_media_embedded_in_content( $content );
if ( ! empty( $embeds ) ) {
foreach ( $embeds as $embed ) {
if ( strpos( $embed, 'video' ) || strpos( $embed, 'youtube' ) || strpos( $embed, 'vimeo' ) ) {
return $embed;
}
}
} else {
return false;
}
}
/*
-----------------------------------------------------------------------------------------------------//
Includes
-------------------------------------------------------------------------------------------------------
*/
require_once( get_template_directory() . '/includes/customizer.php' );
require_once( get_template_directory() . '/includes/typefaces.php' );