Sanjeev Sabhlok's notes on technology, hardware, gardening

Category: Wordpress

How to remove transients from WordPress database + jetpack_nonce

I have a lot of transients, such as:

_transient_jpp_li

_transient_timeout_jpp_li

etc.

These need to be removed physically from time to time:

Run the following query:

DELETE FROM `wp_xxxx_options` WHERE `option_name` LIKE (‘%\_transient\_%’)

Then optimise those tables that have overhead.

I reduced my database size by around 8MB in this manner

ALSO CONSIDER THIS.

jetpack_nonce

This is a big issue. However, I don’t yet know what to do about it.

 

 

Continue Reading

How to fix the 500 internal server error on Dreamhost/ How to optimise WordPress

READ THIS FIRST. Particularly this.

Step 1: Find the error log

https://help.dreamhost.com/hc/en-us/articles/216512197-Viewing-your-error-log-via-SFTP

Step 2: Review the bottom of the error log

I was getting massive errors “Premature end of script headers: index.php” and “Premature end of script headers: xmlrpc.php” – sometimes tens of times every minute.

Step 3: SQL Database – Optimise WordPress tables through phpmyadmin

My database is usually around 96MB. It had grown to 115MB.

DO NOT USE WP-OPTIMISE since it will freeze.

Go to phpmyadmin, select tables with overhead and run optimise from the drop-down menu

Step 4: SQL Database – remove transients

I had thousands of transients in the options table. Removed them (this way – Somehow this doesn’t work anymore, so I’ve started using WP-Optimise again, but only one item at at time, e.g. remove the transients.

Manually Remove Redundant Data From MySQL
Clean up “wp_commentmeta” Junk Entries – Use the following command to delete “junk” entries which have no relation to wp_comments. Junk entries are like orphan entires, data from comments you removed and etc.

DELETE FROM wp_commentmeta WHERE comment_id
NOT IN (
SELECT comment_id
FROM wp_comments
)

Step 5: Plugin: Check cache settings

My cache settings (Super cache) needed to be carefully checked

Step 6: Plugin: Smush it

I installed WP Smush plugin and smushed nearly 2000 images (free version does it, but 50 at a time).

Step 7: Plugin: Minify

I installed WP Super Minify to minify javascript and CSS. I still get a bad score on pingdom for these things, but I don’t know how else to fix this issue.

With all this, the site has come back to life and I can now make new posts/ manage the site without it collapsing/ freezing every second.

ADD THESE TO FUNCTIONS.PHP

DEFER PARSING JAVASCRIPT

/**
* Defer parsing of javascript.
*/
if (!(is_admin() )) {
function defer_parsing_of_js ( $url ) {
if ( FALSE === strpos( $url, ‘.js’ ) ) return $url;
if ( strpos( $url, ‘jquery.js’ ) ) return $url;
// return “$url’ defer “;
return “$url’ defer onload='”;
}
add_filter( ‘clean_url’, ‘defer_parsing_of_js’, 11, 1 );
}

FORCE SCRIPTS INTO FOOTER

/**
* Force scripts into Footer
* @link https://developer.wordpress.org/reference/since/4.2.0/
*/
function enqueue_scripts_in_footer() {
wp_deregister_script( ‘jquery’ ); // https://codex.wordpress.org/Function_Reference/wp_deregister_script
wp_deregister_script( ‘jquery-migrate.min’ );
wp_register_script( ‘jquery’, ‘/wp-includes/js/jquery/jquery.js’, array(), false, true );
wp_register_script( ‘jquery-migrate.min’, ‘/wp-includes/js/jquery/jquery-migrate.min.js’, array(), false, true );
wp_enqueue_script( ‘jquery’, ‘/wp-includes/js/jquery/jquery.js’, array( ‘jquery’ ), false, true );
wp_enqueue_script( ‘jquery-migrate.min’, ‘/wp-includes/js/jquery/jquery-migrate.min.js’, array( ‘jquery-migrate.min’ ), false, true );
}
add_action( ‘wp_enqueue_scripts’, ‘enqueue_scripts_in_footer’ );

 

REMOVE EMOJIS Remove emojis

remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );

 

Continue Reading

Fatal error: Call to undefined function wp_removable_query_args() in …/wp-admin/includes/misc.php on line 900

This is a terrible error, requiring reinstallation of wordpress. The basic installation is swrewed up.

You can’t get access to the wordpress dashboard nor can tinkering with anything (e.g. wp-config.php) help.

SOLUTION ON DREAMHOST

1. Make sure you backup the database through phpmyadmin

2. Take a backup of all server files through FTP. While you CAN’T use most of these files again, you may need some of them, e.g. images that you have separately uploaded.

3. Delete ALL files on the server (including . files, e.g. .htaccess)

4. Go to one-click install and install a new wordpress through Dreamhost

This will provide a totally new table prefix. You now need to:

a) backup the database in case needed again

b) one by one drop and reaname tables

THIS IS VERY COMPLEX BUT NO OTHER WAY EXISTS.

Continue Reading