Creating A Reusable Custom Post

By Top Pro Media Group Lead Developer

Custom post types are very useful for sites and blogs using the WordPress platform. Here at Top Pro Media Group we use them for industry specific galleries, case studies, staff members, etc. Anything you want loopable where you don’t want the person editing to be responsible for the layout of each item. Below I will show you step by step in the process of creating a base class that will create a new custom post type each time you call it. I prefer the class method as a variation on the idea of namespacing in other languages as you don’t have to worry about shared name violations.

In your theme’s functions.php file you’ll want to start with your typical class declaration:

class My_custom_post {
final function __construct() {}
}

This is just standard PHP initializing the class and the __construct function runs whenever a new My_custom_post is called. For this example, I like using the final declaration. We have no need to modify this class later on. What we will want to do is add a method to this class that will do WordPress API calls to actually register the custom post type.

class My_custom_post {
final function __construct() {}

final function register() {
register_post_type( $post_type , array() );
}
}

Here I am using the standard register_post_type via the WordPress Documentation. The idea is to pass a few items through the constructor so that we can add new post types with minimal effort. Basically we need a name, what it supports, custom taxonomies (tags/categories), and an icon. With WordPress, I’ve found it useful to pass both a singular name and a plural name. You could remove that requirement yourself, but then if you have a post type “Fish” you’ll see “Fishs” if you do a straight appending of an “s”. So next, we’ll set up the base variables and some defaults.

class My_custom_post {
private $singular = ‘New Post Type’;
private $plural = ‘New Post Types’;
private $tax = array(‘post_tag’,’category’);
private $supports = array(‘title’,’editor’,’thumbnail’,’page-attributes’);
private $menu_icon = null;

final function __construct() {}

final function register() {
register_post_type( $post_type , array() );
}
}

I like including these default taxonomies and support items just to cover the bases. In $supports, the ‘page-attributes’ will show the menu_order item when editing your post type. In doing so, you can query the custom post by menu_order. It has come in handy more often than not. The private declaration just keeps the variables modifiable by only this class. Speaking of, I should jump into showing how to modify this variables. To do this, we pass values through the constructor.

final function __construct(
$single = null,
$plural = null,
$supports = null,
$tax = null,
$menu_icon = null)
{
if ($single) $this->single = $single;
if ($plural) $this->plural = $plural;
if ($tax) $this->tax = $tax;
if ($supports) $this->supports = $supports;
if ($menu_icon) $this->menu_icon = $menu_icon;
}

What this code is telling us is that $single, $plural, $supports, $tax, and $menu_icon are all null. If we pass through a value new calling the class, it will replace the default variable we assigned previously (but just for this instance). This bit lets us call new My_custom_post(‘Dog’,’Dogs’); and new My_custom_post(‘Fish’,’Fish’); However, if you’re familiar with register_post_type you’ll know that neither name are valid when creating slugs. For that, we just need to perform some actions on the $single variable.

Add this to the private group at the top:

private $slug;

Then add this bit inside at the bottom of the __construct method:

$this->slug = preg_replace(“/[^a-z\-]/”,”,str_replace(‘ ‘,’-‘,strtolower($this->singular)));

That should create a suitable name for a slug.

Next we should jump into the the register_post_type function, since that is already discussed in full on WordPress Documentation, I’ll just show you how to integrate it into this class.

final function register() {
$labels = array(
‘name’ => _x($this->plural, $this->slug.’ general name’),
‘singular_name’ => _x($this->singular, $this->slug.’ singular name’),
‘add_new’ => _x(‘Add New’, $this->slug),
‘add_new_item’ => __(‘Add New ‘.$this->singular),
‘edit_item’ => __(‘Edit ‘.$this->singular),
‘new_item’ => __(‘New ‘.$this->singular),
‘view_item’ => __(‘View ‘.$this->singular),
‘search_items’ => __(‘Search ‘.$this->plural),
‘not_found’ => __(‘Nothing found’),
‘not_found_in_trash’ => __(‘Nothing found in Trash’),
‘parent_item_colon’ => ”
);

$args = array(
‘labels’ => $labels,
‘public’ => true,
‘publicly_queryable’ => true,
‘show_ui’ => true,
‘query_var’ => true,
‘rewrite’ => true,
‘capability_type’ => ‘post’,
‘hierarchical’ => false,
‘menu_position’ => null,
‘supports’ => $this->supports,
‘taxonomies’ => $this->tax
);

if ($this->menu_icon) {
$args[‘menu_icon’] = $this->menu_icon;
}

register_post_type( $this->slug , $args );
}

What I am doing is taking the variables we initialized at the top as private and putting them where they go for the register_post_type function. I should note that if $menu_icon is null, WordPress uses the default pushpin.

Then we need to add this method to the init action so that this method is called. WordPress’s add_action supports wrapping within classes so this is a simple endeavor. Put the following snipit at the end of the __construct method:

add_action(‘init’, array($this, ‘register’));

This actually adds register() to the init and we pass it as an array referencing My_custom_post as $this at index 0.

That’s all there is to it. Now when you add new My_custom_post(); to your functions.php file, it will create a new post_type in the WordPress backend titled “New Post Types”. So essentially you could create the following:

new My_custom_post(‘Staff’,’Staff’);
new My_custom_post(‘Testimonial’,’Testimonials’);
new My_custom_post(‘Review’,’Reviews’);
new My_custom_post(‘Letter’,’Letters’);

And each of those will show up under the Comments section inside your WP Admin area.

Finally, here’s the entire code:

class My_custom_post {
private $singular = ‘New Post Type’;
private $plural = ‘New Post Types’;
private $tax = array(‘post_tag’,’category’);
private $supports = array(‘title’,’editor’,’thumbnail’,’page-attributes’);
private $menu_icon = null;
private $slug;

final function __construct(
$single = null,
$plural = null,
$supports = null,
$tax = null,
$menu_icon = null)
{
if ($single) $this->single = $single;
if ($plural) $this->plural = $plural;
if ($tax) $this->tax = $tax;
if ($supports) $this->supports = $supports;
if ($menu_icon) $this->menu_icon = $menu_icon;

$this->slug = preg_replace(“/[^a-z\-]/”,”,str_replace(‘ ‘,’-‘,strtolower($this->singular)));

add_action(‘init’, array($this, ‘register’));
}
final function register() {
$labels = array(
‘name’ => _x($this->plural, $this->slug.’ general name’),
‘singular_name’ => _x($this->singular, $this->slug.’ singular name’),
‘add_new’ => _x(‘Add New’, $this->slug),
‘add_new_item’ => __(‘Add New ‘.$this->singular),
‘edit_item’ => __(‘Edit ‘.$this->singular),
‘new_item’ => __(‘New ‘.$this->singular),
‘view_item’ => __(‘View ‘.$this->singular),
‘search_items’ => __(‘Search ‘.$this->plural),
‘not_found’ => __(‘Nothing found’),
‘not_found_in_trash’ => __(‘Nothing found in Trash’),
‘parent_item_colon’ => ”
);

$args = array(
‘labels’ => $labels,
‘public’ => true,
‘publicly_queryable’ => true,
‘show_ui’ => true,
‘query_var’ => true,
‘rewrite’ => true,
‘capability_type’ => ‘post’,
‘hierarchical’ => false,
‘menu_position’ => null,
‘supports’ => $this->supports,
‘taxonomies’ => $this->tax
);

if ($this->menu_icon) {
$args[‘menu_icon’] = $this->menu_icon;
}

register_post_type( $this->slug , $args );
}
}

Evolution of Web Design

By Top Pro Media Group Creative Director

evol-design

Do you remember the first search engine you used? Was it Magellan, Yahoo, AltaVista or maybe Google for you younglings? Mine was AOL on Windows 3.0. Do you remember how simple and awesome it was? It was the first time you could talk to someone via chat rooms or skip the library and go straight to your computer after school. It’s also a place where a lot of us got our start and found our passion resulting in the ever-expanding World Wide Web!

As a result of the new developing world within our own, Web Designers were born and Websites were built. Websites were simple and featured basic text. These websites were nothing fancy and were only there to provide information to people with ease. Within a few years, the infant web designers were maturing and so were the websites. Websites quickly became more advanced and visually appealing.

Text started scrolling across the screen and hit counters at the bottom of the website became increasingly popular. At this time, everyone wanted to be on the internet. Companies started asking for music and hover buttons for no other reason but that we had figured out how to do it and it was awesome.

The mid to late 90s gave way to table-based design and page builders. It was now possible to create websites with multiple columns and more dynamic layouts that weren’t possible before. Websites boomed! This was the start of Geocities, Angelfire and crazy off the wall animated clip-art.

Then we come to the 2000’s where CSS became the standard for web design. It was all of a sudden easier to change and alter a variety of features that would have normally made your web designer hate you in the late 90’s. Javascript also became a quick favorite of web designers looking to create drop-down menus, calendars, web forms, and much more.

Today, you will again notice advancement as we have moved into responsive and flat web designs. What will we think of next?

Tech Talk – ARE YOU RESPONSIVE?

By Top Pro Media Group Lead Developer

That is the number of unique screen resolutions in 2013. What does that mean to you? With 37% of web traffic coming from mobile devices, it means a lot.

Let’s say you open your website on your PC. And your friend views it on his iPhone. And then, your patient pulls up your website on her iPad. All three devices offer different resolution. And if your website was not built to be responsive, it won’t be easily viewed or fully functional on all devices. And that is only three of the 232 unique screen resolutions out there today.

That is where Responsive Web Design (or RWD as the techies like to call it) comes in. With RWD, your website will give consistent and optimized experiences each time it is pulled up, no matter which device is being used. Basically, it’s one design that morphs itself based on the device used to view it. Your site will be easy to navigate and therefore have increased visibility and a lower bounce rate.

Send us your website and we will check it out for you and make sure it is responsive. If not, we can have you responsive for less than $25 per month.

Holiday Events

By Top Pro Media Group

As we approach the holiday season, a lot of companies are beginning to plan their holiday parties. Many employees look forward to this time of year because they are excited about spending quality time with their office family minus the work and schedule. When planning your holiday extravaganza, keep in mind that a successful holiday event is one that focuses on detail and inclusion.

Be creative. This is extremely important especially if you plan to do an in-office event. It’s expected that an in-office party will include food, maybe a round of Secret Santa, a candy-cane or two and a punch bowl. But having a creative event means stepping it up a notch by doing something that is unique and fun. Transform your event space by adding a little décor. Fabric is an inexpensive way to dress everything from seating, to table sets to wall design. Don’t be afraid to be festive. Add subtle touches by incorporating elements that are a part of the holiday season. Create a menorah centerpiece out of shot glasses filled with green and red M&M’s and tea-tree candles/lights, or make a Christmas tree out of fish wire and green shaded bulbs (Christmas ornaments) that you can hang from the ceiling. You can even bring 5th Avenue to your office by creating a Tiffany’s themed holiday event inclusive of teal colored fabrics and crystal décor with fresh flowers and a flowing fountain of chocolate or champagne… that is of course if your budget allows you to do so! Your creative ability is endless. Use the internet as your resource for inspiration.

Be generous. Tis the season to be giving! This is the time that you can show off you company’s generosity. Some companies are not prosperous enough during the year to offer bonuses or monetary gifts to their employees. Conversely, using your holiday event to showcase your company’s generosity will prove to your employees that you care and you want to share what you do have with them. If your office event includes food or spirits, allow it to be plentiful; not just in measure but in variety and sumptuousness. If you are taking your team out of the office to celebrate the season, select a location that engages and excites your team. The local pub down the street can’t satisfy every office occasion. Let’s save that location for the impromptu happy hour after work.

Furthermore, be generous with the time you allot for this event. It’s ok to close the office early just this one day to give people time to travel to an off-site location. Or plan an in-office event that extends past the traditional lunch hour. To maximize attendance, having an event during normal business hours is best. People are less likely to return to work after already leaving. A good time frame to do this would be from 3pm – until. Be sure to let your clients or customers know ahead of time that the office will be closing early. An e-blast or post on your Facebook profile should suffice. Always leave a point of contact in case of emergencies.

Brand your event. Let’s give them something to talk about! You won’t curb employee turn-over because your event was super amazing. But you will give everyone something to look forward to for the next year. Branding your event has a simple formula. Great food + Entertainment (of some kind) + Great Ambiance = Amazing Event. Branding isn’t just for your potential customers. Branding is something you also have to do within to keep the morale up and the inspiration flowing. Use this platform to show your fellow team members that the company is ever-creative, ever-generous and always at the forefront of what’s new and what’s current when it comes to planning. Don’t be afraid to use a few creative individuals on your team to help foster the event along.

Password Security

By Top Pro Media Group Director of IT

With the constant expansion of e-commerce websites, identity theft continues to be a growing concern. Websites like healthcare.gov — which has most, if not all of your personal information — become easy targets for hackers to gain access to your identity. The only thing that typically prevents these hackers from getting your information is a username and password that you would need to login to the website. However, most people only use simple passwords which are easy crack.

Surprisingly, most people don’t use very complex passwords because they are hard to remember. This in turn however, makes your password that much easier to guess, which could lead to serious consequences. In fact, most passwords are very common, as they use the same type of keyword or phrase.

The technology at a hacker’s disposal is virtually limitless, and one of those programs is a brute force password cracker. These programs can be used individually, or combined with hundreds of other machines to continuously guess your password until it gains access. These programs also have lists of previously discovered passwords known as “dictionaries”. Most of these lists range from 1,000-10,000 keywords or phrases, and are sorted by how often that term was sucessful, casting a wide net that is fairly successful within 30 seconds to 10 minutes to capture your password.

Here are some interesting facts about password usage:

  • 4.7% of users have the password password;
  • 8.5% have the password “123456”;
  • 9.8% have the passwords “123456” or “12345678”;
  • 14% have a password from the top 10 passwords in a “password dictionary”
  • 40% have a password from the top 100 passwords in a “password dictionary”
  • 79% have a password from the top 500 passwords in a “password dictionary”
  • 91% have a password from the top 1000 passwords in a “password dictionary”

The key to proper security is a proper password. The more secure the password is, the less likely a hacker will be able to guess it. The tips below will help you form stronger, more reliable passwords and help prevent any unauthorized access to your accounts.

Avoid using passwords that are too personal

Just as hackers can get your passwords online, people who may know you could easily guess your password based on information they already know. Always try to avoid using street addresses, pet names, family names, or anything else that is “public knowledge” or used in conversations regularly. Try instead to think of an uncommon or made up word or phrase that only you know. This not only prevents programs from already having it in their password dictionaries, but it also protects you from others you interact with frequently.

Use letters, numbers and symbols to “harden” your password

Just like the inner workings of a safe, the more complex it is, the harder it is to crack. The best way to create your password is to have a mixture of letters, numbers and symbols.

For example, we’ll use the word “flapjack” as the base of our password. By itself, this word can be cracked on average in less than a minute. Below are some variations to the password, as well as how effective it is in terms of the length of time it takes to be cracked by a hacker’s program running on a single computer.

flapjack <– 52 Seconds

flapjack44 <– 10 Days

flapjack44! <– 48 Years

#fl4pj4ck2013! <– 6 Milion Years

Putting just a word followed by numbers and a symbol without mixing it does work, but it’s not as effective. That’s why it’s a great tip to replace certain letters in the key phrase of your password with similar looking numbers. When creating or changing passwords, try replacing As with 4s, Es with 3s, Is with 1s and Ts with 7s. Also add a couple of symbols to the beginning, end or a combination of the two.

The best form of password would be the 4th on the list, due to the fact that the password is longer, has symbols, and doesn’t contain a complete English word or phrase. However, the password still reads “flapjack”, since the 4s look like one-legged As. For added password length, toss in the current year, or a year of importance to you.

Never give your password to anyone, including those who claim to be a support technician

Almost every company that facilitates user accounts have special access to modify user accounts without needing a login and are instructed to never ask you for your password. The only exception to this rule is that you may need to provide access to an external account that a company needs to manage for you. Only provide this information to those who you’ve verified actually work for the company supporting you.

Never leave your password on paper that can be seen by others

One common action is to write your password down, since they can be hard to remember. The best course of action if remembering your passwords is a problem is to use a password manager such as Passpack (http://www.passpack.com), which will require logging in and entering a sentence you create known as a “Packing Key”, when then gives you a list of all of your passwords readily available to use. However, if you are more comfortable writing your passwords down, invest in a small document safe. These safes are usually under $100 and provide efficient protection from thieves and fire damage.

Communication and Cake

By Top Pro Media Group Marketing Director

How happy employees help the state of your business

As we enter the Holiday season the subject of gratitude keeps coming up. Gratitude. That tricky little intangible thing that can forge your relationships or sour them. While chatting with one of our clients’ employees, she mentioned the lack of employee morale as of late. While she knows she is appreciated and the office staff get along quite well, she felt there was something lacking which in turn led to our discussing the day to day activity in the practice. We happened upon a few key things that when initiated in your office can show your gratitude and increase the efficiency of your employees.

Engage in conversations and round-tables with your staff:

When there is a bit of free time, talk to your staff. They are on the front lines of your practice, interacting with patients, vendors, sales reps, everyday. While they may not be the ultimate decision maker, they usually have a pretty good grasp of the business and their insight can be extremely helpful. Also, the fact that you take the time to speak with them and not to them goes a long way. Everyone likes to feel important and when you empower your staff they may pleasantly surprise you.

Encourage Work Breaks:

The non-smokers of the office usually get the short end of the stick. We understand firsthand a busy office environment and know the importance of having a manned desk, phone, exam room. Walking away for a minute, getting some fresh air, a quick phone call, can all lead to a more focused and pleasant demeanor. In turn, this allows your employees that extra bit of patience when dealing with a “difficult” patient (and we all have at least one “difficult” patient…).

Be Gracious:

A smile and a simple “thank you” can go a long way in your employees’ loyalty and willingness to go the extra mile. Reply All to an email update with a “Nice job!”. Jot down a “Thank You!” on a post it note and place it on their desk. Let them leave 20 minutes early on a long Holiday weekend. A little recognition and appreciation builds a positive work environment from the top. Once your staff sees your positive, appreciative attitude, theirs will surely follow.

And everyone’s favorite…Cake!

And by cake, I mean cake…or coffee…or carrot sticks for that matter. Simply a small token of appreciation and celebration when someone has a Birthday or a Wedding or a Baby. When we are involved in celebrating each others’ achievements we feel connected to each other and this instills teamwork in the office and also breeds loyalty. And who doesn’t love cake?