• Resolved rafieek

    (@rafieek)


    Can Code Snippets include HTML, CSS, and Javascript in addition to PHP?

Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    It sure can! You will still need to add the snippets as PHP snippets, with a wrapper function around the CSS, HTML or JavaScript code.

    HTML example (using a shortcode):

    add_shortcode( 'my_content', funcition () { ?>
    
    <p>Insert your HTML code here!</p>
    
    <?php } );

    CSS example:

    add_action( 'wp_head', function () { ?>	
    <style>
    
    /* CSS code goes here */
    
    body {
        background-color: midnightblue;
    }
    
    </style>
    <?php } );

    JavaScript example:

    
    add_action( 'wp_head', function () { ?>	
    <script>
    
    /* JavaScript code goes here */
    
    alert('hello!');
    
    </script>
    <?php } );

    I would like to add better support for adding different sorts of snippets in a future version of the plugin, but for now these wrapper functions are a good alternative.

Viewing 1 replies (of 1 total)

The topic ‘HTML/CSS/Javascript Support?’ is closed to new replies.