Initial commit
This commit is contained in:
572
wp-content/plugins/gp-premium/library/EDD_SL_Plugin_Updater.php
Normal file
572
wp-content/plugins/gp-premium/library/EDD_SL_Plugin_Updater.php
Normal file
@ -0,0 +1,572 @@
|
||||
<?php
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
/**
|
||||
* Allows plugins to use their own update API.
|
||||
*
|
||||
* @author Easy Digital Downloads
|
||||
* @version 1.6.18
|
||||
*/
|
||||
class EDD_SL_Plugin_Updater {
|
||||
|
||||
private $api_url = '';
|
||||
private $api_data = array();
|
||||
private $name = '';
|
||||
private $slug = '';
|
||||
private $version = '';
|
||||
private $wp_override = false;
|
||||
private $cache_key = '';
|
||||
|
||||
private $health_check_timeout = 5;
|
||||
|
||||
/**
|
||||
* 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->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->cache_key = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
|
||||
|
||||
$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 );
|
||||
remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
|
||||
add_action( 'after_plugin_row_' . $this->name, 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 ( 'plugins.php' == $pagenow && is_multisite() ) {
|
||||
return $_transient_data;
|
||||
}
|
||||
|
||||
if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
|
||||
return $_transient_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 ) );
|
||||
|
||||
$this->set_version_info_cache( $version_info );
|
||||
|
||||
}
|
||||
|
||||
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
|
||||
|
||||
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
||||
|
||||
$_transient_data->response[ $this->name ] = $version_info;
|
||||
|
||||
// Make sure the plugin property is set to the plugin's name/location. See issue 1463 on Software Licensing's GitHub repo.
|
||||
$_transient_data->response[ $this->name ]->plugin = $this->name;
|
||||
|
||||
}
|
||||
|
||||
$_transient_data->last_checked = time();
|
||||
$_transient_data->checked[ $this->name ] = $this->version;
|
||||
|
||||
}
|
||||
|
||||
return $_transient_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
|
||||
*
|
||||
* @param string $file
|
||||
* @param array $plugin
|
||||
*/
|
||||
public function show_update_notification( $file, $plugin ) {
|
||||
|
||||
if ( is_network_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! current_user_can( 'update_plugins' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! is_multisite() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $this->name != $file ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove our filter on the site transient
|
||||
remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
|
||||
|
||||
$update_cache = get_site_transient( 'update_plugins' );
|
||||
|
||||
$update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
|
||||
|
||||
if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
|
||||
|
||||
$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 ) );
|
||||
|
||||
// Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
|
||||
if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
|
||||
$version_info->banners = $this->convert_object_to_array( $version_info->banners );
|
||||
}
|
||||
|
||||
if ( isset( $version_info->sections ) && ! is_array( $version_info->sections ) ) {
|
||||
$version_info->sections = $this->convert_object_to_array( $version_info->sections );
|
||||
}
|
||||
|
||||
if ( isset( $version_info->icons ) && ! is_array( $version_info->icons ) ) {
|
||||
$version_info->icons = $this->convert_object_to_array( $version_info->icons );
|
||||
}
|
||||
|
||||
$this->set_version_info_cache( $version_info );
|
||||
}
|
||||
|
||||
if ( ! is_object( $version_info ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
||||
|
||||
$update_cache->response[ $this->name ] = $version_info;
|
||||
|
||||
}
|
||||
|
||||
$update_cache->last_checked = time();
|
||||
$update_cache->checked[ $this->name ] = $this->version;
|
||||
|
||||
set_site_transient( 'update_plugins', $update_cache );
|
||||
|
||||
} else {
|
||||
|
||||
$version_info = $update_cache->response[ $this->name ];
|
||||
|
||||
}
|
||||
|
||||
// Restore our filter
|
||||
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
||||
|
||||
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
||||
|
||||
// build a plugin list row, with update notification
|
||||
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
|
||||
# <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
|
||||
echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
|
||||
echo '<td colspan="3" class="plugin-update colspanchange">';
|
||||
echo '<div class="update-message notice inline notice-warning notice-alt">';
|
||||
|
||||
$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
|
||||
|
||||
if ( empty( $version_info->download_link ) ) {
|
||||
printf(
|
||||
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
|
||||
esc_html( $version_info->name ),
|
||||
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
|
||||
esc_html( $version_info->new_version ),
|
||||
'</a>'
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
|
||||
esc_html( $version_info->name ),
|
||||
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
|
||||
esc_html( $version_info->new_version ),
|
||||
'</a>',
|
||||
'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
|
||||
'</a>'
|
||||
);
|
||||
}
|
||||
|
||||
do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
|
||||
|
||||
echo '</div></td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ( $_action != 'plugin_information' ) {
|
||||
|
||||
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(),
|
||||
)
|
||||
);
|
||||
|
||||
$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
|
||||
|
||||
// Get the transient where we store the api request for this plugin for 24 hours
|
||||
$edd_api_request_transient = $this->get_cached_version_info( $cache_key );
|
||||
|
||||
//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, $cache_key );
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
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 ) {
|
||||
$new_data = array();
|
||||
foreach ( $data as $key => $value ) {
|
||||
$new_data[ $key ] = $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 ) {
|
||||
|
||||
$verify_ssl = $this->verify_ssl();
|
||||
if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
|
||||
$args['sslverify'] = $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
|
||||
*/
|
||||
private function api_request( $_action, $_data ) {
|
||||
|
||||
global $wp_version, $edd_plugin_url_available;
|
||||
|
||||
$verify_ssl = $this->verify_ssl();
|
||||
|
||||
// Do a quick status check on this domain if we haven't already checked it.
|
||||
$store_hash = md5( $this->api_url );
|
||||
if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) {
|
||||
$test_url_parts = parse_url( $this->api_url );
|
||||
|
||||
$scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http';
|
||||
$host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : '';
|
||||
$port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : '';
|
||||
|
||||
if ( empty( $host ) ) {
|
||||
$edd_plugin_url_available[ $store_hash ] = false;
|
||||
} else {
|
||||
$test_url = $scheme . '://' . $host . $port;
|
||||
$response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => $verify_ssl ) );
|
||||
$edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( false === $edd_plugin_url_available[ $store_hash ] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = array_merge( $this->api_data, $_data );
|
||||
|
||||
if ( $data['slug'] != $this->slug ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( $this->api_url == trailingslashit ( home_url() ) ) {
|
||||
return false; // Don't allow a plugin to ping itself
|
||||
}
|
||||
|
||||
$api_params = array(
|
||||
'edd_action' => 'get_version',
|
||||
'license' => ! empty( $data['license'] ) ? $data['license'] : '',
|
||||
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
||||
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
||||
'version' => isset( $data['version'] ) ? $data['version'] : false,
|
||||
'slug' => $data['slug'],
|
||||
'author' => $data['author'],
|
||||
'url' => home_url(),
|
||||
'beta' => ! empty( $data['beta'] ),
|
||||
);
|
||||
|
||||
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
|
||||
|
||||
if ( ! is_wp_error( $request ) ) {
|
||||
$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;
|
||||
}
|
||||
|
||||
public function show_changelog() {
|
||||
|
||||
global $edd_plugin_data;
|
||||
|
||||
if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( empty( $_REQUEST['plugin'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( empty( $_REQUEST['slug'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! current_user_can( 'update_plugins' ) ) {
|
||||
wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
|
||||
}
|
||||
|
||||
$data = $edd_plugin_data[ $_REQUEST['slug'] ];
|
||||
$beta = ! empty( $data['beta'] ) ? true : false;
|
||||
$cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
|
||||
$version_info = $this->get_cached_version_info( $cache_key );
|
||||
|
||||
if( false === $version_info ) {
|
||||
|
||||
$api_params = array(
|
||||
'edd_action' => 'get_version',
|
||||
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
||||
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
||||
'slug' => $_REQUEST['slug'],
|
||||
'author' => $data['author'],
|
||||
'url' => home_url(),
|
||||
'beta' => ! empty( $data['beta'] )
|
||||
);
|
||||
|
||||
$verify_ssl = $this->verify_ssl();
|
||||
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
|
||||
|
||||
if ( ! is_wp_error( $request ) ) {
|
||||
$version_info = json_decode( wp_remote_retrieve_body( $request ) );
|
||||
}
|
||||
|
||||
|
||||
if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
|
||||
$version_info->sections = maybe_unserialize( $version_info->sections );
|
||||
} else {
|
||||
$version_info = false;
|
||||
}
|
||||
|
||||
if( ! empty( $version_info ) ) {
|
||||
foreach( $version_info->sections as $key => $section ) {
|
||||
$version_info->$key = (array) $section;
|
||||
}
|
||||
}
|
||||
|
||||
$this->set_version_info_cache( $version_info, $cache_key );
|
||||
|
||||
}
|
||||
|
||||
if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
|
||||
echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
public function get_cached_version_info( $cache_key = '' ) {
|
||||
|
||||
if( empty( $cache_key ) ) {
|
||||
$cache_key = $this->cache_key;
|
||||
}
|
||||
|
||||
$cache = get_option( $cache_key );
|
||||
|
||||
if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
|
||||
return false; // Cache is expired
|
||||
}
|
||||
|
||||
// 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'];
|
||||
|
||||
}
|
||||
|
||||
public function set_version_info_cache( $value = '', $cache_key = '' ) {
|
||||
|
||||
if( empty( $cache_key ) ) {
|
||||
$cache_key = $this->cache_key;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'timeout' => strtotime( '+3 hours', time() ),
|
||||
'value' => json_encode( $value )
|
||||
);
|
||||
|
||||
update_option( $cache_key, $data, 'no' );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Async Request
|
||||
*
|
||||
* @package WP-Background-Processing
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'WP_Async_Request' ) ) {
|
||||
|
||||
/**
|
||||
* Abstract WP_Async_Request class.
|
||||
*
|
||||
* @abstract
|
||||
*/
|
||||
abstract class WP_Async_Request {
|
||||
|
||||
/**
|
||||
* Prefix
|
||||
*
|
||||
* (default value: 'wp')
|
||||
*
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
protected $prefix = 'wp';
|
||||
|
||||
/**
|
||||
* Action
|
||||
*
|
||||
* (default value: 'async_request')
|
||||
*
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
protected $action = 'async_request';
|
||||
|
||||
/**
|
||||
* Identifier
|
||||
*
|
||||
* @var mixed
|
||||
* @access protected
|
||||
*/
|
||||
protected $identifier;
|
||||
|
||||
/**
|
||||
* Data
|
||||
*
|
||||
* (default value: array())
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $data = array();
|
||||
|
||||
/**
|
||||
* Initiate new async request
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->identifier = $this->prefix . '_' . $this->action;
|
||||
|
||||
add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
|
||||
add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set data used during the request
|
||||
*
|
||||
* @param array $data Data.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function data( $data ) {
|
||||
$this->data = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch the async request
|
||||
*
|
||||
* @return array|WP_Error
|
||||
*/
|
||||
public function dispatch() {
|
||||
$url = add_query_arg( $this->get_query_args(), $this->get_query_url() );
|
||||
$args = $this->get_post_args();
|
||||
|
||||
return wp_remote_post( esc_url_raw( $url ), $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query args
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_query_args() {
|
||||
if ( property_exists( $this, 'query_args' ) ) {
|
||||
return $this->query_args;
|
||||
}
|
||||
|
||||
return array(
|
||||
'action' => $this->identifier,
|
||||
'nonce' => wp_create_nonce( $this->identifier ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_query_url() {
|
||||
if ( property_exists( $this, 'query_url' ) ) {
|
||||
return $this->query_url;
|
||||
}
|
||||
|
||||
return admin_url( 'admin-ajax.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get post args
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_post_args() {
|
||||
if ( property_exists( $this, 'post_args' ) ) {
|
||||
return $this->post_args;
|
||||
}
|
||||
|
||||
return array(
|
||||
'timeout' => 0.01,
|
||||
'blocking' => false,
|
||||
'body' => $this->data,
|
||||
'cookies' => $_COOKIE,
|
||||
'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe handle
|
||||
*
|
||||
* Check for correct nonce and pass to handler.
|
||||
*/
|
||||
public function maybe_handle() {
|
||||
// Don't lock up other requests while processing
|
||||
session_write_close();
|
||||
|
||||
check_ajax_referer( $this->identifier, 'nonce' );
|
||||
|
||||
$this->handle();
|
||||
|
||||
wp_die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle
|
||||
*
|
||||
* Override this method to perform any actions required
|
||||
* during the async request.
|
||||
*/
|
||||
abstract protected function handle();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,506 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Background Process
|
||||
*
|
||||
* @package WP-Background-Processing
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'WP_Background_Process' ) ) {
|
||||
|
||||
/**
|
||||
* Abstract WP_Background_Process class.
|
||||
*
|
||||
* @abstract
|
||||
* @extends WP_Async_Request
|
||||
*/
|
||||
abstract class WP_Background_Process extends WP_Async_Request {
|
||||
|
||||
/**
|
||||
* Action
|
||||
*
|
||||
* (default value: 'background_process')
|
||||
*
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
protected $action = 'background_process';
|
||||
|
||||
/**
|
||||
* Start time of current process.
|
||||
*
|
||||
* (default value: 0)
|
||||
*
|
||||
* @var int
|
||||
* @access protected
|
||||
*/
|
||||
protected $start_time = 0;
|
||||
|
||||
/**
|
||||
* Cron_hook_identifier
|
||||
*
|
||||
* @var mixed
|
||||
* @access protected
|
||||
*/
|
||||
protected $cron_hook_identifier;
|
||||
|
||||
/**
|
||||
* Cron_interval_identifier
|
||||
*
|
||||
* @var mixed
|
||||
* @access protected
|
||||
*/
|
||||
protected $cron_interval_identifier;
|
||||
|
||||
/**
|
||||
* Initiate new background process
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
$this->cron_hook_identifier = $this->identifier . '_cron';
|
||||
$this->cron_interval_identifier = $this->identifier . '_cron_interval';
|
||||
|
||||
add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) );
|
||||
add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function dispatch() {
|
||||
// Schedule the cron healthcheck.
|
||||
$this->schedule_event();
|
||||
|
||||
// Perform remote post.
|
||||
return parent::dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Push to queue
|
||||
*
|
||||
* @param mixed $data Data.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function push_to_queue( $data ) {
|
||||
$this->data[] = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save queue
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function save() {
|
||||
$key = $this->generate_key();
|
||||
|
||||
if ( ! empty( $this->data ) ) {
|
||||
update_site_option( $key, $this->data );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update queue
|
||||
*
|
||||
* @param string $key Key.
|
||||
* @param array $data Data.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function update( $key, $data ) {
|
||||
if ( ! empty( $data ) ) {
|
||||
update_site_option( $key, $data );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete queue
|
||||
*
|
||||
* @param string $key Key.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function delete( $key ) {
|
||||
delete_site_option( $key );
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate key
|
||||
*
|
||||
* Generates a unique key based on microtime. Queue items are
|
||||
* given a unique key so that they can be merged upon save.
|
||||
*
|
||||
* @param int $length Length.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function generate_key( $length = 64 ) {
|
||||
$unique = md5( microtime() . rand() );
|
||||
$prepend = $this->identifier . '_batch_';
|
||||
|
||||
return substr( $prepend . $unique, 0, $length );
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe process queue
|
||||
*
|
||||
* Checks whether data exists within the queue and that
|
||||
* the process is not already running.
|
||||
*/
|
||||
public function maybe_handle() {
|
||||
// Don't lock up other requests while processing
|
||||
session_write_close();
|
||||
|
||||
if ( $this->is_process_running() ) {
|
||||
// Background process already running.
|
||||
wp_die();
|
||||
}
|
||||
|
||||
if ( $this->is_queue_empty() ) {
|
||||
// No data to process.
|
||||
wp_die();
|
||||
}
|
||||
|
||||
check_ajax_referer( $this->identifier, 'nonce' );
|
||||
|
||||
$this->handle();
|
||||
|
||||
wp_die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is queue empty
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_queue_empty() {
|
||||
global $wpdb;
|
||||
|
||||
$table = $wpdb->options;
|
||||
$column = 'option_name';
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$table = $wpdb->sitemeta;
|
||||
$column = 'meta_key';
|
||||
}
|
||||
|
||||
$key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%';
|
||||
|
||||
$count = $wpdb->get_var( $wpdb->prepare( "
|
||||
SELECT COUNT(*)
|
||||
FROM {$table}
|
||||
WHERE {$column} LIKE %s
|
||||
", $key ) );
|
||||
|
||||
return ( $count > 0 ) ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is process running
|
||||
*
|
||||
* Check whether the current process is already running
|
||||
* in a background process.
|
||||
*/
|
||||
protected function is_process_running() {
|
||||
if ( get_site_transient( $this->identifier . '_process_lock' ) ) {
|
||||
// Process already running.
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock process
|
||||
*
|
||||
* Lock the process so that multiple instances can't run simultaneously.
|
||||
* Override if applicable, but the duration should be greater than that
|
||||
* defined in the time_exceeded() method.
|
||||
*/
|
||||
protected function lock_process() {
|
||||
$this->start_time = time(); // Set start time of current process.
|
||||
|
||||
$lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute
|
||||
$lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration );
|
||||
|
||||
set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock process
|
||||
*
|
||||
* Unlock the process so that other instances can spawn.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function unlock_process() {
|
||||
delete_site_transient( $this->identifier . '_process_lock' );
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get batch
|
||||
*
|
||||
* @return stdClass Return the first batch from the queue
|
||||
*/
|
||||
protected function get_batch() {
|
||||
global $wpdb;
|
||||
|
||||
$table = $wpdb->options;
|
||||
$column = 'option_name';
|
||||
$key_column = 'option_id';
|
||||
$value_column = 'option_value';
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$table = $wpdb->sitemeta;
|
||||
$column = 'meta_key';
|
||||
$key_column = 'meta_id';
|
||||
$value_column = 'meta_value';
|
||||
}
|
||||
|
||||
$key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%';
|
||||
|
||||
$query = $wpdb->get_row( $wpdb->prepare( "
|
||||
SELECT *
|
||||
FROM {$table}
|
||||
WHERE {$column} LIKE %s
|
||||
ORDER BY {$key_column} ASC
|
||||
LIMIT 1
|
||||
", $key ) );
|
||||
|
||||
$batch = new stdClass();
|
||||
$batch->key = $query->$column;
|
||||
$batch->data = maybe_unserialize( $query->$value_column );
|
||||
|
||||
return $batch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle
|
||||
*
|
||||
* Pass each queue item to the task handler, while remaining
|
||||
* within server memory and time limit constraints.
|
||||
*/
|
||||
protected function handle() {
|
||||
$this->lock_process();
|
||||
|
||||
do {
|
||||
$batch = $this->get_batch();
|
||||
|
||||
foreach ( $batch->data as $key => $value ) {
|
||||
$task = $this->task( $value );
|
||||
|
||||
if ( false !== $task ) {
|
||||
$batch->data[ $key ] = $task;
|
||||
} else {
|
||||
unset( $batch->data[ $key ] );
|
||||
}
|
||||
|
||||
if ( $this->time_exceeded() || $this->memory_exceeded() ) {
|
||||
// Batch limits reached.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Update or delete current batch.
|
||||
if ( ! empty( $batch->data ) ) {
|
||||
$this->update( $batch->key, $batch->data );
|
||||
} else {
|
||||
$this->delete( $batch->key );
|
||||
}
|
||||
} while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() );
|
||||
|
||||
$this->unlock_process();
|
||||
|
||||
// Start next batch or complete process.
|
||||
if ( ! $this->is_queue_empty() ) {
|
||||
$this->dispatch();
|
||||
} else {
|
||||
$this->complete();
|
||||
}
|
||||
|
||||
wp_die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Memory exceeded
|
||||
*
|
||||
* Ensures the batch process never exceeds 90%
|
||||
* of the maximum WordPress memory.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function memory_exceeded() {
|
||||
$memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory
|
||||
$current_memory = memory_get_usage( true );
|
||||
$return = false;
|
||||
|
||||
if ( $current_memory >= $memory_limit ) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return apply_filters( $this->identifier . '_memory_exceeded', $return );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get memory limit
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get_memory_limit() {
|
||||
if ( function_exists( 'ini_get' ) ) {
|
||||
$memory_limit = ini_get( 'memory_limit' );
|
||||
} else {
|
||||
// Sensible default.
|
||||
$memory_limit = '128M';
|
||||
}
|
||||
|
||||
if ( ! $memory_limit || -1 === intval( $memory_limit ) ) {
|
||||
// Unlimited, set to 32GB.
|
||||
$memory_limit = '32000M';
|
||||
}
|
||||
|
||||
return intval( $memory_limit ) * 1024 * 1024;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time exceeded.
|
||||
*
|
||||
* Ensures the batch never exceeds a sensible time limit.
|
||||
* A timeout limit of 30s is common on shared hosting.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function time_exceeded() {
|
||||
$finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds
|
||||
$return = false;
|
||||
|
||||
if ( time() >= $finish ) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return apply_filters( $this->identifier . '_time_exceeded', $return );
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete.
|
||||
*
|
||||
* Override if applicable, but ensure that the below actions are
|
||||
* performed, or, call parent::complete().
|
||||
*/
|
||||
protected function complete() {
|
||||
// Unschedule the cron healthcheck.
|
||||
$this->clear_scheduled_event();
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule cron healthcheck
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $schedules Schedules.
|
||||
* @return mixed
|
||||
*/
|
||||
public function schedule_cron_healthcheck( $schedules ) {
|
||||
$interval = apply_filters( $this->identifier . '_cron_interval', 5 );
|
||||
|
||||
if ( property_exists( $this, 'cron_interval' ) ) {
|
||||
$interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval );
|
||||
}
|
||||
|
||||
// Adds every 5 minutes to the existing schedules.
|
||||
$schedules[ $this->identifier . '_cron_interval' ] = array(
|
||||
'interval' => MINUTE_IN_SECONDS * $interval,
|
||||
'display' => sprintf( __( 'Every %d Minutes' ), $interval ),
|
||||
);
|
||||
|
||||
return $schedules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle cron healthcheck
|
||||
*
|
||||
* Restart the background process if not already running
|
||||
* and data exists in the queue.
|
||||
*/
|
||||
public function handle_cron_healthcheck() {
|
||||
if ( $this->is_process_running() ) {
|
||||
// Background process already running.
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $this->is_queue_empty() ) {
|
||||
// No data to process.
|
||||
$this->clear_scheduled_event();
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->handle();
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule event
|
||||
*/
|
||||
protected function schedule_event() {
|
||||
if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) {
|
||||
wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear scheduled event
|
||||
*/
|
||||
protected function clear_scheduled_event() {
|
||||
$timestamp = wp_next_scheduled( $this->cron_hook_identifier );
|
||||
|
||||
if ( $timestamp ) {
|
||||
wp_unschedule_event( $timestamp, $this->cron_hook_identifier );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Process
|
||||
*
|
||||
* Stop processing queue items, clear cronjob and delete batch.
|
||||
*
|
||||
*/
|
||||
public function cancel_process() {
|
||||
if ( ! $this->is_queue_empty() ) {
|
||||
$batch = $this->get_batch();
|
||||
|
||||
$this->delete( $batch->key );
|
||||
|
||||
wp_clear_scheduled_hook( $this->cron_hook_identifier );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Task
|
||||
*
|
||||
* Override this method to perform any actions required on each
|
||||
* queue item. Return the modified item for further processing
|
||||
* in the next pass through. Or, return false to remove the
|
||||
* item from the queue.
|
||||
*
|
||||
* @param mixed $item Queue item to iterate over.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract protected function task( $item );
|
||||
|
||||
}
|
||||
}
|
202
wp-content/plugins/gp-premium/library/class-make-css.php
Normal file
202
wp-content/plugins/gp-premium/library/class-make-css.php
Normal file
@ -0,0 +1,202 @@
|
||||
<?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;
|
249
wp-content/plugins/gp-premium/library/customizer-helpers.php
Normal file
249
wp-content/plugins/gp-premium/library/customizer-helpers.php
Normal file
@ -0,0 +1,249 @@
|
||||
<?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() {
|
||||
if ( function_exists( 'generate_typography_default_fonts' ) ) {
|
||||
$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['headerTextColor'] = $color_defaults['header_text_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
|
||||
);
|
||||
}
|
||||
|
||||
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,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
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' => 900,
|
||||
'mobile' => 640,
|
||||
) );
|
||||
?>
|
||||
<style>
|
||||
.wp-customizer .preview-tablet .wp-full-overlay-main {
|
||||
width: <?php echo absint( $sizes['tablet'] ); ?>px;
|
||||
margin: 0 auto;
|
||||
left: 50%;
|
||||
-webkit-transform: translateX(-50%);
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.wp-customizer .preview-mobile .wp-full-overlay-main {
|
||||
width: <?php echo absint( $sizes['mobile'] ); ?>px;
|
||||
margin: 0 auto;
|
||||
left: 50%;
|
||||
-webkit-transform: translateX(-50%);
|
||||
transform: translateX(-50%);
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
}
|
@ -0,0 +1,584 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_mobile_header_activated' ) ) {
|
||||
/**
|
||||
* Check to see if the mobile header is activated
|
||||
*/
|
||||
function generate_mobile_header_activated() {
|
||||
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$generate_menu_plus_settings = wp_parse_args(
|
||||
get_option( 'generate_menu_plus_settings', array() ),
|
||||
generate_menu_plus_get_defaults()
|
||||
);
|
||||
|
||||
return ( 'enable' == $generate_menu_plus_settings[ 'mobile_header' ] ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If we're using the mobile header, and have the logo set as the branding type.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
function generate_mobile_header_logo_active_callback() {
|
||||
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_menu_plus_settings', array() ),
|
||||
generate_menu_plus_get_defaults()
|
||||
);
|
||||
|
||||
return ( 'enable' === $settings['mobile_header'] && 'logo' === $settings['mobile_header_branding'] ) ? true : false;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_mobile_header_sticky_activated' ) ) {
|
||||
/**
|
||||
* Check to see if the mobile header is activated
|
||||
*/
|
||||
function generate_mobile_header_sticky_activated() {
|
||||
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$generate_menu_plus_settings = wp_parse_args(
|
||||
get_option( 'generate_menu_plus_settings', array() ),
|
||||
generate_menu_plus_get_defaults()
|
||||
);
|
||||
|
||||
return ( 'enable' == $generate_menu_plus_settings[ 'mobile_header' ] && 'enable' == $generate_menu_plus_settings[ 'mobile_header_sticky' ] ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sticky_navigation_activated' ) ) {
|
||||
/**
|
||||
* Check to see if the sticky navigation is activated
|
||||
*/
|
||||
function generate_sticky_navigation_activated() {
|
||||
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$generate_menu_plus_settings = wp_parse_args(
|
||||
get_option( 'generate_menu_plus_settings', array() ),
|
||||
generate_menu_plus_get_defaults()
|
||||
);
|
||||
|
||||
return ( 'false' !== $generate_menu_plus_settings[ 'sticky_menu' ] ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_navigation_logo_activated' ) ) {
|
||||
/**
|
||||
* Check to see if the sticky navigation is activated
|
||||
*/
|
||||
function generate_navigation_logo_activated() {
|
||||
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$generate_menu_plus_settings = wp_parse_args(
|
||||
get_option( 'generate_menu_plus_settings', array() ),
|
||||
generate_menu_plus_get_defaults()
|
||||
);
|
||||
|
||||
return ( '' !== $generate_menu_plus_settings[ 'sticky_menu_logo' ] ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_slideout_navigation_activated' ) ) {
|
||||
/**
|
||||
* Check to see if the sticky navigation is activated
|
||||
*/
|
||||
function generate_slideout_navigation_activated() {
|
||||
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$generate_menu_plus_settings = wp_parse_args(
|
||||
get_option( 'generate_menu_plus_settings', array() ),
|
||||
generate_menu_plus_get_defaults()
|
||||
);
|
||||
|
||||
return ( 'false' !== $generate_menu_plus_settings[ 'slideout_menu' ] ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the overlay off canvas panel is activated.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
function generate_is_overlay_navigation_active_callback() {
|
||||
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_menu_plus_settings', array() ),
|
||||
generate_menu_plus_get_defaults()
|
||||
);
|
||||
|
||||
return ( 'false' !== $settings['slideout_menu'] && 'overlay' === $settings['slideout_menu_style'] ) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the slideout off canvas panel is activated.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
function generate_is_slideout_navigation_active_callback() {
|
||||
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_menu_plus_settings', array() ),
|
||||
generate_menu_plus_get_defaults()
|
||||
);
|
||||
|
||||
return ( 'false' !== $settings['slideout_menu'] && 'slide' === $settings['slideout_menu_style'] ) ? true : false;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_blog_content_exists' ) ) {
|
||||
/**
|
||||
* This is an active_callback
|
||||
* Check if page header content exists
|
||||
*/
|
||||
function generate_page_header_blog_content_exists() {
|
||||
if ( ! function_exists( 'generate_page_header_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$options = get_option( 'generate_page_header_options', generate_page_header_get_defaults() );
|
||||
if ( isset( $options[ 'page_header_content' ] ) && '' !== $options[ 'page_header_content' ] ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_blog_image_exists' ) ) {
|
||||
/**
|
||||
* This is an active_callback
|
||||
* Check if page header image exists
|
||||
*/
|
||||
function generate_page_header_blog_image_exists() {
|
||||
if ( ! function_exists( 'generate_page_header_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$options = get_option( 'generate_page_header_options', generate_page_header_get_defaults() );
|
||||
if ( isset( $options[ 'page_header_image' ] ) && '' !== $options[ 'page_header_image' ] ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_blog_crop_exists' ) ) {
|
||||
/**
|
||||
* This is an active_callback
|
||||
* Check if page header image resizing is enabled
|
||||
*/
|
||||
function generate_page_header_blog_crop_exists() {
|
||||
if ( ! function_exists( 'generate_page_header_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$options = get_option( 'generate_page_header_options', generate_page_header_get_defaults() );
|
||||
|
||||
if ( isset( $options[ 'page_header_hard_crop' ] ) && 'disable' !== $options[ 'page_header_hard_crop' ] ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_blog_combined' ) ) {
|
||||
/**
|
||||
* This is an active_callback
|
||||
* Check if page header is merged
|
||||
*/
|
||||
function generate_page_header_blog_combined() {
|
||||
if ( ! function_exists( 'generate_page_header_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$options = get_option( 'generate_page_header_options', generate_page_header_get_defaults() );
|
||||
if ( isset( $options[ 'page_header_combine' ] ) && '' !== $options[ 'page_header_combine' ] ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_full_screen_vertical' ) ) {
|
||||
/**
|
||||
* This is an active_callback
|
||||
* Check if our page header is full screen and vertically centered
|
||||
*/
|
||||
function generate_page_header_full_screen_vertical() {
|
||||
if ( ! function_exists( 'generate_page_header_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$options = get_option( 'generate_page_header_options', generate_page_header_get_defaults() );
|
||||
|
||||
if ( $options[ 'page_header_full_screen' ] && $options[ 'page_header_vertical_center' ] ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_secondary_nav_show_merge_top_bar' ) ) {
|
||||
/**
|
||||
* This is an active callback
|
||||
* Determines whether we should show the Merge with Secondary Navigation option
|
||||
*/
|
||||
function generate_secondary_nav_show_merge_top_bar() {
|
||||
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$generate_settings = wp_parse_args(
|
||||
get_option( 'generate_secondary_nav_settings', array() ),
|
||||
generate_secondary_nav_get_defaults()
|
||||
);
|
||||
|
||||
if ( 'secondary-nav-above-header' == $generate_settings[ 'secondary_nav_position_setting' ] && has_nav_menu( 'secondary' ) && is_active_sidebar( 'top-bar' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_is_top_bar_active' ) ) {
|
||||
/**
|
||||
* Check to see if the top bar is active
|
||||
*
|
||||
* @since 1.3.45
|
||||
*/
|
||||
function generate_premium_is_top_bar_active() {
|
||||
$top_bar = is_active_sidebar( 'top-bar' ) ? true : false;
|
||||
return apply_filters( 'generate_is_top_bar_active', $top_bar );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_masonry_callback' ) ) {
|
||||
/**
|
||||
* Check to see if masonry is activated
|
||||
*/
|
||||
function generate_masonry_callback() {
|
||||
if ( ! function_exists( 'generate_blog_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$generate_blog_settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
// If masonry is enabled, set to true
|
||||
return ( 'true' == $generate_blog_settings['masonry'] ) ? true : false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_is_posts_page' ) ) {
|
||||
/**
|
||||
* Check to see if we're on a posts page
|
||||
*/
|
||||
function generate_premium_is_posts_page() {
|
||||
$blog = ( is_home() || is_archive() || is_attachment() || is_tax() ) ? true : false;
|
||||
|
||||
return $blog;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_is_posts_page_single' ) ) {
|
||||
/**
|
||||
* Check to see if we're on a posts page or a single post
|
||||
*/
|
||||
function generate_premium_is_posts_page_single() {
|
||||
$blog = ( is_home() || is_archive() || is_attachment() || is_tax() || is_single() ) ? true : false;
|
||||
|
||||
return $blog;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_is_excerpt' ) ) {
|
||||
/**
|
||||
* Check to see if we're displaying excerpts
|
||||
*/
|
||||
function generate_premium_is_excerpt() {
|
||||
if ( ! function_exists( 'generate_get_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$generate_settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
generate_get_defaults()
|
||||
);
|
||||
|
||||
return ( 'excerpt' == $generate_settings['post_content'] ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if featured images are active.
|
||||
*
|
||||
* @since 1.5
|
||||
* @return bool Whether featured images are active or not
|
||||
*/
|
||||
function generate_premium_featured_image_active() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings[ 'post_image' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if featured images on single posts are active.
|
||||
*
|
||||
* @since 1.5
|
||||
* @return bool Whether featured images on single posts are active or not.
|
||||
*/
|
||||
function generate_premium_single_featured_image_active() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings[ 'single_post_image' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if featured images on single posts are active.
|
||||
*
|
||||
* @since 1.5
|
||||
* @return bool Whether featured images on single posts are active or not.
|
||||
*/
|
||||
function generate_premium_single_page_featured_image_active() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings[ 'page_post_image' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the blog columns Customizer control is true.
|
||||
*
|
||||
* @since 1.5
|
||||
* @return bool Whether columns are active or not
|
||||
*/
|
||||
function generate_premium_blog_columns_active() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings[ 'column_layout' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the blog masonry Customizer control is true.
|
||||
*
|
||||
* @since 1.5
|
||||
* @return bool Whether masonry is active or not
|
||||
*/
|
||||
function generate_premium_blog_masonry_active() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings[ 'column_layout' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $settings[ 'masonry' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only show padding around image control when alignment is centered.
|
||||
*
|
||||
* @since 1.5
|
||||
* @return bool
|
||||
*/
|
||||
function generate_premium_display_image_padding() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings[ 'post_image' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( 'post-image-aligned-center' !== $settings[ 'post_image_alignment' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only show padding around image control when alignment is centered and not
|
||||
* set to display above our content area.
|
||||
*
|
||||
* @since 1.5
|
||||
* @return bool
|
||||
*/
|
||||
function generate_premium_display_image_padding_single() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings[ 'single_post_image' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( 'center' !== $settings[ 'single_post_image_alignment' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( 'above-content' == $settings[ 'single_post_image_position' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only show padding around image control when alignment is centered and not
|
||||
* set to display above our content area.
|
||||
*
|
||||
* @since 1.5
|
||||
* @return bool
|
||||
*/
|
||||
function generate_premium_display_image_padding_single_page() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings[ 'page_post_image' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( 'center' !== $settings[ 'page_post_image_alignment' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( 'above-content' == $settings[ 'page_post_image_position' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if infinite scroll is activated.
|
||||
*
|
||||
* @since 1.5
|
||||
* @return bool
|
||||
*/
|
||||
function generate_premium_infinite_scroll_active() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings[ 'infinite_scroll' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if infinite scroll is activated and we're using a button.
|
||||
*
|
||||
* @since 1.5
|
||||
* @return bool
|
||||
*/
|
||||
function generate_premium_infinite_scroll_button_active() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings[ 'infinite_scroll' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $settings[ 'infinite_scroll_button' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the WooCommerce menu item is active.
|
||||
*
|
||||
* @since 1.8
|
||||
* @return bool Whether the cart item is active.
|
||||
*/
|
||||
function generate_premium_wc_menu_item_active() {
|
||||
if ( ! function_exists( 'generatepress_wc_defaults' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_woocommerce_settings', array() ),
|
||||
generatepress_wc_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings[ 'cart_menu_item' ] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WP_Customize_Control' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'GeneratePress_Action_Button_Control' ) ) {
|
||||
/**
|
||||
* Add a button which needs javascript attached to it.
|
||||
*/
|
||||
class GeneratePress_Action_Button_Control extends WP_Customize_Control {
|
||||
public $type = 'gp_action_button';
|
||||
public $data_type = '';
|
||||
public $description = '';
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'gp-button-actions', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/button-actions.js', array( 'customize-controls' ), GP_PREMIUM_VERSION, true );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$this->json['data_type'] = $this->data_type;
|
||||
$this->json['description'] = $this->description;
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<button class="button" data-type="{{{ data.data_type }}}">{{{ data.label }}}</button>
|
||||
<span class="description customize-control-description">
|
||||
<p>{{{ data.description }}}</p>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! class_exists( 'GeneratePress_Alpha_Color_Customize_Control' ) ) :
|
||||
class GeneratePress_Alpha_Color_Customize_Control extends WP_Customize_Control {
|
||||
/**
|
||||
* Official control name.
|
||||
*/
|
||||
public $type = 'gp-alpha-color';
|
||||
/**
|
||||
* Add support for palettes to be passed in.
|
||||
*
|
||||
* Supported palette values are true, false, or an array of RGBa and Hex colors.
|
||||
*/
|
||||
public $palette;
|
||||
/**
|
||||
* Add support for showing the opacity value on the slider handle.
|
||||
*/
|
||||
public $show_opacity;
|
||||
/**
|
||||
* Enqueue scripts and styles.
|
||||
*
|
||||
* Ideally these would get registered and given proper paths before this control object
|
||||
* gets initialized, then we could simply enqueue them here, but for completeness as a
|
||||
* stand alone class we'll register and enqueue them here.
|
||||
*/
|
||||
public function enqueue() {
|
||||
wp_enqueue_script(
|
||||
'gp-alpha-color-picker',
|
||||
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/alpha-color-picker.js',
|
||||
array( 'jquery', 'wp-color-picker' ),
|
||||
GP_PREMIUM_VERSION,
|
||||
true
|
||||
);
|
||||
wp_enqueue_style(
|
||||
'gp-alpha-color-picker',
|
||||
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/alpha-color-picker.css',
|
||||
array( 'wp-color-picker' ),
|
||||
GP_PREMIUM_VERSION
|
||||
);
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['palette'] = $this->palette;
|
||||
$this->json['defaultValue'] = $this->setting->default;
|
||||
$this->json[ 'link' ] = $this->get_link();
|
||||
$this->json[ 'show_opacity' ] = $this->show_opacity;
|
||||
|
||||
if ( is_array( $this->json['palette'] ) ) {
|
||||
$this->json['palette'] = implode( '|', $this->json['palette'] );
|
||||
} else {
|
||||
// Default to true.
|
||||
$this->json['palette'] = ( false === $this->json['palette'] || 'false' === $this->json['palette'] ) ? 'false' : 'true';
|
||||
}
|
||||
|
||||
// Support passing show_opacity as string or boolean. Default to true.
|
||||
$this->json[ 'show_opacity' ] = ( false === $this->json[ 'show_opacity' ] || 'false' === $this->json[ 'show_opacity' ] ) ? 'false' : 'true';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the control.
|
||||
*/
|
||||
public function render_content() {}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<# if ( data.label && '' !== data.label ) { #>
|
||||
<span class="customize-control-title">{{ data.label }}</span>
|
||||
<# } #>
|
||||
<input class="gp-alpha-color-control" type="text" data-palette="{{{ data.palette }}}" data-default-color="{{ data.defaultValue }}" {{{ data.link }}} />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
@ -0,0 +1,146 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) ) {
|
||||
class GeneratePress_Background_Images_Customize_Control extends WP_Customize_Control {
|
||||
public $type = 'gp-background-images';
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'gp-backgrounds-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/backgrounds-customizer.js', array( 'customize-controls' ), GP_PREMIUM_VERSION, true );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$this->json[ 'position_title' ] = esc_html__( 'left top, x% y%, xpos ypos (px)', 'gp-premium' );
|
||||
$this->json[ 'position_placeholder' ] = esc_html__( 'Position', 'gp-premium' );
|
||||
|
||||
foreach ( $this->settings as $setting_key => $setting_id ) {
|
||||
$this->json[ $setting_key ] = array(
|
||||
'link' => $this->get_link( $setting_key ),
|
||||
'value' => $this->value( $setting_key ),
|
||||
'default' => isset( $setting_id->default ) ? $setting_id->default : '',
|
||||
'id' => isset( $setting_id->id ) ? $setting_id->id : ''
|
||||
);
|
||||
|
||||
if ( 'repeat' === $setting_key ) {
|
||||
$this->json[ $setting_key ]['choices'] = $this->get_repeat_choices();
|
||||
}
|
||||
|
||||
if ( 'size' === $setting_key ) {
|
||||
$this->json[ $setting_key ]['choices'] = $this->get_size_choices();
|
||||
}
|
||||
|
||||
if ( 'attachment' === $setting_key ) {
|
||||
$this->json[ $setting_key ]['choices'] = $this->get_attachment_choices();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<# if ( '' !== data.label ) { #>
|
||||
<span class="customize-control-title">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.repeat ) ) { #>
|
||||
<div class="generatepress-backgrounds-repeat">
|
||||
<label>
|
||||
<select {{{ data.repeat.link }}}>
|
||||
|
||||
<# _.each( data.repeat.choices, function( label, choice ) { #>
|
||||
|
||||
<option value="{{ choice }}" <# if ( choice === data.repeat.value ) { #> selected="selected" <# } #>>{{ label }}</option>
|
||||
|
||||
<# } ) #>
|
||||
|
||||
</select>
|
||||
<# if ( '' !== data.repeat_title ) { #>
|
||||
<p class="description">{{ data.repeat_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.size ) ) { #>
|
||||
<div class="generatepress-backgrounds-size">
|
||||
<label>
|
||||
<select {{{ data.size.link }}}>
|
||||
|
||||
<# _.each( data.size.choices, function( label, choice ) { #>
|
||||
|
||||
<option value="{{ choice }}" <# if ( choice === data.size.value ) { #> selected="selected" <# } #>>{{ label }}</option>
|
||||
|
||||
<# } ) #>
|
||||
|
||||
</select>
|
||||
<# if ( '' !== data.size_title ) { #>
|
||||
<p class="description">{{ data.size_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.attachment ) ) { #>
|
||||
<div class="generatepress-backgrounds-attachment">
|
||||
<label>
|
||||
<select {{{ data.attachment.link }}}>
|
||||
|
||||
<# _.each( data.attachment.choices, function( label, choice ) { #>
|
||||
|
||||
<option value="{{ choice }}" <# if ( choice === data.attachment.value ) { #> selected="selected" <# } #>>{{ label }}</option>
|
||||
|
||||
<# } ) #>
|
||||
|
||||
</select>
|
||||
<# if ( '' !== data.attachment_title ) { #>
|
||||
<p class="description">{{ data.attachment_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.position ) ) { #>
|
||||
<div class="generatepress-backgrounds-position">
|
||||
<label>
|
||||
<input name="{{{ data.position.id }}}" type="text" {{{ data.position.link }}} value="{{{ data.position.value }}}" placeholder="{{ data.position_placeholder }}" />
|
||||
<# if ( '' !== data.position_title ) { #>
|
||||
<p class="description">{{ data.position_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function get_repeat_choices() {
|
||||
return array(
|
||||
'' => esc_html__( 'Repeat', 'gp-premium' ),
|
||||
'repeat-x' => esc_html__( 'Repeat x', 'gp-premium' ),
|
||||
'repeat-y' => esc_html__( 'Repeat y', 'gp-premium' ),
|
||||
'no-repeat' => esc_html__( 'No Repeat', 'gp-premium' )
|
||||
);
|
||||
}
|
||||
|
||||
public function get_size_choices() {
|
||||
return array(
|
||||
'' => esc_html__( 'Size (Auto)', 'gp-premium' ),
|
||||
'100' => esc_html__( '100% Width', 'gp-premium' ),
|
||||
'cover' => esc_html__( 'Cover', 'gp-premium' ),
|
||||
'contain' => esc_html__( 'Contain', 'gp-premium' )
|
||||
);
|
||||
}
|
||||
|
||||
public function get_attachment_choices() {
|
||||
return array(
|
||||
'' => esc_html__( 'Attachment', 'gp-premium' ),
|
||||
'fixed' => esc_html__( 'Fixed', 'gp-premium' ),
|
||||
'local' => esc_html__( 'Local', 'gp-premium' ),
|
||||
'inherit' => esc_html__( 'Inherit', 'gp-premium' )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Control_Toggle_Customize_Control' ) ) :
|
||||
/**
|
||||
* Add a button to initiate refresh when changing featured image sizes
|
||||
*/
|
||||
class Generate_Control_Toggle_Customize_Control extends WP_Customize_Control {
|
||||
public $type = 'control_section_toggle';
|
||||
public $targets = '';
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'generatepress-pro-control-target', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/control-toggle-customizer.js', array( 'customize-controls', 'jquery' ), GP_PREMIUM_VERSION, true );
|
||||
wp_enqueue_style( 'generatepress-pro-control-target', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/control-toggle-customizer.css', array(), GP_PREMIUM_VERSION );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$this->json[ 'targets' ] = $this->targets;
|
||||
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<div class="generatepress-control-toggles">
|
||||
<# jQuery.each( data.targets, function( index, value ) { #>
|
||||
<button data-target="{{ index }}">{{ value }}</button>
|
||||
<# } ); #>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'GeneratePress_Copyright_Customize_Control' ) ) :
|
||||
/**
|
||||
* Class to create a custom tags control
|
||||
*/
|
||||
class GeneratePress_Copyright_Customize_Control extends WP_Customize_Control
|
||||
{
|
||||
public $type = 'gp-copyright';
|
||||
public $id = '';
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'gp-copyright-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/copyright-customizer.js', array( 'customize-controls' ), GP_PREMIUM_VERSION, true );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json[ 'link' ] = $this->get_link();
|
||||
$this->json[ 'value' ] = $this->value();
|
||||
$this->json[ 'id' ] = $this->id;
|
||||
$this->json[ 'current_year' ] = __( '<code>%current_year%</code> to update year automatically.', 'gp-premium' );
|
||||
$this->json[ 'copyright' ] = __( '<code>%copy%</code> to include the copyright symbol.', 'gp-premium' );
|
||||
$this->json[ 'html' ] = __( 'HTML is allowed.', 'gp-premium' );
|
||||
$this->json[ 'shortcodes' ] = __( 'Shortcodes are allowed.', 'gp-premium' );
|
||||
}
|
||||
/**
|
||||
* Render the control's content.
|
||||
*
|
||||
* Allows the content to be overriden without having to rewrite the wrapper.
|
||||
*
|
||||
* @since 10/16/2012
|
||||
* @return void
|
||||
*/
|
||||
public function content_template() {
|
||||
?>
|
||||
<label>
|
||||
<span class="customize-control-title">{{ data.label }}</span>
|
||||
<textarea id="{{ data.id }}" class="large-text gp-copyright-area" cols="20" rows="5" {{{ data.link }}}>{{{ data.value }}}</textarea>
|
||||
<small style="display:block;margin-bottom:5px;">{{{ data.current_year }}}</small>
|
||||
<small style="display:block;margin-bottom:5px;">{{{ data.copyright }}}</small>
|
||||
<small style="display:block;margin-bottom:5px;">{{{ data.html }}}</small>
|
||||
<small style="display:block;">{{{ data.shortcodes }}}</small>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
@ -0,0 +1,396 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Customize_Spacing_Slider_Control' ) ) :
|
||||
/**
|
||||
* Create our container width slider control
|
||||
* @deprecated 1.3
|
||||
*/
|
||||
class Generate_Customize_Spacing_Slider_Control extends WP_Customize_Control
|
||||
{
|
||||
// Setup control type
|
||||
public $type = 'gp-spacing-slider';
|
||||
public $id = '';
|
||||
public $default_value = '';
|
||||
public $unit = '';
|
||||
public $edit_field = true;
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json[ 'link' ] = $this->get_link();
|
||||
$this->json[ 'value' ] = $this->value();
|
||||
$this->json[ 'id' ] = $this->id;
|
||||
$this->json[ 'default_value' ] = $this->default_value;
|
||||
$this->json[ 'reset_title' ] = esc_attr__( 'Reset','generate-spacing' );
|
||||
$this->json[ 'unit' ] = $this->unit;
|
||||
$this->json[ 'edit_field' ] = $this->edit_field;
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<label>
|
||||
<p style="margin-bottom:0;">
|
||||
<span class="spacing-size-label customize-control-title">
|
||||
{{ data.label }}
|
||||
</span>
|
||||
<span class="value">
|
||||
<input <# if ( '' == data.unit || ! data.edit_field ) { #>style="display:none;"<# } #> name="{{ data.id }}" type="number" {{{ data.link }}} value="{{{ data.value }}}" class="slider-input" /><span <# if ( '' == data.unit || ! data.edit_field ) { #>style="display:none;"<# } #> class="px">{{ data.unit }}</span>
|
||||
<# if ( '' !== data.unit && ! data.edit_field ) { #><span class="no-edit-field"><span class="no-edit-value">{{ data.value }}</span>{{ data.unit }}</span><# } #>
|
||||
</span>
|
||||
</p>
|
||||
</label>
|
||||
<div class="slider gp-flat-slider <# if ( '' !== data.default_value ) { #>show-reset<# } #>"></div>
|
||||
<# if ( '' !== data.default_value ) { #><span style="cursor:pointer;" title="{{ data.reset_title }}" class="gp-spacing-slider-default-value" data-default-value="{{ data.default_value }}"><span class="gp-customizer-icon-undo" aria-hidden="true"></span><span class="screen-reader-text">{{ data.reset_title }}</span></span><# } #>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Function to enqueue the right jquery scripts and styles
|
||||
public function enqueue() {
|
||||
|
||||
wp_enqueue_script( 'gp-spacing-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/spacing-customizer.js', array( 'customize-controls' ), GENERATE_SPACING_VERSION, true );
|
||||
wp_enqueue_style( 'gp-spacing-customizer-controls-css', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/customizer.css', array(), GENERATE_SPACING_VERSION );
|
||||
|
||||
wp_enqueue_script( 'jquery-ui-core' );
|
||||
wp_enqueue_script( 'jquery-ui-slider' );
|
||||
|
||||
wp_enqueue_script( 'generate-spacing-slider-js', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/spacing-slider.js', array( 'jquery-ui-slider' ), GENERATE_SPACING_VERSION );
|
||||
|
||||
wp_enqueue_style('generate-ui-slider', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/jquery-ui.structure.css');
|
||||
wp_enqueue_style('generate-flat-slider', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/range-slider.css');
|
||||
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Spacing_Customize_Control' ) ) :
|
||||
/*
|
||||
* Add our control for our padding options
|
||||
* @deprecated 1.2.95
|
||||
*/
|
||||
class Generate_Spacing_Customize_Control extends WP_Customize_Control {
|
||||
public $type = 'spacing';
|
||||
public $description = '';
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'gp-spacing-customizer', plugin_dir_url( __FILE__ ) . 'js/spacing-customizer.js', array( 'customize-controls' ), GENERATE_SPACING_VERSION, true );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json[ 'link' ] = $this->get_link();
|
||||
$this->json[ 'value' ] = absint( $this->value() );
|
||||
$this->json[ 'description' ] = esc_html( $this->description );
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<label>
|
||||
<# if ( data.label ) { #>
|
||||
<span class="customize-control-title">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<input class="generate-number-control" type="number" style="text-align: center;" {{{ data.link }}} value="{{{ data.value }}}" />
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="description" style="font-style:normal;">{{ data.description }}</span>
|
||||
<# } #>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Spacing_Customize_Misc_Control' ) ) :
|
||||
/*
|
||||
* Add a class to display headings
|
||||
* @deprecated 1.2.95
|
||||
*/
|
||||
class Generate_Spacing_Customize_Misc_Control extends WP_Customize_Control {
|
||||
public $settings = 'generate_spacing_headings';
|
||||
public $description = '';
|
||||
public $areas = '';
|
||||
|
||||
public function render_content() {
|
||||
switch ( $this->type ) {
|
||||
default:
|
||||
case 'text' : ?>
|
||||
<label>
|
||||
<span class="customize-control-title"><?php echo $this->description;?></span>
|
||||
</label>
|
||||
<?php break;
|
||||
|
||||
case 'spacing-heading':
|
||||
if ( ! empty( $this->label ) ) echo '<span class="customize-control-title spacing-title">' . esc_html( $this->label ) . '</span>';
|
||||
if ( ! empty( $this->description ) ) echo '<span class="spacing-title-description">' . esc_html( $this->description ) . '</span>';
|
||||
if ( ! empty( $this->areas ) ) :
|
||||
echo '<div style="clear:both;display:block;"></div>';
|
||||
foreach ( $this->areas as $value => $label ) :
|
||||
echo '<span class="spacing-area">' . esc_html( $label ) . '</span>';
|
||||
endforeach;
|
||||
endif;
|
||||
break;
|
||||
|
||||
case 'line' :
|
||||
echo '<hr />';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Backgrounds_Customize_Control' ) ) :
|
||||
/*
|
||||
* @deprecated 1.3
|
||||
*/
|
||||
class Generate_Backgrounds_Customize_Control extends WP_Customize_Control {
|
||||
public function render() {}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Backgrounds_Customize_Misc_Control' ) ) :
|
||||
/*
|
||||
* No longer used
|
||||
* Kept for back compat purposes
|
||||
* @deprecated 1.2.95
|
||||
*/
|
||||
class Generate_Backgrounds_Customize_Misc_Control extends WP_Customize_Control {
|
||||
public function render() {}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Blog_Customize_Control' ) ) :
|
||||
/**
|
||||
* Add our number input field for the featured image width
|
||||
* @deprecated 1.3
|
||||
*/
|
||||
class Generate_Blog_Customize_Control extends WP_Customize_Control {
|
||||
public $type = 'gp-post-image-size';
|
||||
public $placeholder = '';
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'gp-blog-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/blog-customizer.js', array( 'customize-controls' ), GENERATE_BLOG_VERSION, true );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json[ 'link' ] = $this->get_link();
|
||||
$this->json[ 'value' ] = $this->value();
|
||||
$this->json[ 'placeholder' ] = $this->placeholder;
|
||||
}
|
||||
public function content_template() {
|
||||
?>
|
||||
<label>
|
||||
<span class="customize-control-title">{{{ data.label }}}</span>
|
||||
<input class="blog-size-input" placeholder="{{{ data.placeholder }}}" style="max-width:75px;text-align:center;" type="number" {{{ data.link }}} value="{{ data.value }}" />px
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Blog_Number_Customize_Control' ) ) :
|
||||
/**
|
||||
* Add a regular number input control
|
||||
* @deprecated 1.3
|
||||
*/
|
||||
class Generate_Blog_Number_Customize_Control extends WP_Customize_Control {
|
||||
public $type = 'gp-blog-number';
|
||||
public $placeholder = '';
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'gp-blog-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/blog-customizer.js', array( 'customize-controls' ), GENERATE_BLOG_VERSION, true );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json[ 'link' ] = $this->get_link();
|
||||
$this->json[ 'value' ] = $this->value();
|
||||
$this->json[ 'placeholder' ] = $this->placeholder;
|
||||
}
|
||||
public function content_template() {
|
||||
?>
|
||||
<label>
|
||||
<span class="customize-control-title">{{{ data.label }}}</span>
|
||||
<input class="blog-size-input" placeholder="{{{ data.placeholder }}}" type="number" {{{ data.link }}} value="{{ data.value }}" />
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Post_Image_Save' ) ) :
|
||||
/**
|
||||
* Add a button to initiate refresh when changing featured image sizes
|
||||
* @deprecated 1.3
|
||||
*/
|
||||
class Generate_Post_Image_Save extends WP_Customize_Control {
|
||||
public function render() {}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Blog_Text_Control' ) ) :
|
||||
/**
|
||||
* Add a control to display simple text
|
||||
* @deprecated 1.3
|
||||
*/
|
||||
class Generate_Blog_Text_Control extends WP_Customize_Control {
|
||||
public function render() {}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! class_exists( 'Generate_Customize_Alpha_Color_Control' ) ) :
|
||||
/**
|
||||
* @deprecated 1.3
|
||||
*/
|
||||
class Generate_Customize_Alpha_Color_Control extends WP_Customize_Control {
|
||||
public function render() {}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! class_exists( 'Generate_Copyright_Textarea_Custom_Control' ) ) :
|
||||
/**
|
||||
* Class to create a custom tags control
|
||||
* @deprecated 1.3
|
||||
*/
|
||||
class Generate_Copyright_Textarea_Custom_Control extends WP_Customize_Control {
|
||||
public function render() {}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Generate_Blog_Page_Header_Image_Save' ) ) :
|
||||
/**
|
||||
* Add a control without a button to refresh the frame
|
||||
* This kicks in our image dimension settings
|
||||
*
|
||||
* @deprecated 1.3
|
||||
*/
|
||||
class Generate_Blog_Page_Header_Image_Save extends WP_Customize_Control {
|
||||
public $type = 'page_header_image_save';
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json[ 'text' ] = __( 'Apply image sizes','page-header' );
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<a class="button save-post-images" onclick="wp.customize.previewer.refresh();" href="#">{{{ data.text }}}</a>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! class_exists( 'Generate_Hidden_Input_Control' ) ) :
|
||||
/**
|
||||
* Create our hidden input control
|
||||
* @deprecated 1.3
|
||||
*/
|
||||
class Generate_Hidden_Input_Control extends WP_Customize_Control
|
||||
{
|
||||
// Setup control type
|
||||
public $type = 'gp-hidden-input';
|
||||
public $id = '';
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json[ 'link' ] = $this->get_link();
|
||||
$this->json[ 'value' ] = $this->value();
|
||||
$this->json[ 'id' ] = $this->id;
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<input name="{{ data.id }}" type="text" {{{ data.link }}} value="{{{ data.value }}}" class="gp-hidden-input" />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! class_exists( 'Generate_Text_Transform_Custom_Control' ) ) :
|
||||
/**
|
||||
* A class to create a dropdown for text-transform
|
||||
* @deprecated 1.3
|
||||
*/
|
||||
class Generate_Text_Transform_Custom_Control extends WP_Customize_Control
|
||||
{
|
||||
public function __construct($manager, $id, $args = array(), $options = array())
|
||||
{
|
||||
parent::__construct( $manager, $id, $args );
|
||||
}
|
||||
/**
|
||||
* Render the content of the category dropdown
|
||||
*
|
||||
* @return HTML
|
||||
*/
|
||||
public function render_content()
|
||||
{
|
||||
?>
|
||||
<label>
|
||||
<select <?php $this->link(); ?>>
|
||||
<?php
|
||||
printf('<option value="%s" %s>%s</option>', 'none', selected($this->value(), 'none', false), 'none');
|
||||
printf('<option value="%s" %s>%s</option>', 'capitalize', selected($this->value(), 'capitalize', false), 'capitalize');
|
||||
printf('<option value="%s" %s>%s</option>', 'uppercase', selected($this->value(), 'uppercase', false), 'uppercase');
|
||||
printf('<option value="%s" %s>%s</option>', 'lowercase', selected($this->value(), 'lowercase', false), 'lowercase');
|
||||
?>
|
||||
</select>
|
||||
<p class="description"><?php echo esc_html( $this->label ); ?></p>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! class_exists( 'Generate_Font_Weight_Custom_Control' ) ) :
|
||||
/**
|
||||
* A class to create a dropdown for font weight
|
||||
* @deprecated 1.3
|
||||
*/
|
||||
class Generate_Font_Weight_Custom_Control extends WP_Customize_Control
|
||||
{
|
||||
public function __construct($manager, $id, $args = array(), $options = array())
|
||||
{
|
||||
parent::__construct( $manager, $id, $args );
|
||||
}
|
||||
/**
|
||||
* Render the content of the category dropdown
|
||||
*
|
||||
* @return HTML
|
||||
*/
|
||||
public function render_content()
|
||||
{
|
||||
?>
|
||||
<label>
|
||||
<select <?php $this->link(); ?>>
|
||||
<?php
|
||||
printf('<option value="%s" %s>%s</option>', 'normal', selected($this->value(), 'normal', false), 'normal');
|
||||
printf('<option value="%s" %s>%s</option>', 'bold', selected($this->value(), 'bold', false), 'bold');
|
||||
printf('<option value="%s" %s>%s</option>', '100', selected($this->value(), '100', false), '100');
|
||||
printf('<option value="%s" %s>%s</option>', '200', selected($this->value(), '200', false), '200');
|
||||
printf('<option value="%s" %s>%s</option>', '300', selected($this->value(), '300', false), '300');
|
||||
printf('<option value="%s" %s>%s</option>', '400', selected($this->value(), '400', false), '400');
|
||||
printf('<option value="%s" %s>%s</option>', '500', selected($this->value(), '500', false), '500');
|
||||
printf('<option value="%s" %s>%s</option>', '600', selected($this->value(), '600', false), '600');
|
||||
printf('<option value="%s" %s>%s</option>', '700', selected($this->value(), '700', false), '700');
|
||||
printf('<option value="%s" %s>%s</option>', '800', selected($this->value(), '800', false), '800');
|
||||
printf('<option value="%s" %s>%s</option>', '900', selected($this->value(), '900', false), '900');
|
||||
?>
|
||||
</select>
|
||||
<p class="description"><?php echo esc_html( $this->label ); ?></p>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'GeneratePress_Backgrounds_Customize_Control' ) ) :
|
||||
/**
|
||||
* @deprecated 1.4
|
||||
*/
|
||||
class GeneratePress_Backgrounds_Customize_Control extends WP_Customize_Control {
|
||||
public function render() {}
|
||||
}
|
||||
endif;
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'GeneratePress_Information_Customize_Control' ) ) :
|
||||
/**
|
||||
* Add a control to display simple text
|
||||
*/
|
||||
class GeneratePress_Information_Customize_Control extends WP_Customize_Control {
|
||||
public $type = 'gp_information_control';
|
||||
|
||||
public $description = '';
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json[ 'description' ] = $this->description;
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<# if ( data.label ) { #>
|
||||
<span class="customize-control-title">{{ data.label }}</span>
|
||||
<# } #>
|
||||
<# if ( data.description ) { #>
|
||||
<p>{{{ data.description }}}</p>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
@ -0,0 +1,165 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! function_exists( 'GeneratePress_Pro_Range_Slider_Control' ) ) :
|
||||
class GeneratePress_Pro_Range_Slider_Control extends WP_Customize_Control {
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'generatepress-pro-range-slider';
|
||||
|
||||
public $description = '';
|
||||
|
||||
public $sub_description = '';
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @see WP_Customize_Control::to_json()
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$devices = array( 'desktop','tablet','mobile' );
|
||||
foreach ( $devices as $device ) {
|
||||
$this->json['choices'][$device]['min'] = ( isset( $this->choices[$device]['min'] ) ) ? $this->choices[$device]['min'] : '0';
|
||||
$this->json['choices'][$device]['max'] = ( isset( $this->choices[$device]['max'] ) ) ? $this->choices[$device]['max'] : '100';
|
||||
$this->json['choices'][$device]['step'] = ( isset( $this->choices[$device]['step'] ) ) ? $this->choices[$device]['step'] : '1';
|
||||
$this->json['choices'][$device]['edit'] = ( isset( $this->choices[$device]['edit'] ) ) ? $this->choices[$device]['edit'] : false;
|
||||
$this->json['choices'][$device]['unit'] = ( isset( $this->choices[$device]['unit'] ) ) ? $this->choices[$device]['unit'] : false;
|
||||
}
|
||||
|
||||
foreach ( $this->settings as $setting_key => $setting_id ) {
|
||||
$this->json[ $setting_key ] = array(
|
||||
'link' => $this->get_link( $setting_key ),
|
||||
'value' => $this->value( $setting_key ),
|
||||
'default' => isset( $setting_id->default ) ? $setting_id->default : '',
|
||||
);
|
||||
}
|
||||
|
||||
$this->json['desktop_label'] = __( 'Desktop', 'gp-premium' );
|
||||
$this->json['tablet_label'] = __( 'Tablet', 'gp-premium' );
|
||||
$this->json['mobile_label'] = __( 'Mobile', 'gp-premium' );
|
||||
$this->json['reset_label'] = __( 'Reset', 'gp-premium' );
|
||||
|
||||
$this->json['description'] = $this->description;
|
||||
$this->json['sub_description'] = $this->sub_description;
|
||||
}
|
||||
/**
|
||||
* Enqueue control related scripts/styles.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'generatepress-pro-range-slider', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/slider-customizer.js', array( 'jquery', 'customize-base', 'jquery-ui-slider' ), GP_PREMIUM_VERSION, true );
|
||||
wp_enqueue_style( 'generatepress-pro-range-slider-css', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/slider-customizer.css', GP_PREMIUM_VERSION );
|
||||
}
|
||||
/**
|
||||
* An Underscore (JS) template for this control's content (but not its container).
|
||||
*
|
||||
* Class variables for this control class are available in the `data` JS object;
|
||||
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
|
||||
*
|
||||
* @see WP_Customize_Control::print_template()
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function content_template() {
|
||||
?>
|
||||
<div class="generatepress-range-slider-control">
|
||||
<div class="gp-range-title-area">
|
||||
<# if ( data.label || data.description ) { #>
|
||||
<div class="gp-range-title-info">
|
||||
<# if ( data.label ) { #>
|
||||
<span class="customize-control-title">{{{ data.label }}}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<p class="description">{{{ data.description }}}</p>
|
||||
<# } #>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<div class="gp-range-slider-controls">
|
||||
<span class="gp-device-controls">
|
||||
<# if ( 'undefined' !== typeof ( data.desktop ) ) { #>
|
||||
<span class="generatepress-device-desktop dashicons dashicons-desktop" data-option="desktop" title="{{ data.desktop_label }}"></span>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof (data.tablet) ) { #>
|
||||
<span class="generatepress-device-tablet dashicons dashicons-tablet" data-option="tablet" title="{{ data.tablet_label }}"></span>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof (data.mobile) ) { #>
|
||||
<span class="generatepress-device-mobile dashicons dashicons-smartphone" data-option="mobile" title="{{ data.mobile_label }}"></span>
|
||||
<# } #>
|
||||
</span>
|
||||
|
||||
<span title="{{ data.reset_label }}" class="generatepress-reset dashicons dashicons-image-rotate"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gp-range-slider-areas">
|
||||
<# if ( 'undefined' !== typeof ( data.desktop ) ) { #>
|
||||
<label class="range-option-area" data-option="desktop" style="display: none;">
|
||||
<div class="wrapper <# if ( '' !== data.choices['desktop']['unit'] ) { #>has-unit<# } #>">
|
||||
<div class="generatepress-slider" data-step="{{ data.choices['desktop']['step'] }}" data-min="{{ data.choices['desktop']['min'] }}" data-max="{{ data.choices['desktop']['max'] }}"></div>
|
||||
|
||||
<div class="gp_range_value <# if ( '' == data.choices['desktop']['unit'] && ! data.choices['desktop']['edit'] ) { #>hide-value<# } #>">
|
||||
<input <# if ( data.choices['desktop']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> type="number" step="{{ data.choices['desktop']['step'] }}" class="desktop-range value" value="{{ data.desktop.value }}" min="{{ data.choices['desktop']['min'] }}" max="{{ data.choices['desktop']['max'] }}" {{{ data.desktop.link }}} data-reset_value="{{ data.desktop.default }}" />
|
||||
<span <# if ( ! data.choices['desktop']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> class="value">{{ data.desktop.value }}</span>
|
||||
|
||||
<# if ( data.choices['desktop']['unit'] ) { #>
|
||||
<span class="unit">{{ data.choices['desktop']['unit'] }}</span>
|
||||
<# } #>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.tablet ) ) { #>
|
||||
<label class="range-option-area" data-option="tablet" style="display:none">
|
||||
<div class="wrapper <# if ( '' !== data.choices['tablet']['unit'] ) { #>has-unit<# } #>">
|
||||
<div class="generatepress-slider" data-step="{{ data.choices['tablet']['step'] }}" data-min="{{ data.choices['tablet']['min'] }}" data-max="{{ data.choices['tablet']['max'] }}"></div>
|
||||
|
||||
<div class="gp_range_value <# if ( '' == data.choices['tablet']['unit'] && ! data.choices['desktop']['edit'] ) { #>hide-value<# } #>">
|
||||
<input <# if ( data.choices['tablet']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> type="number" step="{{ data.choices['tablet']['step'] }}" class="tablet-range value" value="{{ data.tablet.value }}" min="{{ data.choices['tablet']['min'] }}" max="{{ data.choices['tablet']['max'] }}" {{{ data.tablet.link }}} data-reset_value="{{ data.tablet.default }}" />
|
||||
<span <# if ( ! data.choices['tablet']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> class="value">{{ data.tablet.value }}</span>
|
||||
|
||||
<# if ( data.choices['tablet']['unit'] ) { #>
|
||||
<span class="unit">{{ data.choices['tablet']['unit'] }}</span>
|
||||
<# } #>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.mobile ) ) { #>
|
||||
<label class="range-option-area" data-option="mobile" style="display:none;">
|
||||
<div class="wrapper <# if ( '' !== data.choices['mobile']['unit'] ) { #>has-unit<# } #>">
|
||||
<div class="generatepress-slider" data-step="{{ data.choices['mobile']['step'] }}" data-min="{{ data.choices['mobile']['min'] }}" data-max="{{ data.choices['mobile']['max'] }}"></div>
|
||||
|
||||
<div class="gp_range_value <# if ( '' == data.choices['mobile']['unit'] && ! data.choices['desktop']['edit'] ) { #>hide-value<# } #>">
|
||||
<input <# if ( data.choices['mobile']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> type="number" step="{{ data.choices['mobile']['step'] }}" class="mobile-range value" value="{{ data.mobile.value }}" min="{{ data.choices['mobile']['min'] }}" max="{{ data.choices['mobile']['max'] }}" {{{ data.mobile.link }}} data-reset_value="{{ data.mobile.default }}" />
|
||||
<span <# if ( ! data.choices['mobile']['edit'] ) { #>style="display:inline-block;"<# } else { #>style="display:none;"<# } #> class="value">{{ data.mobile.value }}</span>
|
||||
|
||||
<# if ( data.choices['mobile']['unit'] ) { #>
|
||||
<span class="unit">{{ data.choices['mobile']['unit'] }}</span>
|
||||
<# } #>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<# if ( data.sub_description ) { #>
|
||||
<p class="description sub-description">{{{ data.sub_description }}}</p>
|
||||
<# } #>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'GeneratePress_Refresh_Button_Customize_Control' ) ) :
|
||||
/**
|
||||
* Add a button to initiate refresh when changing featured image sizes
|
||||
*/
|
||||
class GeneratePress_Refresh_Button_Customize_Control extends WP_Customize_Control {
|
||||
public $type = 'refresh_button';
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<a class="button" onclick="wp.customize.previewer.refresh();" href="#">{{{ data.label }}}</a>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WP_Customize_Control' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a button which needs javascript attached to it.
|
||||
*/
|
||||
class GeneratePress_Section_Shortcut_Control extends WP_Customize_Control {
|
||||
public $type = 'gp_section_shortcut';
|
||||
public $element = '';
|
||||
public $shortcuts = array();
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'gp-section-shortcuts', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/section-shortcuts.js', array( 'customize-controls' ), GP_PREMIUM_VERSION, true );
|
||||
wp_enqueue_style( 'gp-section-shortcuts', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/section-shortcuts.css', false, GP_PREMIUM_VERSION );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$shortcuts = array();
|
||||
foreach( $this->shortcuts as $name => $id ) {
|
||||
if ( 'colors' === $name ) {
|
||||
$name = esc_html__( 'Colors', 'gp-premium' );
|
||||
|
||||
if ( ! generatepress_is_module_active( 'generate_package_colors', 'GENERATE_COLORS' ) ) {
|
||||
$id = false;
|
||||
$name = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'typography' === $name ) {
|
||||
$name = esc_html__( 'Typography', 'gp-premium' );
|
||||
|
||||
if ( ! generatepress_is_module_active( 'generate_package_typography', 'GENERATE_TYPOGRAPHY' ) ) {
|
||||
$id = false;
|
||||
$name = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'backgrounds' === $name ) {
|
||||
$name = esc_html__( 'Backgrounds', 'gp-premium' );
|
||||
|
||||
if ( ! generatepress_is_module_active( 'generate_package_backgrounds', 'GENERATE_BACKGROUNDS' ) ) {
|
||||
$id = false;
|
||||
$name = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'layout' === $name ) {
|
||||
$name = esc_html__( 'Layout', 'gp-premium' );
|
||||
}
|
||||
|
||||
if ( $id && $name ) {
|
||||
$shortcuts[ $id ] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $shortcuts ) ) {
|
||||
$this->json['shortcuts'] = $shortcuts;
|
||||
} else {
|
||||
$this->json['shortcuts'] = false;
|
||||
}
|
||||
|
||||
if ( 'WooCommerce' !== $this->element ) {
|
||||
$this->element = strtolower( $this->element );
|
||||
}
|
||||
|
||||
$this->json['more'] = sprintf(
|
||||
__( 'More %s controls:', 'gp-premium' ),
|
||||
'<span class="more-element">' . $this->element . '</span>'
|
||||
);
|
||||
|
||||
$this->json['return'] = __( 'Go Back', 'gp-premium' );
|
||||
|
||||
$this->json['section'] = $this->section;
|
||||
|
||||
if ( apply_filters( 'generate_disable_customizer_shortcuts', false ) ) {
|
||||
$this->json['shortcuts'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<# if ( data.shortcuts ) { #>
|
||||
<div class="generatepress-shortcuts">
|
||||
<div class="show-shortcuts">
|
||||
<span class="more-controls">
|
||||
{{{ data.more }}}
|
||||
</span>
|
||||
|
||||
<span class="shortcuts">
|
||||
<# _.each( data.shortcuts, function( label, section ) { #>
|
||||
<span class="shortcut">
|
||||
<a href="#" data-section="{{{ section }}}" data-current-section="{{{ data.section }}}">{{{ label }}}</a>
|
||||
</span>
|
||||
<# } ) #>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="return-shortcut" style="display: none;">
|
||||
<span class="dashicons dashicons-no-alt"></span>
|
||||
<a href="#">← {{{ data.return }}}</a>
|
||||
</div>
|
||||
</div>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'GeneratePress_Spacing_Control' ) ) :
|
||||
class GeneratePress_Spacing_Control extends WP_Customize_Control {
|
||||
|
||||
public $type = 'generatepress-spacing';
|
||||
|
||||
public $l10n = array();
|
||||
|
||||
public $element = '';
|
||||
|
||||
public function __construct( $manager, $id, $args = array() ) {
|
||||
// Let the parent class do its thing.
|
||||
parent::__construct( $manager, $id, $args );
|
||||
}
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'gp-spacing-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/spacing-customizer.js', array( 'customize-controls' ), GP_PREMIUM_VERSION, true );
|
||||
wp_enqueue_style( 'gp-spacing-customizer-controls-css', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/spacing-customizer.css', array(), GP_PREMIUM_VERSION );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
// Loop through each of the settings and set up the data for it.
|
||||
foreach ( $this->settings as $setting_key => $setting_id ) {
|
||||
$this->json[ $setting_key ] = array(
|
||||
'link' => $this->get_link( $setting_key ),
|
||||
'value' => $this->value( $setting_key )
|
||||
);
|
||||
}
|
||||
|
||||
$this->json[ 'element' ] = $this->element;
|
||||
$this->json[ 'title' ] = __( 'Link values','generate-spacing' );
|
||||
$this->json[ 'unlink_title' ] = __( 'Un-link values','generate-spacing' );
|
||||
|
||||
$this->json['label_top'] = esc_html__( 'Top', 'gp-premium' );
|
||||
$this->json['label_right'] = esc_html__( 'Right', 'gp-premium' );
|
||||
$this->json['label_bottom'] = esc_html__( 'Bottom', 'gp-premium' );
|
||||
$this->json['label_left'] = esc_html__( 'Left', 'gp-premium' );
|
||||
$this->json['desktop_label'] = esc_html__( 'Desktop', 'gp-premium' );
|
||||
$this->json['tablet_label'] = esc_html__( 'Tablet', 'gp-premium' );
|
||||
$this->json['mobile_label'] = esc_html__( 'Mobile', 'gp-premium' );
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<div class="gp-spacing-control-section">
|
||||
<div class="gp-spacing-control-section-title-area">
|
||||
<# if ( data.label || data.description ) { #>
|
||||
<div class="gp-spacing-control-title-info">
|
||||
<# if ( data.label ) { #>
|
||||
<label for="{{{ data.element }}}-{{{ data.top_label }}}">
|
||||
<span class="customize-control-title">{{ data.label }}</span>
|
||||
</label>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="description customize-control-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<div class="gp-range-slider-controls">
|
||||
<span class="gp-device-controls">
|
||||
<# if ( 'undefined' !== typeof ( data.desktop_top ) ) { #>
|
||||
<span class="generatepress-device-desktop dashicons dashicons-desktop" data-option="desktop" title="{{ data.desktop_label }}"></span>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof (data.tablet_top) ) { #>
|
||||
<span class="generatepress-device-tablet dashicons dashicons-tablet" data-option="tablet" title="{{ data.tablet_label }}"></span>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof (data.mobile_top) ) { #>
|
||||
<span class="generatepress-device-mobile dashicons dashicons-smartphone" data-option="mobile" title="{{ data.mobile_label }}"></span>
|
||||
<# } #>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="spacing-values-container">
|
||||
<div class="spacing-values-desktop spacing-values-area" data-option="desktop" style="display: none;">
|
||||
<div class="gp-spacing-section">
|
||||
<input id="{{{ data.element }}}-{{{ data.label_top }}}" min="0" class="generate-number-control spacing-top" type="number" style="text-align: center;" {{{ data.desktop_top.link }}} value="{{{ data.desktop_top.value }}}" />
|
||||
<# if ( data.label_top ) { #>
|
||||
<label for="{{{ data.element }}}-{{{ data.label_top }}}" class="description" style="font-style:normal;">{{ data.label_top }}</label>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<div class="gp-spacing-section">
|
||||
<input id="{{{ data.element }}}-{{{ data.label_right }}}" min="0" class="generate-number-control spacing-right" type="number" style="text-align: center;" {{{ data.desktop_right.link }}} value="{{{ data.desktop_right.value }}}" />
|
||||
<# if ( data.label_right ) { #>
|
||||
<label for="{{{ data.element }}}-{{{ data.label_right }}}" class="description" style="font-style:normal;">{{ data.label_right }}</label>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<div class="gp-spacing-section">
|
||||
<input id="{{{ data.element }}}-{{{ data.label_bottom }}}" min="0" class="generate-number-control spacing-bottom" type="number" style="text-align: center;" {{{ data.desktop_bottom.link }}} value="{{{ data.desktop_bottom.value }}}" />
|
||||
<# if ( data.label_bottom ) { #>
|
||||
<label for="{{{ data.element }}}-{{{ data.label_bottom }}}" class="description" style="font-style:normal;">{{ data.label_bottom }}</label>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<div class="gp-spacing-section">
|
||||
<input id="{{{ data.element }}}-{{{ data.label_left }}}" min="0" class="generate-number-control spacing-left" type="number" style="text-align: center;" {{{ data.desktop_left.link }}} value="{{{ data.desktop_left.value }}}" />
|
||||
<# if ( data.label_left ) { #>
|
||||
<label for="{{{ data.element }}}-{{{ data.label_left }}}" class="description" style="font-style:normal;">{{ data.label_left }}</label>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<# if ( data.element ) { #>
|
||||
<div class="gp-spacing-section gp-link-spacing-section">
|
||||
<span class="dashicons dashicons-editor-unlink gp-link-spacing" data-element="{{ data.element }}" title="{{ data.title }}"></span>
|
||||
<span class="dashicons dashicons-admin-links gp-unlink-spacing" style="display:none" data-element="{{ data.element }}" title="{{ data.unlink_title }}"></span>
|
||||
</div>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.mobile_top ) ) { #>
|
||||
<div class="spacing-values-mobile spacing-values-area" data-option="mobile" style="display: none;">
|
||||
<div class="gp-spacing-section">
|
||||
<input id="{{{ data.element }}}-mobile-{{{ data.label_top }}}" min="0" class="generate-number-control mobile-spacing-top" type="number" style="text-align: center;" {{{ data.mobile_top.link }}} value="{{{ data.mobile_top.value }}}" />
|
||||
<# if ( data.label_top ) { #>
|
||||
<label for="{{{ data.element }}}-mobile-{{{ data.label_top }}}" class="description" style="font-style:normal;">{{ data.label_top }}</label>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<div class="gp-spacing-section">
|
||||
<input id="{{{ data.element }}}-mobile-{{{ data.label_right }}}" min="0" class="generate-number-control mobile-spacing-right" type="number" style="text-align: center;" {{{ data.mobile_right.link }}} value="{{{ data.mobile_right.value }}}" />
|
||||
<# if ( data.label_right ) { #>
|
||||
<label for="{{{ data.element }}}-mobile-{{{ data.label_right }}}" class="description" style="font-style:normal;">{{ data.label_right }}</label>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<div class="gp-spacing-section">
|
||||
<input id="{{{ data.element }}}-mobile-{{{ data.label_bottom }}}" min="0" class="generate-number-control mobile-spacing-bottom" type="number" style="text-align: center;" {{{ data.mobile_bottom.link }}} value="{{{ data.mobile_bottom.value }}}" />
|
||||
<# if ( data.label_bottom ) { #>
|
||||
<label for="{{{ data.element }}}-mobile-{{{ data.label_bottom }}}" class="description" style="font-style:normal;">{{ data.label_bottom }}</label>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<div class="gp-spacing-section">
|
||||
<input id="{{{ data.element }}}-mobile-{{{ data.label_left }}}" min="0" class="generate-number-control mobile-spacing-left" type="number" style="text-align: center;" {{{ data.mobile_left.link }}} value="{{{ data.mobile_left.value }}}" />
|
||||
<# if ( data.label_left ) { #>
|
||||
<label for="{{{ data.element }}}-mobile-{{{ data.label_left }}}" class="description" style="font-style:normal;">{{ data.label_left }}</label>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<# if ( data.element ) { #>
|
||||
<div class="gp-spacing-section gp-link-spacing-section">
|
||||
<span class="dashicons dashicons-editor-unlink gp-link-spacing" data-element="{{ data.element }}" title="{{ data.title }}"></span>
|
||||
<span class="dashicons dashicons-admin-links gp-unlink-spacing" style="display:none" data-element="{{ data.element }}" title="{{ data.unlink_title }}"></span>
|
||||
</div>
|
||||
<# } #>
|
||||
</div>
|
||||
<# } #>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'GeneratePress_Title_Customize_Control' ) ) :
|
||||
/**
|
||||
* Create a control to display titles within our sections
|
||||
*/
|
||||
class GeneratePress_Title_Customize_Control extends WP_Customize_Control {
|
||||
public $type = 'generatepress-customizer-title';
|
||||
public $title = '';
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_style( 'generatepress-title-customize-control', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/title-customizer.css', array(), GP_PREMIUM_VERSION );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json[ 'title' ] = esc_html( $this->title );
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<div class="generatepress-customizer-title">
|
||||
<span>{{ data.title }}</span>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
endif;
|
@ -0,0 +1,187 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'GeneratePress_Pro_Typography_Customize_Control' ) ) :
|
||||
class GeneratePress_Pro_Typography_Customize_Control extends WP_Customize_Control
|
||||
{
|
||||
public $type = 'gp-pro-customizer-typography';
|
||||
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'generatepress-pro-typography-selectWoo', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/selectWoo.min.js', array( 'customize-controls', 'jquery' ), GP_PREMIUM_VERSION, true );
|
||||
wp_enqueue_style( 'generatepress-pro-typography-selectWoo', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/selectWoo.min.css', array(), GP_PREMIUM_VERSION );
|
||||
|
||||
wp_enqueue_script( 'generatepress-pro-typography-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/typography-customizer.js', array( 'customize-controls', 'generatepress-pro-typography-selectWoo' ), GP_PREMIUM_VERSION, true );
|
||||
|
||||
wp_enqueue_style( 'generatepress-pro-typography-customizer', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/typography-customizer.css', array(), GP_PREMIUM_VERSION );
|
||||
}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$this->json[ 'default_fonts_title'] = __( 'System Fonts', 'gp-premium' );
|
||||
$this->json[ 'google_fonts_title'] = __( 'Google Fonts', 'gp-premium' );
|
||||
$this->json[ 'default_fonts' ] = generate_typography_default_fonts();
|
||||
$this->json[ 'family_title' ] = esc_html__( 'Font family', 'gp-premium' );
|
||||
$this->json[ 'weight_title' ] = esc_html__( 'Font weight', 'gp-premium' );
|
||||
$this->json[ 'transform_title' ] = esc_html__( 'Text transform', 'gp-premium' );
|
||||
$this->json[ 'category_title' ] = '';
|
||||
$this->json[ 'variant_title' ] = esc_html__( 'Variants', 'gp-premium' );
|
||||
|
||||
foreach ( $this->settings as $setting_key => $setting_id ) {
|
||||
$this->json[ $setting_key ] = array(
|
||||
'link' => $this->get_link( $setting_key ),
|
||||
'value' => $this->value( $setting_key ),
|
||||
'default' => isset( $setting_id->default ) ? $setting_id->default : '',
|
||||
'id' => isset( $setting_id->id ) ? $setting_id->id : ''
|
||||
);
|
||||
|
||||
if ( 'weight' === $setting_key ) {
|
||||
$this->json[ $setting_key ]['choices'] = $this->get_font_weight_choices();
|
||||
}
|
||||
|
||||
if ( 'transform' === $setting_key ) {
|
||||
$this->json[ $setting_key ]['choices'] = $this->get_font_transform_choices();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
?>
|
||||
<# if ( '' !== data.label ) { #>
|
||||
<span class="customize-control-title">{{ data.label }}</span>
|
||||
<# } #>
|
||||
<# if ( 'undefined' !== typeof ( data.family ) ) { #>
|
||||
<div class="generatepress-font-family">
|
||||
<label>
|
||||
<select {{{ data.family.link }}} data-category="{{{ data.category.id }}}" data-variants="{{{ data.variant.id }}}" style="width:100%;">
|
||||
<optgroup label="{{ data.default_fonts_title }}">
|
||||
<# for ( var key in data.default_fonts ) { #>
|
||||
<# var name = data.default_fonts[ key ].split(',')[0]; #>
|
||||
<option value="{{ data.default_fonts[ key ] }}" <# if ( data.default_fonts[ key ] === data.family.value ) { #>selected="selected"<# } #>>{{ name }}</option>
|
||||
<# } #>
|
||||
</optgroup>
|
||||
<optgroup label="{{ data.google_fonts_title }}">
|
||||
<# for ( var key in generatePressTypography.googleFonts ) { #>
|
||||
<option value="{{ generatePressTypography.googleFonts[ key ].name }}" <# if ( generatePressTypography.googleFonts[ key ].name === data.family.value ) { #>selected="selected"<# } #>>{{ generatePressTypography.googleFonts[ key ].name }}</option>
|
||||
<# } #>
|
||||
</optgroup>
|
||||
</select>
|
||||
<# if ( '' !== data.family_title ) { #>
|
||||
<p class="description">{{ data.family_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.variant ) ) { #>
|
||||
<#
|
||||
var id = data.family.value.split(' ').join('_').toLowerCase();
|
||||
var font_data = generatePressTypography.googleFonts[id];
|
||||
var variants = '';
|
||||
if ( typeof font_data !== 'undefined' ) {
|
||||
variants = font_data.variants;
|
||||
}
|
||||
|
||||
if ( null === data.variant.value ) {
|
||||
data.variant.value = data.variant.default;
|
||||
}
|
||||
#>
|
||||
<div id={{{ data.variant.id }}}" class="generatepress-font-variant" data-saved-value="{{ data.variant.value }}">
|
||||
<label>
|
||||
<select name="{{{ data.variant.id }}}" multiple class="typography-multi-select" style="width:100%;" {{{ data.variant.link }}}>
|
||||
<# _.each( variants, function( label, choice ) { #>
|
||||
<option value="{{ label }}">{{ label }}</option>
|
||||
<# } ) #>
|
||||
</select>
|
||||
|
||||
<# if ( '' !== data.variant_title ) { #>
|
||||
<p class="description">{{ data.variant_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.category ) ) { #>
|
||||
<div class="generatepress-font-category">
|
||||
<label>
|
||||
<input name="{{{ data.category.id }}}" type="hidden" {{{ data.category.link }}} value="{{{ data.category.value }}}" class="gp-hidden-input" />
|
||||
<# if ( '' !== data.category_title ) { #>
|
||||
<p class="description">{{ data.category_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<div class="generatepress-weight-transform-wrapper">
|
||||
<# if ( 'undefined' !== typeof ( data.weight ) ) { #>
|
||||
<div class="generatepress-font-weight">
|
||||
<label>
|
||||
<select {{{ data.weight.link }}}>
|
||||
|
||||
<# _.each( data.weight.choices, function( label, choice ) { #>
|
||||
|
||||
<option value="{{ choice }}" <# if ( choice === data.weight.value ) { #> selected="selected" <# } #>>{{ label }}</option>
|
||||
|
||||
<# } ) #>
|
||||
|
||||
</select>
|
||||
<# if ( '' !== data.weight_title ) { #>
|
||||
<p class="description">{{ data.weight_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
<# if ( 'undefined' !== typeof ( data.transform ) ) { #>
|
||||
<div class="generatepress-font-transform">
|
||||
<label>
|
||||
<select {{{ data.transform.link }}}>
|
||||
|
||||
<# _.each( data.transform.choices, function( label, choice ) { #>
|
||||
|
||||
<option value="{{ choice }}" <# if ( choice === data.transform.value ) { #> selected="selected" <# } #>>{{ label }}</option>
|
||||
|
||||
<# } ) #>
|
||||
|
||||
</select>
|
||||
<# if ( '' !== data.transform_title ) { #>
|
||||
<p class="description">{{ data.transform_title }}</p>
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<# } #>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function get_font_weight_choices() {
|
||||
return array(
|
||||
'' => esc_html__( 'inherit', 'gp-premium' ),
|
||||
'normal' => esc_html__( 'normal', 'gp-premium' ),
|
||||
'bold' => esc_html__( 'bold', 'gp-premium' ),
|
||||
'100' => esc_html( '100' ),
|
||||
'200' => esc_html( '200' ),
|
||||
'300' => esc_html( '300' ),
|
||||
'400' => esc_html( '400' ),
|
||||
'500' => esc_html( '500' ),
|
||||
'600' => esc_html( '600' ),
|
||||
'700' => esc_html( '700' ),
|
||||
'800' => esc_html( '800' ),
|
||||
'900' => esc_html( '900' ),
|
||||
);
|
||||
}
|
||||
|
||||
public function get_font_transform_choices() {
|
||||
return array(
|
||||
'' => esc_html__( 'inherit', 'gp-premium' ),
|
||||
'none' => esc_html__( 'none', 'gp-premium' ),
|
||||
'capitalize' => esc_html__( 'capitalize', 'gp-premium' ),
|
||||
'uppercase' => esc_html__( 'uppercase', 'gp-premium' ),
|
||||
'lowercase' => esc_html__( 'lowercase', 'gp-premium' ),
|
||||
);
|
||||
}
|
||||
}
|
||||
endif;
|
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Alpha Color Picker CSS
|
||||
*/
|
||||
.customize-control-gp-alpha-color .iris-picker .iris-square {
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
.customize-control-gp-alpha-color .alpha-slider.ui-widget-content,
|
||||
.customize-control-gp-alpha-color .ui-widget-header{
|
||||
background: none;
|
||||
border: 0;
|
||||
box-shadow: 0 0 0 transparent;
|
||||
}
|
||||
|
||||
.alpha-color-picker-wrap a.iris-square-value:focus {
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.gp-alpha-color-picker-container {
|
||||
position: relative;
|
||||
margin-left: 10px;
|
||||
background-image: url(transparency-grid.png);
|
||||
}
|
||||
|
||||
.gp-alpha-color-picker-container .iris-picker .iris-strip .ui-slider-handle {
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.customize-control-gp-alpha-color .wp-picker-input-wrap .button.wp-picker-clear {
|
||||
margin-left: 6px;
|
||||
padding: 2px 8px;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
.generatepress-control-toggles {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.generatepress-control-toggles button {
|
||||
flex-basis: 100%;
|
||||
background-color: #fafafa;
|
||||
border: 1px solid #ddd;
|
||||
cursor: pointer;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
.generatepress-control-toggles button:last-child {
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
.generatepress-control-toggles button.active {
|
||||
background-color: #fff;
|
||||
border: 1px solid #ccc;
|
||||
font-weight: bold;
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
.generatepress-shortcuts {
|
||||
background: #fff;
|
||||
padding: 10px 15px;
|
||||
border-width: 0 1px 1px 0;
|
||||
border-color: #ddd;
|
||||
border-style: solid;
|
||||
}
|
||||
|
||||
.generatepress-shortcuts .more-controls {
|
||||
font-weight: 600;
|
||||
margin-right: 5px;
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.generatepress-shortcuts .shortcuts .shortcut:not(:last-child):after {
|
||||
content: "\2022";
|
||||
padding: 0 1px;
|
||||
}
|
||||
|
||||
.generatepress-shortcuts .shortcut a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.generatepress-shortcuts .shortcut {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.return-shortcut .dashicons {
|
||||
float: right;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.return-shortcut a {
|
||||
font-size: 12px;
|
||||
text-decoration: none;
|
||||
}
|
1
wp-content/plugins/gp-premium/library/customizer/controls/css/selectWoo.min.css
vendored
Normal file
1
wp-content/plugins/gp-premium/library/customizer/controls/css/selectWoo.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,144 @@
|
||||
.customize-control-generatepress-pro-range-slider .generatepress-slider {
|
||||
position: relative;
|
||||
width: calc(100% - 60px);
|
||||
height: 6px;
|
||||
background-color: rgba(0,0,0,.10);
|
||||
cursor: pointer;
|
||||
-webkit-transition: background .5s;
|
||||
-moz-transition: background .5s;
|
||||
transition: background .5s;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .has-unit .generatepress-slider {
|
||||
width: calc(100% - 90px);
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .gp_range_value.hide-value {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .gp_range_value.hide-value + .generatepress-slider {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .generatepress-slider .ui-slider-handle {
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
background-color: #3498D9;
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
-webkit-transform: translateY(-50%) translateX(-4px);
|
||||
transform: translateY(-50%) translateX(-4px);
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .wrapper {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-pack: justify;
|
||||
-ms-flex-pack: justify;
|
||||
justify-content: space-between;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .gp_range_value {
|
||||
font-size: 14px;
|
||||
padding: 0;
|
||||
font-weight: 400;
|
||||
width: 50px;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .has-unit .gp_range_value {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .gp_range_value span.value {
|
||||
font-size: 12px;
|
||||
width: calc(100% - 2px);
|
||||
text-align: center;
|
||||
min-height: 30px;
|
||||
background: #FFF;
|
||||
line-height: 30px;
|
||||
border: 1px solid #DDD;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .has-unit .gp_range_value span.value {
|
||||
width: calc(100% - 32px);
|
||||
display: block;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .gp_range_value .unit {
|
||||
width: 29px;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
line-height: 30px;
|
||||
background: #fff;
|
||||
border: 1px solid #ddd;
|
||||
margin-left: 1px;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .generatepress-pro-range-slider-reset span {
|
||||
font-size: 16px;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .gp_range_value input {
|
||||
font-size: 12px;
|
||||
padding: 0px;
|
||||
text-align: center;
|
||||
min-height: 30px;
|
||||
height: auto;
|
||||
border-radius: 0;
|
||||
border-color: #ddd;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .has-unit .gp_range_value input {
|
||||
width: calc(100% - 30px);
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .gp-range-title-area .dashicons {
|
||||
cursor: pointer;
|
||||
font-size: 11px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
color: #222;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .gp-range-title-area .dashicons:hover {
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .gp-range-title-area .dashicons.selected {
|
||||
background: #fff;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
.gp-range-title-area {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.gp-range-slider-controls {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .gp-device-controls > span:first-child:last-child {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-pro-range-slider .sub-description {
|
||||
margin-top: 10px;
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
.gp-spacing-control-section-title-area {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.gp-range-slider-controls {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.customize-control-spacing .description {
|
||||
font-size: 10px;
|
||||
text-transform: uppercase;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.spacing-values-area {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.gp-spacing-section input {
|
||||
min-height: 30px;
|
||||
border-radius: 0;
|
||||
border-color: #ddd;
|
||||
}
|
||||
|
||||
.gp-link-spacing-section span {
|
||||
display: block;
|
||||
color: #0073aa;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
height: auto;
|
||||
min-height: 28px;
|
||||
line-height: 28px;
|
||||
box-sizing: border-box;
|
||||
width: 40px;
|
||||
background: #fff;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.gp-link-spacing-section span.gp-unlink-spacing {
|
||||
background-color: #0073aa;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.gp-spacing-section {
|
||||
margin-right: 2px;
|
||||
text-align:center
|
||||
}
|
||||
|
||||
.gp-link-spacing-section {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.gp-spacing-section .description {
|
||||
font-size: 10px;
|
||||
text-transform: uppercase;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.no-edit-field {
|
||||
font-size: 11px;
|
||||
opacity: 0.8;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure slider is 100% wide.
|
||||
* Old versions of Secondary Nav will have this set as 50%
|
||||
* so we need to set !important to overwrite that.
|
||||
*/
|
||||
.customize-control.customize-control-gp-spacing-slider {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-spacing .gp-spacing-control-section-title-area .dashicons {
|
||||
cursor: pointer;
|
||||
font-size: 11px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
color: #222;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-spacing .gp-spacing-control-section-title-area .dashicons:hover {
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-spacing .gp-spacing-control-section-title-area .dashicons.selected {
|
||||
background: #fff;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
.customize-control-generatepress-spacing .gp-device-controls > span:first-child:last-child {
|
||||
display: none;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
.generatepress-customizer-title {
|
||||
background: #FFF;
|
||||
padding: 10px 12px;
|
||||
font-weight: 600;
|
||||
border-style: solid;
|
||||
border-width: 0 1px 1px 0;
|
||||
border-color: #ddd;
|
||||
font-size: 15px;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
@ -0,0 +1,64 @@
|
||||
.generatepress-font-family {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.generatepress-weight-transform-wrapper {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-pack: justify;
|
||||
-ms-flex-pack: justify;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.generatepress-font-weight,
|
||||
.generatepress-font-transform {
|
||||
width: calc(50% - 5px);
|
||||
}
|
||||
|
||||
span.select2-container.select2-container--default.select2-container--open li.select2-results__option {
|
||||
margin:0;
|
||||
}
|
||||
|
||||
span.select2-container.select2-container--default.select2-container--open{
|
||||
z-index:999999;
|
||||
}
|
||||
|
||||
.select2-selection__rendered li {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.select2-container--default .select2-selection--single,
|
||||
.select2-container--default.select2-container .select2-selection--multiple,
|
||||
.select2-dropdown,
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
||||
border-color: #ddd;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.select2-container--default .select2-results__option[aria-selected=true] {
|
||||
color: rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.select2-container .select2-search--inline {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#customize-control-single_content_title_control,
|
||||
#customize-control-font_heading_2_control,
|
||||
#customize-control-archive_content_title_control,
|
||||
#customize-control-font_heading_3_control,
|
||||
#customize-control-font_heading_4_control,
|
||||
#customize-control-font_heading_5_control,
|
||||
#customize-control-font_heading_6_control {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.generatepress-weight-transform-wrapper select option[value=""] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#customize-control-single_content_title_control .generatepress-weight-transform-wrapper select option[value=""],
|
||||
#customize-control-archive_content_title_control .generatepress-weight-transform-wrapper select option[value=""] {
|
||||
display: block;
|
||||
}
|
@ -0,0 +1,277 @@
|
||||
/**
|
||||
* Alpha Color Picker JS
|
||||
*
|
||||
* This file includes several helper functions and the core control JS.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Override the stock color.js toString() method to add support for
|
||||
* outputting RGBa or Hex.
|
||||
*/
|
||||
Color.prototype.toString = function( flag ) {
|
||||
|
||||
// If our no-alpha flag has been passed in, output RGBa value with 100% opacity.
|
||||
// This is used to set the background color on the opacity slider during color changes.
|
||||
if ( 'no-alpha' == flag ) {
|
||||
return this.toCSS( 'rgba', '1' ).replace( /\s+/g, '' );
|
||||
}
|
||||
|
||||
// If we have a proper opacity value, output RGBa.
|
||||
if ( 1 > this._alpha ) {
|
||||
return this.toCSS( 'rgba', this._alpha ).replace( /\s+/g, '' );
|
||||
}
|
||||
|
||||
// Proceed with stock color.js hex output.
|
||||
var hex = parseInt( this._color, 10 ).toString( 16 );
|
||||
if ( this.error ) { return ''; }
|
||||
if ( hex.length < 6 ) {
|
||||
for ( var i = 6 - hex.length - 1; i >= 0; i-- ) {
|
||||
hex = '0' + hex;
|
||||
}
|
||||
}
|
||||
|
||||
return '#' + hex;
|
||||
};
|
||||
|
||||
/**
|
||||
* Given an RGBa, RGB, or hex color value, return the alpha channel value.
|
||||
*/
|
||||
function generate_get_alpha_value_from_color( value ) {
|
||||
var alphaVal;
|
||||
|
||||
// Remove all spaces from the passed in value to help our RGBa regex.
|
||||
value = value.toString().replace( / /g, '' );
|
||||
|
||||
if ( value.match( /rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/ ) ) {
|
||||
alphaVal = parseFloat( value.match( /rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/ )[1] ).toFixed(2) * 100;
|
||||
alphaVal = parseInt( alphaVal );
|
||||
} else {
|
||||
alphaVal = 100;
|
||||
}
|
||||
|
||||
return alphaVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force update the alpha value of the color picker object and maybe the alpha slider.
|
||||
*/
|
||||
function generate_update_alpha_value_on_color_control( alpha, $control, $alphaSlider, update_slider ) {
|
||||
var iris, colorPicker, color;
|
||||
|
||||
iris = $control.data( 'a8cIris' );
|
||||
colorPicker = $control.data( 'wpWpColorPicker' );
|
||||
|
||||
// Set the alpha value on the Iris object.
|
||||
iris._color._alpha = alpha;
|
||||
|
||||
// Store the new color value.
|
||||
color = iris._color.toString();
|
||||
|
||||
// Set the value of the input.
|
||||
$control.val( color );
|
||||
|
||||
// Update the background color of the color picker.
|
||||
colorPicker.toggler.css({
|
||||
'background-color': color
|
||||
});
|
||||
|
||||
// Maybe update the alpha slider itself.
|
||||
if ( update_slider ) {
|
||||
generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
|
||||
}
|
||||
|
||||
// Update the color value of the color picker object.
|
||||
$control.wpColorPicker( 'color', color );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the slider handle position and label.
|
||||
*/
|
||||
function generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider ) {
|
||||
$alphaSlider.slider( 'value', alpha );
|
||||
//$alphaSlider.find( '.ui-slider-handle' ).text( alpha.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization trigger.
|
||||
*/
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
|
||||
// Loop over each control and transform it into our color picker.
|
||||
$( '.gp-alpha-color-control' ).each( function() {
|
||||
|
||||
// Scope the vars.
|
||||
var $control, startingColor, paletteInput, showOpacity, defaultColor, palette,
|
||||
colorPickerOptions, $container, $alphaSlider, alphaVal, sliderOptions, savedValue;
|
||||
|
||||
// Store the control instance.
|
||||
$control = $( this );
|
||||
|
||||
// Get our saved value
|
||||
savedValue = wp.customize.value( $control.attr( 'data-customize-setting-link' ) )();
|
||||
|
||||
// Get a clean starting value for the option.
|
||||
startingColor = savedValue.toString().replace( /\s+/g, '' );
|
||||
|
||||
// Get some data off the control.
|
||||
paletteInput = $control.attr( 'data-palette' );
|
||||
showOpacity = $control.attr( 'data-show-opacity' );
|
||||
defaultColor = $control.attr( 'data-default-color' );
|
||||
|
||||
// Process the palette.
|
||||
if ( paletteInput.indexOf( '|' ) !== -1 ) {
|
||||
palette = paletteInput.split( '|' );
|
||||
} else if ( 'false' == paletteInput ) {
|
||||
palette = false;
|
||||
} else {
|
||||
palette = true;
|
||||
}
|
||||
|
||||
// Set up the options that we'll pass to wpColorPicker().
|
||||
colorPickerOptions = {
|
||||
change: function( event, ui ) {
|
||||
var key, value, alpha, $transparency;
|
||||
|
||||
key = $control.attr( 'data-customize-setting-link' );
|
||||
value = $control.wpColorPicker( 'color' );
|
||||
|
||||
// Send ajax request to wp.customize to trigger the Save action.
|
||||
wp.customize( key, function( obj ) {
|
||||
obj.set( value );
|
||||
});
|
||||
|
||||
$transparency = $container.find( '.transparency' );
|
||||
|
||||
// Always show the background color of the opacity slider at 100% opacity.
|
||||
$alphaSlider.closest( '.gp-alpha-color-picker-container' ).css( 'background-color', ui.color.toString( 'no-alpha' ) );
|
||||
},
|
||||
palettes: palette
|
||||
};
|
||||
|
||||
// Create the colorpicker.
|
||||
$control.val( savedValue ).wpColorPicker( colorPickerOptions );
|
||||
|
||||
$container = $control.parents( '.wp-picker-container:first' );
|
||||
|
||||
// Insert our opacity slider.
|
||||
$( '<div class="gp-alpha-color-picker-container iris-slider iris-strip">' +
|
||||
'<div class="alpha-slider iris-slider-offset"></div>' +
|
||||
'</div>' ).appendTo( $container.find( '.iris-picker-inner' ) );
|
||||
|
||||
$alphaSlider = $container.find( '.alpha-slider' );
|
||||
|
||||
// If starting value is in format RGBa, grab the alpha channel.
|
||||
alphaVal = generate_get_alpha_value_from_color( startingColor );
|
||||
|
||||
// Get the solid color
|
||||
solidColor = startingColor.toString().replace( '0.' + alphaVal, '100' );
|
||||
|
||||
// Set up jQuery UI slider() options.
|
||||
sliderOptions = {
|
||||
create: function( event, ui ) {
|
||||
var value = $( this ).slider( 'value' );
|
||||
|
||||
// Set up initial values.
|
||||
//$( this ).find( '.ui-slider-handle' ).text( value );
|
||||
$( this ).closest( '.iris-slider' ).css( 'background-color', solidColor );
|
||||
},
|
||||
value: alphaVal,
|
||||
range: 'max',
|
||||
step: 1,
|
||||
min: 0,
|
||||
max: 100,
|
||||
animate: 300,
|
||||
orientation: "vertical"
|
||||
};
|
||||
|
||||
// Initialize jQuery UI slider with our options.
|
||||
$alphaSlider.slider( sliderOptions );
|
||||
|
||||
// Bind event handler for clicking on a palette color.
|
||||
$container.find( '.iris-palette' ).on( 'click', function() {
|
||||
var color, alpha;
|
||||
|
||||
color = $( this ).css( 'background-color' );
|
||||
alpha = generate_get_alpha_value_from_color( color );
|
||||
|
||||
generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
|
||||
|
||||
// Sometimes Iris doesn't set a perfect background-color on the palette,
|
||||
// for example rgba(20, 80, 100, 0.3) becomes rgba(20, 80, 100, 0.298039).
|
||||
// To compensante for this we round the opacity value on RGBa colors here
|
||||
// and save it a second time to the color picker object.
|
||||
if ( alpha != 100 ) {
|
||||
color = color.toString().replace( /[^,]+(?=\))/, ( alpha / 100 ).toFixed( 2 ) );
|
||||
}
|
||||
|
||||
$control.wpColorPicker( 'color', color );
|
||||
});
|
||||
|
||||
// Bind event handler for clicking on the 'Clear' button.
|
||||
$container.find( '.button.wp-picker-clear' ).on( 'click', function() {
|
||||
var key = $control.attr( 'data-customize-setting-link' );
|
||||
|
||||
// The #fff color is delibrate here. This sets the color picker to white instead of the
|
||||
// defult black, which puts the color picker in a better place to visually represent empty.
|
||||
$control.wpColorPicker( 'color', '#ffffff' );
|
||||
|
||||
// Set the actual option value to empty string.
|
||||
wp.customize( key, function( obj ) {
|
||||
obj.set( '' );
|
||||
});
|
||||
|
||||
generate_update_alpha_value_on_alpha_slider( 100, $alphaSlider );
|
||||
});
|
||||
|
||||
// Bind event handler for clicking on the 'Default' button.
|
||||
$container.find( '.button.wp-picker-default' ).on( 'click', function() {
|
||||
var alpha = generate_get_alpha_value_from_color( defaultColor );
|
||||
|
||||
generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
|
||||
});
|
||||
|
||||
// Bind event handler for typing or pasting into the input.
|
||||
$control.on( 'input', function() {
|
||||
var value = $( this ).val();
|
||||
|
||||
if ( '' === value ) {
|
||||
var key = $control.attr( 'data-customize-setting-link' );
|
||||
|
||||
// The #fff color is delibrate here. This sets the color picker to white instead of the
|
||||
// defult black, which puts the color picker in a better place to visually represent empty.
|
||||
$control.wpColorPicker( 'color', '' );
|
||||
|
||||
// Set the actual option value to empty string.
|
||||
wp.customize( key, function( obj ) {
|
||||
obj.set( '' );
|
||||
});
|
||||
|
||||
generate_update_alpha_value_on_alpha_slider( 100, $alphaSlider );
|
||||
} else {
|
||||
var alpha = generate_get_alpha_value_from_color( value );
|
||||
|
||||
generate_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
|
||||
}
|
||||
});
|
||||
|
||||
// Update all the things when the slider is interacted with.
|
||||
$alphaSlider.slider().on( 'slide', function( event, ui ) {
|
||||
var alpha = parseFloat( ui.value ) / 100.0;
|
||||
|
||||
generate_update_alpha_value_on_color_control( alpha, $control, $alphaSlider, false );
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// Move the opacity bar next to the hue bar
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
var container_width = $( '.customize-control-gp-alpha-color .iris-picker' ).width();
|
||||
var square_width = $( '.customize-control-gp-alpha-color .iris-square' ).width();
|
||||
var available_space = container_width - square_width;
|
||||
var strip_width = ( available_space / 2 ) - 20;
|
||||
var strip_height = $( '.customize-control-gp-alpha-color .iris-strip' ).height();
|
||||
$( '.customize-control-gp-alpha-color .iris-strip, .gp-alpha-color-picker-container' ).css( 'width', strip_width + 'px' );
|
||||
$( '.gp-alpha-color-picker-container' ).css( 'height', strip_height + 'px' );
|
||||
|
||||
});
|
@ -0,0 +1,34 @@
|
||||
( function( api ) {
|
||||
|
||||
api.controlConstructor['gp-background-images'] = api.Control.extend( {
|
||||
ready: function() {
|
||||
var control = this;
|
||||
|
||||
control.container.on( 'change', '.generatepress-backgrounds-repeat select',
|
||||
function() {
|
||||
control.settings['repeat'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change', '.generatepress-backgrounds-size select',
|
||||
function() {
|
||||
control.settings['size'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change', '.generatepress-backgrounds-attachment select',
|
||||
function() {
|
||||
control.settings['attachment'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'input', '.generatepress-backgrounds-position input',
|
||||
function() {
|
||||
control.settings['position'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
} );
|
||||
|
||||
} )( wp.customize );
|
@ -0,0 +1,29 @@
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
$( '[data-type="overlay_design"]' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
if ( ! confirm( gpButtonActions.warning ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
( function( api ) {
|
||||
'use strict';
|
||||
|
||||
api.instance( 'generate_settings[slideout_background_color]' ).set( gpButtonActions.styling.backgroundColor );
|
||||
api.instance( 'generate_settings[slideout_text_color]' ).set( gpButtonActions.styling.textColor );
|
||||
api.instance( 'generate_settings[slideout_background_hover_color]' ).set( gpButtonActions.styling.backgroundHoverColor );
|
||||
api.instance( 'generate_settings[slideout_background_current_color]' ).set( gpButtonActions.styling.backgroundCurrentColor );
|
||||
|
||||
api.instance( 'generate_settings[slideout_submenu_background_color]' ).set( gpButtonActions.styling.subMenuBackgroundColor );
|
||||
api.instance( 'generate_settings[slideout_submenu_text_color]' ).set( gpButtonActions.styling.subMenuTextColor );
|
||||
api.instance( 'generate_settings[slideout_submenu_background_hover_color]' ).set( gpButtonActions.styling.subMenuBackgroundHoverColor );
|
||||
api.instance( 'generate_settings[slideout_submenu_background_current_color]' ).set( gpButtonActions.styling.subMenuBackgroundCurrentColor );
|
||||
|
||||
api.instance( 'generate_settings[slideout_font_weight]' ).set( gpButtonActions.styling.fontWeight );
|
||||
api.instance( 'generate_settings[slideout_font_size]' ).set( gpButtonActions.styling.fontSize );
|
||||
|
||||
$( '.wp-color-picker' ).wpColorPicker().change();
|
||||
|
||||
}( wp.customize ) );
|
||||
} );
|
||||
} );
|
@ -0,0 +1,32 @@
|
||||
jQuery( document ).ready( function($) {
|
||||
$( '.generatepress-control-toggles' ).each( function() {
|
||||
$( this ).find( 'button' ).first().addClass( 'active' );
|
||||
} );
|
||||
|
||||
$( document ).on( 'click', '.generatepress-control-toggles button', function( e ) {
|
||||
e.preventDefault();
|
||||
var button = $( this ),
|
||||
target = button.data( 'target' ),
|
||||
other_targets = button.siblings();
|
||||
|
||||
button.addClass( 'active' );
|
||||
button.siblings().removeClass( 'active' );
|
||||
|
||||
$( 'li[data-control-section="' + target + '"]' ).css( {
|
||||
visibility: 'visible',
|
||||
height: '',
|
||||
width: '',
|
||||
margin: ''
|
||||
} );
|
||||
|
||||
$.each( other_targets, function( index, value ) {
|
||||
var other_target = $( this ).data( 'target' );
|
||||
$( 'li[data-control-section="' + other_target + '"]' ).css( {
|
||||
visibility: 'hidden',
|
||||
height: '0',
|
||||
width: '0',
|
||||
margin: '0'
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
});
|
@ -0,0 +1,12 @@
|
||||
( function( $, api ) {
|
||||
api.controlConstructor['gp-copyright'] = api.Control.extend( {
|
||||
ready: function() {
|
||||
var control = this;
|
||||
$( '.gp-copyright-area', control.container ).on( 'change keyup',
|
||||
function() {
|
||||
control.setting.set( $( this ).val() );
|
||||
}
|
||||
);
|
||||
}
|
||||
} );
|
||||
} )( jQuery, wp.customize );
|
@ -0,0 +1,169 @@
|
||||
( function( $, api ) {
|
||||
|
||||
/**
|
||||
* Set some controls when we're using the navigation as a header.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
api( 'generate_menu_plus_settings[navigation_as_header]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
var navAlignmentSetting = api.instance( 'generate_settings[nav_alignment_setting]' ),
|
||||
navAlignment = gpControls.navigationAlignment,
|
||||
siteTitleFontSizeSetting = api.instance( 'generate_settings[site_title_font_size]' ),
|
||||
mobileSiteTitleFontSizeSetting = api.instance( 'generate_settings[mobile_site_title_font_size]' ),
|
||||
siteTitleFontSize = gpControls.siteTitleFontSize,
|
||||
mobileSiteTitleFontSize = gpControls.mobileSiteTitleFontSize,
|
||||
mobileHeader = api.instance( 'generate_menu_plus_settings[mobile_header]' ).get(),
|
||||
navTextColorSetting = api.instance( 'generate_settings[navigation_text_color]' ),
|
||||
navTextColor = gpControls.navigationTextColor,
|
||||
headerTextColorSetting = api.instance( 'generate_settings[header_text_color]' ),
|
||||
headerTextColor = gpControls.headerTextColor;
|
||||
|
||||
if ( ! siteTitleFontSizeSetting._dirty && 25 !== siteTitleFontSizeSetting.get() ) {
|
||||
siteTitleFontSize = siteTitleFontSizeSetting.get();
|
||||
}
|
||||
|
||||
if ( ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
|
||||
mobileSiteTitleFontSize = mobileSiteTitleFontSizeSetting.get();
|
||||
}
|
||||
|
||||
if ( ! navTextColorSetting._dirty ) {
|
||||
navTextColor = navTextColorSetting.get();
|
||||
}
|
||||
|
||||
if ( ! headerTextColorSetting._dirty ) {
|
||||
headerTextColor = headerTextColorSetting.get();
|
||||
}
|
||||
|
||||
if ( newval ) {
|
||||
navAlignmentSetting.set( 'right' );
|
||||
siteTitleFontSizeSetting.set( 25 );
|
||||
api.instance( 'generate_settings[site_title_color]' ).set( navTextColor );
|
||||
|
||||
if ( 'enable' !== mobileHeader ) {
|
||||
mobileSiteTitleFontSizeSetting.set( 20 );
|
||||
}
|
||||
} else {
|
||||
navAlignmentSetting.set( navAlignment );
|
||||
siteTitleFontSizeSetting.set( siteTitleFontSize );
|
||||
api.instance( 'generate_settings[site_title_color]' ).set( headerTextColor );
|
||||
|
||||
if ( 'enable' !== mobileHeader ) {
|
||||
mobileSiteTitleFontSizeSetting.set( mobileSiteTitleFontSize );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
var showRegularHeader,
|
||||
showRegularHeaderCallback,
|
||||
showNavHeader,
|
||||
showNavHeaderCallback;
|
||||
|
||||
/**
|
||||
* Determine whether we should display our header controls.
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
showRegularHeader = function() {
|
||||
if ( value.get() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine whether our navigation is our header.
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
showNavHeader = function() {
|
||||
if ( value.get() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update a control's active state according to the navigation as header option.
|
||||
*
|
||||
* @param {wp.customize.Control} control
|
||||
*/
|
||||
showRegularHeaderCallback = function( control ) {
|
||||
var setActiveState = function() {
|
||||
control.active.set( showRegularHeader() );
|
||||
};
|
||||
|
||||
control.active.validate = showRegularHeader;
|
||||
setActiveState();
|
||||
value.bind( setActiveState );
|
||||
};
|
||||
|
||||
/**
|
||||
* Update a control's active state according to the navigation as header option.
|
||||
*
|
||||
* @param {wp.customize.Control} control
|
||||
*/
|
||||
showNavHeaderCallback = function( control ) {
|
||||
var setActiveState = function() {
|
||||
control.active.set( showNavHeader() );
|
||||
};
|
||||
|
||||
control.active.validate = showNavHeader;
|
||||
setActiveState();
|
||||
value.bind( setActiveState );
|
||||
};
|
||||
|
||||
api.control( 'generate_header_helper', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[header_layout_setting]', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[header_inner_width]', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[header_alignment_setting]', showRegularHeaderCallback );
|
||||
api.control( 'header_spacing', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[header_background_color]', showRegularHeaderCallback );
|
||||
api.control( 'header_text_color', showRegularHeaderCallback );
|
||||
api.control( 'header_link_color', showRegularHeaderCallback );
|
||||
api.control( 'header_link_hover_color', showRegularHeaderCallback );
|
||||
api.control( 'site_tagline_color', showRegularHeaderCallback );
|
||||
api.control( 'font_site_tagline_control', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[site_tagline_font_size]', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[nav_position_setting]', showRegularHeaderCallback );
|
||||
api.control( 'generate_settings[logo_width]', showRegularHeaderCallback );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Set the navigation branding font size label on mobile header branding change.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
api( 'generate_menu_plus_settings[mobile_header_branding]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( 'title' === newval ) {
|
||||
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( 20 );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Set the navigation branding font size label on mobile header change.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
api( 'generate_menu_plus_settings[mobile_header]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
var mobileSiteTitleFontSizeSetting = api.instance( 'generate_settings[mobile_site_title_font_size]' ),
|
||||
mobileSiteTitleFontSize = gpControls.mobileSiteTitleFontSize;
|
||||
|
||||
if ( ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
|
||||
mobileSiteTitleFontSize = mobileSiteTitleFontSizeSetting.get();
|
||||
}
|
||||
|
||||
if ( 'enable' === newval ) {
|
||||
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( 20 );
|
||||
} else {
|
||||
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( mobileSiteTitleFontSize );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
} )( jQuery, wp.customize );
|
@ -0,0 +1,46 @@
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
$( '.generatepress-shortcuts a' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
var section = $( this ).attr( 'data-section' ),
|
||||
currentSection = $( this ).attr( 'data-current-section' ),
|
||||
destinationSectionElement = $( '[id$="' + section + '"]' );
|
||||
|
||||
if ( section ) {
|
||||
wp.customize.section( section ).focus();
|
||||
|
||||
destinationSectionElement.find( '.show-shortcuts' ).hide();
|
||||
destinationSectionElement.find( '.return-shortcut' ).show();
|
||||
destinationSectionElement.find( '.return-shortcut a' ).attr( 'data-return', currentSection );
|
||||
}
|
||||
} );
|
||||
|
||||
$( '.return-shortcut .dashicons' ).on( 'click', function( e ) {
|
||||
var container = $( this ).closest( '.generatepress-shortcuts' );
|
||||
|
||||
container.find( '.show-shortcuts' ).show();
|
||||
container.find( '.return-shortcut' ).hide();
|
||||
} );
|
||||
|
||||
$( '.return-shortcut a' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var section = $( this ).attr( 'data-return' );
|
||||
var container = $( this ).closest( '.generatepress-shortcuts' );
|
||||
|
||||
if ( section ) {
|
||||
wp.customize.section( section ).focus();
|
||||
|
||||
container.find( '.show-shortcuts' ).show();
|
||||
container.find( '.return-shortcut' ).hide();
|
||||
}
|
||||
} );
|
||||
|
||||
var customizeSectionBack = $( '.customize-section-back' );
|
||||
|
||||
if ( customizeSectionBack ) {
|
||||
customizeSectionBack.on( 'click', function() {
|
||||
$( '.show-shortcuts' ).show();
|
||||
$( '.return-shortcut' ).hide();
|
||||
} );
|
||||
}
|
||||
} );
|
1
wp-content/plugins/gp-premium/library/customizer/controls/js/selectWoo.min.js
vendored
Normal file
1
wp-content/plugins/gp-premium/library/customizer/controls/js/selectWoo.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,134 @@
|
||||
wp.customize.controlConstructor['generatepress-pro-range-slider'] = wp.customize.Control.extend({
|
||||
|
||||
ready: function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
var control = this,
|
||||
value,
|
||||
thisInput,
|
||||
inputDefault,
|
||||
changeAction,
|
||||
controlClass = '.customize-control-generatepress-pro-range-slider',
|
||||
footerActions = jQuery( '#customize-footer-actions' );
|
||||
|
||||
// Set up the sliders
|
||||
jQuery( '.generatepress-slider' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
var _input = _this.closest( 'label' ).find( 'input[type="number"]' );
|
||||
var _text = _input.next( '.value' );
|
||||
_this.slider({
|
||||
value: _input.val(),
|
||||
min: _this.data( 'min' ),
|
||||
max: _this.data( 'max' ),
|
||||
step: _this.data( 'step' ),
|
||||
slide: function( event, ui ) {
|
||||
_input.val( ui.value ).change();
|
||||
_text.text( ui.value );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Update the range value based on the input value
|
||||
jQuery( controlClass + ' .gp_range_value input[type=number]' ).on( 'input', function() {
|
||||
value = jQuery( this ).attr( 'value' );
|
||||
if ( '' == value ) {
|
||||
value = -1;
|
||||
}
|
||||
jQuery( this ).closest( 'label' ).find( '.generatepress-slider' ).slider( 'value', parseFloat(value)).change();
|
||||
});
|
||||
|
||||
// Handle the reset button
|
||||
jQuery( controlClass + ' .generatepress-reset' ).on( 'click', function() {
|
||||
var icon = jQuery( this ),
|
||||
visible_area = icon.closest( '.gp-range-title-area' ).next( '.gp-range-slider-areas' ).children( 'label:visible' ),
|
||||
input = visible_area.find( 'input[type=number]' ),
|
||||
slider_value = visible_area.find( '.generatepress-slider' ),
|
||||
visual_value = visible_area.find( '.gp_range_value' ),
|
||||
reset_value = input.attr( 'data-reset_value' );
|
||||
|
||||
input.val( reset_value ).change();
|
||||
visual_value.find( 'input' ).val( reset_value );
|
||||
visual_value.find( '.value' ).text( reset_value );
|
||||
|
||||
if ( '' == reset_value ) {
|
||||
reset_value = -1;
|
||||
}
|
||||
|
||||
slider_value.slider( 'value', parseFloat( reset_value ) );
|
||||
});
|
||||
|
||||
// Figure out which device icon to make active on load
|
||||
jQuery( controlClass + ' .generatepress-range-slider-control' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
_this.find( '.gp-device-controls' ).children( 'span:first-child' ).addClass( 'selected' );
|
||||
_this.find( '.range-option-area:first-child' ).show();
|
||||
});
|
||||
|
||||
// Do stuff when device icons are clicked
|
||||
jQuery( controlClass + ' .gp-device-controls > span' ).on( 'click', function( event ) {
|
||||
var device = jQuery( this ).data( 'option' );
|
||||
|
||||
jQuery( controlClass + ' .gp-device-controls span' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
if ( device == _this.attr( 'data-option' ) ) {
|
||||
_this.addClass( 'selected' );
|
||||
_this.siblings().removeClass( 'selected' );
|
||||
}
|
||||
});
|
||||
|
||||
jQuery( controlClass + ' .gp-range-slider-areas label' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
if ( device == _this.attr( 'data-option' ) ) {
|
||||
_this.show();
|
||||
_this.siblings().hide();
|
||||
}
|
||||
});
|
||||
|
||||
// Set the device we're currently viewing
|
||||
wp.customize.previewedDevice.set( jQuery( event.currentTarget ).data( 'option' ) );
|
||||
} );
|
||||
|
||||
// Set the selected devices in our control when the Customizer devices are clicked
|
||||
footerActions.find( '.devices button' ).on( 'click', function() {
|
||||
var device = jQuery( this ).data( 'device' );
|
||||
jQuery( controlClass + ' .gp-device-controls span' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
if ( device == _this.attr( 'data-option' ) ) {
|
||||
_this.addClass( 'selected' );
|
||||
_this.siblings().removeClass( 'selected' );
|
||||
}
|
||||
});
|
||||
|
||||
jQuery( controlClass + ' .gp-range-slider-areas label' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
if ( device == _this.attr( 'data-option' ) ) {
|
||||
_this.show();
|
||||
_this.siblings().hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Apply changes when desktop slider is changed
|
||||
control.container.on( 'input change', '.desktop-range',
|
||||
function() {
|
||||
control.settings['desktop'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
// Apply changes when tablet slider is changed
|
||||
control.container.on( 'input change', '.tablet-range',
|
||||
function() {
|
||||
control.settings['tablet'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
// Apply changes when mobile slider is changed
|
||||
control.container.on( 'input change', '.mobile-range',
|
||||
function() {
|
||||
control.settings['mobile'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
});
|
@ -0,0 +1,200 @@
|
||||
( function( $, api ) {
|
||||
// No longer needed as of 1.2.95
|
||||
// Keeping it here just in case
|
||||
api.controlConstructor['spacing'] = api.Control.extend( {
|
||||
ready: function() {
|
||||
var control = this;
|
||||
$( '.generate-number-control', control.container ).on( 'change keyup',
|
||||
function() {
|
||||
control.setting.set( $( this ).val() );
|
||||
}
|
||||
);
|
||||
}
|
||||
} );
|
||||
|
||||
api.controlConstructor['gp-spacing-slider'] = api.Control.extend( {
|
||||
ready: function() {
|
||||
var control = this;
|
||||
$( '.slider-input', control.container ).on( 'change keyup',
|
||||
function() {
|
||||
control.setting.set( $( this ).val() );
|
||||
}
|
||||
);
|
||||
}
|
||||
} );
|
||||
|
||||
api.controlConstructor['generatepress-spacing'] = api.Control.extend( {
|
||||
ready: function() {
|
||||
var control = this,
|
||||
controlClass = '.customize-control-generatepress-spacing',
|
||||
footerActions = jQuery( '#customize-footer-actions' );
|
||||
|
||||
// Figure out which device icon to make active on load
|
||||
jQuery( controlClass + ' .gp-spacing-control-section' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
_this.find( '.gp-device-controls' ).children( 'span:first-child' ).addClass( 'selected' );
|
||||
_this.find( '.spacing-values-area:first-child' ).show();
|
||||
});
|
||||
|
||||
// Do stuff when device icons are clicked
|
||||
jQuery( controlClass + ' .gp-device-controls > span' ).on( 'click', function( event ) {
|
||||
var device = jQuery( this ).data( 'option' );
|
||||
|
||||
jQuery( controlClass + ' .gp-device-controls span' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
if ( device == _this.attr( 'data-option' ) ) {
|
||||
_this.addClass( 'selected' );
|
||||
_this.siblings().removeClass( 'selected' );
|
||||
}
|
||||
});
|
||||
|
||||
jQuery( controlClass + ' .spacing-values-container .spacing-values-area' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
if ( device == _this.attr( 'data-option' ) ) {
|
||||
_this.show();
|
||||
_this.siblings().hide();
|
||||
}
|
||||
});
|
||||
|
||||
// Set the device we're currently viewing
|
||||
wp.customize.previewedDevice.set( jQuery( event.currentTarget ).data( 'option' ) );
|
||||
} );
|
||||
|
||||
// Set the selected devices in our control when the Customizer devices are clicked
|
||||
footerActions.find( '.devices button' ).on( 'click', function() {
|
||||
var device = jQuery( this ).data( 'device' );
|
||||
jQuery( controlClass + ' .gp-device-controls span' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
if ( device == _this.attr( 'data-option' ) ) {
|
||||
_this.addClass( 'selected' );
|
||||
_this.siblings().removeClass( 'selected' );
|
||||
}
|
||||
});
|
||||
|
||||
jQuery( controlClass + ' .spacing-values-container .spacing-values-area' ).each( function() {
|
||||
var _this = jQuery( this );
|
||||
if ( device == _this.attr( 'data-option' ) ) {
|
||||
_this.show();
|
||||
_this.siblings().hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
control.container.on( 'change keyup', '.spacing-top',
|
||||
function() {
|
||||
control.settings['desktop_top'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.spacing-right',
|
||||
function() {
|
||||
control.settings['desktop_right'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.spacing-bottom',
|
||||
function() {
|
||||
control.settings['desktop_bottom'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.spacing-left',
|
||||
function() {
|
||||
control.settings['desktop_left'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.tablet-spacing-top',
|
||||
function() {
|
||||
control.settings['tablet_top'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.tablet-spacing-right',
|
||||
function() {
|
||||
control.settings['tablet_right'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.tablet-spacing-bottom',
|
||||
function() {
|
||||
control.settings['tablet_bottom'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.tablet-spacing-left',
|
||||
function() {
|
||||
control.settings['tablet_left'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.mobile-spacing-top',
|
||||
function() {
|
||||
control.settings['mobile_top'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.mobile-spacing-right',
|
||||
function() {
|
||||
control.settings['mobile_right'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.mobile-spacing-bottom',
|
||||
function() {
|
||||
control.settings['mobile_bottom'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change keyup', '.mobile-spacing-left',
|
||||
function() {
|
||||
control.settings['mobile_left'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
}
|
||||
} );
|
||||
} )( jQuery, wp.customize );
|
||||
|
||||
jQuery( document ).ready( function($) {
|
||||
$( '.gp-link-spacing' ).on( 'click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Set up variables
|
||||
var _this = $( this ),
|
||||
element = _this.data( 'element' );
|
||||
|
||||
// Add our linked-values class to the next 4 elements
|
||||
_this.parent( '.gp-spacing-section' ).prevAll().slice(0,4).find( 'input' ).addClass( 'linked-values' ).attr( 'data-element', element );
|
||||
|
||||
// Change our link icon class
|
||||
_this.hide();
|
||||
_this.next( 'span' ).show();
|
||||
});
|
||||
|
||||
$( '.gp-unlink-spacing' ).on( 'click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Set up variables
|
||||
var _this = $( this );
|
||||
|
||||
// Remove our linked-values class to the next 4 elements
|
||||
_this.parent( '.gp-spacing-section' ).prevAll().slice(0,4).find( 'input' ).removeClass( 'linked-values' ).attr( 'data-element', '' );
|
||||
|
||||
// Change our link icon class
|
||||
_this.hide();
|
||||
_this.prev( 'span' ).show();
|
||||
});
|
||||
|
||||
$( '.gp-spacing-section' ).on( 'input', '.linked-values', function() {
|
||||
var _this = $( this ),
|
||||
data = _this.attr( 'data-element' ),
|
||||
val = _this.val(),
|
||||
targetElements = _this.closest( '.spacing-values-area' ).find( '.linked-values[ data-element="' + data + '" ]' );
|
||||
|
||||
|
||||
targetElements.each( function( key, value ) {
|
||||
var element = $( this );
|
||||
element.val( val ).change();
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,151 @@
|
||||
( function( api ) {
|
||||
|
||||
api.controlConstructor['gp-pro-customizer-typography'] = api.Control.extend( {
|
||||
ready: function() {
|
||||
var control = this;
|
||||
|
||||
control.container.on( 'change', '.generatepress-font-family select',
|
||||
function() {
|
||||
var _this = jQuery( this ),
|
||||
_value = _this.val(),
|
||||
_categoryID = _this.attr( 'data-category' ),
|
||||
_variantsID = _this.attr( 'data-variants' );
|
||||
|
||||
// Set our font family
|
||||
control.settings['family'].set( _this.val() );
|
||||
|
||||
// Bail if our controls don't exist
|
||||
if ( 'undefined' == typeof control.settings['category'] || 'undefined' == typeof control.settings['variant'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout( function() {
|
||||
// Send our request to the generate_get_all_google_fonts_ajax function
|
||||
var response = jQuery.getJSON({
|
||||
type: 'POST',
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
action: 'generate_get_all_google_fonts_ajax',
|
||||
gp_customize_nonce: gp_customize.nonce
|
||||
},
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
});
|
||||
|
||||
// Get our response
|
||||
var fonts = response.responseJSON;
|
||||
|
||||
// Create an ID from our selected font
|
||||
var id = _value.split(' ').join('_').toLowerCase();
|
||||
|
||||
// Set our values if we have them
|
||||
if ( id in fonts ) {
|
||||
|
||||
// Get existing variants if this font is already selected
|
||||
var got_variants = false;
|
||||
jQuery( '.generatepress-font-family select' ).not( _this ).each( function( key, select ) {
|
||||
var parent = jQuery( this ).closest( '.generatepress-font-family' );
|
||||
|
||||
if ( _value == jQuery( select ).val() && _this.data( 'category' ) !== jQuery( select ).data( 'category' ) ) {
|
||||
if ( ! got_variants ) {
|
||||
updated_variants = jQuery( parent.next( '.generatepress-font-variant' ).find( 'select' ) ).val();
|
||||
got_variants = true;
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// We're using a Google font, so show the variants field
|
||||
_this.closest( '.generatepress-font-family' ).next( 'div' ).show();
|
||||
|
||||
// Remove existing variants
|
||||
jQuery( 'select[name="' + _variantsID + '"]' ).find( 'option' ).remove();
|
||||
|
||||
// Populate our select input with available variants
|
||||
jQuery.each( fonts[ id ].variants, function( key, value ) {
|
||||
jQuery( 'select[name="' + _variantsID + '"]' ).append( jQuery( '<option></option>' ).attr( 'value', value ).text( value ) );
|
||||
} );
|
||||
|
||||
// Set our variants
|
||||
if ( ! got_variants ) {
|
||||
control.settings[ 'variant' ].set( fonts[ id ].variants );
|
||||
} else {
|
||||
control.settings[ 'variant' ].set( updated_variants );
|
||||
}
|
||||
|
||||
// Set our font category
|
||||
control.settings[ 'category' ].set( fonts[ id ].category );
|
||||
jQuery( 'input[name="' + _categoryID + '"' ).val( fonts[ id ].category );
|
||||
} else {
|
||||
_this.closest( '.generatepress-font-family' ).next( 'div' ).hide();
|
||||
control.settings[ 'category' ].set( '' )
|
||||
control.settings[ 'variant' ].set( '' )
|
||||
jQuery( 'input[name="' + _categoryID + '"' ).val( '' );
|
||||
jQuery( 'select[name="' + _variantsID + '"]' ).find( 'option' ).remove();
|
||||
}
|
||||
}, 25 );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change', '.generatepress-font-variant select',
|
||||
function() {
|
||||
var _this = jQuery( this );
|
||||
var variants = _this.val();
|
||||
|
||||
control.settings['variant'].set( variants );
|
||||
|
||||
jQuery( '.generatepress-font-variant select' ).each( function( key, value ) {
|
||||
var this_control = jQuery( this ).closest( 'li' ).attr( 'id' ).replace( 'customize-control-', '' );
|
||||
var parent = jQuery( this ).closest( '.generatepress-font-variant' );
|
||||
var font_val = api.control( this_control ).settings['family'].get();
|
||||
|
||||
if ( font_val == control.settings['family'].get() && _this.attr( 'name' ) !== jQuery( value ).attr( 'name' ) ) {
|
||||
jQuery( parent.find( 'select' ) ).not( _this ).val( variants ).triggerHandler( 'change' );
|
||||
api.control( this_control ).settings['variant'].set( variants );
|
||||
}
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change', '.generatepress-font-category input',
|
||||
function() {
|
||||
control.settings['category'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change', '.generatepress-font-weight select',
|
||||
function() {
|
||||
control.settings['weight'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
control.container.on( 'change', '.generatepress-font-transform select',
|
||||
function() {
|
||||
control.settings['transform'].set( jQuery( this ).val() );
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
} );
|
||||
|
||||
} )( wp.customize );
|
||||
|
||||
jQuery( document ).ready( function($) {
|
||||
|
||||
jQuery( '.generatepress-font-family select' ).selectWoo();
|
||||
jQuery( '.generatepress-font-variant' ).each( function( key, value ) {
|
||||
var _this = $( this );
|
||||
var value = _this.data( 'saved-value' );
|
||||
if ( value ) {
|
||||
value = value.toString().split( ',' );
|
||||
}
|
||||
_this.find( 'select' ).selectWoo().val( value ).trigger( 'change.select2' );
|
||||
} );
|
||||
|
||||
$( ".generatepress-font-family" ).each( function( key, value ) {
|
||||
var _this = $( this );
|
||||
if ( $.inArray( _this.find( 'select' ).val(), typography_defaults ) !== -1 ) {
|
||||
_this.next( '.generatepress-font-variant' ).hide();
|
||||
}
|
||||
});
|
||||
|
||||
} );
|
324
wp-content/plugins/gp-premium/library/customizer/deprecated.php
Normal file
324
wp-content/plugins/gp-premium/library/customizer/deprecated.php
Normal file
@ -0,0 +1,324 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_backgrounds_sanitize_choices' ) ) :
|
||||
/**
|
||||
* Sanitize choices
|
||||
*/
|
||||
function generate_backgrounds_sanitize_choices( $input, $setting ) {
|
||||
|
||||
// Ensure input is a slug
|
||||
$input = sanitize_text_field( $input );
|
||||
|
||||
// Get list of choices from the control
|
||||
// associated with the setting
|
||||
$choices = $setting->manager->get_control( $setting->id )->choices;
|
||||
|
||||
// If the input is a valid key, return it;
|
||||
// otherwise, return the default
|
||||
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_backgrounds_is_top_bar_active' ) ) :
|
||||
/**
|
||||
* Check to see if the top bar is active
|
||||
*
|
||||
* @since 1.3.45
|
||||
*/
|
||||
function generate_backgrounds_is_top_bar_active()
|
||||
{
|
||||
$top_bar = is_active_sidebar( 'top-bar' ) ? true : false;
|
||||
return apply_filters( 'generate_is_top_bar_active', $top_bar );
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_blog_sanitize_choices' ) ) :
|
||||
/**
|
||||
* Sanitize choices
|
||||
*/
|
||||
function generate_blog_sanitize_choices( $input, $setting ) {
|
||||
|
||||
// Ensure input is a slug
|
||||
$input = sanitize_key( $input );
|
||||
|
||||
// Get list of choices from the control
|
||||
// associated with the setting
|
||||
$choices = $setting->manager->get_control( $setting->id )->choices;
|
||||
|
||||
// If the input is a valid key, return it;
|
||||
// otherwise, return the default
|
||||
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_blog_is_posts_page' ) ) :
|
||||
/**
|
||||
* Check to see if we're on a posts page
|
||||
*/
|
||||
function generate_blog_is_posts_page()
|
||||
{
|
||||
$blog = ( is_home() || is_archive() || is_attachment() || is_tax() ) ? true : false;
|
||||
|
||||
return $blog;
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_blog_is_posts_page_single' ) ) :
|
||||
/**
|
||||
* Check to see if we're on a posts page or a single post
|
||||
*/
|
||||
function generate_blog_is_posts_page_single()
|
||||
{
|
||||
$blog = ( is_home() || is_archive() || is_attachment() || is_tax() || is_single() ) ? true : false;
|
||||
|
||||
return $blog;
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_blog_is_excerpt' ) ) :
|
||||
/**
|
||||
* Check to see if we're displaying excerpts
|
||||
*/
|
||||
function generate_blog_is_excerpt()
|
||||
{
|
||||
if ( ! function_exists( 'generate_get_defaults' ) )
|
||||
return;
|
||||
|
||||
$generate_settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
generate_get_defaults()
|
||||
);
|
||||
|
||||
return ( 'excerpt' == $generate_settings['post_content'] ) ? true : false;
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_colors_sanitize_hex_color' ) ) :
|
||||
/**
|
||||
* Sanitize hex colors
|
||||
* We don't use the core function as we want to allow empty values
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_colors_sanitize_hex_color( $color ) {
|
||||
if ( '' === $color )
|
||||
return '';
|
||||
|
||||
// 3 or 6 hex digits, or the empty string.
|
||||
if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) )
|
||||
return $color;
|
||||
|
||||
return '';
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_colors_sanitize_rgba' ) ) :
|
||||
/**
|
||||
* Sanitize RGBA colors
|
||||
* @since 1.3.42
|
||||
*/
|
||||
function generate_colors_sanitize_rgba( $color ) {
|
||||
if ( '' === $color )
|
||||
return '';
|
||||
|
||||
// If string does not start with 'rgba', then treat as hex
|
||||
// sanitize the hex color and finally convert hex to rgba
|
||||
if ( false === strpos( $color, 'rgba' ) ) {
|
||||
return generate_colors_sanitize_hex_color( $color );
|
||||
}
|
||||
|
||||
// By now we know the string is formatted as an rgba color so we need to further sanitize it.
|
||||
$color = str_replace( ' ', '', $color );
|
||||
sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
|
||||
return 'rgba('.$red.','.$green.','.$blue.','.$alpha.')';
|
||||
|
||||
return '';
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_menu_plus_sanitize_choices' ) ) :
|
||||
/**
|
||||
* Sanitize choices
|
||||
*/
|
||||
function generate_menu_plus_sanitize_choices( $input, $setting ) {
|
||||
|
||||
// Ensure input is a slug
|
||||
$input = sanitize_key( $input );
|
||||
|
||||
// Get list of choices from the control
|
||||
// associated with the setting
|
||||
$choices = $setting->manager->get_control( $setting->id )->choices;
|
||||
|
||||
// If the input is a valid key, return it;
|
||||
// otherwise, return the default
|
||||
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_is_posts_page' ) ) :
|
||||
/**
|
||||
* This is an active_callback
|
||||
* Check if we're on a posts page
|
||||
*/
|
||||
function generate_page_header_is_posts_page()
|
||||
{
|
||||
$blog = ( is_home() || is_archive() || is_attachment() || is_tax() ) ? true : false;
|
||||
|
||||
return $blog;
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_is_posts_page_single' ) ) :
|
||||
/**
|
||||
* Check to see if we're on a posts page or a single post
|
||||
*/
|
||||
function generate_page_header_is_posts_page_single()
|
||||
{
|
||||
$blog = ( is_home() || is_archive() || is_attachment() || is_tax() || is_single() ) ? true : false;
|
||||
|
||||
return $blog;
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_secondary_nav_sanitize_choices' ) ) :
|
||||
/**
|
||||
* Sanitize choices
|
||||
*/
|
||||
function generate_secondary_nav_sanitize_choices( $input, $setting ) {
|
||||
|
||||
// Ensure input is a slug
|
||||
$input = sanitize_key( $input );
|
||||
|
||||
// Get list of choices from the control
|
||||
// associated with the setting
|
||||
$choices = $setting->manager->get_control( $setting->id )->choices;
|
||||
|
||||
// If the input is a valid key, return it;
|
||||
// otherwise, return the default
|
||||
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_spacing_sanitize_choices' ) ) :
|
||||
/**
|
||||
* Sanitize choices
|
||||
*/
|
||||
function generate_spacing_sanitize_choices( $input, $setting ) {
|
||||
|
||||
// Ensure input is a slug
|
||||
$input = sanitize_key( $input );
|
||||
|
||||
// Get list of choices from the control
|
||||
// associated with the setting
|
||||
$choices = $setting->manager->get_control( $setting->id )->choices;
|
||||
|
||||
// If the input is a valid key, return it;
|
||||
// otherwise, return the default
|
||||
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_premium_sanitize_typography' ) ) :
|
||||
/**
|
||||
* Sanitize typography dropdown
|
||||
* @since 1.1.10
|
||||
* @deprecated 1.2.95
|
||||
*/
|
||||
function generate_premium_sanitize_typography( $input )
|
||||
{
|
||||
if ( ! function_exists( 'generate_get_all_google_fonts' ) || ! function_exists( 'generate_typography_default_fonts' ) ) {
|
||||
return 'Open Sans';
|
||||
}
|
||||
|
||||
// Grab all of our fonts
|
||||
$fonts = generate_get_all_google_fonts();
|
||||
|
||||
// Loop through all of them and grab their names
|
||||
$font_names = array();
|
||||
foreach ( $fonts as $k => $fam ) {
|
||||
$font_names[] = $fam['name'];
|
||||
}
|
||||
|
||||
// Get all non-Google font names
|
||||
$not_google = generate_typography_default_fonts();
|
||||
|
||||
// Merge them both into one array
|
||||
$valid = array_merge( $font_names, $not_google );
|
||||
|
||||
// Sanitize
|
||||
if ( in_array( $input, $valid ) ) {
|
||||
return $input;
|
||||
} else {
|
||||
return 'Open Sans';
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_typography_sanitize_choices' ) ) :
|
||||
/**
|
||||
* Sanitize choices
|
||||
* @since 1.3.24
|
||||
*/
|
||||
function generate_typography_sanitize_choices( $input, $setting ) {
|
||||
|
||||
// Ensure input is a slug
|
||||
$input = sanitize_key( $input );
|
||||
|
||||
// Get list of choices from the control
|
||||
// associated with the setting
|
||||
$choices = $setting->manager->get_control( $setting->id )->choices;
|
||||
|
||||
// If the input is a valid key, return it;
|
||||
// otherwise, return the default
|
||||
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_sanitize_choices' ) ) :
|
||||
/**
|
||||
* Sanitize our select inputs
|
||||
*/
|
||||
function generate_page_header_sanitize_choices( $input, $setting ) {
|
||||
|
||||
// Ensure input is a slug
|
||||
$input = sanitize_key( $input );
|
||||
|
||||
// Get list of choices from the control
|
||||
// associated with the setting
|
||||
$choices = $setting->manager->get_control( $setting->id )->choices;
|
||||
|
||||
// If the input is a valid key, return it;
|
||||
// otherwise, return the default
|
||||
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_sanitize_hex_color' ) ) :
|
||||
/**
|
||||
* Sanitize colors
|
||||
* We don't use the core function as we want to allow empty values
|
||||
*/
|
||||
function generate_page_header_sanitize_hex_color( $color ) {
|
||||
if ( '' === $color )
|
||||
return '';
|
||||
|
||||
// 3 or 6 hex digits, or the empty string.
|
||||
if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) )
|
||||
return $color;
|
||||
|
||||
return '';
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_sanitize_html' ) ) :
|
||||
/**
|
||||
* Sanitize our fields that accept HTML
|
||||
*/
|
||||
function generate_page_header_sanitize_html( $input )
|
||||
{
|
||||
return wp_kses_post( $input );
|
||||
}
|
||||
endif;
|
131
wp-content/plugins/gp-premium/library/customizer/sanitize.php
Normal file
131
wp-content/plugins/gp-premium/library/customizer/sanitize.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_sanitize_empty_absint' ) ) {
|
||||
function generate_premium_sanitize_empty_absint( $input ) {
|
||||
if ( '' == $input ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return absint( $input );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_sanitize_choices' ) ) {
|
||||
/**
|
||||
* Sanitize choices
|
||||
*/
|
||||
function generate_premium_sanitize_choices( $input, $setting ) {
|
||||
|
||||
// Ensure input is a slug
|
||||
$input = sanitize_key( $input );
|
||||
|
||||
// Get list of choices from the control
|
||||
// associated with the setting
|
||||
$choices = $setting->manager->get_control( $setting->id )->choices;
|
||||
|
||||
// If the input is a valid key, return it;
|
||||
// otherwise, return the default
|
||||
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_sanitize_checkbox' ) ) {
|
||||
/**
|
||||
* Sanitize checkbox
|
||||
*/
|
||||
function generate_premium_sanitize_checkbox( $checked ) {
|
||||
// Boolean check.
|
||||
return ( ( isset( $checked ) && true == $checked ) ? true : false );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_sanitize_hex_color' ) ) {
|
||||
/**
|
||||
* Sanitize hex colors
|
||||
* We don't use the core function as we want to allow empty values
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_premium_sanitize_hex_color( $color ) {
|
||||
if ( '' === $color ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// 3 or 6 hex digits, or the empty string.
|
||||
if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
|
||||
return $color;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_sanitize_rgba' ) ) {
|
||||
/**
|
||||
* Sanitize RGBA colors
|
||||
*
|
||||
* @since 1.3.42
|
||||
*/
|
||||
function generate_premium_sanitize_rgba( $color ) {
|
||||
if ( '' === $color ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// If string does not start with 'rgba', then treat as hex
|
||||
// sanitize the hex color and finally convert hex to rgba
|
||||
if ( false === strpos( $color, 'rgba' ) ) {
|
||||
return generate_premium_sanitize_hex_color( $color );
|
||||
}
|
||||
|
||||
// By now we know the string is formatted as an rgba color so we need to further sanitize it.
|
||||
$color = str_replace( ' ', '', $color );
|
||||
sscanf( $color, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
|
||||
return 'rgba('.$red.','.$green.','.$blue.','.$alpha.')';
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_sanitize_decimal_integer' ) ) {
|
||||
/**
|
||||
* Sanitize integers that can use decimals
|
||||
*
|
||||
* @since 1.3.41
|
||||
*/
|
||||
function generate_premium_sanitize_decimal_integer( $input ) {
|
||||
return abs( floatval( $input ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize integers that can use decimals
|
||||
* @since 1.4
|
||||
*/
|
||||
function generate_premium_sanitize_decimal_integer_empty( $input ) {
|
||||
if ( '' == $input ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return abs( floatval( $input ) );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_sanitize_html' ) ) {
|
||||
/**
|
||||
* Sanitize our fields that accept HTML
|
||||
*/
|
||||
function generate_premium_sanitize_html( $input ) {
|
||||
return wp_kses_post( $input );
|
||||
}
|
||||
}
|
||||
|
||||
function generate_premium_sanitize_variants( $input ) {
|
||||
if ( is_array( $input ) ) {
|
||||
$input = implode( ',', $input );
|
||||
}
|
||||
|
||||
return sanitize_text_field( $input );
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2016 Delicious Brains. All rights reserved.
|
||||
*
|
||||
* Released under the GPL license
|
||||
* http://www.opensource.org/licenses/gpl-license.php
|
||||
*/
|
||||
|
||||
defined( 'WPINC' ) or die;
|
||||
|
||||
require_once GP_LIBRARY_DIRECTORY . 'batch-processing/wp-async-request.php';
|
||||
require_once GP_LIBRARY_DIRECTORY . 'batch-processing/wp-background-process.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . 'includes/class-ipq-process.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . 'includes/class-image-processing-queue.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . 'includes/ipq-template-functions.php';
|
||||
|
||||
Image_Processing_Queue::instance();
|
@ -0,0 +1,277 @@
|
||||
<?php
|
||||
/**
|
||||
* Image Processing Queue
|
||||
*
|
||||
* @package Image-Processing-Queue
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'Image_Processing_Queue' ) ) {
|
||||
|
||||
/**
|
||||
* Image Processing Queue
|
||||
*/
|
||||
class Image_Processing_Queue {
|
||||
|
||||
/**
|
||||
* Singleton
|
||||
*
|
||||
* @var Image_Processing_Queue|null
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* Whether or not we're updating the backup sizes
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $is_updating_backup_sizes = false;
|
||||
|
||||
/**
|
||||
* Instance of the background process class
|
||||
*
|
||||
* @var IPQ_Process|null
|
||||
*/
|
||||
public $process = null;
|
||||
|
||||
/**
|
||||
* Singleton
|
||||
*
|
||||
* @return Image_Processing_Queue|null
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Image_Processing_Queue constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->process = new IPQ_Process();
|
||||
add_filter( 'update_post_metadata', array( $this, 'filter_update_post_metadata' ), 10, 5 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the post meta data for backup sizes
|
||||
*
|
||||
* Unfortunately WordPress core is lacking hooks in its image resizing functions so we are reduced
|
||||
* to this hackery to detect when images are resized and previous versions are relegated to backup sizes.
|
||||
*
|
||||
* @param bool $check
|
||||
* @param int $object_id
|
||||
* @param string $meta_key
|
||||
* @param mixed $meta_value
|
||||
* @param mixed $prev_value
|
||||
* @return bool
|
||||
*/
|
||||
public function filter_update_post_metadata( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
|
||||
if ( '_wp_attachment_backup_sizes' !== $meta_key ) {
|
||||
return $check;
|
||||
}
|
||||
|
||||
$current_value = get_post_meta( $object_id, $meta_key, true );
|
||||
|
||||
if ( ! $current_value ) {
|
||||
$current_value = array();
|
||||
}
|
||||
|
||||
$diff = array_diff_key( $meta_value, $current_value );
|
||||
|
||||
if ( ! $diff ) {
|
||||
return $check;
|
||||
}
|
||||
|
||||
$key = key( $diff );
|
||||
$suffix = substr( $key, strrpos( $key, '-' ) + 1 );
|
||||
|
||||
$image_meta = self::get_image_meta( $object_id );
|
||||
|
||||
foreach ( $image_meta['sizes'] as $size_name => $size ) {
|
||||
if ( 0 !== strpos( $size_name, 'ipq-' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$meta_value[ $size_name . '-' . $suffix ] = $size;
|
||||
unset( $image_meta['sizes'][ $size_name ] );
|
||||
}
|
||||
|
||||
if ( ! $this->is_updating_backup_sizes ) {
|
||||
$this->is_updating_backup_sizes = true;
|
||||
update_post_meta( $object_id, '_wp_attachment_backup_sizes', $meta_value );
|
||||
wp_update_attachment_metadata( $object_id, $image_meta );
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->is_updating_backup_sizes = false;
|
||||
|
||||
return $check;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the image sizes exist and push them to the queue if not.
|
||||
*
|
||||
* @param int $post_id
|
||||
* @param array $sizes
|
||||
*/
|
||||
protected function process_image( $post_id, $sizes ) {
|
||||
$new_item = false;
|
||||
|
||||
foreach ( $sizes as $size ) {
|
||||
if ( self::does_size_already_exist_for_image( $post_id, $size ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( self::is_size_larger_than_original( $post_id, $size ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
'post_id' => $post_id,
|
||||
'width' => $size[0],
|
||||
'height' => $size[1],
|
||||
'crop' => $size[2],
|
||||
);
|
||||
$this->process->push_to_queue( $item );
|
||||
$new_item = true;
|
||||
}
|
||||
|
||||
if ( $new_item ) {
|
||||
$this->process->save()->dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image HTML for a specific context in a theme, specifying the exact sizes
|
||||
* for the image. The first image size is always used as the `src` and the other
|
||||
* sizes are used in the `srcset` if they're the same aspect ratio as the original
|
||||
* image. If any of the image sizes don't currently exist, they are queued for
|
||||
* creation by a background process. Example:
|
||||
*
|
||||
* echo ipq_get_theme_image( 1353, array(
|
||||
* array( 600, 400, false ),
|
||||
* array( 1280, 720, false ),
|
||||
* array( 1600, 1067, false ),
|
||||
* ),
|
||||
* array(
|
||||
* 'class' => 'header-banner'
|
||||
* )
|
||||
* );
|
||||
*
|
||||
* @param int $post_id Image attachment ID.
|
||||
* @param array $sizes Array of arrays of sizes in the format array(width,height,crop).
|
||||
* @param string $attr Optional. Attributes for the image markup. Default empty.
|
||||
* @return string HTML img element or empty string on failure.
|
||||
*/
|
||||
public function get_image( $post_id, $sizes, $attr = '' ) {
|
||||
$this->process_image( $post_id, $sizes );
|
||||
|
||||
return wp_get_attachment_image( $post_id, array( $sizes[0][0], $sizes[0][1] ), false, $attr );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image URL for a specific context in a theme, specifying the exact size
|
||||
* for the image. If the image size does not currently exist, it is queued for
|
||||
* creation by a background process. Example:
|
||||
*
|
||||
* echo ipq_get_theme_image_url( 1353, array( 600, 400, false ) );
|
||||
*
|
||||
* @param int $post_id
|
||||
* @param array $size
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_image_url( $post_id, $size ) {
|
||||
$this->process_image( $post_id, array( $size ) );
|
||||
|
||||
$size = self::get_size_name( $size );
|
||||
$src = wp_get_attachment_image_src( $post_id, $size );
|
||||
|
||||
if ( isset( $src[0] ) ) {
|
||||
return $src[0];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array index name for image size.
|
||||
*
|
||||
* @param array $size array in format array(width,height,crop).
|
||||
* @return string Image size name.
|
||||
*/
|
||||
public static function get_size_name( $size ) {
|
||||
$crop = $size[2] ? 'true' : 'false';
|
||||
return 'ipq-' . $size[0] . 'x' . $size[1] . '-' . $crop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an image's file path.
|
||||
*
|
||||
* @param int $post_id ID of the image post.
|
||||
* @return false|string
|
||||
*/
|
||||
public static function get_image_path( $post_id ) {
|
||||
return get_attached_file( $post_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an image's post meta data.
|
||||
*
|
||||
* @param int $post_id ID of the image post.
|
||||
* @return mixed Post meta field. False on failure.
|
||||
*/
|
||||
public static function get_image_meta( $post_id ) {
|
||||
return wp_get_attachment_metadata( $post_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update meta data for an image
|
||||
*
|
||||
* @param int $post_id Image ID.
|
||||
* @param array $data Image data.
|
||||
* @return bool|int False if $post is invalid.
|
||||
*/
|
||||
public static function update_image_meta( $post_id, $data ) {
|
||||
return wp_update_attachment_metadata( $post_id, $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an image size already exists for an image
|
||||
*
|
||||
* @param int $post_id Image ID.
|
||||
* @param array $size array in format array(width,height,crop).
|
||||
* @return bool
|
||||
*/
|
||||
public static function does_size_already_exist_for_image( $post_id, $size ) {
|
||||
$image_meta = self::get_image_meta( $post_id );
|
||||
$size_name = self::get_size_name( $size );
|
||||
|
||||
return isset( $image_meta['sizes'][ $size_name ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an image size is larger than the original.
|
||||
*
|
||||
* @param int $post_id Image ID.
|
||||
* @param array $size array in format array(width,height,crop).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_size_larger_than_original( $post_id, $size ) {
|
||||
$image_meta = self::get_image_meta( $post_id );
|
||||
|
||||
if ( ! isset( $image_meta['width'] ) || ! isset( $image_meta['height'] ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( $size[0] > $image_meta['width'] || $size[1] > $image_meta['height'] ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* Background Process for Image Processing Queue
|
||||
*
|
||||
* @package Image-Processing-Queue
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'IPQ_Process' ) ) {
|
||||
|
||||
/**
|
||||
* Custom exception class for IPQ background processing
|
||||
*/
|
||||
class IPQ_Process_Exception extends Exception {}
|
||||
|
||||
/**
|
||||
* Extends the background processing library and implements image processing routines
|
||||
*/
|
||||
class IPQ_Process extends WP_Background_Process {
|
||||
/**
|
||||
* Action
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $action = 'image_processing_queue';
|
||||
|
||||
/**
|
||||
* Background task to resizes images
|
||||
*
|
||||
* @param mixed $item Image data.
|
||||
* @return bool
|
||||
* @throws IPQ_Process_Exception On error.
|
||||
*/
|
||||
protected function task( $item ) {
|
||||
$defaults = array(
|
||||
'post_id' => 0,
|
||||
'width' => 0,
|
||||
'height' => 0,
|
||||
'crop' => false,
|
||||
);
|
||||
$item = wp_parse_args( $item, $defaults );
|
||||
|
||||
$post_id = $item['post_id'];
|
||||
$width = $item['width'];
|
||||
$height = $item['height'];
|
||||
$crop = $item['crop'];
|
||||
|
||||
if ( ! $width && ! $height ) {
|
||||
throw new IPQ_Process_Exception( "Invalid dimensions '{$width}x{$height}'" );
|
||||
}
|
||||
|
||||
if ( Image_Processing_Queue::does_size_already_exist_for_image( $post_id, array( $width, $height, $crop ) ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$image_meta = Image_Processing_Queue::get_image_meta( $post_id );
|
||||
|
||||
if ( ! $image_meta ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
add_filter( 'as3cf_get_attached_file_copy_back_to_local', '__return_true' );
|
||||
$img_path = Image_Processing_Queue::get_image_path( $post_id );
|
||||
|
||||
if ( ! $img_path ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$editor = wp_get_image_editor( $img_path );
|
||||
|
||||
if ( is_wp_error( $editor ) ) {
|
||||
throw new IPQ_Process_Exception( 'Unable to get WP_Image_Editor for file "' . $img_path . '": ' . $editor->get_error_message() . ' (is GD or ImageMagick installed?)' );
|
||||
}
|
||||
|
||||
if ( is_wp_error( $editor->resize( $width, $height, $crop ) ) ) {
|
||||
throw new IPQ_Process_Exception( 'Error resizing image: ' . $editor->get_error_message() );
|
||||
}
|
||||
|
||||
$resized_file = $editor->save();
|
||||
|
||||
if ( is_wp_error( $resized_file ) ) {
|
||||
throw new IPQ_Process_Exception( 'Unable to save resized image file: ' . $editor->get_error_message() );
|
||||
}
|
||||
|
||||
$size_name = Image_Processing_Queue::get_size_name( array( $width, $height, $crop ) );
|
||||
$image_meta['sizes'][ $size_name ] = array(
|
||||
'file' => $resized_file['file'],
|
||||
'width' => $resized_file['width'],
|
||||
'height' => $resized_file['height'],
|
||||
'mime-type' => $resized_file['mime-type'],
|
||||
);
|
||||
wp_update_attachment_metadata( $post_id, $image_meta );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
if ( ! function_exists( 'ipq_get_theme_image' ) ) {
|
||||
/**
|
||||
* Get image HTML for a specific context in a theme, specifying the exact sizes
|
||||
* for the image. The first image size is always used as the `src` and the other
|
||||
* sizes are used in the `srcset` if they're the same aspect ratio as the original
|
||||
* image. If any of the image sizes don't currently exist, they are queued for
|
||||
* creation by a background process. Example:
|
||||
*
|
||||
* echo ipq_get_theme_image( 1353, array(
|
||||
* array( 600, 400, false ),
|
||||
* array( 1280, 720, false ),
|
||||
* array( 1600, 1067, false ),
|
||||
* ),
|
||||
* array(
|
||||
* 'class' => 'header-banner'
|
||||
* )
|
||||
* );
|
||||
*
|
||||
* @param int $post_id Image attachment ID.
|
||||
* @param array $sizes Array of arrays of sizes in the format array(width,height,crop).
|
||||
* @param string $attr Optional. Attributes for the image markup. Default empty.
|
||||
*
|
||||
* @return string HTML img element or empty string on failure.
|
||||
*/
|
||||
function ipq_get_theme_image( $post_id, $sizes, $attr = '' ) {
|
||||
return Image_Processing_Queue::instance()->get_image( $post_id, $sizes, $attr );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'ipq_get_theme_image_url' ) ) {
|
||||
/**
|
||||
* Get image URL for a specific context in a theme, specifying the exact size
|
||||
* for the image. If the image size does not currently exist, it is queued for
|
||||
* creation by a background process. Example:
|
||||
*
|
||||
* echo ipq_get_theme_image_url( 1353, array( 600, 400, false ) );
|
||||
*
|
||||
* @param int $post_id
|
||||
* @param array $size
|
||||
*
|
||||
* @return string Img URL
|
||||
*/
|
||||
function ipq_get_theme_image_url( $post_id, $size ) {
|
||||
return Image_Processing_Queue::instance()->get_image_url( $post_id, $size );
|
||||
}
|
||||
}
|
1
wp-content/plugins/gp-premium/library/select2/select2.full.min.js
vendored
Normal file
1
wp-content/plugins/gp-premium/library/select2/select2.full.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
wp-content/plugins/gp-premium/library/select2/select2.min.css
vendored
Normal file
1
wp-content/plugins/gp-premium/library/select2/select2.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user