'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() ) { ?>

max_num_pages > 1 ) : ?> ' . __( 'We could not find anything that matches your search query. Please try again.', 'mcluhan' ) . '

'; } // End if(). endif; // End if(). die(); } } // End if(). add_action( 'wp_ajax_nopriv_ajax_pagination', 'mcluhan_ajax_results' ); add_action( 'wp_ajax_ajax_pagination', 'mcluhan_ajax_results' ); /* REMOVE PREFIX BEFORE ARCHIVE TITLES ------------------------------------------------ */ if ( ! function_exists( 'mcluhan_remove_archive_title_prefix' ) ) { function mcluhan_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( 'Aside', 'post format archive title', 'mcluhan' ); } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { $title = _x( 'Galleries', 'post format archive title', 'mcluhan' ); } elseif ( is_tax( 'post_format', 'post-format-image' ) ) { $title = _x( 'Images', 'post format archive title', 'mcluhan' ); } elseif ( is_tax( 'post_format', 'post-format-video' ) ) { $title = _x( 'Videos', 'post format archive title', 'mcluhan' ); } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) { $title = _x( 'Quotes', 'post format archive title', 'mcluhan' ); } elseif ( is_tax( 'post_format', 'post-format-link' ) ) { $title = _x( 'Links', 'post format archive title', 'mcluhan' ); } elseif ( is_tax( 'post_format', 'post-format-status' ) ) { $title = _x( 'Statuses', 'post format archive title', 'mcluhan' ); } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) { $title = _x( 'Audio', 'post format archive title', 'mcluhan' ); } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { $title = _x( 'Chats', 'post format archive title', 'mcluhan' ); } } elseif ( is_post_type_archive() ) { $title = post_type_archive_title( '', false ); } elseif ( is_tax() ) { $title = single_term_title( '', false ); } else { $title = __( 'Archives', 'mcluhan' ); } // End if(). return $title; } } // End if(). add_filter( 'get_the_archive_title', 'mcluhan_remove_archive_title_prefix' ); /* CUSTOM COMMENT OUTPUT ------------------------------------------------ */ if ( ! function_exists( 'mcluhan_comment' ) ) { function mcluhan_comment( $comment, $args, $depth ) { switch ( $comment->comment_type ) : case 'pingback' : case 'trackback' : global $post; ?>
id="comment-">
id="li-comment-">
user_id === $post->post_author ) { echo ''; } ?> '', 'before' => '', 'depth' => $depth, 'max_depth' => $args['max_depth'], 'reply_text' => __( 'Reply', 'mcluhan' ), ) ); ?>
comment_approved ) : ?>

Reading%4$4s to a value exceeding the number of posts on your site.', 'Translators: %1$1s = opening link to the demo site, %2$2s = closing link tag, %3$3s = link to the reading options, %4$4s = closing link tag', 'mcluhan' ), '', '', '', '' ); ?>

add_section( 'mcluhan_options', array( 'capability' => 'edit_theme_options', 'description' => __( 'Customize the theme settings for McLuhan.', 'mcluhan' ), 'title' => __( 'Theme Options', 'mcluhan' ), 'priority' => 35, ) ); // Custom accent color $wp_customize->add_setting( 'mcluhan_accent_color', array( 'default' => '#121212', 'transport' => 'postMessage', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'mcluhan_accent_color', array( 'description' => __( 'Set the background color used for the sidebar on desktop, and the header on tablet and mobile.', 'mcluhan' ), 'label' => __( 'Sidebar background', 'mcluhan' ), 'section' => 'colors', 'settings' => 'mcluhan_accent_color', 'priority' => 10, ) ) ); // Dark sidebar text $wp_customize->add_setting( 'mcluhan_dark_sidebar_text', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => 'mcluhan_sanitize_checkbox', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'mcluhan_dark_sidebar_text', array( 'description' => __( 'Check this if you have set a light background color for the sidebar/mobile header.', 'mcluhan' ), 'label' => __( 'Dark text in sidebar', 'mcluhan' ), 'section' => 'colors', 'type' => 'checkbox', 'priority' => 15, ) ); // Set the home page title $wp_customize->add_setting( 'mcluhan_home_title', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_textarea_field', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'mcluhan_home_title', array( 'description' => __( 'The title you want shown on the page that displays your latest posts.', 'mcluhan' ), 'label' => __( 'Front Page Title', 'mcluhan' ), 'type' => 'textarea', 'section' => 'mcluhan_options', ) ); // Hide social $wp_customize->add_setting( 'mcluhan_hide_social', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => 'mcluhan_sanitize_checkbox', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'mcluhan_hide_social', array( 'type' => 'checkbox', 'section' => 'mcluhan_options', 'label' => __( 'Hide social buttons', 'mcluhan' ), 'description' => __( 'As default, the social section and a search toggle, even if a menu has not been set for the social section.', 'mcluhan' ), ) ); // Decide order of month + day in post previews $wp_customize->add_setting( 'mcluhan_preview_date_format', array( 'capability' => 'edit_theme_options', 'default' => 'month-day', 'sanitize_callback' => 'mcluhan_sanitize_radio', ) ); $wp_customize->add_control( 'mcluhan_preview_date_format', array( 'type' => 'radio', 'section' => 'mcluhan_options', 'label' => __( 'Archive Date Format', 'mcluhan' ), 'description' => __( 'Choose whether post previews should display the date with month or day of month first.', 'mcluhan' ), 'choices' => array( 'month-day' => __( 'Month first (Jan 1)', 'mcluhan' ), 'day-month' => __( 'Day of month first (1 Jan)', 'mcluhan' ), ), ) ); // Lowercase calendar month $wp_customize->add_setting( 'mcluhan_preview_date_lowercase', array( 'capability' => 'edit_theme_options', 'sanitize_callback' => 'mcluhan_sanitize_checkbox', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'mcluhan_preview_date_lowercase', array( 'label' => __( 'Show the month name in lowercase', 'mcluhan' ), 'section' => 'mcluhan_options', 'type' => 'checkbox', 'priority' => 15, ) ); // Make built-in controls use live JS preview $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'background_color' )->transport = 'postMessage'; // SANITATION // Sanitize boolean for checkbox function mcluhan_sanitize_checkbox( $checked ) { return ( ( isset( $checked ) && true == $checked ) ? true : false ); } // Sanitize radio buttons function mcluhan_sanitize_radio( $input, $setting ) { // Ensure input is a slug. $input = sanitize_key( $input ); // Get list of choices from the control associated with the setting. $choices = $setting->manager->get_control( $setting->id )->choices; // If the input is a valid key, return it; otherwise, return the default. return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } } // Output custom CSS in the header public static function mcluhan_header_output() { ?>