22 'title' => __(
'GravityView Entry Field',
'gk-gravityview' ),
23 'render_callback' => [ $this,
'render' ],
25 'previewImage' => untrailingslashit( plugin_dir_url( __FILE__ ) ) .
'/preview.svg' 39 static function render( $block_attributes = [] ) {
40 $block_to_shortcode_attributes_map = [
41 'viewId' =>
'view_id',
42 'entryId' =>
'entry_id',
43 'fieldId' =>
'field_id',
44 'fieldSettingOverrides' =>
'field_setting_overrides',
47 $shortcode_attributes = [];
49 foreach ( $block_attributes as $attribute =>
$value ) {
52 if ( isset( $block_to_shortcode_attributes_map[ $attribute ] ) && ! empty(
$value ) ) {
53 if (
'field_setting_overrides' === $attribute ) {
54 $shortcode_attributes[] =
$value;
56 $shortcode_attributes[] = sprintf(
58 $block_to_shortcode_attributes_map[ $attribute ],
59 str_replace(
'"',
'\"',
$value )
65 $shortcode = sprintf(
'[gvfield %s]', implode(
' ', $shortcode_attributes ) );
67 if (
Arr::get( $block_attributes,
'previewAsShortcode' ) ) {
73 return $rendered_shortcode[
'content'];
static get( $array, $key, $default=null)
{}
modify_block_meta( $block_meta)
Modifies block meta.
static render( $block_attributes=[])
Renders [gvfield] shortcode.
static render_shortcode( $shortcode)
Renders shortcode and returns rendered content along with newly enqueued scripts and styles...