Make WordPress Core

Ticket #51699: 51699-1.patch

File 51699-1.patch, 1.2 KB (added by ttodua, 4 years ago)
  • option.php

     
    178178        return apply_filters( "option_{$option}", maybe_unserialize( $value ), $option );
    179179}
    180180
     181
    181182/**
     183 * Retrieves boolean to check if option exists or not.
     184 *
     185 * This is preferred method rather than using `if (!get_options("xyz"))` because this
     186 * will be misleading if option has legitimate value of `0/false/null/empty-string`.
     187 *
     188 *
     189 * @since 5.5.3
     190 *
     191 * @global wpdb $wpdb WordPress database abstraction object.
     192 *
     193 * @param string $option_name  Name of the option to retrieve. Expected to not be SQL-escaped.
     194 * @param mixed  $site_wide Optional. If user checks for current site or network option.
     195 */
     196function option_exists( $option_name, $site_wide = false ) {
     197        global $wpdb;
     198        return $wpdb->query( $wpdb->prepare( "SELECT * FROM ". ($site_wide ? $wpdb->base_prefix : $wpdb->prefix). "options WHERE option_name ='%s' LIMIT 1", $option_name ) );
     199}
     200 
     201 
     202/**
    182203 * Protects WordPress special option from being modified.
    183204 *
    184205 * Will die if $option is in protected list. Protected options are 'alloptions'