Added auto-menu depth control.

This commit is contained in:
MickeyKay
2014-05-08 12:05:05 -07:00
parent a0fdd02eef
commit e898968b18
2 changed files with 13 additions and 1 deletions
+12 -1
View File
@@ -36,6 +36,7 @@ function trestle_custom_defaults( $defaults ) {
$trestle_defaults = array(
'trestle_layout' => 'solid',
'trestle_auto_nav' => 0,
'trestle_auto_nav_depth' => 0,
'trestle_include_home_link' => 0,
'trestle_home_link_text' => __( 'Home', 'trestle' ),
'trestle_nav_button_text' => '[icon name="icon-list-ul"] ' . __( 'Navigation', 'trestle' ),
@@ -91,6 +92,7 @@ function trestle_register_social_sanitization_filters() {
'absint',
GENESIS_SETTINGS_FIELD,
array(
'trestle_auto_nav_depth',
'trestle_revisions_number',
'trestle_footer_widgets_number',
'trestle_equal_cols_breakpoint',
@@ -156,7 +158,16 @@ function trestle_settings_box() {
<h4><?php _e( 'Primary Navigation', 'trestle' ) ?></h4>
<p>
<input type="checkbox" id="<?php echo GENESIS_SETTINGS_FIELD; ?>[trestle_auto_nav]" name="<?php echo GENESIS_SETTINGS_FIELD; ?>[trestle_auto_nav]" value="1" <?php checked( esc_attr( genesis_get_option( 'trestle_auto_nav' ) ), 1); ?> /> <label for="<?php echo GENESIS_SETTINGS_FIELD; ?>[trestle_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; ?>[trestle_auto_nav]" name="<?php echo GENESIS_SETTINGS_FIELD; ?>[trestle_auto_nav]" value="1" <?php checked( esc_attr( genesis_get_option( 'trestle_auto_nav' ) ), 1); ?> /> <label for="<?php echo GENESIS_SETTINGS_FIELD; ?>[trestle_auto_nav]"><?php _e( 'Automatically generate nav menu', 'trestle' ); ?></label>
<label for="<?php echo GENESIS_SETTINGS_FIELD; ?>[trestle_auto_nav_depth]"><?php _e( 'with a depth of', 'trestle' ) ?>: </label>
<select name="<?php echo GENESIS_SETTINGS_FIELD; ?>[trestle_auto_nav_depth]" />
<option value="0" <?php selected( esc_attr( genesis_get_option( 'trestle_auto_nav_depth' ) ), '0' ); ?> >Unlimited</option>
<?php
for( $i=1; $i<=10; $i++ ) {
echo '<option value="' . $i . '" ' . selected( esc_attr( genesis_get_option( 'trestle_auto_nav_depth' ) ), $i, false ) . '>' . $i . '</option>' . "\n";
}
?>
</select><br />
<input type="checkbox" id="<?php echo GENESIS_SETTINGS_FIELD; ?>[trestle_include_home_link]" name="<?php echo GENESIS_SETTINGS_FIELD; ?>[trestle_include_home_link]" value="1" <?php checked( esc_attr( genesis_get_option( 'trestle_include_home_link' ) ), 1); ?> /> <label for="<?php echo GENESIS_SETTINGS_FIELD; ?>[trestle_include_home_link]"><?php _e( 'Include home link', 'trestle' ); ?></label>
</p>
+1
View File
@@ -115,6 +115,7 @@ function trestle_add_mobile_nav() {
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'