mirror of
https://github.com/10h30/trestle.git
synced 2026-07-11 18:56:07 +09:00
Complete switch over to Trestle settings.
This commit is contained in:
+33
-15
@@ -7,23 +7,10 @@
|
||||
* @package Trestle
|
||||
*/
|
||||
|
||||
add_action( 'admin_enqueue_scripts', 'trestle_admin_actions' );
|
||||
/**
|
||||
* Loads admin scripts and styles.
|
||||
* Set up Trestle default settings.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function trestle_admin_actions() {
|
||||
|
||||
// Include the main stylesheet in the editor
|
||||
add_editor_style( get_stylesheet_uri() );
|
||||
}
|
||||
|
||||
//add_filter( 'after_setup_theme', 'trestle_settings_defaults' );
|
||||
/**
|
||||
* Sets up Trestle default settings.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @return array Genesis settings updated to include Trestle defaults.
|
||||
*/
|
||||
@@ -70,6 +57,37 @@ function trestle_settings_defaults() {
|
||||
|
||||
// Update options with defaults.
|
||||
update_option( TRESTLE_SETTINGS_FIELD, $options );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper function to get Trestle options.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @uses genesis_get_option()
|
||||
*
|
||||
* @return mixed Trestle option value.
|
||||
*/
|
||||
function trestle_get_option( $key, $setting = null, $use_cache = true ) {
|
||||
|
||||
// Set default to TRESTLE_SETTINGS_FIELD.
|
||||
$setting = $setting ? $setting : TRESTLE_SETTINGS_FIELD;
|
||||
|
||||
return genesis_get_option( $key, $setting, false );
|
||||
|
||||
}
|
||||
|
||||
add_action( 'admin_enqueue_scripts', 'trestle_admin_actions' );
|
||||
/**
|
||||
* Loads admin scripts and styles.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function trestle_admin_actions() {
|
||||
|
||||
// Include the main stylesheet in the editor
|
||||
add_editor_style( get_stylesheet_uri() );
|
||||
|
||||
}
|
||||
|
||||
add_action( 'tgmpa_register', 'trestle_register_required_plugins' );
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
/**
|
||||
* JavaScript for the Customizer Preview
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
( function( $ ) {
|
||||
|
||||
// Layout.
|
||||
wp.customize( 'trestle-settings[layout]', function( value ) {
|
||||
value.bind( function( value ) {
|
||||
|
||||
var $body = $( 'body' );
|
||||
|
||||
switch ( value ) {
|
||||
case 'solid':
|
||||
$body.removeClass( 'bubble' );
|
||||
break;
|
||||
case 'bubble':
|
||||
$body.addClass( 'bubble' );
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// Custom logo.
|
||||
wp.customize( 'trestle-settings[logo_url]', function( value ) {
|
||||
value.bind( function( url ) {
|
||||
|
||||
var $body = $( 'body' );
|
||||
|
||||
if ( 0 === $.trim( url ).length ) {
|
||||
$body.removeClass( 'has-logo' );
|
||||
$( '.site-title a.image-link' ).remove();
|
||||
} else {
|
||||
$body.addClass( 'has-logo' );
|
||||
$( '.site-title a.image-link' ).remove();
|
||||
$( '.site-title' ).append( '<a href="/" class="image-link"><img class="logo logo-full show" src="' + url + '" /></a>' );
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// Favicon.
|
||||
wp.customize( 'trestle-settings[favicon_url]', function( value ) {
|
||||
value.bind( function( url ) {
|
||||
|
||||
var $faviconElem = $( 'link[rel="Shortcut Icon"]' );
|
||||
$faviconElem.attr( 'href', url );
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// Primary Nav Location.
|
||||
wp.customize( 'trestle-settings[nav_primary_location]', function( value ) {
|
||||
value.bind( function( value ) {
|
||||
|
||||
var $body = $( 'body' );
|
||||
var $nav = $( '.nav-primary' );
|
||||
|
||||
switch ( value ) {
|
||||
case 'full':
|
||||
$body.removeClass( 'nav-primary-location-header' )
|
||||
.addClass( 'nav-primary-location-full' );
|
||||
$nav.remove().insertAfter( '.site-header' );
|
||||
break;
|
||||
case 'header':
|
||||
$body.removeClass( 'nav-primary-location-full' )
|
||||
.addClass( 'nav-primary-location-header' );
|
||||
$nav.remove().appendTo( '.site-header .wrap' );
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// Custom Read More Link Text.
|
||||
wp.customize( 'trestle-settings[read_more_text]', function( value ) {
|
||||
value.bind( function( value ) {
|
||||
|
||||
$( 'a.more-link' ).html( value );
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// External Links.
|
||||
wp.customize( 'trestle-settings[external_link_icons]', function( value ) {
|
||||
value.bind( function( value ) {
|
||||
|
||||
var $body = $( 'body' );
|
||||
|
||||
if ( value ) {
|
||||
$body.addClass( 'external-link-icons' );
|
||||
} else {
|
||||
$body.removeClass( 'external-link-icons' );
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// Email Links.
|
||||
wp.customize( 'trestle-settings[email_link_icons]', function( value ) {
|
||||
value.bind( function( value ) {
|
||||
|
||||
var $body = $( 'body' );
|
||||
|
||||
if ( value ) {
|
||||
$body.addClass( 'email-link-icons' );
|
||||
} else {
|
||||
$body.removeClass( 'email-link-icons' );
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// PDF Links.
|
||||
wp.customize( 'trestle-settings[pdf_link_icons]', function( value ) {
|
||||
value.bind( function( value ) {
|
||||
|
||||
var $body = $( 'body' );
|
||||
|
||||
if ( value ) {
|
||||
$body.addClass( 'pdf-link-icons' );
|
||||
} else {
|
||||
$body.removeClass( 'pdf-link-icons' );
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// Doc Links.
|
||||
wp.customize( 'trestle-settings[doc_link_icons]', function( value ) {
|
||||
value.bind( function( value ) {
|
||||
|
||||
var $body = $( 'body' );
|
||||
|
||||
if ( value ) {
|
||||
$body.addClass( 'doc-link-icons' );
|
||||
} else {
|
||||
$body.removeClass( 'doc-link-icons' );
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
@@ -2,33 +2,16 @@
|
||||
/**
|
||||
* Trestle Customizer Controls.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @package Trestle
|
||||
*/
|
||||
|
||||
add_action( 'customize_preview_init', 'trestle_customizer_preview_js' );
|
||||
/**
|
||||
* Enqueue scripts for the site preview iframe on the customizer screen.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function trestle_customizer_preview_js() {
|
||||
|
||||
wp_enqueue_script(
|
||||
'trestle_customizer',
|
||||
get_stylesheet_directory_uri() . '/includes/admin/customizer.js',
|
||||
array( 'jquery', 'customize-preview' ), // Dependencies
|
||||
null, // Version
|
||||
true // Load in Footer
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'customize_register', 'trestle_customizer_controls' );
|
||||
/**
|
||||
* Register Trestle's controls.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param $wp_customize The Customizer Object.
|
||||
*/
|
||||
@@ -51,9 +34,8 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'trestle-settings[layout]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'layout', 'trestle-settings' ),
|
||||
'default' => trestle_get_option( 'layout' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
)
|
||||
);
|
||||
@@ -75,9 +57,8 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'trestle-settings[logo_url]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'logo_url', 'trestle-settings' ),
|
||||
'default' => trestle_get_option( 'logo_url' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
)
|
||||
@@ -98,9 +79,8 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'trestle-settings[logo_url_mobile]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'logo_url_mobile', 'trestle-settings' ),
|
||||
'default' => trestle_get_option( 'logo_url_mobile' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
)
|
||||
@@ -121,9 +101,8 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'trestle-settings[favicon_url]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'favicon_url', 'trestle-settings' ),
|
||||
'default' => trestle_get_option( 'favicon_url' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
)
|
||||
@@ -144,9 +123,8 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'trestle-settings[nav_primary_location]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'nav_primary_location', 'trestle-settings' ),
|
||||
'default' => trestle_get_option( 'nav_primary_location' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
)
|
||||
);
|
||||
@@ -168,9 +146,8 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'trestle-settings[search_in_nav]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'search_in_nav', 'trestle-settings' ),
|
||||
'default' => trestle_get_option( 'search_in_nav' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
)
|
||||
);
|
||||
@@ -188,9 +165,8 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'trestle-settings[read_more_text]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'read_more_text', 'trestle-settings' ),
|
||||
'default' => trestle_get_option( 'read_more_text' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'wp_kses_post',
|
||||
)
|
||||
@@ -208,9 +184,8 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'trestle-settings[revisions_number]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'revisions_number', 'trestle-settings' ),
|
||||
'default' => trestle_get_option( 'revisions_number' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
)
|
||||
);
|
||||
@@ -242,9 +217,8 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'trestle-settings[footer_widgets_number]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'footer_widgets_number', 'trestle-settings' ),
|
||||
'default' => trestle_get_option( 'footer_widgets_number' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
)
|
||||
);
|
||||
@@ -289,9 +263,8 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'trestle-settings[external_link_icons]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'external_link_icons', 'trestle-settings' ),
|
||||
'default' => trestle_get_option( 'external_link_icons' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
)
|
||||
);
|
||||
@@ -309,9 +282,8 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'trestle-settings[email_link_icons]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'email_link_icons', 'trestle-settings' ),
|
||||
'default' => trestle_get_option( 'email_link_icons' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
)
|
||||
);
|
||||
@@ -329,9 +301,8 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'trestle-settings[pdf_link_icons]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'pdf_link_icons', 'trestle-settings' ),
|
||||
'default' => trestle_get_option( 'pdf_link_icons' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
)
|
||||
);
|
||||
@@ -349,9 +320,8 @@ function trestle_customizer_controls( $wp_customize ) {
|
||||
$wp_customize->add_setting(
|
||||
'trestle-settings[doc_link_icons]',
|
||||
array(
|
||||
'default' => genesis_get_option( 'doc_link_icons', 'trestle-settings' ),
|
||||
'default' => trestle_get_option( 'doc_link_icons' ),
|
||||
'type' => 'option',
|
||||
'transport' => 'postMessage',
|
||||
'capability' => 'edit_theme_options',
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user