modified file w3-total-cache

This commit is contained in:
2024-03-28 09:40:10 +00:00
committed by Gitium
parent 218272bbcb
commit 34dbbce9b4
3707 changed files with 392891 additions and 166170 deletions

View File

@ -1,250 +0,0 @@
function gp_premium_typography_live_update( id, selector, property, unit, media, settings ) {
settings = typeof settings !== 'undefined' ? settings : 'generate_settings';
wp.customize( settings + '[' + id + ']', function( value ) {
value.bind( function( newval ) {
// Get our unit if applicable
unit = typeof unit !== 'undefined' ? unit : '';
var isTablet = ( 'tablet' == id.substring( 0, 6 ) ) ? true : false,
isMobile = ( 'mobile' == id.substring( 0, 6 ) ) ? true : false;
if ( isTablet ) {
if ( '' == wp.customize(settings + '[' + id + ']').get() ) {
var desktopID = id.replace( 'tablet_', '' );
newval = wp.customize(settings + '[' + desktopID + ']').get();
}
}
if ( isMobile ) {
if ( '' == wp.customize(settings + '[' + id + ']').get() ) {
var desktopID = id.replace( 'mobile_', '' );
newval = wp.customize(settings + '[' + desktopID + ']').get();
}
}
if ( 'buttons_font_size' == id && '' == wp.customize('generate_settings[buttons_font_size]').get() ) {
newval = wp.customize('generate_settings[body_font_size]').get();
}
if ( 'single_post_title_weight' == id && '' == wp.customize('generate_settings[single_post_title_weight]').get() ) {
newval = wp.customize('generate_settings[heading_1_weight]').get();
}
if ( 'single_post_title_transform' == id && '' == wp.customize('generate_settings[single_post_title_transform]').get() ) {
newval = wp.customize('generate_settings[heading_1_transform]').get();
}
if ( 'archive_post_title_weight' == id && '' == wp.customize('generate_settings[archive_post_title_weight]').get() ) {
newval = wp.customize('generate_settings[heading_2_weight]').get();
}
if ( 'archive_post_title_transform' == id && '' == wp.customize('generate_settings[archive_post_title_transform]').get() ) {
newval = wp.customize('generate_settings[heading_2_transform]').get();
}
// We're using a desktop value
if ( ! isTablet && ! isMobile ) {
var tabletValue = ( typeof wp.customize(settings + '[tablet_' + id + ']') !== 'undefined' ) ? wp.customize(settings + '[tablet_' + id + ']').get() : '',
mobileValue = ( typeof wp.customize(settings + '[mobile_' + id + ']') !== 'undefined' ) ? wp.customize(settings + '[mobile_' + id + ']').get() : '';
// The tablet setting exists, mobile doesn't
if ( '' !== tabletValue && '' == mobileValue ) {
media = gp_typography.desktop + ', ' + gp_typography.mobile;
}
// The tablet setting doesn't exist, mobile does
if ( '' == tabletValue && '' !== mobileValue ) {
media = gp_typography.desktop + ', ' + gp_typography.tablet;
}
// The tablet setting doesn't exist, neither does mobile
if ( '' == tabletValue && '' == mobileValue ) {
media = gp_typography.desktop + ', ' + gp_typography.tablet + ', ' + gp_typography.mobile;
}
}
// Check if media query
media_query = typeof media !== 'undefined' ? 'media="' + media + '"' : '';
jQuery( 'head' ).append( '<style id="' + id + '" ' + media_query + '>' + selector + '{' + property + ':' + newval + unit + ';}</style>' );
setTimeout(function() {
jQuery( 'style#' + id ).not( ':last' ).remove();
}, 1000);
setTimeout("jQuery('body').trigger('generate_spacing_updated');", 1000);
} );
} );
}
/**
* Body font size, weight and transform
*/
gp_premium_typography_live_update( 'body_font_size', 'body, button, input, select, textarea', 'font-size', 'px' );
gp_premium_typography_live_update( 'body_line_height', 'body', 'line-height', '' );
gp_premium_typography_live_update( 'paragraph_margin', 'p, .entry-content > [class*="wp-block-"]:not(:last-child)', 'margin-bottom', 'em' );
gp_premium_typography_live_update( 'body_font_weight', 'body, button, input, select, textarea', 'font-weight' );
gp_premium_typography_live_update( 'body_font_transform', 'body, button, input, select, textarea', 'text-transform' );
/**
* Top bar font size, weight and transform
*/
gp_premium_typography_live_update( 'top_bar_font_size', '.top-bar', 'font-size', 'px' );
gp_premium_typography_live_update( 'top_bar_font_weight', '.top-bar', 'font-weight' );
gp_premium_typography_live_update( 'top_bar_font_transform', '.top-bar', 'text-transform' );
/**
* Site title font size, weight and transform
*/
gp_premium_typography_live_update( 'site_title_font_size', '.main-title, .navigation-branding .main-title', 'font-size', 'px', gp_typography.desktop );
gp_premium_typography_live_update( 'tablet_site_title_font_size', '.main-title, .navigation-branding .main-title', 'font-size', 'px', gp_typography.tablet );
gp_premium_typography_live_update( 'mobile_site_title_font_size', '.main-title, .navigation-branding .main-title', 'font-size', 'px', gp_typography.mobile );
gp_premium_typography_live_update( 'site_title_font_weight', '.main-title, .navigation-branding .main-title', 'font-weight' );
gp_premium_typography_live_update( 'site_title_font_transform', '.main-title, .navigation-branding .main-title', 'text-transform' );
/**
* Site description font size, weight and transform
*/
gp_premium_typography_live_update( 'site_tagline_font_size', '.site-description', 'font-size', 'px' );
gp_premium_typography_live_update( 'site_tagline_font_weight', '.site-description', 'font-weight' );
gp_premium_typography_live_update( 'site_tagline_font_transform', '.site-description', 'text-transform' );
/**
* Main navigation font size, weight and transform
*/
gp_premium_typography_live_update( 'navigation_font_size', '.main-navigation a, .menu-toggle, .main-navigation .menu-bar-items', 'font-size', 'px', gp_typography.desktop );
gp_premium_typography_live_update( 'tablet_navigation_font_size', '.main-navigation a, .menu-toggle, .main-navigation .menu-bar-items', 'font-size', 'px', gp_typography.tablet );
gp_premium_typography_live_update( 'mobile_navigation_font_size', '.main-navigation:not(.slideout-navigation) a, .menu-toggle, .main-navigation .menu-bar-items', 'font-size', 'px', gp_typography.mobile );
gp_premium_typography_live_update( 'navigation_font_weight', '.main-navigation a, .menu-toggle', 'font-weight' );
gp_premium_typography_live_update( 'navigation_font_transform', '.main-navigation a, .menu-toggle', 'text-transform' );
/**
* Site title when in navigation.
*/
gp_premium_typography_live_update( 'navigation_site_title_font_size', '.navigation-branding .main-title', 'font-size', 'px', gp_typography.desktop );
gp_premium_typography_live_update( 'tablet_navigation_site_title_font_size', '.navigation-branding .main-title', 'font-size', 'px', gp_typography.tablet );
gp_premium_typography_live_update( 'mobile_navigation_site_title_font_size', '.navigation-branding .main-title', 'font-size', 'px', gp_typography.mobile );
/**
* Secondary navigation font size, weight and transform
*/
gp_premium_typography_live_update( 'secondary_navigation_font_size', '.secondary-navigation .main-nav ul li a,.secondary-navigation .menu-toggle, .secondary-navigation .top-bar, .secondary-navigation .secondary-menu-bar-items', 'font-size', 'px', '', 'generate_secondary_nav_settings' );
gp_premium_typography_live_update( 'secondary_navigation_font_weight', '.secondary-navigation .main-nav ul li a,.secondary-navigation .menu-toggle, .secondary-navigation .top-bar', 'font-weight', '', '', 'generate_secondary_nav_settings' );
gp_premium_typography_live_update( 'secondary_navigation_font_transform', '.secondary-navigation .main-nav ul li a,.secondary-navigation .menu-toggle, .secondary-navigation .top-bar', 'text-transform', '', '', 'generate_secondary_nav_settings' );
/**
* Buttons
*/
gp_premium_typography_live_update( 'buttons_font_size', 'button:not(.menu-toggle),html input[type="button"],input[type="reset"],input[type="submit"],.button,.button:visited,.wp-block-button .wp-block-button__link,.woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button', 'font-size', 'px' );
gp_premium_typography_live_update( 'buttons_font_weight', 'button:not(.menu-toggle),html input[type="button"],input[type="reset"],input[type="submit"],.button,.button:visited,.wp-block-button .wp-block-button__link,.woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button', 'font-weight' );
gp_premium_typography_live_update( 'buttons_font_transform', 'button:not(.menu-toggle),html input[type="button"],input[type="reset"],input[type="submit"],.button,.button:visited,.wp-block-button .wp-block-button__link,.woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button', 'text-transform' );
/**
* H1 font size, weight and transform
*/
gp_premium_typography_live_update( 'heading_1_font_size', 'h1', 'font-size', 'px', gp_typography.desktop );
gp_premium_typography_live_update( 'mobile_heading_1_font_size', 'h1', 'font-size', 'px', gp_typography.mobile );
gp_premium_typography_live_update( 'heading_1_weight', 'h1', 'font-weight' );
gp_premium_typography_live_update( 'heading_1_transform', 'h1', 'text-transform' );
gp_premium_typography_live_update( 'heading_1_line_height', 'h1', 'line-height', 'em' );
gp_premium_typography_live_update( 'heading_1_margin_bottom', 'h1', 'margin-bottom', 'px' );
/**
* Single content title (h1)
*/
gp_premium_typography_live_update( 'single_post_title_font_size', 'h1.entry-title', 'font-size', 'px', gp_typography.desktop );
gp_premium_typography_live_update( 'single_post_title_font_size_mobile', 'h1.entry-title', 'font-size', 'px', gp_typography.mobile );
gp_premium_typography_live_update( 'single_post_title_weight', 'h1.entry-title', 'font-weight' );
gp_premium_typography_live_update( 'single_post_title_transform', 'h1.entry-title', 'text-transform' );
gp_premium_typography_live_update( 'single_post_title_line_height', 'h1.entry-title', 'line-height', 'em' );
/**
* H2 font size, weight and transform
*/
gp_premium_typography_live_update( 'heading_2_font_size', 'h2', 'font-size', 'px', gp_typography.desktop );
gp_premium_typography_live_update( 'mobile_heading_2_font_size', 'h2', 'font-size', 'px', gp_typography.mobile );
gp_premium_typography_live_update( 'heading_2_weight', 'h2', 'font-weight' );
gp_premium_typography_live_update( 'heading_2_transform', 'h2', 'text-transform' );
gp_premium_typography_live_update( 'heading_2_line_height', 'h2', 'line-height', 'em' );
gp_premium_typography_live_update( 'heading_2_margin_bottom', 'h2', 'margin-bottom', 'px' );
/**
* Archive post title (h1)
*/
gp_premium_typography_live_update( 'archive_post_title_font_size', 'h2.entry-title', 'font-size', 'px', gp_typography.desktop );
gp_premium_typography_live_update( 'archive_post_title_font_size_mobile', 'h2.entry-title', 'font-size', 'px', gp_typography.mobile );
gp_premium_typography_live_update( 'archive_post_title_weight', 'h2.entry-title', 'font-weight' );
gp_premium_typography_live_update( 'archive_post_title_transform', 'h2.entry-title', 'text-transform' );
gp_premium_typography_live_update( 'archive_post_title_line_height', 'h2.entry-title', 'line-height', 'em' );
/**
* H3 font size, weight and transform
*/
gp_premium_typography_live_update( 'heading_3_font_size', 'h3', 'font-size', 'px', gp_typography.desktop );
gp_premium_typography_live_update( 'mobile_heading_3_font_size', 'h3', 'font-size', 'px', gp_typography.mobile );
gp_premium_typography_live_update( 'heading_3_weight', 'h3', 'font-weight' );
gp_premium_typography_live_update( 'heading_3_transform', 'h3', 'text-transform' );
gp_premium_typography_live_update( 'heading_3_line_height', 'h3', 'line-height', 'em' );
gp_premium_typography_live_update( 'heading_3_margin_bottom', 'h3', 'margin-bottom', 'px' );
/**
* H4 font size, weight and transform
*/
gp_premium_typography_live_update( 'heading_4_font_size', 'h4', 'font-size', 'px', gp_typography.desktop );
gp_premium_typography_live_update( 'mobile_heading_4_font_size', 'h4', 'font-size', 'px', gp_typography.mobile );
gp_premium_typography_live_update( 'heading_4_weight', 'h4', 'font-weight' );
gp_premium_typography_live_update( 'heading_4_transform', 'h4', 'text-transform' );
gp_premium_typography_live_update( 'heading_4_line_height', 'h4', 'line-height', 'em' );
/**
* H5 font size, weight and transform
*/
gp_premium_typography_live_update( 'heading_5_font_size', 'h5', 'font-size', 'px', gp_typography.desktop );
gp_premium_typography_live_update( 'mobile_heading_5_font_size', 'h5', 'font-size', 'px', gp_typography.mobile );
gp_premium_typography_live_update( 'heading_5_weight', 'h5', 'font-weight' );
gp_premium_typography_live_update( 'heading_5_transform', 'h5', 'text-transform' );
gp_premium_typography_live_update( 'heading_5_line_height', 'h5', 'line-height', 'em' );
/**
* H6 font size, weight and transform
*/
gp_premium_typography_live_update( 'heading_6_font_size', 'h6', 'font-size', 'px' );
gp_premium_typography_live_update( 'heading_6_weight', 'h6', 'font-weight' );
gp_premium_typography_live_update( 'heading_6_transform', 'h6', 'text-transform' );
gp_premium_typography_live_update( 'heading_6_line_height', 'h6', 'line-height', 'em' );
/**
* Widget title font size, weight and transform
*/
gp_premium_typography_live_update( 'widget_title_font_size', '.widget-title', 'font-size', 'px' );
gp_premium_typography_live_update( 'widget_title_font_weight', '.widget-title', 'font-weight' );
gp_premium_typography_live_update( 'widget_title_font_transform', '.widget-title', 'text-transform' );
gp_premium_typography_live_update( 'widget_title_separator', '.widget-title', 'margin-bottom', 'px' );
gp_premium_typography_live_update( 'widget_content_font_size', '.sidebar .widget, .footer-widgets .widget', 'font-size', 'px' );
/**
* Footer font size, weight and transform
*/
gp_premium_typography_live_update( 'footer_font_size', '.site-info', 'font-size', 'px' );
gp_premium_typography_live_update( 'footer_weight', '.site-info', 'font-weight' );
gp_premium_typography_live_update( 'footer_transform', '.site-info', 'text-transform' );
gp_premium_typography_live_update( 'footer_line_height', '.site-info', 'line-height', 'em' );
/**
* WooCommerce product title
*/
gp_premium_typography_live_update( 'wc_product_title_font_size', '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title', 'font-size', 'px', gp_typography.desktop );
gp_premium_typography_live_update( 'mobile_wc_product_title_font_size', '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title', 'font-size', 'px', gp_typography.mobile );
gp_premium_typography_live_update( 'wc_product_title_font_weight', '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title', 'font-weight' );
gp_premium_typography_live_update( 'wc_product_title_font_transform', '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title', 'text-transform' );
gp_premium_typography_live_update( 'wc_related_product_title_font_size', '.woocommerce .up-sells ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce .cross-sells ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce .related ul.products li.product .woocommerce-LoopProduct-link h2', 'font-size', 'px' );
/**
* Slideout navigation font size, weight and transform
*/
gp_premium_typography_live_update( 'slideout_font_size', '.slideout-navigation.main-navigation .main-nav ul li a', 'font-size', 'px', gp_typography.desktop );
gp_premium_typography_live_update( 'slideout_mobile_font_size', '.slideout-navigation.main-navigation .main-nav ul li a', 'font-size', 'px', gp_typography.mobile );
gp_premium_typography_live_update( 'slideout_font_weight', '.slideout-navigation.main-navigation .main-nav ul li a', 'font-weight' );
gp_premium_typography_live_update( 'slideout_font_transform', '.slideout-navigation.main-navigation .main-nav ul li a', 'text-transform' );

