Changeset 42343 for trunk/src/wp-includes/option.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/option.php
r42228 r42343 32 32 33 33 $option = trim( $option ); 34 if ( empty( $option ) ) 34 if ( empty( $option ) ) { 35 35 return false; 36 } 36 37 37 38 /** … … 46 47 * @since 4.4.0 The `$option` parameter was added. 47 48 * @since 4.9.0 The `$default` parameter was added. 48 *49 49 * 50 50 * @param bool|mixed $pre_option The value to return instead of the option value. This differs from … … 58 58 $pre = apply_filters( "pre_option_{$option}", false, $option, $default ); 59 59 60 if ( false !== $pre ) 60 if ( false !== $pre ) { 61 61 return $pre; 62 63 if ( defined( 'WP_SETUP_CONFIG' ) ) 62 } 63 64 if ( defined( 'WP_SETUP_CONFIG' ) ) { 64 65 return false; 66 } 65 67 66 68 // Distinguish between `false` as a default, and not passing one. … … 90 92 $alloptions = wp_load_alloptions(); 91 93 92 if ( isset( $alloptions[ $option] ) ) {93 $value = $alloptions[ $option];94 if ( isset( $alloptions[ $option ] ) ) { 95 $value = $alloptions[ $option ]; 94 96 } else { 95 97 $value = wp_cache_get( $option, 'options' ); … … 106 108 $notoptions = array(); 107 109 } 108 $notoptions[ $option] = true;110 $notoptions[ $option ] = true; 109 111 wp_cache_set( 'notoptions', $notoptions, 'options' ); 110 112 … … 116 118 } else { 117 119 $suppress = $wpdb->suppress_errors(); 118 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );120 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); 119 121 $wpdb->suppress_errors( $suppress ); 120 122 if ( is_object( $row ) ) { … … 127 129 128 130 // If home is not set use siteurl. 129 if ( 'home' == $option && '' == $value ) 131 if ( 'home' == $option && '' == $value ) { 130 132 return get_option( 'siteurl' ); 131 132 if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) ) 133 } 134 135 if ( in_array( $option, array( 'siteurl', 'home', 'category_base', 'tag_base' ) ) ) { 133 136 $value = untrailingslashit( $value ); 137 } 134 138 135 139 /** … … 160 164 */ 161 165 function wp_protect_special_option( $option ) { 162 if ( 'alloptions' === $option || 'notoptions' === $option ) 166 if ( 'alloptions' === $option || 'notoptions' === $option ) { 163 167 wp_die( sprintf( __( '%s is a protected WP option and may not be modified' ), esc_html( $option ) ) ); 168 } 164 169 } 165 170 … … 202 207 $alloptions = array(); 203 208 foreach ( (array) $alloptions_db as $o ) { 204 $alloptions[ $o->option_name] = $o->option_value;209 $alloptions[ $o->option_name ] = $o->option_value; 205 210 } 206 211 … … 240 245 global $wpdb; 241 246 242 if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() ) 247 if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() ) { 243 248 return; 244 245 if ( empty($network_id) ) 249 } 250 251 if ( empty( $network_id ) ) { 246 252 $network_id = get_current_network_id(); 247 248 $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' ); 249 250 $core_options_in = "'" . implode("', '", $core_options) . "'"; 251 $options = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $network_id ) ); 253 } 254 255 $core_options = array( 'site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' ); 256 257 $core_options_in = "'" . implode( "', '", $core_options ) . "'"; 258 $options = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $network_id ) ); 252 259 253 260 foreach ( $options as $option ) { 254 $key = $option->meta_key;255 $cache_key = "{$network_id}:$key";261 $key = $option->meta_key; 262 $cache_key = "{$network_id}:$key"; 256 263 $option->meta_value = maybe_unserialize( $option->meta_value ); 257 264 … … 286 293 global $wpdb; 287 294 288 $option = trim( $option);289 if ( empty( $option) )295 $option = trim( $option ); 296 if ( empty( $option ) ) { 290 297 return false; 298 } 291 299 292 300 wp_protect_special_option( $option ); 293 301 294 if ( is_object( $value ) ) 302 if ( is_object( $value ) ) { 295 303 $value = clone $value; 296 297 $value = sanitize_option( $option, $value ); 304 } 305 306 $value = sanitize_option( $option, $value ); 298 307 $old_value = get_option( $option ); 299 308 … … 368 377 369 378 $result = $wpdb->update( $wpdb->options, $update_args, array( 'option_name' => $option ) ); 370 if ( ! $result ) 379 if ( ! $result ) { 371 380 return false; 381 } 372 382 373 383 $notoptions = wp_cache_get( 'notoptions', 'options' ); 374 if ( is_array( $notoptions ) && isset( $notoptions[ $option] ) ) {375 unset( $notoptions[ $option] );384 if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) { 385 unset( $notoptions[ $option ] ); 376 386 wp_cache_set( 'notoptions', $notoptions, 'options' ); 377 387 } … … 379 389 if ( ! wp_installing() ) { 380 390 $alloptions = wp_load_alloptions(); 381 if ( isset( $alloptions[ $option] ) ) {391 if ( isset( $alloptions[ $option ] ) ) { 382 392 $alloptions[ $option ] = $serialized_value; 383 393 wp_cache_set( 'alloptions', $alloptions, 'options' ); … … 440 450 global $wpdb; 441 451 442 if ( ! empty( $deprecated ) )452 if ( ! empty( $deprecated ) ) { 443 453 _deprecated_argument( __FUNCTION__, '2.3.0' ); 444 445 $option = trim($option); 446 if ( empty($option) ) 454 } 455 456 $option = trim( $option ); 457 if ( empty( $option ) ) { 447 458 return false; 459 } 448 460 449 461 wp_protect_special_option( $option ); 450 462 451 if ( is_object( $value) )463 if ( is_object( $value ) ) { 452 464 $value = clone $value; 465 } 453 466 454 467 $value = sanitize_option( $option, $value ); … … 456 469 // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query 457 470 $notoptions = wp_cache_get( 'notoptions', 'options' ); 458 if ( ! is_array( $notoptions ) || !isset( $notoptions[$option] ) )471 if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) { 459 472 /** This filter is documented in wp-includes/option.php */ 460 if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) ) 473 if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) ) { 461 474 return false; 475 } 476 } 462 477 463 478 $serialized_value = maybe_serialize( $value ); 464 $autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes';479 $autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes'; 465 480 466 481 /** … … 475 490 476 491 $result = $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)", $option, $serialized_value, $autoload ) ); 477 if ( ! $result ) 492 if ( ! $result ) { 478 493 return false; 494 } 479 495 480 496 if ( ! wp_installing() ) { 481 497 if ( 'yes' == $autoload ) { 482 $alloptions = wp_load_alloptions();498 $alloptions = wp_load_alloptions(); 483 499 $alloptions[ $option ] = $serialized_value; 484 500 wp_cache_set( 'alloptions', $alloptions, 'options' ); … … 490 506 // This option exists now 491 507 $notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh 492 if ( is_array( $notoptions ) && isset( $notoptions[ $option] ) ) {493 unset( $notoptions[ $option] );508 if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) { 509 unset( $notoptions[ $option ] ); 494 510 wp_cache_set( 'notoptions', $notoptions, 'options' ); 495 511 } … … 534 550 535 551 $option = trim( $option ); 536 if ( empty( $option ) ) 552 if ( empty( $option ) ) { 537 553 return false; 554 } 538 555 539 556 wp_protect_special_option( $option ); … … 541 558 // Get the ID, if no ID then return 542 559 $row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) ); 543 if ( is_null( $row ) ) 560 if ( is_null( $row ) ) { 544 561 return false; 562 } 545 563 546 564 /** … … 557 575 if ( 'yes' == $row->autoload ) { 558 576 $alloptions = wp_load_alloptions(); 559 if ( is_array( $alloptions ) && isset( $alloptions[ $option] ) ) {560 unset( $alloptions[ $option] );577 if ( is_array( $alloptions ) && isset( $alloptions[ $option ] ) ) { 578 unset( $alloptions[ $option ] ); 561 579 wp_cache_set( 'alloptions', $alloptions, 'options' ); 562 580 } … … 616 634 } else { 617 635 $option_timeout = '_transient_timeout_' . $transient; 618 $option = '_transient_' . $transient;619 $result = delete_option( $option );620 if ( $result ) 636 $option = '_transient_' . $transient; 637 $result = delete_option( $option ); 638 if ( $result ) { 621 639 delete_option( $option_timeout ); 640 } 622 641 } 623 642 … … 667 686 */ 668 687 $pre = apply_filters( "pre_transient_{$transient}", false, $transient ); 669 if ( false !== $pre ) 688 if ( false !== $pre ) { 670 689 return $pre; 690 } 671 691 672 692 if ( wp_using_ext_object_cache() ) { … … 677 697 // If option is not in alloptions, it is not autoloaded and thus has a timeout 678 698 $alloptions = wp_load_alloptions(); 679 if ( ! isset( $alloptions[$transient_option] ) ) {699 if ( ! isset( $alloptions[ $transient_option ] ) ) { 680 700 $transient_timeout = '_transient_timeout_' . $transient; 681 $timeout = get_option( $transient_timeout );701 $timeout = get_option( $transient_timeout ); 682 702 if ( false !== $timeout && $timeout < time() ) { 683 delete_option( $transient_option 703 delete_option( $transient_option ); 684 704 delete_option( $transient_timeout ); 685 705 $value = false; … … 688 708 } 689 709 690 if ( ! isset( $value ) ) 710 if ( ! isset( $value ) ) { 691 711 $value = get_option( $transient_option ); 712 } 692 713 } 693 714 … … 757 778 } else { 758 779 $transient_timeout = '_transient_timeout_' . $transient; 759 $transient_option = '_transient_' . $transient;780 $transient_option = '_transient_' . $transient; 760 781 if ( false === get_option( $transient_option ) ) { 761 782 $autoload = 'yes'; … … 834 855 } 835 856 836 $wpdb->query( $wpdb->prepare( 837 "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b 857 $wpdb->query( 858 $wpdb->prepare( 859 "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b 838 860 WHERE a.option_name LIKE %s 839 861 AND a.option_name NOT LIKE %s 840 862 AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) ) 841 863 AND b.option_value < %d", 842 $wpdb->esc_like( '_transient_' ) . '%', 843 $wpdb->esc_like( '_transient_timeout_' ) . '%', 844 time() 845 ) ); 864 $wpdb->esc_like( '_transient_' ) . '%', 865 $wpdb->esc_like( '_transient_timeout_' ) . '%', 866 time() 867 ) 868 ); 846 869 847 870 if ( ! is_multisite() ) { 848 871 // non-Multisite stores site transients in the options table. 849 $wpdb->query( $wpdb->prepare( 850 "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b 872 $wpdb->query( 873 $wpdb->prepare( 874 "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b 851 875 WHERE a.option_name LIKE %s 852 876 AND a.option_name NOT LIKE %s 853 877 AND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) ) 854 878 AND b.option_value < %d", 855 $wpdb->esc_like( '_site_transient_' ) . '%', 856 $wpdb->esc_like( '_site_transient_timeout_' ) . '%', 857 time() 858 ) ); 879 $wpdb->esc_like( '_site_transient_' ) . '%', 880 $wpdb->esc_like( '_site_transient_timeout_' ) . '%', 881 time() 882 ) 883 ); 859 884 } elseif ( is_multisite() && is_main_site() && is_main_network() ) { 860 885 // Multisite stores site transients in the sitemeta table. 861 $wpdb->query( $wpdb->prepare( 862 "DELETE a, b FROM {$wpdb->sitemeta} a, {$wpdb->sitemeta} b 886 $wpdb->query( 887 $wpdb->prepare( 888 "DELETE a, b FROM {$wpdb->sitemeta} a, {$wpdb->sitemeta} b 863 889 WHERE a.meta_key LIKE %s 864 890 AND a.meta_key NOT LIKE %s 865 891 AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) ) 866 892 AND b.meta_value < %d", 867 $wpdb->esc_like( '_site_transient_' ) . '%', 868 $wpdb->esc_like( '_site_transient_timeout_' ) . '%', 869 time() 870 ) ); 893 $wpdb->esc_like( '_site_transient_' ) . '%', 894 $wpdb->esc_like( '_site_transient_timeout_' ) . '%', 895 time() 896 ) 897 ); 871 898 } 872 899 } … … 897 924 $settings = (string) get_user_option( 'user-settings', $user_id ); 898 925 899 if ( isset( $_COOKIE[ 'wp-settings-' . $user_id] ) ) {900 $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE[ 'wp-settings-' . $user_id] );926 if ( isset( $_COOKIE[ 'wp-settings-' . $user_id ] ) ) { 927 $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE[ 'wp-settings-' . $user_id ] ); 901 928 902 929 // No change or both empty 903 if ( $cookie == $settings ) 930 if ( $cookie == $settings ) { 904 931 return; 932 } 905 933 906 934 $last_saved = (int) get_user_option( 'user-settings-time', $user_id ); 907 $current = isset( $_COOKIE['wp-settings-time-' . $user_id]) ? preg_replace( '/[^0-9]/', '', $_COOKIE['wp-settings-time-' . $user_id] ) : 0;935 $current = isset( $_COOKIE[ 'wp-settings-time-' . $user_id ] ) ? preg_replace( '/[^0-9]/', '', $_COOKIE[ 'wp-settings-time-' . $user_id ] ) : 0; 908 936 909 937 // The cookie is newer than the saved value. Update the user_option and leave the cookie as-is … … 919 947 setcookie( 'wp-settings-' . $user_id, $settings, time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure ); 920 948 setcookie( 'wp-settings-time-' . $user_id, time(), time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure ); 921 $_COOKIE[ 'wp-settings-' . $user_id] = $settings;949 $_COOKIE[ 'wp-settings-' . $user_id ] = $settings; 922 950 } 923 951 … … 934 962 $all_user_settings = get_all_user_settings(); 935 963 936 return isset( $all_user_settings[ $name] ) ? $all_user_settings[$name] : $default;964 return isset( $all_user_settings[ $name ] ) ? $all_user_settings[ $name ] : $default; 937 965 } 938 966 … … 955 983 } 956 984 957 $all_user_settings = get_all_user_settings();958 $all_user_settings[ $name] = $value;985 $all_user_settings = get_all_user_settings(); 986 $all_user_settings[ $name ] = $value; 959 987 960 988 return wp_set_all_user_settings( $all_user_settings ); … … 979 1007 980 1008 $all_user_settings = get_all_user_settings(); 981 $names = (array) $names;982 $deleted = false;1009 $names = (array) $names; 1010 $deleted = false; 983 1011 984 1012 foreach ( $names as $name ) { 985 if ( isset( $all_user_settings[ $name] ) ) {986 unset( $all_user_settings[ $name] );1013 if ( isset( $all_user_settings[ $name ] ) ) { 1014 unset( $all_user_settings[ $name ] ); 987 1015 $deleted = true; 988 1016 } … … 1018 1046 $user_settings = array(); 1019 1047 1020 if ( isset( $_COOKIE[ 'wp-settings-' . $user_id] ) ) {1021 $cookie = preg_replace( '/[^A-Za-z0-9=&_-]/', '', $_COOKIE[ 'wp-settings-' . $user_id] );1048 if ( isset( $_COOKIE[ 'wp-settings-' . $user_id ] ) ) { 1049 $cookie = preg_replace( '/[^A-Za-z0-9=&_-]/', '', $_COOKIE[ 'wp-settings-' . $user_id ] ); 1022 1050 1023 1051 if ( strpos( $cookie, '=' ) ) { // '=' cannot be 1st char … … 1061 1089 $settings = ''; 1062 1090 foreach ( $user_settings as $name => $value ) { 1063 $_name = preg_replace( '/[^A-Za-z0-9_-]+/', '', $name );1091 $_name = preg_replace( '/[^A-Za-z0-9_-]+/', '', $name ); 1064 1092 $_value = preg_replace( '/[^A-Za-z0-9_-]+/', '', $value ); 1065 1093 … … 1218 1246 // prevent non-existent options from triggering multiple queries 1219 1247 $notoptions_key = "$network_id:notoptions"; 1220 $notoptions = wp_cache_get( $notoptions_key, 'site-options' );1248 $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); 1221 1249 1222 1250 if ( isset( $notoptions[ $option ] ) ) { … … 1242 1270 /** This filter is documented in wp-includes/option.php */ 1243 1271 $default = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id ); 1244 $value = get_option( $option, $default );1272 $value = get_option( $option, $default ); 1245 1273 } else { 1246 1274 $cache_key = "$network_id:$option"; 1247 $value = wp_cache_get( $cache_key, 'site-options' );1275 $value = wp_cache_get( $cache_key, 'site-options' ); 1248 1276 1249 1277 if ( ! isset( $value ) || false === $value ) { … … 1351 1379 1352 1380 $serialized_value = maybe_serialize( $value ); 1353 $result = $wpdb->insert( $wpdb->sitemeta, array( 'site_id' => $network_id, 'meta_key' => $option, 'meta_value' => $serialized_value ) ); 1381 $result = $wpdb->insert( 1382 $wpdb->sitemeta, array( 1383 'site_id' => $network_id, 1384 'meta_key' => $option, 1385 'meta_value' => $serialized_value, 1386 ) 1387 ); 1354 1388 1355 1389 if ( ! $result ) { … … 1453 1487 wp_cache_delete( $cache_key, 'site-options' ); 1454 1488 1455 $result = $wpdb->delete( $wpdb->sitemeta, array( 'meta_key' => $option, 'site_id' => $network_id ) ); 1489 $result = $wpdb->delete( 1490 $wpdb->sitemeta, array( 1491 'meta_key' => $option, 1492 'site_id' => $network_id, 1493 ) 1494 ); 1456 1495 } 1457 1496 … … 1547 1586 1548 1587 $notoptions_key = "$network_id:notoptions"; 1549 $notoptions = wp_cache_get( $notoptions_key, 'site-options' );1588 $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); 1550 1589 if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) { 1551 1590 unset( $notoptions[ $option ] ); … … 1559 1598 1560 1599 $serialized_value = maybe_serialize( $value ); 1561 $result = $wpdb->update( $wpdb->sitemeta, array( 'meta_value' => $serialized_value ), array( 'site_id' => $network_id, 'meta_key' => $option ) ); 1600 $result = $wpdb->update( 1601 $wpdb->sitemeta, array( 'meta_value' => $serialized_value ), array( 1602 'site_id' => $network_id, 1603 'meta_key' => $option, 1604 ) 1605 ); 1562 1606 1563 1607 if ( $result ) { … … 1629 1673 } else { 1630 1674 $option_timeout = '_site_transient_timeout_' . $transient; 1631 $option = '_site_transient_' . $transient;1632 $result = delete_site_option( $option );1633 if ( $result ) 1675 $option = '_site_transient_' . $transient; 1676 $result = delete_site_option( $option ); 1677 if ( $result ) { 1634 1678 delete_site_option( $option_timeout ); 1679 } 1635 1680 } 1636 1681 if ( $result ) { … … 1682 1727 $pre = apply_filters( "pre_site_transient_{$transient}", false, $transient ); 1683 1728 1684 if ( false !== $pre ) 1729 if ( false !== $pre ) { 1685 1730 return $pre; 1731 } 1686 1732 1687 1733 if ( wp_using_ext_object_cache() ) { … … 1689 1735 } else { 1690 1736 // Core transients that do not have a timeout. Listed here so querying timeouts can be avoided. 1691 $no_timeout = array('update_core', 'update_plugins', 'update_themes');1737 $no_timeout = array( 'update_core', 'update_plugins', 'update_themes' ); 1692 1738 $transient_option = '_site_transient_' . $transient; 1693 1739 if ( ! in_array( $transient, $no_timeout ) ) { 1694 1740 $transient_timeout = '_site_transient_timeout_' . $transient; 1695 $timeout = get_site_option( $transient_timeout );1741 $timeout = get_site_option( $transient_timeout ); 1696 1742 if ( false !== $timeout && $timeout < time() ) { 1697 delete_site_option( $transient_option 1743 delete_site_option( $transient_option ); 1698 1744 delete_site_option( $transient_timeout ); 1699 1745 $value = false; … … 1701 1747 } 1702 1748 1703 if ( ! isset( $value ) ) 1749 if ( ! isset( $value ) ) { 1704 1750 $value = get_site_option( $transient_option ); 1751 } 1705 1752 } 1706 1753 … … 1769 1816 } else { 1770 1817 $transient_timeout = '_site_transient_timeout_' . $transient; 1771 $option = '_site_transient_' . $transient;1818 $option = '_site_transient_' . $transient; 1772 1819 if ( false === get_site_option( $option ) ) { 1773 if ( $expiration ) 1820 if ( $expiration ) { 1774 1821 add_site_option( $transient_timeout, time() + $expiration ); 1822 } 1775 1823 $result = add_site_option( $option, $value ); 1776 1824 } else { 1777 if ( $expiration ) 1825 if ( $expiration ) { 1778 1826 update_site_option( $transient_timeout, time() + $expiration ); 1827 } 1779 1828 $result = update_site_option( $option, $value ); 1780 1829 } … … 1819 1868 */ 1820 1869 function register_initial_settings() { 1821 register_setting( 'general', 'blogname', array( 1822 'show_in_rest' => array( 1823 'name' => 'title', 1824 ), 1825 'type' => 'string', 1826 'description' => __( 'Site title.' ), 1827 ) ); 1828 1829 register_setting( 'general', 'blogdescription', array( 1830 'show_in_rest' => array( 1831 'name' => 'description', 1832 ), 1833 'type' => 'string', 1834 'description' => __( 'Site tagline.' ), 1835 ) ); 1870 register_setting( 1871 'general', 'blogname', array( 1872 'show_in_rest' => array( 1873 'name' => 'title', 1874 ), 1875 'type' => 'string', 1876 'description' => __( 'Site title.' ), 1877 ) 1878 ); 1879 1880 register_setting( 1881 'general', 'blogdescription', array( 1882 'show_in_rest' => array( 1883 'name' => 'description', 1884 ), 1885 'type' => 'string', 1886 'description' => __( 'Site tagline.' ), 1887 ) 1888 ); 1836 1889 1837 1890 if ( ! is_multisite() ) { 1838 register_setting( 'general', 'siteurl', array( 1891 register_setting( 1892 'general', 'siteurl', array( 1893 'show_in_rest' => array( 1894 'name' => 'url', 1895 'schema' => array( 1896 'format' => 'uri', 1897 ), 1898 ), 1899 'type' => 'string', 1900 'description' => __( 'Site URL.' ), 1901 ) 1902 ); 1903 } 1904 1905 if ( ! is_multisite() ) { 1906 register_setting( 1907 'general', 'admin_email', array( 1908 'show_in_rest' => array( 1909 'name' => 'email', 1910 'schema' => array( 1911 'format' => 'email', 1912 ), 1913 ), 1914 'type' => 'string', 1915 'description' => __( 'This address is used for admin purposes, like new user notification.' ), 1916 ) 1917 ); 1918 } 1919 1920 register_setting( 1921 'general', 'timezone_string', array( 1839 1922 'show_in_rest' => array( 1840 'name' => 'url', 1841 'schema' => array( 1842 'format' => 'uri', 1923 'name' => 'timezone', 1924 ), 1925 'type' => 'string', 1926 'description' => __( 'A city in the same timezone as you.' ), 1927 ) 1928 ); 1929 1930 register_setting( 1931 'general', 'date_format', array( 1932 'show_in_rest' => true, 1933 'type' => 'string', 1934 'description' => __( 'A date format for all date strings.' ), 1935 ) 1936 ); 1937 1938 register_setting( 1939 'general', 'time_format', array( 1940 'show_in_rest' => true, 1941 'type' => 'string', 1942 'description' => __( 'A time format for all time strings.' ), 1943 ) 1944 ); 1945 1946 register_setting( 1947 'general', 'start_of_week', array( 1948 'show_in_rest' => true, 1949 'type' => 'integer', 1950 'description' => __( 'A day number of the week that the week should start on.' ), 1951 ) 1952 ); 1953 1954 register_setting( 1955 'general', 'WPLANG', array( 1956 'show_in_rest' => array( 1957 'name' => 'language', 1958 ), 1959 'type' => 'string', 1960 'description' => __( 'WordPress locale code.' ), 1961 'default' => 'en_US', 1962 ) 1963 ); 1964 1965 register_setting( 1966 'writing', 'use_smilies', array( 1967 'show_in_rest' => true, 1968 'type' => 'boolean', 1969 'description' => __( 'Convert emoticons like :-) and :-P to graphics on display.' ), 1970 'default' => true, 1971 ) 1972 ); 1973 1974 register_setting( 1975 'writing', 'default_category', array( 1976 'show_in_rest' => true, 1977 'type' => 'integer', 1978 'description' => __( 'Default post category.' ), 1979 ) 1980 ); 1981 1982 register_setting( 1983 'writing', 'default_post_format', array( 1984 'show_in_rest' => true, 1985 'type' => 'string', 1986 'description' => __( 'Default post format.' ), 1987 ) 1988 ); 1989 1990 register_setting( 1991 'reading', 'posts_per_page', array( 1992 'show_in_rest' => true, 1993 'type' => 'integer', 1994 'description' => __( 'Blog pages show at most.' ), 1995 'default' => 10, 1996 ) 1997 ); 1998 1999 register_setting( 2000 'discussion', 'default_ping_status', array( 2001 'show_in_rest' => array( 2002 'schema' => array( 2003 'enum' => array( 'open', 'closed' ), 1843 2004 ), 1844 2005 ), 1845 2006 'type' => 'string', 1846 'description' => __( ' Site URL.' ),1847 ) );1848 }1849 1850 if ( ! is_multisite() ) {1851 register_setting( 'general', 'admin_email', array(2007 'description' => __( 'Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.' ), 2008 ) 2009 ); 2010 2011 register_setting( 2012 'discussion', 'default_comment_status', array( 1852 2013 'show_in_rest' => array( 1853 'name' => 'email', 1854 'schema' => array( 1855 'format' => 'email', 2014 'schema' => array( 2015 'enum' => array( 'open', 'closed' ), 1856 2016 ), 1857 2017 ), 1858 2018 'type' => 'string', 1859 'description' => __( 'This address is used for admin purposes, like new user notification.' ), 1860 ) ); 1861 } 1862 1863 register_setting( 'general', 'timezone_string', array( 1864 'show_in_rest' => array( 1865 'name' => 'timezone', 1866 ), 1867 'type' => 'string', 1868 'description' => __( 'A city in the same timezone as you.' ), 1869 ) ); 1870 1871 register_setting( 'general', 'date_format', array( 1872 'show_in_rest' => true, 1873 'type' => 'string', 1874 'description' => __( 'A date format for all date strings.' ), 1875 ) ); 1876 1877 register_setting( 'general', 'time_format', array( 1878 'show_in_rest' => true, 1879 'type' => 'string', 1880 'description' => __( 'A time format for all time strings.' ), 1881 ) ); 1882 1883 register_setting( 'general', 'start_of_week', array( 1884 'show_in_rest' => true, 1885 'type' => 'integer', 1886 'description' => __( 'A day number of the week that the week should start on.' ), 1887 ) ); 1888 1889 register_setting( 'general', 'WPLANG', array( 1890 'show_in_rest' => array( 1891 'name' => 'language', 1892 ), 1893 'type' => 'string', 1894 'description' => __( 'WordPress locale code.' ), 1895 'default' => 'en_US', 1896 ) ); 1897 1898 register_setting( 'writing', 'use_smilies', array( 1899 'show_in_rest' => true, 1900 'type' => 'boolean', 1901 'description' => __( 'Convert emoticons like :-) and :-P to graphics on display.' ), 1902 'default' => true, 1903 ) ); 1904 1905 register_setting( 'writing', 'default_category', array( 1906 'show_in_rest' => true, 1907 'type' => 'integer', 1908 'description' => __( 'Default post category.' ), 1909 ) ); 1910 1911 register_setting( 'writing', 'default_post_format', array( 1912 'show_in_rest' => true, 1913 'type' => 'string', 1914 'description' => __( 'Default post format.' ), 1915 ) ); 1916 1917 register_setting( 'reading', 'posts_per_page', array( 1918 'show_in_rest' => true, 1919 'type' => 'integer', 1920 'description' => __( 'Blog pages show at most.' ), 1921 'default' => 10, 1922 ) ); 1923 1924 register_setting( 'discussion', 'default_ping_status', array( 1925 'show_in_rest' => array( 1926 'schema' => array( 1927 'enum' => array( 'open', 'closed' ), 1928 ), 1929 ), 1930 'type' => 'string', 1931 'description' => __( 'Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.' ), 1932 ) ); 1933 1934 register_setting( 'discussion', 'default_comment_status', array( 1935 'show_in_rest' => array( 1936 'schema' => array( 1937 'enum' => array( 'open', 'closed' ), 1938 ), 1939 ), 1940 'type' => 'string', 1941 'description' => __( 'Allow people to post comments on new articles.' ), 1942 ) ); 2019 'description' => __( 'Allow people to post comments on new articles.' ), 2020 ) 2021 ); 1943 2022 1944 2023 } … … 1954 2033 * 1955 2034 * @param string $option_group A settings group name. Should correspond to a whitelisted option key name. 1956 * 2035 * Default whitelisted option key names include "general," "discussion," and "reading," among others. 1957 2036 * @param string $option_name The name of an option to sanitize and save. 1958 2037 * @param array $args { … … 2003 2082 2004 2083 if ( 'misc' == $option_group ) { 2005 _deprecated_argument( __FUNCTION__, '3.0.0', 2084 _deprecated_argument( 2085 __FUNCTION__, '3.0.0', 2006 2086 /* translators: %s: misc */ 2007 sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 2087 sprintf( 2088 __( 'The "%s" options group has been removed. Use another settings group.' ), 2008 2089 'misc' 2009 2090 ) … … 2013 2094 2014 2095 if ( 'privacy' == $option_group ) { 2015 _deprecated_argument( __FUNCTION__, '3.5.0', 2096 _deprecated_argument( 2097 __FUNCTION__, '3.5.0', 2016 2098 /* translators: %s: privacy */ 2017 sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 2099 sprintf( 2100 __( 'The "%s" options group has been removed. Use another settings group.' ), 2018 2101 'privacy' 2019 2102 ) … … 2049 2132 2050 2133 if ( 'misc' == $option_group ) { 2051 _deprecated_argument( __FUNCTION__, '3.0.0', 2134 _deprecated_argument( 2135 __FUNCTION__, '3.0.0', 2052 2136 /* translators: %s: misc */ 2053 sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 2137 sprintf( 2138 __( 'The "%s" options group has been removed. Use another settings group.' ), 2054 2139 'misc' 2055 2140 ) … … 2059 2144 2060 2145 if ( 'privacy' == $option_group ) { 2061 _deprecated_argument( __FUNCTION__, '3.5.0', 2146 _deprecated_argument( 2147 __FUNCTION__, '3.5.0', 2062 2148 /* translators: %s: privacy */ 2063 sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 2149 sprintf( 2150 __( 'The "%s" options group has been removed. Use another settings group.' ), 2064 2151 'privacy' 2065 2152 ) … … 2073 2160 } 2074 2161 if ( '' !== $deprecated ) { 2075 _deprecated_argument( __FUNCTION__, '4.7.0', 2162 _deprecated_argument( 2163 __FUNCTION__, '4.7.0', 2076 2164 /* translators: 1: $sanitize_callback, 2: register_setting() */ 2077 sprintf( __( '%1$s is deprecated. The callback from %2$s is used instead.' ), 2165 sprintf( 2166 __( '%1$s is deprecated. The callback from %2$s is used instead.' ), 2078 2167 '<code>$sanitize_callback</code>', 2079 2168 '<code>register_setting()</code>'
Note: See TracChangeset
for help on using the changeset viewer.