0) { $sn = 0; foreach ($posttags_data as $key => $value) { $sn++; if ($sn === 1) { $default = $key; } $options[] = ['label' => $value['title'], 'value' => $key]; } } register_block_type('taxopress/post-tags', [ 'attributes' => [ 'posttags_id' => [ 'type' => 'string', 'default' => $default, ], 'post_id' => [ 'type' => 'string', ], ], 'editor_script' => 'st-block-post-tags', 'render_callback' => 'st_post_tags_render', ]); $shortcode_page = sprintf( '%s', add_query_arg( [ 'page' => 'st_post_tags', ], admin_url('admin.php') ), esc_html__('Here', 'simple-tags') ); $select_label = __(' Select current post', 'simple-tags'); $panel_title = __('Current Posts (TaxoPress)', 'simple-tags'); wp_localize_script('st-block-post-tags', 'ST_POST_TAGS', [ 'options' => $options, 'panel_title' => $panel_title, 'select_label' => $select_label, ]); } add_action('init', 'st_post_tags_block_init'); /** * Our combined block and shortcode renderer. * * @param array $attributes The attributes that were set on the block or shortcode. */ function st_post_tags_render($attributes) { global $post; ob_start(); echo do_shortcode('[taxopress_postterms id="' . $attributes['posttags_id'] . '"]'); return ob_get_clean(); }