From b6bddf269ab3ccd704c8a66d4f5857764e0d1662 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Fri, 3 Jul 2020 04:08:24 +1000 Subject: [PATCH 01/40] Yoast Sitemap: List images added using Page Builder --- compat/yoast-sitemap.php | 38 ++++++++++++++++++++++++++++++++++++++ siteorigin-panels.php | 5 +++++ 2 files changed, 43 insertions(+) create mode 100644 compat/yoast-sitemap.php diff --git a/compat/yoast-sitemap.php b/compat/yoast-sitemap.php new file mode 100644 index 000000000..716223c2e --- /dev/null +++ b/compat/yoast-sitemap.php @@ -0,0 +1,38 @@ +render( + $post_id, + false + ); + + libxml_use_internal_errors( true ); + $dom = new DOMDocument(); + $dom->loadHTML( '' . $content ); + libxml_clear_errors(); + + foreach ( $dom->getElementsByTagName( 'img' ) as $img ) { + $src = $img->getAttribute( 'src' ); + + if ( empty( $src ) || $src !== esc_url( $src ) ) { + continue; + } + + $images[] = array( + 'src' => $src, + ); + } + } + + return $images; +} +add_filter( 'wpseo_sitemap_urlimages', 'siteorigin_yoast_sitemap_images_compat', 10, 2 ); diff --git a/siteorigin-panels.php b/siteorigin-panels.php index eaf689455..cae61051f 100644 --- a/siteorigin-panels.php +++ b/siteorigin-panels.php @@ -196,6 +196,11 @@ public function init() { if( class_exists('WP_Widget_Options') ) { require_once plugin_dir_path( __FILE__ ) . 'compat/widget-options.php'; } + + // Compatibility with Yoast Sitemap. + if ( defined( 'WPSEO_FILE' ) ) { + require_once plugin_dir_path( __FILE__ ) . 'compat/yoast-sitemap.php'; + } } /** From 982789722406ca9c3991e082167196f942ffdf64 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Fri, 3 Jul 2020 04:16:50 +1000 Subject: [PATCH 02/40] Flow adjustment Using continue here is, in hindsight, redundant. --- compat/yoast-sitemap.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/compat/yoast-sitemap.php b/compat/yoast-sitemap.php index 716223c2e..9e099ae04 100644 --- a/compat/yoast-sitemap.php +++ b/compat/yoast-sitemap.php @@ -23,13 +23,11 @@ function siteorigin_yoast_sitemap_images_compat( $images, $post_id ) { foreach ( $dom->getElementsByTagName( 'img' ) as $img ) { $src = $img->getAttribute( 'src' ); - if ( empty( $src ) || $src !== esc_url( $src ) ) { - continue; + if ( ! empty( $src ) && $src == esc_url( $src ) ) { + $images[] = array( + 'src' => $src, + ); } - - $images[] = array( - 'src' => $src, - ); } } From 65ddc74e5d42b199f7b0590c9aa1825f559e623c Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Sat, 18 Jul 2020 19:19:53 +1000 Subject: [PATCH 03/40] Layout Block: Update ContentPreview on contentchange --- js/siteorigin-panels/view/builder.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/js/siteorigin-panels/view/builder.js b/js/siteorigin-panels/view/builder.js index 2c417a39b..921421ce1 100644 --- a/js/siteorigin-panels/view/builder.js +++ b/js/siteorigin-panels/view/builder.js @@ -731,8 +731,15 @@ module.exports = Backbone.View.extend( { handleContentChange: function () { // Make sure we actually need to copy content. - if ( panelsOptions.copy_content && this.attachedToEditor && this.$el.is( ':visible' ) ) { - + if ( panelsOptions.copy_content && + ( + typeof wp.blocks !== 'undefined' || + ( + this.attachedToEditor && + this.$el.is( ':visible' ) + ) + ) + ) { var panelsData = this.model.getPanelsData(); if ( !_.isEmpty( panelsData.widgets ) ) { // We're going to create a copy of page builder content into the post content From 0bed3f87ed35f2273e628fa6aebd29f5bfeb4620 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Sat, 18 Jul 2020 19:21:00 +1000 Subject: [PATCH 04/40] Layout Block: Add SEO Support for multiple instances --- compat/js/siteorigin-panels-layout-block.js | 6 +++ compat/js/siteorigin-panels-layout-block.jsx | 6 +++ js/seo-compat.js | 46 ++++++++++++-------- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/compat/js/siteorigin-panels-layout-block.js b/compat/js/siteorigin-panels-layout-block.js index bfed24f29..252d9e9b9 100644 --- a/compat/js/siteorigin-panels-layout-block.js +++ b/compat/js/siteorigin-panels-layout-block.js @@ -167,6 +167,12 @@ function (_Component) { } }); jQuery(document).trigger('panels_setup', this.builderView); + + if ( typeof window.soPanelsBuilderView == 'undefined' ) { + window.soPanelsBuilderView = []; + } + window.soPanelsBuilderView.push( this.builderView ); + this.panelsInitialized = true; } }, { diff --git a/compat/js/siteorigin-panels-layout-block.jsx b/compat/js/siteorigin-panels-layout-block.jsx index b98585892..3d3caec7a 100644 --- a/compat/js/siteorigin-panels-layout-block.jsx +++ b/compat/js/siteorigin-panels-layout-block.jsx @@ -118,6 +118,12 @@ class SiteOriginPanelsLayoutBlock extends Component { } ); jQuery( document ).trigger( 'panels_setup', this.builderView ); + + if ( typeof window.soPanelsBuilderView == 'undefined' ) { + window.soPanelsBuilderView = []; + } + window.soPanelsBuilderView.push( this.builderView ); + } this.panelsInitialized = true; } diff --git a/js/seo-compat.js b/js/seo-compat.js index 17f9d677b..ea9fa06c1 100644 --- a/js/seo-compat.js +++ b/js/seo-compat.js @@ -17,19 +17,7 @@ jQuery(function($){ }; SiteOriginSeoCompat.prototype.contentModification = function(data) { - if( - typeof window.soPanelsBuilderView !== 'undefined' && - window.soPanelsBuilderView.contentPreview - ) { - var $data = $( window.soPanelsBuilderView.contentPreview ); - - if( $data.find('.so-panel.widget').length === 0 ) { - // Skip this for empty pages - return data; - } - - // Remove style tags created by Widgets Bundle - $data.find('style').remove(); + if ( typeof window.soPanelsBuilderView !== 'undefined' ) { var whitelist = [ 'p', 'a', 'img', 'caption', 'br', @@ -41,12 +29,34 @@ jQuery(function($){ 'table', 'tr', 'th', 'td' ].join(','); - $data.find("*").not(whitelist).each(function() { - var content = $(this).contents(); - $(this).replaceWith(content); - }); + var extractContent = function( data ) { + var $data = $( data ); + + if( $data.find('.so-panel.widget').length === 0 ) { + // Skip this for empty pages + return data; + } + + // Remove style tags created by Widgets Bundle + $data.find('style').remove(); - data = $data.html(); + $data.find("*").not(whitelist).each(function() { + var content = $(this).contents(); + $(this).replaceWith(content); + }); + + return $data.html(); + }; + + if ( ! Array.isArray( window.soPanelsBuilderView ) ) { + data = extractContent( window.soPanelsBuilderView.contentPreview ); + } else { + $this = this; + data = null; + window.soPanelsBuilderView.forEach(function(panel){ + data += extractContent( panel.contentPreview ); + }); + } } return data; From 27c9c5c1bf640b62affd7ef69d33ebdf19e43b0a Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Mon, 20 Jul 2020 02:03:27 +1000 Subject: [PATCH 05/40] Remove version from core JS files urls --- inc/admin.php | 2 +- inc/styles.php | 2 +- siteorigin-panels.php | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/inc/admin.php b/inc/admin.php index cf91c81b5..a348f1780 100644 --- a/inc/admin.php +++ b/inc/admin.php @@ -293,7 +293,7 @@ function enqueue_admin_scripts( $prefix = '', $force = false ) { wp_enqueue_media(); wp_enqueue_script( 'so-panels-admin', - siteorigin_panels_url( 'js/siteorigin-panels' . SITEORIGIN_PANELS_VERSION_SUFFIX . SITEORIGIN_PANELS_JS_SUFFIX . '.js' ), + siteorigin_panels_url( 'js/siteorigin-panels' . SITEORIGIN_PANELS_JS_SUFFIX . '.js' ), array( 'jquery', 'jquery-ui-resizable', diff --git a/inc/styles.php b/inc/styles.php index 2a55575a5..7ce4805e6 100644 --- a/inc/styles.php +++ b/inc/styles.php @@ -50,7 +50,7 @@ public static function single() { static function register_scripts() { wp_register_script( 'siteorigin-panels-front-styles', - siteorigin_panels_url( 'js/styling' . SITEORIGIN_PANELS_VERSION_SUFFIX . SITEORIGIN_PANELS_JS_SUFFIX . '.js' ), + siteorigin_panels_url( 'js/styling' . SITEORIGIN_PANELS_JS_SUFFIX . '.js' ), array( 'jquery' ), SITEORIGIN_PANELS_VERSION ); diff --git a/siteorigin-panels.php b/siteorigin-panels.php index fcf7df6d1..057342a8d 100644 --- a/siteorigin-panels.php +++ b/siteorigin-panels.php @@ -16,7 +16,6 @@ define( 'SITEORIGIN_PANELS_JS_SUFFIX', '' ); } define( 'SITEORIGIN_PANELS_CSS_SUFFIX', '' ); -define( 'SITEORIGIN_PANELS_VERSION_SUFFIX', '' ); require_once plugin_dir_path( __FILE__ ) . 'inc/functions.php'; From ef0ac156e4816209efa65aa08397765c281dcec5 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Mon, 20 Jul 2020 02:03:51 +1000 Subject: [PATCH 06/40] Revert "Remove version from core JS files urls" This reverts commit 27c9c5c1bf640b62affd7ef69d33ebdf19e43b0a. --- inc/admin.php | 2 +- inc/styles.php | 2 +- siteorigin-panels.php | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/inc/admin.php b/inc/admin.php index a348f1780..cf91c81b5 100644 --- a/inc/admin.php +++ b/inc/admin.php @@ -293,7 +293,7 @@ function enqueue_admin_scripts( $prefix = '', $force = false ) { wp_enqueue_media(); wp_enqueue_script( 'so-panels-admin', - siteorigin_panels_url( 'js/siteorigin-panels' . SITEORIGIN_PANELS_JS_SUFFIX . '.js' ), + siteorigin_panels_url( 'js/siteorigin-panels' . SITEORIGIN_PANELS_VERSION_SUFFIX . SITEORIGIN_PANELS_JS_SUFFIX . '.js' ), array( 'jquery', 'jquery-ui-resizable', diff --git a/inc/styles.php b/inc/styles.php index 7ce4805e6..2a55575a5 100644 --- a/inc/styles.php +++ b/inc/styles.php @@ -50,7 +50,7 @@ public static function single() { static function register_scripts() { wp_register_script( 'siteorigin-panels-front-styles', - siteorigin_panels_url( 'js/styling' . SITEORIGIN_PANELS_JS_SUFFIX . '.js' ), + siteorigin_panels_url( 'js/styling' . SITEORIGIN_PANELS_VERSION_SUFFIX . SITEORIGIN_PANELS_JS_SUFFIX . '.js' ), array( 'jquery' ), SITEORIGIN_PANELS_VERSION ); diff --git a/siteorigin-panels.php b/siteorigin-panels.php index 057342a8d..fcf7df6d1 100644 --- a/siteorigin-panels.php +++ b/siteorigin-panels.php @@ -16,6 +16,7 @@ define( 'SITEORIGIN_PANELS_JS_SUFFIX', '' ); } define( 'SITEORIGIN_PANELS_CSS_SUFFIX', '' ); +define( 'SITEORIGIN_PANELS_VERSION_SUFFIX', '' ); require_once plugin_dir_path( __FILE__ ) . 'inc/functions.php'; From 7de50e4340a2d1fad1291c0bfe4a23815e16c8c0 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Mon, 20 Jul 2020 02:05:33 +1000 Subject: [PATCH 07/40] Remove version from core JS files urls --- inc/admin.php | 2 +- inc/styles.php | 2 +- siteorigin-panels.php | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/inc/admin.php b/inc/admin.php index cf91c81b5..a348f1780 100644 --- a/inc/admin.php +++ b/inc/admin.php @@ -293,7 +293,7 @@ function enqueue_admin_scripts( $prefix = '', $force = false ) { wp_enqueue_media(); wp_enqueue_script( 'so-panels-admin', - siteorigin_panels_url( 'js/siteorigin-panels' . SITEORIGIN_PANELS_VERSION_SUFFIX . SITEORIGIN_PANELS_JS_SUFFIX . '.js' ), + siteorigin_panels_url( 'js/siteorigin-panels' . SITEORIGIN_PANELS_JS_SUFFIX . '.js' ), array( 'jquery', 'jquery-ui-resizable', diff --git a/inc/styles.php b/inc/styles.php index 2a55575a5..7ce4805e6 100644 --- a/inc/styles.php +++ b/inc/styles.php @@ -50,7 +50,7 @@ public static function single() { static function register_scripts() { wp_register_script( 'siteorigin-panels-front-styles', - siteorigin_panels_url( 'js/styling' . SITEORIGIN_PANELS_VERSION_SUFFIX . SITEORIGIN_PANELS_JS_SUFFIX . '.js' ), + siteorigin_panels_url( 'js/styling' . SITEORIGIN_PANELS_JS_SUFFIX . '.js' ), array( 'jquery' ), SITEORIGIN_PANELS_VERSION ); diff --git a/siteorigin-panels.php b/siteorigin-panels.php index fcf7df6d1..057342a8d 100644 --- a/siteorigin-panels.php +++ b/siteorigin-panels.php @@ -16,7 +16,6 @@ define( 'SITEORIGIN_PANELS_JS_SUFFIX', '' ); } define( 'SITEORIGIN_PANELS_CSS_SUFFIX', '' ); -define( 'SITEORIGIN_PANELS_VERSION_SUFFIX', '' ); require_once plugin_dir_path( __FILE__ ) . 'inc/functions.php'; From 8e6332e8134f322dd8a13878632ddd028ddb6c48 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Mon, 20 Jul 2020 02:26:08 +1000 Subject: [PATCH 08/40] Yoast Sitemap: Check if XML is enabled before processing --- compat/yoast-sitemap.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compat/yoast-sitemap.php b/compat/yoast-sitemap.php index 9e099ae04..de7092972 100644 --- a/compat/yoast-sitemap.php +++ b/compat/yoast-sitemap.php @@ -9,7 +9,11 @@ * @return array */ function siteorigin_yoast_sitemap_images_compat( $images, $post_id ) { - if ( get_post_meta( $post_id, 'panels_data', true ) && class_exists( 'DOMDocument' ) ) { + if ( + get_post_meta( $post_id, 'panels_data', true ) && + extension_loaded( 'xml' ) && + class_exists( 'DOMDocument' ) + ) { $content = SiteOrigin_Panels::renderer()->render( $post_id, false From 6dbc2f9e5f1812ec5937ca096053e171adc69ac8 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Tue, 21 Jul 2020 06:46:39 +1000 Subject: [PATCH 09/40] Prevent Potential Confirm Notice --- js/siteorigin-panels/view/builder.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/siteorigin-panels/view/builder.js b/js/siteorigin-panels/view/builder.js index 2c417a39b..a461f7db6 100644 --- a/js/siteorigin-panels/view/builder.js +++ b/js/siteorigin-panels/view/builder.js @@ -744,12 +744,14 @@ module.exports = Backbone.View.extend( { post_id: this.config.postId }, function ( content ) { + // Post content doesn't need to be generated on load while contentPreview does. + if ( this.contentPreview && content.post_content !== '' ) { + this.updateEditorContent( content.post_content ); + } + if ( content.preview !== '' ) { this.contentPreview = content.preview; } - if ( content.post_content !== '' ) { - this.updateEditorContent( content.post_content ); - } }.bind( this ) ); } From 12ffa8ea124218d7567a9a80955e64be272997e1 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Wed, 22 Jul 2020 01:39:08 +1000 Subject: [PATCH 10/40] Improve formatting --- js/seo-compat.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/js/seo-compat.js b/js/seo-compat.js index ea9fa06c1..e9855c353 100644 --- a/js/seo-compat.js +++ b/js/seo-compat.js @@ -16,7 +16,7 @@ jQuery(function($){ }; - SiteOriginSeoCompat.prototype.contentModification = function(data) { + SiteOriginSeoCompat.prototype.contentModification = function( data ) { if ( typeof window.soPanelsBuilderView !== 'undefined' ) { var whitelist = [ @@ -27,23 +27,23 @@ jQuery(function($){ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'li', 'table', 'tr', 'th', 'td' - ].join(','); + ].join( ',' ); var extractContent = function( data ) { var $data = $( data ); - if( $data.find('.so-panel.widget').length === 0 ) { + if( $data.find( '.so-panel.widget' ).length === 0 ) { // Skip this for empty pages return data; } // Remove style tags created by Widgets Bundle - $data.find('style').remove(); + $data.find( 'style' ).remove(); - $data.find("*").not(whitelist).each(function() { - var content = $(this).contents(); - $(this).replaceWith(content); - }); + $data.find( "*") .not( whitelist ).each( function() { + var content = $( this ).contents(); + $( this ).replaceWith( content ); + } ); return $data.html(); }; @@ -51,11 +51,11 @@ jQuery(function($){ if ( ! Array.isArray( window.soPanelsBuilderView ) ) { data = extractContent( window.soPanelsBuilderView.contentPreview ); } else { - $this = this; + var $this = this; data = null; - window.soPanelsBuilderView.forEach(function(panel){ + window.soPanelsBuilderView.forEach( function( panel ) { data += extractContent( panel.contentPreview ); - }); + } ); } } From b16748fb19c95c0f643fbeb7c667c62b41ff762f Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Tue, 21 Jul 2020 22:12:38 +0200 Subject: [PATCH 11/40] Updated Build submodule --- build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build b/build index f28c76a5b..11a38dbf4 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit f28c76a5b76caa8c933b4eb95ccb56659a0fd19d +Subproject commit 11a38dbf40e42a571970e610b1b9db3d8784dcef From 2123df3c96297c642506434f4e064d9284ed0535 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Thu, 23 Jul 2020 01:35:53 +1000 Subject: [PATCH 12/40] Post Loop: Resolve notice when used outside of Page Builer Resolve: Notice: Undefined index: panels_info --- inc/widgets/post-loop.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/widgets/post-loop.php b/inc/widgets/post-loop.php index 7492d4b3e..e2f062d6d 100644 --- a/inc/widgets/post-loop.php +++ b/inc/widgets/post-loop.php @@ -150,7 +150,7 @@ function widget( $args, $instance ) { if(!empty($matches[1])) $query_args['paged'] = intval($matches[1]); else $query_args['paged'] = 1; } else { - self::$current_pagination_id = strstr( $instance['panels_info']['widget_id'], '-', true ); + self::$current_pagination_id = strstr( $instance['_sow_form_id'], '-', true ); if ( isset( $_GET[ 'page-' . self::$current_pagination_id ] ) && is_numeric( $_GET[ 'page-' . self::$current_pagination_id ] ) ) { $query_args['paged'] = $_GET[ 'page-' . self::$current_pagination_id ]; } else { From d59e8e33f9fafdfd26b75b1f70178322fcba778d Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Fri, 24 Jul 2020 22:08:51 +1000 Subject: [PATCH 13/40] Android Chrome: Improve edit widget touch detection --- js/siteorigin-panels/view/widget.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/siteorigin-panels/view/widget.js b/js/siteorigin-panels/view/widget.js index 51c4def82..3d50263ad 100644 --- a/js/siteorigin-panels/view/widget.js +++ b/js/siteorigin-panels/view/widget.js @@ -11,7 +11,9 @@ module.exports = Backbone.View.extend( { events: { 'click .widget-edit': 'editHandler', + 'touchend .widget-edit': 'editHandler', 'click .title h4': 'editHandler', + 'touchend .title h4': 'editHandler', 'click .actions .widget-duplicate': 'duplicateHandler', 'click .actions .widget-delete': 'deleteHandler' }, From 11fb94d3ad7486ec910e5dd9cb73434070e817ae Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Tue, 28 Jul 2020 02:06:41 +1000 Subject: [PATCH 14/40] Yoast : Resolve 14.6 Integration Issue --- inc/admin.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/inc/admin.php b/inc/admin.php index cf91c81b5..b3a4b6c56 100644 --- a/inc/admin.php +++ b/inc/admin.php @@ -528,11 +528,17 @@ function enqueue_admin_scripts( $prefix = '', $force = false ) { public function enqueue_seo_compat(){ if ( self::is_admin() ) { - if ( defined( 'WPSEO_FILE' ) && wp_script_is( 'yoast-seo-metabox' ) ) { + if ( + defined( 'WPSEO_FILE' ) && + ( + wp_script_is( 'yoast-seo-admin-global-script' ) || // => 14.6 + wp_script_is( 'yoast-seo-metabox' ) // <= 14.5 + ) + ) { wp_enqueue_script( 'so-panels-seo-compat', siteorigin_panels_url( 'js/seo-compat' . SITEORIGIN_PANELS_JS_SUFFIX . '.js' ), - array('jquery', 'yoast-seo-metabox' ), + array( 'jquery' ), SITEORIGIN_PANELS_VERSION, true ); From afe3bfb71e2be109f27eb6f50cd90de474047663 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Tue, 28 Jul 2020 06:23:37 +1000 Subject: [PATCH 15/40] Post Loop: Limit Length of pagination id --- inc/widgets/post-loop.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/widgets/post-loop.php b/inc/widgets/post-loop.php index e2f062d6d..8f749b785 100644 --- a/inc/widgets/post-loop.php +++ b/inc/widgets/post-loop.php @@ -150,7 +150,7 @@ function widget( $args, $instance ) { if(!empty($matches[1])) $query_args['paged'] = intval($matches[1]); else $query_args['paged'] = 1; } else { - self::$current_pagination_id = strstr( $instance['_sow_form_id'], '-', true ); + self::$current_pagination_id = substr( $instance['_sow_form_id'], 0, 7 ); if ( isset( $_GET[ 'page-' . self::$current_pagination_id ] ) && is_numeric( $_GET[ 'page-' . self::$current_pagination_id ] ) ) { $query_args['paged'] = $_GET[ 'page-' . self::$current_pagination_id ]; } else { From 0771528745a48b37c55aec19d94ee52e07d8e8a0 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Fri, 31 Jul 2020 16:13:44 +1000 Subject: [PATCH 16/40] Post Loop: Generate unique id for custom pagination --- inc/widgets/post-loop.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/inc/widgets/post-loop.php b/inc/widgets/post-loop.php index 8f749b785..292303a7c 100644 --- a/inc/widgets/post-loop.php +++ b/inc/widgets/post-loop.php @@ -75,6 +75,7 @@ static function get_current_pagination_id() { * @return array */ function update( $new, $old ){ + $new['pagination_id'] = md5( json_encode( $new ) ); if( class_exists( 'SiteOrigin_Widget' ) && class_exists( 'SiteOrigin_Widget_Field_Posts' ) ) { $helper = $this->get_helper_widget( $this->get_loop_templates() ); return $helper->update( $new, $old ); @@ -150,10 +151,18 @@ function widget( $args, $instance ) { if(!empty($matches[1])) $query_args['paged'] = intval($matches[1]); else $query_args['paged'] = 1; } else { - self::$current_pagination_id = substr( $instance['_sow_form_id'], 0, 7 ); - if ( isset( $_GET[ 'page-' . self::$current_pagination_id ] ) && is_numeric( $_GET[ 'page-' . self::$current_pagination_id ] ) ) { - $query_args['paged'] = $_GET[ 'page-' . self::$current_pagination_id ]; - } else { + if ( isset( $instance['pagination_id'] ) ) { + self::$current_pagination_id = $instance['pagination_id']; + + if ( + isset( $_GET[ 'page-' . self::$current_pagination_id ] ) && + is_numeric( $_GET[ 'page-' . self::$current_pagination_id ] ) + ) { + $query_args['paged'] = $_GET[ 'page-' . self::$current_pagination_id ]; + } + } + + if ( ! isset( $query_args['paged'] ) ) { $query_args['paged'] = 1; } } From c334b6d253cd7eb6d23b695048a16b23fcc2bb6a Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Fri, 31 Jul 2020 16:20:21 +1000 Subject: [PATCH 17/40] Post Loop Pagination:: Generate random number md5, in hindsight, isn't a good idea. --- inc/widgets/post-loop.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/widgets/post-loop.php b/inc/widgets/post-loop.php index 292303a7c..ec0f82a0f 100644 --- a/inc/widgets/post-loop.php +++ b/inc/widgets/post-loop.php @@ -75,7 +75,7 @@ static function get_current_pagination_id() { * @return array */ function update( $new, $old ){ - $new['pagination_id'] = md5( json_encode( $new ) ); + $new['pagination_id'] = rand(); if( class_exists( 'SiteOrigin_Widget' ) && class_exists( 'SiteOrigin_Widget_Field_Posts' ) ) { $helper = $this->get_helper_widget( $this->get_loop_templates() ); return $helper->update( $new, $old ); From 8cfecd18c58e5f3770d0607489188d8cd02473cd Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Fri, 31 Jul 2020 22:02:46 +1000 Subject: [PATCH 18/40] Layout Block: Use new Block Categories if WP 5.5 Uses suggested compatibility code. Tested using 5.5-RC1-48698 and 5.4.2. Please note that formatting is differnet in .js due to spaces being stripped by `build:dev`. --- compat/js/siteorigin-panels-layout-block.js | 5 ++++- compat/js/siteorigin-panels-layout-block.jsx | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/compat/js/siteorigin-panels-layout-block.js b/compat/js/siteorigin-panels-layout-block.js index bfed24f29..9f606e8d1 100644 --- a/compat/js/siteorigin-panels-layout-block.js +++ b/compat/js/siteorigin-panels-layout-block.js @@ -252,6 +252,9 @@ function (_Component) { return SiteOriginPanelsLayoutBlock; }(Component); +var hasLayoutCategory = wp.blocks.getCategories().some(function (category) { + return category.slug === 'layout'; +}); registerBlockType('siteorigin-panels/layout-block', { title: __('SiteOrigin Layout', 'siteorigin-panels'), description: __("Build a layout using SiteOrigin's Page Builder.", 'siteorigin-panels'), @@ -260,7 +263,7 @@ registerBlockType('siteorigin-panels/layout-block', { className: "siteorigin-panels-block-icon" }); }, - category: 'layout', + category: hasLayoutCategory ? 'layout' : 'design', keywords: ['page builder', 'column,grid', 'panel'], supports: { html: false diff --git a/compat/js/siteorigin-panels-layout-block.jsx b/compat/js/siteorigin-panels-layout-block.jsx index b98585892..1142d66e1 100644 --- a/compat/js/siteorigin-panels-layout-block.jsx +++ b/compat/js/siteorigin-panels-layout-block.jsx @@ -212,6 +212,10 @@ class SiteOriginPanelsLayoutBlock extends Component { } } +var hasLayoutCategory = wp.blocks.getCategories().some( function( category ) { + return category.slug === 'layout'; +} ); + registerBlockType( 'siteorigin-panels/layout-block', { title: __( 'SiteOrigin Layout', 'siteorigin-panels' ), @@ -221,7 +225,7 @@ registerBlockType( 'siteorigin-panels/layout-block', { return ; }, - category: 'layout', + category: hasLayoutCategory ? 'layout' : 'design', keywords: [ 'page builder', 'column,grid', 'panel' ], From a7ce188a8cbd044ea05e337eb21912e86e9d5d26 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Sun, 2 Aug 2020 05:32:05 +1000 Subject: [PATCH 19/40] Run wp_targeted_link_rel on the generated preview content This commit prevents an issue where the SO Layout Block may break due to saved data being different. --- inc/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/admin.php b/inc/admin.php index b3a4b6c56..8f3d9b785 100644 --- a/inc/admin.php +++ b/inc/admin.php @@ -1129,7 +1129,7 @@ function action_builder_content_json() { unset( $GLOBALS[ 'SITEORIGIN_PANELS_POST_CONTENT_RENDER' ] ); $GLOBALS[ 'SITEORIGIN_PANELS_PREVIEW_RENDER' ] = true; - $return['preview'] = SiteOrigin_Panels::renderer()->render( intval( $_POST['post_id'] ), false, $panels_data ); + $return['preview'] = wp_targeted_link_rel( SiteOrigin_Panels::renderer()->render( intval( $_POST['post_id'] ), false, $panels_data ) ); unset( $GLOBALS[ 'SITEORIGIN_PANELS_PREVIEW_RENDER' ] ); echo json_encode( $return ); From beefdc0c92cc267bb73eae820dbf9101ce16c8c1 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Tue, 4 Aug 2020 06:25:24 +1000 Subject: [PATCH 20/40] Check if wp_targeted_link_rel exists before usage --- inc/admin.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/inc/admin.php b/inc/admin.php index 8f3d9b785..76fa03cf5 100644 --- a/inc/admin.php +++ b/inc/admin.php @@ -1129,7 +1129,10 @@ function action_builder_content_json() { unset( $GLOBALS[ 'SITEORIGIN_PANELS_POST_CONTENT_RENDER' ] ); $GLOBALS[ 'SITEORIGIN_PANELS_PREVIEW_RENDER' ] = true; - $return['preview'] = wp_targeted_link_rel( SiteOrigin_Panels::renderer()->render( intval( $_POST['post_id'] ), false, $panels_data ) ); + $return['preview'] = SiteOrigin_Panels::renderer()->render( intval( $_POST['post_id'] ), false, $panels_data ); + if ( function_exists( 'wp_targeted_link_rel' ) ) { + $return['preview'] = wp_targeted_link_rel( $return['preview'] ); + } unset( $GLOBALS[ 'SITEORIGIN_PANELS_PREVIEW_RENDER' ] ); echo json_encode( $return ); From 9309b58fd2ba28528a02c5a8a8a81b141b1245c2 Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Tue, 4 Aug 2020 14:26:57 +0200 Subject: [PATCH 21/40] Added PHP required tag --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index 79d9c0ca2..c45b50b32 100644 --- a/readme.txt +++ b/readme.txt @@ -2,6 +2,7 @@ Tags: page builder, responsive, widget, widgets, builder, page, admin, gallery, content, cms, pages, post, css, layout, grid Requires at least: 4.7 Tested up to: 5.5 +Requires PHP: 5.6.20 Stable tag: trunk Build time: unbuilt License: GPLv3 From 043cda0a70ec513ce5655420f1bf098630825a0b Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Wed, 5 Aug 2020 02:39:18 +1000 Subject: [PATCH 22/40] Post Loop: Add siteorigin_panels_post_loop_custom_pagination --- inc/widgets/post-loop.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/inc/widgets/post-loop.php b/inc/widgets/post-loop.php index ec0f82a0f..0ded01126 100644 --- a/inc/widgets/post-loop.php +++ b/inc/widgets/post-loop.php @@ -142,15 +142,7 @@ function widget( $args, $instance ) { if( $wp_rewrite->using_permalinks() ) { - if( get_query_var('paged') ) { - // When the widget appears on a sub page. - $query_args['paged'] = get_query_var('paged'); - } else if ( strpos( $_SERVER['REQUEST_URI'], '/page/' ) !== false ) { - // When the widget appears on the home page. - preg_match('/\/page\/([0-9]+)\//', $_SERVER['REQUEST_URI'], $matches); - if(!empty($matches[1])) $query_args['paged'] = intval($matches[1]); - else $query_args['paged'] = 1; - } else { + if ( apply_filters( 'siteorigin_panels_post_loop_custom_pagination', false ) ) { if ( isset( $instance['pagination_id'] ) ) { self::$current_pagination_id = $instance['pagination_id']; @@ -161,11 +153,21 @@ function widget( $args, $instance ) { $query_args['paged'] = $_GET[ 'page-' . self::$current_pagination_id ]; } } - - if ( ! isset( $query_args['paged'] ) ) { - $query_args['paged'] = 1; + } else { + if ( get_query_var( 'paged' ) ) { + // When the widget appears on a sub page. + $query_args['paged'] = get_query_var('paged'); + } else if ( strpos( $_SERVER['REQUEST_URI'], '/page/' ) !== false ) { + // When the widget appears on the home page. + preg_match('/\/page\/([0-9]+)\//', $_SERVER['REQUEST_URI'], $matches); + if(!empty($matches[1])) $query_args['paged'] = intval($matches[1]); + else $query_args['paged'] = 1; } } + + if ( ! isset( $query_args['paged'] ) ) { + $query_args['paged'] = 1; + } } else { // Get current page number when we're not using permalinks $query_args['paged'] = isset($_GET['paged']) ? intval($_GET['paged']) : 1; From dd22c93ecdfb2eeb34a8c3e8bff3e0d2363a0ec4 Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Tue, 4 Aug 2020 19:34:40 +0200 Subject: [PATCH 23/40] Updated Build submodule --- build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build b/build index f28c76a5b..92d2a38bf 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit f28c76a5b76caa8c933b4eb95ccb56659a0fd19d +Subproject commit 92d2a38bfcaef5e0022d2a3fffb627f00646bb30 From 7cc3aaa1c3625ef7b13bcdd6e02413f263a91b53 Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Tue, 4 Aug 2020 19:38:15 +0200 Subject: [PATCH 24/40] Updated Build submodule --- build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build b/build index 11a38dbf4..92d2a38bf 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 11a38dbf40e42a571970e610b1b9db3d8784dcef +Subproject commit 92d2a38bfcaef5e0022d2a3fffb627f00646bb30 From 4917d556abc11454824fc4e861daec2935fde0b1 Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Tue, 4 Aug 2020 22:16:52 +0200 Subject: [PATCH 25/40] Updated Build submodule --- build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build b/build index 92d2a38bf..c88d71d74 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 92d2a38bfcaef5e0022d2a3fffb627f00646bb30 +Subproject commit c88d71d74d84e26c48efbda43d409ebdbe87b444 From 64daf484fb1731e7db892794b0219b2833237461 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Wed, 5 Aug 2020 23:38:18 +1000 Subject: [PATCH 26/40] Layout Export: Fix post title detection in Block Editor --- js/siteorigin-panels/dialog/prebuilt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/siteorigin-panels/dialog/prebuilt.js b/js/siteorigin-panels/dialog/prebuilt.js index 92e8cd1cb..a42eca5c3 100644 --- a/js/siteorigin-panels/dialog/prebuilt.js +++ b/js/siteorigin-panels/dialog/prebuilt.js @@ -169,7 +169,7 @@ module.exports = panels.view.dialog.extend( { c.find( '.so-export' ).submit( function ( e ) { var $$ = $( this ); var panelsData = thisView.builder.model.getPanelsData(); - var postName = $('input[name="post_title"]').val(); + var postName = $( 'input[name="post_title"], .editor-post-title__input' ).val(); if ( ! postName ) { postName = $('input[name="post_ID"]').val(); } From 300d9c62374a299e2b4c02a8b843fb7a1089dbc9 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Wed, 5 Aug 2020 23:38:38 +1000 Subject: [PATCH 27/40] Revert "Layout Export: Fix post title detection in Block Editor" This reverts commit 64daf484fb1731e7db892794b0219b2833237461. --- js/siteorigin-panels/dialog/prebuilt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/siteorigin-panels/dialog/prebuilt.js b/js/siteorigin-panels/dialog/prebuilt.js index a42eca5c3..92e8cd1cb 100644 --- a/js/siteorigin-panels/dialog/prebuilt.js +++ b/js/siteorigin-panels/dialog/prebuilt.js @@ -169,7 +169,7 @@ module.exports = panels.view.dialog.extend( { c.find( '.so-export' ).submit( function ( e ) { var $$ = $( this ); var panelsData = thisView.builder.model.getPanelsData(); - var postName = $( 'input[name="post_title"], .editor-post-title__input' ).val(); + var postName = $('input[name="post_title"]').val(); if ( ! postName ) { postName = $('input[name="post_ID"]').val(); } From 09bd1ed7b62d2764757d2e8ed3f2ebf900afc2d7 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Wed, 5 Aug 2020 23:40:01 +1000 Subject: [PATCH 28/40] Layout Export: Fix post title detection in Block Editor --- js/siteorigin-panels/dialog/prebuilt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/siteorigin-panels/dialog/prebuilt.js b/js/siteorigin-panels/dialog/prebuilt.js index 92e8cd1cb..a42eca5c3 100644 --- a/js/siteorigin-panels/dialog/prebuilt.js +++ b/js/siteorigin-panels/dialog/prebuilt.js @@ -169,7 +169,7 @@ module.exports = panels.view.dialog.extend( { c.find( '.so-export' ).submit( function ( e ) { var $$ = $( this ); var panelsData = thisView.builder.model.getPanelsData(); - var postName = $('input[name="post_title"]').val(); + var postName = $( 'input[name="post_title"], .editor-post-title__input' ).val(); if ( ! postName ) { postName = $('input[name="post_ID"]').val(); } From 2d86b813e49b43169df5f9180ccff7a74531a389 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Thu, 6 Aug 2020 03:45:45 +1000 Subject: [PATCH 29/40] Block Editor: Add Preview Support for Layout Block --- compat/js/siteorigin-panels-layout-block.js | 9 ++++++++- compat/js/siteorigin-panels-layout-block.jsx | 7 +++++++ compat/layout-block.php | 7 +++++++ js/styling.js | 10 +++++----- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/compat/js/siteorigin-panels-layout-block.js b/compat/js/siteorigin-panels-layout-block.js index 9f606e8d1..2ced2b744 100644 --- a/compat/js/siteorigin-panels-layout-block.js +++ b/compat/js/siteorigin-panels-layout-block.js @@ -367,4 +367,11 @@ registerBlockType('siteorigin-panels/layout-block', { }, 100); }); } -})(jQuery); \ No newline at end of file +})(jQuery); + +// Detect preview mode changes, and trigger resize. +jQuery(document).on('click', '.block-editor-post-preview__button-resize', function (e) { + if (!jQuery(this).hasClass('has-icon')) { + jQuery(window).trigger('resize'); + } +}); diff --git a/compat/js/siteorigin-panels-layout-block.jsx b/compat/js/siteorigin-panels-layout-block.jsx index 1142d66e1..45700d98d 100644 --- a/compat/js/siteorigin-panels-layout-block.jsx +++ b/compat/js/siteorigin-panels-layout-block.jsx @@ -334,3 +334,10 @@ registerBlockType( 'siteorigin-panels/layout-block', { } } )( jQuery ); + +// Detect preview mode changes, and trigger resize. +jQuery( document ).on( 'click', '.block-editor-post-preview__button-resize', function( e ) { + if ( ! jQuery( this ).hasClass('has-icon') ) { + jQuery( window ).trigger( 'resize' ); + } +} ); diff --git a/compat/layout-block.php b/compat/layout-block.php index 8c622219e..d5e3b89c7 100644 --- a/compat/layout-block.php +++ b/compat/layout-block.php @@ -20,6 +20,9 @@ public function __construct() { // This action is slightly later than `enqueue_block_editor_assets`, // which we need to use to ensure our templates are loaded at the right time. add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_layout_block_editor_assets' ) ); + + // We need to override the container when using the Block Editor to allow for resizing. + add_filter( 'siteorigin_panels_full_width_container', array( $this, 'override_container' ) ); } public function register_layout_block() { @@ -113,4 +116,8 @@ private function sanitize_panels_data( $panels_data ) { $panels_data = SiteOrigin_Panels_Styles_Admin::single()->sanitize_all( $panels_data ); return $panels_data; } + + function override_container( $container ) { + return SiteOrigin_Panels_Admin::is_block_editor() ? '.editor-styles-wrapper' : $container; + } } diff --git a/js/styling.js b/js/styling.js index 8d3e09d7f..e47bbd76b 100644 --- a/js/styling.js +++ b/js/styling.js @@ -2,13 +2,13 @@ jQuery( function ( $ ) { - var fullContainer = $( panelsStyles.fullContainer ); - if ( fullContainer.length === 0 ) { - fullContainer = $( 'body' ); - } - // Stretch all the full width rows var stretchFullWidthRows = function () { + var fullContainer = $( panelsStyles.fullContainer ); + if ( fullContainer.length === 0 ) { + fullContainer = $( 'body' ); + } + var $panelsRow = $( '.siteorigin-panels-stretch.panel-row-style' ); $panelsRow.each( function () { var $$ = $( this ); From 1eabdf70ef595df2c4be704d0054d4ceea48a981 Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Thu, 6 Aug 2020 13:31:35 +0200 Subject: [PATCH 30/40] Updated the Build submodule --- build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build b/build index 92d2a38bf..c88d71d74 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 92d2a38bfcaef5e0022d2a3fffb627f00646bb30 +Subproject commit c88d71d74d84e26c48efbda43d409ebdbe87b444 From 9ec0997c9c959977a2ca035788029722cc5137be Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Mon, 10 Aug 2020 06:30:05 +1000 Subject: [PATCH 31/40] Include Block Index in Layout Export --- js/siteorigin-panels/dialog/prebuilt.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/siteorigin-panels/dialog/prebuilt.js b/js/siteorigin-panels/dialog/prebuilt.js index a42eca5c3..93d278461 100644 --- a/js/siteorigin-panels/dialog/prebuilt.js +++ b/js/siteorigin-panels/dialog/prebuilt.js @@ -172,6 +172,12 @@ 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' ) { + var currentBlockPosition = thisView.getCurrentBlockPosition(); + if ( currentBlockPosition >= 0 ) { + postName += '-block-editor-' + currentBlockPosition; + } + } panelsData.name = postName; $$.find( 'input[name="panels_export_data"]' ).val( JSON.stringify( panelsData ) ); @@ -179,6 +185,16 @@ module.exports = panels.view.dialog.extend( { }, + /** + * Return current block index. + */ + getCurrentBlockPosition: function() { + var selectedBlockClientId = wp.data.select( 'core/block-editor' ).getSelectedBlockClientId(); + return wp.data.select( 'core/block-editor' ).getBlocks().findIndex( function ( block ) { + return block.clientId === selectedBlockClientId; + } ); + }, + /** * Display the layout directory tab. * From 5c72453cc89d6b12f49bcbe670528702a175f038 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Wed, 12 Aug 2020 02:37:50 +1000 Subject: [PATCH 32/40] Layout Export: Don't add "block-editor" to Block export filename --- js/siteorigin-panels/dialog/prebuilt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/siteorigin-panels/dialog/prebuilt.js b/js/siteorigin-panels/dialog/prebuilt.js index 93d278461..d01ddc991 100644 --- a/js/siteorigin-panels/dialog/prebuilt.js +++ b/js/siteorigin-panels/dialog/prebuilt.js @@ -175,7 +175,7 @@ module.exports = panels.view.dialog.extend( { } else if ( typeof wp.data != 'undefined' ) { var currentBlockPosition = thisView.getCurrentBlockPosition(); if ( currentBlockPosition >= 0 ) { - postName += '-block-editor-' + currentBlockPosition; + postName += '-' + currentBlockPosition; } } From ceb038e975829fb52353e158f6ca470b2168d376 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Tue, 18 Aug 2020 11:36:30 +1000 Subject: [PATCH 33/40] Avoid potential JS variable conflict with translation __ is far too common to rely on. --- compat/js/siteorigin-panels-layout-block.js | 51 ++++++++++++++++---- compat/js/siteorigin-panels-layout-block.jsx | 9 ++-- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/compat/js/siteorigin-panels-layout-block.js b/compat/js/siteorigin-panels-layout-block.js index 2ced2b744..67d2cf8fb 100644 --- a/compat/js/siteorigin-panels-layout-block.js +++ b/compat/js/siteorigin-panels-layout-block.js @@ -8,16 +8,46 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { + function isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } + } + + return function () { + var Super = _getPrototypeOf(Derived), + result; + + if (isNativeReflectConstruct()) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; +} + function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } - -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } - var _lodash = lodash, isEqual = _lodash.isEqual, debounce = _lodash.debounce, @@ -34,7 +64,6 @@ var _wp$components = wp.components, Toolbar = _wp$components.Toolbar, IconButton = _wp$components.IconButton, Spinner = _wp$components.Spinner; -var __ = wp.i18n.__; var _window = window, soPanelsBlockEditorAdmin = _window.soPanelsBlockEditorAdmin; @@ -43,12 +72,14 @@ var SiteOriginPanelsLayoutBlock = function (_Component) { _inherits(SiteOriginPanelsLayoutBlock, _Component); + var _super = _createSuper(SiteOriginPanelsLayoutBlock); + function SiteOriginPanelsLayoutBlock(props) { var _this; _classCallCheck(this, SiteOriginPanelsLayoutBlock); - _this = _possibleConstructorReturn(this, _getPrototypeOf(SiteOriginPanelsLayoutBlock).call(this, props)); + _this = _super.call(this, props); var editMode = soPanelsBlockEditorAdmin.defaultMode === 'edit' || isEmpty(props.panelsData); _this.state = { editing: editMode, @@ -222,7 +253,7 @@ function (_Component) { return React.createElement(Fragment, null, React.createElement(BlockControls, null, React.createElement(Toolbar, null, React.createElement(IconButton, { icon: "visibility", className: "components-icon-button components-toolbar__control", - label: __('Preview layout.', 'siteorigin-panels'), + label: wp.i18n.__('Preview layout.', 'siteorigin-panels'), onClick: switchToPreview }))), React.createElement("div", { key: "layout-block", @@ -234,7 +265,7 @@ function (_Component) { return React.createElement(Fragment, null, React.createElement(BlockControls, null, React.createElement(Toolbar, null, React.createElement(IconButton, { icon: "edit", className: "components-icon-button components-toolbar__control", - label: __('Edit layout.', 'siteorigin-panels'), + label: wp.i18n.__('Edit layout.', 'siteorigin-panels'), onClick: switchToEditing }))), React.createElement("div", { key: "preview", @@ -256,8 +287,8 @@ var hasLayoutCategory = wp.blocks.getCategories().some(function (category) { return category.slug === 'layout'; }); registerBlockType('siteorigin-panels/layout-block', { - title: __('SiteOrigin Layout', 'siteorigin-panels'), - description: __("Build a layout using SiteOrigin's Page Builder.", 'siteorigin-panels'), + title: wp.i18n.__('SiteOrigin Layout', 'siteorigin-panels'), + description: wp.i18n.__("Build a layout using SiteOrigin's Page Builder.", 'siteorigin-panels'), icon: function icon() { return React.createElement("span", { className: "siteorigin-panels-block-icon" diff --git a/compat/js/siteorigin-panels-layout-block.jsx b/compat/js/siteorigin-panels-layout-block.jsx index 45700d98d..8705f741a 100644 --- a/compat/js/siteorigin-panels-layout-block.jsx +++ b/compat/js/siteorigin-panels-layout-block.jsx @@ -3,7 +3,6 @@ const { registerBlockType } = wp.blocks; const { Component, Fragment, RawHTML, createRef } = wp.element; const { BlockControls } = wp.editor; const { Toolbar, IconButton, Spinner } = wp.components; -const { __ } = wp.i18n; const { soPanelsBlockEditorAdmin } = window; class SiteOriginPanelsLayoutBlock extends Component { @@ -169,7 +168,7 @@ class SiteOriginPanelsLayoutBlock extends Component { @@ -190,7 +189,7 @@ class SiteOriginPanelsLayoutBlock extends Component { @@ -217,9 +216,9 @@ var hasLayoutCategory = wp.blocks.getCategories().some( function( category ) { } ); registerBlockType( 'siteorigin-panels/layout-block', { - title: __( 'SiteOrigin Layout', 'siteorigin-panels' ), + title: wp.i18n.__( 'SiteOrigin Layout', 'siteorigin-panels' ), - description: __( "Build a layout using SiteOrigin's Page Builder.", 'siteorigin-panels' ), + description: wp.i18n.__( "Build a layout using SiteOrigin's Page Builder.", 'siteorigin-panels' ), icon () { return ; From 6e3cd8bb7780c59f6fc994a8fdd397e441f47a4f Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Mon, 24 Aug 2020 07:14:58 +1000 Subject: [PATCH 34/40] Builder: Detect Editor type using panels.helpers.editor This commit adds `panels.helpers.editor` which has `isBlockEditor` and `isClassicEditor`. --- js/siteorigin-panels/helpers/editor.js | 9 +++++++++ js/siteorigin-panels/main.js | 1 + js/siteorigin-panels/view/builder.js | 10 +--------- 3 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 js/siteorigin-panels/helpers/editor.js diff --git a/js/siteorigin-panels/helpers/editor.js b/js/siteorigin-panels/helpers/editor.js new file mode 100644 index 000000000..004b7d233 --- /dev/null +++ b/js/siteorigin-panels/helpers/editor.js @@ -0,0 +1,9 @@ +module.exports = { + isBlockEditor: function() { + return typeof wp.blocks !== 'undefined'; + }, + + isClassicEditor: function( builder ) { + return builder.attachedToEditor && builder.$el.is( ':visible' ); + }, +} diff --git a/js/siteorigin-panels/main.js b/js/siteorigin-panels/main.js index 8040fd295..83b0784fa 100644 --- a/js/siteorigin-panels/main.js +++ b/js/siteorigin-panels/main.js @@ -17,6 +17,7 @@ window.siteoriginPanels = panels; panels.helpers = {}; panels.helpers.clipboard = require( './helpers/clipboard' ); panels.helpers.utils = require( './helpers/utils' ); +panels.helpers.editor = require( './helpers/editor' ); panels.helpers.serialize = require( './helpers/serialize' ); panels.helpers.pageScroll = require( './helpers/page-scroll' ); diff --git a/js/siteorigin-panels/view/builder.js b/js/siteorigin-panels/view/builder.js index 921421ce1..2eeb23828 100644 --- a/js/siteorigin-panels/view/builder.js +++ b/js/siteorigin-panels/view/builder.js @@ -731,15 +731,7 @@ module.exports = Backbone.View.extend( { handleContentChange: function () { // Make sure we actually need to copy content. - if ( panelsOptions.copy_content && - ( - typeof wp.blocks !== 'undefined' || - ( - this.attachedToEditor && - this.$el.is( ':visible' ) - ) - ) - ) { + if ( panelsOptions.copy_content && ( panels.helpers.editor.isBlockEditor() || panels.helpers.editor.isClassicEditor( this ) ) ) { var panelsData = this.model.getPanelsData(); if ( !_.isEmpty( panelsData.widgets ) ) { // We're going to create a copy of page builder content into the post content From 58315a6ddf28606aad26e69c7a90c886efb4fa08 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Mon, 24 Aug 2020 07:40:11 +1000 Subject: [PATCH 35/40] Add Global Setting "Row Mobile Bottom Margin" --- inc/renderer.php | 2 +- inc/settings.php | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/inc/renderer.php b/inc/renderer.php index ea01a9238..e4ad56dc1 100644 --- a/inc/renderer.php +++ b/inc/renderer.php @@ -73,7 +73,7 @@ public function generate_css( $post_id, $panels_data = false, $layout_data = fal // Filter the bottom margin for this row with the arguments $panels_margin_bottom = apply_filters( 'siteorigin_panels_css_row_margin_bottom', $settings['margin-bottom'] . 'px', $row, $ri, $panels_data, $post_id ); - $panels_mobile_margin_bottom = apply_filters( 'siteorigin_panels_css_row_mobile_margin_bottom', '', $row, $ri, $panels_data, $post_id ); + $panels_mobile_margin_bottom = apply_filters( 'siteorigin_panels_css_row_mobile_margin_bottom', $settings['row-mobile-margin-bottom'] . 'px', $row, $ri, $panels_data, $post_id ); if ( empty( $row['cells'] ) ) { continue; diff --git a/inc/settings.php b/inc/settings.php index 310e302c6..6fe99fec7 100644 --- a/inc/settings.php +++ b/inc/settings.php @@ -134,15 +134,16 @@ function settings_defaults( $defaults ) { $defaults['instant-open-widgets'] = false; // The layout fields - $defaults['responsive'] = true; - $defaults['tablet-layout'] = false; - $defaults['legacy-layout'] = 'auto'; - $defaults['tablet-width'] = 1024; - $defaults['mobile-width'] = 780; - $defaults['margin-bottom'] = 30; - $defaults['margin-bottom-last-row'] = false; - $defaults['margin-sides'] = 30; - $defaults['full-width-container'] = 'body'; + $defaults['responsive'] = true; + $defaults['tablet-layout'] = false; + $defaults['legacy-layout'] = 'auto'; + $defaults['tablet-width'] = 1024; + $defaults['mobile-width'] = 780; + $defaults['margin-bottom'] = 30; + $defaults['row-mobile-margin-bottom'] = ''; + $defaults['margin-bottom-last-row'] = false; + $defaults['margin-sides'] = 30; + $defaults['full-width-container'] = 'body'; // Content fields $defaults['copy-content'] = true; @@ -417,6 +418,13 @@ function settings_fields( $fields ) { 'description' => __( 'Default margin below rows and widgets.', 'siteorigin-panels' ), ); + $fields['layout']['fields']['row-mobile-margin-bottom'] = array( + 'type' => 'number', + 'unit' => 'px', + 'label' => __( 'Row Mobile Bottom Margin', 'siteorigin-panels' ), + 'description' => __( 'The default margin below rows on mobile.', 'siteorigin-panels' ), + ); + $fields['layout']['fields']['margin-bottom-last-row'] = array( 'type' => 'checkbox', 'label' => __( 'Last Row With Margin', 'siteorigin-panels' ), From 2e01cdade1dcb95067b9018fb2a9ca2201c12035 Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Thu, 3 Sep 2020 21:28:10 +0200 Subject: [PATCH 36/40] Switch to title case for the CE setting label MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The rest of the settings section is using title case. We’re matching the case of this label to the others. --- inc/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/settings.php b/inc/settings.php index 310e302c6..fb862b881 100644 --- a/inc/settings.php +++ b/inc/settings.php @@ -253,7 +253,7 @@ function settings_fields( $fields ) { $fields['general']['fields']['use-classic'] = array( 'type' => 'checkbox', - 'label' => __( 'Use Classic Editor for new posts', 'siteorigin-panels' ), + 'label' => __( 'Use Classic Editor for New Posts', 'siteorigin-panels' ), 'description' => __( 'New posts of the above Post Types will be created using the Classic Editor.', 'siteorigin-panels' ) ); From f4fe66a66fed49495aa636c0917e44cdd81fcf6b Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Mon, 7 Sep 2020 21:26:53 +0200 Subject: [PATCH 37/40] Updated changelog --- readme.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/readme.txt b/readme.txt index 3bb2d7214..99604162e 100644 --- a/readme.txt +++ b/readme.txt @@ -97,6 +97,21 @@ We've tried to ensure that Page Builder is compatible with most plugin widgets. == Changelog == += 2.11.3 - 10 September 2020 = +* Block Editor: Added SEO support for multiple Layout Block instances. +* Yoast SEO Sitemap: Added images added using Page Builder. +* Prevented potential `Are you sure you want to navigate away?` notice. +* Post Loop: Resolved `Undefined index` notice when used outside of Page Builder. +* Android Chrome: Improved edit widget touch detection. +* Yoast SEO: Resolved version `14.6` integration issue. +* Block Editor: Used new categories for the Layout Block for WP 5.5+. +* Block Editor: Resolved potential Layout Block data validation issue by running `wp_targeted_link_rel` on the generated preview content. +* Block Editor: Added preview support for the Layout Block. +* Block Editor: Updated translation functions to avoid potential conflicts. +* Block Editor: Added the page name and block number to Layout Block JSON export files. +* Block Editor: Improved SEO plugin support. +* Added a global `Row Mobile Bottom Margin` setting at `Settings > Page Builder > Layout`. + = 2.11.2 - 12 August 2020 = * Updated build scripts. From 28b20016b942ccb2f229b5406a704945fca54ab5 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Tue, 8 Sep 2020 06:18:57 +1000 Subject: [PATCH 38/40] Prevent jQuery migrate notice on settings page --- settings/admin-settings.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/settings/admin-settings.js b/settings/admin-settings.js index 7595f1b28..8beeb78e9 100644 --- a/settings/admin-settings.js +++ b/settings/admin-settings.js @@ -16,8 +16,7 @@ jQuery( function($){ .animate({'margin-top' : 0, 'opacity': opacity}, 280 + 40*(4 - v) ); }, 150 + 225 * (4 - v) ); }); - }) - .each(function() { if(this.complete) { $(this).load(); } }); + }); // Settings page tabbing @@ -224,4 +223,4 @@ jQuery( function($){ $.fn.fitVids._count = 0; // Works with either jQuery or Zepto -})( window.jQuery || window.Zepto ); \ No newline at end of file +})( window.jQuery || window.Zepto ); From 753cd6b93b3d23f4f2d2d33a8982f0b2909ad041 Mon Sep 17 00:00:00 2001 From: Alex S <17275120+AlexGStapleton@users.noreply.github.com> Date: Wed, 9 Sep 2020 18:45:17 +1000 Subject: [PATCH 39/40] Yoast SEO Compat: Wait until Yoast is ready --- js/seo-compat.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/seo-compat.js b/js/seo-compat.js index e9855c353..b0734f8a1 100644 --- a/js/seo-compat.js +++ b/js/seo-compat.js @@ -62,5 +62,14 @@ jQuery(function($){ return data; }; - new SiteOriginSeoCompat(); + if ( typeof rankMathEditor !== 'undefined' ) { + new SiteOriginSeoCompat(); + } else { + $( window ).on( + 'YoastSEO:ready', + function () { + new SiteOriginSeoCompat(); + } + ); + } }); From 788c0d264f4865d1f72dc5304716f9551b97de52 Mon Sep 17 00:00:00 2001 From: Andrew Misplon Date: Mon, 14 Sep 2020 11:29:06 +0200 Subject: [PATCH 40/40] Updated changelog to reflect latest commits --- readme.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 99604162e..07dc8bfbc 100644 --- a/readme.txt +++ b/readme.txt @@ -97,7 +97,7 @@ We've tried to ensure that Page Builder is compatible with most plugin widgets. == Changelog == -= 2.11.3 - 10 September 2020 = += 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. * Prevented potential `Are you sure you want to navigate away?` notice. @@ -111,6 +111,8 @@ We've tried to ensure that Page Builder is compatible with most plugin widgets. * Block Editor: Added the page name and block number to Layout Block JSON export files. * Block Editor: Improved SEO plugin support. * Added a global `Row Mobile Bottom Margin` setting at `Settings > Page Builder > Layout`. +* Ensured Yoast SEO is ready before running compatibility functionality. +* Global Settings: Resolved a jQuery Migrate Helper warning. = 2.11.2 - 12 August 2020 = * Updated build scripts.