Changeset 1117133
- Timestamp:
- 03/20/2015 07:48:27 PM (11 years ago)
- Location:
- wp-revisions-limit/trunk
- Files:
-
- 3 edited
-
README.txt (modified) (2 diffs)
-
admin/class-wp-revisions-limit-admin.php (modified) (5 diffs)
-
wp-revisions-limit.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-revisions-limit/trunk/README.txt
r1116968 r1117133 4 4 Requires at least: 3.6 5 5 Tested up to: 4.1 6 Stable tag: 1.0. 06 Stable tag: 1.0.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 33 33 == Changelog == 34 34 35 = 1.0.1 = 36 * Check if WP_POST_REVISIONS is already defined in wp-config.php file. 37 35 38 = 1.0.0 = 36 39 * Initial public release -
wp-revisions-limit/trunk/admin/class-wp-revisions-limit-admin.php
r1116908 r1117133 46 46 47 47 /** 48 * Holds the name of WP_POST_REVISIONS constant 49 */ 50 const WP_POST_REVISIONS = 'WP_POST_REVISIONS'; 51 52 /** 48 53 * Holds the default value of revisions number 49 54 */ 50 private $default_revisions_limit;55 const DEFAULT_REVISIONS_LIMIT = 5; 51 56 52 57 /** … … 61 66 $this->plugin_name = $plugin_name; 62 67 $this->version = $version; 63 $this->default_revisions_limit = 5;64 68 65 69 } … … 186 190 } 187 191 188 require_once 'partials/wp-revisions-limit-admin-display.php'; 192 $wp_config_file = $_SERVER["DOCUMENT_ROOT"] . '/wp-config.php'; 193 $contents = file_get_contents( $wp_config_file ); 194 $pattern = "define\(( )?'WP_POST_REVISIONS'"; 195 $pattern = "/^$pattern.*/m"; 196 197 if ( !preg_match_all( $pattern, $contents, $matches ) ) { 198 require_once 'partials/wp-revisions-limit-admin-display.php'; 199 } else { 200 wp_die( __( 'Constant WP_POST_REVISIONS is already defined in wp-config.php file, remove it to be able to set up a limit for your post revisions.' ) ); 201 } 189 202 190 203 } … … 211 224 public function define_post_revisions() { 212 225 213 $this->load_options(); 214 215 if ( isset( $this->options['revisions_limit'] ) && $this->options['revisions_limit'] != '' ) { 216 if ( is_numeric( $this->options['revisions_limit'] ) ) { 217 define( 'WP_POST_REVISIONS', (int)$this->options['revisions_limit'] + 1 ); 226 if ( !defined( self::WP_POST_REVISIONS ) ) { 227 $this->load_options(); 228 229 if ( isset( $this->options['revisions_limit'] ) && $this->options['revisions_limit'] != '' ) { 230 if ( is_numeric( $this->options['revisions_limit'] ) ) { 231 define( self::WP_POST_REVISIONS, (int)$this->options['revisions_limit'] + 1 ); 232 } else { 233 define( self::WP_POST_REVISIONS, self::DEFAULT_REVISIONS_LIMIT ); 234 } 218 235 } else { 219 define( 'WP_POST_REVISIONS', $this->default_revisions_limit);236 define( self::WP_POST_REVISIONS, self::DEFAULT_REVISIONS_LIMIT ); 220 237 } 221 } else { 222 define( 'WP_POST_REVISIONS', $this->default_revisions_limit ); 223 } 224 238 } 225 239 } 226 240 … … 232 246 public function load_options() { 233 247 234 if ( ! $this->options )248 if ( !isset( $this->options ) ) { 235 249 $this->options = get_option( 'revisions_limit_option' ); 250 } 236 251 237 252 return $this->options; -
wp-revisions-limit/trunk/wp-revisions-limit.php
r1116908 r1117133 11 11 * Plugin URI: http://www.twomandarins.com 12 12 * Description: Limit number of revisions stored. 13 * Version: 1.0. 013 * Version: 1.0.1 14 14 * Author: Roger Rodrigo (TwoMandarins) 15 15 * Author URI: http://www.twomandarins.com
Note: See TracChangeset
for help on using the changeset viewer.