| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Featherweight |
| 4 |
* Plugin URI: https://foliumstudio.co.uk |
| 5 |
* Description: Featherweight (formerly WP Disable) speeds up WordPress by switching off the features you don't use. <a href="admin.php?page=wp-disable">Open Settings</a> |
| 6 |
* Version: 2.2.3 |
| 7 |
* Requires at least: 6.4 |
| 8 |
* Requires PHP: 7.4 |
| 9 |
* Author: Folium Studio |
| 10 |
* Author URI: https://foliumstudio.co.uk |
| 11 |
* License: GPLv2 or later |
| 12 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 13 |
* Text Domain: wp-disable |
| 14 |
* Domain Path: /lang |
| 15 |
* |
| 16 |
* Copyright (C) 2017-2026 Folium Studio |
| 17 |
*/ |
| 18 |
|
| 19 |
// If this file is called directly, abort. |
| 20 |
if ( ! defined( 'WPINC' ) ) { die; } |
| 21 |
|
| 22 |
define( 'OPTIMISATIONIO_WP_DISABLE_ADDON', true); |
| 23 |
|
| 24 |
// Plugin path/URL constants (used for Folium app asset enqueue, etc.). |
| 25 |
define( 'WP_DISABLE_FILE', __FILE__ ); |
| 26 |
define( 'WP_DISABLE_DIR', plugin_dir_path( __FILE__ ) ); |
| 27 |
define( 'WP_DISABLE_URL', plugin_dir_url( __FILE__ ) ); |
| 28 |
define( 'WP_DISABLE_VERSION', '2.2.3' ); |
| 29 |
|
| 30 |
// Shared Folium UI design framework (vendored, newest-wins). Boots on |
| 31 |
// plugins_loaded:4 and owns the single "Folium" admin menu + app frame. |
| 32 |
require_once __DIR__ . '/lib/folium-ui/loader.php'; |
| 33 |
|
| 34 |
require_once 'lib/class-wpperformance.php'; |
| 35 |
require_once 'lib/class-wpperformance-admin.php'; |
| 36 |
|
| 37 |
/** |
| 38 |
* On plugin activation. |
| 39 |
*/ |
| 40 |
function wpperformance_on_activate() { |
| 41 |
|
| 42 |
WpPerformance::check_spam_comments_delete(); |
| 43 |
|
| 44 |
// Clear the legacy Universal Analytics offload cron if it lingers from |
| 45 |
// a pre-2.0 install (the GA feature has been removed). |
| 46 |
wp_clear_scheduled_hook( 'update_local_ga' ); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* On plugin deactivation. |
| 51 |
*/ |
| 52 |
function wpperformance_on_deactivate() { |
| 53 |
|
| 54 |
WpPerformance::delete_transients(); |
| 55 |
WpPerformance::unschedule_spam_comments_delete(); |
| 56 |
|
| 57 |
// Clean up the legacy GA offload cron, if present. |
| 58 |
wp_clear_scheduled_hook( 'update_local_ga' ); |
| 59 |
} |
| 60 |
|
| 61 |
// Register hook to schedule script in wp_cron(). |
| 62 |
register_activation_hook( __FILE__, 'wpperformance_on_activate' ); |
| 63 |
|
| 64 |
// Remove script from wp_cron upon plugin deactivation. |
| 65 |
register_deactivation_hook( __FILE__, 'wpperformance_on_deactivate' ); |
| 66 |
|
| 67 |
/** |
| 68 |
* Initialize WP_Filesystem if hasn't inited yet. |
| 69 |
*/ |
| 70 |
function wpperformance_init_wp_filesystem() { |
| 71 |
global $wp_filesystem; |
| 72 |
if ( null === $wp_filesystem ) { |
| 73 |
if ( ! function_exists( 'WP_Filesystem' ) ) { |
| 74 |
require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
| 75 |
} |
| 76 |
WP_Filesystem(); |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Disable Google maps ob_end. |
| 82 |
*/ |
| 83 |
function wpperformance_disable_google_maps_ob_end( $html ) { |
| 84 |
global $post; |
| 85 |
$exclude_ids = []; |
| 86 |
$settings = get_option( WpPerformance::OPTION_KEY . '_settings', array() ); |
| 87 |
if ( isset( $settings['exclude_from_disable_google_maps'] ) && '' !== $settings['exclude_from_disable_google_maps'] ) { |
| 88 |
$exclude_ids = array_map( 'intval', explode(',', $settings['exclude_from_disable_google_maps']) ); |
| 89 |
} |
| 90 |
if( $post && ! in_array( $post->ID, $exclude_ids, true ) ){ |
| 91 |
$html = preg_replace( '/<script[^<>]*\/\/maps.(googleapis|google|gstatic).com\/[^<>]*><\/script>/i', '', $html ); |
| 92 |
} |
| 93 |
return $html; |
| 94 |
} |
| 95 |
|
| 96 |
function wpperformance_cron_additions( $schedules ) { |
| 97 |
|
| 98 |
$schedules['weekly'] = array( |
| 99 |
'interval' => 86400 * 7, |
| 100 |
'display' => __( 'Once Weekly', 'wp-disable' ), |
| 101 |
); |
| 102 |
|
| 103 |
$schedules['twicemonthly'] = array( |
| 104 |
'interval' => 86400 * 14, |
| 105 |
'display' => __( 'Twice Monthly', 'wp-disable' ), |
| 106 |
); |
| 107 |
|
| 108 |
$schedules['monthly'] = array( |
| 109 |
'interval' => 86400 * 30, |
| 110 |
'display' => __( 'Once Monthly', 'wp-disable' ), |
| 111 |
); |
| 112 |
|
| 113 |
return $schedules; |
| 114 |
} |
| 115 |
|
| 116 |
add_filter( 'cron_schedules', 'wpperformance_cron_additions' ); |
| 117 |
|
| 118 |
add_action( 'plugins_loaded', array( 'WpPerformance', 'get_instance' ) ); |
| 119 |
|