PluginProbe
Powerkit – Supercharge your WordPress Site / 2.3.4
Powerkit – Supercharge your WordPress Site v2.3.4
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 / social-links / public / class-powerkit-social-links-block.php

class-powerkit-social-links-block.php in Powerkit – Supercharge your WordPress Site 2.3.4, at modules/social-links/public/class-powerkit-social-links-block.php

145 lines 4.1 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_Social_Links_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-social-links-block-editor-style',
32 plugins_url( 'css/public-powerkit-social-links.css', __FILE__ ),
33 array( 'wp-edit-blocks' ),
34 filemtime( plugin_dir_path( __FILE__ ) . 'css/public-powerkit-social-links.css' )
35 );
36
37 wp_style_add_data( 'powerkit-social-links-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 $additional_fields = array();
48 $styles = array();
49 $colors = apply_filters( 'powerkit_social_links_color_schemes', array() );
50 $templates = powerkit_social_links_get_templates();
51
52 // Colors.
53 if ( count( (array) $colors ) > 1 ) {
54 foreach ( $colors as $name => $scheme ) {
55 $styles[] = array(
56 'name' => 'pk-social-links-' . $name,
57 'label' => $scheme['name'],
58 );
59 }
60 }
61
62 // Templates.
63 if ( count( (array) $templates ) > 1 ) {
64 $additional_fields[] = array(
65 'key' => 'template',
66 'label' => esc_html__( 'Template', 'powerkit' ),
67 'section' => 'general',
68 'type' => 'select',
69 'default' => 'default',
70 'choices' => $templates,
71 );
72 }
73
74 $blocks[] = array(
75 'name' => 'canvas/social-links',
76 'title' => esc_html__( 'Social Links', 'powerkit' ),
77 'category' => 'canvas',
78 'keywords' => array(),
79 'icon' => '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path fill="none" d="M0 0h24v24H0z"/><g stroke="#2D2D2D" stroke-width="1.5"><path d="M10 12.83a5.45 5.45 0 003.97 2.156 5.46 5.46 0 004.237-1.571l3.265-3.246a5.387 5.387 0 00-.066-7.584 5.465 5.465 0 00-7.63-.066l-1.871 1.85"/><path d="M14 11.17a5.45 5.45 0 00-3.97-2.156 5.46 5.46 0 00-4.237 1.571l-3.265 3.246a5.387 5.387 0 00.066 7.584 5.465 5.465 0 007.63.066l1.86-1.85"/></g></g></svg>',
80 'supports' => array(
81 'className' => true,
82 'anchor' => true,
83 'html' => false,
84 'canvasSpacings' => true,
85 'canvasBorder' => true,
86 'canvasResponsive' => true,
87 ),
88 'styles' => $styles,
89 'location' => array(),
90
91 'sections' => array(
92 'general' => array(
93 'title' => esc_html__( 'Block Settings', 'powerkit' ),
94 'priority' => 5,
95 'open' => true,
96 ),
97 ),
98 'layouts' => array(),
99 'fields' => array_merge(
100 $additional_fields, array(
101 array(
102 'key' => 'showLabels',
103 'label' => esc_html__( 'Display Labels', 'powerkit' ),
104 'section' => 'general',
105 'type' => 'toggle',
106 'default' => true,
107 ),
108 array(
109 'key' => 'showTitles',
110 'label' => esc_html__( 'Display Titles', 'powerkit' ),
111 'section' => 'general',
112 'type' => 'toggle',
113 'default' => true,
114 ),
115 array(
116 'key' => 'showCounts',
117 'label' => esc_html__( 'Display Counts', 'powerkit' ),
118 'section' => 'general',
119 'type' => 'toggle',
120 'default' => true,
121 ),
122 array(
123 'key' => 'count',
124 'label' => esc_html__( 'Maximum number of social links', 'powerkit' ),
125 'help' => esc_html__( 'Input -1 to remove the maximum limit of the social links.', 'powerkit' ),
126 'section' => 'general',
127 'type' => 'number',
128 'min' => -1,
129 'max' => 50,
130 'default' => -1,
131 ),
132 )
133 ),
134 'template' => dirname( __FILE__ ) . '/block/render.php',
135
136 // enqueue registered scripts/styles.
137 'editor_style' => 'powerkit-social-links-block-editor-style',
138 );
139
140 return $blocks;
141 }
142 }
143
144 new Powerkit_Social_Links_Block();
145