Skip to main content

GF_Block_Form

Source: includes/blocks/class-gf-block-form.php:8

Details​

  • Kind: class
  • Namespace: (global)
  • Extends: GF_Block

Properties​

PropertyTypeDescription
$typestringBlock type.
$script_handlestringHandle of primary block script.
$style_handlestringHandle of primary block style.

Methods​

MethodDescription
init()Register block type and add filters specific to the form block.
get_instance()Get instance of this class.
fix_custom_css_class_placement()Move the WordPress "Custom CSS" block-support classes from a leading <script> to the gform_wrapper <div>.
scripts()Register scripts for block.
localize_script()Localize Form block script.
styles()Register styles for block.
render_block()Display block contents on frontend.

Method Reference​

init()​

public function init()

Register block type and add filters specific to the form block.

Returns​

  • void

Since: 2.10.5

Source: includes/blocks/class-gf-block-form.php:53

get_instance()​

public static function get_instance()

Get instance of this class.

Returns​

Since: 2.4.10

Source: includes/blocks/class-gf-block-form.php:78

fix_custom_css_class_placement()​

public function fix_custom_css_class_placement( $block_content, $block )

Move the WordPress "Custom CSS" block-support classes from a leading <script> to the gform_wrapper <div>.

The block "Custom CSS" setting introduced in WP 7.0 adds custom CSS classes to the first HTML element in a block, which might be the <script> tag added by GFForms::maybe_prepend_hooks_js_script() instead of the <div class="gform_wrapper">. This filter corrects that.

Parameters​

NameTypeDefaultDescription
$block_contentstringThe rendered block HTML.
$blockarrayThe parsed block data.

Returns​

  • string — The (possibly corrected) block HTML.

Since: 2.10.5

Source: includes/blocks/class-gf-block-form.php:102

scripts()​

public function scripts()

Register scripts for block.

Returns​

  • array

Since: 2.4.10

Source: includes/blocks/class-gf-block-form.php:172

localize_script()​

public function localize_script( $script=[] )

Localize Form block script.

Parameters​

NameTypeDefaultDescription
$scriptarray[]Script arguments.

Since: 2.4.10

Source: includes/blocks/class-gf-block-form.php:183

styles()​

public function styles()

Register styles for block.

Returns​

  • array

Since: 2.4.10

Source: includes/blocks/class-gf-block-form.php:208

render_block()​

public function render_block( $attributes=[] )

Display block contents on frontend.

Parameters​

NameTypeDefaultDescription
$attributesarray[]Block attributes.

Returns​

  • string

Since: 2.4.10

Source: includes/blocks/class-gf-block-form.php:256