Get 25% off any hosting plan at Hostgator. Use coupon code wphosting9 at Hostgator checkout

Tutorials

How to force all WordPress Users to Relogin

It may be necessary, for a variety of reasons, to force all your WordPress.org users to relogin without changing the password/passwords. A WordPress users login details are kept in a cookie stored on their PC, iPad, Apple Mac etc. and therefore we need to invalidate their cookies in order to force the cookies to be recreated and for the user to login when next visiting your Website.

Fortunately WordPress provides a very simple means of invalidating existing cookies. Here is how to force all users to relogin:

1. Open the wp-config.php file on your Host so that you may edit it (use notepad, notepad++ or similar)

2. Go to the section that looks like the following:

/**

* Authentication Unique Keys and Salts.

*

* Change these to different unique phrases!

* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}

* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.

*

* @since 2.6.0

*/

define(‘AUTH_KEY’, ‘put your unique phrase here’);

define(‘SECURE_AUTH_KEY’, ‘put your unique phrase here’);

define(‘LOGGED_IN_KEY’, ‘put your unique phrase here’);

define(‘NONCE_KEY’, ‘put your unique phrase here’);

define(‘AUTH_SALT’, ‘put your unique phrase here’);

define(‘SECURE_AUTH_SALT’, ‘put your unique phrase here’);

define(‘LOGGED_IN_SALT’, ‘put your unique phrase here’);

define(‘NONCE_SALT’, ‘put your unique phrase here’);

/**

3. In your Internet Browser (Firefox, Chrome, Internet Explorer, Opera etc.) go to https://api.wordpress.org/secret-key/1.1/salt/ . You’ll see that a set of values that looks like the below has been generated (it won’t look exactly the same as below as each time the URL is visited, a unique set of values is shown):

define(‘AUTH_KEY’, ‘Mx5osjW`6K-96^AHABvmVr9l6.N}~.X#grH]{kZuS(‘);

define(‘SECURE_AUTH_KEY’, ‘GItBZ)Q$,c@tYRnv~s[&,E`i4T_=:hupl>|<|x7+Cw');

define('LOGGED_IN_KEY', 'FP&M&Mt:A$[b_{N/q+KVaNRM+mp%<v%[)21K$ECy3K');

define('NONCE_KEY', 'Q)o9M{[k?5tFz^q?`!MLcRrx)IAv58:=A_;$W,@feD');

define('AUTH_SALT', '+9Af6Xv+5 h{moT?Go E{_$>=%nn%xa!hZ~i9-1AVr');

define('SECURE_AUTH_SALT', 'M9c8%gy#*GAZm8TLW5 MA|+eIS2~|:N0cHEL)[_1fn');

define('LOGGED_IN_SALT', 'bcIJ[VGl]b7pAV=c`6I&B;a82&ov{5|7GBdMdqrjCt’);

define(‘NONCE_SALT’, ‘bQwO[t{$#,9!Q&se)M1&iHF*nF2c$El+)zGe*KkFYO');

4. Copy the text that has been generated in your Browser (from https://api.wordpress.org/secret-key/1.1/salt/).

5. Go to notepad or wherever you have wp-config.php open; delete the text as below from wp-config.php and paste the new codes where you deleted the text as below:

define('AUTH_KEY', 'put your unique phrase here');

define('SECURE_AUTH_KEY', 'put your unique phrase here');

define('LOGGED_IN_KEY', 'put your unique phrase here');

define('NONCE_KEY', 'put your unique phrase here');

define('AUTH_SALT', 'put your unique phrase here');

define('SECURE_AUTH_SALT', 'put your unique phrase here');

define('LOGGED_IN_SALT', 'put your unique phrase here');

define('NONCE_SALT', 'put your unique phrase here');

6. Save changes to wp-config.php.

You’ll notice that when you visit your WordPress login details will not longer be stored and will need to be entered afresh.

Use robots.txt Hack to Speed Up WordPress

WordPress Sites generally get rated as slow by Google. How do I know? I have inspected the Google Webmaster Tools ‘Site Performance’ of over 100 WordPress Websites. The great news is that what is causing WordPress to be perceived as slow is, in fact, extremely simple to rectify.

Google measures the Speed of your Website as an aggregate of your Page load speeds. What this means is that every page indexed by Google is included in the speed score calculation. There are various means of identifying and reducing the pages that are Slow to load however a generalised ‘blanket’ approach is probably the first step;

Identify why Google sees WordPress as Slow

I come from a Management background and am a bit of a fan of the Theory of Constraints (TOC). This whole WordPress speed dilemma is a great candidate for using one of the core principals of TOC; identify and eliminate the significant bottleneck. To identify the significant bottleneck, as identified within the measurement tool which, in this case, is Google Webmaster Tools we need merely look at Labs -> Site Performance in the menu of Google WebMaster Tools. Under ‘Example pages’ you’ll see the browser load speeds of various Pages. If you use WordPress you’ll notice that Pages beginning wp-admin are generally the slowest loading.

Do any Pages beginning wp-admin need to be indexed by the Search Engines? Almost always the answer is that there is no need for wp-admin pages to be indexed. From a Search Engine Optimization (SEO) perspective it makes sense to do something to remove the non value adding wp-admin from being indexed and identified as a bottleneck.

The Solution

The solution, very fortunately, is incredibly simple; we need to let Google (and Yahoo, Bing etc.) know not to index anything on your Site starting with wp-admin. The means of doing this is through the robots.txt file (this is far more simple and effective than trying to use rel=”nofollow” on all wp-admin links). Below are instructions on two methods of achieving the result of advising Google et.al. not to index wp-admin pages:

1. WordPress robots.txt Plugin

WordPress creates a virtual robots.txt. This means that you won’t see a file named robots.txt in the root folder of your fileserver. When you go to http://yourdomainname.com/robots.txt in your Internet Browser you’ll see the dynamically generated (virtual) robots.txt file created by WordPress. There are various WordPress Plugins which assist with changing the virtual robots.txt and all you need do is instruct the Plugin to exclude /wp-admin/ files from being indexed. I like the KB Robots.txt Plugin for its simplicity and effectiveness. All you need do is enter the following in the Robots.txt Editor (found at Settings->KB Robots.txt):

User-agent: *

Disallow: /wp-admin/

2. Static robots.txt file

It is incredibly simple to create a static robots.txt file (which will override the virtual one). Create a file named robots.txt, add the two lines of text as below, save and then copy the file to the root of your fileserver (the root folder of your domain):

User-agent: *

Disallow: /wp-admin/

Explanation of robots.txt Content

The information being added to the robots.txt file in both options above is as follows:

User-agent: * is saying that all Bots may index the Site

Disallow: /wp-admin/ is instructing the Bots not to index and content in the wp-admin folder

Shouldn’t I have a link to my sitemap in robots.txt

Having a reference/link to your sitemap.xml file in your robots.txt is unnecessary as the Bots anyway look for sitemap.xml (or sitemap.xml.gz) in the root of your domain just as the Bots look for robots.txt. WordPress Plugins such as the excellent Google XML Sitemaps have the option to ‘add the sitemap URL to the virtual robots.txt file’ but this is not needed (if however you do want your sitemap.xml URL in the robots.txt then just add Sitemap: http://wordpresspartner.com/sitemap.xml.gz to a new line in your robots.txt Plugin or robots.txt file (obviously change my domain to yours and remove the .gz if your sitemap.xml isn’t gzipped)).

What next for WordPress Speed

There are many things that may be done to improve WordPress load speeds. The tutorial above is but one in numerous activities to improve the speed of WordPress. Keep at improving Page load speeds … it’s good SEO!

How to Install Zend Optimizer with Godaddy

Zend, ‘the PHP company’ describes Zend Guard/Zend Optimizer as follows:

‘Zend Guard provides independent software vendors and IT managers with the ability to safely distribute and manage the distribution of their PHP applications while protecting their source code.
Zend Optimizer is a free application that runs the files encoded using Zend Guard and enhances the overall performance of your PHP applications.’

Zend make awesome PHP software however if using any applications which rely on Zend Guard/Optimizer and you use Godaddy shared hosting then there are a few steps that are necessary to enable Zend Guard/Optimizer with Godaddy hosting. For example, the

Instructions to install Zend Optimizer / Zend Guard

1. Open a text editor such as notepad or notepad++.

2. Insert the following into the text document:

[Zend]
zend_optimizer.optimization_level=15
zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3
zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/ZendExtensionManager.so
zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/ZendExtensionManager_TS.so

3. Save the file to your local drive as php5.ini

4. Transfer php5.ini to the root of your domain at Godaddy (usually through an FTP application such as Filezilla)

5. Let me know how you get along

Zend Optimizer / Zend Guard and WordPress

I discovered this Godaddy problem/requirement when wanting to test the WordPress Plugin called MultiPress Lite Autoblogging. The error message I received was:

Zend Optimizer not installed

This file was encoded by the Zend Guard. In order to run it, please install the Zend Optimizer (available without charge), version 3.0.0 or later.

Seeing this message instead of the website you expected?

This means that this webserver is not configured correctly. In order to view this website properly, please contact the website’s system administrator/webmaster with the following message:
The component "Zend Optimizer" is not installed on the Web Server and therefore cannot service encoded files. Please download and install the Zend Optimizer (available without charge) on the Web Server.
Note: Zend Technologies cannot resolve issues related to this message appearing on websites not belonging to
Zend Technologies.

What is the Zend Optimizer?

The Zend Optimizer is one of the most popular PHP plugins for performance-improvement, and has been available without charge, since the early days of PHP 4. It improves performance by scanning PHP’s intermediate code and passing it through multiple Optimization Passes to replace inefficient code patterns with more efficient code blocks. The replaced code blocks perform exactly the same operations as the original code, only faster.

In addition to improving performance, the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Guard.

The Zend Optimizer is a free product available for download from Zend Technologies. Zend Technologies also developed the PHP scripting engine, known as the Zend Engine.

How to Compress and Cache with Godaddy hosting

Want to speed up your Website load times (including Yahoo YSlow and Google PageSpeed performance)? There are various options of which many include adding a bit of text to the .htaccess file. For those using Godaddy shared hosting a workaround (hack) is needed as Godaddy doesn’t like the usual .htaccess means of compression and caching. The method used in this tutorial uses PHP to compress CSS and Javascript as well as .htaccess to cache images.

Note: Please read Jared’s Comments Below

This solution to speeding up your Godaddy hosted Website has 4 actions:

  1. Create a PHP file to compress CSS
  2. Create a PHP file to compress JavaScript
  3. Save the two new PHP files to the root of your Website
  4. Add entries to your Website .htaccess file to run the two compression scripts and cache images (including ico images).

Here are more detailed instructions:

1. Create a PHP file to compress CSS

Create a file called compress-css.php (this is likely best created in a text editor such as Notepad or Notepad++) and save it on your local computer. Copy and paste the following into compress-css.php:

<?
ob_start("ob_gzhandler");
header("content-type: text/css; charset: UTF-8");
header ("expires: " . gmdate ("D, d M Y H:i:s", time() + 302400) . " GMT");
header("Cache-Control: max-age=302400, public, must-revalidate", true);
echo "/*\n";
echo "Generated by www.wordpresspartner.com\n";
echo "*/\n";
echo file_get_contents($_GET['file']);
?>

