-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpage-block-editor.php
More file actions
76 lines (64 loc) · 2.06 KB
/
Copy pathpage-block-editor.php
File metadata and controls
76 lines (64 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* The template for displaying block editor pages.
*
* This is a complete replacement of page.php when all pages are converted to
* blocks.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package shiro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // File should never be accessed directly.
}
get_header();
while ( have_posts() ) {
the_post();
$template_args = [];
$blocks = parse_blocks( get_post()->post_content );
$first_block = $blocks[0]['blockName'];
$show_title = (
$first_block !== 'shiro/landing-page-hero' &&
$first_block !== 'shiro/home-page-hero' &&
$first_block !== 'shiro/report-landing-hero'
);
if ( $show_title ) {
$template_args['h1_title'] = get_the_title();
}
/**
* Breadcrumb link switch
*
* Possible values of the switch:
* 1. '' - meta data from component not set (page wasn't yet edited with this component on the page)
* 2. 'on' - set to yes
* 3. 'off' - set to no
*/
$breadcrumb_link_switch = get_post_meta( get_the_ID(), 'show_breadcrumb_links', true );
$parent_page = wp_get_post_parent_id( get_the_ID() );
$template_args['breadcrumb_parent'] = $parent_page;
$show_breadcrumb = false;
if ( $breadcrumb_link_switch === 'on' ) {
$template_args['breadcrumb_custom_parent_link'] = get_post_meta( get_the_ID(), 'breadcrumb_link_url', true );
$template_args['breadcrumb_custom_parent_title'] = get_post_meta( get_the_ID(), 'breadcrumb_link_title', true );
$show_breadcrumb = true;
} elseif ( $breadcrumb_link_switch === 'off' ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedElseif
// Does nothing.
} elseif ( $breadcrumb_link_switch === '' && $show_title ) {
// Default behavior.
if ( ! empty( $parent_page ) ) {
$show_breadcrumb = true;
}
}
if ( $show_title || $show_breadcrumb ) {
get_template_part( 'template-parts/header/page', 'noimage', $template_args );
} else {
?>
</div>
</div><!-- Close out the secondary header. -->
<main id="content" class="module-area article-main is-layout-constrained has-global-padding">
<?php
}
the_content();
}
get_footer();