Initial commit

This commit is contained in:
2020-04-07 13:03:04 +00:00
committed by Gitium
commit 00f842d9bf
1673 changed files with 471161 additions and 0 deletions

View File

@ -0,0 +1,584 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'generate_mobile_header_activated' ) ) {
/**
* Check to see if the mobile header is activated
*/
function generate_mobile_header_activated() {
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
return false;
}
$generate_menu_plus_settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
return ( 'enable' == $generate_menu_plus_settings[ 'mobile_header' ] ) ? true : false;
}
}
/**
* If we're using the mobile header, and have the logo set as the branding type.
*
* @since 1.8
*/
function generate_mobile_header_logo_active_callback() {
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
return false;
}
$settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
return ( 'enable' === $settings['mobile_header'] && 'logo' === $settings['mobile_header_branding'] ) ? true : false;
}
if ( ! function_exists( 'generate_mobile_header_sticky_activated' ) ) {
/**
* Check to see if the mobile header is activated
*/
function generate_mobile_header_sticky_activated() {
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
return false;
}
$generate_menu_plus_settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
return ( 'enable' == $generate_menu_plus_settings[ 'mobile_header' ] && 'enable' == $generate_menu_plus_settings[ 'mobile_header_sticky' ] ) ? true : false;
}
}
if ( ! function_exists( 'generate_sticky_navigation_activated' ) ) {
/**
* Check to see if the sticky navigation is activated
*/
function generate_sticky_navigation_activated() {
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
return false;
}
$generate_menu_plus_settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
return ( 'false' !== $generate_menu_plus_settings[ 'sticky_menu' ] ) ? true : false;
}
}
if ( ! function_exists( 'generate_navigation_logo_activated' ) ) {
/**
* Check to see if the sticky navigation is activated
*/
function generate_navigation_logo_activated() {
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
return false;
}
$generate_menu_plus_settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
return ( '' !== $generate_menu_plus_settings[ 'sticky_menu_logo' ] ) ? true : false;
}
}
if ( ! function_exists( 'generate_slideout_navigation_activated' ) ) {
/**
* Check to see if the sticky navigation is activated
*/
function generate_slideout_navigation_activated() {
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
return false;
}
$generate_menu_plus_settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
return ( 'false' !== $generate_menu_plus_settings[ 'slideout_menu' ] ) ? true : false;
}
}
/**
* Check whether the overlay off canvas panel is activated.
*
* @since 1.8
*/
function generate_is_overlay_navigation_active_callback() {
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
return false;
}
$settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
return ( 'false' !== $settings['slideout_menu'] && 'overlay' === $settings['slideout_menu_style'] ) ? true : false;
}
/**
* Check whether the slideout off canvas panel is activated.
*
* @since 1.8
*/
function generate_is_slideout_navigation_active_callback() {
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
return false;
}
$settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
return ( 'false' !== $settings['slideout_menu'] && 'slide' === $settings['slideout_menu_style'] ) ? true : false;
}
if ( ! function_exists( 'generate_page_header_blog_content_exists' ) ) {
/**
* This is an active_callback
* Check if page header content exists
*/
function generate_page_header_blog_content_exists() {
if ( ! function_exists( 'generate_page_header_get_defaults' ) ) {
return false;
}
$options = get_option( 'generate_page_header_options', generate_page_header_get_defaults() );
if ( isset( $options[ 'page_header_content' ] ) && '' !== $options[ 'page_header_content' ] ) {
return true;
}
return false;
}
}
if ( ! function_exists( 'generate_page_header_blog_image_exists' ) ) {
/**
* This is an active_callback
* Check if page header image exists
*/
function generate_page_header_blog_image_exists() {
if ( ! function_exists( 'generate_page_header_get_defaults' ) ) {
return false;
}
$options = get_option( 'generate_page_header_options', generate_page_header_get_defaults() );
if ( isset( $options[ 'page_header_image' ] ) && '' !== $options[ 'page_header_image' ] ) {
return true;
}
return false;
}
}
if ( ! function_exists( 'generate_page_header_blog_crop_exists' ) ) {
/**
* This is an active_callback
* Check if page header image resizing is enabled
*/
function generate_page_header_blog_crop_exists() {
if ( ! function_exists( 'generate_page_header_get_defaults' ) ) {
return false;
}
$options = get_option( 'generate_page_header_options', generate_page_header_get_defaults() );
if ( isset( $options[ 'page_header_hard_crop' ] ) && 'disable' !== $options[ 'page_header_hard_crop' ] ) {
return true;
}
return false;
}
}
if ( ! function_exists( 'generate_page_header_blog_combined' ) ) {
/**
* This is an active_callback
* Check if page header is merged
*/
function generate_page_header_blog_combined() {
if ( ! function_exists( 'generate_page_header_get_defaults' ) ) {
return false;
}
$options = get_option( 'generate_page_header_options', generate_page_header_get_defaults() );
if ( isset( $options[ 'page_header_combine' ] ) && '' !== $options[ 'page_header_combine' ] ) {
return true;
}
return false;
}
}
if ( ! function_exists( 'generate_page_header_full_screen_vertical' ) ) {
/**
* This is an active_callback
* Check if our page header is full screen and vertically centered
*/
function generate_page_header_full_screen_vertical() {
if ( ! function_exists( 'generate_page_header_get_defaults' ) ) {
return false;
}
$options = get_option( 'generate_page_header_options', generate_page_header_get_defaults() );
if ( $options[ 'page_header_full_screen' ] && $options[ 'page_header_vertical_center' ] ) {
return true;
}
return false;
}
}
if ( ! function_exists( 'generate_secondary_nav_show_merge_top_bar' ) ) {
/**
* This is an active callback
* Determines whether we should show the Merge with Secondary Navigation option
*/
function generate_secondary_nav_show_merge_top_bar() {
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
return false;
}
$generate_settings = wp_parse_args(
get_option( 'generate_secondary_nav_settings', array() ),
generate_secondary_nav_get_defaults()
);
if ( 'secondary-nav-above-header' == $generate_settings[ 'secondary_nav_position_setting' ] && has_nav_menu( 'secondary' ) && is_active_sidebar( 'top-bar' ) ) {
return true;
}
return false;
}
}
if ( ! function_exists( 'generate_premium_is_top_bar_active' ) ) {
/**
* Check to see if the top bar is active
*
* @since 1.3.45
*/
function generate_premium_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_masonry_callback' ) ) {
/**
* Check to see if masonry is activated
*/
function generate_masonry_callback() {
if ( ! function_exists( 'generate_blog_get_defaults' ) ) {
return false;
}
$generate_blog_settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
// If masonry is enabled, set to true
return ( 'true' == $generate_blog_settings['masonry'] ) ? true : false;
}
}
if ( ! function_exists( 'generate_premium_is_posts_page' ) ) {
/**
* Check to see if we're on a posts page
*/
function generate_premium_is_posts_page() {
$blog = ( is_home() || is_archive() || is_attachment() || is_tax() ) ? true : false;
return $blog;
}
}
if ( ! function_exists( 'generate_premium_is_posts_page_single' ) ) {
/**
* Check to see if we're on a posts page or a single post
*/
function generate_premium_is_posts_page_single() {
$blog = ( is_home() || is_archive() || is_attachment() || is_tax() || is_single() ) ? true : false;
return $blog;
}
}
if ( ! function_exists( 'generate_premium_is_excerpt' ) ) {
/**
* Check to see if we're displaying excerpts
*/
function generate_premium_is_excerpt() {
if ( ! function_exists( 'generate_get_defaults' ) ) {
return false;
}
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
return ( 'excerpt' == $generate_settings['post_content'] ) ? true : false;
}
}
/**
* Check to see if featured images are active.
*
* @since 1.5
* @return bool Whether featured images are active or not
*/
function generate_premium_featured_image_active() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! $settings[ 'post_image' ] ) {
return false;
}
return true;
}
/**
* Check to see if featured images on single posts are active.
*
* @since 1.5
* @return bool Whether featured images on single posts are active or not.
*/
function generate_premium_single_featured_image_active() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! $settings[ 'single_post_image' ] ) {
return false;
}
return true;
}
/**
* Check to see if featured images on single posts are active.
*
* @since 1.5
* @return bool Whether featured images on single posts are active or not.
*/
function generate_premium_single_page_featured_image_active() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! $settings[ 'page_post_image' ] ) {
return false;
}
return true;
}
/**
* Check to see if the blog columns Customizer control is true.
*
* @since 1.5
* @return bool Whether columns are active or not
*/
function generate_premium_blog_columns_active() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! $settings[ 'column_layout' ] ) {
return false;
}
return true;
}
/**
* Check to see if the blog masonry Customizer control is true.
*
* @since 1.5
* @return bool Whether masonry is active or not
*/
function generate_premium_blog_masonry_active() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! $settings[ 'column_layout' ] ) {
return false;
}
if ( ! $settings[ 'masonry' ] ) {
return false;
}
return true;
}
/**
* Only show padding around image control when alignment is centered.
*
* @since 1.5
* @return bool
*/
function generate_premium_display_image_padding() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! $settings[ 'post_image' ] ) {
return false;
}
if ( 'post-image-aligned-center' !== $settings[ 'post_image_alignment' ] ) {
return false;
}
return true;
}
/**
* Only show padding around image control when alignment is centered and not
* set to display above our content area.
*
* @since 1.5
* @return bool
*/
function generate_premium_display_image_padding_single() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! $settings[ 'single_post_image' ] ) {
return false;
}
if ( 'center' !== $settings[ 'single_post_image_alignment' ] ) {
return false;
}
if ( 'above-content' == $settings[ 'single_post_image_position' ] ) {
return false;
}
return true;
}
/**
* Only show padding around image control when alignment is centered and not
* set to display above our content area.
*
* @since 1.5
* @return bool
*/
function generate_premium_display_image_padding_single_page() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! $settings[ 'page_post_image' ] ) {
return false;
}
if ( 'center' !== $settings[ 'page_post_image_alignment' ] ) {
return false;
}
if ( 'above-content' == $settings[ 'page_post_image_position' ] ) {
return false;
}
return true;
}
/**
* Check to see if infinite scroll is activated.
*
* @since 1.5
* @return bool
*/
function generate_premium_infinite_scroll_active() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! $settings[ 'infinite_scroll' ] ) {
return false;
}
return true;
}
/**
* Check to see if infinite scroll is activated and we're using a button.
*
* @since 1.5
* @return bool
*/
function generate_premium_infinite_scroll_button_active() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! $settings[ 'infinite_scroll' ] ) {
return false;
}
if ( ! $settings[ 'infinite_scroll_button' ] ) {
return false;
}
return true;
}
/**
* Check to see if the WooCommerce menu item is active.
*
* @since 1.8
* @return bool Whether the cart item is active.
*/
function generate_premium_wc_menu_item_active() {
if ( ! function_exists( 'generatepress_wc_defaults' ) ) {
return false;
}
$settings = wp_parse_args(
get_option( 'generate_woocommerce_settings', array() ),
generatepress_wc_defaults()
);
if ( ! $settings[ 'cart_menu_item' ] ) {
return false;
}
return true;
}

View File

@ -0,0 +1,39 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
if ( ! class_exists( 'WP_Customize_Control' ) ) {
return;
}
if ( ! class_exists( 'GeneratePress_Action_Button_Control' ) ) {
/**
* Add a button which needs javascript attached to it.
*/
class GeneratePress_Action_Button_Control extends WP_Customize_Control {
public $type = 'gp_action_button';
public $data_type = '';
public $description = '';
public function enqueue() {
wp_enqueue_script( 'gp-button-actions', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/button-actions.js', array( 'customize-controls' ), GP_PREMIUM_VERSION, true );
}
public function to_json() {
parent::to_json();
$this->json['data_type'] = $this->data_type;
$this->json['description'] = $this->description;
}
public function content_template() {
?>
<button class="button" data-type="{{{ data.data_type }}}">{{{ data.label }}}</button>
<span class="description customize-control-description">
<p>{{{ data.description }}}</p>
</span>
<?php
}
}
}

View File

@ -0,0 +1,76 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'GeneratePress_Alpha_Color_Customize_Control' ) ) :
class GeneratePress_Alpha_Color_Customize_Control extends WP_Customize_Control {
/**
* Official control name.
*/
public $type = 'gp-alpha-color';
/**
* Add support for palettes to be passed in.
*
* Supported palette values are true, false, or an array of RGBa and Hex colors.
*/
public $palette;
/**
* Add support for showing the opacity value on the slider handle.
*/
public $show_opacity;
/**
* Enqueue scripts and styles.
*
* Ideally these would get registered and given proper paths before this control object
* gets initialized, then we could simply enqueue them here, but for completeness as a
* stand alone class we'll register and enqueue them here.
*/
public function enqueue() {
wp_enqueue_script(
'gp-alpha-color-picker',
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/alpha-color-picker.js',
array( 'jquery', 'wp-color-picker' ),
GP_PREMIUM_VERSION,
true
);
wp_enqueue_style(
'gp-alpha-color-picker',
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/alpha-color-picker.css',
array( 'wp-color-picker' ),
GP_PREMIUM_VERSION
);
}
public function to_json() {
parent::to_json();
$this->json['palette'] = $this->palette;
$this->json['defaultValue'] = $this->setting->default;
$this->json[ 'link' ] = $this->get_link();
$this->json[ 'show_opacity' ] = $this->show_opacity;
if ( is_array( $this->json['palette'] ) ) {
$this->json['palette'] = implode( '|', $this->json['palette'] );
} else {
// Default to true.
$this->json['palette'] = ( false === $this->json['palette'] || 'false' === $this->json['palette'] ) ? 'false' : 'true';
}
// Support passing show_opacity as string or boolean. Default to true.
$this->json[ 'show_opacity' ] = ( false === $this->json[ 'show_opacity' ] || 'false' === $this->json[ 'show_opacity' ] ) ? 'false' : 'true';
}
/**
* Render the control.
*/
public function render_content() {}
public function content_template() {
?>
<# if ( data.label && '' !== data.label ) { #>
<span class="customize-control-title">{{ data.label }}</span>
<# } #>
<input class="gp-alpha-color-control" type="text" data-palette="{{{ data.palette }}}" data-default-color="{{ data.defaultValue }}" {{{ data.link }}} />
<?php
}
}
endif;

