Changeset 54948
- Timestamp:
- 12/07/2022 09:30:47 PM (23 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/option.php
r54637 r54948 30 30 * Exceptions: 31 31 * 32 * 1. When the option has not been saved in the database, the `$default ` value32 * 1. When the option has not been saved in the database, the `$default_value` value 33 33 * is returned if provided. If not, boolean `false` is returned. 34 34 * 2. When one of the Options API filters is used: {@see 'pre_option_$option'}, … … 68 68 * @global wpdb $wpdb WordPress database abstraction object. 69 69 * 70 * @param string $option Name of the option to retrieve. Expected to not be SQL-escaped.71 * @param mixed $default Optional. Default value to return if the option does not exist.70 * @param string $option Name of the option to retrieve. Expected to not be SQL-escaped. 71 * @param mixed $default_value Optional. Default value to return if the option does not exist. 72 72 * @return mixed Value of the option. A value of any type may be returned, including 73 73 * scalar (string, boolean, float, integer), null, array, object. … … 76 76 * boolean `false` is returned. 77 77 */ 78 function get_option( $option, $default = false ) {78 function get_option( $option, $default_value = false ) { 79 79 global $wpdb; 80 80 … … 107 107 ) 108 108 ); 109 return get_option( $deprecated_keys[ $option ], $default );109 return get_option( $deprecated_keys[ $option ], $default_value ); 110 110 } 111 111 … … 120 120 * @since 1.5.0 121 121 * @since 4.4.0 The `$option` parameter was added. 122 * @since 4.9.0 The `$default ` parameter was added.123 * 124 * @param mixed $pre_option The value to return instead of the option value. This differs125 * from `$default`, which is used as the fallback value in the event126 * the option doesn't exist elsewhere in get_option().127 * Default false (to skip past the short-circuit).128 * @param string $option Option name.129 * @param mixed $default 130 * Default false.131 */ 132 $pre = apply_filters( "pre_option_{$option}", false, $option, $default );122 * @since 4.9.0 The `$default_value` parameter was added. 123 * 124 * @param mixed $pre_option The value to return instead of the option value. This differs from 125 * `$default_value`, which is used as the fallback value in the event 126 * the option doesn't exist elsewhere in get_option(). 127 * Default false (to skip past the short-circuit). 128 * @param string $option Option name. 129 * @param mixed $default_value The fallback value to return if the option does not exist. 130 * Default false. 131 */ 132 $pre = apply_filters( "pre_option_{$option}", false, $option, $default_value ); 133 133 134 134 /** … … 140 140 * @since 6.1.0 141 141 * 142 * @param mixed $pre_option The value to return instead of the option value. This differs143 * from `$default`, which is used as the fallback value in the event144 * the option doesn't exist elsewhere in get_option().145 * Default false (to skip past the short-circuit).146 * @param string $option Name of the option.147 * @param mixed $default 148 * Default false.149 */ 150 $pre = apply_filters( 'pre_option', $pre, $option, $default );142 * @param mixed $pre_option The value to return instead of the option value. This differs from 143 * `$default_value`, which is used as the fallback value in the event 144 * the option doesn't exist elsewhere in get_option(). 145 * Default false (to skip past the short-circuit). 146 * @param string $option Name of the option. 147 * @param mixed $default_value The fallback value to return if the option does not exist. 148 * Default false. 149 */ 150 $pre = apply_filters( 'pre_option', $pre, $option, $default_value ); 151 151 152 152 if ( false !== $pre ) { … … 181 181 * @since 4.7.0 The `$passed_default` parameter was added to distinguish between a `false` value and the default parameter value. 182 182 * 183 * @param mixed $default The default value to return if the option does not exist184 * in the database.185 * @param string $option Option name.183 * @param mixed $default_value The default value to return if the option does not exist 184 * in the database. 185 * @param string $option Option name. 186 186 * @param bool $passed_default Was `get_option()` passed a default value? 187 187 */ 188 return apply_filters( "default_option_{$option}", $default , $option, $passed_default );188 return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default ); 189 189 } 190 190 … … 212 212 213 213 /** This filter is documented in wp-includes/option.php */ 214 return apply_filters( "default_option_{$option}", $default , $option, $passed_default );214 return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default ); 215 215 } 216 216 } … … 225 225 } else { 226 226 /** This filter is documented in wp-includes/option.php */ 227 return apply_filters( "default_option_{$option}", $default , $option, $passed_default );227 return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default ); 228 228 } 229 229 } … … 1146 1146 * @since 2.7.0 1147 1147 * 1148 * @param string $name The name of the setting.1149 * @param string|false $default Optional. Default value to return when $name is not set. Default false.1148 * @param string $name The name of the setting. 1149 * @param string|false $default_value Optional. Default value to return when $name is not set. Default false. 1150 1150 * @return mixed The last saved user setting or the default value/false if it doesn't exist. 1151 1151 */ 1152 function get_user_setting( $name, $default = false ) {1152 function get_user_setting( $name, $default_value = false ) { 1153 1153 $all_user_settings = get_all_user_settings(); 1154 1154 1155 return isset( $all_user_settings[ $name ] ) ? $all_user_settings[ $name ] : $default ;1155 return isset( $all_user_settings[ $name ] ) ? $all_user_settings[ $name ] : $default_value; 1156 1156 } 1157 1157 … … 1325 1325 * @see get_network_option() 1326 1326 * 1327 * @param string $option Name of the option to retrieve. Expected to not be SQL-escaped.1328 * @param mixed $default 1329 * @param bool $deprecated Whether to use cache. Multisite only. Always set to true.1327 * @param string $option Name of the option to retrieve. Expected to not be SQL-escaped. 1328 * @param mixed $default_value Optional. Value to return if the option doesn't exist. Default false. 1329 * @param bool $deprecated Whether to use cache. Multisite only. Always set to true. 1330 1330 * @return mixed Value set for the option. 1331 1331 */ 1332 function get_site_option( $option, $default = false, $deprecated = true ) {1333 return get_network_option( null, $option, $default );1332 function get_site_option( $option, $default_value = false, $deprecated = true ) { 1333 return get_network_option( null, $option, $default_value ); 1334 1334 } 1335 1335 … … 1392 1392 * @global wpdb $wpdb WordPress database abstraction object. 1393 1393 * 1394 * @param int $network_id ID of the network. Can be null to default to the current network ID.1395 * @param string $option Name of the option to retrieve. Expected to not be SQL-escaped.1396 * @param mixed $default 1394 * @param int $network_id ID of the network. Can be null to default to the current network ID. 1395 * @param string $option Name of the option to retrieve. Expected to not be SQL-escaped. 1396 * @param mixed $default_value Optional. Value to return if the option doesn't exist. Default false. 1397 1397 * @return mixed Value set for the option. 1398 1398 */ 1399 function get_network_option( $network_id, $option, $default = false ) {1399 function get_network_option( $network_id, $option, $default_value = false ) { 1400 1400 global $wpdb; 1401 1401 … … 1423 1423 * @since 4.4.0 The `$option` parameter was added. 1424 1424 * @since 4.7.0 The `$network_id` parameter was added. 1425 * @since 4.9.0 The `$default ` parameter was added.1426 * 1427 * @param mixed $pre_option The value to return instead of the option value. This differs1428 * from `$default`, which is used as the fallback value in the event1429 * the option doesn't exist elsewhere in get_network_option().1430 * Default false (to skip past the short-circuit).1431 * @param string $option Option name.1432 * @param int $network_id ID of the network.1433 * @param mixed $default 1434 * Default false.1435 */ 1436 $pre = apply_filters( "pre_site_option_{$option}", false, $option, $network_id, $default );1425 * @since 4.9.0 The `$default_value` parameter was added. 1426 * 1427 * @param mixed $pre_option The value to return instead of the option value. This differs from 1428 * `$default_value`, which is used as the fallback value in the event 1429 * the option doesn't exist elsewhere in get_network_option(). 1430 * Default false (to skip past the short-circuit). 1431 * @param string $option Option name. 1432 * @param int $network_id ID of the network. 1433 * @param mixed $default_value The fallback value to return if the option does not exist. 1434 * Default false. 1435 */ 1436 $pre = apply_filters( "pre_site_option_{$option}", false, $option, $network_id, $default_value ); 1437 1437 1438 1438 if ( false !== $pre ) { … … 1455 1455 * @since 4.7.0 The `$network_id` parameter was added. 1456 1456 * 1457 * @param mixed $default 1458 * in the database.1459 * @param string $option Option name.1460 * @param int $network_id ID of the network.1457 * @param mixed $default_value The value to return if the site option does not exist 1458 * in the database. 1459 * @param string $option Option name. 1460 * @param int $network_id ID of the network. 1461 1461 */ 1462 return apply_filters( "default_site_option_{$option}", $default , $option, $network_id );1462 return apply_filters( "default_site_option_{$option}", $default_value, $option, $network_id ); 1463 1463 } 1464 1464 1465 1465 if ( ! is_multisite() ) { 1466 1466 /** This filter is documented in wp-includes/option.php */ 1467 $default = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );1468 $value = get_option( $option, $default );1467 $default_value = apply_filters( 'default_site_option_' . $option, $default_value, $option, $network_id ); 1468 $value = get_option( $option, $default_value ); 1469 1469 } else { 1470 1470 $cache_key = "$network_id:$option"; … … 1488 1488 1489 1489 /** This filter is documented in wp-includes/option.php */ 1490 $value = apply_filters( 'default_site_option_' . $option, $default , $option, $network_id );1490 $value = apply_filters( 'default_site_option_' . $option, $default_value, $option, $network_id ); 1491 1491 } 1492 1492 } … … 2555 2555 * @since 4.7.0 2556 2556 * 2557 * @param mixed $default 2557 * @param mixed $default_value Existing default value to return. 2558 2558 * @param string $option Option name. 2559 2559 * @param bool $passed_default Was `get_option()` passed a default value? 2560 2560 * @return mixed Filtered default value. 2561 2561 */ 2562 function filter_default_option( $default , $option, $passed_default ) {2562 function filter_default_option( $default_value, $option, $passed_default ) { 2563 2563 if ( $passed_default ) { 2564 return $default ;2564 return $default_value; 2565 2565 } 2566 2566 2567 2567 $registered = get_registered_settings(); 2568 2568 if ( empty( $registered[ $option ] ) ) { 2569 return $default ;2569 return $default_value; 2570 2570 } 2571 2571
Note: See TracChangeset
for help on using the changeset viewer.