PluginProbe
Code Snippets / 3.10.0
Code Snippets v3.10.0
3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 3.0.1 All 64 releases
code-snippets / php / Utils / Code_Highlighter.php

Code_Highlighter.php in Code Snippets 3.10.0, at php/Utils/Code_Highlighter.php

55 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Code_Snippets\Utils;
4
5 use const Code_Snippets\PLUGIN_FILE;
6 use const Code_Snippets\PLUGIN_VERSION;
7
8 /**
9 * This class handles the integration of the PrismJS syntax highlighter.
10 *
11 * @package Code_Snippets
12 */
13 class Code_Highlighter {
14
15 /**
16 * Handle to use for the PrismJS library.
17 */
18 public const PRISM_HANDLE = 'code-snippets-prism';
19
20 /**
21 * Enqueue the styles and scripts for the Prism syntax highlighter.
22 *
23 * @return void
24 */
25 public static function register_prism_assets() {
26 wp_register_script(
27 self::PRISM_HANDLE,
28 plugins_url( 'dist/prism.js', PLUGIN_FILE ),
29 [],
30 PLUGIN_VERSION,
31 [ 'in_footer' => true ]
32 );
33
34 wp_register_style(
35 self::PRISM_HANDLE,
36 plugins_url( 'dist/prism.css', PLUGIN_FILE ),
37 [],
38 PLUGIN_VERSION
39 );
40 }
41
42
43 /**
44 * Enqueue all available Prism themes.
45 *
46 * @return void
47 */
48 public static function enqueue_all_prism_themes() {
49 self::register_prism_assets();
50
51 wp_enqueue_style( self::PRISM_HANDLE );
52 wp_enqueue_script( self::PRISM_HANDLE );
53 }
54 }
55