Category: Code/Archives

Notes about coding: PHP, HTML, CSS, JavaScript, WordPress, etc.

Safe and Secure

Badbot, part of Popbot Universe by ThreeA Production

Christian Szell: Is it safe?
Babe: Yes, it’s safe, it’s very safe, it’s so safe you wouldn’t believe it.
Christian Szell: Is it safe?
Babe: No. It’s not safe, it’s… very dangerous, be careful.
—Laurence Olivier and Dustin Hoffman in “Marathon Man”

Upfront, you need to know: You’re not safe; you’re not secure. Running a website is an inherently insecure operation. However, you can radically reduce your risk.

Much has been written about web and WordPress security. If you’re responsible for a website and have read none of it, your site is probably insecure. It’ll stay that way until you take your security responsibilities seriously.

Rather than repeat the volumes of excellent advice, we’ll link to some of the best sources, and briefly recap the basics. The following is (as is often the case at Transom) WordPress-centric. More…

WordPress Unplugged

Website owners often go WordPress plugin crazy. Plugins do so much, so quickly, so easily — from adding image galleries to keeping your site more secure. But plugins can cause WordPress woes: different plugs may not play well together, or, when not updated, may behave weirdly with recent WordPress versions.

So how do you know if a plugin is A-OK or D.O.A.? Glad you asked. When evaluating a WordPress plugin, Transom poses these questions: More…

Playtagger- Mod

The Delicious Playtagger seems to be gone, for now, maybe forever– possibly due to Yahoo! revisions to the Delicious service. Here’s a quick fix (version 0.1; check back: will write a better one later): playtagger_mod.zip

This uses the same Delicious audio player (playtagger.swf) and images (stop.gif, play.gif), with a revised JavaScript (playtagger_mod.js). It lets you store the files locally. (Also adds a class to the image: “mp3” for CSS styling, courtesey Consuming Experience. Plus you could create your own play/stop icons.).

To get ‘er goin’:

  1. Unzip playtagger_mod.zip and upload to your site the folder: playtagger_mod
  2. In the file: playtagger_mod.js.
  3. Change the variable at the top: playtagger_url.
  4. from: http://YOUR_DOMAIN.COM/PATH_TO_FOLDER/playtagger_mod/.
    to the URL of your uploaded /playtagger_mod folder (needs trailing “/”).

  5. In the <head> of any files you want the Playtagger- Mod to work, place:
    <script type="text/javascript" src="http://YOUR_DOMAIN.COM/PATH_TO_FOLDER/playtagger_mod/playtagger_mod.js"></script>

    (Again, replace http://YOUR_DOMAIN.COM/PATH_TO_FOLDER/playtagger_mod with the URL of your /playtagger_mod folder.)

Should be good to go. The Playtagger- Mod script looks adds a little Flash audio-player mext to any mp3 links on your page. Looks/works like this:
Specialist “Laser” Lawrence (2:08; audio: Jake Warga, Iraq: Soldier’s Soundtrack.)

UPDATE: Playtagger- Mod is now working in the wilds of the great WFMU’s Beware of the Blog.

WP Password Prose

Post Edit- Publish and Visibility boxPassword-protecting a WordPress Post/Page hides its Content and Excerpt, but not its Custom Fields: those can still show. Below are ways to hide ’em, and functions for customizing the default WP Password-Protected messages.

Password-protect a Page/Post

Setting the Visibility to Password-protected changes the:

  1. Title– Adds this string "Protected: ", to the output of get_the_title().
  2. Excerpt– Returns this text when we get_the_excerpt(): “There is no excerpt because this is a protected post.”
  3. Content– Returns a password form (w/ text) when we get_the_content().

More…

I learned to program…

Coders, complete this sentence:

I learned to program…

Some responses:

…when I was 11 so that I could beat my dad at Robot Battle.

…on the back side of punched cards on a UNIVAC 1100 as an intern at the Swedish Defence Central in the late 70s.

…making a website for my band that I wanted to be more dynamic.

…because I believed (and still do) it’s one of the best skills to have in order to change people’s live for the better.

…and it changed my life forever.

I learned to program… is a project of Ben Chun, who posted this call to coders on wp-hackers (WordPress maillist):

I’m a high school computer science teacher and I often have students who
want to hack on things like WordPress or other open-source projects, but they don’t see a path from where they are to that goal.

So I started a web site for sharing how and why people started programming. Will you share your story? http://ilearnedtoprogram.com.

As the site has gotten more entries, I’ve been reminded of a bunch of fun things from my childhood. Maybe you’ll enjoy a trip down memory lane as well.

For more, see Ben’s post, “How did you learn to program? « And Yet It Moves.”

(FWIW, my answer:
I learned to program… to make web presentations of our public radio stories — now I do far more web and far less radio.)

HTML5 Audio Player

Hearing Voices uses the WPAudioPlayer plug, which, since it’s Flash, the iPhone can’t see. But iPhone Safari is HTML 5 aware, and supports mp3 play. So here’s our quick&filthy fix. In the file: /plugins/audio-player/audio-player.php, find the: function getPlayer, and w/in that the variable: $playerCode. More…

WP Page Excerpt

Hand-crafting Excerpts for Pages got a lot easier in in WordPress 3+. Put this in your functions.php:

add_post_type_support( 'page', 'excerpt' );

And voilà, an Excerpt textarea should now show on your Edit Page screen (make sure “Excerpt” is checked in Edit Page»Screen Options). To extract Pages’ Excerpts…

More…

WP Planets

HV is Obsessed with WordPress. Are you? Then schedule regular visits to WP’s “Planets”*: More…