Playing with WordPress plugins – Part I

Quite a while back, I wanted to make a quiz site with questions about PHP, and as I’m still into learning more about WordPress, the only logical thing to do is to develop a plugin that will make WordPress into the perfect CMS for this project.

At this moment, there are 5,855 plugins in the WordPress plugin directory. If so many other people have done it, surely it can’t be too hard, right? But I spent countless hours reading the documentation months ago and never had anything to show for it….

Well, this time I’m going agile. I wrote a post asking “What is 2 + 2?”, added a custom field called “correct” with the value 4, and now have the code to make that answer appear underneath the blog entry. It took me a while to figure out that I needed to pass $content to my function to keep the post from disappearing, but it looks like I’m on my way.


add_action( 'the_content', 'the_pop_quiz' );
function the_pop_quiz($content) {
echo $content;
$flif_pid = get_the_ID();
$pop_quiz_answer = get_post_meta( $flif_pid, 'correct', true );
echo $pop_quiz_answer;
}

bbPress 1.0 is finally here!

Hive Bee Honey
Whoa! Two and a half months since my last blog, but bbPress 1.0 just came out recently and I updated the Chavez360 project with this and WordPress 2.8.1, and I finally have a site that integrates as smoothly as I’d like. The only really important suggestion for anybody about to set this up is to install WordPress completely first, including the new bbPress plugin before going on to the bbPress installation. The process would have been a tad smoother for me if only I had thought to do that.

Blogging in DVORAK

Why would anyone who can type 71 wpm in QWERTY want to switch to a different keyboard layout? There are many cases like the guys at DVzine.org who have improved their typing speed by switching, but their speeds in QWERTY were significantly lower than mine. And after a week an a half of using mostly DVORAK when typing, my speed is only around 19 wpm. But then again, switching back to QWERTY occasionally probably doesn’t help.

The hardest part is what to do about all the keyboard shortcuts that were designed for right-handed people with QWERTY. Quite frequently, I’m using Firefox with my right hand on the touchpad. I want to open a link in a new tab, but my left hand still on the keyboard is nowhere near the “t”. And the thought of relearning the muscle memory for all my VIM commands is just painful. That’s why I’ve been switching back and forth a bit too much for the good of my learning.

Oh well, school’s almost out for the summer, at which point I’ll have the extra time to take things slow and see if I really can improve my typing speed with less stress on my hands.

Oracle to Buy Sun

… and I have no idea what this means for MySQL, so I guess this is a short one.

Full press release on Oracle.com.

Book Review: Here Comes Everybody

I recently read Clay Shirky’s book Here Comes Everybody: The Power of Organizing Without Organizations. It gives us a few more examples about how the internet is changing the world:

We are used to a world where little things happen for love and big things happen for money. Love motivates people to bake a cake and money motivates people to make an encyclopedia. Now, though, we can do big things for love.

as well as explains why visitor interaction only sometimes succeeds:

Every webpage is a latent community. Each page collects the attention of people interested in its contents, and those people might well be interested in conversing with one another, too. In almost all cases the community will remain latent, either because the potential ties are too weak (any two users of Google are not likely to have much else in common) or because the people looking at the page are separated by too wide a gulf of time, and so on. But things like the comments section on Flickr allow those people who do want to activate otherwise-latent groups to at least try it. The basic question “How did you do that?” seems like a simple request for a transfer of information, but when it takes place out in public, it is also a spur to such communities of practice, bridging the former gap between publishing and conversation.

Whether you plan to have a small community or a large one, the focus is on making it easy and on trying to understand where your visitors will want interaction. If you’re interested in a web community or just want a little bit of occasional interaction with visitors, Here Comes Everybody will probably help you figure out how to do just that.

Just one last tidbit that I found interesting:

In 1991 Richard Gabriel, a software engineer at Sun Microsystems, wrote an essay that included a section called “Worse Is Better,” describing this effect. He contrasted two programming languages, one elegant but complex versus another that was awkward but simple. The belief at the time was that the elegant solution would eventually triumph; Gabriel instead predicted, correctly, that the language that was simpler would spread faster, and as a result, more people would come to care about improving the simple language than improving the complex one. The early successes of a simple model created exactly the incentives (attention, the desire to see your work spread) needed to create serious improvements.

goto in PHP

xkcd

I had a class in middle school where we did a little bit of programming. I don’t remember much about it, and the programs we wrote probably weren’t more than 25 lines. The one thing I do remember is that we used gotos. No object-oriented programming, not even functional programming.

The reason I mention this now is that I was talking one of my colleagues today, arguing PHP’s case, as he supported Python, and I mentioned that as of PHP 5.3, PHP now has a goto operator. He was really hoping that was a joke, and now probably takes the language significantly less seriously.

There are plenty of criticisms of goto, not the least important of which is Edsger Dijkstra’s Go To Statement Considered Harmful. The crux of most arguments, though, seems to be that goto statements are not inherently semantic and as such aren’t appropriate for modern structured languages.

I’m not using PHP 5.3 yet, so I can’t say that I’ve used goto already, but I don’t see why having a goto operator can make a language intrinsicly bad. There’s some code that looks gacky however you try to write it, and in some cases a simple goto may actually make it easier to read and understand, even if it also has its share of bad uses.

Looking over some comments on goto use, one of the concerns I find most interesting is that of the kitchen sink mentality. Personally, I enjoy PHP because I can have one language and use it for procedural, functional, or object-oriented code–whatever I feel is most appropriate at the time. But, yes, this can also lead to poor coding standards and huge misunderstandings between, say two developers who are both writing code in PHP but with two completely different programming paradigms.

