PluginProbe
Getwid – Gutenberg Blocks / 2.1.3
Getwid – Gutenberg Blocks v2.1.3
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 / circle-progress-bar.php

circle-progress-bar.php in Getwid – Gutenberg Blocks 2.1.3, at includes/blocks/circle-progress-bar.php

78 lines 1.8 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 CircleProgressBar extends \Getwid\Blocks\AbstractBlock {
6
7 protected static $blockName = 'getwid/circle-progress-bar';
8
9 public function __construct() {
10
11 parent::__construct( self::$blockName );
12
13 register_block_type(
14 'getwid/circle-progress-bar',
15 array(
16 'render_callback' => [ $this, 'render_callback' ]
17 )
18 );
19
20 //Register JS/CSS assets
21 wp_register_script(
22 'waypoints',
23 getwid_get_plugin_url( 'vendors/waypoints/lib/jquery.waypoints.min.js' ),
24 [ 'jquery' ],
25 '4.0.1',
26 true
27 );
28 }
29
30 public function getLabel() {
31 return __('Circular Progress Bar', 'getwid');
32 }
33
34 public function block_frontend_assets( $attributes = null ) {
35
36 if ( is_admin() ) {
37 return;
38 }
39
40 //jquery.waypoints.min.js
41 if ( ! wp_script_is( 'waypoints', 'enqueued' ) ) {
42 wp_enqueue_script('waypoints');
43 }
44
45 if ( FALSE == getwid()->assetsOptimization()->load_assets_on_demand() ) {
46 return;
47 }
48
49 $rtl = is_rtl() ? '.rtl' : '';
50
51 wp_enqueue_style(
52 self::$blockName,
53 getwid_get_plugin_url( 'assets/blocks/circle-progress-bar/style' . $rtl . '.css' ),
54 [],
55 getwid()->settings()->getVersion()
56 );
57
58 wp_enqueue_script(
59 self::$blockName,
60 getwid_get_plugin_url( 'assets/blocks/circle-progress-bar/frontend.js' ),
61 [ 'jquery', 'waypoints' ],
62 getwid()->settings()->getVersion(),
63 true
64 );
65 }
66
67 public function render_callback( $attributes, $content ) {
68
69 $this->block_frontend_assets( $attributes );
70
71 return $content;
72 }
73 }
74
75 getwid()->blocksManager()->addBlock(
76 new \Getwid\Blocks\CircleProgressBar()
77 );
78