Advertisement
Guest User

Untitled

a guest
May 30th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.73 KB | None | 0 0
  1. <?php
  2. //* Start the engine
  3. include_once( get_template_directory() . '/lib/init.php' );
  4.  
  5. //* Setup Theme
  6. include_once( get_stylesheet_directory() . '/lib/theme-defaults.php' );
  7.  
  8. //* Set Localization (do not remove)
  9. load_child_theme_textdomain( 'altitude', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'altitude' ) );
  10.  
  11. //* Add Image upload and Color select to WordPress Theme Customizer
  12. require_once( get_stylesheet_directory() . '/lib/customize.php' );
  13.  
  14. //* Include Customizer CSS
  15. include_once( get_stylesheet_directory() . '/lib/output.php' );
  16.  
  17. //* Child theme (do not remove)
  18. define( 'CHILD_THEME_NAME', 'mfs' );
  19. define( 'CHILD_THEME_URL', '//regeneration.org/' );
  20. define( 'CHILD_THEME_VERSION', '3.2.4' );
  21.  
  22. //* Enqueue scripts and styles
  23. add_action( 'wp_enqueue_scripts', 'mfs_enqueue_scripts_styles' );
  24. function mfs_enqueue_scripts_styles() {
  25.  
  26. wp_enqueue_script( 'mfs-global', get_bloginfo( 'stylesheet_directory' ) . '/js/global.js', array( 'jquery' ), '1.0.0' );
  27.  
  28. wp_enqueue_style( 'mfs-google-fonts', '//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,700italic,800italic,400,300,800,700', array(), CHILD_THEME_VERSION );
  29.  
  30. wp_enqueue_style( 'ionicons', '//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css', array(), CHILD_THEME_VERSION );
  31. }
  32.  
  33. //* Relocate Post Title and Post Info
  34. add_action( 'genesis_after_header', 'mfs_relocate_post_title_info' );
  35. function mfs_relocate_post_title_info() {
  36.  
  37. if ( is_singular('post' ) ) {
  38.  
  39. remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
  40. remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
  41. remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
  42. //* Reposition Post Info on blog page
  43. add_action( 'genesis_entry_header', 'genesis_post_info', 12 );
  44.  
  45. echo '<div class="featured-single"><div class="overlay-gradient"><div class="wrap">';
  46. genesis_entry_header_markup_open();
  47. genesis_do_post_title();
  48. genesis_post_info();
  49. genesis_entry_header_markup_close();
  50. echo '</div></div></div>';
  51.  
  52. }
  53.  
  54. }
  55.  
  56. //* Enqueue scripts on single Post pages
  57. add_action( 'wp_enqueue_scripts', 'enqueue_singular' );
  58. function enqueue_singular() {
  59.  
  60. if ( is_singular('post' ) ) {
  61.  
  62. // to add a dynamically-resized background image to .featured-single
  63. wp_enqueue_script( 'backstretch', get_stylesheet_directory_uri() . '/js/jquery.backstretch.min.js', array( 'jquery' ), '', true );
  64. wp_enqueue_script( 'backstretch-init', get_stylesheet_directory_uri() . '/js/backstretch-init.js', array( 'backstretch' ), '1.0.0', true );
  65.  
  66. // if the post has a featured image, send it to Backstretch else use a default one
  67. if ( has_post_thumbnail() ) {
  68. wp_localize_script( 'backstretch-init', 'BackStretchImg', array( 'src' => wp_get_attachment_url( get_post_thumbnail_id() ) ) );
  69. }
  70. else {
  71. wp_localize_script( 'backstretch-init', 'BackStretchImg', array( 'src' => '/wp-content/themes/mfs/images/bg-1.jpg' ) );
  72. }
  73.  
  74. // for smooth scrolling when the down arrow is clicked
  75. wp_enqueue_script( 'scrollTo', get_stylesheet_directory_uri() . '/js/jquery.scrollTo.min.js', array( 'jquery' ), '', true );
  76. wp_enqueue_script( 'localScroll', get_stylesheet_directory_uri() . '/js/jquery.localScroll.min.js', array( 'scrollTo' ), '', true );
  77.  
  78. // for setting the height of 'Featured Single' section so its background fills the viewport, adding the down arrow, and setting smooth scrolling speed
  79. wp_enqueue_script( 'singular', get_bloginfo( 'stylesheet_directory' ) . '/js/singular-scripts.js', array( 'jquery' ), '1.0.0', true );
  80.  
  81. // for fading away Post title and info when scrolling down and fading in when scrolling up
  82. wp_enqueue_script( 'fade-on-scroll', get_stylesheet_directory_uri() . '/js/fade-on-scroll.js', array( 'scrollTo' ), '1.0.0', true );
  83.  
  84. }
  85.  
  86. }
  87.  
  88. //* Add Nav Menu Item for Search
  89. add_filter( 'wp_nav_menu_items', 'theme_menu_extras', 10, 2 );
  90.  
  91. /**
  92. * Filter menu items to append a search form.
  93. *
  94. * @param string $menu HTML string of list items.
  95. * @param stdClass $args Menu arguments.
  96. *
  97. * @return string Amended HTML string of list items.
  98. */
  99. function theme_menu_extras( $menu, $args ) {
  100.  
  101. if ( 'primary' !== $args->theme_location )
  102. return $menu;
  103.  
  104. $menu .= '<li class="search"><a id="main-nav-search-link" class="icon-search"></a><div class="search-div">' . get_search_form( false ) . '</div></li>';
  105.  
  106. return $menu;
  107.  
  108. }
  109.  
  110. //* Add HTML5 markup structure
  111. add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
  112.  
  113. //* Add viewport meta tag for mobile browsers
  114. add_theme_support( 'genesis-responsive-viewport' );
  115.  
  116. //* Add new image sizes
  117. add_image_size( 'featured-page', 1140, 400, TRUE );
  118. add_image_size( 'blog-post', 800, 450, TRUE );
  119. add_image_size( 'widget-image', 574, 342, TRUE );
  120. add_image_size( 'team-member', 500, 500, TRUE );
  121.  
  122. //* Add support for 2-column footer widget area
  123. add_theme_support( 'genesis-footer-widgets', 2 );
  124.  
  125. //* Add support for footer menu
  126. add_theme_support ( 'genesis-menus' , array ( 'primary' => 'Primary Navigation Menu', 'secondary' => 'Secondary Navigation Menu', 'footer' => 'Footer Navigation Menu' ) );
  127.  
  128. //* Unregister the header right widget area
  129. unregister_sidebar( 'header-right' );
  130.  
  131. //* Reposition the primary navigation menu
  132. remove_action( 'genesis_after_header', 'genesis_do_nav' );
  133. add_action( 'genesis_header', 'genesis_do_nav', 12 );
  134.  
  135. //* Remove output of primary navigation right extras
  136. remove_filter( 'genesis_nav_items', 'genesis_nav_right', 10, 2 );
  137. remove_filter( 'wp_nav_menu_items', 'genesis_nav_right', 10, 2 );
  138.  
  139. //* Reposition the secondary navigation menu
  140. remove_action( 'genesis_after_header', 'genesis_do_subnav' );
  141. add_action( 'genesis_header', 'genesis_do_subnav', 5 );
  142.  
  143. //* Add secondary-nav class if secondary navigation is used
  144. add_filter( 'body_class', 'mfs_secondary_nav_class' );
  145. function mfs_secondary_nav_class( $classes ) {
  146.  
  147. $menu_locations = get_theme_mod( 'nav_menu_locations' );
  148.  
  149. if ( ! empty( $menu_locations['secondary'] ) ) {
  150. $classes[] = 'secondary-nav';
  151. }
  152. return $classes;
  153.  
  154. }
  155.  
  156. //* Hook menu in footer
  157. add_action( 'genesis_footer', 'mfs_footer_menu', 7 );
  158. function mfs_footer_menu() {
  159. printf( '<nav %s>', genesis_attr( 'nav-footer' ) );
  160. wp_nav_menu( array(
  161. 'theme_location' => 'footer',
  162. 'container' => false,
  163. 'depth' => 1,
  164. 'fallback_cb' => false,
  165. 'menu_class' => 'genesis-nav-menu',
  166. ) );
  167.  
  168. echo '</nav>';
  169. }
  170.  
  171. //* Unregister layout settings
  172. genesis_unregister_layout( 'content-sidebar-sidebar' );
  173. genesis_unregister_layout( 'sidebar-content-sidebar' );
  174. genesis_unregister_layout( 'sidebar-sidebar-content' );
  175.  
  176. //* Unregister secondary sidebar
  177. unregister_sidebar( 'sidebar-alt' );
  178.  
  179. //* Add support for custom header
  180. add_theme_support( 'custom-header', array(
  181. 'flex-height' => true,
  182. 'width' => 360,
  183. 'height' => 76,
  184. 'header-selector' => '.site-title a',
  185. 'header-text' => false,
  186. ) );
  187.  
  188. //* Add support for structural wraps
  189. add_theme_support( 'genesis-structural-wraps', array(
  190. 'header',
  191. 'nav',
  192. 'subnav',
  193. 'footer',
  194. ) );
  195.  
  196. //* Remove comment form allowed tags
  197. add_filter( 'comment_form_defaults', 'mfs_remove_comment_form_allowed_tags' );
  198. function mfs_remove_comment_form_allowed_tags( $defaults ) {
  199.  
  200. $defaults['comment_field'] = '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun', 'altitude' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>';
  201. $defaults['comment_notes_after'] = '';
  202. return $defaults;
  203.  
  204. }
  205.  
  206. //* Add support for after entry widget
  207. add_theme_support( 'genesis-after-entry-widget-area' );
  208.  
  209. //* Relocate after entry widget
  210. remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' );
  211. add_action( 'genesis_after_entry', 'genesis_after_entry_widget_area', 5 );
  212.  
  213. //* Setup widget counts
  214. function mfs_count_widgets( $id ) {
  215. global $sidebars_widgets;
  216.  
  217. if ( isset( $sidebars_widgets[ $id ] ) ) {
  218. return count( $sidebars_widgets[ $id ] );
  219. }
  220.  
  221. }
  222.  
  223. function mfs_widget_area_class( $id ) {
  224. $count = mfs_count_widgets( $id );
  225.  
  226. $class = '';
  227.  
  228. if( $count == 1 ) {
  229. $class .= ' widget-full';
  230. } elseif( $count % 3 == 1 ) {
  231. $class .= ' widget-thirds';
  232. } elseif( $count % 4 == 1 ) {
  233. $class .= ' widget-fourths';
  234. } elseif( $count % 2 == 0 ) {
  235. $class .= ' widget-halves uneven';
  236. } else {
  237. $class .= ' widget-halves';
  238. }
  239. return $class;
  240.  
  241. }
  242.  
  243. //* Register widget areas
  244. genesis_register_sidebar( array(
  245. 'id' => 'front-page-1',
  246. 'name' => __( 'Front Page 1', 'altitude' ),
  247. 'description' => __( 'This is the front page 1 section.', 'altitude' ),
  248. ) );
  249. genesis_register_sidebar( array(
  250. 'id' => 'front-page-2',
  251. 'name' => __( 'Front Page 2', 'altitude' ),
  252. 'description' => __( 'This is the front page 2 section.', 'altitude' ),
  253. ) );
  254. genesis_register_sidebar( array(
  255. 'id' => 'front-page-3',
  256. 'name' => __( 'Front Page 3', 'altitude' ),
  257. 'description' => __( 'This is the front page 3 section.', 'altitude' ),
  258. ) );
  259. genesis_register_sidebar( array(
  260. 'id' => 'front-page-4',
  261. 'name' => __( 'Front Page 4', 'altitude' ),
  262. 'description' => __( 'This is the front page 4 section.', 'altitude' ),
  263. ) );
  264. genesis_register_sidebar( array(
  265. 'id' => 'front-page-5',
  266. 'name' => __( 'Front Page 5', 'altitude' ),
  267. 'description' => __( 'This is the front page 5 section.', 'altitude' ),
  268. ) );
  269. genesis_register_sidebar( array(
  270. 'id' => 'front-page-6',
  271. 'name' => __( 'Front Page 6', 'altitude' ),
  272. 'description' => __( 'This is the front page 6 section.', 'altitude' ),
  273. ) );
  274. genesis_register_sidebar( array(
  275. 'id' => 'front-page-7',
  276. 'name' => __( 'Front Page 7', 'altitude' ),
  277. 'description' => __( 'This is the front page 7 section.', 'altitude' ),
  278. ) );
  279.  
  280.  
  281. //* Add "Continue"
  282. function mfs_continue_reading() {
  283. ?>
  284. <a href="<?php echo get_permalink(); ?>" class="more-link button clear">Continue</a>
  285. <?php
  286. }
  287.  
  288.  
  289.  
  290. //* Customize the post info function
  291. add_filter( 'genesis_post_info', 'mfs_post_info_filter' );
  292. function mfs_post_info_filter($post_info) {
  293. $post_info = 'Published on[post_date] by [post_author]';
  294. return $post_info;
  295. }
  296.  
  297. //* Customize the entry meta in the entry footer
  298. add_filter( 'genesis_post_meta', 'mfs_post_meta_filter' );
  299. function mfs_post_meta_filter($post_meta) {
  300. $post_meta = '[post_categories before=""] [post_tags before=""]';
  301. return $post_meta;
  302. }
  303.  
  304. //* Modify the Genesis content limit read more link
  305. add_filter( 'get_the_content_more_link', 'mfs_read_more_link' );
  306. function mfs_read_more_link() {
  307. return '...<br /><a class="clearfix button-clear more-link" href="' . get_permalink() . '">Continue</a>';
  308. }
  309.  
  310. //* Add a ID to .site-inner
  311. add_filter( 'genesis_attr_site-inner', 'custom_attributes_content' );
  312. function custom_attributes_content( $attributes ) {
  313.  
  314. if ( is_singular('post' ) ) {
  315. $attributes['id'] = 'site-inner';
  316. }
  317. return $attributes;
  318.  
  319. }
  320.  
  321. //* Move comments box above comments list
  322. add_action( 'genesis_before_comments' , 'mfs_comment_box_move' );
  323. function mfs_comment_box_move () {
  324. if ( is_single() ) {
  325. if ( have_comments() ) {
  326. remove_action( 'genesis_comment_form', 'genesis_do_comment_form' );
  327. add_action( 'genesis_list_comments', 'genesis_do_comment_form' , 5 );
  328. }
  329. }
  330. }
  331.  
  332. //* Customize the Genesis Credits
  333. add_filter( 'genesis_footer_creds_text', 'sp_footer_creds_text' );
  334. function sp_footer_creds_text() {
  335. echo '<div class="creds"><p>';
  336. echo 'Copyright &copy; ';
  337. echo date('Y');
  338. echo ' &middot; <a href="https://www.regenerationministries.org">Regeneration Ministries</a>';
  339. echo '</p></div>';
  340. }
  341.  
  342. add_image_size( 'sidebar-recent', 360, 135, true );
  343.  
  344. //* Removed "Protected" from Protected pages
  345. function the_title_trim($title) {
  346.  
  347. $title = esc_attr($title);
  348.  
  349. $findthese = array(
  350. '#Protected:#',
  351. '#Private:#'
  352. );
  353.  
  354. $replacewith = array(
  355. '', // What to replace "Protected:" with
  356. '' // What to replace "Private:" with
  357. );
  358.  
  359. $title = preg_replace($findthese, $replacewith, $title);
  360. return $title;
  361. }
  362. add_filter('the_title', 'the_title_trim');
  363.  
  364. // REMOVE EMOJI ICONS
  365. remove_action('wp_head', 'print_emoji_detection_script', 7);
  366. remove_action('wp_print_styles', 'print_emoji_styles');
  367.  
  368. add_action('genesis_before_content', 'child_404_image');
  369. /**
  370. * Add an image to the top of the 404 page
  371. *
  372. * @author K. Shoffner
  373. */
  374. function child_404_image() {
  375. if ( is_404() )
  376. echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/404.png" alt="OOPS, Nothing Found" />';
  377. }
  378.  
  379. // Register a custom image size for Team images
  380. add_image_size( 'team', 295, 295, true );
  381.  
  382. function featured_post_image() {
  383. if ( ! is_singular( 'page' ) ) return;
  384. the_post_thumbnail('post-image');
  385. }
  386.  
  387. // Display featured image before title on the single page in Genesis
  388. add_action( 'genesis_entry_header', 'featured_post_image', 8 );
  389.  
  390. add_action( 'get_header', 'remove_titles_from_pages' );
  391. function remove_titles_from_pages() {
  392. if ( is_page(array('contact', 'programs', 'coaching') ) ) {
  393. remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
  394. }
  395. }
  396.  
  397. // Display floating donation button
  398. add_action( 'genesis_before_loop', 'wpsites_hook_button', 25 );
  399. function wpsites_hook_button() {
  400. echo'<div id="fixed-buttons">';
  401. echo'<a href="https://interland3.donorperfect.net/weblink/weblink.aspx?name=regeneration&id=1" target="_blank" id="fixed-donate"><span class="ic-icon-heart"></span>Donate</a>';
  402. echo'</div>';
  403. }
  404.  
  405. // Remove Dashicons from Genesis Theme
  406. add_action( 'wp_print_styles', 'tn_dequeue_dashicons_style' );
  407. function tn_dequeue_dashicons_style() {
  408. wp_dequeue_style( 'dashicons' );
  409. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement