Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 includes/Rest/RenderBlockRestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function get_item( $request ) {
$this->setup_block_support_styles_capture();

/** This filter is documented in wp-includes/post-template.php */
$block_render = apply_filters( 'the_content', render_block( $shared_block_data ) );
$block_render = apply_filters( 'the_content', serialize_block( $shared_block_data ) );

// Get list of block types used while rendering the shared block.
$use_block_types = $this->capture_use_block_types();
Expand Down
35,916 changes: 18,357 additions & 17,559 deletions package-lock.json

Large diffs are not rendered by default.

31 changes: 15 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,23 @@
"license": "GPL-2.0-or-later",
"dependencies": {
"react-infinite-scroll-component": "^6.1.0",
"use-constant": "^1.1.0",
"uuid": "^8.3.2"
"use-constant": "^1.1.1",
"uuid": "^9.0.1"
},
"devDependencies": {
"@wordpress/block-editor": "^9.7.0",
"@wordpress/blocks": "^11.14.0",
"@wordpress/components": "^19.17.0",
"@wordpress/compose": "^5.13.0",
"@wordpress/core-data": "^4.13.0",
"@wordpress/data": "^6.15.0",
"@wordpress/element": "^4.13.0",
"@wordpress/env": "^5.2.0",
"@wordpress/hooks": "^3.15.0",
"@wordpress/i18n": "^4.15.0",
"@wordpress/primitives": "^3.16.0",
"@wordpress/scripts": "^23.7.2",
"@wordpress/wordcount": "^3.15.0",
"lodash": "^4.17.21"
"@wordpress/block-editor": "^12.14.0",
"@wordpress/blocks": "^12.23.0",
"@wordpress/components": "^25.12.0",
"@wordpress/compose": "^6.23.0",
"@wordpress/core-data": "^6.23.0",
"@wordpress/data": "^9.16.0",
"@wordpress/element": "^5.23.0",
"@wordpress/env": "^8.12.0",
"@wordpress/hooks": "^3.46.0",
"@wordpress/i18n": "^4.46.0",
"@wordpress/primitives": "^3.44.0",
"@wordpress/scripts": "^26.17.0",
"@wordpress/wordcount": "^3.46.0"
},
"volta": {
"node": "16.19.0"
Expand Down
12 changes: 4 additions & 8 deletions src/blocks/shared-block/edit.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { isEmpty } from 'lodash';

/**
* WordPress dependencies
*/
Expand All @@ -26,6 +21,7 @@ import './editor.scss';

export default function Edit( { attributes, setAttributes } ) {
const { blockId, blockTitle, display } = attributes;
const hasBlockId = blockId && blockId.length > 0 ? true : false;
Comment thread
petitphp marked this conversation as resolved.

const [ isEditing, setIsEditing ] = useState( false );

Expand Down Expand Up @@ -98,9 +94,9 @@ export default function Edit( { attributes, setAttributes } ) {
</ButtonGroup>
</PanelBody>
</InspectorControls>
{ isEmpty( blockId ) || isEditing ? (
{ ! hasBlockId || isEditing ? (
<div className={ 'shared-block-selector-wrapper' }>
{ false === isEmpty( blockId ) && (
{ hasBlockId && (
<div
className={
'shared-block-selector-wrapper__cancel'
Expand Down Expand Up @@ -142,9 +138,9 @@ export default function Edit( { attributes, setAttributes } ) {
<Placeholder
icon={ BlockIcon }
label={ __( 'Shared Block', 'multisite-shared-blocks' ) }
instructions={ getPlaceholderLabel( display ) }
className={ 'shared-block-placeholder' }
>
{ getPlaceholderLabel( display ) }
<Button
variant="primary"
onClick={ () => setIsEditing( true ) }
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/shared-block/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const MultisiteSharedBlockIcon = (
>
<Path
fill="#000"
fill-rule="evenodd"
fillRule="evenodd"
Comment thread
petitphp marked this conversation as resolved.
d="M14.247 0H9.753c-.715 0-1.327.647-1.327 1.402V4.8c0 .755.612 1.402 1.327 1.402h1.736v2.034c-1.599.242-2.857 1.601-3.04 3.306h-1.3v-1.295c0-.755-.613-1.402-1.328-1.402H1.328C.613 8.845 0 9.492 0 10.247v3.398c0 .755.613 1.402 1.328 1.402H5.82c.715 0 1.328-.647 1.328-1.402V12.62h1.329c.262 1.602 1.48 2.859 3.011 3.09v2.088H9.753c-.715 0-1.327.647-1.327 1.402v3.398c0 .755.612 1.402 1.327 1.402h4.494c.715 0 1.328-.647 1.328-1.402V19.2c0-.809-.613-1.402-1.328-1.402H12.51V15.71c1.53-.231 2.75-1.488 3.011-3.09h1.329v1.025c0 .755.613 1.402 1.328 1.402h4.493c.715 0 1.328-.647 1.328-1.402v-3.398c0-.755-.613-1.402-1.328-1.402H18.18c-.715 0-1.328.647-1.328 1.402v1.295h-1.3c-.183-1.705-1.441-3.064-3.04-3.306V6.202h1.736c.715 0 1.328-.647 1.328-1.402V1.402C15.575.593 14.962 0 14.247 0Zm.306 4.746c0 .162-.153.324-.306.324H9.753c-.153 0-.306-.162-.306-.324V1.402c0-.162.153-.323.306-.323h4.494c.153 0 .306.108.306.323v3.344ZM12 9.276c-1.41 0-2.553 1.208-2.553 2.697 0 1.49 1.143 2.697 2.553 2.697s2.553-1.208 2.553-2.697c0-1.49-1.143-2.697-2.553-2.697Zm10.979 4.369c0 .162-.153.324-.307.324H18.18c-.153 0-.307-.162-.307-.324v-3.398c0-.162.154-.323.307-.323h4.493c.154 0 .307.161.307.323v3.398Zm-17.158.324c.153 0 .307-.162.307-.324v-3.398c0-.162-.154-.323-.307-.323H1.328c-.154 0-.307.161-.307.323v3.398c0 .162.153.324.307.324H5.82Zm8.426 8.898c.153 0 .306-.161.306-.323v-3.398c0-.162-.153-.323-.306-.323H9.753c-.153 0-.306.161-.306.323v3.398c0 .162.153.323.306.323h4.494Z"
clip-rule="evenodd"
clipRule="evenodd"
Comment thread
petitphp marked this conversation as resolved.
/>
</SVG>
);
Expand Down
1 change: 1 addition & 0 deletions src/blocks/shared-block/sharedBlocksSelector.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* global multisiteSharedBlocksEditorData */
/* eslint-disable jsdoc/check-line-alignment */

/**
* External dependencies
Expand Down
20 changes: 11 additions & 9 deletions src/hooks/registerSharedBlockAttributes.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { assign, isEmpty } from 'lodash';

/**
* Internal dependencies
*/
Expand All @@ -21,13 +16,20 @@ import { blockSupportSharing, getBlockSharingAttributes } from './helper';
const registerSharedBlockAttributes = ( settings, name ) => {
const sharedBlockAttributes = getBlockSharingAttributes();

if ( ! blockSupportSharing( name ) || isEmpty( sharedBlockAttributes ) ) {
if (
Comment thread
petitphp marked this conversation as resolved.
! blockSupportSharing( name ) ||
Comment thread
petitphp marked this conversation as resolved.
Object.keys( sharedBlockAttributes ).length === 0
Comment thread
petitphp marked this conversation as resolved.
) {
Comment thread
petitphp marked this conversation as resolved.
return settings;
}

return assign( {}, settings, {
attributes: assign( {}, settings.attributes, sharedBlockAttributes ),
} );
return {
Comment thread
petitphp marked this conversation as resolved.
...settings,
Comment thread
petitphp marked this conversation as resolved.
attributes: {
...settings.attributes,
...sharedBlockAttributes,
},
Comment thread
petitphp marked this conversation as resolved.
};
Comment thread
petitphp marked this conversation as resolved.
};

export default registerSharedBlockAttributes;
29 changes: 13 additions & 16 deletions src/hooks/sharedBlockIdControls.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { isEmpty } from 'lodash';

/**
* WordPress dependencies
*/
Expand All @@ -27,6 +22,10 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
const { name, attributes, setAttributes } = props;
const { sharedBlockId, sharedBlockIsShared, sharedBlockShareTitle } =
attributes;
const hasShareTitle =
Comment thread
petitphp marked this conversation as resolved.
sharedBlockShareTitle && sharedBlockShareTitle.length > 0
? true
: false;

const getEmptySharedBlockTitle = () => {
return sprintf(
Expand All @@ -45,15 +44,11 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
};

const getTitleCharCount = ( title ) => {
if ( isEmpty( title ) ) {
return '0';
if ( title && title.length > 0 ) {
Comment thread
petitphp marked this conversation as resolved.
return count( title, 'characters_including_spaces', {} );
Comment thread
petitphp marked this conversation as resolved.
}

return count(
sharedBlockShareTitle,
'characters_including_spaces',
{}
);
return 0;
Comment thread
petitphp marked this conversation as resolved.
};

if ( ! blockSupportSharing( name ) ) {
Expand Down Expand Up @@ -94,9 +89,11 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
'Public title for the shared block (%d/200)',
'multisite-shared-blocks'
),
getTitleCharCount(
sharedBlockShareTitle
)
hasShareTitle
? getTitleCharCount(
sharedBlockShareTitle
)
: 0
) }
value={ sharedBlockShareTitle }
onChange={ ( value ) => setTitle( value ) }
Expand All @@ -105,7 +102,7 @@ const sharedBlockIdControls = createHigherOrderComponent( ( BlockEdit ) => {
'multisite-shared-blocks'
) }
/>
{ isEmpty( sharedBlockShareTitle ) && (
{ ! hasShareTitle && (
<p>
<small>
{ createInterpolateElement(
Expand Down