Changeset 3072571
- Timestamp:
- 04/17/2024 05:35:16 PM (23 months ago)
- Location:
- plugins-last-updated-column/trunk
- Files:
-
- 3 edited
-
readme.md (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
sk-plugins-last-updated-column.php (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins-last-updated-column/trunk/readme.md
r3069744 r3072571 29 29 Changelot 30 30 = 31 * 0.1.3 32 * Fixed debug warnings 31 33 * 0.1.2 32 34 * Version number bump -
plugins-last-updated-column/trunk/readme.txt
r3069748 r3072571 1 === Plugin s Last Updated Column===1 === Plugin Name === 2 2 Contributors: Fastmover, karissa 3 3 Tags: plugins, plugins last updated, last updated, updated 4 4 Requires at least: 3.7 5 5 Tested up to: 6.5.2 6 Stable tag: 0.1. 26 Stable tag: 0.1.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 27 27 28 28 == Changelog == 29 30 = 0.1.3 = 31 * Fixed debug warnings 29 32 30 33 = 0.1.2 = -
plugins-last-updated-column/trunk/sk-plugins-last-updated-column.php
r3069744 r3072571 4 4 * Plugin URI: http://stevenkohlmeyer.com/plugins-last-updated-column/ 5 5 * Description: This plugin adds a 'Last Updated' column to the admin plugins page. 6 * Version: 0.1. 26 * Version: 0.1.3 7 7 * Author: Fastmover 8 8 * Author URI: http://StevenKohlmeyer.com … … 16 16 class SK_Plugins_Last_Updated_Column 17 17 { 18 19 18 public $cacheTime = 1800; 20 21 19 public $slugUpdated = "sk-plugin-last-updated "; 22 23 20 public $slugUpgraded = "sk-plugin-last-upgraded "; 24 25 21 public $slugSettings = "plugins-last-updated-settings"; 22 public $currentDateTime = false; 26 23 27 24 function __construct () 28 25 { 29 30 26 add_filter ( 'manage_plugins_columns', array ( $this, 'columnHeading' ) ); 31 27 add_filter ( 'manage_plugins-network_columns', array ( $this, 'columnHeading' ) ); … … 33 29 add_action ( 'admin_head', array ( $this, 'css' ) ); 34 30 add_action ( 'admin_menu', array ( $this, 'menu' ) ); 35 36 31 add_action ( 'admin_notices', array ( $this, 'notices' ) ); 37 32 add_action ( 'admin_enqueue_scripts', array ( $this, 'js' ) ); 38 39 $this->firstColumnHeading = true;40 41 33 } 42 34 43 35 public function color ( $level ) 44 36 { 45 46 37 switch ( $level ) { 47 38 … … 71 62 72 63 return $color; 73 74 64 } 75 65 76 66 function columnData ( $columnName, $pluginFile, $pluginData ) 77 67 { 78 79 68 if ( $this->slugUpdated == $columnName ) { 80 81 69 $this->columnLastUpdated ( $columnName, $pluginFile, $pluginData ); 82 83 84 70 } elseif ( $this->slugUpgraded == $columnName ) { 85 86 71 $this->columnLastUpgraded ( $columnName, $pluginFile, $pluginData ); 87 88 } 89 72 } 90 73 } 91 74 … … 105 88 if ( $lastUpdated !== "-1" && $lastUpdated !== -1 ) { 106 89 107 if ( ! isset( $this->currentDateTime ) ) { 108 90 if ( ! $this->currentDateTime ) { 109 91 $this->currentDateTime = new DateTime(); 110 111 92 } 112 93 … … 145 126 } else { 146 127 ?> 147 <span>Not Avail.</span><?php 128 <span>Not Avail.</span> 129 <?php 148 130 } 149 131 … … 153 135 style="background-color: <?php echo $color; ?>"><?php echo $msg; ?></span> 154 136 <?php 155 156 137 } 157 138 … … 161 142 ?><span class="lastUpgradedMobileTitle">Last Upgraded: </span><?php 162 143 163 164 144 $version = $pluginData[ 'Version' ]; 165 145 166 146 if ( isset( $pluginData[ 'slug' ] ) ) { 167 168 147 $slug = $pluginData[ 'slug' ]; 169 170 148 } else { 171 172 149 $slug = sanitize_title ( $pluginFile ); 173 174 150 } 175 151 176 152 $lastUpgradedOutput = ""; 177 178 $lastUpgradedSlug = 'plugin_last_upgraded_version_' . $slug; 179 $lastUpgradedDate = 'plugin_last_upgraded_date_' . $slug; 180 $lastVersion = get_option ( $lastUpgradedSlug, false ); 181 $lastDate = get_option ( $lastUpgradedDate, false ); 153 $lastUpgradedSlug = 'plugin_last_upgraded_version_' . $slug; 154 $lastUpgradedDate = 'plugin_last_upgraded_date_' . $slug; 155 $lastVersion = get_option ( $lastUpgradedSlug, false ); 156 $lastDate = get_option ( $lastUpgradedDate, false ); 182 157 183 158 if ( $lastDate === false ) { 184 185 159 add_option ( $lastUpgradedDate, "Not Avail." ); 186 160 $lastUpgradedOutput = "Not Avail."; 187 188 161 } else { 189 190 162 $lastUpgradedOutput = $lastDate; 191 192 163 } 193 164 194 165 if ( ! $lastVersion or $lastVersion !== $version ) { 195 196 166 if ( $lastVersion === false ) { 197 198 167 add_option ( $lastUpgradedSlug, $version ); 199 200 } else { 201 168 } else { 202 169 update_option ( $lastUpgradedSlug, $version ); 203 204 170 } 205 171 206 172 if ( $lastDate !== false ) { 207 208 173 $lastUpgradedOutput = Date ( 'Y-m-d' ); 209 174 update_option ( $lastUpgradedDate, $lastUpgradedOutput ); 210 211 } 212 213 } 214 215 216 ?><span><?php echo $lastUpgradedOutput; ?></span><?php 217 175 } 176 } 177 178 ?> 179 <span><?php echo $lastUpgradedOutput; ?></span> 180 <?php 218 181 219 182 } … … 237 200 /** Check for Errors & Display the results */ 238 201 if ( is_wp_error ( $call_api ) ) { 239 240 202 set_transient ( $this->slugUpdated . $pluginSlug, -1, $this->cacheTime ); 241 203 242 204 return -1; 243 244 } else { 245 205 } else { 246 206 if ( ! empty( $call_api->last_updated ) ) { 247 248 207 set_transient ( $this->slugUpdated . $pluginSlug, $call_api->last_updated, 249 208 $this->cacheTime ); 250 209 251 210 return $call_api->last_updated; 252 253 211 } else { 254 255 212 set_transient ( $this->slugUpdated . $pluginSlug, -1, $this->cacheTime ); 256 213 257 214 return -1; 258 259 215 } 260 261 216 } 262 217 263 218 } else { 264 265 219 //Debugging purposes: 266 220 //delete_transient( 'sk_plugins_last_updated' . $pluginSlug ); 267 221 268 269 222 return get_transient ( $this->slugUpdated . $pluginSlug ); 270 271 223 } 272 224 } … … 274 226 function columnHeading ( $columns ) 275 227 { 276 277 228 $columns[ $this->slugUpdated ] = '<span>Last Updated</span>'; 278 229 $columns[ $this->slugUpgraded ] = '<span>Last Upgraded</span>'; 279 230 280 231 return $columns; 281 282 232 } 283 233 284 234 function css () 285 235 { 286 287 236 ?> 288 237 <style type="text/css"> … … 319 268 public function js ( $hook = false ) 320 269 { 321 322 270 if ( 'plugins.php' != $hook ) { 323 271 return; 324 272 } 325 326 // var_dump( plugin_dir_url( __FILE__ ) . 'plugins-last-updated.js' ); die;327 273 328 274 wp_enqueue_script ( … … 333 279 true 334 280 ); 335 336 337 281 } 338 282 339 283 public function menu () 340 284 { 341 342 285 add_submenu_page ( 'plugins.php', 'Plugins Columns', 'Plugin Columns', 'manage_options', $this->slugSettings, 343 286 array ( $this, 'settings' ) ); … … 354 297 355 298 if( $yearDiff == 1 ) { 356 357 299 $msg .= " Year "; 358 359 } else { 360 300 } else { 361 301 $msg .= " Years "; 362 363 302 } 364 303 … … 366 305 367 306 if ( $monthDiff !== 0 ) { 368 369 307 $msg .= $monthDiff . " Mon. "; 370 371 308 } 372 309 … … 376 313 377 314 if( $dayDiff == 1 ) { 378 379 315 $msg .= " Day"; 380 381 } else { 382 316 } else { 383 317 $msg .= " Days"; 384 385 318 } 386 319 } … … 393 326 public function notices () 394 327 { 395 396 328 $screen = get_current_screen (); 397 329 398 if ( isset( $screen ) and $screen->base === ( "plugins_page_" . $this->slugSettings ) and $_REQUEST[ 'clear-cache' ] == "true" ): 330 if ( 331 isset( $screen ) and 332 $screen->base === ( "plugins_page_" . $this->slugSettings ) and 333 ( isset( $_REQUEST[ 'clear-cache' ] ) and $_REQUEST[ 'clear-cache' ] == "true" ) 334 ): 399 335 400 336 global $wpdb; … … 416 352 public function roundDown ( $num, $max ) 417 353 { 418 419 if( $num === 0 ) 354 if( $num === 0 ) { 420 355 return $num; 356 } 421 357 422 358 $remainder = ( $num % $max ); 423 359 424 if ( $remainder > 0 ) 360 if ( $remainder > 0 ) { 425 361 return $remainder; 362 } 426 363 427 364 return $num; 428 429 365 } 430 366 … … 447 383 } 448 384 449 function timeDiff ( $start, $end )450 {451 452 // To Add php 5.2 support or not?453 454 // http://stackoverflow.com/questions/4033224/what-can-use-for-datetimediff-for-php-5-2455 456 // https://github.com/symphonycms/symphony-2/commit/c8b0ee87ce0f72cad2ac5ba1c88ddd7c258bfc62457 458 /*459 460 $phpVersion = phpversion();461 ?>462 <?php var_dump( $phpVersion ); ?><br />463 5.2.1 <?= ( $phpVersion > "5.2.1" ); ?><br />464 5.5.1 <?= ( $phpVersion > "5.5.1" ); ?><br />465 5.5.2 <?= ( $phpVersion > "5.5.2" ); ?><br />466 5.5.21 <?= ( $phpVersion > "5.5.21" ); ?><br />467 5.5.26 <?= ( $phpVersion > "5.5.26" ); ?><br />468 5.5.27 <?= ( $phpVersion === "5.5.27" ); ?><br />469 5.6.1 <?= ( $phpVersion > "5.6.1" ); ?><br />470 <?php471 472 // */473 474 475 }476 477 385 function warningLevel( $yearDiff, $monthDiff, $dayDiff ) 478 386 { 479 387 480 388 $warningLevel = 1; 481 482 389 483 390 if ( $yearDiff === 0 ) { … … 494 401 $warningLevel = 4; 495 402 } 496 497 403 } 498 404 499 405 return $warningLevel; 500 501 } 502 406 } 503 407 504 408 } 505 409 506 410 $SK_Plugins_Last_Updated_Column = new SK_Plugins_Last_Updated_Column(); 507 508 ?>
Note: See TracChangeset
for help on using the changeset viewer.