PluginProbe
FileBird – WordPress Media Library Folders & File Manager / 6.3
FileBird – WordPress Media Library Folders & File Manager v6.3
6.5.8 6.5.7 6.5.5 6.5.4 trunk 4.3.1 5.1.6 5.3 5.3.2 5.4.3 5.4.4 5.4.5 5.5 5.5.3 5.5.5 5.5.8 5.5.8.1 5.6 5.6.1 5.6.2 5.6.3 5.6.4 6.2.3 6.2.5 6.3 All 36 releases
filebird / includes / Blocks / AbstractBlock.php

AbstractBlock.php in FileBird – WordPress Media Library Folders & File Manager 6.3, at includes/Blocks/AbstractBlock.php

77 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FileBird\Blocks;
4
5 abstract class AbstractBlock {
6
7 protected $namespace = 'filebird';
8
9 protected $block_name = '';
10
11 public function __construct() {
12 $this->init();
13 }
14
15 abstract protected function enqueue_frontend_assets();
16
17 protected function get_block_type() {
18 return $this->namespace . '/' . $this->block_name;
19 }
20
21 protected function get_block_attributes() {
22 return array();
23 }
24
25 protected function get_editor_dependencies() {
26 return array();
27 }
28
29 protected function register_block_editor_script() {
30 wp_register_script(
31 $this->namespace . '-' . $this->block_name . '-js',
32 NJFB_PLUGIN_URL . 'blocks/' . $this->block_name . '/dist/index.js',
33 $this->get_editor_dependencies(),
34 NJFB_VERSION,
35 true
36 );
37 wp_register_style(
38 $this->namespace . '-' . $this->block_name . '-css',
39 NJFB_PLUGIN_URL . 'blocks/' . $this->block_name . '/dist/index.css',
40 $this->get_editor_dependencies(),
41 NJFB_VERSION
42 );
43 }
44
45 public function render_callback( $attributes = array(), $content = '' ) {
46 if ( ! is_admin() ) {
47 $this->enqueue_frontend_assets();
48 }
49 return $this->render( $attributes, $content );
50 }
51
52 protected function render( $attributes, $content ) {
53
54 }
55
56 protected function get_render_callback() {
57 return array( $this, 'render_callback' );
58 }
59
60 protected function register_block_type() {
61 $this->register_block_editor_script();
62 register_block_type(
63 $this->get_block_type(),
64 array(
65 'editor_script' => $this->namespace . '-' . $this->block_name . '-js',
66 'editor_style' => $this->namespace . '-' . $this->block_name . '-css',
67 // 'style' => $this->namespace . '-' . $this->block_name,
68 'render_callback' => $this->get_render_callback(),
69 'attributes' => $this->get_block_attributes(),
70 )
71 );
72 }
73
74 protected function init() {
75 $this->register_block_type();
76 }
77 }