updated theme GeneratePress
version 3.1.0
This commit is contained in:
@ -0,0 +1,217 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles adding Customizer controls.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper functions to add Customizer fields.
|
||||
*/
|
||||
class GeneratePress_Customize_Field {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @access private
|
||||
* @var object Instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*
|
||||
* @since 1.2.0
|
||||
* @return object initialized object of class.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a wrapper for defined controls.
|
||||
*
|
||||
* @param string $id The settings ID for this field.
|
||||
* @param array $control_args The args for add_control().
|
||||
*/
|
||||
public static function add_wrapper( $id, $control_args = array() ) {
|
||||
global $wp_customize;
|
||||
|
||||
if ( ! $id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$control_args['settings'] = isset( $wp_customize->selective_refresh ) ? array() : 'blogname';
|
||||
$control_args['choices']['id'] = str_replace( '_', '-', $id );
|
||||
$control_args['type'] = 'generate-wrapper-control';
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Customize_React_Control(
|
||||
$wp_customize,
|
||||
$id,
|
||||
$control_args
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a title.
|
||||
*
|
||||
* @param string $id The settings ID for this field.
|
||||
* @param array $control_args The args for add_control().
|
||||
*/
|
||||
public static function add_title( $id, $control_args = array() ) {
|
||||
global $wp_customize;
|
||||
|
||||
if ( ! $id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$control_args['settings'] = isset( $wp_customize->selective_refresh ) ? array() : 'blogname';
|
||||
$control_args['type'] = 'generate-title-control';
|
||||
$control_args['choices']['title'] = $control_args['title'];
|
||||
unset( $control_args['title'] );
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Customize_React_Control(
|
||||
$wp_customize,
|
||||
$id,
|
||||
$control_args
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Customizer field.
|
||||
*
|
||||
* @param string $id The settings ID for this field.
|
||||
* @param object $control_class A custom control classes if we want one.
|
||||
* @param array $setting_args The args for add_setting().
|
||||
* @param array $control_args The args for add_control().
|
||||
*/
|
||||
public static function add_field( $id, $control_class, $setting_args = array(), $control_args = array() ) {
|
||||
global $wp_customize;
|
||||
|
||||
if ( ! $id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = wp_parse_args(
|
||||
$setting_args,
|
||||
array(
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'default' => '',
|
||||
'transport' => 'refresh',
|
||||
'validate_callback' => '',
|
||||
'sanitize_callback' => '',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
$id,
|
||||
array(
|
||||
'type' => $settings['type'],
|
||||
'capability' => $settings['capability'],
|
||||
'default' => $settings['default'],
|
||||
'transport' => $settings['transport'],
|
||||
'validate_callback' => $settings['validate_callback'],
|
||||
'sanitize_callback' => $settings['sanitize_callback'],
|
||||
)
|
||||
);
|
||||
|
||||
$control_args['settings'] = $id;
|
||||
|
||||
if ( ! isset( $control_args['type'] ) ) {
|
||||
unset( $control_args['type'] );
|
||||
}
|
||||
|
||||
if ( ! isset( $control_args['defaultValue'] ) && isset( $setting_args['default'] ) ) {
|
||||
$control_args['defaultValue'] = $setting_args['default'];
|
||||
}
|
||||
|
||||
if ( isset( $control_args['output'] ) ) {
|
||||
global $generate_customize_fields;
|
||||
|
||||
$generate_customize_fields[] = array(
|
||||
'js_vars' => $control_args['output'],
|
||||
'settings' => $id,
|
||||
);
|
||||
}
|
||||
|
||||
if ( $control_class ) {
|
||||
$wp_customize->add_control(
|
||||
new $control_class(
|
||||
$wp_customize,
|
||||
$id,
|
||||
$control_args
|
||||
)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$wp_customize->add_control(
|
||||
$id,
|
||||
$control_args
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add color field group.
|
||||
*
|
||||
* @param string $id The ID for the group wrapper.
|
||||
* @param string $section_id The section ID.
|
||||
* @param string $toggle_id The Toggle ID.
|
||||
* @param array $fields The color fields.
|
||||
*/
|
||||
public static function add_color_field_group( $id, $section_id, $toggle_id, $fields ) {
|
||||
self::add_wrapper(
|
||||
"generate_{$id}_wrapper",
|
||||
array(
|
||||
'section' => $section_id,
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => $toggle_id,
|
||||
'items' => array_keys( $fields ),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $fields as $key => $field ) {
|
||||
self::add_field(
|
||||
$key,
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $field['default_value'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => $field['label'],
|
||||
'section' => $section_id,
|
||||
'choices' => array(
|
||||
'alpha' => isset( $field['alpha'] ) ? $field['alpha'] : true,
|
||||
'toggleId' => $toggle_id,
|
||||
'wrapper' => $key,
|
||||
'tooltip' => $field['tooltip'],
|
||||
'hideLabel' => isset( $field['hide_label'] ) ? $field['hide_label'] : false,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $field['element'],
|
||||
'property' => $field['property'],
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Customize API: ColorAlpha class
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Customize Color Control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @see WP_Customize_Control
|
||||
*/
|
||||
class GeneratePress_Customize_Color_Control extends WP_Customize_Color_Control {
|
||||
/**
|
||||
* Type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'generate-color-control';
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @since 3.4.0
|
||||
* @uses WP_Customize_Control::to_json()
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['choices'] = $this->choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty JS template.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function content_template() {}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Customize API: ColorAlpha class
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Customize Color Control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @see WP_Customize_Control
|
||||
*/
|
||||
class GeneratePress_Customize_React_Control extends WP_Customize_Control {
|
||||
/**
|
||||
* Type.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'generate-react-control';
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @since 3.4.0
|
||||
* @uses WP_Customize_Control::to_json()
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['choices'] = $this->choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty JS template.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function content_template() {}
|
||||
|
||||
/**
|
||||
* Empty PHP template.
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function render_content() {}
|
||||
}
|
@ -1,501 +1,297 @@
|
||||
( function( api ) {
|
||||
'use strict';
|
||||
|
||||
// Add callback for when the header_textcolor setting exists.
|
||||
api( 'generate_settings[nav_position_setting]', function( setting ) {
|
||||
var isNavFloated, isNavAlignable, setNavDropPointActiveState, setNavAlignmentsActiveState;
|
||||
|
||||
/**
|
||||
* Determine whether the navigation is floating.
|
||||
*
|
||||
* @returns {boolean} Is floating?
|
||||
*/
|
||||
isNavFloated = function() {
|
||||
if ( 'nav-float-right' === setting.get() || 'nav-float-left' === setting.get() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine whether the navigation is align-able.
|
||||
*
|
||||
* @returns {boolean} Is floating?
|
||||
*/
|
||||
isNavAlignable = function() {
|
||||
if ( 'nav-float-right' === setting.get() || 'nav-float-left' === setting.get() ) {
|
||||
var navAsHeader = api.instance( 'generate_menu_plus_settings[navigation_as_header]' );
|
||||
|
||||
if ( navAsHeader && navAsHeader.get() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update a control's active state according to the navigation location setting's value.
|
||||
*
|
||||
* @param {wp.customize.Control} control
|
||||
*/
|
||||
setNavDropPointActiveState = function( control ) {
|
||||
var setActiveState = function() {
|
||||
control.active.set( isNavFloated() );
|
||||
};
|
||||
|
||||
// FYI: With the following we can eliminate all of our PHP active_callback code.
|
||||
control.active.validate = isNavFloated;
|
||||
|
||||
// Set initial active state.
|
||||
setActiveState();
|
||||
|
||||
/*
|
||||
* Update activate state whenever the setting is changed.
|
||||
* Even when the setting does have a refresh transport where the
|
||||
* server-side active callback will manage the active state upon
|
||||
* refresh, having this JS management of the active state will
|
||||
* ensure that controls will have their visibility toggled
|
||||
* immediately instead of waiting for the preview to load.
|
||||
* This is especially important if the setting has a postMessage
|
||||
* transport where changing the setting wouldn't normally cause
|
||||
* the preview to refresh and thus the server-side active_callbacks
|
||||
* would not get invoked.
|
||||
*/
|
||||
setting.bind( setActiveState );
|
||||
};
|
||||
|
||||
/**
|
||||
* Update a control's active state according to the navigation location setting's value.
|
||||
*
|
||||
* @param {wp.customize.Control} control
|
||||
*/
|
||||
setNavAlignmentsActiveState = function( control ) {
|
||||
var setActiveState = function() {
|
||||
control.active.set( isNavAlignable() );
|
||||
};
|
||||
|
||||
// FYI: With the following we can eliminate all of our PHP active_callback code.
|
||||
control.active.validate = isNavAlignable;
|
||||
|
||||
// Set initial active state.
|
||||
setActiveState();
|
||||
|
||||
/*
|
||||
* Update activate state whenever the setting is changed.
|
||||
* Even when the setting does have a refresh transport where the
|
||||
* server-side active callback will manage the active state upon
|
||||
* refresh, having this JS management of the active state will
|
||||
* ensure that controls will have their visibility toggled
|
||||
* immediately instead of waiting for the preview to load.
|
||||
* This is especially important if the setting has a postMessage
|
||||
* transport where changing the setting wouldn't normally cause
|
||||
* the preview to refresh and thus the server-side active_callbacks
|
||||
* would not get invoked.
|
||||
*/
|
||||
setting.bind( setActiveState );
|
||||
};
|
||||
|
||||
api.control( 'generate_settings[nav_drop_point]', setNavDropPointActiveState );
|
||||
api.control( 'generate_settings[nav_layout_setting]', setNavAlignmentsActiveState );
|
||||
api.control( 'generate_settings[nav_inner_width]', setNavAlignmentsActiveState );
|
||||
api.control( 'generate_settings[nav_alignment_setting]', setNavAlignmentsActiveState );
|
||||
} );
|
||||
|
||||
var setOption = function( options ) {
|
||||
if ( options.headerAlignment ) {
|
||||
api.instance( 'generate_settings[header_alignment_setting]' ).set( options.headerAlignment );
|
||||
}
|
||||
|
||||
if ( options.navLocation ) {
|
||||
api.instance( 'generate_settings[nav_position_setting]' ).set( options.navLocation );
|
||||
}
|
||||
|
||||
if ( options.navAlignment ) {
|
||||
api.instance( 'generate_settings[nav_alignment_setting]' ).set( options.navAlignment );
|
||||
}
|
||||
|
||||
if ( options.boxAlignment ) {
|
||||
api.instance( 'generate_settings[container_alignment]' ).set( options.boxAlignment );
|
||||
}
|
||||
|
||||
if ( options.siteTitleFontSize ) {
|
||||
api.instance( 'generate_settings[site_title_font_size]' ).set( options.siteTitleFontSize );
|
||||
}
|
||||
|
||||
if ( 'undefined' !== typeof options.hideSiteTagline ) {
|
||||
api.instance( 'generate_settings[hide_tagline]' ).set( options.hideSiteTagline );
|
||||
}
|
||||
|
||||
if ( options.headerPaddingTop ) {
|
||||
api.instance( 'generate_spacing_settings[header_top]' ).set( options.headerPaddingTop );
|
||||
}
|
||||
|
||||
if ( options.headerPaddingBottom ) {
|
||||
api.instance( 'generate_spacing_settings[header_bottom]' ).set( options.headerPaddingBottom );
|
||||
}
|
||||
};
|
||||
|
||||
api( 'generate_header_helper', function( value ) {
|
||||
var headerAlignment = false,
|
||||
navLocation = false,
|
||||
navAlignment = false,
|
||||
boxAlignment = false,
|
||||
siteTitleFontSize = false,
|
||||
hideSiteTagline = false,
|
||||
headerPaddingTop = false,
|
||||
headerPaddingBottom = false;
|
||||
|
||||
value.bind( function( newval ) {
|
||||
var headerAlignmentSetting = api.instance( 'generate_settings[header_alignment_setting]' );
|
||||
var navLocationSetting = api.instance( 'generate_settings[nav_position_setting]' );
|
||||
var navAlignmentSetting = api.instance( 'generate_settings[nav_alignment_setting]' );
|
||||
var boxAlignmentSetting = api.instance( 'generate_settings[container_alignment]' );
|
||||
var siteTitleFontSizeSetting = api.instance( 'generate_settings[site_title_font_size]' );
|
||||
var hideSiteTaglineSetting = api.instance( 'generate_settings[hide_tagline]' );
|
||||
var headerPaddingTopSetting = api.instance( 'generate_spacing_settings[header_top]' );
|
||||
var headerPaddingBottomSetting = api.instance( 'generate_spacing_settings[header_bottom]' );
|
||||
|
||||
if ( ! headerAlignmentSetting._dirty ) {
|
||||
headerAlignment = headerAlignmentSetting.get();
|
||||
}
|
||||
|
||||
if ( ! navLocationSetting._dirty ) {
|
||||
navLocation = navLocationSetting.get();
|
||||
}
|
||||
|
||||
if ( ! navAlignmentSetting._dirty ) {
|
||||
navAlignment = navAlignmentSetting.get();
|
||||
}
|
||||
|
||||
if ( ! boxAlignmentSetting._dirty ) {
|
||||
boxAlignment = boxAlignmentSetting.get();
|
||||
}
|
||||
|
||||
if ( ! siteTitleFontSizeSetting._dirty ) {
|
||||
siteTitleFontSize = siteTitleFontSizeSetting.get();
|
||||
}
|
||||
|
||||
if ( ! hideSiteTaglineSetting._dirty ) {
|
||||
hideSiteTagline = hideSiteTaglineSetting.get();
|
||||
}
|
||||
|
||||
if ( ! headerPaddingTopSetting._dirty ) {
|
||||
headerPaddingTop = headerPaddingTopSetting.get();
|
||||
}
|
||||
|
||||
if ( ! headerPaddingBottomSetting._dirty ) {
|
||||
headerPaddingBottom = headerPaddingBottomSetting.get();
|
||||
}
|
||||
|
||||
var options = {
|
||||
headerAlignment: generatepress_defaults.header_alignment_setting,
|
||||
navLocation: generatepress_defaults.nav_position_setting,
|
||||
navAlignment: generatepress_defaults.nav_alignment_setting,
|
||||
boxAlignment: generatepress_defaults.container_alignment,
|
||||
siteTitleFontSize: generatepress_typography_defaults.site_title_font_size,
|
||||
hideSiteTagline: generatepress_defaults.hide_tagline,
|
||||
headerPaddingTop: generatepress_spacing_defaults.header_top,
|
||||
headerPaddingBottom: generatepress_spacing_defaults.header_bottom,
|
||||
};
|
||||
|
||||
if ( 'current' === newval ) {
|
||||
options = {
|
||||
headerAlignment: headerAlignment,
|
||||
navLocation: navLocation,
|
||||
navAlignment: navAlignment,
|
||||
boxAlignment: boxAlignment,
|
||||
siteTitleFontSize: siteTitleFontSize,
|
||||
hideSiteTagline: hideSiteTagline,
|
||||
headerPaddingTop: headerPaddingTop,
|
||||
headerPaddingBottom: headerPaddingBottom,
|
||||
};
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'default' === newval ) {
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'classic' === newval ) {
|
||||
var options = {
|
||||
headerAlignment: 'left',
|
||||
navLocation: 'nav-below-header',
|
||||
navAlignment: 'left',
|
||||
boxAlignment: 'boxes',
|
||||
siteTitleFontSize: '45',
|
||||
hideSiteTagline: '',
|
||||
headerPaddingTop: '40',
|
||||
headerPaddingBottom: '40',
|
||||
};
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-before' === newval ) {
|
||||
options['headerAlignment'] = 'left';
|
||||
options['navLocation'] = 'nav-above-header';
|
||||
options['navAlignment'] = 'left';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-after' === newval ) {
|
||||
options['headerAlignment'] = 'left';
|
||||
options['navLocation'] = 'nav-below-header';
|
||||
options['navAlignment'] = 'left';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-before-centered' === newval ) {
|
||||
options['headerAlignment'] = 'center';
|
||||
options['navLocation'] = 'nav-above-header';
|
||||
options['navAlignment'] = 'center';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-after-centered' === newval ) {
|
||||
options['headerAlignment'] = 'center';
|
||||
options['navLocation'] = 'nav-below-header';
|
||||
options['navAlignment'] = 'center';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-left' === newval ) {
|
||||
options['headerAlignment'] = 'left';
|
||||
options['navLocation'] = 'nav-float-left';
|
||||
options['navAlignment'] = 'right';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
api( 'nav_color_presets', function( value ) {
|
||||
var backgroundColor = false,
|
||||
textColor = false,
|
||||
backgroundColorHover = false,
|
||||
textColorHover = false,
|
||||
currentBackgroundColor = false,
|
||||
currentTextColor = false,
|
||||
subMenuBackgroundColor = false,
|
||||
subMenuTextColor = false,
|
||||
subMenuBackgroundColorHover = false,
|
||||
subMenuTextColorHover = false,
|
||||
subMenuCurrentBackgroundColor = false,
|
||||
subMenuCurrentTextColor = false;
|
||||
|
||||
value.bind( function( newval ) {
|
||||
var backgroundColorSetting = api.instance( 'generate_settings[navigation_background_color]' ),
|
||||
textColorSetting = api.instance( 'generate_settings[navigation_text_color]' ),
|
||||
backgroundColorHoverSetting = api.instance( 'generate_settings[navigation_background_hover_color]' ),
|
||||
textColorHoverSetting = api.instance( 'generate_settings[navigation_text_hover_color]' ),
|
||||
currentBackgroundColorSetting = api.instance( 'generate_settings[navigation_background_current_color]' ),
|
||||
currentTextColorSetting = api.instance( 'generate_settings[navigation_text_current_color]' ),
|
||||
subMenuBackgroundColorSetting = api.instance( 'generate_settings[subnavigation_background_color]' ),
|
||||
subMenuTextColorSetting = api.instance( 'generate_settings[subnavigation_text_color]' ),
|
||||
subMenuBackgroundColorHoverSetting = api.instance( 'generate_settings[subnavigation_background_hover_color]' ),
|
||||
subMenuTextColorHoverSetting = api.instance( 'generate_settings[subnavigation_text_hover_color]' ),
|
||||
subMenuCurrentBackgroundColorSetting = api.instance( 'generate_settings[subnavigation_background_current_color]' ),
|
||||
subMenuCurrentTextColorSetting = api.instance( 'generate_settings[subnavigation_text_current_color]' );
|
||||
|
||||
if ( ! backgroundColorSetting._dirty ) {
|
||||
backgroundColor = backgroundColorSetting.get();
|
||||
}
|
||||
|
||||
if ( ! textColorSetting._dirty ) {
|
||||
textColor = textColorSetting.get();
|
||||
}
|
||||
|
||||
if ( ! backgroundColorHoverSetting._dirty ) {
|
||||
backgroundColorHover = backgroundColorHoverSetting.get();
|
||||
}
|
||||
|
||||
if ( ! textColorHoverSetting._dirty ) {
|
||||
textColorHover = textColorHoverSetting.get();
|
||||
}
|
||||
|
||||
if ( ! currentBackgroundColorSetting._dirty ) {
|
||||
currentBackgroundColor = currentBackgroundColorSetting.get();
|
||||
}
|
||||
|
||||
if ( ! currentTextColorSetting._dirty ) {
|
||||
currentTextColor = currentTextColorSetting.get();
|
||||
}
|
||||
|
||||
if ( ! subMenuBackgroundColorSetting._dirty ) {
|
||||
subMenuBackgroundColor = subMenuBackgroundColorSetting.get();
|
||||
}
|
||||
|
||||
if ( ! subMenuTextColorSetting._dirty ) {
|
||||
subMenuTextColor = subMenuTextColorSetting.get();
|
||||
}
|
||||
|
||||
if ( ! subMenuBackgroundColorHoverSetting._dirty ) {
|
||||
subMenuBackgroundColorHover = subMenuBackgroundColorHoverSetting.get();
|
||||
}
|
||||
|
||||
if ( ! subMenuTextColorHoverSetting._dirty ) {
|
||||
subMenuTextColorHover = subMenuTextColorHoverSetting.get();
|
||||
}
|
||||
|
||||
if ( ! subMenuCurrentBackgroundColorSetting._dirty ) {
|
||||
subMenuCurrentBackgroundColor = subMenuCurrentBackgroundColorSetting.get();
|
||||
}
|
||||
|
||||
if ( ! subMenuCurrentTextColorSetting._dirty ) {
|
||||
subMenuCurrentTextColor = subMenuCurrentTextColorSetting.get();
|
||||
}
|
||||
|
||||
if ( 'current' === newval ) {
|
||||
backgroundColorSetting.set( backgroundColor );
|
||||
textColorSetting.set( textColor );
|
||||
|
||||
backgroundColorHoverSetting.set( backgroundColorHover );
|
||||
textColorHoverSetting.set( textColorHover );
|
||||
|
||||
currentBackgroundColorSetting.set( currentBackgroundColor );
|
||||
currentTextColorSetting.set( currentTextColorSetting );
|
||||
|
||||
subMenuBackgroundColorSetting.set( subMenuBackgroundColor );
|
||||
subMenuTextColorSetting.set( subMenuTextColor );
|
||||
|
||||
subMenuBackgroundColorHoverSetting.set( subMenuBackgroundColorHover );
|
||||
subMenuTextColorHoverSetting.set( subMenuTextColorHover );
|
||||
|
||||
subMenuCurrentBackgroundColorSetting.set( subMenuCurrentBackgroundColor );
|
||||
subMenuCurrentTextColorSetting.set( subMenuCurrentTextColorSetting );
|
||||
}
|
||||
|
||||
if ( 'default' === newval ) {
|
||||
backgroundColorSetting.set( generatepress_color_defaults.navigation_background_color );
|
||||
textColorSetting.set( generatepress_color_defaults.navigation_text_color );
|
||||
|
||||
backgroundColorHoverSetting.set( generatepress_color_defaults.navigation_background_hover_color );
|
||||
textColorHoverSetting.set( generatepress_color_defaults.navigation_text_hover_color );
|
||||
|
||||
currentBackgroundColorSetting.set( generatepress_color_defaults.navigation_background_current_color );
|
||||
currentTextColorSetting.set( generatepress_color_defaults.navigation_text_current_color );
|
||||
|
||||
subMenuBackgroundColorSetting.set( generatepress_color_defaults.subnavigation_background_color );
|
||||
subMenuTextColorSetting.set( generatepress_color_defaults.subnavigation_text_color );
|
||||
|
||||
subMenuBackgroundColorHoverSetting.set( generatepress_color_defaults.subnavigation_background_hover_color );
|
||||
subMenuTextColorHoverSetting.set( generatepress_color_defaults.subnavigation_text_hover_color );
|
||||
|
||||
subMenuCurrentBackgroundColorSetting.set( generatepress_color_defaults.subnavigation_background_current_color );
|
||||
subMenuCurrentTextColorSetting.set( generatepress_color_defaults.subnavigation_text_current_color );
|
||||
}
|
||||
|
||||
if ( 'classic' === newval ) {
|
||||
backgroundColorSetting.set( '#222222' );
|
||||
textColorSetting.set( '#ffffff' );
|
||||
|
||||
backgroundColorHoverSetting.set( '#3f3f3f' );
|
||||
textColorHoverSetting.set( '#ffffff' );
|
||||
|
||||
currentBackgroundColorSetting.set( '#3f3f3f' );
|
||||
currentTextColorSetting.set( '#ffffff' );
|
||||
|
||||
subMenuBackgroundColorSetting.set( '#3f3f3f' );
|
||||
subMenuTextColorSetting.set( '#ffffff' );
|
||||
|
||||
subMenuBackgroundColorHoverSetting.set( '#4f4f4f' );
|
||||
subMenuTextColorHoverSetting.set( '#ffffff' );
|
||||
|
||||
subMenuCurrentBackgroundColorSetting.set( '#4f4f4f' );
|
||||
subMenuCurrentTextColorSetting.set( '#ffffff' );
|
||||
}
|
||||
|
||||
if ( 'grey' === newval ) {
|
||||
backgroundColorSetting.set( '#595959' );
|
||||
textColorSetting.set( '#ffffff' );
|
||||
|
||||
backgroundColorHoverSetting.set( '#424242' );
|
||||
textColorHoverSetting.set( '#ffffff' );
|
||||
|
||||
currentBackgroundColorSetting.set( '#424242' );
|
||||
currentTextColorSetting.set( '#ffffff' );
|
||||
|
||||
subMenuBackgroundColorSetting.set( '#424242' );
|
||||
subMenuTextColorSetting.set( '#ffffff' );
|
||||
|
||||
subMenuBackgroundColorHoverSetting.set( '#424242' );
|
||||
subMenuTextColorHoverSetting.set( '#dbdbdb' );
|
||||
|
||||
subMenuCurrentBackgroundColorSetting.set( '#424242' );
|
||||
subMenuCurrentTextColorSetting.set( '#dbdbdb' );
|
||||
}
|
||||
|
||||
if ( 'blue' === newval ) {
|
||||
backgroundColorSetting.set( '#1e73be' );
|
||||
textColorSetting.set( '#ffffff' );
|
||||
|
||||
backgroundColorHoverSetting.set( '#035a9e' );
|
||||
textColorHoverSetting.set( '#ffffff' );
|
||||
|
||||
currentBackgroundColorSetting.set( '#035a9e' );
|
||||
currentTextColorSetting.set( '#ffffff' );
|
||||
|
||||
subMenuBackgroundColorSetting.set( '#035a9e' );
|
||||
subMenuTextColorSetting.set( '#ffffff' );
|
||||
|
||||
subMenuBackgroundColorHoverSetting.set( '#035a9e' );
|
||||
subMenuTextColorHoverSetting.set( '#bbd2e8' );
|
||||
|
||||
subMenuCurrentBackgroundColorSetting.set( '#035a9e' );
|
||||
subMenuCurrentTextColorSetting.set( '#bbd2e8' );
|
||||
}
|
||||
|
||||
if ( 'red' === newval ) {
|
||||
backgroundColorSetting.set( '#ed4250' );
|
||||
textColorSetting.set( '#ffffff' );
|
||||
|
||||
backgroundColorHoverSetting.set( '#c42f2f' );
|
||||
textColorHoverSetting.set( '#ffffff' );
|
||||
|
||||
currentBackgroundColorSetting.set( '#c42f2f' );
|
||||
currentTextColorSetting.set( '#ffffff' );
|
||||
|
||||
subMenuBackgroundColorSetting.set( '#c42f2f' );
|
||||
subMenuTextColorSetting.set( '#ffffff' );
|
||||
|
||||
subMenuBackgroundColorHoverSetting.set( '#c42f2f' );
|
||||
subMenuTextColorHoverSetting.set( '#fcd9d6' );
|
||||
|
||||
subMenuCurrentBackgroundColorSetting.set( '#c42f2f' );
|
||||
subMenuCurrentTextColorSetting.set( '#fcd9d6' );
|
||||
}
|
||||
|
||||
if ( 'green' === newval ) {
|
||||
backgroundColorSetting.set( '#16aa74' );
|
||||
textColorSetting.set( '#ffffff' );
|
||||
|
||||
backgroundColorHoverSetting.set( '#119b6d' );
|
||||
textColorHoverSetting.set( '#ffffff' );
|
||||
|
||||
currentBackgroundColorSetting.set( '#119b6d' );
|
||||
currentTextColorSetting.set( '#ffffff' );
|
||||
|
||||
subMenuBackgroundColorSetting.set( '#119b6d' );
|
||||
subMenuTextColorSetting.set( '#ffffff' );
|
||||
|
||||
subMenuBackgroundColorHoverSetting.set( '#119b6d' );
|
||||
subMenuTextColorHoverSetting.set( '#c2e8de' );
|
||||
|
||||
subMenuCurrentBackgroundColorSetting.set( '#119b6d' );
|
||||
subMenuCurrentTextColorSetting.set( '#c2e8de' );
|
||||
}
|
||||
|
||||
jQuery('.wp-color-picker').wpColorPicker().change();
|
||||
} );
|
||||
} );
|
||||
|
||||
}( wp.customize ) );
|
||||
( function( api ) {
|
||||
'use strict';
|
||||
|
||||
// Add callback for when the header_textcolor setting exists.
|
||||
api( 'generate_settings[nav_position_setting]', function( setting ) {
|
||||
var isNavFloated, isNavAlignable, setNavDropPointActiveState, setNavAlignmentsActiveState;
|
||||
|
||||
/**
|
||||
* Determine whether the navigation is floating.
|
||||
*
|
||||
* @returns {boolean} Is floating?
|
||||
*/
|
||||
isNavFloated = function() {
|
||||
if ( 'nav-float-right' === setting.get() || 'nav-float-left' === setting.get() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine whether the navigation is align-able.
|
||||
*
|
||||
* @returns {boolean} Is floating?
|
||||
*/
|
||||
isNavAlignable = function() {
|
||||
if ( 'nav-float-right' === setting.get() || 'nav-float-left' === setting.get() ) {
|
||||
var navAsHeader = api.instance( 'generate_menu_plus_settings[navigation_as_header]' );
|
||||
|
||||
if ( navAsHeader && navAsHeader.get() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update a control's active state according to the navigation location setting's value.
|
||||
*
|
||||
* @param {wp.customize.Control} control
|
||||
*/
|
||||
setNavDropPointActiveState = function( control ) {
|
||||
var setActiveState = function() {
|
||||
control.active.set( isNavFloated() );
|
||||
};
|
||||
|
||||
// FYI: With the following we can eliminate all of our PHP active_callback code.
|
||||
control.active.validate = isNavFloated;
|
||||
|
||||
// Set initial active state.
|
||||
setActiveState();
|
||||
|
||||
/*
|
||||
* Update activate state whenever the setting is changed.
|
||||
* Even when the setting does have a refresh transport where the
|
||||
* server-side active callback will manage the active state upon
|
||||
* refresh, having this JS management of the active state will
|
||||
* ensure that controls will have their visibility toggled
|
||||
* immediately instead of waiting for the preview to load.
|
||||
* This is especially important if the setting has a postMessage
|
||||
* transport where changing the setting wouldn't normally cause
|
||||
* the preview to refresh and thus the server-side active_callbacks
|
||||
* would not get invoked.
|
||||
*/
|
||||
setting.bind( setActiveState );
|
||||
};
|
||||
|
||||
/**
|
||||
* Update a control's active state according to the navigation location setting's value.
|
||||
*
|
||||
* @param {wp.customize.Control} control
|
||||
*/
|
||||
setNavAlignmentsActiveState = function( control ) {
|
||||
var setActiveState = function() {
|
||||
control.active.set( isNavAlignable() );
|
||||
};
|
||||
|
||||
// FYI: With the following we can eliminate all of our PHP active_callback code.
|
||||
control.active.validate = isNavAlignable;
|
||||
|
||||
// Set initial active state.
|
||||
setActiveState();
|
||||
|
||||
/*
|
||||
* Update activate state whenever the setting is changed.
|
||||
* Even when the setting does have a refresh transport where the
|
||||
* server-side active callback will manage the active state upon
|
||||
* refresh, having this JS management of the active state will
|
||||
* ensure that controls will have their visibility toggled
|
||||
* immediately instead of waiting for the preview to load.
|
||||
* This is especially important if the setting has a postMessage
|
||||
* transport where changing the setting wouldn't normally cause
|
||||
* the preview to refresh and thus the server-side active_callbacks
|
||||
* would not get invoked.
|
||||
*/
|
||||
setting.bind( setActiveState );
|
||||
};
|
||||
|
||||
api.control( 'generate_settings[nav_drop_point]', setNavDropPointActiveState );
|
||||
api.control( 'generate_settings[nav_layout_setting]', setNavAlignmentsActiveState );
|
||||
api.control( 'generate_settings[nav_inner_width]', setNavAlignmentsActiveState );
|
||||
api.control( 'generate_settings[nav_alignment_setting]', setNavAlignmentsActiveState );
|
||||
} );
|
||||
|
||||
var setOption = function( options ) {
|
||||
if ( options.headerAlignment ) {
|
||||
api.instance( 'generate_settings[header_alignment_setting]' ).set( options.headerAlignment );
|
||||
}
|
||||
|
||||
if ( options.navLocation ) {
|
||||
api.instance( 'generate_settings[nav_position_setting]' ).set( options.navLocation );
|
||||
}
|
||||
|
||||
if ( options.navAlignment ) {
|
||||
api.instance( 'generate_settings[nav_alignment_setting]' ).set( options.navAlignment );
|
||||
}
|
||||
|
||||
if ( options.boxAlignment ) {
|
||||
api.instance( 'generate_settings[container_alignment]' ).set( options.boxAlignment );
|
||||
}
|
||||
|
||||
if ( options.siteTitleFontSize ) {
|
||||
api.instance( 'generate_settings[site_title_font_size]' ).set( options.siteTitleFontSize );
|
||||
}
|
||||
|
||||
if ( 'undefined' !== typeof options.hideSiteTagline ) {
|
||||
api.instance( 'generate_settings[hide_tagline]' ).set( options.hideSiteTagline );
|
||||
}
|
||||
|
||||
if ( options.headerPaddingTop ) {
|
||||
api.instance( 'generate_spacing_settings[header_top]' ).set( options.headerPaddingTop );
|
||||
}
|
||||
|
||||
if ( options.headerPaddingBottom ) {
|
||||
api.instance( 'generate_spacing_settings[header_bottom]' ).set( options.headerPaddingBottom );
|
||||
}
|
||||
};
|
||||
|
||||
api( 'generate_header_helper', function( value ) {
|
||||
var headerAlignment = false,
|
||||
navLocation = false,
|
||||
navAlignment = false,
|
||||
boxAlignment = false,
|
||||
siteTitleFontSize = false,
|
||||
hideSiteTagline = false,
|
||||
headerPaddingTop = false,
|
||||
headerPaddingBottom = false;
|
||||
|
||||
value.bind( function( newval ) {
|
||||
var headerAlignmentSetting = api.instance( 'generate_settings[header_alignment_setting]' );
|
||||
var navLocationSetting = api.instance( 'generate_settings[nav_position_setting]' );
|
||||
var navAlignmentSetting = api.instance( 'generate_settings[nav_alignment_setting]' );
|
||||
var boxAlignmentSetting = api.instance( 'generate_settings[container_alignment]' );
|
||||
var siteTitleFontSizeSetting = api.instance( 'generate_settings[site_title_font_size]' );
|
||||
var hideSiteTaglineSetting = api.instance( 'generate_settings[hide_tagline]' );
|
||||
var headerPaddingTopSetting = api.instance( 'generate_spacing_settings[header_top]' );
|
||||
var headerPaddingBottomSetting = api.instance( 'generate_spacing_settings[header_bottom]' );
|
||||
|
||||
if ( ! headerAlignmentSetting._dirty ) {
|
||||
headerAlignment = headerAlignmentSetting.get();
|
||||
}
|
||||
|
||||
if ( ! navLocationSetting._dirty ) {
|
||||
navLocation = navLocationSetting.get();
|
||||
}
|
||||
|
||||
if ( ! navAlignmentSetting._dirty ) {
|
||||
navAlignment = navAlignmentSetting.get();
|
||||
}
|
||||
|
||||
if ( ! boxAlignmentSetting._dirty ) {
|
||||
boxAlignment = boxAlignmentSetting.get();
|
||||
}
|
||||
|
||||
if ( ! siteTitleFontSizeSetting._dirty ) {
|
||||
siteTitleFontSize = siteTitleFontSizeSetting.get();
|
||||
}
|
||||
|
||||
if ( ! hideSiteTaglineSetting._dirty ) {
|
||||
hideSiteTagline = hideSiteTaglineSetting.get();
|
||||
}
|
||||
|
||||
if ( ! headerPaddingTopSetting._dirty ) {
|
||||
headerPaddingTop = headerPaddingTopSetting.get();
|
||||
}
|
||||
|
||||
if ( ! headerPaddingBottomSetting._dirty ) {
|
||||
headerPaddingBottom = headerPaddingBottomSetting.get();
|
||||
}
|
||||
|
||||
var options = {
|
||||
headerAlignment: generatepress_defaults.header_alignment_setting,
|
||||
navLocation: generatepress_defaults.nav_position_setting,
|
||||
navAlignment: generatepress_defaults.nav_alignment_setting,
|
||||
boxAlignment: generatepress_defaults.container_alignment,
|
||||
siteTitleFontSize: generatepress_typography_defaults.site_title_font_size,
|
||||
hideSiteTagline: generatepress_defaults.hide_tagline,
|
||||
headerPaddingTop: generatepress_spacing_defaults.header_top,
|
||||
headerPaddingBottom: generatepress_spacing_defaults.header_bottom,
|
||||
};
|
||||
|
||||
if ( 'current' === newval ) {
|
||||
options = {
|
||||
headerAlignment: headerAlignment,
|
||||
navLocation: navLocation,
|
||||
navAlignment: navAlignment,
|
||||
boxAlignment: boxAlignment,
|
||||
siteTitleFontSize: siteTitleFontSize,
|
||||
hideSiteTagline: hideSiteTagline,
|
||||
headerPaddingTop: headerPaddingTop,
|
||||
headerPaddingBottom: headerPaddingBottom,
|
||||
};
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'default' === newval ) {
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'classic' === newval ) {
|
||||
var options = {
|
||||
headerAlignment: 'left',
|
||||
navLocation: 'nav-below-header',
|
||||
navAlignment: 'left',
|
||||
boxAlignment: 'boxes',
|
||||
siteTitleFontSize: '45',
|
||||
hideSiteTagline: '',
|
||||
headerPaddingTop: '40',
|
||||
headerPaddingBottom: '40',
|
||||
};
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-before' === newval ) {
|
||||
options['headerAlignment'] = 'left';
|
||||
options['navLocation'] = 'nav-above-header';
|
||||
options['navAlignment'] = 'left';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-after' === newval ) {
|
||||
options['headerAlignment'] = 'left';
|
||||
options['navLocation'] = 'nav-below-header';
|
||||
options['navAlignment'] = 'left';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-before-centered' === newval ) {
|
||||
options['headerAlignment'] = 'center';
|
||||
options['navLocation'] = 'nav-above-header';
|
||||
options['navAlignment'] = 'center';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-after-centered' === newval ) {
|
||||
options['headerAlignment'] = 'center';
|
||||
options['navLocation'] = 'nav-below-header';
|
||||
options['navAlignment'] = 'center';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
|
||||
if ( 'nav-left' === newval ) {
|
||||
options['headerAlignment'] = 'left';
|
||||
options['navLocation'] = 'nav-float-left';
|
||||
options['navAlignment'] = 'right';
|
||||
|
||||
setOption( options );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
api( 'generate_settings[use_dynamic_typography]', function( value ) {
|
||||
var fontManager = api.control( 'generate_settings[font_manager]' );
|
||||
var typographyManager = api.control( 'generate_settings[typography]' );
|
||||
|
||||
value.bind( function( newval ) {
|
||||
if ( newval ) {
|
||||
if ( fontManager.setting.get().length === 0 ) {
|
||||
fontManager.setting.set( generatepressCustomizeControls.mappedTypographyData.fonts );
|
||||
}
|
||||
|
||||
if ( typographyManager.setting.get().length === 0 ) {
|
||||
typographyManager.setting.set( generatepressCustomizeControls.mappedTypographyData.typography );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}( wp.customize ) );
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,341 @@
|
||||
/* global gpPostMessageFields */
|
||||
/* eslint max-depth: off */
|
||||
var gpPostMessage = {
|
||||
|
||||
/**
|
||||
* The fields.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
fields: {},
|
||||
|
||||
/**
|
||||
* A collection of methods for the <style> tags.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
styleTag: {
|
||||
|
||||
/**
|
||||
* Add a <style> tag in <head> if it doesn't already exist.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {string} id - The field-ID.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
add( id ) {
|
||||
id = id.replace( /[^\w\s]/gi, '-' );
|
||||
if ( null === document.getElementById( 'gp-postmessage-' + id ) || 'undefined' === typeof document.getElementById( 'gp-postmessage-' + id ) ) {
|
||||
jQuery( 'head' ).append( '<style id="gp-postmessage-' + id + '"></style>' );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a <style> tag in <head> if it doesn't already exist,
|
||||
* by calling the this.add method, and then add styles inside it.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {string} id - The field-ID.
|
||||
* @param {string} styles - The styles to add.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
addData( id, styles ) {
|
||||
id = id.replace( '[', '-' ).replace( ']', '' );
|
||||
gpPostMessage.styleTag.add( id );
|
||||
jQuery( '#gp-postmessage-' + id ).text( styles );
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Common utilities.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
util: {
|
||||
|
||||
/**
|
||||
* Processes the value and applies any replacements and/or additions.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {Object} output - The output (js_vars) argument.
|
||||
* @param {mixed} value - The value.
|
||||
* @param {string} controlType - The control-type.
|
||||
*
|
||||
* @return {string|false} - Returns false if value is excluded, otherwise a string.
|
||||
*/
|
||||
processValue( output, value ) {
|
||||
var self = this,
|
||||
settings = window.parent.wp.customize.get(),
|
||||
excluded = false;
|
||||
|
||||
if ( 'object' === typeof value ) {
|
||||
_.each( value, function( subValue, key ) {
|
||||
value[ key ] = self.processValue( output, subValue );
|
||||
} );
|
||||
return value;
|
||||
}
|
||||
output = _.defaults( output, {
|
||||
prefix: '',
|
||||
units: '',
|
||||
suffix: '',
|
||||
value_pattern: '$',
|
||||
pattern_replace: {},
|
||||
exclude: [],
|
||||
} );
|
||||
|
||||
if ( 1 <= output.exclude.length ) {
|
||||
_.each( output.exclude, function( exclusion ) {
|
||||
if ( value == exclusion ) {
|
||||
excluded = true;
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
if ( excluded ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
value = output.value_pattern.replace( new RegExp( '\\$', 'g' ), value );
|
||||
_.each( output.pattern_replace, function( id, placeholder ) {
|
||||
if ( ! _.isUndefined( settings[ id ] ) ) {
|
||||
value = value.replace( placeholder, settings[ id ] );
|
||||
}
|
||||
} );
|
||||
return output.prefix + value + output.units + output.suffix;
|
||||
},
|
||||
|
||||
/**
|
||||
* Make sure urls are properly formatted for background-image properties.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {string} url - The URL.
|
||||
*
|
||||
* @return {string} - Returns the URL.
|
||||
*/
|
||||
backgroundImageValue( url ) {
|
||||
return ( -1 === url.indexOf( 'url(' ) ) ? 'url(' + url + ')' : url;
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* A collection of utilities for CSS generation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
css: {
|
||||
|
||||
/**
|
||||
* Generates the CSS from the output (js_vars) parameter.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {Object} output - The output (js_vars) argument.
|
||||
* @param {mixed} value - The value.
|
||||
* @param {string} controlType - The control-type.
|
||||
*
|
||||
* @return {string} - Returns CSS as a string.
|
||||
*/
|
||||
fromOutput( output, value, controlType ) {
|
||||
var styles = '',
|
||||
mediaQuery = false,
|
||||
processedValue;
|
||||
|
||||
try {
|
||||
value = JSON.parse( value );
|
||||
} catch ( e ) {} // eslint-disable-line no-empty
|
||||
|
||||
if ( output.js_callback && 'function' === typeof window[ output.js_callback ] ) {
|
||||
value = window[ output.js_callback[ 0 ] ]( value, output.js_callback[ 1 ] );
|
||||
}
|
||||
|
||||
// Apply the gpPostMessageStylesOutput filter.
|
||||
styles = wp.hooks.applyFilters( 'gpPostMessageStylesOutput', styles, value, output, controlType );
|
||||
|
||||
if ( '' === styles ) {
|
||||
switch ( controlType ) {
|
||||
case 'kirki-multicolor':
|
||||
case 'kirki-sortable':
|
||||
styles += output.element + '{';
|
||||
_.each( value, function( val, key ) {
|
||||
if ( output.choice && key !== output.choice ) {
|
||||
return;
|
||||
}
|
||||
processedValue = gpPostMessage.util.processValue( output, val );
|
||||
|
||||
if ( '' === processedValue ) {
|
||||
if ( 'background-color' === output.property ) {
|
||||
processedValue = 'unset';
|
||||
} else if ( 'background-image' === output.property ) {
|
||||
processedValue = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if ( false !== processedValue ) {
|
||||
styles += output.property ? output.property + '-' + key + ':' + processedValue + ';' : key + ':' + processedValue + ';';
|
||||
}
|
||||
} );
|
||||
styles += '}';
|
||||
break;
|
||||
default:
|
||||
if ( 'kirki-image' === controlType ) {
|
||||
value = ( ! _.isUndefined( value.url ) ) ? gpPostMessage.util.backgroundImageValue( value.url ) : gpPostMessage.util.backgroundImageValue( value );
|
||||
}
|
||||
if ( _.isObject( value ) ) {
|
||||
styles += output.element + '{';
|
||||
_.each( value, function( val, key ) {
|
||||
var property;
|
||||
if ( output.choice && key !== output.choice ) {
|
||||
return;
|
||||
}
|
||||
processedValue = gpPostMessage.util.processValue( output, val );
|
||||
property = output.property ? output.property : key;
|
||||
|
||||
if ( '' === processedValue ) {
|
||||
if ( 'background-color' === property ) {
|
||||
processedValue = 'unset';
|
||||
} else if ( 'background-image' === property ) {
|
||||
processedValue = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if ( false !== processedValue ) {
|
||||
styles += property + ':' + processedValue + ';';
|
||||
}
|
||||
} );
|
||||
styles += '}';
|
||||
} else {
|
||||
processedValue = gpPostMessage.util.processValue( output, value );
|
||||
if ( '' === processedValue ) {
|
||||
if ( 'background-color' === output.property ) {
|
||||
processedValue = 'unset';
|
||||
} else if ( 'background-image' === output.property ) {
|
||||
processedValue = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if ( false !== processedValue ) {
|
||||
styles += output.element + '{' + output.property + ':' + processedValue + ';}';
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the media-query.
|
||||
if ( output.media_query && 'string' === typeof output.media_query && ! _.isEmpty( output.media_query ) ) {
|
||||
mediaQuery = output.media_query;
|
||||
if ( -1 === mediaQuery.indexOf( '@media' ) ) {
|
||||
mediaQuery = '@media ' + mediaQuery;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a media-query, add it and return.
|
||||
if ( mediaQuery ) {
|
||||
return mediaQuery + '{' + styles + '}';
|
||||
}
|
||||
|
||||
// Return the styles.
|
||||
return styles;
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* A collection of utilities to change the HTML in the document.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
html: {
|
||||
|
||||
/**
|
||||
* Modifies the HTML from the output (js_vars) parameter.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {Object} output - The output (js_vars) argument.
|
||||
* @param {mixed} value - The value.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
fromOutput( output, value ) {
|
||||
if ( output.js_callback && 'function' === typeof window[ output.js_callback ] ) {
|
||||
value = window[ output.js_callback[ 0 ] ]( value, output.js_callback[ 1 ] );
|
||||
}
|
||||
|
||||
if ( _.isObject( value ) || _.isArray( value ) ) {
|
||||
if ( ! output.choice ) {
|
||||
return;
|
||||
}
|
||||
_.each( value, function( val, key ) {
|
||||
if ( output.choice && key !== output.choice ) {
|
||||
return;
|
||||
}
|
||||
value = val;
|
||||
} );
|
||||
}
|
||||
value = gpPostMessage.util.processValue( output, value );
|
||||
|
||||
if ( output.attr ) {
|
||||
jQuery( output.element ).attr( output.attr, value );
|
||||
} else {
|
||||
jQuery( output.element ).html( value );
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* A collection of utilities to allow toggling a CSS class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
toggleClass: {
|
||||
|
||||
/**
|
||||
* Toggles a CSS class from the output (js_vars) parameter.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param {Object} output - The output (js_vars) argument.
|
||||
* @param {mixed} value - The value.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
fromOutput( output, value ) {
|
||||
if ( 'undefined' === typeof output.class || 'undefined' === typeof output.value ) {
|
||||
return;
|
||||
}
|
||||
if ( value === output.value && ! jQuery( output.element ).hasClass( output.class ) ) {
|
||||
jQuery( output.element ).addClass( output.class );
|
||||
} else {
|
||||
jQuery( output.element ).removeClass( output.class );
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
jQuery( document ).ready( function() {
|
||||
var styles;
|
||||
_.each( gpPostMessageFields, function( field ) {
|
||||
wp.customize( field.settings, function( value ) {
|
||||
value.bind( function( newVal ) {
|
||||
styles = '';
|
||||
_.each( field.js_vars, function( output ) {
|
||||
output.function = ( ! output.function || 'undefined' === typeof gpPostMessage[ output.function ] ) ? 'css' : output.function;
|
||||
field.type = ( field.choices && field.choices.parent_type ) ? field.choices.parent_type : field.type;
|
||||
|
||||
if ( 'css' === output.function ) {
|
||||
styles += gpPostMessage.css.fromOutput( output, newVal, field.type );
|
||||
} else {
|
||||
gpPostMessage[ output.function ].fromOutput( output, newVal, field.type );
|
||||
}
|
||||
} );
|
||||
gpPostMessage.styleTag.addData( field.settings, styles );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
} );
|
@ -1,23 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Load necessary Customizer controls and functions.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
// Controls.
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-range-control.php';
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-typography-control.php';
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-upsell-section.php';
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-upsell-control.php';
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-deprecated.php';
|
||||
|
||||
// Helper functions.
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'helpers.php';
|
||||
|
||||
// Deprecated.
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'deprecated.php';
|
||||
<?php
|
||||
/**
|
||||
* Load necessary Customizer controls and functions.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
// Add fields.
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'class-customize-field.php';
|
||||
|
||||
// Controls.
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-react-control.php';
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-color-control.php';
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-range-control.php';
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-typography-control.php';
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-upsell-section.php';
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-upsell-control.php';
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'controls/class-deprecated.php';
|
||||
|
||||
// Helper functions.
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'helpers.php';
|
||||
|
||||
// Deprecated.
|
||||
require_once trailingslashit( dirname( __FILE__ ) ) . 'deprecated.php';
|
||||
|
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the back to top button.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_back_to_top_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Back to Top', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'back-to-top-colors',
|
||||
),
|
||||
'active_callback' => function() {
|
||||
if ( generate_get_option( 'back_to_top' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_back_to_top_background_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'back-to-top-colors',
|
||||
'items' => array(
|
||||
'back_to_top_background_color',
|
||||
'back_to_top_background_color_hover',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[back_to_top_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['back_to_top_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'back-to-top-colors',
|
||||
'wrapper' => 'back_to_top_background_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'a.generate-back-to-top',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[back_to_top_background_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['back_to_top_background_color_hover'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'back-to-top-colors',
|
||||
'wrapper' => 'back_to_top_background_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'a.generate-back-to-top:hover, a.generate-back-to-top:focus',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_back_to_top_text_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'back-to-top-colors',
|
||||
'items' => array(
|
||||
'back_to_top_text_color',
|
||||
'back_to_top_text_color_hover',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[back_to_top_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['back_to_top_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'button-colors',
|
||||
'wrapper' => 'back_to_top_text_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'a.generate-back-to-top',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[back_to_top_text_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['back_to_top_text_color_hover'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'back-to-top-colors',
|
||||
'wrapper' => 'back_to_top_text_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'a.generate-back-to-top:hover, a.generate-back-to-top:focus',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
156
wp-content/themes/generatepress/inc/customizer/fields/body.php
Normal file
156
wp-content/themes/generatepress/inc/customizer/fields/body.php
Normal file
@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the Body.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_body_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Body', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'base-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $defaults['background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'base-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'body',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $defaults['text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'base-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'body',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_body_link_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'base-colors',
|
||||
'items' => array(
|
||||
'link_color',
|
||||
'link_color_hover',
|
||||
'link_color_visited',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $defaults['link_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'toggleId' => 'base-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'a, a:visited',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[link_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $defaults['link_color_hover'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'link_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'toggleId' => 'base-colors',
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => 'a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
if ( '' !== generate_get_option( 'link_color_visited' ) ) {
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[link_color_visited]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $defaults['link_color_visited'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'refresh',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Color Visited', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'link_color_visited',
|
||||
'tooltip' => __( 'Choose Visited Color', 'generatepress' ),
|
||||
'toggleId' => 'base-colors',
|
||||
'hideLabel' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the Body.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_buttons_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Buttons', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'button-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_buttons_background_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'button-colors',
|
||||
'items' => array(
|
||||
'form_button_background_color',
|
||||
'form_button_background_color_hover',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$buttons_selector = 'button, html input[type="button"], input[type="reset"], input[type="submit"], a.button, a.button:visited, a.wp-block-button__link:not(.has-background)';
|
||||
$buttons_hover_selector = 'button:hover, html input[type="button"]:hover, input[type="reset"]:hover, input[type="submit"]:hover, a.button:hover, button:focus, html input[type="button"]:focus, input[type="reset"]:focus, input[type="submit"]:focus, a.button:focus, a.wp-block-button__link:not(.has-background):active, a.wp-block-button__link:not(.has-background):focus, a.wp-block-button__link:not(.has-background):hover';
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_button_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_button_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'button-colors',
|
||||
'wrapper' => 'form_button_background_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $buttons_selector,
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_button_background_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_button_background_color_hover'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'button-colors',
|
||||
'wrapper' => 'form_button_background_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $buttons_hover_selector,
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_buttons_text_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'button-colors',
|
||||
'items' => array(
|
||||
'form_button_text_color',
|
||||
'form_button_text_color_hover',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_button_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_button_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'button-colors',
|
||||
'wrapper' => 'form_button_text_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $buttons_selector,
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_button_text_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_button_text_color_hover'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'button-colors',
|
||||
'wrapper' => 'form_button_text_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $buttons_hover_selector,
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
@ -0,0 +1,372 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the content.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_content_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Content', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$content_colors = '.separate-containers .inside-article, .separate-containers .comments-area, .separate-containers .page-header, .one-container .container, .separate-containers .paging-navigation, .inside-page-header';
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[content_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['content_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $content_colors,
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[content_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['content_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $content_colors,
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_content_link_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'content-colors',
|
||||
'items' => array(
|
||||
'content_link_color',
|
||||
'content_link_hover_color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[content_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['content_link_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'content_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.inside-article a:not(.button):not(.wp-block-button__link), .inside-article a:not(.button):not(.wp-block-button__link):visited, .paging-navigation a, .paging-navigation a:visited, .comments-area a, .comments-area a:visited, .page-header a, .page-header a:visited',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[content_link_hover_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['content_link_hover_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'content_link_hover_color',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'toggleId' => 'content-colors',
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.inside-article a:not(.button):not(.wp-block-button__link):hover, .paging-navigation a:hover, .comments-area a:hover, .page-header a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[content_title_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['content_title_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Content Title', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.entry-header h1,.page-header h1',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_archive_content_title_link_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'content-colors',
|
||||
'items' => array(
|
||||
'blog_post_title_color',
|
||||
'blog_post_title_hover_color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[blog_post_title_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['blog_post_title_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Archive Content Title', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'blog_post_title_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.entry-title a,.entry-title a:visited',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[blog_post_title_hover_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['blog_post_title_hover_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Archive Content Title Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'blog_post_title_hover_color',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'toggleId' => 'content-colors',
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.entry-title a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[entry_meta_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['entry_meta_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Entry Meta Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.entry-meta',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_entry_meta_link_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'content-colors',
|
||||
'items' => array(
|
||||
'entry_meta_link_color',
|
||||
'entry_meta_link_color_hover',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[entry_meta_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['entry_meta_link_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Entry Meta Links', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'entry_meta_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.entry-meta a',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[entry_meta_link_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['entry_meta_link_color_hover'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Entry Meta Links Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'wrapper' => 'entry_meta_link_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'toggleId' => 'content-colors',
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.entry-meta a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$headings = array(
|
||||
array(
|
||||
'slug' => 'h1_color',
|
||||
'label' => __( 'Heading 1 (H1) Color', 'generatepress' ),
|
||||
'selector' => 'h1',
|
||||
),
|
||||
array(
|
||||
'slug' => 'h2_color',
|
||||
'label' => __( 'Heading 2 (H2) Color', 'generatepress' ),
|
||||
'selector' => 'h2',
|
||||
),
|
||||
array(
|
||||
'slug' => 'h3_color',
|
||||
'label' => __( 'Heading 3 (H3) Color', 'generatepress' ),
|
||||
'selector' => 'h3',
|
||||
),
|
||||
array(
|
||||
'slug' => 'h4_color',
|
||||
'label' => __( 'Heading 4 (H4) Color', 'generatepress' ),
|
||||
'selector' => 'h4',
|
||||
),
|
||||
array(
|
||||
'slug' => 'h5_color',
|
||||
'label' => __( 'Heading 5 (H5) Color', 'generatepress' ),
|
||||
'selector' => 'h5',
|
||||
),
|
||||
array(
|
||||
'slug' => 'h6_color',
|
||||
'label' => __( 'Heading 6 (H6) Color', 'generatepress' ),
|
||||
'selector' => 'h6',
|
||||
),
|
||||
);
|
||||
|
||||
foreach ( $headings as $heading ) {
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[' . $heading['slug'] . ']',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults[ $heading['slug'] ],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => $heading['label'],
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'content-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $heading['selector'],
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the footer bar.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_footer_bar_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Footer Bar', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-bar-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'footer-bar-colors',
|
||||
'wrapper' => 'footer_background_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-info',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-bar-colors',
|
||||
'wrapper' => 'footer_text_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-info',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_footer_bar_colors_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'footer-bar-colors',
|
||||
'items' => array(
|
||||
'footer_link_color',
|
||||
'footer_link_hover_color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_link_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-bar-colors',
|
||||
'wrapper' => 'footer_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-info a',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_link_hover_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_link_hover_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-bar-colors',
|
||||
'wrapper' => 'footer_link_hover_color',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-info a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the footer widgets.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_footer_widgets_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Footer Widgets', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_widget_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_widget_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
'wrapper' => 'footer_widget_background_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.footer-widgets',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_widget_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_widget_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
'wrapper' => 'footer_widget_text_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.footer-widgets',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_footer_widget_colors_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
'items' => array(
|
||||
'footer_widget_link_color',
|
||||
'footer_widget_link_hover_color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_widget_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_widget_link_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
'wrapper' => 'footer_widget_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.footer-widgets a',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_widget_link_hover_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_widget_link_hover_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
'wrapper' => 'footer_widget_link_hover_color',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.footer-widgets a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[footer_widget_title_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['footer_widget_title_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Widget Title', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'footer-widget-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.footer-widgets .widget-title',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
226
wp-content/themes/generatepress/inc/customizer/fields/forms.php
Normal file
226
wp-content/themes/generatepress/inc/customizer/fields/forms.php
Normal file
@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the Body.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_forms_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Forms', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'form-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_forms_background_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'form-colors',
|
||||
'items' => array(
|
||||
'form_background_color',
|
||||
'form_background_color_focus',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$forms_selector = 'input[type="text"], input[type="email"], input[type="url"], input[type="password"], input[type="search"], input[type="number"], input[type="tel"], textarea, select';
|
||||
$forms_focus_selector = 'input[type="text"]:focus, input[type="email"]:focus, input[type="url"]:focus, input[type="password"]:focus, input[type="search"]:focus, input[type="number"]:focus, input[type="tel"]:focus, textarea:focus, select:focus';
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'form-colors',
|
||||
'wrapper' => 'form_background_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $forms_selector,
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_background_color_focus]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_background_color_focus'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background Focus', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'form-colors',
|
||||
'wrapper' => 'form_background_color_focus',
|
||||
'tooltip' => __( 'Choose Focus Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $forms_focus_selector,
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_forms_text_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'form-colors',
|
||||
'items' => array(
|
||||
'form_text_color',
|
||||
'form_text_color_focus',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'form-colors',
|
||||
'wrapper' => 'form_text_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $forms_selector,
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_text_color_focus]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_text_color_focus'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text Focus', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'form-colors',
|
||||
'wrapper' => 'form_text_color_focus',
|
||||
'tooltip' => __( 'Choose Focus Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $forms_focus_selector,
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_forms_border_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'form-colors',
|
||||
'items' => array(
|
||||
'form_border_color',
|
||||
'form_border_color_focus',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_border_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_border_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Border', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'form-colors',
|
||||
'wrapper' => 'form_border_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $forms_selector,
|
||||
'property' => 'border-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[form_border_color_focus]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['form_border_color_focus'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Border Focus', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'form-colors',
|
||||
'wrapper' => 'form_border_color_focus',
|
||||
'tooltip' => __( 'Choose Focus Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => $forms_focus_selector,
|
||||
'property' => 'border-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
180
wp-content/themes/generatepress/inc/customizer/fields/header.php
Normal file
180
wp-content/themes/generatepress/inc/customizer/fields/header.php
Normal file
@ -0,0 +1,180 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the header.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_header_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Header', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'header-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[header_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['header_background_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'header-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-header',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[header_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['header_text_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'header-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-header',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_header_link_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'header-colors',
|
||||
'items' => array(
|
||||
'header_link_color',
|
||||
'header_link_hover_color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[header_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['header_link_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'header-colors',
|
||||
'wrapper' => 'header_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-header a:not([rel="home"])',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[header_link_hover_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['header_link_hover_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'header-colors',
|
||||
'wrapper' => 'header_link_hover_color',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-header a:not([rel="home"]):hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[site_title_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['site_title_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Site Title', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'header-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.main-title a, .main-title a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[site_tagline_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['site_tagline_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Tagline', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'header-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.site-description',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
@ -0,0 +1,214 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the primary navigation.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*
|
||||
* @var array $color_defaults
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
$menu_hover_selectors = '.navigation-search input[type="search"], .navigation-search input[type="search"]:active, .navigation-search input[type="search"]:focus, .main-navigation .main-nav ul li:not([class*="current-menu-"]):hover > a, .main-navigation .main-nav ul li:not([class*="current-menu-"]):focus > a, .main-navigation .main-nav ul li.sfHover:not([class*="current-menu-"]) > a, .main-navigation .menu-bar-item:hover > a, .main-navigation .menu-bar-item.sfHover > a';
|
||||
$menu_current_selectors = '.main-navigation .main-nav ul li[class*="current-menu-"] > a';
|
||||
$submenu_hover_selectors = '.main-navigation .main-nav ul ul li:not([class*="current-menu-"]):hover > a,.main-navigation .main-nav ul ul li:not([class*="current-menu-"]):focus > a,.main-navigation .main-nav ul ul li.sfHover:not([class*="current-menu-"]) > a';
|
||||
$submenu_current_selectors = '.main-navigation .main-nav ul ul li[class*="current-menu-"] > a';
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_primary_navigation_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Primary Navigation', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'primary-navigation-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Navigation background group.
|
||||
GeneratePress_Customize_Field::add_color_field_group(
|
||||
'primary_navigation_background',
|
||||
'generate_colors_section',
|
||||
'primary-navigation-colors',
|
||||
array(
|
||||
'generate_settings[navigation_background_color]' => array(
|
||||
'default_value' => $color_defaults['navigation_background_color'],
|
||||
'label' => __( 'Navigation Background', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'element' => '.main-navigation',
|
||||
'property' => 'background-color',
|
||||
'hide_label' => false,
|
||||
),
|
||||
'generate_settings[navigation_background_hover_color]' => array(
|
||||
'default_value' => $color_defaults['navigation_background_hover_color'],
|
||||
'label' => __( 'Navigation Background Hover', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'element' => $menu_hover_selectors,
|
||||
'property' => 'background-color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
'generate_settings[navigation_background_current_color]' => array(
|
||||
'default_value' => $color_defaults['navigation_background_current_color'],
|
||||
'label' => __( 'Navigation Background Current', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Current Color', 'generatepress' ),
|
||||
'element' => $menu_current_selectors,
|
||||
'property' => 'background-color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Navigation text group.
|
||||
GeneratePress_Customize_Field::add_color_field_group(
|
||||
'primary_navigation_text',
|
||||
'generate_colors_section',
|
||||
'primary-navigation-colors',
|
||||
array(
|
||||
'generate_settings[navigation_text_color]' => array(
|
||||
'default_value' => $color_defaults['navigation_text_color'],
|
||||
'label' => __( 'Navigation Text', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'element' => '.main-navigation .main-nav ul li a, .main-navigation .menu-toggle, .main-navigation button.menu-toggle:hover, .main-navigation button.menu-toggle:focus, .main-navigation .mobile-bar-items a, .main-navigation .mobile-bar-items a:hover, .main-navigation .mobile-bar-items a:focus, .main-navigation .menu-bar-items',
|
||||
'property' => 'color',
|
||||
'hide_label' => false,
|
||||
),
|
||||
'generate_settings[navigation_text_hover_color]' => array(
|
||||
'default_value' => $color_defaults['navigation_text_hover_color'],
|
||||
'label' => __( 'Navigation Text Hover', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'element' => $menu_hover_selectors,
|
||||
'property' => 'color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
'generate_settings[navigation_text_current_color]' => array(
|
||||
'default_value' => $color_defaults['navigation_text_current_color'],
|
||||
'label' => __( 'Navigation Text Current', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Current Color', 'generatepress' ),
|
||||
'element' => $menu_current_selectors,
|
||||
'property' => 'color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Sub-Menu background group.
|
||||
GeneratePress_Customize_Field::add_color_field_group(
|
||||
'primary_navigation_submenu_background',
|
||||
'generate_colors_section',
|
||||
'primary-navigation-colors',
|
||||
array(
|
||||
'generate_settings[subnavigation_background_color]' => array(
|
||||
'default_value' => $color_defaults['subnavigation_background_color'],
|
||||
'label' => __( 'Sub-Menu Background', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'element' => '.main-navigation ul ul',
|
||||
'property' => 'background-color',
|
||||
'hide_label' => false,
|
||||
),
|
||||
'generate_settings[subnavigation_background_hover_color]' => array(
|
||||
'default_value' => $color_defaults['subnavigation_background_hover_color'],
|
||||
'label' => __( 'Sub-Menu Background Hover', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'element' => $submenu_hover_selectors,
|
||||
'property' => 'background-color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
'generate_settings[subnavigation_background_current_color]' => array(
|
||||
'default_value' => $color_defaults['subnavigation_background_current_color'],
|
||||
'label' => __( 'Sub-Menu Background Current', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Current Color', 'generatepress' ),
|
||||
'element' => $submenu_current_selectors,
|
||||
'property' => 'background-color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Sub-Menu text group.
|
||||
GeneratePress_Customize_Field::add_color_field_group(
|
||||
'primary_navigation_submenu_text',
|
||||
'generate_colors_section',
|
||||
'primary-navigation-colors',
|
||||
array(
|
||||
'generate_settings[subnavigation_text_color]' => array(
|
||||
'default_value' => $color_defaults['subnavigation_text_color'],
|
||||
'label' => __( 'Sub-Menu Text', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'element' => '.main-navigation .main-nav ul ul li a',
|
||||
'property' => 'color',
|
||||
'hide_label' => false,
|
||||
),
|
||||
'generate_settings[subnavigation_text_hover_color]' => array(
|
||||
'default_value' => $color_defaults['subnavigation_text_hover_color'],
|
||||
'label' => __( 'Sub-Menu Text Hover', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'element' => $submenu_hover_selectors,
|
||||
'property' => 'color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
'generate_settings[subnavigation_text_current_color]' => array(
|
||||
'default_value' => $color_defaults['subnavigation_text_current_color'],
|
||||
'label' => __( 'Sub-Menu Text Current', 'generatepress' ),
|
||||
'tooltip' => __( 'Choose Current Color', 'generatepress' ),
|
||||
'element' => $submenu_current_selectors,
|
||||
'property' => 'color',
|
||||
'hide_label' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_navigation_search_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Navigation Search', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'primary-navigation-search-colors',
|
||||
),
|
||||
'active_callback' => function() {
|
||||
if ( 'enable' === generate_get_option( 'nav_search' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[navigation_search_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['navigation_search_background_color'],
|
||||
'transport' => 'refresh',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'primary-navigation-search-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[navigation_search_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['navigation_search_text_color'],
|
||||
'transport' => 'refresh',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'primary-navigation-search-colors',
|
||||
),
|
||||
)
|
||||
);
|
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the sidebar widgets.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_sidebar_widgets_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Sidebar Widgets', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[sidebar_widget_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['sidebar_widget_background_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
'wrapper' => 'sidebar_widget_background_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.sidebar .widget',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[sidebar_widget_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['sidebar_widget_text_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
'wrapper' => 'sidebar_widget_text_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.sidebar .widget',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_sidebar_widget_colors_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
'items' => array(
|
||||
'sidebar_widget_link_color',
|
||||
'sidebar_widget_link_hover_color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[sidebar_widget_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['sidebar_widget_link_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
'wrapper' => 'sidebar_widget_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.sidebar .widget a',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[sidebar_widget_link_hover_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['sidebar_widget_link_hover_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
'wrapper' => 'sidebar_widget_link_hover_color',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.sidebar .widget a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[sidebar_widget_title_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['sidebar_widget_title_color'],
|
||||
'sanitize_callback' => 'generate_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Widget Title', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'toggleId' => 'sidebar-widget-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.sidebar .widget .widget-title',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the customizer fields for the top bar.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
GeneratePress_Customize_Field::add_title(
|
||||
'generate_top_bar_colors_title',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'title' => __( 'Top Bar', 'generatepress' ),
|
||||
'choices' => array(
|
||||
'toggleId' => 'top-bar-colors',
|
||||
),
|
||||
'active_callback' => 'generate_is_top_bar_active',
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[top_bar_background_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['top_bar_background_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Background', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'settings' => 'generate_settings[top_bar_background_color]',
|
||||
'active_callback' => 'generate_is_top_bar_active',
|
||||
'choices' => array(
|
||||
'alpha' => true,
|
||||
'toggleId' => 'top-bar-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.top-bar',
|
||||
'property' => 'background-color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[top_bar_text_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['top_bar_text_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Text', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'active_callback' => 'generate_is_top_bar_active',
|
||||
'choices' => array(
|
||||
'toggleId' => 'top-bar-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.top-bar',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_wrapper(
|
||||
'generate_top_bar_link_wrapper',
|
||||
array(
|
||||
'section' => 'generate_colors_section',
|
||||
'choices' => array(
|
||||
'type' => 'color',
|
||||
'toggleId' => 'top-bar-colors',
|
||||
'items' => array(
|
||||
'top_bar_link_color',
|
||||
'top_bar_link_color_hover',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[top_bar_link_color]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['top_bar_link_color'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'active_callback' => 'generate_is_top_bar_active',
|
||||
'choices' => array(
|
||||
'wrapper' => 'top_bar_link_color',
|
||||
'tooltip' => __( 'Choose Initial Color', 'generatepress' ),
|
||||
'toggleId' => 'top-bar-colors',
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.top-bar a',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
GeneratePress_Customize_Field::add_field(
|
||||
'generate_settings[top_bar_link_color_hover]',
|
||||
'GeneratePress_Customize_Color_Control',
|
||||
array(
|
||||
'default' => $color_defaults['top_bar_link_color_hover'],
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_sanitize_rgba_color',
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Link Hover', 'generatepress' ),
|
||||
'section' => 'generate_colors_section',
|
||||
'active_callback' => 'generate_is_top_bar_active',
|
||||
'choices' => array(
|
||||
'wrapper' => 'top_bar_link_color_hover',
|
||||
'tooltip' => __( 'Choose Hover Color', 'generatepress' ),
|
||||
'toggleId' => 'top-bar-colors',
|
||||
'hideLabel' => true,
|
||||
),
|
||||
'output' => array(
|
||||
array(
|
||||
'element' => '.top-bar a:hover',
|
||||
'property' => 'color',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
@ -1,348 +1,453 @@
|
||||
<?php
|
||||
/**
|
||||
* Helper functions for the Customizer.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_is_posts_page' ) ) {
|
||||
/**
|
||||
* Check to see if we're on a posts page
|
||||
*
|
||||
* @since 1.3.39
|
||||
*/
|
||||
function generate_is_posts_page() {
|
||||
return ( is_home() || is_archive() || is_tax() ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_is_footer_bar_active' ) ) {
|
||||
/**
|
||||
* Check to see if we're using our footer bar widget
|
||||
*
|
||||
* @since 1.3.42
|
||||
*/
|
||||
function generate_is_footer_bar_active() {
|
||||
return ( is_active_sidebar( 'footer-bar' ) ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_is_top_bar_active' ) ) {
|
||||
/**
|
||||
* Check to see if the top bar is active
|
||||
*
|
||||
* @since 1.3.45
|
||||
*/
|
||||
function generate_is_top_bar_active() {
|
||||
$top_bar = is_active_sidebar( 'top-bar' ) ? true : false;
|
||||
return apply_filters( 'generate_is_top_bar_active', $top_bar );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_customize_partial_blogname' ) ) {
|
||||
/**
|
||||
* Render the site title for the selective refresh partial.
|
||||
*
|
||||
* @since 1.3.41
|
||||
*/
|
||||
function generate_customize_partial_blogname() {
|
||||
bloginfo( 'name' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_customize_partial_blogdescription' ) ) {
|
||||
/**
|
||||
* Render the site tagline for the selective refresh partial.
|
||||
*
|
||||
* @since 1.3.41
|
||||
*/
|
||||
function generate_customize_partial_blogdescription() {
|
||||
bloginfo( 'description' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_enqueue_color_palettes' ) ) {
|
||||
add_action( 'customize_controls_enqueue_scripts', 'generate_enqueue_color_palettes' );
|
||||
/**
|
||||
* Add our custom color palettes to the color pickers in the Customizer.
|
||||
*
|
||||
* @since 1.3.42
|
||||
*/
|
||||
function generate_enqueue_color_palettes() {
|
||||
// Old versions of WP don't get nice things.
|
||||
if ( ! function_exists( 'wp_add_inline_script' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Grab our palette array and turn it into JS.
|
||||
$palettes = wp_json_encode( generate_get_default_color_palettes() );
|
||||
|
||||
// Add our custom palettes.
|
||||
// json_encode takes care of escaping.
|
||||
wp_add_inline_script( 'wp-color-picker', 'jQuery.wp.wpColorPicker.prototype.options.palettes = ' . $palettes . ';' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_integer' ) ) {
|
||||
/**
|
||||
* Sanitize integers.
|
||||
*
|
||||
* @since 1.0.8
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_integer( $input ) {
|
||||
return absint( $input );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_decimal_integer' ) ) {
|
||||
/**
|
||||
* Sanitize integers that can use decimals.
|
||||
*
|
||||
* @since 1.3.41
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_decimal_integer( $input ) {
|
||||
return abs( floatval( $input ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize a positive number, but allow an empty value.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_empty_absint( $input ) {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
if ( '' == $input ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return absint( $input );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_checkbox' ) ) {
|
||||
/**
|
||||
* Sanitize checkbox values.
|
||||
*
|
||||
* @since 1.0.8
|
||||
* @param string $checked The value to check.
|
||||
*/
|
||||
function generate_sanitize_checkbox( $checked ) {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
return ( ( isset( $checked ) && true == $checked ) ? true : false );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_blog_excerpt' ) ) {
|
||||
/**
|
||||
* Sanitize blog excerpt.
|
||||
* Needed because GP Premium calls the control ID which is different from the settings ID.
|
||||
*
|
||||
* @since 1.0.8
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_blog_excerpt( $input ) {
|
||||
$valid = array(
|
||||
'full',
|
||||
'excerpt',
|
||||
);
|
||||
|
||||
if ( in_array( $input, $valid ) ) {
|
||||
return $input;
|
||||
} else {
|
||||
return 'full';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_hex_color' ) ) {
|
||||
/**
|
||||
* Sanitize colors.
|
||||
* Allow blank value.
|
||||
*
|
||||
* @since 1.2.9.6
|
||||
* @param string $color The color to check.
|
||||
*/
|
||||
function generate_sanitize_hex_color( $color ) {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
if ( '' === $color ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// 3 or 6 hex digits, or the empty string.
|
||||
if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
|
||||
return $color;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize RGBA colors.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $color The color to check.
|
||||
*/
|
||||
function generate_sanitize_rgba_color( $color ) {
|
||||
if ( '' === $color ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( false === strpos( $color, 'rgba' ) ) {
|
||||
return generate_sanitize_hex_color( $color );
|
||||
}
|
||||
|
||||
$color = str_replace( ' ', '', $color );
|
||||
sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
|
||||
|
||||
return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_choices' ) ) {
|
||||
/**
|
||||
* Sanitize choices.
|
||||
*
|
||||
* @since 1.3.24
|
||||
* @param string $input The value to check.
|
||||
* @param object $setting The setting object.
|
||||
*/
|
||||
function generate_sanitize_choices( $input, $setting ) {
|
||||
// Ensure input is a slug.
|
||||
$input = sanitize_key( $input );
|
||||
|
||||
// Get list of choices from the control.
|
||||
// associated with the setting.
|
||||
$choices = $setting->manager->get_control( $setting->id )->choices;
|
||||
|
||||
// If the input is a valid key, return it.
|
||||
// otherwise, return the default.
|
||||
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize our Google Font variants
|
||||
*
|
||||
* @since 2.0
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_variants( $input ) {
|
||||
if ( is_array( $input ) ) {
|
||||
$input = implode( ',', $input );
|
||||
}
|
||||
return sanitize_text_field( $input );
|
||||
}
|
||||
|
||||
add_action( 'customize_controls_enqueue_scripts', 'generate_do_control_inline_scripts', 100 );
|
||||
/**
|
||||
* Add misc inline scripts to our controls.
|
||||
*
|
||||
* We don't want to add these to the controls themselves, as they will be repeated
|
||||
* each time the control is initialized.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
function generate_do_control_inline_scripts() {
|
||||
wp_localize_script(
|
||||
'generatepress-typography-customizer',
|
||||
'gp_customize',
|
||||
array(
|
||||
'nonce' => wp_create_nonce( 'gp_customize_nonce' ),
|
||||
)
|
||||
);
|
||||
|
||||
$number_of_fonts = apply_filters( 'generate_number_of_fonts', 200 );
|
||||
|
||||
wp_localize_script(
|
||||
'generatepress-typography-customizer',
|
||||
'generatePressTypography',
|
||||
array(
|
||||
'googleFonts' => apply_filters( 'generate_typography_customize_list', generate_get_all_google_fonts( $number_of_fonts ) ),
|
||||
)
|
||||
);
|
||||
|
||||
wp_localize_script( 'generatepress-typography-customizer', 'typography_defaults', generate_typography_default_fonts() );
|
||||
|
||||
wp_enqueue_script( 'generatepress-customizer-controls', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/customizer-controls.js', array( 'customize-controls', 'jquery' ), GENERATE_VERSION, true );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_defaults', generate_get_defaults() );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_color_defaults', generate_get_color_defaults() );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_typography_defaults', generate_get_default_fonts() );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_spacing_defaults', generate_spacing_get_defaults() );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_customizer_live_preview' ) ) {
|
||||
add_action( 'customize_preview_init', 'generate_customizer_live_preview', 100 );
|
||||
/**
|
||||
* Add our live preview scripts
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_customizer_live_preview() {
|
||||
$spacing_settings = wp_parse_args(
|
||||
get_option( 'generate_spacing_settings', array() ),
|
||||
generate_spacing_get_defaults()
|
||||
);
|
||||
|
||||
wp_enqueue_script( 'generate-themecustomizer', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/customizer-live-preview.js', array( 'customize-preview' ), GENERATE_VERSION, true );
|
||||
|
||||
wp_localize_script(
|
||||
'generate-themecustomizer',
|
||||
'generatepress_live_preview',
|
||||
array(
|
||||
'mobile' => generate_get_media_query( 'mobile' ),
|
||||
'tablet' => generate_get_media_query( 'tablet' ),
|
||||
'desktop' => generate_get_media_query( 'desktop' ),
|
||||
'contentLeft' => absint( $spacing_settings['content_left'] ),
|
||||
'contentRight' => absint( $spacing_settings['content_right'] ),
|
||||
'isFlex' => generate_is_using_flexbox(),
|
||||
'isRTL' => is_rtl(),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if we have a logo or not.
|
||||
*
|
||||
* Used as an active callback. Calling has_custom_logo creates a PHP notice for
|
||||
* multisite users.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
function generate_has_custom_logo_callback() {
|
||||
if ( get_theme_mod( 'custom_logo' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save our preset layout controls. These should always save to be "current".
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
function generate_sanitize_preset_layout() {
|
||||
return 'current';
|
||||
}
|
||||
|
||||
/**
|
||||
* Display options if we're using the Floats structure.
|
||||
*/
|
||||
function generate_is_using_floats_callback() {
|
||||
return 'floats' === generate_get_option( 'structure' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine whether to show the inline logo option.
|
||||
*/
|
||||
function generate_show_inline_logo_callback() {
|
||||
return 'floats' === generate_get_option( 'structure' ) && generate_has_logo_site_branding();
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Helper functions for the Customizer.
|
||||
*
|
||||
* @package GeneratePress
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_is_posts_page' ) ) {
|
||||
/**
|
||||
* Check to see if we're on a posts page
|
||||
*
|
||||
* @since 1.3.39
|
||||
*/
|
||||
function generate_is_posts_page() {
|
||||
return ( is_home() || is_archive() || is_tax() ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_is_footer_bar_active' ) ) {
|
||||
/**
|
||||
* Check to see if we're using our footer bar widget
|
||||
*
|
||||
* @since 1.3.42
|
||||
*/
|
||||
function generate_is_footer_bar_active() {
|
||||
return ( is_active_sidebar( 'footer-bar' ) ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_is_top_bar_active' ) ) {
|
||||
/**
|
||||
* Check to see if the top bar is active
|
||||
*
|
||||
* @since 1.3.45
|
||||
*/
|
||||
function generate_is_top_bar_active() {
|
||||
$top_bar = is_active_sidebar( 'top-bar' ) ? true : false;
|
||||
return apply_filters( 'generate_is_top_bar_active', $top_bar );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_customize_partial_blogname' ) ) {
|
||||
/**
|
||||
* Render the site title for the selective refresh partial.
|
||||
*
|
||||
* @since 1.3.41
|
||||
*/
|
||||
function generate_customize_partial_blogname() {
|
||||
bloginfo( 'name' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_customize_partial_blogdescription' ) ) {
|
||||
/**
|
||||
* Render the site tagline for the selective refresh partial.
|
||||
*
|
||||
* @since 1.3.41
|
||||
*/
|
||||
function generate_customize_partial_blogdescription() {
|
||||
bloginfo( 'description' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_enqueue_color_palettes' ) ) {
|
||||
add_action( 'customize_controls_enqueue_scripts', 'generate_enqueue_color_palettes' );
|
||||
/**
|
||||
* Add our custom color palettes to the color pickers in the Customizer.
|
||||
*
|
||||
* @since 1.3.42
|
||||
*/
|
||||
function generate_enqueue_color_palettes() {
|
||||
// Old versions of WP don't get nice things.
|
||||
if ( ! function_exists( 'wp_add_inline_script' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Grab our palette array and turn it into JS.
|
||||
$palettes = wp_json_encode( generate_get_default_color_palettes() );
|
||||
|
||||
// Add our custom palettes.
|
||||
// json_encode takes care of escaping.
|
||||
wp_add_inline_script( 'wp-color-picker', 'jQuery.wp.wpColorPicker.prototype.options.palettes = ' . $palettes . ';' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_integer' ) ) {
|
||||
/**
|
||||
* Sanitize integers.
|
||||
*
|
||||
* @since 1.0.8
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_integer( $input ) {
|
||||
return absint( $input );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_decimal_integer' ) ) {
|
||||
/**
|
||||
* Sanitize integers that can use decimals.
|
||||
*
|
||||
* @since 1.3.41
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_decimal_integer( $input ) {
|
||||
return abs( floatval( $input ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize integers that can use decimals.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_empty_decimal_integer( $input ) {
|
||||
if ( '' === $input ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return abs( floatval( $input ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize integers that can use negative decimals.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_empty_negative_decimal_integer( $input ) {
|
||||
if ( '' === $input ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return floatval( $input );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize a positive number, but allow an empty value.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_empty_absint( $input ) {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
if ( '' == $input ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return absint( $input );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_checkbox' ) ) {
|
||||
/**
|
||||
* Sanitize checkbox values.
|
||||
*
|
||||
* @since 1.0.8
|
||||
* @param string $checked The value to check.
|
||||
*/
|
||||
function generate_sanitize_checkbox( $checked ) {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
return ( ( isset( $checked ) && true == $checked ) ? true : false );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_blog_excerpt' ) ) {
|
||||
/**
|
||||
* Sanitize blog excerpt.
|
||||
* Needed because GP Premium calls the control ID which is different from the settings ID.
|
||||
*
|
||||
* @since 1.0.8
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_blog_excerpt( $input ) {
|
||||
$valid = array(
|
||||
'full',
|
||||
'excerpt',
|
||||
);
|
||||
|
||||
if ( in_array( $input, $valid ) ) {
|
||||
return $input;
|
||||
} else {
|
||||
return 'full';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_hex_color' ) ) {
|
||||
/**
|
||||
* Sanitize colors.
|
||||
* Allow blank value.
|
||||
*
|
||||
* @since 1.2.9.6
|
||||
* @param string $color The color to check.
|
||||
*/
|
||||
function generate_sanitize_hex_color( $color ) {
|
||||
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Intentially loose.
|
||||
if ( '' === $color ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// 3 or 6 hex digits, or the empty string.
|
||||
if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
|
||||
return $color;
|
||||
}
|
||||
|
||||
if ( strpos( $color, 'var(' ) !== false ) {
|
||||
return sanitize_text_field( $color );
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize RGBA colors.
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $color The color to check.
|
||||
*/
|
||||
function generate_sanitize_rgba_color( $color ) {
|
||||
if ( '' === $color ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( false === strpos( $color, 'rgba' ) ) {
|
||||
return generate_sanitize_hex_color( $color );
|
||||
}
|
||||
|
||||
$color = str_replace( ' ', '', $color );
|
||||
sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
|
||||
|
||||
return 'rgba(' . $red . ',' . $green . ',' . $blue . ',' . $alpha . ')';
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sanitize_choices' ) ) {
|
||||
/**
|
||||
* Sanitize choices.
|
||||
*
|
||||
* @since 1.3.24
|
||||
* @param string $input The value to check.
|
||||
* @param object $setting The setting object.
|
||||
*/
|
||||
function generate_sanitize_choices( $input, $setting ) {
|
||||
// Ensure input is a slug.
|
||||
$input = sanitize_key( $input );
|
||||
|
||||
// Get list of choices from the control.
|
||||
// associated with the setting.
|
||||
$choices = $setting->manager->get_control( $setting->id )->choices;
|
||||
|
||||
// If the input is a valid key, return it.
|
||||
// otherwise, return the default.
|
||||
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize our Google Font variants
|
||||
*
|
||||
* @since 2.0
|
||||
* @param string $input The value to check.
|
||||
*/
|
||||
function generate_sanitize_variants( $input ) {
|
||||
if ( is_array( $input ) ) {
|
||||
$input = implode( ',', $input );
|
||||
}
|
||||
return sanitize_text_field( $input );
|
||||
}
|
||||
|
||||
add_action( 'customize_controls_enqueue_scripts', 'generate_do_control_inline_scripts', 100 );
|
||||
/**
|
||||
* Add misc inline scripts to our controls.
|
||||
*
|
||||
* We don't want to add these to the controls themselves, as they will be repeated
|
||||
* each time the control is initialized.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
function generate_do_control_inline_scripts() {
|
||||
wp_localize_script(
|
||||
'generatepress-typography-customizer',
|
||||
'gp_customize',
|
||||
array(
|
||||
'nonce' => wp_create_nonce( 'gp_customize_nonce' ),
|
||||
)
|
||||
);
|
||||
|
||||
$number_of_fonts = apply_filters( 'generate_number_of_fonts', 200 );
|
||||
|
||||
wp_localize_script(
|
||||
'generatepress-typography-customizer',
|
||||
'generatePressTypography',
|
||||
array(
|
||||
'googleFonts' => apply_filters( 'generate_typography_customize_list', generate_get_all_google_fonts( $number_of_fonts ) ),
|
||||
)
|
||||
);
|
||||
|
||||
wp_localize_script( 'generatepress-typography-customizer', 'typography_defaults', generate_typography_default_fonts() );
|
||||
|
||||
wp_enqueue_script( 'generatepress-customizer-controls', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/customizer-controls.js', array( 'customize-controls', 'jquery' ), GENERATE_VERSION, true );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_defaults', generate_get_defaults() );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_color_defaults', generate_get_color_defaults() );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_typography_defaults', generate_get_default_fonts() );
|
||||
wp_localize_script( 'generatepress-customizer-controls', 'generatepress_spacing_defaults', generate_spacing_get_defaults() );
|
||||
|
||||
wp_localize_script(
|
||||
'generatepress-customizer-controls',
|
||||
'generatepressCustomizeControls',
|
||||
array(
|
||||
'mappedTypographyData' => array(
|
||||
'typography' => GeneratePress_Typography_Migration::get_mapped_typography_data(),
|
||||
'fonts' => GeneratePress_Typography_Migration::get_mapped_font_data(),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'generate-customizer-controls',
|
||||
trailingslashit( get_template_directory_uri() ) . 'assets/dist/customizer.js',
|
||||
// We're including wp-color-picker for localized strings, nothing more.
|
||||
array( 'customize-controls', 'wp-i18n', 'wp-components', 'wp-element', 'jquery', 'customize-base', 'wp-color-picker' ),
|
||||
GENERATE_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
$color_palette = get_theme_support( 'editor-color-palette' );
|
||||
$colors = array();
|
||||
|
||||
if ( is_array( $color_palette ) ) {
|
||||
foreach ( $color_palette as $key => $value ) {
|
||||
foreach ( $value as $color ) {
|
||||
$colors[] = array(
|
||||
'name' => $color['name'],
|
||||
'color' => $color['color'],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wp_localize_script(
|
||||
'generate-customizer-controls',
|
||||
'generateCustomizerControls',
|
||||
array(
|
||||
'palette' => $colors,
|
||||
)
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'generate-customizer-controls',
|
||||
trailingslashit( get_template_directory_uri() ) . 'assets/dist/style-customizer.css',
|
||||
array( 'wp-components' ),
|
||||
GENERATE_VERSION
|
||||
);
|
||||
|
||||
$global_colors = generate_get_global_colors();
|
||||
$global_colors_css = ':root {';
|
||||
|
||||
if ( ! empty( $global_colors ) ) {
|
||||
foreach ( (array) $global_colors as $key => $data ) {
|
||||
$global_colors_css .= '--' . $data['slug'] . ':' . $data['color'] . ';';
|
||||
}
|
||||
}
|
||||
|
||||
$global_colors_css .= '}';
|
||||
|
||||
wp_add_inline_style( 'generate-customizer-controls', $global_colors_css );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_customizer_live_preview' ) ) {
|
||||
add_action( 'customize_preview_init', 'generate_customizer_live_preview', 100 );
|
||||
/**
|
||||
* Add our live preview scripts
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_customizer_live_preview() {
|
||||
$spacing_settings = wp_parse_args(
|
||||
get_option( 'generate_spacing_settings', array() ),
|
||||
generate_spacing_get_defaults()
|
||||
);
|
||||
|
||||
wp_enqueue_script( 'generate-themecustomizer', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/customizer-live-preview.js', array( 'customize-preview' ), GENERATE_VERSION, true );
|
||||
|
||||
wp_localize_script(
|
||||
'generate-themecustomizer',
|
||||
'generatepress_live_preview',
|
||||
array(
|
||||
'mobile' => generate_get_media_query( 'mobile' ),
|
||||
'tablet' => generate_get_media_query( 'tablet_only' ),
|
||||
'desktop' => generate_get_media_query( 'desktop' ),
|
||||
'contentLeft' => absint( $spacing_settings['content_left'] ),
|
||||
'contentRight' => absint( $spacing_settings['content_right'] ),
|
||||
'isFlex' => generate_is_using_flexbox(),
|
||||
'isRTL' => is_rtl(),
|
||||
)
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'generate-postMessage',
|
||||
trailingslashit( get_template_directory_uri() ) . 'inc/customizer/controls/js/postMessage.js',
|
||||
array( 'jquery', 'customize-preview', 'wp-hooks' ),
|
||||
GENERATE_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
global $generate_customize_fields;
|
||||
wp_localize_script( 'generate-postMessage', 'gpPostMessageFields', $generate_customize_fields );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if we have a logo or not.
|
||||
*
|
||||
* Used as an active callback. Calling has_custom_logo creates a PHP notice for
|
||||
* multisite users.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
function generate_has_custom_logo_callback() {
|
||||
if ( get_theme_mod( 'custom_logo' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save our preset layout controls. These should always save to be "current".
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
function generate_sanitize_preset_layout() {
|
||||
return 'current';
|
||||
}
|
||||
|
||||
/**
|
||||
* Display options if we're using the Floats structure.
|
||||
*/
|
||||
function generate_is_using_floats_callback() {
|
||||
return 'floats' === generate_get_option( 'structure' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine whether to show the inline logo option.
|
||||
*/
|
||||
function generate_show_inline_logo_callback() {
|
||||
return 'floats' === generate_get_option( 'structure' ) && generate_has_logo_site_branding();
|
||||
}
|
||||
|
Reference in New Issue
Block a user