Block.php
1.24 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
<?php
namespace AIOSEO\Plugin\Common\Breadcrumbs;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Breadcrumb Block.
*
* @since 4.1.1
*/
class Block {
/**
* Class constructor.
*
* @since 4.1.1
*/
public function __construct() {
$this->register();
}
/**
* Registers the block.
*
* @since 4.1.1
*
* @return void
*/
public function register() {
aioseo()->blocks->registerBlock(
'aioseo/breadcrumbs', [
'render_callback' => [ $this, 'render' ]
]
);
}
/**
* Renders the block.
*
* @since 4.1.1
*
* @param array $blockAttributes The block attributes.
* @return string The output from the output buffering.
*/
public function render( $blockAttributes ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$postId = ! empty( $_GET['post_id'] ) ? wp_unslash( $_GET['post_id'] ) : false; // phpcs:ignore HM.Security.ValidatedSanitizedInput.InputNotSanitized
if ( aioseo()->blocks->isGBEditor() && ! empty( $postId ) ) {
return aioseo()->breadcrumbs->frontend->sideDisplay( false, 'post' === get_post_type( $postId ) ? 'post' : 'single', get_post( $postId ) );
}
return aioseo()->breadcrumbs->frontend->display( false );
}
}