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.

238 lines
7.9 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <?php
  2. /**
  3. * Portage theme functions and definitions
  4. *
  5. * @package Portage
  6. */
  7. if ( ! function_exists( 'portage_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 portage_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 Portage, use a find and replace
  20. * to change 'portage' to the name of your theme in all the template files
  21. */
  22. load_theme_textdomain( 'portage', 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', 'portage' ),
  41. 'primary-menu' => esc_html__( 'Primary Menu', 'portage' ),
  42. 'footer-menu' => esc_html__( 'Footer Menu', 'portage' ),
  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( 'portage_custom_background_args', array(
  72. 'default-color' => 'ffffff',
  73. 'default-image' => '',
  74. ) ) );
  75. }
  76. endif; // portage_setup
  77. add_action( 'after_setup_theme', 'portage_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 portage_content_width() {
  86. $GLOBALS['content_width'] = apply_filters( 'portage_content_width', 620 );
  87. }
  88. add_action( 'after_setup_theme', 'portage_content_width', 0 );
  89. /**
  90. * Register widget area.
  91. *
  92. * @link http://codex.wordpress.org/Function_Reference/register_sidebar
  93. */
  94. function portage_widgets_init() {
  95. register_sidebar( array(
  96. 'name' => esc_html__( 'Sidebar', 'portage' ),
  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', 'portage_widgets_init' );
  106. /**
  107. * Enqueue scripts and styles.
  108. */
  109. function portage_scripts() {
  110. wp_enqueue_style( 'portage-googlefont', 'https://fonts.googleapis.com/css?family=IM+Fell+English:400,400italic', 'portage-style', wp_get_theme() -> get( 'Version' ), 'all' );
  111. /*
  112. if ( !wp_style_is( 'font-awesome.min.css', 'enqueued' ) ) {
  113. wp_enqueue_style( 'portage-fa', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', 'portage-style', wp_get_theme() -> get( 'Version' ), 'all' );
  114. }
  115. */
  116. wp_enqueue_style( 'portage-style', get_stylesheet_uri() );
  117. wp_enqueue_style( 'portage-menus', get_template_directory_uri() . '/styles/menus.css', array( 'portage-style' ), wp_get_theme() -> get( 'Version' ) );
  118. wp_enqueue_style( 'portage-mobile', get_template_directory_uri() . '/styles/mobile.css', array( 'portage-style' ), wp_get_theme() -> get( 'Version' ), 'screen and (max-width: '. get_theme_mod( 'portage_mobile_breakpoint' ) . 'px)' );
  119. wp_enqueue_style( 'portage-print', get_template_directory_uri() . '/styles/print.css', array( 'portage-style' ), wp_get_theme() -> get( 'Version' ), 'print' );
  120. wp_enqueue_script( 'portage-menumaker', get_template_directory_uri() . '/js/menumaker.js', array( 'jquery' ), wp_get_theme() -> get( 'Version' ), true );
  121. wp_enqueue_script( 'portage-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), wp_get_theme() -> get( 'Version' ), true );
  122. wp_enqueue_script( 'portage-font-awesome', 'https://kit.fontawesome.com/7a45e15014.js', array(), wp_get_theme() -> get( 'Version' ), true );
  123. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  124. wp_enqueue_script( 'comment-reply' );
  125. }
  126. }
  127. add_action( 'wp_enqueue_scripts', 'portage_scripts' );
  128. /**
  129. * Enable live changes in the customizer
  130. */
  131. function portage_customizer_script() {
  132. wp_enqueue_script( 'portage-theme-customizer', get_template_directory_uri() . '/js/customizer.js', array(), wp_get_theme() -> get( 'Version' ), true );
  133. }
  134. add_action( 'customize_preview_init', 'portage_customizer_script' );
  135. // Change "read more" link on excerpts
  136. // codex.wordpress.org/Function_Reference/the_excerpt
  137. function portage_excerpt_more( $more ) {
  138. $text = get_theme_mod( 'portage_readmore', '&hellip;read more&hellip;' );
  139. return ' <a class="excerpt-link" href="' . get_permalink( get_the_ID() ) . '">' . $text . '</a>';
  140. }
  141. add_filter( 'excerpt_more', 'portage_excerpt_more' );
  142. // Add descriptions to main menu
  143. // http://www.wpbeginner.com/wp-themes/how-to-add-menu-descriptions-in-your-wordpress-themes/
  144. /*
  145. class portage_Menu_With_Description extends Walker_Nav_Menu {
  146. function start_el(&$output, $item, $depth=0, $args = array(), $id=0) {
  147. global $wp_query;
  148. $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  149. $class_names = $value = '';
  150. $classes = empty( $item->classes ) ? array() : (array) $item->classes;
  151. $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
  152. $class_names = ' class="' . esc_attr( $class_names ) . '"';
  153. $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
  154. $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
  155. $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
  156. $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
  157. $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
  158. $item_output = $args->before;
  159. $item_output .= '<a'. $attributes .'>';
  160. $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
  161. $item_output .= '<p class="sub">' . $item->description . '</p>';
  162. $item_output .= '</a>';
  163. $item_output .= $args->after;
  164. $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args, $id );
  165. }
  166. }
  167. */
  168. /**
  169. * Implement the Custom Header feature.
  170. */
  171. require get_template_directory() . '/functions/custom-header.php';
  172. /**
  173. * Custom template tags for this theme.
  174. */
  175. require get_template_directory() . '/functions/template-tags.php';
  176. /**
  177. * Customizer additions.
  178. */
  179. require get_template_directory() . '/functions/customizer.php';
  180. /**
  181. * Load Jetpack compatibility file.
  182. */
  183. require get_template_directory() . '/functions/jetpack.php';
  184. /**
  185. * Add our widget areas.
  186. */
  187. require get_template_directory() . '/functions/widget-areas.php';
  188. /**
  189. * Make our menus mobile.
  190. */
  191. require get_template_directory() . '/functions/mobile-menus.php';
  192. // Include our update script to update from private repo
  193. /* Deleted for now; get other theme issues working (2021.08.01)
  194. require 'update/puc.php';
  195. $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
  196. 'http://api.kjodle.net/?action=get_metadata&slug=portage',
  197. __FILE__,
  198. 'portage'
  199. );
  200. */