Skip to content

Commit

Permalink
Merge branch 'development' into feat/posts-rank-math
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Sep 25, 2023
2 parents 5699665 + c815809 commit e14821a
Show file tree
Hide file tree
Showing 23 changed files with 505 additions and 125 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
#### [Version 2.4.0](https://github.com/Codeinwp/otter-blocks/compare/v2.3.4...v2.4.0) (2023-09-21)

- Introducing Otter AI Block With Form AI & Content AI Support
- Added Webhooks Integration to Form Block
- Added Hidden Field to Form Block
- Circle Counter Block Enhancements
- Adding RequestAnimationFrame() to Scroll Sniffing for Better Performance
- Added Stripe Field to Form Block
- Add Link Target Setting in Product Review Block
- Fix Slider Block Image Arrangement Behaving Weirdly
- Fix CSS Not Generating When Switching to FSE Theme
- Fix Visual Issues in Section’s Background & Overlay Controls
- Fix Box Shadow Not Changing on Section Columns
- Fix Block Settings Panel Being Visible for Non-Admins
- Fix Form Block Not Saving Changes in FSE Templates
- Fix Multiple Otter Notices Appearing at Once
- Various Small Fixes

##### [Version 2.3.4](https://github.com/Codeinwp/otter-blocks/compare/v2.3.3...v2.3.4) (2023-08-23)

- Fix z-index with Shape Divider in Section
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "codeinwp/otter-blocks",
"description": "A set of awesome Gutenberg Blocks by ThemeIsle.",
"type": "wordpress-plugin",
"version": "2.3.4",
"version": "2.4.0",
"require-dev": {
"squizlabs/php_codesniffer": "^3.3",
"wp-coding-standards/wpcs": "^1",
Expand All @@ -13,7 +13,7 @@
"yoast/phpunit-polyfills": "^2.0",
"phpstan/phpstan": "^1.10",
"szepeviktor/phpstan-wordpress": "^1.3",
"php-stubs/woocommerce-stubs": "^7.7",
"php-stubs/woocommerce-stubs": "^8.0",
"php-stubs/acf-pro-stubs": "^6.0",
"spaze/phpstan-stripe": "^2.4"
},
Expand Down
43 changes: 21 additions & 22 deletions composer.lock

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

2 changes: 1 addition & 1 deletion inc/class-blocks-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function_exists( 'wp_is_block_theme' ) &&
$templates_parts = get_block_templates( array( 'slugs__in' => $slugs ), 'wp_template_part' );

