Changeset 3220440
- Timestamp:
- 01/10/2025 08:20:16 PM (13 months ago)
- File:
-
- 1 edited
-
people-lists/trunk/people-lists.php (modified) (39 diffs)
Legend:
- Unmodified
- Added
- Removed
-
people-lists/trunk/people-lists.php
r3220439 r3220440 4 4 * Plugin URI: http://www.ctlt.ubc.ca 5 5 * 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. Users7 * will also be able to add custom fields to their user profile and these fields can be displayed on any page8 * using the People Lists template (which can be styled using HTML) that provides codes for every field that is9 * 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. 10 10 * Author: Gagan Sandhu , Enej Bajgoric , CTLT DEV, UBC 11 * Version: 1.3.1011 * Version: 2.0.0 12 12 * Author URI: http://www.ctlt.ubc.ca 13 13 * … … 28 28 */ 29 29 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 36 if ( ! defined( 'PEOPLE_LIST_VISUAL_EDITOR' ) ) { 37 } 38 define( 'PEOPLE_LIST_VISUAL_EDITOR', true ); 39 40 add_action( 'admin_print_styles-settings_page_people_lists', 'people_list_options_init_style' ); 41 add_action( 'admin_print_scripts-settings_page_people_lists', 'people_list_options_init_script' ); 42 43 if ( 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' ); 48 49 49 50 // 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' ); 54 55 add_filter( 'get_the_author_description', 'people_list_edit_user_profile_bio_filter' ); 55 56 56 57 57 58 // 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 ); 60 61 61 62 endif; 62 63 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) {64 add_action( 'admin_footer-user-edit.php', 'wp_preload_dialogs', 30 ); 65 add_action( 'admin_footer-profile.php', 'wp_preload_dialogs', 30 ); 66 67 68 69 add_action( 'admin_init', 'people_list_register_options_init' ); 70 add_action( 'admin_menu', 'people_list_options_add_page' ); 71 add_action( 'wp_ajax_people_list_save', 'people_list_saving_list' ); 72 add_action( 'wp_ajax_people_settings_save', 'people_list_saving_settings' ); 73 add_action( 'media_buttons_context', 'people_lists_overlay_button' ); 74 add_action( 'admin_footer', 'people_lists_overlay_popup_form' ); 75 76 add_shortcode( 'people-lists', 'people_lists_shortcode' ); 77 78 add_filter( 'widget_text', 'do_shortcode' ); 79 add_filter( 'user_contactmethods', 'people_lists_user_fields_filter' ); 80 81 82 83 84 85 86 function people_list_edit_user_profile_bio_field( $user ) { 86 87 $news_user = new WP_User( $user->ID ); 87 ?>88 ?> 88 89 <table class="form-table"> 89 90 <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> 93 94 </tr> 94 95 </table> … … 102 103 103 104 function 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 } 107 function people_list_edit_user_profile_bio_filter( $bio ) { 108 return apply_filters( 'the_content', $bio ); 108 109 } 109 110 110 111 /** 111 112 * 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 * 114 116 * @access public 115 117 * @param mixed $user_fields 116 118 * @return void 117 119 */ 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); 120 function 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 ); 126 127 } 127 128 endif; 128 129 129 if (empty($people_list_option['settings'])){130 if ( empty( $people_list_option['settings'] ) ) { 130 131 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 ); 134 134 } 135 135 } … … 138 138 * people_list_saving_settings function. 139 139 * Description: Storing the new fields information in the database and saving sorting of that list. 140 * 140 141 * @access public 141 142 * @return void … … 147 148 148 149 $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 ); 152 153 153 154 $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; 161 161 } 162 162 endif; … … 164 164 $people_list['settings'] = $final_field_array; 165 165 166 update_option( $option_name, $people_list);166 update_option( $option_name, $people_list ); 167 167 } 168 168 … … 170 170 * people_list_saving_list function. 171 171 * Description: Storing list information in the database for new and updated lists to track any sorting of the lists. 172 * 172 173 * @access public 173 174 * @return void … … 178 179 } 179 180 180 $option_name = 'people-lists';181 $option_name = 'people-lists'; 181 182 $people_list['lists'] = array(); 182 $people_list = get_option($option_name);183 $people_list = get_option( $option_name ); 183 184 184 185 wp_parse_str( $_POST['list'], $list ); 185 186 186 187 wp_parse_str($_POST['form'], $data); 187 wp_parse_str( $_POST['form'], $data ); 188 188 189 189 // set the list to be something nice 190 190 $data['list'] = $list; 191 191 192 if (!is_numeric($data['avatar_size']))192 if ( ! is_numeric( $data['avatar_size'] ) ) { 193 193 $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'] ] ) ) : 196 197 // 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; 199 200 echo 'update'; 200 else :201 else : 201 202 $slug = people_lists_slug( $data['title'] ); 202 203 // Check if the slug exists 203 204 $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; 207 207 $counter += 1; 208 208 } … … 213 213 endif; 214 214 215 update_option( $option_name, $people_list);216 die(); // thats it215 update_option( $option_name, $people_list ); 216 die(); // thats it 217 217 } 218 218 … … 221 221 * people_lists_slug function. 222 222 * Description: Creating a slug (shortcode list name) using the list name provided by the user. 223 * 223 224 * @access public 224 225 * @param mixed $str 225 226 * @return void 226 227 */ 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); 228 function people_lists_slug( $str ) { 229 $str = strtolower( trim( $str ) ); 230 $str = preg_replace( '/[^a-z0-9-]/', '-', $str ); 231 $str = preg_replace( '/-+/', '-', $str ); 232 232 return $str; 233 233 } … … 236 236 * people_lists_slug_exists function. 237 237 * Description: Check if a slug (shortcode list name) exists. 238 * 238 239 * @access public 239 240 * @param mixed $slug … … 241 242 * @return void 242 243 */ 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) 244 function people_lists_slug_exists( $slug, $people_list ) { 245 if ( is_array( $people_list ) ) : 246 foreach ( $people_list as $list ) : 247 if ( $list['slug'] == $slug ) { 248 248 return $list; 249 } 249 250 endforeach; 250 251 endif; … … 255 256 * people_lists_field_slug_exists function. 256 257 * Description: Check if a field slug with that name exists. 258 * 257 259 * @access public 258 260 * @param mixed $slug … … 260 262 * @return void 261 263 */ 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) 264 function 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 ) { 267 268 return $fields; 269 } 268 270 endforeach; 269 271 endif; … … 276 278 * people_lists_media_buttons function. 277 279 * add media buttons if they need to be there 280 * 278 281 * @access public 279 282 * @return void 280 283 */ 281 284 function 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>'; 286 291 } 287 292 … … 289 294 * people_lists_tinymce_init_script function. 290 295 * 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 */ 300 function people_lists_tinymce_init_script() { 295 301 // wp_enqueue_script('tiny_mce'); 296 302 // add_action('admin_print_footer_scripts', 'wp_tiny_mce', 25 ); 297 303 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' ); 299 305 300 306 // add_filter( 'tiny_mce_before_init', 'people_lists_tiny_filter_remove_fullscreen'); … … 304 310 * people_lists_tinymce_init_style function. 305 311 * 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 */ 316 function people_lists_tinymce_init_style() { 310 317 // wp_enqueue_style('people-lists-tinymce', plugins_url('/people-lists/css/people-lists-tinymce.css'),'css'); 311 318 } … … 313 320 * people_list_register_options_init function. 314 321 * 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 */ 326 function people_list_register_options_init() { 319 327 register_setting( 'people_lists_options', 'people_lists', 'people_list_validate_admin_page' ); 320 328 321 329 // 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' ); 324 331 } 325 332 … … 327 334 * people_list_options_init_style function. 328 335 * 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 */ 340 function people_list_options_init_style() { 341 wp_enqueue_style( 'people-lists-style', plugins_url( '/people-lists/css/people-lists.css' ), 'css' ); 334 342 } 335 343 /** 336 344 * people_list_options_init_script function. 337 345 * 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 */ 350 function 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 } 344 353 345 354 … … 347 356 * people_list_options_add_page function. 348 357 * Description: Initialize People Lists Option page. 358 * 349 359 * @access public 350 360 * @return void 351 361 */ 352 362 function 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' ); 355 365 } 356 366 … … 358 368 * people_lists_admin_styles function. 359 369 * Description: JQuery Sortable initialization call. 370 * 360 371 * @access public 361 372 * @return void 362 373 */ 363 374 function 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' ); 368 379 } 369 380 … … 372 383 * people_lists_overlay_button function. 373 384 * Description: For adding the People Lists "Insert List" button to the pages & posts editing screens. 385 * 374 386 * @access public 375 387 * @param mixed $context 376 388 * @return void 377 389 */ 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;390 function 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; 382 394 } 383 395 … … 385 397 * people_lists_overlay_popup_form function. 386 398 * 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 */ 403 function 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'); 397 410 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' ); ?>"); 399 412 return; 400 413 } 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();"/> 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();"/> 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 438 455 } 439 456 … … 441 458 * people_list_admin_page function. 442 459 * Description: HTML layout creation of the admin page and building/calling different panels (create/edit/manage). 460 * 443 461 * @access public 444 462 * @return void … … 446 464 function people_list_admin_page() { 447 465 448 $people_list_option = get_option( 'people-lists');466 $people_list_option = get_option( 'people-lists' ); 449 467 450 468 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 ); 453 471 endif; 454 472 455 if ( isset( $_GET['delete-all'] ) ) 456 delete_option('people-lists'); 473 if ( isset( $_GET['delete-all'] ) ) { 474 delete_option( 'people-lists' ); 475 } 457 476 ?> 458 477 <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 : ?> 471 494 <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> 473 496 <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 ?> 476 501 <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> 478 503 </li> 479 <?php endforeach; 480 endif; ?> 504 <?php 505 endforeach; 506 endif; 507 ?> 481 508 </ul> 482 509 </li> … … 485 512 <ul id="people-list-settings"> 486 513 <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> 488 515 </li> 489 516 </ul> 490 517 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'] ] ) : 503 531 $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'; 508 536 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; 518 546 519 547 default: 520 require_once ('views/create.php');521 break;548 require_once 'views/create.php'; 549 break; 522 550 } 523 551 endif; 524 552 ?> 525 553 </div> 526 <?php554 <?php 527 555 } 528 556 … … 530 558 * people_list_validate_admin_page function. 531 559 * Description: Sanitizes and validates an inputted array. 560 * 532 561 * @access public 533 562 * @param mixed $input 534 563 * @return void 535 564 */ 536 function people_list_validate_admin_page( $input) {565 function people_list_validate_admin_page( $input ) { 537 566 return $input; 538 567 } … … 542 571 * Description: Building of form users interact with, including a name field, a modifiable people lists profile display 543 572 * template and jQuery Sortable lists that allow for dragging and dropping of users for a specific list. 573 * 544 574 * @access public 545 575 * @param bool $list_id. (default: false) … … 547 577 * @return void 548 578 */ 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'])) 579 function 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'] ) ) { 556 585 $list['list']['uid'] = array(); 586 } 557 587 558 588 if ( ! isset( $list['title'] ) ) { … … 560 590 } 561 591 562 if ( ! isset ( $list['avatar_size'] ) ) {592 if ( ! isset( $list['avatar_size'] ) ) { 563 593 $list['avatar_size'] = ''; 564 594 } … … 567 597 <div id="people-list-form-shell"> 568 598 <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> 574 604 <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> 576 606 577 607 <div class="template-tabbed"> … … 579 609 <div class="template-area"> 580 610 <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> 584 614 </ul> 585 615 <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> 601 631 </ul> 602 632 </div> 603 633 <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> 605 635 <ul> 606 636 <?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 ?> 609 640 <li class="template-code-list">%<?php echo $index; ?>%</li> 610 <?php endforeach; 641 <?php 642 endforeach; 611 643 $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>'; 616 648 endforeach; 617 649 618 endif; ?> 650 endif; 651 ?> 619 652 </ul> 620 653 </div> … … 623 656 <li id="header-before-after"><span >before</span><span class='after-item'>after</span></li> 624 657 <?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 ); 629 662 endforeach; 630 663 $item = null; 631 664 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 ] : '' ); 635 668 people_lists_before_after_item( $field_slug, $before, $after, $item ); 636 669 endforeach; 637 670 } 638 671 639 $item = null;672 $item = null; 640 673 $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 ] : '' ); 646 679 people_lists_before_after_item( $item, $before, $after, $item ); 647 680 endforeach; … … 653 686 </div> 654 687 </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 ?> 660 696 </textarea><br /> 661 697 … … 663 699 664 700 <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> 668 711 <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 ?> 672 717 <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 ); ?> 674 719 <?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; 677 723 endif; 678 724 endforeach; 679 endif; ?> 725 endif; 726 ?> 680 727 </ul> 681 728 </div> 682 729 683 730 <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> 686 733 <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 ?> 694 745 </ul> 695 746 </div> 696 747 697 748 <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' ); ?>" /> 703 754 <?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" /> 705 756 </p> 706 757 </form> 707 758 </div> 708 <?php759 <?php 709 760 } 710 761 … … 712 763 * people_list_field_form function. 713 764 * 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 */ 771 function people_list_field_form() { 772 $option_name = 'people-lists'; 773 $people_list_option = get_option( $option_name ); 774 775 ?> 724 776 <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 /> 726 778 <input type="text" name="contact-info-field" id="contact-info-field" size="30" /> 727 779 728 780 <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" /> 731 783 </p> 732 784 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 /> 735 787 <form id="profile-field-form"> 736 788 <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> 740 794 <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[]" /> 742 796 </li> 743 <?php endforeach; 744 endif; ?> 797 <?php 798 endforeach; 799 endif; 800 ?> 745 801 </ul> 746 802 </form> 747 803 </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 807 function people_lists_before_after_item( $item = null, $before_value = null, $after_value = null, $id = null ) { 808 if ( isset( $item ) ) : 809 810 ?> 756 811 <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" /> 758 813 <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" /> 760 815 </li> 761 <?php endif; 816 <?php 817 endif; 762 818 } 763 819 /** 764 820 * people_lists_default_template function. 765 821 * Description: Display the default template, which includes a thumbnail, nickname, email and user's bio from their "Your 766 * Profile" tab.767 * @access public768 * @ return void769 * /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 */ 827 function 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"; 776 832 777 833 return $html; … … 781 837 * people_lists_shortcode function. 782 838 * 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 * 784 841 * @access public 785 842 * @param mixed $atts 786 843 * @return void 787 844 */ 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 845 function 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 } 799 861 800 862 // $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(); 807 870 $input_template = array(); 808 871 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%'; 822 885 823 886 $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; 828 891 endforeach; 829 892 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 ) : 833 896 $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; 856 918 endforeach; 857 919 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 ) ); 863 925 864 926 endforeach; … … 869 931 870 932 871 if ( function_exists('register_uninstall_hook') ) 872 register_uninstall_hook(__FILE__, 'people_lists_uninstall_hook'); 933 if ( function_exists( 'register_uninstall_hook' ) ) { 934 register_uninstall_hook( __FILE__, 'people_lists_uninstall_hook' ); 935 } 873 936 /** 874 937 * people_lists_uninstall_hook function. 875 938 * Delete options once the plugin is disabled 876 * @access public877 * @ return void878 * /879 function people_lists_uninstall_hook() 880 {939 * 940 * @access public 941 * @return void 942 */ 943 function people_lists_uninstall_hook() { 881 944 $option_name = 'people-lists'; 882 delete_option($option_name);945 delete_option( $option_name ); 883 946 } 884 947 … … 890 953 * @return void 891 954 */ 892 function people_lists_tiny_filter_remove_fullscreen( $initArray){893 $initArray[ "theme_advanced_buttons1"] = str_replace(',fullscreen', '', $initArray["theme_advanced_buttons1"]);955 function people_lists_tiny_filter_remove_fullscreen( $initArray ) { 956 $initArray['theme_advanced_buttons1'] = str_replace( ',fullscreen', '', $initArray['theme_advanced_buttons1'] ); 894 957 return $initArray; 895 896 958 } 897 959
Note: See TracChangeset
for help on using the changeset viewer.