Twenty-thirteen in April

At least that is the plan from the development blog on core. I updated my trunk version on my desktop which I use primarily for testing and will be using for all my theme and plugin development needs.

The one thing that just about everybody noticed from the get-go was the color usage. Vibrant and a good color scheme as well. The one thing I don’t like is the way it presents itself on wider screens. Part of that reason is the content doesn’t take up much real estate and is centered. When I’m using my 22 inch monitor it does look really strange to see a band of color stretching from left to right.

The focus on this theme is post-formats. I’ve wanted to experiment with that for some time now ever since I learned about them. The best part about it is that with 3.6 launching the focus is also post-formats. Themes should be pretty interesting to see on how they style each one should they choose to. I have a few ideas on how I want my theme to look once I’m done – whenever that is. I’m tempted to just do text and call it a day; do it all in one file.

Looking over the files for the theme and I notice a few different things from previous bundled themes. One of the first things that I noticed is how few lines of code there are on the index file. Only thirty-eight lines and of those seventeen are comment/documentation. I still have several other files to look over and read to get more familiar with the theme.

I am tempted to create a child theme and use it on my personal site. So many ideas! I still have to take several pictures for the theme I’m creating so I can submit it to the WordPress repository. I think the challenge there will be keeping up to date and maintaining the theme as up to date as I possibly can.

Twenty-thirteen has a lot of promise and a lot of potential to it and I think it can derive some really cool themes down the road with a few tweaks here and there.

I hate not finding the right documentation

I really do. Recently I was trying to see if I could help anybody out with their WordPress questions and came across the sub-forum of localhost installs. I figure why not? I once had issues trying to figure out why I couldn’t see the pages.

The issue that was on the plate was a server 500 error. I’ve had quiet a few of those and to this day I don’t like seeing them. Simple thing meaning that the server isn’t configured properly. At least that was the solution after I read the title and posted. I read the first reply which was simple with a link to how to install WordPress on a local machine with different software. I checked it out to see some of the documentation and lo and behold it was a little out of date.

The link to the tutorial was an expired domain. Needless to say it was pretty useless. Hoping to see a tutorial I found nothing but an outdated documentation for something useful. At least I think it is useful. Now part of me wants to create a quick tutorial on how to install the most current version of XAMPP ( 1.8.1 currently ) on a Windows 7 computer. While it is simple since they have been gracious enough to include an executable file for simpletons like myself they also have documentation on how to install without the installer for the more adventurous types out there.

At the same time I feel like it will be an almost moot point in that it is extremely easy to just click a few buttons and call it a day. I hate debating simple things like that sometimes but when it comes down to it some people really don’t know what they are doing. I was like that at one point.

I can remember trying to set up my testing environment and trying to use DreamWeaver almost two years ago when I was taking online courses. It felt like a huge ordeal to get it to work properly until I finally read part of the instructions that made sense to me. As it turned out I was using the wrong directory in DreamWeaver.

One more reason I deterred from using any WYSIWYG editors. I like being able to see the code I am typing. Takes me back to when sites were done using tables where now they are using sections, articles and divisions but I’m getting sidetracked.

I’m tempted to find who is responsible for that page that was linked so that I can report the broken link and see about putting in my own steps to creating a localhost and installing WordPress on it to test and hack. In the mean time I just have to take screenshots of every step taken or find a way to create a screencast for future users.

New ideas and learning from them

One day while at work I was talking to one of the girls and brought up the fact that I love to mess around with WordPress. She was delighted to hear that because she was starting a personal blog for her child’s milestones.

She was on the lookout for a good theme for her newly created site. I told her that I was willing and happy to recommend some sites that offer some free ones as well as some that have premium themes. Now, I’ve never been a huge fan of paying in general so of course I was a little hesitant to name off a few but you are not just paying for the theme you are also paying for their support.

Recently on Twitter I’ve seen a lot of discussion about GPL. I do like it. I, unfortunately, haven’t read all of it. I have skimmed through some of the parts and I agree with what many of the people have to say about it but I am getting a little sidetracked. Although this does slightly pertain to what I have on my mind: themes. I know shocker, right?

I have messed with how WordPress handles some code and seeing how to create not only a useful theme but good ones as well. Since being able to assign myself tickets on Trac-WordPress Theme Review Team- I have been able to see how many other developers and theme-connoisseurs code their themes. This has given me plenty of ideas for my themes as well. Being able to test with somebody else’s code has been a great learning experience for me and has given me more confidence in applying for a job @Automattic as a theme developer/wrangler.

Yes, there are things that I still don’t feel as strong about but I am more than capable of finding the answer.

With that being said the current theme I am actually creating is for a baby milestone blog. What I am implementing is a custom post type called “milestones” which was a slight pain to get working at first. I finally managed to get the index page to work the way I intended since I was calling the wrong function to begin with.

What I was trying to use was

new wp_Query()

and not hooking to it to add the custom post type to the main query. In order to hook to the main query you have to use the hook:

add_action ( 'pre_get_posts' , 'add_custom_post_type_to_main', 9, 1 );
// Create the callback function
function add_custom_post_type_to_main( $query ) {
    if ( is_home() && $query->is_main_query() )
        $query->set( 'post_type',array( 'post', 'milestones' ) );
    return $query;
} 

in order for it to work properly. What it actually does it create the default

$query

and adds to it the newly created custom post type from the array of post_type.

The error I kept getting was a 404, meaning that there were no results being found when I would try to see more posts through the next_posts_link() and it kept giving me a minor headache. After some searching and reading I finally found the function I needed and now all is well. Next stage is getting all the images and the final look of the site down.

Theme reviewing

I recently got a chance to assign my own themes in the WordPress Theme Trac in order to review submitted themes. I am beyond elated and feel a little honored at the same time. Some people may not understand what that means to me but I’m not too worried about that.

What this means to me is that I can now go in and review newly submitted themes and give feedback to the developer about the status of their theme. Approved or not. Sounds a little simple but there is more to it. I look over the implementation of both functionality and presentation of content.

The nice thing is that I am learning more and more about how WordPress works and feel even more confident about my coding skills to the point where I may just try to apply for an entry level web developer job or support staff job at Automattic.com since they have a happiness engineer job have been eyeing for some time now.

To top things off I have been in a better mood more and more these past few weeks. A lot of it is knowing that I can make a difference and actually seeing it. Motivation has been pretty clear in not only my everyday life but a bit more at work. I know, slightly branching off but it is on my mind. Always will be no matter what job I do.

WordPress has slowly become my learning annex and I love it. I have learned a lot since I first began looking at the code and working with Theme Development. This coming year will be full of good things and I can feel it.

Learning with practice

The progress of my theme is decent. I have been learning how to work with Git and SVN more and more. I did recently have a little conversation with @ipstenu on Twitter about learning version control. Yes, I am still learning how to harness the power of simple commits and getting the hang of how to use branches and tags.

Which brought me to my main point: tutorials.

People on the web have dozens and dozens of them. Some are better than others and some are just beyond outdated. I was looking for a tutorial on how version control works using SVN. You would think I would find at least five. No. I found links talking about how SVN works but no real tutorial.

@ipstenu asked me if I could find one noob friendly tutorial. Of course I couldn’t. True, there wasn’t one. Yet. I have been contemplating creating a simple tutorial on how to use TortoiseSVN in a local setup. Sounds simple, right? Yes and no. The writing is a simple thing but taking all those screenshots to go with that will be a task in itself. I know I’m capable of it I just now have to find the time. Keeping in mind that even my current knowledge is not that great but it should suffice for the time being.

One of the first things that I learned was ‘commit’ so of course that will be the first topic. Next in line is ‘branches’ and ‘tags. and how they work. That is one thing I still haven’t yet mastered through a GUI. Just takes me back to when I was in Junior High and learning about computers but that is another story.

Yes, tutorials have helped me understand certain things but often times I don’t really learn unless I put forth the effort. Learning by practice is a great method and a great way for me and others to learn as well. I just hope that I can get my tutorial written out so that people understand. Although this has given me an idea for a future post: translation.

HTML validation issues

If it’s one thing I hate it’s loading up a site, click on something and then the layout gets all wonky on me. For the last two years I have read and learned about HTML and CSS validation. The one thing I have learned is that there are people out there that don’t care for it.

What I have learned from reading tutorials, forums and glanced from other (what I consider professionals) developers is that validation is key. I, too, agree that it should be good practice. Better yet: natural. The one issue I have run into as of lately is that WordPress will output an empty element and you get an error in validation. The other thing I noticed is that often times an image doesn’t always get a “alt” attribute. Yes, this can be remedied by making one in the media editing section but what happens when a user doesn’t put one in?

I think that by default WordPress should at least create a sort of container or filler for those rare scenarios. A good example is the gallery shortcode and the captions it creates; or rather it doesn’t. When there is no caption for the image it will still output that element but will be empty. Bad. Rather than creating an empty element just don’t output it. Again: bad.

So, rather than nothing do something. It’s what I kind of did with a quick solution.

$caption = wptexturize( $image->post_excerpt );
 if ( !empty($caption) ) {
 $output .= "tt< {$captiontag} class='wp-caption-text gallery-caption'>" . $caption . "n";
 } else {
 $caption = "No caption entered";
 $output .= "tt< {$captiontag} class='no-caption'>" . $caption . "n";
 }

It works for my needs and what is really nice is that if I forget to put a caption on an image for my gallery posts it will say: No caption entered.

Now I just have to work on REGEX to remove unwanted attributes. The journey continues! 🙂

One more week

Earlier today when I got home from work I did my usual routine of updating to the most current development version of WordPress, made sure all other applications were up to date and opened up my code editor (Notepad++) to view and edit my theme files. Since I was wide awake I tried my hand at experimenting with Git and TortoiseGit on my main computer. One thing leads to another and I managed to delete my theme. I hadn’t made the last commit of adding my modified gallery shortcode.

Needless to say I am kicking myself pretty hard. What this means now is that I am starting over with a new repo but still with SVN and not Git. Git will be for my next project theme. The reason I am starting over is because I deleted the working copy and didn’t realize that I hadn’t added all the files and hadn’t made all the commits I needed to be in sync.

In about one week WordPress 3.5 will be launching and I am pretty stoked about it. The reason is because the way media is uploaded has improved. I feel this is a huge step in the right direction for WordPress development and adoption. People want to be able to share not only their stories but some want to share photos, videos and sometimes audio. The uploader is fairly easy to use and the user interface is elegantly designed.

But enough drooling about what is to come more about what I was trying to get across: patience. I have plenty of it and sometimes I feel I have too much of it. In one week I will make an attempt to rebuild all the code I lost and have it all finished by the time 3.5 launches. This should be manageable since I know what files I need this time after having tested file hierarchy with my previously deleted theme.

Today I created all the empty files and committed that to the repository so I can code away and make the final commits when I am satisfied with the code; that way I won’t have so many commits and a lot versions to go through down the line if I ever have to see why I did what I did.

Me, WordPress and Template tags

Recently I have been working more diligently on putting some finishing touches on my personal blog’s theme. Working on a local machine is so much easier now that I understand how it works. I remember when I started out with PHP it was painful.

I got frustrated because I didn’t know where the files had to go at first, the changes I had made to the configuration weren’t taking effect and random little things that almost discouraged me from continuing.

The other day I was reading on the WordPress forums seeing if there was somebody I could help. One thing leads to another and I wind up looking at frameworks, plugins and template tags. Now, I have posted something pretty similar to this before because it was a bit of a rant when I saw somebody posting code I felt was not good practice but that is besides the point at the moment.

What I really want to get to is why I’m writing about template tags. They are an extremely useful thing to know – to some. WordPress has several template tags at your disposal and I love it. There are however some that I have seen in some themes that I would love to use in some of my themes down the road.

A perfect example is using a template tag for navigational links. WordPress has a really good template tag:

< ?php posts_nav_link(); ?>

Simple. It does the job: create navigational links for more posts. I feel the downside to that is that it is all in one container. Yes, there are ways around it by creating your own template tag (which a lot of people seem to do) and use that instead. But what to use? I like the Kubrick method of navigational links where rather than using the one

post_nav_links()

you use two in one. Creating a previous and next link is easy. A better way of doing this is if you are using just the bare minimum amount of files in a WordPress theme is using conditionals to create the navigational links for certain looks.

< ?php
/* Create page navigation and post navigation
 * depending on what is being viewed.
 */
if ( is_single() ) { ?>
  
< ?php } else { ?>

< ?php } // end else statement

The little snippet works fairly decent but it is a little cluttered. It can be simplified a little more so that the only things that change are the

<

div>s containing the actual links. So we can modify it to:

< ?php
/* Create page navigation and post navigation
 * depending on what is being viewed.
 */

Now we don't repeat code and saves some processing power for other things. Amazing what cutting down two lines of code will do! Now we can wrap all that into a function and use it as a template tag to make things easier in an

index.php

file. So the final code would look something like:

/* Create page navigation and post navigation
 * depending on what is being viewed.
 */

function my_theme_nav_links() { ?>
  
< ?php }; // end my_theme_nav_links() 

Now we can use the function anywhere in our theme for post navigation.