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

  1. N. Mallory :

    Jul 8, 2005 7:04 pm

    Hi!

    This looks fabu and it looks like just what I was looking for, I think... ;)

    I want to drop my adsense code placed in a div into the_content() of every post. I think that means I would use a global variable, but I'm not sure what it would be and I'm not even sure that's really possible. Please help. :)

    TIA!

  2. author
    Another John :

    Jul 8, 2005 2:28 pm

    Ok, I'm stumped. I still don't understand how "Example 1." is generated rvrn after reading through all the documentation. Please enlighten me. Step by step if possible, since I have limited brain capacity. Thanks!

  3. author
    Rob :

    Jul 5, 2005 11:52 am

    Worked for me! Great stuff!

  4. John (author) :

    Jul 3, 2005 6:15 am

    Hmm, very strange - a stupid typing error that should have broken it on my own website, but somehow slipped through.

    Anyway, version 1.4 fixes the problem. Thanks for the info, Rob!

  5. author
    Rob :

    Jul 3, 2005 5:51 am

    I get the following error when I enable Inscript, ([full path] removed for brevity)

    Fatal error: Call to undefined function: get_filters() in [full path]/wp-content/plugins/inscript.php on line 384

    This happens on every page, I have to rename the inscript plugin file to get my site back. I've chmodded the inscript directory to 777 but no luck so far.

    Any ideas what's going on?

  6. Geoff :

    Jul 1, 2005 2:07 pm

    An incredible plugin, John. Great work.

  7. Andreas :

    Jun 27, 2005 4:04 pm

    This is amazing... Great work! =)

  8. John (author) :

    Jun 23, 2005 3:31 am

    Ok, found that the problem was caused by the PHP configuration setting 'magic_quotes_gpc' - if this was set then PHP would automatically escape all quotes, and InScript would then escape them again. This has been fixed and version 1.1 released.

  9. Alderete :

    Jun 22, 2005 12:53 am

    I'm having a small problem with global keywords. It seems that when I add them, they get escaped. This is mostly happening on quotation marks. And, when I Update Options again, it gets escaped again, leading to stuff like: \\\" in the fields.

    Once escaped, it seems to be fouling up the evaluation of the commands. So instead of being able to add e.g. meta keywords to my wp_head, it is just dumping the raw text of the global keyword field.

    This would be OK, I could just put the raw meta tag there, but *that* gets escaped, too, so it's invalid.

    I am using WordPress 1.5.1.2 with MySQL 3.23.49 and PHP 4.3.10.

    Anything else I should include to track this down, e.g., php.ini settings and such?

    Thanks!

  10. Chris :

    Jun 19, 2005 8:21 pm

    Oops...

    I meant: "Therefore, this should read:

    %%rsslink [rss_feed_url=http://someplace.com/feed.xml] [num_items=3]%%"

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