modified file bootstrap-buttons.css

This commit is contained in:
2023-12-08 23:23:36 +00:00
committed by Gitium
parent 33d18af972
commit 3f4d8b933f
2304 changed files with 24432 additions and 417943 deletions

View File

@ -1,635 +0,0 @@
/**!
* wp-color-picker-alpha
*
* Overwrite Automattic Iris for enabled Alpha Channel in wpColorPicker
* Only run in input and is defined data alpha in true
*
* Version: 3.0.0
* https://github.com/kallookoo/wp-color-picker-alpha
* Licensed under the GPLv2 license or later.
*/
( function( $, undef ) {
var wpColorPickerAlpha = {
'version' : 300
};
// Always try to use the last version of this script.
if ( 'wpColorPickerAlpha' in window && 'version' in window.wpColorPickerAlpha ) {
var version = parseInt( window.wpColorPickerAlpha.version, 10 );
if ( ! isNaN( version ) && version >= wpColorPickerAlpha.version ) {
return;
}
}
// Prevent multiple initiations
if ( Color.fn.hasOwnProperty( 'to_s' ) ) {
return;
}
// Create new method to replace the `Color.toString()` inside the scripts.
Color.fn.to_s = function( type ) {
type = ( type || 'hex' );
// Change hex to rgba to return the correct color.
if ( 'hex' === type && this._alpha < 1 ) {
type = 'rgba';
}
var color = '';
if ( 'hex' === type ) {
color = this.toString();
} else if ( ! this.error ) {
color = this.toCSS( type ).replace( /\(\s+/, '(' ).replace( /\s+\)/, ')' );
}
return color;
}
// Register the global variable.
window.wpColorPickerAlpha = wpColorPickerAlpha;
// Background image encoded
var backgroundImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==';
/**
* Iris
*/
$.widget( 'a8c.iris', $.a8c.iris, {
/**
* Alpha options
*
* @since 3.0.0
*
* @type {Object}
*/
alphaOptions: {
alphaEnabled: false,
},
/**
* Get the current color or the new color.
*
* @since 3.0.0
* @access private
*
* @param {Object|*} The color instance if not defined return the cuurent color.
*
* @return {string} The element's color.
*/
_getColor: function( color ) {
if ( color === undef ) {
color = this._color;
}
if ( this.alphaOptions.alphaEnabled ) {
color = color.to_s( this.alphaOptions.alphaColorType );
if ( ! this.alphaOptions.alphaColorWithSpace ) {
color = color.replace( /\s+/g, '' );
}
return color;
}
return color.toString();
},
/**
* Create widget
*
* @since 3.0.0
* @access private
*
* @return {void}
*/
_create: function() {
try {
// Try to get the wpColorPicker alpha options.
this.alphaOptions = this.element.wpColorPicker( 'instance' ).alphaOptions;
} catch( e ) {}
// We make sure there are all options
$.extend( {}, this.alphaOptions, {
alphaEnabled: false,
alphaCustomWidth: 130,
alphaReset: false,
alphaColorType: 'hex',
alphaColorWithSpace: false,
} );
this._super();
},
/**
* Binds event listeners to the Iris.
*
* @since 3.0.0
* @access private
*
* @return {void}
*/
_addInputListeners: function( input ) {
var self = this,
debounceTimeout = 100,
callback = function( event ){
var val = input.val(),
color = new Color( val ),
val = val.replace( /^(#|(rgb|hsl)a?)/, '' ),
type = self.alphaOptions.alphaColorType;
input.removeClass( 'iris-error' );
if ( ! color.error ) {
// let's not do this on keyup for hex shortcodes
if ( 'hex' !== type || ! ( event.type === 'keyup' && val.match( /^[0-9a-fA-F]{3}$/ ) ) ) {
// Compare color ( #AARRGGBB )
if ( color.toIEOctoHex() !== self._color.toIEOctoHex() ) {
self._setOption( 'color', self._getColor( color ) );
}
}
} else if ( val !== '' ) {
input.addClass( 'iris-error' );
}
};
input.on( 'change', callback ).on( 'keyup', self._debounce( callback, debounceTimeout ) );
// If we initialized hidden, show on first focus. The rest is up to you.
if ( self.options.hide ) {
input.one( 'focus', function() {
self.show();
});
}
},
/**
* Init Controls
*
* @since 3.0.0
* @access private
*
* @return {void}
*/
_initControls: function() {
this._super();
if ( this.alphaOptions.alphaEnabled ) {
// Create Alpha controls
var self = this,
stripAlpha = self.controls.strip.clone(false, false),
stripAlphaSlider = stripAlpha.find( '.iris-slider-offset' ),
controls = {
stripAlpha : stripAlpha,
stripAlphaSlider : stripAlphaSlider
};
stripAlpha.addClass( 'iris-strip-alpha' );
stripAlphaSlider.addClass( 'iris-slider-offset-alpha' );
stripAlpha.appendTo( self.picker.find( '.iris-picker-inner' ) );
// Push new controls
$.each( controls, function( k, v ) {
self.controls[k] = v;
} );
// Create slider
self.controls.stripAlphaSlider.slider( {
orientation : 'vertical',
min : 0,
max : 100,
step : 1,
value : parseInt( self._color._alpha * 100 ),
slide : function( event, ui ) {
self.active = 'strip';
// Update alpha value
self._color._alpha = parseFloat( ui.value / 100 );
self._change.apply( self, arguments );
}
} );
}
},
/**
* Create the controls sizes
*
* @since 3.0.0
* @access private
*
* @param {bool} reset Set to True for recreate the controls sizes.
*
* @return {void}
*/
_dimensions: function( reset ) {
this._super( reset );
if ( this.alphaOptions.alphaEnabled ) {
var self = this,
opts = self.options,
controls = self.controls,
square = controls.square,
strip = self.picker.find( '.iris-strip' ),
innerWidth, squareWidth, stripWidth, stripMargin, totalWidth;
/**
* I use Math.round() to avoid possible size errors,
* this function returns the value of a number rounded
* to the nearest integer.
*
* The width to append all widgets,
* if border is enabled, 22 is subtracted.
* 20 for css left and right property
* 2 for css border
*/
innerWidth = Math.round( self.picker.outerWidth( true ) - ( opts.border ? 22 : 0 ) );
// The width of the draggable, aka square.
squareWidth = Math.round( square.outerWidth() );
// The width for the sliders
stripWidth = Math.round( ( innerWidth - squareWidth ) / 2 );
// The margin for the sliders
stripMargin = Math.round( stripWidth / 2 );
// The total width of the elements.
totalWidth = Math.round( squareWidth + ( stripWidth * 2 ) + ( stripMargin * 2 ) );
// Check and change if necessary.
while ( totalWidth > innerWidth ) {
stripWidth = Math.round( stripWidth - 2 );
stripMargin = Math.round( stripMargin - 1 );
totalWidth = Math.round( squareWidth + ( stripWidth * 2 ) + ( stripMargin * 2 ) );
}
square.css( 'margin', '0' );
strip.width( stripWidth ).css( 'margin-left', stripMargin + 'px' );
}
},
/**
* Callback to update the controls and the current color.
*
* @since 3.0.0
* @access private
*
* @return {void}
*/
_change: function() {
var self = this,
active = self.active;
self._super();
if ( self.alphaOptions.alphaEnabled ) {
var controls = self.controls,
alpha = parseInt( self._color._alpha * 100 ),
color = self._color.toRgb(),
gradient = [
'rgb(' + color.r + ',' + color.g + ',' + color.b + ') 0%',
'rgba(' + color.r + ',' + color.g + ',' + color.b + ', 0) 100%'
],
target = self.picker.closest( '.wp-picker-container' ).find( '.wp-color-result' );
self.options.color = self._getColor();
// Generate background slider alpha, only for CSS3.
controls.stripAlpha.css( { 'background' : 'linear-gradient(to bottom, ' + gradient.join( ', ' ) + '), url(' + backgroundImage + ')' } );
// Update alpha value
if ( active ) {
controls.stripAlphaSlider.slider( 'value', alpha );
}
if ( ! self._color.error ) {
self.element.removeClass( 'iris-error' ).val( self.options.color );
}
self.picker.find( '.iris-palette-container' ).on( 'click.palette', '.iris-palette', function() {
var color = $( this ).data( 'color' );
if ( self.alphaOptions.alphaReset ) {
self._color._alpha = 1;
color = self._getColor();
}
self._setOption( 'color', color );
} );
}
},
/**
* Paint dimensions.
*
* @since 3.0.0
* @access private
*
* @param {string} origin Origin (position).
* @param {string} control Type of the control,
*
* @return {void}
*/
_paintDimension: function( origin, control ) {
var self = this,
color = false;
// Fix for slider hue opacity.
if ( self.alphaOptions.alphaEnabled && 'strip' === control ) {
color = self._color;
self._color = new Color( color.toString() );
self.hue = self._color.h();
}
self._super( origin, control );
// Restore the color after paint.
if ( color ) {
self._color = color;
}
},
/**
* To update the options, see original source to view the available options.
*
* @since 3.0.0
*
* @param {string} key The Option name.
* @param {mixed} value The Option value to update.
*
* @return {void}
*/
_setOption: function( key, value ) {
var self = this;
if ( 'color' === key && self.alphaOptions.alphaEnabled ) {
// cast to string in case we have a number
value = '' + value;
newColor = new Color( value ).setHSpace( self.options.mode );
// Check if error && Check the color to prevent callbacks with the same color.
if ( ! newColor.error && self._getColor( newColor ) !== self._getColor() ) {
self._color = newColor;
self.options.color = self._getColor();
self.active = 'external';
self._change();
}
} else {
return self._super( key, value );
}
},
/**
* Returns the iris object if no new color is provided. If a new color is provided, it sets the new color.
*
* @param newColor {string|*} The new color to use. Can be undefined.
*
* @since 3.0.0
*
* @return {string} The element's color.
*/
color: function( newColor ) {
if ( newColor === true ) {
return this._color.clone();
}
if ( newColor === undef ) {
return this._getColor();
}
this.option( 'color', newColor );
},
} );
/**
* wpColorPicker
*/
$.widget( 'wp.wpColorPicker', $.wp.wpColorPicker, {
/**
* Alpha options
*
* @since 3.0.0
*
* @type {Object}
*/
alphaOptions: {
alphaEnabled: false,
},
/**
* Get the alpha options.
*
* @since 3.0.0
* @access private
*
* @return {object} The current alpha options.
*/
_getAlphaOptions: function() {
var el = this.element,
type = ( el.data( 'type' ) || this.options.type ),
color = ( el.data( 'defaultColor' ) || el.val() ),
options = {
alphaEnabled: ( el.data( 'alphaEnabled' ) || false ),
alphaCustomWidth: 130,
alphaReset: false,
alphaColorType: 'rgb',
alphaColorWithSpace: false,
};
if ( options.alphaEnabled ) {
options.alphaEnabled = ( el.is( 'input' ) && 'full' === type );
}
if ( ! options.alphaEnabled ) {
return options;
}
options.alphaColorWithSpace = ( color && color.match( /\s/ ) );
$.each( options, function( name, defaultValue ) {
var value = ( el.data( name ) || defaultValue );
switch ( name ) {
case 'alphaCustomWidth':
value = ( value ? parseInt( value, 10 ) : 0 );
value = ( isNaN( value ) ? defaultValue : value );
break;
case 'alphaColorType':
if ( ! value.match( /^(hex|(rgb|hsl)a?)$/ ) ) {
if ( color && color.match( /^#/ ) ) {
value = 'hex';
} else if ( color && color.match( /^hsla?/ ) ) {
value = 'hsl';
} else {
value = defaultValue;
}
}
break;
default:
value = !!value;
break;
}
options[name] = value;
} );
return options;
},
/**
* Create widget
*
* @since 3.0.0
* @access private
*
* @return {void}
*/
_create: function() {
// Return early if Iris support is missing.
if ( ! $.support.iris ) {
return;
}
// Set the alpha options for the current instance.
this.alphaOptions = this._getAlphaOptions();
// Create widget.
this._super();
},
/**
* Binds event listeners to the color picker and create options, etc...
*
* @since 3.0.0
* @access private
*
* @return {void}
*/
_addListeners: function() {
if ( ! this.alphaOptions.alphaEnabled ) {
return this._super();
}
var self = this,
el = self.element,
isDeprecated = self.toggler.is( 'a' );
this.alphaOptions.defaultWidth = el.width();
if ( this.alphaOptions.alphaCustomWidth ) {
el.width( parseInt( this.alphaOptions.defaultWidth + this.alphaOptions.alphaCustomWidth, 10 ) );
}
self.toggler.css( {
'position': 'relative',
'background-image' : 'url(' + backgroundImage + ')'
} );
if ( isDeprecated ) {
self.toggler.html( '<span class="color-alpha" />' );
} else {
self.toggler.append( '<span class="color-alpha" />' );
}
self.colorAlpha = self.toggler.find( 'span.color-alpha' ).css( {
'width' : '30px',
'height' : '100%',
'position' : 'absolute',
'top' : 0,
'background-color' : el.val(),
} );
// Define the correct position for ltr or rtl direction.
if ( 'ltr' === self.colorAlpha.css( 'direction' ) ) {
self.colorAlpha.css( {
'border-bottom-left-radius' : '2px',
'border-top-left-radius' : '2px',
'left' : 0
} );
} else {
self.colorAlpha.css( {
'border-bottom-right-radius' : '2px',
'border-top-right-radius' : '2px',
'right' : 0
} );
}
el.iris( {
/**
* @summary Handles the onChange event if one has been defined in the options.
*
* Handles the onChange event if one has been defined in the options and additionally
* sets the background color for the toggler element.
*
* @since 3.0.0
*
* @param {Event} event The event that's being called.
* @param {HTMLElement} ui The HTMLElement containing the color picker.
*
* @returns {void}
*/
change: function( event, ui ) {
self.colorAlpha.css( { 'background-color': ui.color.to_s( self.alphaOptions.alphaColorType ) } );
// fire change callback if we have one
if ( $.isFunction( self.options.change ) ) {
self.options.change.call( this, event, ui );
}
}
} );
/**
* Prevent any clicks inside this widget from leaking to the top and closing it.
*
* @since 3.0.0
*
* @param {Event} event The event that's being called.
*
* @return {void}
*/
self.wrap.on( 'click.wpcolorpicker', function( event ) {
event.stopPropagation();
});
/**
* Open or close the color picker depending on the class.
*
* @since 3.0.0
*/
self.toggler.click( function() {
if ( self.toggler.hasClass( 'wp-picker-open' ) ) {
self.close();
} else {
self.open();
}
});
/**
* Checks if value is empty when changing the color in the color picker.
* If so, the background color is cleared.
*
* @since 3.0.0
*
* @param {Event} event The event that's being called.
*
* @return {void}
*/
el.change( function( event ) {
var val = $( this ).val();
if ( el.hasClass( 'iris-error' ) || val === '' || val.match( /^(#|(rgb|hsl)a?)$/ ) ) {
if ( isDeprecated ) {
self.toggler.removeAttr( 'style' );
}
self.colorAlpha.css( 'background-color', '' );
// fire clear callback if we have one
if ( $.isFunction( self.options.clear ) ) {
self.options.clear.call( this, event );
}
}
} );
/**
* Enables the user to either clear the color in the color picker or revert back to the default color.
*
* @since 3.0.0
*
* @param {Event} event The event that's being called.
*
* @return {void}
*/
self.button.click( function( event ) {
if ( $( this ).hasClass( 'wp-picker-default' ) ) {
el.val( self.options.defaultColor ).change();
} else if ( $( this ).hasClass( 'wp-picker-clear' ) ) {
el.val( '' );
if ( isDeprecated ) {
self.toggler.removeAttr( 'style' );
}
self.colorAlpha.css( 'background-color', '' );
// fire clear callback if we have one
if ( $.isFunction( self.options.clear ) ) {
self.options.clear.call( this, event );
}
el.trigger( 'change' );
}
} );
},
} );
} ( jQuery ) );

View File

@ -1,202 +0,0 @@
<?php
defined( 'WPINC' ) or die;
if ( ! class_exists( 'GeneratePress_Pro_CSS' ) ) :
/**
* Creates minified css via PHP.
*
* @author Carlos Rios
* Modified by Tom Usborne for GeneratePress
*/
class GeneratePress_Pro_CSS {
/**
* The css selector that you're currently adding rules to
*
* @access protected
* @var string
*/
protected $_selector = '';
/**
* Stores the final css output with all of its rules for the current selector.
*
* @access protected
* @var string
*/
protected $_selector_output = '';
/**
* Stores all of the rules that will be added to the selector
*
* @access protected
* @var string
*/
protected $_css = '';
/**
* The string that holds all of the css to output
*
* @access protected
* @var string
*/
protected $_output = '';
/**
* Stores media queries
*
* @var null
*/
protected $_media_query = null;
/**
* The string that holds all of the css to output inside of the media query
*
* @access protected
* @var string
*/
protected $_media_query_output = '';
/**
* Sets a selector to the object and changes the current selector to a new one
*
* @access public
* @since 1.0
*
* @param string $selector - the css identifier of the html that you wish to target
* @return $this
*/
public function set_selector( $selector = '' ) {
// Render the css in the output string everytime the selector changes
if( $this->_selector !== '' ){
$this->add_selector_rules_to_output();
}
$this->_selector = $selector;
return $this;
}
/**
* Adds a css property with value to the css output
*
* @access public
* @since 1.0
*
* @param string $property - the css property
* @param string $value - the value to be placed with the property
* @param string $og_default - check to see if the value matches the default
* @param string $unit - the unit for the value (px)
* @return $this
*/
public function add_property( $property, $value, $og_default = false, $unit = false ) {
// Add our unit to our value if it exists
if ( $unit && '' !== $unit ) {
$value = $value . $unit;
if ( '' !== $og_default ) {
$og_default = $og_default . $unit;
}
}
// If we don't have a value or our value is the same as our og default, bail
if ( empty( $value ) || $og_default == $value )
return false;
$this->_css .= $property . ':' . $value . ';';
return $this;
}
/**
* Sets a media query in the class
*
* @since 1.1
* @param string $value
* @return $this
*/
public function start_media_query( $value ) {
// Add the current rules to the output
$this->add_selector_rules_to_output();
// Add any previous media queries to the output
if ( ! empty( $this->_media_query ) ) {
$this->add_media_query_rules_to_output();
}
// Set the new media query
$this->_media_query = $value;
return $this;
}
/**
* Stops using a media query.
*
* @see start_media_query()
*
* @since 1.1
* @return $this
*/
public function stop_media_query() {
return $this->start_media_query( null );
}
/**
* Adds the current media query's rules to the class' output variable
*
* @since 1.1
* @return $this
*/
private function add_media_query_rules_to_output() {
if( !empty( $this->_media_query_output ) ) {
$this->_output .= sprintf( '@media %1$s{%2$s}', $this->_media_query, $this->_media_query_output );
// Reset the media query output string
$this->_media_query_output = '';
}
return $this;
}
/**
* Adds the current selector rules to the output variable
*
* @access private
* @since 1.0
*
* @return $this
*/
private function add_selector_rules_to_output() {
if( !empty( $this->_css ) ) {
$this->_selector_output = $this->_selector;
$selector_output = sprintf( '%1$s{%2$s}', $this->_selector_output, $this->_css );
// Add our CSS to the output
if ( ! empty( $this->_media_query ) ) {
$this->_media_query_output .= $selector_output;
$this->_css = '';
} else {
$this->_output .= $selector_output;
}
// Reset the css
$this->_css = '';
}
return $this;
}
/**
* Returns the minified css in the $_output variable
*
* @access public
* @since 1.0
*
* @return string
*/
public function css_output()
{
// Add current selector's rules to output
$this->add_selector_rules_to_output();
// Output minified css
return $this->_output;
}
}
endif;

View File

@ -1,676 +0,0 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Allows plugins to use their own update API.
*
* @author Easy Digital Downloads
* @version 1.9.2
*/
class GeneratePress_Premium_Plugin_Updater {
private $api_url = '';
private $api_data = array();
private $plugin_file = '';
private $name = '';
private $slug = '';
private $version = '';
private $wp_override = false;
private $beta = false;
private $failed_request_cache_key;
/**
* Class constructor.
*
* @uses plugin_basename()
* @uses hook()
*
* @param string $_api_url The URL pointing to the custom API endpoint.
* @param string $_plugin_file Path to the plugin file.
* @param array $_api_data Optional data to send with API calls.
*/
public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
global $edd_plugin_data;
$this->api_url = trailingslashit( $_api_url );
$this->api_data = $_api_data;
$this->plugin_file = $_plugin_file;
$this->name = plugin_basename( $_plugin_file );
$this->slug = basename( $_plugin_file, '.php' );
$this->version = $_api_data['version'];
$this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
$this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
$this->failed_request_cache_key = 'edd_sl_failed_http_' . md5( $this->api_url );
$edd_plugin_data[ $this->slug ] = $this->api_data;
/**
* Fires after the $edd_plugin_data is setup.
*
* @since x.x.x
*
* @param array $edd_plugin_data Array of EDD SL plugin data.
*/
do_action( 'post_edd_sl_plugin_updater_setup', $edd_plugin_data );
// Set up hooks.
$this->init();
}
/**
* Set up WordPress filters to hook into WP's update process.
*
* @uses add_filter()
*
* @return void
*/
public function init() {
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
add_action( 'after_plugin_row', array( $this, 'show_update_notification' ), 10, 2 );
add_action( 'admin_init', array( $this, 'show_changelog' ) );
}
/**
* Check for Updates at the defined API endpoint and modify the update array.
*
* This function dives into the update API just when WordPress creates its update array,
* then adds a custom API call and injects the custom plugin data retrieved from the API.
* It is reassembled from parts of the native WordPress plugin update code.
* See wp-includes/update.php line 121 for the original wp_update_plugins() function.
*
* @uses api_request()
*
* @param array $_transient_data Update array build by WordPress.
* @return array Modified update array with custom plugin data.
*/
public function check_update( $_transient_data ) {
global $pagenow;
if ( ! is_object( $_transient_data ) ) {
$_transient_data = new stdClass();
}
if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
return $_transient_data;
}
$current = $this->get_repo_api_data();
if ( false !== $current && is_object( $current ) && isset( $current->new_version ) ) {
if ( version_compare( $this->version, $current->new_version, '<' ) ) {
$_transient_data->response[ $this->name ] = $current;
} else {
// Populating the no_update information is required to support auto-updates in WordPress 5.5.
$_transient_data->no_update[ $this->name ] = $current;
}
}
$_transient_data->last_checked = time();
$_transient_data->checked[ $this->name ] = $this->version;
return $_transient_data;
}
/**
* Get repo API data from store.
* Save to cache.
*
* @return \stdClass
*/
public function get_repo_api_data() {
$version_info = $this->get_cached_version_info();
if ( false === $version_info ) {
$version_info = $this->api_request(
'plugin_latest_version',
array(
'slug' => $this->slug,
'beta' => $this->beta,
)
);
if ( ! $version_info ) {
return false;
}
// This is required for your plugin to support auto-updates in WordPress 5.5.
$version_info->plugin = $this->name;
$version_info->id = $this->name;
$version_info->tested = $this->get_tested_version( $version_info );
$this->set_version_info_cache( $version_info );
}
return $version_info;
}
/**
* Gets the plugin's tested version.
*
* @since 1.9.2
* @param object $version_info
* @return null|string
*/
private function get_tested_version( $version_info ) {
// There is no tested version.
if ( empty( $version_info->tested ) ) {
return null;
}
// Strip off extra version data so the result is x.y or x.y.z.
list( $current_wp_version ) = explode( '-', get_bloginfo( 'version' ) );
// The tested version is greater than or equal to the current WP version, no need to do anything.
if ( version_compare( $version_info->tested, $current_wp_version, '>=' ) ) {
return $version_info->tested;
}
$current_version_parts = explode( '.', $current_wp_version );
$tested_parts = explode( '.', $version_info->tested );
// The current WordPress version is x.y.z, so update the tested version to match it.
if ( isset( $current_version_parts[2] ) && $current_version_parts[0] === $tested_parts[0] && $current_version_parts[1] === $tested_parts[1] ) {
$tested_parts[2] = $current_version_parts[2];
}
return implode( '.', $tested_parts );
}
/**
* Show the update notification on multisite subsites.
*
* @param string $file
* @param array $plugin
*/
public function show_update_notification( $file, $plugin ) {
// Return early if in the network admin, or if this is not a multisite install.
if ( is_network_admin() || ! is_multisite() ) {
return;
}
// Allow single site admins to see that an update is available.
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
if ( $this->name !== $file ) {
return;
}
// Do not print any message if update does not exist.
$update_cache = get_site_transient( 'update_plugins' );
if ( ! isset( $update_cache->response[ $this->name ] ) ) {
if ( ! is_object( $update_cache ) ) {
$update_cache = new stdClass();
}
$update_cache->response[ $this->name ] = $this->get_repo_api_data();
}
// Return early if this plugin isn't in the transient->response or if the site is running the current or newer version of the plugin.
if ( empty( $update_cache->response[ $this->name ] ) || version_compare( $this->version, $update_cache->response[ $this->name ]->new_version, '>=' ) ) {
return;
}
printf(
'<tr class="plugin-update-tr %3$s" id="%1$s-update" data-slug="%1$s" data-plugin="%2$s">',
$this->slug,
$file,
in_array( $this->name, $this->get_active_plugins(), true ) ? 'active' : 'inactive'
);
echo '<td colspan="3" class="plugin-update colspanchange">';
echo '<div class="update-message notice inline notice-warning notice-alt"><p>';
$changelog_link = '';
if ( ! empty( $update_cache->response[ $this->name ]->sections->changelog ) ) {
$changelog_link = add_query_arg(
array(
'edd_sl_action' => 'view_plugin_changelog',
'plugin' => urlencode( $this->name ),
'slug' => urlencode( $this->slug ),
'TB_iframe' => 'true',
'width' => 77,
'height' => 911,
),
self_admin_url( 'index.php' )
);
}
$update_link = add_query_arg(
array(
'action' => 'upgrade-plugin',
'plugin' => urlencode( $this->name ),
),
self_admin_url( 'update.php' )
);
printf(
/* translators: the plugin name. */
esc_html__( 'There is a new version of %1$s available.', 'easy-digital-downloads' ),
esc_html( $plugin['Name'] )
);
if ( ! current_user_can( 'update_plugins' ) ) {
echo ' ';
esc_html_e( 'Contact your network administrator to install the update.', 'easy-digital-downloads' );
} elseif ( empty( $update_cache->response[ $this->name ]->package ) && ! empty( $changelog_link ) ) {
echo ' ';
printf(
/* translators: 1. opening anchor tag, do not translate 2. the new plugin version 3. closing anchor tag, do not translate. */
__( '%1$sView version %2$s details%3$s.', 'easy-digital-downloads' ),
'<a target="_blank" class="thickbox open-plugin-details-modal" href="' . esc_url( $changelog_link ) . '">',
esc_html( $update_cache->response[ $this->name ]->new_version ),
'</a>'
);
} elseif ( ! empty( $changelog_link ) ) {
echo ' ';
printf(
__( '%1$sView version %2$s details%3$s or %4$supdate now%5$s.', 'easy-digital-downloads' ),
'<a target="_blank" class="thickbox open-plugin-details-modal" href="' . esc_url( $changelog_link ) . '">',
esc_html( $update_cache->response[ $this->name ]->new_version ),
'</a>',
'<a target="_blank" class="update-link" href="' . esc_url( wp_nonce_url( $update_link, 'upgrade-plugin_' . $file ) ) . '">',
'</a>'
);
} else {
printf(
' %1$s%2$s%3$s',
'<a target="_blank" class="update-link" href="' . esc_url( wp_nonce_url( $update_link, 'upgrade-plugin_' . $file ) ) . '">',
esc_html__( 'Update now.', 'easy-digital-downloads' ),
'</a>'
);
}
do_action( "in_plugin_update_message-{$file}", $plugin, $plugin );
echo '</p></div></td></tr>';
}
/**
* Gets the plugins active in a multisite network.
*
* @return array
*/
private function get_active_plugins() {
$active_plugins = (array) get_option( 'active_plugins' );
$active_network_plugins = (array) get_site_option( 'active_sitewide_plugins' );
return array_merge( $active_plugins, array_keys( $active_network_plugins ) );
}
/**
* Updates information on the "View version x.x details" page with custom data.
*
* @uses api_request()
*
* @param mixed $_data
* @param string $_action
* @param object $_args
* @return object $_data
*/
public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
if ( 'plugin_information' !== $_action ) {
return $_data;
}
if ( ! isset( $_args->slug ) || ( $_args->slug !== $this->slug ) ) {
return $_data;
}
$to_send = array(
'slug' => $this->slug,
'is_ssl' => is_ssl(),
'fields' => array(
'banners' => array(),
'reviews' => false,
'icons' => array(),
),
);
// Get the transient where we store the api request for this plugin for 24 hours
$edd_api_request_transient = $this->get_cached_version_info();
//If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
if ( empty( $edd_api_request_transient ) ) {
$api_response = $this->api_request( 'plugin_information', $to_send );
// Expires in 3 hours
$this->set_version_info_cache( $api_response );
if ( false !== $api_response ) {
$_data = $api_response;
}
} else {
$_data = $edd_api_request_transient;
}
// Convert sections into an associative array, since we're getting an object, but Core expects an array.
if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
$_data->sections = $this->convert_object_to_array( $_data->sections );
}
// Convert banners into an associative array, since we're getting an object, but Core expects an array.
if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
$_data->banners = $this->convert_object_to_array( $_data->banners );
}
// Convert icons into an associative array, since we're getting an object, but Core expects an array.
if ( isset( $_data->icons ) && ! is_array( $_data->icons ) ) {
$_data->icons = $this->convert_object_to_array( $_data->icons );
}
// Convert contributors into an associative array, since we're getting an object, but Core expects an array.
if ( isset( $_data->contributors ) && ! is_array( $_data->contributors ) ) {
$_data->contributors = $this->convert_object_to_array( $_data->contributors );
}
if ( ! isset( $_data->plugin ) ) {
$_data->plugin = $this->name;
}
return $_data;
}
/**
* Convert some objects to arrays when injecting data into the update API
*
* Some data like sections, banners, and icons are expected to be an associative array, however due to the JSON
* decoding, they are objects. This method allows us to pass in the object and return an associative array.
*
* @since 3.6.5
*
* @param stdClass $data
*
* @return array
*/
private function convert_object_to_array( $data ) {
if ( ! is_array( $data ) && ! is_object( $data ) ) {
return array();
}
$new_data = array();
foreach ( $data as $key => $value ) {
$new_data[ $key ] = is_object( $value ) ? $this->convert_object_to_array( $value ) : $value;
}
return $new_data;
}
/**
* Disable SSL verification in order to prevent download update failures
*
* @param array $args
* @param string $url
* @return object $array
*/
public function http_request_args( $args, $url ) {
if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
$args['sslverify'] = $this->verify_ssl();
}
return $args;
}
/**
* Calls the API and, if successfull, returns the object delivered by the API.
*
* @uses get_bloginfo()
* @uses wp_remote_post()
* @uses is_wp_error()
*
* @param string $_action The requested action.
* @param array $_data Parameters for the API action.
* @return false|object|void
*/
private function api_request( $_action, $_data ) {
$data = array_merge( $this->api_data, $_data );
if ( $data['slug'] !== $this->slug ) {
return;
}
// Don't allow a plugin to ping itself
if ( trailingslashit( home_url() ) === $this->api_url ) {
return false;
}
if ( $this->request_recently_failed() ) {
return false;
}
return $this->get_version_from_remote();
}
/**
* Determines if a request has recently failed.
*
* @since 1.9.1
*
* @return bool
*/
private function request_recently_failed() {
$failed_request_details = get_option( $this->failed_request_cache_key );
// Request has never failed.
if ( empty( $failed_request_details ) || ! is_numeric( $failed_request_details ) ) {
return false;
}
/*
* Request previously failed, but the timeout has expired.
* This means we're allowed to try again.
*/
if ( time() > $failed_request_details ) {
delete_option( $this->failed_request_cache_key );
return false;
}
return true;
}
/**
* Logs a failed HTTP request for this API URL.
* We set a timestamp for 1 hour from now. This prevents future API requests from being
* made to this domain for 1 hour. Once the timestamp is in the past, API requests
* will be allowed again. This way if the site is down for some reason we don't bombard
* it with failed API requests.
*
* @see EDD_SL_Plugin_Updater::request_recently_failed
*
* @since 1.9.1
*/
private function log_failed_request() {
update_option( $this->failed_request_cache_key, strtotime( '+1 hour' ) );
}
/**
* If available, show the changelog for sites in a multisite install.
*/
public function show_changelog() {
if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' !== $_REQUEST['edd_sl_action'] ) {
return;
}
if ( empty( $_REQUEST['plugin'] ) ) {
return;
}
if ( empty( $_REQUEST['slug'] ) || $this->slug !== $_REQUEST['slug'] ) {
return;
}
if ( ! current_user_can( 'update_plugins' ) ) {
wp_die( esc_html__( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), esc_html__( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
}
$version_info = $this->get_repo_api_data();
if ( isset( $version_info->sections ) ) {
$sections = $this->convert_object_to_array( $version_info->sections );
if ( ! empty( $sections['changelog'] ) ) {
echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>';
}
}
exit;
}
/**
* Gets the current version information from the remote site.
*
* @return array|false
*/
private function get_version_from_remote() {
$api_params = array(
'edd_action' => 'get_version',
'license' => ! empty( $this->api_data['license'] ) ? $this->api_data['license'] : '',
'item_name' => isset( $this->api_data['item_name'] ) ? $this->api_data['item_name'] : false,
'item_id' => isset( $this->api_data['item_id'] ) ? $this->api_data['item_id'] : false,
'version' => isset( $this->api_data['version'] ) ? $this->api_data['version'] : false,
'slug' => $this->slug,
'author' => $this->api_data['author'],
'url' => home_url(),
'beta' => $this->beta,
'php_version' => phpversion(),
'wp_version' => get_bloginfo( 'version' ),
);
/**
* Filters the parameters sent in the API request.
*
* @param array $api_params The array of data sent in the request.
* @param array $this->api_data The array of data set up in the class constructor.
* @param string $this->plugin_file The full path and filename of the file.
*/
$api_params = apply_filters( 'edd_sl_plugin_updater_api_params', $api_params, $this->api_data, $this->plugin_file );
$request = wp_remote_post(
$this->api_url,
array(
'timeout' => 15,
'sslverify' => $this->verify_ssl(),
'body' => $api_params,
)
);
if ( is_wp_error( $request ) || ( 200 !== wp_remote_retrieve_response_code( $request ) ) ) {
$this->log_failed_request();
return false;
}
$request = json_decode( wp_remote_retrieve_body( $request ) );
if ( $request && isset( $request->sections ) ) {
$request->sections = maybe_unserialize( $request->sections );
} else {
$request = false;
}
if ( $request && isset( $request->banners ) ) {
$request->banners = maybe_unserialize( $request->banners );
}
if ( $request && isset( $request->icons ) ) {
$request->icons = maybe_unserialize( $request->icons );
}
if ( ! empty( $request->sections ) ) {
foreach ( $request->sections as $key => $section ) {
$request->$key = (array) $section;
}
}
return $request;
}
/**
* Get the version info from the cache, if it exists.
*
* @param string $cache_key
* @return object
*/
public function get_cached_version_info( $cache_key = '' ) {
if ( empty( $cache_key ) ) {
$cache_key = $this->get_cache_key();
}
$cache = get_option( $cache_key );
// Cache is expired
if ( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
return false;
}
// We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
$cache['value'] = json_decode( $cache['value'] );
if ( ! empty( $cache['value']->icons ) ) {
$cache['value']->icons = (array) $cache['value']->icons;
}
return $cache['value'];
}
/**
* Adds the plugin version information to the database.
*
* @param string $value
* @param string $cache_key
*/
public function set_version_info_cache( $value = '', $cache_key = '' ) {
if ( empty( $cache_key ) ) {
$cache_key = $this->get_cache_key();
}
$data = array(
'timeout' => strtotime( '+3 hours', time() ),
'value' => wp_json_encode( $value ),
);
update_option( $cache_key, $data, 'no' );
// Delete the duplicate option
delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ) );
}
/**
* Returns if the SSL of the store should be verified.
*
* @since 1.6.13
* @return bool
*/
private function verify_ssl() {
return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
}
/**
* Gets the unique key (option name) for a plugin.
*
* @since 1.9.0
* @return string
*/
private function get_cache_key() {
$string = $this->slug . $this->api_data['license'] . $this->beta;
return 'edd_sl_' . md5( serialize( $string ) );
}
}

