Skip to content

Instantly share code, notes, and snippets.

@gspice
Forked from srikat/functions.php
Created March 5, 2017 18:07
Show Gist options
  • Save gspice/26f4ab06c940e490682d86a2242587be to your computer and use it in GitHub Desktop.
Save gspice/26f4ab06c940e490682d86a2242587be to your computer and use it in GitHub Desktop.
<?php
/**
* Genesis Sample.
*
* This file adds functions to the Genesis Sample Theme.
*
* @package Genesis Sample
* @author StudioPress
* @license GPL-2.0+
* @link http://www.studiopress.com/
*/
// 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( 'genesis-sample', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'genesis-sample' ) );
// 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', 'Genesis Sample' );
define( 'CHILD_THEME_URL', 'http://www.studiopress.com/' );
define( 'CHILD_THEME_VERSION', '2.2.4' );
add_action( 'wp_enqueue_scripts', 'genesis_sample_enqueue_scripts_styles' );
/**
* Enqueue Scripts and Styles.
*/
function genesis_sample_enqueue_scripts_styles() {
wp_enqueue_style( 'genesis-sample-fonts', '//fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700', array(), CHILD_THEME_VERSION );
wp_enqueue_style( 'dashicons' );
wp_enqueue_script( 'genesis-sample-responsive-menu', get_stylesheet_directory_uri() . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0', true );
$output = array(
'mainMenu' => __( 'Menu', 'genesis-sample' ),
'subMenu' => __( 'Menu', 'genesis-sample' ),
);
wp_localize_script( 'genesis-sample-responsive-menu', 'genesisSampleL10n', $output );
}
// Add HTML5 markup structure.
add_theme_support( 'html5', array( 'caption', 'comment-form', 'comment-list', 'gallery', 'search-form' ) );
// Add Accessibility support.
add_theme_support( 'genesis-accessibility', array( '404-page', 'drop-down-menu', 'headings', 'rems', 'search-form', 'skip-links' ) );
// Add viewport meta tag for mobile browsers.
add_theme_support( 'genesis-responsive-viewport' );
// Add support for custom header.
add_theme_support( 'custom-header', array(
'width' => 600,
'height' => 160,
'header-selector' => '.site-title a',
'header-text' => false,
'flex-height' => true,
) );
// Add support for custom background.
add_theme_support( 'custom-background' );
// Add support for after entry widget.
add_theme_support( 'genesis-after-entry-widget-area' );
// Add support for 3-column footer widgets.
add_theme_support( 'genesis-footer-widgets', 3 );
// Add Image Sizes.
add_image_size( 'featured-image', 720, 400, true );
// Rename primary and secondary navigation menus.
add_theme_support( 'genesis-menus' , array(
'primary' => __( 'After Header Menu', 'genesis-sample' ),
'secondary' => __( 'Footer Menu', 'genesis-sample' ),
) );
// Reposition the secondary navigation menu.
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_footer', 'genesis_do_subnav', 5 );
add_filter( 'wp_nav_menu_args', 'genesis_sample_secondary_menu_args' );
/**
* Reduce the secondary navigation menu to one level depth.
*
* @param array $args An array containing wp_nav_menu() arguments.
* @return array $args Modified array containing wp_nav_menu() arguments.
*/
function genesis_sample_secondary_menu_args( $args ) {
if ( 'secondary' !== $args['theme_location'] ) {
return $args;
}
$args['depth'] = 1;
return $args;
}
add_filter( 'genesis_author_box_gravatar_size', 'genesis_sample_author_box_gravatar' );
/**
* Modify size of the Gravatar in the author box.
*
* @param int $size Current size of gravatar. Default is 70.
* @return int Modified size of gravatar.
*/
function genesis_sample_author_box_gravatar( $size ) {
return 90;
}
add_filter( 'genesis_comment_list_args', 'genesis_sample_comments_gravatar' );
/**
* Modify size of the Gravatar in the entry comments.
*
* @param array $args Current arguments for the list of comments.
* @return array Modified arguments with size of gravatar changed from the default of 48.
*/
function genesis_sample_comments_gravatar( $args ) {
$args['avatar_size'] = 60;
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment