| | 1769 | * Set/update the value of a site transient without calling the sometimes expensive hooks. |
| | 1770 | * |
| | 1771 | * This is particularly for the special case of wp_update_plugins() where set_site_transient() was called twice |
| | 1772 | * and the first time was only for setting up the last_checked update_plugins option. |
| | 1773 | * |
| | 1774 | * @since 4.9.3 |
| | 1775 | * |
| | 1776 | * @see wp_update_plugins() |
| | 1777 | * |
| | 1778 | * @param string $transient Transient name. Expected to not be SQL-escaped. Must be |
| | 1779 | * 167 characters or fewer in length. |
| | 1780 | * @param mixed $value Transient value. Expected to not be SQL-escaped. |
| | 1781 | * @param int $expiration Optional. Time until expiration in seconds. Default 0 (no expiration). |
| | 1782 | * @return bool False if value was not set and true if value was set. |
| | 1783 | */ |
| | 1784 | function set_site_transient_nohook( $transient, $value, $expiration = 0 ) { |
| | 1785 | |
| | 1786 | $expiration = (int) $expiration; |
| | 1787 | |
| | 1788 | if ( wp_using_ext_object_cache() ) { |
| | 1789 | $result = wp_cache_set( $transient, $value, 'site-transient', $expiration ); |
| | 1790 | } else { |
| | 1791 | $transient_timeout = '_site_transient_timeout_' . $transient; |
| | 1792 | $option = '_site_transient_' . $transient; |
| | 1793 | if ( false === get_site_option( $option ) ) { |
| | 1794 | if ( $expiration ) |
| | 1795 | add_site_option( $transient_timeout, time() + $expiration ); |
| | 1796 | $result = add_site_option( $option, $value ); |
| | 1797 | } else { |
| | 1798 | if ( $expiration ) |
| | 1799 | update_site_option( $transient_timeout, time() + $expiration ); |
| | 1800 | $result = update_site_option( $option, $value ); |
| | 1801 | } |
| | 1802 | } |
| | 1803 | return $result; |
| | 1804 | } |
| | 1805 | |
| | 1806 | /** |
| 1814 | | if ( wp_using_ext_object_cache() ) { |
| 1815 | | $result = wp_cache_set( $transient, $value, 'site-transient', $expiration ); |
| 1816 | | } else { |
| 1817 | | $transient_timeout = '_site_transient_timeout_' . $transient; |
| 1818 | | $option = '_site_transient_' . $transient; |
| 1819 | | if ( false === get_site_option( $option ) ) { |
| 1820 | | if ( $expiration ) { |
| 1821 | | add_site_option( $transient_timeout, time() + $expiration ); |
| 1822 | | } |
| 1823 | | $result = add_site_option( $option, $value ); |
| 1824 | | } else { |
| 1825 | | if ( $expiration ) { |
| 1826 | | update_site_option( $transient_timeout, time() + $expiration ); |
| 1827 | | } |
| 1828 | | $result = update_site_option( $option, $value ); |
| 1829 | | } |
| 1830 | | } |
| | 1852 | $result = set_site_transient_nohook( $transient, $value, $expiration ); |
| | 1853 | |