Cyber Week Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

[Resolved] How to manually install Highlight.js?

Home Forums Support How to manually install Highlight.js?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #399554
    Marthur

    Morning,

    What would be the best method of manually installing highlight.js in WordPress? I reviewed the instructions, but wanted to know if there is a way to do this via the child theme’s functions.php file.

    My child theme’s functions.php file currently looks like:

    <?php
    /**
     * GeneratePress child theme functions and definitions.
     *
     * Add your custom PHP in this file. 
     * Only edit this file if you have direct access to it on your server (to fix errors if they happen).
     */
    
    function generatepress_child_enqueue_scripts() {
    	if ( is_rtl() ) {
    		wp_enqueue_style( 'generatepress-rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' );
    	}
    }
    add_action( 'wp_enqueue_scripts', 'generatepress_child_enqueue_scripts', 100 );
    add_filter('widget_text', 'do_shortcode');
    add_filter('jpeg_quality', function($arg){return 100;});
    ?>
    GeneratePress 1.4
    GP Premium 1.4.3
    #399581
    Marthur

    Nevermind, I figured it out.

    1. Uploaded necessary files to site (CSS and JS files).
    2. Using GP Hooks, added the following to wp_head:

    <link rel="stylesheet" href="/path/to/styles/default.css">
    <script src="/path/to/highlight.pack.js"></script>
    <script>hljs.initHighlightingOnLoad();</script>
    #399584
    Tom
    Lead Developer
    Lead Developer
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.