mirror of
https://github.com/10h30/trestle.git
synced 2026-07-11 18:56:07 +09:00
Syncing with dev branch
This commit is contained in:
@@ -35,6 +35,7 @@ function trestle_custom_defaults( $defaults ) {
|
||||
'trestle_layout' => 'solid',
|
||||
'trestle_logo_url' => '',
|
||||
'trestle_logo_url_mobile' => '',
|
||||
'trestle_favicon_url' => '',
|
||||
'trestle_nav_primary_location' => 'full',
|
||||
'trestle_read_more_text' => __( 'Read More »', 'trestle' ),
|
||||
'trestle_revisions_number' => 3,
|
||||
@@ -94,6 +95,12 @@ function trestle_register_required_plugins() {
|
||||
'required' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'name' => 'Equal Height Columns',
|
||||
'slug' => 'equal-height-columns',
|
||||
'required' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'name' => 'Events Manager',
|
||||
'slug' => 'events-manager',
|
||||
@@ -113,8 +120,8 @@ function trestle_register_required_plugins() {
|
||||
),
|
||||
|
||||
array(
|
||||
'name' => 'FancyBox for WordPress',
|
||||
'slug' => 'fancybox-for-wordpress',
|
||||
'name' => 'Easy FancyBox',
|
||||
'slug' => 'easy-fancybox',
|
||||
'required' => false,
|
||||
),
|
||||
|
||||
@@ -257,4 +264,4 @@ function trestle_register_required_plugins() {
|
||||
);
|
||||
|
||||
tgmpa( $plugins, $config );
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,16 @@
|
||||
});
|
||||
});
|
||||
|
||||
// Favicon
|
||||
wp.customize( 'genesis-settings[trestle_favicon_url]', function( value ) {
|
||||
value.bind( function( url ) {
|
||||
|
||||
var $faviconElem = $( 'link[rel="Shortcut Icon"]' );
|
||||
$faviconElem.attr( 'href', url );
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// Primary Nav Location
|
||||
wp.customize( 'genesis-settings[trestle_nav_primary_location]', function( value ) {
|
||||
value.bind( function( value ) {
|
||||
@@ -69,7 +79,7 @@
|
||||
wp.customize( 'genesis-settings[trestle_read_more_text]', function( value ) {
|
||||
value.bind( function( value ) {
|
||||
|
||||
$( 'a.more-link' ).text( value );
|
||||
$( 'a.more-link' ).html( value );
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -108,13 +108,35 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize,
|
||||
'trestle_mobile_logo_control',
|
||||
array(
|
||||
'label' => __( 'Upload a logo for mobile', 'trestle' ),
|
||||
'label' => __( 'Upload a mobile logo', 'trestle' ),
|
||||
'section' => 'trestle_settings_section',
|
||||
'settings' => 'genesis-settings[trestle_logo_url_mobile]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Upload a mobile logo
|
||||
$wp_customize->add_setting(
|
||||
'genesis-settings[trestle_favicon_url]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'trestle_favicon_url' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
)
|
||||
);
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Image_Control(
|
||||
$wp_customize,
|
||||
'trestle_favicon_control',
|
||||
array(
|
||||
'label' => __( 'Upload a favicon', 'trestle' ),
|
||||
'section' => 'trestle_settings_section',
|
||||
'settings' => 'genesis-settings[trestle_favicon_url]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Primary nav style
|
||||
$wp_customize->add_setting(
|
||||
'genesis-settings[trestle_nav_primary_location]',
|
||||
@@ -139,6 +161,26 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
)
|
||||
);
|
||||
|
||||
// Primary nav extras
|
||||
$wp_customize->add_setting(
|
||||
'genesis-settings[trestle_custom_nav_extras_text]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'trestle_custom_nav_extras_text' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
)
|
||||
);
|
||||
$wp_customize->add_control(
|
||||
'trestle_custom_nav_extras_text_control',
|
||||
array(
|
||||
'section' => 'trestle_settings_section',
|
||||
'settings' => 'genesis-settings[trestle_custom_nav_extras_text]',
|
||||
'label' => __( 'Add search to mobile navigation', 'trestle' ),
|
||||
'type' => 'checkbox',
|
||||
)
|
||||
);
|
||||
|
||||
// Blog post custom read more link text
|
||||
$wp_customize->add_setting(
|
||||
'genesis-settings[trestle_read_more_text]',
|
||||
|
||||
@@ -10,7 +10,35 @@
|
||||
*/
|
||||
|
||||
/*===========================================
|
||||
* Head Styles & Scripts
|
||||
* 3rd Party Libraries
|
||||
===========================================*/
|
||||
|
||||
add_action( 'init', 'trestle_load_bfa' );
|
||||
/**
|
||||
* Initialize the Better Font Awesome Library.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function trestle_load_bfa() {
|
||||
|
||||
// Set the library initialization args
|
||||
$args = array(
|
||||
'version' => 'latest',
|
||||
'minified' => true,
|
||||
'remove_existing_fa' => false,
|
||||
'load_styles' => true,
|
||||
'load_admin_styles' => true,
|
||||
'load_shortcode' => true,
|
||||
'load_tinymce_plugin' => true,
|
||||
);
|
||||
|
||||
// Initialize the Better Font Awesome Library.
|
||||
Better_Font_Awesome_Library::get_instance( $args );
|
||||
|
||||
}
|
||||
|
||||
/*===========================================
|
||||
* Header
|
||||
===========================================*/
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'trestle_header_actions' );
|
||||
@@ -44,6 +72,20 @@ function trestle_header_actions() {
|
||||
|
||||
}
|
||||
|
||||
add_filter( 'genesis_pre_load_favicon', 'trestle_do_custom_favicon' );
|
||||
/**
|
||||
* Output custom favicon if specified in the theme options.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param string $favicon_url Default favicon URL.
|
||||
*
|
||||
* @return string Custom favicon URL (if specified), or the default URL.
|
||||
*/
|
||||
function trestle_do_custom_favicon( $favicon_url ) {
|
||||
return genesis_get_option( 'trestle_favicon_url' ) ? genesis_get_option( 'trestle_favicon_url' ) : $favicon_url;
|
||||
}
|
||||
|
||||
/*===========================================
|
||||
* Body Classes
|
||||
===========================================*/
|
||||
@@ -164,42 +206,6 @@ function trestle_do_logos( $title, $inside, $wrap ) {
|
||||
* Navigation
|
||||
===========================================*/
|
||||
|
||||
add_action( 'init', 'trestle_nav_modifications' );
|
||||
/**
|
||||
* Performs modifications to the primary navigation menu
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @see trestle_add_mobile_nav()
|
||||
* @see trestle_auto_nav_items()
|
||||
* @see trestle_custom_nav_extras()
|
||||
* @see trestle_nav_placeholder()
|
||||
*/
|
||||
function trestle_nav_modifications() {
|
||||
|
||||
global $trestle_nav_title;
|
||||
|
||||
// Set title for Trestle placeholder navigation menu
|
||||
$trestle_nav_title = __( 'Trestle Auto Nav Placeholder', 'trestle' );
|
||||
|
||||
// Auto-generate nav if Genesis theme setting is checked
|
||||
if ( 1 == genesis_get_option( 'trestle_auto_nav' ) ) {
|
||||
add_filter( 'wp_nav_menu_items', 'trestle_auto_nav_items', 9, 2 );
|
||||
}
|
||||
|
||||
// Do custom nav extras
|
||||
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 );
|
||||
}
|
||||
|
||||
// Create placeholder navigation menu object if needed
|
||||
trestle_nav_placeholder();
|
||||
}
|
||||
|
||||
add_action( 'init', 'trestle_nav_primary_location' );
|
||||
/**
|
||||
* Move primary navigation into the header if need be.
|
||||
@@ -215,94 +221,25 @@ function trestle_nav_primary_location() {
|
||||
|
||||
}
|
||||
|
||||
add_filter( 'wp_nav_menu_items', 'trestle_custom_nav_extras', 10, 2 );
|
||||
/**
|
||||
* Auto-generates list of pages for use in the primary navigation menu.
|
||||
* Add custom nav extras.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param string $nav_items <li> list of navigation menu items.
|
||||
* @param stdClass $menu_args Arguments for the menu.
|
||||
* @return string <li> 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,
|
||||
'echo' => false,
|
||||
'show_home' => ( genesis_get_option( 'trestle_include_home_link' ) && genesis_get_option( 'trestle_home_link_text' ) ) ? do_shortcode( genesis_get_option( 'trestle_home_link_text' ) ): genesis_get_option( 'trestle_include_home_link' ),
|
||||
'menu_class' => 'auto-menu'
|
||||
);
|
||||
|
||||
$ul_class = 'menu genesis-nav-menu menu-primary';
|
||||
|
||||
$menu_args = new stdClass();
|
||||
|
||||
$menu_args->theme_location = 'primary';
|
||||
|
||||
$nav_items = wp_page_menu( $args );
|
||||
|
||||
// Remove opening <div class="auto-nav"><ul>
|
||||
$nav_items = preg_replace( '/<div\s*.*auto-menu[^>]*>\s*<ul>/', '', $nav_items );
|
||||
|
||||
// Remove closing </ul></div>
|
||||
$nav_items = preg_replace( '/<\/ul>\s*<\/div>/', '', $nav_items );
|
||||
}
|
||||
|
||||
return $nav_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces standard Genesis navigation extras with custom input navigation extras.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param string $nav_items <li> list of menu items.
|
||||
* @param stdClass $menu_args Arguments for the menu.
|
||||
* @param string $nav_items <li> list of menu items.
|
||||
* @param stdClass $menu_args Arguments for the menu.
|
||||
* @return string <li> list of menu items with custom navigation extras <li> 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 . '<li class="right custom">' . do_shortcode( genesis_get_option( 'trestle_custom_nav_extras_text' ) ) . '</li>';
|
||||
if ( 'primary' == $menu_args->theme_location && genesis_get_option( 'trestle_custom_nav_extras_text' ) ) {
|
||||
return $nav_items . '<li class="right custom">' . get_search_form( false ) . '</li>';
|
||||
}
|
||||
|
||||
return $nav_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a placeholder navigation menu object.
|
||||
*
|
||||
* When using Trestle's auto-generated navigation feature,
|
||||
* it is necessary to ensure that some nav menu object is
|
||||
* selected as primary otherwise no navigation will be generated.
|
||||
*
|
||||
* @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
|
||||
if ( 1 == genesis_get_option( 'trestle_auto_nav' ) && ! wp_get_nav_menu_object( $trestle_nav_title ) ) {
|
||||
wp_create_nav_menu( $trestle_nav_title );
|
||||
}
|
||||
|
||||
// Assign placeholder menu to 'primary' if auto-nav is selected and there is no current primary menu
|
||||
if ( 1 == genesis_get_option( 'trestle_auto_nav' ) && ! wp_get_nav_menu_object( $trestle_nav_title ) && ! has_nav_menu( 'primary' ) ) {
|
||||
$menu_locations = get_theme_mod( 'nav_menu_locations' );
|
||||
$menu_locations['primary'] = wp_get_nav_menu_object( $trestle_nav_title )->term_id;
|
||||
set_theme_mod( 'nav_menu_locations', $menu_locations );
|
||||
}
|
||||
|
||||
// Remove placeholder menu if auto-nav is disabled
|
||||
$menus = get_registered_nav_menus();
|
||||
|
||||
if ( 1 != genesis_get_option( 'trestle_auto_nav' ) && wp_get_nav_menu_object( $trestle_nav_title ) && $trestle_nav_title != $menus['primary'] )
|
||||
wp_delete_nav_menu( $trestle_nav_title );
|
||||
}
|
||||
|
||||
|
||||
/*===========================================
|
||||
* Posts & Pages
|
||||
@@ -420,8 +357,9 @@ 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 '… <a class="more-link" title="' . $custom_text . '" href="' . get_permalink() . '">' . $custom_text . '</a>';
|
||||
else
|
||||
} else {
|
||||
return $default_text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ jQuery( document ).ready( function( $ ) {
|
||||
$( 'li:first-child' ).addClass( 'first' );
|
||||
$( 'ul, ol' ).parent( 'li' ).addClass( 'parent' );
|
||||
|
||||
// Mobile header toggle buttons
|
||||
// Create mobile header toggle buttons
|
||||
$( '.site-header .title-area' ).after( '<div class="toggle-buttons" />' );
|
||||
$( '.site-header .widget-area, .nav-primary' ).each( function( i ) {
|
||||
|
||||
@@ -58,7 +58,7 @@ jQuery( document ).ready( function( $ ) {
|
||||
$target.addClass( 'toggle-target-' + i );
|
||||
});
|
||||
|
||||
// Toggle widget areas and primary nav
|
||||
// A widget areas and primary nav mobile toggle functionality
|
||||
$( '.site-header .toggle-button' ).click( function( event ) {
|
||||
|
||||
// Prevent default behavior
|
||||
@@ -70,11 +70,9 @@ jQuery( document ).ready( function( $ ) {
|
||||
// Get toggle button that was clicked
|
||||
$button = $( this );
|
||||
|
||||
//Remove focus
|
||||
$button.blur();
|
||||
|
||||
// Match the button to the right target
|
||||
$target = $( '.toggle-target-' + $button.attr( 'id' ).match( /\d+/ ) );
|
||||
console.log( 'Target: ' + $target.attr('class'));
|
||||
|
||||
// Toggle buttons
|
||||
$button.toggleClass( 'open' );
|
||||
@@ -82,7 +80,11 @@ jQuery( document ).ready( function( $ ) {
|
||||
|
||||
// Toggle targets
|
||||
$target.toggleClass( 'open' );
|
||||
$( '[class^="toggle-target"]' ).not( $target ).removeClass( 'open' );
|
||||
$( '[class*="toggle-target"]' ).not( $target ).removeClass( 'open' );
|
||||
|
||||
// Remove focus
|
||||
$button.blur();
|
||||
|
||||
});
|
||||
|
||||
// Mobile navigation icons
|
||||
@@ -137,4 +139,4 @@ jQuery( document ).ready( function( $ ) {
|
||||
|
||||
});
|
||||
|
||||
}); /* end of page load scripts */
|
||||
}); /* end of page load scripts */
|
||||
@@ -102,7 +102,7 @@ function trestle_date( $atts ) {
|
||||
return date( $format );
|
||||
}
|
||||
|
||||
add_shortcode( 'blockquote', 'igg_blockquote_shortcode' );
|
||||
add_shortcode( 'blockquote', 'trestle_blockquote_shortcode' );
|
||||
/**
|
||||
* Blockquote
|
||||
*
|
||||
@@ -114,7 +114,7 @@ add_shortcode( 'blockquote', 'igg_blockquote_shortcode' );
|
||||
*
|
||||
* @return string Shortcode output.
|
||||
*/
|
||||
function igg_blockquote_shortcode( $atts, $content = null ) {
|
||||
function trestle_blockquote_shortcode( $atts, $content = null ) {
|
||||
|
||||
$atts = shortcode_atts( array(
|
||||
'citation' => '',
|
||||
|
||||
Reference in New Issue
Block a user