Add a new 'theme' to SyntaxHighlighter Evolved

Since 2016 I no longer make use of SyntaxHighlighter Evolved. I use WP-SynHighlight instead.

To publish code on my site I use the WordPress plugin SyntaxHighlighter Evolved. On the website of the author is described how to add a new theme to the plugin. If you follow the instructions it will work out fine. Only one small detail, wordpress will generate an error notice. If you have wp-debug on this will be visible: Notice: wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks.

Simply put this is caused because the codes starts to early. By wrapping it in a function this is solved:

1 2 3 4 56 7 8 9 
function yoursyntheme_enqueue_styles() { // Prevent: Notice: wp_enqueue_style was called incorrectly.       wp_register_style(         'syntaxhighlighter-theme-yoursyntheme',         content_url( 'path/to/your/theme.css' ),        array( 'syntaxhighlighter-core' ),         '1.2.3' // A version number. It doesn’t matter what you set it to, it’s for browser cache busting     ); }

Now that the stylesheet has been registered we need to inform the SyntaxHighlighter plugin about it:

10 11 12 13 1415 16 
add_filter( 'syntaxhighlighter_themes', 'your_function_name_here' );   function your_function_name_here( $themes ) {    $themes['yoursyntheme'] = 'The Name Of Your Theme';  return $themes;  }

And likes this everything works without any error, just like we wanted. The theme that I created myself for this site is available for download. You could use this as is, or as a starting point for your own theme. Have fun!

  • I apologize for my poor English. I should have paid more attention in school...
    If there are any huge mistakes please inform me
  • I've never studied C, Javascript or PHP. Everything I know is learned via youtube and google.
    I realize my code is often unnecessarily long, but I prefer writing it this way so I can still understand myself later on. If there are other mistakes please let me know.