Plugin Directory

Changeset 576057


Ignore:
Timestamp:
07/23/2012 01:31:03 PM (14 years ago)
Author:
gchokeen
Message:
 
Location:
wp-wiki-userprofile/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-wiki-userprofile/trunk/readme.txt

    r561301 r576057  
    11=== Wp Wiki Userprofile ===
    22Contributors: gchokeen
    3 Donate link: http://example.com/
     3Donate link: http://code-cocktail.in/donate-me/
    44Tags: widget, wiki
    55Requires at least: 2.8
    6 Tested up to: 3.3.2
    7 Stable tag: 1.0
     6Tested up to: 3.4.1
     7Stable tag: 1.1
    88License: GPLv2
    99
     
    1616using CURL request.
    1717
     18= Plugin Features =
     19
     20* Widget Support
     21* Shortcode support
     22
     23= Shortcode Usage =
     24*`[wikiuser]`
     25
     26*`[wikiuser  param="editcount"]`
     27
     28*`[wikiuser username="xxx" param="editcount"]`
     29
     30
    1831
    1932== Installation ==
     
    25381. Upload the entire `wp-wiki-userprofile` folder to the `/wp-content/plugins/` directory
    26392. Activate the plugin through the 'Plugins' menu in WordPress
     40
     41
    2742
    2843
     
    4459== Changelog ==
    4560
     61= 1.1 =
     62* Shortcode support added.
     63* Feedback links is are added.
     64 
     65
    4666= 1.0 =
    4767* Initial release.
  • wp-wiki-userprofile/trunk/wp-wiki-userprofile.php

    r561301 r576057  
    44Plugin URI: http://wordpress.org/extend/plugins/wp-wiki-userprofile/
    55Description: This plugin is used to grab Wikipedia user contribution to wordpress blog.
    6 Version: 1.0
     6Version: 1.1
    77Author: Gowri Sankar Ramasamy.
     8Author URI: http://code-cocktail.in/author/gowrisankar/
     9Donate link: http://code-cocktail.in/donate-me/
    810License: GPL2
    911*/
     
    4648}
    4749
     50
     51// admin wiki userprofile settings page
     52
    4853function wiki_profile_options() {
    49     if ( !current_user_can( 'manage_options' ) )  {
    50         wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
    51     }
    52 
    53 if(isset($_POST['wiki-profile-submit'])){
    54 
    55     update_option('codecocktail_wiki_username',$_POST['codecocktail_wiki_username']);
    56     update_option('codecocktail_wiki_user_param',$_POST['codecocktail_wiki_user_param']);
    57        
    58 }
    59 
    60    
    61    
    62 echo '
    63     <form method="post" action="" name="wiki-profile-form">
    64     <div class="wrap">
    65   <div class="icon32" id="icon-options-general"><br>
    66   </div>
    67   <h2>Wiki Userprofile Settings</h2>
    68   <table class="form-table">
    69     <tbody>
    70       <tr>
    71         <td width="30%" valign="top"><strong>'.__('Wiki Userprofile UserName:','codecocktail-wikiprofile').'</strong></td>
    72         <td valign="top">
    73         <input type="text" name="codecocktail_wiki_username" value="'.get_option("codecocktail_wiki_username").'" size="60"/>
    74         </td>
    75       </tr>
    76       <tr>
    77         <td width="30%" valign="top"><strong>'.__('Parameters:','codecocktail-wikiprofile').'</strong></td>
    78         <td valign="top">
    79         <input type="text" name="codecocktail_wiki_user_param" value="'.get_option("codecocktail_wiki_user_param").'" size="80"/>
    80         </td>
    81       </tr>
    82     </tbody>
    83   </table>
    84   <h3>&nbsp;</h3>
    85   <p class="submit">
    86     <input type="submit" value="Save Changes" class="button-primary" name="wiki-profile-submit">
    87   </p>
    88 </div>
    89 </form>
    90    
    91     ';
    92    
    93 
     54        if ( !current_user_can( 'manage_options' ) )  {
     55            wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
     56        }
     57   
     58    if(isset($_POST['wiki-profile-submit'])){
     59   
     60        update_option('codecocktail_wiki_username',$_POST['codecocktail_wiki_username']);
     61        update_option('codecocktail_wiki_user_param',$_POST['codecocktail_wiki_user_param']);
     62           
     63    }
     64   
     65       
     66       
     67    echo '
     68        <div class="wrap">
     69        <form method="post" action="" name="wiki-profile-form">
     70   
     71      <div class="icon32" id="icon-options-general"><br>
     72      </div>
     73      <h2>'.__('Wiki Userprofile Settings','codecocktail-wikiprofile').'</h2>
     74      <table class="form-table">
     75        <tbody>
     76          <tr>
     77            <td width="30%" valign="top"><strong>'.__('Wikipedia UserName:','codecocktail-wikiprofile').'</strong></td>
     78            <td valign="top">
     79            <input type="text" name="codecocktail_wiki_username" value="'.get_option("codecocktail_wiki_username").'" size="60"/>
     80            </td>
     81          </tr>
     82          <tr>
     83            <td width="30%" valign="top"><strong>'.__('Parameters:','codecocktail-wikiprofile').'</strong></td>
     84            <td valign="top">
     85            <input type="text" name="codecocktail_wiki_user_param" value="'.get_option("codecocktail_wiki_user_param").'" size="80"/>
     86            </td>
     87          </tr>
     88        </tbody>
     89      </table>
     90      <h3>&nbsp;</h3>
     91      <p class="submit">
     92        <input type="submit" value="Save Changes" class="button-primary" name="wiki-profile-submit">
     93      </p>
     94   
     95    </form>
     96    <div class="shortcode-doc">
     97    <strong>'.__("Example Shortcode Usage:","codecocktail-wikiprofile").'</strong>
     98    <ul>
     99        <li>[wikiuser]</li>
     100        <li>[wikiuser  param="editcount"]</li>
     101        <li>[wikiuser username="xxx" param="editcount"]</li>
     102    </ul>
     103    </div>
     104    <div class="feedback-doc">
     105    <strong>'.__("Feedback","codecocktail-wikiprofile").'</strong>
     106     <p>Feel free to contact me <a href="mailto:[email protected]?subject=Wp Wiki Userprofile">[email protected]</a>. I like to hear
     107     <a href="mailto:[email protected]?subject=Wp Wiki Userprofile Feedback">'.__("Future request","codecocktail-wikiprofile").'</a>,
     108     <a href="mailto:[email protected]?subject=Wp Wiki Userprofile Suggestion">'.__("Suggestion","codecocktail-wikiprofile").'</a>,
     109     <a href="mailto:[email protected]?subject=Wp Wiki Userprofile Bug Report">'.__("Bug Report","codecocktail-wikiprofile").'</a>
     110     or
     111     <a href="mailto:[email protected]?subject=Wp Wiki Userprofile Future request">'.__("Future request","codecocktail-wikiprofile").'</a>
     112     from you.</p>
     113    </div>
     114    </div>
     115   
     116       
     117        ';
     118       
     119   
    94120}
    95121
     
    111137
    112138function wiki_profile_admin_notices() {
    113     echo "<div id='notice' class='updated fade'><p>". __( 'Wiki Userprofile is not configured yet. Please do it now.','codecocktail-wikiprofile' )."</p></div>\n";
     139    echo "<div id='notice' class='updated fade'><p>". __( 'Wiki Userprofile is not configured yet. Please configure it <a href="'.admin_url( 'options-general.php?page=wiki-profile').'">here</a> .','codecocktail-wikiprofile' )."</p></div>\n";
    114140}
    115141
     
    159185}
    160186
    161 function get_wiki_response(){
     187function get_wiki_response($wiki_username = "",$wiki_user_param=""){
    162188    do_action('get_wiki_response');
    163189
    164 $codecocktail_wiki_username =   get_option("codecocktail_wiki_username");
    165     $codecocktail_wiki_user_param =     get_option("codecocktail_wiki_user_param");
     190$codecocktail_wiki_username = ($wiki_username=="" ? get_option("codecocktail_wiki_username"):$wiki_username);
     191$codecocktail_wiki_user_param = ($wiki_user_param=="" ? get_option("codecocktail_wiki_user_param"):$wiki_user_param);
     192   
    166193           
    167194     $wiki_API_URL ="http://en.wikipedia.org/w/api.php?format=json&action=query&list=users&ususers=".$codecocktail_wiki_username."&usprop=".$codecocktail_wiki_user_param."";
     
    186213
    187214
    188 /*function wiki_reorder($array){
    189     do_action('wiki_reorder');
    190    
    191  $wiki_reposnse = $array['query']['users'];
    192  $order_referece = explode("|",get_option("codecocktail_wiki_user_param"));
    193  
    194   $temp_array = array();
    195 
    196  foreach($wiki_reposnse as $key=>$value){
    197  
    198  //print_r($value);
    199  
    200   //    $temp_array[$key] = array_multisort($order_referece,$value);
    201    
    202  }
    203  
    204  return $temp_array;
    205    
    206 }*/
    207 
    208 
     215/**
     216 * array_tree function will help to convert php array data into <ul>,<li> Html format.
     217 */
    209218
    210219function array_tree($array,$args = array(),$level=0){
     
    218227$data = array_merge($default,$args);
    219228
    220 if(is_array($array)){   
    221 
    222 $output .= '<ul'.($level==0?" class='$data[container_class]'":" class='sub-level-$level'").($level==0?" id='$data[container_id]'":'').'>';
    223 
    224 foreach($array as $key=>$value){
    225 
    226     if(is_array($value)){
    227        
    228     $output .='<li>'.(!is_numeric($key)?'<label>'.ucfirst($key).'</label>: ':'');
    229     $output .=array_tree($value,$data,$level++);
    230     $output .='</li>';
     229    if(is_array($array)){   
     230   
     231    $output .= '<ul'.($level==0?" class='$data[container_class]'":" class='sub-level-$level'").($level==0?" id='$data[container_id]'":'').'>';
     232   
     233    foreach($array as $key=>$value){
     234   
     235        if(is_array($value)){
     236           
     237        $output .='<li>'.(!is_numeric($key)?'<label>'.ucfirst($key).'</label>: ':'');
     238        $output .=array_tree($value,$data,$level++);
     239        $output .='</li>';
     240        }
     241        else{
     242            if(!in_array(strtolower($key),$data['exclude'])){
     243           
     244            $output .= '<li>'.(!is_numeric($key)?'<label>'.ucfirst($key).'</label>: ':'').ucfirst($value).'</li>';
     245            }
     246            }   
     247        }
     248    $output .= '</ul>';
     249   
     250    return $output;
    231251    }
    232252    else{
    233         if(!in_array(strtolower($key),$data['exclude'])){
    234        
    235         $output .= '<li>'.(!is_numeric($key)?'<label>'.ucfirst($key).'</label>: ':'').ucfirst($value).'</li>';
    236         }
    237         }   
    238     }
    239 $output .= '</ul>';
    240 
    241 return $output;
    242 }
    243 else{
    244     return $array;
    245 }
    246 
    247    
    248 }
    249 
    250 
    251 
    252 
    253 function get_wiki_display(){
    254    
    255     $array = get_wiki_response();
     253        return $array;
     254    }
     255
     256   
     257}
     258
     259
     260
     261
     262function get_wiki_display($wiki_username = "",$wiki_user_param=""){
     263   
     264    $array = get_wiki_response($wiki_username,$wiki_user_param);
    256265   
    257266     $wiki_reposnse = $array['query']['users'];
    258     //print_r( $wiki_reposnse);
    259267   
    260268    return array_tree($wiki_reposnse,array('exclude'=>array('userid')));
     
    295303        if ( ! empty( $title ) )
    296304            echo $before_title . $title . $after_title;
    297            
    298    
    299            
    300            
    301 //'http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=API|Main_Page&rvprop=timestamp|user|comment|content';                   
    302        
    303    
    304     echo get_wiki_display();
    305            
    306 /*          echo "<pre>";
    307             print_r(get_wiki_display());
    308            
    309        
    310             echo "</pre>";  */ 
    311            
    312         ?><?php
    313         echo $after_widget;
     305            echo get_wiki_display();   
     306
     307            echo $after_widget;
    314308    }
    315309
     
    359353add_action( 'widgets_init', create_function( '', 'register_widget( "wiki_profile_widget" );' ) );
    360354
     355
     356/**
     357 * short code support added.
     358 *
     359 * @version 1.1
     360 *
     361 * @param username,param.
     362 */
     363
     364function wikiuser_shortcode($atts) {
     365
     366$codecocktail_wiki_username =   get_option("codecocktail_wiki_username");
     367$codecocktail_wiki_user_param =     get_option("codecocktail_wiki_user_param");
     368   
     369     extract(shortcode_atts(array(
     370          'username' => $codecocktail_wiki_username,
     371          'param' => $codecocktail_wiki_user_param,
     372     ), $atts));
     373     
     374     return get_wiki_display($username,$param);
     375}
     376add_shortcode('wikiuser', 'wikiuser_shortcode');
Note: See TracChangeset for help on using the changeset viewer.