403 Error in Word press when saving pages or posts.

apache-logoWe recently ran into an issue being rolled on out on a handful of various web hosting companies using the Apache/Cpanel and whm server configuration. This recent server patch which started with one host and we observed as other host providers implemented it later and observed the same error happen these other hosting companies. The issue exists with Apache Mod Security (mod_sec) firewall flags.

THE PROBLEM

wordpress-logoThe error in word press you will see will be a 403 error on saving a page or post.

Another symptom you can’t edit a page or post as a 403 error also gets generated.

This recent patch, has a mod_security setting that has an issue with flagging functionality in wordpress forcing a mod_security flag causing the error.

 

THE FIX

Please note that not every item below is part of the fix, in most cases one of these 4 options will correct the problem. If the problems persist look into tracking the IP addresses via .conf rules to adjust for true attacks vs false positives.

1. In the .htaccess file for wordpress add in a mod_security parameter to disable (mod_security might be compiled to prevent this switch from working or by limiting the .htaccess authorization via AllowOverride settings.

SIMPLE HTACCESS CODE:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_security.c>
  SecFilterEngine Off
  SecFilterScanPOST Off
</IfModule>
# END WordPress

2. In Cpanel you can go to the mod security tab – disable mod security (not all web hosts allow mod security changing through cpanel – some providers restrict it).

3. If you are on a shared/co-host environment you may to contact your hosting support –  tell them you are having a mod security issue related to 403 error and they should be able reset the mod security so your install works correctly.

4 . If you are on a VPS or DEDICATED SERVER you should have access to root folders in cpanel you can edit your conf and mod security rules at  /usr/local/apache/conf/ and edit httpd.conf

Find the configuration item and remove the # symbol.

#LoadModule rewrite_module modules/mod_rewrite.so

NOTE: The other cause of this problem can sometimes be file permissions, permalinks or corrupted .htaccess files, all of which are relatively easy to correct.

 

Visual Composer – buttons dont save data, undefined

Recently we had a client who had an issue with visual composer and buttons not saving urls and returning and undefined “Error”

To correct this problem you have change the variable names of the tags

File URL fix location:

Find the file assets/js/params/composer-atts.js or for older versions it can be in assets/js/params/all.js

if (_.isString(value_object.url)) $(‘#url-field’).val(value_object.url);
if (_.isString(value_object.title)) $(‘#link-title-field’).val(value_object.title);
$(‘#link-target-checkbox’).prop(‘checked’, !_.isEmpty(value_object.target));

$vc_link_submit.unbind(‘click.vcLink’).bind(‘click.vcLink’, function (e) {
e.preventDefault();
e.stopImmediatePropagation();
var options = {},
string = ”;
options.url = $(‘#url-field’).val();
options.title = $(‘#link-title-field’).val();
var $checkbox = $(‘#link-target-checkbox’);

And replace with:

if (_.isString(value_object.url)) $(‘#wp-link-url’).val(value_object.url);
if (_.isString(value_object.title)) $(‘#wp-link-text’).val(value_object.title);
$(‘#wp-link-target’).prop(‘checked’, !_.isEmpty(value_object.target));

$vc_link_submit.unbind(‘click.vcLink’).bind(‘click.vcLink’, function (e) {
e.preventDefault();
e.stopImmediatePropagation();
var options = {},
string = ”;
options.url = $(‘#wp-link-url’).val();
options.title = $(‘#wp-link-text’).val();
var $checkbox = $(‘#wp-link-target’);

WordPress 3.1.1 admin area is blank

We recently had someone come to us asking for help with an older wordpress install (3.1.1) that had some problems.  They could login to the admin area, but the main content area screen was blank.

The admin area displayed this error in the source:

Fatal error: Access to undeclared static property: WP_Screen::$this in blog/wp-admin/includes/screen.php on line 706

TO FIX:

  1. Open file wp-admin/includes/screen.php in whatever editor you use.
  2. Scroll to line 706 find the following PHP statement: <?php echo self::$this->_help_sidebar; ?>
  3. Replace the old statement, with this new statement: <?php echo $this->_help_sidebar; ?>
  4. Save your changes.

WordPress website slow?

We receive alot of contacts from businesses who use WordPress and experience a less speedy experience.  Over the past 7 years or so in our experience with WordPress there are a few things can speed up many processes and response time with your site.

1. Page Caching

This would be the first thing you will want to setup (if you haven’t already).  A database driven content management system require alot of queries to load in data and build pages, by default every page is a query.  Page caching basically takes these queries and creates static html versions, which are then servered to the browser.  This increases site speed and also reduces over all baggage on your server.

2. Excessive Plugin usage

Try to only install plugins that you need, using plugins that are no longer developed can also lead to excessive memory issues and many other kinds of errors.

3. Widget Caching

This is similar to page caching only it’s religated to the widget objects of Word Press.

4. Minify JS and CSS

With wordpress each plugin adds a new set of css and js files to load in your header and on request, this means more load time. Minification of your JS and CSS will compress all the files into one file.  This can sometimes cause issues with WordPress themes and plugins to do alot of testing.

5.Content – Make sure your images and videos are a decent size for quick viewing, also try hosting certain files externally using a cdn (Content Delivery Network).

NOTE:

If you are still having problems, check your web hosting….Some hosts are better than others, any cms using a database can experience slowdown due to traffic, number of queries to database, render large db records etc.  If you have completed most of the items in this list, then your issue may be a slow host.

 

Disable warning and errors in wordpress

To disable php warning and general errors you can adjust your wp-settings.php file with the code below.
//Add define(‘WP_DEBUG’,true);
//to wp-config.php to enable display of notices during development.
if (defined(‘WP_DEBUG’) and WP_DEBUG == true){     error_reporting(E_ALL); }
else {     //error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE);     error_reporting(0); }

Changing wordpress wp-content folder

Add this to the bottom of the wpconfig file. where newfolder is the new name of your wp-content folder.

/* Adjust content directory to new name */
    define (‘WP_CONTENT_FOLDERNAME’, ‘newfolder’);  
     define (‘WP_CONTENT_DIR’, ABSPATH . WP_CONTENT_FOLDERNAME) ;  

Add this to the bottom of the wpconfig file.  to adjust for change in folder name ie – plugins disappearing/linkage structure.
  /* Adjust for proper url relinking after folder change*/
      define(‘WP_SITEURL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/’);  
    define(‘WP_CONTENT_URL’, WP_SITEURL . WP_CONTENT_FOLDERNAME);