View File

@ -0,0 +1,146 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( class_exists( 'WP_Customize_Control' ) ) {
class GeneratePress_Background_Images_Customize_Control extends WP_Customize_Control {
public $type = 'gp-background-images';
public function enqueue() {
wp_enqueue_script( 'gp-backgrounds-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/backgrounds-customizer.js', array( 'customize-controls' ), GP_PREMIUM_VERSION, true );
}
public function to_json() {
parent::to_json();
$this->json[ 'position_title' ] = esc_html__( 'left top, x% y%, xpos ypos (px)', 'gp-premium' );
$this->json[ 'position_placeholder' ] = esc_html__( 'Position', 'gp-premium' );
foreach ( $this->settings as $setting_key => $setting_id ) {
$this->json[ $setting_key ] = array(
'link' => $this->get_link( $setting_key ),
'value' => $this->value( $setting_key ),
'default' => isset( $setting_id->default ) ? $setting_id->default : '',
'id' => isset( $setting_id->id ) ? $setting_id->id : ''
);
if ( 'repeat' === $setting_key ) {
$this->json[ $setting_key ]['choices'] = $this->get_repeat_choices();
}
if ( 'size' === $setting_key ) {
$this->json[ $setting_key ]['choices'] = $this->get_size_choices();
}
if ( 'attachment' === $setting_key ) {
$this->json[ $setting_key ]['choices'] = $this->get_attachment_choices();
}
}
}
public function content_template() {
?>
<# if ( '' !== data.label ) { #>
<span class="customize-control-title">{{ data.label }}</span>
<# } #>
<# if ( 'undefined' !== typeof ( data.repeat ) ) { #>
<div class="generatepress-backgrounds-repeat">
<label>
<select {{{ data.repeat.link }}}>
<# _.each( data.repeat.choices, function( label, choice ) { #>
<option value="{{ choice }}" <# if ( choice === data.repeat.value ) { #> selected="selected" <# } #>>{{ label }}</option>
<# } ) #>
</select>
<# if ( '' !== data.repeat_title ) { #>
<p class="description">{{ data.repeat_title }}</p>
<# } #>
</label>
</div>
<# } #>
<# if ( 'undefined' !== typeof ( data.size ) ) { #>
<div class="generatepress-backgrounds-size">
<label>
<select {{{ data.size.link }}}>
<# _.each( data.size.choices, function( label, choice ) { #>
<option value="{{ choice }}" <# if ( choice === data.size.value ) { #> selected="selected" <# } #>>{{ label }}</option>
<# } ) #>
</select>
<# if ( '' !== data.size_title ) { #>
<p class="description">{{ data.size_title }}</p>
<# } #>
</label>
</div>
<# } #>
<# if ( 'undefined' !== typeof ( data.attachment ) ) { #>
<div class="generatepress-backgrounds-attachment">
<label>
<select {{{ data.attachment.link }}}>
<# _.each( data.attachment.choices, function( label, choice ) { #>
<option value="{{ choice }}" <# if ( choice === data.attachment.value ) { #> selected="selected" <# } #>>{{ label }}</option>
<# } ) #>
</select>
<# if ( '' !== data.attachment_title ) { #>
<p class="description">{{ data.attachment_title }}</p>
<# } #>
</label>
</div>
<# } #>
<# if ( 'undefined' !== typeof ( data.position ) ) { #>
<div class="generatepress-backgrounds-position">
<label>
<input name="{{{ data.position.id }}}" type="text" {{{ data.position.link }}} value="{{{ data.position.value }}}" placeholder="{{ data.position_placeholder }}" />
<# if ( '' !== data.position_title ) { #>
<p class="description">{{ data.position_title }}</p>
<# } #>
</label>
</div>
<# } #>
<?php
}
public function get_repeat_choices() {
return array(
'' => esc_html__( 'Repeat', 'gp-premium' ),
'repeat-x' => esc_html__( 'Repeat x', 'gp-premium' ),
'repeat-y' => esc_html__( 'Repeat y', 'gp-premium' ),
'no-repeat' => esc_html__( 'No Repeat', 'gp-premium' )
);
}
public function get_size_choices() {
return array(
'' => esc_html__( 'Size (Auto)', 'gp-premium' ),
'100' => esc_html__( '100% Width', 'gp-premium' ),
'cover' => esc_html__( 'Cover', 'gp-premium' ),
'contain' => esc_html__( 'Contain', 'gp-premium' )
);
}
public function get_attachment_choices() {
return array(
'' => esc_html__( 'Attachment', 'gp-premium' ),
'fixed' => esc_html__( 'Fixed', 'gp-premium' ),
'local' => esc_html__( 'Local', 'gp-premium' ),
'inherit' => esc_html__( 'Inherit', 'gp-premium' )
);
}
}
}

View File

@ -0,0 +1,37 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Control_Toggle_Customize_Control' ) ) :
/**
* Add a button to initiate refresh when changing featured image sizes
*/
class Generate_Control_Toggle_Customize_Control extends WP_Customize_Control {
public $type = 'control_section_toggle';
public $targets = '';
public function enqueue() {
wp_enqueue_script( 'generatepress-pro-control-target', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/control-toggle-customizer.js', array( 'customize-controls', 'jquery' ), GP_PREMIUM_VERSION, true );
wp_enqueue_style( 'generatepress-pro-control-target', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/control-toggle-customizer.css', array(), GP_PREMIUM_VERSION );
}
public function to_json() {
parent::to_json();
$this->json[ 'targets' ] = $this->targets;
}
public function content_template() {
?>
<div class="generatepress-control-toggles">
<# jQuery.each( data.targets, function( index, value ) { #>
<button data-target="{{ index }}">{{ value }}</button>
<# } ); #>
</div>
<?php
}
}
endif;

View File

@ -0,0 +1,51 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'GeneratePress_Copyright_Customize_Control' ) ) :
/**
* Class to create a custom tags control
*/
class GeneratePress_Copyright_Customize_Control extends WP_Customize_Control
{
public $type = 'gp-copyright';
public $id = '';
public function enqueue() {
wp_enqueue_script( 'gp-copyright-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/copyright-customizer.js', array( 'customize-controls' ), GP_PREMIUM_VERSION, true );
}
public function to_json() {
parent::to_json();
$this->json[ 'link' ] = $this->get_link();
$this->json[ 'value' ] = $this->value();
$this->json[ 'id' ] = $this->id;
$this->json[ 'current_year' ] = __( '<code>%current_year%</code> to update year automatically.', 'gp-premium' );
$this->json[ 'copyright' ] = __( '<code>%copy%</code> to include the copyright symbol.', 'gp-premium' );
$this->json[ 'html' ] = __( 'HTML is allowed.', 'gp-premium' );
$this->json[ 'shortcodes' ] = __( 'Shortcodes are allowed.', 'gp-premium' );
}
/**
* Render the control's content.
*
* Allows the content to be overriden without having to rewrite the wrapper.
*
* @since 10/16/2012
* @return void
*/
public function content_template() {
?>
<label>
<span class="customize-control-title">{{ data.label }}</span>
<textarea id="{{ data.id }}" class="large-text gp-copyright-area" cols="20" rows="5" {{{ data.link }}}>{{{ data.value }}}</textarea>
<small style="display:block;margin-bottom:5px;">{{{ data.current_year }}}</small>
<small style="display:block;margin-bottom:5px;">{{{ data.copyright }}}</small>
<small style="display:block;margin-bottom:5px;">{{{ data.html }}}</small>
<small style="display:block;">{{{ data.shortcodes }}}</small>
</label>
<?php
}
}
endif;

View File