How well a language like this works for you depends on how you use it, and I think I can use it effectively, but if others prefer to work with just one subset at a time–that’s totally fine too. Anyhow, I plan to take a look this summer at this awe-inspiring Python that everyone around me keeps evangelizing (except for Jared, who loves Rails), so who knows? Maybe I’ll be enlightened then.

Faculty Lunch: Dr. J Strother Moore

On Friday, WICS hosted a faculty lunch with our department chair, Dr. J Strother Moore. I was a little late coming from class, but fortunately the part I missed out on was about backpacking, rock-climbing, and fishing, none of which interest me too much.

Afterwards, he talked quite a bit about his main project as chair–which is to get a new building for our Computer Science department. Right now our faculty is spread across 6 different buildings, not all close to each other, and having everyone together would be great for sharing ideas, working on research, and just building a community. I frequently hang out in the basement where the ACM and WICS offices are, but it’s not convenient for most other people to just come by, and yes, it does smell a little funny. Unfortunately, the date for starting the new building still isn’t set, and it would take four years or so to complete, so it definitely won’t be up while I’m still here. I’m still not completely sure it’s necessary to take on that cost of not having a central hub for that amount of time, but the ideas Moore presented of our new building sure did sound lovely.

Another interesting idea he had was to have senior faculty teach the lower-level classes, while the newer faculty who are doing more research would be teaching the upper level classes. Personally, I think that’s a great idea since there’s nothing that turns more students off of certain classes than not having a teacher who really has teaching experience. I agree with this completely, as well as his idea to have larger class sizes using tools such as iClicker for extra interaction. My one concern with his ideas here was that of reducing reliance on lecturers. It really makes sense financially since the funds for lecturers fluctuate every year, but Mike Scott has been doing a great job of teaching CS 307 for about a decade now, and I don’t know if anyone else could fill that role so well.

Anyhow, Moore is teaching CS 313k occassionally and I don’t have him next semester, so I may never get to see how he is as a professor, but it certainly was enjoyable to have our group sit down to lunch with him and learn a bit more about what’s going on with the department.

Damn Spammers

In the past few days, I’ve received about 25 emails from my blog to moderate spam comments–all obviously from the same idiot spambot. So I can understand now why the default option is set to send email notifications to the blog administrator. Even if the comments aren’t posted without moderation (by default), that administrator still needs to know what is going on to find some other method to keep these spam comments from getting in their way.

Since Akismet (I can never spell that right) is built into WordPress, the first thing I did was to activate it and see how that worked. Fortunately, on the Akismet configuration page is an option to “Automatically discard spam comments on posts older than a month.” That’s wonderful! The post that that bot keeps trying to comment on is over two months old. Why didn’t they make this option more obvious so I could’ve signed up sooner? Well, I can’t really complain. I just have to sit back now and make sure this works….

Update: it works! So many spam comments caught. Akismet, I love you!

Choosing bbPress / WordPress

My pet project has undergone many changes in the past several years. What started as a 20 pages of HTML on a free webhost in early 2005 has developed into over 150 pages of content with a news blog, forum, and gallery. Back in 2005, though, I had a lot of free time on my hands. For a while, there was even a wiki for my content. That had been my original idea behind using Chavez360 as the site name: if you followed links around the site, eventually you’d link back to where you started from. But that seemed to be kind of overdoing it, and at the time I couldn’t figure out how to integrate the wiki membership with the rest of my site.

What I had just wasn’t working as planned. As I learned more about webdevelopment and coding, I more and more wanted to create a new CMS and forum from scratch so I could have exactly what I wanted. Unfortunately, it was a needlessly complex task, and it took well over a year before I realized that I wasn’t going to create anything that I’d be satisfied with anytime soon. So I started looking around. There were big CMS’s, blog software, forum software, all in several languages and with a huge variety of features available. How to decide which was the best for me? I wanted something:

  1. simple–something that wasn’t already bloated with features that probably would never get used and something where I would at least understand most of the source code. This was probably the strongest factor in my choosing bbPress. By default, it has only the most basic functionality, and anything else can be easily added to taste with plugins.
  2. clean–not just the code, but the actually look and feel of the forum pages. It’s easier to find what you’re looking for quickly when it’s neatly organized and not cluttered with lots of unnecessaries.
  3. with a community–okay, so maybe the bbPress community isn’t that large, but the WordPress community definitely is. Between the bbPress forums and the WordPress codex, I can find anything I’m looking for.
  4. fresh–not so old that everything you could possibly do with it has already been done. I’m looking forward to making a couple of plugins available for others to use… eventually.

It may be weird to choose bbPress first and then WordPress also for consistency, but so far, so good.

Role Models for Women In Technology

I’m not quite sure what to make of Ada Lovelace Day. They cite research on female role models which I don’t quite relate to:

…students were asked to name a real person who was a role-model for them in their career ambitions. Sixty-three per cent of female students chose a woman, 75.6 per cent of male students chose a man. But crucially, whereas the male students said gender was not a factor in their choice, 27 per cent of female students who named a female role-model said that they were inspired by the gender-related obstacles overcome by their choice.

Personally, most of the role models I’ve ever had were male–from MacGyver (resourcefulness and inventiveness) to Ricardo Lopez (discipline and determination). And 100% of the tech role models I’ve had have been men. A few years ago, Udi and Wally were my dev idols. Then I was exposed to Wayne and Bruce’s PHP wizardry and backend skills. Yes, and if there had been any women role models in there, I still don’t think I could have been more inspired than I am now to work in technology. If I find a real standout in the next year, I’ll do a blog on a woman in technology for the next Ada Lovelace Day, but otherwise it’ll be a man, and I’m sure that’ll still work to keep plenty of others inspired.

Ringbinder theme by Themocracy