Showing posts with label wp-config.php. Show all posts
Showing posts with label wp-config.php. Show all posts

Thursday 28 November 2013

Disable Auto Updates In WordPress

WordPress 3.7 came out with a new automatic background update feature in an effort to promote better security. By the default, only minor releases and translation file updates are enable. But we could manually disable or enable anything we want.

Just put following codes to your wp-config.php file to disable/enable the updates:

To specifically enable development (nightly) updates, use the following:

add_filter( 'allow_dev_auto_core_updates', '__return_true' );

To specifically disable minor updates, use the following:

add_filter( 'allow_minor_auto_core_updates', '__return_false' );

To specifically enable major updates, use the following:

add_filter( 'allow_major_auto_core_updates', '__return_true' );

Plugins, themes and translation file:

Automatic plugin and theme updates are disabled by default.

To enable automatic updates for plugins, use the following:

add_filter( 'auto_update_plugin', '__return_true' );

To enable automatic updates for themes, use the following:

add_filter( 'auto_update_theme', '__return_true' );

Automatic translation file updates are already enabled by default, the same as minor core updates.  To disable translation file updates, use the following:

add_filter( 'auto_update_translation', '__return_false' );

Core Updates:

To disable all core-type updates only, use the following:

add_filter( 'auto_update_core', '__return_false' );

All Updates

To completely disable all types of automatic updates, core or otherwise, add the following to your wp-config.php file:

define( 'AUTOMATIC_UPDATER_DISABLED', true );

You can also disable all automatic updates using the following filter:

add_filter( 'automatic_updater_disabled', '__return_true' );

Hope this would help you. Source: WordPress Codex

Friday 11 October 2013

Protect Your wp-config.php File With .htaccess

As a webmaster, it's our duty to take care of our website. And security is our #1 priority when it comes to take care of a blog. As we know, there are millions of security issues with WordPress, which can be solved with some simple things, such as security plugins, configuring our .htaccess file, etc.

Today we'll secure our wp-config.php file with some basic .htaccess editing. Add following code to your .htaccess file:

<files wp-config.php>
order allow,deny
deny from all
</files>

This code should be placed in an .htaccess file located in the directory that contains your wp-config.php file.

Thursday 10 October 2013

Optimize And Repair WordPress Database

In WordPress 2.9, WordPress gave us a new automatic database repair feature. This feature enables you to repair and optimize your database. You should use this feature time to time to take care of your website's home.

You can use this feature even when you're not logged in to your website. This is because its main intent is to repair a corrupted database, Users can often not login to their WordPress when the database is corrupt.

Just add following snippet to your wp-config.php file to activate this feature:

define( 'WP_ALLOW_REPAIR', true );

Once activated, you can see the settings on this page: http://www.yoursite.com/wp-admin/maint/repair.php

Once you are done repairing and optimizing your database, make sure to remove this from your wp-config.php.

Tuesday 1 October 2013

How To Automatically Empty Trash In WordPress

The Trash feature was introduced in WordPress 2.7, and since then, if you click "Trash" for any item, it will be sent to the trash. It works similar to the Recycling Bin feature on Windows. By default, the content you trash remains there for 30 days before being permanently deleted. However, you can also delete items from the Trash at any time.

You can also modify the 30 day period with some simple codes. Just add this line to wp-config.php and you’re done:

define('EMPTY_TRASH_DAYS', 5 ); // Empty trash every 5 days

Wednesday 25 September 2013

How To Change The Default WordPress Media Uploads Folder


I'm really loving all the wp-config.php tricks. We can do so much amazing stuff with just some little codes.

Before WordPress 3.5 you used to be able to change the upload directory path from the Settings menu in the dashboard. However, now you can't do anything like that from the settings option, but it’s still possible.

How to Change The Default WordPress Media Uploads Folder:

Open wp-config.php (located in root of WordPress installation) and add following code before the line that says require_once(ABSPATH.’wp-settings.php’);.

define( 'UPLOADS', 'wp-content/custom-path' );

Change wp-content/custom-path with your custom upload path. For example, you can can change it to wp-content/files. Don't forget to add the code before require_once(ABSPATH.’wp-settings.php’);.

Thursday 19 September 2013

3 Ways To Disable WordPress AutoSave


This is my second post of the day here on BWidgets, and it's also about Daniel Bryan wp-config.php file and WordPress AutoPost. This time I'll show you one three ways to disable WordPress AutoSave feature.

When editing a post, the changes you make are automatically saved every 2 minutes. You can also use our last trick to Modify AutoSave Interval.

By Editing wp-config.php File:

This is the easiest way to disable WordPress AutoSave feature. To modify autosave interval simply open wp-config.php (located in root of WordPress installation) and add following code to the end of file:

define('AUTOSAVE_INTERVAL', 86400);

We've set WordPress AutoSave interval to 86400 seconds which is an entire day. So this effectively disables the autosave functionality. Thanks to Jacob Nicholson for the idea.

By Editing post.php File:

This is the smartest way to disable AutoSave feature without any heavy codes. Thanks to Shane G. for sharing this trick on a WordPress forum.

  • Open your wp-admin/post.php file and wp-admin/post-new.php files.
  • You will find this line of code there:

wp_enqueue_script('autosave');

  • Add // to the beginning of this code. It'll look something like this:

// wp_enqueue_script('autosave');

The AutoSave option will be disabled for your existing and new posts.

By Editing functions.php File:

Last but not the least. This is the most preferred way to disable this feature, as we don't have to re-edit our post.php and post-new.php file after every WordPress update, nor we have to adjust AutoSave interval. This trick will simple disable AutoSave feature. Thanks to Egill R. Erlendsson for sharing this trick on a WordPress forum.

Simple throw this in your functions.php file:

add_action( 'admin_init', 'disable_autosave' );
function disable_autosave() {
        wp_deregister_script( 'autosave' );
}

That's it folks. Thanks for all amazing guys that I mentioned on the article for sharing these amazing tricks around the internet. Don't forget to give us a backlink if you're sharing this article on your blog.

Modify WordPress AutoSave Interval


Here we're again! Another post about my favorite Pokemon WordPress core file. YES! YES! YES, this post is also about Daniel Bryan wp-config.php file.

When editing a post, the changes you make are automatically saved every 2 minutes. It seems bit weird, but you can actually change the setting for longer delays in between auto-saves, or decrease the setting to make sure you never lose changes.

And we don't need a crappy plugin for this simple hack. Technically, it's not even a hack, but a simple option described in original WordPress codex.

Modify WordPress AutoSave Interval:

To modify autosave interval simply open wp-config.php (located in root of WordPress installation) and add following code to the end of file:

define('AUTOSAVE_INTERVAL', 160 );  // seconds

Replace 160 with your custom autosave interval (in seconds).

Save your config.php file & that's it!

Friday 13 September 2013

How To Disable Or Limit WordPress Post Revisions

Post Revisions are a feature introduced in WordPress 2.6. A revision is automatically stored in your database, whenever you save or draft a post or a page. Earlier this year, I posted an article about Deleting Old WordPress Post Revisions at this link.

Today we're going to learn a very simple tweak to disable or limit WordPress post revisions without installing any crappy plugin, which saves a lot of space. We just have to add a little snippet to your our config.php file.

Limit WordPress Post Revisions:

To limit Post revisions simply open wp-config.php (located in root of WordPress installation) and add following code to the end of file:

define('WP_POST_REVISIONS', 3);

Replace 3 with maximum number of Post revisions per post/page.

Disable WordPress Post Revisions:

To disable Post revisions simply open wp-config.php (located in root of WordPress installation) and add following code to the end of file:

define('WP_POST_REVISIONS', false );

 Save your config.php file & that's it!

Monday 9 September 2013

Editing WordPress wp-config.php File


Editing WordPress core files is a very risky and hard job, especially for WordPress beginners like me. Yea, I'm using WordPress only from last four months, but I have learned a lot from it.

The wp-config.php file is one of the most important files in WordPress. It contains the login information for WordPress to connect to your database as well as table prefix, secret keys, e.t.c. Editing wp-config.php file is very easy, but this file looks a bit scary so beginners usually keeps themselves away from it.

If you installed WordPress using your hosting provider's install wizard, then wp-config.php file will be in your root directory. If you installed WordPress using FTP, then you can find wp-config.php (named as wp-config-sample.php) file in your WordPress download. Don't forget to rename wp-config-sample.php to wp-config.php.

Adding Database Info:

To change the wp-config.php file for your installation, you will need this information:

Database Name
Database Name used by WordPress
Database Username
Username used to access Database
Database Password
Password used by Username to access Database
Database Host
The hostname of your Database Server. A port number, Unix socket file path or pipe may be needed as well. 

Find following lines in your wp-config.php file:

define( 'DB_NAME',     'database_name_here' );
define( 'DB_USER',     'username_here' );
define( 'DB_PASSWORD', 'password_here' );
define( 'DB_HOST',     'localhost' );

It's not that hard. We just have to replace above text with our database's info.

Set Database Name:

Replace 'database_name_here', with the name of your database, e.g. MyDatabaseName.

define( 'DB_NAME', 'MyDatabaseName' );

Set Database User:

Replace 'username_here', with the name of your username e.g. MyUserName.

define( 'DB_USER', 'MyUserName' );

Set Database Password:

Replace 'password_here', with the your password, e.g. MyPassWord.

define( 'DB_PASSWORD', 'MyPassWord' );

Set Database Host:

Replace 'localhost', with the name of your database host, e.g. MyDatabaseHost.
define( 'DB_HOST', 'MyDatabaseHost' );

That's it for this part. Now we have to follow one simple step to complete our wp-config.php file.

Adding Secret Keys:

Now we just have to add some unique keys to our wp-config.php file. Find following in your wp-config.php file:

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' );

Put your unique keys in above spaces. You don't have to remember the keys, just make them long, random and complicated. You can change these keys at any time. You can also use WordPress' online generator to automatically generate these keys for you.

These secret key protects your site from getting hacked. A password like "password" or "facebook" is simple and easily broken. A random password such as "w<$4c$aPHmd%/*]`Oom>(hpdXW|0M=X={we6;Mphvtg+V.o<$|#_}qG(GaVDEsn,~*4i')" takes years to come up with the right combination.

That's it for this time. Now after adding/editing above details, your wp-config.php file is ready for some action. You can now save/update the file to your file manager's root directory to see it in action.

Popular Posts

 
Powered by Blogger.