@ -0,0 +1,396 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Customize_Spacing_Slider_Control' ) ) :
/**
* Create our container width slider control
* @deprecated 1.3
*/
class Generate_Customize_Spacing_Slider_Control extends WP_Customize_Control
{
// Setup control type
public $type = 'gp-spacing-slider';
public $id = '';
public $default_value = '';
public $unit = '';
public $edit_field = true;
public function to_json() {
parent::to_json();
$this->json[ 'link' ] = $this->get_link();
$this->json[ 'value' ] = $this->value();
$this->json[ 'id' ] = $this->id;
$this->json[ 'default_value' ] = $this->default_value;
$this->json[ 'reset_title' ] = esc_attr__( 'Reset','generate-spacing' );
$this->json[ 'unit' ] = $this->unit;
$this->json[ 'edit_field' ] = $this->edit_field;
}
public function content_template() {
?>
<label>
<p style="margin-bottom:0;">
<span class="spacing-size-label customize-control-title">
{{ data.label }}
</span>
<span class="value">
<input <# if ( '' == data.unit || ! data.edit_field ) { #>style="display:none;"<# } #> name="{{ data.id }}" type="number" {{{ data.link }}} value="{{{ data.value }}}" class="slider-input" /><span <# if ( '' == data.unit || ! data.edit_field ) { #>style="display:none;"<# } #> class="px">{{ data.unit }}</span>
<# if ( '' !== data.unit && ! data.edit_field ) { #><span class="no-edit-field"><span class="no-edit-value">{{ data.value }}</span>{{ data.unit }}</span><# } #>
</span>
</p>
</label>
<div class="slider gp-flat-slider <# if ( '' !== data.default_value ) { #>show-reset<# } #>"></div>
<# if ( '' !== data.default_value ) { #><span style="cursor:pointer;" title="{{ data.reset_title }}" class="gp-spacing-slider-default-value" data-default-value="{{ data.default_value }}"><span class="gp-customizer-icon-undo" aria-hidden="true"></span><span class="screen-reader-text">{{ data.reset_title }}</span></span><# } #>
<?php
}
// Function to enqueue the right jquery scripts and styles
public function enqueue() {
wp_enqueue_script( 'gp-spacing-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/spacing-customizer.js', array( 'customize-controls' ), GENERATE_SPACING_VERSION, true );
wp_enqueue_style( 'gp-spacing-customizer-controls-css', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/customizer.css', array(), GENERATE_SPACING_VERSION );
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script( 'jquery-ui-slider' );
wp_enqueue_script( 'generate-spacing-slider-js', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/spacing-slider.js', array( 'jquery-ui-slider' ), GENERATE_SPACING_VERSION );
wp_enqueue_style('generate-ui-slider', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/jquery-ui.structure.css');
wp_enqueue_style('generate-flat-slider', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/range-slider.css');
}
}
endif;
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Spacing_Customize_Control' ) ) :
/*
* Add our control for our padding options
* @deprecated 1.2.95
*/
class Generate_Spacing_Customize_Control extends WP_Customize_Control {
public $type = 'spacing';
public $description = '';
public function enqueue() {
wp_enqueue_script( 'gp-spacing-customizer', plugin_dir_url( __FILE__ ) . 'js/spacing-customizer.js', array( 'customize-controls' ), GENERATE_SPACING_VERSION, true );
}
public function to_json() {
parent::to_json();
$this->json[ 'link' ] = $this->get_link();
$this->json[ 'value' ] = absint( $this->value() );
$this->json[ 'description' ] = esc_html( $this->description );
}
public function content_template() {
?>
<label>
<# if ( data.label ) { #>
<span class="customize-control-title">{{ data.label }}</span>
<# } #>
<input class="generate-number-control" type="number" style="text-align: center;" {{{ data.link }}} value="{{{ data.value }}}" />
<# if ( data.description ) { #>
<span class="description" style="font-style:normal;">{{ data.description }}</span>
<# } #>
</label>
<?php
}
}
endif;
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Spacing_Customize_Misc_Control' ) ) :
/*
* Add a class to display headings
* @deprecated 1.2.95
*/
class Generate_Spacing_Customize_Misc_Control extends WP_Customize_Control {
public $settings = 'generate_spacing_headings';
public $description = '';
public $areas = '';
public function render_content() {
switch ( $this->type ) {
default:
case 'text' : ?>
<label>
<span class="customize-control-title"><?php echo $this->description;?></span>
</label>
<?php break;
case 'spacing-heading':
if ( ! empty( $this->label ) ) echo '<span class="customize-control-title spacing-title">' . esc_html( $this->label ) . '</span>';
if ( ! empty( $this->description ) ) echo '<span class="spacing-title-description">' . esc_html( $this->description ) . '</span>';
if ( ! empty( $this->areas ) ) :
echo '<div style="clear:both;display:block;"></div>';
foreach ( $this->areas as $value => $label ) :
echo '<span class="spacing-area">' . esc_html( $label ) . '</span>';
endforeach;
endif;
break;
case 'line' :
echo '<hr />';
break;
}
}
}
endif;
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Backgrounds_Customize_Control' ) ) :
/*
* @deprecated 1.3
*/
class Generate_Backgrounds_Customize_Control extends WP_Customize_Control {
public function render() {}
}
endif;
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Backgrounds_Customize_Misc_Control' ) ) :
/*
* No longer used
* Kept for back compat purposes
* @deprecated 1.2.95
*/
class Generate_Backgrounds_Customize_Misc_Control extends WP_Customize_Control {
public function render() {}
}
endif;
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Blog_Customize_Control' ) ) :
/**
* Add our number input field for the featured image width
* @deprecated 1.3
*/
class Generate_Blog_Customize_Control extends WP_Customize_Control {
public $type = 'gp-post-image-size';
public $placeholder = '';
public function enqueue() {
wp_enqueue_script( 'gp-blog-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/blog-customizer.js', array( 'customize-controls' ), GENERATE_BLOG_VERSION, true );
}
public function to_json() {
parent::to_json();
$this->json[ 'link' ] = $this->get_link();
$this->json[ 'value' ] = $this->value();
$this->json[ 'placeholder' ] = $this->placeholder;
}
public function content_template() {
?>
<label>
<span class="customize-control-title">{{{ data.label }}}</span>
<input class="blog-size-input" placeholder="{{{ data.placeholder }}}" style="max-width:75px;text-align:center;" type="number" {{{ data.link }}} value="{{ data.value }}" />px
</label>
<?php
}
}
endif;
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Blog_Number_Customize_Control' ) ) :
/**
* Add a regular number input control
* @deprecated 1.3
*/
class Generate_Blog_Number_Customize_Control extends WP_Customize_Control {
public $type = 'gp-blog-number';
public $placeholder = '';
public function enqueue() {
wp_enqueue_script( 'gp-blog-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/blog-customizer.js', array( 'customize-controls' ), GENERATE_BLOG_VERSION, true );
}
public function to_json() {
parent::to_json();
$this->json[ 'link' ] = $this->get_link();
$this->json[ 'value' ] = $this->value();
$this->json[ 'placeholder' ] = $this->placeholder;
}
public function content_template() {
?>
<label>
<span class="customize-control-title">{{{ data.label }}}</span>
<input class="blog-size-input" placeholder="{{{ data.placeholder }}}" type="number" {{{ data.link }}} value="{{ data.value }}" />
</label>
<?php
}
}
endif;
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Post_Image_Save' ) ) :
/**
* Add a button to initiate refresh when changing featured image sizes
* @deprecated 1.3
*/
class Generate_Post_Image_Save extends WP_Customize_Control {
public function render() {}
}
endif;
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Blog_Text_Control' ) ) :
/**
* Add a control to display simple text
* @deprecated 1.3
*/
class Generate_Blog_Text_Control extends WP_Customize_Control {
public function render() {}
}
endif;
if ( ! class_exists( 'Generate_Customize_Alpha_Color_Control' ) ) :
/**
* @deprecated 1.3
*/
class Generate_Customize_Alpha_Color_Control extends WP_Customize_Control {
public function render() {}
}
endif;
if ( ! class_exists( 'Generate_Copyright_Textarea_Custom_Control' ) ) :
/**
* Class to create a custom tags control
* @deprecated 1.3
*/
class Generate_Copyright_Textarea_Custom_Control extends WP_Customize_Control {
public function render() {}
}
endif;
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Blog_Page_Header_Image_Save' ) ) :
/**
* Add a control without a button to refresh the frame
* This kicks in our image dimension settings
*
* @deprecated 1.3
*/
class Generate_Blog_Page_Header_Image_Save extends WP_Customize_Control {
public $type = 'page_header_image_save';
public function to_json() {
parent::to_json();
$this->json[ 'text' ] = __( 'Apply image sizes','page-header' );
}
public function content_template() {
?>
<a class="button save-post-images" onclick="wp.customize.previewer.refresh();" href="#">{{{ data.text }}}</a>
<?php
}
}
endif;
if ( ! class_exists( 'Generate_Hidden_Input_Control' ) ) :
/**
* Create our hidden input control
* @deprecated 1.3
*/
class Generate_Hidden_Input_Control extends WP_Customize_Control
{
// Setup control type
public $type = 'gp-hidden-input';
public $id = '';
public function to_json() {
parent::to_json();
$this->json[ 'link' ] = $this->get_link();
$this->json[ 'value' ] = $this->value();
$this->json[ 'id' ] = $this->id;
}
public function content_template() {
?>
<input name="{{ data.id }}" type="text" {{{ data.link }}} value="{{{ data.value }}}" class="gp-hidden-input" />
<?php
}
}
endif;
if ( ! class_exists( 'Generate_Text_Transform_Custom_Control' ) ) :
/**
* A class to create a dropdown for text-transform
* @deprecated 1.3
*/
class Generate_Text_Transform_Custom_Control extends WP_Customize_Control
{
public function __construct($manager, $id, $args = array(), $options = array())
{
parent::__construct( $manager, $id, $args );
}
/**
* Render the content of the category dropdown
*
* @return HTML
*/
public function render_content()
{
?>
<label>
<select <?php $this->link(); ?>>
<?php
printf('<option value="%s" %s>%s</option>', 'none', selected($this->value(), 'none', false), 'none');
printf('<option value="%s" %s>%s</option>', 'capitalize', selected($this->value(), 'capitalize', false), 'capitalize');
printf('<option value="%s" %s>%s</option>', 'uppercase', selected($this->value(), 'uppercase', false), 'uppercase');
printf('<option value="%s" %s>%s</option>', 'lowercase', selected($this->value(), 'lowercase', false), 'lowercase');
?>
</select>
<p class="description"><?php echo esc_html( $this->label ); ?></p>
</label>
<?php
}
}
endif;
if ( ! class_exists( 'Generate_Font_Weight_Custom_Control' ) ) :
/**
* A class to create a dropdown for font weight
* @deprecated 1.3
*/
class Generate_Font_Weight_Custom_Control extends WP_Customize_Control
{
public function __construct($manager, $id, $args = array(), $options = array())
{
parent::__construct( $manager, $id, $args );
}
/**
* Render the content of the category dropdown
*
* @return HTML
*/
public function render_content()
{
?>
<label>
<select <?php $this->link(); ?>>
<?php
printf('<option value="%s" %s>%s</option>', 'normal', selected($this->value(), 'normal', false), 'normal');
printf('<option value="%s" %s>%s</option>', 'bold', selected($this->value(), 'bold', false), 'bold');
printf('<option value="%s" %s>%s</option>', '100', selected($this->value(), '100', false), '100');
printf('<option value="%s" %s>%s</option>', '200', selected($this->value(), '200', false), '200');
printf('<option value="%s" %s>%s</option>', '300', selected($this->value(), '300', false), '300');
printf('<option value="%s" %s>%s</option>', '400', selected($this->value(), '400', false), '400');
printf('<option value="%s" %s>%s</option>', '500', selected($this->value(), '500', false), '500');
printf('<option value="%s" %s>%s</option>', '600', selected($this->value(), '600', false), '600');
printf('<option value="%s" %s>%s</option>', '700', selected($this->value(), '700', false), '700');
printf('<option value="%s" %s>%s</option>', '800', selected($this->value(), '800', false), '800');
printf('<option value="%s" %s>%s</option>', '900', selected($this->value(), '900', false), '900');
?>
</select>
<p class="description"><?php echo esc_html( $this->label ); ?></p>
</label>
<?php
}
}
endif;
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'GeneratePress_Backgrounds_Customize_Control' ) ) :
/**
* @deprecated 1.4
*/
class GeneratePress_Backgrounds_Customize_Control extends WP_Customize_Control {
public function render() {}
}
endif;

View File

@ -0,0 +1,31 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'GeneratePress_Information_Customize_Control' ) ) :
/**
* Add a control to display simple text
*/
class GeneratePress_Information_Customize_Control extends WP_Customize_Control {
public $type = 'gp_information_control';
public $description = '';
public function to_json() {
parent::to_json();
$this->json[ 'description' ] = $this->description;
}
public function content_template() {
?>
<# if ( data.label ) { #>
<span class="customize-control-title">{{ data.label }}</span>
<# } #>
<# if ( data.description ) { #>
<p>{{{ data.description }}}</p>
<# } #>
<?php
}
}
endif;

View File

@ -0,0 +1,165 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! function_exists( 'GeneratePress_Pro_Range_Slider_Control' ) ) :
class GeneratePress_Pro_Range_Slider_Control extends WP_Customize_Control {
/**
* The control type.
*
* @access public
* @var string
*/
public $type = 'generatepress-pro-range-slider';
public $description = '';
public $sub_description = '';
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Customize_Control::to_json()
*/
public function to_json() {
parent::to_json();
$devices = array( 'desktop','tablet','mobile' );
foreach ( $devices as $device ) {
$this->json['choices'][$device]['min'] = ( isset( $this->choices[$device]['min'] ) ) ? $this->choices[$device]['min'] : '0';
$this->json['choices'][$device]['max'] = ( isset( $this->choices[$device]['max'] ) ) ? $this->choices[$device]['max'] : '100';
$this->json['choices'][$device]['step'] = ( isset( $this->choices[$device]['step'] ) ) ? $this->choices[$device]['step'] : '1';
$this->json['choices'][$device]['edit'] = ( isset( $this->choices[$device]['edit'] ) ) ? $this->choices[$device]['edit'] : false;
$this->json['choices'][$device]['unit'] = ( isset( $this->choices[$device]['unit'] ) ) ? $this->choices[$device]['unit'] : false;
}
foreach ( $this->settings as $setting_key => $setting_id ) {
$this->json[ $setting_key ] = array(
'link' => $this->get_link( $setting_key ),
'value' => $this->value( $setting_key ),
'default' => isset( $setting_id->default ) ? $setting_id->default : '',
);
}
$this->json['desktop_label'] = __( 'Desktop', 'gp-premium' );
$this->json['tablet_label'] = __( 'Tablet', 'gp-premium' );
$this->json['mobile_label'] = __( 'Mobile', 'gp-premium' );
$this->json['reset_label'] = __( 'Reset', 'gp-premium' );
$this->json['description'] = $this->description;
$this->json['sub_description'] = $this->sub_description;
}
/**
* Enqueue control related scripts/styles.
*
* @access public
*/
public function enqueue() {
wp_enqueue_script( 'generatepress-pro-range-slider', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/slider-customizer.js', array( 'jquery', 'customize-base', 'jquery-ui-slider' ), GP_PREMIUM_VERSION, true );
wp_enqueue_style( 'generatepress-pro-range-slider-css', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/slider-customizer.css', GP_PREMIUM_VERSION );
}
/**
* An Underscore (JS) template for this control's content (but not its container).
*
* Class variables for this control class are available in the `data` JS object;
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
*
* @see WP_Customize_Control::print_template()
*
* @access protected
*/
protected function content_template() {
?>
<div class="generatepress-range-slider-control">
<div class="gp-range-title-area">
<# if ( data.label || data.description ) { #>
<div class="gp-range-title-info">
<# if ( data.label ) { #>
<span class="customize-control-title">{{{ data.label }}}</span>
<# } #>
<# if ( data.description ) { #>
<p class="description">{{{ data.description }}}</p>
<# } #>
</div>
<# } #>
<div class="gp-range-slider-controls">
<span class="gp-device-controls">
<# if ( 'undefined' !== typeof ( data.desktop ) ) { #>
<span class="generatepress-device-desktop dashicons dashicons-desktop" data-option="desktop" title="{{ data.desktop_label }}"></span>
<# } #>
<# if ( 'undefined' !== typeof (data.tablet) ) { #>
<span class="generatepress-device-tablet dashicons dashicons-tablet" data-option="tablet" title="{{ data.tablet_label }}"></span>
<# } #>
<# if ( 'undefined' !== typeof (data.mobile) ) { #>
<span class="generatepress-device-mobile dashicons dashicons-smartphone" data-option="mobile" title="{{ data.mobile_label }}"></span>
<# } #>
</span>
<span title="{{ data.reset_label }}" class="generatepress-reset dashicons dashicons-image-rotate"></span>
</div>
</div>
<div class="gp-range-slider-areas">
<# if ( 'undefined' !== typeof ( data.desktop ) ) { #>
<label class="range-option-area" data-option="desktop" style="display: none;">
<div class="wrapper <# if ( '' !== data.choices['desktop']['unit'] ) { #>has-unit<# } #>">
<div class="generatepress-slider" data-step="{{ data.choices['desktop']['step'] }}" data-min="{{ data.choices['desktop']['min'] }}" data-max="{{ data.choices['desktop']['max'] }}"></div>
<div class="gp_range_value <# if ( '' == data.choices['desktop']['unit'] && ! data.choices['desktop']['edit'] ) { #>hide-value<# } #>">
<input <# if ( data.choices['desktop']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> type="number" step="{{ data.choices['desktop']['step'] }}" class="desktop-range value" value="{{ data.desktop.value }}" min="{{ data.choices['desktop']['min'] }}" max="{{ data.choices['desktop']['max'] }}" {{{ data.desktop.link }}} data-reset_value="{{ data.desktop.default }}" />
<span <# if ( ! data.choices['desktop']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> class="value">{{ data.desktop.value }}</span>
<# if ( data.choices['desktop']['unit'] ) { #>
<span class="unit">{{ data.choices['desktop']['unit'] }}</span>
<# } #>
</div>
</div>
</label>
<# } #>
<# if ( 'undefined' !== typeof ( data.tablet ) ) { #>
<label class="range-option-area" data-option="tablet" style="display:none">
<div class="wrapper <# if ( '' !== data.choices['tablet']['unit'] ) { #>has-unit<# } #>">
<div class="generatepress-slider" data-step="{{ data.choices['tablet']['step'] }}" data-min="{{ data.choices['tablet']['min'] }}" data-max="{{ data.choices['tablet']['max'] }}"></div>
<div class="gp_range_value <# if ( '' == data.choices['tablet']['unit'] && ! data.choices['desktop']['edit'] ) { #>hide-value<# } #>">
<input <# if ( data.choices['tablet']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> type="number" step="{{ data.choices['tablet']['step'] }}" class="tablet-range value" value="{{ data.tablet.value }}" min="{{ data.choices['tablet']['min'] }}" max="{{ data.choices['tablet']['max'] }}" {{{ data.tablet.link }}} data-reset_value="{{ data.tablet.default }}" />
<span <# if ( ! data.choices['tablet']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> class="value">{{ data.tablet.value }}</span>
<# if ( data.choices['tablet']['unit'] ) { #>
<span class="unit">{{ data.choices['tablet']['unit'] }}</span>
<# } #>
</div>
</div>
</label>
<# } #>
<# if ( 'undefined' !== typeof ( data.mobile ) ) { #>
<label class="range-option-area" data-option="mobile" style="display:none;">
<div class="wrapper <# if ( '' !== data.choices['mobile']['unit'] ) { #>has-unit<# } #>">
<div class="generatepress-slider" data-step="{{ data.choices['mobile']['step'] }}" data-min="{{ data.choices['mobile']['min'] }}" data-max="{{ data.choices['mobile']['max'] }}"></div>
<div class="gp_range_value <# if ( '' == data.choices['mobile']['unit'] && ! data.choices['desktop']['edit'] ) { #>hide-value<# } #>">
<input <# if ( data.choices['mobile']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> type="number" step="{{ data.choices['mobile']['step'] }}" class="mobile-range value" value="{{ data.mobile.value }}" min="{{ data.choices['mobile']['min'] }}" max="{{ data.choices['mobile']['max'] }}" {{{ data.mobile.link }}} data-reset_value="{{ data.mobile.default }}" />
<span <# if ( ! data.choices['mobile']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> class="value">{{ data.mobile.value }}</span>
<# if ( data.choices['mobile']['unit'] ) { #>
<span class="unit">{{ data.choices['mobile']['unit'] }}</span>
<# } #>
</div>
</div>
</label>
<# } #>
</div>
<# if ( data.sub_description ) { #>
<p class="description sub-description">{{{ data.sub_description }}}</p>
<# } #>
</div>
<?php
}
}
endif;

View File

@ -0,0 +1,24 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'GeneratePress_Refresh_Button_Customize_Control' ) ) :
/**
* Add a button to initiate refresh when changing featured image sizes
*/
class GeneratePress_Refresh_Button_Customize_Control extends WP_Customize_Control {
public $type = 'refresh_button';
public function to_json() {
parent::to_json();
}
public function content_template() {
?>
<a class="button" onclick="wp.customize.previewer.refresh();" href="#">{{{ data.label }}}</a>
<?php
}
}
endif;

View File

@ -0,0 +1,114 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
if ( ! class_exists( 'WP_Customize_Control' ) ) {
return;
}
/**
* Add a button which needs javascript attached to it.
*/
class GeneratePress_Section_Shortcut_Control extends WP_Customize_Control {
public $type = 'gp_section_shortcut';
public $element = '';
public $shortcuts = array();
public function enqueue() {
wp_enqueue_script( 'gp-section-shortcuts', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/section-shortcuts.js', array( 'customize-controls' ), GP_PREMIUM_VERSION, true );
wp_enqueue_style( 'gp-section-shortcuts', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/section-shortcuts.css', false, GP_PREMIUM_VERSION );
}
public function to_json() {
parent::to_json();
$shortcuts = array();
foreach( $this->shortcuts as $name => $id ) {
if ( 'colors' === $name ) {
$name = esc_html__( 'Colors', 'gp-premium' );
if ( ! generatepress_is_module_active( 'generate_package_colors', 'GENERATE_COLORS' ) ) {
$id = false;
$name = false;
}
}
if ( 'typography' === $name ) {
$name = esc_html__( 'Typography', 'gp-premium' );
if ( ! generatepress_is_module_active( 'generate_package_typography', 'GENERATE_TYPOGRAPHY' ) ) {
$id = false;
$name = false;
}
}
if ( 'backgrounds' === $name ) {
$name = esc_html__( 'Backgrounds', 'gp-premium' );
if ( ! generatepress_is_module_active( 'generate_package_backgrounds', 'GENERATE_BACKGROUNDS' ) ) {
$id = false;
$name = false;
}
}
if ( 'layout' === $name ) {
$name = esc_html__( 'Layout', 'gp-premium' );
}
if ( $id && $name ) {
$shortcuts[ $id ] = $name;
}
}
if ( ! empty( $shortcuts ) ) {
$this->json['shortcuts'] = $shortcuts;
} else {
$this->json['shortcuts'] = false;
}
if ( 'WooCommerce' !== $this->element ) {
$this->element = strtolower( $this->element );
}
$this->json['more'] = sprintf(
__( 'More %s controls:', 'gp-premium' ),
'<span class="more-element">' . $this->element . '</span>'
);
$this->json['return'] = __( 'Go Back', 'gp-premium' );
$this->json['section'] = $this->section;
if ( apply_filters( 'generate_disable_customizer_shortcuts', false ) ) {
$this->json['shortcuts'] = false;
}
}
public function content_template() {
?>
<# if ( data.shortcuts ) { #>
<div class="generatepress-shortcuts">
<div class="show-shortcuts">
<span class="more-controls">
{{{ data.more }}}
</span>
<span class="shortcuts">
<# _.each( data.shortcuts, function( label, section ) { #>
<span class="shortcut">
<a href="#" data-section="{{{ section }}}" data-current-section="{{{ data.section }}}">{{{ label }}}</a>
</span>
<# } ) #>
</span>
</div>
<div class="return-shortcut" style="display: none;">
<span class="dashicons dashicons-no-alt"></span>
<a href="#">&larr; {{{ data.return }}}</a>
</div>
</div>
<# } #>
<?php
}
}

View File

@ -0,0 +1,165 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'GeneratePress_Spacing_Control' ) ) :
class GeneratePress_Spacing_Control extends WP_Customize_Control {
public $type = 'generatepress-spacing';
public $l10n = array();
public $element = '';
public function __construct( $manager, $id, $args = array() ) {
// Let the parent class do its thing.
parent::__construct( $manager, $id, $args );
}
public function enqueue() {
wp_enqueue_script( 'gp-spacing-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/spacing-customizer.js', array( 'customize-controls' ), GP_PREMIUM_VERSION, true );
wp_enqueue_style( 'gp-spacing-customizer-controls-css', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/spacing-customizer.css', array(), GP_PREMIUM_VERSION );
}
public function to_json() {
parent::to_json();
// Loop through each of the settings and set up the data for it.
foreach ( $this->settings as $setting_key => $setting_id ) {
$this->json[ $setting_key ] = array(
'link' => $this->get_link( $setting_key ),
'value' => $this->value( $setting_key )
);
}
$this->json[ 'element' ] = $this->element;
$this->json[ 'title' ] = __( 'Link values','generate-spacing' );
$this->json[ 'unlink_title' ] = __( 'Un-link values','generate-spacing' );
$this->json['label_top'] = esc_html__( 'Top', 'gp-premium' );
$this->json['label_right'] = esc_html__( 'Right', 'gp-premium' );
$this->json['label_bottom'] = esc_html__( 'Bottom', 'gp-premium' );
$this->json['label_left'] = esc_html__( 'Left', 'gp-premium' );
$this->json['desktop_label'] = esc_html__( 'Desktop', 'gp-premium' );
$this->json['tablet_label'] = esc_html__( 'Tablet', 'gp-premium' );
$this->json['mobile_label'] = esc_html__( 'Mobile', 'gp-premium' );
}
public function content_template() {
?>
<div class="gp-spacing-control-section">
<div class="gp-spacing-control-section-title-area">
<# if ( data.label || data.description ) { #>
<div class="gp-spacing-control-title-info">
<# if ( data.label ) { #>
<label for="{{{ data.element }}}-{{{ data.top_label }}}">
<span class="customize-control-title">{{ data.label }}</span>
</label>
<# } #>
<# if ( data.description ) { #>
<span class="description customize-control-description">{{{ data.description }}}</span>
<# } #>
</div>
<# } #>
<div class="gp-range-slider-controls">
<span class="gp-device-controls">
<# if ( 'undefined' !== typeof ( data.desktop_top ) ) { #>
<span class="generatepress-device-desktop dashicons dashicons-desktop" data-option="desktop" title="{{ data.desktop_label }}"></span>
<# } #>
<# if ( 'undefined' !== typeof (data.tablet_top) ) { #>
<span class="generatepress-device-tablet dashicons dashicons-tablet" data-option="tablet" title="{{ data.tablet_label }}"></span>
<# } #>
<# if ( 'undefined' !== typeof (data.mobile_top) ) { #>
<span class="generatepress-device-mobile dashicons dashicons-smartphone" data-option="mobile" title="{{ data.mobile_label }}"></span>
<# } #>
</span>
</div>
</div>
<div class="spacing-values-container">
<div class="spacing-values-desktop spacing-values-area" data-option="desktop" style="display: none;">
<div class="gp-spacing-section">
<input id="{{{ data.element }}}-{{{ data.label_top }}}" min="0" class="generate-number-control spacing-top" type="number" style="text-align: center;" {{{ data.desktop_top.link }}} value="{{{ data.desktop_top.value }}}" />
<# if ( data.label_top ) { #>
<label for="{{{ data.element }}}-{{{ data.label_top }}}" class="description" style="font-style:normal;">{{ data.label_top }}</label>
<# } #>
</div>
<div class="gp-spacing-section">
<input id="{{{ data.element }}}-{{{ data.label_right }}}" min="0" class="generate-number-control spacing-right" type="number" style="text-align: center;" {{{ data.desktop_right.link }}} value="{{{ data.desktop_right.value }}}" />
<# if ( data.label_right ) { #>
<label for="{{{ data.element }}}-{{{ data.label_right }}}" class="description" style="font-style:normal;">{{ data.label_right }}</label>
<# } #>
</div>
<div class="gp-spacing-section">
<input id="{{{ data.element }}}-{{{ data.label_bottom }}}" min="0" class="generate-number-control spacing-bottom" type="number" style="text-align: center;" {{{ data.desktop_bottom.link }}} value="{{{ data.desktop_bottom.value }}}" />
<# if ( data.label_bottom ) { #>
<label for="{{{ data.element }}}-{{{ data.label_bottom }}}" class="description" style="font-style:normal;">{{ data.label_bottom }}</label>
<# } #>
</div>
<div class="gp-spacing-section">
<input id="{{{ data.element }}}-{{{ data.label_left }}}" min="0" class="generate-number-control spacing-left" type="number" style="text-align: center;" {{{ data.desktop_left.link }}} value="{{{ data.desktop_left.value }}}" />
<# if ( data.label_left ) { #>
<label for="{{{ data.element }}}-{{{ data.label_left }}}" class="description" style="font-style:normal;">{{ data.label_left }}</label>
<# } #>
</div>
<# if ( data.element ) { #>
<div class="gp-spacing-section gp-link-spacing-section">
<span class="dashicons dashicons-editor-unlink gp-link-spacing" data-element="{{ data.element }}" title="{{ data.title }}"></span>
<span class="dashicons dashicons-admin-links gp-unlink-spacing" style="display:none" data-element="{{ data.element }}" title="{{ data.unlink_title }}"></span>
</div>
<# } #>
</div>
<# if ( 'undefined' !== typeof ( data.mobile_top ) ) { #>
<div class="spacing-values-mobile spacing-values-area" data-option="mobile" style="display: none;">
<div class="gp-spacing-section">
<input id="{{{ data.element }}}-mobile-{{{ data.label_top }}}" min="0" class="generate-number-control mobile-spacing-top" type="number" style="text-align: center;" {{{ data.mobile_top.link }}} value="{{{ data.mobile_top.value }}}" />
<# if ( data.label_top ) { #>
<label for="{{{ data.element }}}-mobile-{{{ data.label_top }}}" class="description" style="font-style:normal;">{{ data.label_top }}</label>
<# } #>
</div>
<div class="gp-spacing-section">
<input id="{{{ data.element }}}-mobile-{{{ data.label_right }}}" min="0" class="generate-number-control mobile-spacing-right" type="number" style="text-align: center;" {{{ data.mobile_right.link }}} value="{{{ data.mobile_right.value }}}" />
<# if ( data.label_right ) { #>
<label for="{{{ data.element }}}-mobile-{{{ data.label_right }}}" class="description" style="font-style:normal;">{{ data.label_right }}</label>
<# } #>
</div>
<div class="gp-spacing-section">
<input id="{{{ data.element }}}-mobile-{{{ data.label_bottom }}}" min="0" class="generate-number-control mobile-spacing-bottom" type="number" style="text-align: center;" {{{ data.mobile_bottom.link }}} value="{{{ data.mobile_bottom.value }}}" />
<# if ( data.label_bottom ) { #>
<label for="{{{ data.element }}}-mobile-{{{ data.label_bottom }}}" class="description" style="font-style:normal;">{{ data.label_bottom }}</label>
<# } #>
</div>
<div class="gp-spacing-section">
<input id="{{{ data.element }}}-mobile-{{{ data.label_left }}}" min="0" class="generate-number-control mobile-spacing-left" type="number" style="text-align: center;" {{{ data.mobile_left.link }}} value="{{{ data.mobile_left.value }}}" />
<# if ( data.label_left ) { #>
<label for="{{{ data.element }}}-mobile-{{{ data.label_left }}}" class="description" style="font-style:normal;">{{ data.label_left }}</label>
<# } #>
</div>
<# if ( data.element ) { #>
<div class="gp-spacing-section gp-link-spacing-section">
<span class="dashicons dashicons-editor-unlink gp-link-spacing" data-element="{{ data.element }}" title="{{ data.title }}"></span>
<span class="dashicons dashicons-admin-links gp-unlink-spacing" style="display:none" data-element="{{ data.element }}" title="{{ data.unlink_title }}"></span>
</div>
<# } #>
</div>
<# } #>
</div>
</div>
<?php
}
}
endif;

View File

@ -0,0 +1,32 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'GeneratePress_Title_Customize_Control' ) ) :
/**
* Create a control to display titles within our sections
*/
class GeneratePress_Title_Customize_Control extends WP_Customize_Control {
public $type = 'generatepress-customizer-title';
public $title = '';
public function enqueue() {
wp_enqueue_style( 'generatepress-title-customize-control', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/title-customizer.css', array(), GP_PREMIUM_VERSION );
}
public function to_json() {
parent::to_json();
$this->json[ 'title' ] = esc_html( $this->title );
}
public function content_template() {
?>
<div class="generatepress-customizer-title">
<span>{{ data.title }}</span>
</div>
<?php
}
}
endif;

View File

@ -0,0 +1,187 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'GeneratePress_Pro_Typography_Customize_Control' ) ) :
class GeneratePress_Pro_Typography_Customize_Control extends WP_Customize_Control
{
public $type = 'gp-pro-customizer-typography';
public function enqueue() {
wp_enqueue_script( 'generatepress-pro-typography-selectWoo', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/selectWoo.min.js', array( 'customize-controls', 'jquery' ), GP_PREMIUM_VERSION, true );
wp_enqueue_style( 'generatepress-pro-typography-selectWoo', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/selectWoo.min.css', array(), GP_PREMIUM_VERSION );
wp_enqueue_script( 'generatepress-pro-typography-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/typography-customizer.js', array( 'customize-controls', 'generatepress-pro-typography-selectWoo' ), GP_PREMIUM_VERSION, true );
wp_enqueue_style( 'generatepress-pro-typography-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/typography-customizer.css', array(), GP_PREMIUM_VERSION );
}
public function to_json() {
parent::to_json();
$this->json[ 'default_fonts_title'] = __( 'System Fonts', 'gp-premium' );
$this->json[ 'google_fonts_title'] = __( 'Google Fonts', 'gp-premium' );
$this->json[ 'default_fonts' ] = generate_typography_default_fonts();
$this->json[ 'family_title' ] = esc_html__( 'Font family', 'gp-premium' );
$this->json[ 'weight_title' ] = esc_html__( 'Font weight', 'gp-premium' );
$this->json[ 'transform_title' ] = esc_html__( 'Text transform', 'gp-premium' );
$this->json[ 'category_title' ] = '';
$this->json[ 'variant_title' ] = esc_html__( 'Variants', 'gp-premium' );
foreach ( $this->settings as $setting_key => $setting_id ) {
$this->json[ $setting_key ] = array(
'link' => $this->get_link( $setting_key ),
'value' => $this->value( $setting_key ),
'default' => isset( $setting_id->default ) ? $setting_id->default : '',
'id' => isset( $setting_id->id ) ? $setting_id->id : ''
);
if ( 'weight' === $setting_key ) {
$this->json[ $setting_key ]['choices'] = $this->get_font_weight_choices();
}
if ( 'transform' === $setting_key ) {
$this->json[ $setting_key ]['choices'] = $this->get_font_transform_choices();
}
}
}
public function content_template() {
?>
<# if ( '' !== data.label ) { #>
<span class="customize-control-title">{{ data.label }}</span>
<# } #>
<# if ( 'undefined' !== typeof ( data.family ) ) { #>
<div class="generatepress-font-family">
<label>
<select {{{ data.family.link }}} data-category="{{{ data.category.id }}}" data-variants="{{{ data.variant.id }}}" style="width:100%;">
<optgroup label="{{ data.default_fonts_title }}">
<# for ( var key in data.default_fonts ) { #>
<# var name = data.default_fonts[ key ].split(',')[0]; #>
<option value="{{ data.default_fonts[ key ] }}" <# if ( data.default_fonts[ key ] === data.family.value ) { #>selected="selected"<# } #>>{{ name }}</option>
<# } #>
</optgroup>
<optgroup label="{{ data.google_fonts_title }}">
<# for ( var key in generatePressTypography.googleFonts ) { #>
<option value="{{ generatePressTypography.googleFonts[ key ].name }}" <# if ( generatePressTypography.googleFonts[ key ].name === data.family.value ) { #>selected="selected"<# } #>>{{ generatePressTypography.googleFonts[ key ].name }}</option>
<# } #>
</optgroup>
</select>
<# if ( '' !== data.family_title ) { #>
<p class="description">{{ data.family_title }}</p>
<# } #>
</label>
</div>
<# } #>
<# if ( 'undefined' !== typeof ( data.variant ) ) { #>
<#
var id = data.family.value.split(' ').join('_').toLowerCase();
var font_data = generatePressTypography.googleFonts[id];
var variants = '';
if ( typeof font_data !== 'undefined' ) {
variants = font_data.variants;
}
if ( null === data.variant.value ) {
data.variant.value = data.variant.default;
}
#>
<div id={{{ data.variant.id }}}" class="generatepress-font-variant" data-saved-value="{{ data.variant.value }}">
<label>
<select name="{{{ data.variant.id }}}" multiple class="typography-multi-select" style="width:100%;" {{{ data.variant.link }}}>
<# _.each( variants, function( label, choice ) { #>
<option value="{{ label }}">{{ label }}</option>
<# } ) #>
</select>
<# if ( '' !== data.variant_title ) { #>
<p class="description">{{ data.variant_title }}</p>
<# } #>
</label>
</div>
<# } #>
<# if ( 'undefined' !== typeof ( data.category ) ) { #>
<div class="generatepress-font-category">
<label>
<input name="{{{ data.category.id }}}" type="hidden" {{{ data.category.link }}} value="{{{ data.category.value }}}" class="gp-hidden-input" />
<# if ( '' !== data.category_title ) { #>
<p class="description">{{ data.category_title }}</p>
<# } #>
</label>
</div>
<# } #>
<div class="generatepress-weight-transform-wrapper">
<# if ( 'undefined' !== typeof ( data.weight ) ) { #>
<div class="generatepress-font-weight">
<label>
<select {{{ data.weight.link }}}>
<# _.each( data.weight.choices, function( label, choice ) { #>
<option value="{{ choice }}" <# if ( choice === data.weight.value ) { #> selected="selected" <# } #>>{{ label }}</option>
<# } ) #>
</select>
<# if ( '' !== data.weight_title ) { #>
<p class="description">{{ data.weight_title }}</p>
<# } #>
</label>
</div>
<# } #>
<# if ( 'undefined' !== typeof ( data.transform ) ) { #>
<div class="generatepress-font-transform">
<label>
<select {{{ data.transform.link }}}>
<# _.each( data.transform.choices, function( label, choice ) { #>
<option value="{{ choice }}" <# if ( choice === data.transform.value ) { #> selected="selected" <# } #>>{{ label }}</option>
<# } ) #>
</select>
<# if ( '' !== data.transform_title ) { #>
<p class="description">{{ data.transform_title }}</p>
<# } #>
</label>
</div>
<# } #>
</div>
<?php
}
public function get_font_weight_choices() {
return array(
'' => esc_html__( 'inherit', 'gp-premium' ),
'normal' => esc_html__( 'normal', 'gp-premium' ),
'bold' => esc_html__( 'bold', 'gp-premium' ),
'100' => esc_html( '100' ),
'200' => esc_html( '200' ),
'300' => esc_html( '300' ),
'400' => esc_html( '400' ),
'500' => esc_html( '500' ),
'600' => esc_html( '600' ),
'700' => esc_html( '700' ),
'800' => esc_html( '800' ),
'900' => esc_html( '900' ),
);
}
public function get_font_transform_choices() {
return array(
'' => esc_html__( 'inherit', 'gp-premium' ),
'none' => esc_html__( 'none', 'gp-premium' ),
'capitalize' => esc_html__( 'capitalize', 'gp-premium' ),
'uppercase' => esc_html__( 'uppercase', 'gp-premium' ),
'lowercase' => esc_html__( 'lowercase', 'gp-premium' ),
);
}
}
endif;

View File

@ -0,0 +1,33 @@
/**
* Alpha Color Picker CSS
*/
.customize-control-gp-alpha-color .iris-picker .iris-square {
margin-right:10px;
}
.customize-control-gp-alpha-color .alpha-slider.ui-widget-content,
.customize-control-gp-alpha-color .ui-widget-header{
background: none;
border: 0;
box-shadow: 0 0 0 transparent;
}
.alpha-color-picker-wrap a.iris-square-value:focus {
-webkit-box-shadow: none;
box-shadow: none;
}
.gp-alpha-color-picker-container {
position: relative;
margin-left: 10px;
background-image: url(transparency-grid.png);
}
.gp-alpha-color-picker-container .iris-picker .iris-strip .ui-slider-handle {
z-index: 100;
}
.customize-control-gp-alpha-color .wp-picker-input-wrap .button.wp-picker-clear {
margin-left: 6px;
padding: 2px 8px;
}

View File

@ -0,0 +1,21 @@
.generatepress-control-toggles {
display: flex;
}
.generatepress-control-toggles button {
flex-basis: 100%;
background-color: #fafafa;
border: 1px solid #ddd;
cursor: pointer;
padding: 5px 10px;
}
.generatepress-control-toggles button:last-child {
border-left: 0;
}
.generatepress-control-toggles button.active {
background-color: #fff;
border: 1px solid #ccc;
font-weight: bold;
}

View File

@ -0,0 +1,38 @@
.generatepress-shortcuts {
background: #fff;
padding: 10px 15px;
border-width: 0 1px 1px 0;
border-color: #ddd;
border-style: solid;
}
.generatepress-shortcuts .more-controls {
font-weight: 600;
margin-right: 5px;
display: block;
font-size: 12px;
margin-bottom: 3px;
}
.generatepress-shortcuts .shortcuts .shortcut:not(:last-child):after {
content: "\2022";
padding: 0 1px;
}
.generatepress-shortcuts .shortcut a {
text-decoration: none;
}
.generatepress-shortcuts .shortcut {
font-size: 12px;
}
.return-shortcut .dashicons {
float: right;
cursor: pointer;
}
.return-shortcut a {
font-size: 12px;
text-decoration: none;
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,144 @@
.customize-control-generatepress-pro-range-slider .generatepress-slider {
position: relative;
width: calc(100% - 60px);
height: 6px;
background-color: rgba(0,0,0,.10);
cursor: pointer;
-webkit-transition: background .5s;
-moz-transition: background .5s;
transition: background .5s;
}
.customize-control-generatepress-pro-range-slider .has-unit .generatepress-slider {
width: calc(100% - 90px);
}
.customize-control-generatepress-pro-range-slider .gp_range_value.hide-value {
display: none;
}
.customize-control-generatepress-pro-range-slider .gp_range_value.hide-value + .generatepress-slider {
width: 100%;
}
.customize-control-generatepress-pro-range-slider .generatepress-slider .ui-slider-handle {
height: 16px;
width: 16px;
background-color: #3498D9;
display: inline-block;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%) translateX(-4px);
transform: translateY(-50%) translateX(-4px);
border-radius: 50%;
cursor: pointer;
}
.customize-control-generatepress-pro-range-slider .wrapper {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.customize-control-generatepress-pro-range-slider .gp_range_value {
font-size: 14px;
padding: 0;
font-weight: 400;
width: 50px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.customize-control-generatepress-pro-range-slider .has-unit .gp_range_value {
width: 80px;
}
.customize-control-generatepress-pro-range-slider .gp_range_value span.value {
font-size: 12px;
width: calc(100% - 2px);
text-align: center;
min-height: 30px;
background: #FFF;
line-height: 30px;
border: 1px solid #DDD;
}
.customize-control-generatepress-pro-range-slider .has-unit .gp_range_value span.value {
width: calc(100% - 32px);
display: block;
}
.customize-control-generatepress-pro-range-slider .gp_range_value .unit {
width: 29px;
text-align: center;
font-size: 12px;
line-height: 30px;
background: #fff;
border: 1px solid #ddd;
margin-left: 1px;
}
.customize-control-generatepress-pro-range-slider .generatepress-pro-range-slider-reset span {
font-size: 16px;
line-height: 22px;
}
.customize-control-generatepress-pro-range-slider .gp_range_value input {
font-size: 12px;
padding: 0px;
text-align: center;
min-height: 30px;
height: auto;
border-radius: 0;
border-color: #ddd;
}
.customize-control-generatepress-pro-range-slider .has-unit .gp_range_value input {
width: calc(100% - 30px);
}
.customize-control-generatepress-pro-range-slider .gp-range-title-area .dashicons {
cursor: pointer;
font-size: 11px;
width: 20px;
height: 20px;
line-height: 20px;
color: #222;
text-align: center;
position: relative;
top: 2px;
}
.customize-control-generatepress-pro-range-slider .gp-range-title-area .dashicons:hover {
background: #fafafa;
}
.customize-control-generatepress-pro-range-slider .gp-range-title-area .dashicons.selected {
background: #fff;
color: #222;
}
.gp-range-title-area {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.gp-range-slider-controls {
margin-left: auto;
}
.customize-control-generatepress-pro-range-slider .gp-device-controls > span:first-child:last-child {
display: none;
}
.customize-control-generatepress-pro-range-slider .sub-description {
margin-top: 10px;
}

View File

@ -0,0 +1,105 @@
.gp-spacing-control-section-title-area {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.gp-range-slider-controls {
margin-left: auto;
}
.customize-control-spacing .description {
font-size: 10px;
text-transform: uppercase;
font-weight: bold;
font-style: normal;
opacity: 0.7;
}
.spacing-values-area {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.gp-spacing-section input {
min-height: 30px;
border-radius: 0;
border-color: #ddd;
}
.gp-link-spacing-section span {
display: block;
color: #0073aa;
font-size: 14px;
cursor: pointer;
height: auto;
min-height: 28px;
line-height: 28px;
box-sizing: border-box;
width: 40px;
background: #fff;
border: 1px solid #ddd;
}
.gp-link-spacing-section span.gp-unlink-spacing {
background-color: #0073aa;
color: #fff;
}
.gp-spacing-section {
margin-right: 2px;
text-align:center
}
.gp-link-spacing-section {
margin-right: 0;
}
.gp-spacing-section .description {
font-size: 10px;
text-transform: uppercase;
font-weight: bold;
font-style: normal;
opacity: 0.7;
}
.no-edit-field {
font-size: 11px;
opacity: 0.8;
font-weight: 600;
}
/*
* Make sure slider is 100% wide.
* Old versions of Secondary Nav will have this set as 50%
* so we need to set !important to overwrite that.
*/
.customize-control.customize-control-gp-spacing-slider {
width: 100% !important;
}
.customize-control-generatepress-spacing .gp-spacing-control-section-title-area .dashicons {
cursor: pointer;
font-size: 11px;
width: 20px;
height: 20px;
line-height: 20px;
color: #222;
text-align: center;
position: relative;
top: 2px;
}
.customize-control-generatepress-spacing .gp-spacing-control-section-title-area .dashicons:hover {
background: #fafafa;
}
.customize-control-generatepress-spacing .gp-spacing-control-section-title-area .dashicons.selected {
background: #fff;
color: #222;
}
.customize-control-generatepress-spacing .gp-device-controls > span:first-child:last-child {
display: none;
}

View File

@ -0,0 +1,9 @@
.generatepress-customizer-title {
background: #FFF;
padding: 10px 12px;
font-weight: 600;
border-style: solid;
border-width: 0 1px 1px 0;
border-color: #ddd;
font-size: 15px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -0,0 +1,64 @@
.generatepress-font-family {
margin-bottom: 12px;
}
.generatepress-weight-transform-wrapper {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
}
.generatepress-font-weight,
.generatepress-font-transform {
width: calc(50% - 5px);
}
span.select2-container.select2-container--default.select2-container--open li.select2-results__option {
margin:0;
}
span.select2-container.select2-container--default.select2-container--open{
z-index:999999;
}
.select2-selection__rendered li {
margin-bottom: 0;
}
.select2-container--default .select2-selection--single,
.select2-container--default.select2-container .select2-selection--multiple,
.select2-dropdown,
.select2-container--default .select2-selection--multiple .select2-selection__choice {
border-color: #ddd;
border-radius: 0;
}
.select2-container--default .select2-results__option[aria-selected=true] {
color: rgba(0,0,0,0.4);
}
.select2-container .select2-search--inline {
display: none;
}
#customize-control-single_content_title_control,
#customize-control-font_heading_2_control,
#customize-control-archive_content_title_control,
#customize-control-font_heading_3_control,
#customize-control-font_heading_4_control,
#customize-control-font_heading_5_control,
#customize-control-font_heading_6_control {
margin-top: 20px;
}
.generatepress-weight-transform-wrapper select option[value=""] {
display: none;
}
#customize-control-single_content_title_control .generatepress-weight-transform-wrapper select option[value=""],
#customize-control-archive_content_title_control .generatepress-weight-transform-wrapper select option[value=""] {
display: block;
}

View File

@ -0,0 +1,277 @@
/**
* Alpha Color Picker JS
*
* This file includes several helper functions and the core control JS.
*/
/**
* Override the stock color.js toString() method to add support for
* outputting RGBa or Hex.
*/
Color.prototype.toString = function( flag ) {
// If our no-alpha flag has been passed in, output RGBa value with 100% opacity.
// This is used to set the background color on the opacity slider during color changes.
if ( 'no-alpha' == flag ) {
return this.toCSS( 'rgba', '1' ).replace( /\s+/g, '' );
}
// If we have a proper opacity value, output RGBa.
if ( 1 > this._alpha ) {
return this.toCSS( 'rgba', this._alpha ).replace( /\s+/g, '' );
}
// Proceed with stock color.js hex output.
var hex = parseInt( this._color, 10 ).toString( 16 );
if ( this.error ) { return ''; }
if ( hex.length < 6 ) {
for ( var i = 6 - hex.length - 1; i >= 0; i-- ) {
hex = '0' + hex;
}
}
return '#' + hex;
};
/**
* Given an RGBa, RGB, or hex color value, return the alpha channel value.
*/
function generate_get_alpha_value_from_color( value ) {
var alphaVal;
// Remove all spaces from the passed in value to help our RGBa regex.
value = value.toString().replace( / /g, '' );
if ( value.match( /rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/ ) ) {
alphaVal = parseFloat( value.match( /rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/ )[1] ).toFixed(2) * 100;
alphaVal = parseInt( alphaVal );
} else {
alphaVal = 100;
}
return alphaVal;
}
/**
* Force update the alpha value of the color picker object and maybe the alpha slider.
*/
function generate_update_alpha_value_on_color_control( alpha, $control, $alphaSlider, update_slider ) {
var iris, colorPicker, color;
iris = $control.data( 'a8cIris' );
colorPicker = $control.data( 'wpWpColorPicker' );
// Set the alpha value on the Iris object.
iris._color._alpha = alpha;
// Store the new color value.
color = iris._color.toString();
// Set the value of the input.
$control.val( color );
// Update the background color of the color picker.
colorPicker.toggler.css({
'background-color': color
});
// Maybe update the alpha slider itself.
if ( update_slider ) {
generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
}
// Update the color value of the color picker object.
$control.wpColorPicker( 'color', color );
}
/**
* Update the slider handle position and label.
*/
function generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider ) {
$alphaSlider.slider( 'value', alpha );
//$alphaSlider.find( '.ui-slider-handle' ).text( alpha.toString() );
}
/**
* Initialization trigger.
*/
jQuery( document ).ready( function( $ ) {
// Loop over each control and transform it into our color picker.
$( '.gp-alpha-color-control' ).each( function() {
// Scope the vars.
var $control, startingColor, paletteInput, showOpacity, defaultColor, palette,
colorPickerOptions, $container, $alphaSlider, alphaVal, sliderOptions, savedValue;
// Store the control instance.
$control = $( this );
// Get our saved value
savedValue = wp.customize.value( $control.attr( 'data-customize-setting-link' ) )();
// Get a clean starting value for the option.
startingColor = savedValue.toString().replace( /\s+/g, '' );
// Get some data off the control.
paletteInput = $control.attr( 'data-palette' );
showOpacity = $control.attr( 'data-show-opacity' );
defaultColor = $control.attr( 'data-default-color' );
// Process the palette.
if ( paletteInput.indexOf( '|' ) !== -1 ) {
palette = paletteInput.split( '|' );
} else if ( 'false' == paletteInput ) {
palette = false;
} else {
palette = true;
}
// Set up the options that we'll pass to wpColorPicker().
colorPickerOptions = {
change: function( event, ui ) {
var key, value, alpha, $transparency;
key = $control.attr( 'data-customize-setting-link' );
value = $control.wpColorPicker( 'color' );
// Send ajax request to wp.customize to trigger the Save action.
wp.customize( key, function( obj ) {
obj.set( value );
});
$transparency = $container.find( '.transparency' );
// Always show the background color of the opacity slider at 100% opacity.
$alphaSlider.closest( '.gp-alpha-color-picker-container' ).css( 'background-color', ui.color.toString( 'no-alpha' ) );
},
palettes: palette
};
// Create the colorpicker.
$control.val( savedValue ).wpColorPicker( colorPickerOptions );
$container = $control.parents( '.wp-picker-container:first' );
// Insert our opacity slider.
$( '<div class="gp-alpha-color-picker-container iris-slider iris-strip">' +
'<div class="alpha-slider iris-slider-offset"></div>' +
'</div>' ).appendTo( $container.find( '.iris-picker-inner' ) );
$alphaSlider = $container.find( '.alpha-slider' );
// If starting value is in format RGBa, grab the alpha channel.
alphaVal = generate_get_alpha_value_from_color( startingColor );
// Get the solid color
solidColor = startingColor.toString().replace( '0.' + alphaVal, '100' );
// Set up jQuery UI slider() options.
sliderOptions = {
create: function( event, ui ) {
var value = $( this ).slider( 'value' );
// Set up initial values.
//$( this ).find( '.ui-slider-handle' ).text( value );
$( this ).closest( '.iris-slider' ).css( 'background-color', solidColor );
},
value: alphaVal,
range: 'max',
step: 1,
min: 0,
max: 100,
animate: 300,
orientation: "vertical"
};
// Initialize jQuery UI slider with our options.
$alphaSlider.slider( sliderOptions );
// Bind event handler for clicking on a palette color.
$container.find( '.iris-palette' ).on( 'click', function() {
var color, alpha;
color = $( this ).css( 'background-color' );
alpha = generate_get_alpha_value_from_color( color );
generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
// Sometimes Iris doesn't set a perfect background-color on the palette,
// for example rgba(20, 80, 100, 0.3) becomes rgba(20, 80, 100, 0.298039).
// To compensante for this we round the opacity value on RGBa colors here
// and save it a second time to the color picker object.
if ( alpha != 100 ) {
color = color.toString().replace( /[^,]+(?=\))/, ( alpha / 100 ).toFixed( 2 ) );
}
$control.wpColorPicker( 'color', color );
});
// Bind event handler for clicking on the 'Clear' button.
$container.find( '.button.wp-picker-clear' ).on( 'click', function() {
var key = $control.attr( 'data-customize-setting-link' );
// The #fff color is delibrate here. This sets the color picker to white instead of the
// defult black, which puts the color picker in a better place to visually represent empty.
$control.wpColorPicker( 'color', '#ffffff' );
// Set the actual option value to empty string.
wp.customize( key, function( obj ) {
obj.set( '' );
});
generate_update_alpha_value_on_alpha_slider( 100, $alphaSlider );
});
// Bind event handler for clicking on the 'Default' button.
$container.find( '.button.wp-picker-default' ).on( 'click', function() {
var alpha = generate_get_alpha_value_from_color( defaultColor );
generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
});
// Bind event handler for typing or pasting into the input.
$control.on( 'input', function() {
var value = $( this ).val();
if ( '' === value ) {
var key = $control.attr( 'data-customize-setting-link' );
// The #fff color is delibrate here. This sets the color picker to white instead of the
// defult black, which puts the color picker in a better place to visually represent empty.
$control.wpColorPicker( 'color', '' );
// Set the actual option value to empty string.
wp.customize( key, function( obj ) {
obj.set( '' );
});
generate_update_alpha_value_on_alpha_slider( 100, $alphaSlider );
} else {
var alpha = generate_get_alpha_value_from_color( value );
generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
}
});
// Update all the things when the slider is interacted with.
$alphaSlider.slider().on( 'slide', function( event, ui ) {
var alpha = parseFloat( ui.value ) / 100.0;
generate_update_alpha_value_on_color_control( alpha, $control, $alphaSlider, false );
});
});
});
// Move the opacity bar next to the hue bar
jQuery( document ).ready( function( $ ) {
var container_width = $( '.customize-control-gp-alpha-color .iris-picker' ).width();
var square_width = $( '.customize-control-gp-alpha-color .iris-square' ).width();
var available_space = container_width - square_width;
var strip_width = ( available_space / 2 ) - 20;
var strip_height = $( '.customize-control-gp-alpha-color .iris-strip' ).height();
$( '.customize-control-gp-alpha-color .iris-strip, .gp-alpha-color-picker-container' ).css( 'width', strip_width + 'px' );
$( '.gp-alpha-color-picker-container' ).css( 'height', strip_height + 'px' );
});

View File

@ -0,0 +1,34 @@
( function( api ) {
api.controlConstructor['gp-background-images'] = api.Control.extend( {
ready: function() {
var control = this;
control.container.on( 'change', '.generatepress-backgrounds-repeat select',
function() {
control.settings['repeat'].set( jQuery( this ).val() );
}
);
control.container.on( 'change', '.generatepress-backgrounds-size select',
function() {
control.settings['size'].set( jQuery( this ).val() );
}
);
control.container.on( 'change', '.generatepress-backgrounds-attachment select',
function() {
control.settings['attachment'].set( jQuery( this ).val() );
}
);
control.container.on( 'input', '.generatepress-backgrounds-position input',
function() {
control.settings['position'].set( jQuery( this ).val() );
}
);
}
} );
} )( wp.customize );

View File

@ -0,0 +1,29 @@
jQuery( document ).ready( function( $ ) {
$( '[data-type="overlay_design"]' ).on( 'click', function( e ) {
e.preventDefault();
if ( ! confirm( gpButtonActions.warning ) ) {
return;
}
( function( api ) {
'use strict';
api.instance( 'generate_settings[slideout_background_color]' ).set( gpButtonActions.styling.backgroundColor );
api.instance( 'generate_settings[slideout_text_color]' ).set( gpButtonActions.styling.textColor );
api.instance( 'generate_settings[slideout_background_hover_color]' ).set( gpButtonActions.styling.backgroundHoverColor );
api.instance( 'generate_settings[slideout_background_current_color]' ).set( gpButtonActions.styling.backgroundCurrentColor );
api.instance( 'generate_settings[slideout_submenu_background_color]' ).set( gpButtonActions.styling.subMenuBackgroundColor );
api.instance( 'generate_settings[slideout_submenu_text_color]' ).set( gpButtonActions.styling.subMenuTextColor );
api.instance( 'generate_settings[slideout_submenu_background_hover_color]' ).set( gpButtonActions.styling.subMenuBackgroundHoverColor );
api.instance( 'generate_settings[slideout_submenu_background_current_color]' ).set( gpButtonActions.styling.subMenuBackgroundCurrentColor );
api.instance( 'generate_settings[slideout_font_weight]' ).set( gpButtonActions.styling.fontWeight );
api.instance( 'generate_settings[slideout_font_size]' ).set( gpButtonActions.styling.fontSize );
$( '.wp-color-picker' ).wpColorPicker().change();
}( wp.customize ) );
} );
} );

View File

@ -0,0 +1,32 @@
jQuery( document ).ready( function($) {
$( '.generatepress-control-toggles' ).each( function() {
$( this ).find( 'button' ).first().addClass( 'active' );
} );
$( document ).on( 'click', '.generatepress-control-toggles button', function( e ) {
e.preventDefault();
var button = $( this ),
target = button.data( 'target' ),
other_targets = button.siblings();
button.addClass( 'active' );
button.siblings().removeClass( 'active' );
$( 'li[data-control-section="' + target + '"]' ).css( {
visibility: 'visible',
height: '',
width: '',
margin: ''
} );
$.each( other_targets, function( index, value ) {
var other_target = $( this ).data( 'target' );
$( 'li[data-control-section="' + other_target + '"]' ).css( {
visibility: 'hidden',
height: '0',
width: '0',
margin: '0'
} );
} );
} );
});

View File

@ -0,0 +1,12 @@
( function( $, api ) {
api.controlConstructor['gp-copyright'] = api.Control.extend( {
ready: function() {
var control = this;
$( '.gp-copyright-area', control.container ).on( 'change keyup',
function() {
control.setting.set( $( this ).val() );
}
);
}
} );
} )( jQuery, wp.customize );

View File

@ -0,0 +1,169 @@
( function( $, api ) {
/**
* Set some controls when we're using the navigation as a header.
*
* @since 1.8
*/
api( 'generate_menu_plus_settings[navigation_as_header]', function( value ) {
value.bind( function( newval ) {
var navAlignmentSetting = api.instance( 'generate_settings[nav_alignment_setting]' ),
navAlignment = gpControls.navigationAlignment,
siteTitleFontSizeSetting = api.instance( 'generate_settings[site_title_font_size]' ),
mobileSiteTitleFontSizeSetting = api.instance( 'generate_settings[mobile_site_title_font_size]' ),
siteTitleFontSize = gpControls.siteTitleFontSize,
mobileSiteTitleFontSize = gpControls.mobileSiteTitleFontSize,
mobileHeader = api.instance( 'generate_menu_plus_settings[mobile_header]' ).get(),
navTextColorSetting = api.instance( 'generate_settings[navigation_text_color]' ),
navTextColor = gpControls.navigationTextColor,
headerTextColorSetting = api.instance( 'generate_settings[header_text_color]' ),
headerTextColor = gpControls.headerTextColor;
if ( ! siteTitleFontSizeSetting._dirty && 25 !== siteTitleFontSizeSetting.get() ) {
siteTitleFontSize = siteTitleFontSizeSetting.get();
}
if ( ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
mobileSiteTitleFontSize = mobileSiteTitleFontSizeSetting.get();
}
if ( ! navTextColorSetting._dirty ) {
navTextColor = navTextColorSetting.get();
}
if ( ! headerTextColorSetting._dirty ) {
headerTextColor = headerTextColorSetting.get();
}
if ( newval ) {
navAlignmentSetting.set( 'right' );
siteTitleFontSizeSetting.set( 25 );
api.instance( 'generate_settings[site_title_color]' ).set( navTextColor );
if ( 'enable' !== mobileHeader ) {
mobileSiteTitleFontSizeSetting.set( 20 );
}
} else {
navAlignmentSetting.set( navAlignment );
siteTitleFontSizeSetting.set( siteTitleFontSize );
api.instance( 'generate_settings[site_title_color]' ).set( headerTextColor );
if ( 'enable' !== mobileHeader ) {
mobileSiteTitleFontSizeSetting.set( mobileSiteTitleFontSize );
}
}
} );
var showRegularHeader,
showRegularHeaderCallback,
showNavHeader,
showNavHeaderCallback;
/**
* Determine whether we should display our header controls.
*
* @returns {boolean}
*/
showRegularHeader = function() {
if ( value.get() ) {
return false;
}
return true;
};
/**
* Determine whether our navigation is our header.
*
* @returns {boolean}
*/
showNavHeader = function() {
if ( value.get() ) {
return true;
}
return false;
};
/**
* Update a control's active state according to the navigation as header option.
*
* @param {wp.customize.Control} control
*/
showRegularHeaderCallback = function( control ) {
var setActiveState = function() {
control.active.set( showRegularHeader() );
};
control.active.validate = showRegularHeader;
setActiveState();
value.bind( setActiveState );
};
/**
* Update a control's active state according to the navigation as header option.
*
* @param {wp.customize.Control} control
*/
showNavHeaderCallback = function( control ) {
var setActiveState = function() {
control.active.set( showNavHeader() );
};
control.active.validate = showNavHeader;
setActiveState();
value.bind( setActiveState );
};
api.control( 'generate_header_helper', showRegularHeaderCallback );
api.control( 'generate_settings[header_layout_setting]', showRegularHeaderCallback );
api.control( 'generate_settings[header_inner_width]', showRegularHeaderCallback );
api.control( 'generate_settings[header_alignment_setting]', showRegularHeaderCallback );
api.control( 'header_spacing', showRegularHeaderCallback );
api.control( 'generate_settings[header_background_color]', showRegularHeaderCallback );
api.control( 'header_text_color', showRegularHeaderCallback );
api.control( 'header_link_color', showRegularHeaderCallback );
api.control( 'header_link_hover_color', showRegularHeaderCallback );
api.control( 'site_tagline_color', showRegularHeaderCallback );
api.control( 'font_site_tagline_control', showRegularHeaderCallback );
api.control( 'generate_settings[site_tagline_font_size]', showRegularHeaderCallback );
api.control( 'generate_settings[nav_position_setting]', showRegularHeaderCallback );
api.control( 'generate_settings[logo_width]', showRegularHeaderCallback );
} );
/**
* Set the navigation branding font size label on mobile header branding change.
*
* @since 1.8
*/
api( 'generate_menu_plus_settings[mobile_header_branding]', function( value ) {
value.bind( function( newval ) {
if ( 'title' === newval ) {
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( 20 );
}
} );
} );
/**
* Set the navigation branding font size label on mobile header change.
*
* @since 1.8
*/
api( 'generate_menu_plus_settings[mobile_header]', function( value ) {
value.bind( function( newval ) {
var mobileSiteTitleFontSizeSetting = api.instance( 'generate_settings[mobile_site_title_font_size]' ),
mobileSiteTitleFontSize = gpControls.mobileSiteTitleFontSize;
if ( ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
mobileSiteTitleFontSize = mobileSiteTitleFontSizeSetting.get();
}
if ( 'enable' === newval ) {
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( 20 );
} else {
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( mobileSiteTitleFontSize );
}
} );
} );
} )( jQuery, wp.customize );

View File

@ -0,0 +1,46 @@
jQuery( document ).ready( function( $ ) {
$( '.generatepress-shortcuts a' ).on( 'click', function( e ) {
e.preventDefault();
var section = $( this ).attr( 'data-section' ),
currentSection = $( this ).attr( 'data-current-section' ),
destinationSectionElement = $( '[id$="' + section + '"]' );
if ( section ) {
wp.customize.section( section ).focus();
destinationSectionElement.find( '.show-shortcuts' ).hide();
destinationSectionElement.find( '.return-shortcut' ).show();
destinationSectionElement.find( '.return-shortcut a' ).attr( 'data-return', currentSection );
}
} );
$( '.return-shortcut .dashicons' ).on( 'click', function( e ) {
var container = $( this ).closest( '.generatepress-shortcuts' );
container.find( '.show-shortcuts' ).show();
container.find( '.return-shortcut' ).hide();
} );
$( '.return-shortcut a' ).on( 'click', function( e ) {
e.preventDefault();
var section = $( this ).attr( 'data-return' );
var container = $( this ).closest( '.generatepress-shortcuts' );
if ( section ) {
wp.customize.section( section ).focus();
container.find( '.show-shortcuts' ).show();
container.find( '.return-shortcut' ).hide();
}
} );
var customizeSectionBack = $( '.customize-section-back' );
if ( customizeSectionBack ) {
customizeSectionBack.on( 'click', function() {
$( '.show-shortcuts' ).show();
$( '.return-shortcut' ).hide();
} );
}
} );

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,134 @@
wp.customize.controlConstructor['generatepress-pro-range-slider'] = wp.customize.Control.extend({
ready: function() {
'use strict';
var control = this,
value,
thisInput,
inputDefault,
changeAction,
controlClass = '.customize-control-generatepress-pro-range-slider',
footerActions = jQuery( '#customize-footer-actions' );
// Set up the sliders
jQuery( '.generatepress-slider' ).each( function() {
var _this = jQuery( this );
var _input = _this.closest( 'label' ).find( 'input[type="number"]' );
var _text = _input.next( '.value' );
_this.slider({
value: _input.val(),
min: _this.data( 'min' ),
max: _this.data( 'max' ),
step: _this.data( 'step' ),
slide: function( event, ui ) {
_input.val( ui.value ).change();
_text.text( ui.value );
}
});
});
// Update the range value based on the input value
jQuery( controlClass + ' .gp_range_value input[type=number]' ).on( 'input', function() {
value = jQuery( this ).attr( 'value' );
if ( '' == value ) {
value = -1;
}
jQuery( this ).closest( 'label' ).find( '.generatepress-slider' ).slider( 'value', parseFloat(value)).change();
});
// Handle the reset button
jQuery( controlClass + ' .generatepress-reset' ).on( 'click', function() {
var icon = jQuery( this ),
visible_area = icon.closest( '.gp-range-title-area' ).next( '.gp-range-slider-areas' ).children( 'label:visible' ),
input = visible_area.find( 'input[type=number]' ),
slider_value = visible_area.find( '.generatepress-slider' ),
visual_value = visible_area.find( '.gp_range_value' ),
reset_value = input.attr( 'data-reset_value' );
input.val( reset_value ).change();
visual_value.find( 'input' ).val( reset_value );
visual_value.find( '.value' ).text( reset_value );
if ( '' == reset_value ) {
reset_value = -1;
}
slider_value.slider( 'value', parseFloat( reset_value ) );
});
// Figure out which device icon to make active on load
jQuery( controlClass + ' .generatepress-range-slider-control' ).each( function() {
var _this = jQuery( this );
_this.find( '.gp-device-controls' ).children( 'span:first-child' ).addClass( 'selected' );
_this.find( '.range-option-area:first-child' ).show();
});
// Do stuff when device icons are clicked
jQuery( controlClass + ' .gp-device-controls > span' ).on( 'click', function( event ) {
var device = jQuery( this ).data( 'option' );
jQuery( controlClass + ' .gp-device-controls span' ).each( function() {
var _this = jQuery( this );
if ( device == _this.attr( 'data-option' ) ) {
_this.addClass( 'selected' );
_this.siblings().removeClass( 'selected' );
}
});
jQuery( controlClass + ' .gp-range-slider-areas label' ).each( function() {
var _this = jQuery( this );
if ( device == _this.attr( 'data-option' ) ) {
_this.show();
_this.siblings().hide();
}
});
// Set the device we're currently viewing
wp.customize.previewedDevice.set( jQuery( event.currentTarget ).data( 'option' ) );
} );
// Set the selected devices in our control when the Customizer devices are clicked
footerActions.find( '.devices button' ).on( 'click', function() {
var device = jQuery( this ).data( 'device' );
jQuery( controlClass + ' .gp-device-controls span' ).each( function() {
var _this = jQuery( this );
if ( device == _this.attr( 'data-option' ) ) {
_this.addClass( 'selected' );
_this.siblings().removeClass( 'selected' );
}
});
jQuery( controlClass + ' .gp-range-slider-areas label' ).each( function() {
var _this = jQuery( this );
if ( device == _this.attr( 'data-option' ) ) {
_this.show();
_this.siblings().hide();
}
});
});
// Apply changes when desktop slider is changed
control.container.on( 'input change', '.desktop-range',
function() {
control.settings['desktop'].set( jQuery( this ).val() );
}
);
// Apply changes when tablet slider is changed
control.container.on( 'input change', '.tablet-range',
function() {
control.settings['tablet'].set( jQuery( this ).val() );
}
);
// Apply changes when mobile slider is changed
control.container.on( 'input change', '.mobile-range',
function() {
control.settings['mobile'].set( jQuery( this ).val() );
}
);
}
});

View File

@ -0,0 +1,200 @@
( function( $, api ) {
// No longer needed as of 1.2.95
// Keeping it here just in case
api.controlConstructor['spacing'] = api.Control.extend( {
ready: function() {
var control = this;
$( '.generate-number-control', control.container ).on( 'change keyup',
function() {
control.setting.set( $( this ).val() );
}
);
}
} );
api.controlConstructor['gp-spacing-slider'] = api.Control.extend( {
ready: function() {
var control = this;
$( '.slider-input', control.container ).on( 'change keyup',
function() {
control.setting.set( $( this ).val() );
}
);
}
} );
api.controlConstructor['generatepress-spacing'] = api.Control.extend( {
ready: function() {
var control = this,
controlClass = '.customize-control-generatepress-spacing',
footerActions = jQuery( '#customize-footer-actions' );
// Figure out which device icon to make active on load
jQuery( controlClass + ' .gp-spacing-control-section' ).each( function() {
var _this = jQuery( this );
_this.find( '.gp-device-controls' ).children( 'span:first-child' ).addClass( 'selected' );
_this.find( '.spacing-values-area:first-child' ).show();
});
// Do stuff when device icons are clicked
jQuery( controlClass + ' .gp-device-controls > span' ).on( 'click', function( event ) {
var device = jQuery( this ).data( 'option' );
jQuery( controlClass + ' .gp-device-controls span' ).each( function() {
var _this = jQuery( this );
if ( device == _this.attr( 'data-option' ) ) {
_this.addClass( 'selected' );
_this.siblings().removeClass( 'selected' );
}
});
jQuery( controlClass + ' .spacing-values-container .spacing-values-area' ).each( function() {
var _this = jQuery( this );
if ( device == _this.attr( 'data-option' ) ) {
_this.show();
_this.siblings().hide();
}
});
// Set the device we're currently viewing
wp.customize.previewedDevice.set( jQuery( event.currentTarget ).data( 'option' ) );
} );
// Set the selected devices in our control when the Customizer devices are clicked
footerActions.find( '.devices button' ).on( 'click', function() {
var device = jQuery( this ).data( 'device' );
jQuery( controlClass + ' .gp-device-controls span' ).each( function() {
var _this = jQuery( this );
if ( device == _this.attr( 'data-option' ) ) {
_this.addClass( 'selected' );
_this.siblings().removeClass( 'selected' );
}
});
jQuery( controlClass + ' .spacing-values-container .spacing-values-area' ).each( function() {
var _this = jQuery( this );
if ( device == _this.attr( 'data-option' ) ) {
_this.show();
_this.siblings().hide();
}
});
});
control.container.on( 'change keyup', '.spacing-top',
function() {
control.settings['desktop_top'].set( jQuery( this ).val() );
}
);
control.container.on( 'change keyup', '.spacing-right',
function() {
control.settings['desktop_right'].set( jQuery( this ).val() );
}
);
control.container.on( 'change keyup', '.spacing-bottom',
function() {
control.settings['desktop_bottom'].set( jQuery( this ).val() );
}
);
control.container.on( 'change keyup', '.spacing-left',
function() {
control.settings['desktop_left'].set( jQuery( this ).val() );
}
);
control.container.on( 'change keyup', '.tablet-spacing-top',
function() {
control.settings['tablet_top'].set( jQuery( this ).val() );
}
);
control.container.on( 'change keyup', '.tablet-spacing-right',
function() {
control.settings['tablet_right'].set( jQuery( this ).val() );
}
);
control.container.on( 'change keyup', '.tablet-spacing-bottom',
function() {
control.settings['tablet_bottom'].set( jQuery( this ).val() );
}
);
control.container.on( 'change keyup', '.tablet-spacing-left',
function() {
control.settings['tablet_left'].set( jQuery( this ).val() );
}
);
control.container.on( 'change keyup', '.mobile-spacing-top',
function() {
control.settings['mobile_top'].set( jQuery( this ).val() );
}
);
control.container.on( 'change keyup', '.mobile-spacing-right',
function() {
control.settings['mobile_right'].set( jQuery( this ).val() );
}
);
control.container.on( 'change keyup', '.mobile-spacing-bottom',
function() {
control.settings['mobile_bottom'].set( jQuery( this ).val() );
}
);
control.container.on( 'change keyup', '.mobile-spacing-left',
function() {
control.settings['mobile_left'].set( jQuery( this ).val() );
}
);
}
} );
} )( jQuery, wp.customize );
jQuery( document ).ready( function($) {
$( '.gp-link-spacing' ).on( 'click', function(e) {
e.preventDefault();
// Set up variables
var _this = $( this ),
element = _this.data( 'element' );
// Add our linked-values class to the next 4 elements
_this.parent( '.gp-spacing-section' ).prevAll().slice(0,4).find( 'input' ).addClass( 'linked-values' ).attr( 'data-element', element );
// Change our link icon class
_this.hide();
_this.next( 'span' ).show();
});
$( '.gp-unlink-spacing' ).on( 'click', function(e) {
e.preventDefault();
// Set up variables
var _this = $( this );
// Remove our linked-values class to the next 4 elements
_this.parent( '.gp-spacing-section' ).prevAll().slice(0,4).find( 'input' ).removeClass( 'linked-values' ).attr( 'data-element', '' );
// Change our link icon class
_this.hide();
_this.prev( 'span' ).show();
});
$( '.gp-spacing-section' ).on( 'input', '.linked-values', function() {
var _this = $( this ),
data = _this.attr( 'data-element' ),
val = _this.val(),
targetElements = _this.closest( '.spacing-values-area' ).find( '.linked-values[ data-element="' + data + '" ]' );
targetElements.each( function( key, value ) {
var element = $( this );
element.val( val ).change();
});
});
});

View File

@ -0,0 +1,151 @@
( function( api ) {
api.controlConstructor['gp-pro-customizer-typography'] = api.Control.extend( {
ready: function() {
var control = this;
control.container.on( 'change', '.generatepress-font-family select',
function() {
var _this = jQuery( this ),
_value = _this.val(),
_categoryID = _this.attr( 'data-category' ),
_variantsID = _this.attr( 'data-variants' );
// Set our font family
control.settings['family'].set( _this.val() );
// Bail if our controls don't exist
if ( 'undefined' == typeof control.settings['category'] || 'undefined' == typeof control.settings['variant'] ) {
return;
}
setTimeout( function() {
// Send our request to the generate_get_all_google_fonts_ajax function
var response = jQuery.getJSON({
type: 'POST',
url: ajaxurl,
data: {
action: 'generate_get_all_google_fonts_ajax',
gp_customize_nonce: gp_customize.nonce
},
async: false,
dataType: 'json',
});
// Get our response
var fonts = response.responseJSON;
// Create an ID from our selected font
var id = _value.split(' ').join('_').toLowerCase();
// Set our values if we have them
if ( id in fonts ) {
// Get existing variants if this font is already selected
var got_variants = false;
jQuery( '.generatepress-font-family select' ).not( _this ).each( function( key, select ) {
var parent = jQuery( this ).closest( '.generatepress-font-family' );
if ( _value == jQuery( select ).val() && _this.data( 'category' ) !== jQuery( select ).data( 'category' ) ) {
if ( ! got_variants ) {
updated_variants = jQuery( parent.next( '.generatepress-font-variant' ).find( 'select' ) ).val();
got_variants = true;
}
}
} );
// We're using a Google font, so show the variants field
_this.closest( '.generatepress-font-family' ).next( 'div' ).show();
// Remove existing variants
jQuery( 'select[name="' + _variantsID + '"]' ).find( 'option' ).remove();
// Populate our select input with available variants
jQuery.each( fonts[ id ].variants, function( key, value ) {
jQuery( 'select[name="' + _variantsID + '"]' ).append( jQuery( '<option></option>' ).attr( 'value', value ).text( value ) );
} );
// Set our variants
if ( ! got_variants ) {
control.settings[ 'variant' ].set( fonts[ id ].variants );
} else {
control.settings[ 'variant' ].set( updated_variants );
}
// Set our font category
control.settings[ 'category' ].set( fonts[ id ].category );
jQuery( 'input[name="' + _categoryID + '"' ).val( fonts[ id ].category );
} else {
_this.closest( '.generatepress-font-family' ).next( 'div' ).hide();
control.settings[ 'category' ].set( '' )
control.settings[ 'variant' ].set( '' )
jQuery( 'input[name="' + _categoryID + '"' ).val( '' );
jQuery( 'select[name="' + _variantsID + '"]' ).find( 'option' ).remove();
}
}, 25 );
}
);
control.container.on( 'change', '.generatepress-font-variant select',
function() {
var _this = jQuery( this );
var variants = _this.val();
control.settings['variant'].set( variants );
jQuery( '.generatepress-font-variant select' ).each( function( key, value ) {
var this_control = jQuery( this ).closest( 'li' ).attr( 'id' ).replace( 'customize-control-', '' );
var parent = jQuery( this ).closest( '.generatepress-font-variant' );
var font_val = api.control( this_control ).settings['family'].get();
if ( font_val == control.settings['family'].get() && _this.attr( 'name' ) !== jQuery( value ).attr( 'name' ) ) {
jQuery( parent.find( 'select' ) ).not( _this ).val( variants ).triggerHandler( 'change' );
api.control( this_control ).settings['variant'].set( variants );
}
} );
}
);
control.container.on( 'change', '.generatepress-font-category input',
function() {
control.settings['category'].set( jQuery( this ).val() );
}
);
control.container.on( 'change', '.generatepress-font-weight select',
function() {
control.settings['weight'].set( jQuery( this ).val() );
}
);
control.container.on( 'change', '.generatepress-font-transform select',
function() {
control.settings['transform'].set( jQuery( this ).val() );
}
);
}
} );
} )( wp.customize );
jQuery( document ).ready( function($) {
jQuery( '.generatepress-font-family select' ).selectWoo();
jQuery( '.generatepress-font-variant' ).each( function( key, value ) {
var _this = $( this );
var value = _this.data( 'saved-value' );
if ( value ) {
value = value.toString().split( ',' );
}
_this.find( 'select' ).selectWoo().val( value ).trigger( 'change.select2' );
} );
$( ".generatepress-font-family" ).each( function( key, value ) {
var _this = $( this );
if ( $.inArray( _this.find( 'select' ).val(), typography_defaults ) !== -1 ) {
_this.next( '.generatepress-font-variant' ).hide();
}
});
} );

View File

@ -0,0 +1,324 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'generate_backgrounds_sanitize_choices' ) ) :
/**
* Sanitize choices
*/
function generate_backgrounds_sanitize_choices( $input, $setting ) {
// Ensure input is a slug
$input = sanitize_text_field( $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 );
}
endif;
if ( ! function_exists( 'generate_backgrounds_is_top_bar_active' ) ) :
/**
* Check to see if the top bar is active
*
* @since 1.3.45
*/
function generate_backgrounds_is_top_bar_active()
{
$top_bar = is_active_sidebar( 'top-bar' ) ? true : false;
return apply_filters( 'generate_is_top_bar_active', $top_bar );
}
endif;
if ( ! function_exists( 'generate_blog_sanitize_choices' ) ) :
/**
* Sanitize choices
*/
function generate_blog_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 );
}
endif;
if ( ! function_exists( 'generate_blog_is_posts_page' ) ) :
/**
* Check to see if we're on a posts page
*/
function generate_blog_is_posts_page()
{
$blog = ( is_home() || is_archive() || is_attachment() || is_tax() ) ? true : false;
return $blog;
}
endif;
if ( ! function_exists( 'generate_blog_is_posts_page_single' ) ) :
/**
* Check to see if we're on a posts page or a single post
*/
function generate_blog_is_posts_page_single()
{
$blog = ( is_home() || is_archive() || is_attachment() || is_tax() || is_single() ) ? true : false;
return $blog;
}
endif;
if ( ! function_exists( 'generate_blog_is_excerpt' ) ) :
/**
* Check to see if we're displaying excerpts
*/
function generate_blog_is_excerpt()
{
if ( ! function_exists( 'generate_get_defaults' ) )
return;
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
return ( 'excerpt' == $generate_settings['post_content'] ) ? true : false;
}
endif;
if ( ! function_exists( 'generate_colors_sanitize_hex_color' ) ) :
/**
* Sanitize hex colors
* We don't use the core function as we want to allow empty values
* @since 0.1
*/
function generate_colors_sanitize_hex_color( $color ) {
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 '';
}
endif;
if ( ! function_exists( 'generate_colors_sanitize_rgba' ) ) :
/**
* Sanitize RGBA colors
* @since 1.3.42
*/
function generate_colors_sanitize_rgba( $color ) {
if ( '' === $color )
return '';
// If string does not start with 'rgba', then treat as hex
// sanitize the hex color and finally convert hex to rgba
if ( false === strpos( $color, 'rgba' ) ) {
return generate_colors_sanitize_hex_color( $color );
}
// By now we know the string is formatted as an rgba color so we need to further sanitize it.
$color = str_replace( ' ', '', $color );
sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
return 'rgba('.$red.','.$green.','.$blue.','.$alpha.')';
return '';
}
endif;
if ( ! function_exists( 'generate_menu_plus_sanitize_choices' ) ) :
/**
* Sanitize choices
*/
function generate_menu_plus_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 );
}
endif;
if ( ! function_exists( 'generate_page_header_is_posts_page' ) ) :
/**
* This is an active_callback
* Check if we're on a posts page
*/
function generate_page_header_is_posts_page()
{
$blog = ( is_home() || is_archive() || is_attachment() || is_tax() ) ? true : false;
return $blog;
}
endif;
if ( ! function_exists( 'generate_page_header_is_posts_page_single' ) ) :
/**
* Check to see if we're on a posts page or a single post
*/
function generate_page_header_is_posts_page_single()
{
$blog = ( is_home() || is_archive() || is_attachment() || is_tax() || is_single() ) ? true : false;
return $blog;
}
endif;
if ( ! function_exists( 'generate_secondary_nav_sanitize_choices' ) ) :
/**
* Sanitize choices
*/
function generate_secondary_nav_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 );
}
endif;
if ( ! function_exists( 'generate_spacing_sanitize_choices' ) ) :
/**
* Sanitize choices
*/
function generate_spacing_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 );
}
endif;
if ( ! function_exists( 'generate_premium_sanitize_typography' ) ) :
/**
* Sanitize typography dropdown
* @since 1.1.10
* @deprecated 1.2.95
*/
function generate_premium_sanitize_typography( $input )
{
if ( ! function_exists( 'generate_get_all_google_fonts' ) || ! function_exists( 'generate_typography_default_fonts' ) ) {
return 'Open Sans';
}
// Grab all of our fonts
$fonts = generate_get_all_google_fonts();
// Loop through all of them and grab their names
$font_names = array();
foreach ( $fonts as $k => $fam ) {
$font_names[] = $fam['name'];
}
// Get all non-Google font names
$not_google = generate_typography_default_fonts();
// Merge them both into one array
$valid = array_merge( $font_names, $not_google );
// Sanitize
if ( in_array( $input, $valid ) ) {
return $input;
} else {
return 'Open Sans';
}
}
endif;
if ( ! function_exists( 'generate_typography_sanitize_choices' ) ) :
/**
* Sanitize choices
* @since 1.3.24
*/
function generate_typography_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 );
}
endif;
if ( ! function_exists( 'generate_page_header_sanitize_choices' ) ) :
/**
* Sanitize our select inputs
*/
function generate_page_header_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 );
}
endif;
if ( ! function_exists( 'generate_page_header_sanitize_hex_color' ) ) :
/**
* Sanitize colors
* We don't use the core function as we want to allow empty values
*/
function generate_page_header_sanitize_hex_color( $color ) {
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 '';
}
endif;
if ( ! function_exists( 'generate_page_header_sanitize_html' ) ) :
/**
* Sanitize our fields that accept HTML
*/
function generate_page_header_sanitize_html( $input )
{
return wp_kses_post( $input );
}
endif;

