240,
'width' => 240,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
) );
// Title tag
add_theme_support( 'title-tag' );
// Add nav menu
register_nav_menu( 'primary-menu', __( 'Primary Menu', 'miyazaki' ) );
register_nav_menu( 'mobile-menu', __( 'Mobile Menu', 'miyazaki' ) );
register_nav_menu( 'footer-menu', __( 'Footer Menu', 'miyazaki' ) );
// HTML5 semantic markup
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
// Make the theme translation ready
load_theme_textdomain( 'miyazaki', get_template_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'miyazaki_setup' );
endif;
/* ---------------------------------------------------------------------------------------------
ENQUEUE STYLES
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_load_style' ) ) :
function miyazaki_load_style() {
if ( ! is_admin() ) :
$dependencies = array();
/**
* Translators: If there are characters in your language that are not
* supported by Teko, translate this to 'off'. Do not translate
* into your own language.
*/
$teko = _x( 'on', 'Teko font: on or off', 'miyazaki' );
if ( 'off' !== $teko ) {
$font_families = array();
$font_families[] = 'Teko:400,500,600,700';
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
wp_register_style( 'miyazaki-google-fonts', $fonts_url, array() );
$dependencies[] = 'miyazaki-google-fonts';
}
wp_enqueue_style( 'miyazaki-style', get_template_directory_uri() . '/style.css', $dependencies, wp_get_theme( 'miyazaki' )->get( 'Version' ) );
endif;
}
add_action( 'wp_enqueue_scripts', 'miyazaki_load_style' );
endif;
/* ---------------------------------------------------------------------------------------------
ADD EDITOR STYLES
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_add_editor_styles' ) ) :
function miyazaki_add_editor_styles() {
add_editor_style( array(
'miyazaki-editor-styles.css',
'https://fonts.googleapis.com/css?family=Teko:400,500,600,700',
) );
}
add_action( 'init', 'miyazaki_add_editor_styles' );
endif;
/* ---------------------------------------------------------------------------------------------
ENQUEUE SCRIPTS
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_enqueue_scripts' ) ) :
function miyazaki_enqueue_scripts() {
wp_enqueue_script( 'miyazaki_construct', get_template_directory_uri() . '/assets/js/construct.js', array( 'jquery', 'imagesloaded', 'masonry' ), wp_get_theme()->get( 'Version' ), true );
if ( ( ! is_admin() ) && is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
$ajax_url = admin_url( 'admin-ajax.php' );
// AJAX Load More
wp_localize_script( 'miyazaki_construct', 'miyazaki_ajax_load_more', array(
'ajaxurl' => esc_url( $ajax_url ),
) );
}
add_action( 'wp_enqueue_scripts', 'miyazaki_enqueue_scripts' );
endif;
/* ---------------------------------------------------------------------------------------------
INCLUDE THEME WIDGETS
--------------------------------------------------------------------------------------------- */
require_once( get_template_directory() . '/widgets/recent-comments.php' );
require_once( get_template_directory() . '/widgets/recent-posts.php' );
/* ---------------------------------------------------------------------------------------------
REGISTER THEME WIDGETS
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_register_widgets' ) ) {
function miyazaki_register_widgets() {
// Default widgets
register_widget( 'Miyazaki_Recent_Comments' );
register_widget( 'Miyazaki_Recent_Posts' );
}
add_action( 'widgets_init', 'miyazaki_register_widgets' );
}
/* ---------------------------------------------------------------------------------------------
DELIST DEFAULT WIDGETS REPLACE BY THEME ONES
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_unregister_default_widgets' ) ) {
function miyazaki_unregister_default_widgets() {
unregister_widget( 'WP_Widget_Recent_Comments' );
unregister_widget( 'WP_Widget_Recent_Posts' );
}
add_action( 'widgets_init', 'miyazaki_unregister_default_widgets', 11 );
}
/* ---------------------------------------------------------------------------------------------
POST CLASSES
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_post_classes' ) ) :
function miyazaki_post_classes( $classes ) {
global $post;
// Class indicating presence/lack of post thumbnail
$classes[] = ( has_post_thumbnail() ? 'has-thumbnail' : 'missing-thumbnail' );
return $classes;
}
add_action( 'post_class', 'miyazaki_post_classes' );
endif;
/* ---------------------------------------------------------------------------------------------
BODY CLASSES
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_body_classes' ) ) :
function miyazaki_body_classes( $classes ) {
global $post;
// Determine type of infinite scroll
$pagination_type = get_theme_mod( 'miyazaki_pagination_type' ) ? get_theme_mod( 'miyazaki_pagination_type' ) : 'button';
switch ( $pagination_type ) {
case 'button' :
$classes[] = 'pagination-type-button';
break;
case 'scroll' :
$classes[] = 'pagination-type-scroll';
break;
case 'links' :
$classes[] = 'pagination-type-links';
break;
}
// Add class for front page title styling
if ( is_home() && is_front_page() && ! get_theme_mod( 'miyazaki_disable_front_page_title' ) && ! get_theme_mod( 'custom_logo' ) ) {
$classes[] = 'has-front-header';
}
// Add class for overlay logo
if ( get_theme_mod( 'miyazaki_overlay_logo' ) ) {
$classes[] = 'has-overlay-logo';
}
// Check for post thumbnail
if ( is_singular() && has_post_thumbnail() ) {
$classes[] = 'has-post-thumbnail';
} elseif ( is_singular() ) {
$classes[] = 'missing-post-thumbnail';
}
// Check whether we're in the customizer preview
if ( is_customize_preview() ) {
$classes[] = 'customizer-preview';
}
// Slim page template class names (class = name - file suffix)
if ( is_page_template() ) {
$classes[] = preg_replace( '/\\.[^.\\s]{3,4}$/', '', get_page_template_slug( $post->ID ) );
}
return $classes;
}
add_action( 'body_class', 'miyazaki_body_classes' );
endif;
/* ---------------------------------------------------------------------------------------------
ADD HTML CLASS IF THERE'S JAVASCRIPT
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_has_js' ) ) :
function miyazaki_has_js() {
?>
__( 'Footer #1', 'miyazaki' ),
'id' => 'footer-one',
'description' => __( 'Widgets in this area will be shown in the first footer column.', 'miyazaki' ),
'before_title' => '
',
'after_title' => '
',
'before_widget' => '
',
'after_widget' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer #2', 'miyazaki' ),
'id' => 'footer-two',
'description' => __( 'Widgets in this area will be shown in the second footer column.', 'miyazaki' ),
'before_title' => '
',
'after_title' => '
',
'before_widget' => '
',
'after_widget' => '
',
) );
register_sidebar( array(
'name' => __( 'Footer #3', 'miyazaki' ),
'id' => 'footer-three',
'description' => __( 'Widgets in this area will be shown in the third footer column.', 'miyazaki' ),
'before_title' => '
',
'after_title' => '
',
'before_widget' => '
',
'after_widget' => '
',
) );
}
add_action( 'widgets_init', 'miyazaki_widget_areas' );
endif;
/* ---------------------------------------------------------------------------------------------
REMOVE ARCHIVE PREFIXES
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_remove_archive_title_prefix' ) ) :
function miyazaki_remove_archive_title_prefix( $title ) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '' . get_the_author() . '';
} elseif ( is_year() ) {
$title = get_the_date( 'Y' );
} elseif ( is_month() ) {
$title = get_the_date( 'F Y' );
} elseif ( is_day() ) {
$title = get_the_date( get_option( 'date_format' ) );
} elseif ( is_tax( 'post_format' ) ) {
if ( is_tax( 'post_format', 'post-format-aside' ) ) {
$title = _x( 'Asides', 'post format archive title', 'miyazaki' );
} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
$title = _x( 'Galleries', 'post format archive title', 'miyazaki' );
} elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
$title = _x( 'Images', 'post format archive title', 'miyazaki' );
} elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
$title = _x( 'Videos', 'post format archive title', 'miyazaki' );
} elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
$title = _x( 'Quotes', 'post format archive title', 'miyazaki' );
} elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
$title = _x( 'Links', 'post format archive title', 'miyazaki' );
} elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
$title = _x( 'Statuses', 'post format archive title', 'miyazaki' );
} elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
$title = _x( 'Audio', 'post format archive title', 'miyazaki' );
} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
$title = _x( 'Chats', 'post format archive title', 'miyazaki' );
}
} elseif ( is_post_type_archive() ) {
$title = post_type_archive_title( '', false );
} elseif ( is_tax() ) {
$title = single_term_title( '', false );
} elseif ( is_search() ) {
$title = '‘' . get_search_query() . '’';
} else {
$title = __( 'Archives', 'miyazaki' );
} // End if().
return $title;
}
add_filter( 'get_the_archive_title', 'miyazaki_remove_archive_title_prefix' );
endif;
/* ---------------------------------------------------------------------------------------------
GET ARCHIVE PREFIX
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_get_archive_title_prefix' ) ) :
function miyazaki_get_archive_title_prefix() {
if ( is_category() ) {
$title_prefix = __( 'Category', 'miyazaki' );
} elseif ( is_tag() ) {
$title_prefix = __( 'Tag', 'miyazaki' );
} elseif ( is_author() ) {
$title_prefix = __( 'Author', 'miyazaki' );
} elseif ( is_year() ) {
$title_prefix = __( 'Year', 'miyazaki' );
} elseif ( is_month() ) {
$title_prefix = __( 'Month', 'miyazaki' );
} elseif ( is_day() ) {
$title_prefix = __( 'Day', 'miyazaki' );
} elseif ( is_tax() ) {
$tax = get_taxonomy( get_queried_object()->taxonomy );
$title_prefix = $tax->labels->singular_name;
} elseif ( is_search() ) {
$title_prefix = __( 'Search', 'miyazaki' );
} else {
$title_prefix = __( 'Archives', 'miyazaki' );
}
return $title_prefix;
}
endif;
/* ---------------------------------------------------------------------------------------------
GET FALLBACK IMAGE
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_get_fallback_image_url' ) ) :
function miyazaki_get_fallback_image_url() {
$disable_fallback_image = get_theme_mod( 'miyazaki_disable_fallback_image' );
if ( $disable_fallback_image ) {
return '';
}
$fallback_image_id = get_theme_mod( 'miyazaki_fallback_image' );
if ( $fallback_image_id ) {
$fallback_image = wp_get_attachment_image_src( $fallback_image_id, 'full' );
}
$fallback_image_url = isset( $fallback_image ) ? esc_url( $fallback_image[0] ) : get_template_directory_uri() . '/assets/images/default-fallback-image.png';
return $fallback_image_url;
}
endif;
/* ---------------------------------------------------------------------------------------------
OUTPUT FALLBACK IMAGE
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_the_fallback_image' ) ) :
function miyazaki_the_fallback_image() {
$fallback_image_url = miyazaki_get_fallback_image_url();
if ( ! $fallback_image_url ) {
return;
}
echo '';
}
endif;
/* ---------------------------------------------------------------------------------------------
GET THE IMAGE SIZE OF PREVIEWS
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_get_preview_image_size' ) ) :
function miyazaki_get_preview_image_size() {
// Check if low-resolution images are activated in the customizer
$low_res_images = get_theme_mod( 'miyazaki_activate_low_resolution_images' );
// If they are, we're using the low resolution image size
if ( $low_res_images ) {
return 'miyazaki_preview_image_low_resolution';
// If not, we're using the high resolution image size
} else {
return 'miyazaki_preview_image_high_resolution';
}
}
endif;
/* ---------------------------------------------------------------------------------------------
OUTPUT POST META
If it's a single post, output the post meta values specified in the Customizer settings.
@param $post_id int The ID of the post for which the post meta should be output
@param $location string Which post meta location to output – single or preview
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_the_post_meta' ) ) :
function miyazaki_the_post_meta( $post_id = null, $location = 'single-top' ) {
echo miyazaki_get_post_meta( $post_id, $location );
}
endif;
/* ---------------------------------------------------------------------------------------------
GET THE POST META
If the provided ID is for a single post, return the post meta values specified in the Customizer settings.
@param $post_id int The ID of the post for which the post meta should be output
@param $location string Which post meta location to output – single or preview
--------------------------------------------------------------------------------------------- */
if ( ! function_exists( 'miyazaki_get_post_meta' ) ) :
function miyazaki_get_post_meta( $post_id = null, $location = 'single-top' ) {
// Require post ID
if ( ! $post_id ) {
return;
}
// Check that the post type should be able to output post meta
$allowed_post_types = apply_filters( 'miyazaki_allowed_post_types_for_meta_output', array( 'post' ) );
if ( ! in_array( get_post_type( $post_id ), $allowed_post_types ) ) {
return;
}
$post_meta_wrapper_classes = '';
$post_meta_classes = '';
// Get the post meta settings for the location specified
if ( 'preview' === $location ) {
$post_meta = get_theme_mod( 'miyazaki_post_meta_preview' );
$post_meta_wrapper_classes = ' post-meta-preview';
// Empty = use default
if ( ! $post_meta ) {
$post_meta = array();
}
} elseif ( 'single-top' === $location ) {
$post_meta = get_theme_mod( 'miyazaki_post_meta_single_top' );
$post_meta_wrapper_classes = ' post-meta-single post-meta-single-top';
// Empty = use default
if ( ! $post_meta ) {
$post_meta = array(
'post-date',
'categories',
);
}
} elseif ( 'single-bottom' === $location ) {
$post_meta = get_theme_mod( 'miyazaki_post_meta_single_bottom' );
$post_meta_wrapper_classes = ' post-meta-single post-meta-single-bottom';
// Empty = use default
if ( ! $post_meta ) {
$post_meta = array(
'tags',
);
}
}
// If the post meta setting has the value 'empty', it's explicitly empty and the default post meta shouldn't be output
if ( $post_meta && ! in_array( 'empty', $post_meta ) ) :
ob_start();
setup_postdata( $post_id );
?>