price-list.php
1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace Getwid\Blocks;
class PriceList extends \Getwid\Blocks\AbstractBlock {
protected static $blockName = 'getwid/price-list';
public function __construct() {
parent::__construct( self::$blockName );
register_block_type(
'getwid/price-list',
array(
'render_callback' => [ $this, 'render_callback' ]
)
);
}
public function getLabel() {
return __('Price List', 'getwid');
}
public function block_frontend_assets() {
if ( is_admin() ) {
return;
}
if ( FALSE == getwid()->assetsOptimization()->load_assets_on_demand() ) {
return;
}
$rtl = is_rtl() ? '.rtl' : '';
wp_enqueue_style(
self::$blockName,
getwid_get_plugin_url( 'assets/blocks/price-list/style' . $rtl . '.css' ),
[],
getwid()->settings()->getVersion()
);
}
public function render_callback( $attributes, $content ) {
$this->block_frontend_assets();
return $content;
}
}
getwid()->blocksManager()->addBlock(
new \Getwid\Blocks\PriceList()
);