An updated theme (based on Atticus Finch) for ClassicPress
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
8.0 KiB

3 years ago
  1. <?php
  2. /**
  3. * Atticus Finch functions and definitions
  4. *
  5. * @package Atticus Finch
  6. */
  7. if ( ! function_exists( 'atticus_finch_setup' ) ) :
  8. /**
  9. * Sets up theme defaults and registers support for various WordPress features.
  10. *
  11. * Note that this function is hooked into the after_setup_theme hook, which
  12. * runs before the init hook. The init hook is too late for some features, such
  13. * as indicating support for post thumbnails.
  14. */
  15. function atticus_finch_setup() {
  16. /*
  17. * Make theme available for translation.
  18. * Translations can be filed in the /languages/ directory.
  19. * If you're building a theme based on Atticus Finch, use a find and replace
  20. * to change 'atticus-finch' to the name of your theme in all the template files
  21. */
  22. load_theme_textdomain( 'atticus-finch', get_template_directory() . '/lang' );
  23. // Add default posts and comments RSS feed links to head.
  24. add_theme_support( 'automatic-feed-links' );
  25. /*
  26. * Let WordPress manage the document title.
  27. * By adding theme support, we declare that this theme does not use a
  28. * hard-coded <title> tag in the document head, and expect WordPress to
  29. * provide it for us.
  30. */
  31. add_theme_support( 'title-tag' );
  32. /*
  33. * Enable support for Post Thumbnails on posts and pages.
  34. *
  35. * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
  36. */
  37. add_theme_support( 'post-thumbnails' );
  38. // This theme uses wp_nav_menu() in three locations.
  39. register_nav_menus( array(
  40. 'top-menu' => esc_html__( 'Top Menu', 'atticus-finch' ),
  41. 'primary-menu' => esc_html__( 'Primary Menu', 'atticus-finch' ),
  42. 'footer-menu' => esc_html__( 'Footer Menu', 'atticus-finch' ),
  43. ) );
  44. /*
  45. * Switch default core markup for search form, comment form, and comments
  46. * to output valid HTML5.
  47. */
  48. add_theme_support( 'html5', array(
  49. 'search-form',
  50. 'comment-form',
  51. 'comment-list',
  52. 'gallery',
  53. 'caption',
  54. ) );
  55. /*
  56. * Enable support for Post Formats.
  57. * See http://codex.wordpress.org/Post_Formats
  58. */
  59. add_theme_support( 'post-formats', array(
  60. 'aside',
  61. 'audio',
  62. 'chat',
  63. 'gallery',
  64. 'image',
  65. 'link',
  66. 'quote',
  67. 'status',
  68. 'video',
  69. ) );
  70. // Set up the WordPress core custom background feature.
  71. add_theme_support( 'custom-background', apply_filters( 'atticus_finch_custom_background_args', array(
  72. 'default-color' => 'ffffff',
  73. 'default-image' => '',
  74. ) ) );
  75. }
  76. endif; // atticus_finch_setup
  77. add_action( 'after_setup_theme', 'atticus_finch_setup' );
  78. /**
  79. * Set the content width in pixels, based on the theme's design and stylesheet.
  80. *
  81. * Priority 0 to make it available to lower priority callbacks.
  82. *
  83. * @global int $content_width
  84. */
  85. function atticus_finch_content_width() {
  86. $GLOBALS['content_width'] = apply_filters( 'atticus_finch_content_width', 620 );
  87. }
  88. add_action( 'after_setup_theme', 'atticus_finch_content_width', 0 );
  89. /**
  90. * Register widget area.
  91. *
  92. * @link http://codex.wordpress.org/Function_Reference/register_sidebar
  93. */
  94. function atticus_finch_widgets_init() {
  95. register_sidebar( array(
  96. 'name' => esc_html__( 'Sidebar', 'atticus-finch' ),
  97. 'id' => 'sidebar-1',
  98. 'description' => '',
  99. 'before_widget' => '',
  100. 'after_widget' => '',
  101. 'before_title' => '<h2 class="widget-title">',
  102. 'after_title' => '</h2>',
  103. ) );
  104. }
  105. add_action( 'widgets_init', 'atticus_finch_widgets_init' );
  106. /**
  107. * Enqueue scripts and styles.
  108. */
  109. function atticus_finch_scripts() {
  110. wp_enqueue_style( 'atticus-finch-googlefont', 'https://fonts.googleapis.com/css?family=IM+Fell+English:400,400italic', 'atticus-finch-style', wp_get_theme() -> get( 'Version' ), 'all' );
  111. if ( !wp_style_is( 'font-awesome.min.css', 'enqueued' ) ) {
  112. wp_enqueue_style( 'atticus-finch-fa', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', 'atticus-finch-style', wp_get_theme() -> get( 'Version' ), 'all' );
  113. }
  114. wp_enqueue_style( 'atticus-finch-style', get_stylesheet_uri() );
  115. wp_enqueue_style( 'atticus-finch-menus', get_template_directory_uri() . '/styles/menus.css', array( 'atticus-finch-style' ), wp_get_theme() -> get( 'Version' ) );
  116. wp_enqueue_style( 'atticus-finch-mobile', get_template_directory_uri() . '/styles/mobile.css', array( 'atticus-finch-style' ), wp_get_theme() -> get( 'Version' ), 'screen and (max-width: '. get_theme_mod( 'atticus_finch_mobile_breakpoint' ) . 'px)' );
  117. wp_enqueue_style( 'atticus-finch-print', get_template_directory_uri() . '/styles/print.css', array( 'atticus-finch-style' ), wp_get_theme() -> get( 'Version' ), 'print' );
  118. wp_enqueue_script( 'atticus-finch-menumaker', get_template_directory_uri() . '/js/menumaker.js', array( 'jquery' ), wp_get_theme() -> get( 'Version' ), true );
  119. wp_enqueue_script( 'atticus-finch-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), wp_get_theme() -> get( 'Version' ), true );
  120. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  121. wp_enqueue_script( 'comment-reply' );
  122. }
  123. }
  124. add_action( 'wp_enqueue_scripts', 'atticus_finch_scripts' );
  125. /**
  126. * Enable live changes in the customizer
  127. */
  128. function atticus_finch_customizer_script() {
  129. wp_enqueue_script( 'atticus-finch-theme-customizer', get_template_directory_uri() . '/js/customizer.js', array(), wp_get_theme() -> get( 'Version' ), true );
  130. }
  131. add_action( 'customize_preview_init', 'atticus_finch_customizer_script' );
  132. // Change "read more" link on excerpts
  133. // codex.wordpress.org/Function_Reference/the_excerpt
  134. function atticus_finch_excerpt_more( $more ) {
  135. $text = get_theme_mod( 'atticus_finch_readmore', '&hellip;read more&hellip;' );
  136. return ' <a class="excerpt-link" href="' . get_permalink( get_the_ID() ) . '">' . $text . '</a>';
  137. }
  138. add_filter( 'excerpt_more', 'atticus_finch_excerpt_more' );
  139. // Add descriptions to main menu
  140. // http://www.wpbeginner.com/wp-themes/how-to-add-menu-descriptions-in-your-wordpress-themes/
  141. /*
  142. class Atticus_Finch_Menu_With_Description extends Walker_Nav_Menu {
  143. function start_el(&$output, $item, $depth=0, $args = array(), $id=0) {
  144. global $wp_query;
  145. $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  146. $class_names = $value = '';
  147. $classes = empty( $item->classes ) ? array() : (array) $item->classes;
  148. $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
  149. $class_names = ' class="' . esc_attr( $class_names ) . '"';
  150. $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
  151. $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
  152. $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
  153. $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
  154. $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
  155. $item_output = $args->before;
  156. $item_output .= '<a'. $attributes .'>';
  157. $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
  158. $item_output .= '<p class="sub">' . $item->description . '</p>';
  159. $item_output .= '</a>';
  160. $item_output .= $args->after;
  161. $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args, $id );
  162. }
  163. }
  164. */
  165. /**
  166. * Implement the Custom Header feature.
  167. */
  168. require get_template_directory() . '/functions/custom-header.php';
  169. /**
  170. * Custom template tags for this theme.
  171. */
  172. require get_template_directory() . '/functions/template-tags.php';
  173. /**
  174. * Customizer additions.
  175. */
  176. require get_template_directory() . '/functions/customizer.php';
  177. /**
  178. * Load Jetpack compatibility file.
  179. */
  180. require get_template_directory() . '/functions/jetpack.php';
  181. /**
  182. * Add our widget areas.
  183. */
  184. require get_template_directory() . '/functions/widget-areas.php';
  185. /**
  186. * Make our menus mobile.
  187. */
  188. require get_template_directory() . '/functions/mobile-menus.php';
  189. // Include our update script to update from private repo
  190. require 'update/puc.php';
  191. $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
  192. 'http://api.kjodle.net/?action=get_metadata&slug=atticus-finch',
  193. __FILE__,
  194. 'atticus-finch'
  195. );