samedi 21 mai 2016

Reuse html-code for posts via a plugin

So I wrote something in HTML, JavaScript and CSS for a post today and it's very likely that I'll need this code quite often and now I want to write a plugin to ease my work and have valid code (what I wrote is actually not valid: style-tag in the body, etc.).

My goals for the plugings are:

  • What I write in a post:
    if possible: <foo><bar>Headline</bar><boo>Text</boo></foo>
    good enough: <a onclick="foo('Headline', 'Text');">
    (both should actually perform the second statement)

  • What the plugin should do(frontend):

    1. load my JS and CSS files
    2. insert a code snippet at the top in the <div class="entry-content"> and maybe even add a random id to the div
    3. the code should not be visible in the backend
    4. only do 1. and 2. if I wrote the statement in the post

To me it sounds quite simple, but tbh. I don't know much about coding in PHP or coding WP-Plugins, I started to read me up on these subjects, but I don't understand them (the required PHP knowledge is too far) ...yeah I know that's a good premise for writing a plugin! :o

It would be awsome if someone could help me writing my own plugin!

Greets, MasterBolle



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire