Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed cover layout issue with CPT #4295

Merged
merged 11 commits into from
Oct 28, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ test.describe('Single Post Check', function () {
baseURL,
});
const HIDDEN = [
'.entry-header',
'.nv-thumb-wrap',
'.entry-content',
'.nv-tags-list',
Expand All @@ -116,11 +115,11 @@ test.describe('Single Post Check', function () {
baseURL,
});
const ORDER = [
'entry-header',
'nv-post-navigation',
'nv-tags-list',
'nv-content-wrap',
'comments-area',
'entry-header',
'nv-thumb-wrap',
];
await page.goto(
Expand Down
5 changes: 4 additions & 1 deletion inc/customizer/defaults/single_post.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ public function get_cpt_context( $allowed = [ 'post', 'page' ] ) {
*/
$allowed_context = apply_filters( 'neve_allowed_custom_post_types', $allowed, 10, 1 );
$context = get_post_type();
$context = apply_filters( 'neve_context_filter', $context, 10, 1 );
if ( ! has_filter( 'neve_context_filter' ) && ! in_array( get_post_type(), $allowed_context, true ) ) {
$context = 'post';
}
$context = apply_filters( 'neve_context_filter', $context, 10, 1 );

return [ $context, $allowed_context ];
}
Expand Down
2 changes: 1 addition & 1 deletion inc/customizer/options/layout_single_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ public function add_controls() {
* @return bool
*/
public static function is_cover_layout() {
return get_theme_mod( 'neve_page_header_layout' ) === 'cover';
return class_exists( '\Neve_Pro\Admin\Custom_Layouts_Cpt' ) && get_theme_mod( 'neve_page_header_layout' ) === 'cover';
}
}
2 changes: 1 addition & 1 deletion inc/customizer/options/layout_single_post.php
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ public function sanitize_post_elements_ordering( $value ) {
* @return bool
*/
public static function is_cover_layout() {
return get_theme_mod( 'neve_post_header_layout' ) === 'cover';
return class_exists( '\Neve_Pro\Admin\Custom_Layouts_Cpt' ) && get_theme_mod( 'neve_post_header_layout' ) === 'cover';
}

/**
Expand Down
4 changes: 4 additions & 0 deletions inc/views/cover_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public function render_cover_header() {
return;
}

if ( ! class_exists( '\Neve_Pro\Admin\Custom_Layouts_Cpt' ) && get_post_type() !== $context ) {
return;
}

$header_layout = get_theme_mod( 'neve_' . $context . '_header_layout', 'normal' );
if ( $header_layout !== 'cover' ) {
return;
Expand Down
5 changes: 5 additions & 0 deletions inc/views/post_layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ private function get_content_order() {
}
}

list( $context ) = $this->get_cpt_context();
if ( ! Layout_Single_Post::is_cover_layout() && get_post_type() !== $context ) {
$content_order = array_unique( array_merge( array( 'title-meta' ), $content_order ) );
}

return apply_filters( 'neve_layout_single_post_elements_order', $content_order );
}
}
Loading