'ffffff', ) ); // Title tag support add_theme_support( 'title-tag' ); // Add nav menu register_nav_menu( 'main-menu', __( 'Main menu', 'mcluhan' ) ); register_nav_menu( 'social-menu', __( 'Social links', 'mcluhan' ) ); // Add excerpts to pages add_post_type_support( 'page', array( 'excerpt' ) ); // HTML5 semantic markup add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) ); // Make the theme translation ready load_theme_textdomain( 'mcluhan', get_template_directory() . '/languages' ); } } // End if(). add_action( 'after_setup_theme', 'mcluhan_setup' ); /* IN SEARCH, LIST RESULTS BY DATE ------------------------------------------------ */ if ( ! function_exists( 'mcluhan_sort_search_posts_by_date' ) ) { function mcluhan_sort_search_posts_by_date( $query ) { if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { $query->set( 'orderby', 'date' ); } } } add_action( 'pre_get_posts', 'mcluhan_sort_search_posts_by_date' ); /* ENQUEUE STYLES ------------------------------------------------ */ if ( ! function_exists( 'mcluhan_load_style' ) ) { function mcluhan_load_style() { if ( ! is_admin() ) { wp_register_style( 'mcluhan-fonts', 'https://fonts.googleapis.com/css?family=Archivo:400,400i,600,600i,700,700i&subset=latin-ext', array(), null ); wp_register_style( 'fontawesome', get_template_directory_uri() . '/assets/css/font-awesome.css', null ); wp_enqueue_style( 'mcluhan-style', get_template_directory_uri() . '/style.css', array( 'fontawesome', 'mcluhan-fonts' ) ); } } } add_action( 'wp_enqueue_scripts', 'mcluhan_load_style' ); /* ADD EDITOR STYLES ------------------------------------------------ */ if ( ! function_exists( 'mcluhan_add_editor_styles' ) ) { function mcluhan_add_editor_styles() { add_editor_style( array( 'mcluhan-editor-styles.css', 'https://fonts.googleapis.com/css?family=Archivo:400,400i,600,700,700i&subset=latin-ext', ) ); } } add_action( 'init', 'mcluhan_add_editor_styles' ); /* DEACTIVATE DEFAULT WP GALLERY STYLES ------------------------------------------------ */ add_filter( 'use_default_gallery_style', '__return_false' ); /* ENQUEUE SCRIPTS ------------------------------------------------ */ if ( ! function_exists( 'mcluhan_enqueue_scripts' ) ) { function mcluhan_enqueue_scripts() { wp_enqueue_script( 'mcluhan_global', get_template_directory_uri() . '/assets/js/global.js', array( 'jquery', 'imagesloaded', 'masonry' ), '', true ); global $wp_query; // AJAX PAGINATION wp_localize_script( 'mcluhan_global', 'mcluhan_ajaxpagination', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'query_vars' => wp_json_encode( $wp_query->query ), ) ); } } add_action( 'wp_enqueue_scripts', 'mcluhan_enqueue_scripts' ); /* POST CLASSES ------------------------------------------------ */ if ( ! function_exists( 'mcluhan_post_classes' ) ) { function mcluhan_post_classes( $classes ) { // Class indicating presence/lack of post thumbnail $classes[] = ( has_post_thumbnail() ? 'has-thumbnail' : 'missing-thumbnail' ); return $classes; } } add_action( 'post_class', 'mcluhan_post_classes' ); /* BODY CLASSES ------------------------------------------------ */ if ( ! function_exists( 'mcluhan_body_classes' ) ) { function mcluhan_body_classes( $classes ) { // Check whether we're in the customizer preview if ( is_customize_preview() ) { $classes[] = 'customizer-preview'; } // Hide social buttons if ( get_theme_mod( 'mcluhan_hide_social' ) ) { $classes[] = 'hide-social'; } // White bg class if ( get_theme_mod( 'mcluhan_accent_color' ) == '#ffffff' && ( ! get_background_color() || get_background_color() == 'ffffff' ) ) { $classes[] = 'white-bg'; } // Check whether the custom backgrounds are both set to the same thing if ( get_theme_mod( 'mcluhan_accent_color' ) && get_background_color() && ltrim( get_theme_mod( 'mcluhan_accent_color' ), '#' ) == get_background_color() ) { $classes[] = 'same-custom-bgs'; } // Dark sidebar text if ( get_theme_mod( 'mcluhan_dark_sidebar_text' ) ) { $classes[] = 'dark'; } // Add short class for resume page template if ( is_page_template( 'resume-page-template.php' ) ) { $classes[] = 'resume-template'; } // Add short class for full width page template if ( is_page_template( 'full-width-page-template.php' ) ) { $classes[] = 'full-width-template'; } return $classes; } } // End if(). add_action( 'body_class', 'mcluhan_body_classes' ); /* MODIFY HTML CLASS TO INDICATE JS ------------------------------------------------ */ if ( ! function_exists( 'mcluhan_has_js' ) ) { function mcluhan_has_js() { ?> taxonomy; $taxonomy_labels = get_taxonomy_labels( get_taxonomy( $taxonomy ) ); $type = $taxonomy_labels->name; } else { $type = __( 'Archives', 'mcluhan' ); } return $type; } } /* OUTPUT THE TYPE */ if ( ! function_exists( 'mcluhan_the_archive_type' ) ) { function mcluhan_the_archive_type() { $type = mcluhan_get_archive_type(); echo $type; } } /* --------------------------------------------------------------------------------------------- AJAX PAGINATION This function is called to load the next set of posts --------------------------------------------------------------------------------------------- */ if ( ! function_exists( 'mcluhan_ajax_results' ) ) { function mcluhan_ajax_results() { $string = json_decode( stripslashes( $_POST['query_data'] ), true ); if ( $string ) : $args = array( 's' => $string, 'posts_per_page' => 5, 'post_status' => 'publish', ); $ajax_query = new WP_Query( $args ); if ( $ajax_query->have_posts() ) { ?>