View File

@ -1,359 +0,0 @@
<?php
if ( ! function_exists( 'generate_typography_convert_values' ) ) {
add_action( 'admin_init', 'generate_typography_convert_values' );
/**
* Our font family values used to have all of the variants attached to them
* This function removes those and keeps your select font family
*/
function generate_typography_convert_values() {
// Bail if we don't have our defaults
if ( ! function_exists( 'generate_get_default_fonts' ) ) {
return;
}
// If we've already ran this function, bail
if ( 'true' == get_option( 'generate_update_premium_typography' ) ) {
return;
}
// Get all settings
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_default_fonts()
);
// Get our font family keys
$font_settings = array(
'font_body',
'font_site_title',
'font_site_tagline',
'font_navigation',
'font_widget_title',
'font_heading_1',
'font_heading_2',
'font_heading_3'
);
// Create our new empty array
$new_settings = array();
// For each font family key
foreach( $font_settings as $key ) {
// Get the value of each key
$value = $generate_settings[$key];
// If our value has : in it and is not empty
if ( strpos( $value, ':' ) !== false && ! empty( $value ) ) {
// Remove the : and anything past it
$value = current( explode( ':', $value ) );
// Populate our new array with our new value
$new_settings[ $key ] = $value;
}
}
// If our new array isn't empty, update the options
if ( ! empty( $new_settings ) ) {
$generate_new_typography_settings = wp_parse_args( $new_settings, $generate_settings );
update_option( 'generate_settings', $generate_new_typography_settings );
}
// All done, set an option so we don't have to do this again
update_option( 'generate_update_premium_typography', 'true' );
}
}
if ( ! function_exists( 'generate_typography_convert_secondary_nav_values' ) ) {
add_action( 'admin_init', 'generate_typography_convert_secondary_nav_values' );
/**
* Take the old secondary navigation font value and strip it of variants
* This should only run once.
*
* @since 1.3.0
*/
function generate_typography_convert_secondary_nav_values() {
// Bail if Secondary Nav isn't active
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
return;
}
// If we've done this before, bail
if ( 'true' == get_option( 'generate_update_secondary_typography' ) ) {
return;
}
// Get all settings
$generate_secondary_nav_settings = wp_parse_args(
get_option( 'generate_secondary_nav_settings', array() ),
generate_secondary_nav_get_defaults()
);
// Get our secondary nav font family setting
$value = $generate_secondary_nav_settings[ 'font_secondary_navigation' ];
// Create a new, empty array
$new_settings = array();
// If our value has : in it, and isn't empty
if ( strpos( $value, ':' ) !== false && ! empty( $value ) ) {
// Remove the : and anything past it
$value = current( explode( ':', $value ) );
// Populate our new array with our new, clean value
$new_settings[ 'font_secondary_navigation' ] = $value;
}
// Update our options if our new array isn't empty
if ( ! empty( $new_settings ) ) {
$generate_new_typography_settings = wp_parse_args( $new_settings, $generate_secondary_nav_settings );
update_option( 'generate_secondary_nav_settings', $generate_new_typography_settings );
}
// All done, set an option so we don't go through this again
update_option( 'generate_update_secondary_typography','true' );
}
}
if ( ! function_exists( 'generate_add_to_font_customizer_list' ) ) {
add_filter( 'generate_typography_customize_list', 'generate_add_to_font_customizer_list' );
/**
* This function makes sure your selected typography option exists in the Customizer list
* The list gets updated from time to time, which means some fonts might be replaced by others.
*
* @since 1.3.40
*/
function generate_add_to_font_customizer_list( $fonts ) {
// Bail if we don't have our defaults
if ( ! function_exists( 'generate_get_default_fonts' ) ) {
return;
}
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_default_fonts()
);
$font_settings = array(
'font_body',
'font_top_bar',
'font_site_title',
'font_site_tagline',
'font_navigation',
'font_widget_title',
'font_buttons',
'font_heading_1',
'font_heading_2',
'font_heading_3',
'font_heading_4',
'font_heading_5',
'font_heading_6',
'font_footer',
);
$all_fonts = false; // We'll get this later if we need it.
$select_fonts = generate_get_all_google_fonts( apply_filters( 'generate_number_of_fonts', 200 ) );
foreach ( $font_settings as $setting ) {
// If we don't have a setting, keep going
if ( ! isset( $generate_settings[ $setting ] ) ) {
continue;
}
$id = strtolower( str_replace( ' ', '_', $generate_settings[ $setting ] ) );
if ( array_key_exists( $id, $select_fonts ) || in_array( $generate_settings[ $setting ], generate_typography_default_fonts() ) ) {
continue;
}
$variants = get_theme_mod( $setting . '_variants', array() );
$category = get_theme_mod( $setting . '_category' );
if ( ! empty( $variants ) && ! is_array( $variants ) ) {
$variants = explode( ',', $variants );
}
if ( ! $variants ) {
if ( ! $all_fonts ) {
$all_fonts = generate_get_all_google_fonts();
}
if ( array_key_exists( $id, $all_fonts ) ) {
$variants = $all_fonts[ $id ]['variants'];
}
}
if ( ! $category ) {
if ( ! $all_fonts ) {
$all_fonts = generate_get_all_google_fonts();
}
if ( array_key_exists( $id, $all_fonts ) ) {
$category = $all_fonts[ $id ]['category'];
}
}
$fonts[ $id ] = array(
'name' => $generate_settings[ $setting ],
'variants' => $variants,
'category' => $category ? $category : 'sans-serif',
);
}
if ( function_exists( 'generate_secondary_nav_get_defaults' ) ) {
$secondary_nav_settings = wp_parse_args(
get_option( 'generate_secondary_nav_settings', array() ),
generate_secondary_nav_get_defaults()
);
$secondary_nav_id = strtolower( str_replace( ' ', '_', $secondary_nav_settings[ 'font_secondary_navigation' ] ) );
if ( ! array_key_exists( $secondary_nav_id, $select_fonts ) && ! in_array( $secondary_nav_settings[ 'font_secondary_navigation' ], generate_typography_default_fonts() ) ) {
$variants = get_theme_mod( 'font_secondary_navigation_variants', array() );
$category = get_theme_mod( 'font_secondary_navigation_category' );
if ( ! empty( $variants ) && ! is_array( $variants ) ) {
$variants = explode( ',', $variants );
}
if ( ! $variants ) {
if ( ! $all_fonts ) {
$all_fonts = generate_get_all_google_fonts();
}
if ( array_key_exists( $secondary_nav_id, $all_fonts ) ) {
$variants = $all_fonts[ $secondary_nav_id ]['variants'];
}
}
if ( ! $category ) {
if ( ! $all_fonts ) {
$all_fonts = generate_get_all_google_fonts();
}
if ( array_key_exists( $secondary_nav_id, $all_fonts ) ) {
$category = $all_fonts[ $secondary_nav_id ]['category'];
}
}
$fonts[ $secondary_nav_id ] = array(
'name' => $secondary_nav_settings[ 'font_secondary_navigation' ],
'variants' => $variants,
'category' => $category ? $category : 'sans-serif',
);
}
}
return $fonts;
}
}
if ( ! function_exists( 'generate_typography_set_font_data' ) ) {
add_action( 'admin_init', 'generate_typography_set_font_data' );
/**
* This function will check to see if your category and variants are saved
* If not, it will set them for you, and won't run again
*
* @since 1.2.90
*/
function generate_typography_set_font_data() {
// Bail if we don't have our defaults
if ( ! function_exists( 'generate_get_default_fonts' ) ) {
return;
}
// Get our defaults
$defaults = generate_get_default_fonts();
// Get our settings
$generate_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_default_fonts()
);
// We need to loop through these settings
$font_settings = array(
'font_body',
'font_site_title',
'font_site_tagline',
'font_navigation',
'font_widget_title',
'font_heading_1',
'font_heading_2',
'font_heading_3'
);
// Add secondary navigation to the array last if it exists
if ( function_exists( 'generate_secondary_nav_get_defaults' ) ) {
$font_settings[ 'font_secondary_navigation' ] = 'font_secondary_navigation';
}
// Start looping
foreach( $font_settings as $setting ) {
// Change our variables for the secondary navigation - this will run last
if ( function_exists( 'generate_secondary_nav_get_defaults' ) && 'font_secondary_navigation' == $setting ) {
$generate_settings = wp_parse_args(
get_option( 'generate_secondary_nav_settings', array() ),
generate_secondary_nav_get_defaults()
);
$defaults = generate_secondary_nav_get_defaults();
}
// We don't need to do this if we're using the default font, as these values have defaults already
if ( $defaults[ $setting ] == $generate_settings[ $setting ] ) {
continue;
}
// Don't need to continue if we're using a system font or our default font
if ( in_array( $generate_settings[ $setting ], generate_typography_default_fonts() ) || 'Open Sans' == $generate_settings[ $setting ] ) {
continue;
}
// Don't continue if our category and variants are already set
if ( get_theme_mod( $setting . '_category' ) && get_theme_mod( $setting . '_variants' ) ) {
continue;
}
// Get all of our fonts
$fonts = generate_get_all_google_fonts();
// Get the ID from our font
$id = strtolower( str_replace( ' ', '_', $generate_settings[ $setting ] ) );
// If the ID doesn't exist within our fonts, we can bail
if ( ! array_key_exists( $id, $fonts ) ) {
continue;
}
// Let's grab our category to go with our font
$category = ! empty( $fonts[$id]['category'] ) ? $fonts[$id]['category'] : '';
// Grab all of the variants associated with our font
$variants = $fonts[$id]['variants'];
// Loop through our variants and put them into an array, then turn them into a comma separated list
$output = array();
if ( $variants ) {
foreach ( $variants as $variant ) {
$output[] = $variant;
}
$variants = implode( ',', $output );
}
// Set our theme mods with our new settings
if ( '' !== $category ) {
set_theme_mod( $setting . '_category', $category );
}
if ( '' !== $variants ) {
set_theme_mod( $setting . '_variants', $variants );
}
}
}
}