View File

@ -1,531 +0,0 @@
<?php
defined( 'WPINC' ) or die;
// Controls
require plugin_dir_path( __FILE__ ) . 'customizer/controls/class-information-control.php';
require plugin_dir_path( __FILE__ ) . 'customizer/controls/class-backgrounds-control.php';
require plugin_dir_path( __FILE__ ) . 'customizer/controls/class-refresh-button-control.php';
require plugin_dir_path( __FILE__ ) . 'customizer/controls/class-alpha-color-control.php';
require plugin_dir_path( __FILE__ ) . 'customizer/controls/class-copyright-control.php';
require plugin_dir_path( __FILE__ ) . 'customizer/controls/class-spacing-control.php';
require plugin_dir_path( __FILE__ ) . 'customizer/controls/class-range-slider-control.php';
require plugin_dir_path( __FILE__ ) . 'customizer/controls/class-title-control.php';
require plugin_dir_path( __FILE__ ) . 'customizer/controls/class-typography-control.php';
require plugin_dir_path( __FILE__ ) . 'customizer/controls/class-control-toggle.php';
require plugin_dir_path( __FILE__ ) . 'customizer/controls/class-action-button-control.php';
require plugin_dir_path( __FILE__ ) . 'customizer/controls/class-section-shortcuts-control.php';
require plugin_dir_path( __FILE__ ) . 'customizer/controls/class-deprecated.php';
// Other
require plugin_dir_path( __FILE__ ) . 'customizer/sanitize.php';
require plugin_dir_path( __FILE__ ) . 'customizer/active-callbacks.php';
require plugin_dir_path( __FILE__ ) . 'customizer/deprecated.php';
add_action( 'customize_controls_enqueue_scripts', 'generate_premium_control_inline_scripts', 100 );
/**
* Add misc inline scripts to our controls.
*
* We don't want to add these to the controls themselves, as they will be repeated
* each time the control is initialized.
*
* @since 1.4
*/
function generate_premium_control_inline_scripts() {
$is_using_dynamic_typography = function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography();
if ( function_exists( 'generate_typography_default_fonts' ) && ! $is_using_dynamic_typography ) {
$number_of_fonts = apply_filters( 'generate_number_of_fonts', 200 );
wp_localize_script( 'generatepress-pro-typography-customizer', 'gp_customize', array( 'nonce' => wp_create_nonce( 'gp_customize_nonce' ) ) );
wp_localize_script( 'generatepress-pro-typography-customizer', 'typography_defaults', generate_typography_default_fonts() );
wp_localize_script(
'generatepress-pro-typography-customizer',
'generatePressTypography',
array(
'googleFonts' => apply_filters( 'generate_typography_customize_list', generate_get_all_google_fonts( $number_of_fonts ) )
)
);
}
wp_enqueue_script( 'generatepress-pro-customizer-controls', plugin_dir_url( __FILE__ ) . 'customizer/controls/js/generatepress-controls.js', array( 'customize-controls', 'jquery' ), GP_PREMIUM_VERSION, true );
$overlay_defaults = apply_filters( 'generate_off_canvas_overlay_style_defaults', array(
'backgroundColor' => 'rgba(10,10,10,0.95)',
'textColor' => '#ffffff',
'backgroundHoverColor' => 'rgba(0,0,0,0)',
'backgroundCurrentColor' => 'rgba(0,0,0,0)',
'subMenuBackgroundColor' => 'rgba(0,0,0,0)',
'subMenuTextColor' => '#ffffff',
'subMenuBackgroundHoverColor' => 'rgba(0,0,0,0)',
'subMenuBackgroundCurrentColor' => 'rgba(0,0,0,0)',
'fontWeight' => 200,
'fontSize' => 25,
) );
wp_localize_script(
'gp-button-actions',
'gpButtonActions',
array(
'warning' => esc_html__( 'This will design your overlay by changing options in the Customizer for you. Once saved, this can not be undone.', 'gp-premium' ),
'styling' => $overlay_defaults,
)
);
$controls_a11y = array(
'fontSizeLabel' => esc_html__( 'Font size', 'gp-premium' ),
'mobileHeaderFontSizeLabel' => esc_html__( 'Mobile header font size', 'gp-premium' ),
);
if ( function_exists( 'generate_get_default_fonts' ) ) {
$font_defaults = generate_get_default_fonts();
$controls_a11y['siteTitleFontSize'] = $font_defaults['site_title_font_size'];
$controls_a11y['mobileSiteTitleFontSize'] = $font_defaults['mobile_site_title_font_size'];
}
if ( function_exists( 'generate_get_color_defaults' ) ) {
$color_defaults = generate_get_color_defaults();
$controls_a11y['navigationTextColor'] = $color_defaults['navigation_text_color'];
$controls_a11y['siteTitleTextColor'] = $color_defaults['site_title_color'];
}
if ( function_exists( 'generate_get_defaults' ) ) {
$defaults = generate_get_defaults();
$controls_a11y['navigationAlignment'] = $defaults['nav_alignment_setting'];
}
wp_localize_script(
'generatepress-pro-customizer-controls',
'gpControls',
$controls_a11y
);
wp_enqueue_script(
'generate-pro-customizer-controls',
GP_PREMIUM_DIR_URL . 'dist/customizer.js',
array( 'customize-controls', 'wp-i18n', 'wp-element', 'customize-base' ),
GP_PREMIUM_VERSION,
true
);
if ( function_exists( 'wp_set_script_translations' ) ) {
wp_set_script_translations( 'generate-pro-customizer-controls', 'gp-premium' );
}
wp_localize_script(
'generate-pro-customizer-controls',
'gpCustomizerControls',
array(
'hasSecondaryNav' => generatepress_is_module_active( 'generate_package_secondary_nav', 'GENERATE_SECONDARY_NAV' ),
'hasMenuPlus' => generatepress_is_module_active( 'generate_package_menu_plus', 'GENERATE_MENU_PLUS' ),
'hasWooCommerce' => class_exists( 'WooCommerce' ) && generatepress_is_module_active( 'generate_package_woocommerce', 'GENERATE_WOOCOMMERCE' ),
)
);
}
add_action( 'customize_register', 'generate_premium_customizer_shortcut_controls', 100 );
/**
* Add shortcuts to sections we don't control in this plugin.
*
* @since 1.8
*/
function generate_premium_customizer_shortcut_controls( $wp_customize ) {
if ( ! class_exists( 'WP_Customize_Panel' ) ) {
return;
}
if ( ! $wp_customize->get_panel( 'generate_layout_panel' ) ) {
return;
}
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
}
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_header_layout_shortcuts',
array(
'section' => 'generate_layout_header',
'element' => __( 'Header', 'gp-premium' ),
'shortcuts' => array(
'colors' => 'header_color_section',
'typography' => 'font_header_section',
'backgrounds' => 'generate_backgrounds_header',
),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
)
)
);
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_primary_navigation_layout_shortcuts',
array(
'section' => 'generate_layout_navigation',
'element' => __( 'Primary Navigation', 'gp-premium' ),
'shortcuts' => array(
'colors' => 'navigation_color_section',
'typography' => 'font_navigation_section',
'backgrounds' => 'generate_backgrounds_navigation',
),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
)
)
);
if ( $wp_customize->get_control( 'blogname' ) ) {
$wp_customize->get_control( 'generate_settings[container_width]' )->priority = 1;
}
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_content_layout_shortcuts',
array(
'section' => 'generate_layout_container',
'element' => __( 'Content', 'gp-premium' ),
'shortcuts' => array(
'colors' => 'content_color_section',
'typography' => 'font_content_section',
'backgrounds' => 'generate_backgrounds_content',
),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 0,
)
)
);
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_sidebar_layout_shortcuts',
array(
'section' => 'generate_layout_sidebars',
'element' => __( 'Sidebar', 'gp-premium' ),
'shortcuts' => array(
'colors' => 'sidebar_widget_color_section',
'typography' => 'font_widget_section',
'backgrounds' => 'generate_backgrounds_sidebars',
),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
)
)
);
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_footer_layout_shortcuts',
array(
'section' => 'generate_layout_footer',
'element' => __( 'Footer', 'gp-premium' ),
'shortcuts' => array(
'colors' => 'footer_color_section',
'typography' => 'font_footer_section',
'backgrounds' => 'generate_backgrounds_footer',
),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
)
)
);
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_colors_shortcuts',
array(
'section' => 'generate_colors_section',
'element' => __( 'Colors', 'gp-premium' ),
'shortcuts' => array(),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
)
)
);
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_typography_shortcuts',
array(
'section' => 'generate_typography_section',
'element' => __( 'Typography', 'gp-premium' ),
'shortcuts' => array(),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
)
)
);
}
add_action( 'customize_register', 'generate_premium_layout_block_element_messages', 1000 );
/**
* Add shortcuts to sections we don't control in this plugin.
*
* @since 1.8
*/
function generate_premium_layout_block_element_messages( $wp_customize ) {
if ( ! class_exists( 'WP_Customize_Panel' ) ) {
return;
}
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Information_Customize_Control' );
}
if ( version_compare( PHP_VERSION, '5.6', '>=' ) ) {
$footer_sections = array(
'generate_layout_footer',
'footer_color_section',
'font_footer_section',
'generate_backgrounds_footer',
);
foreach ( $footer_sections as $section ) {
if ( $wp_customize->get_section( $section ) ) {
$wp_customize->add_control(
new GeneratePress_Information_Customize_Control(
$wp_customize,
'generate_using_site_footer_element_' . $section,
array(
'section' => $section,
'description' => sprintf(
/* translators: URL to the Elements dashboard. */
__( 'This page is using a <a href="%s">Site Footer Element</a>. Some of the options below may not apply.', 'gp-premium' ),
admin_url( 'edit.php?post_type=gp_elements' )
),
'notice' => true,
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'active_callback' => function() {
$has_block_element = generate_has_active_element( 'site-footer', true );
if ( $has_block_element ) {
return true;
}
return false;
},
'priority' => 0,
)
)
);
}
}
$header_sections = array(
'generate_layout_header',
'header_color_section',
'font_header_section',
'generate_backgrounds_header',
);
foreach ( $header_sections as $section ) {
if ( $wp_customize->get_section( $section ) ) {
$wp_customize->add_control(
new GeneratePress_Information_Customize_Control(
$wp_customize,
'generate_using_site_header_element_' . $section,
array(
'section' => $section,
'description' => sprintf(
/* translators: URL to the Elements dashboard. */
__( 'This page is using a <a href="%s">Site Header Element</a>. Some of the options below may not apply.', 'gp-premium' ),
admin_url( 'edit.php?post_type=gp_elements' )
),
'notice' => true,
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'active_callback' => function() {
$has_block_element = generate_has_active_element( 'site-header', true );
if ( $has_block_element ) {
return true;
}
return false;
},
'priority' => 0,
)
)
);
}
}
$sidebar_sections = array(
'generate_layout_sidebars',
'sidebar_widget_color_section',
'font_widget_section',
'generate_backgrounds_sidebars',
);
foreach ( $sidebar_sections as $section ) {
if ( $wp_customize->get_section( $section ) ) {
$wp_customize->add_control(
new GeneratePress_Information_Customize_Control(
$wp_customize,
'generate_using_sidebar_element_' . $section,
array(
'section' => $section,
'description' => sprintf(
/* translators: URL to the Elements dashboard. */
__( 'This page is using a <a href="%s">Sidebar Element</a>. Some of the options below may not apply.', 'gp-premium' ),
admin_url( 'edit.php?post_type=gp_elements' )
),
'notice' => true,
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'active_callback' => function() {
$has_right_sidebar_block_element = generate_has_active_element( 'right-sidebar', true );
if ( $has_right_sidebar_block_element ) {
return true;
}
$has_left_sidebar_block_element = generate_has_active_element( 'left-sidebar', true );
if ( $has_left_sidebar_block_element ) {
return true;
}
return false;
},
'priority' => 0,
)
)
);
}
}
if ( $wp_customize->get_section( 'generate_blog_section' ) ) {
$wp_customize->add_control(
new GeneratePress_Information_Customize_Control(
$wp_customize,
'generate_using_post_loop_item_element',
array(
'section' => 'generate_blog_section',
'description' => sprintf(
/* translators: URL to the Elements dashboard. */
__( 'This page is using a <a href="%s">Content Template Element</a>. Some of the options below may not apply.', 'gp-premium' ),
admin_url( 'edit.php?post_type=gp_elements' )
),
'notice' => true,
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'active_callback' => function() {
$has_block_element = generate_has_active_element( 'content-template', true );
if ( $has_block_element ) {
return true;
}
return false;
},
'priority' => 0,
)
)
);
$wp_customize->add_control(
new GeneratePress_Information_Customize_Control(
$wp_customize,
'generate_using_page_hero_element',
array(
'section' => 'generate_blog_section',
'description' => sprintf(
/* translators: URL to the Elements dashboard. */
__( 'This page is using a <a href="%s">Page Hero Element</a>. Some of the options below may not apply.', 'gp-premium' ),
admin_url( 'edit.php?post_type=gp_elements' )
),
'notice' => true,
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'active_callback' => function() {
$has_block_element = generate_has_active_element( 'page-hero', true );
if ( $has_block_element ) {
return true;
}
return false;
},
'priority' => 0,
)
)
);
$wp_customize->add_control(
new GeneratePress_Information_Customize_Control(
$wp_customize,
'generate_using_post_meta_area_element',
array(
'section' => 'generate_blog_section',
'description' => sprintf(
/* translators: URL to the Elements dashboard. */
__( 'This page is using a <a href="%s">Post Meta Template Element</a>. Some of the options below may not apply.', 'gp-premium' ),
admin_url( 'edit.php?post_type=gp_elements' )
),
'notice' => true,
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'active_callback' => function() {
$has_block_element = generate_has_active_element( 'post-meta-template', true );
if ( $has_block_element ) {
return true;
}
return false;
},
'priority' => 0,
)
)
);
}
}
}
add_action( 'customize_controls_print_styles', 'generate_premium_customize_print_styles' );
/**
* Print control styles for the Customizer.
*
* @since 1.9
*/
function generate_premium_customize_print_styles() {
$sizes = apply_filters( 'generate_customizer_device_preview_sizes', array(
'tablet' => 800,
'mobile' => 411,
'mobile_height' => 731,
) );
?>
<style>
.wp-customizer .preview-tablet .wp-full-overlay-main {
width: <?php echo absint( $sizes['tablet'] ); ?>px;
margin-left: 0;
margin-right: 0;
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
}
.wp-customizer .preview-mobile .wp-full-overlay-main {
width: <?php echo absint( $sizes['mobile'] ); ?>px;
height: <?php echo absint( $sizes['mobile_height'] ); ?>px;
margin-left: 0;
margin-right: 0;
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
}
.rtl.wp-customizer .preview-tablet .wp-full-overlay-main,
.rtl.wp-customizer .preview-mobile .wp-full-overlay-main {
-webkit-transform: translateX(50%);
transform: translateX(50%);
}
</style>
<?php
}

View File

@ -1,601 +0,0 @@
<?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;
}
/**
* Checks to see if we're using external CSS file.
*
* @since 1.11.0
*/
function generate_is_using_external_css_file_callback() {
if ( ! function_exists( 'generate_get_option' ) ) {
return false;
}
if ( 'file' === generate_get_option( 'css_print_method' ) ) {
return true;
}
return false;
}

View File

@ -1,44 +0,0 @@
<?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 $nonce = '';
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 );
wp_enqueue_style( 'gp-button-actions', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/button-actions.css', array(), GP_PREMIUM_VERSION );
}
public function to_json() {
parent::to_json();
$this->json['data_type'] = $this->data_type;
$this->json['description'] = $this->description;
$this->json['nonce'] = $this->nonce;
}
public function content_template() {
?>
<button class="button" data-type="{{{ data.data_type }}}" data-nonce="{{{ data.nonce }}}">{{{ data.label }}}</button>
<# if ( data.description ) { #>
<span class="description customize-control-description">
<p>{{{ data.description }}}</p>
</span>
<# } #>
<?php
}
}
}

View File

@ -1,76 +0,0 @@
<?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

@ -1,146 +0,0 @@
<?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

@ -1,37 +0,0 @@
<?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

@ -1,51 +0,0 @@
<?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

