| @@ -1,82 +1,23 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Getwid\Blocks; |
| 4 | 4 | |
| 5 | -class SocialLinks extends \Getwid\Blocks\AbstractBlock { | |
| 5 | +class SocialLinks extends AbstractBlock { | |
| 6 | 6 | |
| 7 | - protected static $blockName = 'getwid/social-links'; | |
| 7 | + public function __construct() { | |
| 8 | 8 | |
| 9 | - public function __construct() { | |
| 9 | + parent::__construct( 'getwid/social-links' ); | |
| 10 | 10 | |
| 11 | - parent::__construct( self::$blockName ); | |
| 11 | + register_block_type( | |
| 12 | + getwid_get_plugin_path( 'assets/blocks/social-links' ) | |
| 13 | + ); | |
| 14 | + } | |
| 12 | 15 | |
| 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'); | |
| 16 | + public function get_label() { | |
| 17 | + return __( 'Social Links', 'getwid' ); | |
| 28 | 18 | } |
| 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 | 19 | } |
| 79 | 20 | |
| 80 | 21 | getwid()->blocksManager()->addBlock( |
| 81 | - new \Getwid\Blocks\SocialLinks() | |
| 22 | + new SocialLinks() | |
| 82 | 23 | ); |