Plugin Directory

Changeset 486495


Ignore:
Timestamp:
01/08/2012 12:51:57 PM (14 years ago)
Author:
digitalnature
Message:

added a few filters

Location:
post-ratings
Files:
14 added
5 edited

Legend:

Unmodified
Added
Removed
  • post-ratings/trunk/lang/post-ratings.pot

    r476957 r486495  
    33"Project-Id-Version: Post Ratings\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: 2011-12-18 00:20+0200\n"
     5"POT-Creation-Date: 2012-01-05 21:13+0200\n"
    66"PO-Revision-Date: \n"
    77"Last-Translator: http://digitalnature.eu <hello@digitalnature.eu>\n"
     
    1717"X-Poedit-SearchPath-1: .\n"
    1818
    19 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:156
    20 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:250
     19#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:149
     20#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:246
    2121msgid "Post Ratings"
    2222msgstr ""
    2323
    24 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:181
     24#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:177
    2525msgid "Settings"
    2626msgstr ""
    2727
    28 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:242
     28#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:238
    2929msgid "Home"
    3030msgstr ""
    3131
    32 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:243
     32#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:239
    3333msgid "Archives"
    3434msgstr ""
    3535
    36 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:244
     36#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:240
    3737msgid "Single pages"
    3838msgstr ""
    3939
    40 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:245
     40#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:241
    4141msgid "Search results"
    4242msgstr ""
    4343
    44 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:256
     44#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:251
    4545msgid "Global stats"
    4646msgstr ""
    4747
    48 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:258
     48#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:253
    4949#, php-format
    5050msgid "%1$s votes (on %2$s posts)"
    5151msgstr ""
    5252
    53 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:259
     53#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:254
    5454#, php-format
    5555msgid "Average vote count per post: %s"
    5656msgstr ""
    5757
    58 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:260
     58#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:255
    5959#, php-format
    6060msgid "Average rating per post: %s"
    6161msgstr ""
    6262
    63 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:269
     63#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:264
    6464msgid "Access level"
    6565msgstr ""
    6666
    67 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:273
     67#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:268
    6868msgid "Allow unregistered users to vote"
    6969msgstr ""
    7070
    71 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:279
     71#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:274
    7272msgid "Maximum rating"
    7373msgstr ""
    7474
    75 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:282
     75#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:277
    7676msgid "Changing this option will reset existing post rating records"
    7777msgstr ""
    7878
    79 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:287
     79#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:283
    8080msgid "Bayesian rating (score) formula"
    8181msgstr ""
    8282
    83 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:310
     83#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:306
    8484msgid "I have my own formula:"
    8585msgstr ""
    8686
    87 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:316
     87#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:308
     88msgid "Legend"
     89msgstr ""
     90
     91#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:313
    8892msgid "Global average number of votes per post"
    8993msgstr ""
    9094
    91 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:318
     95#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:315
    9296msgid "Global number of votes (from all posts)"
    9397msgstr ""
    9498
    95 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:320
     99#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:317
    96100msgid "Number of votes from the current post"
    97101msgstr ""
    98102
    99 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:322
     103#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:319
    100104#, php-format
    101105msgid "Global average rating per post (from 1 to %d)"
    102106msgstr ""
    103107
    104 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:324
     108#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:321
    105109#, php-format
    106110msgid "Average rating of the current post (from 1 to %d)"
    107111msgstr ""
    108112
    109 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:326
     113#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:323
    110114#, php-format
    111115msgid "Minimum vote count per post to consider (%d by default)"
    112116msgstr ""
    113117
    114 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:328
     118#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:325
    115119#, php-format
    116120msgid "Maximum rating, see option above (currently %d)"
    117121msgstr ""
    118122
    119 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:336
     123#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:334
    120124msgid "Allow ratings on"
    121125msgstr ""
    122126
    123 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:352
     127#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:350
    124128msgid "Locations of the rate links"
    125129msgstr ""
    126130
    127 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:358
     131#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:356
    128132msgid "Before post content"
    129133msgstr ""
    130134
    131 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:363
     135#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:361
    132136msgid "After post content "
    133137msgstr ""
    134138
    135 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:368
     139#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:366
    136140msgid "I have my own action hook:"
    137141msgstr ""
    138142
    139 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:374
     143#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:372
    140144#, php-format
    141145msgid "You can also add it manually anywhere by using the %s shortcode"
    142146msgstr ""
    143147
    144 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:381
     148#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:379
    145149msgid "Page visibility"
    146150msgstr ""
    147151
    148 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:401
     152#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:399
    149153msgid "Save Changes"
    150154msgstr ""
    151155
    152 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:405
     156#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:403
    153157msgid "Delete rating records from all posts"
    154158msgstr ""
    155159
    156 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:512
     160#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:502
    157161msgid "Invalid vote! Cheatin' uh?"
    158162msgstr ""
    159163
    160 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:576
     164#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:563
    161165msgid "You cannot rate this post!"
    162166msgstr ""
    163167
    164 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:664
     168#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:652
    165169#, php-format
    166170msgid "%1$s vote, %2$s avg. rating (%3$s%% score)"
     
    169173msgstr[1] ""
    170174
    171 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:695
     175#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:685
    172176#, php-format
    173177msgid "Your '%s' action is must run in a post's context!"
    174178msgstr ""
    175179
    176 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:723
     180#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/post-ratings.php:715
    177181#, php-format
    178182msgid "Give %1$d out of %2$d stars"
     
    180184
    181185#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:28
    182 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:34
    183 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:364
    184 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:397
    185 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:498
     186#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:35
     187#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:341
     188#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:375
     189#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:474
    186190msgid "Top Rated"
    187191msgstr ""
    188192
    189193#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:29
    190 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:363
     194#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:340
    191195msgid "The highest rated posts on your site"
    192196msgstr ""
    193197
    194 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:139
    195 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:142
     198#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:117
     199#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:120
    196200#, php-format
    197201msgid "%s out of 10"
    198202msgstr ""
    199203
    200 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:256
    201 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:508
     204#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:187
     205#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:288
     206msgid "Show More"
     207msgstr ""
     208
     209#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:234
     210#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:484
    202211msgid "Title:"
    203212msgstr ""
    204213
    205 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:261
    206 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:513
     214#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:239
     215#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:489
    207216msgid "Get most rated:"
    208217msgstr ""
    209218
     219#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:249
     220#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:499
     221msgid "Sort by:"
     222msgstr ""
     223
     224#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:251
     225#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:501
     226msgid "Overall bayesian rating (score)"
     227msgstr ""
     228
     229#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:252
     230#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:502
     231msgid "Average rating"
     232msgstr ""
     233
     234#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:253
     235#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:503
     236msgid "Number of votes"
     237msgstr ""
     238
     239#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:260
     240#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:510
     241msgid "Descending"
     242msgstr ""
     243
     244#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:265
     245#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:515
     246msgid "Ascending"
     247msgstr ""
     248
     249#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:270
     250#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:520
     251msgid "Ignore posts older than:"
     252msgstr ""
     253
    210254#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:271
     255#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:521
     256msgid "days"
     257msgstr ""
     258
     259#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:273
    211260#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:523
    212 msgid "Sort by:"
    213 msgstr ""
    214 
    215 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:273
    216 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:525
    217 msgid "Overall bayesian rating (score)"
    218 msgstr ""
    219 
    220 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:274
    221 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:526
    222 msgid "Average rating"
    223 msgstr ""
    224 
    225 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:275
     261msgid "(0 to ignore date)"
     262msgstr ""
     263
     264#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:277
     265msgid "Thumbnail Size:"
     266msgstr ""
     267
     268#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:278
     269msgid "pixels"
     270msgstr ""
     271
     272#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:282
    226273#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:527
    227 msgid "Number of votes"
    228 msgstr ""
    229 
    230 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:282
    231 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:534
    232 msgid "Descending"
    233 msgstr ""
    234 
    235 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:287
    236 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:539
    237 msgid "Ascending"
    238 msgstr ""
    239 
    240 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:292
    241 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:544
    242 msgid "Ignore posts older than:"
    243 msgstr ""
    244 
    245 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:293
    246 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:545
    247 msgid "days"
     274msgid "Limit:"
     275msgstr ""
     276
     277#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:288
     278#, php-format
     279msgid "Display %s Link"
    248280msgstr ""
    249281
    250282#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:295
    251 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:547
    252 msgid "(0 to ignore date)"
    253 msgstr ""
    254 
    255 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:299
    256 msgid "Thumbnail Size:"
    257 msgstr ""
    258 
    259 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:300
    260 msgid "pixels"
    261 msgstr ""
    262 
    263 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:305
    264 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:551
    265 msgid "Limit:"
    266 msgstr ""
    267 
    268 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:311
    269 #, php-format
    270 msgid "Display %s Link"
    271 msgstr ""
    272 
    273 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:311
    274 msgid "Show More"
    275 msgstr ""
    276 
    277 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:318
    278283#, php-format
    279284msgid "Read the %s to see all available keywords."
    280285msgstr ""
    281286
    282 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:318
     287#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:295
    283288msgid "documentation"
    284289msgstr ""
    285290
    286 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:327
     291#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:304
    287292#, php-format
    288293msgid "<strong>Important:</strong> %1$s sized thumbnails have to be created if you just added this widget, or if you're changing the thumbnail size. Read more about thumbnail sizes %2$s"
    289294msgstr ""
    290295
    291 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:327
     296#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:304
    292297msgid "here"
    293298msgstr ""
    294299
    295 #: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:427
     300#: c:\wamp\www\wpmu\wp-content\plugins\post-ratings/widget.php:403
    296301#, php-format
    297302msgid "%d vote"
  • post-ratings/trunk/post-ratings.js

    r466038 r486495  
    22jQuery(document).ready(function($){
    33
    4   // @todo: use $.on in future versions, when 1.7
     4  // @todo: use $.on in future versions (jQuery 1.7+)
    55  $(document).delegate('.rating:not(.rated) a', 'click', function(){
    66
     
    2929        }else{
    3030          control.removeClass('loading').addClass('rated');
    31           $('.now', control).width(response.rating * 16).parents('ul').attr('title', response.rating + '/' + response.max_rating);
     31          $('.now', control).width(response.rating * 16).parents('ul').attr('title', response.text);
    3232          $('.meta', control).html(response.status);
     33
     34          // other plugin can hook into this event...
     35          control.trigger('rated_post', response);
    3336        }
    3437
  • post-ratings/trunk/post-ratings.php

    r483864 r486495  
    22/*
    33Plugin Name: Post Ratings
    4 Version: 1.5
     4Version: 1.6
    55Plugin URI: http://digitalnature.eu/forum/plugins/post-ratings/
    66Description: Simple, developer-friendly, straightforward post rating plugin. Relies on post meta to store avg. rating / vote count.
     
    3030
    3131
    32 /**
     32/*
    3333 * PostRatings Class
    3434 *
     
    4040
    4141  const
    42     VERSION   = '1.5',                                      // plugin version
     42    VERSION   = '1.6',                                      // plugin version
    4343    ID        = 'post_ratings',                             // internally used for text domain, theme option group name etc.
    4444    MIN_VOTES = 1,                                          // minimum vote count (MV)
    4545    BR1       = '(v / (v + MV)) * r + (MV / (v + MV)) * R', // bayesian rating formula (the IMDB version)
    46     BR2       = '((AV * R) + (v * r)) / (AV + v)';          // thebroth.com version
     46    BR2       = '((AV * R) + (v * r)) / (AV + v)';          // bayesian rating formula (thebroth.com version)
    4747
    4848
     
    5050  // this will be a singleton instance
    5151  // we can call any public methods below trough PostRatings::app(), without having to worry about instantiation, globals etc.
    52   private static $instance;
    53 
    54 
    55 
    56   /**
    57    * This will instantiate the class if needed, and return the only class instance if not...
    58    *
    59    * @since 1.0
    60    */
     52  protected static $instance;
     53
     54
     55
     56 /*
     57  * This will instantiate the class if needed, and return the only class instance if not...
     58  *
     59  * @since 1.0
     60  */
    6161  public static function app(){
    6262
     
    6767
    6868      // localize
    69       $locale = get_locale();
    70       $locale_file = dirname(plugin_basename(__FILE__))."/lang/{$locale}.php";
    71       if(is_readable($locale_file))
    72         require_once($locale_file);
    73 
    7469      load_plugin_textdomain(self::ID, false, dirname(plugin_basename(__FILE__)).'/lang');
    7570
     
    8075      }else{
    8176        add_action('wp', array(self::$instance, 'Run'));
    82 
    8377      }
    8478
     
    9387    }
    9488
    95 
    9689    return self::$instance;
    9790  }
     
    9992
    10093
    101   /**
    102    * A single instance only
    103    *
    104    * @since 1.0
    105    */
     94 /*
     95  * A single instance only
     96  *
     97  * @since 1.0
     98  */
    10699  final protected function __construct(){}
    107100
    108101
    109102
    110   /**
    111    * No cloning
    112    *
    113    * @since 1.0
    114    */
     103 /*
     104  * No cloning
     105  *
     106  * @since 1.0
     107  */
    115108  final protected function __clone(){}
    116109
    117110
    118111
    119   /**
    120    * Plugin options.
    121    * If an option doesn't exist in the db, the default value will be returned instead
    122    *
    123    * @since 1.0
    124    * @param string $single_option_req Optional, if passed the function will return the value of this option
    125    * @return array|string
    126    */
     112 /*
     113  * Plugin options.
     114  * If an option doesn't exist in the db, the default value will be returned instead
     115  *
     116  * @since    1.0
     117  * @param    string $single_option_req    Optional, if passed the function will return the value of this option
     118  * @return  array|string
     119  */
    127120  public function Options($single_option_req = ''){
    128121
     
    148141
    149142
    150   /**
    151    * Hook our plugin options menu / page
    152    *
    153    * @since 1.0
    154    */
     143 /*
     144  * Hook our plugin options menu / page
     145  *
     146  * @since 1.0
     147  */
    155148  public function CreateMenu(){
    156149    add_options_page(__('Post Ratings', self::ID), __('Post Ratings', self::ID), 'manage_options', self::ID, array(&$this, 'SettingsPage'));
     
    159152
    160153
    161   /**
    162    * Register our setting with the new useless Settings API bloat...
    163    *
    164    * @since 1.0
    165    */
     154 /*
     155  * Register our setting with the new useless Settings API bloat...
     156  *
     157  * @since 1.0
     158  */
    166159  public function RegisterSettings(){
    167160    register_setting(self::ID, self::ID, array(&$this, 'ValidateSettings'));
     
    171164
    172165
    173   /**
    174    * Settings link in the plugin list
    175    *
    176    * @since 1.0
    177    */
     166 /*
     167  * Settings link in the plugin list
     168  *
     169  * @since    1.0
     170  * @param    string $file
     171  * @param    array $links
     172  * @return   array
     173  */
    178174  public function PluginSettingsLink($links, $file){
    179175
     
    188184
    189185
    190   /**
    191    * Validate our settings
    192    *
    193    * @param array $input
    194    * @return array
    195    * @since 1.0
    196    */
     186 /*
     187  * Validate our settings
     188  *
     189  * @since    1.0
     190  * @param    array $input
     191  * @return   array
     192  */
    197193  public function ValidateSettings($input){
    198194
     
    229225
    230226
    231   /**
    232    * The options page (form)
    233    *
    234    * @since 1.0
    235    */
     227 /*
     228  * The options page (form)
     229  *
     230  * @since 1.0
     231  */
    236232  public function SettingsPage(){
    237233
     
    249245    <div class="wrap metabox-holder">
    250246      <h2><?php _e('Post Ratings', self::ID); ?></h2>
    251 
    252247
    253248      <form method="post" action="options.php" style="position:relative;">
     
    285280
    286281          <tr valign="top">
    287             <th scope="row"><?php _e('Bayesian rating (score) formula', self::ID); ?></th>
     282            <th scope="row">
     283              <?php _e('Bayesian rating (score) formula', self::ID); ?>
     284            </th>
    288285            <td>
    289286
     
    304301               </p>
    305302
    306 
    307303               <p>
    308304               <label for="user_formula">
     
    310306                 <?php _e('I have my own formula:'); ?>
    311307                 <input <?php if(!current_user_can('edit_plugins')): ?>disabled="disabled"<?php endif; ?> type=text name="<?php echo self::ID; ?>[user_formula]" size="46" class="code" value="<?php echo $user_formula; ?>" />
    312                </label>
     308               </label> <a href="#" onclick="jQuery('#legend').toggle();">(<?php _e('Legend', self::ID); ?>)</a>
    313309               </p>
    314310
    315                <p>
     311               <div id="legend" style="display:none;">
     312                <p>
    316313                 <code style="font-size: 14px;"><strong>AV</strong></code> = <?php _e('Global average number of votes per post', self::ID); ?>
    317314                 <br />
    318315                 <code style="font-size: 14px;"><strong>&nbsp;V</strong></code> = <?php _e('Global number of votes (from all posts)', self::ID); ?>
    319316                 <br />
    320                  <code style="font-size: 14px;"><em>&nbsp;v</em></code> = <?php _e("Number of votes from the current post", self::ID); ?>
     317                 <code style="font-size: 14px;"><em>&nbsp;v</em></code> = <?php _e('Number of votes from the current post', self::ID); ?>
    321318                 <br />
    322319                 <code style="font-size: 14px;"><strong>&nbsp;R</strong></code> = <?php printf(__('Global average rating per post (from 1 to %d)', self::ID), $max_rating); ?>
    323320                 <br />
    324                  <code style="font-size: 14px;"><em>&nbsp;r</em></code> = <?php printf(__("Average rating of the current post (from 1 to %d)", self::ID), $max_rating); ?>
     321                 <code style="font-size: 14px;"><em>&nbsp;r</em></code> = <?php printf(__('Average rating of the current post (from 1 to %d)', self::ID), $max_rating); ?>
    325322                 <br />
    326323                 <code style="font-size: 14px;"><strong>MV</strong></code> = <?php printf(__('Minimum vote count per post to consider (%d by default)', self::ID), self::MIN_VOTES); ?>
     
    328325                 <code style="font-size: 14px;"><strong>MR</strong></code> = <?php printf(__('Maximum rating, see option above (currently %d)', self::ID), $max_rating); ?>
    329326               </p>
     327              </div>
    330328
    331329              </fieldset>
     
    419417
    420418
    421   /**
    422    * Javascript used by the plugin
    423    *
    424    * @since 1.0
    425    */
    426   public function JS(){
    427 
     419 /*
     420  * Javascript and CSS used by the plugin
     421  *
     422  * @since 1.0
     423  */
     424  public function assets(){
     425
     426    // js
    428427    wp_enqueue_script('jquery');
    429428    wp_enqueue_script(self::ID, plugins_url('post-ratings.js', __FILE__), array('jquery'), self::VERSION, true);
     
    432431    if(!class_exists('Atom') && (!defined('Atom::VERSION')))
    433432      wp_localize_script(self::ID, 'post_ratings', array('blog_url' => home_url('/')));
    434   }
    435 
    436 
    437 
    438   /**
    439    * CSS used by the plugin
    440    *
    441    * @since 1.0
    442    */
    443   public function CSS(){
     433
     434    // css
    444435    wp_enqueue_style(self::ID, plugins_url('post-ratings.css', __FILE__));
    445436  }
     
    447438
    448439
    449   /**
    450    * Remove plugin options and rating stats on uninstall
    451    *
    452    * @since 1.0
    453    */
     440 /*
     441  * Remove plugin options and rating stats on uninstall
     442  *
     443  * @since 1.0
     444  */
    454445  public static function Uninstall(){
    455446    PostRatings::app()->DeleteRatingRecords();
     
    459450
    460451
    461   /**
    462    * Get user rating for a post
    463    *
    464    * @param int $post_id Post ID
    465    * @since 1.0
    466    * @return array Rating and vote count
    467    */
     452 /*
     453  * Get user rating for a post
     454  *
     455  * @since    1.0
     456  * @param    int $post_id     Post ID
     457  * @return   array            Rating and vote count
     458  */
    468459  public function getRating($post_id){
    469460    return array((float)get_post_meta($post_id, 'rating', true), (int)get_post_meta($post_id, 'votes', true));
     
    472463
    473464
    474   /**
    475    * Process rating, or set up plugin hooks if this is not a rate request
    476    *
    477    * @since 1.0
    478    */
     465 /*
     466  * Process rating, or set up plugin hooks if this is not a rate request
     467  *
     468  * @since 1.0
     469  */
    479470  public function Run(){
    480471
     
    495486      }
    496487
    497       add_action('wp_print_scripts', array(&$this, 'JS'));
    498       add_action('wp_print_styles', array(&$this, 'CSS'));
     488      add_action('wp_enqueue_scripts', array(&$this, 'assets'));
    499489
    500490    // this is our $.ajax request
     
    554544            array_shift($ip_cache[$post_id]);
    555545
    556           set_transient('post_ratings_ip_cache', $ip_cache, 60*60*24*14);
     546          set_transient('post_ratings_ip_cache', $ip_cache, 60 * 60 * 24 * 14);
    557547
    558548          // update user meta
     
    566556          $posts_rated = array_slice($posts_rated, -20); // keep it under 20 entries
    567557          $posts_rated[] = $post_id;
    568           setcookie('posts_rated', implode('-', $posts_rated),  time() + 60*60*24*90, '/'); // keep it for 90 days
    569 
    570 
    571 
     558          setcookie('posts_rated', implode('-', $posts_rated),  time() + 60 * 60 * 24 * 90, '/'); // keep it for 90 days
    572559
    573560          do_action('rated_post', $post_id);
     
    583570        'error'      => $error,
    584571        'rating'     => sprintf('%.2F', $rating),
     572        'text'       => esc_attr(apply_filters('post_ratings_current_rating', sprintf('%.2F / %d', $rating, $max_rating), $rating, $max_rating)),
    585573        'max_rating' => $max_rating,
    586574        'votes'      => $votes,
     
    596584
    597585
    598   /**
    599    * Delete all ratings-related meta data from the database
    600    *
    601    * @since 1.0
    602    */
     586 /*
     587  * Delete all ratings-related meta data from the database
     588  *
     589  * @since 1.0
     590  */
    603591  public function DeleteRatingRecords(){
    604592
     
    621609
    622610
    623   /**
    624    * Return a string with the rating and vote count info
    625    *
    626    * @since 1.0
    627    * @param int $rating
    628    * @param int $votes
    629    * @return string
    630    */
     611 /*
     612  * Return a string with the rating and vote count info
     613  *
     614  * @since    1.0
     615  * @param    int $rating
     616  * @param    int $votes
     617  * @return    string
     618  */
    631619  public function FormatRatingMeta($rating, $votes){
    632620
     
    662650    }
    663651
    664     return sprintf(_n('%1$s vote, %2$s avg. rating (%3$s%% score)', '%1$s votes, %2$s avg. rating (%3$s%% score)', $votes, self::ID),
     652    $text = sprintf(_n('%1$s vote, %2$s avg. rating (%3$s%% score)', '%1$s votes, %2$s avg. rating (%3$s%% score)', $votes, self::ID),
    665653              sprintf('<strong>%d</strong>', $votes), sprintf('<strong>%.2F</strong>', $rating), sprintf('<strong>%d</strong>', $bayesian_rating));
    666   }
    667 
    668 
    669 
    670   /**
    671    * The rate links
    672    *
    673    * @param string $content
    674    * @param int $post_id
    675    * @param bool $ignore_visibility_setting
    676    * @return string
    677    * @since 1.0
    678    */
     654
     655    return apply_filters('post_ratings_meta_text', $text, $votes, $rating, $bayesian_rating);
     656  }
     657
     658
     659
     660 /*
     661  * The rate links
     662  *
     663  * @since     1.0
     664  * @param     string $content
     665  * @param     int $post_id
     666  * @param     bool $ignore_visibility_setting
     667  * @return    string
     668  */
    679669  public function Control($content = '', $post_id = '', $ignore_visibility_setting = false){
    680670    global $post, $wp_current_filter;
     
    715705      $can_rate = $this->CurrentUserCanRate($post_id);
    716706
     707      $current_rating = apply_filters('post_ratings_current_rating', sprintf('%.2F / %d', $rating, $max_rating), $rating, $max_rating);
     708
    717709      $control[] = '<div class="rating">';
    718       $control[] = '<ul '.(!$can_rate ? 'class="rated"' : '').' data-post="'.$post_id.'" style="width:'.($max_rating * 16).'px" title="'.sprintf('%.2F / %d', $rating, $max_rating).'">';
     710      $control[] = '<ul '.(!$can_rate ? 'class="rated"' : '').' data-post="'.$post_id.'" style="width:'.($max_rating * 16).'px" title="'.esc_attr($current_rating).'">';
    719711      $control[] = '<li class="now" style="width:'.($rating * 16).'px"></li>';
    720712
    721713      if($can_rate)
    722         for($i = 1; $i <= $max_rating; $i++)
    723           $control[] = '<li class="s'.$i.'"><a title="'.sprintf(__('Give %1$d out of %2$d stars', self::ID), $i, $max_rating).'">'.sprintf('%d / %d', $i, $max_rating).'</a></li>';
     714        for($i = 1; $i <= $max_rating; $i++){
     715          $title = apply_filters('post_ratings_control_title', sprintf(__('Give %1$d out of %2$d stars', self::ID), $i, $max_rating), $i, $max_rating);
     716          $text = apply_filters('post_ratings_control_text', sprintf('%d / %d', $i, $max_rating), $i, $max_rating);
     717          $control[] = '<li class="s'.$i.'"><a title="'.esc_attr($title).'">'.$text.'</a></li>';
     718        }
    724719
    725720      $control[] = '</ul>';
     
    728723
    729724      $control = implode("\n", $control);
    730 
    731725
    732726      // this is the user's custom action, so directly output the HTML
     
    759753
    760754
    761   /**
    762    * Checks if the current user can rate a post.
    763    *
    764    * @since 1.0
    765    * @param int $post_id Post ID to check
    766    * @return bool
    767    */
     755 /*
     756  * Checks if the current user can rate a post.
     757  *
     758  * @since    1.0
     759  * @param    int $post_id    Post ID to check
     760  * @return  bool
     761  */
    768762  public function CurrentUserCanRate($post_id){
    769763
     
    775769        $ip_cache = get_transient('post_ratings_ip_cache');
    776770        $posts_rated = isset($_COOKIE['posts_rated']) ? explode('-', $_COOKIE['posts_rated']) : array();
    777         $user_ip  = $_SERVER['REMOTE_ADDR'];
     771        $user_ip = $_SERVER['REMOTE_ADDR'];
    778772
    779773        if(is_user_logged_in()){
     
    791785
    792786
    793   /**
    794    * Get a list of most rated posts.
    795    * The results are returned as an array of objects
    796    *
    797    * @since 1.0
    798    * @param array $args Arguments
    799    * @return array
    800    */
     787 /*
     788  * Get a list of most rated posts.
     789  * The results are returned as an array of objects
     790  *
     791  * @since    1.0
     792  * @param     array $args    Arguments, see below
     793  * @return    array
     794  */
    801795  public function getTopRated($args){
    802796    global $wpdb;
     
    874868
    875869
    876   /**
    877    * The [rate] shortcode
    878    *
    879    * @since 1.0
    880    * @params string $atts Can accept the post ID as argument; if not given, control() will use the $post global
    881    * @return string
     870 /*
     871  * The [rate] shortcode
     872  *
     873  * @since    1.0
     874  * @params    array $atts    Can accept the post ID as argument; if not given, control() will use the $post global
     875  * @return    string
    882876   */
    883877  public function Shortcode($atts){
    884 
    885     $post_id = (isset($atts[0])) ? (int)$atts[0] : '';
    886 
    887     return $this->Control('', $post_id);
    888   }
    889 
    890 
    891 
    892   /**
    893    * Register the "Top Rated" widget -- @todo
    894    *
    895    * @since 1.0
    896    */
     878    return $this->Control('', (isset($atts[0])) ? (int)$atts[0] : '');
     879  }
     880
     881
     882
     883 /*
     884  * Register the "Top Rated" widget
     885  *
     886  * @since 1.0
     887  */
    897888  public function Widget(){
    898889    require dirname(__FILE__).'/widget.php';
     
    902893
    903894}
    904 
  • post-ratings/trunk/readme.txt

    r483864 r486495  
    7373== Changelog ==
    7474
     75= 1.6 =
     76* Added a few filter tags (and a javascript event on succesful rate), so the output can be easily changed
     77
    7578= 1.5 =
    7679* Fixed a js issue with voting introduced by mistake in 1.4
  • post-ratings/trunk/widget.php

    r483864 r486495  
    33
    44// if this an Atom theme make a special widget for it ;)
    5 if(class_exists('Atom') && (defined('Atom::VERSION'))){
    6 
    7 
    8   /**
    9    * Atom Top Rated Widget
    10    *
    11    * @since 1.0
    12    */
     5if(class_exists('AtomWidget') && (defined('Atom::VERSION'))){
     6
     7
     8 /*
     9  * Atom Top Rated Widget
     10  *
     11  * @since 1.0
     12  */
    1313  class PostRatingsWidget extends AtomWidget{
    1414
    1515
    1616
    17     /**
    18      * Initialization
    19      *
    20      * @see AtomWidget::set and WP_Widget::__construct
    21      */
     17   /*
     18    * Initialization
     19    *
     20    * @see AtomWidget::set and WP_Widget::__construct
     21    */
    2222    public function __construct(){
    2323
     
    9292
    9393      extract($args);
    94       $app = &Atom::app();
    9594
    9695      $posts = PostRatings::app()->getTopRated(array(
     
    108107      foreach($posts as $index => $post){
    109108
    110         $app->post = $post;
     109        atom()->post = $post;
    111110        $output[] = '<li>';
    112111
    113         $avg_rating = $app->post->get('rating');
    114         $bayesian_rating = $app->post->get('bayesian_rating');
     112        $avg_rating = atom()->post->get('rating');
     113        $bayesian_rating = atom()->post->get('bayesian_rating');
    115114
    116115
     
    122121
    123122        $fields = array(
    124           'TITLE'               => $app->post->getTitle(),
    125           'COMMENT_COUNT'       => $app->post->getCommentCount(),
    126           'THUMBNAIL'           => $app->post->getThumbnail(str_replace('instance-', '', $id)),
    127           'URL'                 => $app->post->getURL(),
    128           'CONTENT'             => convert_smilies($app->post->getContent(150, array(
     123          'TITLE'               => atom()->post->getTitle(),
     124          'COMMENT_COUNT'       => atom()->post->getCommentCount(),
     125          'THUMBNAIL'           => atom()->post->getThumbnail(str_replace('instance-', '', $id)),
     126          'URL'                 => atom()->post->getURL(),
     127          'CONTENT'             => convert_smilies(atom()->post->getContent(150, array(
    129128                                     'allowed_tags' => Atom::SAFE_INLINE_TAGS,
    130129                                     'more'         => '[&hellip;]',
     
    134133          'BAYESIAN_RATING_BAR' => $bayesian_rating_bar,
    135134          'AVG_RATING_BAR'      => $avg_rating_bar,
    136           'VOTES'               => (int)$app->post->get('votes'),
     135          'VOTES'               => (int)atom()->post->get('votes'),
    137136          'MAX_RATING'          => $max_rating,
    138           'EXCERPT'             => $app->post->getContent('e'),
    139           'DATE'                => $app->post->getDate('relative'),
    140           'AUTHOR'              => $app->post->author->getName(),
    141           'CATEGORIES'          => strip_tags($app->post->getTerms('category')),
    142           'TAGS'                => strip_tags($app->post->getTerms()),
    143           'VIEWS'               => number_format_i18n($app->post->getViews()),
     137          'EXCERPT'             => atom()->post->getContent('e'),
     138          'DATE'                => atom()->post->getDate('relative'),
     139          'AUTHOR'              => atom()->post->author->getName(),
     140          'CATEGORIES'          => strip_tags(atom()->post->getTerms('category')),
     141          'TAGS'                => strip_tags(atom()->post->getTerms()),
     142          'VIEWS'               => number_format_i18n(atom()->post->getViews()),
    144143          'INDEX'               => isset($posts->current_post) ? ($posts->current_post + 1) : $index,
    145           'ID'                  => $app->post->getID(),
     144          'ID'                  => atom()->post->getID(),
    146145        );
    147146
    148147
    149         $fields = apply_filters('atom_widget_top_rated_keywords', $fields, $app->post, $args);
     148        $fields = apply_filters('atom_widget_top_rated_keywords', $fields, atom()->post, $args);
    150149
    151150        // output template
    152         $output[] = $app->getBlockTemplate($template, $fields);
     151        $output[] = atom()->getBlockTemplate($template, $fields);
    153152
    154153        $output[] = '</li>';
    155154      }
    156155
    157       $app->resetCurrentPost();
     156      atom()->resetCurrentPost();
    158157
    159158      return implode("\n", $output);
     
    176175
    177176      if(empty($posts))
    178         return Atom::app()->log("No rated posts found in {$args['widget_id']} ({$args['widget_name']}). Widget marked as inactive");
     177        return atom()->log("No rated posts found in {$args['widget_id']} ({$args['widget_name']}). Widget marked as inactive");
    179178
    180179      $output = $before_widget;
     
    185184      $output .= "<ul class=\"menu fadeThis ratings clear-block\">\n{$posts}\n</ul>\n";
    186185
    187       if($instance['more'] && $next && Atom::app()->options('jquery')){
     186      if($instance['more'] && $next && atom()->options('jquery')){
    188187        $output .= '<div class="fadeThis clear-block"><a href="#" class="more" data-count="'.$instance['number'].'">'.__('Show More', PostRatings::ID).'</a></div>';
    189188        $output .= $this->getShowMoreCtrl('get_top_rated');
     
    199198
    200199
    201     /**
    202      * Saves the widget options
    203      *
    204      * @see WP_Widget::update
    205      */
     200   /*
     201    * Saves the widget options
     202    *
     203    * @see WP_Widget::update
     204    */
    206205    public function update($new_instance, $old_instance){
    207206
     
    280279        </p>
    281280
    282 
    283281        <p>
    284282          <label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Limit:', PostRatings::ID); ?></label>
     
    287285
    288286        <p>
    289          <input <?php if(!Atom::app()->options('jquery')) echo "disabled=\"disabled\""; ?> type="checkbox" id="<?php echo $this->get_field_id('more'); ?>" name="<?php echo $this->get_field_name('more'); ?>"<?php checked($instance['more']); ?> />
    290          <label for="<?php echo $this->get_field_id('more'); ?>" <?php if(!Atom::app()->options('jquery')) echo "class=\"disabled\""; ?>><?php printf(__('Display %s Link', PostRatings::ID), '<code>'.__('Show More', PostRatings::ID).'</code>'); ?></label>
     287         <input <?php if(!atom()->options('jquery')) echo "disabled=\"disabled\""; ?> type="checkbox" id="<?php echo $this->get_field_id('more'); ?>" name="<?php echo $this->get_field_name('more'); ?>"<?php checked($instance['more']); ?> />
     288         <label for="<?php echo $this->get_field_id('more'); ?>" <?php if(!atom()->options('jquery')) echo "class=\"disabled\""; ?>><?php printf(__('Display %s Link', PostRatings::ID), '<code>'.__('Show More', PostRatings::ID).'</code>'); ?></label>
    291289        </p>
    292290
     
    325323
    326324
    327   /**
    328    * Top Rated posts widget
    329    *
    330    * @since 1.0
    331    */
     325 /*
     326  * Top Rated posts widget
     327  *
     328  * @since 1.0
     329  */
    332330  class PostRatingsWidget extends WP_Widget{
    333331
    334332
    335333
    336     /**
    337      * @see WP_Widget::__construct
    338      * @since 1.0
    339      */
     334   /*
     335    * @since   1.0
     336    * @see     WP_Widget::__construct
     337    */
    340338    function __construct(){
    341339
     
    352350
    353351
    354     /**
    355      * @see WP_Widget::widget
    356      * @since 1.0
    357      */
     352   /*
     353    * @since   1.0
     354    * @see     WP_Widget::widget
     355    */
    358356    public function widget($args, $instance){
    359357      global $post;
    360358
     359      extract($args);
     360
    361361      $cache = wp_cache_get('widget_top_rated', 'widget');
    362       $options = PostRatings::app()->options();
    363       $output = array();
    364362
    365363      if(!is_array($cache))
    366364        $cache = array();
    367365
    368       if(isset($cache[$args['widget_id']])){
    369         echo $cache[$args['widget_id']];
     366      if(isset($cache[$widget_id])){
     367        echo $cache[$widget_id];
    370368        return;
    371369      }
    372370
    373       extract($args);
     371      $output = array();
     372      $options = PostRatings::app()->options();
    374373      extract($options);
    375374
    376       $title = apply_filters('widget_title', empty($instance['title']) ? __('Top Rated', PostRatings::ID) : $instance['title'], $instance, $this->id_base);
    377       $number = min(max((int)$instance['number'], 1), 20);
     375      $title      = apply_filters('widget_title', empty($instance['title']) ? __('Top Rated', PostRatings::ID) : $instance['title'], $instance, $this->id_base);
     376      $number     = min(max((int)$instance['number'], 1), 20);
    378377      $date_limit = min(max((int)$instance['date_limit'], 0), 999);
    379       $post_type = post_type_exists($instance['post_type']) ? $instance['post_type'] : 'post';
    380 
    381       // order by / where clauses
    382       $sort = isset($instance['sort']) ? esc_attr($instance['sort']) : 'bayesian_rating';
     378      $post_type  = post_type_exists($instance['post_type']) ? $instance['post_type'] : 'post';
     379      $sort       = isset($instance['sort']) ? esc_attr($instance['sort']) : 'bayesian_rating';
    383380
    384381      $output[] = $before_widget;
     
    426423      echo $output;
    427424
    428       $cache[$args['widget_id']] = $output;
     425      $cache[$widget_id] = $output;
    429426      wp_cache_set('widget_top_rated', $cache, 'widget');
    430427    }
     
    432429
    433430
    434     /**
    435      * @see WP_Widget::update
    436      * @since 1.0
    437      */
     431   /*
     432    * @since   1.0
     433    * @see     WP_Widget::update
     434    */
    438435    public function update($new_instance, $old_instance){
    439436
     
    456453
    457454
    458     /**
    459      * Clears widget cache.
    460      * Should run after a post has been rated, deleted, edited etc...
    461      *
    462      * @since 1.0
    463      */
     455   /*
     456    * Clears widget cache.
     457    * Should run after a post has been rated, deleted, edited etc...
     458    *
     459    * @since 1.0
     460    */
    464461    public function flush_widget_cache(){
    465462      wp_cache_delete('widget_top_rated', 'widget');
     
    468465
    469466
    470     /**
    471      * @see WP_Widget::form
    472      * @since 1.0
    473      */
     467   /*
     468    * @since   1.0
     469    * @see     WP_Widget::form
     470    */
    474471    public function form($instance){
    475472
     
    534531      <?php
    535532    }
    536    }
     533
     534  }
    537535
    538536
Note: See TracChangeset for help on using the changeset viewer.