-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path0_dedicated_transients.php
55 lines (48 loc) · 1.27 KB
/
0_dedicated_transients.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
$di_plugin_constants = WP_PLUGIN_DIR . '/dedicated-transients/constants.php';
if ( is_file( $di_plugin_constants ) ) {
include_once $di_plugin_constants;
}
if ( ! defined( 'DEDICATED_TRANSIENTS_WPMU_DROPIN' ) ||
! defined( 'DEDICATED_TRANSIENTS_TABLE' ) ||
! defined( 'DEDICATED_TRANSIENTS_WPMU_TABLE' ) ) {
return;
}
/**
* @param string $query
*/
function dedicated_transients_process_query( $query ) {
global $wpdb;
if ( false !== strpos( $query, $wpdb->options ) ) {
foreach (
array(
'_transient_',
'\_transient\_',
'_transient_timeout',
'\_transient\_timeout',
) as $search
) {
if ( false !== strpos( $query, $search ) ) {
$query = str_replace( $wpdb->options, $wpdb->get_blog_prefix() . DEDICATED_TRANSIENTS_TABLE, $query );
break;
}
}
}
if ( is_multisite() && false !== strpos( $query, $wpdb->sitemeta ) ) {
foreach (
array(
'_site_transient_',
'\_site\_transient\_',
'_site_transient_timeout',
'\_site\_transient\_timeout',
) as $search
) {
if ( false !== strpos( $query, $search ) ) {
$query = str_replace( $wpdb->sitemeta, $wpdb->base_prefix . DEDICATED_TRANSIENTS_WPMU_TABLE, $query );
break;
}
}
}
return $query;
}
add_filter( 'query', 'dedicated_transients_process_query' );