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

  1. author
    jon :

    Oct 25, 2005 12:13 pm

    john: thanks for the response, and the advice!

  2. John (author) :

    Oct 25, 2005 11:52 am

    Martin: Are other Inscript functions working correctly? For example, if you enter %%system%% into the post does it display some details about your webhost, or %%system%%? If that is working correctly then can you send me the text from your post? (the text stored inside WordPress, not the text that is displayed)

  3. John (author) :

    Oct 25, 2005 11:46 am

    Jon: I'm not sure I understand you correctly - you want it so that when you log into vbulletin, you are also logged into WordPress? If this is the case then you'll need to do it from within vbulletin itself, and 'chain' the login to WordPress. You should never trust the data being sent back to you as it is very easy to fake, and this includes any hidden values.

  4. Martin Ralya :

    Oct 25, 2005 11:15 am

    I've been trying to show AdSense blocks in my posts, and I'd like to do so without shutting off autop and texturize for the whole site. So far, no other plugin has worked for me (including adsense.php and Adsense Deluze) -- InScript looks like what I need.

    Except that it doesn't work for me either. ;) I think I must be doing something wrong. Here's what I'm doing:

    1. I've turned on "hook to post content."
    2. Where I want an ad, I've inserted a short function for google_adsense, and plugged in my code.

    When I save the post, the ad doesn't display. If I view the source, I find it in there -- but it still has the br tags that WP has automatically inserted, even though the google_adsense function should be skipping those. Even if I manually add a 'wp="off"' to the function, it still doesn't work.

    What am I missing? (And thanks in advance for your help!)

  5. author
    jon :

    Oct 24, 2005 9:26 am

    hi john,

    inscript looks pretty powerful! i'm not sure if it will help me do what i initially looked into it for though? i'd like to take my vbulletin forum login and insert it onto my wordpress page (which i think is possible even without inscript) and then if the vb user is logged in use inscript to automatically insert their vb username into the comment form's name field (as a hidden value); if a vb user is not logged in then it would just show "guest" in the comment form's name field. this way if they log into the forums they are simultaneously logged into the wordpress commenting system as well. hope that makes sense! (and moreso, hope it's possible!)

    thanks

  6. John (author) :

    Oct 3, 2005 11:24 am

    Could you send me an example of the strange effect?

    It may sound a stupid question, but did you hook the comment notification message? There's no way for Inscript to hook things unless told to do so, and so it shouldnt be possible for it to be causing wierd things like sending emails to random people.

  7. damselfly :

    Sep 24, 2005 3:19 am

    Hi John, sorry to contact you when you're enjoying Oslo. Just wanted to let you know InScript doesn't seem to play nice with a couple of my other plugins -- in particular it seems to have a strange effect on Miniblog - it seems to interfere with the way the miniblog entries are called. Also (more worryingly), my blog started sending comment notifications to the wrong email address. So I've uninstalled for the time being. Any ideas on what might be going wrong (when you have time)?

  8. author
    Ismaelj :

    Aug 31, 2005 4:49 pm

    When using formating declared like

    ...

    it worls OK... as long as you don't declare it again! I mean you can't format_geshi more than once, at least in my installation. I looked at your code and found a solution: in formatting.php, line 43, replace

    include (dirname (__FILE__).DIRECTORY_SEPARATOR."geshi/geshi.php");

    for

    include_once (dirname (__FILE__).DIRECTORY_SEPARATOR."geshi/geshi.php");

    and everithing works right now!

    Keep on making it better!

  9. John (author) :

    Aug 24, 2005 10:52 am

    Now fixed in 1.6! You solution was correct, and the error was just caused because you had a backup file in the directory which redefined the same functions as the original.

  10. emilio :

    Aug 23, 2005 8:42 pm

    Sorry, but the problem persist. I can't use post_coment function. When I fixed the wrong word "helpoer" for "helper" my weblog crashes again whit the same message:
    Fatal error: Cannot redeclare inscript_post_get() (previously declared in /home/emilio/public_html/wordpress/wp-content/plugins/inscript/post.php:3) in /home/emilio/public_html/wordpress/wp-content/plugins/inscript/post.php~ on line 3
    I have had than replace inscript directory with the new one from the zip.
    Then my blog comes to live again. The anothers tags from inscript that I have used work good. How can I fix the problem?
    Thank you

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