Skip to content

Commit

Permalink
Merge pull request #447 from pixelgrade/dev
Browse files Browse the repository at this point in the history
2.1.7
  • Loading branch information
georgeolaru authored May 3, 2024
2 parents 19501fe + 1f58470 commit eef1063
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 24 deletions.
4 changes: 2 additions & 2 deletions nova-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* Plugin Name: Nova Blocks
* Plugin URI: https://github.com/pixelgrade/nova-blocks/
* Description: Nova Blocks is a collection of <strong>distinctive Gutenberg blocks</strong>, 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
Expand Down
12 changes: 6 additions & 6 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 packages/block-editor/src/components/drawer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) {
Expand Down
12 changes: 11 additions & 1 deletion packages/block-library/src/blocks/post-comments/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,6 +37,7 @@ const PostCommentsEdit = props => {
if ( ! postType || ! postId ) {
return (
<div { ...blockProps }>
<InspectorControls { ...props } />
<Placeholder>{ __( 'Nova Blocks: Conversation System Block.', '__plugin_txtd' ) }</Placeholder>
</div>
);
Expand Down
19 changes: 14 additions & 5 deletions packages/block-library/src/blocks/post-comments/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/**
* Internal dependencies
*/
Expand All @@ -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 <InnerBlocks.Content />;
return <InnerBlocks.Content />;
},
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' } : {};
},
} );
} );

Original file line number Diff line number Diff line change
@@ -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 (
<Fragment>
<ControlsSection
id={ 'layout' }
order={ 10 }
label={ __( 'Elements Visibility', '__plugin_txtd' ) }
group={ __( 'Block Anatomy', '__plugin_txtd' ) }
key={ 'post_comments' }>
<ControlsTab label={ __( 'Settings', '__plugin_txtd' ) }>
<ControlsGroup>

<ToggleControl
label="User Background or Experience"
help={
hasUserExperience
? 'Display user background field.'
: 'Hide the user background field.'
}
checked={ hasUserExperience }
onChange={() => {
setHasUserExperience(!hasUserExperience);
setAttributes({
...attributes,
hasUserExperience: !hasUserExperience,
});
}}
/>


</ControlsGroup>
</ControlsTab>
</ControlsSection>
</Fragment>
);
};

export default PostCommentsInspectorControls;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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', __( '<strong>Error</strong>: 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', __( '<strong>Error</strong>: Your background or experience is too long.' ), 200 );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down Expand Up @@ -111,6 +111,10 @@ public function __construct( $post = null, array $args = [] ) {
] );
}

public function getArgs() {
return $this->args;
}

/**
* Entry point to render the comments form.
*
Expand Down Expand Up @@ -550,18 +554,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( '
<p class="comment-form-background comment-fields-wrapper">
<label for="nb_commenter_background">%s%s</label>
<span class="field-description">%s</span>
<input id="nb_commenter_background" name="nb_commenter_background" type="text" value="%s" size="30" placeholder="%s" required="required" />
<input id="nb_commenter_background" name="nb_commenter_background" type="text" value="%s" size="30" placeholder="%s" %s />
</p>',
$args['commenterBackgroundLabel'],
( $args['commenterBackgroundRequired'] ? ' <span class="required">*</span>' : '' ),
$args['commenterBackgroundDescription'],
esc_attr( $previous_commenter_background ),
esc_attr( $args['commenterBackgroundPlaceholder'] )
esc_attr( $args['commenterBackgroundPlaceholder'] ),
( $args['commenterBackgroundRequired'] ? 'required="required"' : '')
);
}

Expand Down
10 changes: 8 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit eef1063

Please sign in to comment.