Parting ways with ChurchThemes.net and looking ahead toward a brighter future

New ChurchThemes.net

Three years ago, in July 2011, I started a theme shop. It was an era where many people in smaller niches were yet to be discovered by developers as a force to be reckoned with. The “The Long Tail” principal hadn’t yet sunk in, at least not enough for churches to have viable WordPress theme options available to them.

Churches were being grossly under-served in every WordPress theme marketplace. The most common option for them was to customize their favorite “photography” or “design agency” theme, somehow seeing past page after page of irrelevant stock imagery and the thousands of “shortcodes” they wouldn’t be using. Sprinkle in a few plugins, and say a prayer – maybe, just maybe, this would work.

Thanks to the encouragement I received from friends and family (and a few discouragements too) I launched ChurchThemes.net in an effort to bring robust WordPress theme options to churches and fulfill my dream of seeing churches launch full-featured websites, that would typically cost thousands of dollars, for less than $100.

The past three years have been a massive learning experience for me. Dealing with issues like pricing, upgrades, support, competitors, backwards compatibility – the list goes on. I’ve enjoyed so many experiences, both failures and successes, because of starting this business.

But the entrepreneur in me just can’t be satisfied with one business. Late last year my friends at X-Team and I began prototyping the product now known as Stream. And it’s taking off like a rocket in the WordPress community.

So this year we decided to undertake even more ambitious plans to establish Stream as the de facto standard in WordPress activity tracking. And now we’re well on our way to achieving it. And I can’t even mention another secret personal project I’ve been working on! Needless to say, the time has come to part ways with ChurchThemes.net.

Today, I’m happy to say that Lift has acquired ChurchThemes.net and will be ushering in a new chapter for the business and its customers. I cannot say enough about the Lift co-founders Chris Wallace and Brad Miller. These guys not only have insane WordPress theme chops, they have a deep-rooted passion to see churches succeed.

Churches are no longer under-served in WordPress theme marketplaces, but there are plenty of innovative challenges just waiting for someone to spearhead and break open new possibilities, just as ChurchThemes.net did in the very beginning. I am confident that the guys at Lift are going to blow the roof off of the industry and define the future for churches using WordPress.

It’s a bittersweet moment for me as I officially part ways with ChurchThemes.net. But its future has never been brighter, and for that, I am very thankful.

Read the full press release

WordCamp KC: Version Control Using Git

Version control is a must for any professional web developer, frontend or backend. I had the privelege of speaking this year at WordCamp KC on the topic of Version Control Using Git.

There are many ways to setup Git, but in my talk, the aim was to cover the simplest approach possible so folks could get set up quickly.

This tutorial-style post is meant to provide more detail on how to start using Git on your local environment.

The slides used for this presentation can be seen at: http://www.slideshare.net/fjarrett/wordcamp-kc-2014-version-control-using-git

Basic Tools To Get Started

This article assumes you are using a POSIX-compatible operating system, like Mac OS X or Linux.

If you are a Mac user, this is all you will need to download and install.

  1. OS X Mavericks – Found in the Mac App Store
  2. XcodeGit is included! Also found in the Mac App Store
  3. iTerm2 – A free and feature-rich alternative to the default Terminal on OS X

Basic CLI Commands

Using your terminal might seem intimidating, but don’t let the fear of leaving your mouse behind deter you from giving it a try!

You can become a terminal power user today simply by memorizing a half-dozen commands:

  1. Change directories: cd wp-content/themes
  2. Shortcut to your home directory: cd ~
  3. Go up one directory: cd ..
  4. List: ls or ls -la
  5. Create a file: touch filename.txt
  6. Edit a file: nano filename.txt
  7. Clean up our terminal view: clear

Basic Git Commands

Git is extremely powerful. There are a multitude of commands and options within commands that can take you a while to learn.

But that doesn’t mean you can’t start using Git today!

All you really need to know are a few commands and you can start making Git commits to a remote repository and enjoying the power of version control on all of your projects.

  1. Copy a repo from GitHub.com to your computer: git clone git@the_url_dot_git
  2. See your changed files: git status
  3. Queue up files: git add -A
  4. Make a commit: git commit -m ‘Fixed a broken footer link’
  5. Push our commits to GitHub.com: git push
  6. Pull down the latest from GitHub.com: git pull
  7. Switch branches: git checkout branchname

Customizing Your Bash Profile

There is a hidden file on your Mac inside your user “home” directory named .bash_profile.

Before Terminal loads your shell environment, the .bash_profile is loaded (or “sourced”). Inside this file, you can have custom preferences for the way you want your command line interface to look and operate – like changing your terminal prompt, the colors of your text, adding aliases (shortcuts) to commands and functions you use most often, and more.

