functions.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <?php
  2. /**
  3. * Intergalactic 2 functions and definitions
  4. *
  5. * @package Intergalactic 2
  6. */
  7. /**
  8. * Set the content width in pixels, based on the theme's design and stylesheet.
  9. *
  10. * Priority 0 to make it available to lower priority callbacks.
  11. *
  12. * @global int $content_width
  13. */
  14. function intergalactic_2_content_width() {
  15. $GLOBALS['content_width'] = apply_filters( 'intergalactic_2_content_width', 1000 );
  16. }
  17. add_action( 'after_setup_theme', 'intergalactic_2_content_width', 0 );
  18. if ( ! function_exists( 'intergalactic_2_setup' ) ) :
  19. /**
  20. * Sets up theme defaults and registers support for various WordPress features.
  21. *
  22. * Note that this function is hooked into the after_setup_theme hook, which
  23. * runs before the init hook. The init hook is too late for some features, such
  24. * as indicating support for post thumbnails.
  25. */
  26. function intergalactic_2_setup() {
  27. /*
  28. * Make theme available for translation.
  29. * Translations can be filed in the /languages/ directory.
  30. * If you're building a theme based on Intergalactic 2, use a find and replace
  31. * to change 'intergalactic-2' to the name of your theme in all the template files
  32. */
  33. load_theme_textdomain( 'intergalactic-2', get_template_directory() . '/languages' );
  34. // Add default posts and comments RSS feed links to head.
  35. add_theme_support( 'automatic-feed-links' );
  36. /*
  37. * Let WordPress manage the document title.
  38. * By adding theme support, we declare that this theme does not use a
  39. * hard-coded <title> tag in the document head, and expect WordPress to
  40. * provide it for us.
  41. */
  42. add_theme_support( 'title-tag' );
  43. /*
  44. * Enable support for Post Thumbnails on posts and pages.
  45. *
  46. * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
  47. */
  48. add_theme_support( 'post-thumbnails' );
  49. add_image_size( 'intergalactic-2-large', '1440', '960', false );
  50. // Enable support for custom logo.
  51. add_theme_support( 'custom-logo', array(
  52. 'height' => 400,
  53. 'width' => 1200,
  54. 'flex-height' => true,
  55. 'flex-width' => true
  56. ) );
  57. // This theme uses wp_nav_menu() in two locations.
  58. register_nav_menus( array(
  59. 'menu-1' => esc_html__( 'Slide-Out Menu', 'intergalactic-2' ),
  60. ) );
  61. /*
  62. * Switch default core markup for search form, comment form, and comments
  63. * to output valid HTML5.
  64. */
  65. add_theme_support( 'html5', array(
  66. 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption',
  67. ) );
  68. // Setup the WordPress core custom background feature.
  69. add_theme_support( 'custom-background', apply_filters( 'intergalactic_2_custom_background_args', array(
  70. 'default-color' => 'ffffff',
  71. 'default-image' => '',
  72. ) ) );
  73. // Add theme support for selective refresh for widgets.
  74. add_theme_support( 'customize-selective-refresh-widgets' );
  75. }
  76. endif; // intergalactic_2_setup
  77. add_action( 'after_setup_theme', 'intergalactic_2_setup' );
  78. /**
  79. * Register widget area.
  80. *
  81. * @link http://codex.wordpress.org/Function_Reference/register_sidebar
  82. */
  83. function intergalactic_2_widgets_init() {
  84. register_sidebar( array(
  85. 'name' => esc_html__( 'Sidebar', 'intergalactic-2' ),
  86. 'id' => 'sidebar-1',
  87. 'description' => '',
  88. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  89. 'after_widget' => '</aside>',
  90. 'before_title' => '<h1 class="widget-title">',
  91. 'after_title' => '</h1>',
  92. ) );
  93. register_sidebar( array(
  94. 'name' => esc_html__( 'Footer 1', 'intergalactic-2' ),
  95. 'id' => 'sidebar-2',
  96. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  97. 'after_widget' => '</aside>',
  98. 'before_title' => '<h1 class="widget-title">',
  99. 'after_title' => '</h1>',
  100. ) );
  101. register_sidebar( array(
  102. 'name' => esc_html__( 'Footer 2', 'intergalactic-2' ),
  103. 'id' => 'sidebar-3',
  104. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  105. 'after_widget' => '</aside>',
  106. 'before_title' => '<h1 class="widget-title">',
  107. 'after_title' => '</h1>',
  108. ) );
  109. register_sidebar( array(
  110. 'name' => esc_html__( 'Footer 3', 'intergalactic-2' ),
  111. 'id' => 'sidebar-4',
  112. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  113. 'after_widget' => '</aside>',
  114. 'before_title' => '<h1 class="widget-title">',
  115. 'after_title' => '</h1>',
  116. ) );
  117. }
  118. add_action( 'widgets_init', 'intergalactic_2_widgets_init' );
  119. /**
  120. * Enqueue scripts and styles.
  121. */
  122. function intergalactic_2_scripts() {
  123. wp_enqueue_style( 'intergalactic-2-style', get_stylesheet_uri() );
  124. wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.4.1' );
  125. wp_enqueue_script( 'intergalactic-2-script', get_template_directory_uri() . '/js/intergalactic-2.js', array( 'jquery' ), '20170428', true );
  126. wp_enqueue_script( 'intergalactic-2-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
  127. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  128. wp_enqueue_script( 'comment-reply' );
  129. }
  130. wp_enqueue_style( 'intergalactic-2-lato', intergalactic_2_fonts_url(), array(), null );
  131. }
  132. add_action( 'wp_enqueue_scripts', 'intergalactic_2_scripts' );
  133. /**
  134. * Register Google Fonts
  135. */
  136. function intergalactic_2_fonts_url() {
  137. $fonts_url = '';
  138. /* Translators: If there are characters in your language that are not
  139. * supported by Lato, translate this to 'off'. Do not translate
  140. * into your own language.
  141. */
  142. $arimo = esc_html_x( 'on', 'Lato font: on or off', 'intergalactic-2' );
  143. if ( 'off' !== $arimo ) {
  144. $font_families = array();
  145. $font_families[] = 'Lato:300,400,700,300italic,400italic,700italic&subset=latin,latin-ext';
  146. $query_args = array(
  147. 'family' => urlencode( implode( '|', $font_families ) ),
  148. 'subset' => urlencode( 'latin,latin-ext' ),
  149. );
  150. $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
  151. }
  152. return $fonts_url;
  153. }
  154. if ( ! function_exists( 'intergalactic_2_continue_reading_link' ) ) :
  155. /**
  156. * Returns an ellipsis and "Continue reading" plus off-screen title link for excerpts
  157. */
  158. function intergalactic_2_continue_reading_link() {
  159. return '<a href="'. esc_url( get_permalink() ) . '" class="more-link">' . sprintf( __( 'Read More <span class="screen-reader-text">%1$s</span>', 'intergalactic-2' ), esc_attr( strip_tags( get_the_title() ) ) ) . '</a>';
  160. }
  161. endif; // intergalactic_2_continue_reading_link
  162. /**
  163. * Always display a Read More link when using the_excerpt()
  164. */
  165. function intergalactic_2_excerpt_more( $output ) {
  166. return $output . intergalactic_2_continue_reading_link();
  167. }
  168. add_filter( 'the_excerpt', 'intergalactic_2_excerpt_more' );
  169. /**
  170. * Implement the Custom Header feature.
  171. */
  172. require get_template_directory() . '/inc/custom-header.php';
  173. /**
  174. * Custom template tags for this theme.
  175. */
  176. require get_template_directory() . '/inc/template-tags.php';
  177. /**
  178. * Custom functions that act independently of the theme templates.
  179. */
  180. require get_template_directory() . '/inc/extras.php';
  181. /**
  182. * Customizer additions.
  183. */
  184. require get_template_directory() . '/inc/customizer.php';
  185. /**
  186. * Load Jetpack compatibility file.
  187. */
  188. require get_template_directory() . '/inc/jetpack.php';