@ -1,396 +0,0 @@
<?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

@ -1,42 +0,0 @@
<?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 $notice = '';
public function to_json() {
parent::to_json();
$this->json['description'] = $this->description;
$this->json['notice'] = $this->notice;
}
public function content_template() {
?>
<# if ( data.notice ) { #>
<div class="notice notice-info">
<# } #>
<# if ( data.label ) { #>
<span class="customize-control-title">{{ data.label }}</span>
<# } #>
<# if ( data.description ) { #>
<p>{{{ data.description }}}</p>
<# } #>
<# if ( data.notice ) { #>
</div>
<# } #>
<?php
}
}
endif;

View File

@ -1,165 +0,0 @@
<?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

@ -1,24 +0,0 @@
<?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

@ -1,123 +0,0 @@
<?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 ( version_compare( generate_premium_get_theme_version(), '3.1.0-alpha.1', '>=' ) && 'generate_woocommerce_colors' !== $id ) {
$id = 'generate_colors_section';
}
if ( ! generatepress_is_module_active( 'generate_package_colors', 'GENERATE_COLORS' ) ) {
$id = false;
$name = false;
}
}
if ( 'typography' === $name ) {
$name = esc_html__( 'Typography', 'gp-premium' );
if ( function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography() ) {
$id = 'generate_typography_section';
}
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() {
?>
<div class="generatepress-shortcuts">
<# if ( data.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

@ -1,165 +0,0 @@
<?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', 'gp-premium' );
$this->json[ 'unlink_title' ] = __( 'Un-link values', 'gp-premium' );
$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

@ -1,32 +0,0 @@
<?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

@ -1,187 +0,0 @@
<?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

@ -1,32 +0,0 @@
/**
* 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 {
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

@ -1,19 +0,0 @@
button[data-type="regenerate_external_css"]:before {
font: normal 20px/.5 dashicons;
display: inline-block;
padding: 0;
top: 9px;
left: -4px;
position: relative;
vertical-align: top;
content: "\f463";
}
button[data-type="regenerate_external_css"].loading:before {
animation: rotation 1s infinite linear;
}
button[data-type="regenerate_external_css"].success:before {
content: "\f147";
color: #46b450;
}

View File

@ -1,21 +0,0 @@
.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

@ -1,43 +0,0 @@
.generatepress-shortcuts > div {
background: #fff;
padding: 10px 15px;
border-width: 0 1px 1px 0;
border-color: #ddd;
border-style: solid;
margin-bottom: 10px;
}
.customize-control-gp_section_shortcut {
margin-bottom: 0;
}
.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

@ -1,131 +0,0 @@
.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;
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%;
transform: translateY(-50%) translateX(-4px);
border-radius: 50%;
cursor: pointer;
}
.customize-control-generatepress-pro-range-slider .wrapper {
display: flex;
justify-content: space-between;
align-items: center;
}
.customize-control-generatepress-pro-range-slider .gp_range_value {
font-size: 14px;
padding: 0;
font-weight: 400;
width: 50px;
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: 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

@ -1,101 +0,0 @@
.gp-spacing-control-section-title-area {
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: 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

@ -1,9 +0,0 @@
.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;
}

View File

@ -1,60 +0,0 @@
.generatepress-font-family {
margin-bottom: 12px;
}
.generatepress-weight-transform-wrapper {
display: flex;
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

@ -1,277 +0,0 @@
/**
* 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

@ -1,31 +0,0 @@
( function( api ) {
api.controlConstructor[ 'gp-background-images' ] = api.Control.extend( {
ready() {
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

@ -1,43 +0,0 @@
jQuery( function( $ ) {
$( '[data-type="overlay_design"]' ).on( 'click', function( e ) {
e.preventDefault();
// eslint-disable-next-line no-alert
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 ) );
} );
$( '[data-type="regenerate_external_css"]' ).on( 'click', function( e ) {
var $thisButton = $( this ); // eslint-disable-line no-var
e.preventDefault();
$thisButton.removeClass( 'success' ).addClass( 'loading' );
$.post( ajaxurl, {
action: 'generatepress_regenerate_css_file',
_nonce: $thisButton.data( 'nonce' ),
} ).done( function() {
$thisButton.removeClass( 'loading' ).addClass( 'success' );
} );
} );
} );

View File

@ -1,35 +0,0 @@
jQuery( 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' ),
otherTargets = button.siblings();
button.addClass( 'active' );
button.siblings().removeClass( 'active' );
$( 'li[data-control-section="' + target + '"]' ).css( {
visibility: 'visible',
height: '',
width: '',
margin: '',
overflow: '',
} );
$.each( otherTargets, function() {
var otherTarget = $( this ).data( 'target' );
$( 'li[data-control-section="' + otherTarget + '"]' ).css( {
visibility: 'hidden',
height: '0',
width: '0',
margin: '0',
overflow: 'hidden',
} );
} );
} );
} );

View File

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

View File

@ -1,151 +0,0 @@
( 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,
siteTitleTextColorSetting = api.instance( 'generate_settings[site_title_color]' ),
siteTitleTextColor = gpControls.siteTitleTextColor;
if ( siteTitleFontSizeSetting && ! siteTitleFontSizeSetting._dirty && 25 !== siteTitleFontSizeSetting.get() ) {
siteTitleFontSize = siteTitleFontSizeSetting.get();
}
if ( mobileSiteTitleFontSizeSetting && ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
mobileSiteTitleFontSize = mobileSiteTitleFontSizeSetting.get();
}
if ( navTextColorSetting && ! navTextColorSetting._dirty ) {
navTextColor = navTextColorSetting.get();
}
if ( siteTitleTextColorSetting && ! siteTitleTextColorSetting._dirty ) {
siteTitleTextColor = siteTitleTextColorSetting.get();
}
if ( newval ) {
navAlignmentSetting.set( 'right' );
if ( siteTitleFontSizeSetting ) {
siteTitleFontSizeSetting.set( 25 );
}
if ( api.instance( 'generate_settings[site_title_color]' ) ) {
api.instance( 'generate_settings[site_title_color]' ).set( navTextColor );
}
if ( mobileSiteTitleFontSizeSetting && 'enable' !== mobileHeader ) {
mobileSiteTitleFontSizeSetting.set( 20 );
}
} else {
navAlignmentSetting.set( navAlignment );
if ( siteTitleFontSizeSetting ) {
siteTitleFontSizeSetting.set( siteTitleFontSize );
}
if ( api.instance( 'generate_settings[site_title_color]' ) ) {
api.instance( 'generate_settings[site_title_color]' ).set( siteTitleTextColor );
}
if ( mobileSiteTitleFontSizeSetting && 'enable' !== mobileHeader ) {
mobileSiteTitleFontSizeSetting.set( mobileSiteTitleFontSize );
}
}
} );
var showRegularHeader,
showRegularHeaderCallback;
/**
* Determine whether we should display our header controls.
*
* @return {boolean} Whether we should show the regular header.
*/
showRegularHeader = function() {
if ( value.get() ) {
return false;
}
return true;
};
/**
* Update a control's active state according to the navigation as header option.
*
* @param {wp.customize.Control} control The current control.
*/
showRegularHeaderCallback = function( control ) {
var setActiveState = function() {
control.active.set( showRegularHeader() );
};
control.active.validate = showRegularHeader;
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 ( api.instance( 'generate_settings[mobile_site_title_font_size]' ) && '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 && ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
mobileSiteTitleFontSize = mobileSiteTitleFontSizeSetting.get();
}
if ( api.instance( 'generate_settings[mobile_site_title_font_size]' ) ) {
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

@ -1,46 +0,0 @@
jQuery( 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() {
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

@ -1,137 +0,0 @@
wp.customize.controlConstructor[ 'generatepress-pro-range-slider' ] = wp.customize.Control.extend( {
ready() {
'use strict';
var control = this,
value,
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( 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 ),
visibleArea = icon.closest( '.gp-range-title-area' ).next( '.gp-range-slider-areas' ).children( 'label:visible' ),
input = visibleArea.find( 'input[type=number]' ),
sliderValue = visibleArea.find( '.generatepress-slider' ),
visualValue = visibleArea.find( '.gp_range_value' ),
resetValue = input.attr( 'data-reset_value' );
input.val( resetValue ).change();
visualValue.find( 'input' ).val( resetValue );
visualValue.find( '.value' ).text( resetValue );
if ( '' == resetValue ) {
resetValue = -1;
}
sliderValue.slider( 'value', parseFloat( resetValue ) );
} );
// 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

@ -1,203 +0,0 @@
( function( $, api ) {
// No longer needed as of 1.2.95
// Keeping it here just in case
api.controlConstructor.spacing = api.Control.extend( {
ready() {
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() {
var control = this;
$( '.slider-input', control.container ).on( 'change keyup',
function() {
control.setting.set( $( this ).val() );
}
);
},
} );
api.controlConstructor[ 'generatepress-spacing' ] = api.Control.extend( {
ready() {
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( 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() {
var element = $( this );
element.val( val ).change();
} );
} );
} );

View File

@ -1,148 +0,0 @@
( function( api ) {
api.controlConstructor[ 'gp-pro-customizer-typography' ] = api.Control.extend( {
ready() {
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 );
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

@ -1,324 +0,0 @@
<?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

@ -1,131 +0,0 @@
<?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 );
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long