Created
June 8, 2020 11:00
-
-
Save maheshwaghmare/2973a996d133d8aa35e5ffe1220262fa to your computer and use it in GitHub Desktop.
Get autoload heavy options from the WordPress `wp_options` ($wpdb->options) table.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get autoload heavy options from options table | |
* | |
* @todo Change the `prefix_` and with your own unique prefix. | |
* | |
* @since 1.0.0 | |
*/ | |
if( ! function_exists( 'prefix_get_heavy_autoload_options' ) ) : | |
function prefix_get_heavy_autoload_options() { | |
global $wpdb; | |
$details = $wpdb->get_col( "SELECT `option_name`, length(`option_value`) AS `option_value_length` FROM {$wpdb->options} WHERE autoload='yes' ORDER BY option_value_length DESC LIMIT 10" ); | |
var_dump( $details ); | |
// Output: (Something similar) | |
// | |
// array (size=10) | |
// 0 => string 'xxxxxxxxxxxx' (length=17) | |
// 1 => string 'xxxxxxxxxxxxxxxxxx' (length=23) | |
// 2 => string 'xxxxxxxxxxxxxxxxxxx' (length=41) | |
// 3 => string 'xxxxxxxxxxxxxx-1' (length=27) | |
// 4 => string 'xxxxxxxxxxxxxx-2' (length=27) | |
// 5 => string 'xxxxxxxxxxxxxx-3' (length=27) | |
// 6 => string 'xxxxxxxxxxxxxxxxx' (length=23) | |
// 7 => string 'xxxxxxxxxxxxxxxxxxxxxxx' (length=16) | |
// 8 => string 'xxxxxxxxxxxxx' (length=13) | |
// 9 => string 'xxxxxxxxxxxxxxxxxxxxxxxxx' (length=32) | |
wp_die(); | |
} | |
add_action( 'wp_head', 'prefix_get_heavy_autoload_options' ); | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment