diff --git a/compat/js/siteorigin-panels-layout-block.js b/compat/js/siteorigin-panels-layout-block.js index bfed24f29..74b824d89 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, @@ -167,6 +198,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; } }, { @@ -222,7 +259,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 +271,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", @@ -252,15 +289,18 @@ 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'), + 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" }); }, - category: 'layout', + category: hasLayoutCategory ? 'layout' : 'design', keywords: ['page builder', 'column,grid', 'panel'], supports: { html: false @@ -364,4 +404,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 b98585892..934ed4add 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 { @@ -118,6 +117,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; } @@ -169,7 +174,7 @@ class SiteOriginPanelsLayoutBlock extends Component { @@ -190,7 +195,7 @@ class SiteOriginPanelsLayoutBlock extends Component { @@ -212,16 +217,20 @@ 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' ), + 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 ; }, - category: 'layout', + category: hasLayoutCategory ? 'layout' : 'design', keywords: [ 'page builder', 'column,grid', 'panel' ], @@ -330,3 +339,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/compat/yoast-sitemap.php b/compat/yoast-sitemap.php new file mode 100644 index 000000000..de7092972 --- /dev/null +++ b/compat/yoast-sitemap.php @@ -0,0 +1,40 @@ +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 ) ) { + $images[] = array( + 'src' => $src, + ); + } + } + } + + return $images; +} +add_filter( 'wpseo_sitemap_urlimages', 'siteorigin_yoast_sitemap_images_compat', 10, 2 ); diff --git a/inc/admin.php b/inc/admin.php index a348f1780..c4ab70b4c 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 ); @@ -1124,6 +1130,9 @@ function action_builder_content_json() { $GLOBALS[ 'SITEORIGIN_PANELS_PREVIEW_RENDER' ] = true; $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 ); 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..ff498034a 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; @@ -253,7 +254,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' ) ); @@ -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' ), diff --git a/inc/widgets/post-loop.php b/inc/widgets/post-loop.php index 7492d4b3e..0ded01126 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'] = 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 ); @@ -141,22 +142,32 @@ 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; + if ( apply_filters( 'siteorigin_panels_post_loop_custom_pagination', false ) ) { + 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 ]; + } + } } else { - self::$current_pagination_id = strstr( $instance['panels_info']['widget_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 { - $query_args['paged'] = 1; + 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; diff --git a/js/seo-compat.js b/js/seo-compat.js index 17f9d677b..b0734f8a1 100644 --- a/js/seo-compat.js +++ b/js/seo-compat.js @@ -16,20 +16,8 @@ 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(); + SiteOriginSeoCompat.prototype.contentModification = function( data ) { + if ( typeof window.soPanelsBuilderView !== 'undefined' ) { var whitelist = [ 'p', 'a', 'img', 'caption', 'br', @@ -39,18 +27,49 @@ 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 ) { + // Skip this for empty pages + return data; + } - $data.find("*").not(whitelist).each(function() { - var content = $(this).contents(); - $(this).replaceWith(content); - }); + // 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 { + var $this = this; + data = null; + window.soPanelsBuilderView.forEach( function( panel ) { + data += extractContent( panel.contentPreview ); + } ); + } } return data; }; - new SiteOriginSeoCompat(); + if ( typeof rankMathEditor !== 'undefined' ) { + new SiteOriginSeoCompat(); + } else { + $( window ).on( + 'YoastSEO:ready', + function () { + new SiteOriginSeoCompat(); + } + ); + } }); diff --git a/js/siteorigin-panels/dialog/prebuilt.js b/js/siteorigin-panels/dialog/prebuilt.js index 92e8cd1cb..d01ddc991 100644 --- a/js/siteorigin-panels/dialog/prebuilt.js +++ b/js/siteorigin-panels/dialog/prebuilt.js @@ -169,9 +169,15 @@ 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(); + } else if ( typeof wp.data != 'undefined' ) { + var currentBlockPosition = thisView.getCurrentBlockPosition(); + if ( currentBlockPosition >= 0 ) { + postName += '-' + 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. * 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 2c417a39b..c0a6f5b3f 100644 --- a/js/siteorigin-panels/view/builder.js +++ b/js/siteorigin-panels/view/builder.js @@ -731,8 +731,7 @@ 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 && ( 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 @@ -744,12 +743,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 ) ); } 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' }, 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 ); diff --git a/readme.txt b/readme.txt index f58a3f396..07dc8bfbc 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 @@ -96,6 +97,23 @@ We've tried to ensure that Page Builder is compatible with most plugin widgets. == Changelog == += 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. +* 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`. +* 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. 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 ); diff --git a/siteorigin-panels.php b/siteorigin-panels.php index 057342a8d..2c03d60e6 100644 --- a/siteorigin-panels.php +++ b/siteorigin-panels.php @@ -31,13 +31,13 @@ function __construct() { add_action( 'plugins_loaded', array( $this, 'init' ) ); add_action( 'plugins_loaded', array( $this, 'init_compat' ), 100 ); add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100 ); - + add_action('widgets_init', array( $this, 'widgets_init' ) ); add_filter( 'body_class', array( $this, 'body_class' ) ); add_filter( 'siteorigin_panels_data', array( $this, 'process_panels_data' ), 5 ); add_filter( 'siteorigin_panels_widget_class', array( $this, 'fix_namespace_escaping' ), 5 ); - + add_action( 'activated_plugin', array($this, 'activation_flag_redirect') ); add_action( 'admin_init', array($this, 'activation_do_redirect') ); @@ -58,7 +58,7 @@ function __construct() { if ( self::is_live_editor() ) { SiteOrigin_Panels_Live_Editor::single(); } - + SiteOrigin_Panels::renderer(); SiteOrigin_Panels_Styles_Admin::single(); @@ -67,22 +67,22 @@ function __construct() { } SiteOrigin_Panels_Widget_Shortcode::init(); - + // We need to generate fresh post content add_filter( 'the_content', array( $this, 'generate_post_content' ) ); add_filter( 'woocommerce_format_content', array( $this, 'generate_woocommerce_content' ) ); add_filter( 'wp_enqueue_scripts', array( $this, 'generate_post_css' ) ); - + // Remove the default excerpt function add_filter( 'get_the_excerpt', array( $this, 'generate_post_excerpt' ), 9 ); - + // Content cache has been removed. SiteOrigin_Panels_Cache_Renderer just deletes any existing caches. SiteOrigin_Panels_Cache_Renderer::single(); - + if ( function_exists( 'register_block_type' ) ) { SiteOrigin_Panels_Compat_Layout_Block::single(); } - + define( 'SITEORIGIN_PANELS_BASE_FILE', __FILE__ ); } @@ -91,7 +91,7 @@ public static function single() { static $single; return empty( $single ) ? $single = new self() : $single; } - + /** * Get an instance of the renderer * @@ -104,11 +104,11 @@ public static function renderer(){ case 'always': $renderer = SiteOrigin_Panels_Renderer_Legacy::single(); break; - + case 'never': $renderer = SiteOrigin_Panels_Renderer::single(); break; - + default : $renderer = self::is_legacy_browser() ? SiteOrigin_Panels_Renderer_Legacy::single() : @@ -116,14 +116,14 @@ public static function renderer(){ break; } } - + return $renderer; } - + public static function is_legacy_browser(){ $agent = ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; if( empty( $agent ) ) return false; - + return // IE lte 11 ( preg_match('/Trident\/(?P\d+)/i', $agent, $B) && $B['v'] <= 7 ) || @@ -156,7 +156,7 @@ public static function autoloader( $class ) { $filename = str_replace( array( 'SiteOrigin_Panels_', '_' ), array( '', '-' ), $class ); $filename = plugin_dir_path( __FILE__ ) . 'inc/' . strtolower( $filename ) . '.php'; } - + if ( ! empty( $filename ) && file_exists( $filename ) ) { include $filename; } @@ -202,6 +202,11 @@ public function init_compat() { 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'; + } + // Compatibility with AMP plugin if ( is_admin() && function_exists( 'amp_bootstrap_plugin' ) ) { require_once plugin_dir_path( __FILE__ ) . 'compat/amp.php'; @@ -285,7 +290,7 @@ public function get_home_page_data() { return $panels_data; } - + /** * Generate post content for WooCommerce shop page if it's using a PB layout. * @@ -299,7 +304,7 @@ public function generate_woocommerce_content( $content ) { if ( class_exists( 'WooCommerce' ) && is_shop() ) { return $this->generate_post_content( $content ); } - + return $content; } @@ -321,9 +326,9 @@ public function generate_post_content( $content ) { if ( ! apply_filters( 'siteorigin_panels_filter_content_enabled', true ) ) { return $content; } - + $post_id = $this->get_post_id(); - + // Check if this post has panels_data if ( get_post_meta( $post_id, 'panels_data', true ) ) { $panel_content = SiteOrigin_Panels::renderer()->render( @@ -357,7 +362,7 @@ public function generate_post_content( $content ) { return $content; } - + /** * Generate an excerpt for the current post, if possible. * @@ -370,9 +375,9 @@ public function generate_post_excerpt( $text ) { if ( ( empty( $post ) && ! in_the_loop() ) || $text !== '' ) { return $text; } - + $post_id = $this->get_post_id(); - + // Check if this post has panels_data $panels_data = get_post_meta( $post_id, 'panels_data', true ); if ( $panels_data && ! empty( $panels_data['widgets'] ) ) { @@ -396,19 +401,19 @@ public function generate_post_excerpt( $text ) { } } } - + $text = strip_shortcodes( $raw_excerpt ); $text = str_replace( ']]>', ']]>', $text ); - + $excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' ); $text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); } - + return $text; } - + private function get_localized_word_count( $text ) { - + // From the core `wp_trim_words` function to get localized word count. $text = wp_strip_all_tags( $text ); if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { @@ -418,29 +423,29 @@ private function get_localized_word_count( $text ) { } else { $words_array = preg_split( "/[\n\r\t ]+/", $text, -1, PREG_SPLIT_NO_EMPTY ); } - + return count( $words_array ); } - + /** * Generate CSS for the current post */ public function generate_post_css() { $post_id = $this->get_post_id(); - + if( is_singular() && get_post_meta( $post_id, 'panels_data', true ) ) { $renderer = SiteOrigin_Panels::renderer(); $renderer->add_inline_css( $post_id, $renderer->generate_css( $post_id ) ); } } - + /** * Get the post id for the current post. */ function get_post_id() { - + $post_id = get_the_ID(); - + if ( class_exists( 'WooCommerce' ) && is_shop() ) { $post_id = wc_get_page_id( 'shop' ); } @@ -452,7 +457,7 @@ function get_post_id() { $post_id = $preview_post->ID; } } - + return $post_id; } @@ -525,7 +530,7 @@ function admin_bar_menu( $admin_bar ) { return $admin_bar; } - + function widgets_init(){ register_widget( 'SiteOrigin_Panels_Widgets_PostContent' ); register_widget( 'SiteOrigin_Panels_Widgets_PostLoop' ); @@ -587,7 +592,7 @@ function process_panels_data( $panels_data ) { return $panels_data; } - + /** * Fix class names that have been incorrectly escaped * @@ -620,7 +625,7 @@ public function version_check(){ public function strip_before_js(){ ?>