\GE_Block_Wrapper

GE_Block_Wrapper is our "Una Matina". Imagine factory making houses for little elements.

That's what this does. It wraps elements into wrappers, so they can be edited. NICE.

Summary

Methods
Properties
Constants
content_wrapper()
wrap_block()
detect_block_wrapper()
do_special_block()
do_goldenegg_wrapping()
add_ids_to_blocks()
add_class()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$layout_loaded
N/A

Properties

$layout_loaded

$layout_loaded : boolean

Content_wrapper should be called twice, so this says if it is loading for first time, or if it is already loaded

Type

boolean

Methods

content_wrapper()

content_wrapper(string  $html) : string

Content filter for GoldenEgg page. It's used to add our own HTML codes to layout, so we can style it as We WANT! Origins of this function comes from ancient GoldenEgg Theme, which even didn't know what Gutenberg is and how he acts.

Thus this is heart of GoldenEgg, thank him in advance. (This function replaces Gutenberg do_blocks hook, but we use it in this function, thus it is save to use)

Parameters

string $html

Page (HTML) content supplied by Wordpress

Returns

string —

Page (HTML) content supplied to Wordpress

wrap_block()

wrap_block(array  $block, string  $wrapper_html) : string

Wraps block with wrapper. If is full_column, don't wrap it. If is wide_column, wrap it half way.

Wriggity wrapitty wrap.

Parameters

array $block

Block (in array) parsed by Gutenberg native parser

string $wrapper_html

Html of main wrapper

Returns

string —

Return content of block

detect_block_wrapper()

detect_block_wrapper(string  $block_content, string  $wrapper_attributes, string  $editbutton_html, string  $block_class) : array

Detects, if has block wrapper. If so, place our wrapper into this, so we save some problems with their wrappers.

Parameters

string $block_content

Raw block html

string $wrapper_attributes

Wrapper attributes

string $editbutton_html

Edit button html code

string $block_class

Wrapper class

Returns

array —

Array with 'wrap_block' (bool) and 'raw_content' (string)

do_special_block()

do_special_block(string  $name, array  $arguments = array()) : string

Does special magic with PHP rendered blocks. Firstly it rebuilds Gutenberg code of this block and then it runs Gutenberg functions to render them.

Parameters

string $name

Block name (e.g. core/latest-posts)

array $arguments

Array of attributes of that block

Returns

string —

HTML code of this block, generated by PHP

do_goldenegg_wrapping()

do_goldenegg_wrapping(string  $html) : string

Very tricks function. This one wraps (GoldenEggifies) every block in its own way.

It has own array for adding more wrapping options, feel free to expand him.

Parameters

string $html

HTML of one particular block

Returns

string —

GoldenEggified block html

add_ids_to_blocks()

add_ids_to_blocks(string  $html) : string

Blocks now should have it's own ID on save. If blocks have it's own ID, let them be as they are.

Parameters

string $html

HTML code with blocks from butenberg

Returns

string —

HTML code to return

add_class()

add_class(string  $attributes, string  $classname) : string

Support function for adding class to parsed attributes

Parameters

string $attributes

String attributes of tag

string $classname

Class name you want to insert

Returns

string —

Returns attributes string with new classname