Skip to content

Commit

Permalink
Merge branch 'release/2.11.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
gregpriday committed Sep 29, 2020
2 parents 065d4b9 + 6ca3f1b commit 2fe61e6
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 24 deletions.
27 changes: 17 additions & 10 deletions compat/js/siteorigin-panels-layout-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ function (_Component) {
_this.state = {
editing: editMode,
loadingPreview: !editMode,
previewHtml: ''
previewHtml: '',
previewInitialized: !editMode
};
_this.panelsContainer = createRef();
_this.previewContainer = createRef();
_this.panelsInitialized = false;
_this.previewInitialized = false;
return _this;
}

Expand Down Expand Up @@ -117,14 +117,16 @@ function (_Component) {
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
// let propsChanged = !isEqual( prevProps.panelsData, this.props.panelsData );
if (this.state.editing && !this.panelsInitialized) {
this.setupPanels();
} else if (this.state.loadingPreview) {
this.fetchPreview(this.props);
} else if (!this.previewInitialized && this.previewContainer.current) {
this.fetchPreview = debounce(this.fetchPreview, 500);
} else if (!this.state.previewInitialized) {
jQuery(document).trigger('panels_setup_preview');
this.previewInitialized = true;
this.setState({
previewInitialized: true
});
}
}
}, {
Expand Down Expand Up @@ -199,11 +201,11 @@ function (_Component) {
});
jQuery(document).trigger('panels_setup', this.builderView);

