PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.3
Kubio AI Page Builder v2.8.3
2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / build / block-library / blocks / post-comments-form / index.php
kubio / build / block-library / blocks / post-comments-form Last commit date
block.json 3 years ago index.php 1 year ago
index.php
62 lines
1 <?php
2
3 namespace Kubio\Blocks;
4
5 use Kubio\Core\Blocks\BlockBase;
6 use Kubio\Core\Registry;
7
8 class PostCommentsFormBlock extends BlockBase {
9
10 const CONTAINER = 'container';
11
12 function disableCurrentUser() {
13 return false;
14 }
15
16 public function serverSideRender() {
17 $user = wp_get_current_user();
18 wp_set_current_user( 0 );
19 add_filter( 'determine_current_user', array( $this, 'disableCurrentUser' ), PHP_INT_MAX );
20
21 $content = $this->renderForm();
22
23 if ( empty( $content ) ) {
24 $content = sprintf(
25 '<p class="comments-disabled"><p>%s</p></p>',
26 __( 'Comments are closed. This Post Comments Form block is still present here but is not visible on front-end.', 'kubio' )
27 );
28 }
29
30 if ( $user ) {
31 wp_set_current_user( $user->ID );
32 }
33 remove_filter( 'determine_current_user', array( $this, 'disableCurrentUser' ), PHP_INT_MAX );
34
35 return $content;
36 }
37
38 function renderForm() {
39
40 if ( $this->isSandboxRender() ) {
41 return '';
42 }
43
44 ob_start();
45 if ( comments_open( get_the_ID() ) ) {
46 comment_form( get_the_ID() );
47 }
48
49 return ob_get_clean();
50 }
51
52 public function mapPropsToElements() {
53 return array(
54 self::CONTAINER => array(
55 'innerHTML' => $this->renderForm(),
56 ),
57 );
58 }
59 }
60
61 Registry::registerBlock( __DIR__, PostCommentsFormBlock::class );
62