Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release: 1.6.0 #661

Merged
merged 103 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
34fe06e
Improve frontend CSS generation
tomusborne Jun 23, 2022
1005708
Fix headline output
tomusborne Jun 23, 2022
70d30aa
Fix attributes variables
tomusborne Jun 23, 2022
f183d4d
Add with_inline_styles function
tomusborne Jun 23, 2022
c294a8f
Update descriptions
tomusborne Jun 27, 2022
af14bd5
Fix inline style generation
tomusborne Jun 27, 2022
61ab0d7
Simplify CSS functions
tomusborne Jun 27, 2022
34aaf0c
Replace call_user_func
tomusborne Jun 28, 2022
c8a0ce9
Merge branch 'release/1.6.0' into better-css-generation
tomusborne Jun 29, 2022
aa52376
Fix: Reset the query with wp_reset_postdata
tomusborne Jun 29, 2022
d1bb313
Change inline style function name
tomusborne Jun 29, 2022
85a9ccc
Don't try to output Query Loop CSS
tomusborne Jun 29, 2022
86f0aa1
Store block ID after all CSS generation
tomusborne Jun 29, 2022
1539d07
Merge branch 'master' into better-css-generation
tomusborne Jul 12, 2022
89cf77d
Merge branch 'release/1.6.0' into better-css-generation
tomusborne Jul 14, 2022
ef3ab4a
Feature: Improve select components
JeanPaiva Jul 27, 2022
49d438e
Feature: Add filters to integrate ACF
JeanPaiva Aug 8, 2022
d6a8552
Fix 404 error when fetching media of id "Loading..."
JeanPaiva Aug 22, 2022
d1dcba9
Fix: Sticky posts only not displaying correctly in the frontend
JeanPaiva Aug 22, 2022
85273cb
Update to version 1.6.0
JeanPaiva Aug 22, 2022
c5aaf59
Fix: Pass dynamic container link to settings
tomusborne Aug 22, 2022
764d727
Tweak: Remove block-editor-block-list__block class from root
tomusborne Aug 22, 2022
14f8246
Merge pull request #642 from tomusborne/improve-select-components
JeanPaiva Aug 23, 2022
40b8a6e
Update dist files
github-actions[bot] Aug 23, 2022
7f18f55
Merge pull request #660 from tomusborne/fix-sticky-posts-only
JeanPaiva Aug 23, 2022
ea55f81
Merge pull request #607 from tomusborne/better-css-generation
tomusborne Aug 23, 2022
ee8add2
Merge pull request #664 from tomusborne/remove-list__block-class-from…
tomusborne Aug 23, 2022
17a832d
Update dist files
github-actions[bot] Aug 23, 2022
b834edd
Fix image block not loading meta field url
JeanPaiva Aug 23, 2022
6f9785e
Merge branch 'release/1.6.0' into feature-acf-integration
JeanPaiva Aug 23, 2022
ba0daf2
Fix: Removing icons without text does not display text back again
JeanPaiva Aug 23, 2022
26308e5
Tweak: Headline transform to core Heading keep the level
JeanPaiva Aug 23, 2022
16de519
Feature: Add filter for query loop enabled post types
JeanPaiva Aug 23, 2022
cf5d22e
Fix: Color picker behavior
JeanPaiva Aug 23, 2022
ef50185
Tweak: Add container article tag
JeanPaiva Aug 24, 2022
c78c875
Merge branch 'release/1.6.0' into fix-container-dynamic-wrapper-link
tomusborne Aug 24, 2022
5c2ab26
Fix: Pass dynamic container link to settings
tomusborne Aug 24, 2022
60ba8e6
Merge pull request #663 from tomusborne/fix-container-dynamic-wrapper…
tomusborne Aug 24, 2022
0adff11
Merge pull request #666 from tomusborne/fix-icon-without-text
JeanPaiva Aug 24, 2022
c66c628
Merge pull request #667 from tomusborne/tweak-headline-transform
JeanPaiva Aug 24, 2022
aeb1ac1
Update dist files
github-actions[bot] Aug 24, 2022
5ac524a
Change filter name to the correct pattern
JeanPaiva Aug 24, 2022
f2221ec
Merge pull request #669 from tomusborne/fix-color-picker
JeanPaiva Aug 24, 2022
3e571cd
Update dist files
github-actions[bot] Aug 24, 2022
c4e59d1
Fix: Align classes when using theme.json
tomusborne Aug 25, 2022
8725033
Update versions
tomusborne Aug 25, 2022
c3da6ef
Merge branch 'release/1.6.0' into fix-aligns-supports-layout
tomusborne Aug 25, 2022
ab8ac2d
Update readme.txt
tomusborne Aug 25, 2022
b6be0e1
Merge pull request #668 from tomusborne/feat-add-query-loop-enabled-t…
JeanPaiva Aug 25, 2022
056731e
Merge pull request #652 from tomusborne/feature-acf-integration
JeanPaiva Aug 25, 2022
1173c12
Update dist files
github-actions[bot] Aug 25, 2022
66eb188
Fix: Query Loop template key warning
tomusborne Aug 25, 2022
53a5995
Update readme.txt
tomusborne Aug 25, 2022
a7b6407
Update readme.txt
tomusborne Aug 26, 2022
65b9dc6
Merge pull request #672 from tomusborne/fix-loop-template-key
tomusborne Aug 26, 2022
3d8161d
Update dist files
github-actions[bot] Aug 26, 2022
bf5ce2e
Merge pull request #671 from tomusborne/fix-aligns-supports-layout
tomusborne Aug 26, 2022
4ffe6f8
Update dist files
github-actions[bot] Aug 26, 2022
d44a31d
Fix broken dynamic image when loading
tomusborne Aug 26, 2022
a06101d
Merge pull request #670 from tomusborne/tweak-add-article-tag
JeanPaiva Aug 29, 2022
83d306a
Merge pull request #674 from tomusborne/fix-broken-dynamic-image
JeanPaiva Aug 29, 2022
5905555
Update dist files
github-actions[bot] Aug 29, 2022
36b9725
Tweak: Improve author select component
JeanPaiva Aug 29, 2022
733af0c
Tweak: Improve taxonomy records select component
JeanPaiva Aug 29, 2022
1503c63
Fix: Author select isLoading
JeanPaiva Aug 29, 2022
7e03da2
Fix component placeholders, order by and label inconsistency
JeanPaiva Aug 30, 2022
a974729
Fix posts order by date
JeanPaiva Aug 30, 2022
fdecc26
Fix basecotrol without id
JeanPaiva Aug 30, 2022
eac27a0
Merge pull request #675 from tomusborne/tweak-improve-select-components
JeanPaiva Aug 30, 2022
fda4603
Update dist files
github-actions[bot] Aug 30, 2022
818c7ce
Update package-lock.json version
JeanPaiva Aug 30, 2022
31e3cb9
Fix: Duplicate CSS when using external file
tomusborne Aug 31, 2022
c41e4aa
Store block ID separately
tomusborne Aug 31, 2022
af8085b
Update code comment
tomusborne Aug 31, 2022
2bca8f7
Change param name
tomusborne Sep 1, 2022
8be8387
Merge pull request #679 from tomusborne/fix-duplicate-css-external-file
tomusborne Sep 1, 2022
4a83b30
Update readme.txt
tomusborne Sep 1, 2022
249a2a1
Fix: Missing CSS when do_blocks is ran early
tomusborne Sep 3, 2022
dca8fa7
Add block_id_exists function
tomusborne Sep 5, 2022
8abf7b2
Merge pull request #683 from tomusborne/fix-missing-css
tomusborne Sep 5, 2022
4d9df4c
Update readme.txt
tomusborne Sep 5, 2022
413b09c
1.6.0-alpha.2
tomusborne Sep 6, 2022
00e8343
1.6.0-beta.1
tomusborne Sep 12, 2022
98bd813
Fix: Container styles being overwritten when multi-selected
JeanPaiva Sep 13, 2022
f28f0e3
Update readme.txt
tomusborne Sep 13, 2022
ad8ccc4
Add empty string default to color
tomusborne Sep 13, 2022
ccf457d
Merge pull request #695 from tomusborne/fix-container-multi-select
tomusborne Sep 13, 2022
bd50228
Update dist files
github-actions[bot] Sep 13, 2022
065e63b
Fix: Remove gb-*-text class from blocks with icons
tomusborne Sep 20, 2022
c6318f4
Fix: Dynamic content conflict with icons and custom classes
tomusborne Sep 20, 2022
7317879
Fix: Missing legacy alpha color slider
tomusborne Sep 20, 2022
834db8b
Update readme.txt
tomusborne Sep 20, 2022
f829112
Merge pull request #699 from tomusborne/fix-dynamic-class-conflict
tomusborne Sep 21, 2022
7628c89
Merge pull request #700 from tomusborne/fix-missing-legacy-alpha-slider
tomusborne Sep 21, 2022
64807c9
Update dist files
github-actions[bot] Sep 21, 2022
930def0
1.6.0-rc.1
tomusborne Sep 21, 2022
12305a5
Fix php 8 deprecation warning
JeanPaiva Sep 26, 2022
edcbbd1
Merge pull request #703 from tomusborne/fix-php8-warning
JeanPaiva Sep 27, 2022
57fd861
1.6.0-rc.2
JeanPaiva Sep 27, 2022
3569204
Fix: Default button not showing after buttons block added
JeanPaiva Oct 3, 2022
0aeb7c1
Merge pull request #712 from tomusborne/fix-default-buttons
JeanPaiva Oct 3, 2022
47f1d7d
Update dist files
github-actions[bot] Oct 3, 2022
5a21fca
1.6.0
tomusborne Oct 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-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' => '014d85cef652b1076b830deafd78f166');
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', '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' => '2621a2be94ece6e8e748da3efcd2ac0d');
28 changes: 14 additions & 14 deletions dist/blocks.js

