Advertisement
sarcoguy

functions.php

Jan 16th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.72 KB | None | 0 0
  1. <?php
  2. function my_theme_enqueue_styles() {
  3.  
  4.     $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
  5.  
  6.     wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
  7.     wp_enqueue_style( 'child-style',
  8.         get_stylesheet_directory_uri() . '/style.css',
  9.         array( $parent_style ),
  10.         wp_get_theme()->get('Version')
  11.     );
  12. }
  13. add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
  14. ?>
  15.  
  16. <?php
  17. /**
  18.  * Misty Lake functions and definitions
  19.  *
  20.  * @package Misty Lake
  21.  * @since Misty Lake 1.0
  22.  */
  23.  
  24. /**
  25.  * Set the content width based on the theme's design and stylesheet.
  26.  *
  27.  * @since Misty Lake 1.0
  28.  */
  29. if ( ! isset( $content_width ) )
  30.     $content_width = 660; /* pixels */
  31.  
  32. /**
  33.  * Adjust the content width for Full Width page template.
  34.  */
  35. function mistylake_set_content_width() {
  36.     global $content_width;
  37.  
  38.     if ( is_page_template( 'page-full-width.php' ) )
  39.         $content_width = 878;
  40. }
  41. add_action( 'template_redirect', 'mistylake_set_content_width' );
  42.  
  43. if ( ! function_exists( 'mistylake_setup' ) ) :
  44. /**
  45.  * Sets up theme defaults and registers support for various WordPress features.
  46.  *
  47.  * Note that this function is hooked into the after_setup_theme hook, which runs
  48.  * before the init hook. The init hook is too late for some features, such as indicating
  49.  * support post thumbnails.
  50.  *
  51.  * @since Misty Lake 1.0
  52.  */
  53. function mistylake_setup() {
  54.  
  55.     /**
  56.      * Make theme available for translation
  57.      * Translations can be filed in the /languages/ directory
  58.      * If you're building a theme based on Misty Lake, use a find and replace
  59.      * to change 'mistylake' to the name of your theme in all the template files
  60.      */
  61.     load_theme_textdomain( 'mistylake', get_template_directory() . '/languages' );
  62.  
  63.     /**
  64.      * Add default posts and comments RSS feed links to head
  65.      */
  66.     add_theme_support( 'automatic-feed-links' );
  67.  
  68.     /*
  69.      * Let WordPress manage the document title.
  70.      * By adding theme support, we declare that this theme does not use a
  71.      * hard-coded <title> tag in the document head, and expect WordPress to
  72.      * provide it for us.
  73.      *
  74.      * @since Misty Lake 1.2.1
  75.      */
  76.     add_theme_support( 'title-tag' );
  77.  
  78.     /**
  79.      * Enable support for Post Thumbnails
  80.      */
  81.     add_theme_support( 'post-thumbnails' );
  82.     add_image_size( 'mistylake-thumbnail', '619', '9999' );
  83.  
  84.     /**
  85.      * This theme uses wp_nav_menu() in one location.
  86.      */
  87.     register_nav_menus( array(
  88.         'primary' => __( 'Primary Menu', 'mistylake' ),
  89.     ) );
  90.  
  91.     /**
  92.      * Add support for custom backgrounds
  93.      */
  94.     add_theme_support( 'custom-background' );
  95.  
  96.     /**
  97.      * Add support for required post formats
  98.      */
  99.     add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) );
  100. }
  101. endif; // mistylake_setup
  102. add_action( 'after_setup_theme', 'mistylake_setup' );
  103.  
  104.  
  105. /**
  106.  * Enqueue Google Fonts
  107.  */
  108.  
  109. function mistylake_fonts() {
  110.  
  111.     /* translators: If there are characters in your language that are not supported
  112.        by Open Sans, translate this to 'off'. Do not translate into your own language. */
  113.     if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'mistylake' ) ) {
  114.  
  115.         $opensans_subsets = 'latin,latin-ext';
  116.  
  117.         /* translators: To add an additional Open Sans character subset specific to your language, translate
  118.            this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. */
  119.         $opensans_subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)', 'mistylake' );
  120.  
  121.         if ( 'cyrillic' == $opensans_subset )
  122.             $opensans_subsets .= ',cyrillic,cyrillic-ext';
  123.         elseif ( 'greek' == $opensans_subset )
  124.             $opensans_subsets .= ',greek,greek-ext';
  125.         elseif ( 'vietnamese' == $opensans_subset )
  126.             $opensans_subsets .= ',vietnamese';
  127.  
  128.         $opensans_query_args = array(
  129.             'family' => 'Open+Sans:300,300italic,400,400italic,600,600italic,700,700italic',
  130.             'subset' => $opensans_subsets,
  131.         );
  132.         wp_register_style( 'mistylake-open-sans', add_query_arg( $opensans_query_args, "https://fonts.googleapis.com/css" ), array(), null );
  133.     }
  134.  
  135.  
  136.  
  137.     /* translators: If there are characters in your language that are not supported
  138.        by Droid Serif, translate this to 'off'. Do not translate into your own language. */
  139.     if ( 'off' !== _x( 'on', 'Droid Serif font: on or off', 'mistylake' ) )
  140.         wp_register_style( 'mistylake-droid-serif', "https://fonts.googleapis.com/css?family=Droid+Serif:400,400italic,400bold&subset=latin" );
  141. }
  142. add_action( 'init', 'mistylake_fonts' );
  143.  
  144. /**
  145.  * Enqueue font styles in custom header admin
  146.  */
  147.  
  148. function mistylake_admin_fonts() {
  149.     wp_enqueue_style( 'mistylake-open-sans' );
  150.     wp_enqueue_style( 'mistylake-droid-serif' );
  151.  
  152. }
  153. add_action( 'admin_print_styles-appearance_page_custom-header', 'mistylake_admin_fonts' );
  154.  
  155. /**
  156.  * Register widgetized area and update sidebar with default widgets
  157.  *
  158.  * @since Misty Lake 1.0
  159.  */
  160. function mistylake_widgets_init() {
  161.     register_sidebar( array(
  162.         'name'          => __( 'Sidebar', 'mistylake' ),
  163.         'id'            => 'sidebar-1',
  164.         'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  165.         'after_widget'  => '</aside>',
  166.         'before_title'  => '<h1 class="widget-title">',
  167.         'after_title'   => '</h1>',
  168.     ) );
  169. }
  170. add_action( 'widgets_init', 'mistylake_widgets_init' );
  171.  
  172. /**
  173.  * Enqueue scripts and styles
  174.  */
  175. function mistylake_scripts() {
  176.     global $wp_styles;
  177.  
  178.     wp_enqueue_style( 'mistylake', get_stylesheet_uri() );
  179.  
  180.     wp_enqueue_style( 'mistylake-ie', get_template_directory_uri() . '/ie.css', array( 'mistylake' ) );
  181.     $wp_styles->add_data( 'mistylake-ie', 'conditional', 'IE 8' );
  182.  
  183.     wp_enqueue_script( 'mistylake-small-menu', get_template_directory_uri() . '/js/small-menu.js', array( 'jquery' ), '20120206', true );
  184.  
  185.     if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
  186.         wp_enqueue_script( 'comment-reply' );
  187.  
  188.     wp_enqueue_style( 'mistylake-open-sans' );
  189.     wp_enqueue_style( 'mistylake-droid-serif' );
  190.  
  191.     if ( is_singular() && wp_attachment_is_image() )
  192.         wp_enqueue_script( 'mistylake-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
  193. }
  194. add_action( 'wp_enqueue_scripts', 'mistylake_scripts' );
  195.  
  196. /**
  197.  * Add theme options in the Customizer
  198.  */
  199.  
  200. function mistylake_customize( $wp_customize ) {
  201.  
  202.     $wp_customize->add_section( 'mistylake_settings', array(
  203.         'title'    => __( 'Theme Options', 'mistylake' ),
  204.         'priority' => 35,
  205.     ) );
  206.  
  207.     $wp_customize->add_setting( 'mistylake_show_subpages', array(
  208.         'default'           => '',
  209.         'sanitize_callback' => 'mistylake_sanitize_checkbox',
  210.     ) );
  211.  
  212.     $wp_customize->add_control( 'mistylake_show_subpages', array(
  213.         'label'    => __( 'Show list of subpages below content on Parent Pages', 'mistylake' ),
  214.         'section'  => 'mistylake_settings',
  215.         'settings' => 'mistylake_show_subpages',
  216.         'type'     => 'checkbox',
  217.         'choices'  => array(
  218.             'yes' => 'Yes',
  219.         ),
  220.     ) );
  221. }
  222. add_action( 'customize_register', 'mistylake_customize' );
  223.  
  224. if ( ! function_exists( 'mistylake_sanitize_checkbox' ) ) :
  225. /**
  226.  * Sanitize a checkbox setting.
  227.  *
  228.  * @since Misty lake 1.2.1
  229.  */
  230. function mistylake_sanitize_checkbox( $value ) {
  231.     return ( 1 == $value ) ? 1 : '';
  232. }
  233. endif;
  234.  
  235. /**
  236.  * Implement the Custom Header feature.
  237.  */
  238. require get_template_directory() . '/inc/custom-header.php';
  239.  
  240. /**
  241.  * Custom template tags for this theme.
  242.  */
  243. require get_template_directory() . '/inc/template-tags.php';
  244.  
  245. /**
  246.  * Custom functions that act independently of the theme templates
  247.  */
  248. require get_template_directory() . '/inc/extras.php';
  249.  
  250. /**
  251.  * Custom functions for Jetpack.
  252.  */
  253. require get_template_directory() . '/inc/jetpack.php';
  254.  
  255. /**
  256.  * Customizer support
  257.  */
  258. require get_template_directory() . '/inc/customizer.php';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement