post_content, '[code_snippet' ) ) { $found = true; break; } } if ( ! $found ) { return $posts; } $plugin = code_snippets(); wp_enqueue_style( 'code-snippets-prism', plugins_url( 'js/vendor/prism.css', $plugin->file ), array(), $plugin->version ); wp_enqueue_script( 'code-snippets-prism', plugins_url( 'js/vendor/prism.js', $plugin->file ), array(), $plugin->version, true ); return $posts; } function render_shortcode( $atts ) { $atts = shortcode_atts( array( 'id' => 0, 'network' => false, ), $atts, 'code_snippet' ); if ( ! $id = intval( $atts['id'] ) ) { return ''; } $network = $atts['network'] ? true : false; $snippet = get_snippet( $id, $network ); if ( ! trim( $snippet->code ) ) { return ''; } return '
' . esc_html( $snippet->code ) . '';
}
}