We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e8b72d6 commit 06874a6Copy full SHA for 06874a6
php/class-shortcode.php
@@ -46,15 +46,25 @@ function enqueue_prism( $posts ) {
46
47
function render_shortcode( $atts ) {
48
49
- if ( ! isset( $atts['id'] ) || ! intval( $atts['id'] ) ) {
+ $atts = shortcode_atts(
50
+ array(
51
+ 'id' => 0,
52
+ 'network' => false,
53
+ ),
54
+ $atts, 'code_snippet'
55
+ );
56
+
57
+ if ( ! $id = intval( $atts['id'] ) ) {
58
return '';
59
}
60
- $id = intval( $atts['id'] );
- $network = isset( $atts['network'] ) && $atts['network'] ? true : false;
-
61
+ $network = $atts['network'] ? true : false;
62
$snippet = get_snippet( $id, $network );
63
64
+ if ( ! trim( $snippet->code ) ) {
65
+ return '';
66
+ }
67
68
return '<pre><code class="language-php">' . esc_html( $snippet->code ) . '</code></pre>';
69
70
0 commit comments