if ( typeof window.soPanelsBuilderView == 'undefined' ) {
if (typeof window.soPanelsBuilderView == 'undefined') {
window.soPanelsBuilderView = [];
}
window.soPanelsBuilderView.push( this.builderView );

window.soPanelsBuilderView.push(this.builderView);
this.panelsInitialized = true;
}
}, {
Expand All @@ -215,7 +217,9 @@ function (_Component) {
return;
}

this.previewInitialized = false;
this.setState({
previewInitialized: false
});
var fetchRequest = this.currentFetchRequest = jQuery.post({
url: soPanelsBlockEditorAdmin.previewUrl,
data: {
Expand All @@ -226,7 +230,8 @@ function (_Component) {
if (_this3.isStillMounted && fetchRequest === _this3.currentFetchRequest && preview) {
_this3.setState({
previewHtml: preview,
loadingPreview: false
loadingPreview: false,
previewInitialized: false
});
}
});
Expand All @@ -250,7 +255,9 @@ function (_Component) {
var switchToPreview = function switchToPreview() {
if (panelsData) {
_this4.setState({
editing: false
editing: false,
loadingPreview: !_this4.state.previewHtml,
previewInitialized: false
});
}
};
Expand Down
28 changes: 18 additions & 10 deletions compat/js/siteorigin-panels-layout-block.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class SiteOriginPanelsLayoutBlock extends Component {
this.state = {
editing: editMode,
loadingPreview: ! editMode,
previewHtml: ''
previewHtml: '',
previewInitialized: ! editMode,
};
this.panelsContainer = createRef();
this.previewContainer = createRef();
this.panelsInitialized = false;
this.previewInitialized = false;
}

componentDidMount() {
Expand All @@ -39,14 +39,16 @@ class SiteOriginPanelsLayoutBlock extends Component {
}

componentDidUpdate( prevProps ) {
// let propsChanged = !isEqual( prevProps.panelsData, this.props.panelsData );
if ( this.state.editing && ! this.panelsInitialized ) {
this.setupPanels();
} else if ( this.state.loadingPreview ) {
this.fetchPreview( this.props );
} else if ( ! this.previewInitialized && this.previewContainer.current){
this.fetchPreview = debounce( this.fetchPreview, 500 );
} else if ( ! this.state.previewInitialized ) {
jQuery( document ).trigger( 'panels_setup_preview' );
this.previewInitialized = true;
this.setState( {
previewInitialized: true,
} );
}
}

Expand Down Expand Up @@ -121,8 +123,7 @@ class SiteOriginPanelsLayoutBlock extends Component {
if ( typeof window.soPanelsBuilderView == 'undefined' ) {
window.soPanelsBuilderView = [];
}
window.soPanelsBuilderView.push( this.builderView );
}
window.soPanelsBuilderView.push( this.builderView );

this.panelsInitialized = true;
}
Expand All @@ -131,8 +132,10 @@ class SiteOriginPanelsLayoutBlock extends Component {
if ( ! this.isStillMounted ) {
return;
}

this.previewInitialized = false;

this.setState( {
previewInitialized: false,
} );

const fetchRequest = this.currentFetchRequest = jQuery.post( {
url: soPanelsBlockEditorAdmin.previewUrl,
Expand All @@ -146,6 +149,7 @@ class SiteOriginPanelsLayoutBlock extends Component {
this.setState( {
previewHtml: preview,
loadingPreview: false,
previewInitialized: false,
} );
}
} );
Expand All @@ -162,7 +166,11 @@ class SiteOriginPanelsLayoutBlock extends Component {

let switchToPreview = () => {
if ( panelsData ) {
this.setState( { editing: false } );
this.setState({
editing: false,
loadingPreview: ! this.state.previewHtml,
previewInitialized: false,
});
}
}

Expand Down
6 changes: 4 additions & 2 deletions inc/widgets/post-loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ function update( $new, $old ){
*/
function widget( $args, $instance ) {
if( empty( $instance['template'] ) ) return;
if( is_admin() ) return;

// The Post Loop widget should only preview in WP Admin if it's Layout Block preview.
if ( is_admin() && ! ( isset( $_POST['action'] ) && $_POST['action'] == 'so_panels_layout_block_preview' ) ) {
return;
}
static $depth = 0;
$depth++;
if( $depth > 1 ) {
Expand Down
7 changes: 6 additions & 1 deletion js/seo-compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ jQuery(function($){
};

SiteOriginSeoCompat.prototype.contentModification = function( data ) {
if ( typeof window.soPanelsBuilderView !== 'undefined' ) {

var isBlockEditorPanelsEnabled = $( '.block-editor-page' ).length && typeof window.soPanelsBuilderView !== 'undefined';
var isClassicEditorPanelsEnabled = $( '#so-panels-panels.attached-to-editor' ).is( ':visible' );

// Check if the editor has Page Builder Enabled before proceeding.
if ( isClassicEditorPanelsEnabled || isBlockEditorPanelsEnabled ) {

var whitelist = [
'p', 'a', 'img', 'caption', 'br',
Expand Down
2 changes: 1 addition & 1 deletion js/siteorigin-panels/dialog/prebuilt.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ module.exports = panels.view.dialog.extend( {
var postName = $( 'input[name="post_title"], .editor-post-title__input' ).val();
if ( ! postName ) {
postName = $('input[name="post_ID"]').val();
} else if ( typeof wp.data != 'undefined' ) {
} else if ( $( '.block-editor-page' ).length ) {
var currentBlockPosition = thisView.getCurrentBlockPosition();
if ( currentBlockPosition >= 0 ) {
postName += '-' + currentBlockPosition;
Expand Down
7 changes: 7 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ We've tried to ensure that Page Builder is compatible with most plugin widgets.

== Changelog ==

= 2.11.4 - 28 September 2020 =
* Block Editor: Fixed SiteOrigin Widgets Bundle block preview.
* Yoast SEO: Fixed word count in the Classic Editor when Page Builder is not in use.
* Yoast SEO: Resolved a console error in the Block Editor.
* Block Editor: Enhanced the Layout Block to allow for Post Loop widget previews.
* Layout Export: Resolved JSON files exported without contents.

= 2.11.3 - 14 September 2020 =
* Block Editor: Added SEO support for multiple Layout Block instances.
* Yoast SEO Sitemap: Added images added using Page Builder.
Expand Down

0 comments on commit 2fe61e6

Please sign in to comment.