Plugin Directory

Changeset 972684


Ignore:
Timestamp:
08/25/2014 10:07:56 PM (12 years ago)
Author:
joshcanhelp
Message:

Version 1.0.1 - PHP 5.2 fix for posts widget

Location:
proper-widgets/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • proper-widgets/trunk/proper-widgets.php

    r969970 r972684  
    55Plugin URI: http://theproperweb.com/product/proper-widgets/
    66Description: More widgets than you can shake a stick at.
    7 Version: 1.0.0
     7Version: 1.0.1
    88Author: PROPER Web Development
    99Author URI: http://theproperweb.com
     
    1313
    1414// Constants
    15 define( 'PROPER_WIDGETS_VERSION', '1.0.0' );
     15define( 'PROPER_WIDGETS_VERSION', '1.0.1' );
    1616define( 'PROPER_WIDGETS_MINIMUM_WP_VERSION', '3.0' );
    1717define( 'PROPER_WIDGETS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
  • proper-widgets/trunk/readme.txt

    r969972 r972684  
    55Requires at least: 3.0
    66Tested up to: 4.0
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88
    99Creates easy-to-use, helpful widgets
     
    4343== Changelog ==
    4444
     45= 1.0.1 =
     46* Fixed issue with Posts widget in PHP 5.2
     47
    4548= 1.0.0 =
    4649* Added the Author widget
  • proper-widgets/trunk/the-widgets/proper-posts-widget.php

    r969970 r972684  
    143143            switch ( $instance['orderby_final'] ) {
    144144                case 'date':
    145                     usort( $the_posts, function ($a, $b) {
    146                         return $a->post_date < $b->post_date;
    147                     });
    148                     break;
     145                    usort( $the_posts, array( $this, 'usort_published' ) );
     146                    break;
     147
    149148                case 'modified':
    150                     usort( $the_posts, function ( $a, $b ) {
    151                         return $a->post_modified < $b->post_modified;
    152                     } );
    153                     break;
     149                    usort( $the_posts, array( $this, 'usort_modified' ) );
     150                    break;
     151
     152                case 'title':
     153                    usort( $the_posts, array( $this, 'usort_title' ) );
     154                    break;
     155
     156                case 'comment_count':
     157                    usort( $the_posts, array( $this, 'usort_comments' ) );
     158                    break;
     159
    154160                case 'rand':
    155161                    shuffle( $the_posts );
    156                     break;
    157                 case 'title':
    158                     usort( $the_posts, function  ($a, $b) {
    159                         return strcmp( $a->post_title, $b->post_title );
    160                     });
    161                     break;
    162                 case 'comment_count':
    163                     usort( $the_posts, function ( $a, $b ) {
    164                         return $a->comment_count > $b->comment_count;
    165                     } );
    166162                    break;
    167163            }
     
    263259
    264260    }
     261
     262    /**
     263     * Sorting functions used by usort
     264     */
     265    private function usort_published ( $a, $b ) {
     266        return $a->post_date < $b->post_date;
     267    }
     268
     269    private function usort_modified ( $a, $b ) {
     270        return $a->post_modified < $b->post_modified;
     271    }
     272
     273    private function usort_title ( $a, $b ) {
     274        return strcmp( $a->post_title, $b->post_title );
     275    }
     276
     277    private function usort_comments ( $a, $b ) {
     278        return $a->comment_count > $b->comment_count;
     279    }
    265280}
    266281
Note: See TracChangeset for help on using the changeset viewer.