PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / trunk
GenerateBlocks vtrunk
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / includes / blocks / class-block.php
generateblocks / includes / blocks Last commit date
class-block.php 1 year ago class-button-container.php 2 years ago class-button.php 2 years ago class-container.php 2 years ago class-element.php 1 year ago class-grid.php 2 years ago class-headline.php 1 week ago class-image.php 2 years ago class-loop-item.php 1 year ago class-looper.php 1 year ago class-media.php 1 year ago class-query-loop.php 3 years ago class-query-no-results.php 1 year ago class-query-page-numbers.php 1 year ago class-query.php 1 year ago class-shape.php 1 year ago class-text.php 1 year ago
class-block.php
84 lines
1 <?php
2 /**
3 * Handles block functionality.
4 *
5 * @package GenerateBlocks
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * The Block class.
14 */
15 class GenerateBlocks_Block {
16 /**
17 * Keep track of all blocks of this type on the page.
18 *
19 * @var array $block_ids The current block id.
20 */
21 protected static $block_ids = [];
22
23 /**
24 * Store our block name.
25 *
26 * @var string $block_name The block name.
27 */
28 public static $block_name = '';
29
30 /**
31 * Store our block ID in memory.
32 *
33 * @param string $id The block ID to store.
34 */
35 public static function store_block_id( $id ) {
36 static::$block_ids[] = $id;
37 }
38
39 /**
40 * Check if our block ID exists.
41 *
42 * @param string $id The block ID to check.
43 */
44 public static function block_id_exists( $id ) {
45 return in_array( $id, (array) static::$block_ids );
46 }
47
48 /**
49 * Render the block.
50 *
51 * @param array $attributes The block attributes.
52 * @param string $block_content The block content.
53 * @param array $block The block.
54 */
55 public static function render_block( $attributes, $block_content, $block ) {
56 return $block_content;
57 }
58
59 /**
60 * Get the block CSS.
61 *
62 * @param array $attributes The block attributes.
63 */
64 public static function get_css( $attributes ) {
65 $id = $attributes['uniqueId'] ?? '';
66
67 if ( ! $id ) {
68 return '';
69 }
70
71 // Store this block ID in memory.
72 static::store_block_id( $id );
73
74 return apply_filters(
75 'generateblocks_block_css',
76 $attributes['css'] ?? '',
77 [
78 'attributes' => $attributes ?? [],
79 'block_name' => static::$block_name ?? '',
80 ]
81 );
82 }
83 }
84