GF_Block
Base Gravity Forms Block class.
Since: 2.4.10 (Class GF_Block)
Source: includes/blocks/class-gf-block.php:15
Details
- Kind:
class - Namespace:
(global)
Properties
| Property | Type | Description |
|---|---|---|
$type | string | Block type. |
$script_handle | string | Handle of primary block editor script. |
$style_handle | string | Handle of primary block editor style. |
$fe_script_handle | string | Handle of primary block FE script. |
$fe_style_handle | string | Handle of primary block FE style. |
$attributes | array | Block attributes. |
Methods
| Method | Description |
|---|---|
init() | Register block type. |
get_type() | Get block type. |
register_block_type() | Register block with WordPress. |
register_block_assets() | Enqueue/register the block's assets upon init |
check_allowed_blocks() | Checks allowed blocks for Gravity forms blocks to only enqueue block editor assets when necessary. |
register_scripts() | Enqueue block scripts. |
enqueue_scripts() | Enqueue scripts |
scripts() | Override this function to provide a list of scripts to be enqueued. |
register_styles() | Enqueue block styles. |
enqueue_styles() | Enqueue styles |
styles() | Override this function to provide a list of styles to be enqueued. |
render_block() | Display block contents on frontend. |
post_enqueue_scripts() | Override to perform additional actions when scripts/styles are enqueued on the wp_enqueue_scripts hook. |
Method Reference
init()
public function init()
Register block type.
Enqueue editor assets.
Since: 2.4.10
Source: includes/blocks/class-gf-block.php:81
get_type()
public function get_type()
Get block type.
Returns
string
Since: 2.4.10
Source: includes/blocks/class-gf-block.php:104
register_block_type()
public function register_block_type()
Register block with WordPress.
Since: 2.4.10
Source: includes/blocks/class-gf-block.php:115
register_block_assets()
public function register_block_assets()
Enqueue/register the block's assets upon init
Returns
void
Since: 2.5.6
Source: includes/blocks/class-gf-block.php:145
check_allowed_blocks()
public function check_allowed_blocks( $allowed_block_types )
Checks allowed blocks for Gravity forms blocks to only enqueue block editor assets when necessary.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$allowed_block_types | bool | array | Array of block type slugs, or boolean to enable/disable all. |
Returns
bool|array
Since: 2.4.18
Deprecated: since 2.5.6. See GF_Block::register_block_assets()
Source: includes/blocks/class-gf-block.php:161
register_scripts()
public function register_scripts()
Enqueue block scripts.
Since: 2.4.10
Source: includes/blocks/class-gf-block.php:184
enqueue_scripts()
public function enqueue_scripts()
Enqueue scripts
Returns
void
Source: includes/blocks/class-gf-block.php:235
scripts()
public function scripts()
Override this function to provide a list of scripts to be enqueued.
Following is an example of the array that is expected to be returned by this function: <pre>
array(
array(
'handle' => 'super_signature_script',
'src' => $this->get_base_url() . '/super_signature/ss.js',
'version' => $this->_version,
'deps' => array( 'jquery'),
'callback' => array( $this, 'localize_scripts' ),
'strings' => array(
// Accessible in JavaScript using the global variable "[script handle]_strings"
'stringKey1' => __( 'The string', 'gravityforms' ),
'stringKey2' => __( 'Another string.', 'gravityforms' )
)
)
);
</pre>
Returns
array
Since: 2.4.10
Source: includes/blocks/class-gf-block.php:267
register_styles()
public function register_styles()
Enqueue block styles.
Since: 2.4.10
Source: includes/blocks/class-gf-block.php:284
enqueue_styles()
public function enqueue_styles()
Enqueue styles
Returns
void
Source: includes/blocks/class-gf-block.php:324
styles()
public function styles()
Override this function to provide a list of styles to be enqueued.
See scripts() for an example of the format expected to be returned.
Returns
array
Since: 2.4.10
Source: includes/blocks/class-gf-block.php:336
render_block()
public function render_block( $attributes=[] )
Display block contents on frontend.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$attributes | array | [] | Block attributes. |
Returns
string
Since: 2.4.10
Source: includes/blocks/class-gf-block.php:357
post_enqueue_scripts()
public function post_enqueue_scripts( $found_forms, $found_blocks, $post )
Override to perform additional actions when scripts/styles are enqueued on the wp_enqueue_scripts hook.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$found_forms | array | An array of found forms using the form ID as the key to the ajax status. | |
$found_blocks | array | An array of found GF blocks. | |
$post | WP_Post | The post which was processed. |
Since: 2.4.18
Source: includes/blocks/class-gf-block.php:372