Include Private/Draft Pages In Parent Dropdowns

Screen Shot 2014-09-02 at 3.52.08 PMBy default, WordPress only includes published pages in the dropdown select menu that allows you to choose a parent for a particular page. This is a pretty well documented problem that is yet to be addressed in core. Not a huge issue, however it can cause some pretty pesky problems.

For example, say you have a parent page and a child page that aren’t quite ready to share with the world, so you want to make them private. So you edit the parent page and set it to private. Then you go to the child page to set it to private. Alas, the parent page will no longer appear in the dropdown “parent” menu, and thus if you save the child page at all, it becomes parentless. No fun, right?

So this snippet fixes that problem by adding private and pending (awaiting review) pages to the parent dropdown menu – and it works for bulk editing, quick editing, and editing in a single page view. If you want to tweak the post_status types that are included, just edit the array listed in the code, using values from the WP_Query codex page.

How to Properly Move the Entire Site Footer in Genesis

How to properly move the Genesis site footerWe recently had the need to move the entire .site-footer div in Genesis. There are various tutorials out there that suggest using the following code to relocate your footer content:

However this won’t actually move the entire .site-footer div. On the contrary, it will only relocate the contents of the div, which means you’ll end up with:

  1. An empty .siter-footer div
  2. Your site-footer content orphaned somewhere on your page with no good semantic classes or IDs

Not good, right?

So if you want to properly move the entire site footer, use the following code (making sure to substitute the desired hook in place of new_hook below):

How to Synchronize Social Media Shares, Counts, and Comments Across HTTP and HTTPS

Social Media

The Issue

I use a social media, sharing, or commenting plugin and it shows different data on HTTP and HTTPS versions of the same page/post.

Viewed via HTTP

Viewed via HTTP

Viewed via HTTPS

Viewed via HTTPS

Why Does This Happen?

We build a lot of sites that use social media sharing and commenting plugins, such as:

And if you really want to boil it down to the basics, each of these plugins essentially does the same thing: associate data (comments, share counts, likes, etc) with a specific URL. Pretty simple, right?

The issue described at the very beginning of this article arises because HTTP and HTTPS versions of the same page look like two separate URLs to most of these plugins.For all intents and purposes, these two URLs are treated as separate pages by most plugins, even though they point to the exact same content. That little ‘s’ makes all the difference.

I imagine there are times when this separation is desirable, however we typically want HTTP and HTTPS versions of a page to be treated the same, so that all comments, likes, shares, etc. appear the same, regardless of which protocol is being used in the URL. If that’s what you’re looking to do, then read on. . .

The Solution

To solve this problem, we essentially have to do two things:

  1. Get the HTTP version of the current page/post URL.
  2. Pass this URL to the plugin.

1. Get the HTTP URL

This is the easy part. We generally use the following bit of code (which can be placed in functions.php):

In this snippet, we’re doing two things:

  1. Defining a function, get_http_url( $url ), which converts any URL to HTTP.
  2. Creating a shortcode, [http-url], which outputs the HTTP version of the current post/page URL.

Note: We could have combined these into one simple shortcode, however I prefer separating each bit of functionality out into it’s own function, so that we can use them later if so desired.

2. Pass the HTTP URL to the plugin

Now that we can generate the HTTP version of a post/page URL, we need to basically tell our plugin to use this URL (always HTTP) instead of the auto-generated URL (HTTP or HTTPS). How we accomplish this varies from plugin to plugin, so we’ll outline the basic steps and then give two examples below.

The Steps

  1. Figure out how to inject your HTTP URL in place of the auto-generated URL used by your plugin. Good plugins will have a well-documented way to do this. Decent plugins will have a way to do this. Bad plugins will have neither a way to do this, nor documentation (if this is the case, time to switch plugins).
  2. Use the shortcode you created above to insert your HTTP URL.

Examples

We’ll look at two examples: Share Buttons by AddThis and Facebook Comments Box.

Example 1: Share Buttons by AddThis

Share Buttons by AddThis
By default, this plugin will automatically use the current post URL to send and retrieve associated share counts. Fortunately, this plugin falls into the “good” category, as it provides a simple method and clear documentation for overriding the default URL using the addthis:url attribute.

So, say we’ve created a text widget that displays our share buttons. Out of the box, the HTML looks like this:

If we want to ensure that our sharing buttons will always reference the HTTP version of a page’s URL, and likewise ensure that our share counts are the same regardless of which protocol we’re using to view the page, then we can easily use the addthis:url attribute along with our [http-url] shortcode like so:

NOTE: you’ll need to make sure shortcodes are enabled inside widgets, which you can do by adding add_filter('widget_text', 'do_shortcode'); to functions.php.

Presto! Our share counts are now the same whether we’re viewing HTTP or HTTPS.

Example 2: Facebook Comments Box

Facebook
This plugin is a little trickier, and falls somewhere between “good” and “decent”. The plugin does provide us with a handy filter, facebook_rel_canonical, however the documentation is pretty tough to track down. According to the plugin’s readme.txt file, the facebook_rel_canonical filter “affects Open Graph protocol URL definitions, URL references sent in Open Graph actions, and more.” Kind of obscure, but sounds like we’re in the right place.

So, whereas before we we’re simply outputting some custom HTML, this time we have to use WordPress’ native filters API to substitute our HTTP URL for the plugins default URL:

Just include this snippet in functions.php and you’re ready to go! Comments will now all be associated with the HTTP URL of any given post/page.

In Conclusion

While the details may vary depending on what plugin you’re using, the essential principals remain the same:

  1. Get the HTTP version of the current URL.
  2. Pass this URL to your plugin.

I find that sleuthing around different plugins to figure out how to pass in my custom URL is actually a pretty enjoyable (though sometimes time-consuming) task. I inevitably learn more about how the plugin works, and usually discover a handy trick or two along the way.

And if you run into a brick wall and just can’t figure it out, always feel free to file a support request or email the plugin author.

And if that fails, you can always contact us – we love a good challenge.

And if that fails. . . well. . . time to switch plugins 🙂

New Mm Theme: Trestle

[box type=”download”]

Trestle

A handy boilerplate child theme for serious Genesis developers.

Trestle takes a lot of the grunt work out of building sites using the Genesis Framework, providing quick and easy-to-implement solutions to common problems and repetitive tasks. We’ve taken Genesis’ rock-solid foundation, integrated mobile-first CSS, responsive navigation, a full-featured settings panel, and much more. Download. Install. Enjoy.

View Demo » Download »[/box]

Features

Trestle: A handy boilerplate theme for serious Genesis developersTrestle includes tons of helpful features such as:

  • Centralized control panel (Genesis → Theme Settings)
  • Responsive navigation menu
  • Mobile first CSS
  • Custom control over post info and meta
  • Multiple page layouts
  • Auto-generating primary navigation
  • Ability to auto-install your favorite plugins
  • Helpful theme jQuery
  • Compatibility with Genesis Extender plugin
  • Optional link icons
  • Built-in shortcodes (columns, buttons, Font Awesome, etc)
  • Front-end styles appear in editor as well
  • And more!

Still to come. . .

There are some features still on the horizon as well (feel free to add a pull request if you’re interested in contributing):

  • SASS support
  • Direct logo implementation (non-CSS)

Plugin Review: blogVault

I’m just going to come right out and say it: blogVault is my new favorite way to backup, migrate, and restore WordPress websites.

We stumbled upon blogVault – or rather, it stumbled upon us – when blogVault founder Akshat Choudhary paid a visit to one of our Bay Area Web Freelancer Meetups. Long story short, Akshat demoed blogVault for us, it looked good, we signed up for a trial, and then. . . well, here’s what we found:

As Easy As It Gets

blogVault - adding a new site

Adding a new site to blogVault

One of blogVault’s defining features is its simplicity. Installing and using blogVault can all be managed from the blogVault admin dashboard. Just click the “Add Site” button, enter the URL and admin creds for your site, and blogVault will automatically install its plugin and start backing up. It’s as simple as that.

And every step of the way is surprisingly simple, which has been a welcome surprise.

Clean & Clear Interface

blogVault does come packaged as a plugin to be installed on your WordPress site, however it is different from most plugins in that all site management/interaction happens outside of the WP dashboard. Instead, you log into blogVault’s own dashboard (https://webapp.blogvault.net) to manage all your sites from one centralized location. I can see how some might like the ability to manage site backups, restores, and migrations from directly within WordPress, but I’ve been pretty content with using blogVault’s dashboard on its own.

blogVault - dashboard

Sites in the blogVault dashboard

The blogVault dashboard displays each site along with its backup status and a number of actions (backup now, test restore, migrate, etc). The interface clearly puts all the options right out in front of the user, and makes it very easy to check the status of a site (last backup, current backup progress, etc) without having to dig.

Backups, Restores, & Migrations

It goes without saying that a good backup plugin should just work. No ifs, ands, or buts. Unfortunately, this has not always been our experience in the past. With blogVault, however, we’ve had a remarkably high success rate (and we’re currently using it to manage over 100 sites). Backups automatically run every 24 hours and can be manually triggered at any point in time. If something goes wonky on a site and you need to restore a backup, you can just click the “Auto Restore” button (or “Test Restore” if you’d like to see what the backup looks like before officially restoring), and that’s that. blogVault also adds a nice feature in that you can download any previous backup (files, database, or both) in case you want to do things manually.

blogVault - migrating

Migrating a site with blogVault

Similarly, migrating sites is a piece of cake. We build most of our sites locally or on dev servers, and when it’s time to take the site live we need to migrate it to the final server and/or URL. In the past, this meant downloading all files, exporting the database from the dev site, uploading the files to the live site, importing the database to the live site, running a serialized search and replace script to correct URLs in the database, and praying that nothing went wrong during the process. With blogVault, the process is simplified immensely. After clicking the “Migrate-Site” link, users are prompted for the target site’s URL and FTP credentials, and that’s pretty much the whole process. blogVault ports all files and the database, and automatically replaces all instances of old URLs with new ones. This is hands down the easiest that migrating a site has ever been for us here at MIGHTYminnow.

Helpful History

Changes are highlighted in the history panel

Changes are highlighted in the history panel

One of our favorite blogVault features is the history panel. Many backup solutions allow you to see a site’s backup history, but blogVault does a few nice things that make it stand out. For one, plugin and theme changes are highlighted, which can make all the difference when troubleshooting a broken site. Additionally, blogVault allows you to add custom notes to each backup. We use this feature quite often to do things like explicitly mark a backup right before performing some operations on the database, or to make note of the first clean backup after fixing a broken site – essentially setting backup waypoints to guide us in the future.

Fantastic Support

I tend to think that the folks at blogVault have treated us especially well because we’ve provided them with a lot of feedback and testing, but I have to say that blogVault support has been amongst the best I’ve ever received. Support requests are handled quickly and efficiently. Akshat and his team have repeatedly gone the extra mile. Whereas other premium services and hosts sometimes push issues back on us with generic suggestions, the blogVault team has typically taken it upon themselves to just plain fix an issue when we face it. They’ve also been surprisingly responsive to feature requests and bug reports.

Issues & Bugs

blogVault - layout weirdness

Some wonky aesthetics

Any good review will cover a product’s issues/bugs, and blogVault does have its share of quirks. The good news is that, functionally, the product has proved itself completely sound in our experience. The issues we have encountered are primarily aesthetic in nature. A few examples include:

  • In the dashboard, some sites seem to get thumbnails and some don’t. And at various screen resolutions, things overlap in strange ways.
  • Progress indicators can act a bit unpredictably when migrating and/or backing up a site. During one migration, the indicator seemed to be stuck at 43%, then suddenly jumped to 118%, before coming back down again to just below 100%. The migration completed just fine, but there was some funny math happening in there somewhere.
  • When migrating a site, the progress indicator overlay covers everything else, so you’re stuck waiting until the migration is complete and can’t perform any other actions on other sites.
  • For a while, backups in the history panel seemed to be mixing up timezones. We’d backup a site, and the timestamp would say it was backed up “in 8 hours” – this appears to have been fixed shortly after we submitted a bug report however.

Bottom Line

Thumbs Up!All in all, the issues we’ve encountered with blogVault are pretty trivial when compared to the immense amount of time and hassle we’ve been saving. And the product only gets better – Akshat and his team have been extremely responsive and proactive about responding to bugs and implementing new features, and we’re excited for the improvements yet to come. We highly recommend signing up for a free trial and testing out the awesomeness of blogVault for yourself.

Try out blogVault →

WordPress Captions – How to Remove Default 10px Padding

One of the things WordPress does right out of the box that we don’t always like is automatically add an extra 10px of width to all images with captions. This is great if you want to preserve the default .wp-caption styling with a nice 5px of padded gray around the image, but if you change your CSS then you can end up with something not so great, like this:

Why the extra padding!

Well here’s a quick workaround using the newish img_caption_shortcode_width filter:

 

Mm Plugin: WP Hotkeys

WP Hotkeys

WP Hotkeys provides time-saving keyboard shortcuts to help you quickly navigate the WordPress dashboard.

Download Now »

WP Hotkeys helps you navigate your dashboard as quickly as possible with fully customizable keyboard shortcuts. After installing WP Hotkeys, you will see the default hotkey hints display in brackets next to each standard menu item in the admin. Typing a hotkey will access the associated top-level admin menu item (e.g. Pages), and will display any submenu items and activate their associated hotkeys (e.g. All Pages, Add New). At any point you can use the arrow keys to navigate between menu items (left/right will enter/exit submenus), and the enter key to navigate to the active (underlined) menu item.

Features

  • Works right out of the box with built-in default hotkeys for each standard dashboard menu item.
  • Hotkey hints next to each menu item help you remember your shortcuts (can be toggled on/off).
  • Fully customizable – define your own hotkeys.
  • Lightweight – less than 4kb minified jQuery.
  • Built-in warning to let you know if you have duplicate hotkeys.

Coming Soon…

  • Export/import your favorite hotkey setup
  • Define custom URL/hotkey pairings

Equal Height Columns with jQuery

Equal Height Columns with jQueryThere are a ton of great solutions out there for creating equal heights columns – so many that it can get a bit daunting to choose one. Here’s a simple jQuery snippet we’ve started using when CSS alone won’t suffice. Thanks to Rob Glazebrook for the building blocks, to which we added some special functionality including binding the equal height-ing to orientation change (for mobile) and window resize, as well as the option to specify a breakpoint above which the functionality should work.

How to Get URLs for WordPress Admin Menu Items

Get WordPress admin menu item URL'sRecently, we were working on a project in which we needed a reliable way to get URL’s for WordPress admin menu items (Dashboard, Posts, Plugins, Tools, etc). Despite our best searching efforts, we simply could not find an answer – seemingly no existing function to accomplish this task. So we ended up digging into menu-header.php, the file that generates WordPress admin menu, and creating a function of our own.

get_admin_menu_item_url() retrieves a URL based on an admin menu item’s associated “file”:

 Usage

To use get_admin_menu_item_url(), you first need to figure out the “file” that corresponds to the menu item you’re interested in. This file name can be found by accessing items in the global $menu and $submenu arrays – which hold the top- and sub-level admin menu items. Each of these items is an array with the following key/value pairs:

0 – name
1 – capability
2 – file
3 – class
4 – id
5 – icon source

What we’re interested in is the file, which is the unique identifier that will allow us to retrieve the menu item’s URL. So when all is said and done, your code might look like this:

 

Meetup Fun and Productivity Tool Roundup

Lightbulb IconThe latest Bay Area Web Freelancers Meetup lived up to its name – “Productivity & Pinot” – with a healthy dose of both. Individuals from a wide variety of backgrounds and professions descended on MIGHTYminnow HQ to share their favorite tools of the trade. Here are some of our favorites:

Vimium

http://vimium.github.io/
This Chrome browser extension allows you to navigate the web mouse-free. Simple keyboard shortcuts are used for a wide array of browsing functionality (string search, quick link navigation, search tabs, etc). Takes some getting used to, but I’ve been at it for less than a week and I think I’m in love.

Emmet Package for Sublime Text

https://github.com/sergeche/emmet-sublime
If you use Sublime Text to code, then this package is a must. Emmet gives you a massive set of abbreviations that auto-magically turn into their fully-formed code/markup/CSS counterparts. HUGE time saver.

Default Folder X

http://www.stclairsoft.com/DefaultFolderX/
Great Mac app that turbo-charges your finder’s open/save functionality. No more navigating down through directory upon directory each time you save – Default Finder X lets you specify default save/open locations, remembers your most recent locations, and generally saves some serious time and clicking.

Google Hangout (Remote Desktop)

http://www.google.com/+/learnmore/hangouts/
We typically use Join Me for screen sharing because of its easy-to-use interface, but if you’re looking for a free alternative, Google Hangout now offers Remote Desktop functionality as well.

Skitch

http://evernote.com/skitch/
Looking for a better alternative to your standard screen capture tool? Skitch is a great app (and it’s free) that let’s you take screen grabs, make edits, add notes, and much more.

PopClip

http://pilotmoon.com/popclip/
PopClip takes selecting, copying, and pasting text to a whole new level. Right click selected text and you’ll get a contextual menu with over 90 actions.

Digital Ocean

https://www.digitalocean.com/
This $5/month, SSD, cloud hosting sounds too good to be true, but our trusted friend Eddie Monge (@eddiemonge) seems to think it rocks.

Google Keep

https://drive.google.com/keep/
Another handy tool for keeping your notes and lists organized. Plus it’s Google, so you know it works!