Skip to content

Commit

Permalink
Merge branch 'release/2.31.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Misplon committed Dec 14, 2024
2 parents 7a2e707 + 0a86e88 commit b42443b
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 8 deletions.
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
== Changelog ==

= 2.31.2 – 14 December 2024 =
* Improved post type handling.
* Select2: Improved input alignment.

= 2.31.1 – 11 December 2024 =
* Layouts Block: Prevented double toolbar when in development mode.
* Improved row, cell, and widget attribute handling.
Expand Down
23 changes: 22 additions & 1 deletion css/admin.less
Original file line number Diff line number Diff line change
Expand Up @@ -2538,8 +2538,29 @@
.select2-container {
width: 100% !important;

.select2-container .select2-selection__choice__remove {
.select2-selection--multiple {
align-items: center;
display: flex;
padding: 0;
}

.select2-selection__rendered {
margin: 0;
padding: 0;
}

.select2-search__field {
margin-top: 0;
}

.select2-selection__choice__remove {
height: 100%;

span {
display: inline-block;
margin-top: 8px;
transform: translateY(-50%);
}
}
}
}
Expand Down
43 changes: 41 additions & 2 deletions inc/admin-layouts.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,22 @@ public function action_get_prebuilt_layouts() {
}
}
} elseif ( strpos( $type, 'clone_' ) !== false ) {
// Check that the user can view the given page types
$post_type = get_post_type_object( str_replace( 'clone_', '', $type ) );
$post_type = str_replace( 'clone_', '', $type );
$post_types_editable_by_user = SiteOrigin_Panels_Admin_Layouts::single()->post_types();

// Can the user edit posts from this post type?
if (
empty( $post_type ) ||
empty( $post_types_editable_by_user ) ||
! in_array(
$post_type,
$post_types_editable_by_user
)
) {
return;
}

$post_type = get_post_type_object( $post_type );
if ( empty( $post_type ) ) {
return;
}
Expand Down Expand Up @@ -577,4 +590,30 @@ public function load_layout( $id, $name, $json_file, $screenshot = false ) {

return $layout_data;
}

/**
* Get the post types that the current user can edit.
*
* This function retrieves the post types specified in the
* SiteOrigin Panels settings. It then filters out post types that the
* current user does not have permission to edit.
*
* @return array The post types that the current user can edit.
*/
public function post_types() {
$post_types = siteorigin_panels_setting( 'post-types' );
if ( empty( $post_types ) ) {
return array();
}

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 ) ) {
unset( $post_types[ $id ] );
}
}

return $post_types;
}
}
5 changes: 1 addition & 4 deletions inc/styles-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,7 @@ class="image-fallback widefat" />
<option
value="<?php echo esc_attr( $k ); ?>"
<?php echo isset( $values[ $k ] ) ? 'selected' : ''; ?>
>
<?php echo esc_html( $v ); ?>
</option>

><?php echo esc_html( $v ); ?></option>
<?php } ?>
</select>
<?php
Expand Down
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ SiteOrigin offers a single premium plugin that enhances and extends Page Builder

== Changelog ==

= 2.31.2 – 14 December 2024 =
* Improved post type handling.
* Select2: Improved input alignment.

= 2.31.1 – 11 December 2024 =
* Layouts Block: Prevented double toolbar when in development mode.
* Improved row, cell, and widget attribute handling.
Expand Down
2 changes: 1 addition & 1 deletion tpl/js-templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class="button-secondary dashicons so-mode"
}
$tabs['import'] = __( 'Import/Export', 'siteorigin-panels' );

$post_types = siteorigin_panels_setting( 'post-types' );
$post_types = SiteOrigin_Panels_Admin_Layouts::single()->post_types();
foreach( $post_types as $post_type ) {
$type = get_post_type_object( $post_type );
if ( empty( $type ) ) {
Expand Down

0 comments on commit b42443b

Please sign in to comment.