PluginProbe
TableKit – WordPress Table Builder for Data Tables, WooCommerce Product Tables & Post Tables / 2.3.0
TableKit – WordPress Table Builder for Data Tables, WooCommerce Product Tables & Post Tables v2.3.0
2.3.0 2.2.14 2.2.13 2.2.12 2.2.11 2.2.10 2.2.9 2.2.8 2.2.7 2.2.6 2.2.5 2.2.4 2.2.3 trunk 1.0.0 1.0.1 2.0.0 2.0.1 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2
← All changes | includes/Shortcode/Shortcode.php +19 -9 2.2.11 → 2.3.0 View file →
@@ -6,8 +6,9 @@
6 6 */
7 7
8 8 namespace TableBuilder\Shortcode;
9 9
10 +use TableBuilder\Hooks\AssetGenerator;
10 11 use TableBuilder\Shortcode\ShortcodeUtils;
11 12 use TableBuilder\Render\BlockRenderer;
12 13 use TableBuilder\Traits\Singleton;
13 14
@@ -75,22 +76,31 @@
75 76 public function render( $raw_atts, string $content = '' ): string {
76 77 $atts = $this->sanitize_atts( shortcode_atts( self::DEFAULT_ATTS, (array) $raw_atts, 'tableKit' ) );
77 78 $ids = $this->parse_ids( $atts );
78 79
80 + // The shortcode prints its own table CSS, so the generic late-CSS
81 + // printer (AssetGenerator) must not print it a second time.
82 + $asset_generator = AssetGenerator::instance();
83 + $asset_generator->suspend_late_css();
84 +
79 85 ob_start();
80 86
81 - if ( empty( $ids['block_id'] ) && empty( $ids['raw_id'] ) ) {
82 - echo $this->render_all_blocks( $ids, $atts, $content ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built from the_content filter output and esc_*()-escaped pieces, see render_all_blocks().
83 - return (string) ob_get_clean();
84 - }
87 + try {
88 + if ( empty( $ids['block_id'] ) && empty( $ids['raw_id'] ) ) {
89 + echo $this->render_all_blocks( $ids, $atts, $content ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built from the_content filter output and esc_*()-escaped pieces, see render_all_blocks().
90 + return (string) ob_get_clean();
91 + }
85 92
86 - $block = $this->locate_block( $ids['post_id'], $ids['block_id'], $ids['raw_id'] );
93 + $block = $this->locate_block( $ids['post_id'], $ids['block_id'], $ids['raw_id'] );
87 94
88 - if ( ! empty( $block ) ) {
89 - echo $this->render_single_block( $block, $atts, $ids, $content ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- delegates to BlockRenderer::render_table_builder(), which escapes/kses's its own output.
95 + if ( ! empty( $block ) ) {
96 + echo $this->render_single_block( $block, $atts, $ids, $content ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- delegates to BlockRenderer::render_table_builder(), which escapes/kses's its own output.
97 + }
98 +
99 + return (string) ob_get_clean();
100 + } finally {
101 + $asset_generator->resume_late_css();
90 102 }
91 -
92 - return (string) ob_get_clean();
93 103 }
94 104
95 105 // -------------------------------------------------------------------------
96 106 // Multi-block rendering (no block_id given)