WordPress.org

Plugin Directory

Changeset 541146


Ignore:
Timestamp:
05/08/12 03:47:03 (2 years ago)
Author:
ericmann
Message:

Updating to version 1.2.2.

Location:
wp-core-contributions-widget
Files:
19 added
5 edited

Legend:

Unmodified
Added
Removed
  • wp-core-contributions-widget/trunk/lib/class.wp-codex-contributions-widget.php

    r532117 r541146  
    1919            $title = esc_attr( $instance[ 'title' ] ); 
    2020        } else { 
    21             $title = __( 'WP Codex Contributions', 'wp-core-contributions-widget' ); 
     21            $title = esc_attr__( 'WP Codex Contributions', 'wp-core-contributions-widget' ); 
    2222        } 
    2323         
    2424        if ( $instance && isset( $instance[ 'codex-user' ] ) ) { 
    25             $codexUser = esc_attr( $instance[ 'codex-user' ] ); 
     25            $codex_user = esc_attr( $instance[ 'codex-user' ] ); 
    2626        } else { 
    27             $codexUser = __( 'Codex Username', 'wp-core-contributions-widget' ); 
     27            $codex_user = esc_attr__( 'Codex Username', 'wp-core-contributions-widget' ); 
    2828        } 
    2929         
    3030        if ( $instance && isset( $instance[ 'display-count' ] ) ) { 
    31             $codexCount = esc_attr( $instance[ 'display-count' ] ); 
     31            $codex_count = absint( $instance[ 'display-count' ] ); 
    3232        } else { 
    33             $codexCount = 5; 
     33            $codex_count = 5; 
    3434        } 
    3535        ?> 
    3636        <p> 
    37             <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> 
    38             <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /> 
     37            <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wp-core-contributions-widget' ); ?></label> 
     38            <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /> 
    3939 
    40             <label for="<?php echo $this->get_field_id('codex-user'); ?>"><?php _e('Codex Username:'); ?></label> 
    41             <input class="widefat" id="<?php echo $this->get_field_id('codex-user'); ?>" name="<?php echo $this->get_field_name('codex-user'); ?>" type="text" value="<?php echo $codexUser; ?>" /> 
     40            <label for="<?php echo $this->get_field_id( 'codex-user' ); ?>"><?php _e( 'Codex Username:', 'wp-core-contributions-widget' ); ?></label> 
     41            <input class="widefat" id="<?php echo $this->get_field_id( 'codex-user' ); ?>" name="<?php echo $this->get_field_name( 'codex-user' ); ?>" type="text" value="<?php echo $codex_user; ?>" /> 
    4242 
    43             <label for="<?php echo $this->get_field_id('display-count'); ?>"><?php _e('Display How Many Changes?'); ?></label> 
    44             <input class="widefat" id="<?php echo $this->get_field_id('display-count'); ?>" name="<?php echo $this->get_field_name('display-count'); ?>" type="text" value="<?php echo $codexCount; ?>" /> 
     43            <label for="<?php echo $this->get_field_id( 'display-count' ); ?>"><?php _e( 'Display How Many Changes?', 'wp-core-contributions-widget' ); ?></label> 
     44            <input class="widefat" id="<?php echo $this->get_field_id( 'display-count' ); ?>" name="<?php echo $this->get_field_name( 'display-count' ); ?>" type="text" value="<?php echo $codex_count; ?>" /> 
    4545        </p> 
    4646        <?php 
     
    4949    function update( $new_instance, $old_instance ) { 
    5050        $instance = $old_instance; 
    51         $instance['title'] = strip_tags($new_instance['title']); 
    52         $instance['codex-user'] = strip_tags($new_instance['codex-user']); 
    53         $instance['display-count'] = strip_tags($new_instance['display-count']); 
     51        $instance['title']          = strip_tags( $new_instance['title'] ); 
     52        $instance['codex-user']     = strip_tags( $new_instance['codex-user'] ); 
     53        $instance['display-count']  = absint( $new_instance['display-count'] ); 
    5454        return $instance; 
    5555    } 
     
    6060        // Mediawiki usernames uppercase on 1st letter & case-specific 
    6161        $user = $instance['codex-user']; 
    62         $count = isset($instance['display-count']) ? $instance['display-count'] : 10; 
     62        $count = isset( $instance['display-count'] ) ? $instance['display-count'] : 5; 
    6363 
    6464        echo $before_widget; 
     
    6969 
    7070        // Widget content 
    71         $items = array_slice( WP_Core_Contributions::get_codex_items($user, $count), 0, $count ); 
    72         $total = WP_Core_Contributions::get_codex_count($user); 
     71        $items = array_slice( WP_Core_Contributions::get_codex_items( $user, $count ), 0, $count ); 
     72        $total = WP_Core_Contributions::get_codex_count( $user ); 
    7373 
    7474        // Include template - can be overriden by a theme! 
  • wp-core-contributions-widget/trunk/lib/class.wp-core-contributions-widget.php

    r532117 r541146  
    1919            $title = esc_attr( $instance[ 'title' ] ); 
    2020        } else { 
    21             $title = __( 'WP Core Contributions', 'wp-core-contributions-widget' ); 
     21            $title = esc_attr__( 'WP Core Contributions', 'wp-core-contributions-widget' ); 
    2222        } 
    2323         
    2424        if ( $instance && isset( $instance[ 'trac-user' ] ) ) { 
    25             $tracUser = esc_attr( $instance[ 'trac-user' ] ); 
     25            $trac_user = esc_attr( $instance[ 'trac-user' ] ); 
    2626        } else { 
    27             $tracUser = __( 'Trac Username', 'wp-core-contributions-widget' ); 
     27            $trac_user = esc_attr__( 'Trac Username', 'wp-core-contributions-widget' ); 
    2828        } 
    2929         
    3030        if ( $instance && isset( $instance[ 'display-count' ] ) ) { 
    31             $tracCount = esc_attr( $instance[ 'display-count' ] ); 
     31            $trac_count = absint( $instance[ 'display-count' ] ); 
    3232        } else { 
    33             $tracCount = 5; 
     33            $trac_count = 5; 
    3434        } 
    3535        ?> 
    3636        <p> 
    37             <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> 
    38             <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /> 
     37            <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wp-core-contributions-widget' ); ?></label> 
     38            <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /> 
    3939 
    40             <label for="<?php echo $this->get_field_id('trac-user'); ?>"><?php _e('Trac Username:'); ?></label> 
    41             <input class="widefat" id="<?php echo $this->get_field_id('trac-user'); ?>" name="<?php echo $this->get_field_name('trac-user'); ?>" type="text" value="<?php echo $tracUser; ?>" /> 
     40            <label for="<?php echo $this->get_field_id( 'trac-user' ); ?>"><?php _e( 'Trac Username:', 'wp-core-contributions-widget' ); ?></label> 
     41            <input class="widefat" id="<?php echo $this->get_field_id('trac-user'); ?>" name="<?php echo $this->get_field_name( 'trac-user' ); ?>" type="text" value="<?php echo $trac_user; ?>" /> 
    4242 
    43             <label for="<?php echo $this->get_field_id('display-count'); ?>"><?php _e('Display How Many Tickets?'); ?></label> 
    44             <input class="widefat" id="<?php echo $this->get_field_id('display-count'); ?>" name="<?php echo $this->get_field_name('display-count'); ?>" type="text" value="<?php echo $tracCount; ?>" /> 
     43            <label for="<?php echo $this->get_field_id( 'display-count' ); ?>"><?php _e( 'Display How Many Tickets?', 'wp-core-contributions-widget' ); ?></label> 
     44            <input class="widefat" id="<?php echo $this->get_field_id( 'display-count' ); ?>" name="<?php echo $this->get_field_name( 'display-count' ); ?>" type="text" value="<?php echo $trac_count; ?>" /> 
    4545        </p> 
    4646        <?php 
     
    4949    function update( $new_instance, $old_instance ) { 
    5050        $instance = $old_instance; 
    51         $instance['title'] = strip_tags($new_instance['title']); 
    52         $instance['trac-user'] = strip_tags($new_instance['trac-user']); 
    53         $instance['display-count'] = strip_tags($new_instance['display-count']); 
     51        $instance['title']          = strip_tags( $new_instance['title'] ); 
     52        $instance['trac-user']      = strip_tags( $new_instance['trac-user'] ); 
     53        $instance['display-count']  = absint( $new_instance['display-count'] ); 
    5454        return $instance; 
    5555    } 
     
    5959        $title = apply_filters( 'widget_title', $instance['title'] ); 
    6060        $user = $instance['trac-user']; 
    61         $count = isset($instance['display-count']) ? $instance['display-count'] : 10; 
     61        $count = isset( $instance['display-count'] ) ? $instance['display-count'] : 5; 
    6262 
    6363        echo $before_widget; 
     
    6868 
    6969        // Widget content 
    70         $items = array_slice( WP_Core_Contributions::get_items($user), 0, $count ); 
    71         $total = WP_Core_Contributions::get_changeset_count($user); 
     70        $items = array_slice( WP_Core_Contributions::get_items( $user ), 0, $count ); 
     71        $total = WP_Core_Contributions::get_changeset_count( $user ); 
    7272 
    7373        // Include template - can be overriden by a theme! 
  • wp-core-contributions-widget/trunk/lib/class.wp-core-contributions.php

    r532117 r541146  
    22if ( ! class_exists('WP_Core_Contributions') ) : 
    33 
    4 class WP_Core_Contributions{ 
     4class WP_Core_Contributions { 
    55    public static function init() { 
    66        add_action( 'init',         array( 'WP_Core_Contributions', 'wp_init' ) ); 
     
    99 
    1010    public static function wp_init() { 
    11         load_plugin_textdomain( 'wp-core-contributions-widget', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' ); 
     11        load_plugin_textdomain( 'wp-core-contributions-widget', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/lang/' ); 
    1212    } 
    1313 
    1414    public static function register_widget() { 
    15         register_widget('WP_Core_Contributions_Widget'); 
    16         register_widget('WP_Codex_Contributions_Widget'); 
     15        register_widget( 'WP_Core_Contributions_Widget' ); 
     16        register_widget( 'WP_Codex_Contributions_Widget' ); 
    1717    } 
    1818 
    1919    public static function get_items( $username ) { 
    20         if($username == null) return array(); 
     20        if ( null == $username ) return array(); 
    2121 
    22         if( false === ( $formatted = get_transient( 'wp-core-contributions-' . $username ) ) ) { 
    23  
    24             $results = wp_remote_retrieve_body(wp_remote_get('https://core.trac.wordpress.org/search?q=props+' . $username . '&noquickjump=1&changeset=on', array('sslverify'=>false))); 
     22        if ( false === ( $formatted = get_transient( 'wp-core-contributions-' . $username ) ) ) { 
     23            $results_url = add_query_arg( array( 
     24                    'q'             =>  'props+' . $username, 
     25                    'noquickjump'   =>  '1', 
     26                    'changeset'     =>  'on' 
     27            ), 'https://core.trac.wordpress.org/search' ); 
     28            $results = wp_remote_retrieve_body( wp_remote_get( $results_url, array( 'sslverify' => false ) ) ); 
    2529 
    2630            $pattern = '/<dt><a href="(.*?)" class="searchable">\[(.*?)\]: ((?s).*?)<\/a><\/dt>\n\s*(<dd class="searchable">.*\n?.*(?:ixes|ee) #(.*?)\n?<\/dd>)?/'; 
    2731 
    28             preg_match_all($pattern, $results, $matches, PREG_SET_ORDER); 
     32            preg_match_all( $pattern, $results, $matches, PREG_SET_ORDER ); 
    2933 
    3034            $formatted = array(); 
    3135 
    32             foreach($matches as $match) { 
    33                 array_shift($match); 
    34                 $newMatch = array( 
    35                     'link' => 'https://core.trac.wordpress.org' . $match[0], 
    36                     'changeset' => intval($match[1]), 
    37                     'description' => $match[2], 
    38                     'ticket' => isset( $match[3] ) ? intval($match[4]) : '', 
     36            foreach ( $matches as $match ) { 
     37                array_shift( $match ); 
     38                $new_match = array( 
     39                    'link'          => 'https://core.trac.wordpress.org' . $match[0], 
     40                    'changeset'     => intval($match[1]), 
     41                    'description'   => $match[2], 
     42                    'ticket'        => isset( $match[3] ) ? intval($match[4]) : '', 
    3943                ); 
    40                 array_push($formatted, $newMatch); 
     44                array_push( $formatted, $new_match ); 
    4145            } 
    4246 
     
    4852 
    4953    public static function get_changeset_count( $username ) { 
    50         if ( $username == null ) return array(); 
     54        if ( null == $username ) return array(); 
    5155 
    5256        if ( false == ( $count = get_transient( 'wp-core-contributions-count-' . $username ) ) ) { 
    53             $results = wp_remote_retrieve_body(wp_remote_get('https://core.trac.wordpress.org/search?q=props+' . $username . '&noquickjump=1&changeset=on', array('sslverify'=>false))); 
     57            $results_url = add_query_arg( array( 
     58                'q'             =>  'props+' . $username, 
     59                'noquickjump'   =>  '1', 
     60                'changeset'     =>  'on' 
     61            ), 'https://core.trac.wordpress.org/search' ); 
     62            $results = wp_remote_retrieve_body( wp_remote_get( $results_url, array( 'sslverify' => false ) ) ); 
    5463 
    5564            $pattern = '/<meta name="totalResults" content="(\d*)" \/>/'; 
    5665 
    57             preg_match($pattern, $results, $matches); 
     66            preg_match( $pattern, $results, $matches ); 
    5867 
    59             $count = intval($matches[1]); 
     68            $count = intval( $matches[1] ); 
    6069 
    6170            set_transient( 'wp-core-contributions-count-' . $username, $count, 60 * 60 * 12 ); 
     
    6675     
    6776    public static function get_codex_items( $username, $limit = 10 ) { 
    68         if ( $username == null ) return array(); 
     77        if ( null == $username ) return array(); 
    6978         
    7079        if ( true || false == ( $formatted = get_transient( 'wp-codex-contributions-' . $username ) ) ) { 
    7180             
    72             $results_url = 'http://codex.wordpress.org/api.php?action=query&list=usercontribs&ucuser=' . $username . '&uclimit=' . $limit . '&ucdir=older&format=php'; 
    73             $results = wp_remote_retrieve_body( wp_remote_get( $results_url, array('sslverify'=>false) ) ); 
     81            $results_url = add_query_arg( array( 
     82                'action'    =>  'query', 
     83                'list'      =>  'usercontribs', 
     84                'ucuser'    =>  $username, 
     85                'uclimit'   =>  $limit, 
     86                'ucdir'     =>  'older', 
     87                'format'    =>  'php' 
     88            ), 'http://codex.wordpress.org/api.php' ); 
     89            $results = wp_remote_retrieve_body( wp_remote_get( $results_url, array( 'sslverify' => false ) ) ); 
    7490 
    75             $raw = unserialize( $results ); 
     91            $raw = maybe_unserialize( $results ); 
    7692             
    7793            /* Expected array format is as follows: 
     
    99115            foreach( $raw['query']['usercontribs'] as $item ) { 
    100116                $count = 0; 
    101                 $clean_title = preg_replace( '/^Function Reference\//', '', (string)$item['title'], 1, $count ); 
     117                $clean_title = preg_replace( '/^Function Reference\//', '', (string) $item['title'], 1, $count ); 
    102118 
    103                 $newItem = array( 
    104                     'title' => $clean_title, 
    105                     'description' => (string)$item['comment'], 
    106                     'revision' => (int)$item['revid'], 
    107                     'function_ref' => $count == 0 ? false : true 
     119                $new_item = array( 
     120                    'title'         => $clean_title, 
     121                    'description'   => (string) $item['comment'], 
     122                    'revision'      => (int) $item['revid'], 
     123                    'function_ref'  => (bool) $count 
    108124                ); 
    109                 array_push( $formatted, $newItem ); 
     125                array_push( $formatted, $new_item ); 
    110126            } 
    111127             
     
    117133     
    118134    public static function get_codex_count( $username ) { 
    119         if ( $username == null ) return array(); 
     135        if ( null == $username ) return array(); 
    120136 
    121137        if ( false == ( $count = get_transient( 'wp-codex-contributions-count-' . $username ) ) ) { 
    122138             
    123             $results_url = 'http://codex.wordpress.org/api.php?action=query&list=users&ususers=' . $username . '&usprop=editcount&format=xml'; 
     139            $results_url = add_query_arg( array( 
     140                'action'    =>  'query', 
     141                'list'      =>  'users', 
     142                'ususers'   =>  $username, 
     143                'usprop'    =>  'editcount', 
     144                'format'    =>  'xml' 
     145            ), 'http://codex.wordpress.org/api.php' ); 
    124146            $results = wp_remote_retrieve_body( wp_remote_get( $results_url, array('sslverify'=>false) ) ); 
    125147             
     
    136158             
    137159            $raw = new SimpleXMLElement( $results ); 
    138             $count = (int)$raw->query->users->user["editcount"]; 
     160            $count = (int) $raw->query->users->user["editcount"]; 
    139161             
    140162            set_transient( 'wp-codex-contributions-count-' . $username, $count, 60 * 60 * 12 ); 
     
    146168 
    147169endif; 
    148 ?> 
  • wp-core-contributions-widget/trunk/readme.txt

    r532117 r541146  
    11=== WP Core Contributions Widget === 
    2 Contributors: ericmann, mfields, JohnPBloch, mbijon 
     2Contributors: ericmann, mfields, JohnPBloch, mbijon, kobenland 
    33Donate link: http://jumping-duck.com/wordpress 
    44Tags: core, widget, contributions 
    55Requires at least: 3.2.1 
    66Tested up to: 3.4 
    7 Stable tag: 1.2.1 
     7Stable tag: 1.2.2 
    88License: GPLv2+ 
    99 
     
    6767== Changelog == 
    6868 
     69= 1.2.2 = 
     70* Clean up query string generation with Trac API 
     71* Add German translation 
     72 
    6973= 1.2.1 = 
    7074* Switch to PHP return for Codex data 
  • wp-core-contributions-widget/trunk/wp-core-contributions-widget.php

    r532117 r541146  
    44Plugin URI: http://jumping-duck.com/wordpress 
    55Description: Add a list of your accepted contributions to WordPress Core as a sidebar widget. 
    6 Version: 1.2.1 
     6Version: 1.2.2 
    77Author: Eric Mann 
    88Author URI: http://eamann.com 
Note: See TracChangeset for help on using the changeset viewer.