Large diffs are not rendered by default.

297 changes: 297 additions & 0 deletions includes/blocks/class-button-container.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
<?php
/**
* Handles the Button Container block.
*
* @package GenerateBlocks
*/

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

/**
* Add Button Container related functions.
*/
class GenerateBlocks_Block_Button_Container {
/**
* Keep track of all blocks of this type on the page.
*
* @var array $block_ids The current block id.
*/
private static $block_ids = [];

/**
* Keep track of CSS we want to output once per block type.
*
* @var boolean
*/
private static $singular_css_added = false;

/**
* Block defaults.
*/
public static function defaults() {
return [
'alignment' => '',
'alignmentTablet' => '',
'alignmentMobile' => '',
'marginTop' => '',
'marginRight' => '',
'marginBottom' => '',
'marginLeft' => '',
'marginTopTablet' => '',
'marginRightTablet' => '',
'marginBottomTablet' => '',
'marginLeftTablet' => '',
'marginTopMobile' => '',
'marginRightMobile' => '',
'marginBottomMobile' => '',
'marginLeftMobile' => '',
'marginUnit' => 'px',
'stack' => false,
'stackTablet' => false,
'stackMobile' => false,
'fillHorizontalSpace' => false,
'fillHorizontalSpaceTablet' => false,
'fillHorizontalSpaceMobile' => false,
];
}

/**
* Store our block ID in memory.
*
* @param string $id The block ID to store.
*/
public static function store_block_id( $id ) {
self::$block_ids[] = $id;
}

/**
* Check if our block ID exists.
*
* @param string $id The block ID to store.
*/
public static function block_id_exists( $id ) {
return in_array( $id, (array) self::$block_ids );
}

/**
* Compile our CSS data based on our block attributes.
*
* @param array $attributes Our block attributes.
*/
public static function get_css_data( $attributes ) {
$css = new GenerateBlocks_Dynamic_CSS();
$desktop_css = new GenerateBlocks_Dynamic_CSS();
$tablet_css = new GenerateBlocks_Dynamic_CSS();
$tablet_only_css = new GenerateBlocks_Dynamic_CSS();
$mobile_css = new GenerateBlocks_Dynamic_CSS();
$css_data = [];

$defaults = generateblocks_get_block_defaults();

$settings = wp_parse_args(
$attributes,
$defaults['buttonContainer']
);

$id = $attributes['uniqueId'];
$blockVersion = ! empty( $settings['blockVersion'] ) ? $settings['blockVersion'] : 1;

// Only add this CSS once.
if ( ! self::$singular_css_added ) {
$css->set_selector( '.gb-button-wrapper' );
$css->add_property( 'display', 'flex' );
$css->add_property( 'flex-wrap', 'wrap' );
$css->add_property( 'align-items', 'flex-start' );
$css->add_property( 'justify-content', 'flex-start' );
$css->add_property( 'clear', 'both' );

self::$singular_css_added = true;
}

$css->set_selector( '.gb-button-wrapper-' . $id );
$css->add_property( 'margin', array( $settings['marginTop'], $settings['marginRight'], $settings['marginBottom'], $settings['marginLeft'] ), $settings['marginUnit'] );
$css->add_property( 'justify-content', generateblocks_get_flexbox_alignment( $settings['alignment'] ) );

$stack_desktop = $desktop_css;
$stack_tablet_only = $tablet_only_css;

if ( $blockVersion < 2 ) {
$stack_desktop = $css;
$stack_tablet_only = $tablet_css;
}

if ( $settings['stack'] ) {
$stack_desktop->set_selector( '.gb-button-wrapper-' . $id );
$stack_desktop->add_property( 'flex-direction', 'column' );
$stack_desktop->add_property( 'align-items', generateblocks_get_flexbox_alignment( $settings['alignment'] ) );
}

if ( $settings['fillHorizontalSpace'] ) {
$stack_desktop->set_selector( '.gb-button-wrapper-' . $id . ' > .gb-button' );
$stack_desktop->add_property( 'flex', '1' );
}

if ( $settings['stack'] && $settings['fillHorizontalSpace'] ) {
$stack_desktop->add_property( 'width', '100%' );
$stack_desktop->add_property( 'box-sizing', 'border-box' );
}

$tablet_css->set_selector( '.gb-button-wrapper-' . $id );
$tablet_css->add_property( 'margin', array( $settings['marginTopTablet'], $settings['marginRightTablet'], $settings['marginBottomTablet'], $settings['marginLeftTablet'] ), $settings['marginUnit'] );
$tablet_css->add_property( 'justify-content', generateblocks_get_flexbox_alignment( $settings['alignmentTablet'] ) );

if ( $settings['stackTablet'] ) {
$stack_tablet_only->set_selector( '.gb-button-wrapper-' . $id );
$stack_tablet_only->add_property( 'flex-direction', 'column' );
$stack_tablet_only->add_property( 'align-items', generateblocks_get_flexbox_alignment( $settings['alignmentTablet'] ) );
}

if ( $settings['fillHorizontalSpaceTablet'] ) {
$stack_tablet_only->set_selector( '.gb-button-wrapper-' . $id . ' > .gb-button' );
$stack_tablet_only->add_property( 'flex', '1' );
}

if ( $settings['stackTablet'] && $settings['fillHorizontalSpaceTablet'] ) {
$stack_tablet_only->add_property( 'width', '100%' );
$stack_tablet_only->add_property( 'box-sizing', 'border-box' );
}

$mobile_css->set_selector( '.gb-button-wrapper-' . $id );
$mobile_css->add_property( 'margin', array( $settings['marginTopMobile'], $settings['marginRightMobile'], $settings['marginBottomMobile'], $settings['marginLeftMobile'] ), $settings['marginUnit'] );
$mobile_css->add_property( 'justify-content', generateblocks_get_flexbox_alignment( $settings['alignmentMobile'] ) );

if ( $settings['stackMobile'] ) {
$mobile_css->add_property( 'flex-direction', 'column' );
$mobile_css->add_property( 'align-items', generateblocks_get_flexbox_alignment( $settings['alignmentMobile'] ) );
}

if ( $settings['fillHorizontalSpaceMobile'] ) {
$mobile_css->set_selector( '.gb-button-wrapper-' . $id . ' > .gb-button' );
$mobile_css->add_property( 'flex', '1' );
}

if ( $settings['stackMobile'] && $settings['fillHorizontalSpaceMobile'] ) {
$mobile_css->add_property( 'width', '100%' );
$mobile_css->add_property( 'box-sizing', 'border-box' );
}

// Store this block ID in memory.
self::store_block_id( $id );

/**
* Do generateblocks_block_css_data hook
*
* @since 1.0
*
* @param string $name The name of our block.
* @param array $settings The settings for the current block.
* @param object $css Our desktop/main CSS data.
* @param object $desktop_css Our desktop only CSS data.
* @param object $tablet_css Our tablet CSS data.
* @param object $tablet_only_css Our tablet only CSS data.
* @param object $mobile_css Our mobile CSS data.
*/
do_action(
'generateblocks_block_css_data',
'button-container',
$settings,
$css,
$desktop_css,
$tablet_css,
$tablet_only_css,
$mobile_css
);

return [
'main' => $css->css_output(),
'desktop' => $desktop_css->css_output(),
'tablet' => $tablet_css->css_output(),
'tablet_only' => $tablet_only_css->css_output(),
'mobile' => $mobile_css->css_output(),
];
}

/**
* Wrapper function for our dynamic buttons.
*
* @since 1.6.0
* @param array $attributes The block attributes.
* @param string $content The dynamic text to display.
* @param WP_Block $block Block instance.
*/
public static function render_block( $attributes, $content, $block ) {
if ( ! isset( $attributes['isDynamic'] ) || ! $attributes['isDynamic'] ) {
// Add styles to this block if needed.
$content = generateblocks_maybe_add_block_css(
$content,
[
'class_name' => 'GenerateBlocks_Block_Button_Container',
'attributes' => $attributes,
'block_ids' => self::$block_ids,
]
);

return $content;
}

if ( isset( $block->parsed_block['innerBlocks'] ) ) {
$button_count = apply_filters(
'generateblocks_button_count',
count( (array) $block->parsed_block['innerBlocks'] ),
$attributes,
$block
);

if ( 0 === $button_count ) {
return;
}
}

$defaults = generateblocks_get_block_defaults();

$settings = wp_parse_args(
$attributes,
$defaults['buttonContainer']
);

$classNames = array(
'gb-button-wrapper',
'gb-button-wrapper-' . $settings['uniqueId'],
);

if ( ! empty( $settings['className'] ) ) {
$classNames[] = $settings['className'];
}

// Add styles to this block if needed.
$output = generateblocks_maybe_add_block_css(
'',
[
'class_name' => 'GenerateBlocks_Block_Button_Container',
'attributes' => $attributes,
'block_ids' => self::$block_ids,
]
);

$output .= sprintf(
'<div %s>',
generateblocks_attr(
'button-container',
array(
'id' => isset( $settings['anchor'] ) ? $settings['anchor'] : null,
'class' => implode( ' ', $classNames ),
),
$settings,
$block
)
);

$output .= $content;

$output .= '</div>';

return $output;
}
}
Loading