Half-Elf on Tech

Thoughts From a Professional Lesbian

Author: Ipstenu (Mika Epstein)

  • WordPress Multisite 110 – Electric Boogaloo

    Multisite 110

    Introducing WordPress Multisite 110

    I promised a sequel and I delivered. I hope you guys find it helpful. The sequel is out, and it’s longer than the original. Weighing in at over 80 pages, WordPress Multisite 110 has even more information about WordPress Multisite!

    Why a sequel and not a second edition? There were more things to add than a few extra plugins. Branching into a little more philosophy and explanations to the whys, Multisite 110 hopes to be the second handbook you’ll need. The funny thing is most people who read my site regularly don’t need this at all. But your clients might. Imagine being able to hand that off to them saying ‘I’ve got you started, here’s how you can make it epic.’

    Oh yes, with a Creative Commons release, you can pass this on to your clients as you like. I won’t stop you, just don’t sell it to them. If you want to get into the shenanigans, you can bill them for it, but not sell it. Yeah, licenses will kill us all one day. Speaking of licenses, there’s code in this one, and it’s all under GPL2 (most of it’s also on this site already).

    What’s not in it? Deep diving into the database. Fixing everything… There’s no way to cover everything. This one gets into the machinations of how you make a multisite where everything looks the same, or where your admins aren’t admins at all. Favicons? Got that covered too! The White Page of Death? How to figure out what plugin you want? Man, you know I got your back! Backups, control, security, uploads… the list isn’t endless, but there’s a lot going on.

    Check out WordPress Multisite 110

    The post title of ‘Electric Boogaloo’ comes from a movie that came out in 1984: Breakin’ Two: Electric Boogaloo. All sequels should have that sub-title

  • You Can’t Be Everything

    You Can’t Be Everything

    There’s no app out there that does everything.

    A lot of you just said ‘I know.’ but did you ever stop to think about why that’s the case? After all, some applications do everything you need them to do, and some you don’t, so who gets to decide what is and isn’t needed? When I talked about how WordPress was just fine on it’s own, without any plugins, people stepped up and said “But Ipstenu, I really need XYZ.” Heck, Lorelle said she needed Akismet.

    Learning how to separate your personal needs from the needs of the masses, when writing software, is a full-time job, and many of us come at it from a slant-wise point of view. In fact, writing core code for WordPress is in diametric opposition to why we write plugins! While I’m going to talk about it from a WordPress point of view, the concept holds true to any application that has ‘add ons.’

    Plugins are written, by in large, to solve a specific problem. They’re not ‘fixing’ WordPress, they’re expanding. Remember, your iPhone wasn’t broken until it had Angry Birds, nor was your iPad incomplete without Twitter. Those are things you wanted, and solved a problem for you. The base tools, in and of themselves, address a broader group of people, with a diverse set of needs, and have the option of being everything or nothing.

    The best tool, WordPress, your computer, etc, are built to be extendable. They’re built with the innate knowledge that the users may want things they can’t forsee. Five years ago, how many of you thought Google+ or Twitter would be a ‘thing’?  Let’s take that further. You know how when a new video game comes out, sometimes you can’t play it on your older computer? That’s because it wasn’t built with the new game in mind, so it’s just not capable. And that’s why computers generally let you upgrade memory, CPU, and hard drives. They are built to be extendable becuase they know they can’t know the future.

    Bringing it back to WordPress, it was built to meet a need. People wanted to blog, they wanted it to be easy and they wanted it to just bloody work! So the Matts said ‘This is what we want’ and built it. Thankfully, they understood that people wanted to extend WordPress. But not at first. Oh you didn’t know? Back in December 2003, a ‘new feature’ was introduced called my-hacks.php, which let you put a file by that name in the root of WP, and it would treat it like a functions file. In fact, that’s why I call my non-plugin code ‘hacks.’ Heck, we didn’t get pretty permalinks until January 2004 (then called ‘cruft free’ URLs).

    The point of this is not to expose the funny looking beginnings, but to demonstrate the nature of the software. As it grew, people had needs, and instead of writing everything into core, they cleverly changed WordPress so it was extendable and let people grow as they needed. So when we talk about things like needs and wants, we do it in the understanding that we write our software to fill a need, and we make add-ons to fill wants. Sounds like double speak, I know, but that’s why I said plugins and core development are in direct opposition.

    When I want to add things to core, I want them to be useful to everyone, so I’m forced to remove my ego from the equation. Looking at the (few) core submissions I’ve made, I carefully thought them out beforehand. I looked at places were the user experience was inconsistent or diminished. When I make suggestions or offer commentary to what I think could be better, I try to show my passion without acting like a teenager’s first big crush, or a screaming fangirl meeting her heroes.

    This isn’t to say I don’t think passion is a part of the driving force of any product, but that it must be tempered and controlled in things like WordPress core. We know that we can’t make WordPress core do everything, and we know we shouldn’t. When things are extendable, we utilize that and demonstrate our fire. When they’re difficult to extend, or kludgy to implement, we come back and say ‘You know, it would be nice if we could…’ But at the end of the day, when WordPress tags your trac ticket ‘wontfix,’ it’s because they know, being unable to be all things, that they must limit the things they are.

    If you haven’t yet, take the time to read WordPress’s Philosophy.

    Aaron Jorbin - Haters Gonna HateWhen I usually talk about divorcing my ego from a project, what I mean is that I don’t let my passion cloud my better judgement. One of the lessons I’ve learned in nearly 20 years of active fandom is that when you love something, you get fired up about it, and you tend to view peoples opinions and actions as a personal attack when, in fact, they often aren’t. Yes, there are idiots and trolls and people who hate-monger, but in general, people actually aren’t dicks. They’re selfish and self-centered, but that’s just human nature. Part of designing a project means you have to let go of your personal attachment to your baby, and understand that haters are just gonna hate, and there’s nothing you can do about it.

    This also applies to using a tool, though. People mock the evangelists, and we all hate the extremists, and certainly no one actually supports those who are outright malicious. But all those archtypes come part and parcel with a system, and are all aspects of the simple problem that no one product can do all the things. We want things to be a silver bullet, to fix everything we, personally, have a problem with, and we’re totally unrealistic in wanting that.

    Mark and I were talking recently, and he pointed out that WordPress was once 230kb. It’s now 3.8megs, even zipped up. Part of this is because it all grew and became more, but if you ask the old-timers, some will complain that around the 1.5 days, WordPress just became too big. It does too much! And those people say we should pull things like the importer out of WordPress. After all, you’re going to use it once, if at all. Core plugins would get pretty big too. Jetpack is 2.4megs on its own, zipped up. By trying to be everything, maybe we’re making things a little worse.

    So the next time someone gets their panties in a bunch at you for not doing everything, tell that it’s by design. Do what you want with your code, make it easily extendable for the next guy (or forkable), and carry on. They’re not getting that unicorn.

  • Embedding CBS Video

    Embedding CBS Video

    Video!This spun out of someone who was _doing_it_wrong(). His plugin embed code reinvented all four wheels. First he was doing a reg4exp to implement shortcodes, then he was replicating oEmbeds that WordPress already has. I told him to first remove the ones that existed (so as not to cause conflicts) and then look up shortcodes.

    But since the shortcodes he wanted to make were a little weird, I thought “Well, I know I would like to see the CBS Videos one, since I embed a lot of them…” So I took ten minutes to eat a cracker and re-write his code.

    Here’s my code first.

    // CBS Video Shortcode
    function cbsvideo_func( $atts ) {
            extract( shortcode_atts( array(
                    'id' => '00',
                    'width' => '480',
                    'height' => '270',
            ), $attr ) );
    
            return '<object width="'.$width.'" height="'.$height.'"><param name="movie" value="http://www.cbs.com/e/'.$id.'/cbs/1/" /></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed width="'.$width.'" height="'.$height.'" src="http://www.cbs.com/e/'.$id.'/cbs/1/" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash"></embed></object>';
            }
    add_shortcode( 'cbsvideo', 'cbsvideo_func' );
    

    Then you use [cbsvideo id="9wFRf8KYoAXipnXgA8GKIm1VNaMgKjpE"] to embed it and have a beer. I put it in a file called sitewide-functions.php in my mu-plugins folder and walked away.

    Here’s his code, as a reference.

    define("CBS_WIDTH", 480); // default width
    define("CBS_HEIGHT", 270); // default height
    define("CBS_REGEXP", "/\[cbs ([[:print:]]+)\]/");
    define("CBS_TARGET", "<object width=\"###WIDTH###\" height=\"###HEIGHT###\"><param name=\"movie\" value=\"http://www.cbs.com/e/###URL###/cbs/1/\" /></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowScriptAccess\" value=\"always\"></param><embed width=\"###WIDTH###\" height=\"###HEIGHT###\" src=\"http://www.cbs.com/e/###URL###/cbs/1/\" allowFullScreen=\"true\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"></embed></object>");
    
    function cbs_plugin_callback($match)
    {
    	$tag_parts = explode(" ", rtrim($match[0], "]"));
    	$output = CBS_TARGET;
    	$output = str_replace("###URL###", $tag_parts[1], $output);
    	if (count($tag_parts) > 2) {
    		if ($tag_parts[2] == 0) {
    			$output = str_replace("###WIDTH###", CBS_WIDTH, $output);
    		} else {
    			$output = str_replace("###WIDTH###", $tag_parts[2], $output);
    		}
    		if ($tag_parts[3] == 0) {
    			$output = str_replace("###HEIGHT###", CBS_HEIGHT, $output);
    		} else {
    			$output = str_replace("###HEIGHT###", $tag_parts[3], $output);
    		}
    	} else {
    		$output = str_replace("###WIDTH###", CBS_WIDTH, $output);
    		$output = str_replace("###HEIGHT###", CBS_HEIGHT, $output);	
    	}
    	return ($output);
    }
    function cbs_plugin($content)
    {
    	return (preg_replace_callback(CBS_REGEXP, 'cbs_plugin_callback', $content));
    }
    
    add_filter('the_content', 'cbs_plugin',1);
    add_filter('the_content_rss', 'cbs_plugin');
    add_filter('comment_text', 'cbs_plugin');
    

    35 lines of code vs 11, and my 11 will run faster.

  • Permalink Elephants

    Permalink Elephants

    Broken Link The best permalink format for your site is so simple, you’re going to wonder why you never thought of it before. It’s obvious, intuitive, and perfect. In fact, I dare say it’s genius. Want to know what it is?

    The best permalink is the one your visitors can remember.

    I told you it was obvious.

    Look, you can waste immesurable hours and days trying to determine if /postname/ is better than /2012/postname, or you can sit down and remember you’re not making a site for search engines, but for your visitors.

    SEO does have a point, don’t get me wrong. If it’s easy for people to find your site, you get more traffic. One of my sites, following the recent Panda and Penguin updates on Google, jumped from 5th place to 3rd on a search for the major keyword. Another went from 12th to 9th (we’re working on that). None of that has to do with me changing anything, or even picking the best SEO plugin. It was done the traditional way.

    1. I wrote good copy
    2. I networked with related sites for links
    3. I advertised
    4. I was memorable

    Those three things, when done correctly, are how you get your site to rank high. And it’s that last item, being memorable, that should drive your URL choices.

    A URL like http://example.com/12897342134/jkahsdu.aspx isn’t memorable. It tells me nothing of what your site’s about, what the topics are, what the subject is.

    Elephants being adorableOn the other hand, a URL like http://example.com/2011/how-to-save-elephants tells me quite a bit. I know when the post was written, so if there was a big to-do about elephants in 2011, it probably is related. But it’s not always easy to tell someone that URL, nor is it a given I’ll remember it tomorrow. I may remember that example.com had a cool posts about saving elephants,  however. It’s certainly more likely I’ll remember it than the other link!

    This is where WordPress does something cool, though. See, I can tell someone to go to http://example.com/how-to-save-elephants/ and that will redirect them to the right URL! You can do this on Drupal as well with a module called Global Redirect (Drupal folks, correct me if I’m wrong/there’s a better one).

    To me, that says the issue isn’t what permalink pattern you pick, but what permalink slug you use! On that train of thought, what if I made my URL http://example.com/2011/save-elephants instead? Naturally then http://example.com/save-elephants  would also work.

    Now we can clearly see that ultimate issue is not the permalink structure. The only thing I don’t like about how WordPress defaults URLs is that I have to tell people ‘it’s example dot com slash save dash elephants’ and that’s not as easy as ‘example dot com slash elephants.’ Or even ‘saveelephants, all one word’ (I don’t know why that’s easier, but people tell me it is).

    The whole reason people like short URLs is that they’re short and easier to remember. If I told you to get to a site you used http://bit.ly/elephant, you’d have a much higher likelihood of remembering. Invariably, however, we look at branding and think “I don’t want bit.ly to have my name.” That’s a case for Yourls, and now, as long as you customize all your Yourls, you’re in it to win it. I know most people use short URLs for Twitter and such, but I find that making a handy short URL to tell someone ‘go to foo dot in slash facebook’ works astonishingly well. Of course Facebook knows that too, and lets you use http://fb.com/username to find people.(I don’t have a yourls setup here because I’m incapable of finding a short URL I like.)

    Sadly, there is one problem with this, and it’s that you can only use each ‘slug’ once, so once you’ve use ‘elephant’ you’re never able to use it again.

    Name your slugs wisely and plan, as best you can, for the future.

  • WordPress 3.4 – No Problem

    WordPress 3.4 – No Problem

    It’s in beta, don’t nobody panic.

    The last 3 releases of WP, I’ve made troubleshooting posts about what to do, what plugins are going to barf, and so on. This time, there really doesn’t seem as much to worry about. Of course, having said that, everything will die in a fire. Actually, though, I haven’t made a list of things yet, because there’s nothing to list. I’ve not run into any stand out ‘Oh shits!’ and the forums are remarkably quiet. So. If you’ve got stupid problems, or found you have to edit themes/plugins, please reply and let me know! I’ll get on it.

    So here’s some of the cool new stuff:

    Akismet 2.5.6

    Custom Headers and Backgrounds — See also Flexible Headers in 3.4 Themes and Backwards Compatibility for WP 3.4 Headers and Backgrounds

    Twitter was added to oEmbeds — This should just work out of the box, but if you have a plugin (like Blackbird Pie), you may want to disable it before upgrading.

    RPC-XML support for Custom Post-Types.

    Admin Toolbar To The Top! Click on any blank space in the admin bar and you go to the top of the page. (It’s the toolbar, damn it, I know this!)

    Sexier Theme Options. Have you ever wanted to see what the changes did to your theme on the fly? Go to WP Admin > Themes and click on Customize Theme to get a quick way to see what you’re tweaking. Not every option is there, nor will every option be added, but this is pretty nice!
    Theme Options

    You also get that view when you preview a theme.

    Of note, Twenty Twelve and Favicons got punted to 3.5.

    Edited to add…

    Jane Wells has a nice write up of some of the new stuff. It’s on .com, but a lot of this (all) is on 3.4 too. What? You didn’t know .com used the same (mostly) WordPress we do?

  • Storify oEmbed

    Storify oEmbed

    Of note, this no longer appears to work. It’s been almost 2 years. Not shocked. Embedly has a plugin though. http://wordpress.org/plugins/embedly/

    I was reviewing a plugin that went the long way around for this (similar to how things work on my Rickroll plugin, with a search/replace).

    You would think this is easier:

    // Add Storify oEmbed
    function add_oembed_storify(){
        wp_oembed_add_provider( 'http://storify.com/*', 'http://api.storify.com/v1/stories/');
    }
    add_action('init','add_oembed_storify');
    

    But even though there’s a nice API, it won’t work. Why not? Because Storify doesn’t have it’s own oembed provider. Boo. Instead you have to use something like embed.ly

    wp_oembed_add_provider( 'http://storify.com/*', 'http://api.embed.ly/1/oembed?url=http://storify.com/');
    

    Then you put http://storify.com/dailydot/betty-white-joins-twitter in your post and it shows a story.

    Example:

    http://storify.com/dailydot/betty-white-joins-twitter