[$this, 'render'], ]); } public function render(array $attributes): string { $id = absint($attributes['id'] ?? 0); if (! $id) { return ''; } $renderer = Plugin::instance()->get(Renderer::class); return $renderer instanceof Renderer ? $renderer->render_shortcode(['id' => $id]) : ''; } public function editor_data(): void { $funnels = []; foreach (get_posts([ 'post_type' => FunnelCpt::POST_TYPE, 'post_status' => 'publish', 'posts_per_page' => 200, 'orderby' => 'title', 'order' => 'ASC', ]) as $post) { $funnels[] = [ 'id' => (int) $post->ID, 'title' => wp_specialchars_decode(get_the_title($post), ENT_QUOTES) ?: ('#' . $post->ID), ]; } $data = [ 'funnels' => $funnels, 'newUrl' => current_user_can(Plugin::capability()) ? admin_url('admin.php?page=' . Admin::MENU_SLUG) : '', ]; wp_add_inline_script( 'funnelnode-funnel-editor-script', 'window.funnelnodeBlock = ' . wp_json_encode($data) . ';', 'before' ); } }