Skip to content

Commit

Permalink
Merge branch 'release/2.31.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Misplon committed Dec 20, 2024
2 parents b42443b + 94d1b59 commit 6e2eb20
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 46 deletions.
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
== Changelog ==

= 2.31.3 – 20 December 2024 =
* WPML: Improved compatibility by excluding `panels_data` field from automatic translation handling.
* Prebuilt Layouts: Added text/html to accepted mime types for layout exports.
* Added compatibility with Popup Maker to ensure correct layout rendering in popups.
* Row Labels: Improved handling and display consistency.

= 2.31.2 – 14 December 2024 =
* Improved post type handling.
* Select2: Improved input alignment.
Expand Down
33 changes: 33 additions & 0 deletions compat/popup-maker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* SiteOrigin Page Builder compatibility with Popup Maker.
*
* Popup Maker uses a custom `the_content` filter `pum_popup_content`.
* This compatibility function ensures that the Page Builder content is
* displayed correctly within Popup Maker popups.
*
* @param string $content The original content of the popup.
* @param int $popup_id The ID of the popup.
*
* @return string The modified content, or the original content.
*/
function siteorigin_popup_maker( $content, $popup_id ) {

if ( empty( $popup_id ) || ! is_numeric( $popup_id ) ) {
return $content;
}

$panels_data = get_post_meta( (int) $popup_id, 'panels_data', true );
if ( empty( $panels_data ) ) {
return $content;
}

$panel_content = SiteOrigin_Panels::renderer()->render(
$popup_id,
true,
$panels_data
);

return $panel_content ? $panel_content : $content;
}
add_filter( 'pum_popup_content', 'siteorigin_popup_maker', 10, 2 );
55 changes: 38 additions & 17 deletions inc/admin-layouts.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
class SiteOrigin_Panels_Admin_Layouts {
const LAYOUT_URL = 'https://layouts.siteorigin.com/';

const VALID_MIME_TYPES = array(
'application/json',
'text/plain',
'text/html',
);

public function __construct() {
// Filter all the available external layout directories.
add_filter( 'siteorigin_panels_external_layout_directories', array( $this, 'filter_directories' ), 8 );
Expand Down Expand Up @@ -63,6 +69,29 @@ public function get_directories() {
return $directories;
}

/**
* Check if the file has a valid MIME type.
*
* This method checks if the given file has a valid MIME type. It first verifies
* if the `mime_content_type` function exists. If it doesn't, it returns true
* as it can't check the MIME type due to server settings.
* If the function exists, it retrieves the MIME type of the file and checks
* if it is in the list of valid MIME types.
*
* @param string $file The file path to check.
*
* @return bool True if the file has a valid MIME type, false otherwise.
*/
private static function check_file_mime( $file ) {
if ( ! function_exists( 'mime_content_type' ) ) {
// Can't check mime type due to server settings.
return true;
}

$mime_type = mime_content_type( $file );
return in_array( $mime_type, self::VALID_MIME_TYPES );
}

/**
* Determines if file has a JSON extension.
*
Expand Down Expand Up @@ -103,22 +132,11 @@ public function get_local_layouts() {
}

foreach ( $files as $file ) {
$valid_file_type = false;
if ( function_exists( 'mime_content_type' ) ) {
$mime_type = mime_content_type( $file );
$valid_file_type = strpos( $mime_type, '/json' ) !== false;

if ( ! $valid_file_type ) {
// It could have the wrong MIME type. Check for text/plain, and if it is, check the extension.
$valid_file_type = strpos( $mime_type, 'text/plain' ) !== false &&
self::check_file_ext( $file );
}
} else {
// Can't check MIME. Check extension.
$valid_file_type = self::check_file_ext( $file );
}

if ( ! $valid_file_type ) {
// Check the file.
if (
! self::check_file_mime( $file ) ||
! self::check_file_ext( $file )
) {
continue;
}

Expand Down Expand Up @@ -609,7 +627,10 @@ public function post_types() {
foreach ( $post_types as $id => $post_type ) {
$post_type_object = get_post_type_object( $post_type );

if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) {
if (
empty( $post_type_object ) ||
! current_user_can( $post_type_object->cap->edit_posts )
) {
unset( $post_types[ $id ] );
}
}
Expand Down
34 changes: 21 additions & 13 deletions inc/compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
* Compatibility class SiteOrigin Page Builder.
*/
class SiteOrigin_Panels_Compatibility {
private $compat_path;

public function __construct() {
$this->compat_path = plugin_dir_path( SITEORIGIN_PANELS_BASE_FILE ) . 'compat/';
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'plugins_loaded', array( $this, 'init' ), 100 );
add_action( 'init', array( $this, 'init' ), 100 );
}

public static function single() {
Expand All @@ -17,7 +20,7 @@ public static function single() {
public function admin_init() {
// SEO analysis compatibility.
if ( defined( 'WPSEO_FILE' ) || defined( 'RANK_MATH_VERSION' ) ) {
require_once plugin_dir_path( SITEORIGIN_PANELS_BASE_FILE ) . 'compat/seo.php';
require_once $this->compat_path . 'seo.php';
}

// Compatibility with ACF.
Expand All @@ -32,35 +35,35 @@ class_exists( 'ACF' ) &&
public function init() {
// Compatibility with Widget Options.
if ( class_exists( 'WP_Widget_Options' ) ) {
require_once plugin_dir_path( SITEORIGIN_PANELS_BASE_FILE ) . 'compat/widget-options.php';
require_once $this->compat_path . 'widget-options.php';
}

// Compatibility with Yoast plugins.
if (
defined( 'WPSEO_FILE' ) ||
function_exists( 'yoast_wpseo_video_seo_init' )
) {
require_once plugin_dir_path( SITEORIGIN_PANELS_BASE_FILE ) . 'compat/yoast.php';
require_once $this->compat_path . 'yoast.php';
}

// Compatibility with Rank Math.
if ( class_exists( 'RankMath' ) ) {
require_once plugin_dir_path( SITEORIGIN_PANELS_BASE_FILE ) . 'compat/rank-math.php';
require_once $this->compat_path . 'rank-math.php';
}

// Compatibility with AMP plugin.
if ( is_admin() && function_exists( 'amp_bootstrap_plugin' ) ) {
require_once plugin_dir_path( SITEORIGIN_PANELS_BASE_FILE ) . 'compat/amp.php';
require_once $this->compat_path . 'amp.php';
}

// Compatibility with Gravity Forms.
if ( class_exists( 'GFCommon' ) ) {
require_once plugin_dir_path( SITEORIGIN_PANELS_BASE_FILE ) . 'compat/gravity-forms.php';
require_once $this->compat_path . 'gravity-forms.php';
}

// Compatibility with Yikes Custom Product Tabs.
if ( class_exists( 'YIKES_Custom_Product_Tabs' ) ) {
require_once plugin_dir_path( SITEORIGIN_PANELS_BASE_FILE ) . 'compat/yikes.php';
require_once $this->compat_path . 'yikes.php';
}

// Compatibility with WP Rocket and WP Rocket LazyLoad.
Expand All @@ -75,22 +78,22 @@ function_exists( 'yoast_wpseo_video_seo_init' )
}

if ( apply_filters( 'siteorigin_lazyload_compat', $load_lazy_load_compat ) ) {
require_once plugin_dir_path( SITEORIGIN_PANELS_BASE_FILE ) . 'compat/lazy-load-backgrounds.php';
require_once $this->compat_path . 'lazy-load-backgrounds.php';
}

// Compatibility with Jetpack.
if ( class_exists( 'Jetpack' ) ) {
require_once plugin_dir_path( SITEORIGIN_PANELS_BASE_FILE ) . 'compat/jetpack.php';
require_once $this->compat_path . 'jetpack.php';
}

// Compatibility with Polylang.
if ( class_exists( 'Polylang' ) ) {
require_once plugin_dir_path( SITEORIGIN_PANELS_BASE_FILE ) . 'compat/polylang.php';
require_once $this->compat_path . 'polylang.php';
}

// Compatibility with SeoPress.
if ( defined( 'SEOPRESS_VERSION' ) ) {
require_once plugin_dir_path( SITEORIGIN_PANELS_BASE_FILE ) . 'compat/seopress.php';
require_once $this->compat_path . 'seopress.php';
}

// Compatibility with WP Event Manager.
Expand All @@ -100,12 +103,17 @@ function_exists( 'yoast_wpseo_video_seo_init' )

// Compatibility with Vantage.
if ( get_template() == 'vantage' ) {
require_once plugin_dir_path( SITEORIGIN_PANELS_BASE_FILE ) . 'compat/vantage.php';
require_once $this->compat_path . 'vantage.php';
}

// Compatibility with Pagelayer.
if ( defined( 'PAGELAYER_VERSION' ) ) {
SiteOrigin_Panels_Compat_Pagelayer::single();
}

// Compatibility with Popup Maker.
if ( class_exists( 'PUM_Site' )) {
require_once $this->compat_path . 'popup-maker.php';
}
}
}
6 changes: 6 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ SiteOrigin offers a single premium plugin that enhances and extends Page Builder

== Changelog ==

= 2.31.3 – 20 December 2024 =
* WPML: Improved compatibility by excluding `panels_data` field from automatic translation handling.
* Prebuilt Layouts: Added text/html to accepted mime types for layout exports.
* Added compatibility with Popup Maker to ensure correct layout rendering in popups.
* Row Labels: Improved handling and display consistency.

= 2.31.2 – 14 December 2024 =
* Improved post type handling.
* Select2: Improved input alignment.
Expand Down
19 changes: 3 additions & 16 deletions wpml-config.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<wpml-config>
<built-with-page-builder>/\[siteorigin_widget.*\]/</built-with-page-builder>
<admin-texts>
<key name="so_widget_settings[SiteOrigin_Widget_GoogleMap_Widget]">
<key name="map_consent_btn_text" />
<key name="map_consent_notice" />
</key>
</admin-texts>
<gutenberg-blocks>
<gutenberg-block type="siteorigin-panels/layout-block" translate="1">
<key name="panelsData">
Expand Down Expand Up @@ -308,11 +302,6 @@
<field type="Feature more URL" editor_type="LINK">more_url</field>
</fields-in-item>
</widget>
<widget name="SiteOrigin_Widget_GoogleMap_Widget">
<fields-in-item items_of="markers>marker_positions">
<field type="Map marker info" editor_type="VISUAL">info</field>
</fields-in-item>
</widget>
<widget name="SiteOrigin_Widget_Headline_Widget">
<fields>
<field type="Headline text">headline>text</field>
Expand Down Expand Up @@ -445,10 +434,8 @@
<field type="Feature hover text">hover</field>
</fields-in-item>
</widget>
<widget name="SiteOrigin_Widget_GoogleMap_Widget">
<fields-in-item items_of="markers>marker_positions">
<field type="Map marker info" editor_type="VISUAL">info</field>
</fields-in-item>
</widget>
</siteorigin-widgets>
<custom-fields>
<custom-field action="ignore">panels_data</custom-field>
</custom-fields>
</wpml-config>

0 comments on commit 6e2eb20

Please sign in to comment.