Multisite: Add $network_id parameter to filters in get_network_option().

Props flixos90.
Fixes #38319.


git-svn-id: https://develop.svn.wordpress.org/trunk@38815 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
jeremyfelt 2016-10-19 04:53:02 +00:00
parent 2979167ba7
commit be51e30f40

View File

@ -1100,12 +1100,14 @@ function get_network_option( $network_id, $option, $default = false ) {
* *
* @since 2.9.0 As 'pre_site_option_' . $key * @since 2.9.0 As 'pre_site_option_' . $key
* @since 3.0.0 * @since 3.0.0
* @since 4.4.0 The `$option` parameter was added * @since 4.4.0 The `$option` parameter was added.
* @since 4.7.0 The `$network_id` parameter was added.
* *
* @param mixed $pre_option The default value to return if the option does not exist. * @param mixed $pre_option The default value to return if the option does not exist.
* @param string $option Option name. * @param string $option Option name.
* @param int $network_id ID of the network.
*/ */
$pre = apply_filters( "pre_site_option_{$option}", false, $option ); $pre = apply_filters( "pre_site_option_{$option}", false, $option, $network_id );
if ( false !== $pre ) { if ( false !== $pre ) {
return $pre; return $pre;
@ -1124,17 +1126,19 @@ function get_network_option( $network_id, $option, $default = false ) {
* *
* @since 3.4.0 * @since 3.4.0
* @since 4.4.0 The `$option` parameter was added. * @since 4.4.0 The `$option` parameter was added.
* @since 4.7.0 The `$network_id` parameter was added.
* *
* @param mixed $default The value to return if the site option does not exist * @param mixed $default The value to return if the site option does not exist
* in the database. * in the database.
* @param string $option Option name. * @param string $option Option name.
* @param int $network_id ID of the network.
*/ */
return apply_filters( "default_site_option_{$option}", $default, $option ); return apply_filters( "default_site_option_{$option}", $default, $option, $network_id );
} }
if ( ! is_multisite() ) { if ( ! is_multisite() ) {
/** This filter is documented in wp-includes/option.php */ /** This filter is documented in wp-includes/option.php */
$default = apply_filters( 'default_site_option_' . $option, $default, $option ); $default = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );
$value = get_option( $option, $default ); $value = get_option( $option, $default );
} else { } else {
$cache_key = "$network_id:$option"; $cache_key = "$network_id:$option";
@ -1156,7 +1160,7 @@ function get_network_option( $network_id, $option, $default = false ) {
wp_cache_set( $notoptions_key, $notoptions, 'site-options' ); wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
/** This filter is documented in wp-includes/option.php */ /** This filter is documented in wp-includes/option.php */
$value = apply_filters( 'default_site_option_' . $option, $default, $option ); $value = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );
} }
} }
} }
@ -1168,12 +1172,14 @@ function get_network_option( $network_id, $option, $default = false ) {
* *
* @since 2.9.0 As 'site_option_' . $key * @since 2.9.0 As 'site_option_' . $key
* @since 3.0.0 * @since 3.0.0
* @since 4.4.0 The `$option` parameter was added * @since 4.4.0 The `$option` parameter was added.
* @since 4.7.0 The `$network_id` parameter was added.
* *
* @param mixed $value Value of network option. * @param mixed $value Value of network option.
* @param string $option Option name. * @param string $option Option name.
* @param int $network_id ID of the network.
*/ */
return apply_filters( "site_option_{$option}", $value, $option ); return apply_filters( "site_option_{$option}", $value, $option, $network_id );
} }
/** /**