Skip to content

Instantly share code, notes, and snippets.

View Digiover's full-sized avatar
💭
☕️

Jan Reilink Digiover

💭
☕️
View GitHub Profile
@Digiover
Digiover / wp-database-tables-optimizer.php
Last active April 15, 2019 15:26
Optimizes WordPress database behind the scenes by executing an OPTIMIZE TABLE statement on all MySQL tables, 'daily' or 'hourly' as a WordPress Cron. More information @ https://www.saotn.org/optimize-wordpress-mysql-tables-cron/
<?php
/**
* Plugin Name: Saotn Database Table Optimizer
* Plugin URI: https://www.saotn.org
* Description: Optimizes WordPress database behind the scenes by executing an OPTIMIZE TABLE statement on all MySQL tables, 'daily' or 'hourly'. Please <a rel="nofollow" target="_blank" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=4EFPSXA623NZA" title="donate to Sysadmins of the North">donate $2.50 USD</a> through PayPal to support me in my research time and hosting costs.
* Version: 1.0.2
* Author: Jan Reilink
* Author URI: https://www.saotn.org
* License: GPLv2
*/
@Digiover
Digiover / check-website-availability.php
Last active January 15, 2022 07:17
PHP/cURL function to check a web site status. If HTTP status is not 200 or 302, or the requests takes longer than 10 seconds, the website is unreachable. See https://www.saotn.org/php-curl-check-website-availability/.
<?php
/**
* PHP/cURL function to check a web site status. If HTTP status is not 200 or 302, or
* the requests takes longer than 10 seconds, the website is unreachable.
*
* Follow me on Twitter: @Jan_Reilink
*
* @param string $url URL that must be checked
*/
function url_test($url) {
@Digiover
Digiover / saotn-wpdb-optimizer.php
Last active June 7, 2023 08:35
Executes an OPTIMIZE TABLE statement on all WordPress MySQL database tables, for instance from within a plugin: https://www.saotn.org/optimize-wordpress-mysql-tables-cron/
/**
* Executes an OPTIMIZE TABLE statement on all WordPress database
* tables.
*/
public static function saotn_wpdb_optimizer() {
global $wpdb;
$tables = $wpdb->get_col( "SHOW TABLES" );
foreach ( $tables as $table ) {
$wpdb->query( "OPTIMIZE TABLE $table" );
}