Options, and Transients, and Theme Mods — Oh my!

50 %
50 %
Information about Options, and Transients, and Theme Mods — Oh my!
Technology

Published on March 1, 2014

Author: obenland

Source: slideshare.net

Options, and Transients, and Theme Mods — Oh my! WordCamp St. Louis March 1, 2014

Konstantin Obenland Chairman Of Height at Automattic ! @obenland konstantin.obenland.it

get_option() queries the database every time it is called. True or False?

Transients are Options with an expiration date. True or False?

wp-includes/option.php

Options vs. Transients Choose one.

Options API

A simple and way of storing arbitrary data in the database.

get_option() Is it in $all_options? Yes No Is it in $wp_cache? Return value. Yes No Is it in the database? Yes No Add to $wp_cache Return $default.

What are Notoptions?

Well, they are not options!

get_option() Is it in $all_options? Yes No Is it in $wp_cache? Return value. Yes No Is it in the database? Yes No Add to $wp_cache Return $default.

get_option() Is it in $notoptions? Yes No Is it in $all_options? Yes No Is it in $wp_cache? Return value. Yes No Is it in the database? Yes No Add to $wp_cache Add to $notopions Return $default.

Transients API

A simple way of storing cached data.

Transients API ↓ Object Cache API ↓ WP_Object_Cache

They may use the Options API.

They can optionally expire.

function get_transient( $transient ) { ! if ( wp_using_ext_object_cache() ) { return wp_cache_get( $transient, 'transient' ); ! } else { // Check wp_load_all_options() ! } } return get_option( $transient_option );

function set_transient( $transient, $value, $expiration = 0 ) { // Check for external object cache and use it. // Check DB for existing value and update expiration. // Add an option with the expiration of this transient. // Add the transient value to the DB. }

function get_my_data() { $data = get_transient( 'my_data' ); if ( false === $data ) { $data = $wpdb->get_results( $query ); set_transient( 'my_data', $data, DAY_IN_SECONDS ); } ! // Do something with $data. ! } return $data;

function get_my_data() { $data = wp_cache_get( 'my_data', 'my_group' ); if ( false === $data ) { $data = $wpdb->get_results( $query ); wp_cache_set( 'my_data', $data, 'my_group', DAY_IN_SECONDS ); } ! // Do something with $data. ! } return $data;

External Object Cache

By default, the built-in the object cache is non-persistent.

Pluggable, to allow for third party object caches.

Most popular: APC & Memcached Source: Grokking the WordPress Object Cache; Tollmanz, Zack.

Recommended Reading http://vip.wordpress.com/documentation/caching/ http://tollmanz.com/core-caching-concepts-in-wordpress/ http://tollmanz.com/grokking-the-wp-object-cache/ http://scotty-t.com/2012/01/20/wordpress-memcached/

Theme Mods

set_theme_mod( $name, $value ); get_theme_mod( $name, $default = false ); remove_theme_mod( $name ); ! get_theme_mods(); remove_theme_mods();

function get_theme_mod( $name, $default = false ) { $mods = get_option( 'theme_mods_' . get_option( 'stylesheet' ) ); ! if ( isset( $mods[ $name ] ) ) return $mods[ $name ]; ! return $default; }

Site Options & Site Transients

Uses the sitemeta table on Multisite.

User Settings & User Options

User Settings

User Settings Primary examples are the expansion/collapse of the admin menu, and switching between text and visual. These can happen without a form submit, and you wouldn't want to fire an XHR request every time just to save the previous state. —Andrew Nacin

User Options Uses the User Meta API

But!

User Options vs. User Meta

Thank you!

Konstantin Obenland @obenland konstantin.obenland.it

Add a comment

Comments

Chris Chelios Jersey | 19/10/16
Not to worry. There are a number methods for getting a continuous mode of qualified referrals without having to go through the hurtful means of demanding contacts face-to-face. The key to finding testimonials without demanding these products would be to establish referral programs that the particular demanding anyone. Allow me to share six innovative products to get testimonials and referrals without asking. [url=http://www.redwingsfansale.com/27-chris-chelios-jersey]Chris Chelios Jersey[/url]
bergeron jersey | 24/10/16
To conclude, CEOs can't eliminate sight in the serious climate move that has come to cruise over the corner place of work. Williams can be co-founder and also a handling director connected with Leadership Research Fondation, referred to as one of the leading direction consulting companies focusing on being a leader development in addition to review. Physical fitness Crossfit The fact that Trims Often the Fat around your belly [url=http://bruins-jerseys.com/32-patrice-bergeron-jersey]bergeron jersey[/url]

Related presentations

Related pages

Options, and Transients, and Theme Mods — Oh my! - Technology

ALA Summer 2007Habing1 METS, MODS and PREMIS, Oh My! (and a little MIX and other schema too) Integrating Digital Library Standards for Interoperability.
Read more

Options, and Transients, and Theme Mods — Oh my ...

Options, and Transients, and Theme Mods — Oh my! WordCamp St. Louis March 1, 2014 Konstantin Obenland Chairman Of Height at Automattic ! @obenland ...
Read more

Options, and Transients, and Theme Mods, Oh My! - wordpress.tv

We will look at the difference between Options and Transients, in what situations plugin developers should use one over the other, and why one is not ...
Read more

WordCamp St. Louis 2014 – Mike Hansen - bluehost.blog

This was my first time to St.Louis and I was not ... After this I headed to “Options, transients and theme_mods, Oh My!” by Konstantin Obenland.
Read more

WordCamp St. Louis 2014 | Event | WordPress.tv

... Options, and Transients, and Theme Mods, Oh My! Chris Koerner: How to Get Involved with the WordPress Community; accessibility API Beginner blogging ...
Read more

Presentations | Konstantin Obenland

January 17: WordCamp Phoenix: Cain & Obenland in the Morning: Pilot: March 1: WordCamp St. Louis: Options, and Transients, and Theme Mods, Oh My! March 14
Read more

WordCamp St.Louis 2014 - Official Bluehost Blog

WordCamp St.Louis 2014. March 3, 2014 November 5, ... After this I headed to “Options, transients and theme_mods, Oh My!” by Konstantin Obenland.
Read more

Videos Archives - The St. Louis WordPress Community

Two more videos have been published from WordCamp St. Louis 2014! This time we have Konstantin Obenland talking about options, transients, and theme mods ...
Read more

WordCamps Archives - The St. Louis WordPress Community

The St. Louis WordPress Community. Search. Primary Menu Skip to content. Home; About Us. ... We’d like to have light breakfast options, snacks and drinks.
Read more