diff --git a/wp-revisions-control.php b/wp-revisions-control.php index 27609a79262fe2e5a032a26d36cd495179cad5a3..fae037ef50d921b25994d2d003f26f3dbf1714a5 100644 --- a/wp-revisions-control.php +++ b/wp-revisions-control.php @@ -57,19 +57,6 @@ class WP_Revisions_Control { return self::$__instance; } - /** - * Magic getter to provide access to class variables - * - * @param string $name - * @return mixed - */ - // public function __get( $name ) { - // if ( property_exists( $this, $name ) ) - // return $this->$name; - // else - // return null; - // } - /** * Register actions and filters * @@ -89,13 +76,23 @@ class WP_Revisions_Control { public function action_admin_init() { register_setting( $this->settings_page, $this->settings_section, array( $this, 'sanitize_options' ) ); - add_settings_section( $this->settings_section, __( 'WP Revisions Control', 'wp_revisions_control' ), '__return_false', $this->settings_page ); + add_settings_section( $this->settings_section, __( 'WP Revisions Control', 'wp_revisions_control' ), array( $this, 'settings_section_intro' ), $this->settings_page ); foreach ( $this->get_post_types() as $post_type => $name ) { add_settings_field( $this->settings_section . '-' . $post_type, $name, array( $this, 'field_post_type' ), $this->settings_page, $this->settings_section, array( 'post_type' => $post_type ) ); } } + /** + * + */ + public function settings_section_intro() { + ?> + <p><?php _e( 'Set the number of revisions to save for each post type listed. To retain all revisions for a given post type, leave the field empty.', 'wp_revisions_control' ); ?></p> + <p><?php _e( "If a post type isn't listed, revisions are not enabled for that post type.", 'wp_revisions_control' ); ?></p> + <?php + } + /** * */ @@ -114,11 +111,15 @@ class WP_Revisions_Control { if ( is_array( $options ) ) { foreach ( $options as $post_type => $to_keep ) { - if ( empty( $to_keep ) ) + if ( 0 === strlen( $to_keep ) ) $to_keep = -1; else $to_keep = intval( $to_keep ); + // Lowest possible value is -1, used to indicate infinite revisions are stored + if ( -1 > $to_keep ) + $to_keep = -1; + $options_sanitized[ $post_type ] = $to_keep; } }