Here’s a quick tutorial on how to customize this file:

  1. Navigate to your home directory: cd ~
  2. List hidden files to see if the .bash_profile already exists: ls -ld .*
  3. If it does exist go to the next step, if it does not exist, then create it: touch .bash_profile
  4. Open up the file for editing: nano .bash_profile
  5. After entering your customizations, save the file: Ctrl + x then y
  6. Now we now need to “source” it in the terminal: source .bash_profile
  7. Quit and restart your terminal.

Here’s a gist of my .bash_profile file to get you started: https://gist.github.com/fjarrett/d089fbcfe0a8c22ca8a3

Setting Your Global Git Config

GitHub uses the email address you set in your local Git configuration to associate commits with your GitHub account.

GitHub has an easy tutorial on how to add your email to the global Git config on our computer.

Configuring SSH

SSH stands for “Secure Shell” and it’s the preferred way to securely transmit commits to and from your computer and the remote repo.

  1. Generate an SSH key on your computer
  2. Add your SSH key to your GitHub account profile

Clone a repo onto our computer using SSH

The first thing to do is create a new public repo on your GitHub.com account. Also be sure to give it a “README” file by default.

After your repo is created, it will have it’s very own URL which can be used to clone this repo to your computer.

GitHub has a simple example of how to do this, however, instead of using HTTPS, you’ll want to use SSH.

Commit and push changes back to GitHub.com

Now that you have a repo from GitHub cloned onto your computer, you can start adding files to it locally, committing those files and pushing them back to GitHub.

  1. Create a new file, like: style.css
  2. Put something in this file and save it
  3. In terminal, do: git status
  4. Now we’re going to “queue up” our change: git add -A
  5. Now we can commit this file: git commit -m 'My first commit!'
  6. Now we can “push” this commit to our remote repo at GitHub: git push
  7. Go to your repo at GitHub.com and see your new file has been added!

Next Steps

Now that you’ve jumped into the shallow end of Git, you’ll want to continue learning and exploring all of its amazing possibilities, such as, ignoring files, viewing diffs and stats, merging, tagging, stashing, rebasing, and more!

Here are a few helpful links to continue your Git learning:

How to ignore files – This is an important next step to learn about if you don’t want everything in your project to be under version control.

GitRef.org – Consider this your “Git Bible” for learning more about Git commands.

git ready – Don’t let the punny name fool you. This site has excellent “how-to” style tutorials on using Git.

Was this helpful? See a problem? Please let me know in the comments!

Get an attachment ID by URL in WordPress

We all know you can use wp_get_attachment_url() to return an attachment’s URL by passing in the ID, but what about the reverse scenario?

There are a lot of long-winded examples of how to get an attachment ID by URL floating around the interwebs. Most of them limit results to only returning images or use expensive DB queries. Really, there should be a function for this in core, but there isn’t.

Needless to say, I wasn’t really happy with any of the solutions I found people using, so I decided to take a stab at it.

Below is the most lightweight method I’ve come up with (so far) to get an attachment ID by passing through an attachment URL.

Example usage

Just as an example, this would echo the attachment ID integer of test-image.jpg onto the page:

<?php echo fjarrett_get_attachment_id_by_url( 'http://frankiejarrett.com/wp-content/uploads/2013/05/test-image.jpg' ) ?>

This would echo the same result as above because we are ignoring www usage in the URL being passed through:

<?php echo fjarrett_get_attachment_id_by_url( 'http://www.frankiejarrett.com/wp-content/uploads/2013/05/test-image.jpg' ) ?>

This would echo nothing, because the image doesn’t exist in the WordPress uploads directory:

<?php echo fjarrett_get_attachment_id_by_url( 'http://frankiejarrett.com/foo/test-image.jpg' ) ?>

And finally, this would also echo nothing because the URL of the file is pointing to an external domain:

<?php echo fjarrett_get_attachment_id_by_url( 'http://www.anotherdomain.com/wp-content/uploads/2013/05/test-image.jpg' ) ?>

Conclusion

We managed to fetch an attachment ID in just a few lines of code with no expensive DB queries! Awesome 8-)

Now you can do cool things like turn a URL into an absolute path:

<?php
$url = 'http://frankiejarrett.com/wp-content/uploads/2013/05/test-image.jpg';
$attachment_id = fjarrett_get_attachment_id_by_url( $url );
$path = ( $attachment_id ) ? get_attached_file( $attachment_id ) : null;
echo $path;
?>

For more information about what was used in this function, please see:
http://php.net/manual/en/function.explode.php
http://php.net/manual/en/function.parse-url.php
http://php.net/manual/en/function.str-ireplace.php
http://codex.wordpress.org/Function_Reference/home_url
http://codex.wordpress.org/Determining_Plugin_and_Content_Directories#Constants
http://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Column

Was this code helpful to you? Let me know in the comments!

Remove specific menu items from the WordPress Admin

Sometimes it’s best – especially when you’re using WordPress as a CMS – to remove those unwanted admin menus that create clutter for clients. They are never going to use them so why confuse their admin experience? For example: if the client isn’t going to blog, why include Posts or Comments in the menu at all?

Just insert this code into the functions.php file of your WordPress theme and *bam!* no more clutter. Please note that we are not going to restrict the Administrator user experience, this will just affect logged in users who can’t manage options.

(Make sure to edit the $restricted array with the items you want to hide, this is just an example so you can see what’s possible) Enjoy!

Add prefixes to WordPress post types when a theme is activated

Recently, I had a real problem on my hands.

I had neglected to prefix the post type names in some of my themes, and as it turns out, so did another popular WordPress plugin. Long story short: this plugin became unusable when running my themes, and this did not make my users very happy.

It became clear that I needed to bust out some ninja moves to overcome this dilema.

The code below is the solution I drafted – maybe it will help you too. It’s a function that runs when the theme is in use, and rewrites the post type names in the database with any prefix you choose.

After the theme is activated the specified post types will be renamed to: fjarrett_acme, fjarrett_foo and fjarrett_bar.

Sadly, there is not yet a hook that will fire only when themes are activated/updated. The after_setup_theme action is a little misleading in that it fires when WordPress sets up the current theme, not when an admin activates and/or updates the current theme.

So, it’s basically firing with every load of WordPress when the theme is active. Someone first made a patch for this 3 years ago and it looks like it’s finally being revisited.

For that reason, this is by no means the most resource-friendly solution, but we are killing the script if the prefixed post type already exists – which requires an additional query – but this is crucial for two reasons:

  1. So we’re not attempting to update the database with every page load – after the original post types are given prefixes the database update will never run again.
  2. So other plugins/themes (like the one I was in conflict with) can be installed later, creating their blasphemous post type names, and we won’t attempt to rewrite them.

Hopefully this is helpful to you and your project in some way. If so, please tell me about it the comments!

How to hide your WordPress version number…completely

Did you know that your WordPress version number is visible to everyone?

As Matt Mullenweg rightly pointed out several years ago, simply hiding your WordPress version number is not enough by itself to stay protected from potential threats (you should always be keeping your WordPress installation up-to-date).

But perhaps you have a client who has specifically requested its removal or maybe you just like keeping things on the safe side, either way there are a lot of tutorials out there on how to remove it from various areas but none that I’ve found showing how to remove it from every area at the same time.

The WordPress version number appears in three areas:

1. Generator Meta Tag in the Header

<meta name="generator" content="WordPress 3.3.2" />

2. Generator Tag in RSS Feeds

<generator>http://wordpress.org/?v=3.3.2</generator>

3. Query Strings on Scripts & Styles

If a script or style does not specify a version number when enqueued, the current version of WordPress is used.

foo.js?ver=3.3.2

One Block of Code to Rule Them All

Just enter this into your functions.php file and your WordPress version will be safely hidden from the public.

However, there is one small caveat to be aware of when using this method: This function will check to see if the ver query string matches the WordPress version number, so if the version of the enqueued script happens to be the exact same as the WordPress version then its version string will be removed as well.

This will occur rarely (if ever), especially when the current WordPress version is a point release, such as 3.3.2.

Frankie Jarrett - The Solution

I’ve been HEROized as The Solution!

Last night was a very memorable night for me as my friends at X-Team unveiled my inner superhero, dubbing me as The Solution!

The Solution

When Frankie Jarrett isn’t living his passion for working in WordPress or making music, he’s the problem solving hero known as, The Solution!

He was born with the amazing cerebral super power to solve any problem. Frankie can always figure out a way to communicate clearly with anyone. He is often there to listen and offer support to others, no matter how difficult their situation. Often Frankie only needs to say, “I’ll have to think about this problem a little”, and soon he has an exciting solution!

No situation is too big or too small and there is no danger too great for him to face. Whether you are having a tough time remembering trigonometry for your math test, or you are stranded on the roof of a burning building, The Solution can always figure out the best way to rescue someone.

Our hero also has the natural ability to inspire others, whether leading musical worship in his church or jamming with friends, Frankie uses his voice and musical talents to uplift and inspire those around him.

When not saving the innocent, Frankie spends his time watching the History channel with his wife, whom he absolutely adores.

Being HEROized is a true honor, and I am grateful to Dave and the rest of the team for recognizing me in this way.

Now to create more solutions! :)