PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.6
Kubio AI Page Builder v2.8.6
2.9.0 2.8.6 2.8.5 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 / language-selector / index.php
kubio / build / block-library / blocks / language-selector Last commit date
block.json 1 year ago index.php 1 year ago
index.php
71 lines
1 <?php
2
3 namespace Kubio\Blocks;
4
5 use Kubio\Core\Blocks\BlockBase;
6 use Kubio\Core\Registry;
7
8 class LanguageSelector extends BlockBase {
9 const OUTER = 'outer';
10
11 public function mapPropsToElements() {
12 //$name = $this->getAttribute( 'name' );
13 $content = '';
14 if ( $this->getAttribute( 'show', false ) ) {
15 $content = $this->getContent();
16 }
17
18 return array(
19 self::OUTER => array(
20 'innerHTML' => $content,
21 ),
22 );
23 }
24
25 public function serverSideRender() {
26 $content = $this->getContent();
27
28 return $content;
29 }
30
31 public function getContent() {
32
33 $is_editor = $this->getAttribute( 'isEditor', false );
34 $display_as_flags = $this->getAttribute( 'displayAs', false ) === 'flags';
35 $show_flags = $this->getAttribute( 'showFlags', false );
36 $show_names = $this->getAttribute( 'showNames', false );
37
38 if ( $is_editor ) {
39 $post_id = $this->getAttribute( 'postId' );
40 } else {
41 $post_id = get_the_ID();
42 }
43
44 $languages = pll_get_post_translations( $post_id );
45
46 ob_start();
47 ?>
48 <div class="wp-block-kubio-language-selector__wrapper <?php echo $is_editor ? '--is-editor' : ''; ?>">
49 <?php
50 pll_the_languages(
51 array(
52 'dropdown' => ! $display_as_flags,
53 'show_flags' => $display_as_flags && $show_flags,
54 'show_names' => $display_as_flags && $show_names,
55 'hide_current' => true,
56 )
57 )
58 ?>
59 </div>
60 <?php
61 $content = ob_get_clean();
62 return $content;
63 }
64 }
65
66
67 Registry::registerBlock(
68 __DIR__,
69 LanguageSelector::class
70 );
71