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.9.2 #1251

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
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' => '8eefe8b6380072d833c4');
<?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' => '6c1ebe60a240c7da4e5c');
18 changes: 9 additions & 9 deletions dist/blocks.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

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

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.9.1",
"version": "1.9.2",
"private": true,
"description": "A small collection of lightweight WordPress blocks that can accomplish nearly anything.",
"author": "Tom Usborne",
Expand Down
6 changes: 3 additions & 3 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.9.1
* Version: 1.9.2
* Requires at least: 5.9
* Requires PHP: 7.2
* License: GPL2+
Expand All @@ -19,7 +19,7 @@
exit; // Exit if accessed directly.
}

define( 'GENERATEBLOCKS_VERSION', '1.9.1' );
define( 'GENERATEBLOCKS_VERSION', '1.9.2' );
define( 'GENERATEBLOCKS_DIR', plugin_dir_path( __FILE__ ) );
define( 'GENERATEBLOCKS_DIR_URL', plugin_dir_url( __FILE__ ) );

Expand Down Expand Up @@ -59,7 +59,7 @@
require_once GENERATEBLOCKS_DIR . 'includes/blocks/class-image.php';
require_once GENERATEBLOCKS_DIR . 'includes/blocks/class-query-loop.php';

add_action( 'plugins_loaded', 'generateblocks_load_plugin_textdomain' );
add_action( 'after_setup_theme', 'generateblocks_load_plugin_textdomain' );
/**
* Load GenerateBlocks textdomain.
*
Expand Down
14 changes: 9 additions & 5 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
=== GenerateBlocks ===
Contributors: edge22
Donate link: https://generateblocks.com
Donate link: https://generatepress.com
Tags: blocks, gutenberg, editor, page builder, posts
Requires at least: 5.9
Tested up to: 6.5
Tested up to: 6.7
Requires PHP: 7.2
Stable tag: 1.9.1
Stable tag: 1.9.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -15,9 +15,9 @@ A small collection of lightweight WordPress blocks that can accomplish nearly an

Add incredible versatility to your editor without bloating it with tons of one-dimensional Gutenberg blocks. With GenerateBlocks, you can learn a handful of blocks deeply and use them to build anything.

[GenerateBlocks](https://generateblocks.com?utm_source=wp-repo&utm_medium=link&utm_campaign=readme) works hand-in-hand with [GeneratePress](https://generatepress.com?utm_source=wp-repo&utm_medium=link&utm_campaign=generateblocks-readme), but is built to work with any theme.
[GenerateBlocks](https://generatepress.com/blocks?utm_source=wp-repo&utm_medium=link&utm_campaign=readme) works hand-in-hand with [GeneratePress](https://generatepress.com/theme?utm_source=wp-repo&utm_medium=link&utm_campaign=generateblocks-readme), but is built to work with any theme.

Looking for more features? Check out [GenerateBlocks Pro](https://generateblocks.com/pro?utm_source=wp-repo&utm_medium=link&utm_campaign=readme).
Looking for more features? Check out [GenerateBlocks Pro](https://generatepress.com/blocks?utm_source=wp-repo&utm_medium=link&utm_campaign=readme).

= Container =

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

== Changelog ==

= 1.9.2 =
* Fix: Use latest getDeviceType functions in 6.7 if available
* Tweak: Loading order of load_plugin_textdomain()

= 1.9.1 =
* Fix: Patterns not loading properly in Chrome
* Fix: Pattern search mixing up active libraries
Expand Down
14 changes: 10 additions & 4 deletions src/blocks/button-container/components/ComponentCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ import shouldRebuildCSS from '../../../utils/should-rebuild-css';

function ComponentCSS( props ) {
const deviceType = useSelect( ( select ) => {
if ( ! select( 'core/edit-post' ) ) {
return 'Desktop';
const { getDeviceType } = select( 'core/editor' ) || {};

if ( 'function' === typeof getDeviceType ) {
return getDeviceType();
}

const {
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType = () => 'Desktop',
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType,
} = select( 'core/edit-post' );

return experimentalGetPreviewDeviceType();
if ( 'function' === typeof experimentalGetPreviewDeviceType ) {
return experimentalGetPreviewDeviceType();
}

return '';
}, [] );

const {
Expand Down
14 changes: 10 additions & 4 deletions src/blocks/button/components/ComponentCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ import shouldRebuildCSS from '../../../utils/should-rebuild-css';

function ComponentCSS( props ) {
const deviceType = useSelect( ( select ) => {
if ( ! select( 'core/edit-post' ) ) {
return 'Desktop';
const { getDeviceType } = select( 'core/editor' ) || {};

if ( 'function' === typeof getDeviceType ) {
return getDeviceType();
}

const {
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType = () => 'Desktop',
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType,
} = select( 'core/edit-post' );

return experimentalGetPreviewDeviceType();
if ( 'function' === typeof experimentalGetPreviewDeviceType ) {
return experimentalGetPreviewDeviceType();
}

return '';
}, [] );

const {
Expand Down
14 changes: 10 additions & 4 deletions src/blocks/container/components/ComponentCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ import shouldRebuildCSS from '../../../utils/should-rebuild-css';

function ComponentCSS( props ) {
const deviceType = useSelect( ( select ) => {
if ( ! select( 'core/edit-post' ) ) {
return 'Desktop';
const { getDeviceType } = select( 'core/editor' ) || {};

if ( 'function' === typeof getDeviceType ) {
return getDeviceType();
}

const {
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType = () => 'Desktop',
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType,
} = select( 'core/edit-post' );

return experimentalGetPreviewDeviceType();
if ( 'function' === typeof experimentalGetPreviewDeviceType ) {
return experimentalGetPreviewDeviceType();
}

return '';
}, [] );

const {
Expand Down
14 changes: 10 additions & 4 deletions src/blocks/grid/components/ComponentCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ import shouldRebuildCSS from '../../../utils/should-rebuild-css';

function ComponentCSS( props ) {
const deviceType = useSelect( ( select ) => {
if ( ! select( 'core/edit-post' ) ) {
return 'Desktop';
const { getDeviceType } = select( 'core/editor' ) || {};

if ( 'function' === typeof getDeviceType ) {
return getDeviceType();
}

const {
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType = () => 'Desktop',
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType,
} = select( 'core/edit-post' );

return experimentalGetPreviewDeviceType();
if ( 'function' === typeof experimentalGetPreviewDeviceType ) {
return experimentalGetPreviewDeviceType();
}

return '';
}, [] );

const {
Expand Down
14 changes: 10 additions & 4 deletions src/blocks/headline/components/ComponentCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ import shouldRebuildCSS from '../../../utils/should-rebuild-css';

function ComponentCSS( props ) {
const deviceType = useSelect( ( select ) => {
if ( ! select( 'core/edit-post' ) ) {
return 'Desktop';
const { getDeviceType } = select( 'core/editor' ) || {};

if ( 'function' === typeof getDeviceType ) {
return getDeviceType();
}

const {
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType = () => 'Desktop',
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType,
} = select( 'core/edit-post' );

return experimentalGetPreviewDeviceType();
if ( 'function' === typeof experimentalGetPreviewDeviceType ) {
return experimentalGetPreviewDeviceType();
}

return '';
}, [] );

const {
Expand Down
14 changes: 10 additions & 4 deletions src/blocks/image/components/ComponentCSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ import shouldRebuildCSS from '../../../utils/should-rebuild-css';

function ComponentCSS( props ) {
const deviceType = useSelect( ( select ) => {
if ( ! select( 'core/edit-post' ) ) {
return 'Desktop';
const { getDeviceType } = select( 'core/editor' ) || {};

if ( 'function' === typeof getDeviceType ) {
return getDeviceType();
}

const {
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType = () => 'Desktop',
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType,
} = select( 'core/edit-post' );

return experimentalGetPreviewDeviceType();
if ( 'function' === typeof experimentalGetPreviewDeviceType ) {
return experimentalGetPreviewDeviceType();
}

return '';
}, [] );

const {
Expand Down
48 changes: 36 additions & 12 deletions src/hooks/useDeviceType.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useDispatch, useSelect, dispatch } from '@wordpress/data';
import { dispatch, useSelect } from '@wordpress/data';
import { useEffect } from '@wordpress/element';
import useLocalStorageState from 'use-local-storage-state';

Expand All @@ -10,26 +10,50 @@ export default ( initialDeviceType = 'Desktop' ) => {
}
);

if ( ! dispatch( 'core/edit-post' ) || ( generateBlocksInfo && ! generateBlocksInfo.syncResponsivePreviews ) ) {
const setDeviceType = ( type ) => {
setLocalDeviceType( type );
};
const setPreviewDeviceType = ( deviceType ) => {
const { setDeviceType } = dispatch( 'core/editor' ) || {};

return [ localDeviceType, setDeviceType ];
}
if ( 'function' === typeof setDeviceType ) {
return setDeviceType( deviceType );
}

const {
__experimentalSetPreviewDeviceType: setPreviewDeviceType = () => {},
} = useDispatch( 'core/edit-post' );
const { __experimentalSetPreviewDeviceType: experimentalSetPreviewDeviceType } = dispatch( 'core/edit-post' );

if ( 'function' === typeof experimentalSetPreviewDeviceType ) {
return experimentalSetPreviewDeviceType( deviceType );
}
};

const previewDeviceType = useSelect( ( select ) => {
const { getDeviceType } = select( 'core/editor' ) || {};

if ( 'function' === typeof getDeviceType ) {
return getDeviceType();
}

const {
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType = () => false,
__experimentalGetPreviewDeviceType: experimentalGetPreviewDeviceType,
} = select( 'core/edit-post' );

return experimentalGetPreviewDeviceType();
if ( 'function' === typeof experimentalGetPreviewDeviceType ) {
return experimentalGetPreviewDeviceType();
}

return undefined;
}, [] );

if (
undefined === previewDeviceType || // core/editor and/or core/edit-post must not be available.
( generateBlocksInfo && ! generateBlocksInfo.syncResponsivePreviews )
) {
const setDeviceType = ( type ) => {
setLocalDeviceType( type );
};

// If we don't have the necessary functions, or sync previews are turned off, return the local states here.
return [ localDeviceType, setDeviceType ];
}

useEffect( () => {
if ( previewDeviceType !== localDeviceType ) {
setLocalDeviceType( previewDeviceType );
Expand Down
Loading