Plugin Directory

Changeset 3072571


Ignore:
Timestamp:
04/17/2024 05:35:16 PM (23 months ago)
Author:
Fastmover
Message:

fixed debug warnings

Location:
plugins-last-updated-column/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • plugins-last-updated-column/trunk/readme.md

    r3069744 r3072571  
    2929Changelot
    3030=
     31* 0.1.3
     32  * Fixed debug warnings
    3133* 0.1.2
    3234  * Version number bump
  • plugins-last-updated-column/trunk/readme.txt

    r3069748 r3072571  
    1 === Plugins Last Updated Column ===
     1=== Plugin Name ===
    22Contributors: Fastmover, karissa
    33Tags: plugins, plugins last updated, last updated, updated
    44Requires at least: 3.7
    55Tested up to: 6.5.2
    6 Stable tag: 0.1.2
     6Stable tag: 0.1.3
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2727
    2828== Changelog ==
     29
     30= 0.1.3 =
     31* Fixed debug warnings
    2932
    3033= 0.1.2 =
  • plugins-last-updated-column/trunk/sk-plugins-last-updated-column.php

    r3069744 r3072571  
    44 * Plugin URI: http://stevenkohlmeyer.com/plugins-last-updated-column/
    55 * Description: This plugin adds a 'Last Updated' column to the admin plugins page.
    6  * Version: 0.1.2
     6 * Version: 0.1.3
    77 * Author: Fastmover
    88 * Author URI: http://StevenKohlmeyer.com
     
    1616class SK_Plugins_Last_Updated_Column
    1717{
    18 
    1918    public $cacheTime    = 1800;
    20 
    2119    public $slugUpdated  = "sk-plugin-last-updated ";
    22 
    2320    public $slugUpgraded = "sk-plugin-last-upgraded ";
    24 
    2521    public $slugSettings = "plugins-last-updated-settings";
     22    public $currentDateTime = false;
    2623
    2724    function __construct ()
    2825    {
    29 
    3026        add_filter ( 'manage_plugins_columns', array ( $this, 'columnHeading' ) );
    3127        add_filter ( 'manage_plugins-network_columns', array ( $this, 'columnHeading' ) );
     
    3329        add_action ( 'admin_head', array ( $this, 'css' ) );
    3430        add_action ( 'admin_menu', array ( $this, 'menu' ) );
    35 
    3631        add_action ( 'admin_notices', array ( $this, 'notices' ) );
    3732        add_action ( 'admin_enqueue_scripts', array ( $this, 'js' ) );
    38 
    39         $this->firstColumnHeading = true;
    40 
    4133    }
    4234
    4335    public function color ( $level )
    4436    {
    45 
    4637        switch ( $level ) {
    4738
     
    7162
    7263        return $color;
    73 
    7464    }
    7565
    7666    function columnData ( $columnName, $pluginFile, $pluginData )
    7767    {
    78 
    7968        if ( $this->slugUpdated == $columnName ) {
    80 
    8169            $this->columnLastUpdated ( $columnName, $pluginFile, $pluginData );
    82 
    83 
    8470        } elseif ( $this->slugUpgraded == $columnName ) {
    85 
    8671            $this->columnLastUpgraded ( $columnName, $pluginFile, $pluginData );
    87 
    88         }
    89 
     72        }
    9073    }
    9174
     
    10588        if ( $lastUpdated !== "-1" && $lastUpdated !== -1 ) {
    10689
    107             if ( ! isset( $this->currentDateTime ) ) {
    108 
     90            if ( ! $this->currentDateTime ) {
    10991                $this->currentDateTime = new DateTime();
    110 
    11192            }
    11293
     
    145126        } else {
    146127            ?>
    147             <span>Not Avail.</span><?php
     128            <span>Not Avail.</span>
     129            <?php
    148130        }
    149131
     
    153135              style="background-color: <?php echo $color; ?>"><?php echo $msg; ?></span>
    154136        <?php
    155 
    156137    }
    157138
     
    161142        ?><span class="lastUpgradedMobileTitle">Last Upgraded: </span><?php
    162143
    163 
    164144        $version = $pluginData[ 'Version' ];
    165145
    166146        if ( isset( $pluginData[ 'slug' ] ) ) {
    167 
    168147            $slug = $pluginData[ 'slug' ];
    169 
    170148        } else {
    171 
    172149            $slug = sanitize_title ( $pluginFile );
    173 
    174150        }
    175151
    176152        $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 );
    182157
    183158        if ( $lastDate === false ) {
    184 
    185159            add_option ( $lastUpgradedDate, "Not Avail." );
    186160            $lastUpgradedOutput = "Not Avail.";
    187 
    188161        } else {
    189 
    190162            $lastUpgradedOutput = $lastDate;
    191 
    192163        }
    193164
    194165        if ( ! $lastVersion or $lastVersion !== $version ) {
    195 
    196166            if ( $lastVersion === false ) {
    197 
    198167                add_option ( $lastUpgradedSlug, $version );
    199 
    200             } else {
    201 
     168            } else {
    202169                update_option ( $lastUpgradedSlug, $version );
    203 
    204170            }
    205171
    206172            if ( $lastDate !== false ) {
    207 
    208173                $lastUpgradedOutput = Date ( 'Y-m-d' );
    209174                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
    218181
    219182    }
     
    237200            /** Check for Errors & Display the results */
    238201            if ( is_wp_error ( $call_api ) ) {
    239 
    240202                set_transient ( $this->slugUpdated . $pluginSlug, -1, $this->cacheTime );
    241203
    242204                return -1;
    243 
    244             } else {
    245 
     205            } else {
    246206                if ( ! empty( $call_api->last_updated ) ) {
    247 
    248207                    set_transient ( $this->slugUpdated . $pluginSlug, $call_api->last_updated,
    249208                            $this->cacheTime );
    250209
    251210                    return $call_api->last_updated;
    252 
    253211                } else {
    254 
    255212                    set_transient ( $this->slugUpdated . $pluginSlug, -1, $this->cacheTime );
    256213
    257214                    return -1;
    258 
    259215                }
    260 
    261216            }
    262217
    263218        } else {
    264 
    265219            //Debugging purposes:
    266220            //delete_transient( 'sk_plugins_last_updated' . $pluginSlug );
    267221
    268 
    269222            return get_transient ( $this->slugUpdated . $pluginSlug );
    270 
    271223        }
    272224    }
     
    274226    function columnHeading ( $columns )
    275227    {
    276 
    277228        $columns[ $this->slugUpdated ]  = '<span>Last Updated</span>';
    278229        $columns[ $this->slugUpgraded ] = '<span>Last Upgraded</span>';
    279230
    280231        return $columns;
    281 
    282232    }
    283233
    284234    function css ()
    285235    {
    286 
    287236        ?>
    288237        <style type="text/css">
     
    319268    public function js ( $hook = false )
    320269    {
    321 
    322270        if ( 'plugins.php' != $hook ) {
    323271            return;
    324272        }
    325 
    326 //        var_dump( plugin_dir_url( __FILE__ ) . 'plugins-last-updated.js' ); die;
    327273
    328274        wp_enqueue_script (
     
    333279                true
    334280        );
    335 
    336 
    337281    }
    338282
    339283    public function menu ()
    340284    {
    341 
    342285        add_submenu_page ( 'plugins.php', 'Plugins Columns', 'Plugin Columns', 'manage_options', $this->slugSettings,
    343286                array ( $this, 'settings' ) );
     
    354297
    355298            if( $yearDiff == 1 ) {
    356 
    357299                $msg .= " Year ";
    358 
    359             } else {
    360 
     300            } else {
    361301                $msg .= " Years ";
    362 
    363302            }
    364303
     
    366305
    367306        if ( $monthDiff !== 0 ) {
    368 
    369307            $msg .= $monthDiff . " Mon. ";
    370 
    371308        }
    372309
     
    376313
    377314            if( $dayDiff == 1 ) {
    378 
    379315                $msg .= " Day";
    380 
    381             } else {
    382 
     316            } else {
    383317                $msg .= " Days";
    384 
    385318            }
    386319        }
     
    393326    public function notices ()
    394327    {
    395 
    396328        $screen = get_current_screen ();
    397329
    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            ):
    399335
    400336            global $wpdb;
     
    416352    public function roundDown ( $num, $max )
    417353    {
    418 
    419         if( $num === 0 )
     354        if( $num === 0 ) {
    420355            return $num;
     356        }
    421357
    422358        $remainder = ( $num % $max );
    423359
    424         if ( $remainder > 0 )
     360        if ( $remainder > 0 ) {
    425361            return $remainder;
     362        }
    426363
    427364        return $num;
    428 
    429365    }
    430366
     
    447383    }
    448384
    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-2
    455 
    456 //        https://github.com/symphonycms/symphony-2/commit/c8b0ee87ce0f72cad2ac5ba1c88ddd7c258bfc62
    457 
    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         <?php
    471 
    472         // */
    473 
    474 
    475     }
    476 
    477385    function warningLevel( $yearDiff, $monthDiff, $dayDiff )
    478386    {
    479387
    480388        $warningLevel = 1;
    481 
    482389
    483390        if ( $yearDiff === 0 ) {
     
    494401                $warningLevel = 4;
    495402            }
    496 
    497403        }
    498404
    499405        return $warningLevel;
    500 
    501     }
    502 
     406    }
    503407
    504408}
    505409
    506410$SK_Plugins_Last_Updated_Column = new SK_Plugins_Last_Updated_Column();
    507 
    508 ?>
Note: See TracChangeset for help on using the changeset viewer.