Changeset 550252
- Timestamp:
- 05/29/2012 02:31:33 PM (14 years ago)
- Location:
- my-coderwall-badges/trunk
- Files:
-
- 3 edited
-
cw_badges.php (modified) (5 diffs)
-
cwbclass.php (modified) (2 diffs)
-
readme.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
my-coderwall-badges/trunk/cw_badges.php
r536872 r550252 4 4 Description: gets your badges from coderwall website and let you show them on your blog. 5 5 Author: Francesco Lentini 6 Version: 0. 46 Version: 0.5 7 7 Plugin URI: https://github.com/flentini/my-coderwall-badges 8 8 Author URI: http://spugna.org/tpk … … 32 32 $cwb_css_url = plugins_url('css/style.css', __FILE__); 33 33 $cwb_css_file = WP_PLUGIN_DIR . '/coderwall-badges/css/style.css'; 34 34 35 35 wp_register_style('cwb-css', $cwb_css_url); 36 36 wp_enqueue_style('cwb-css', $cwb_css_file, false, false, 'all'); … … 46 46 } 47 47 global $cwb; 48 48 49 49 if (isset($_POST['cwusername'])&&!empty($_POST['cwusername'])) { 50 50 $cwb->set_username($_POST['cwusername']); 51 51 } 52 53 if (isset($_POST['cwendorse'])&&!empty($_POST['cwendorse'])) { 54 $cwb->set_show_endorse($_POST['cwendorse']); 55 } else { 56 $cwb->set_show_endorse('off'); 57 } 58 52 59 ?> 53 60 54 61 <div class="wrap"> 55 62 <p><div id="icon-users" class="icon32"></div><h2><?php _e('My Coderwall Badges', 'my-coderwall-badges'); ?></h2></p> 56 <div> 63 <div> 57 64 <div style="display: inline-block; float: left"> 58 65 <?php echo __('Name', 'my-coderwall-badges').': <h3>'.$cwb->get_name().'</h3>'; ?> … … 63 70 <label for="cwusername"><?php _e('Coderwall username', 'my-coderwall-badges'); ?>: </label> 64 71 <input id="cwusername" maxlength="45" size="25" name="cwusername" value="<?php echo $cwb->get_username(); ?>" /> 65 66 <input class="button-primary" type="submit" name="Save" value='<?php _e("Save"); ?>' /> 72 </br> 73 <label for="cwendorse"><?php _e('Display endorse count', 'my-coderwall-endorsecount'); ?>: </label> 74 <input id="cwendorse" type="checkbox" name="cwendorse" <?php if($cwb->get_show_endorse() == 'on') echo 'checked = checked' ?>/> 75 </br> 76 <?php submit_button(); ?> 67 77 </form> 68 78 </div> 69 </div> 79 </div> 70 80 <div> 71 81 <?php echo $cwb->get_badges(); ?> 72 82 </div> 73 </div> 83 </div> 74 84 <?php } 75 85 … … 83 93 echo $after_title; 84 94 echo $cwb->get_badges(); 95 if ($cwb->get_show_endorse()=='on'){ 96 echo $cwb->get_endorsements(); 97 } 85 98 echo $after_widget; 86 99 } -
my-coderwall-badges/trunk/cwbclass.php
r536870 r550252 6 6 private $location; 7 7 private $badges; 8 8 private $show_endorse; 9 9 10 public function __construct(){ 10 11 $this->username = get_option('cwb_username'); 12 $this->show_endorse = get_option('cwb_endorse'); 11 13 $this->name = null; 12 14 $this->location = null; 13 15 $this->init_badges(); 14 16 } 15 17 16 18 public function set_username($cwbusername) { 17 19 $this->username = $cwbusername; … … 19 21 $this->init_badges(); 20 22 } 21 23 24 public function set_show_endorse($cwendorse){ 25 $this->endorse = $cwendorse; 26 update_option('cwb_endorse', $cwendorse); 27 } 28 22 29 public function get_username() { 23 30 return get_option('cwb_username'); 24 31 } 25 32 33 public function get_show_endorse(){ 34 return get_option('cwb_endorse'); 35 } 36 26 37 public function get_name(){ 27 38 return $this->name; 28 39 } 29 40 30 41 public function get_badges() { 31 42 return $this->badges; 32 43 } 33 44 34 45 public function get_location() { 35 46 return $this->location; 36 47 } 37 48 49 public function get_endorsements() { 50 return "<a href='http://coderwall.com/$this->username' title='Coderwall endorsements'>" . 51 "<img src='http://api.coderwall.com/$this->username/endorsecount.png' alt='Coderwall endorsements' />" . 52 "</a>"; 53 } 54 55 38 56 protected function init_badges() { 39 57 $cwbadges = wp_remote_get('http://coderwall.com/'.$this->username.'.json'); 40 if(!empty($cwbadges) ){58 if(!empty($cwbadges) && !is_wp_error($cwbadges)){ 41 59 $badges_string = '<div>'; 42 60 $cwbadges = json_decode($cwbadges['body']); -
my-coderwall-badges/trunk/readme.txt
r536870 r550252 4 4 Requires at least: 3.0 5 5 Tested up to: 3.3.1 6 Stable tag: 0. 46 Stable tag: 0.5 7 7 8 8 gets your badges from coderwall website and let you show them on your blog. … … 10 10 == Description == 11 11 12 this simple plugin lets you get your coderwall.com badges and show them on your blog. 13 install, activate the plugin and set your username in the CW Badges Panel.12 This simple plugin lets you get your [Coderwall](http://coderwall.com) badges and show them on your blog. 13 Install, activate the plugin and set your username in the CW Badges Panel. 14 14 You can display your badges using the [cwbadges] shortcode inside your pages/posts. 15 You have also these functions available:15 You also have these functions available: 16 16 17 17 echo $cwb->get_username() -> display username … … 23 23 echo $cwb->get_badges() -> display user badges 24 24 25 you can call them inside your theme's files.25 You can call them inside your theme's files. 26 26 27 27 There's also a widget which waits to be activated by you in the theme options. … … 30 30 31 31 1. Upload my-coderwall-badges directory to the `/wp-content/plugins/` directory 32 1. Activate the plugin through the 'Plugins' menu in WordPress 32 2. Activate the plugin through the 'Plugins' menu in WordPress 33 3. Copy the style in `css/style.css` to your theme's stylesheet and adapt it to your needs. 33 34 34 35 == Screenshots == … … 37 38 38 39 == Changelog == 40 41 = 0.5 = 42 * Added option to show Coderwall endorsements (http://coderwall.com/blog/2012-01-16-the-hacker-version-of-an-embeddable-social-button) 39 43 40 44 = 0.4 =
Note: See TracChangeset
for help on using the changeset viewer.