-
Notifications
You must be signed in to change notification settings - Fork 138
Add module to warn about excessive amount of autoloaded options #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
3528dd8
b5049c0
eac9521
d3f7d52
74932f8
11dd3f3
be7b17d
814bb4a
a1ebb71
389a0ff
7c6a9f7
b6a1949
f45fc53
725bbd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,42 +63,43 @@ function perflab_aao_autoloaded_options_test() { | |
| */ | ||
| $limit = apply_filters( 'perflab_aao_autoloaded_options_limit_size_in_bytes', 800000 ); | ||
|
|
||
| if ( $autoloaded_options_size > $limit ) { | ||
| $result['status'] = 'critical'; | ||
| $result['badge']['color'] = 'red'; | ||
| $result['description'] = sprintf( | ||
| /* translators: 1: Number of autoloaded options. 2.Autoloaded options size. */ | ||
| '<p>' . esc_html__( 'Your website uses %1$s autoloaded options (size: %2$s). Try to reduce the number of autoloaded options or performance will be affected.', 'performance-lab' ) . '</p>', | ||
| $autoloaded_options_count, | ||
| size_format( $autoloaded_options_size ) | ||
| ); | ||
| if ( $autoloaded_options_size < $limit ) { | ||
| return $result; | ||
| } | ||
|
|
||
| /** | ||
| * Hostings can modify description to be shown on site health screen. | ||
| * | ||
| * @since 1.0.0 | ||
| * | ||
| * @param string $description Description message when autoloaded options bigger than treshold. | ||
| */ | ||
| $result['description'] = apply_filters( 'perflab_aao_autoloaded_options_limit_description', $result['description'] ); | ||
| $result['status'] = 'critical'; | ||
| $result['badge']['color'] = 'red'; | ||
| $result['description'] = sprintf( | ||
| /* translators: 1: Number of autoloaded options. 2.Autoloaded options size. */ | ||
| '<p>' . esc_html__( 'Your website uses %1$s autoloaded options (size: %2$s). Try to reduce the number of autoloaded options or performance will be affected.', 'performance-lab' ) . '</p>', | ||
| $autoloaded_options_count, | ||
| size_format( $autoloaded_options_size ) | ||
| ); | ||
|
|
||
| $result['actions'] = sprintf( | ||
| /* translators: 1: HelpHub URL. 2: Link description. */ | ||
| '<p><a target="_blank" href="%1$s">%2$s</a></p>', | ||
| esc_url( __( 'https://wordpress.org/support/article/optimization/', 'performance-lab' ) ), | ||
| esc_html__( 'More info about performance optimization', 'performance-lab' ) | ||
| ); | ||
| /** | ||
| * Hostings can modify description to be shown on site health screen. | ||
felixarntz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * @since 1.0.0 | ||
| * | ||
| * @param string $description Description message when autoloaded options bigger than treshold. | ||
| */ | ||
| $result['description'] = apply_filters( 'perflab_aao_autoloaded_options_limit_description', $result['description'] ); | ||
|
|
||
| /** | ||
| * Hostings can add actions to take to reduce size of autoloaded options linking to their own guides. | ||
| * | ||
| * @since 1.0.0 | ||
| * | ||
| * @param string $actions Call to Action to be used to point to the right direction to solve the issue. | ||
| */ | ||
| $result['actions'] = apply_filters( 'perflab_aao_autoloaded_options_action_to_perform', $result['actions'] ); | ||
| } | ||
| $result['actions'] = sprintf( | ||
| /* translators: 1: HelpHub URL. 2: Link description. */ | ||
| '<p><a target="_blank" href="%1$s">%2$s</a></p>', | ||
| esc_url( __( 'https://wordpress.org/support/article/optimization/', 'performance-lab' ) ), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this link should go right to a support section explaining how to optimize autoload options, eg
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with this, https://wordpress.org/support/article/optimization/#autoload should be written and we can link in there. |
||
| esc_html__( 'More info about performance optimization', 'performance-lab' ) | ||
| ); | ||
|
|
||
| /** | ||
| * Hostings can add actions to take to reduce size of autoloaded options linking to their own guides. | ||
felixarntz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * @since 1.0.0 | ||
| * | ||
| * @param string $actions Call to Action to be used to point to the right direction to solve the issue. | ||
| */ | ||
| $result['actions'] = apply_filters( 'perflab_aao_autoloaded_options_action_to_perform', $result['actions'] ); | ||
| return $result; | ||
| } | ||
|
|
||
|
|
@@ -111,5 +112,5 @@ function perflab_aao_autoloaded_options_test() { | |
| */ | ||
| function perflab_aao_autoloaded_options_size() { | ||
| global $wpdb; | ||
| return $wpdb->get_var( 'SELECT SUM(LENGTH(option_value)) FROM ' . $wpdb->prefix . 'options WHERE autoload = \'yes\'' ); | ||
| return (int) $wpdb->get_var( 'SELECT SUM(LENGTH(option_value)) FROM ' . $wpdb->prefix . 'options WHERE autoload = \'yes\'' ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.