View File

@ -1,176 +0,0 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'generate_fonts_secondary_nav_customizer' ) ) {
add_action( 'customize_register', 'generate_fonts_secondary_nav_customizer', 1000 );
/**
* Adds our Secondary Nav typography options
*
* These options are in their own function so we can hook it in late to
* make sure Secondary Nav is activated.
*
* 1000 priority is there to make sure Secondary Nav is registered (999)
* as we check to see if the layout control exists.
*
* Secondary Nav now uses 100 as a priority.
*/
function generate_fonts_secondary_nav_customizer( $wp_customize ) {
// Bail if we don't have our defaults function
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
return;
}
// Make sure Secondary Nav is activated
if ( ! $wp_customize->get_section( 'secondary_nav_section' ) ) {
return;
}
// Get our controls
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Get our defaults
$defaults = generate_secondary_nav_get_defaults();
// Register our custom controls
if ( method_exists( $wp_customize,'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Pro_Typography_Customize_Control' );
$wp_customize->register_control_type( 'GeneratePress_Pro_Range_Slider_Control' );
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
}
// Add our section
$wp_customize->add_section(
'secondary_font_section',
array(
'title' => __( 'Secondary Navigation', 'gp-premium' ),
'capability' => 'edit_theme_options',
'description' => '',
'priority' => 51,
'panel' => 'generate_typography_panel'
)
);
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_secondary_navigation_typography_shortcuts',
array(
'section' => 'secondary_font_section',
'element' => __( 'Secondary Navigation', 'gp-premium' ),
'shortcuts' => array(
'layout' => 'secondary_nav_section',
'colors' => 'secondary_navigation_color_section',
'backgrounds' => 'secondary_bg_images_section',
),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
)
)
);
// Font family
$wp_customize->add_setting(
'generate_secondary_nav_settings[font_secondary_navigation]',
array(
'default' => $defaults['font_secondary_navigation'],
'type' => 'option',
'sanitize_callback' => 'sanitize_text_field'
)
);
// Category
$wp_customize->add_setting(
'font_secondary_navigation_category',
array(
'default' => $defaults['font_secondary_navigation_category'],
'sanitize_callback' => 'sanitize_text_field'
)
);
// Variants
$wp_customize->add_setting(
'font_secondary_navigation_variants',
array(
'default' => $defaults['font_secondary_navigation_variants'],
'sanitize_callback' => 'generate_premium_sanitize_variants'
)
);
// Font weight
$wp_customize->add_setting(
'generate_secondary_nav_settings[secondary_navigation_font_weight]',
array(
'default' => $defaults['secondary_navigation_font_weight'],
'type' => 'option',
'sanitize_callback' => 'sanitize_key',
'transport' => 'postMessage'
)
);
// Font transform
$wp_customize->add_setting(
'generate_secondary_nav_settings[secondary_navigation_font_transform]',
array(
'default' => $defaults['secondary_navigation_font_transform'],
'type' => 'option',
'sanitize_callback' => 'sanitize_key',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
new GeneratePress_Pro_Typography_Customize_Control(
$wp_customize,
'google_font_site_secondary_navigation_control',
array(
'section' => 'secondary_font_section',
'settings' => array(
'family' => 'generate_secondary_nav_settings[font_secondary_navigation]',
'variant' => 'font_secondary_navigation_variants',
'category' => 'font_secondary_navigation_category',
'weight' => 'generate_secondary_nav_settings[secondary_navigation_font_weight]',
'transform' => 'generate_secondary_nav_settings[secondary_navigation_font_transform]',
),
)
)
);
// Font size
$wp_customize->add_setting(
'generate_secondary_nav_settings[secondary_navigation_font_size]',
array(
'default' => $defaults['secondary_navigation_font_size'],
'type' => 'option',
'sanitize_callback' => 'absint',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
new GeneratePress_Pro_Range_Slider_Control(
$wp_customize,
'generate_secondary_nav_settings[secondary_navigation_font_size]',
array(
'description' => __( 'Font size', 'gp-premium' ),
'section' => 'secondary_font_section',
'priority' => 165,
'settings' => array(
'desktop' => 'generate_secondary_nav_settings[secondary_navigation_font_size]',
),
'choices' => array(
'desktop' => array(
'min' => 6,
'max' => 30,
'step' => 1,
'edit' => true,
'unit' => 'px',
),
),
)
)
);
}
}

