2015-03-19 15:14:31 -07:00
|
|
|
<?php
|
|
|
|
|
/**
|
2015-04-30 12:24:30 -07:00
|
|
|
* Trestle Customizer Controls.
|
2015-03-19 15:14:31 -07:00
|
|
|
*
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
*
|
|
|
|
|
* @package Trestle
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
add_action( 'customize_preview_init', 'trestle_customizer_preview_js' );
|
|
|
|
|
/**
|
2015-04-30 12:24:30 -07:00
|
|
|
* Enqueue scripts for the site preview iframe on the customizer screen.
|
2015-03-19 15:14:31 -07:00
|
|
|
*
|
|
|
|
|
* @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' );
|
|
|
|
|
/**
|
2015-04-30 12:24:30 -07:00
|
|
|
* Register Trestle's controls.
|
2015-03-19 15:14:31 -07:00
|
|
|
*
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
*
|
2015-04-30 12:24:30 -07:00
|
|
|
* @param $wp_customize The Customizer Object.
|
2015-03-19 15:14:31 -07:00
|
|
|
*/
|
|
|
|
|
function trestle_customizer_controls( $wp_customize ) {
|
|
|
|
|
|
|
|
|
|
/**
|
2015-04-30 12:24:30 -07:00
|
|
|
* Trestle Settings Section.
|
2015-03-19 15:14:31 -07:00
|
|
|
*/
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// Add the section.
|
2015-03-19 15:14:31 -07:00
|
|
|
$wp_customize->add_section(
|
|
|
|
|
'trestle_settings_section',
|
|
|
|
|
array(
|
|
|
|
|
'title' => __( 'Trestle Settings', 'trestle' ),
|
|
|
|
|
'priority' => 160,
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// Layout.
|
2015-03-19 15:14:31 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 12:24:30 -07:00
|
|
|
'trestle-settings[layout]',
|
2015-03-19 15:14:31 -07:00
|
|
|
array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'default' => genesis_get_option( 'layout', 'trestle-settings' ),
|
|
|
|
|
'type' => 'option',
|
|
|
|
|
'transport' => 'postMessage',
|
|
|
|
|
'capability' => 'edit_theme_options',
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
'trestle_layout_control',
|
|
|
|
|
array(
|
|
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 12:24:30 -07:00
|
|
|
'settings' => 'trestle-settings[layout]',
|
2015-03-19 15:14:31 -07:00
|
|
|
'label' => __( 'Layout', 'trestle' ),
|
|
|
|
|
'type' => 'radio',
|
|
|
|
|
'choices' => array(
|
|
|
|
|
'bubble' => __( 'Bubble', 'trestle' ),
|
|
|
|
|
'solid' => __( 'Solid', 'trestle' ),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// Upload a logo.
|
2015-03-19 15:14:31 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 12:24:30 -07:00
|
|
|
'trestle-settings[logo_url]',
|
2015-03-19 15:14:31 -07:00
|
|
|
array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'default' => genesis_get_option( 'logo_url', 'trestle-settings' ),
|
|
|
|
|
'type' => 'option',
|
|
|
|
|
'transport' => 'postMessage',
|
|
|
|
|
'capability' => 'edit_theme_options',
|
|
|
|
|
'sanitize_callback' => 'esc_url_raw',
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
new WP_Customize_Image_Control(
|
|
|
|
|
$wp_customize,
|
|
|
|
|
'trestle_logo_control',
|
|
|
|
|
array(
|
|
|
|
|
'label' => __( 'Upload a logo', 'trestle' ),
|
|
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 12:24:30 -07:00
|
|
|
'settings' => 'trestle-settings[logo_url]',
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// Upload a mobile logo.
|
2015-03-19 15:14:31 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 12:24:30 -07:00
|
|
|
'trestle-settings[logo_url_mobile]',
|
2015-03-19 15:14:31 -07:00
|
|
|
array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'default' => genesis_get_option( 'logo_url_mobile', 'trestle-settings' ),
|
|
|
|
|
'type' => 'option',
|
|
|
|
|
'transport' => 'postMessage',
|
|
|
|
|
'capability' => 'edit_theme_options',
|
|
|
|
|
'sanitize_callback' => 'esc_url_raw',
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
new WP_Customize_Image_Control(
|
|
|
|
|
$wp_customize,
|
|
|
|
|
'trestle_mobile_logo_control',
|
|
|
|
|
array(
|
2015-04-21 12:05:22 -07:00
|
|
|
'label' => __( 'Upload a mobile logo', 'trestle' ),
|
2015-03-19 15:14:31 -07:00
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 12:24:30 -07:00
|
|
|
'settings' => 'trestle-settings[logo_url_mobile]',
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// Upload a mobile logo.
|
2015-04-21 12:05:22 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 12:24:30 -07:00
|
|
|
'trestle-settings[favicon_url]',
|
2015-04-21 12:05:22 -07:00
|
|
|
array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'default' => genesis_get_option( 'favicon_url', 'trestle-settings' ),
|
|
|
|
|
'type' => 'option',
|
|
|
|
|
'transport' => 'postMessage',
|
|
|
|
|
'capability' => 'edit_theme_options',
|
|
|
|
|
'sanitize_callback' => 'esc_url_raw',
|
2015-04-21 12:05:22 -07:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
new WP_Customize_Image_Control(
|
|
|
|
|
$wp_customize,
|
|
|
|
|
'trestle_favicon_control',
|
|
|
|
|
array(
|
|
|
|
|
'label' => __( 'Upload a favicon', 'trestle' ),
|
|
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 12:24:30 -07:00
|
|
|
'settings' => 'trestle-settings[favicon_url]',
|
2015-04-21 12:05:22 -07:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// Primary nav style.
|
2015-03-19 15:14:31 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 12:24:30 -07:00
|
|
|
'trestle-settings[nav_primary_location]',
|
2015-03-19 15:14:31 -07:00
|
|
|
array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'default' => genesis_get_option( 'nav_primary_location', 'trestle-settings' ),
|
|
|
|
|
'type' => 'option',
|
|
|
|
|
'transport' => 'postMessage',
|
|
|
|
|
'capability' => 'edit_theme_options',
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
'trestle_nav_primary_location_control',
|
|
|
|
|
array(
|
|
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 12:24:30 -07:00
|
|
|
'settings' => 'trestle-settings[nav_primary_location]',
|
2015-03-19 15:14:31 -07:00
|
|
|
'label' => __( 'Menu style', 'trestle' ),
|
|
|
|
|
'type' => 'select',
|
|
|
|
|
'choices' => array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'full' => __( 'Full Width', 'trestle' ),
|
|
|
|
|
'header' => __( 'Header Right', 'trestle' ),
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// Primary nav extras.
|
2015-04-21 12:05:22 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 14:49:46 -07:00
|
|
|
'trestle-settings[search_in_nav]',
|
2015-04-21 12:05:22 -07:00
|
|
|
array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'default' => genesis_get_option( 'search_in_nav', 'trestle-settings' ),
|
|
|
|
|
'type' => 'option',
|
|
|
|
|
'transport' => 'postMessage',
|
|
|
|
|
'capability' => 'edit_theme_options',
|
2015-04-21 12:05:22 -07:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
'trestle_custom_nav_extras_text_control',
|
|
|
|
|
array(
|
|
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 14:49:46 -07:00
|
|
|
'settings' => 'trestle-settings[search_in_nav]',
|
2015-04-21 12:05:22 -07:00
|
|
|
'label' => __( 'Add search to mobile navigation', 'trestle' ),
|
|
|
|
|
'type' => 'checkbox',
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// Blog post custom read more link text.
|
2015-03-19 15:14:31 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 12:24:30 -07:00
|
|
|
'trestle-settings[read_more_text]',
|
2015-03-19 15:14:31 -07:00
|
|
|
array(
|
2015-04-30 12:24:30 -07:00
|
|
|
'default' => genesis_get_option( 'read_more_text', 'trestle-settings' ),
|
2015-03-19 15:14:31 -07:00
|
|
|
'type' => 'option',
|
|
|
|
|
'transport' => 'postMessage',
|
|
|
|
|
'capability' => 'edit_theme_options',
|
|
|
|
|
'sanitize_callback' => 'wp_kses_post',
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
'trestle_read_more_text_control',
|
|
|
|
|
array(
|
|
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 12:24:30 -07:00
|
|
|
'settings' => 'trestle-settings[read_more_text]',
|
2015-03-19 15:14:31 -07:00
|
|
|
'label' => __( 'Custom read more link text', 'trestle' ),
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// Post revisions number.
|
2015-03-19 15:14:31 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 12:24:30 -07:00
|
|
|
'trestle-settings[revisions_number]',
|
2015-03-19 15:14:31 -07:00
|
|
|
array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'default' => genesis_get_option( 'revisions_number', 'trestle-settings' ),
|
|
|
|
|
'type' => 'option',
|
|
|
|
|
'transport' => 'postMessage',
|
|
|
|
|
'capability' => 'edit_theme_options',
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
'trestle_revisions_number_control',
|
|
|
|
|
array(
|
|
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 12:24:30 -07:00
|
|
|
'settings' => 'trestle-settings[revisions_number]',
|
2015-03-19 15:14:31 -07:00
|
|
|
'label' => __( 'Number of post revisions', 'trestle' ),
|
|
|
|
|
'type' => 'select',
|
|
|
|
|
'choices' => array(
|
|
|
|
|
'-1' => __( 'Unlimited', 'trestle' ),
|
|
|
|
|
'0' => '0',
|
|
|
|
|
'1' => '1',
|
|
|
|
|
'2' => '2',
|
|
|
|
|
'3' => '3',
|
|
|
|
|
'4' => '4',
|
|
|
|
|
'5' => '5',
|
|
|
|
|
'6' => '6',
|
|
|
|
|
'7' => '7',
|
|
|
|
|
'8' => '8',
|
|
|
|
|
'9' => '9',
|
|
|
|
|
'10' => '10',
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// Footer Widget Areas.
|
2015-03-19 15:14:31 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 12:24:30 -07:00
|
|
|
'trestle-settings[footer_widgets_number]',
|
2015-03-19 15:14:31 -07:00
|
|
|
array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'default' => genesis_get_option( 'footer_widgets_number', 'trestle-settings' ),
|
|
|
|
|
'type' => 'option',
|
|
|
|
|
'transport' => 'postMessage',
|
|
|
|
|
'capability' => 'edit_theme_options',
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
'trestle_footer_widgets_number_control',
|
|
|
|
|
array(
|
|
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 12:24:30 -07:00
|
|
|
'settings' => 'trestle-settings[footer_widgets_number]',
|
2015-03-19 15:14:31 -07:00
|
|
|
'label' => __( 'Number of footer widgets', 'trestle' ),
|
|
|
|
|
'type' => 'select',
|
|
|
|
|
'choices' => array(
|
|
|
|
|
'0' => '0',
|
|
|
|
|
'1' => '1',
|
|
|
|
|
'2' => '2',
|
|
|
|
|
'3' => '3',
|
|
|
|
|
'4' => '4',
|
|
|
|
|
'5' => '5',
|
|
|
|
|
'6' => '6',
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// Add a label for the link icons.
|
2015-03-19 15:14:31 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 12:24:30 -07:00
|
|
|
'trestle-settings[link_icons_title]',
|
2015-03-19 15:14:31 -07:00
|
|
|
array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'default' => '',
|
|
|
|
|
'type' => 'option',
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
'trestle_link_icons_title',
|
|
|
|
|
array(
|
|
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 12:24:30 -07:00
|
|
|
'settings' => 'trestle-settings[link_icons_title]',
|
2015-03-19 15:14:31 -07:00
|
|
|
'label' => __( 'Icon links', 'trestle' ),
|
|
|
|
|
'type' => 'hidden',
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// External Link Icons.
|
2015-03-19 15:14:31 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 12:24:30 -07:00
|
|
|
'trestle-settings[external_link_icons]',
|
2015-03-19 15:14:31 -07:00
|
|
|
array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'default' => genesis_get_option( 'external_link_icons', 'trestle-settings' ),
|
|
|
|
|
'type' => 'option',
|
|
|
|
|
'transport' => 'postMessage',
|
|
|
|
|
'capability' => 'edit_theme_options',
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
'trestle_external_link_icons',
|
|
|
|
|
array(
|
|
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 12:24:30 -07:00
|
|
|
'settings' => 'trestle-settings[external_link_icons]',
|
2015-03-19 15:14:31 -07:00
|
|
|
'label' => __( 'Add icons to external links', 'trestle' ),
|
|
|
|
|
'type' => 'checkbox',
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// E-mail Link Icons.
|
2015-03-19 15:14:31 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 12:24:30 -07:00
|
|
|
'trestle-settings[email_link_icons]',
|
2015-03-19 15:14:31 -07:00
|
|
|
array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'default' => genesis_get_option( 'email_link_icons', 'trestle-settings' ),
|
|
|
|
|
'type' => 'option',
|
|
|
|
|
'transport' => 'postMessage',
|
|
|
|
|
'capability' => 'edit_theme_options',
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
'trestle_email_link_icons',
|
|
|
|
|
array(
|
|
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 12:24:30 -07:00
|
|
|
'settings' => 'trestle-settings[email_link_icons]',
|
2015-03-19 15:14:31 -07:00
|
|
|
'label' => __( 'Add icons to email links', 'trestle' ),
|
|
|
|
|
'type' => 'checkbox',
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// PDF Link Icons.
|
2015-03-19 15:14:31 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 12:24:30 -07:00
|
|
|
'trestle-settings[pdf_link_icons]',
|
2015-03-19 15:14:31 -07:00
|
|
|
array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'default' => genesis_get_option( 'pdf_link_icons', 'trestle-settings' ),
|
|
|
|
|
'type' => 'option',
|
|
|
|
|
'transport' => 'postMessage',
|
|
|
|
|
'capability' => 'edit_theme_options',
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
'trestle_pdf_link_icons',
|
|
|
|
|
array(
|
|
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 12:24:30 -07:00
|
|
|
'settings' => 'trestle-settings[pdf_link_icons]',
|
2015-03-19 15:14:31 -07:00
|
|
|
'label' => __( 'Add icons to .pdf links', 'trestle' ),
|
|
|
|
|
'type' => 'checkbox',
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2015-04-30 12:24:30 -07:00
|
|
|
// Doc Link Icons.
|
2015-03-19 15:14:31 -07:00
|
|
|
$wp_customize->add_setting(
|
2015-04-30 12:24:30 -07:00
|
|
|
'trestle-settings[doc_link_icons]',
|
2015-03-19 15:14:31 -07:00
|
|
|
array(
|
2015-04-30 14:49:46 -07:00
|
|
|
'default' => genesis_get_option( 'doc_link_icons', 'trestle-settings' ),
|
|
|
|
|
'type' => 'option',
|
|
|
|
|
'transport' => 'postMessage',
|
|
|
|
|
'capability' => 'edit_theme_options',
|
2015-03-19 15:14:31 -07:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$wp_customize->add_control(
|
|
|
|
|
'trestle_doc_link_icons',
|
|
|
|
|
array(
|
|
|
|
|
'section' => 'trestle_settings_section',
|
2015-04-30 12:24:30 -07:00
|
|
|
'settings' => 'trestle-settings[doc_link_icons]',
|
2015-03-19 15:14:31 -07:00
|
|
|
'label' => __( 'Add icons to .doc links', 'trestle' ),
|
|
|
|
|
'type' => 'checkbox',
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|