Make WordPress Core

Ticket #37178: 37178.diff

File 37178.diff, 1.3 KB (added by joostdevalk, 8 years ago)

Patch, first go.

  • wp-includes/option.php

     
    2323 *
    2424 * @global wpdb $wpdb WordPress database abstraction object.
    2525 *
    26  * @param string $option  Name of option to retrieve. Expected to not be SQL-escaped.
    27  * @param mixed  $default Optional. Default value to return if the option does not exist.
     26 * @param string $option     Name of option to retrieve. Expected to not be SQL-escaped.
     27 * @param mixed  $default    Optional. Default value to return if the option does not exist.
     28 * @param bool   $cache_only If set to true, no query will be done if there is no cached option.
    2829 * @return mixed Value set for the option.
    2930 */
    30 function get_option( $option, $default = false ) {
     31function get_option( $option, $default = false, $cache_only = false ) {
    3132        global $wpdb;
    3233
    3334        $option = trim( $option );
     
    8384                        $value = wp_cache_get( $option, 'options' );
    8485
    8586                        if ( false === $value ) {
     87                                if ( $cache_only ) {
     88                                        return false;
     89                                }
    8690                                $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
    8791
    8892                                // Has to be get_row instead of get_var because of funkiness with 0, false, null values