added textdomain, added ability to change nav menu button text along with default value

This commit is contained in:
Mickey Kay
2013-11-14 12:42:45 -08:00
parent fdae4e5958
commit 2c2b86f147
4 changed files with 105 additions and 36 deletions
+3
View File
@@ -21,6 +21,9 @@ function trestle_theme_setup() {
define( 'CHILD_THEME_URL', 'http://demo.mightyminnow.com/theme/trestle/' );
define( 'CHILD_THEME_VERSION', '1.0' );
// Load theme text domain
load_theme_textdomain( 'trestle', get_template_directory() . '/languages');
// Add HTML5 markup structure
add_theme_support( 'html5' );
+35 -9
View File
@@ -9,16 +9,33 @@
* 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' );
@@ -29,6 +46,8 @@ add_filter( 'genesis_theme_settings_defaults', 'trestle_custom_defaults' );
*/
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
+14 -8
View File
@@ -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>&nbsp;&nbsp;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
===========================================*/
+48 -14
View File
@@ -6,6 +6,8 @@
Author: MIGHTYminnow
Author URI: http://www.mightyminnow.com/
Version: 1.0
Tags: genesis, mobile, first, responsive, clean, black, orange, white, one-column, two-columns, three-columns, left-sidebar, right-sidebar, fixed-width, custom-menu, full-width-template, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready
Text Domain: trestle;
*/
/* Table of Contents
@@ -277,13 +279,13 @@ h6 {
}
h1 {
font-size: 36px;
font-size: 3.6rem;
font-size: 28px;
font-size: 2.8rem;
}
h2 {
font-size: 30px;
font-size: 3rem;
font-size: 24px;
font-size: 2.4rem;
}
.entry-content h2 {
@@ -291,20 +293,20 @@ h2 {
}
h3 {
font-size: 24px;
font-size: 2.4rem;
}
h4 {
font-size: 20px;
font-size: 2rem;
}
h5 {
h4 {
font-size: 18px;
font-size: 1.8rem;
}
h5 {
font-size: 16px;
font-size: 1.6rem;
}
h6 {
font-size: 16px;
font-size: 1.6rem;
@@ -421,7 +423,7 @@ input:hover[type="submit"],
}
.arrow-left:before {
content: "\f0a9\00a0\00a0";
content: "\f0a8\00a0\00a0";
font-family: FontAwesome;
}
@@ -705,8 +707,6 @@ img.alignright,
--------------------------------------------- */
.entry-title {
font-size: 36px;
font-size: 3.6rem;
line-height: 1;
}
@@ -1545,7 +1545,41 @@ Media Queries
}
@media only screen and (min-width: 768px) {
@media only screen and (min-width: 480px) {
h1 {
font-size: 36px;
font-size: 3.6rem;
}
h2 {
font-size: 30px;
font-size: 3rem;
}
h3 {
font-size: 24px;
font-size: 2.4rem;
}
h4 {
font-size: 20px;
font-size: 2rem;
}
h5 {
font-size: 18px;
font-size: 1.8rem;
}
h6 {
font-size: 16px;
font-size: 1.6rem;
}
}
@media (min-width: 768px) {
body {
background-color: #f5f5f5;