| Plugin Name: | Quick Code |
| Version: | 0.95 |
| Plugin URI: | http://blog.netnerds.net/quickcode/ |
| Author: | Chrissy LeMaire |
| Last Updated: | 12/13/06 |
| Download: | [ zip ] | [ view source (.phps) and quickcode.gif ] |
| Description: | Transforms any code (SQL, CSS, PHP, ASP, etc) between <quickcode> and </quickcode> into a good looking div which can disappear or reappear with a click. |
| =>> Use this in conjunction with an older version of coffee2code's awesome Preserve Code Formatting plugin archived here. Also, thanks to NetLobo for the div hiding code.
<<=
EXAMPLES:
1. Quick Code
<?php
function includeit($text)
{
$temptext=" ".$text;
if ((strpos($temptext,":includeit:"))>0)
{
$includethis=str_replace(":includeit:","",$text);
$includethis=trim(str_replace(":","",$includethis));
include("/nn/includes/".$includethis);
}
else
{
return trim($text);
}
}
add_filter('the_content', 'includeit',9);
?>
2. You Can Also Have a Custom Title
<style type='text/css'>
a.quickcode {
padding-left: 20px;
background: url('/wp-includes/images/quickcode.gif') no-repeat;
}
</style>
3. <?php print "Or you can just make it auto-expand by default"; ?>
|
|
Installation |
| 1. | Download and extract the quickcode.zip into your /wp-content/plugins/ directory. There are several ways to do this, here is one option:
open a shell, cd into your /wp-content/plugins/ directory and execute the following command(s):
curl -o quickcode.zip http://blog.netnerds.net/code/quickcode.zip && unzip quickcode.zip && rm quickcode.zip
|
| 2. | Activate the plugin from your WordPress admin 'Plugins' page.
|
| 3. | Make sure you have downloaded and activated the older/archived version of coffee2code's awesome Preserve Code Formatting plugin. Otherwise, your code may not appear.
|
| 4. | Place your code between the <quickcode>  tag. You can do this three ways: a. <quickcode>Some code</quickcode> b. <quickcode:Place Custom Title Here>Some code</quickcode> c. <quickcode:noclick>Some code</quickcode> d. In the event that your Wordpress editor tears out <quickcode></quickcode>, can also use brackets instead of carrots. ie. [quickcode]Some code[/quickcode].
|
| 5. | Use an editor other than the default Wordpress editor. I don't know if other people encounter this but, for me, Wordpress tears out tags it doesn't recognize. Drives me crazy! But I ended up finding a much better Windows desktop based editor anyway called w.bloggar. Very fast, easy and it works well. Linux or MacOS X users can find alternative desktop blogging tools here. If you are set on using the web interface, you can try using brackets instead of carrots as shown above.
|
|
What It Does: |
| 1. | quickcode_add_options_page() adds a Quickcode section to your Admin->Options page. Use this page to set whether you'd like your code to be auto-expanded in Single Posts. It is set to Yes by default.
|
| 2. | pretty_code_quick() replaces the <quickcode> text with pretty divs. It then extracts the title, if any, and adds it as the text to the hyperlink. If the parsed title is "noclick", it replaces the pretty divs with differnet divs to auto-expand the block of code.
|
| 3. | pretty_code_converter_jscss() adds the Javascript and CSS links to the head. The code is not embedded. This is important -- search engines may penalize "hidden" code and may not process it if you include the CSS within the head of the main page. Just keep it linked and you should be fine.
|
|
Optional Customizations: |
| 1. | Default link text. It is currently "Quick Code." Change this variable: $codeTitle="Quick Code";
|
| 2. | In the CSS section, you can change the background color and default text.
|
| 3. | You can also change the type of CSS overflow style you'd like. Currently, it is set only to scroll horizontally (when necessary)
|
| 4. | You can change the priority for this script, it is currently at the highest priority (0). Just make sure it has a higher priority than coffee2code's preserve-code-formatting script.
|
|
Notes |
| 1. | If my code is silly looking its because I'm not a native PHP coder. I just wrote up the code in ASP and used asp2php.exe to transform.
|
| 2. | This script works with Firefox and IE. The ordering of the CSS elements overflow-y and overflow is important for cross-browser compatibility. Leave it as is.
|
|
Bugs |
| 1. | I've only noticed one -- do not use the quickcode tag as the very first thing in your post or your formatting will mess up. I'll fix this soon.
|
Tips & Examples
1. The default output
<quickcode>
<style type='text/css'>
a.quickcode {
padding-left: 20px;
background: url('/wp-includes/images/quickcode.gif') no-repeat;
}
</style>
</quickcode>
Produces the following:
Quick Code
<style type='text/css'>
a.quickcode {
padding-left: 20px;
background: url('/wp-includes/images/quickcode.gif') no-repeat;
}
</style>
2. Custom Title
<quickcode:Custom Title>
<style type='text/css'>
a.quickcode {
padding-left: 20px;
background: url('/wp-includes/images/quickcode.gif') no-repeat;
}
</style>
</quickcode>
Produces the following:
Custom Title
<style type='text/css'>
a.quickcode {
padding-left: 20px;
background: url('/wp-includes/images/quickcode.gif') no-repeat;
}
</style>
3. Just an extra.. no hiding.
<quickcode:noclick>
<style type='text/css'>
a.quickcode {
padding-left: 20px;
background: url('/wp-includes/images/quickcode.gif') no-repeat;
}
</style>
</quickcode>
Produces the following:
<style type='text/css'>
a.quickcode {
padding-left: 20px;
background: url('/wp-includes/images/quickcode.gif') no-repeat;
}
</style>
Release Log:
* 13 Dec 2006 : v0.95 - Added a value for overflow-x to stop IE's truncation of the code.
* 18 May 2006 : v0.94 - Added image to auto expanded single links. Removed titles in single links if title is "noclick" or "Quick Code".
* 15 May 2006 : v0.93 - Added support for brackets for people who want to use the built-in Wordpress editor
* 11 May 2006 : v0.92 - Added title and line break to auto-expanded code in single posts.
* 28 Apr 2006 : v0.91 - Added Control Panel support to auto-expand code in single posts. Consolidated all the files into one directory.
* 20 Apr 2006 : v0.9 - Released to the public
Copyright & Disclaimer:
Copyright (c) 2006 by Chrissy LeMaire
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.