JavaScript Logic is a plugin that allows you to add JavaScript however you want. There's no need to add a script on all of your blog's pages when you only need it on a few.
By using WordPress conditional tags or through a meta box on the Write Post/Page screen, you control what files are added to your site and when.
javascript-logic.zip folder.javascript-logic folder to your /wp-content/plugins directory.Once you've activated the plugin, you have two choice of how to add JavaScript:
Go to the JavaScript Logic page located under Appearance (maybe Themes or Design, depending on what WP version you're using). You can have site-wide control over when JavaScript is loaded from this page.
There are 10 JavaScript Sets altogether. You can add up to three different scripts to each set. I'll walk you through what each setting means here.
/javascript-loader/js.<?php and ?> tags. If nothing is input, your JavaScript will load on every page (see examples below).Here's an example of Script Logic that loads a set on the home page.
is_home()
An example of loading scripts on the About page or a post with the ID of 205.
is_page('about') || is_single(205)
How about we get a little more complicated? Let's check for single posts with the tag of Gallery, the category archive WordPress, or all search results pages.
has_tag('gallery') || is_category('wordpress') || is_search()
Okay, that wasn't really complicated. WordPress conditional tags are actually quite simple to use.
This plugin will also provide you with an additional meta box on the Write Post and Page screens. It's clearly labeled JavaScript Logic Settings.
This will allow you to load JavaScript on a per-post or per-page basis. It's great because it gives you control right when you're writing a post/page, but it's somewhat limiting because you can't add as many scripts as you can from the plugin settings page.
There are three boxes. Anything you select or input will be automatically loaded on that particular single post or page view.
/javascript-loader/js.I run a WordPress community called Theme Hybrid, which is where I fully support all of my WordPress projects, including plugins. You can sign up for an account to get plugin support for a small yearly fee ($25 USD at the time of writing).
I know. I know. You might not want to pay for support, but just consider it a donation to the project. I am fully employed through my work with WordPress, so to continue making cool, GPL-licensed plugins and having the time to support them, I must pay the bills.
JavaScript Logic is licensed under the GNU General Public License, version 2 (GPL).
This plugin is copyrighted to Justin Tadlock.
2008 © Justin Tadlock