Update theme-functions.php

This commit is contained in:
Braad
2015-03-19 15:18:43 -07:00
parent 47ca5a873a
commit 26278516b6
+27 -21
View File
@@ -20,7 +20,7 @@ add_action( 'wp_enqueue_scripts', 'trestle_header_actions' );
* @since 1.0.0 * @since 1.0.0
*/ */
function trestle_header_actions() { function trestle_header_actions() {
// Google fonts // Google fonts
wp_enqueue_style( 'theme-google-fonts', '//fonts.googleapis.com/css?family=Lato:300,400,700' ); wp_enqueue_style( 'theme-google-fonts', '//fonts.googleapis.com/css?family=Lato:300,400,700' );
@@ -36,7 +36,7 @@ function trestle_header_actions() {
$custom_css_file = '/trestle/custom.css'; $custom_css_file = '/trestle/custom.css';
if ( is_readable( $upload_path . $custom_css_file ) ) if ( is_readable( $upload_path . $custom_css_file ) )
wp_enqueue_style( 'trestle-custom-css', $upload_url . $custom_css_file ); wp_enqueue_style( 'trestle-custom-css', $upload_url . $custom_css_file );
// Custom jQuery (if it exists) // Custom jQuery (if it exists)
$custom_js_file = '/trestle/custom.js'; $custom_js_file = '/trestle/custom.js';
if ( is_readable( $upload_path . $custom_js_file ) ) if ( is_readable( $upload_path . $custom_js_file ) )
@@ -58,7 +58,7 @@ add_filter( 'body_class', 'trestle_body_classes' );
* @return array Updated body classes. * @return array Updated body classes.
*/ */
function trestle_body_classes( $classes ) { function trestle_body_classes( $classes ) {
// Add 'no-jquery' class to be removed by jQuery if enabled // Add 'no-jquery' class to be removed by jQuery if enabled
$classes[] = 'no-jquery'; $classes[] = 'no-jquery';
@@ -79,19 +79,15 @@ function trestle_body_classes( $classes ) {
// Add menu style class // Add menu style class
if ( genesis_get_option( 'trestle_nav_primary_location' ) ) if ( genesis_get_option( 'trestle_nav_primary_location' ) )
$classes[] = 'nav-primary-location-' . esc_attr( genesis_get_option( 'trestle_nav_primary_location' ) ); $classes[] = 'nav-primary-location-' . esc_attr( genesis_get_option( 'trestle_nav_primary_location' ) );
// Add footer widget number class // Add footer widget number class
if ( genesis_get_option( 'trestle_footer_widgets_number' ) ) if ( genesis_get_option( 'trestle_footer_widgets_number' ) )
$classes[] = 'footer-widgets-number-' . esc_attr( genesis_get_option( 'trestle_footer_widgets_number' ) ); $classes[] = 'footer-widgets-number-' . esc_attr( genesis_get_option( 'trestle_footer_widgets_number' ) );
// Add class for equal height Genesis Extender columns
if ( 1 == genesis_get_option( 'trestle_equal_height_cols' ) )
$classes[] = 'equal-height-genesis-extender-cols';
// Add logo class // Add logo class
if ( genesis_get_option( 'trestle_logo_url' ) || genesis_get_option( 'trestle_logo_url_mobile' ) ) if ( genesis_get_option( 'trestle_logo_url' ) || genesis_get_option( 'trestle_logo_url_mobile' ) )
$classes[] = 'has-logo'; $classes[] = 'has-logo';
return $classes; return $classes;
} }
@@ -108,6 +104,7 @@ add_filter( 'genesis_seo_title', 'trestle_do_logos', 10, 3 );
* @since 1.0.0 * @since 1.0.0
*/ */
function trestle_do_logos( $title, $inside, $wrap ) { function trestle_do_logos( $title, $inside, $wrap ) {
$logo_url = genesis_get_option( 'trestle_logo_url' ); $logo_url = genesis_get_option( 'trestle_logo_url' );
$logo_url_mobile = genesis_get_option( 'trestle_logo_url_mobile' ); $logo_url_mobile = genesis_get_option( 'trestle_logo_url_mobile' );
$logo_html = ''; $logo_html = '';
@@ -125,7 +122,7 @@ function trestle_do_logos( $title, $inside, $wrap ) {
$logo_html .= sprintf( '<img class="logo %s" alt="%s" src="%s" />', $logo_html .= sprintf( '<img class="logo %s" alt="%s" src="%s" />',
implode(' ', $classes), implode(' ', $classes),
esc_attr( get_bloginfo( 'name' ) ), esc_attr( get_bloginfo( 'name' ) ),
$logo_url $logo_url
); );
} }
@@ -142,8 +139,8 @@ function trestle_do_logos( $title, $inside, $wrap ) {
$logo_html .= sprintf( '<img class="logo %s" alt="%s" src="%s" />', $logo_html .= sprintf( '<img class="logo %s" alt="%s" src="%s" />',
implode(' ', $classes), implode(' ', $classes),
esc_attr( get_bloginfo( 'name' ) ), esc_attr( get_bloginfo( 'name' ) ),
$logo_url_mobile $logo_url_mobile
); );
} }
if ( $logo_html ) { if ( $logo_html ) {
@@ -154,11 +151,11 @@ function trestle_do_logos( $title, $inside, $wrap ) {
); );
} }
//* Build the title // Build the title
$title = genesis_html5() ? sprintf( "<{$wrap} %s>", genesis_attr( 'site-title' ) ) : sprintf( '<%s id="title">%s</%s>', $wrap, $inside, $wrap ); $title = genesis_html5() ? sprintf( "<{$wrap} %s>", genesis_attr( 'site-title' ) ) : sprintf( '<%s id="title">%s</%s>', $wrap, $inside, $wrap );
$title .= genesis_html5() ? "{$inside}</{$wrap}>" : ''; $title .= genesis_html5() ? "{$inside}</{$wrap}>" : '';
//* Echo (filtered) // Echo (filtered)
return $title; return $title;
} }
@@ -179,6 +176,7 @@ add_action( 'init', 'trestle_nav_modifications' );
* @see trestle_nav_placeholder() * @see trestle_nav_placeholder()
*/ */
function trestle_nav_modifications() { function trestle_nav_modifications() {
global $trestle_nav_title; global $trestle_nav_title;
// Set title for Trestle placeholder navigation menu // Set title for Trestle placeholder navigation menu
@@ -193,7 +191,7 @@ function trestle_nav_modifications() {
if ( 1 == genesis_get_option( 'trestle_custom_nav_extras' ) ) { if ( 1 == genesis_get_option( 'trestle_custom_nav_extras' ) ) {
// Remove default nav extras // Remove default nav extras
remove_filter( 'wp_nav_menu_items', 'genesis_nav_right' ); remove_filter( 'wp_nav_menu_items', 'genesis_nav_right' );
// Add custom nav extras // Add custom nav extras
add_filter( 'wp_nav_menu_items', 'trestle_custom_nav_extras', 10, 2 ); add_filter( 'wp_nav_menu_items', 'trestle_custom_nav_extras', 10, 2 );
} }
@@ -227,6 +225,7 @@ function trestle_nav_primary_location() {
* @return string <li> list of (modified) navigation menu items. * @return string <li> list of (modified) navigation menu items.
*/ */
function trestle_auto_nav_items( $nav_items, stdClass $menu_args ) { function trestle_auto_nav_items( $nav_items, stdClass $menu_args ) {
if ( 'primary' == $menu_args->theme_location ) { if ( 'primary' == $menu_args->theme_location ) {
$args = array( $args = array(
'depth' => genesis_get_option( 'trestle_auto_nav_depth' ) ? genesis_get_option( 'trestle_auto_nav_depth' ) : 0, 'depth' => genesis_get_option( 'trestle_auto_nav_depth' ) ? genesis_get_option( 'trestle_auto_nav_depth' ) : 0,
@@ -249,7 +248,7 @@ function trestle_auto_nav_items( $nav_items, stdClass $menu_args ) {
// Remove closing </ul></div> // Remove closing </ul></div>
$nav_items = preg_replace( '/<\/ul>\s*<\/div>/', '', $nav_items ); $nav_items = preg_replace( '/<\/ul>\s*<\/div>/', '', $nav_items );
} }
return $nav_items; return $nav_items;
} }
@@ -263,6 +262,7 @@ function trestle_auto_nav_items( $nav_items, stdClass $menu_args ) {
* @return string <li> list of menu items with custom navigation extras <li> appended. * @return string <li> list of menu items with custom navigation extras <li> appended.
*/ */
function trestle_custom_nav_extras( $nav_items, stdClass $menu_args ) { function trestle_custom_nav_extras( $nav_items, stdClass $menu_args ) {
if ( 'primary' == $menu_args->theme_location ) { if ( 'primary' == $menu_args->theme_location ) {
$custom_text = esc_attr( genesis_get_option( 'trestle_custom_nav_extras_text' ) ); $custom_text = esc_attr( genesis_get_option( 'trestle_custom_nav_extras_text' ) );
return $nav_items . '<li class="right custom">' . do_shortcode( genesis_get_option( 'trestle_custom_nav_extras_text' ) ) . '</li>'; return $nav_items . '<li class="right custom">' . do_shortcode( genesis_get_option( 'trestle_custom_nav_extras_text' ) ) . '</li>';
@@ -281,6 +281,7 @@ function trestle_custom_nav_extras( $nav_items, stdClass $menu_args ) {
* @since 1.0.0 * @since 1.0.0
*/ */
function trestle_nav_placeholder() { function trestle_nav_placeholder() {
global $trestle_nav_title; global $trestle_nav_title;
// Create placeholder menu for 'primary' spot if auto-nav is selected - this ensures that nav extras can be used even when no custom menu is formally set to primary // Create placeholder menu for 'primary' spot if auto-nav is selected - this ensures that nav extras can be used even when no custom menu is formally set to primary
@@ -309,7 +310,7 @@ function trestle_nav_placeholder() {
add_filter( 'wp_revisions_to_keep', 'trestle_update_revisions_number', 10, 2 ); add_filter( 'wp_revisions_to_keep', 'trestle_update_revisions_number', 10, 2 );
/** /**
* Sets the number of post revisions. * Sets the number of post revisions.
* *
* @since 1.0.0 * @since 1.0.0
* *
@@ -317,6 +318,7 @@ add_filter( 'wp_revisions_to_keep', 'trestle_update_revisions_number', 10, 2 );
* @return int Number of post revisions specified in Trestle admin panel. * @return int Number of post revisions specified in Trestle admin panel.
*/ */
function trestle_update_revisions_number( $num ) { function trestle_update_revisions_number( $num ) {
$trestle_revisions_number = esc_attr( genesis_get_option( 'trestle_revisions_number' ) ); $trestle_revisions_number = esc_attr( genesis_get_option( 'trestle_revisions_number' ) );
if ( isset( $trestle_revisions_number ) ) if ( isset( $trestle_revisions_number ) )
@@ -335,13 +337,14 @@ add_action( 'the_post', 'trestle_post_info_meta', 5 );
* @global object $post The current $post object. * @global object $post The current $post object.
*/ */
function trestle_post_info_meta() { function trestle_post_info_meta() {
if ( ! is_admin() && in_the_loop() && genesis_get_option( 'trestle_manual_post_info_meta' ) ) { if ( ! is_admin() && in_the_loop() && genesis_get_option( 'trestle_manual_post_info_meta' ) ) {
global $post; global $post;
// Get post type // Get post type
$post_type = get_post_type( $post->ID ); $post_type = get_post_type( $post->ID );
// Remove all Post Info & Meta // Remove all Post Info & Meta
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
@@ -350,7 +353,7 @@ function trestle_post_info_meta() {
if ( is_singular() ) { if ( is_singular() ) {
$single_info_option = 'trestle_post_info_' . $post_type . '_single'; $single_info_option = 'trestle_post_info_' . $post_type . '_single';
$single_meta_option = 'trestle_post_meta_' . $post_type . '_single'; $single_meta_option = 'trestle_post_meta_' . $post_type . '_single';
// Post Info // Post Info
if ( genesis_get_option( $single_info_option ) ) if ( genesis_get_option( $single_info_option ) )
add_action( 'genesis_entry_header', 'genesis_post_info', 12 ); add_action( 'genesis_entry_header', 'genesis_post_info', 12 );
@@ -364,7 +367,7 @@ function trestle_post_info_meta() {
if ( ! is_singular() ) { if ( ! is_singular() ) {
$archive_info_option = 'trestle_post_info_' . $post_type . '_archive'; $archive_info_option = 'trestle_post_info_' . $post_type . '_archive';
$archive_meta_option = 'trestle_post_meta_' . $post_type . '_archive'; $archive_meta_option = 'trestle_post_meta_' . $post_type . '_archive';
// Post Info // Post Info
if ( genesis_get_option( $archive_info_option ) ) if ( genesis_get_option( $archive_info_option ) )
add_action( 'genesis_entry_header', 'genesis_post_info', 12 ); add_action( 'genesis_entry_header', 'genesis_post_info', 12 );
@@ -390,7 +393,9 @@ add_filter( 'genesis_get_image_default_args', 'trestle_featured_image_fallback'
* @return array Updated image args * @return array Updated image args
*/ */
function trestle_featured_image_fallback( $args ) { function trestle_featured_image_fallback( $args ) {
$args['fallback'] = false; $args['fallback'] = false;
return $args; return $args;
} }
@@ -411,10 +416,11 @@ add_filter( 'the_content_more_link', 'trestle_read_more_link' );
* @return string (Updated) "read more" text. * @return string (Updated) "read more" text.
*/ */
function trestle_read_more_link( $default_text ) { function trestle_read_more_link( $default_text ) {
// Get Trestle custom "read more" link text // Get Trestle custom "read more" link text
$custom_text = esc_attr( genesis_get_option( 'trestle_read_more_text' ) ); $custom_text = esc_attr( genesis_get_option( 'trestle_read_more_text' ) );
if ( $custom_text ) if ( $custom_text )
return '&hellip;&nbsp;<a class="more-link" title="' . $custom_text . '" href="' . get_permalink() . '">' . $custom_text . '</a>'; return '&hellip;&nbsp;<a class="more-link" title="' . $custom_text . '" href="' . get_permalink() . '">' . $custom_text . '</a>';
else else
return $default_text; return $default_text;