123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- <?php
- /**
- * This file adds all the functions to the Captivating theme.
- *
- * @package Captivating
- * @link http://restored316designs.com/themes
- * @author Lauren Gaige // Restored 316 LLC
- * @copyright Copyright (c) 2015, Restored 316 LLC, Released 08/09/2017
- * @license GPL-2.0+
- */
- //* Start the engine
- include_once( get_template_directory() . '/lib/init.php' );
- //* Setup Theme
- include_once( get_stylesheet_directory() . '/lib/theme-defaults.php' );
- //* Add Color selections to WordPress Theme Customizer
- require_once( get_stylesheet_directory() . '/lib/customize.php' );
- //* Include Customizer CSS
- include_once( get_stylesheet_directory() . '/lib/output.php' );
- //* Add Widget Spaces
- require_once( get_stylesheet_directory() . '/lib/widgets.php' );
- //* Install Plugins
- require_once( get_stylesheet_directory() . '/lib/plugins/tgm-plugin-activation/register-plugins.php' );
- //* Child theme (do not remove)
- define( 'CHILD_THEME_NAME', 'captivating' );
- define( 'CHILD_THEME_URL', 'http://restored316designs.com' );
- define( 'CHILD_THEME_VERSION', '1.0.0' );
- //* Loads Responsive Menu, Google Fonts, Icons, and other scripts
- add_action( 'wp_enqueue_scripts', 'captivating_enqueue_scripts' );
- function captivating_enqueue_scripts() {
- wp_enqueue_style( 'google-font', '//fonts.googleapis.com/css?family=Montserrat:300,300i,400,700,700i|Open+Sans:400,400i,700,700i|Playfair+Display:400,400i,700,700i|Poppins|Satisfy', array() );
- wp_enqueue_style( 'ionicons', '//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css', array(), CHILD_THEME_VERSION );
- wp_enqueue_style( 'dashicons' );
- wp_enqueue_script( 'captivating-global-script', get_bloginfo( 'stylesheet_directory' ) . '/js/global.js', array( 'jquery' ), '1.0.0' );
- wp_enqueue_script( 'match-height', get_stylesheet_directory_uri() . '/js/jquery.matchHeight-min.js', array( 'jquery' ), '1.0.0', true );
- wp_enqueue_script( 'match-height-init', get_stylesheet_directory_uri() . '/js/matchheight-init.js', array( 'match-height' ), '1.0.0', true );
-
- $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
- wp_enqueue_script( 'captivating-responsive-menu', get_stylesheet_directory_uri() . "/js/responsive-menus{$suffix}.js", array( 'jquery' ), CHILD_THEME_VERSION, true );
- wp_localize_script(
- 'captivating-responsive-menu',
- 'genesis_responsive_menu',
- captivating_responsive_menu_settings()
- );
- }
- // Define our responsive menu settings.
- function captivating_responsive_menu_settings() {
- $settings = array(
- 'mainMenu' => __( 'Menu', 'captivating' ),
- 'menuIconClass' => 'dashicons-before dashicons-menu',
- 'subMenu' => __( 'Submenu', 'captivating' ),
- 'subMenuIconsClass' => 'dashicons-before dashicons-arrow-down-alt2',
- 'menuClasses' => array(
- 'combine' => array(
- '.nav-header',
- '.nav-header-left',
- '.nav-header-right',
- '.nav-secondary',
- '.nav-primary',
- ),
- 'others' => array(
- '.nav-footer',
- ),
- ),
- );
- return $settings;
- }
- //* Add support for footer menu & rename menus
- add_theme_support ( 'genesis-menus' , array (
- 'primary' => 'Above Header Menu',
- 'secondary' => 'Below Header Menu',
- 'header-left' => 'Header Left',
- 'header-right' => 'Header Right',
- 'footer' => 'Footer Menu'
- ) );
- //* Add HTML5 markup structure
- add_theme_support( 'html5' );
- //* Add new featured image sizes
- add_image_size( 'square-entry-image', 400, 400, TRUE );
- add_image_size( 'vertical-entry-image', 400, 600, TRUE );
- add_image_size( 'horizontal-entry-image', 820, 550, TRUE );
- //* Add support for 3-column footer widgets
- add_theme_support( 'genesis-footer-widgets', 3 );
- //* Add viewport meta tag for mobile browsers
- add_theme_support( 'genesis-responsive-viewport' );
- //* Add support for custom background
- add_theme_support( 'custom-background', array(
- 'default-color' => 'FFFFFF',
- ));
-
- //* Add support for after entry widget
- add_theme_support( 'genesis-after-entry-widget-area' );
- //* Add support for custom header
- add_theme_support( 'custom-header', array(
- 'width' => 2000,
- 'height' => 1562,
- 'header-selector' => '.site-title a',
- 'header-text' => false,
- ) );
- //* Remove the site description
- remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
- //* 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' );
- //* Reposition the primary navigation menu
- remove_action( 'genesis_after_header', 'genesis_do_nav' );
- add_action( 'genesis_before_header', 'genesis_do_nav', 7 );
- //* Add search form to navigation
- add_filter( 'wp_nav_menu_items', 'captivating_primary_nav_extras', 10, 2 );
- function captivating_primary_nav_extras( $menu, $args ) {
- if ( 'primary' !== $args->theme_location ) {
- return $menu;
- }
- ob_start();
- get_search_form();
- $search = ob_get_clean();
- $menu .= '<li class="right search">' . $search . '</li>';
- return $menu;
- }
- //* Add widget to primary navigation
- add_filter( 'genesis_nav_items', 'captivating_social_icons', 10, 2 );
- add_filter( 'wp_nav_menu_items', 'captivating_social_icons', 10, 2 );
- function captivating_social_icons($menu, $args) {
- $args = (array)$args;
- if ( 'primary' !== $args['theme_location'] )
- return $menu;
- ob_start();
- genesis_widget_area('nav-social-menu');
- $social = ob_get_clean();
- return $menu . $social;
- }
- //* Hook menu to left of Logo
- add_action( 'genesis_header', 'captivating_header_left_menu', 6 );
- function captivating_header_left_menu() {
- genesis_nav_menu( array(
- 'theme_location' => 'header-left',
- 'depth' => 2,
- ) );
- }
- //* Hook menu to right of Logo
- add_action( 'genesis_header', 'captivating_header_right_menu', 9 );
- function captivating_header_right_menu() {
- genesis_nav_menu( array(
- 'theme_location' => 'header-right',
- 'depth' => 2,
- ) );
- }
- //* Hook menu in footer
- add_action( 'genesis_before_footer', 'captivating_footer_menu', 7 );
- function captivating_footer_menu() {
- genesis_nav_menu( array(
- 'theme_location' => 'footer',
- 'depth' => 1,
- ) );
- }
-
- //* Reposition Featured Images
- remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
- add_action( 'genesis_entry_header', 'genesis_do_post_image', 5 );
- //* Reposition Post Info Above Post Title
- remove_action( 'genesis_entry_header', 'genesis_post_info', 12);
- add_action( 'genesis_entry_header', 'genesis_post_info', 9 );
- //* Reposition Post Meta Below Post Title
- remove_action( 'genesis_entry_footer', 'genesis_post_meta');
- add_action( 'genesis_entry_header', 'genesis_post_meta', 12 );
- //* Customize the Post Info Function
- add_filter( 'genesis_post_info', 'captivating_post_info_filter' );
- function captivating_post_info_filter( $post_info ) {
- $post_info = '[post_date] · [post_comments before="<i class="icon ion-paintbucket"></i>" zero="Leave a Comment" one="1 Comment" more="% Comments"]';
- return $post_info;
- }
- //* Customize the Post Meta function
- add_filter( 'genesis_post_meta', 'captivating_post_meta_filter' );
- function captivating_post_meta_filter( $post_meta ) {
- $post_meta = '[post_categories before="" sep="·"]';
- return $post_meta;
- }
- //* Modify the size of the Gravatar in the entry comments
- add_filter( 'genesis_comment_list_args', 'captivating_comments_gravatar' );
- function captivating_comments_gravatar( $args ) {
- $args['avatar_size'] = 96;
- return $args;
- }
- //* Modify the size of the Gravatar in the author box
- add_filter( 'genesis_author_box_gravatar_size', 'captivating_author_box_gravatar' );
- function captivating_author_box_gravatar( $size ) {
- return 200;
- }
- //* Customize search form input box text
- add_filter( 'genesis_search_text', 'captivating_search_text' );
- function captivating_search_text( $text ) {
- return esc_attr( 'Search . . .' );
- }
- //* Remove comment form allowed tags
- add_filter( 'comment_form_defaults', 'captivating_remove_comment_form_allowed_tags' );
- function captivating_remove_comment_form_allowed_tags( $defaults ) {
- $defaults['comment_notes_after'] = '';
- return $defaults;
- }
- // Customize 'Read More' text with accessibility.
- add_filter( 'excerpt_more', 'captivating_read_more_link' );
- add_filter( 'get_the_content_more_link', 'captivating_read_more_link' );
- add_filter( 'the_content_more_link', 'captivating_read_more_link' );
- function captivating_read_more_link($more) {
-
- $new_a11y_read_more_title = sprintf( '<span class="screen-reader-text">%s %s</span>', __( 'about ', 'captivating' ), get_the_title() );
- return sprintf( ' ... <a href="%s" class="more-link">%s %s</a>', get_permalink(), __( 'Read More', 'captivating' ), $new_a11y_read_more_title );
- }
- //* Hooks Announcement Widget
- add_action( 'genesis_before', 'captivating_announcement_widget', 8 );
- function captivating_announcement_widget() {
- genesis_widget_area( 'announcement-widget', array(
- 'before' => '<div class="announcement-widget widget-area"><div class="wrap">',
- 'after' => '</div></div>',
- ) );
- }
- //* Hooks Widget Area Above Content
- add_action( 'genesis_before_footer', 'captivating_site_wide_cta', 6 );
- function captivating_site_wide_cta() {
- if ( !is_home() ){
- genesis_widget_area( 'site-wide-cta', array(
- 'before' => '<div class="site-wide-cta widget-area"><div class="wrap">',
- 'after' => '</div></div>',
- ) );
- }}
- //* Hooks Widget Area Below Footer
- add_action( 'genesis_before_footer', 'captivating_widget_below_footer', 12 );
- function captivating_widget_below_footer() {
- genesis_widget_area( 'widget-below-footer', array(
- 'before' => '<div class="widget-below-footer widget-area">',
- 'after' => '</div>',
- ) );
- }
- //* Force 12 posts to appear on all archive pages
- add_action('pre_get_posts', 'captivating_change_posts_per_page', 1);
- function captivating_change_posts_per_page( $query ) {
- if( ! $query->is_main_query() )
- return;
- if ( is_archive() ){
- $query->set( 'posts_per_page', 12); //* This changes the # of posts displayed on the category pages
- }
- }
- //* Load Entry Navigation
- add_action( 'genesis_after_entry', 'genesis_prev_next_post_nav', 9 );
- //* Customize the credits
- add_filter('genesis_footer_creds_text', 'captivating_footer_creds_text');
- function captivating_footer_creds_text( $creds ) {
- $creds = '<div class="creds">Copyright [footer_copyright] · <a target="_blank" href="http://restored316designs.com/themes">captivating theme</a> by <a target="_blank" href="http://www.restored316designs.com">Restored 316</a></div>';
- return $creds;
- }
- //* Add Theme Support for WooCommerce
- add_theme_support( 'genesis-connect-woocommerce' );
- //* Remove Related Products
- remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
- //* Change number or products per row to 3
- add_filter('loop_shop_columns', 'loop_columns');
- if (!function_exists('loop_columns')) {
- function loop_columns() {
- return 3; // 3 products per row
- }
- }
- //* Add WooCommerce Gallery Options
- add_action( 'after_setup_theme', 'captivating_woo_gallery' );
- function captivating_woo_gallery() {
- //add_theme_support( 'wc-product-gallery-zoom' );
- add_theme_support( 'wc-product-gallery-lightbox' );
- add_theme_support( 'wc-product-gallery-slider' );
- }
- //* Add WP Recipe Maker Jump to Recipe
- add_action('genesis_entry_content', 'captivating_wprm_buttons', 1);
- function captivating_wprm_buttons() {
- if ( is_single() && ( shortcode_exists( 'wprm-recipe-jump' ) || shortcode_exists( 'wprm-recipe-print' ) ) ) {
- echo '<div class="wprm-buttons">';
- if ( shortcode_exists( 'wprm-recipe-jump' ) ) {
- echo do_shortcode( '[wprm-recipe-jump]' );
- }
- echo '</div>';
- }
- }
|