Version Description
- Fixed: Potential PHP warnings when generating global styles
Download this release
Release Info
Developer | bfintal |
Plugin | Stackable – Page Builder Gutenberg Blocks |
Version | 2.11.2 |
Comparing to | |
See all releases |
Code changes from version 2.11.1 to 2.11.2
- plugin.php +2 -2
- readme.txt +4 -1
- src/global-settings.php +54 -26
plugin.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* Author: Gambit Technologies, Inc
|
8 |
* Author URI: http://gambit.ph
|
9 |
* Text Domain: stackable-ultimate-gutenberg-blocks
|
10 |
-
* Version: 2.11.
|
11 |
*
|
12 |
* @package Stackable
|
13 |
*/
|
@@ -23,7 +23,7 @@ if ( function_exists( 'sugb_fs' ) ) {
|
|
23 |
}
|
24 |
|
25 |
defined( 'STACKABLE_SHOW_PRO_NOTICES' ) || define( 'STACKABLE_SHOW_PRO_NOTICES', true );
|
26 |
-
defined( 'STACKABLE_VERSION' ) || define( 'STACKABLE_VERSION', '2.11.
|
27 |
defined( 'STACKABLE_FILE' ) || define( 'STACKABLE_FILE', __FILE__ );
|
28 |
defined( 'STACKABLE_I18N' ) || define( 'STACKABLE_I18N', 'stackable-ultimate-gutenberg-blocks' );
|
29 |
// Plugin slug.
|
7 |
* Author: Gambit Technologies, Inc
|
8 |
* Author URI: http://gambit.ph
|
9 |
* Text Domain: stackable-ultimate-gutenberg-blocks
|
10 |
+
* Version: 2.11.2
|
11 |
*
|
12 |
* @package Stackable
|
13 |
*/
|
23 |
}
|
24 |
|
25 |
defined( 'STACKABLE_SHOW_PRO_NOTICES' ) || define( 'STACKABLE_SHOW_PRO_NOTICES', true );
|
26 |
+
defined( 'STACKABLE_VERSION' ) || define( 'STACKABLE_VERSION', '2.11.2' );
|
27 |
defined( 'STACKABLE_FILE' ) || define( 'STACKABLE_FILE', __FILE__ );
|
28 |
defined( 'STACKABLE_I18N' ) || define( 'STACKABLE_I18N', 'stackable-ultimate-gutenberg-blocks' );
|
29 |
// Plugin slug.
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: blocks, gutenberg, gutenberg blocks, page builder, WordPress blocks
|
|
4 |
Requires at least: 5.4
|
5 |
Tested up to: 5.5
|
6 |
Requires PHP: 5.3
|
7 |
-
Stable tag: 2.11.
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -194,6 +194,9 @@ Nope. Stackable only works with Gutenberg, the new WordPress editor.
|
|
194 |
|
195 |
== Changelog ==
|
196 |
|
|
|
|
|
|
|
197 |
= 2.11.1 =
|
198 |
* Fixed: Custom HTML block can result in invalid HTML and can cause frontend display issues
|
199 |
* Fixed: Global colors can possibly show a warning
|
4 |
Requires at least: 5.4
|
5 |
Tested up to: 5.5
|
6 |
Requires PHP: 5.3
|
7 |
+
Stable tag: 2.11.2
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
194 |
|
195 |
== Changelog ==
|
196 |
|
197 |
+
= 2.11.2 =
|
198 |
+
* Fixed: Potential PHP warnings when generating global styles
|
199 |
+
|
200 |
= 2.11.1 =
|
201 |
* Fixed: Custom HTML block can result in invalid HTML and can cause frontend display issues
|
202 |
* Fixed: Global colors can possibly show a warning
|
src/global-settings.php
CHANGED
@@ -302,8 +302,15 @@ if ( ! class_exists( 'Stackable_Global_Settings' ) ) {
|
|
302 |
);
|
303 |
}
|
304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
// Append our global colors with the theme/default ones.
|
306 |
-
$colors = array_merge( $colors, $global_colors
|
307 |
add_theme_support( 'editor-color-palette', $colors );
|
308 |
}
|
309 |
}
|
@@ -323,8 +330,19 @@ if ( ! class_exists( 'Stackable_Global_Settings' ) ) {
|
|
323 |
$css = array();
|
324 |
$core_css = array();
|
325 |
|
326 |
-
|
327 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
$color_name = strtolower( $color['slug'] );
|
329 |
|
330 |
// Convert the name to kebab casing,
|
@@ -332,28 +350,30 @@ if ( ! class_exists( 'Stackable_Global_Settings' ) ) {
|
|
332 |
$color_background_name = 'body .has-' . implode( '-', explode( ' ', $color_name ) ) . '-background-color';
|
333 |
|
334 |
// Only do this for our global colors.
|
335 |
-
if ( $color['color'] && $color['slug']){
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
|
345 |
// For background colors.
|
346 |
-
|
347 |
}
|
348 |
}
|
349 |
}
|
350 |
|
351 |
-
$
|
352 |
-
|
353 |
-
|
|
|
|
|
354 |
|
355 |
-
|
356 |
-
|
|
|
357 |
}
|
358 |
|
359 |
/**-----------------------------------------------------------------------------
|
@@ -374,7 +394,7 @@ if ( ! class_exists( 'Stackable_Global_Settings' ) ) {
|
|
374 |
|
375 |
// We can have multiple entries in the future, use the first one.
|
376 |
$active_typography = $typography[0];
|
377 |
-
if ( empty( $active_typography ) ) {
|
378 |
return;
|
379 |
}
|
380 |
|
@@ -384,6 +404,10 @@ if ( ! class_exists( 'Stackable_Global_Settings' ) ) {
|
|
384 |
// $tags = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' );
|
385 |
foreach ( $active_typography as $tag => $styles ) {
|
386 |
|
|
|
|
|
|
|
|
|
387 |
$selectors = $this->form_selectors( $tag );
|
388 |
$css[] = $this->generate_typography_styles( implode( ', ', $selectors ), $styles );
|
389 |
|
@@ -400,7 +424,11 @@ if ( ! class_exists( 'Stackable_Global_Settings' ) ) {
|
|
400 |
// Load the Google Font.
|
401 |
Stackable_Google_Fonts::enqueue_google_fonts( $google_fonts, 'stackable-global-typography-google-fonts' );
|
402 |
|
403 |
-
|
|
|
|
|
|
|
|
|
404 |
}
|
405 |
|
406 |
public function form_selectors( $tag ) {
|
@@ -532,7 +560,7 @@ if ( ! class_exists( 'Stackable_Global_Settings' ) ) {
|
|
532 |
if ( $inherit ) {
|
533 |
if ( array_key_exists( 'fontSize', $styles ) ) {
|
534 |
$clamp_desktop_value = $this->clamp_inherited_style( $styles['fontSize'], $inherit_max );
|
535 |
-
if ( $clamp_desktop_value ) {
|
536 |
$font_size = $this->create_style( 'font-size', $clamp_desktop_value . $styles['fontSizeUnit'] );
|
537 |
}
|
538 |
}
|
@@ -540,7 +568,7 @@ if ( ! class_exists( 'Stackable_Global_Settings' ) ) {
|
|
540 |
if ( array_key_exists( 'tabletFontSize', $styles ) ) {
|
541 |
$font_size = $this->create_style( 'font-size', $styles['tabletFontSize'] . $styles['tabletFontSizeUnit'] );
|
542 |
}
|
543 |
-
if ( $font_size ) {
|
544 |
$css['tablet'][] = $font_size;
|
545 |
}
|
546 |
|
@@ -557,7 +585,7 @@ if ( ! class_exists( 'Stackable_Global_Settings' ) ) {
|
|
557 |
$has_clamped_font_size = false;
|
558 |
if ( array_key_exists( 'fontSize', $styles ) ) {
|
559 |
$clamp_desktop_value = $this->clamp_inherited_style( $styles['fontSize'], $inherit_max );
|
560 |
-
if ( $clamp_desktop_value ) {
|
561 |
$font_size = $this->create_style( 'font-size', $clamp_desktop_value . $styles['fontSizeUnit'] );
|
562 |
}
|
563 |
}
|
@@ -565,12 +593,12 @@ if ( ! class_exists( 'Stackable_Global_Settings' ) ) {
|
|
565 |
$clamp_tablet_value = null;
|
566 |
if ( array_key_exists( 'tabletFontSize', $styles ) ) {
|
567 |
$clamp_tablet_value = $this->clamp_inherited_style( $style['tabletFontSize'], $inherit_max );
|
568 |
-
if ( $clamp_tablet_value ) {
|
569 |
$font_size = $this->create_style( 'font-size', $clamp_tablet_value . $styles['tabletFontSizeUnit'] );
|
570 |
}
|
571 |
}
|
572 |
-
if (
|
573 |
-
if ( $clamp_desktop_value || array_key_exists( 'tabletFontSize', $styles ) ) {
|
574 |
// If we have a desktop value clamped, and there's a tablet value, don't do anything.
|
575 |
if ( $has_clamped_font_size ) {
|
576 |
$font_size = '';
|
@@ -581,7 +609,7 @@ if ( ! class_exists( 'Stackable_Global_Settings' ) ) {
|
|
581 |
if ( array_key_exists( 'mobileFontSize', $styles ) ) {
|
582 |
$font_size = $this->create_style( 'font-size', $styles['mobileFontSize'] . $styles['mobileFontSizeUnit'] );
|
583 |
}
|
584 |
-
if ( $font_size ) {
|
585 |
$css['mobile'][] = $font_size;
|
586 |
}
|
587 |
|
302 |
);
|
303 |
}
|
304 |
|
305 |
+
if ( is_array( $global_colors ) ) {
|
306 |
+
$global_colors = $global_colors[0];
|
307 |
+
}
|
308 |
+
if ( empty( $global_colors ) ) {
|
309 |
+
$global_colors = array();
|
310 |
+
}
|
311 |
+
|
312 |
// Append our global colors with the theme/default ones.
|
313 |
+
$colors = array_merge( $colors, $global_colors );
|
314 |
add_theme_support( 'editor-color-palette', $colors );
|
315 |
}
|
316 |
}
|
330 |
$css = array();
|
331 |
$core_css = array();
|
332 |
|
333 |
+
foreach( $colors as $color_palette ) {
|
334 |
+
if ( ! is_array( $color_palette ) ) {
|
335 |
+
continue;
|
336 |
+
}
|
337 |
+
|
338 |
+
foreach( $color_palette as $color ) {
|
339 |
+
if ( ! is_array( $color ) ) {
|
340 |
+
continue;
|
341 |
+
}
|
342 |
+
if ( ! array_key_exists( 'slug', $color ) || ! array_key_exists( 'color', $color ) || ! array_key_exists( 'rgb', $color ) ) {
|
343 |
+
continue;
|
344 |
+
}
|
345 |
+
|
346 |
$color_name = strtolower( $color['slug'] );
|
347 |
|
348 |
// Convert the name to kebab casing,
|
350 |
$color_background_name = 'body .has-' . implode( '-', explode( ' ', $color_name ) ) . '-background-color';
|
351 |
|
352 |
// Only do this for our global colors.
|
353 |
+
if ( $color['color'] && $color['slug'] ) {
|
354 |
+
// Add the custom css property.
|
355 |
+
$css[] = '--' . $color['slug'] . ': ' . $color['color'] . ';';
|
356 |
+
$css[] = '--' . $color['slug'] . '-rgba: ' . $color['rgb'] . ';';
|
|
|
357 |
|
358 |
+
// Add custom css class rule for other blocks.
|
359 |
+
// For typography colors.
|
360 |
+
$core_css[] = $color_typography_name . ' { color: ' . $color['color'] . ' !important; }';
|
361 |
|
362 |
// For background colors.
|
363 |
+
$core_css[] = $color_background_name . ' { background-color: ' . $color['color'] . ' !important; }';
|
364 |
}
|
365 |
}
|
366 |
}
|
367 |
|
368 |
+
if ( count( $css ) ) {
|
369 |
+
$generated_color_css = "/* Global colors */\n";
|
370 |
+
$generated_color_css .= ':root {' . implode( ' ', $css ) . '}';
|
371 |
+
wp_add_inline_style( 'ugb-style-css', $generated_color_css );
|
372 |
+
}
|
373 |
|
374 |
+
if ( count( $core_css ) ) {
|
375 |
+
wp_add_inline_style( 'ugb-style-css', implode( ' ', $core_css ) );
|
376 |
+
}
|
377 |
}
|
378 |
|
379 |
/**-----------------------------------------------------------------------------
|
394 |
|
395 |
// We can have multiple entries in the future, use the first one.
|
396 |
$active_typography = $typography[0];
|
397 |
+
if ( empty( $active_typography ) || ! is_array( $active_typography ) ) {
|
398 |
return;
|
399 |
}
|
400 |
|
404 |
// $tags = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' );
|
405 |
foreach ( $active_typography as $tag => $styles ) {
|
406 |
|
407 |
+
if ( ! is_array( $styles ) ) {
|
408 |
+
continue;
|
409 |
+
}
|
410 |
+
|
411 |
$selectors = $this->form_selectors( $tag );
|
412 |
$css[] = $this->generate_typography_styles( implode( ', ', $selectors ), $styles );
|
413 |
|
424 |
// Load the Google Font.
|
425 |
Stackable_Google_Fonts::enqueue_google_fonts( $google_fonts, 'stackable-global-typography-google-fonts' );
|
426 |
|
427 |
+
if ( count( $css ) ) {
|
428 |
+
$inline_css = "/* Global typography */\n";
|
429 |
+
$inline_css .= implode( "\n", $css );
|
430 |
+
wp_add_inline_style( 'ugb-style-css', $inline_css );
|
431 |
+
}
|
432 |
}
|
433 |
|
434 |
public function form_selectors( $tag ) {
|
560 |
if ( $inherit ) {
|
561 |
if ( array_key_exists( 'fontSize', $styles ) ) {
|
562 |
$clamp_desktop_value = $this->clamp_inherited_style( $styles['fontSize'], $inherit_max );
|
563 |
+
if ( ! empty( $clamp_desktop_value ) ) {
|
564 |
$font_size = $this->create_style( 'font-size', $clamp_desktop_value . $styles['fontSizeUnit'] );
|
565 |
}
|
566 |
}
|
568 |
if ( array_key_exists( 'tabletFontSize', $styles ) ) {
|
569 |
$font_size = $this->create_style( 'font-size', $styles['tabletFontSize'] . $styles['tabletFontSizeUnit'] );
|
570 |
}
|
571 |
+
if ( ! empty( $font_size ) ) {
|
572 |
$css['tablet'][] = $font_size;
|
573 |
}
|
574 |
|
585 |
$has_clamped_font_size = false;
|
586 |
if ( array_key_exists( 'fontSize', $styles ) ) {
|
587 |
$clamp_desktop_value = $this->clamp_inherited_style( $styles['fontSize'], $inherit_max );
|
588 |
+
if ( ! empty( $clamp_desktop_value ) ) {
|
589 |
$font_size = $this->create_style( 'font-size', $clamp_desktop_value . $styles['fontSizeUnit'] );
|
590 |
}
|
591 |
}
|
593 |
$clamp_tablet_value = null;
|
594 |
if ( array_key_exists( 'tabletFontSize', $styles ) ) {
|
595 |
$clamp_tablet_value = $this->clamp_inherited_style( $style['tabletFontSize'], $inherit_max );
|
596 |
+
if ( ! empty( $clamp_tablet_value ) ) {
|
597 |
$font_size = $this->create_style( 'font-size', $clamp_tablet_value . $styles['tabletFontSizeUnit'] );
|
598 |
}
|
599 |
}
|
600 |
+
if ( empty( $clamp_tablet_value ) ) {
|
601 |
+
if ( ! empty( $clamp_desktop_value ) || array_key_exists( 'tabletFontSize', $styles ) ) {
|
602 |
// If we have a desktop value clamped, and there's a tablet value, don't do anything.
|
603 |
if ( $has_clamped_font_size ) {
|
604 |
$font_size = '';
|
609 |
if ( array_key_exists( 'mobileFontSize', $styles ) ) {
|
610 |
$font_size = $this->create_style( 'font-size', $styles['mobileFontSize'] . $styles['mobileFontSizeUnit'] );
|
611 |
}
|
612 |
+
if ( ! empty( $font_size ) ) {
|
613 |
$css['mobile'][] = $font_size;
|
614 |
}
|
615 |
|