View File

@ -0,0 +1,131 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'generate_premium_sanitize_empty_absint' ) ) {
function generate_premium_sanitize_empty_absint( $input ) {
if ( '' == $input ) {
return '';
}
return absint( $input );
}
}
if ( ! function_exists( 'generate_premium_sanitize_choices' ) ) {
/**
* Sanitize choices
*/
function generate_premium_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 );
}
}
if ( ! function_exists( 'generate_premium_sanitize_checkbox' ) ) {
/**
* Sanitize checkbox
*/
function generate_premium_sanitize_checkbox( $checked ) {
// Boolean check.
return ( ( isset( $checked ) && true == $checked ) ? true : false );
}
}
if ( ! function_exists( 'generate_premium_sanitize_hex_color' ) ) {
/**
* Sanitize hex colors
* We don't use the core function as we want to allow empty values
*
* @since 0.1
*/
function generate_premium_sanitize_hex_color( $color ) {
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 '';
}
}
if ( ! function_exists( 'generate_premium_sanitize_rgba' ) ) {
/**
* Sanitize RGBA colors
*
* @since 1.3.42
*/
function generate_premium_sanitize_rgba( $color ) {
if ( '' === $color ) {
return '';
}
// If string does not start with 'rgba', then treat as hex
// sanitize the hex color and finally convert hex to rgba
if ( false === strpos( $color, 'rgba' ) ) {
return generate_premium_sanitize_hex_color( $color );
}
// By now we know the string is formatted as an rgba color so we need to further sanitize it.
$color = str_replace( ' ', '', $color );
sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
return 'rgba('.$red.','.$green.','.$blue.','.$alpha.')';
return '';
}
}
if ( ! function_exists( 'generate_premium_sanitize_decimal_integer' ) ) {
/**
* Sanitize integers that can use decimals
*
* @since 1.3.41
*/
function generate_premium_sanitize_decimal_integer( $input ) {
return abs( floatval( $input ) );
}
}
/**
* Sanitize integers that can use decimals
* @since 1.4
*/
function generate_premium_sanitize_decimal_integer_empty( $input ) {
if ( '' == $input ) {
return '';
}
return abs( floatval( $input ) );
}
if ( ! function_exists( 'generate_premium_sanitize_html' ) ) {
/**
* Sanitize our fields that accept HTML
*/
function generate_premium_sanitize_html( $input ) {
return wp_kses_post( $input );
}
}
function generate_premium_sanitize_variants( $input ) {
if ( is_array( $input ) ) {
$input = implode( ',', $input );
}
return sanitize_text_field( $input );
}