Changeset 692934
- Timestamp:
- 04/06/2013 11:54:44 PM (13 years ago)
- Location:
- captain-up/trunk
- Files:
-
- 1 added
- 2 edited
-
README.md (added)
-
captainup.php (modified) (13 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
captain-up/trunk/captainup.php
r673835 r692934 13 13 14 14 function 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 15 24 // See if Captain Up is Enabled 16 25 $captain_up = get_option('captain-up-enabled'); … … 18 27 // Get the Captain Up API Key 19 28 $captain_api = get_option('captain-api-key'); 29 30 // Get the Captain Up Locale 31 $captain_locale = get_option('captain-locale'); 20 32 21 33 $pwd = dirname(__FILE__) . '/'; # Plugin Directory … … 42 54 <label for="captain-api-key">Your API Key:</label> 43 55 <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'> 44 69 <input type="submit" class="cpt-x-btn cpt-btn-success padded" name="submit" value="Save" /> 45 70 </div> … … 79 104 80 105 <?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 }87 106 } 88 107 … … 129 148 130 149 // 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. 132 153 function cptup_start() { 154 // Grab a reference to the API Key 133 155 $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 134 161 ?> 135 162 … … 138 165 (function() { 139 166 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'; 141 168 (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(cpt); 142 169 })(); … … 144 171 145 172 <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: []}; 147 174 captain.up({ 148 175 api_key: '<?php echo $captain_api; ?>' … … 182 209 extract($args); 183 210 $type = $instance['type']; 184 $width = $instance['width'];185 211 $height = $instance['height']; 186 212 … … 188 214 ?> 189 215 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;'> 191 217 </div> 192 218 … … 200 226 $instance['type'] = strip_tags($new_instance['type']); 201 227 $instance['css'] = strip_tags($new_instance['css']); 202 $instance['width'] = strip_tags($new_instance['width']);203 228 $instance['height'] = strip_tags($new_instance['height']); 204 229 return $instance; … … 209 234 $type = esc_attr($instance['type']); 210 235 $css = esc_attr($instance['css']); 211 $width = esc_attr($instance['width']);212 236 $height = esc_attr($instance['height']); 213 237 214 238 if (!$type) $type = 'leaderboard'; 215 239 if (!$css) $css = 'height: 300px; margin-top: 20px;'; 216 if (!$width) $width = '250';217 240 if (!$height) $height = '350'; 218 241 … … 232 255 </select> 233 256 </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; ?>" />px240 </p>241 257 242 258 <p> … … 255 271 256 272 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 283 function 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 } 293 add_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 302 function 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 } 312 add_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" 318 function 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 } 326 add_shortcode('captain-sign-up', 'captain_sign_up_link_shortcode' ); 327 328 257 329 ?> -
captain-up/trunk/readme.txt
r673845 r692934 3 3 Tags: game-mechanics,captainup,gamification,engagement,comments,widget,plugin,twitter,facebook,google 4 4 Requires at least: 3.0.1 5 Tested up to: 3. 45 Tested up to: 3.5.1 6 6 Stable tag: trunk 7 7 License: GPLv2 or later … … 12 12 == Description == 13 13 14 Captain Upis 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. 15 15 16 16 Captain 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. 17 17 18 18 You 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. 19 21 20 22 **Features**: … … 31 33 32 34 - **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 38 You 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". 33 45 34 46 **Contributing Code** … … 104 116 == Changelog == 105 117 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 106 128 = 1.0 = 129 107 130 * First Release.
Note: See TracChangeset
for help on using the changeset viewer.