2. Create a PHP file to compress JavaScript

Create a file called compress-js.php (this is likely best created in a text editor such as Notepad or Notepad++) and save it on your local computer. Copy and paste the following into compress-js.php:

<?

ob_start(“ob_gzhandler”);

header(“content-type: text/javascript; charset: UTF-8″);

header (“expires: ” . gmdate (“D, d M Y H:i:s”, time() + 302400) . ” GMT”);

header(“Cache-Control: max-age=302400, private, must-revalidate”, true);

echo “/*\n”;

echo “Generated by www.wordpresspartner.com\n”;

echo “*/\n”;

echo file_get_contents($_GET['file']);

?>

3. Save the two new PHP files to the root of your Website

Copy compress-css.php and compress-js.php to the root of your Website (this is usually achieved via FTP).

4. Add entries to your Website .htaccess file to run the two compression scripts and cache images

Add the following to the end of the .htaccess file (usually at the root of your Website). If a file named .htaccess doesn’t exist then create a file named .htaccess in a text editor, add the text below and then transfer to the root of your Site.

# BEGIN Compression and Caching Script per http://wordpresspartner.com

# This calls the ‘compress-css.php’ and ‘compress-js.php’ files

<ifModule mod_rewrite.c>

RewriteEngine on

RewriteRule ^(.*\.(css))$ compress-css.php?file=$1

RewriteRule ^(.*\.(js))$ compress-js.php?file=$1

</ifModule>

# This enables caching

<ifModule mod_headers.c>

<filesMatch “\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$”>

Header set Cache-Control “max-age=2592000, public”

</filesMatch>

<filesMatch “\\.(xml|txt)$”>

Header set Cache-Control “max-age=216000, public, must-revalidate”

</filesMatch>

<filesMatch “\\.(html|htm|php)$”>

Header set Cache-Control “max-age=1, private, must-revalidate”

</filesMatch>

</ifModule>

# End Compression Script

P.S. The method as described above has been tested with numerous WordPress Sites hosted by Godaddy (e.g. this WordPress Site uses this exact caching and compression method) however please leave a comment of you encounter errors or need more information.