Tampa WordPress Meetup 6/8/11

June 8th 2011

Alison Foxall, sent the following message to some members of TampaBay WordPress:

This meeting snuck up on us! So this month do some homework and come prepared to talk about a useful plugin for your site or blog or a plugin that you thought was really “cool.” We’ll all take part in this discussion and enjoy some Italian food while we’re at it.

These are the plugins I generally find myself using on various sites time and time again, most of them are pretty common, but users new to wordpress may not know of them and find them pretty handy. I only included the plugins gauranteed to work with the most current version of wordpress, there are a few other plugins I love, but haven’t confirmed they are all stable with the latest version yet.


Continue reading “Tampa WordPress Meetup 6/8/11” »

View Comments

Not yet possible to assign complex types to properties.

February 17th 2011

Came across something new (for me anyway) today. I was using PHP5′s SimpleXML functions to grab youtube video data so I could make automatic posts (and attach youtube comments) in wordpress based off a video’s ID. At some point I was passing what I thought was a variable into an array that was then later being manipulated by a native wordpress function during the comment post processing. While the code itself was actually working and attaching the comments to the posts, I was getting a weird error on each insert that was warning me about assigning complex types to properties, something I had never seen before.

A stackoverflow post on Forcing a SimpleXML Object to a String was the guiding light I needed.

The Error

Warning: It is not yet possible to assign complex types to properties in wp-includes\formatting.php on line 1234

The Solution

Typecast the object as a string before attempting to manipulate it.

$foo = array( (string) $xml->channel->item->title );

View Comments

The World According to Aidan

February 5th 2011

Aiden, my nephew, turns 8 tomorrow.

“Kaia doesn’t like me anymore. But that’s okay – I’ll get her back. See, boys have ways to get girls – especially me, even if the girl doesn’t like me at first. Some boys just won’t tell a girl that they like her or anything, and they NEVER get the girl. I just always tell girls that I love them right in the beginning. That way once we’re, like, GOING OUT they don’t try to force me to say it – I already did, so they can’t complain at me that I don’t love them. But they get kinda mad if they hear that you said ‘I love you’ to another girl too. They don’t like that. But what are you supposed to do when EVERY girl that you get wants you to say that you love them, but they only want you to say it to them? Somebody’s always mad!”

View Comments

Web Developer Toolbar wont Display – Firefox Fix

December 13th 2010

Today I was working on a cleaning up some CSS when suddenly a plugin I use for Firefox, Web Developer Toolbar, suddenly disappeared. I found a couple older posts with people having a similar problem, but then I stumbled across voodish.co.uk1 and it seemed to do the trick for me.

The Problem

Firefox Web Developer Toolbar addon is not showing icons or text, or both.

The Solution

A very very easy solution, as long as your Firefox toolbar positioning isn’t extremely customized. A few quick steps and you will be able to display the toolbar again.

  1. Right-click on the Toolbar and choose ‘Customize’
  2. Click ‘Restore Default Set‘ or Drag any missing buttons from the ‘Customize Toolbar’ window to the toolbar.
  3. Click ‘Done.’

And that’s it, make sure Icons and Text are selected from the drop down menu if you require both and your all set.

  1. source: Web Developer Toolbar Broken / Empty / not showing, Fixed []
View Comments

Code Poetry Redeux, Ryans Response

August 20th 2010

As usual, ryan wins this round.

<?php
//jackandjill.php
$kidsnames = $_SERVER['PHP_SELF'];
$kidsnames = basename($kidsnames, ".php");
$firstkid = substr($kidsnames,0,4);
$joinword = substr($kidsnames,4,3);
$secondkid = substr($kidsnames,7,4);
$kidsnames = $firstkid . " " . $joinword . " " . $secondkid;
function makewherecode($whereto){
if($whereto == "halibel"){
$newplace = substr($whereto,0,1);
$newplace = $newplace . substr($whereto,3,1);
$newplace = $newplace . substr($whereto,2,1);
$newplace = $newplace . substr($whereto,2,1);
return $newplace . "\n";
}
}
function hextostr($hex)
{
    $string='';
    for ($i=0; $i < strlen($hex)-1; $i+=2)
    {
        $string .= chr(hexdec($hex[$i].$hex[$i+1]));
    }
    return $string;
}
$rhyme =  nl2br($kidsnames . " went &uarr; a " . makewherecode("halibel"));
$getting = array("pail","water");
$line = "to fetch a " . $getting[0] . " of " . $getting[1];
$rhyme = $rhyme . $line . "<br>";
$line = $firstkid . " fell &darr; <br>";
$rhyme = $rhyme . $line;
$brokewhat = "63726f776e";
if (hextostr($brokewhat) == "crown"){
$line = $joinword . " broke his " . hextostr($brokewhat);
}
$rhyme = $rhyme . $line . hextostr("3c62723e");
$line = $joinword . " " . $secondkid . " came tumbling after.";
$rhyme = $rhyme . $line;
echo $rhyme;
?>
View Comments

Code is Poetry example? Ryan is Challenged!

August 19th 2010

The gauntlet has been dropped, Ryan has been challenged!

<?php
//im-a-little-teapot.php
$whatami = $_SERVER['PHP_SELF'];
$whatami = basename($whatami);
$whatami = basename($whatami, '.php');
$im = str_replace("-", " ", $whatami);
function what_do_i_do($var, $poem) {
	if (strripos($var, "teapot")) {
		return nl2br($mypoem = $poem . "when i get all worked up");
	}
}
$im != "im a little teapot" ? die : $mypoem = $im . "\n short and stout\n"; $teapot = "me";
$container = array("handle", "spout");
foreach ($container as $part) {
	$mypoem = $mypoem . "here is my " . $part . "\n";
}
echo what_do_i_do($im, $mypoem);
if (empty($error)) {
	trigger_error("YOU BETTER WATCH OUT!", E_USER_WARNING);
	$mypoem = "TOOOOOOT! \n";
}
echo nl2br($mypoem . "tip " . $teapot . " over and pour " . $teapot . " out");
?>
View Comments

Tumblr Style Chat Posts for WordPress

August 15th 2010

The problem with Tumblr, for me anyway, is the loss of direct control over the code and ability to host my submissions locally. I know tumblr has been around for a while and it doesn’t look like it’s going anywhere, but anyone who has been on the net for a while knows that just because a site is here today, that doesn’t mean it will still be here tomorrow. Tumblr doesn’t have an export option, so needless to say I’m a little wary about posting anything I might want to be able to look at or back reference a few years from now. Does anyone remember scribble.nu, run by Dustin Vannatter1 of the then OHHELLO network (Swank Army!). It was one of the first blogging platforms, before blog’s were even called blog’s and they were still just called journals. For a time everyone who was anyone had a scribble.nu journal running inline with their current site. The same goes for sites like MODblog2, from Mike Pacific and Gorman of DeskMOD3 fame. I’m sure everyone has sites they have used at one time that just couldn’t handle the traffic or for one reason or another just died a unfortunate death.

I’ve have been toying around with Tumblr a little bit recently though and I am enjoying how it automatically handles different types of content and formats it without any thought on my part. Right now this is something that is still lacking in WordPress, which I touched base in a round-about way on my last post.4

Tumblr makes it incredibly easy to post different types of submissions and have them styled automatically without any per-entry coding, not forcing us to remember which posts require what custom fields like we have to do in WordPress. I had thought WordPress 3.0 was going to help solve some of these problems by introducing Custom Post Types, but unfortunately it’s still not quiet there yet and Custom Post Types aren’t quiet what some of us expected them to be (although the new functions are extremely useful if you use them in the way they were designed for).

So, as part of a larger project I have been working on, here is a quick and easy way to implement tumblr-esque “chat” posts into your site. The following code will take any content between the [chat] and [/chat] shortcodes, automatically format it and apply a specific style. Currently it sorts anything that matches into relevant DL and DT html tags, and applies a highlight class to every other row. So very quickly I can turn this:

Fight Club (1999)
Narrator: You’re making a big mistake, fellas!
Police Officer: You said you would say that.
Narrator: I’m not Tyler Durden!
Police Officer: You told us you’d say that, too.
Narrator: All right then, I’m Tyler Durden. Listen to me, I’m giving you a direct order. We’re aborting this mission right now.
Police Officer: You said you would definitely say that.

Into something a little prettier, like this:

Fight Club (1999)

Narrator:
You’re making a big mistake, fellas!
Police Officer:
You said you would say that.
Narrator:
I’m not Tyler Durden!
Police Officer:
You told us you’d say that, too.
Narrator:
All right then, I’m Tyler Durden. Listen to me, I’m giving you a direct order. We’re aborting this mission right now.
Police Officer:
You said you would definitely say that.
function tumblr_chat_post_shortcode($atts, $content=null) {
$chatoutput = "<dl class=\"chat-transcript\">\n";
$split = preg_split("/(\r?\n)+|(<br\s*\/?>\s*)+/", $content);
	foreach($split as $haystack) {
		if (strpos($haystack, ":")) {
			$string = explode(":", trim($haystack), 2);
			$who = strip_tags(trim($string[0]));
			$what = strip_tags(trim($string[1]));
			$row_class = empty($row_class)? " class=\"chat-highlight\"" : "";
			$chatoutput = $chatoutput . "<dt$row_class><strong>$who:</strong></dt> <dd>$what</dd>\n";
		}
		else {
			// the string didn't contain a needle. Displaying anyway in case theres anything additional you want to add within the transcript
			$chatoutput = $chatoutput . $haystack . "\n";
		}
	}
// print our new formated chat post
$content = $chatoutput . "</dl>\n";
return $content;
}
add_shortcode("chat", "tumblr_chat_post_shortcode");

