Ticket #19910: default_option.diff

File default_option.diff, 1.7 KB (added by Otto42, 13 months ago)

add and use a default_option_ filter

Line 
1Index: wp-includes/class-wp-customize-setting.php
2===================================================================
3--- wp-includes/class-wp-customize-setting.php  (revision 20725)
4+++ wp-includes/class-wp-customize-setting.php  (working copy)
5@@ -68,8 +68,10 @@
6                        case 'option' :
7                                if ( empty( $this->id_data[ 'keys' ] ) )
8                                        add_filter( 'pre_option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
9-                               else
10+                               else {
11                                        add_filter( 'option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
12+                                       add_filter( 'default_option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
13+                               }
14                                break;
15                        default :
16                                do_action( 'customize_preview_' . $this->id );
17Index: wp-includes/option.php
18===================================================================
19--- wp-includes/option.php      (revision 20725)
20+++ wp-includes/option.php      (working copy)
21@@ -48,7 +48,7 @@
22                // prevent non-existent options from triggering multiple queries
23                $notoptions = wp_cache_get( 'notoptions', 'options' );
24                if ( isset( $notoptions[$option] ) )
25-                       return $default;
26+                       return apply_filters('default_option_'.$option, $default);
27 
28                $alloptions = wp_load_alloptions();
29 
30@@ -67,7 +67,7 @@
31                                } else { // option does not exist, so we must cache its non-existence
32                                        $notoptions[$option] = true;
33                                        wp_cache_set( 'notoptions', $notoptions, 'options' );
34-                                       return $default;
35+                                       return apply_filters('default_option_'.$option, $default);
36                                }
37                        }
38                }
39@@ -78,7 +78,7 @@
40                if ( is_object( $row ) )
41                        $value = $row->option_value;
42                else
43-                       return $default;
44+                       return apply_filters('default_option_'.$option, $default);
45        }
46 
47        // If home is not set use siteurl.