From 26278516b694ec19851135b10b72966c162136d5 Mon Sep 17 00:00:00 2001 From: Braad Date: Thu, 19 Mar 2015 15:18:43 -0700 Subject: [PATCH] Update theme-functions.php --- includes/functions/theme-functions.php | 48 +++++++++++++++----------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/includes/functions/theme-functions.php b/includes/functions/theme-functions.php index 2efc389..40309e6 100644 --- a/includes/functions/theme-functions.php +++ b/includes/functions/theme-functions.php @@ -20,7 +20,7 @@ add_action( 'wp_enqueue_scripts', 'trestle_header_actions' ); * @since 1.0.0 */ function trestle_header_actions() { - + // Google fonts 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'; if ( is_readable( $upload_path . $custom_css_file ) ) wp_enqueue_style( 'trestle-custom-css', $upload_url . $custom_css_file ); - + // Custom jQuery (if it exists) $custom_js_file = '/trestle/custom.js'; if ( is_readable( $upload_path . $custom_js_file ) ) @@ -58,7 +58,7 @@ add_filter( 'body_class', 'trestle_body_classes' ); * @return array Updated body classes. */ function trestle_body_classes( $classes ) { - + // Add 'no-jquery' class to be removed by jQuery if enabled $classes[] = 'no-jquery'; @@ -79,19 +79,15 @@ function trestle_body_classes( $classes ) { // Add menu style class if ( 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 if ( 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 if ( genesis_get_option( 'trestle_logo_url' ) || genesis_get_option( 'trestle_logo_url_mobile' ) ) $classes[] = 'has-logo'; - + return $classes; } @@ -108,6 +104,7 @@ add_filter( 'genesis_seo_title', 'trestle_do_logos', 10, 3 ); * @since 1.0.0 */ function trestle_do_logos( $title, $inside, $wrap ) { + $logo_url = genesis_get_option( 'trestle_logo_url' ); $logo_url_mobile = genesis_get_option( 'trestle_logo_url_mobile' ); $logo_html = ''; @@ -125,7 +122,7 @@ function trestle_do_logos( $title, $inside, $wrap ) { $logo_html .= sprintf( '', implode(' ', $classes), esc_attr( get_bloginfo( 'name' ) ), - $logo_url + $logo_url ); } @@ -142,8 +139,8 @@ function trestle_do_logos( $title, $inside, $wrap ) { $logo_html .= sprintf( '', implode(' ', $classes), esc_attr( get_bloginfo( 'name' ) ), - $logo_url_mobile - ); + $logo_url_mobile + ); } 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', $wrap, $inside, $wrap ); $title .= genesis_html5() ? "{$inside}" : ''; - //* Echo (filtered) + // Echo (filtered) return $title; } @@ -179,6 +176,7 @@ add_action( 'init', 'trestle_nav_modifications' ); * @see trestle_nav_placeholder() */ function trestle_nav_modifications() { + global $trestle_nav_title; // Set title for Trestle placeholder navigation menu @@ -193,7 +191,7 @@ function trestle_nav_modifications() { if ( 1 == genesis_get_option( 'trestle_custom_nav_extras' ) ) { // Remove default nav extras remove_filter( 'wp_nav_menu_items', 'genesis_nav_right' ); - + // Add custom nav extras add_filter( 'wp_nav_menu_items', 'trestle_custom_nav_extras', 10, 2 ); } @@ -227,6 +225,7 @@ function trestle_nav_primary_location() { * @return string
  • list of (modified) navigation menu items. */ function trestle_auto_nav_items( $nav_items, stdClass $menu_args ) { + if ( 'primary' == $menu_args->theme_location ) { $args = array( '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 $nav_items = preg_replace( '/<\/ul>\s*<\/div>/', '', $nav_items ); } - + return $nav_items; } @@ -263,6 +262,7 @@ function trestle_auto_nav_items( $nav_items, stdClass $menu_args ) { * @return string
  • list of menu items with custom navigation extras
  • appended. */ function trestle_custom_nav_extras( $nav_items, stdClass $menu_args ) { + if ( 'primary' == $menu_args->theme_location ) { $custom_text = esc_attr( genesis_get_option( 'trestle_custom_nav_extras_text' ) ); return $nav_items . '
  • ' . do_shortcode( genesis_get_option( 'trestle_custom_nav_extras_text' ) ) . '
  • '; @@ -281,6 +281,7 @@ function trestle_custom_nav_extras( $nav_items, stdClass $menu_args ) { * @since 1.0.0 */ function trestle_nav_placeholder() { + 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 @@ -309,7 +310,7 @@ function trestle_nav_placeholder() { 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 * @@ -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. */ function trestle_update_revisions_number( $num ) { + $trestle_revisions_number = esc_attr( genesis_get_option( '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. */ function trestle_post_info_meta() { + if ( ! is_admin() && in_the_loop() && genesis_get_option( 'trestle_manual_post_info_meta' ) ) { global $post; // Get post type $post_type = get_post_type( $post->ID ); - + // Remove all Post Info & Meta remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); @@ -350,7 +353,7 @@ function trestle_post_info_meta() { if ( is_singular() ) { $single_info_option = 'trestle_post_info_' . $post_type . '_single'; $single_meta_option = 'trestle_post_meta_' . $post_type . '_single'; - + // Post Info if ( genesis_get_option( $single_info_option ) ) add_action( 'genesis_entry_header', 'genesis_post_info', 12 ); @@ -364,7 +367,7 @@ function trestle_post_info_meta() { if ( ! is_singular() ) { $archive_info_option = 'trestle_post_info_' . $post_type . '_archive'; $archive_meta_option = 'trestle_post_meta_' . $post_type . '_archive'; - + // Post Info if ( genesis_get_option( $archive_info_option ) ) 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 */ function trestle_featured_image_fallback( $args ) { + $args['fallback'] = false; + return $args; } @@ -411,10 +416,11 @@ add_filter( 'the_content_more_link', 'trestle_read_more_link' ); * @return string (Updated) "read more" text. */ function trestle_read_more_link( $default_text ) { + // Get Trestle custom "read more" link text $custom_text = esc_attr( genesis_get_option( 'trestle_read_more_text' ) ); - if ( $custom_text ) + if ( $custom_text ) return '… ' . $custom_text . ''; else return $default_text;