switched over to genesis_setup hook for functions.php, moved function defs to trestle-functions.php

This commit is contained in:
Mickey Kay
2013-11-07 14:15:57 -08:00
parent 6b098b0055
commit fd863f19a6
7 changed files with 640 additions and 288 deletions
-107
View File
@@ -1,107 +0,0 @@
<?php
/*===========================================
* Trestle Custom Theme Settings
*
* Modified from: http://www.billerickson.net/genesis-theme-options/
===========================================*/
/**
* Register Defaults
*
* @param array $defaults
* @return array modified defaults
*
*/
function trestle_custom_defaults( $defaults ) {
$defaults['auto_nav'] = '0';
$defaults['include_home_link'] = '1';
$defaults['nav_extras'] = '1';
return $defaults;
}
add_filter( 'genesis_theme_settings_defaults', 'trestle_custom_defaults' );
/**
* Sanitization
*/
function trestle_register_social_sanitization_filters() {
genesis_add_option_filter(
'no_html',
GENESIS_SETTINGS_FIELD,
array(
'auto_nav',
'include_home_link',
)
);
genesis_add_option_filter(
'safe_html',
GENESIS_SETTINGS_FIELD,
array(
'footer_text',
)
);
}
add_action( 'genesis_settings_sanitizer_init', 'trestle_register_social_sanitization_filters' );
/**
* Register Metabox
*
* @param string $_genesis_theme_settings_pagehook
*/
function trestle_register_settings_box( $_genesis_theme_settings_pagehook ) {
global $_genesis_admin_settings;
// Remove default Genesis nav metabox
remove_meta_box('genesis-theme-settings-nav', $_genesis_admin_settings->pagehook, 'main');
// Call our own custom nav metabox which combines our own settings with Genesis'
add_meta_box('mm-navigation-settings', __( 'Navigation', 'trestle' ), 'trestle_navigation_settings_box', $_genesis_theme_settings_pagehook, 'main', 'high');
}
add_action('genesis_theme_settings_metaboxes', 'trestle_register_settings_box');
/**
* Create Navigation Metabox
*/
function trestle_navigation_settings_box() {
?>
<h4><?php _e( 'Primary Navigation Options', 'trestle' ) ?></h4>
<p>
<input type="checkbox" id="<?php echo GENESIS_SETTINGS_FIELD; ?>[auto_nav]" name="<?php echo GENESIS_SETTINGS_FIELD; ?>[auto_nav]" value="1" <?php checked( esc_attr( genesis_get_option('auto_nav') ), 1); ?> /> <label for="<?php echo GENESIS_SETTINGS_FIELD; ?>[auto_nav]"><?php _e(' Automatically generate nav menu (replaces custom/manual menu with auto-generated menu)', 'trestle' ); ?></label><br />
<input type="checkbox" id="<?php echo GENESIS_SETTINGS_FIELD; ?>[include_home_link]" name="<?php echo GENESIS_SETTINGS_FIELD; ?>[include_home_link]" value="1" <?php checked( esc_attr( genesis_get_option('include_home_link') ), 1); ?> /> <label for="<?php echo GENESIS_SETTINGS_FIELD; ?>[include_home_link]"><?php _e( 'Include Home Link', 'trestle' ); ?></label>
</p>
<?php
$trestle_nav_title = __( 'Trestle Auto Nav Placeholder', 'trestle' );
// 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( 'auto_nav' ) && !wp_get_nav_menu_object( $trestle_nav_title ) && !has_nav_menu( 'primary' ) ) {
// Create placholder menu
wp_create_nav_menu( $trestle_nav_title );
// Assign placeholder menu to '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
if ( 1 != genesis_get_option( 'auto_nav' ) && wp_get_nav_menu_object( $trestle_nav_title ) && $trestle_nav_title != get_registered_nav_menus()['primary'] )
wp_delete_nav_menu( $trestle_nav_title );
// Output default Genesis nav options
$genesis_settings_object = new Genesis_Admin_Settings;
$genesis_settings_object->nav_box();
}
File diff suppressed because it is too large Load Diff
-54
View File
@@ -1,54 +0,0 @@
// Executes when the document is ready
jQuery(document).ready(function() {
// Remove .no-jquery body class
jQuery('body').removeClass('no-jquery');
// Get our URL
var h = window.location.host.toLowerCase();
// External Links
jQuery('[href^="http://"],[href^="https://"]').not('[href*="' + h + '"], .button, .menu-primary a').addClass('externalLink').attr("target", "_blank");
// Add classes to different types of media links
jQuery('a[href^="mailto:"]:not(.button)').addClass('emailLink');
jQuery('a[href*=".pdf"]:not(.button)').attr({"target":"_blank"}).addClass('pdfLink');
jQuery('a[href*=".doc"]:not(.button)').attr({"target":"_blank"}).addClass('docLink');
jQuery('img').parent('a:not(.button)').addClass('imageLink').removeClass('externalLink');
// Add classes to parts of lists
jQuery('li:last-child').addClass('last');
jQuery('li:first-child').addClass('first');
jQuery('ul, ol').parent('li').addClass('parent');
// Mobile navigation button
jQuery('#menu-button').click(function() {
var button = jQuery(this);
button.toggleClass('open');
jQuery('.menu-primary').slideToggle();
});
// Mobile navigation icons
var closedIcon = '+';
var openIcon = '-';
jQuery('.genesis-nav-menu .parent:not(.current-menu-item, .current_page_item, .current_page_parent, .current_page_ancestor) > a').after('<a class="sub-icon" href="javascript:void()">' + closedIcon + '</a>');
jQuery('.genesis-nav-menu .parent.current-menu-item > a, .genesis-nav-menu .parent.current_page_item > a, .genesis-nav-menu .parent.current_page_parent > a, .genesis-nav-menu .parent.current_page_ancestor > a').after('<a class="sub-icon" href="javscript: void()">' + openIcon + '</a>');
// Mobile navigation expand/contract functionality
jQuery('.sub-icon').click(function() {
var icon = jQuery(this);
icon.next('ul').slideToggle();
if ( icon.text().indexOf( closedIcon ) !== -1 )
icon.text(openIcon);
else if ( icon.text().indexOf( openIcon ) !== -1 )
icon.text(closedIcon);
});
}); /* end of as page load scripts */
// Executes when complete page is fully loaded, including all frames, objects, and images
jQuery(window).load(function() {
});