View File

@ -1,149 +0,0 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'customize_register', 'generate_slideout_typography_customizer', 150 );
/**
* Adds our WooCommerce color options
*/
function generate_slideout_typography_customizer( $wp_customize ) {
// Bail if we don't have our defaults function
if ( ! function_exists( 'generate_get_default_fonts' ) ) {
return;
}
// Get our custom controls
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Get our defaults
$defaults = generate_get_default_fonts();
// Register our custom control types
if ( method_exists( $wp_customize,'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Pro_Range_Slider_Control' );
$wp_customize->register_control_type( 'GeneratePress_Pro_Typography_Customize_Control' );
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
}
// Bail if Menu Plus isn't activated
if ( ! $wp_customize->get_section( 'menu_plus_slideout_menu' ) ) {
return;
}
$wp_customize->add_section(
'generate_slideout_typography',
array(
'title' => __( 'Off Canvas Panel', 'gp-premium' ),
'capability' => 'edit_theme_options',
'priority' => 52,
'panel' => 'generate_typography_panel'
)
);
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_off_canvas_panel_typography_shortcuts',
array(
'section' => 'generate_slideout_typography',
'element' => esc_html__( 'Off Canvas Panel', 'gp-premium' ),
'shortcuts' => array(
'colors' => 'slideout_color_section',
'layout' => 'menu_plus_slideout_menu',
),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
)
)
);
$wp_customize->add_setting(
'generate_settings[slideout_font_weight]',
array(
'default' => $defaults['slideout_font_weight'],
'type' => 'option',
'sanitize_callback' => 'sanitize_key',
'transport' => 'postMessage'
)
);
// Text transform
$wp_customize->add_setting(
'generate_settings[slideout_font_transform]',
array(
'default' => $defaults['slideout_font_transform'],
'type' => 'option',
'sanitize_callback' => 'sanitize_key',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
new GeneratePress_Pro_Typography_Customize_Control(
$wp_customize,
'slideout_navigation_typography',
array(
'label' => esc_html__( 'Menu Items', 'gp-premium' ),
'section' => 'generate_slideout_typography',
'settings' => array(
'weight' => 'generate_settings[slideout_font_weight]',
'transform' => 'generate_settings[slideout_font_transform]',
),
)
)
);
// Font size
$wp_customize->add_setting(
'generate_settings[slideout_font_size]',
array(
'default' => $defaults['slideout_font_size'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_empty_absint',
'transport' => 'postMessage'
)
);
$wp_customize->add_setting(
'generate_settings[slideout_mobile_font_size]',
array(
'default' => $defaults['slideout_mobile_font_size'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_empty_absint',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
new GeneratePress_Pro_Range_Slider_Control(
$wp_customize,
'generate_settings[slideout_font_size]',
array(
'description' => __( 'Font size', 'gp-premium' ),
'section' => 'generate_slideout_typography',
'settings' => array(
'desktop' => 'generate_settings[slideout_font_size]',
'mobile' => 'generate_settings[slideout_mobile_font_size]',
),
'choices' => array(
'desktop' => array(
'min' => 10,
'max' => 80,
'step' => 1,
'edit' => true,
'unit' => 'px',
),
'mobile' => array(
'min' => 10,
'max' => 80,
'step' => 1,
'edit' => true,
'unit' => 'px',
),
),
)
)
);
}

View File

@ -1,179 +0,0 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'generate_typography_wc_customizer' ) ) {
add_action( 'customize_register', 'generate_typography_wc_customizer', 100 );
/**
* Adds our WooCommerce color options
*/
function generate_typography_wc_customizer( $wp_customize ) {
// Bail if we don't have our defaults function
if ( ! function_exists( 'generate_get_default_fonts' ) ) {
return;
}
// Get our custom controls
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Get our defaults
$defaults = generate_get_default_fonts();
// Register our custom control types
if ( method_exists( $wp_customize,'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Pro_Range_Slider_Control' );
$wp_customize->register_control_type( 'GeneratePress_Pro_Typography_Customize_Control' );
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
}
// Bail if WooCommerce isn't activated
if ( ! $wp_customize->get_section( 'generate_woocommerce_typography' ) ) {
return;
}
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_woocommerce_typography_shortcuts',
array(
'section' => 'generate_woocommerce_typography',
'element' => __( 'WooCommerce', 'gp-premium' ),
'shortcuts' => array(
'layout' => 'generate_woocommerce_layout',
'colors' => 'generate_woocommerce_colors',
),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 0,
)
)
);
// WooCommerce
$wp_customize->add_setting(
'generate_settings[wc_product_title_font_weight]',
array(
'default' => $defaults['wc_product_title_font_weight'],
'type' => 'option',
'sanitize_callback' => 'sanitize_key',
'transport' => 'postMessage'
)
);
// Text transform
$wp_customize->add_setting(
'generate_settings[wc_product_title_font_transform]',
array(
'default' => $defaults['wc_product_title_font_transform'],
'type' => 'option',
'sanitize_callback' => 'sanitize_key',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
new GeneratePress_Pro_Typography_Customize_Control(
$wp_customize,
'google_wc_product_title_control',
array(
'label' => __( 'Shop Product Titles', 'gp-premium' ),
'section' => 'generate_woocommerce_typography',
'settings' => array(
'weight' => 'generate_settings[wc_product_title_font_weight]',
'transform' => 'generate_settings[wc_product_title_font_transform]',
),
)
)
);
// Font size
$wp_customize->add_setting(
'generate_settings[wc_product_title_font_size]',
array(
'default' => $defaults['wc_product_title_font_size'],
'type' => 'option',
'sanitize_callback' => 'absint',
'transport' => 'postMessage'
)
);
$wp_customize->add_setting(
'generate_settings[mobile_wc_product_title_font_size]',
array(
'default' => $defaults['mobile_wc_product_title_font_size'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_empty_absint',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
new GeneratePress_Pro_Range_Slider_Control(
$wp_customize,
'generate_settings[wc_product_title_font_size]',
array(
'description' => __( 'Font size', 'gp-premium' ),
'section' => 'generate_woocommerce_typography',
'priority' => 240,
'settings' => array(
'desktop' => 'generate_settings[wc_product_title_font_size]',
'mobile' => 'generate_settings[mobile_wc_product_title_font_size]',
),
'choices' => array(
'desktop' => array(
'min' => 10,
'max' => 80,
'step' => 1,
'edit' => true,
'unit' => 'px',
),
'mobile' => array(
'min' => 10,
'max' => 80,
'step' => 1,
'edit' => true,
'unit' => 'px',
),
),
)
)
);
// Font size
$wp_customize->add_setting(
'generate_settings[wc_related_product_title_font_size]',
array(
'default' => $defaults['wc_related_product_title_font_size'],
'type' => 'option',
'sanitize_callback' => 'absint',
'transport' => 'postMessage'
)
);
$wp_customize->add_control(
new GeneratePress_Pro_Range_Slider_Control(
$wp_customize,
'generate_settings[wc_related_product_title_font_size]',
array(
'description' => __( 'Related/upsell title font size', 'gp-premium' ),
'section' => 'generate_woocommerce_typography',
'priority' => 240,
'settings' => array(
'desktop' => 'generate_settings[wc_related_product_title_font_size]',
'mobile' => 'generate_settings[mobile_wc_product_title_font_size]',
),
'choices' => array(
'desktop' => array(
'min' => 10,
'max' => 80,
'step' => 1,
'edit' => true,
'unit' => 'px',
),
),
)
)
);
}
}

View File

@ -1,20 +0,0 @@
<?php
/**
* The Typography module.
*
* @since 1.0.0
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
// Define the version.
if ( ! defined( 'GENERATE_FONT_VERSION' ) ) {
define( 'GENERATE_FONT_VERSION', GP_PREMIUM_VERSION );
}
// Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';