Plugin Directory

Changeset 751697


Ignore:
Timestamp:
08/05/2013 03:02:53 PM (13 years ago)
Author:
cptup
Message:

version 1.4.0

Location:
captain-up/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • captain-up/trunk/README.md

    r725144 r751697  
    8383You can add the Captain Up leaderboard widget or activity widget inside your posts using a shortcode:
    8484
    85 * `[captain-leaderboard width="250px" height="400px" title="Leaderboard"]` - adds the leaderboard widget. All attributes are optional. By default the width of the widget will be 300 pixels, the height 400 pixels and the title will be "Leaderboard".
     85* `[captain-leaderboard width="250px" height="400px" title="Leaderboard" leaderboard="all-time-ranking"]` - adds the leaderboard widget. All attributes are optional. By default the width of the widget will be 300 pixels, the height 400 pixels and the title will be "Leaderboard". The leaderboard option selects the default leaderboard to show, can be either one of `"all-time-ranking"`, `"monthly-ranking"`, `"weekly-ranking"` or `"daily-ranking"`.
    8686
    8787* `[captain-activity width="250px" height="400px" title="Activity Feed"]` - adds the activity widget. All attributes are optional. By default the width of the widget will be 300 pixels, the height 400 pixels and the title will be "Activity".
     
    9494
    9595## Changelog
     96
     97###### 1.4.0
     98
     99* Support for WordPress 3.5.2 and 3.6.0
     100
     101* You can now select the default leaderboard for the Leaderboard widget. There are four options: All Time, Monthly, Weekly and Daily. This can be set in the Widgets tab or inside the Shortcodes.
     102
     103* Fixed an issue with Cloudflare's Rocket Loader.
    96104
    97105###### 1.3.1
  • captain-up/trunk/captainup.js

    r673835 r751697  
    11(function($, win) {
    2 
    32})(jQuery, window);
  • captain-up/trunk/captainup.php

    r725144 r751697  
    44Plugin URI: http://www.captainup.com
    55Description: Add Game Mechanics to your site and increase your engagement and retention. 2 minutes install: Simply add your free Captain Up API Key and you are good to go. The plugin also adds widgets you can use to show leaderboards and activities within your site.
    6 Version: 1.3.1
     6Version: 1.4.0
    77Author: Captain Up Team
    88License: GPL2
     
    240240
    241241    <div id='cptup-ready'></div>
    242     <script type='text/javascript'>
     242    <script data-cfasync='false' type='text/javascript'>
    243243      window.captain = {up: function(fn) { captain.topics.push(fn) }, topics: []};
    244244      captain.up({
     
    253253      });
    254254    </script>
    255     <script type='text/javascript'>
     255    <script data-cfasync='false' type='text/javascript'>
    256256      (function() {
    257257          var cpt = document.createElement('script'); cpt.type = 'text/javascript'; cpt.async = true;
     
    274274 * ---------------------------------------*/
    275275
    276 /*
    277 Plugin Name: Captain Up Widget
    278 Plugin URI: http://captainup.com/
    279 Description: Captain Up Widget - Leaderboards and Activity Feed
    280 Version: 1.0
    281 */
     276// Enqueue scripts to handle editing the Widgets options in
     277# the widgets admin panel tab.
     278function widgets_edit_script() {
     279        wp_enqueue_script(
     280            'cptup_widgets_edit',
     281            plugins_url('/js/cptup_widgets_edit.js', __FILE__),
     282            array('jquery')
     283        );
     284}
     285add_action('widgets_init', 'widgets_edit_script');
     286
     287
    282288class Captainup_Widget extends WP_Widget {
    283289
    284290    /** constructor */
    285291    function __construct() {
    286         parent::WP_Widget('cptup_widget', 'Captainup Widget', array(
     292        parent::WP_Widget('cptup_widget', 'Captain Up Widget', array(
    287293            'description' => 'Captain Up Leaderboards and Recent Activity'
    288294        ));
     
    294300        $type = $instance['type'];
    295301        $height = $instance['height'];
     302        $default_leaderboard = $instance['default_leaderboard'];
    296303       
    297304        echo $before_widget;
    298305        ?>
    299306
    300         <div class='captain-<?php echo $type; ?>-widget' style='width: auto; height: <?php echo $height; ?>px; display: none;'>
     307        <div class='captain-<?php echo $type; ?>-widget' <?php if($type=='leaderboard') echo 'data-cpt-leaderboard='.$default_leaderboard ?> style='width: auto; height: <?php echo $height; ?>px; display: none;'>
    301308        </div>
    302309       
     
    311318        $instance['css']    = strip_tags($new_instance['css']);
    312319        $instance['height'] = strip_tags($new_instance['height']);
     320        $instance['default_leaderboard'] = strip_tags($new_instance['default_leaderboard']);
    313321        return $instance;
    314322    }
     
    323331        if (!$css) $css = 'height: 300px; margin-top: 20px;';
    324332        if (!$height) $height = '350';
     333        if (!$default_leaderboard) $default_leaderboard = 'monthly_ranking';
    325334       
    326335        ?>
     
    330339                <?php _e('Widget type'); ?>
    331340            </label>
    332             <select id="<?php echo $this->get_field_id('type'); ?>" name="<?php echo $this->get_field_name('type'); ?>">
     341            <select id="<?php echo $this->get_field_id('type'); ?>" class="cpt-widget-type-select" name="<?php echo $this->get_field_name('type'); ?>">
    333342                <option <?php if($type == "activity") { echo "selected"; }; ?> value="activity">
    334343                    Activity Widget
     
    346355            <input size="4" id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo $height; ?>" />px
    347356        </p>
     357
     358        <p class='cpt-select-leaderboard-type'>
     359            <label for="<?php echo $this->get_field_id('default_leaderboard'); ?>">
     360                <?php _e('Default view:') ?>
     361            </label>
     362
     363            <select id="<?php echo $this->get_field_id('default_leaderboard'); ?>" name="<?php echo $this->get_field_name('default_leaderboard'); ?>">
     364               
     365                <option value="all-time-ranking" <?php if($default_leaderboard == 'all-time-ranking') echo 'selected'?>>
     366                    All Time
     367                </option>
     368
     369                <option value="monthly-ranking" <?php if($default_leaderboard == 'monthly-ranking') echo 'selected'?>>
     370                    Monthly
     371                </option>
     372
     373                <option value="weekly-ranking" <?php if($default_leaderboard == 'weekly-ranking') echo 'selected'?>>
     374                    Weekly
     375                </option>
     376
     377                <option value="daily-ranking" <?php if($default_leaderboard == 'daily-ranking') echo 'selected'?>>
     378                    Daily
     379                </option>
     380
     381            </select>
     382        </p>
     383
     384        <script>
     385            jQuery(function() {
     386                // Run over all the Captain Up widgets and call the
     387                // `toggle_leaderboard_option` on them. The function is
     388                // defined under `cptup_widgets_edit.js`. We call it here as
     389                // well as the widget form gets re-rendered every time it is
     390                // saved.
     391                jQuery('.cpt-widget-type-select').each(function(index, element) {
     392                    toggle_leaderboard_option(element);
     393                });
     394            });
     395        </script>
    348396       
    349397        <?php
     
    359407
    360408// Leaderboard Widget Shortcode
    361 // [captain-leaderboard width="300" height="400" title="Hello"]
     409// [captain-leaderboard width="300" height="400" title="Hello" leaderboard="all-time-ranking"]
    362410// Options:
    363411// - width - css attribute. by default 300px
    364412// - height - css attribute. by default 500px
     413// - leaderboard - the default ranking view (all time, monthly, weekly, daily),
     414//                 by default set to the monthly leaderboard.
    365415// - title - the title of the widget, by default 'Leaderboard'
    366 //           in the current locale language
     416//           in the current locale language.
    367417function captain_leaderboard_shortcode($atts) {
    368418    extract(shortcode_atts(
    369419        array(
    370             'width' => '300px',
    371             'height' => '500px',
    372             'title' => false
     420            'width' => '300',
     421            'height' => '500',
     422            'title' => false,
     423            'leaderboard' => 'monthly-ranking'
    373424        ), $atts
    374425    ));
    375     return "<div style='margin: 20px auto; width: $width; height: $height;' class='captain-leaderboard-widget' data-cpt-title='$title'></div>";
     426    return "<div style='margin: 20px auto; width: $width"."px; height: $height"."px;' class='captain-leaderboard-widget' data-cpt-leaderboard='" . str_replace("-", "_", $leaderboard) . "' data-cpt-title='$title'></div>";
    376427}
    377428add_shortcode('captain-leaderboard', 'captain_leaderboard_shortcode' );
     
    387438    extract(shortcode_atts(
    388439        array(
    389             'width' => '300px',
    390             'height' => '500px',
     440            'width' => '300',
     441            'height' => '500',
    391442            'title' => false
    392443        ), $atts
    393444    ));
    394     return "<div style='margin: 20px auto; width: $width; height: $height;' class='captain-activity-widget' data-cpt-title='$title'></div>";
     445    return "<div style='margin: 20px auto; width: $width"."px; height: $height"."px;' class='captain-activity-widget' data-cpt-title='$title'></div>";
    395446}
    396447add_shortcode('captain-activity', 'captain_activity_shortcode' );
     
    452503function captain_add_new_comment() {
    453504    ?>
    454     <script type='text/javascript'>
     505    <script data-cfasync='false' type='text/javascript'>
    455506        window._cpt_wordpress_events = {
    456507            new_comment: true
  • captain-up/trunk/readme.txt

    r725144 r751697  
    33Tags: game-mechanics,captainup,gamification,engagement,comments,widget,plugin,twitter,facebook,google
    44Requires at least: 3.0.1
    5 Tested up to: 3.5.1
     5Tested up to: 3.6.0
    66Stable tag: trunk
    77License: GPLv2 or later
     
    1818You will need to associate your WordPress site with a free Captain Up account. If you don't have one yet - [sign up now](http://captainup.com/).
    1919
    20 **NEW**: Localization support for French, German, Portuguese and Thai. Awesome shortcodes for adding the activity widget, the leaderboard widget and a sign up link inside your posts. Support for native WordPress comments.
     20**NEW**: Localization support for over 10 languages. Awesome shortcodes for adding the activity widget, the leaderboard widget and a sign up link inside your posts. Support for native WordPress comments. Support for differnet default leaderboards. CloudFlare issue resolved.
    2121
    2222**Features**:
     
    3838You can add the Captain Up leaderboard widget or activity widget inside your posts using a shortcode:
    3939
    40 * `[captain-leaderboard width="250px" height="400px" title="Leaderboard"]` - adds the leaderboard widget. All attributes are optional. By default the width of the widget will be 300 pixels, the height 400 pixels and the title will be "Leaderboard".
     40* `[captain-leaderboard width="250px" height="400px" title="Leaderboard" leaderboard="all-time-ranking"]` - adds the leaderboard widget. All attributes are optional. By default the width of the widget will be 300 pixels, the height 400 pixels and the title will be "Leaderboard". The leaderboard option selects the default leaderboard to show, can be either one of `"all-time-ranking"`, `"monthly-ranking"`, `"weekly-ranking"` or `"daily-ranking"`.
    4141
    4242* `[captain-activity width="250px" height="400px" title="Activity Feed"]` - adds the activity widget. All attributes are optional. By default the width of the widget will be 300 pixels, the height 400 pixels and the title will be "Activity".
     
    116116== Changelog ==
    117117
     118= 1.4.0 =
     119
     120* Support for WordPress 3.5.2 and 3.6.0
     121
     122* You can now select the default leaderboard for the Leaderboard widget. There are four options: All Time, Monthly, Weekly and Daily. This can be set in the Widgets tab or inside the Shortcodes.
     123
     124* Fixed an issue with Cloudflare's Rocket Loader.
     125
    118126= 1.3.1 =
    119127
Note: See TracChangeset for help on using the changeset viewer.