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 3 of 11)

  1. emilio :

    Aug 23, 2005 7:25 pm

    Hello. First of all I should say that your plugin is great!! Thank you for creating it. I am starting to use it in my weblog. It's a powerful tool.
    In second instance, I think I have found one typing error in the post.php file, line 134 in the function "post_coment"
    this is:

    return inscript_post_helpoer ("content", $args);

    I tried to use that function, then I found the error and I "fixed" it. But my blog crashes with message:

    Fatal error: Cannot redeclare inscript_post_get() (previously declared in /home/emilio/public_html/wordpress/wp-content/plugins/inscript/post.php.ori:3) in /home/emilio/public_html/wordpress/wp-content/plugins/inscript/post.php~ on line 3
    Fortunately I had a recent backup, and reinstalled inscript. Everything is right now.
    It is a little error, but the consequences ... :-)
    Thank you again
    PD: My english is not good. Well you saw it!

  2. Chris :

    Aug 18, 2005 12:19 pm

    Works like a champ!!! Thanks John.

  3. John (author) :

    Aug 18, 2005 11:24 am

    Try %%rsslink [rss_feed_url=http://news.com.com/2547-1_3-0-5.xml] [num_items=3]%%

    I hadn't realized there are no docs for the function!

  4. Chris :

    Aug 17, 2005 8:11 pm

    Okay, I enabled the "hook" and how, I get this:

    http://www.uberwerks.org/test/

    I'm using this as the code:

    '%%_rssLinkList [rss_feed_url=http://news.com.com/2547-1_3-0-5.xml] [num_items=3]%%'

    I've also tried this:

    '%%rssLinkList [rss_feed_url=http://news.com.com/2547-1_3-0-5.xml] [num_items=3]%%'

    I'm not sure what else to do. The rssLinkList plugin is activated?! He has version 0.9 out, do you think your scriptlet needs updating or am I just doing something wrong?

  5. John (author) :

    Aug 17, 2005 12:30 pm

    Hi Chris,

    It doesn't look like InScript is enabled for that page. Check that the plugin is activated and that in the InScript options you have hooked the filter 'the_content'. If these are both ok then try a really simple InScript command like:

    %%php_version%%

    If you get a version number then InScript is enabled and there's some problem with the rsslinklist command in the post. If you just see %%php_version%% then InScript isn't enabled.

    Let me know how it goes.

  6. Chris :

    Aug 17, 2005 10:57 am

    John,

    I have downloaded your InScript plugin with the rssLinkList scriptlet and I cannot seem to get it to work. I have installed the seperate rssLinkList plugin from rawlinson.us, but as you can see, it doesn't work:

    http://www.uberwerks.org/test/

    Any thoughts? Thank you.

  7. Another John :

    Jul 24, 2005 6:31 am

    John, thanks for the info, but right after I posted the comment my brain kicked in and I managed to work things out.

    Thanks for the great plugin!

  8. N. Mallory :

    Jul 9, 2005 8:17 am

    OK Well, that does not work very well with the_excerpt_reloaded() which is what I use on my main page...and it didn't appear to do anything on the actual post pages. The code is showing up outside of the_content formatting and I'd like it to appear just inside the first ''.

    So, I guess what I'm trying to do is prepend the code to the beginning of the post before the format filters have their way...but I still want the formatting too.

  9. John (author) :

    Jul 9, 2005 6:36 am

    N. Mallory:

    Yes, you should be able to do that using a global keyword. From the Inscript options page, create a new global keyword called 'the_content' and set it to something like this:

    %%echo [text=%2]%%<div>the code for adsense</div>

    The first part is a little bit of inscript to 'echo' the content (very important!), and then the rest is your adsense code.

    Let me know if that does the trick. It may actually make an interesting candidate for an inscript function

  10. John (author) :

    Jul 9, 2005 6:25 am

    John:

    Think of the Inscript tags just like any other HTML tags. For example, if you wanted to make some text bold in HTML, you would wrap the text inside the <strong> tag: <strong>text</strong>

    The same applies for Inscript. In the case of example 1, the text is wrapped inside an inscript tag, with the function changing from Textile to Markdown.

    This calls the function 'echo' and turns off the default WordPress texturizing:
    <inscript func="echo" text="%1" wp="off">
    text
    </inscript>

    This applies the function 'format_textile' to the text, while also turning off the default texturizing:

    <inscript func="format_textile" text="%1" wp="off">
    text
    </inscript>

    This applies Markdown to the text, while also turning of the texturizing:

    <inscript func="format_markdown" text="%1" wp="off">
    text
    </inscript>

    Note the use of the special %1. This is replaced by whatever is inside the body of the inscript tag. In the examples above, that would be 'text'.

    Hope that helps.

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