Ticket #39072: gmt_offset_rest_api.diff
File gmt_offset_rest_api.diff, 1.9 KB (added by , 7 years ago) |
---|
-
wp-includes/default-filters.php
385 385 add_action( 'rest_api_init', 'register_initial_settings', 10 ); 386 386 add_action( 'rest_api_init', 'create_initial_rest_routes', 99 ); 387 387 add_action( 'parse_request', 'rest_api_loaded' ); 388 add_filter( 'rest_pre_update_setting', 'rest_pre_update_settings', 10, 4 ); 388 389 389 390 /** 390 391 * Filters formerly mixed into wp-includes -
wp-includes/option.php
1771 1771 'description' => __( 'A city in the same timezone as you.' ), 1772 1772 ) ); 1773 1773 1774 register_setting( 'general', 'gmt_offset', array( 1775 'show_in_rest' => true, 1776 'type' => 'string', 1777 'description' => __( 'UTC timezone offset.' ), 1778 ) ); 1779 1774 1780 register_setting( 'general', 'date_format', array( 1775 1781 'show_in_rest' => true, 1776 1782 'type' => 'string', … … 2010 2016 2011 2017 return $registered[ $option ]['default']; 2012 2018 } 2019 2020 /** 2021 * Runs before the value of an option is updated via the REST API. 2022 * 2023 * @param bool $result Whether to override the default behavior for updating the 2024 * value of a setting. 2025 * @param string $name Setting name (as shown in REST API responses). 2026 * @param mixed $value Updated setting value. 2027 * @param array $args Arguments passed to register_setting() for this setting. 2028 * @return bool False if value was not updated and true if value was updated. 2029 */ 2030 function rest_pre_update_settings( $result, $name, $value, $args ) { 2031 switch ( $name ) { 2032 case 'gmt_offset': 2033 update_option( 'timezone_string', '' ); 2034 update_option( 'gmt_offset', $value ); 2035 return true; 2036 default: 2037 return $result; 2038 } 2039 }