foreach ( $templates_parts as $templates_part ) {
if ( isset( $templates_part->content ) && isset( $templates_part->slug ) && in_array( $templates_part->slug, $slugs ) ) {
if ( ! empty( $templates_part->content ) && ! empty( $templates_part->slug ) && in_array( $templates_part->slug, $slugs ) ) {
$content .= $templates_part->content;
}
}
Expand Down
56 changes: 46 additions & 10 deletions inc/class-registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ class Registration {
*/
public static $block_dependencies = array();

/**
* The ids of the used widgets in the page.
*
* @var array<string>
*/
public static $widget_used = array(); // TODO: Monitor all the rendered widgets and enqueue the assets.

/**
* Flag to mark that the scripts which have loaded.
*
Expand Down Expand Up @@ -81,6 +88,7 @@ public function init() {
add_action( 'enqueue_block_assets', array( $this, 'enqueue_block_assets' ) );
add_filter( 'render_block', array( $this, 'load_sticky' ), 900, 2 );
add_filter( 'render_block', array( $this, 'subscribe_fa' ), 10, 2 );
add_filter( 'dynamic_sidebar_params', array( $this, 'watch_used_widgets' ), 9999 );

add_action(
'wp_footer',
Expand Down Expand Up @@ -348,7 +356,15 @@ function ( $content ) {
}

if ( $has_widgets ) {
$this->enqueue_dependencies( 'widgets' );
add_filter(
'wp_footer',
function ( $content ) {
$this->enqueue_dependencies( 'widgets' );

return $content;
}
);

}

if ( function_exists( 'get_block_templates' ) && function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() && current_theme_supports( 'block-templates' ) ) {
Expand Down Expand Up @@ -383,7 +399,7 @@ public function enqueue_dependencies( $post = null ) {
$templates_parts = get_block_templates( array( 'slugs__in' => $slugs ), 'wp_template_part' );

foreach ( $templates_parts as $templates_part ) {
if ( isset( $templates_part->content ) && isset( $templates_part->slug ) && in_array( $templates_part->slug, $slugs ) ) {
if ( ! empty( $templates_part->content ) && ! empty( $templates_part->slug ) && in_array( $templates_part->slug, $slugs ) ) {
$content .= $templates_part->content;
}
}
Expand Down Expand Up @@ -968,25 +984,31 @@ public static function sticky_style() {
* @return string
*/
public static function get_active_widgets_content() {
$content = '';

if ( 0 === count( self::$widget_used ) ) {
return $content;
}

global $wp_registered_widgets;
$content = '';
$valid_widgets = array();
$widget_data = get_option( 'widget_block', array() );

// Loop through all widgets, and add any that are active.
foreach ( $wp_registered_widgets as $widget_name => $widget ) {
// Get the active sidebar the widget is located in.
$sidebar = is_active_widget( $widget['callback'], $widget['id'] );
if ( ! in_array( $widget['id'], self::$widget_used, true ) ) {
continue;
}

if ( $sidebar && 'wp_inactive_widgets' !== $sidebar ) {
$key = $widget['params'][0]['number'];
$key = $widget['params'][0]['number'];

if ( isset( $widget_data[ $key ] ) ) {
$valid_widgets[] = (object) $widget_data[ $key ];
}
if ( isset( $widget_data[ $key ] ) ) {
$valid_widgets[] = (object) $widget_data[ $key ];
}
}

self::$widget_used = array();

foreach ( $valid_widgets as $widget ) {
if ( isset( $widget->content ) ) {
$content .= $widget->content;
Expand All @@ -996,6 +1018,20 @@ public static function get_active_widgets_content() {
return $content;
}

/**
* Watch and save the used widgets.
*
* @param array $params The widget params.
* @return mixed
*/
public function watch_used_widgets( $params ) {
if ( isset( $params[0]['widget_id'] ) && ! in_array( $params[0]['widget_id'], self::$widget_used ) ) {
self::$widget_used[] = $params[0]['widget_id'];
}

return $params;
}

/**
* The instance method for the static class.
* Defines and returns the instance of the static class.
Expand Down
2 changes: 1 addition & 1 deletion inc/css/class-block-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ public function enqueue_fse_css() {
$templates_parts = get_block_templates( array( 'slugs__in' => $slugs ), 'wp_template_part' );

foreach ( $templates_parts as $templates_part ) {
if ( isset( $templates_part->content ) && isset( $templates_part->slug ) && in_array( $templates_part->slug, $slugs ) ) {
if ( ! empty( $templates_part->content ) && ! empty( $templates_part->slug ) && in_array( $templates_part->slug, $slugs ) ) {
$content .= $templates_part->content;
}
}
Expand Down
4 changes: 2 additions & 2 deletions otter-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Plugin Name: Otter – Page Builder Blocks & Extensions for Gutenberg
* Plugin URI: https://themeisle.com/plugins/otter-blocks
* Description: Create beautiful and attracting posts, pages, and landing pages with Otter – Page Builder Blocks & Extensions for Gutenberg. Otter comes with dozens of Gutenberg blocks that are all you need to build beautiful pages.
* Version: 2.3.4
* Version: 2.4.0
* Author: ThemeIsle
* Author URI: https://themeisle.com
* License: GPL-2.0+
Expand All @@ -26,7 +26,7 @@
define( 'OTTER_BLOCKS_BASEFILE', __FILE__ );
define( 'OTTER_BLOCKS_URL', plugins_url( '/', __FILE__ ) );
define( 'OTTER_BLOCKS_PATH', dirname( __FILE__ ) );
define( 'OTTER_BLOCKS_VERSION', '2.3.4' );
define( 'OTTER_BLOCKS_VERSION', '2.4.0' );
define( 'OTTER_BLOCKS_PRO_SUPPORT', true );
define( 'OTTER_BLOCKS_SHOW_NOTICES', false );

Expand Down
2 changes: 1 addition & 1 deletion 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": "otter-blocks",
"version": "2.3.4",
"version": "2.4.0",
"description": "Otter – Page Builder Blocks & Extensions for Gutenberg",
"scripts": {
"build": "npm-run-all --parallel prod:*",
Expand Down
2 changes: 1 addition & 1 deletion plugins/blocks-animation/blocks-animation.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Blocks Animation: CSS Animations for Gutenberg Blocks
* Plugin URI: https://github.com/Codeinwp/otter-blocks
* Description: Blocks Animation allows you to add CSS Animations to all of your Gutenberg blocks in the most elegent way.
* Version: 2.3.4
* Version: 2.4.0
* Author: ThemeIsle
* Author URI: https://themeisle.com
* License: GPL-3.0+
Expand Down
2 changes: 1 addition & 1 deletion plugins/blocks-css/blocks-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Blocks CSS: CSS Editor for Gutenberg Blocks
* Plugin URI: https://github.com/Codeinwp/otter-blocks
* Description: Blocks CSS allows you add custom CSS to your Blocks straight from the Block Editor (Gutenberg).
* Version: 2.3.4
* Version: 2.4.0
* Author: ThemeIsle
* Author URI: https://themeisle.com
* License: GPL-3.0+
Expand Down
Loading

0 comments on commit e14821a

Please sign in to comment.