Unqualified

Every great developer you know got there by solving problems they were unqualified to solve until they actually did it.

Patrick McKenzie

Indie Experts – A Community for Independent Experts

When I was freelancing full-time, I imagined what would have been helpful for me to find more work, to connect with other freelancers, and to help others getting started or struggling. I was frustrated with what was already available, especially when it came to finding work. So I compiled what I liked and didn’t like, wrote out a plan, and got to work.

Indie Experts

Indie Experts is a community of people working for themselves to connect with others to help build their business.

Why am I building Indie Experts?

As a freelancer I would often get asked if I knew someone who did X or Y, if I could suggest someone who would be good for a specific project and is looking for work. Other times I would get an inquiry from someone looking to work with me but I was busy for the next month and couldn’t take it on, but I also didn’t have a person to pass them off to that could take on the project. And there were also times where work dried up and I felt like I was scrambling to find something but didn’t have anywhere to turn for help. I think these are pretty common situations for every freelancer out there and is only a part of why I’m building Indie Experts.

What’s the plan?

I’ve got a lot planned out already and the more I talk about it the more ideas come up. I’ve got features planned out for the future as well as possible monetization options to sustain it. But right now I believe the MVP should be a directory of profiles, the ability to search it, and a place for people to set their availability and how to contact them. This alone sounds very basic and I tend to think “it needs to be more”, but there needs to be people on the site in order to build a community. This directory of profiles and the initial newsletter signup should be a decent gauge of interest at the start.

In the future I’d like to improve on profiles a lot to include more details about the individual, what they’ve worked on, etc. I also believe adding the ability to endorse others will be a very important part of the site, especially to solve the problem of not knowing who to pass inquiries to. Other ideas include a reddit-esque discussion board, job listing board (no bidding!), teams for grouping together individuals that work well together for larger projects, and a listing/profiles for companies that work with freelancers.

The biggest challenge for me is thinking beyond the web industry. I’m not building this just for people who work in the web industry. I’m building this for any self-employed person. The thinking behind each piece needs to be useful and beneficial to everyone.

Let’s Go!

I’ve got a good plan written up right now and I’m executing it. I don’t know how it will grow or how users will mold it but I’m excited and believe it will be incredibly useful! If you’re interested and self-employed you can sign up for the newsletter. I’ll be publishing updates there, looking for feedback, and giving initial access when it’s ready.



Success

“Success is liking yourself, liking what you do, and liking how you do it.”

– Maya Angelou

Joining 10up

I’m excited to announce that today marks the first day of my employment as a Web Engineer at 10up!

Being an independent consultant for the past two years has been a blast but I’ve missed working with a dedicated team towards a common goal. 10up has always been a huge name in the WordPress community both in what they do for their clients and what they contribute back into the community.

They’ve created Varying Vagrant Vagrants for local WordPress development which I use each and every day already, the ElasticPress plugin, WP_Mock for unit testing within WordPress, and a number of other projects. I’m excited to be a part of this amazing team and contributing to its growth.

Mastering Programming

The journeyman learns to solve bigger problems by solving more problems at once. The master learns to solve even bigger problems than that by solving fewer problems at once.

Spend 80% of your time on low-risk/reasonable-payoff work. Spend 15% of your time on related high-risk/high-payoff work. Spend 5% of your time on things that tickle you, regardless of payoff. Teach the next generation to do your 80% job. By the time someone is ready to take over, one of your 15% experiments (or, less frequently, one of your 5% experiments) will have paid off and will become your new 80%. Repeat.

Nai-post ni Kent Beck noong Martes, Hunyo 7, 2016

Featured Image Fallback for Child Pages

Continuing on from the same project where I needed to highlight a parent page in a WordPress menu when on a child page, featured images is another place where I wanted some custom functionality. This custom functionality I’m about to share wasn’t necessarily a requirement but I wanted to make it as simple as possible for the client to edit the site easily while still maintaining the design the designer had created.

As I mentioned in the last post the site was designed to have a handful of top-level pages (parents) with an undefined number of related child pages. This site also uses the static front page option in WordPress. The site’s layout was a top header navbar, then below that a featured image with text overlaid, then the page content below that.

What I wanted to do to implement the featured image was to build in a fallback so that we always have a featured image displayed behind the overlaid text. The other option would be to have a different layout where the featured image is not displayed and the page content contains the overlaid text above the actual page content. The fallback is a bit more graceful so I decided to do that.

Below is my solution for this fallback. First we want to see if the current page has a post_thumbnail (which is our featured image). If the current page returns a post_thumbnail we want to use that. The client should be able to specify an image for any page they want. Now if we don’t find a post_thumbnail on the current page I want to check the topmost parent page for it. This would allow the client to set a featured image for an entire group of child pages. And finally, if a post_thumbnail was not returned from the topmost parent page we would then check the defined static front page and pull it from there.

More simply the fallback for the post_thumbnail would be: Child Page -> Parent Page -> Front Page.

<?php

/**
 * Generate markup for the featured image above each page.
 *
 * If a featured image does not exist for the current page we will try and pull one from the parent page. If we still
 * haven't found a featured image we will try and pull one from the 'page_on_front' (when using a static front-page).
 * Otherwise we show nothing.
 */
function featured_image( $size = 'post-thumbnail' )
{
    global $post;

    if ( !is_page() ) {
        return;
    }

    $the_post_thumbnail = get_the_post_thumbnail( $size );

    // Get post_thumbnail from top most parent if we haven't found one yet.
    if ( empty( $the_post_thumbnail ) ) {
        $page_parents   = get_post_ancestors( $post );
        $topmost_parent = array_pop( $page_parents );

        $the_post_thumbnail = get_the_post_thumbnail( $topmost_parent );
    }

    // Get post_thumbnail from "Front Page" template if we still don't find one.
    if ( empty( $the_post_thumbnail ) ) {
        $the_post_thumbnail = get_the_post_thumbnail( get_option( 'page_on_front' ), $size );
    }

    echo $the_post_thumbnail;
}

It’s unlikely we wouldn’t find a post_thumbnail like this but we could return a hard-coded default to account for that possibility if we didn’t find one on the front page.

Highlighting parent page in WordPress menus

Menus in WordPress are a really simple and easy way to manage various navigation bars in a theme. wp_nav_menu() does a lot of the work automatically and includes a number of CSS classes for styling. Highlighting the current page is especially useful using .current-menu-item and .current-menu-ancestor classes.

There was one issue I recently ran into though. In order for the top-level page to be highlighted when a sub-page has been selected, you must have the sub-pages added into the navigation. This makes sense but for a recent project I wanted to make it easy for the client to add sub-pages to the site without having to also add the pages to the WordPress navigation menu for parent-menu highlighting. I wanted top-level pages to have the .current-menu-ancestor to be added regardless if it was in the a sub-menu.

Below is a solution for this problem. With the way I setup my project was a handful of parent pages with an undefined number of child pages. I then added the parent pages to the Menu. We didn’t want a dropdown menu.

Here we add a filter to the classes generated during the generation of the menu. First we check if we’re on a page with is_page(), if not we don’t filter anything. If we are on a page we access the current post from the global $post variable and look for the topmost parent, if we don’t find one the current post is not a child and we don’t filter anything.

If we’re on a page and we found a topmost parent we then check if the current menu $item being generated matches the topmost parent we found. If so we add the .current-menu-ancestor CSS class.

<?php

/**
 * Add the 'current-menu-ancestor' class to a parent page menu item where the child page is not part of the menu.
 *
 * @param array   $classes The CSS classes that are applied to the menu item's <li> element
 * @param WP_Post $item    The current menu item
 *
 * @return array The filtered CSS classes.
 */
function active_parent_in_menu_for_page( $classes, $item )
{
    global $post;

    if ( !is_page() ) {
        return $classes;
    }

    $page_parents   = get_post_ancestors( $post );
    $topmost_parent = array_pop( $page_parents );

    if ( empty( $topmost_parent ) ) {
        return $classes;
    }

    if ( $topmost_parent == $item->object_id ) {
        array_push( $classes, 'current-menu-ancestor' );
    }

    return $classes;
}

add_filter( 'nav_menu_css_class', 'active_parent_in_menu_for_page', 10, 2 );

Such a simple solution which makes the editing experience easier for the client when working with a custom theme.

Problem Solving

“Software is messy because it reflects our evolving understanding of the problem as we wrote it.”

– Sarah Mei