updated plugin GP Premium
version 2.1.1
This commit is contained in:
@ -767,6 +767,9 @@ function generatepress_wc_css() {
|
||||
require_once GP_LIBRARY_DIRECTORY . 'class-make-css.php';
|
||||
$css = new GeneratePress_Pro_CSS();
|
||||
|
||||
// Check if we're using our legacy typography system.
|
||||
$using_dynamic_typography = function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography();
|
||||
|
||||
// Product title color.
|
||||
$css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link' );
|
||||
$css->add_property( 'color', esc_attr( $settings['wc_product_title_color'] ) );
|
||||
@ -775,15 +778,17 @@ function generatepress_wc_css() {
|
||||
$css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link:hover' );
|
||||
$css->add_property( 'color', esc_attr( $settings['wc_product_title_color_hover'] ) );
|
||||
|
||||
// Product title font size.
|
||||
$css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title' );
|
||||
$css->add_property( 'font-weight', esc_attr( $settings['wc_product_title_font_weight'] ) );
|
||||
$css->add_property( 'text-transform', esc_attr( $settings['wc_product_title_font_transform'] ) );
|
||||
$css->add_property( 'font-size', esc_attr( $settings['wc_product_title_font_size'] ), false, 'px' );
|
||||
if ( ! $using_dynamic_typography ) {
|
||||
// Product title font size.
|
||||
$css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title' );
|
||||
$css->add_property( 'font-weight', esc_attr( $settings['wc_product_title_font_weight'] ) );
|
||||
$css->add_property( 'text-transform', esc_attr( $settings['wc_product_title_font_transform'] ) );
|
||||
$css->add_property( 'font-size', esc_attr( $settings['wc_product_title_font_size'] ), false, 'px' );
|
||||
|
||||
$css->set_selector( '.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' );
|
||||
if ( '' !== $settings['wc_related_product_title_font_size'] ) {
|
||||
$css->add_property( 'font-size', esc_attr( $settings['wc_related_product_title_font_size'] ), false, 'px' );
|
||||
$css->set_selector( '.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' );
|
||||
if ( '' !== $settings['wc_related_product_title_font_size'] ) {
|
||||
$css->add_property( 'font-size', esc_attr( $settings['wc_related_product_title_font_size'] ), false, 'px' );
|
||||
}
|
||||
}
|
||||
|
||||
// Primary button.
|
||||
@ -791,7 +796,7 @@ function generatepress_wc_css() {
|
||||
$css->add_property( 'color', esc_attr( $settings['form_button_text_color'] ) );
|
||||
$css->add_property( 'background-color', esc_attr( $settings['form_button_background_color'] ) );
|
||||
|
||||
if ( isset( $settings['buttons_font_size'] ) ) {
|
||||
if ( ! $using_dynamic_typography && isset( $settings['buttons_font_size'] ) ) {
|
||||
$css->add_property( 'font-weight', esc_attr( $settings['buttons_font_weight'] ) );
|
||||
$css->add_property( 'text-transform', esc_attr( $settings['buttons_font_transform'] ) );
|
||||
|
||||
@ -800,6 +805,38 @@ function generatepress_wc_css() {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $using_dynamic_typography && class_exists( 'GeneratePress_Typography' ) ) {
|
||||
$typography = generate_get_option( 'typography' );
|
||||
|
||||
foreach ( (array) $typography as $key => $data ) {
|
||||
if ( 'buttons' === $data['selector'] ) {
|
||||
if ( ! empty( $data['fontSize'] ) ) {
|
||||
$css->add_property( 'font-size', absint( $data['fontSize'] ), false, 'px' );
|
||||
}
|
||||
|
||||
if ( ! empty( $data['fontWeight'] ) ) {
|
||||
$css->add_property( 'font-weight', absint( $data['fontWeight'] ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $data['textTransform'] ) ) {
|
||||
$css->add_property( 'text-transform', absint( $data['textTransform'] ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $data['fontSizeTablet'] ) ) {
|
||||
$css->start_media_query( generate_premium_get_media_query( 'tablet' ) );
|
||||
$css->add_property( 'font-size', absint( $data['fontSizeTablet'] ), false, 'px' );
|
||||
$css->stop_media_query();
|
||||
}
|
||||
|
||||
if ( ! empty( $data['fontSizeMobile'] ) ) {
|
||||
$css->start_media_query( generate_premium_get_media_query( 'mobile' ) );
|
||||
$css->add_property( 'font-size', absint( $data['fontSizeMobile'] ), false, 'px' );
|
||||
$css->stop_media_query();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Primary button hover.
|
||||
$css->set_selector( '.woocommerce #respond input#submit:hover, .woocommerce a.button:hover, .woocommerce button.button:hover, .woocommerce input.button:hover' );
|
||||
$css->add_property( 'color', esc_attr( $settings['form_button_text_color_hover'] ) );
|
||||
@ -898,7 +935,7 @@ function generatepress_wc_css() {
|
||||
$css->set_selector( '.woocommerce #content div.product div.images, .woocommerce div.product div.images, .woocommerce-page #content div.product div.images, .woocommerce-page div.product div.images' );
|
||||
$css->add_property( 'width', absint( generatepress_wc_get_setting( 'single_product_image_width' ) ), false, '%' );
|
||||
|
||||
if ( function_exists( 'generate_get_font_family_css' ) ) {
|
||||
if ( ! $using_dynamic_typography && function_exists( 'generate_get_font_family_css' ) ) {
|
||||
$buttons_family = generate_get_font_family_css( 'font_buttons', 'generate_settings', generate_get_default_fonts() );
|
||||
$css->set_selector( '.woocommerce.widget_shopping_cart .woocommerce-mini-cart__buttons a' );
|
||||
$css->add_property( 'font-family', $buttons_family );
|
||||
@ -1043,9 +1080,11 @@ function generatepress_wc_css() {
|
||||
$css->stop_media_query();
|
||||
|
||||
$css->start_media_query( generate_premium_get_media_query( 'mobile' ) );
|
||||
$css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title' );
|
||||
if ( '' !== $settings[ 'mobile_wc_product_title_font_size' ] ) {
|
||||
$css->add_property( 'font-size', esc_attr( $settings[ 'mobile_wc_product_title_font_size' ] ), false, 'px' );
|
||||
if ( ! $using_dynamic_typography ) {
|
||||
$css->set_selector( '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title' );
|
||||
if ( '' !== $settings[ 'mobile_wc_product_title_font_size' ] ) {
|
||||
$css->add_property( 'font-size', esc_attr( $settings[ 'mobile_wc_product_title_font_size' ] ), false, 'px' );
|
||||
}
|
||||
}
|
||||
|
||||
$css->set_selector( '.add-to-cart-panel .continue-shopping' );
|
||||
@ -1101,6 +1140,10 @@ add_action( 'wp_enqueue_scripts', 'generatepress_wc_enqueue_css', 100 );
|
||||
*/
|
||||
function generatepress_wc_enqueue_css() {
|
||||
wp_add_inline_style( 'generate-woocommerce', generatepress_wc_css() );
|
||||
|
||||
if ( class_exists( 'GeneratePress_Typography' ) ) {
|
||||
wp_add_inline_style( 'generate-woocommerce', GeneratePress_Typography::get_css( 'woocommerce' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1252,7 +1295,7 @@ function generatepress_wc_add_to_cart_helper() {
|
||||
?>
|
||||
<div class="continue-shopping <?php echo $svg_icon ? 'has-svg-icon' : ''; ?>">
|
||||
<?php echo $svg_icon; ?>
|
||||
<a href="#"><span class="continue-shopping-text"><?php _e( 'Continue Shopping', 'gp-premium' ); ?> →</span></a>
|
||||
<a href="#" class="continue-shopping-link"><span class="continue-shopping-text"><?php _e( 'Continue Shopping', 'gp-premium' ); ?> →</span></a>
|
||||
</div>
|
||||
|
||||
<div class="cart-info">
|
||||
@ -1395,11 +1438,32 @@ function generatepress_wc_show_sticky_add_to_cart() {
|
||||
* Checks if a color is light or dark.
|
||||
*
|
||||
* @since 1.8
|
||||
*
|
||||
* @param string $color
|
||||
* @return string
|
||||
* @param string $color The color to check.
|
||||
*/
|
||||
function generate_premium_check_text_color( $color ) {
|
||||
// Get the hex value if we're using variables.
|
||||
if ( function_exists( 'generate_get_option' ) && strpos( $color, 'var(' ) !== false ) {
|
||||
$global_colors = generate_get_option( 'global_colors' );
|
||||
$found_color = false;
|
||||
|
||||
// Remove whitespace if it's been added.
|
||||
$color = str_replace( ' ', '', $color );
|
||||
|
||||
foreach ( (array) $global_colors as $key => $data ) {
|
||||
// Check for the full variable - var(--color) - or a variable with a fallback - var(--color,#fff).
|
||||
if ( 'var(--' . $data['slug'] . ')' === $color || strpos( $color, 'var(--' . $data['slug'] . ',' ) !== false ) {
|
||||
$color = $data['color'];
|
||||
$found_color = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If we didn't find the hex value, bail.
|
||||
if ( ! $found_color ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$r = hexdec( substr( $color, 1, 2 ) );
|
||||
$g = hexdec( substr( $color, 3, 2 ) );
|
||||
$b = hexdec( substr( $color, 5, 2 ) );
|
||||
@ -1407,3 +1471,24 @@ function generate_premium_check_text_color( $color ) {
|
||||
|
||||
return ( $yiq >= 128 ) ? 'light' : 'dark';
|
||||
}
|
||||
|
||||
add_filter( 'generate_typography_css_selector', 'generate_woocommerce_typography_selectors' );
|
||||
/**
|
||||
* Add the WooCommerce typography CSS selectors.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @param string $selector The selector we're targeting.
|
||||
*/
|
||||
function generate_woocommerce_typography_selectors( $selector ) {
|
||||
switch ( $selector ) {
|
||||
case 'woocommerce-catalog-product-titles':
|
||||
$selector = '.woocommerce ul.products li.product .woocommerce-LoopProduct-link h2, .woocommerce ul.products li.product .woocommerce-loop-category__title';
|
||||
break;
|
||||
|
||||
case 'woocommerce-related-product-titles':
|
||||
$selector = '.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';
|
||||
break;
|
||||
}
|
||||
|
||||
return $selector;
|
||||
}
|
||||
|
Reference in New Issue
Block a user