Plugin Directory

Changeset 692934


Ignore:
Timestamp:
04/06/2013 11:54:44 PM (13 years ago)
Author:
cptup
Message:

version 1.1

Location:
captain-up/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • captain-up/trunk/captainup.php

    r673835 r692934  
    1313
    1414function cptup_settings() {
     15
     16    if ( isset($_POST['submit']) ) {
     17        update_option('captain-up-enabled', $_POST['captain-up-enabled']);
     18        update_option('captain-api-key', $_POST['captain-api-key']);
     19        update_option('captain-locale', $_POST['captain-locale']);
     20
     21        echo "<div id='update' class='updated'><p>Settings updated.</p></div>\n";
     22    }
     23
    1524    // See if Captain Up is Enabled
    1625    $captain_up  = get_option('captain-up-enabled');
     
    1827    // Get the Captain Up API Key
    1928    $captain_api = get_option('captain-api-key');
     29
     30    // Get the Captain Up Locale
     31    $captain_locale = get_option('captain-locale');
    2032
    2133    $pwd = dirname(__FILE__) . '/'; # Plugin Directory
     
    4254                                    <label for="captain-api-key">Your API Key:</label>
    4355                                    <input id="captain-api-key" name="captain-api-key" type="text" size="50" value="<?php echo $captain_api; ?>"/>
     56                                </div>
     57
     58                                <div id="cpt-language">
     59                                    <label for="captain-language">Language:</label>
     60                                    <select id='captain-locale' name='captain-locale'>
     61                                        <option value='en'>English</option>
     62                                        <option value='he' <?php if ($captain_locale == 'he') echo 'selected';?>>Hebrew</option>
     63                                        <option value='it' <?php if ($captain_locale == 'it') echo 'selected';?>>Italian</option>
     64                                        <option value='ru' <?php if ($captain_locale == 'ru') echo 'selected';?>>Russian</option>
     65                                    </select>
     66                                </div>
     67
     68                                <div id='cpt-submit'>
    4469                                    <input type="submit" class="cpt-x-btn cpt-btn-success padded" name="submit" value="Save" />
    4570                                </div>
     
    79104
    80105    <?php
    81     if ( isset($_POST['submit']) ) {
    82         update_option('captain-up-enabled', $_POST['captain-up-enabled']);
    83         update_option('captain-api-key', $_POST['captain-api-key']);
    84 
    85         echo "<div id='update' class='updated'><p>Settings updated.</p></div>\n";
    86     }
    87106}
    88107
     
    129148
    130149// cptup_start() adds the Captain Up script
    131 // asynchronously to the footer.
     150// asynchronously to the footer. It's only
     151// called from cptup_print if the API Key was
     152// set.
    132153function cptup_start() {
     154    // Grab a reference to the API Key
    133155    $captain_api = get_option('captain-api-key');
     156
     157    // Add a language suffix to the Embed Script, if the
     158    // captain-locale was not set it will return 'en'.
     159    $lang = "." . get_option('captain-locale', 'en');
     160
    134161    ?>
    135162
     
    138165      (function() {
    139166          var cpt = document.createElement('script'); cpt.type = 'text/javascript'; cpt.async = true;
    140           cpt.src = 'http' + (location.protocol == 'https:' ? 's' : '') + '://captainup.com/assets/embed.js';
     167          cpt.src = 'http' + (location.protocol == 'https:' ? 's' : '') + '://captainup.com/assets/embed<?php echo $lang; ?>.js';
    141168          (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(cpt);
    142169       })();
     
    144171
    145172    <script type='text/javascript'>
    146       window.captain = {up: function(fn) { captain.topics.push(fn) }, topics: []}
     173      window.captain = {up: function(fn) { captain.topics.push(fn) }, topics: []};
    147174      captain.up({
    148175          api_key: '<?php echo $captain_api; ?>'
     
    182209        extract($args);
    183210        $type = $instance['type'];
    184         $width = $instance['width'];
    185211        $height = $instance['height'];
    186212       
     
    188214        ?>
    189215
    190         <div class='captain-<?php echo $type; ?>-widget' style='width:<?php echo $width; ?>px;height:<?php echo $height; ?>px; display:none;'>
     216        <div class='captain-<?php echo $type; ?>-widget' style='width: auto; height: <?php echo $height; ?>px; display: none;'>
    191217        </div>
    192218       
     
    200226        $instance['type']   = strip_tags($new_instance['type']);
    201227        $instance['css']    = strip_tags($new_instance['css']);
    202         $instance['width']  = strip_tags($new_instance['width']);
    203228        $instance['height'] = strip_tags($new_instance['height']);
    204229        return $instance;
     
    209234        $type   = esc_attr($instance['type']);
    210235        $css    = esc_attr($instance['css']);
    211         $width  = esc_attr($instance['width']);
    212236        $height = esc_attr($instance['height']);
    213237
    214238        if (!$type) $type = 'leaderboard';
    215239        if (!$css) $css = 'height: 300px; margin-top: 20px;';
    216         if (!$width) $width = '250';
    217240        if (!$height) $height = '350';
    218241       
     
    232255            </select>
    233256        </p>
    234        
    235         <p>
    236             <label for="<?php echo $this->get_field_id('width'); ?>">
    237                 <?php _e('Width:'); ?>
    238             </label>
    239             <input size="4" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo $width; ?>" />px
    240         </p>
    241257
    242258        <p>
     
    255271
    256272
     273/* Shortcodes
     274 * -----------------------------------*/
     275
     276// Leaderboard Widget Shortcode
     277// [captain-leaderboard width="300" height="400" title="Hello"]
     278// Options:
     279// - width - css attribute. by default 300px
     280// - height - css attribute. by default 500px
     281// - title - the title of the widget, by default 'Leaderboard'
     282//           in the current locale language
     283function captain_leaderboard_shortcode($atts) {
     284    extract(shortcode_atts(
     285        array(
     286            'width' => '300px',
     287            'height' => '500px',
     288            'title' => false
     289        ), $atts
     290    ));
     291    return "<div style='margin: 20px auto; width: $width; height: $height;' class='captain-leaderboard-widget' data-cpt-title='$title'></div>";
     292}
     293add_shortcode('captain-leaderboard', 'captain_leaderboard_shortcode' );
     294
     295// Activity Widget Shortcode
     296// [captain-activitiy width="500" height="400" title="Hello"]
     297// Options:
     298// - width - css attribute. by default 300px
     299// - height - css attribute. by default 500px
     300// - title - the title of the widget, by default 'Activities'
     301//           in the current locale language
     302function captain_activity_shortcode($atts) {
     303    extract(shortcode_atts(
     304        array(
     305            'width' => '300px',
     306            'height' => '500px',
     307            'title' => false
     308        ), $atts
     309    ));
     310    return "<div style='margin: 20px auto; width: $width; height: $height;' class='captain-activity-widget' data-cpt-title='$title'></div>";
     311}
     312add_shortcode('captain-activity', 'captain_activity_shortcode' );
     313
     314// Sign Up Link Shortcode
     315// [captain-sign-up text="Hello"]
     316// Options:
     317// - text - the text of the link, by default "Sign Up Now"
     318function captain_sign_up_link_shortcode($atts) {
     319    extract(shortcode_atts(
     320        array(
     321            'text' => 'Sign Up Now',
     322        ), $atts
     323    ));
     324    return "<a style='cursor: pointer' class='captain-sign-up-link'>$text</a>";
     325}
     326add_shortcode('captain-sign-up', 'captain_sign_up_link_shortcode' );
     327
     328
    257329?>
  • captain-up/trunk/readme.txt

    r673845 r692934  
    33Tags: game-mechanics,captainup,gamification,engagement,comments,widget,plugin,twitter,facebook,google
    44Requires at least: 3.0.1
    5 Tested up to: 3.4
     5Tested up to: 3.5.1
    66Stable tag: trunk
    77License: GPLv2 or later
     
    1212== Description ==
    1313
    14 Captain Up is a Game Mechanics and User Engagement platform for your WordPress site. After a quick install your users will be able to connect with Facebook or Twitter, earn points, progress through the levels, achieve badges and compete in leaderboards.
     14[Captain Up](http://captainup.com/) is a Game Mechanics and User Engagement platform for your WordPress site. After a quick install your users will be able to connect with Facebook or Twitter, earn points, progress through the levels, achieve badges and compete in leaderboards.
    1515
    1616Captain Up helps you engage with your users. You will see more likes, more tweets, more comments and more repeated visits to your site. You can learn more about your users and see who is passionate about your blog and who has the most influence in social networks.
    1717
    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/).
     19
     20**NEW**: Localization support for English, Hebrew, Italian and Russian. Awesome shortcodes for adding the activity widget, the leaderboard widget and a sign up link inside your posts.
    1921
    2022**Features**:
     
    3133
    3234- **Tons of Actions** - Players can earn points for visiting your site consistently, for visiting specific pages on your site, for commenting or liking on Facebook or Tweeting about you or even watching videos on your site.
     35
     36**Shortcodes**
     37
     38You can add the Captain Up leaderboard widget or activity widget inside your posts using a shortcode:
     39
     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".
     41
     42* `[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".
     43
     44* `[captain-sign-up text="Join the Game"]` - adds a link to join the Captain Up game. It will open the sign up modal, incentivizing your users to start playing. By default the text of the link will be "Sign Up Now".
    3345
    3446**Contributing Code**
     
    104116== Changelog ==
    105117
     118= 1.1 =
     119
     120* Removed the width option from the widgets
     121
     122* Added Shortcodes for adding the Leaderboard Widget, the Activity Widget and a sign up link.
     123
     124* Added Localization Options (Hebrew, English, Italian, Russian)
     125
     126* Added missing semicolon in the embed script;
     127
    106128= 1.0 =
     129
    107130* First Release.
Note: See TracChangeset for help on using the changeset viewer.