functions.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <?php
  2. /**
  3. * Radcliffe 2 functions and definitions
  4. *
  5. * @link https://developer.wordpress.org/themes/basics/theme-functions/
  6. *
  7. * @package Radcliffe 2
  8. */
  9. if ( ! function_exists( 'radcliffe_2_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 radcliffe_2_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 _s, use a find and replace
  22. * to change 'radcliffe-2' to the name of your theme in all the template files.
  23. */
  24. load_theme_textdomain( 'radcliffe-2', get_template_directory() . '/languages' );
  25. // Add default posts and comments RSS feed links to head.
  26. add_theme_support( 'automatic-feed-links' );
  27. /*
  28. * Let WordPress manage the document title.
  29. * By adding theme support, we declare that this theme does not use a
  30. * hard-coded <title> tag in the document head, and expect WordPress to
  31. * provide it for us.
  32. */
  33. add_theme_support( 'title-tag' );
  34. /*
  35. * Enable support for Post Thumbnails on posts and pages.
  36. *
  37. * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
  38. */
  39. add_theme_support( 'post-thumbnails' );
  40. add_image_size( 'radcliffe-post-image', 2000, 1500 );
  41. // This theme uses wp_nav_menu() in one location.
  42. register_nav_menus(
  43. array(
  44. 'menu-1' => esc_html__( 'Header', 'radcliffe-2' ),
  45. )
  46. );
  47. /*
  48. * Switch default core markup for search form, comment form, and comments
  49. * to output valid HTML5.
  50. */
  51. add_theme_support(
  52. 'html5',
  53. array(
  54. 'search-form',
  55. 'comment-form',
  56. 'comment-list',
  57. 'gallery',
  58. 'caption',
  59. )
  60. );
  61. // Add theme support for Custom Logo.
  62. add_theme_support(
  63. 'custom-logo',
  64. array(
  65. 'width' => 1200,
  66. 'height' => 900,
  67. 'flex-width' => true,
  68. 'flex-height' => true,
  69. 'header-text' => array( 'site-title', 'site-description' ),
  70. )
  71. );
  72. // Set up the WordPress core custom background feature.
  73. add_theme_support(
  74. 'custom-background',
  75. apply_filters(
  76. 'radcliffe_2_custom_background_args',
  77. array(
  78. 'default-color' => 'ffffff',
  79. 'default-image' => '',
  80. )
  81. )
  82. );
  83. // Add theme support for selective refresh for widgets.
  84. add_theme_support( 'customize-selective-refresh-widgets' );
  85. // Add support for responsive embeds.
  86. add_theme_support( 'responsive-embeds' );
  87. // Gutenberg: Add Custom Palette
  88. $stylepack = get_theme_mod( 'active_style_pack' );
  89. if ( 'vintage' === $stylepack ) {
  90. add_theme_support(
  91. 'editor-color-palette',
  92. array(
  93. array(
  94. 'name' => esc_html__( 'Vintage Off-White', 'radcliffe-2' ),
  95. 'slug' => 'vintage-off-white',
  96. 'color' => '#fff',
  97. ),
  98. array(
  99. 'name' => esc_html__( 'Vintage Light Brown', 'radcliffe-2' ),
  100. 'slug' => 'vintage-light-brown',
  101. 'color' => '#c7c4b4',
  102. ),
  103. array(
  104. 'name' => esc_html__( 'Vintage Light Gray', 'radcliffe-2' ),
  105. 'slug' => 'vintage-light-gray',
  106. 'color' => '#666',
  107. ),
  108. array(
  109. 'name' => esc_html__( 'Vintage Dark Gray', 'radcliffe-2' ),
  110. 'slug' => 'vintage-dark-gray',
  111. 'color' => '#222',
  112. ),
  113. array(
  114. 'name' => esc_html__( 'Vintage Blue', 'radcliffe-2' ),
  115. 'slug' => 'vintage-blue',
  116. 'color' => '#2b6e9d',
  117. ),
  118. )
  119. );
  120. } elseif ( 'colorful' === $stylepack ) {
  121. add_theme_support(
  122. 'editor-color-palette',
  123. array(
  124. array(
  125. 'name' => esc_html__( 'Colorful White', 'radcliffe-2' ),
  126. 'slug' => 'colorful-white',
  127. 'color' => '#fff',
  128. ),
  129. array(
  130. 'name' => esc_html__( 'Colorful Light Gray', 'radcliffe-2' ),
  131. 'slug' => 'colorful-light-gray',
  132. 'color' => '#e5e5e5',
  133. ),
  134. array(
  135. 'name' => esc_html__( 'Colorful Dark Gray', 'radcliffe-2' ),
  136. 'slug' => 'colorful-dark-gray',
  137. 'color' => '#222222',
  138. ),
  139. array(
  140. 'name' => esc_html__( 'Colorful Blue', 'radcliffe-2' ),
  141. 'slug' => 'colorful-blue',
  142. 'color' => '#4ba3c3',
  143. ),
  144. array(
  145. 'name' => esc_html__( 'Colorful Green', 'radcliffe-2' ),
  146. 'slug' => 'colorful-green',
  147. 'color' => '#71db9d',
  148. ),
  149. array(
  150. 'name' => esc_html__( 'Colorful Orange', 'radcliffe-2' ),
  151. 'slug' => 'colorful-orange',
  152. 'color' => '#d97059',
  153. ),
  154. )
  155. );
  156. } elseif ( 'modern' === $stylepack ) {
  157. add_theme_support(
  158. 'editor-color-palette',
  159. array(
  160. array(
  161. 'name' => esc_html__( 'Modern White', 'radcliffe-2' ),
  162. 'slug' => 'modern-white',
  163. 'color' => '#fff',
  164. ),
  165. array(
  166. 'name' => esc_html__( 'Modern Light Gray', 'radcliffe-2' ),
  167. 'slug' => 'modern-light-gray',
  168. 'color' => '#f1f1f1',
  169. ),
  170. array(
  171. 'name' => esc_html__( 'Modern Medium Gray', 'radcliffe-2' ),
  172. 'slug' => 'modern-medium-gray',
  173. 'color' => '#aaa',
  174. ),
  175. array(
  176. 'name' => esc_html__( 'Modern Dark Gray', 'radcliffe-2' ),
  177. 'slug' => 'modern-dark-gray',
  178. 'color' => '#222',
  179. ),
  180. )
  181. );
  182. } else {
  183. add_theme_support(
  184. 'editor-color-palette',
  185. array(
  186. array(
  187. 'name' => esc_html__( 'White', 'radcliffe-2' ),
  188. 'slug' => 'white',
  189. 'color' => '#fff',
  190. ),
  191. array(
  192. 'name' => esc_html__( 'Dark Gray', 'radcliffe-2' ),
  193. 'slug' => 'dark-gray',
  194. 'color' => '#222',
  195. ),
  196. array(
  197. 'name' => esc_html__( 'Light Gray', 'radcliffe-2' ),
  198. 'slug' => 'light-gray',
  199. 'color' => '#666666',
  200. ),
  201. array(
  202. 'name' => esc_html__( 'Red', 'radcliffe-2' ),
  203. 'slug' => 'red',
  204. 'color' => '#ca2017',
  205. ),
  206. )
  207. );
  208. }
  209. // Add support for wide alignment
  210. add_theme_support( 'align-wide' );
  211. }
  212. endif;
  213. add_action( 'after_setup_theme', 'radcliffe_2_setup' );
  214. /**
  215. * Set the content width in pixels, based on the theme's design and stylesheet.
  216. *
  217. * Priority 0 to make it available to lower priority callbacks.
  218. *
  219. * @global int $content_width
  220. */
  221. function radcliffe_2_content_width() {
  222. $GLOBALS['content_width'] = apply_filters( 'radcliffe_2_content_width', 740 );
  223. }
  224. add_action( 'after_setup_theme', 'radcliffe_2_content_width', 0 );
  225. /**
  226. * Register widget area.
  227. *
  228. * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
  229. */
  230. function radcliffe_2_widgets_init() {
  231. register_sidebar(
  232. array(
  233. 'name' => esc_html__( 'Footer 1', 'radcliffe-2' ),
  234. 'id' => 'sidebar-1',
  235. 'description' => '',
  236. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  237. 'after_widget' => '</section>',
  238. 'before_title' => '<h2 class="widget-title">',
  239. 'after_title' => '</h2>',
  240. )
  241. );
  242. register_sidebar(
  243. array(
  244. 'name' => esc_html__( 'Footer 2', 'radcliffe-2' ),
  245. 'id' => 'sidebar-2',
  246. 'description' => '',
  247. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  248. 'after_widget' => '</section>',
  249. 'before_title' => '<h2 class="widget-title">',
  250. 'after_title' => '</h2>',
  251. )
  252. );
  253. register_sidebar(
  254. array(
  255. 'name' => esc_html__( 'Footer 3', 'radcliffe-2' ),
  256. 'id' => 'sidebar-3',
  257. 'description' => '',
  258. 'before_widget' => '<section id="%1$s" class="widget %2$s">',
  259. 'after_widget' => '</section>',
  260. 'before_title' => '<h2 class="widget-title">',
  261. 'after_title' => '</h2>',
  262. )
  263. );
  264. }
  265. add_action( 'widgets_init', 'radcliffe_2_widgets_init' );
  266. /**
  267. * Enqueue scripts and styles.
  268. */
  269. function radcliffe_2_scripts() {
  270. wp_enqueue_style( 'radcliffe-2-style', get_stylesheet_uri() );
  271. wp_enqueue_style( 'radcliffe-2-block-styles', get_template_directory_uri() . '/assets/css/blocks.css' );
  272. $stylepack = get_theme_mod( 'active_style_pack' );
  273. if ( 'vintage' === $stylepack ) {
  274. wp_enqueue_style( 'radcliffe-2-block-vintage-styles', get_template_directory_uri() . '/assets/css/blocks-vintage.css' );
  275. }
  276. wp_enqueue_script( 'radcliffe-2-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array(), '20151215', true );
  277. wp_localize_script(
  278. 'radcliffe-2-navigation',
  279. 'screenReaderText',
  280. array(
  281. 'expand' => esc_html__( 'Expand child menu', 'radcliffe-2' ),
  282. 'collapse' => esc_html__( 'Collapse child menu', 'radcliffe-2' ),
  283. 'icon_expand' => radcliffe_2_get_svg( array( 'icon' => 'expand' ) ),
  284. 'icon_zoom' => radcliffe_2_get_svg( array( 'icon' => 'zoom' ) ),
  285. )
  286. );
  287. wp_enqueue_script( 'radcliffe-2-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/skip-link-focus-fix.js', array(), '20151215', true );
  288. wp_enqueue_script( 'radcliffe-2', get_template_directory_uri() . '/assets/js/radcliffe-2.js', array( 'jquery' ), '20170629', true );
  289. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  290. wp_enqueue_script( 'comment-reply' );
  291. }
  292. }
  293. add_action( 'wp_enqueue_scripts', 'radcliffe_2_scripts' );
  294. /**
  295. * Enqueue editor styles for Gutenberg
  296. */
  297. function radcliffe_2_editor_styles() {
  298. wp_enqueue_style( 'radcliffe-2-editor-style', get_template_directory_uri() . '/assets/css/editor-style.css' );
  299. $stylepack = get_theme_mod( 'active_style_pack' );
  300. if ( 'colorful' === $stylepack ) {
  301. wp_enqueue_style( 'radcliffe-2-editor-style-colorful', get_template_directory_uri() . '/assets/css/editor-style-colorful.css' );
  302. } elseif ( 'modern' === $stylepack ) {
  303. wp_enqueue_style( 'radcliffe-2-editor-style-modern', get_template_directory_uri() . '/assets/css/editor-style-modern.css' );
  304. } elseif ( 'vintage' === $stylepack ) {
  305. wp_enqueue_style( 'radcliffe-2-editor-style-vintage', get_template_directory_uri() . '/assets/css/editor-style-vintage.css' );
  306. }
  307. }
  308. add_action( 'enqueue_block_editor_assets', 'radcliffe_2_editor_styles' );
  309. /**
  310. * Enqueue stylesheet inside the Customizer.
  311. */
  312. function radcliffe_2_custom_customize_enqueue() {
  313. wp_enqueue_style( 'customizer-css', get_stylesheet_directory_uri() . '/assets/css/customizer.css' );
  314. }
  315. add_action( 'customize_controls_enqueue_scripts', 'radcliffe_2_custom_customize_enqueue' );
  316. /**
  317. * Add a pingback url auto-discovery header for singularly identifiable articles.
  318. */
  319. function radcliffe_2_pingback_header() {
  320. if ( is_singular() && pings_open() ) {
  321. echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
  322. }
  323. }
  324. add_action( 'wp_head', 'radcliffe_2_pingback_header' );
  325. /**
  326. * Custom template tags for this theme.
  327. */
  328. require get_template_directory() . '/inc/template-tags.php';
  329. /**
  330. * Additional features to allow styling of the templates.
  331. */
  332. require get_template_directory() . '/inc/template-functions.php';
  333. /**
  334. * Style packs.
  335. */
  336. require get_template_directory() . '/inc/style-packs-core.php';
  337. require get_template_directory() . '/inc/style-packs.php';
  338. /**
  339. * Customizer additions.
  340. */
  341. require get_template_directory() . '/inc/customizer.php';
  342. /**
  343. * SVG icons functions and filters.
  344. */
  345. require get_parent_theme_file_path( '/inc/icon-functions.php' );
  346. /**
  347. * Load Jetpack compatibility file.
  348. */
  349. require get_template_directory() . '/inc/jetpack.php';
  350. /**
  351. * Load Hero Area code.
  352. */
  353. require get_template_directory() . '/hero-area/hero-area-functions.php';
  354. /**
  355. * Load Contact Info code.
  356. */
  357. require get_template_directory() . '/contact-info/contact-info-functions.php';
  358. /**
  359. * Load WooCommerce compatibility file.
  360. */
  361. if ( class_exists( 'WooCommerce' ) ) {
  362. require get_template_directory() . '/inc/woocommerce.php';
  363. }