__( 'Top Menu', 'nasio' ),
'social' => __( 'Social Links Menu', 'nasio' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'comment-form',
'comment-list',
'gallery',
'caption',
) );
// Add theme support for Custom Logo.
add_theme_support( 'custom-logo', array(
'height' => 250,
'width' => 250,
'flex-height' => true,
'flex-width' => true,
) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
}
add_action( 'after_setup_theme', 'nasio_setup' );
if (isset( $content_width ))
$nasio_content_width = 900;
//Register widget area.
function nasio_widgets_init() {
register_sidebar( array(
'name' => __( 'Right Sidebar', 'nasio' ),
'id' => 'sidebar-1',
'description' => __( 'Add widgets here to appear in your sidebar on blog posts and archive pages.', 'nasio' ),
'before_widget' => '',
'before_title' => '
',
'after_title' => ' ',
) );
register_sidebar( array(
'name' => __( 'Footer 1', 'nasio' ),
'id' => 'sidebar-2',
'description' => __( 'Add widgets here to appear in your footer.', 'nasio' ),
'before_widget' => '',
'before_title' => '',
'after_title' => ' ',
) );
register_sidebar( array(
'name' => __( 'Footer 2', 'nasio' ),
'id' => 'sidebar-3',
'description' => __( 'Add widgets here to appear in your footer.', 'nasio' ),
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'nasio_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function nasio_styles() {
//Theme Navigation
wp_enqueue_script( 'navigation', get_template_directory_uri() . '/assets/js/navigation-min.js', array( 'jquery' ),'',true);
//Theme stylesheet.
wp_enqueue_style( 'nasio-css', get_template_directory_uri() . '/style-min.css', '', '1.0.3' );
}
add_action( 'wp_enqueue_scripts', 'nasio_styles' );
/**
* Enqueue fonts to the footer for better peformance
*/
function nasio_fonts() {
//Font Awesome
wp_enqueue_style('font-awesome', get_template_directory_uri() . '/public/css/font-awesome.min.css');
//Add google fonts
wp_enqueue_style( 'Merriweather', '//fonts.googleapis.com/css?family=Merriweather&display=swap' );
wp_enqueue_style( 'OpenSans', '//fonts.googleapis.com/css?family=Open+Sans' );
}
add_action( 'wp_footer', 'nasio_fonts' );
//Remove default width and height attributes from image tags
function nasio_remove_image_size_attributes( $html ) {
return preg_replace( '/(width|height)="\d*"/', '', $html );
}
// Remove image size attributes from post thumbnails
add_filter( 'post_thumbnail_html', 'nasio_remove_image_size_attributes' );
// Remove image size attributes from images added to a WordPress post
add_filter( 'image_send_to_editor', 'nasio_remove_image_size_attributes' );
function nasio_front_page_template( $template ) {
return is_home() ? '' : $template;
}
add_filter( 'frontpage_template', 'nasio_front_page_template' );
function nasio_posted_on() {
if ( is_sticky() && is_home() && ! is_paged() ) {
echo '' . __( 'Sticky', 'nasio' ) . ' ';
}
// Set up and print post meta information.
printf( '%3$s
%5$s ',
esc_url( get_permalink() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr(get_the_author())
);
}
function nasio_get_category(){
$categories = get_the_category();
$separator = ' ';
$output = '';
if ( ! empty( $categories ) ) {
foreach( $categories as $category ) {
$output .= '' . esc_html( $category->name ) . ' ' . $separator;
}
echo trim( $output, $separator );
}
}
//Make drop down menu accessible by screen readers
/**
* WCAG 2.0 Attributes for Dropdown Menus
*
* Adjustments to menu attributes tot support WCAG 2.0 recommendations
* for flyout and dropdown menus.
*
* @ref https://www.w3.org/WAI/tutorials/menus/flyout/
*/
function nasio_nav_menu_link_attributes( $atts, $item, $args, $depth ) {
// Add [aria-haspopup] and [aria-expanded] to menu items that have children
$item_has_children = in_array( 'menu-item-has-children', $item->classes );
if ( $item_has_children ) {
$atts['aria-haspopup'] = "true";
$atts['aria-expanded'] = "false";
}
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'nasio_nav_menu_link_attributes', 10, 4 );
/**
* Extend Recent Posts Widget
*
* Adds Images to the default WordPress Recent Posts Widget
*/
Class Nasio_Recent_Posts_Widget extends WP_Widget_Recent_Posts {
function widget($args, $instance) {
if ( ! isset( $args['widget_id'] ) ) {
$args['widget_id'] = $this->id;
}
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts', 'nasio' );
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
$number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 3;
if ( ! $number )
$number = 3;
$show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
/**
* Filter the arguments for the Recent Posts widget.
*
* @since 3.4.0
*
* @see WP_Query::get_posts()
*
* @param array $args An array of arguments used to retrieve the recent posts.
*/
$r = new WP_Query( apply_filters( 'widget_posts_args', array(
'posts_per_page' => $number,
'no_found_rows' => true,
'post_status' => 'publish',
'ignore_sticky_posts' => true
) ) );
if ($r->have_posts()) :
echo $args['before_widget']; ?>
have_posts() ) : $r->the_post(); ?>
< id="comment-"
>
$max_words && $max_words > 0)
$phrase = implode(' ', array_slice($phrase_array, 0, $max_words)) . __('...', 'nasio');
return $phrase;
}
// ADD OPTIONS TO THEME CUSTOMIZER
if ( function_exists( 'get_parent_theme_file_path' ) ){ // Since WordPress 4.7
require get_parent_theme_file_path( '/inc/customizer.php' );
}
else{
require get_template_directory() . '/inc/customizer.php';
}
// PAGINATION
function nasio_numeric_posts_nav() {
if( is_singular() )
return;
global $wp_query;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( '%s ' . "\n", get_previous_posts_link() );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="active"' : '';
printf( '%s ' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '... ';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="active"' : '';
printf( '%s ' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '... ' . "\n";
$class = $paged == $max ? ' class="active"' : '';
printf( '%s ' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( '%s ' . "\n", get_next_posts_link() );
echo ' ' . "\n";
}