mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-29 15:44:27 +00:00
Widgets: when getting settings, and none exist, set them to empty to avoid extraneous database queries on subsequent requests.
Adds unit tests. Props kovshenin, MikeHansenMe, dlh. Fixes #26876. git-svn-id: https://develop.svn.wordpress.org/trunk@35100 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -539,8 +539,13 @@ class WP_Widget {
|
||||
|
||||
$settings = get_option( $this->option_name );
|
||||
|
||||
if ( false === $settings && isset( $this->alt_option_name ) ) {
|
||||
$settings = get_option( $this->alt_option_name );
|
||||
if ( false === $settings ) {
|
||||
if ( isset( $this->alt_option_name ) ) {
|
||||
$settings = get_option( $this->alt_option_name );
|
||||
} else {
|
||||
// Save an option so it can be autoloaded next time.
|
||||
$this->save_settings( array() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! is_array( $settings ) && ! ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) ) {
|
||||
|
||||
Reference in New Issue
Block a user