Posts for: December 8th, 2010

I Am Number Four is directed by American filmmaker D.J. Caruso, of The Salton Sea, Taking Lives, Two for the Money, Disturbia and Eagle Eye most recently. The screenplay was co-written by writing partners Alfred Gough and Miles Millar (Lethal Weapon 4, Shanghai Knights, Spider-Man 2, Herbie Fully Loaded, “Smallville”) and is based on James Frey & Jobie Hughes‘ novel of the same name that just hit bookshelves. DreamWorks is producing and Disney is bringing I Am Number Four to theaters on February 18th, 2011.

Переводить не буду, т.к. в основном это как памятка для себя… :smoking:

There are a lot of tutorials available for editing the quicktags.js file in the WordPress wp-includes folder, but they all seem to want you to edit the file directly. That’s a Bad Idea because the next time you upgrade, your changes are kaput. [...] There are some perfectly capable plugins for adding new buttons, too. [...]

The quicktags.js file

1. Go into the /wp-includes/js folder and find quicktags.dev.js. Copy it to your template folder (or any subfolder) and rename it quicktags.js.

2. Edit the file. The code has some localization in it which we’re about to break, so search for quicktagsL10n and replace every instance with an appropriate, quoted string.

For example:
prompt(quicktagsL10n.enterURL, defaultValue);

Should be something like:
prompt('Enter the URL', defaultValue);

Overriding the original

Now we just need to change which script gets called when you’re in the post editor. Add the following to your theme’s functions.php file:

function bt_load_admin_scripts() {
  if ( is_admin() ) {
    wp_deregister_script('quicktags');
    wp_register_script('quicktags', ("/path/to/your/quicktags.js"), false, '', true);
  }
}
if (is_admin()) {
  add_action('init', bt_load_admin_scripts);
}

Modify the path in wp_register_script to point to the location where you put your quicktags.js file. This will tell WordPress to load your file instead of its own.

Now, edit a new post (in the HTML editor, not the Visual editor) to test out your changes. If everything is correct, modified and new buttons should show up and function the way you want. Your changes will persist, even after a WordPress upgrade!

© BrettTerpstra.com

Comment and Win a Userpic!

Recommended Stuff

This is a random selection from a list of stuff/posts I personally enjoyed a lot. Some sort of "My Favorites" or "Bookmarks"...

  • Johnny Depp – Julian Schnabel Shoot
  • Agyness Deyn by Mert & Marcu
  • How Star Wars (Episode IV) Should Have Ended
  • Miranda Kerr
Bookmark and Share