Changeset 225203
- Timestamp:
- 04/04/2010 01:00:48 PM (16 years ago)
- Location:
- custom-avatars-for-comments/trunk
- Files:
-
- 2 edited
-
comment_avatars.php (modified) (1 diff)
-
inc/admin.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
custom-avatars-for-comments/trunk/comment_avatars.php
r225201 r225203 76 76 * @since 0.0.2 77 77 */ 78 function get_option ( $option ) {78 function get_option( $option ) { 79 79 if ( isset ( $this->options[$option] ) ) 80 80 return $this->options[$option]; -
custom-avatars-for-comments/trunk/inc/admin.php
r225202 r225203 9 9 class CommentAvatarsAdmin extends CommentAvatars { 10 10 11 12 /** 13 * Version of the options format 14 * 15 * @since 0.2.0.0 16 * @var string 17 */ 18 var $version = '0.2.0.0'; 19 11 20 /** 12 21 * Path to the main plugin file … … 31 40 * 32 41 * @return none 33 * @since 3.0.0.042 * @since 0.0.2 34 43 */ 35 44 function __construct () { 36 45 CommentAvatars::__construct (); 37 46 47 $this->check_upgrade(); 48 38 49 // Full path to main file 39 50 $this->plugin_file = dirname ( dirname ( __FILE__ ) ) . '/comment_avatars.php'; … … 70 81 function defaults () { 71 82 $defaults = array ( 72 'version' => '0. 1.2',83 'version' => '0.2.0.0', 73 84 'usedefaultpng' => '0', 74 85 'hidedefaultpng' => '0', … … 92 103 * @since 0.0.2 93 104 */ 94 function init () {105 function init() { 95 106 if ( ! get_option ( 'commentavatars' ) ) 96 107 add_option ( 'commentavatars' , $this->defaults () ); 97 } 108 else 109 $this->check_upgrade(); 110 } 111 112 /** 113 * Check if we need to perform an upgrade 114 * 115 * @return none 116 * @since 0.2.0.0 117 */ 118 function check_upgrade() { 119 if ( version_compare ( $this->get_option( 'version' ), $this->version, '<' ) ) 120 $this->upgrade(); 121 } 122 123 /** 124 * Perform an upgrade 125 * 126 * @return none 127 * @since 0.2.0.0 128 */ 129 function upgrade() { 130 if ( version_compare( $this->get_option( 'version' ), '0.2.0.0' ) == -1 ) { 131 // If the plugin was already in use we assume the user added the 132 // select field by hand and hide it. 133 $newopts = $this->defaults(); 134 $this->options = array_merge( $this->options , $newopts ); 135 $this->options['removeselect'] = '1'; 136 #var_dump( $this->options ); 137 update_option( 'commentavatars', $this->options ); 138 } 139 } 98 140 99 141 /** … … 103 145 * @since 0.0.2 104 146 */ 105 function add_page () {147 function add_page() { 106 148 if ( current_user_can ( 'manage_options' ) && function_exists ( 'add_options_page' ) ) { 107 149 $options_page = add_options_page ( __( 'Comment Avatars' , 'custom-avatars-for-comments' ) , __( 'Comment Avatars' , 'custom-avatars-for-comments' ) , 'manage_options' , 'commentavatars' , array ( &$this , 'admin_page' ) ); … … 163 205 <form method="post" action="options.php"> <?php 164 206 settings_fields( 'commentavatars_options' ); ?> 207 <input type="hidden" name="commentavatars[version]" value="<?php echo $this->get_option( 'version' ) ?>" /> 165 208 <table class="form-table form-table-clearnone" > 166 209 … … 262 305 </tr> 263 306 264 </table>265 307 <tr valign="top"> 266 308 <th scope="row"> <?php
Note: See TracChangeset
for help on using the changeset viewer.