Skip to content

Commit

Permalink
Merge pull request #920 from tomusborne/release/1.7.1
Browse files Browse the repository at this point in the history
Release: 1.7.1
  • Loading branch information
tomusborne authored Mar 1, 2023
2 parents 88590c3 + d89289c commit 5911030
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 132 deletions.
2 changes: 1 addition & 1 deletion dist/blocks.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-rich-text'), 'version' => '3f9fed44ddc284b43582');
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-notices', 'wp-primitives', 'wp-rich-text'), 'version' => 'ecdb0999dd4c9ddf0fdf');
2 changes: 1 addition & 1 deletion dist/blocks.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/blocks.js

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions includes/class-enqueue-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ class GenerateBlocks_Enqueue_CSS {
*/
private static $has_made_css = false;

/**
* Check to see if we've enqueued our CSS.
*
* @access private
* @var boolean
*/
private static $has_enqueued_css = false;

/**
* Initiator.
*
Expand Down Expand Up @@ -58,6 +66,20 @@ public function __construct() {
add_action( 'customize_save_after', array( $this, 'force_file_regen_on_customizer_save' ) );
}

/**
* Tell our system it's ok to generate CSS.
*/
private function enable_enqueue() {
self::$has_enqueued_css = true;
}

/**
* Check to see if we can generate CSS.
*/
public static function can_enqueue() {
return self::$has_enqueued_css;
}

/**
* Enqueue our front-end assets.
*/
Expand Down Expand Up @@ -125,6 +147,7 @@ public function mode() {
* Enqueue the dynamic CSS.
*/
public function enqueue_dynamic_css() {
$this->enable_enqueue();
$page_id = $this->page_id();

if ( ! $page_id ) {
Expand All @@ -151,6 +174,8 @@ public function enqueue_dynamic_css() {
* Print our inline CSS.
*/
public function print_inline_css() {
$this->enable_enqueue();

if ( 'inline' === $this->mode() || ! wp_style_is( 'generateblocks', 'enqueued' ) ) {
// Build our CSS based on the content we find.
generateblocks_get_dynamic_css();
Expand Down
12 changes: 6 additions & 6 deletions includes/defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ function generateblocks_get_block_defaults() {
return apply_filters(
'generateblocks_defaults',
[
'container' => GenerateBlocks_Block_Container::defaults(),
'buttonContainer' => GenerateBlocks_Block_Button_Container::defaults(),
'button' => GenerateBlocks_Block_Button::defaults(),
'gridContainer' => GenerateBlocks_Block_Grid::defaults(),
'headline' => GenerateBlocks_Block_Headline::defaults(),
'image' => GenerateBlocks_Block_Image::defaults(),
'container' => generateblocks_with_global_defaults( GenerateBlocks_Block_Container::defaults() ),
'buttonContainer' => generateblocks_with_global_defaults( GenerateBlocks_Block_Button_Container::defaults() ),
'button' => generateblocks_with_global_defaults( GenerateBlocks_Block_Button::defaults() ),
'gridContainer' => generateblocks_with_global_defaults( GenerateBlocks_Block_Grid::defaults() ),
'headline' => generateblocks_with_global_defaults( GenerateBlocks_Block_Headline::defaults() ),
'image' => generateblocks_with_global_defaults( GenerateBlocks_Block_Image::defaults() ),
]
);
}
Expand Down
75 changes: 75 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,10 @@ function generateblocks_maybe_add_block_css( $content = '', $data = [] ) {
return $content;
}

if ( ! GenerateBlocks_Enqueue_CSS::can_enqueue() ) {
return $content;
}

$css_data = is_callable( [ $data['class_name'], 'get_css_data' ] )
? $data['class_name']::get_css_data( $data['attributes'] )
: false;
Expand Down Expand Up @@ -1362,3 +1366,74 @@ function generateblocks_get_wp_filesystem() {

return $wp_filesystem;
}

/**
* Add global defaults to our blocks.
*
* @since 1.7.1
* @param array $defaults The existing defaults.
*/
function generateblocks_with_global_defaults( $defaults ) {
$display = [
'display',
'flexDirection',
'flexWrap',
'alignItems',
'justifyContent',
'columnGap',
'rowGap',
'position',
'overflowX',
'overflowY',
'zindex',
];

$flex_child = [
'flexGrow',
'flexShrink',
'flexBasis',
'order',
];

$spacing = [
'marginTop',
'marginRight',
'marginBottom',
'marginLeft',
'paddingTop',
'paddingRight',
'paddingBottom',
'paddingLeft',
'borderSizeTop',
'borderSizeRight',
'borderSizeBottom',
'borderSizeLeft',
'borderRadiusTopRight',
'borderRadiusBottomRight',
'borderRadiusBottomLeft',
'borderRadiusTopLeft',
];

$options = array_merge(
$display,
$flex_child,
$spacing
);

foreach ( $options as $option ) {
$defaults[ $option ] = '';
$defaults[ $option . 'Tablet' ] = '';
$defaults[ $option . 'Mobile' ] = '';
}

// Spacing.
$defaults['marginUnit'] = 'px';
$defaults['paddingUnit'] = 'px';
$defaults['borderRadiusUnit'] = 'px';

// Sizing.
$defaults['sizing'] = [];
$defaults['useGlobalMaxWidth'] = false;

return $defaults;
}
113 changes: 0 additions & 113 deletions includes/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,119 +330,6 @@ function generateblocks_set_inline_background_style( $attributes, $settings ) {
return $attributes;
}

add_filter( 'generateblocks_defaults', 'generateblocks_set_layout_component_defaults' );
/**
* Set the defaults for our Layout options.
*
* @param array $defaults Existing defaults.
*/
function generateblocks_set_layout_component_defaults( $defaults ) {
$options = [
'display',
'flexDirection',
'flexWrap',
'alignItems',
'justifyContent',
'columnGap',
'rowGap',
'position',
'overflowX',
'overflowY',
'zindex',
];

foreach ( $defaults as $block => $values ) {
foreach ( $options as $option ) {
$defaults[ $block ][ $option ] = '';
$defaults[ $block ][ $option . 'Tablet' ] = '';
$defaults[ $block ][ $option . 'Mobile' ] = '';
}
}

return $defaults;
}

add_filter( 'generateblocks_defaults', 'generateblocks_set_sizing_component_defaults' );
/**
* Set the defaults for our Layout options.
*
* @param array $defaults Existing defaults.
*/
function generateblocks_set_sizing_component_defaults( $defaults ) {
foreach ( $defaults as $block => $values ) {
$defaults[ $block ]['sizing'] = [];
$defaults[ $block ]['useGlobalMaxWidth'] = false;
}

return $defaults;
}

add_filter( 'generateblocks_defaults', 'generateblocks_set_flex_child_component_defaults' );
/**
* Set the defaults for our Flex Child options.
*
* @param array $defaults Existing defaults.
*/
function generateblocks_set_flex_child_component_defaults( $defaults ) {
$options = [
'flexGrow',
'flexShrink',
'flexBasis',
'order',
];

foreach ( $defaults as $block => $values ) {
foreach ( $options as $option ) {
$defaults[ $block ][ $option ] = '';
$defaults[ $block ][ $option . 'Tablet' ] = '';
$defaults[ $block ][ $option . 'Mobile' ] = '';
}
}

return $defaults;
}

add_filter( 'generateblocks_defaults', 'generateblocks_set_spacing_defaults' );
/**
* Set the defaults for our Spacing options.
*
* @param array $defaults Existing defaults.
*/
function generateblocks_set_spacing_defaults( $defaults ) {
$options = [
'marginTop',
'marginRight',
'marginBottom',
'marginLeft',
'paddingTop',
'paddingRight',
'paddingBottom',
'paddingLeft',
'borderSizeTop',
'borderSizeRight',
'borderSizeBottom',
'borderSizeLeft',
'borderRadiusTopRight',
'borderRadiusBottomRight',
'borderRadiusBottomLeft',
'borderRadiusTopLeft',
];

foreach ( $defaults as $block => $values ) {
foreach ( $options as $option ) {
$defaults[ $block ][ $option ] = '';
$defaults[ $block ][ $option . 'Tablet' ] = '';
$defaults[ $block ][ $option . 'Mobile' ] = '';
}

$defaults[ $block ]['marginUnit'] = 'px';
$defaults[ $block ]['paddingUnit'] = 'px';
$defaults[ $block ]['borderRadiusUnit'] = 'px';
}

return $defaults;
}

add_filter( 'generateblocks_block_css_selector', 'generateblocks_set_block_css_selectors', 10, 3 );
/**
* Change our block selectors if needed.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generateblocks",
"version": "1.7.0",
"version": "1.7.1",
"private": true,
"description": "A small collection of lightweight WordPress blocks that can accomplish nearly anything.",
"author": "Tom Usborne",
Expand Down
4 changes: 2 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: A small collection of lightweight WordPress blocks that can accomplish nearly anything.
* Author: Tom Usborne
* Author URI: https://tomusborne.com
* Version: 1.7.0
* Version: 1.7.1
* Requires at least: 5.9
* Requires PHP: 5.6
* License: GPL2+
Expand All @@ -19,7 +19,7 @@
exit; // Exit if accessed directly.
}

define( 'GENERATEBLOCKS_VERSION', '1.7.0' );
define( 'GENERATEBLOCKS_VERSION', '1.7.1' );
define( 'GENERATEBLOCKS_DIR', plugin_dir_path( __FILE__ ) );
define( 'GENERATEBLOCKS_DIR_URL', plugin_dir_url( __FILE__ ) );

Expand Down
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: blocks, gutenberg, container, headline, grid, columns, page builder, wysiw
Requires at least: 5.9
Tested up to: 6.1
Requires PHP: 5.6
Stable tag: 1.7.0
Stable tag: 1.7.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -83,6 +83,12 @@ GenerateBlocks was built to work hand-in-hand with [GeneratePress](https://gener

== Changelog ==

= 1.7.1 =
* Tweak: Add link to documentation under legacy layout toggle
* Fix: Container width migration for old blockVersion: 1 blocks
* Fix: Container padding migration for old blockVersion: 1 blocks
* Fix: Missing block styling with some third-party plugins

= 1.7.0 =
* Feature: Add flexbox controls to all blocks
* Feature: Add sizing controls to all blocks
Expand Down
Loading

0 comments on commit 5911030

Please sign in to comment.