Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //* Start the engine
- include_once( get_template_directory() . '/lib/init.php' );
- //* Setup Theme
- include_once( get_stylesheet_directory() . '/lib/theme-defaults.php' );
- //* Set Localization (do not remove)
- load_child_theme_textdomain( 'altitude', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'altitude' ) );
- //* Add Image upload and Color select to WordPress Theme Customizer
- require_once( get_stylesheet_directory() . '/lib/customize.php' );
- //* Include Customizer CSS
- include_once( get_stylesheet_directory() . '/lib/output.php' );
- //* Child theme (do not remove)
- define( 'CHILD_THEME_NAME', 'mfs' );
- define( 'CHILD_THEME_URL', '//regeneration.org/' );
- define( 'CHILD_THEME_VERSION', '3.2.4' );
- //* Enqueue scripts and styles
- add_action( 'wp_enqueue_scripts', 'mfs_enqueue_scripts_styles' );
- function mfs_enqueue_scripts_styles() {
- wp_enqueue_script( 'mfs-global', get_bloginfo( 'stylesheet_directory' ) . '/js/global.js', array( 'jquery' ), '1.0.0' );
- 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 );
- wp_enqueue_style( 'ionicons', '//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css', array(), CHILD_THEME_VERSION );
- }
- //* Relocate Post Title and Post Info
- add_action( 'genesis_after_header', 'mfs_relocate_post_title_info' );
- function mfs_relocate_post_title_info() {
- if ( is_singular('post' ) ) {
- remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
- remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
- remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
- //* Reposition Post Info on blog page
- add_action( 'genesis_entry_header', 'genesis_post_info', 12 );
- echo '<div class="featured-single"><div class="overlay-gradient"><div class="wrap">';
- genesis_entry_header_markup_open();
- genesis_do_post_title();
- genesis_post_info();
- genesis_entry_header_markup_close();
- echo '</div></div></div>';
- }
- }
- //* Enqueue scripts on single Post pages
- add_action( 'wp_enqueue_scripts', 'enqueue_singular' );
- function enqueue_singular() {
- if ( is_singular('post' ) ) {
- // to add a dynamically-resized background image to .featured-single
- wp_enqueue_script( 'backstretch', get_stylesheet_directory_uri() . '/js/jquery.backstretch.min.js', array( 'jquery' ), '', true );
- wp_enqueue_script( 'backstretch-init', get_stylesheet_directory_uri() . '/js/backstretch-init.js', array( 'backstretch' ), '1.0.0', true );
- // if the post has a featured image, send it to Backstretch else use a default one
- if ( has_post_thumbnail() ) {
- wp_localize_script( 'backstretch-init', 'BackStretchImg', array( 'src' => wp_get_attachment_url( get_post_thumbnail_id() ) ) );
- }
- else {
- wp_localize_script( 'backstretch-init', 'BackStretchImg', array( 'src' => '/wp-content/themes/mfs/images/bg-1.jpg' ) );
- }
- // for smooth scrolling when the down arrow is clicked
- wp_enqueue_script( 'scrollTo', get_stylesheet_directory_uri() . '/js/jquery.scrollTo.min.js', array( 'jquery' ), '', true );
- wp_enqueue_script( 'localScroll', get_stylesheet_directory_uri() . '/js/jquery.localScroll.min.js', array( 'scrollTo' ), '', true );
- // for setting the height of 'Featured Single' section so its background fills the viewport, adding the down arrow, and setting smooth scrolling speed
- wp_enqueue_script( 'singular', get_bloginfo( 'stylesheet_directory' ) . '/js/singular-scripts.js', array( 'jquery' ), '1.0.0', true );
- // for fading away Post title and info when scrolling down and fading in when scrolling up
- wp_enqueue_script( 'fade-on-scroll', get_stylesheet_directory_uri() . '/js/fade-on-scroll.js', array( 'scrollTo' ), '1.0.0', true );
- }
- }
- //* Add Nav Menu Item for Search
- add_filter( 'wp_nav_menu_items', 'theme_menu_extras', 10, 2 );
- /**
- * Filter menu items to append a search form.
- *
- * @param string $menu HTML string of list items.
- * @param stdClass $args Menu arguments.
- *
- * @return string Amended HTML string of list items.
- */
- function theme_menu_extras( $menu, $args ) {
- if ( 'primary' !== $args->theme_location )
- return $menu;
- $menu .= '<li class="search"><a id="main-nav-search-link" class="icon-search"></a><div class="search-div">' . get_search_form( false ) . '</div></li>';
- return $menu;
- }
- //* Add HTML5 markup structure
- add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
- //* Add viewport meta tag for mobile browsers
- add_theme_support( 'genesis-responsive-viewport' );
- //* Add new image sizes
- add_image_size( 'featured-page', 1140, 400, TRUE );
- add_image_size( 'blog-post', 800, 450, TRUE );
- add_image_size( 'widget-image', 574, 342, TRUE );
- add_image_size( 'team-member', 500, 500, TRUE );
- //* Add support for 2-column footer widget area
- add_theme_support( 'genesis-footer-widgets', 2 );
- //* Add support for footer menu
- add_theme_support ( 'genesis-menus' , array ( 'primary' => 'Primary Navigation Menu', 'secondary' => 'Secondary Navigation Menu', 'footer' => 'Footer Navigation Menu' ) );
- //* Unregister the header right widget area
- unregister_sidebar( 'header-right' );
- //* Reposition the primary navigation menu
- remove_action( 'genesis_after_header', 'genesis_do_nav' );
- add_action( 'genesis_header', 'genesis_do_nav', 12 );
- //* Remove output of primary navigation right extras
- remove_filter( 'genesis_nav_items', 'genesis_nav_right', 10, 2 );
- remove_filter( 'wp_nav_menu_items', 'genesis_nav_right', 10, 2 );
- //* Reposition the secondary navigation menu
- remove_action( 'genesis_after_header', 'genesis_do_subnav' );
- add_action( 'genesis_header', 'genesis_do_subnav', 5 );
- //* Add secondary-nav class if secondary navigation is used
- add_filter( 'body_class', 'mfs_secondary_nav_class' );
- function mfs_secondary_nav_class( $classes ) {
- $menu_locations = get_theme_mod( 'nav_menu_locations' );
- if ( ! empty( $menu_locations['secondary'] ) ) {
- $classes[] = 'secondary-nav';
- }
- return $classes;
- }
- //* Hook menu in footer
- add_action( 'genesis_footer', 'mfs_footer_menu', 7 );
- function mfs_footer_menu() {
- printf( '<nav %s>', genesis_attr( 'nav-footer' ) );
- wp_nav_menu( array(
- 'theme_location' => 'footer',
- 'container' => false,
- 'depth' => 1,
- 'fallback_cb' => false,
- 'menu_class' => 'genesis-nav-menu',
- ) );
- echo '</nav>';
- }
- //* Unregister layout settings
- genesis_unregister_layout( 'content-sidebar-sidebar' );
- genesis_unregister_layout( 'sidebar-content-sidebar' );
- genesis_unregister_layout( 'sidebar-sidebar-content' );
- //* Unregister secondary sidebar
- unregister_sidebar( 'sidebar-alt' );
- //* Add support for custom header
- add_theme_support( 'custom-header', array(
- 'flex-height' => true,
- 'width' => 360,
- 'height' => 76,
- 'header-selector' => '.site-title a',
- 'header-text' => false,
- ) );
- //* Add support for structural wraps
- add_theme_support( 'genesis-structural-wraps', array(
- 'header',
- 'nav',
- 'subnav',
- 'footer',
- ) );
- //* Remove comment form allowed tags
- add_filter( 'comment_form_defaults', 'mfs_remove_comment_form_allowed_tags' );
- function mfs_remove_comment_form_allowed_tags( $defaults ) {
- $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>';
- $defaults['comment_notes_after'] = '';
- return $defaults;
- }
- //* Add support for after entry widget
- add_theme_support( 'genesis-after-entry-widget-area' );
- //* Relocate after entry widget
- remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' );
- add_action( 'genesis_after_entry', 'genesis_after_entry_widget_area', 5 );
- //* Setup widget counts
- function mfs_count_widgets( $id ) {
- global $sidebars_widgets;
- if ( isset( $sidebars_widgets[ $id ] ) ) {
- return count( $sidebars_widgets[ $id ] );
- }
- }
- function mfs_widget_area_class( $id ) {
- $count = mfs_count_widgets( $id );
- $class = '';
- if( $count == 1 ) {
- $class .= ' widget-full';
- } elseif( $count % 3 == 1 ) {
- $class .= ' widget-thirds';
- } elseif( $count % 4 == 1 ) {
- $class .= ' widget-fourths';
- } elseif( $count % 2 == 0 ) {
- $class .= ' widget-halves uneven';
- } else {
- $class .= ' widget-halves';
- }
- return $class;
- }
- //* Register widget areas
- genesis_register_sidebar( array(
- 'id' => 'front-page-1',
- 'name' => __( 'Front Page 1', 'altitude' ),
- 'description' => __( 'This is the front page 1 section.', 'altitude' ),
- ) );
- genesis_register_sidebar( array(
- 'id' => 'front-page-2',
- 'name' => __( 'Front Page 2', 'altitude' ),
- 'description' => __( 'This is the front page 2 section.', 'altitude' ),
- ) );
- genesis_register_sidebar( array(
- 'id' => 'front-page-3',
- 'name' => __( 'Front Page 3', 'altitude' ),
- 'description' => __( 'This is the front page 3 section.', 'altitude' ),
- ) );
- genesis_register_sidebar( array(
- 'id' => 'front-page-4',
- 'name' => __( 'Front Page 4', 'altitude' ),
- 'description' => __( 'This is the front page 4 section.', 'altitude' ),
- ) );
- genesis_register_sidebar( array(
- 'id' => 'front-page-5',
- 'name' => __( 'Front Page 5', 'altitude' ),
- 'description' => __( 'This is the front page 5 section.', 'altitude' ),
- ) );
- genesis_register_sidebar( array(
- 'id' => 'front-page-6',
- 'name' => __( 'Front Page 6', 'altitude' ),
- 'description' => __( 'This is the front page 6 section.', 'altitude' ),
- ) );
- genesis_register_sidebar( array(
- 'id' => 'front-page-7',
- 'name' => __( 'Front Page 7', 'altitude' ),
- 'description' => __( 'This is the front page 7 section.', 'altitude' ),
- ) );
- //* Add "Continue"
- function mfs_continue_reading() {
- ?>
- <a href="<?php echo get_permalink(); ?>" class="more-link button clear">Continue</a>
- <?php
- }
- //* Customize the post info function
- add_filter( 'genesis_post_info', 'mfs_post_info_filter' );
- function mfs_post_info_filter($post_info) {
- $post_info = 'Published on[post_date] by [post_author]';
- return $post_info;
- }
- //* Customize the entry meta in the entry footer
- add_filter( 'genesis_post_meta', 'mfs_post_meta_filter' );
- function mfs_post_meta_filter($post_meta) {
- $post_meta = '[post_categories before=""] [post_tags before=""]';
- return $post_meta;
- }
- //* Modify the Genesis content limit read more link
- add_filter( 'get_the_content_more_link', 'mfs_read_more_link' );
- function mfs_read_more_link() {
- return '...<br /><a class="clearfix button-clear more-link" href="' . get_permalink() . '">Continue</a>';
- }
- //* Add a ID to .site-inner
- add_filter( 'genesis_attr_site-inner', 'custom_attributes_content' );
- function custom_attributes_content( $attributes ) {
- if ( is_singular('post' ) ) {
- $attributes['id'] = 'site-inner';
- }
- return $attributes;
- }
- //* Move comments box above comments list
- add_action( 'genesis_before_comments' , 'mfs_comment_box_move' );
- function mfs_comment_box_move () {
- if ( is_single() ) {
- if ( have_comments() ) {
- remove_action( 'genesis_comment_form', 'genesis_do_comment_form' );
- add_action( 'genesis_list_comments', 'genesis_do_comment_form' , 5 );
- }
- }
- }
- //* Customize the Genesis Credits
- add_filter( 'genesis_footer_creds_text', 'sp_footer_creds_text' );
- function sp_footer_creds_text() {
- echo '<div class="creds"><p>';
- echo 'Copyright © ';
- echo date('Y');
- echo ' · <a href="https://www.regenerationministries.org">Regeneration Ministries</a>';
- echo '</p></div>';
- }
- add_image_size( 'sidebar-recent', 360, 135, true );
- //* Removed "Protected" from Protected pages
- function the_title_trim($title) {
- $title = esc_attr($title);
- $findthese = array(
- '#Protected:#',
- '#Private:#'
- );
- $replacewith = array(
- '', // What to replace "Protected:" with
- '' // What to replace "Private:" with
- );
- $title = preg_replace($findthese, $replacewith, $title);
- return $title;
- }
- add_filter('the_title', 'the_title_trim');
- // REMOVE EMOJI ICONS
- remove_action('wp_head', 'print_emoji_detection_script', 7);
- remove_action('wp_print_styles', 'print_emoji_styles');
- add_action('genesis_before_content', 'child_404_image');
- /**
- * Add an image to the top of the 404 page
- *
- * @author K. Shoffner
- */
- function child_404_image() {
- if ( is_404() )
- echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/404.png" alt="OOPS, Nothing Found" />';
- }
- // Register a custom image size for Team images
- add_image_size( 'team', 295, 295, true );
- function featured_post_image() {
- if ( ! is_singular( 'page' ) ) return;
- the_post_thumbnail('post-image');
- }
- // Display featured image before title on the single page in Genesis
- add_action( 'genesis_entry_header', 'featured_post_image', 8 );
- add_action( 'get_header', 'remove_titles_from_pages' );
- function remove_titles_from_pages() {
- if ( is_page(array('contact', 'programs', 'coaching') ) ) {
- remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
- }
- }
- // Display floating donation button
- add_action( 'genesis_before_loop', 'wpsites_hook_button', 25 );
- function wpsites_hook_button() {
- echo'<div id="fixed-buttons">';
- 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>';
- echo'</div>';
- }
- // Remove Dashicons from Genesis Theme
- add_action( 'wp_print_styles', 'tn_dequeue_dashicons_style' );
- function tn_dequeue_dashicons_style() {
- wp_dequeue_style( 'dashicons' );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement