functions.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <?php
  2. /**
  3. * Ixion functions and definitions.
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package Ixion
  8. */
  9. if ( ! function_exists( 'ixion_setup' ) ) :
  10. /**
  11. * Sets up theme defaults and registers support for various WordPress features.
  12. *
  13. * Note that this function is hooked into the after_setup_theme hook, which
  14. * runs before the init hook. The init hook is too late for some features, such
  15. * as indicating support for post thumbnails.
  16. */
  17. function ixion_setup() {
  18. /*
  19. * Make theme available for translation.
  20. * Translations can be filed in the /languages/ directory.
  21. * If you're building a theme based on components, use a find and replace
  22. * to change 'ixion' to the name of your theme in all the template files.
  23. */
  24. load_theme_textdomain( 'ixion', get_template_directory() . '/languages' );
  25. // Add default posts and comments RSS feed links to head.
  26. add_theme_support( 'automatic-feed-links' );
  27. // Add support for responsive embeds.
  28. add_theme_support( 'responsive-embeds' );
  29. /**
  30. * Gutenberg wide and full images support
  31. */
  32. add_theme_support( 'align-wide' );
  33. // Add custom colors to Gutenberg
  34. add_theme_support(
  35. 'editor-color-palette', array(
  36. array(
  37. 'name' => esc_html__( 'Black', 'ixion' ),
  38. 'slug' => 'black',
  39. 'color' => '#192930',
  40. ),
  41. array(
  42. 'name' => esc_html__( 'Dark Gray', 'ixion' ),
  43. 'slug' => 'dark-gray',
  44. 'color' => '#474f53',
  45. ),
  46. array(
  47. 'name' => esc_html__( 'Medium Gray', 'ixion' ),
  48. 'slug' => 'medium-gray',
  49. 'color' => '#a5a29d',
  50. ),
  51. array(
  52. 'name' => esc_html__( 'Light Gray', 'ixion' ),
  53. 'slug' => 'light-gray',
  54. 'color' => '#eeece8',
  55. ),
  56. array(
  57. 'name' => esc_html__( 'White', 'ixion' ),
  58. 'slug' => 'white',
  59. 'color' => '#ffffff',
  60. ),
  61. array(
  62. 'name' => esc_html__( 'Yellow', 'ixion' ),
  63. 'slug' => 'yellow',
  64. 'color' => '#d7b221',
  65. ),
  66. array(
  67. 'name' => esc_html__( 'Dark Yellow', 'ixion' ),
  68. 'slug' => 'dark-yellow',
  69. 'color' => '#9c8012',
  70. ),
  71. )
  72. );
  73. /*
  74. * Let WordPress manage the document title.
  75. * By adding theme support, we declare that this theme does not use a
  76. * hard-coded <title> tag in the document head, and expect WordPress to
  77. * provide it for us.
  78. */
  79. add_theme_support( 'title-tag' );
  80. /*
  81. * Enable support for Post Thumbnails on posts and pages.
  82. *
  83. * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
  84. */
  85. add_theme_support( 'post-thumbnails' );
  86. add_image_size( 'ixion-featured-content', 680, 382, true );
  87. add_image_size( 'ixion-featured-image', 1080, 9999 );
  88. add_image_size( 'ixion-avatar', 75, 75, true );
  89. // This theme uses wp_nav_menu() in three locations.
  90. register_nav_menus( array(
  91. 'menu-1' => esc_html__( 'Header', 'ixion' ),
  92. ) );
  93. /**
  94. * Add support for core custom logo.
  95. */
  96. add_theme_support( 'custom-logo', array(
  97. 'height' => 100,
  98. 'width' => 500,
  99. 'flex-width' => true,
  100. 'flex-height' => true,
  101. ) );
  102. /*
  103. * Switch default core markup for search form, comment form, and comments
  104. * to output valid HTML5.
  105. */
  106. add_theme_support( 'html5', array(
  107. 'search-form',
  108. 'comment-form',
  109. 'comment-list',
  110. 'gallery',
  111. 'caption',
  112. ) );
  113. // Set up the WordPress core custom background feature.
  114. add_theme_support( 'custom-background', apply_filters( 'ixion_custom_background_args', array(
  115. 'default-color' => 'ffffff',
  116. ) ) );
  117. }
  118. endif;
  119. add_action( 'after_setup_theme', 'ixion_setup' );
  120. /**
  121. * Set the content width in pixels, based on the theme's design and stylesheet.
  122. *
  123. * Priority 0 to make it available to lower priority callbacks.
  124. *
  125. * @global int $content_width
  126. */
  127. function ixion_content_width() {
  128. $GLOBALS['content_width'] = apply_filters( 'ixion_content_width', 712 );
  129. }
  130. add_action( 'after_setup_theme', 'ixion_content_width', 0 );
  131. /**
  132. * Set larger content width in some situations.
  133. */
  134. function ixion_adjust_content_width() {
  135. /* Allow for full-width gallery display in the footer */
  136. if ( is_active_sidebar( 'sidebar-2' ) || is_active_sidebar( 'sidebar-3' ) || is_active_sidebar( 'sidebar-4' ) || is_active_sidebar( 'sidebar-5' ) ) {
  137. $GLOBALS['content_width'] = 1080;
  138. }
  139. }
  140. add_action( 'template_redirect', 'ixion_adjust_content_width' );
  141. /**
  142. * Return early if Custom Logos are not available.
  143. *
  144. * @todo Remove after WP 4.7
  145. */
  146. function ixion_the_custom_logo() {
  147. if ( ! function_exists( 'the_custom_logo' ) ) {
  148. return;
  149. } else {
  150. the_custom_logo();
  151. }
  152. }
  153. /**
  154. * Register widget areas.
  155. *
  156. * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
  157. */
  158. function ixion_widgets_init() {
  159. register_sidebar( array(
  160. 'name' => esc_html__( 'Sidebar', 'ixion' ),
  161. 'id' => 'sidebar-1',
  162. 'description' => '',
  163. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  164. 'after_widget' => '</section>',
  165. 'before_title' => '<h2 class="widget-title">',
  166. 'after_title' => '</h2>',
  167. ) );
  168. register_sidebar( array(
  169. 'name' => esc_html__( 'Footer 1', 'ixion' ),
  170. 'id' => 'sidebar-2',
  171. 'description' => '',
  172. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  173. 'after_widget' => '</section>',
  174. 'before_title' => '<h2 class="widget-title">',
  175. 'after_title' => '</h2>',
  176. ) );
  177. register_sidebar( array(
  178. 'name' => esc_html__( 'Footer 2', 'ixion' ),
  179. 'id' => 'sidebar-3',
  180. 'description' => '',
  181. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  182. 'after_widget' => '</section>',
  183. 'before_title' => '<h2 class="widget-title">',
  184. 'after_title' => '</h2>',
  185. ) );
  186. register_sidebar( array(
  187. 'name' => esc_html__( 'Footer 3', 'ixion' ),
  188. 'id' => 'sidebar-4',
  189. 'description' => '',
  190. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  191. 'after_widget' => '</section>',
  192. 'before_title' => '<h2 class="widget-title">',
  193. 'after_title' => '</h2>',
  194. ) );
  195. register_sidebar( array(
  196. 'name' => esc_html__( 'Footer 4', 'ixion' ),
  197. 'id' => 'sidebar-5',
  198. 'description' => '',
  199. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  200. 'after_widget' => '</section>',
  201. 'before_title' => '<h2 class="widget-title">',
  202. 'after_title' => '</h2>',
  203. ) );
  204. }
  205. add_action( 'widgets_init', 'ixion_widgets_init' );
  206. /**
  207. * Register Google Fonts
  208. */
  209. function ixion_fonts_url_archivo() {
  210. $fonts_url = '';
  211. /* Translators: If there are characters in your language that are not
  212. * supported by Archivo Narrow, translate this to 'off'. Do not translate
  213. * into your own language.
  214. */
  215. $archivo = esc_html_x( 'on', 'Archivo Narrow font: on or off', 'ixion' );
  216. if ( 'off' !== $archivo ) {
  217. $font_families = array();
  218. $font_families[] = 'Archivo Narrow:400,400i,700,700i';
  219. $query_args = array(
  220. 'family' => urlencode( implode( '|', $font_families ) ),
  221. 'subset' => urlencode( 'latin,latin-ext' ),
  222. );
  223. $fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );
  224. }
  225. return $fonts_url;
  226. }
  227. /**
  228. * Register local fonts
  229. */
  230. function ixion_fonts_url_cooper() {
  231. $fonts_url = '';
  232. /* Translators: If there are characters in your language that are not
  233. * supported by Cooper Hewitt, translate this to 'off'. Do not translate
  234. * into your own language.
  235. */
  236. $cooper = esc_html_x( 'on', 'Cooper Hewitt font: on or off', 'ixion' );
  237. if ( 'off' !== $cooper ) {
  238. $fonts_url = get_template_directory_uri() . "/assets/fonts/cooperhewitt.css";
  239. }
  240. return $fonts_url;
  241. }
  242. /**
  243. * Enqueue scripts and styles.
  244. */
  245. function ixion_scripts() {
  246. wp_enqueue_style( 'ixion-style', get_stylesheet_uri() );
  247. // Gutenberg styles
  248. wp_enqueue_style( 'ixion-blocks', get_template_directory_uri() . '/blocks.css' );
  249. wp_enqueue_style( 'ixion-fonts-archivo', ixion_fonts_url_archivo(), array(), null );
  250. wp_enqueue_style( 'ixion-fonts-cooper', ixion_fonts_url_cooper(), array(), null );
  251. wp_enqueue_style( 'genericons', get_template_directory_uri() . '/assets/fonts/genericons/genericons/genericons.css' );
  252. wp_enqueue_script( 'ixion-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array(), '20151215', true );
  253. wp_enqueue_script( 'ixion-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/skip-link-focus-fix.js', array(), '20151215', true );
  254. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  255. wp_enqueue_script( 'comment-reply' );
  256. }
  257. if ( is_post_type_archive( 'jetpack-testimonial' ) ) {
  258. wp_enqueue_script( 'masonry' );
  259. wp_enqueue_script( 'ixion-testimonials', get_template_directory_uri() . '/assets/js/testimonials.js', array( 'jquery', 'masonry' ), '24102016', true );
  260. }
  261. }
  262. add_action( 'wp_enqueue_scripts', 'ixion_scripts' );
  263. /**
  264. * Gutenberg Editor Styles
  265. */
  266. function ixion_editor_styles() {
  267. wp_enqueue_style( 'ixion-editor-block-style', get_template_directory_uri() . '/editor-blocks.css');
  268. wp_enqueue_style( 'ixion-fonts-archivo', ixion_fonts_url_archivo(), array(), null );
  269. wp_enqueue_style( 'ixion-fonts-cooper', ixion_fonts_url_cooper(), array(), null );
  270. }
  271. add_action( 'enqueue_block_editor_assets', 'ixion_editor_styles' );
  272. /**
  273. * Replaces "[...]" (appended to automatically generated excerpts) with ... and a 'Continue reading' link.
  274. * @return string 'Continue reading' link prepended with an ellipsis.
  275. */
  276. if ( ! function_exists( 'ixion_excerpt_more' ) ) :
  277. function ixion_excerpt_more( $more ) {
  278. $link = sprintf( '<a href="%1$s" class="more-link">%2$s</a>',
  279. esc_url( get_permalink( get_the_ID() ) ),
  280. /* translators: %s: Name of current post */
  281. sprintf( esc_html__( 'Continue reading %s', 'ixion' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' )
  282. );
  283. return ' &hellip; ' . $link;
  284. }
  285. add_filter( 'excerpt_more', 'ixion_excerpt_more' );
  286. endif;
  287. /**
  288. * Custom header.
  289. */
  290. require get_template_directory() . '/inc/custom-header.php';
  291. /**
  292. * Custom template tags for this theme.
  293. */
  294. require get_template_directory() . '/inc/template-tags.php';
  295. /**
  296. * Custom functions that act independently of the theme templates.
  297. */
  298. require get_template_directory() . '/inc/extras.php';
  299. /**
  300. * Customizer additions.
  301. */
  302. require get_template_directory() . '/inc/customizer.php';
  303. /**
  304. * Load Jetpack compatibility file.
  305. */
  306. require get_template_directory() . '/inc/jetpack.php';