| @@ -1,76 +1,27 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Getwid\Blocks; |
| 4 | 4 | |
| 5 | -class ContentTimeline extends \Getwid\Blocks\AbstractBlock { | |
| 5 | +class ContentTimeline extends AbstractBlock { | |
| 6 | 6 | |
| 7 | - protected static $blockName = 'getwid/content-timeline'; | |
| 8 | - | |
| 9 | 7 | public function __construct() { |
| 10 | 8 | |
| 11 | - parent::__construct( self::$blockName ); | |
| 9 | + parent::__construct( 'getwid/content-timeline' ); | |
| 12 | 10 | |
| 13 | 11 | register_block_type( |
| 14 | - 'getwid/content-timeline', | |
| 15 | - array( | |
| 16 | - 'render_callback' => [ $this, 'render_callback' ] | |
| 17 | - ) | |
| 12 | + getwid_get_plugin_path( 'assets/blocks/content-timeline/content-timeline' ) | |
| 18 | 13 | ); |
| 19 | 14 | |
| 15 | + register_block_type( | |
| 16 | + getwid_get_plugin_path( 'assets/blocks/content-timeline/content-timeline-item' ) | |
| 17 | + ); | |
| 20 | 18 | } |
| 21 | 19 | |
| 22 | - public function getLabel() { | |
| 23 | - return __('Content Timeline', 'getwid'); | |
| 20 | + public function get_label() { | |
| 21 | + return __( 'Content Timeline', 'getwid' ); | |
| 24 | 22 | } |
| 25 | - | |
| 26 | - public function block_frontend_assets() { | |
| 27 | - | |
| 28 | - if ( is_admin() ) { | |
| 29 | - return; | |
| 30 | - } | |
| 31 | - | |
| 32 | - if ( FALSE == getwid()->assetsOptimization()->load_assets_on_demand() ) { | |
| 33 | - return; | |
| 34 | - } | |
| 35 | - | |
| 36 | - add_filter( 'getwid/optimize/assets', | |
| 37 | - function ( $assets ) { | |
| 38 | - $assets[] = getwid()->settings()->getPrefix() . '-blocks-common'; | |
| 39 | - | |
| 40 | - return $assets; | |
| 41 | - } | |
| 42 | - ); | |
| 43 | - | |
| 44 | - add_filter( 'getwid/optimize/should_load_common_css', '__return_true' ); | |
| 45 | - | |
| 46 | - $rtl = is_rtl() ? '.rtl' : ''; | |
| 47 | - | |
| 48 | - wp_enqueue_style( | |
| 49 | - self::$blockName, | |
| 50 | - getwid_get_plugin_url( 'assets/blocks/content-timeline/style' . $rtl . '.css' ), | |
| 51 | - [], | |
| 52 | - getwid()->settings()->getVersion() | |
| 53 | - ); | |
| 54 | - | |
| 55 | - wp_enqueue_script( | |
| 56 | - self::$blockName, | |
| 57 | - getwid_get_plugin_url( 'assets/blocks/content-timeline/frontend.js' ), | |
| 58 | - [ 'jquery' ], | |
| 59 | - getwid()->settings()->getVersion(), | |
| 60 | - true | |
| 61 | - ); | |
| 62 | - | |
| 63 | - } | |
| 64 | - | |
| 65 | - public function render_callback( $attributes, $content ) { | |
| 66 | - | |
| 67 | - $this->block_frontend_assets(); | |
| 68 | - | |
| 69 | - return $content; | |
| 70 | - } | |
| 71 | - | |
| 72 | 23 | } |
| 73 | 24 | |
| 74 | 25 | getwid()->blocksManager()->addBlock( |
| 75 | - new \Getwid\Blocks\ContentTimeline() | |
| 26 | + new ContentTimeline() | |
| 76 | 27 | ); |