From 514e459ae9b6c6f1aac935097ee3bacb5007ac2b Mon Sep 17 00:00:00 2001 From: George Olaru Date: Thu, 15 Jun 2023 11:24:26 +0300 Subject: [PATCH 1/7] Update the input required attribute based on the commenterBackgroundRequired value #441 --- .../lib/renderers/class-novablocks-comments-form.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/blocks/post-comments/lib/renderers/class-novablocks-comments-form.php b/packages/block-library/src/blocks/post-comments/lib/renderers/class-novablocks-comments-form.php index 34b4e685..8c59ef5a 100644 --- a/packages/block-library/src/blocks/post-comments/lib/renderers/class-novablocks-comments-form.php +++ b/packages/block-library/src/blocks/post-comments/lib/renderers/class-novablocks-comments-form.php @@ -550,18 +550,20 @@ public function adjust_comment_form_defaults( $defaults ) { } // We need to add the commenter background field to the comment textarea because we want it for logged in users too. + $defaults['comment_field'] .= sprintf( '

%s - +

', $args['commenterBackgroundLabel'], ( $args['commenterBackgroundRequired'] ? ' *' : '' ), $args['commenterBackgroundDescription'], esc_attr( $previous_commenter_background ), - esc_attr( $args['commenterBackgroundPlaceholder'] ) + esc_attr( $args['commenterBackgroundPlaceholder'] ), + ( $args['commenterBackgroundRequired'] ? 'required="required"' : '') ); } From a2bc4fd1518bfa99df4a38c7ae9c66dd0caa5eef Mon Sep 17 00:00:00 2001 From: George Olaru Date: Thu, 15 Jun 2023 12:24:02 +0300 Subject: [PATCH 2/7] Added a block option to enable/disable the User Background #441 Next: save it to the database and retrieve it via PHP --- .../src/blocks/post-comments/edit.js | 12 +++- .../src/blocks/post-comments/index.js | 19 ++++-- .../post-comments/inspector-controls.js | 63 +++++++++++++++++++ 3 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 packages/block-library/src/blocks/post-comments/inspector-controls.js diff --git a/packages/block-library/src/blocks/post-comments/edit.js b/packages/block-library/src/blocks/post-comments/edit.js index ed4fb6c9..b6d56e70 100644 --- a/packages/block-library/src/blocks/post-comments/edit.js +++ b/packages/block-library/src/blocks/post-comments/edit.js @@ -9,9 +9,18 @@ import { useSelect } from "@wordpress/data"; import { RawHTML } from "@wordpress/element"; import { useBlockProps, Warning } from "@wordpress/block-editor"; +import { useInnerBlocks, VariationPicker } from "@novablocks/block-editor"; + +import InspectorControls from "./inspector-controls"; + const PostCommentsEdit = props => { - const { context } = props; + const { + context, + attributes: { + hasUserExperience + }, + } = props; const commentStatus = useSelect( select => select( 'core/editor' ).getEditedPostAttribute( 'comment_status' ) ); const { postId, postType } = context; @@ -28,6 +37,7 @@ const PostCommentsEdit = props => { if ( ! postType || ! postId ) { return (
+ { __( 'Nova Blocks: Conversation System Block.', '__plugin_txtd' ) }
); diff --git a/packages/block-library/src/blocks/post-comments/index.js b/packages/block-library/src/blocks/post-comments/index.js index 74c7464f..0043ea17 100644 --- a/packages/block-library/src/blocks/post-comments/index.js +++ b/packages/block-library/src/blocks/post-comments/index.js @@ -1,3 +1,4 @@ + /** * Internal dependencies */ @@ -8,17 +9,25 @@ import edit from './edit'; * WordPress dependencies */ import { registerBlockType } from '@wordpress/blocks'; +import { addFilter } from "@wordpress/hooks"; import { InnerBlocks } from "@wordpress/block-editor"; import { getSvg } from "@novablocks/block-editor"; registerBlockType( 'novablocks/post-comments', { - icon: getSvg( iconSvg ), + icon: getSvg( iconSvg ), + attributes: { // Define block attributes + hasUserExperience: { + type: 'boolean', + default: true, + }, + }, edit, save() { - return ; + return ; }, getEditWrapperProps() { - const settings = wp.data.select( 'core/block-editor' ).getSettings(); - return settings.alignWide ? { 'data-align': 'full' } : {}; + const settings = wp.data.select( 'core/block-editor' ).getSettings(); + return settings.alignWide ? { 'data-align': 'full' } : {}; }, -} ); + } ); + diff --git a/packages/block-library/src/blocks/post-comments/inspector-controls.js b/packages/block-library/src/blocks/post-comments/inspector-controls.js new file mode 100644 index 00000000..be274270 --- /dev/null +++ b/packages/block-library/src/blocks/post-comments/inspector-controls.js @@ -0,0 +1,63 @@ +/** + * WordPress dependencies + */ +import { __ } from '@wordpress/i18n'; +import { ToggleControl } from '@wordpress/components'; +import { Fragment, useState } from "@wordpress/element"; +import { ControlsGroup, ControlsSection, ControlsTab } from "@novablocks/block-editor"; +import { useEffect } from '@wordpress/element'; // Import useEffect + +const PostCommentsInspectorControls = ( props ) => { + + const { + attributes, + setAttributes, + } = props; + + const { + hasUserExperience: hasUserExperienceAttribute = true + } = attributes; + + const [hasUserExperience, setHasUserExperience] = useState(hasUserExperienceAttribute); + + useEffect(() => { + setHasUserExperience(hasUserExperienceAttribute); + }, [hasUserExperienceAttribute]); + + return ( + + + + + + { + setHasUserExperience(!hasUserExperience); + setAttributes({ + ...attributes, + hasUserExperience: !hasUserExperience, + }); + }} + /> + + + + + + + ); +}; + +export default PostCommentsInspectorControls; From 8c53b6de934debd27582e3e0b3edbd3005b55ed4 Mon Sep 17 00:00:00 2001 From: George Olaru Date: Mon, 3 Jul 2023 14:40:54 +0300 Subject: [PATCH 3/7] Made the necessary checks on PHP side too #441 --- .../metas/class-novablocks-comments-meta.php | 18 +++++++++++++++--- .../class-novablocks-comments-form.php | 6 +++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/blocks/post-comments/lib/metas/class-novablocks-comments-meta.php b/packages/block-library/src/blocks/post-comments/lib/metas/class-novablocks-comments-meta.php index b917e5d8..bfdfb237 100644 --- a/packages/block-library/src/blocks/post-comments/lib/metas/class-novablocks-comments-meta.php +++ b/packages/block-library/src/blocks/post-comments/lib/metas/class-novablocks-comments-meta.php @@ -62,6 +62,17 @@ public function verify_comment_meta_data( array $commentdata ): array { return $commentdata; } + + // Include or require the class-novablocks-comments-form.php file if it's not already included. + require_once dirname(__FILE__) . '/../renderers/class-novablocks-comments-form.php'; + + // Create an instance of NovaBlocks_Comments_Form. + $commentsForm = new NovaBlocks_Comments_Form(); + + // Access the $commenterBackgroundRequired variable. + $commenter_background_required = $commentsForm->getArgs()['commenterBackgroundRequired']; + + // We only enforce the commenter background for comments, not other types like reviews. if ( empty( $commentdata['comment_type'] ) || 'comment' !== $commentdata['comment_type'] ) { return $commentdata; @@ -76,11 +87,12 @@ public function verify_comment_meta_data( array $commentdata ): array { } } - if ( empty( $_POST['nb_commenter_background'] ) ) { + if (empty($_POST['nb_commenter_background']) && $commenter_background_required) { $comment = new WP_Error( 'require_nb_commenter_background', __( 'Error: You did not add your relevant background or experience.', '__plugin_txtd' ), 200 ); } else { - $stripped_background = trim( strip_tags( $_POST['nb_commenter_background'] ) ); - if ( mb_strlen( $stripped_background, '8bit' ) > 245 ) { + $stripped_background = isset($_POST['nb_commenter_background']) ? trim( strip_tags( $_POST['nb_commenter_background'] ) ) : ''; + + if (isset($stripped_background) && mb_strlen($stripped_background, '8bit') > 245) { $comment = new WP_Error( 'nb_commenter_background_length', __( 'Error: Your background or experience is too long.' ), 200 ); } } diff --git a/packages/block-library/src/blocks/post-comments/lib/renderers/class-novablocks-comments-form.php b/packages/block-library/src/blocks/post-comments/lib/renderers/class-novablocks-comments-form.php index 8c59ef5a..89d45627 100644 --- a/packages/block-library/src/blocks/post-comments/lib/renderers/class-novablocks-comments-form.php +++ b/packages/block-library/src/blocks/post-comments/lib/renderers/class-novablocks-comments-form.php @@ -74,7 +74,7 @@ public function __construct( $post = null, array $args = [] ) { // Display the commenter background field. 'commenterBackground' => true, - 'commenterBackgroundRequired' => true, + 'commenterBackgroundRequired' => false, 'commenterBackgroundLabel' => esc_html__( 'What is your background around this topic?', '__plugin_txtd' ), // Leave empty for no description. 'commenterBackgroundDescription' => esc_html__( 'Example: Practical philosopher, therapist and writer.', '__plugin_txtd' ), @@ -111,6 +111,10 @@ public function __construct( $post = null, array $args = [] ) { ] ); } + public function getArgs() { + return $this->args; + } + /** * Entry point to render the comments form. * From d88de0243e4b36d000c57740402e497fa7c9568b Mon Sep 17 00:00:00 2001 From: George Olaru Date: Thu, 30 Nov 2023 16:33:24 +0200 Subject: [PATCH 4/7] Fix zero height issue in novablocks-drawers with auto fallback #443 Implemented a temporary fix for the intermittent zero height issue in `novablocks-drawers`. In situations where the calculated height of the drawers is `0px`, a fallback height of 'auto' is now used. This ensures that the drawers do not collapse unexpectedly. Note: This is a temporary solution, and further investigation is needed to address the root cause of the incorrect height calculation. --- packages/block-editor/src/components/drawer/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/drawer/index.js b/packages/block-editor/src/components/drawer/index.js index 4214e751..13912c9f 100644 --- a/packages/block-editor/src/components/drawer/index.js +++ b/packages/block-editor/src/components/drawer/index.js @@ -59,7 +59,7 @@ const Drawers = ( ownProps ) => { const drawerPanelHeight = getActiveDrawerTitleHeight(); // If the drawer is open, the height of the wrapper should be the height of the drawer panel. - setWrapperHeight( !! open ? drawerPanelHeight : drawerListHeight ); + setWrapperHeight( (!!open ? drawerPanelHeight : drawerListHeight) || 'auto' ); }; // This hook updates the height of the collapsible to match the height of the content From 6a742cf53126cbdef42823e88d432c59fe76ea91 Mon Sep 17 00:00:00 2001 From: George Olaru Date: Thu, 2 May 2024 17:32:50 +0300 Subject: [PATCH 5/7] Temporary disable Duotone filter #445 --- .../with-overlay-filter/with-overlay-filter-controls.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/filters/with-overlay-filter/with-overlay-filter-controls.js b/packages/block-editor/src/filters/with-overlay-filter/with-overlay-filter-controls.js index c1ed1602..8a9fb24f 100644 --- a/packages/block-editor/src/filters/with-overlay-filter/with-overlay-filter-controls.js +++ b/packages/block-editor/src/filters/with-overlay-filter/with-overlay-filter-controls.js @@ -7,13 +7,17 @@ import { useSupports } from "../../hooks"; import Controls from "./controls"; import { getDuotoneFilterSvg } from "@novablocks/utils"; +import { useRef, useEffect } from "@wordpress/element"; +import { useBlockProps } from "@wordpress/block-editor"; + + const DuotoneFilter = ( props ) => { const { attributes, clientId } = props; const { overlayFilterDuotoneConfig, overlayFilterType } = attributes; const from = overlayFilterDuotoneConfig?.from; const to = overlayFilterDuotoneConfig?.to; - const element = useContext( BlockList.__unstableElementContext ); + // const element = useContext( BlockList.__unstableElementContext ); // WordPress 6.5 conflict const id = `novablocks-duotone-${ clientId }`; if ( ! from || ! to || overlayFilterType !== 'duotone' ) { From 224ea88d74add5a4f03cd06bc63fd2c1ccea7c7b Mon Sep 17 00:00:00 2001 From: George Olaru Date: Thu, 2 May 2024 17:32:57 +0300 Subject: [PATCH 6/7] Update package-lock.json --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index ab15d865..0b74e2cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19734,6 +19734,12 @@ "find-up": "^4.0.0" } }, + "prettier": { + "version": "npm:wp-prettier@2.2.1-beta-1", + "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.2.1-beta-1.tgz", + "integrity": "sha512-+JHkqs9LC/JPp51yy1hzs3lQ7qeuWCwOcSzpQNeeY/G7oSpnF61vxt7hRh87zNRTr6ob2ndy0W8rVzhgrcA+Gw==", + "dev": true + }, "react": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", @@ -36804,12 +36810,6 @@ "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", "dev": true }, - "prettier": { - "version": "npm:wp-prettier@2.2.1-beta-1", - "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.2.1-beta-1.tgz", - "integrity": "sha512-+JHkqs9LC/JPp51yy1hzs3lQ7qeuWCwOcSzpQNeeY/G7oSpnF61vxt7hRh87zNRTr6ob2ndy0W8rVzhgrcA+Gw==", - "dev": true - }, "prettier-linter-helpers": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", From 1f58470c67824e811621dc130d19531885ae1ad5 Mon Sep 17 00:00:00 2001 From: George Olaru Date: Fri, 3 May 2024 13:08:22 +0300 Subject: [PATCH 7/7] Updated version and number of tags --- nova-blocks.php | 4 ++-- readme.txt | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/nova-blocks.php b/nova-blocks.php index 906715a6..40664d54 100644 --- a/nova-blocks.php +++ b/nova-blocks.php @@ -3,14 +3,14 @@ * Plugin Name: Nova Blocks * Plugin URI: https://github.com/pixelgrade/nova-blocks/ * Description: Nova Blocks is a collection of distinctive Gutenberg blocks, committed to making your site shine like a newborn star. It is taking a design-driven approach to help you made the right decisions and showcase your content in the best shape. - * Version: 2.1.6 + * Version: 2.1.7 * Author: Pixelgrade * Author URI: https://www.pixelgrade.com * License: GPLv2 or later * License URI: http://www.gnu.org/licenses/gpl-2.0.txt * Text Domain: __plugin_txtd * Requires at least: 5.9 - * Tested up to: 6.2 + * Tested up to: 6.5.3 * Requires PHP: 7.4 * GitHub Plugin URI: pixelgrade/nova-blocks * Release Asset: true diff --git a/readme.txt b/readme.txt index ec9cd05d..d62fade6 100644 --- a/readme.txt +++ b/readme.txt @@ -2,8 +2,8 @@ Contributors: pixelgrade, vlad.olaru, babbardel, razvanonofrei, gorby31 Tags: blocks, editor, gutenberg, gutenberg blocks, page builder, block enabled, page building, full site editing, site editor, posts collection Requires at least: 5.9 -Tested up to: 6.2.0 -Stable tag: 2.1.6 +Tested up to: 6.5.3 +Stable tag: 2.1.7 Requires PHP: 7.4 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -94,6 +94,12 @@ Yes! Nova Block's core features are free to use. == Changelog == += 2.1.7 = +* Resolved a compatibility issue with WordPress 6.5.x where blocks displayed the error "This block has encountered an error and cannot be previewed." +* Fixed an intermittent issue where 'novablocks-drawers' could collapse due to a miscalculation of height at 0px. This was caused by the 'getActiveDrawerTitleHeight' function returning incorrect values under certain rendering conditions. +* Modified the Conversation System to make the "Background" field optional, addressing errors encountered when users tried to comment without filling this field. +* Tested compatibility with the latest WordPress 6.5.3 version. + = 2.1.6 = * Fixed issue with blocks options being hidden when opening a sliding panel * Restored missing Content Alignment icons in Space and Sizing component