Plugin Directory

Changeset 550252


Ignore:
Timestamp:
05/29/2012 02:31:33 PM (14 years ago)
Author:
tpk
Message:
 
Location:
my-coderwall-badges/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • my-coderwall-badges/trunk/cw_badges.php

    r536872 r550252  
    44Description: gets your badges from coderwall website and let you show them on your blog.
    55Author: Francesco Lentini
    6 Version: 0.4
     6Version: 0.5
    77Plugin URI: https://github.com/flentini/my-coderwall-badges
    88Author URI: http://spugna.org/tpk
     
    3232    $cwb_css_url = plugins_url('css/style.css', __FILE__);
    3333    $cwb_css_file = WP_PLUGIN_DIR . '/coderwall-badges/css/style.css';
    34    
     34
    3535    wp_register_style('cwb-css', $cwb_css_url);
    3636    wp_enqueue_style('cwb-css', $cwb_css_file, false, false, 'all');
     
    4646    }
    4747    global $cwb;
    48      
     48
    4949    if (isset($_POST['cwusername'])&&!empty($_POST['cwusername'])) {
    5050        $cwb->set_username($_POST['cwusername']);
    5151    }
     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
    5259    ?>
    53    
     60
    5461    <div class="wrap">
    5562        <p><div id="icon-users" class="icon32"></div><h2><?php _e('My Coderwall Badges', 'my-coderwall-badges'); ?></h2></p>
    56         <div>   
     63        <div>
    5764            <div style="display: inline-block; float: left">
    5865                <?php echo __('Name', 'my-coderwall-badges').': <h3>'.$cwb->get_name().'</h3>'; ?>
     
    6370                <label for="cwusername"><?php _e('Coderwall username', 'my-coderwall-badges'); ?>: </label>
    6471                <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(); ?>
    6777            </form>
    6878            </div>
    69         </div> 
     79        </div>
    7080        <div>
    7181            <?php echo $cwb->get_badges(); ?>
    7282        </div>
    73     </div> 
     83    </div>
    7484<?php }
    7585
     
    8393    echo $after_title;
    8494    echo $cwb->get_badges();
     95    if ($cwb->get_show_endorse()=='on'){
     96        echo $cwb->get_endorsements();
     97    }
    8598    echo $after_widget;
    8699}
  • my-coderwall-badges/trunk/cwbclass.php

    r536870 r550252  
    66        private $location;
    77        private $badges;
    8        
     8        private $show_endorse;
     9
    910        public function __construct(){
    1011            $this->username = get_option('cwb_username');
     12            $this->show_endorse = get_option('cwb_endorse');
    1113            $this->name = null;
    1214            $this->location = null;
    1315            $this->init_badges();
    1416        }
    15        
     17
    1618        public function set_username($cwbusername) {
    1719            $this->username = $cwbusername;
     
    1921            $this->init_badges();
    2022        }
    21        
     23
     24        public function set_show_endorse($cwendorse){
     25            $this->endorse = $cwendorse;
     26            update_option('cwb_endorse', $cwendorse);
     27        }
     28
    2229        public function get_username() {
    2330            return get_option('cwb_username');
    2431        }
    25        
     32
     33        public function get_show_endorse(){
     34            return get_option('cwb_endorse');
     35        }
     36
    2637        public function get_name(){
    2738            return $this->name;
    2839        }
    29        
     40
    3041        public function get_badges() {
    3142            return $this->badges;
    3243        }
    33        
     44
    3445        public function get_location() {
    3546            return $this->location;
    3647        }
    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
    3856        protected function init_badges() {
    3957            $cwbadges = wp_remote_get('http://coderwall.com/'.$this->username.'.json');
    40             if(!empty($cwbadges)){
     58            if(!empty($cwbadges) && !is_wp_error($cwbadges)){
    4159                $badges_string = '<div>';
    4260                $cwbadges = json_decode($cwbadges['body']);
  • my-coderwall-badges/trunk/readme.txt

    r536870 r550252  
    44Requires at least: 3.0
    55Tested up to: 3.3.1
    6 Stable tag: 0.4
     6Stable tag: 0.5
    77
    88gets your badges from coderwall website and let you show them on your blog.
     
    1010== Description ==
    1111
    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.
     12This simple plugin lets you get your [Coderwall](http://coderwall.com) badges and show them on your blog.
     13Install, activate the plugin and set your username in the CW Badges Panel.
    1414You can display your badges using the [cwbadges] shortcode inside your pages/posts.
    15 You have also these functions available:
     15You also have these functions available:
    1616
    1717echo $cwb->get_username() -> display username
     
    2323echo $cwb->get_badges() -> display user badges
    2424
    25 you can call them inside your theme's files.
     25You can call them inside your theme's files.
    2626
    2727There's also a widget which waits to be activated by you in the theme options.
     
    3030
    31311. Upload my-coderwall-badges directory to the `/wp-content/plugins/` directory
    32 1. Activate the plugin through the 'Plugins' menu in WordPress
     322. Activate the plugin through the 'Plugins' menu in WordPress
     333. Copy the style in `css/style.css` to your theme's stylesheet and adapt it to your needs.
    3334
    3435== Screenshots ==
     
    3738
    3839== 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)
    3943
    4044= 0.4 =
Note: See TracChangeset for help on using the changeset viewer.