Commit 5edfa78c authored by Erick Hitter's avatar Erick Hitter
Browse files

Convert get_settings() method to use a static variable store

parent 72c36f97
...@@ -32,6 +32,7 @@ class WP_Revisions_Control { ...@@ -32,6 +32,7 @@ class WP_Revisions_Control {
* Class variables * Class variables
*/ */
private static $post_types = array(); private static $post_types = array();
private static $settings = array();
private $settings_page = 'writing'; private $settings_page = 'writing';
private $settings_section = 'wp_revisions_control'; private $settings_section = 'wp_revisions_control';
...@@ -172,20 +173,24 @@ class WP_Revisions_Control { ...@@ -172,20 +173,24 @@ class WP_Revisions_Control {
* @return array * @return array
*/ */
private function get_settings() { private function get_settings() {
$post_types = $this->get_post_types(); if ( empty( self::$settings ) ) {
$post_types = $this->get_post_types();
$settings = get_option( $this->settings_section, array() ); $settings = get_option( $this->settings_section, array() );
$merged_settings = array(); $merged_settings = array();
foreach ( $post_types as $post_type => $name ) { foreach ( $post_types as $post_type => $name ) {
if ( array_key_exists( $post_type, $settings ) ) if ( array_key_exists( $post_type, $settings ) )
$merged_settings[ $post_type ] = (int) $settings[ $post_type ]; $merged_settings[ $post_type ] = (int) $settings[ $post_type ];
else else
$merged_settings[ $post_type ] = -1; $merged_settings[ $post_type ] = -1;
}
self::$settings = $merged_settings;
} }
return $merged_settings; return self::$settings;
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment