Creating User API Keys with WordPress

Pro Blogging Tip: Advertising with WordPress

In the age of Professional Blogging, there are many ways to make money with your words. The most common is through advertisements. Some of the easiest way to make money are through targeted ad networks such as Google’s AdSense and Adbrite. You can guess, with the advent of advertising, came WordPress advertising plugins. I’ve got a winning combination of plugins and networks that you can use to help fund your blogging habits.

Networks

There are hundreds of advertising networks out there. Currently I use 3 modes to advertise:

  • Google’s AdSense
  • Share A Sale
  • Amazon Associates

You can consider this my full disclosure. I use all of these networks just a bit differently, and there are different plugins and widgets for each. Google’s AdSense is used for my in page/post advertisements. They are based and determined by the content and keywords for the page being viewed. This is where I use two of the plugins mentioned. I use the Share A Sale network to show the sidebar advertisements. This network pays per lead or per sale depending on the affiliate. I also use the Amazon Affiliates network for when I mention a book, dvd, or music. These pay our a percentage of each sale.

Plugins

Plugins are where the magic happens. It makes advertising with WordPress much easier than normal. I have 3 plugins I use to manage my advertisements currently:

  • Better AdSense Targeting
  • Advertising Manager
  • WP125

Better AdSense Targeting: This is one of my plugins that I use to help you target in your AdSense ads to your page’s content. What this plugin does is help you tell Google’s service know what content to pay attention to, and ignore, when determining your ads for that page. There isn’t a whole lot when it comes to configuration, just a few dropdowns and you are configured.

Advertising Manager: I have been using this plugin for quite a few years. Advertising Manager makes it easy for you to setup your ads quickly and display them even easier. In 4 steps you and have ads displaying on your site. My favorite feature is being able to call the ‘default’ ad by simply adding a shortcode in the middle of my post. View the plugin page to see more about the setup process.

WP125: This is a new plugin for me, and was pointed out by my friends over at Video Quick Tips. What this plugin allows you to do is setup an Image and Link to a 125px by 125px image for advertisement. You can also setup expiration dates, have it email you when an ad is approaching expiration, and allows people to click blank ad to contact you. So far this plugin has worked extremely well for me. I setup this plugin with my Share A Sale ads so I can rotate them in and out when I get more.

SEO Optimization

Part of using targeted advertising is having a proper SEO plugin. Currently I’m stuck on SEO Ultimate. This plugin is offering me the largest selection of tools and features to help me optimize this site for the search engines.…

Plugin Review: Quick Drafts Access

The ‘draft’ status is a feature in WordPress that I use heavily. When I get an idea for a topic, I will typically just write up a title to remind me I have something I want to write about. I went looking for a way to quickly access my drafts and stumbled upon ‘Quick Drafts Access‘.

This plugin adds a menu item under the ‘Pages’ and ‘Posts’ sidebar menu of the WordPress Admin interface, with a count of the number of drafts you currently have. As expected, clicking on this will bring you to your list of drafts. Quick, Simple, and meets my needs. I figured, it could probably help some of yours too.

A few things I think I’d like to see out of this useful plugin would be the ability show this menu to only a specified WordPress role(s), making posts and pages a separate option (would allow the roles option to be more useful), and for WordPress 3.2+ I’d like to see this in the Admin Bar list so I can quickly get to the drafts from anywhere on my site.

I think these three options would make the plugin even more useful to me than it already is. Go install it today if you are having to manage a number of drafts on your WordPress site.…

Using Varnish Cache with WordPress

Using Varnish Cache with WordPress

Varnish Cache is a power Caching proxy that you can use to help mitigate large amounts of traffic from hitting your http server (typically Apache, Lighttpd, or others). What Varnish does is keeps a cached copy of a URL in memory when it’s loaded, and then the next person to request that page, will receive the cached copy. You can set Varnish to then expire the page in cache after any amount of time you deem necessary.

For a little more about Varnish you can view their ‘About‘ section.

Where most people have an issue is setting up a good ‘VCL’ or Varnish Configuration Language. To me it looks like a mixture of PERL, C, and some custom formatting but overall, it can be confusing at times. Well, I’ve spent A LOT of time trying to configure Varnish to work with WordPress and today, I think I’ve finally done it. This configuration includes not caching wp-admin, when cookies are set, and if the person is viewing on a mobile or smartphone the hash key is set differently so that plugins like WPTouch will still work.

If you have changes or improvements let me know! The basics were taken from GitHub user mattiasgeniar in his list of Varnish 3.0 Examples

Using Varnish Cache with WordPress

backend default {
.host = “127.0.0.1”;
.port = “8080”;
}
# Called after a document has been successfully retrieved from the backend.
sub vcl_fetch {
set req.http.X-Forwarded-For = client.ip;

# Uncomment this if you want to block certain user agents
#if (req.http.user-agent ~ “yandex” || req.http.user-agent ~ “Yandex” || req.http.user-agent ~ “Baidu” || req.http.user-agent ~ “baidu” || req.http.user-agent ~ “Baidubot” || req.http.user-agent ~ “baidubot”) {
# error 403 “Forbidden, naughty naughty bot.”;
#}

# Get Device type (for caching hashes)
call detect_device;

# Add a www if there isn’t one so we only cache 1 version for www and non-www
if (req.http.host !~ “www.”) {
set req.http.host = regsub(req.http.host, “$”,”www.$”);
}

# Uncomment to make the default cache “time to live” is 5 minutes, handy
# but it may cache stale pages unless purged. (TODO)
# By default Varnish will use the headers sent to it by Apache (the backend server)
# to figure out the correct TTL.
# WP Super Cache sends a TTL of 3 seconds, set in wp-content/cache/.htaccess

set beresp.ttl = 24h;

# Strip cookies for static files and set a long cache expiry time.
if (req.url ~ “.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$”) {
unset beresp.http.set-cookie;
set beresp.ttl = 24h;
}

# If WordPress cookies found then page is not cacheable
if (req.http.Cookie ~”(wp-postpass|wordpress_logged_in|comment_author_)”) {
# set beresp.cacheable = false;#versions less than 3
#beresp.ttl>0 is cacheable so 0 will not be cached
set beresp.ttl = 0s;
} else {
# set beresp.cacheable = true;
set beresp.ttl=24h;#cache for 24hrs
}

# Varnish determined the object was not cacheable
#if ttl is not > 0 seconds then it is cachebale
if (!beresp.ttl > 0s) {
set beresp.http.X-Cacheable = “NO:Not Cacheable”;
} else if ( req.http.Cookie ~”(wp-postpass|wordpress_logged_in|comment_author_)” ) {
# You don’t wish to cache content for logged in users
set beresp.http.X-Cacheable = “NO:Got Session”;
return(hit_for_pass); #previously just pass but changed in v3+
} else if ( beresp.http.Cache-Control ~ “private”) {
# You are respecting the Cache-Control=private header from the backend
set beresp.http.X-Cacheable = “NO:Cache-Control=private”;
return(hit_for_pass);
} else if ( beresp.ttl < 1s ) { # You are extending the lifetime of the object artificially set beresp.ttl = 300s; set beresp.grace = 300s; set beresp.http.X-Cacheable = “YES:Forced”; } else { # Varnish determined the object was cacheable set beresp.http.X-Cacheable = “YES”; } if (beresp.status == 404 || beresp.status >= 500) {
set beresp.ttl = 0s;
}

# Deliver the content
return(deliver);
}

sub vcl_hash {
# Each cached page has to be identified by a key that unlocks it.
# Add the browser cookie only if a WordPress cookie found.
if ( req.http.Cookie ~”(wp-postpass|wordpress_logged_in|comment_author_)” ) {
#set req.hash += req.http.Cookie;
hash_data(req.http.Cookie);
}

# And then add the device to the hash (if its a mobile device)
if (req.http.X-Device ~ “smart” || req.http.X-Device ~ “other”) {
hash_data(req.http.X-Device);
}
}

# Deliver
sub vcl_deliver {
# Uncomment these lines to remove these headers once you’ve finished setting up Varnish.
remove resp.http.X-Varnish;
remove resp.http.Via;
remove resp.http.Age;
remove resp.http.X-Powered-By;…

Adding Featured Post Images in Thesis

Adding Featured Post Images in Thesis

You may have noticed that I have added a little bit of an enhancement to my themes lately, with the custom post thumbnails added to the to of some (soon to be all) posts. You may also be wondering how I did this. Well, you are in luck. Here’s how I did it.

First I started with a little tutorial over at ‘ThemeBig’ about Adding WordPress Post Thumbnails to Thesis. This was a great start but it had a few things added that I didn’t want like the teaser images and was missing something I found necessary which was the proper title attribute on the images. So here’s the custom_functions.php and custom.css additions you’ll need to make and what they do.

custom_functions.php

// Custom Featured Post Image code
add_theme_support( ‘post-thumbnails’ );
set_post_thumbnail_size( 700, 100, true );

function add_post_image() {
if(has_post_thumbnail()) { // Make sure we have a post thumbnail
if(is_single()) { // If this is a single blog post ?>

get_the_title())); ?>

The following two items Enable the post-thumbnails and sets the default post size.

add_theme_support( ‘post-thumbnails’ );

set_post_thumbnail_size( 700, 100, true );

Adding Featured Post Images in Thesis

The arguments you are using on the set_post_thumbnail_size are the image with, height, and ‘true’ tells WordPress to crop the image you provide. Since you are using Thesis, you should set the ‘width’ item (or the ‘700’ in this case) to the width of your content column. From here on out, the images you upload to your ‘Featured Image’ should be at least as wide as the width you have specified here to allow proper cropping.

The next thing we need to do is add some custom CSS.

custom.css

.post_image { margin-bottom: 1em; margin-left: 1em; float: right; }

The CSS is pretty self-explanatory.

Adding Featured Images

This is done from the Edit screen of a post. On the right hand side you should have a pod that is by default under the ‘Tags’ pod. It’s labeled Featured Image. Clicking that link to ‘Set featured image’ gives you a modal. Where you can either add your own new image or use and existing image from your Media Library. From here, you DO NOT want to insert into post but use a small link at the bottom that says ‘Use as featured image’. Once this is done, You can click ‘Done’ and now your post has a featured image. If you need more help on this you can visit the Post Thumbnails page in the WordPress Codex.…

Creating User API Keys with WordPress

Creating User API Keys with WordPress

After WordCamp 2012 in San Francisco, I started to realize how many people were using WordPress as a platform for their web based application. Well with web based application come API’s and with that, unique user keys. I’ve been working on such a service lately and was in need of setting up a quick script that assigns an API Key to a user when they signup on a WordPress site. Here’s the code, and a quick explanation.

user_email . timestamp();
$user_api_key = sha1( $pre_obfu );
update_user_meta( $user_id, ‘wpcronme_user_api’, $user_api_key );
}
add_action( ‘user_register’, ‘ck_assign_api_key’ );

Ok, so what we did was hook onto the user_register hook. This passes along a user ID. From there we can get all the information we need about the newly registered user.

So, what’s the next part:

$pre_obfu = $user_id . NONCE_SALT . $user_data->user_email . timestamp();

Creating User API Keys with WordPress

We’re making a string that’s unique to this user, this site, and this timestamp (important later). When creating User API Keys the important thing is that they be unique. With WordPress this is pretty easy in that, by default, an email address can only be assigned to one account. Using the user ID and the email address as part of the hash assures we don’t get a duplicate. You may be asking about the other two parts NONCE_SALT and timestamp().

If you are following best security practices you have added unique keys and salts to your wp-config.php file right? …Right?! Go do this now if you haven’t. Now, this is a unique string to your site, meaning that unless someone else has the same key as you, they can’t replicate the exact same User API Keys.

The timestamp call does one thing and it’s very important. The first 3 items are unique, and don’t typically change. If someone’s User API Key get’s missused, you need a way for the users to recreate a new key so the previous one is invalidated. This timestamp will allow the API Key to be different if you run the same function again after a user edit, or something of the likes (I’ll leave that code up to you).

So that’s it, quickly generated unique keys for new users in WordPress. Hope this helps someone out.…

Web Design

Planning a reasonable site has an amazingly significant impact in advancing your online business on an expert level. Having a site which additionally shows up great on a cell phone or tablet is fundamental to keep on staying with your serious. To do this, your site ought to be spotless, with straightforward route, and a look and feel that is easy to follow for an improved client experience. read more about the importance of good web design at https://themesnap.com/why-a-professional-website-design-is-important/

Web architecture needs a great deal of inventiveness. An engaging plan of the site is the mystery, which will acquire loads of potential customers. A magnificent site configuration can take your association diagram higher than ever. It’s a perfect smaller plan that may fit even in little spaces and is made altogether in the United States, to ensure quality and backing.

Since you’ll be leaving the planning of your site to an organization, pick a website composition organization who utilizes the most current innovation to keep your site on head of the opposition. Aside from that you could likewise find an incredible organization which could offer security answers for your business undertaking.

Without this, another business will rapidly supplant your business. While you’re searching for the website composition organization that is generally reasonable for you, don’t neglect to audit about the association’s name, notoriety and friends approaches. It’s frequently difficult to make sure about a website architecture organization with ability in superb online business programming, it isn’t incomprehensible. So now you’ve discovered outstanding amongst other online business web composition firms.

The sites are made very easy to use. The sites are totally planned and created utilizing WordPress or comparable CMS stage and it is the ideal stage inside this field. Submitting to professional resources increment your private company site’s website streamlining (site design improvement), implying that it will be less complex for clients to find your business through web indexes.

On the off chance that you might want your site to perform and produce leads for expanded deals, your organization will require undeniably more than simply a site. In the event that you own a website yet not fulfilled, at that point it is conceivable to find support from presumed website architecture firm to dispose of same. The fascinating part about this site is it doesn’t generally follow the tides of the style world, however rather expects to gain its very own sign. It’s through getting your own site. You can do all these by getting your own site which works.

Your website is an immediate impression of your online business. At whatever point your site is prepared and open flawlessly across various cell phones, at that point your site become more noteworthy commitment medium and a more prominent pace of maintenance. In addition to the fact that this increases your private venture site’s SEO, furthermore, it stays with individuals keen on your by giving them new substance to see consistently. Submitting to nearby independent venture catalogs is another extraordinary method to showcase your private company site.

Every site is redone to their prerequisites. Numerous organizations sites have an awful situation in web index rankings, or probably won’t be recorded at all since they don’t see how web crawlers work. Moreover, keeping up your site content transfers the message that you’re staying with your methods refreshed and keeps your private venture picture cleaned, thus prevailing upon new clients.

Envision having your clients see your site, essentially to find that pieces of your site are broken. To achieve achievement, a site should be planned under the umbrella of one group. Your site is improved for web crawlers to guarantee it is straightforward for your customers to discover you. In the advanced innovation driven world, your site is frequently the absolute early introduction of your organization and need to catch the client’s consideration in a flash. A site, with quick and direct area search, was additionally a need for neighborhood business.

Rosario Berry is an expert independent essayist, as to present Mystic Web Designs. A fantastic Web Design can take your association’s business volume diagram higher than ever. It ought to be slick and clean plan which might be appropriate for even private …

WordPress Installation

WordPress Installation via Subversion

The installation process of WordPress has become easier and easier as web hosting providers create ’1-Click Installations’ for people to use, so why learn a new way to install WordPress? As a developer it’s sometimes important to use older versions during testing, or in some cases, unreleased ‘beta’ versions of WordPress to verify your plugins and themes are still compatible. WordPress makes older versions of the software available via their website, but you can save time by just using the following commands on your server.

To get a specific release version of WordPress you can use the following (replacing 3.3.1 with the version you want):

$ svn export http://core.svn.wordpress.org/tags/3.3.1 .

To explain,

svn

is the Subversion command.

export

The method allows us to get all the files without their revision history.

http://core.svn.wordpress.org/tags/3.3.1

Is the location of the source files. In Subversion ‘tags’ are major release versions.

WordPress Installation
The trailing ‘.’ character means to copy the files from the repository to the current directory.

If you want to get the source code with revision history use the ‘co’ method, instead of the export.

$ svn co http://core.svn.wordpress.org/tags/3.3.1 .

If you want to be on the ‘latest and greatest’ version of the codebase (called ‘trunk’ in subversion) you can use:

$ svn co http://core.svn.wordpress.org/trunk/ .

Choosing to use the trunk via a checkout or ‘co’ allows you to do an SVN Update to get new code changes made by the core developers (use the following while in the WordPress installation’s root directory):

$ svn update

For more information about using WordPress via Subversion you can hit up the ‘Installing/Updating WordPress with Subversion‘ page in the WordPress Codex.…