Support » Plugin: Code Snippets » Adding HTML, CSS, JavaScript and PHP Codes?

  • Gamicord

    (@gamicord)


    Hello Sir,
    I add PHP Code snippets in my Child Theme’s functions.php file. Then I use Simple Custom CSS and JS plugin to add CSS and JavaScript Code snippets.

    But I was wondering that, is there no plugin that can enable us do HTML, CSS, JavaScript and PHP Code snippets together in one single plugin?

    Then I was reading some articles online, and they seem to suggest that your Code Snippets plugin can let us do HTML, CSS, JavaScript and PHP Code snippets together in one plugin. Is this true?

    The reason why I’m asking and doubting that statement which says that your plugin can do HTML, CSS, JavaScript and PHP Code snippets together is because when I read your Description, you seem to be saying that your plugin can do only PHP Code snippets.

    1.) But is it true that you can also be used to do HTML, CSS, JavaScript and PHP Code snippets together in one?

    2.) If your Code Snippets plugin cannot be used to do HTML, CSS, JavaScript and PHP Code snippets together in one, do you know of any plugin with such capabilities?

    3.) If your Code Snippets plugin cannot be used to do HTML, CSS, JavaScript and PHP Code snippets together in one, can you consider adding such a capability to your Code Snippets plugin?

    Needing to hear from you soon.
    Regards.

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

    (@bungeshea)

    It can work with all of those snippet types. It’s true that the plugin only works with PHP snippets, in its current version, but the power of PHP snippets is you can use them to add CSS, JS and PHP code. When you install the plugin, there’ll be examples of each type for you to copy and modify for your purposes.

    Version 3 is in the works which will add support for HTML (content) snippets in the regular release, and special support for PHP and JS snippets in a pro version. This won’t take away from the current way of adding CSS and JS snippets; it will make it easier to add them and far more efficient to run them on your site.

    Thread Starter Gamicord

    (@gamicord)

    Thanks very much Sir, for your reply.

    The challenge is that many people who use WordPress are people who basically can’t code PHP, and just want a straight forward Drag-and-Drop system.

    Sadly I fall under such people, and to say that “the power of PHP snippets is you can use them to add CSS, JS and PHP code” means that — adding HTML, CSS and JavaScript Codes is not an Out-Of-The-Box default Feature of the plugin. I’m I correct?

    And I think it also means that to be able to add CSS and JavaScript Codes through PHP Code Snippets is an Advanced Feature. I’m I correct?

    So I’m saying that from your explanation, what I get is that–

    1.) adding HTML, CSS and JavaScript Codes is not an Out-Of-The-Box default Feature of the plugin, and,

    2.) To be able to add CSS and JavaScript Codes through PHP Code Snippets is an Advanced Feature.

    Are these my assumptions correct?

    3.) Could you answer a straight Yes or No if you can add HTML, CSS and JavaScript Codes out of the box with the plugin?

    What I mean for example is that, when you install the plugin called “SIMPLE CSS AND JS” you can actually specify which particular code you are about to add: whether it’s a CSS or JS Code before you start adding any Code.

    If you select CSS, it opens an Editor for CSS Code. If JS, it opens an Editor for JS Code.

    I’m asking that, do you have such Feature where we can specify which particular code we want to Add?

    Regards.

    Plugin Author Shea Bunge

    (@bungeshea)

    If you cannot code with PHP, I would recommend not using a plugin that directly involves adding code to your site. It is too easy to mess things up and cause a problem if you don’t have a basic understanding of what the code is doing.

    I’m not really sure if I would charactarise it as an advanced feature. It just involves adding some extra PHP code around the CSS or JS that tells WordPress where you want to put it.

    For example, if you wanted to add some CSS code to the each page of the site, you could do it like this:

    add_action( 'wp_head', function () { ?>
    <style>
    
    /* css code here */
    
    </style>
    <?php } );

    If you wanted to add some JavaScript code into the body (footer) section of each page, you would use something like this:

    add_action( 'wp_footer', function () { ?>
    <script>
    
    // js code here
    
    </script>
    <?php } );

    This is the extent of support for CSS and JS that is included in the current version of the plugin. Like I said, in version 3 pro, which we hope to release soon, we will be adding special modes for CSS, JS and Content (HTML) which will function like you describe.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.