From 763685ae9df7d8f962b36d2d03591555a4f1eb97 Mon Sep 17 00:00:00 2001 From: lancewillett Date: Wed, 18 Jul 2012 18:41:17 +0000 Subject: [PATCH] Twenty Twelve: update theme options file to use PHP5 constructor and visibility keywords, and also minor DocBlock cleanup. Props Mamaduka and obenland, closes #21297. git-svn-id: http://core.svn.wordpress.org/trunk@21280 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- inc/theme-options.php | 73 +++++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/inc/theme-options.php b/inc/theme-options.php index d06907bf6..8a6780ef0 100644 --- a/inc/theme-options.php +++ b/inc/theme-options.php @@ -11,15 +11,28 @@ class Twenty_Twelve_Options { /** * The option value in the database will be based on get_stylesheet() * so child themes don't share the parent theme's option value. + * + * @access public + * @var string */ - var $option_key = 'twentytwelve_theme_options'; + public $option_key = 'twentytwelve_theme_options'; /** - * Initialize our options. + * Holds our options. + * + * @access public + * @var array */ - var $options = array(); + public $options = array(); - function Twenty_Twelve_Options() { + /** + * Constructor + * + * @access public + * + * @return Twenty_Twelve_Options + */ + public function __construct() { // Set option key based on get_stylesheet() if ( 'twentytwelve' != get_stylesheet() ) $this->option_key = get_stylesheet() . '_theme_options'; @@ -37,8 +50,12 @@ class Twenty_Twelve_Options { * This call to register_setting() registers a validation callback, validate(), * which is used when the option is saved, to ensure that our option values are properly * formatted, and safe. + * + * @access public + * + * @return void */ - function options_init() { + public function options_init() { // Load our options for use in any method. $this->options = $this->get_theme_options(); @@ -71,8 +88,12 @@ class Twenty_Twelve_Options { * Add our theme options page to the admin menu. * * This function is attached to the admin_menu action hook. + * + * @access public + * + * @return void */ - function add_page() { + public function add_page() { $theme_page = add_theme_page( __( 'Theme Options', 'twentytwelve' ), // Name of page __( 'Theme Options', 'twentytwelve' ), // Label in menu @@ -84,8 +105,12 @@ class Twenty_Twelve_Options { /** * Returns the default options. + * + * @access public + * + * @return array */ - function get_default_theme_options() { + public function get_default_theme_options() { $default_theme_options = array( 'enable_fonts' => false, ); @@ -95,15 +120,23 @@ class Twenty_Twelve_Options { /** * Returns the options array. + * + * @access public + * + * @return array */ - function get_theme_options() { + public function get_theme_options() { return get_option( $this->option_key, $this->get_default_theme_options() ); } /** * Renders the enable fonts checkbox setting field. + * + * @access public + * + * @return void */ - function settings_field_enable_fonts() { + public function settings_field_enable_fonts() { $options = $this->options; ?>