InScript

Jun 5, 2005 | Tags: , , , , , | Written by John

InScript is an extensible scripting framework that provides the capability to insert and modify data without needing to modify any WordPress files.

At the simplest level, it is a generic pattern matcher – it searches for specific patterns, or tags, and replaces them with something else. However, instead of replacing these patterns with static text, you can replace them with variables, functions, and even PHP code.

Some of the features that InScript provides are:

  • Dynamic variables, which can be used in many places and are automatically updated (the version and last updated details above are dynamic variables)
  • Disable WordPress texturize functions across the whole blog, individual posts, or even individual words
  • Conversely, enable texturize, textile, markdown, or any formatting on individual posts or words
  • Embed well-defined scripts inside posts and any other part of WordPress, without modifying the theme

The embedded scripts are very powerful, and allow you to do things like:

  • Insert post & author information
  • Add HTTP meta-values and make them post-specific
  • Customise the appearance of words, paragraphs, or posts
  • Change date formats on individual sections
  • Insert highlighted code
  • Insert custom PHP code
  • Add custom stylesheets for specific posts

Because of the extensible nature of the plugin, you can add ‘scriptlets’ (mini-plugins) that provide extra features and yet use the same InScript framework.

Here are the current scriptlets:

  • rss-link-list.zip - embed RSS feeds in conjunction with the rssLinkList plugin (which must be installed and enabled)
  • pinyin-converter.zip - Pinyin converter allows Chinese pinyin to be inserted in the form zhong1guo2 and converted to the correct tonal version of %%lang_pinyin [text=zhong1guo2]%%

Note: install scriptlets into the /wp-content/plugins/inscript/scripts directory.

No really, what does it do?

The best way to explain what InScript does is by providing examples. Note that these examples are provided 'live' by InScript.

Example 1 – Code highlighting

Often you want to highlight some code within a post. This creates several problems:

  • Code uses special characters that interfere with HTML
  • WordPress mangles a lot of the characters
  • It’s a chore to color the code by hand

We can insert an InScript tag to do all this for us.

%%format_highlight [file=/wp-feed.php] [wp=off]%%

And this produces:

%%format_highlight [file=/wp-feed.php] [wp=off]%%

Example 2 – Blog title & description

Notice anything special about the title of this page? No? Okay, go and look at it again. Yes, that's right, it's different from the rest of the blog. This is because of these two custom fields:

inscript_option_blogdescription = Now with added plugin goodness!
inscript_option_blogname = SuburbanGiraffe

More fun

Of course, all of these are simplistic examples. Separate plugins already exist to achieve many of the functions described here. The point is that InScript gives you the ability to perform these functions anywhere in your blog, using just one syntax and one plugin. Additionally, you can customise the output exactly as you want, using a wider range of functions. You can cook up all sorts of madness – now, who’s for colour-highlighted code in their title?

Before I finish, here are some more live functions:

  • Word shuffle - %%str_shuffle [text=my old man is a dustman and he likes giraffes]%%
  • Reverse - %%str_reverse [text=hello world and welcome to my plugin]%%
  • Rot13 - %%str_rot13 [text=hello world and welcome to my plugin]%%
  • Leet - %%str_leet [text=hello world and welcome to my plugin]%%
  • Email obsfucator - %%str_obscure_email [email=test.email@example.com]%%
  • System info - %%system_os%% %%system_release%% %%system_version%% %%system_machine%%
  • Time since - this page was created (as opposed to %%post_date%%)
  • PHP version - %%php_version%%
  • HTTP agent - your browser is %%http_agent%%
  • WordPress version - %%blog_version%%

And here's the WordPress calendar function embedded into a post:

%%wp_getcalendar%%
Share This

Comments (page 5 of 11)

  1. John (author) :

    Nov 3, 2005 7:28 am

    I've included your changes into InScript 1.7. Thanks!

  2. Jeena Paradies :

    Nov 2, 2005 2:50 am

    John, it seems to be the default setting on gentoos PHP >= 4.4 duno why. I've changed a little bit the behaviour, I think this version makes more sense:


    // enable the ctype_al[somethin]() functions if they are disabled
    if(!function_exists('ctype_alpha')){
    function ctype_alpha($string){
    return preg_match('/^[a-z]*$/i', $string);
    }
    }
    if(!function_exists('ctype_alnum')){
    function ctype_alnum($string){
    return preg_match('/^[a-z0-9]*$/i', $string);
    }
    }

  3. Martin Ralya :

    Nov 1, 2005 2:07 pm

    John: Thanks for getting back to me -- I'll give that a shot. :)

  4. John (author) :

    Nov 1, 2005 1:45 pm

    Thanks for the tip Jeena, I'll include that in the next version so no one else experiences the problem. It's bizarre that someone would purposefully disable ctype functions on a webhost!

  5. John (author) :

    Nov 1, 2005 1:41 pm

    Martin: The best way to use google_adsense is to create an InScript variable that contains all of your AdSense code. So, for example, you could create a variable called 'google_code'. Then in your post you can insert: %%google_adsense [code=!!google_code!!]%% (the !! indicates it is an InScript variable).

    This menthod ensures that WordPress does not try to reformat your code before it is saved, and before InScript even has chance to look at it.

  6. Jeena Paradies :

    Nov 1, 2005 1:08 pm

    Yea I got it working. My PHP was compiled with --disable-ctype so I had to workaround this. I added this two functions on the top of the plugin (after the licence text):


    // enable the ctype_al$something() functions if they are disabled
    if(!function_exists('ctype_alpha')){ function ctype_alpha($sring){ return !preg_match('([^a-zA-Z])', $string); } }
    if(!function_exists('ctype_alnum')){ function ctype_alnum($sring){ return !preg_match('([^a-zA-Z0-9])', $string); } }

    And now it works perfectly! Thanks for this great plugin!

  7. Jeena Paradies :

    Nov 1, 2005 5:12 am

    Hi,

    I'm trying to install your plugin on my WordPress installation because it seems the perfect way to turn off WordPress' textuize functions in a single page, where I want to post some Google Maps sourcecode within WordPress.

    I've downloaded it, unzipped and uploaded into my plugin directory on the server. I've activated it in the plugins section within the admin interface on my WordPress blog. I've made a new page and postet %%php_version%% on it. I opened this page in my browser and see a page with the text %%php_version%% and not the PHP versionnumber. What did I wrong? Can you help me? I've read the manual three times but couldn't find a solution.

  8. Asagai :

    Oct 31, 2005 6:33 am

    Been looking for somthing like this for a while, going to go fire up my blog and give it a test run immediately..

    Thanks

  9. Martin Ralya :

    Oct 26, 2005 1:04 pm

    Did you get my email, John? (I sent it via your contact form.)

  10. Martin Ralya :

    Oct 25, 2005 12:28 pm

    John: %%system%% worked just fine. It sounded like you'd prefer an email to another comment, so I've gone that route. Thanks for getting back to me so quickly! :)

Leave a comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Home | Software | Terms & Conditions | Sitemap | John Godley © 2008
Close
E-mail It