If shortcodes just aren’t your style and you want something to work on posts transparently, that’s not very difficult either. All we have to do is create a new category (in this example we are using “chats”), and the code posted below will automatically process and format any submissions. Using the built in add_filter functions wordpress provides, it’s easy to modify content before it gets displayed to the browser, allowing us a way to format posts differently based on the category they are in.

function tumblr_chat_post($content) {
global $post;
	//$content = $post->post_content;
	if ($post->post_type == 'post') {
		$postcats = wp_get_object_terms($post->ID, 'category');
		foreach ($postcats as $mycat) {
			if ($mycat->name == "chats") {
			remove_filter ('the_content',  'wpautop');
				$chatoutput = "<dl class=\"chat-transcript\">\n";
				$split = preg_split("/(\r?\n)+|(<br\s*\/?>\s*)+/", $content);
					foreach($split as $haystack) {
						if (strpos($haystack, ":")) {
							$string = explode(":", trim($haystack), 2);
							//list($who, $what) = explode(":", $haystack, 2);
							$who = strip_tags(trim($string[0]));
							$what = strip_tags(trim($string[1]));
							$row_class = empty($row_class)? " class=\"chat-highlight\"" : "";
							$chatoutput = $chatoutput . "<dt$row_class><strong>$who:</strong></dt> <dd>$what</dd>\n";
						}
						else {
						// the string didn't contain a needle. Displaying anyway in case theres anything additional you want to add within the transcript
							$chatoutput = $chatoutput . $haystack . "\n";
						}
					}
					// print our new formated chat post
					$content = $chatoutput . "</dl>\n";
					return $content;
			}
			else {
			add_filter ('the_content',  'wpautop');
			// I don't exist in the defined category, so no processing is needed
			return $content;
			}
		}
	}
	else {

		// I'm not a regular post, so no processing is needed.
		return $content;
	}
}
add_filter( "the_content", "tumblr_chat_post", 9);

Either of these functions can be placed in your themes function.php file and will work automatically as long as your chat transcripts are formatted in a Name: Message structure. This is a fairly simple example on how to use wordpress hooks and shortcodes to modify your post before it gets outputted to the browser, which provides us with some interesting ways to implement specific styled post types without hacking apart the “Custom Post Type” functions WordPress released with version 3.0, something that is just not suited very well or meant for for these type of tasks.

  1. Dustin.Vannater.com : Things I’ve Done []
  2. Interview of Mike Pacific from DeskMOD.com []
  3. Stamford Advocate: Danbury man manages Web Site from his bedroom []
  4. The Problem with WordPress Custom Post Types []
View Comments

The Problem with WordPress Custom Post Types

August 12th 2010

Xzibit Moddin My WordPress!

A lot of “names” in wordpress on the net are politely bashing people because they are trying to use Custom Post Types in the wrong way, but really in my (and clearly a lot of other users) opinions, what they are trying to do is what should be defaultly working in the first place.

Custom post types should be exactly that, custom post types. It should give me the ability to define a custom submission area with specific meta content completely separated from the normal “Submit New Post” area. If you have ever built something for a client, and not just for personal use, you would see how extremely useful this would be. But what we have now with this new feature isn’t custom “post” types like it’s named, it’s actually custom “content” types.

Right now we are stuck with using custom fields and trying to explain to clients in explicitly detailed instructions how to properly define key pairs for specific post types that all still need to be displayed inline with the regular “blog”. Why is it so hard for people to understand that being able to use custom post types as an ability to specifically define certain REAL post submission meta boxes and separate them out in the dashboard is a useful thing.


Continue reading “The Problem with WordPress Custom Post Types” »

View Comments

Transparent PNG background turns into a Gradient in IE8 – Fixed

August 9th 2010

While cross checking between Firefox and IE8 I came across an odd bug on a site I was working on. Whenever I tried to apply Internet Explorers gimped css opacity settings to a block level element that was wrapped by another div with a Alpha Transparent PNG background, the container background would gradient/fadeout from left to right, rather than displaying the alpha transparent png in it’s normal state. For example:

PNG Trasparency shows correctly in Firefox

PNG Trasparency shows correctly in Firefox

Alpha Transparent PNG shows as Gradient in IE8

Alpha Transparent PNG shows as Gradient in IE8


Continue reading “Transparent PNG background turns into a Gradient in IE8 – Fixed” »

View Comments

July Desktop, Litestep Enabled Win7 x64bit

July 30th 2010

Litestep theme: Switch LS [link]
Visual Style: 7Pro Final for Win7 x64bit [link]
Firefox Theme: Deuces [link]
Wallpaper: The Great Wave off Kanagawa [link]
Ad-Free MSN Live Messenger thanks to A-Patch (Lite)

View Comments