Skip to content

2.x Update methods to retrieve site option#1700

Merged
jarednova merged 2 commits into2.xfrom
2.x-site-option
Apr 4, 2018
Merged

2.x Update methods to retrieve site option#1700
jarednova merged 2 commits into2.xfrom
2.x-site-option

Conversation

@gchtr
Copy link
Copy Markdown
Member

@gchtr gchtr commented Mar 30, 2018

Ticket: #1580

Issue

Up until now, site option values could be retrieved through {{ site.option_name }} or {{ site.meta('option_name') }}. The term meta doesn’t fit very well for a site option, because the value doesn’t live in a meta database table, but in wp_options. It would be more intuitive to have the following methods available for retrieving site options:

  • {{ site.option_name }} (leave as is)
  • {{ site.option('option_name') }}

Solution

  • Add option() method that retrieves a site option through __get().
  • Deprecate meta() method in favor of option().
  • Update DocBlocks.

Testing

  • Added test for new option() method.
  • Updated test for meta() to catch deprecation.

@jarednova
Copy link
Copy Markdown
Member

Looks good! While I love the idea of meta everywhere; this is where people expect the WP convention of "Terms/Users/Posts have meta, Sites have options" (but we still have meta as a backup for now) — merged!

@jarednova jarednova merged commit 80ce86c into 2.x Apr 4, 2018
@jarednova jarednova deleted the 2.x-site-option branch April 4, 2018 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants