160 // Distinguish between `false` as a default, and not passing one. |
160 // Distinguish between `false` as a default, and not passing one. |
161 $passed_default = func_num_args() > 1; |
161 $passed_default = func_num_args() > 1; |
162 |
162 |
163 if ( ! wp_installing() ) { |
163 if ( ! wp_installing() ) { |
164 $alloptions = wp_load_alloptions(); |
164 $alloptions = wp_load_alloptions(); |
165 |
165 /* |
|
166 * When getting an option value, we check in the following order for performance: |
|
167 * |
|
168 * 1. Check the 'alloptions' cache first to prioritize existing loaded options. |
|
169 * 2. Check the 'notoptions' cache before a cache lookup or DB hit. |
|
170 * 3. Check the 'options' cache prior to a DB hit. |
|
171 * 4. Check the DB for the option and cache it in either the 'options' or 'notoptions' cache. |
|
172 */ |
166 if ( isset( $alloptions[ $option ] ) ) { |
173 if ( isset( $alloptions[ $option ] ) ) { |
167 $value = $alloptions[ $option ]; |
174 $value = $alloptions[ $option ]; |
168 } else { |
175 } else { |
|
176 // Check for non-existent options first to avoid unnecessary object cache lookups and DB hits. |
|
177 $notoptions = wp_cache_get( 'notoptions', 'options' ); |
|
178 |
|
179 if ( ! is_array( $notoptions ) ) { |
|
180 $notoptions = array(); |
|
181 wp_cache_set( 'notoptions', $notoptions, 'options' ); |
|
182 } |
|
183 |
|
184 if ( isset( $notoptions[ $option ] ) ) { |
|
185 /** |
|
186 * Filters the default value for an option. |
|
187 * |
|
188 * The dynamic portion of the hook name, `$option`, refers to the option name. |
|
189 * |
|
190 * @since 3.4.0 |
|
191 * @since 4.4.0 The `$option` parameter was added. |
|
192 * @since 4.7.0 The `$passed_default` parameter was added to distinguish between a `false` value and the default parameter value. |
|
193 * |
|
194 * @param mixed $default_value The default value to return if the option does not exist |
|
195 * in the database. |
|
196 * @param string $option Option name. |
|
197 * @param bool $passed_default Was `get_option()` passed a default value? |
|
198 */ |
|
199 return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default ); |
|
200 } |
|
201 |
169 $value = wp_cache_get( $option, 'options' ); |
202 $value = wp_cache_get( $option, 'options' ); |
170 |
203 |
171 if ( false === $value ) { |
204 if ( false === $value ) { |
172 // Prevent non-existent options from triggering multiple queries. |
|
173 $notoptions = wp_cache_get( 'notoptions', 'options' ); |
|
174 |
|
175 // Prevent non-existent `notoptions` key from triggering multiple key lookups. |
|
176 if ( ! is_array( $notoptions ) ) { |
|
177 $notoptions = array(); |
|
178 wp_cache_set( 'notoptions', $notoptions, 'options' ); |
|
179 } elseif ( isset( $notoptions[ $option ] ) ) { |
|
180 /** |
|
181 * Filters the default value for an option. |
|
182 * |
|
183 * The dynamic portion of the hook name, `$option`, refers to the option name. |
|
184 * |
|
185 * @since 3.4.0 |
|
186 * @since 4.4.0 The `$option` parameter was added. |
|
187 * @since 4.7.0 The `$passed_default` parameter was added to distinguish between a `false` value and the default parameter value. |
|
188 * |
|
189 * @param mixed $default_value The default value to return if the option does not exist |
|
190 * in the database. |
|
191 * @param string $option Option name. |
|
192 * @param bool $passed_default Was `get_option()` passed a default value? |
|
193 */ |
|
194 return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default ); |
|
195 } |
|
196 |
205 |
197 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); |
206 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); |
198 |
207 |
199 // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values. |
208 // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values. |
200 if ( is_object( $row ) ) { |
209 if ( is_object( $row ) ) { |
373 * This function allows modifying the autoload value for multiple options without changing the actual option value. |
382 * This function allows modifying the autoload value for multiple options without changing the actual option value. |
374 * This is for example recommended for plugin activation and deactivation hooks, to ensure any options exclusively used |
383 * This is for example recommended for plugin activation and deactivation hooks, to ensure any options exclusively used |
375 * by the plugin which are generally autoloaded can be set to not autoload when the plugin is inactive. |
384 * by the plugin which are generally autoloaded can be set to not autoload when the plugin is inactive. |
376 * |
385 * |
377 * @since 6.4.0 |
386 * @since 6.4.0 |
|
387 * @since 6.7.0 The autoload values 'yes' and 'no' are deprecated. |
378 * |
388 * |
379 * @global wpdb $wpdb WordPress database abstraction object. |
389 * @global wpdb $wpdb WordPress database abstraction object. |
380 * |
390 * |
381 * @param array $options Associative array of option names and their autoload values to set. The option names are |
391 * @param array $options Associative array of option names and their autoload values to set. The option names are |
382 * expected to not be SQL-escaped. The autoload values accept 'yes'|true to enable or 'no'|false |
392 * expected to not be SQL-escaped. The autoload values should be boolean values. For backward |
383 * to disable. |
393 * compatibility 'yes' and 'no' are also accepted, though using these values is deprecated. |
384 * @return array Associative array of all provided $options as keys and boolean values for whether their autoload value |
394 * @return array Associative array of all provided $options as keys and boolean values for whether their autoload value |
385 * was updated. |
395 * was updated. |
386 */ |
396 */ |
387 function wp_set_option_autoload_values( array $options ) { |
397 function wp_set_option_autoload_values( array $options ) { |
388 global $wpdb; |
398 global $wpdb; |
396 'off' => array(), |
406 'off' => array(), |
397 ); |
407 ); |
398 $results = array(); |
408 $results = array(); |
399 foreach ( $options as $option => $autoload ) { |
409 foreach ( $options as $option => $autoload ) { |
400 wp_protect_special_option( $option ); // Ensure only valid options can be passed. |
410 wp_protect_special_option( $option ); // Ensure only valid options can be passed. |
401 if ( 'off' === $autoload || 'no' === $autoload || false === $autoload ) { // Sanitize autoload value and categorize accordingly. |
411 |
|
412 /* |
|
413 * Sanitize autoload value and categorize accordingly. |
|
414 * The values 'yes', 'no', 'on', and 'off' are supported for backward compatibility. |
|
415 */ |
|
416 if ( 'off' === $autoload || 'no' === $autoload || false === $autoload ) { |
402 $grouped_options['off'][] = $option; |
417 $grouped_options['off'][] = $option; |
403 } else { |
418 } else { |
404 $grouped_options['on'][] = $option; |
419 $grouped_options['on'][] = $option; |
405 } |
420 } |
406 $results[ $option ] = false; // Initialize result value. |
421 $results[ $option ] = false; // Initialize result value. |
494 * |
509 * |
495 * This is a wrapper for {@see wp_set_option_autoload_values()}, which can be used to set different autoload values for |
510 * This is a wrapper for {@see wp_set_option_autoload_values()}, which can be used to set different autoload values for |
496 * each option at once. |
511 * each option at once. |
497 * |
512 * |
498 * @since 6.4.0 |
513 * @since 6.4.0 |
|
514 * @since 6.7.0 The autoload values 'yes' and 'no' are deprecated. |
499 * |
515 * |
500 * @see wp_set_option_autoload_values() |
516 * @see wp_set_option_autoload_values() |
501 * |
517 * |
502 * @param string[] $options List of option names. Expected to not be SQL-escaped. |
518 * @param string[] $options List of option names. Expected to not be SQL-escaped. |
503 * @param string|bool $autoload Autoload value to control whether to load the options when WordPress starts up. |
519 * @param bool $autoload Autoload value to control whether to load the options when WordPress starts up. |
504 * Accepts 'yes'|true to enable or 'no'|false to disable. |
520 * For backward compatibility 'yes' and 'no' are also accepted, though using these values is |
|
521 * deprecated. |
505 * @return array Associative array of all provided $options as keys and boolean values for whether their autoload value |
522 * @return array Associative array of all provided $options as keys and boolean values for whether their autoload value |
506 * was updated. |
523 * was updated. |
507 */ |
524 */ |
508 function wp_set_options_autoload( array $options, $autoload ) { |
525 function wp_set_options_autoload( array $options, $autoload ) { |
509 return wp_set_option_autoload_values( |
526 return wp_set_option_autoload_values( |
516 * |
533 * |
517 * This is a wrapper for {@see wp_set_option_autoload_values()}, which can be used to set the autoload value for |
534 * This is a wrapper for {@see wp_set_option_autoload_values()}, which can be used to set the autoload value for |
518 * multiple options at once. |
535 * multiple options at once. |
519 * |
536 * |
520 * @since 6.4.0 |
537 * @since 6.4.0 |
|
538 * @since 6.7.0 The autoload values 'yes' and 'no' are deprecated. |
521 * |
539 * |
522 * @see wp_set_option_autoload_values() |
540 * @see wp_set_option_autoload_values() |
523 * |
541 * |
524 * @param string $option Name of the option. Expected to not be SQL-escaped. |
542 * @param string $option Name of the option. Expected to not be SQL-escaped. |
525 * @param string|bool $autoload Autoload value to control whether to load the option when WordPress starts up. |
543 * @param bool $autoload Autoload value to control whether to load the option when WordPress starts up. |
526 * Accepts 'yes'|true to enable or 'no'|false to disable. |
544 * For backward compatibility 'yes' and 'no' are also accepted, though using these values is |
|
545 * deprecated. |
527 * @return bool True if the autoload value was modified, false otherwise. |
546 * @return bool True if the autoload value was modified, false otherwise. |
528 */ |
547 */ |
529 function wp_set_option_autoload( $option, $autoload ) { |
548 function wp_set_option_autoload( $option, $autoload ) { |
530 $result = wp_set_option_autoload_values( array( $option => $autoload ) ); |
549 $result = wp_set_option_autoload_values( array( $option => $autoload ) ); |
531 if ( isset( $result[ $option ] ) ) { |
550 if ( isset( $result[ $option ] ) ) { |
801 * This function is designed to work with or without a logged-in user. In terms of security, |
820 * This function is designed to work with or without a logged-in user. In terms of security, |
802 * plugin developers should check the current user's capabilities before updating any options. |
821 * plugin developers should check the current user's capabilities before updating any options. |
803 * |
822 * |
804 * @since 1.0.0 |
823 * @since 1.0.0 |
805 * @since 4.2.0 The `$autoload` parameter was added. |
824 * @since 4.2.0 The `$autoload` parameter was added. |
|
825 * @since 6.7.0 The autoload values 'yes' and 'no' are deprecated. |
806 * |
826 * |
807 * @global wpdb $wpdb WordPress database abstraction object. |
827 * @global wpdb $wpdb WordPress database abstraction object. |
808 * |
828 * |
809 * @param string $option Name of the option to update. Expected to not be SQL-escaped. |
829 * @param string $option Name of the option to update. Expected to not be SQL-escaped. |
810 * @param mixed $value Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped. |
830 * @param mixed $value Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped. |
811 * @param bool|null $autoload Optional. Whether to load the option when WordPress starts up. |
831 * @param bool|null $autoload Optional. Whether to load the option when WordPress starts up. |
812 * Accepts a boolean, or `null` to stick with the initial value or, if no initial value is set, |
832 * Accepts a boolean, or `null` to stick with the initial value or, if no initial value is |
813 * to leave the decision up to default heuristics in WordPress. |
833 * set, to leave the decision up to default heuristics in WordPress. |
814 * For existing options, |
834 * For existing options, `$autoload` can only be updated using `update_option()` if `$value` |
815 * `$autoload` can only be updated using `update_option()` if `$value` is also changed. |
835 * is also changed. |
816 * For backward compatibility 'yes' and 'no' are also accepted. |
836 * For backward compatibility 'yes' and 'no' are also accepted, though using these values is |
|
837 * deprecated. |
817 * Autoloading too many options can lead to performance problems, especially if the |
838 * Autoloading too many options can lead to performance problems, especially if the |
818 * options are not frequently used. For options which are accessed across several places |
839 * options are not frequently used. For options which are accessed across several places |
819 * in the frontend, it is recommended to autoload them, by using true. |
840 * in the frontend, it is recommended to autoload them, by using true. |
820 * For options which are accessed only on few specific URLs, it is recommended |
841 * For options which are accessed only on few specific URLs, it is recommended |
821 * to not autoload them, by using false. |
842 * to not autoload them, by using false. |
1024 * aren't adding a protected WordPress option. Care should be taken to not name |
1045 * aren't adding a protected WordPress option. Care should be taken to not name |
1025 * options the same as the ones which are protected. |
1046 * options the same as the ones which are protected. |
1026 * |
1047 * |
1027 * @since 1.0.0 |
1048 * @since 1.0.0 |
1028 * @since 6.6.0 The $autoload parameter's default value was changed to null. |
1049 * @since 6.6.0 The $autoload parameter's default value was changed to null. |
|
1050 * @since 6.7.0 The autoload values 'yes' and 'no' are deprecated. |
1029 * |
1051 * |
1030 * @global wpdb $wpdb WordPress database abstraction object. |
1052 * @global wpdb $wpdb WordPress database abstraction object. |
1031 * |
1053 * |
1032 * @param string $option Name of the option to add. Expected to not be SQL-escaped. |
1054 * @param string $option Name of the option to add. Expected to not be SQL-escaped. |
1033 * @param mixed $value Optional. Option value. Must be serializable if non-scalar. |
1055 * @param mixed $value Optional. Option value. Must be serializable if non-scalar. |
1034 * Expected to not be SQL-escaped. |
1056 * Expected to not be SQL-escaped. |
1035 * @param string $deprecated Optional. Description. Not used anymore. |
1057 * @param string $deprecated Optional. Description. Not used anymore. |
1036 * @param bool|null $autoload Optional. Whether to load the option when WordPress starts up. |
1058 * @param bool|null $autoload Optional. Whether to load the option when WordPress starts up. |
1037 * Accepts a boolean, or `null` to leave the decision up to default heuristics in WordPress. |
1059 * Accepts a boolean, or `null` to leave the decision up to default heuristics in |
1038 * For backward compatibility 'yes' and 'no' are also accepted. |
1060 * WordPress. For backward compatibility 'yes' and 'no' are also accepted, though using |
|
1061 * these values is deprecated. |
1039 * Autoloading too many options can lead to performance problems, especially if the |
1062 * Autoloading too many options can lead to performance problems, especially if the |
1040 * options are not frequently used. For options which are accessed across several places |
1063 * options are not frequently used. For options which are accessed across several places |
1041 * in the frontend, it is recommended to autoload them, by using 'yes'|true. |
1064 * in the frontend, it is recommended to autoload them, by using true. |
1042 * For options which are accessed only on few specific URLs, it is recommended |
1065 * For options which are accessed only on few specific URLs, it is recommended |
1043 * to not autoload them, by using false. |
1066 * to not autoload them, by using false. |
1044 * Default is null, which means WordPress will determine the autoload value. |
1067 * Default is null, which means WordPress will determine the autoload value. |
1045 * @return bool True if the option was added, false otherwise. |
1068 * @return bool True if the option was added, false otherwise. |
1046 */ |
1069 */ |
1258 * decision could be made. |
1290 * decision could be made. |
1259 * |
1291 * |
1260 * @since 6.6.0 |
1292 * @since 6.6.0 |
1261 * @access private |
1293 * @access private |
1262 * |
1294 * |
1263 * @param string $option The name of the option. |
1295 * @param string $option The name of the option. |
1264 * @param mixed $value The value of the option to check its autoload value. |
1296 * @param mixed $value The value of the option to check its autoload value. |
1265 * @param mixed $serialized_value The serialized value of the option to check its autoload value. |
1297 * @param mixed $serialized_value The serialized value of the option to check its autoload value. |
1266 * @param bool|null $autoload The autoload value to check. |
1298 * @param bool|null $autoload The autoload value to check. |
1267 * Accepts 'on'|true to enable or 'off'|false to disable, or |
1299 * Accepts 'on'|true to enable or 'off'|false to disable, or |
1268 * 'auto-on', 'auto-off', or 'auto' for internal purposes. |
1300 * 'auto-on', 'auto-off', or 'auto' for internal purposes. |
1269 * Any other autoload value will be forced to either 'auto-on', |
1301 * Any other autoload value will be forced to either 'auto-on', |
1270 * 'auto-off', or 'auto'. |
1302 * 'auto-off', or 'auto'. |
1271 * 'yes' and 'no' are supported for backward compatibility. |
1303 * 'yes' and 'no' are supported for backward compatibility. |
1272 * @return string Returns the original $autoload value if explicit, or 'auto-on', 'auto-off', |
1304 * @return string Returns the original $autoload value if explicit, or 'auto-on', 'auto-off', |
1273 * or 'auto' depending on default heuristics. |
1305 * or 'auto' depending on default heuristics. |
1274 */ |
1306 */ |
1275 function wp_determine_option_autoload_value( $option, $value, $serialized_value, $autoload ) { |
1307 function wp_determine_option_autoload_value( $option, $value, $serialized_value, $autoload ) { |
1276 |
1308 |
1562 do_action( "set_transient_{$transient}", $value, $expiration, $transient ); |
1594 do_action( "set_transient_{$transient}", $value, $expiration, $transient ); |
1563 |
1595 |
1564 /** |
1596 /** |
1565 * Fires after the value for a transient has been set. |
1597 * Fires after the value for a transient has been set. |
1566 * |
1598 * |
1567 * @since 3.0.0 |
1599 * @since 6.8.0 |
1568 * @since 3.6.0 The `$value` and `$expiration` parameters were added. |
|
1569 * |
1600 * |
1570 * @param string $transient The name of the transient. |
1601 * @param string $transient The name of the transient. |
1571 * @param mixed $value Transient value. |
1602 * @param mixed $value Transient value. |
1572 * @param int $expiration Time until expiration in seconds. |
1603 * @param int $expiration Time until expiration in seconds. |
1573 */ |
1604 */ |
1574 do_action( 'setted_transient', $transient, $value, $expiration ); |
1605 do_action( 'set_transient', $transient, $value, $expiration ); |
|
1606 |
|
1607 /** |
|
1608 * Fires after the transient is set. |
|
1609 * |
|
1610 * @since 3.0.0 |
|
1611 * @since 3.6.0 The `$value` and `$expiration` parameters were added. |
|
1612 * @deprecated 6.8.0 Use {@see 'set_transient'} instead. |
|
1613 * |
|
1614 * @param string $transient The name of the transient. |
|
1615 * @param mixed $value Transient value. |
|
1616 * @param int $expiration Time until expiration in seconds. |
|
1617 */ |
|
1618 do_action_deprecated( 'setted_transient', array( $transient, $value, $expiration ), '6.8.0', 'set_transient' ); |
1575 } |
1619 } |
1576 |
1620 |
1577 return $result; |
1621 return $result; |
1578 } |
1622 } |
1579 |
1623 |
1675 if ( $cookie === $settings ) { |
1719 if ( $cookie === $settings ) { |
1676 return; |
1720 return; |
1677 } |
1721 } |
1678 |
1722 |
1679 $last_saved = (int) get_user_option( 'user-settings-time', $user_id ); |
1723 $last_saved = (int) get_user_option( 'user-settings-time', $user_id ); |
1680 $current = isset( $_COOKIE[ 'wp-settings-time-' . $user_id ] ) ? preg_replace( '/[^0-9]/', '', $_COOKIE[ 'wp-settings-time-' . $user_id ] ) : 0; |
1724 $current = 0; |
|
1725 |
|
1726 if ( isset( $_COOKIE[ 'wp-settings-time-' . $user_id ] ) ) { |
|
1727 $current = (int) preg_replace( '/[^0-9]/', '', $_COOKIE[ 'wp-settings-time-' . $user_id ] ); |
|
1728 } |
1681 |
1729 |
1682 // The cookie is newer than the saved value. Update the user_option and leave the cookie as-is. |
1730 // The cookie is newer than the saved value. Update the user_option and leave the cookie as-is. |
1683 if ( $current > $last_saved ) { |
1731 if ( $current > $last_saved ) { |
1684 update_user_option( $user_id, 'user-settings', $cookie, false ); |
1732 update_user_option( $user_id, 'user-settings', $cookie, false ); |
1685 update_user_option( $user_id, 'user-settings-time', time() - 5, false ); |
1733 update_user_option( $user_id, 'user-settings-time', time() - 5, false ); |
1943 * |
1991 * |
1944 * @see get_option() |
1992 * @see get_option() |
1945 * |
1993 * |
1946 * @global wpdb $wpdb WordPress database abstraction object. |
1994 * @global wpdb $wpdb WordPress database abstraction object. |
1947 * |
1995 * |
1948 * @param int $network_id ID of the network. Can be null to default to the current network ID. |
1996 * @param int|null $network_id ID of the network. Can be null to default to the current network ID. |
1949 * @param string $option Name of the option to retrieve. Expected to not be SQL-escaped. |
1997 * @param string $option Name of the option to retrieve. Expected to not be SQL-escaped. |
1950 * @param mixed $default_value Optional. Value to return if the option doesn't exist. Default false. |
1998 * @param mixed $default_value Optional. Value to return if the option doesn't exist. Default false. |
1951 * @return mixed Value set for the option. |
1999 * @return mixed Value set for the option. |
1952 */ |
2000 */ |
1953 function get_network_option( $network_id, $option, $default_value = false ) { |
2001 function get_network_option( $network_id, $option, $default_value = false ) { |
1954 global $wpdb; |
2002 global $wpdb; |
1955 |
2003 |
1976 * @since 3.0.0 |
2024 * @since 3.0.0 |
1977 * @since 4.4.0 The `$option` parameter was added. |
2025 * @since 4.4.0 The `$option` parameter was added. |
1978 * @since 4.7.0 The `$network_id` parameter was added. |
2026 * @since 4.7.0 The `$network_id` parameter was added. |
1979 * @since 4.9.0 The `$default_value` parameter was added. |
2027 * @since 4.9.0 The `$default_value` parameter was added. |
1980 * |
2028 * |
1981 * @param mixed $pre_option The value to return instead of the option value. This differs from |
2029 * @param mixed $pre_site_option The value to return instead of the option value. This differs from |
1982 * `$default_value`, which is used as the fallback value in the event |
2030 * `$default_value`, which is used as the fallback value in the event |
1983 * the option doesn't exist elsewhere in get_network_option(). |
2031 * the option doesn't exist elsewhere in get_network_option(). |
1984 * Default false (to skip past the short-circuit). |
2032 * Default false (to skip past the short-circuit). |
1985 * @param string $option Option name. |
2033 * @param string $option Option name. |
1986 * @param int $network_id ID of the network. |
2034 * @param int $network_id ID of the network. |
1987 * @param mixed $default_value The fallback value to return if the option does not exist. |
2035 * @param mixed $default_value The fallback value to return if the option does not exist. |
1988 * Default false. |
2036 * Default false. |
1989 */ |
2037 */ |
1990 $pre = apply_filters( "pre_site_option_{$option}", false, $option, $network_id, $default_value ); |
2038 $pre = apply_filters( "pre_site_option_{$option}", false, $option, $network_id, $default_value ); |
1991 |
2039 |
1992 if ( false !== $pre ) { |
2040 if ( false !== $pre ) { |
1993 return $pre; |
2041 return $pre; |
2077 * |
2125 * |
2078 * @see add_option() |
2126 * @see add_option() |
2079 * |
2127 * |
2080 * @global wpdb $wpdb WordPress database abstraction object. |
2128 * @global wpdb $wpdb WordPress database abstraction object. |
2081 * |
2129 * |
2082 * @param int $network_id ID of the network. Can be null to default to the current network ID. |
2130 * @param int|null $network_id ID of the network. Can be null to default to the current network ID. |
2083 * @param string $option Name of the option to add. Expected to not be SQL-escaped. |
2131 * @param string $option Name of the option to add. Expected to not be SQL-escaped. |
2084 * @param mixed $value Option value, can be anything. Expected to not be SQL-escaped. |
2132 * @param mixed $value Option value, can be anything. Expected to not be SQL-escaped. |
2085 * @return bool True if the option was added, false otherwise. |
2133 * @return bool True if the option was added, false otherwise. |
2086 */ |
2134 */ |
2087 function add_network_option( $network_id, $option, $value ) { |
2135 function add_network_option( $network_id, $option, $value ) { |
2088 global $wpdb; |
2136 global $wpdb; |
2089 |
2137 |
2204 * |
2252 * |
2205 * @see delete_option() |
2253 * @see delete_option() |
2206 * |
2254 * |
2207 * @global wpdb $wpdb WordPress database abstraction object. |
2255 * @global wpdb $wpdb WordPress database abstraction object. |
2208 * |
2256 * |
2209 * @param int $network_id ID of the network. Can be null to default to the current network ID. |
2257 * @param int|null $network_id ID of the network. Can be null to default to the current network ID. |
2210 * @param string $option Name of the option to delete. Expected to not be SQL-escaped. |
2258 * @param string $option Name of the option to delete. Expected to not be SQL-escaped. |
2211 * @return bool True if the option was deleted, false otherwise. |
2259 * @return bool True if the option was deleted, false otherwise. |
2212 */ |
2260 */ |
2213 function delete_network_option( $network_id, $option ) { |
2261 function delete_network_option( $network_id, $option ) { |
2214 global $wpdb; |
2262 global $wpdb; |
2215 |
2263 |
2297 * |
2356 * |
2298 * @see update_option() |
2357 * @see update_option() |
2299 * |
2358 * |
2300 * @global wpdb $wpdb WordPress database abstraction object. |
2359 * @global wpdb $wpdb WordPress database abstraction object. |
2301 * |
2360 * |
2302 * @param int $network_id ID of the network. Can be null to default to the current network ID. |
2361 * @param int|null $network_id ID of the network. Can be null to default to the current network ID. |
2303 * @param string $option Name of the option. Expected to not be SQL-escaped. |
2362 * @param string $option Name of the option. Expected to not be SQL-escaped. |
2304 * @param mixed $value Option value. Expected to not be SQL-escaped. |
2363 * @param mixed $value Option value. Expected to not be SQL-escaped. |
2305 * @return bool True if the value was updated, false otherwise. |
2364 * @return bool True if the value was updated, false otherwise. |
2306 */ |
2365 */ |
2307 function update_network_option( $network_id, $option, $value ) { |
2366 function update_network_option( $network_id, $option, $value ) { |
2308 global $wpdb; |
2367 global $wpdb; |
2309 |
2368 |
2627 do_action( "set_site_transient_{$transient}", $value, $expiration, $transient ); |
2686 do_action( "set_site_transient_{$transient}", $value, $expiration, $transient ); |
2628 |
2687 |
2629 /** |
2688 /** |
2630 * Fires after the value for a site transient has been set. |
2689 * Fires after the value for a site transient has been set. |
2631 * |
2690 * |
2632 * @since 3.0.0 |
2691 * @since 6.8.0 |
2633 * |
2692 * |
2634 * @param string $transient The name of the site transient. |
2693 * @param string $transient The name of the site transient. |
2635 * @param mixed $value Site transient value. |
2694 * @param mixed $value Site transient value. |
2636 * @param int $expiration Time until expiration in seconds. |
2695 * @param int $expiration Time until expiration in seconds. |
2637 */ |
2696 */ |
2638 do_action( 'setted_site_transient', $transient, $value, $expiration ); |
2697 do_action( 'set_site_transient', $transient, $value, $expiration ); |
|
2698 |
|
2699 /** |
|
2700 * Fires after the value for a site transient has been set. |
|
2701 * |
|
2702 * @since 3.0.0 |
|
2703 * @deprecated 6.8.0 Use {@see 'set_site_transient'} instead. |
|
2704 * |
|
2705 * @param string $transient The name of the site transient. |
|
2706 * @param mixed $value Site transient value. |
|
2707 * @param int $expiration Time until expiration in seconds. |
|
2708 */ |
|
2709 do_action_deprecated( 'setted_site_transient', array( $transient, $value, $expiration ), '6.8.0', 'set_site_transient' ); |
2639 } |
2710 } |
2640 |
2711 |
2641 return $result; |
2712 return $result; |
2642 } |
2713 } |
2643 |
2714 |