PluginProbe
Getwid – Gutenberg Blocks / 2.0.13
Getwid – Gutenberg Blocks v2.0.13
3.0.1 3.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.2.0 trunk 1.8.7 1.9.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9
getwid / includes / blocks / social-links.php

social-links.php in Getwid – Gutenberg Blocks 2.0.13, at includes/blocks/social-links.php

83 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Getwid\Blocks;
4
5 class SocialLinks extends \Getwid\Blocks\AbstractBlock {
6
7 protected static $blockName = 'getwid/social-links';
8
9 public function __construct() {
10
11 parent::__construct( self::$blockName );
12
13 register_block_type(
14 'getwid/social-links',
15 array(
16 'render_callback' => [ $this, 'render_callback' ]
17 )
18 );
19
20 if ( $this->isEnabled() ) {
21
22 add_filter( 'getwid/blocks_style_css/dependencies', [ $this, 'block_frontend_styles' ] );
23 }
24 }
25
26 public function getLabel() {
27 return __('Social Links', 'getwid');
28 }
29
30 public function block_frontend_styles($styles) {
31
32 //fontawesome
33 $styles = getwid()->fontIconsManager()->enqueueFonts( $styles );
34
35 return $styles;
36 }
37
38 public function block_frontend_assets() {
39
40 if ( is_admin() ) {
41 return;
42 }
43
44 if ( FALSE == getwid()->assetsOptimization()->load_assets_on_demand() ) {
45 return;
46 }
47
48 add_filter( 'getwid/optimize/assets',
49 function ( $assets ) {
50 $assets[] = getwid()->settings()->getPrefix() . '-blocks-common';
51
52 return $assets;
53 }
54 );
55
56 add_filter( 'getwid/optimize/should_load_common_css', '__return_true' );
57
58 //fontawesome
59 $deps = getwid()->fontIconsManager()->enqueueFonts( [] );
60
61 $rtl = is_rtl() ? '.rtl' : '';
62
63 wp_enqueue_style(
64 self::$blockName,
65 getwid_get_plugin_url( 'assets/blocks/social-links/style' . $rtl . '.css' ),
66 $deps,
67 getwid()->settings()->getVersion()
68 );
69 }
70
71 public function render_callback( $attributes, $content ) {
72
73 $this->block_frontend_assets();
74
75 return $content;
76 }
77
78 }
79
80 getwid()->blocksManager()->addBlock(
81 new \Getwid\Blocks\SocialLinks()
82 );
83