Plugin Directory

Changeset 3220440


Ignore:
Timestamp:
01/10/2025 08:20:16 PM (13 months ago)
Author:
ctltwp
Message:

updated plugin version to 2.0.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • people-lists/trunk/people-lists.php

    r3220439 r3220440  
    44 * Plugin URI: http://www.ctlt.ubc.ca
    55 * Description: Plugin providing a rich text editor on the profile page for easy modifications of specific user profile
    6  *              information that can be displayed on any page using the [people-lists list=example-list] shortcode. Users
    7  *              will also be able to add custom fields to their user profile and these fields can be displayed on any page
    8  *              using the People Lists template (which can be styled using HTML) that provides codes for every field that is
    9  *              desired to be displayed.
     6 *              information that can be displayed on any page using the [people-lists list=example-list] shortcode. Users
     7 *              will also be able to add custom fields to their user profile and these fields can be displayed on any page
     8 *              using the People Lists template (which can be styled using HTML) that provides codes for every field that is
     9 *              desired to be displayed.
    1010 * Author: Gagan Sandhu , Enej Bajgoric , CTLT DEV, UBC
    11  * Version: 1.3.10
     11 * Version: 2.0.0
    1212 * Author URI: http://www.ctlt.ubc.ca
    1313 *
     
    2828 */
    2929
    30 # now you can define to for people list to not include the visual editor for
    31 # there are other plugins that do that quite well
    32 # like http://wordpress.org/extend/plugins/visual-biography-editor/
    33 
    34 
    35 
    36 if(!defined("PEOPLE_LIST_VISUAL_EDITOR"));
    37     define("PEOPLE_LIST_VISUAL_EDITOR", true);
    38 
    39 add_action('admin_print_styles-settings_page_people_lists', 'people_list_options_init_style' );
    40 add_action('admin_print_scripts-settings_page_people_lists', 'people_list_options_init_script' );
    41 
    42 if(PEOPLE_LIST_VISUAL_EDITOR):
    43     add_action('admin_print_scripts-user-edit.php', 'people_lists_tinymce_init_script');
    44     add_action('admin_print_scripts-profile.php', 'people_lists_tinymce_init_script');
    45 
    46     add_action('admin_print_styles-user-edit.php', 'people_lists_tinymce_init_style');
    47     add_action('admin_print_styles-profile.php', 'people_lists_tinymce_init_style');
     30// now you can define to for people list to not include the visual editor for
     31// there are other plugins that do that quite well
     32// like http://wordpress.org/extend/plugins/visual-biography-editor/
     33
     34
     35
     36if ( ! defined( 'PEOPLE_LIST_VISUAL_EDITOR' ) ) {
     37}
     38    define( 'PEOPLE_LIST_VISUAL_EDITOR', true );
     39
     40add_action( 'admin_print_styles-settings_page_people_lists', 'people_list_options_init_style' );
     41add_action( 'admin_print_scripts-settings_page_people_lists', 'people_list_options_init_script' );
     42
     43if ( PEOPLE_LIST_VISUAL_EDITOR ) :
     44    add_action( 'admin_print_scripts-user-edit.php', 'people_lists_tinymce_init_script' );
     45    add_action( 'admin_print_scripts-profile.php', 'people_lists_tinymce_init_script' );
     46
     47    add_action( 'admin_print_styles-user-edit.php', 'people_lists_tinymce_init_style' );
     48    add_action( 'admin_print_styles-profile.php', 'people_lists_tinymce_init_style' );
    4849
    4950    // add wysiwig textarea to  to
    50     add_action('show_user_profile', 'people_list_edit_user_profile_bio_field', 10, 1);
    51     add_action('edit_user_profile', 'people_list_edit_user_profile_bio_field', 10 ,1);
    52 
    53     add_action("admin_init",'people_list_edit_user_profile_bio_init');
     51    add_action( 'show_user_profile', 'people_list_edit_user_profile_bio_field', 10, 1 );
     52    add_action( 'edit_user_profile', 'people_list_edit_user_profile_bio_field', 10, 1 );
     53
     54    add_action( 'admin_init', 'people_list_edit_user_profile_bio_init' );
    5455    add_filter( 'get_the_author_description', 'people_list_edit_user_profile_bio_filter' );
    5556
    5657
    5758    // for the media buttons - I think this could probably be removed
    58     add_action('admin_footer-user-edit.php', 'people_lists_media_buttons', 40 );
    59     add_action('admin_footer-profile.php', 'people_lists_media_buttons', 40 );
     59    add_action( 'admin_footer-user-edit.php', 'people_lists_media_buttons', 40 );
     60    add_action( 'admin_footer-profile.php', 'people_lists_media_buttons', 40 );
    6061
    6162endif;
    6263
    63 add_action('admin_footer-user-edit.php', 'wp_preload_dialogs', 30 );
    64 add_action('admin_footer-profile.php', 'wp_preload_dialogs', 30 );
    65 
    66 
    67 
    68 add_action('admin_init', 'people_list_register_options_init');
    69 add_action('admin_menu', 'people_list_options_add_page');
    70 add_action('wp_ajax_people_list_save', 'people_list_saving_list');
    71 add_action('wp_ajax_people_settings_save', 'people_list_saving_settings');
    72 add_action('media_buttons_context', 'people_lists_overlay_button');
    73 add_action('admin_footer', 'people_lists_overlay_popup_form');
    74 
    75 add_shortcode('people-lists', 'people_lists_shortcode');
    76 
    77 add_filter('widget_text', 'do_shortcode');
    78 add_filter('user_contactmethods','people_lists_user_fields_filter');
    79 
    80 
    81 
    82 
    83 
    84 
    85 function people_list_edit_user_profile_bio_field($user) {
     64add_action( 'admin_footer-user-edit.php', 'wp_preload_dialogs', 30 );
     65add_action( 'admin_footer-profile.php', 'wp_preload_dialogs', 30 );
     66
     67
     68
     69add_action( 'admin_init', 'people_list_register_options_init' );
     70add_action( 'admin_menu', 'people_list_options_add_page' );
     71add_action( 'wp_ajax_people_list_save', 'people_list_saving_list' );
     72add_action( 'wp_ajax_people_settings_save', 'people_list_saving_settings' );
     73add_action( 'media_buttons_context', 'people_lists_overlay_button' );
     74add_action( 'admin_footer', 'people_lists_overlay_popup_form' );
     75
     76add_shortcode( 'people-lists', 'people_lists_shortcode' );
     77
     78add_filter( 'widget_text', 'do_shortcode' );
     79add_filter( 'user_contactmethods', 'people_lists_user_fields_filter' );
     80
     81
     82
     83
     84
     85
     86function people_list_edit_user_profile_bio_field( $user ) {
    8687    $news_user = new WP_User( $user->ID );
    87 ?>
     88    ?>
    8889    <table class="form-table">
    8990    <tr>
    90         <th><label for="description"><?php _e('General Information'); ?></label></th>
    91         <td><?php wp_editor($news_user->description, "description-1", array('textarea_name'=>'description')); ?>
    92         <span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td>
     91        <th><label for="description"><?php _e( 'General Information' ); ?></label></th>
     92        <td><?php wp_editor( $news_user->description, 'description-1', array( 'textarea_name' => 'description' ) ); ?>
     93        <span class="description"><?php _e( 'Share a little biographical information to fill out your profile. This may be shown publicly.' ); ?></span></td>
    9394    </tr>
    9495    </table>
     
    102103
    103104function people_list_edit_user_profile_bio_init() {
    104     remove_all_filters('pre_user_description');
    105 }
    106 function people_list_edit_user_profile_bio_filter($bio){
    107     return apply_filters('the_content', $bio);
     105    remove_all_filters( 'pre_user_description' );
     106}
     107function people_list_edit_user_profile_bio_filter( $bio ) {
     108    return apply_filters( 'the_content', $bio );
    108109}
    109110
    110111/**
    111112 * people_lists_user_fields_filter function.
    112  * Description: Saves the list of fields added by user to Wordpress default fields in array user_contactmethods for
    113  *              displaying in the Your Profile section.
     113 * Description: Saves the list of fields added by user to WordPress default fields in array user_contactmethods for
     114 *              displaying in the Your Profile section.
     115 *
    114116 * @access public
    115117 * @param mixed $user_fields
    116118 * @return void
    117119 */
    118 function people_lists_user_fields_filter($user_fields)
    119 {
    120     $option_name = 'people-lists';
    121     $people_list_option = get_option($option_name);
    122 
    123     if( is_array($people_list_option['settings']) ):
    124         foreach ($people_list_option['settings'] as $index => $list){
    125              $user_field_added[$index] = stripslashes($list);
     120function people_lists_user_fields_filter( $user_fields ) {
     121    $option_name        = 'people-lists';
     122    $people_list_option = get_option( $option_name );
     123
     124    if ( is_array( $people_list_option['settings'] ) ) :
     125        foreach ( $people_list_option['settings'] as $index => $list ) {
     126            $user_field_added[ $index ] = stripslashes( $list );
    126127        }
    127128    endif;
    128129
    129     if(empty($people_list_option['settings'])){
     130    if ( empty( $people_list_option['settings'] ) ) {
    130131        return $user_fields;
    131     }
    132     else{
    133         return array_merge($user_field_added,$user_fields);
     132    } else {
     133        return array_merge( $user_field_added, $user_fields );
    134134    }
    135135}
     
    138138 * people_list_saving_settings function.
    139139 * Description: Storing the new fields information in the database and saving sorting of that list.
     140 *
    140141 * @access public
    141142 * @return void
     
    147148
    148149    $option_name = 'people-lists';
    149     $people_list = get_option($option_name);
    150 
    151     wp_parse_str( urldecode($_POST['field_info']), $field_info );
     150    $people_list = get_option( $option_name );
     151
     152    wp_parse_str( urldecode( $_POST['field_info'] ), $field_info );
    152153
    153154    $final_field_array = array();
    154     $count = 0;
    155 
    156     if( is_array($field_info['field_slug_list']) ):
    157         foreach($field_info['field_slug_list'] as $slug)
    158         {
    159             $final_field_array[$slug] = $field_info['field_name_list'][$count];
    160             $count++;
     155    $count             = 0;
     156
     157    if ( is_array( $field_info['field_slug_list'] ) ) :
     158        foreach ( $field_info['field_slug_list'] as $slug ) {
     159            $final_field_array[ $slug ] = $field_info['field_name_list'][ $count ];
     160            ++$count;
    161161        }
    162162    endif;
     
    164164    $people_list['settings'] = $final_field_array;
    165165
    166     update_option( $option_name, $people_list);
     166    update_option( $option_name, $people_list );
    167167}
    168168
     
    170170 * people_list_saving_list function.
    171171 * Description: Storing list information in the database for new and updated lists to track any sorting of the lists.
     172 *
    172173 * @access public
    173174 * @return void
     
    178179    }
    179180
    180     $option_name = 'people-lists';
     181    $option_name          = 'people-lists';
    181182    $people_list['lists'] = array();
    182     $people_list = get_option($option_name);
     183    $people_list          = get_option( $option_name );
    183184
    184185    wp_parse_str( $_POST['list'], $list );
    185186
    186 
    187     wp_parse_str($_POST['form'], $data);
     187    wp_parse_str( $_POST['form'], $data );
    188188
    189189    // set the list to be something nice
    190190    $data['list'] = $list;
    191191
    192     if(!is_numeric($data['avatar_size']))
     192    if ( ! is_numeric( $data['avatar_size'] ) ) {
    193193        $data['avatar_size'] = 96;
    194 
    195     if( is_numeric( $data['list_id'] ) ||  is_array( $people_list['lists'][$data['list_id']] )):
     194    }
     195
     196    if ( is_numeric( $data['list_id'] ) || is_array( $people_list['lists'][ $data['list_id'] ] ) ) :
    196197        // make sure that the slug is beeing passed on
    197         $data['slug'] = $people_list['lists'][$data['list_id']]['slug'];
    198         $people_list['lists'][$data['list_id']] = $data;
     198        $data['slug']                             = $people_list['lists'][ $data['list_id'] ]['slug'];
     199        $people_list['lists'][ $data['list_id'] ] = $data;
    199200        echo 'update';
    200     else:
     201    else :
    201202        $slug = people_lists_slug( $data['title'] );
    202203        // Check if the slug exists
    203204        $counter = 1;
    204         while( people_lists_slug_exists($slug,$people_list['lists']) )
    205         {
    206             $slug = people_lists_slug($data['title'])."-".$counter;
     205        while ( people_lists_slug_exists( $slug, $people_list['lists'] ) ) {
     206            $slug     = people_lists_slug( $data['title'] ) . '-' . $counter;
    207207            $counter += 1;
    208208        }
     
    213213    endif;
    214214
    215     update_option( $option_name, $people_list);
    216     die(); // thats it
     215    update_option( $option_name, $people_list );
     216    die(); // thats it
    217217}
    218218
     
    221221 * people_lists_slug function.
    222222 * Description: Creating a slug (shortcode list name) using the list name provided by the user.
     223 *
    223224 * @access public
    224225 * @param mixed $str
    225226 * @return void
    226227 */
    227 function people_lists_slug($str)
    228 {
    229     $str = strtolower(trim($str));
    230     $str = preg_replace('/[^a-z0-9-]/', '-', $str);
    231     $str = preg_replace('/-+/', "-", $str);
     228function people_lists_slug( $str ) {
     229    $str = strtolower( trim( $str ) );
     230    $str = preg_replace( '/[^a-z0-9-]/', '-', $str );
     231    $str = preg_replace( '/-+/', '-', $str );
    232232    return $str;
    233233}
     
    236236 * people_lists_slug_exists function.
    237237 * Description: Check if a slug (shortcode list name) exists.
     238 *
    238239 * @access public
    239240 * @param mixed $slug
     
    241242 * @return void
    242243 */
    243 function people_lists_slug_exists($slug,$people_list)
    244 {
    245     if( is_array($people_list) ):
    246         foreach($people_list as $list):
    247             if($list['slug'] == $slug)
     244function people_lists_slug_exists( $slug, $people_list ) {
     245    if ( is_array( $people_list ) ) :
     246        foreach ( $people_list as $list ) :
     247            if ( $list['slug'] == $slug ) {
    248248                return $list;
     249            }
    249250        endforeach;
    250251    endif;
     
    255256 * people_lists_field_slug_exists function.
    256257 * Description: Check if a field slug with that name exists.
     258 *
    257259 * @access public
    258260 * @param mixed $slug
     
    260262 * @return void
    261263 */
    262 function people_lists_field_slug_exists($field_slug,$people_list)
    263 {
    264     if( is_array($people_list) ):
    265         foreach($people_list as $fields):
    266             if($fields['field_slug'] == $field_slug)
     264function people_lists_field_slug_exists( $field_slug, $people_list ) {
     265    if ( is_array( $people_list ) ) :
     266        foreach ( $people_list as $fields ) :
     267            if ( $fields['field_slug'] == $field_slug ) {
    267268                return $fields;
     269            }
    268270        endforeach;
    269271    endif;
     
    276278 * people_lists_media_buttons function.
    277279 * add media buttons if they need to be there
     280 *
    278281 * @access public
    279282 * @return void
    280283 */
    281284function people_lists_media_buttons() {
    282         if ( !current_user_can( 'upload_files' ) ) return;
    283         echo '<div id="media-buttons-shell"><span id="media-buttons" class="hide-if-no-js" style="display:none">';
    284         do_action( 'media_buttons' );
    285         echo '</span></div>';
     285    if ( ! current_user_can( 'upload_files' ) ) {
     286        return;
     287    }
     288        echo '<div id="media-buttons-shell"><span id="media-buttons" class="hide-if-no-js" style="display:none">';
     289        do_action( 'media_buttons' );
     290        echo '</span></div>';
    286291}
    287292
     
    289294 * people_lists_tinymce_init_script function.
    290295 * Description: Calling the appropriate JS files to initialize tinyMCE on profile page.
    291  * @access public
    292  * @return void
    293  */
    294 function people_lists_tinymce_init_script(){
     296 *
     297 * @access public
     298 * @return void
     299 */
     300function people_lists_tinymce_init_script() {
    295301    // wp_enqueue_script('tiny_mce');
    296302    // add_action('admin_print_footer_scripts', 'wp_tiny_mce', 25 );
    297303
    298     wp_enqueue_script('people-lists-tinymce', plugins_url('/people-lists/js/people-lists-tinymce.js'),'jquery');
     304    wp_enqueue_script( 'people-lists-tinymce', plugins_url( '/people-lists/js/people-lists-tinymce.js' ), 'jquery' );
    299305
    300306    // add_filter( 'tiny_mce_before_init', 'people_lists_tiny_filter_remove_fullscreen');
     
    304310 * people_lists_tinymce_init_style function.
    305311 * Description: Calling the appropriate CSS files to initialize tinyMCE on profile page.
    306  * @access public
    307  * @return void
    308  */
    309 function people_lists_tinymce_init_style(){
     312 *
     313 * @access public
     314 * @return void
     315 */
     316function people_lists_tinymce_init_style() {
    310317    // wp_enqueue_style('people-lists-tinymce', plugins_url('/people-lists/css/people-lists-tinymce.css'),'css');
    311318}
     
    313320 * people_list_register_options_init function.
    314321 * Description: Registering People Lists Settings Page
    315  * @access public
    316  * @return void
    317  */
    318 function people_list_register_options_init(){
     322 *
     323 * @access public
     324 * @return void
     325 */
     326function people_list_register_options_init() {
    319327    register_setting( 'people_lists_options', 'people_lists', 'people_list_validate_admin_page' );
    320328
    321329    // set the language
    322     load_plugin_textdomain( 'people-list', false , basename( dirname( __FILE__ ) ) . '/languages' );
    323 
     330    load_plugin_textdomain( 'people-list', false, basename( __DIR__ ) . '/languages' );
    324331}
    325332
     
    327334 * people_list_options_init_style function.
    328335 * Description: Calling the appropriate CSS files to initialize functionality on the People Lists Settings page.
    329  * @access public
    330  * @return void
    331  */
    332 function people_list_options_init_style(){
    333     wp_enqueue_style('people-lists-style',  plugins_url('/people-lists/css/people-lists.css'),'css');
     336 *
     337 * @access public
     338 * @return void
     339 */
     340function people_list_options_init_style() {
     341    wp_enqueue_style( 'people-lists-style', plugins_url( '/people-lists/css/people-lists.css' ), 'css' );
    334342}
    335343/**
    336344 * people_list_options_init_script function.
    337345 * Description: Calling the appropriate JS files to initialize functionality on the People Lists Settings page.
    338  * @access public
    339  * @return void
    340  */
    341 function people_list_options_init_script(){
    342     wp_enqueue_script('people-lists', plugins_url('/people-lists/js/people-lists.js'), array('jquery','jquery-ui-tabs','jquery-ui-sortable'));
    343     }
     346 *
     347 * @access public
     348 * @return void
     349 */
     350function people_list_options_init_script() {
     351    wp_enqueue_script( 'people-lists', plugins_url( '/people-lists/js/people-lists.js' ), array( 'jquery', 'jquery-ui-tabs', 'jquery-ui-sortable' ) );
     352}
    344353
    345354
     
    347356 * people_list_options_add_page function.
    348357 * Description: Initialize People Lists Option page.
     358 *
    349359 * @access public
    350360 * @return void
    351361 */
    352362function people_list_options_add_page() {
    353     $page = add_options_page('People Lists', 'People Lists', 'manage_options', 'people_lists', 'people_list_admin_page');
    354      add_action('admin_print_styles-' . $page,'people_lists_admin_styles');
     363    $page = add_options_page( 'People Lists', 'People Lists', 'manage_options', 'people_lists', 'people_list_admin_page' );
     364    add_action( 'admin_print_styles-' . $page, 'people_lists_admin_styles' );
    355365}
    356366
     
    358368 * people_lists_admin_styles function.
    359369 * Description: JQuery Sortable initialization call.
     370 *
    360371 * @access public
    361372 * @return void
    362373 */
    363374function people_lists_admin_styles() {
    364      wp_enqueue_script('people-lists-jquery-sortable');
    365      wp_enqueue_script('people-lists');
    366      wp_enqueue_style( 'people-lists-style');
    367      wp_enqueue_script('jquery-ui-tabs');
     375    wp_enqueue_script( 'people-lists-jquery-sortable' );
     376    wp_enqueue_script( 'people-lists' );
     377    wp_enqueue_style( 'people-lists-style' );
     378    wp_enqueue_script( 'jquery-ui-tabs' );
    368379}
    369380
     
    372383 * people_lists_overlay_button function.
    373384 * Description: For adding the People Lists "Insert List" button to the pages & posts editing screens.
     385 *
    374386 * @access public
    375387 * @param mixed $context
    376388 * @return void
    377389 */
    378 function people_lists_overlay_button($context){
    379     $people_lists_overlay_image_button = plugins_url('/people-lists/img/form-button.png');
    380     $output_link = '<a href="#TB_inline?width=450&inlineId=people_lists_select_list_form" class="thickbox" id="add-people-list-button" title="' . __("Add People List", 'people-lists') . '"><img src="'.$people_lists_overlay_image_button.'" alt="' . __("Add People List", 'people-lists') . '" /></a>';
    381     return $context.$output_link;
     390function people_lists_overlay_button( $context ) {
     391    $people_lists_overlay_image_button = plugins_url( '/people-lists/img/form-button.png' );
     392    $output_link                       = '<a href="#TB_inline?width=450&inlineId=people_lists_select_list_form" class="thickbox" id="add-people-list-button" title="' . __( 'Add People List', 'people-lists' ) . '"><img src="' . $people_lists_overlay_image_button . '" alt="' . __( 'Add People List', 'people-lists' ) . '" /></a>';
     393    return $context . $output_link;
    382394}
    383395
     
    385397 * people_lists_overlay_popup_form function.
    386398 * Description: For displaying the overlay to insert a People List to the pages & posts editing screens.
    387  * @access public
    388  * @return void
    389  */
    390 function people_lists_overlay_popup_form(){
    391     $option_name = 'people-lists';
    392     $people_list_option = get_option($option_name);
    393     ?>
    394     <script>
    395         function people_lists_insert_overlay_form(){
    396             var people_lists_user_selection_list_value = jQuery("#people_lists_dropdown_selection option:selected").attr('value');
     399 *
     400 * @access public
     401 * @return void
     402 */
     403function people_lists_overlay_popup_form() {
     404    $option_name        = 'people-lists';
     405    $people_list_option = get_option( $option_name );
     406    ?>
     407    <script>
     408        function people_lists_insert_overlay_form(){
     409                var people_lists_user_selection_list_value = jQuery("#people_lists_dropdown_selection option:selected").attr('value');
    397410            if (people_lists_user_selection_list_value == "dropdown-first-option"){
    398                 alert("<?php _e('Please select a list.','people-list');?>");
     411                alert("<?php _e( 'Please select a list.', 'people-list' ); ?>");
    399412                return;
    400413            }
    401             var win = window.dialogArguments || opener || parent || top;
    402             win.send_to_editor("[people-lists list=" + people_lists_user_selection_list_value + "]");
    403         }
    404     </script>
    405 
    406     <div id="people_lists_select_list_form" style="display:none;">
    407         <div class="people_lists_select_list_form_wrap">
    408             <?php if(empty($people_list_option['lists'] )) : ?>
    409                 <div id="message" class="updated below-h2 clear"><p><?php _e('You currently have no lists. Go ahead and create one! Click','people-list');?> <a href="/wp-admin/options-general.php?page=people_lists"><?php _e('here','people-list');?></a>.</p></div>
    410             <?php else: ?>
    411             <div style="padding:15px 15px 0 15px;">
    412                 <h3 style="color:#5A5A5A!important; font-family:Georgia,Times New Roman,Times,serif!important; font-size:1.8em!important; font-weight:normal!important;"><?php _e("Insert A People List",'people-list');?></h3>
    413                 <span>
    414                     <?php _e("Select a list from the dropdown below to add it to your post or page.",'people-list');?>
    415                 </span>
    416             </div>
    417             <div style="padding:15px 15px 0 15px;">
    418                 <select id="people_lists_dropdown_selection">
    419                     <option value="dropdown-first-option">  <?php _e("Select a Form",'people-list');?>  </option>
    420                     <?php if( is_array($people_list_option['lists']) ):
    421                          foreach ($people_list_option['lists'] as $index =>$list_name): ?>
    422                             <option value="<?php echo $list_name['slug']; ?>"><?php echo esc_html($list_name['title']); ?></option>
    423                     <?php endforeach;
    424                     endif; ?>
    425                 </select> <br/>
    426 
    427             </div>
    428             <div style="padding:15px;">
    429                 <input type="button" class="button-primary" value="<?php _e('Insert People List','people-list');?>" onclick="people_lists_insert_overlay_form();"/>&nbsp;&nbsp;&nbsp;
    430                 <a class="button" style="color:#bbb;" href="#" onclick="tb_remove(); return false;"><?php _e("Cancel"); ?></a>
    431             </div>
    432 
    433             <?php endif; ?>
    434 
    435         </div>
    436     </div>
    437     <?php
     414            var win = window.dialogArguments || opener || parent || top;
     415            win.send_to_editor("[people-lists list=" + people_lists_user_selection_list_value + "]");
     416        }
     417    </script>
     418
     419    <div id="people_lists_select_list_form" style="display:none;">
     420        <div class="people_lists_select_list_form_wrap">
     421            <?php if ( empty( $people_list_option['lists'] ) ) : ?>
     422                <div id="message" class="updated below-h2 clear"><p><?php _e( 'You currently have no lists. Go ahead and create one! Click', 'people-list' ); ?> <a href="/wp-admin/options-general.php?page=people_lists"><?php _e( 'here', 'people-list' ); ?></a>.</p></div>
     423            <?php else : ?>
     424            <div style="padding:15px 15px 0 15px;">
     425                <h3 style="color:#5A5A5A!important; font-family:Georgia,Times New Roman,Times,serif!important; font-size:1.8em!important; font-weight:normal!important;"><?php _e( 'Insert A People List', 'people-list' ); ?></h3>
     426                <span>
     427                    <?php _e( 'Select a list from the dropdown below to add it to your post or page.', 'people-list' ); ?>
     428                </span>
     429            </div>
     430            <div style="padding:15px 15px 0 15px;">
     431                <select id="people_lists_dropdown_selection">
     432                    <option value="dropdown-first-option">  <?php _e( 'Select a Form', 'people-list' ); ?>  </option>
     433                    <?php
     434                    if ( is_array( $people_list_option['lists'] ) ) :
     435                        foreach ( $people_list_option['lists'] as $index => $list_name ) :
     436                            ?>
     437                            <option value="<?php echo $list_name['slug']; ?>"><?php echo esc_html( $list_name['title'] ); ?></option>
     438                            <?php
     439                    endforeach;
     440                    endif;
     441                    ?>
     442                </select> <br/>
     443
     444            </div>
     445            <div style="padding:15px;">
     446                <input type="button" class="button-primary" value="<?php _e( 'Insert People List', 'people-list' ); ?>" onclick="people_lists_insert_overlay_form();"/>&nbsp;&nbsp;&nbsp;
     447                    <a class="button" style="color:#bbb;" href="#" onclick="tb_remove(); return false;"><?php _e( 'Cancel' ); ?></a>
     448            </div>
     449
     450            <?php endif; ?>
     451
     452        </div>
     453    </div>
     454    <?php
    438455}
    439456
     
    441458 * people_list_admin_page function.
    442459 * Description: HTML layout creation of the admin page and building/calling different panels (create/edit/manage).
     460 *
    443461 * @access public
    444462 * @return void
     
    446464function people_list_admin_page() {
    447465
    448     $people_list_option = get_option('people-lists');
     466    $people_list_option = get_option( 'people-lists' );
    449467
    450468    if ( isset( $_GET['delete'] ) && is_numeric( $_GET['delete'] ) ) :
    451         unset($people_list_option['lists'][$_GET['delete']]);
    452         update_option( 'people-lists', $people_list_option);
     469        unset( $people_list_option['lists'][ $_GET['delete'] ] );
     470        update_option( 'people-lists', $people_list_option );
    453471    endif;
    454472
    455     if ( isset( $_GET['delete-all'] ) )
    456         delete_option('people-lists');
     473    if ( isset( $_GET['delete-all'] ) ) {
     474        delete_option( 'people-lists' );
     475    }
    457476    ?>
    458477    <div class="wrap" id="people-list-page">
    459         <h2 id="people-list-header"><?php _e('People Lists','people-list');?></h2>
    460         <?php if ( ( isset( $_GET['panel'] ) && $_GET['panel']=="create" ) || empty( $people_list_option['lists']) || ! isset($_GET['panel'] ) ) :
    461 
    462         else: ?>
    463             <a href="options-general.php?page=people_lists&panel=create" class="button"><?php _e('Add New People List','people-list');?></a>
    464 
    465         <?php endif;
    466 
    467         if(empty($people_list_option['lists'] )) : ?>
    468             <div id="message" class="updated below-h2 clear"><p><?php _e('You currently have no lists. Go ahead and create one!','people-list');?></p></div>
    469 
    470         <?php else: ?>
     478        <h2 id="people-list-header"><?php _e( 'People Lists', 'people-list' ); ?></h2>
     479        <?php
     480        if ( ( isset( $_GET['panel'] ) && $_GET['panel'] == 'create' ) || empty( $people_list_option['lists'] ) || ! isset( $_GET['panel'] ) ) :
     481
     482        else :
     483            ?>
     484            <a href="options-general.php?page=people_lists&panel=create" class="button"><?php _e( 'Add New People List', 'people-list' ); ?></a>
     485
     486            <?php
     487        endif;
     488
     489        if ( empty( $people_list_option['lists'] ) ) :
     490            ?>
     491            <div id="message" class="updated below-h2 clear"><p><?php _e( 'You currently have no lists. Go ahead and create one!', 'people-list' ); ?></p></div>
     492
     493        <?php else : ?>
    471494            <ul id="people-list-manage">
    472                 <li><a href="options-general.php?page=people_lists&panel=manage"><?php _e('View All Lists','people-list');?></a>
     495                <li><a href="options-general.php?page=people_lists&panel=manage"><?php _e( 'View All Lists', 'people-list' ); ?></a>
    473496                <ul>
    474                 <?php if( is_array($people_list_option['lists']) ):
    475                     foreach($people_list_option['lists'] as $index =>$list): ?>
     497                <?php
     498                if ( is_array( $people_list_option['lists'] ) ) :
     499                    foreach ( $people_list_option['lists'] as $index => $list ) :
     500                        ?>
    476501                    <li>
    477                         <a href="options-general.php?page=people_lists&panel=edit&list_id=<?php echo $index;?>"><?php echo $list['title']; ?></a>
     502                        <a href="options-general.php?page=people_lists&panel=edit&list_id=<?php echo $index; ?>"><?php echo $list['title']; ?></a>
    478503                    </li>
    479                 <?php endforeach;
    480                 endif; ?>
     504                        <?php
     505                endforeach;
     506                endif;
     507                ?>
    481508                </ul>
    482509                </li>
     
    485512            <ul id="people-list-settings">
    486513                <li>
    487                     <a href="options-general.php?page=people_lists&panel=settings" id="people-lists-settings-link"><?php _e('Profile Settings','people-list');?></a> <span> <?php _e('add new fields to the user profile','people-list');?></span>
     514                    <a href="options-general.php?page=people_lists&panel=settings" id="people-lists-settings-link"><?php _e( 'Profile Settings', 'people-list' ); ?></a> <span> <?php _e( 'add new fields to the user profile', 'people-list' ); ?></span>
    488515                </li>
    489516            </ul>
    490517
    491         <?php endif;
    492 
    493         if( empty($people_list_option['lists']) ):
    494             require_once('views/create.php');
    495         else:
    496             switch($_GET['panel']) {
    497                 case "create":
    498                     require_once('views/create.php');
    499                 break;
    500 
    501                 case "edit":
    502                     if( is_numeric( $_GET['list_id'] ) && $people_list_option['lists'][$_GET['list_id']] ):
     518            <?php
     519        endif;
     520
     521        if ( empty( $people_list_option['lists'] ) ) :
     522            require_once 'views/create.php';
     523        else :
     524            switch ( $_GET['panel'] ) {
     525                case 'create':
     526                    require_once 'views/create.php';
     527                    break;
     528
     529                case 'edit':
     530                    if ( is_numeric( $_GET['list_id'] ) && $people_list_option['lists'][ $_GET['list_id'] ] ) :
    503531                        $list_id = $_GET['list_id'];
    504                         $list = $people_list_option['lists'][$_GET['list_id']];
    505                         require_once('views/edit.php');
    506                     else:
    507                         require_once('views/create.php');
     532                        $list    = $people_list_option['lists'][ $_GET['list_id'] ];
     533                        require_once 'views/edit.php';
     534                    else :
     535                        require_once 'views/create.php';
    508536                    endif;
    509                 break;
    510 
    511                 case "manage":
    512                     require_once('views/manage.php');
    513                 break;
    514 
    515                 case "settings":
    516                     require_once('views/settings.php');
    517                 break;
     537                    break;
     538
     539                case 'manage':
     540                    require_once 'views/manage.php';
     541                    break;
     542
     543                case 'settings':
     544                    require_once 'views/settings.php';
     545                    break;
    518546
    519547                default:
    520                     require_once('views/create.php');
    521                 break;
     548                    require_once 'views/create.php';
     549                    break;
    522550            }
    523551        endif;
    524552        ?>
    525553    </div>
    526 <?php
     554    <?php
    527555}
    528556
     
    530558 * people_list_validate_admin_page function.
    531559 * Description: Sanitizes and validates an inputted array.
     560 *
    532561 * @access public
    533562 * @param mixed $input
    534563 * @return void
    535564 */
    536 function people_list_validate_admin_page($input) {
     565function people_list_validate_admin_page( $input ) {
    537566    return $input;
    538567}
     
    542571 * Description: Building of form users interact with, including a name field, a modifiable people lists profile display
    543572 *              template and jQuery Sortable lists that allow for dragging and dropping of users for a specific list.
     573 *
    544574 * @access public
    545575 * @param bool $list_id. (default: false)
     
    547577 * @return void
    548578 */
    549 function people_list_form($list_id=false,$list=false)
    550 {
    551     $users_of_blog = get_users_of_blog();
    552     $option_name = 'people-lists';
    553     $people_list_option = get_option($option_name);
    554 
    555     if(empty($list['list']['uid']))
     579function people_list_form( $list_id = false, $list = false ) {
     580    $users_of_blog      = get_users_of_blog();
     581    $option_name        = 'people-lists';
     582    $people_list_option = get_option( $option_name );
     583
     584    if ( empty( $list['list']['uid'] ) ) {
    556585        $list['list']['uid'] = array();
     586    }
    557587
    558588    if ( ! isset( $list['title'] ) ) {
     
    560590    }
    561591
    562     if ( ! isset ( $list['avatar_size'] ) ) {
     592    if ( ! isset( $list['avatar_size'] ) ) {
    563593        $list['avatar_size'] = '';
    564594    }
     
    567597    <div id="people-list-form-shell">
    568598        <form method="post" id="people-list-form" action="options.php">
    569         <label for="title"><?php _e('Name','people-list');?></label><br />
    570         <input type="text" value="<?php echo $list['title'];?>" name="title" id="title" size="50" />
    571         <p><?php _e('The name helps identify which list you are editing.','people-list');?></p>
    572 
    573         <a id="template-link" href="#"><?php _e('Template Info','people-list');?></a>
     599        <label for="title"><?php _e( 'Name', 'people-list' ); ?></label><br />
     600        <input type="text" value="<?php echo $list['title']; ?>" name="title" id="title" size="50" />
     601        <p><?php _e( 'The name helps identify which list you are editing.', 'people-list' ); ?></p>
     602
     603        <a id="template-link" href="#"><?php _e( 'Template Info', 'people-list' ); ?></a>
    574604        <div class="template-info" id="template-info" >
    575             <label id="avatar_size_label"><?php _e('User Picture size:','people-list');?> <input type="text" id="avatar_size" value="<?php echo $list['avatar_size'];?>" name="avatar_size" size="3" />px <span><?php _e('the size of the image that is created when %thumbnail% is called in the template.','people-list');?></span></label>
     605            <label id="avatar_size_label"><?php _e( 'User Picture size:', 'people-list' ); ?> <input type="text" id="avatar_size" value="<?php echo $list['avatar_size']; ?>" name="avatar_size" size="3" />px <span><?php _e( 'the size of the image that is created when %thumbnail% is called in the template.', 'people-list' ); ?></span></label>
    576606
    577607            <div class="template-tabbed">
     
    579609                <div class="template-area">
    580610                    <ul class="template-tabs">
    581                         <li><a href="#default_codes" title="Default Codes" class="tabbed"><?php _e('Default Codes','people-list');?></a></li>
    582                         <li><a href="#added_fields" title="Added Fields" class="tabbed" ><?php _e('Added Fields Codes','people-list');?></a></li>
    583                         <li><a href="#before_after" title="Added Fields" class="tabbed" ><?php _e('Before & After','people-list');?></a></li>
     611                        <li><a href="#default_codes" title="Default Codes" class="tabbed"><?php _e( 'Default Codes', 'people-list' ); ?></a></li>
     612                        <li><a href="#added_fields" title="Added Fields" class="tabbed" ><?php _e( 'Added Fields Codes', 'people-list' ); ?></a></li>
     613                        <li><a href="#before_after" title="Added Fields" class="tabbed" ><?php _e( 'Before & After', 'people-list' ); ?></a></li>
    584614                    </ul>
    585615                    <div id="default_codes" class="template-content">
    586                         <strong><?php _e('Default codes you can use are:','people-list');?> </strong>
    587                         <ul>
    588                             <li>%nickname% - <?php _e('To display nickname','people-list');?> </li>
    589                             <li>%email%    - <?php _e('To display email','people-list');?> </li>
    590                             <li>%bio%      - <?php _e('To display user rich-text info from profile','people-list');?> </li>
    591                             <li>%firstname%     - <?php _e('To display first name','people-list');?> </li>
    592                             <li>%lastname%      - <?php _e('To display last name','people-list');?> </li>
    593                             <li>%username%      - <?php _e('To display username','people-list');?> </li>
    594                             <li>%thumbnail% - <?php _e('To display user\'s thumbnail photo','people-list');?> </li>
    595                             <li>%website% - <?php _e('To display user\'s website','people-list');?> </li>
    596                             <li>%aim% - <?php _e('To display user\'s website','people-list');?> </li>
    597                             <li>%yahooim% - <?php _e('To display user\'s website','people-list');?> </li>
    598                             <li>%jabbergoogle% - <?php _e('To display user\'s website','people-list');?> </li>
    599                             <li>%id% - <?php _e('To display the user id','people-list');?></li>
    600                             <li>%authorurl% <?php _e('To display the link url to this users posts','people-list');?></li>
     616                            <strong><?php _e( 'Default codes you can use are:', 'people-list' ); ?> </strong>
     617                            <ul>
     618                                <li>%nickname% - <?php _e( 'To display nickname', 'people-list' ); ?> </li>
     619                            <li>%email%    - <?php _e( 'To display email', 'people-list' ); ?> </li>
     620                            <li>%bio%      - <?php _e( 'To display user rich-text info from profile', 'people-list' ); ?> </li>
     621                            <li>%firstname%     - <?php _e( 'To display first name', 'people-list' ); ?> </li>
     622                            <li>%lastname%      - <?php _e( 'To display last name', 'people-list' ); ?> </li>
     623                            <li>%username%      - <?php _e( 'To display username', 'people-list' ); ?> </li>
     624                            <li>%thumbnail% - <?php _e( 'To display user\'s thumbnail photo', 'people-list' ); ?> </li>
     625                            <li>%website% - <?php _e( 'To display user\'s website', 'people-list' ); ?> </li>
     626                            <li>%aim% - <?php _e( 'To display user\'s website', 'people-list' ); ?> </li>
     627                            <li>%yahooim% - <?php _e( 'To display user\'s website', 'people-list' ); ?> </li>
     628                            <li>%jabbergoogle% - <?php _e( 'To display user\'s website', 'people-list' ); ?> </li>
     629                            <li>%id% - <?php _e( 'To display the user id', 'people-list' ); ?></li>
     630                            <li>%authorurl% <?php _e( 'To display the link url to this users posts', 'people-list' ); ?></li>
    601631                        </ul>
    602632                    </div>
    603633                    <div id="added_fields" class="template-content">
    604                         <strong><?php _e('Codes that you have added are:','people-list');?></strong>
     634                        <strong><?php _e( 'Codes that you have added are:', 'people-list' ); ?></strong>
    605635                        <ul>
    606636                        <?php
    607                          if( is_array($people_list_option['settings']) ):
    608                             foreach ($people_list_option['settings'] as $index => $field_slug): ?>
     637                        if ( is_array( $people_list_option['settings'] ) ) :
     638                            foreach ( $people_list_option['settings'] as $index => $field_slug ) :
     639                                ?>
    609640                                <li class="template-code-list">%<?php echo $index; ?>%</li>
    610                         <?php endforeach;
     641                                <?php
     642                        endforeach;
    611643                            $filter_array = array();
    612                             $filter_array =  apply_filters('people_list_custom_fields',$filter_array);
    613 
    614                             foreach ( $filter_array as $item):
    615                                 echo '<li class="template-code-list">'.$item.'</li>';
     644                            $filter_array = apply_filters( 'people_list_custom_fields', $filter_array );
     645
     646                            foreach ( $filter_array as $item ) :
     647                                echo '<li class="template-code-list">' . $item . '</li>';
    616648                            endforeach;
    617649
    618                         endif; ?>
     650                        endif;
     651                        ?>
    619652                        </ul>
    620653                    </div>
     
    623656                            <li id="header-before-after"><span >before</span><span class='after-item'>after</span></li>
    624657                            <?php
    625                             foreach(array('nickname','email','bio','firstname','lastname','username','thumbnail','website','aim','yahooim','jabbergoogle','id','authorurl') as $item):
    626                                 $before = ( isset($list['before'][$item]) ? $list['before'][$item]: '' );
    627                                 $after  = ( isset($list['after'][$item]) ? $list['after'][$item]: '' );
    628                                 people_lists_before_after_item($item,$before,$after,$item);
     658                            foreach ( array( 'nickname', 'email', 'bio', 'firstname', 'lastname', 'username', 'thumbnail', 'website', 'aim', 'yahooim', 'jabbergoogle', 'id', 'authorurl' ) as $item ) :
     659                                $before = ( isset( $list['before'][ $item ] ) ? $list['before'][ $item ] : '' );
     660                                $after  = ( isset( $list['after'][ $item ] ) ? $list['after'][ $item ] : '' );
     661                                people_lists_before_after_item( $item, $before, $after, $item );
    629662                            endforeach;
    630663                            $item = null;
    631664                            if ( is_array( $people_list_option['settings'] ) ) {
    632                                 foreach ($people_list_option['settings'] as $item => $field_slug):
    633                                     $before = ( isset($list['before'][$item]) ? $list['before'][$item]: '' );
    634                                     $after  = ( isset($list['after'][$item]) ? $list['after'][$item]: '' );
     665                                foreach ( $people_list_option['settings'] as $item => $field_slug ) :
     666                                    $before = ( isset( $list['before'][ $item ] ) ? $list['before'][ $item ] : '' );
     667                                    $after  = ( isset( $list['after'][ $item ] ) ? $list['after'][ $item ] : '' );
    635668                                    people_lists_before_after_item( $field_slug, $before, $after, $item );
    636669                                endforeach;
    637670                            }
    638671
    639                             $item = null;
     672                            $item         = null;
    640673                            $filter_array = array();
    641                             $filter_array =  apply_filters('people_list_custom_fields',$filter_array);
    642                             if(is_array($filter_array)):
    643                                 foreach ( $filter_array as $item):
    644                                     $before = ( isset($list['before'][$item]) ? $list['before'][$item]: '' );
    645                                     $after  = ( isset($list['after'][$item]) ? $list['after'][$item]: '' );
     674                            $filter_array = apply_filters( 'people_list_custom_fields', $filter_array );
     675                            if ( is_array( $filter_array ) ) :
     676                                foreach ( $filter_array as $item ) :
     677                                    $before = ( isset( $list['before'][ $item ] ) ? $list['before'][ $item ] : '' );
     678                                    $after  = ( isset( $list['after'][ $item ] ) ? $list['after'][ $item ] : '' );
    646679                                    people_lists_before_after_item( $item, $before, $after, $item );
    647680                                endforeach;
     
    653686                </div>
    654687            </div>
    655             <textarea name="template" class="template-text" id="template-text"><?php
    656                 if( !empty($list['template']) )
    657                     echo  stripslashes(trim($list['template']));
    658                 else
    659                     echo people_lists_default_template(); ?>
     688            <textarea name="template" class="template-text" id="template-text">
     689            <?php
     690            if ( ! empty( $list['template'] ) ) {
     691                echo stripslashes( trim( $list['template'] ) );
     692            } else {
     693                echo people_lists_default_template();
     694            }
     695            ?>
    660696            </textarea><br />
    661697
     
    663699
    664700        <div id="availableList" class="listDiv">
    665             <h4><?php _e('Available People','people-list');?></h4>
    666             <p><?php _e('List of users that have not been selected to be in your list.
    667             Drag and drop the a person into the selected people area.','people-list');?></p>
     701            <h4><?php _e( 'Available People', 'people-list' ); ?></h4>
     702            <p>
     703            <?php
     704            _e(
     705                'List of users that have not been selected to be in your list.
     706            Drag and drop the a person into the selected people area.',
     707                'people-list'
     708            );
     709            ?>
     710                </p>
    668711            <ul id="sortable1" class='droptrue'>
    669             <?php if( is_array($users_of_blog) ):
    670                 foreach($users_of_blog as $person):
    671                     if(!in_array($person->ID, $list['list']['uid'])): ?>
     712            <?php
     713            if ( is_array( $users_of_blog ) ) :
     714                foreach ( $users_of_blog as $person ) :
     715                    if ( ! in_array( $person->ID, $list['list']['uid'] ) ) :
     716                        ?>
    672717                        <li class="ui-state-default ui-state-default-list" id="uid_<?php echo $person->ID; ?>">
    673                         <?php echo get_avatar($person->ID, 32); ?>
     718                        <?php echo get_avatar( $person->ID, 32 ); ?>
    674719                        <?php echo $person->display_name; ?><span><?php echo $person->user_email; ?></span></li>
    675                     <?php else:
    676                         $selected_people[$person->ID] = $person;
     720                        <?php
     721                    else :
     722                        $selected_people[ $person->ID ] = $person;
    677723                        endif;
    678724                endforeach;
    679             endif; ?>
     725            endif;
     726            ?>
    680727            </ul>
    681728        </div>
    682729
    683730        <div id="selectedUserList" class="listDiv">
    684             <h4><?php _e('Selected People','people-list');?></h4> <a href="#" id="selected-lock"><?php _e('Pin','people-list');?></a>
    685             <p><?php _e('List of users that are have been selected to be in your list. Drag and drop a person into the available people area to remove them.','people-list');?></p>
     731            <h4><?php _e( 'Selected People', 'people-list' ); ?></h4> <a href="#" id="selected-lock"><?php _e( 'Pin', 'people-list' ); ?></a>
     732            <p><?php _e( 'List of users that are have been selected to be in your list. Drag and drop a person into the available people area to remove them.', 'people-list' ); ?></p>
    686733            <ul id="sortable2" class='droptrue clear'>
    687             <?php if( is_array($list['list']['uid']) ):
    688                 foreach(  $list['list']['uid'] as $person_id ): ?>
    689                     <li class="ui-state-default ui-state-default-list" id="uid_<?php echo $selected_people[$person_id]->ID; ?>">
    690                     <?php echo get_avatar($selected_people[$person_id]->ID, 32); ?>
    691                     <?php echo $selected_people[$person_id]->display_name; ?><span><?php echo $selected_people[$person_id]->user_email; ?></span></li>
    692             <?php endforeach;
    693             endif;?>
     734            <?php
     735            if ( is_array( $list['list']['uid'] ) ) :
     736                foreach ( $list['list']['uid'] as $person_id ) :
     737                    ?>
     738                    <li class="ui-state-default ui-state-default-list" id="uid_<?php echo $selected_people[ $person_id ]->ID; ?>">
     739                    <?php echo get_avatar( $selected_people[ $person_id ]->ID, 32 ); ?>
     740                    <?php echo $selected_people[ $person_id ]->display_name; ?><span><?php echo $selected_people[ $person_id ]->user_email; ?></span></li>
     741                    <?php
     742            endforeach;
     743            endif;
     744            ?>
    694745            </ul>
    695746        </div>
    696747
    697748        <p class="submit clear">
    698         <?php if(is_numeric($list_id)): ?>
    699             <input type="hidden" value="<?php echo esc_attr($list_id);?>" name="list_id" id="list-id" />
    700             <input id="submit-people-list" type="submit" class="button-primary" value="<?php _e('Update Changes','people-list');?>" />
    701         <?php else: ?>
    702             <input id="submit-people-list" type="submit" class="button-primary" value="<?php _e('Add List','people-list');?>" />
     749        <?php if ( is_numeric( $list_id ) ) : ?>
     750            <input type="hidden" value="<?php echo esc_attr( $list_id ); ?>" name="list_id" id="list-id" />
     751            <input id="submit-people-list" type="submit" class="button-primary" value="<?php _e( 'Update Changes', 'people-list' ); ?>" />
     752        <?php else : ?>
     753            <input id="submit-people-list" type="submit" class="button-primary" value="<?php _e( 'Add List', 'people-list' ); ?>" />
    703754        <?php endif; ?>
    704             <img src="<?php bloginfo('url'); ?>/wp-admin/images/wpspin_light.gif" id="ajax-response" />
     755            <img src="<?php bloginfo( 'url' ); ?>/wp-admin/images/wpspin_light.gif" id="ajax-response" />
    705756        </p>
    706757        </form>
    707758    </div>
    708 <?php
     759    <?php
    709760}
    710761
     
    712763 * people_list_field_form function.
    713764 * Description: Building of form users interact with to add fields that are inserted into a jQuery Sortable list that allows
    714  *              for sorting and lists the field name, the template code that goes along with that field and an option for
    715  *              deletion of added fields.
    716  * @access public
    717  * @return void
    718  */
    719 function people_list_field_form(){
    720     $option_name = 'people-lists';
    721     $people_list_option = get_option($option_name);
    722 
    723 ?>
     765 *              for sorting and lists the field name, the template code that goes along with that field and an option for
     766 *              deletion of added fields.
     767 *
     768 * @access public
     769 * @return void
     770 */
     771function people_list_field_form() {
     772    $option_name        = 'people-lists';
     773    $people_list_option = get_option( $option_name );
     774
     775    ?>
    724776    <div id="contact-info-shell">
    725         <label for="contact-info-field"><?php _e('Name of new field','people-list');?></label><br />
     777        <label for="contact-info-field"><?php _e( 'Name of new field', 'people-list' ); ?></label><br />
    726778        <input type="text" name="contact-info-field" id="contact-info-field" size="30" />
    727779
    728780        <p class="submit">
    729             <input type="submit" id="add-field-button" class="button-secondary" value="<?php _e('Add Field') ?>" />
    730             <img src="<?php bloginfo('url'); ?>/wp-admin/images/wpspin_light.gif" id="ajax-response2" />
     781            <input type="submit" id="add-field-button" class="button-secondary" value="<?php _e( 'Add Field' ); ?>" />
     782            <img src="<?php bloginfo( 'url' ); ?>/wp-admin/images/wpspin_light.gif" id="ajax-response2" />
    731783        </p>
    732784
    733         <p><?php _e('This name should be a one or two word description of your new field. (eg. Position, Location, etc.)','people-list');?></p><br />
    734         <p><?php _e('List of fields that are being added to contact info section in your profile. <br/> Drag & Drop to change the order of their display in Your Profile.','people-list');?></p><br />
     785        <p><?php _e( 'This name should be a one or two word description of your new field. (eg. Position, Location, etc.)', 'people-list' ); ?></p><br />
     786        <p><?php _e( 'List of fields that are being added to contact info section in your profile. <br/> Drag & Drop to change the order of their display in Your Profile.', 'people-list' ); ?></p><br />
    735787        <form id="profile-field-form">
    736788            <ul id="sortable-profile-field">
    737             <?php if( is_array($people_list_option['settings']) ):
    738                 foreach ($people_list_option['settings'] as $index => $field_slug):?>
    739                     <li class="ui-state-default ui-state-default-list" ><?php echo stripslashes($field_slug); ?><span><?php _e('Template Code','people-list');?>: %<?php echo $index; ?>%<br /><a href="#" class="delete-field-link"><?php _e('Delete','people-list');?></a></span>
     789            <?php
     790            if ( is_array( $people_list_option['settings'] ) ) :
     791                foreach ( $people_list_option['settings'] as $index => $field_slug ) :
     792                    ?>
     793                    <li class="ui-state-default ui-state-default-list" ><?php echo stripslashes( $field_slug ); ?><span><?php _e( 'Template Code', 'people-list' ); ?>: %<?php echo $index; ?>%<br /><a href="#" class="delete-field-link"><?php _e( 'Delete', 'people-list' ); ?></a></span>
    740794                        <input type="hidden" value="<?php echo $index; ?>" name="field_slug_list[]" />
    741                         <input type="hidden" value="<?php echo stripslashes($field_slug); ?>" name="field_name_list[]" />
     795                        <input type="hidden" value="<?php echo stripslashes( $field_slug ); ?>" name="field_name_list[]" />
    742796                    </li>
    743             <?php endforeach;
    744             endif; ?>
     797                    <?php
     798            endforeach;
     799            endif;
     800            ?>
    745801            </ul>
    746802        </form>
    747803    </div>
    748 <?php
    749 }
    750 
    751 function people_lists_before_after_item($item = null, $before_value=null,$after_value=null,$id=null)
    752 {
    753     if( isset($item) ):
    754 
    755     ?>
     804    <?php
     805}
     806
     807function people_lists_before_after_item( $item = null, $before_value = null, $after_value = null, $id = null ) {
     808    if ( isset( $item ) ) :
     809
     810        ?>
    756811    <li class="before-after-item">
    757         <input type="text" name="before[<?php echo $id; ?>]" value="<?php echo esc_attr($before_value); ?>" class="before-item" />
     812        <input type="text" name="before[<?php echo $id; ?>]" value="<?php echo esc_attr( $before_value ); ?>" class="before-item" />
    758813        <span class="before-after-item-label"><?php echo $item; ?></span>
    759         <input type="text"  name="after[<?php echo $id; ?>]" value="<?php echo esc_attr($after_value); ?>" class="after-item" />
     814        <input type="text"  name="after[<?php echo $id; ?>]" value="<?php echo esc_attr( $after_value ); ?>" class="after-item" />
    760815    </li>
    761     <?php endif;
     816        <?php
     817    endif;
    762818}
    763819/**
    764820 * people_lists_default_template function.
    765821 * Description: Display the default template, which includes a thumbnail, nickname, email and user's bio from their "Your
    766  *              Profile" tab.
    767  * @access public
    768  * @return void
    769  */
    770 function people_lists_default_template()
    771 {
    772     $html  =    "<div class ='user-thumbnail'>%thumbnail%</div> \n";
    773     $html .=    "<div class ='user-info'>%nickname%</div> \n";
    774     $html .=    "<div class ='user-info'>%email%</div> \n";
    775     $html .=    "<div class ='user-bio'>%bio%</div> \n";
     822 *              Profile" tab.
     823 *
     824 * @access public
     825 * @return void
     826 */
     827function people_lists_default_template() {
     828    $html  = "<div class ='user-thumbnail'>%thumbnail%</div> \n";
     829    $html .= "<div class ='user-info'>%nickname%</div> \n";
     830    $html .= "<div class ='user-info'>%email%</div> \n";
     831    $html .= "<div class ='user-bio'>%bio%</div> \n";
    776832
    777833    return $html;
     
    781837 * people_lists_shortcode function.
    782838 * Description: Creation of the [people-lists list=example-list] shortcode and conversion of the template codes into the
    783  *              selected display option selected by the user.
     839 *              selected display option selected by the user.
     840 *
    784841 * @access public
    785842 * @param mixed $atts
    786843 * @return void
    787844 */
    788 function people_lists_shortcode($atts) {
    789 
    790     $option_name = 'people-lists';
    791     $people_list_option = get_option($option_name);
    792 
    793     extract(shortcode_atts(array(
    794         'list' => null,
    795             ), $atts));
    796     if( !isset($list) )
    797         return "Empty list - Please remove the [people-lists] code.";
    798 
     845function people_lists_shortcode( $atts ) {
     846
     847    $option_name        = 'people-lists';
     848    $people_list_option = get_option( $option_name );
     849
     850    extract(
     851        shortcode_atts(
     852            array(
     853                'list' => null,
     854            ),
     855            $atts
     856        )
     857    );
     858    if ( ! isset( $list ) ) {
     859        return 'Empty list - Please remove the [people-lists] code.';
     860    }
    799861
    800862    // $people_lists = get_option('people-lists');
    801     $found_people_list = people_lists_slug_exists($list,$people_list_option['lists']);
    802 
    803     if(!$found_people_list)
    804         return "This list is non-existent - Please remove the [people-lists list=".$list."] code.";
    805 
    806     $users_of_blog = get_users_of_blog();
     863    $found_people_list = people_lists_slug_exists( $list, $people_list_option['lists'] );
     864
     865    if ( ! $found_people_list ) {
     866        return 'This list is non-existent - Please remove the [people-lists list=' . $list . '] code.';
     867    }
     868
     869    $users_of_blog  = get_users_of_blog();
    807870    $input_template = array();
    808871
    809     $input_template[0] = "%nickname%";
    810     $input_template[1] = "%email%";
    811     $input_template[2] = "%bio%";
    812     $input_template[3] = "%firstname%";
    813     $input_template[4] = "%lastname%";
    814     $input_template[5] = "%username%";
    815     $input_template[6] = "%thumbnail%";
    816     $input_template[7] = "%website%";
    817     $input_template[8] = "%aim%";
    818     $input_template[9] = "%yahooim%";
    819     $input_template[10] = "%jabbergoogle%";
    820     $input_template[11] = "%id%";
    821     $input_template[12] = "%authorurl%";
     872    $input_template[0]  = '%nickname%';
     873    $input_template[1]  = '%email%';
     874    $input_template[2]  = '%bio%';
     875    $input_template[3]  = '%firstname%';
     876    $input_template[4]  = '%lastname%';
     877    $input_template[5]  = '%username%';
     878    $input_template[6]  = '%thumbnail%';
     879    $input_template[7]  = '%website%';
     880    $input_template[8]  = '%aim%';
     881    $input_template[9]  = '%yahooim%';
     882    $input_template[10] = '%jabbergoogle%';
     883    $input_template[11] = '%id%';
     884    $input_template[12] = '%authorurl%';
    822885
    823886    $counter = 13;
    824     if( is_array($people_list_option['settings']) ):
    825         foreach($people_list_option['settings'] as $index => $field_slug):
    826             $input_template[$counter] = "%".$index."%";
    827             $counter++;
     887    if ( is_array( $people_list_option['settings'] ) ) :
     888        foreach ( $people_list_option['settings'] as $index => $field_slug ) :
     889            $input_template[ $counter ] = '%' . $index . '%';
     890            ++$counter;
    828891        endforeach;
    829892    endif;
    830     $input_template = apply_filters('people_list_custom_fields',$input_template);
    831     if( is_array($found_people_list['list']['uid']) ):
    832         foreach($found_people_list['list']['uid'] as $id):
     893    $input_template = apply_filters( 'people_list_custom_fields', $input_template );
     894    if ( is_array( $found_people_list['list']['uid'] ) ) :
     895        foreach ( $found_people_list['list']['uid'] as $id ) :
    833896            $replacements = array();
    834             $user_data = get_userdata($id);
    835 
    836             $replacements[0] = ( !empty($user_data->nickname) ?     $found_people_list['before']['nickname']. $user_data->nickname.         $found_people_list['after']['nickname']:"");
    837             $replacements[1] = ( !empty($user_data->user_email) ?   $found_people_list['before']['email'].   $user_data->user_email.    $found_people_list['after']['email']:"");
    838             $replacements[2] = ( !empty($user_data->description) ?  $found_people_list['before']['bio'].         $user_data->description.   $found_people_list['after']['bio']:"");
    839             $replacements[3] = ( !empty($user_data->first_name) ?   $found_people_list['before']['firstname'].$user_data->first_name.   $found_people_list['after']['firstname']:"");
    840             $replacements[4] = ( !empty($user_data->last_name) ?    $found_people_list['before']['lastname']. $user_data->last_name.    $found_people_list['after']['lastname']:"");
    841             $replacements[5] = ( !empty($user_data->user_login) ?   $found_people_list['before']['username']. $user_data->user_login.   $found_people_list['after']['username']:"");
    842             $replacements[6] = $found_people_list['before']['thumbnail'].get_avatar($id,$found_people_list['avatar_size']). $found_people_list['after']['thumbnail'];
    843             $replacements[7] = ( !empty($user_data->user_url) ?     $found_people_list['before']['website'].     $user_data->user_url.      $found_people_list['after']['website']:"");
    844             $replacements[8] = ( !empty($user_data->aim) ?          $found_people_list['before']['aim'].         $user_data->aim.           $found_people_list['after']['aim']:"");
    845             $replacements[9] = ( !empty($user_data->yim) ?          $found_people_list['before']['yahooim'].  $user_data->yim.          $found_people_list['after']['yahooim']:"");
    846             $replacements[10] = ( !empty($user_data->jabber) ?      $found_people_list['before']['jabbergoogle'].$user_data->jabber.    $found_people_list['after']['jabbergoogle']:"");
    847             $replacements[11] = $found_people_list['before']['id'].      $id. $found_people_list['after']['id'];
    848             $replacements[12] = $found_people_list['before']['authorurl'].get_author_posts_url($id).$found_people_list['after']['authorurl'];
    849             $counter = 13;
    850 
    851 
    852             if( is_array($people_list_option['settings']) ):
    853                 foreach($people_list_option['settings'] as $index => $field_slug):
    854                     $replacements[$counter] =  ( !empty( $user_data->$index) ? $found_people_list['before'][$index]. $user_data->$index.$found_people_list['after'][$index]: "");
    855                     $counter++;
     897            $user_data    = get_userdata( $id );
     898
     899            $replacements[0]  = ( ! empty( $user_data->nickname ) ? $found_people_list['before']['nickname'] . $user_data->nickname . $found_people_list['after']['nickname'] : '' );
     900            $replacements[1]  = ( ! empty( $user_data->user_email ) ? $found_people_list['before']['email'] . $user_data->user_email . $found_people_list['after']['email'] : '' );
     901            $replacements[2]  = ( ! empty( $user_data->description ) ? $found_people_list['before']['bio'] . $user_data->description . $found_people_list['after']['bio'] : '' );
     902            $replacements[3]  = ( ! empty( $user_data->first_name ) ? $found_people_list['before']['firstname'] . $user_data->first_name . $found_people_list['after']['firstname'] : '' );
     903            $replacements[4]  = ( ! empty( $user_data->last_name ) ? $found_people_list['before']['lastname'] . $user_data->last_name . $found_people_list['after']['lastname'] : '' );
     904            $replacements[5]  = ( ! empty( $user_data->user_login ) ? $found_people_list['before']['username'] . $user_data->user_login . $found_people_list['after']['username'] : '' );
     905            $replacements[6]  = $found_people_list['before']['thumbnail'] . get_avatar( $id, $found_people_list['avatar_size'] ) . $found_people_list['after']['thumbnail'];
     906            $replacements[7]  = ( ! empty( $user_data->user_url ) ? $found_people_list['before']['website'] . $user_data->user_url . $found_people_list['after']['website'] : '' );
     907            $replacements[8]  = ( ! empty( $user_data->aim ) ? $found_people_list['before']['aim'] . $user_data->aim . $found_people_list['after']['aim'] : '' );
     908            $replacements[9]  = ( ! empty( $user_data->yim ) ? $found_people_list['before']['yahooim'] . $user_data->yim . $found_people_list['after']['yahooim'] : '' );
     909            $replacements[10] = ( ! empty( $user_data->jabber ) ? $found_people_list['before']['jabbergoogle'] . $user_data->jabber . $found_people_list['after']['jabbergoogle'] : '' );
     910            $replacements[11] = $found_people_list['before']['id'] . $id . $found_people_list['after']['id'];
     911            $replacements[12] = $found_people_list['before']['authorurl'] . get_author_posts_url( $id ) . $found_people_list['after']['authorurl'];
     912            $counter          = 13;
     913
     914            if ( is_array( $people_list_option['settings'] ) ) :
     915                foreach ( $people_list_option['settings'] as $index => $field_slug ) :
     916                    $replacements[ $counter ] = ( ! empty( $user_data->$index ) ? $found_people_list['before'][ $index ] . $user_data->$index . $found_people_list['after'][ $index ] : '' );
     917                    ++$counter;
    856918                endforeach;
    857919            endif;
    858             $replacements = apply_filters('people_list_fields_display',$replacements, $user_data, $found_people_list );
    859             $html = '<div class="person">';
    860             $html .= stripslashes($found_people_list['template']);
    861             $html .= '</div>';
    862             $html2 .= apply_filters("people_list_shortcode", str_replace($input_template, $replacements, $html));
     920            $replacements = apply_filters( 'people_list_fields_display', $replacements, $user_data, $found_people_list );
     921            $html         = '<div class="person">';
     922            $html        .= stripslashes( $found_people_list['template'] );
     923            $html        .= '</div>';
     924            $html2       .= apply_filters( 'people_list_shortcode', str_replace( $input_template, $replacements, $html ) );
    863925
    864926        endforeach;
     
    869931
    870932
    871 if ( function_exists('register_uninstall_hook') )
    872     register_uninstall_hook(__FILE__, 'people_lists_uninstall_hook');
     933if ( function_exists( 'register_uninstall_hook' ) ) {
     934    register_uninstall_hook( __FILE__, 'people_lists_uninstall_hook' );
     935}
    873936/**
    874937 * people_lists_uninstall_hook function.
    875938 * Delete options once the plugin is disabled
    876  * @access public
    877  * @return void
    878  */
    879 function people_lists_uninstall_hook()
    880 {
     939 *
     940 * @access public
     941 * @return void
     942 */
     943function people_lists_uninstall_hook() {
    881944    $option_name = 'people-lists';
    882     delete_option($option_name);
     945    delete_option( $option_name );
    883946}
    884947
     
    890953 * @return void
    891954 */
    892 function people_lists_tiny_filter_remove_fullscreen($initArray){
    893     $initArray["theme_advanced_buttons1"] = str_replace(',fullscreen', '', $initArray["theme_advanced_buttons1"]);
     955function people_lists_tiny_filter_remove_fullscreen( $initArray ) {
     956    $initArray['theme_advanced_buttons1'] = str_replace( ',fullscreen', '', $initArray['theme_advanced_buttons1'] );
    894957    return $initArray;
    895 
    896958}
    897959
Note: See TracChangeset for help on using the changeset viewer.