22 'title' => __(
'GravityView Entry Link',
'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',
44 'postId' =>
'post_id',
45 'returnFormat' =>
'return',
46 'linkAtts' =>
'link_atts',
47 'fieldValues' =>
'field_values',
48 'content' =>
'content',
51 $shortcode_attributes = [];
53 foreach ( $block_attributes as $attribute =>
$value ) {
56 if ( isset( $block_to_shortcode_attributes_map[ $attribute ] ) && ! empty(
$value ) ) {
57 $shortcode_attributes[] = sprintf(
59 $block_to_shortcode_attributes_map[ $attribute ],
60 str_replace(
'"',
'\"',
$value )
65 if ( ! empty( $block_attributes[
'content'] ) ) {
67 '[gv_entry_link %s]%s[/gv_entry_link]',
68 implode(
' ', $shortcode_attributes ),
69 wp_kses_post( $block_attributes[
'content'] )
72 $shortcode = sprintf(
'[gv_entry_link %s/]', implode(
' ', $shortcode_attributes ) );
75 if ( defined(
'REST_REQUEST' ) && REST_REQUEST ) {
76 add_filter(
'gravityview/entry_link/add_query_args',
'__return_false' );
79 if (
Arr::get( $block_attributes,
'previewAsShortcode' ) ) {
85 return $rendered_shortcode[
'content'];
static get( $array, $key, $default=null)
{}
static render( $block_attributes=[])
Renders [gv_entry_link] shortcode.
modify_block_meta( $block_meta)
Modifies block meta.
static render_shortcode( $shortcode)
Renders shortcode and returns rendered content along with newly enqueued scripts and styles...