WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#7637 closed enhancement (fixed)

Pass default value to get_option()

Reported by: azaozz Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

Allows a default value to be passed through get_option() and returned if the option is not set. So all of these would work well:

$myarray = get_option( 'myarray', array('q', 'w', 'e') );
$myvar = get_option( 'myvar', '<p>My var is not set</p>' );
$mybool = get_option( 'mybool', true );

The second arg is optional and is fully backwards-compatible, get_option() will return false when the option is not set and default value is not specified.

Attachments (1)

get_option.patch (1011 bytes) - added by azaozz 6 years ago.

Download all attachments as: .zip

Change History (2)

azaozz6 years ago

comment:1 azaozz6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [8770]) Pass default value to get_option(), fixes #7637

Note: See TracTickets for help on using tickets.