PluginProbe
Powerkit – Supercharge your WordPress Site / 2.3.6
Powerkit – Supercharge your WordPress Site v2.3.6
3.1.1 3.1.0 3.0.9 3.0.8 trunk 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 All 87 releases
powerkit / modules / twitter / public / class-powerkit-twitter-block.php

class-powerkit-twitter-block.php in Powerkit – Supercharge your WordPress Site 2.3.6, at modules/twitter/public/class-powerkit-twitter-block.php

149 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The Gutenberg Block.
4 *
5 * @link https://codesupply.co
6 * @since 1.0.0
7 *
8 * @package Powerkit
9 * @subpackage Modules/public
10 */
11
12 /**
13 * The initialize block.
14 */
15 class Powerkit_Twitter_Block {
16
17 /**
18 * Initialize
19 */
20 public function __construct() {
21 add_action( 'init', array( $this, 'block' ) );
22 add_filter( 'canvas_register_block_type', array( $this, 'register_block_type' ) );
23 }
24
25 /**
26 * Enqueue the block's assets for the editor.
27 */
28 public function block() {
29 // Styles.
30 wp_register_style(
31 'powerkit-twitter-block-editor-style',
32 plugins_url( 'css/public-powerkit-twitter.css', __FILE__ ),
33 array( 'wp-edit-blocks' ),
34 filemtime( plugin_dir_path( __FILE__ ) . 'css/public-powerkit-twitter.css' )
35 );
36
37 wp_style_add_data( 'powerkit-twitter-block-editor-style', 'rtl', 'replace' );
38 }
39
40 /**
41 * Register block
42 *
43 * @param array $blocks all registered blocks.
44 * @return array
45 */
46 public function register_block_type( $blocks ) {
47 $blocks[] = array(
48 'name' => 'canvas/twitter',
49 'title' => esc_html__( 'Twitter', 'powerkit' ),
50 'description' => esc_html__( 'The block allows you to display feed from your twitter account.', 'powerkit' ),
51 'category' => 'canvas',
52 'keywords' => array(),
53 'icon' => '
54 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
55 <path d="M22 5.924C21.264 6.25 20.473 6.471 19.643 6.57C20.49 6.062 21.141 5.258 21.447 4.3C20.654 4.77 19.777 5.112 18.841 5.296C18.095 4.498 17.028 4 15.848 4C13.582 4 11.745 5.837 11.745 8.103C11.745 8.425 11.781 8.738 11.851 9.038C8.441 8.868 5.418 7.234 3.394 4.751C3.041 5.358 2.838 6.063 2.838 6.815C2.838 8.239 3.562 9.495 4.663 10.23C3.99 10.208 3.358 10.023 2.803 9.716V9.768C2.803 11.756 4.218 13.415 6.096 13.791C5.752 13.886 5.389 13.936 5.016 13.936C4.751 13.936 4.494 13.91 4.243 13.862C4.765 15.492 6.281 16.679 8.076 16.712C6.672 17.812 4.902 18.469 2.98 18.469C2.648 18.469 2.32 18.449 2 18.412C3.816 19.576 5.973 20.255 8.29 20.255C15.837 20.255 19.965 14.003 19.965 8.58C19.965 8.402 19.961 8.225 19.953 8.05C20.755 7.472 21.45 6.75 22 5.926V5.924Z" />
56 </svg>
57 ',
58 'supports' => array(
59 'className' => true,
60 'anchor' => true,
61 'html' => false,
62 'canvasSpacings' => true,
63 'canvasBorder' => true,
64 'canvasResponsive' => true,
65 ),
66 'styles' => array(),
67 'location' => array(),
68 'sections' => array(
69 'general' => array(
70 'title' => esc_html__( 'Block Settings', 'powerkit' ),
71 'priority' => 5,
72 'open' => true,
73 ),
74 'buttonSettings' => array(
75 'title' => esc_html__( 'Button Settings', 'powerkit' ),
76 'priority' => 50,
77 ),
78 ),
79 'layouts' => array(),
80 'fields' => array_merge(
81 array(
82 array(
83 'key' => 'username',
84 'label' => esc_html__( 'User Name', 'powerkit' ),
85 'section' => 'general',
86 'type' => 'text',
87 'default' => '',
88 ),
89 array(
90 'key' => 'showHeader',
91 'label' => esc_html__( 'Display Header', 'powerkit' ),
92 'section' => 'general',
93 'type' => 'toggle',
94 'default' => true,
95 ),
96 array(
97 'key' => 'showFollowButton',
98 'label' => esc_html__( 'Display Follow Button', 'powerkit' ),
99 'section' => 'general',
100 'type' => 'toggle',
101 'default' => true,
102 ),
103 array(
104 'key' => 'showReplies',
105 'label' => esc_html__( 'Display Replies', 'powerkit' ),
106 'section' => 'general',
107 'type' => 'toggle',
108 'default' => false,
109 ),
110 array(
111 'key' => 'showRetweets',
112 'label' => esc_html__( 'Display Retweets', 'powerkit' ),
113 'section' => 'general',
114 'type' => 'toggle',
115 'default' => false,
116 ),
117 array(
118 'key' => 'number',
119 'label' => esc_html__( 'Number of Tweets', 'powerkit' ),
120 'section' => 'general',
121 'type' => 'number',
122 'min' => 1,
123 'max' => 12,
124 'default' => 4,
125 ),
126 ), powerkit_get_gutenberg_button_fields(
127 'button',
128 'buttonSettings',
129 array(
130 array(
131 'field' => 'showFollowButton',
132 'operator' => '==',
133 'value' => true,
134 ),
135 )
136 )
137 ),
138 'template' => dirname( __FILE__ ) . '/block/render.php',
139
140 // enqueue registered scripts/styles.
141 'editor_style' => 'powerkit-twitter-block-editor-style',
142 );
143
144 return $blocks;
145 }
146 }
147
148 new Powerkit_Twitter_Block();
149