diff --git a/changelog.txt b/changelog.txt index d091a9da..915dec35 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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. diff --git a/css/admin.less b/css/admin.less index 93594bf1..70d697e9 100644 --- a/css/admin.less +++ b/css/admin.less @@ -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%); + } } } } diff --git a/inc/admin-layouts.php b/inc/admin-layouts.php index 07203991..8eaeee34 100644 --- a/inc/admin-layouts.php +++ b/inc/admin-layouts.php @@ -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; } @@ -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; + } } diff --git a/inc/styles-admin.php b/inc/styles-admin.php index d613bdfc..564c7b09 100644 --- a/inc/styles-admin.php +++ b/inc/styles-admin.php @@ -390,10 +390,7 @@ class="image-fallback widefat" /> - + > post_types(); foreach( $post_types as $post_type ) { $type = get_post_type_object( $post_type ); if ( empty( $type ) ) {