mirror of
https://github.com/10h30/trestle.git
synced 2026-06-05 15:09:35 +09:00
added textdomain, added ability to change nav menu button text along with default value
This commit is contained in:
+39
-13
@@ -4,31 +4,50 @@
|
||||
*
|
||||
* Modified from: http://www.billerickson.net/genesis-theme-options/
|
||||
===========================================*/
|
||||
|
||||
|
||||
/**
|
||||
* Register Defaults
|
||||
*
|
||||
* @param array $defaults
|
||||
* @return array modified defaults
|
||||
*
|
||||
* @return array $defaults updated defaults
|
||||
*/
|
||||
|
||||
function trestle_custom_defaults( $defaults ) {
|
||||
|
||||
$defaults['auto_nav'] = '0';
|
||||
$defaults['include_home_link'] = '1';
|
||||
$defaults['nav_extras'] = '1';
|
||||
|
||||
|
||||
// Trestle default key/value pairs
|
||||
$trestle_defaults = array(
|
||||
'trestle_auto_nav' => '0',
|
||||
'trestle_include_home_link' => '0',
|
||||
'trestle_nav_button_text' => __( '[icon name="icon-list-ul"] Navigation', 'trestle' ),
|
||||
);
|
||||
|
||||
// Populate Trestle settings with default values if they don't yet exist
|
||||
$options = get_option( GENESIS_SETTINGS_FIELD );
|
||||
foreach ( $trestle_defaults as $k => $v ) {
|
||||
|
||||
// Add defaults to Genesis default settings array
|
||||
$defaults[$k] = $v;
|
||||
|
||||
// Update actual options if they don't yet exist
|
||||
if ( !array_key_exists( $k, $options ) )
|
||||
$options[$k] = $v;
|
||||
|
||||
}
|
||||
update_option( GENESIS_SETTINGS_FIELD, $options );
|
||||
|
||||
// Return modified default array
|
||||
return $defaults;
|
||||
}
|
||||
add_filter( 'genesis_theme_settings_defaults', 'trestle_custom_defaults' );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sanitization
|
||||
*/
|
||||
|
||||
function trestle_register_social_sanitization_filters() {
|
||||
|
||||
// No HTML
|
||||
genesis_add_option_filter(
|
||||
'no_html',
|
||||
GENESIS_SETTINGS_FIELD,
|
||||
@@ -38,11 +57,12 @@ function trestle_register_social_sanitization_filters() {
|
||||
)
|
||||
);
|
||||
|
||||
// Safe HTML
|
||||
genesis_add_option_filter(
|
||||
'safe_html',
|
||||
GENESIS_SETTINGS_FIELD,
|
||||
array(
|
||||
'footer_text',
|
||||
'nav_button_text',
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -65,6 +85,7 @@ function trestle_register_settings_box( $_genesis_theme_settings_pagehook ) {
|
||||
// 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');
|
||||
|
||||
@@ -76,8 +97,12 @@ 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>
|
||||
<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_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>
|
||||
<p>
|
||||
<?php _e('Text for mobile navigation button (shortcodes can be included):', 'trestle' ); ?></label><br />
|
||||
<input class="widefat" type="text" id="<?php echo GENESIS_SETTINGS_FIELD; ?>[trestle_nav_button_text]" name="<?php echo GENESIS_SETTINGS_FIELD; ?>[trestle_nav_button_text]" value="<?php echo esc_attr( genesis_get_option('trestle_nav_button_text') ); ?>" /> <label for="<?php echo GENESIS_SETTINGS_FIELD; ?>[trestle_nav_button_text]">
|
||||
</p>
|
||||
<?php
|
||||
|
||||
@@ -97,7 +122,8 @@ function trestle_navigation_settings_box() {
|
||||
}
|
||||
|
||||
// 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'] )
|
||||
$menus = get_registered_nav_menus();
|
||||
if ( 1 != genesis_get_option( 'auto_nav' ) && wp_get_nav_menu_object( $trestle_nav_title ) && $trestle_nav_title != $menus['primary'] )
|
||||
wp_delete_nav_menu( $trestle_nav_title );
|
||||
|
||||
// Output default Genesis nav options
|
||||
|
||||
@@ -24,6 +24,7 @@ function trestle_header_actions() {
|
||||
* Admin styles and scripts
|
||||
===========================================*/
|
||||
|
||||
// Add admin stylesheet (doesn't yet exist)
|
||||
function trestle_admin_actions() {
|
||||
add_editor_style( get_stylesheet_directory_uri() . '/lib/admin/admin.css' );
|
||||
}
|
||||
@@ -192,6 +193,7 @@ function trestle_register_required_plugins() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*===========================================
|
||||
* Auto & Mobile Navigation
|
||||
===========================================*/
|
||||
@@ -199,7 +201,7 @@ function trestle_register_required_plugins() {
|
||||
function trestle_nav_modifications() {
|
||||
|
||||
// Auto-generate nav if Genesis theme setting is checked
|
||||
if ( 1 == genesis_get_option( 'auto_nav' ) ) {
|
||||
if ( 1 == genesis_get_option( 'trestle_auto_nav' ) ) {
|
||||
|
||||
// Remove existing nav
|
||||
remove_action( 'genesis_after_header', 'genesis_do_nav' );
|
||||
@@ -209,7 +211,7 @@ function trestle_nav_modifications() {
|
||||
|
||||
$args = array(
|
||||
'echo' => false,
|
||||
'show_home' => genesis_get_option( 'include_home_link' ),
|
||||
'show_home' => genesis_get_option( 'trestle_include_home_link' ),
|
||||
'menu_class' => 'auto-menu'
|
||||
);
|
||||
|
||||
@@ -257,10 +259,16 @@ function trestle_nav_modifications() {
|
||||
|
||||
// Add mobile menu button
|
||||
function trestle_add_mobile_nav() {
|
||||
if ( 1 == genesis_get_option( 'auto_nav' ) || has_nav_menu( 'primary' ) )
|
||||
echo '<a id="menu-button" class="button" href="javascript: void(0)"><i class="icon-list-ul"></i> Navigation</a>';
|
||||
|
||||
// Only add the button if there is a primary menu
|
||||
if ( 1 == genesis_get_option( 'trestle_auto_nav' ) || has_nav_menu( 'primary' ) ) {
|
||||
|
||||
echo '<a id="menu-button" class="button" href="javascript: void(0)">' . do_shortcode( genesis_get_option('trestle_nav_button_text') ) . '</a>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*===========================================
|
||||
* Actions & Filters
|
||||
===========================================*/
|
||||
@@ -271,13 +279,11 @@ function no_jquery( $classes ) {
|
||||
return $classes;
|
||||
}
|
||||
|
||||
|
||||
/*===========================================
|
||||
* Footer
|
||||
===========================================*/
|
||||
|
||||
function trestle_custom_footer($output) {
|
||||
return $output . '<p class="mm">[footer_childtheme_link before=""] by <a href="http://mightyminnow.com">MIGHTYminnow</a></p>';
|
||||
}
|
||||
|
||||
/*===========================================
|
||||
* Shortcodes
|
||||
===========================================*/
|
||||
}
|
||||
Reference in New Issue
Block a user