added maple performance caching plugin
This commit is contained in:
parent
c44c49a836
commit
e468202f95
12 changed files with 4501 additions and 0 deletions
68
native/wordpress/maple-performance-wp/uninstall.php
Normal file
68
native/wordpress/maple-performance-wp/uninstall.php
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* Uninstall Maple Performance WP
|
||||
*
|
||||
* Removes all plugin data when uninstalled.
|
||||
*
|
||||
* @package MaplePerformance
|
||||
*/
|
||||
|
||||
// Exit if not called by WordPress
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Delete options
|
||||
delete_option( 'maple_performance_settings' );
|
||||
|
||||
// Delete cache directory
|
||||
$cache_dir = WP_CONTENT_DIR . '/cache/maple-performance/';
|
||||
|
||||
// Verify path is valid and within wp-content
|
||||
$real_cache_dir = realpath( $cache_dir );
|
||||
$real_content_dir = realpath( WP_CONTENT_DIR );
|
||||
|
||||
if ( $real_cache_dir && $real_content_dir && strpos( $real_cache_dir, $real_content_dir ) === 0 ) {
|
||||
if ( is_dir( $cache_dir ) ) {
|
||||
$files = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator( $cache_dir, RecursiveDirectoryIterator::SKIP_DOTS ),
|
||||
RecursiveIteratorIterator::CHILD_FIRST
|
||||
);
|
||||
|
||||
foreach ( $files as $file ) {
|
||||
$file_path = $file->getRealPath();
|
||||
|
||||
// Verify each file is within cache directory
|
||||
if ( strpos( $file_path, $real_cache_dir ) !== 0 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $file->isDir() ) {
|
||||
@rmdir( $file_path );
|
||||
} else {
|
||||
@unlink( $file_path );
|
||||
}
|
||||
}
|
||||
|
||||
@rmdir( $cache_dir );
|
||||
}
|
||||
}
|
||||
|
||||
// Clear any transients using proper LIKE escaping
|
||||
global $wpdb;
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
$wpdb->query(
|
||||
$wpdb->prepare(
|
||||
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
|
||||
$wpdb->esc_like( '_transient_maple_perf_' ) . '%'
|
||||
)
|
||||
);
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||
$wpdb->query(
|
||||
$wpdb->prepare(
|
||||
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
|
||||
$wpdb->esc_like( '_transient_timeout_maple_perf_' ) . '%'
|
||||
)
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue