Ticket #3970: admin-functions-phpdoc.diff

File admin-functions-phpdoc.diff, 29.6 KB (added by m0n5t3r, 5 years ago)

admin-functions phpdoc take 2

  • wp-admin/admin-functions.php

    === modified file 'wp-admin/admin-functions.php'
     
    11<?php 
     2/** 
     3 * admin-functions 
     4 * 
     5 * @author Wordpress team (FIXME) 
     6 * @version "$Id$" 
     7 * @copyright FIXME 
     8 * @package wordpress 
     9 * @subpackage admin-functions 
     10 */ 
    211 
     12/** 
     13 * calls wp_write_post and handles the errors 
     14 * 
     15 * @return int post ID, dies in case of failure 
     16 */ 
    317function write_post() { 
    418        $result = wp_write_post(); 
    519        if( is_wp_error( $result ) ) 
     
    822                return $result; 
    923} 
    1024 
    11 // Creates a new post from the "Write Post" form using $_POST information. 
     25/** 
     26 * Creates a new post from the "Write Post" form using $_POST information. 
     27 * 
     28 * @return mixed post ID on success, Wp_Error on failure 
     29 */ 
    1230function wp_write_post() { 
    1331        global $user_ID; 
    1432 
     
    131149        return $post_ID; 
    132150} 
    133151 
    134 // Move child posts to a new parent 
     152/** 
     153 * Move child posts to a new parent 
     154 * 
     155 * @param int $old_ID current parent ID 
     156 * @param int $new_ID ID of the new parent 
     157 * @return mixed number of affected rows on success, false on failure 
     158 */ 
    135159function relocate_children( $old_ID, $new_ID ) { 
    136160        global $wpdb; 
    137161        $old_ID = (int) $old_ID; 
     
    139163        return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID" ); 
    140164} 
    141165 
    142 // Replace hrefs of attachment anchors with up-to-date permalinks. 
     166/** 
     167 * Replace hrefs of attachment anchors with up-to-date permalinks. 
     168 * 
     169 * @param int $post_ID 
     170 * @return int post ID  
     171 */ 
    143172function fix_attachment_links( $post_ID ) { 
    144173        global $wp_rewrite; 
    145174 
     
    181210        return wp_update_post( $post); 
    182211} 
    183212 
    184 // Update an existing post with values provided in $_POST. 
     213/** 
     214 * Update an existing post with values provided in $_POST. 
     215 * 
     216 * @filter autosave_interval 
     217 * @return int post ID or dies on wrong permissions 
     218 */ 
    185219function edit_post() { 
    186220        global $user_ID; 
    187221 
     
    299333        return $post_ID; 
    300334} 
    301335 
     336/** 
     337 * update a comment using data from $_POST 
     338 * 
     339 * @return int number of affected rows 
     340 */ 
    302341function edit_comment() { 
    303342        global $user_ID; 
    304343 
     
    332371        wp_update_comment( $_POST); 
    333372} 
    334373 
    335 // Get an existing post and format it for editing. 
     374/** 
     375 * Get an existing post and format it for editing. 
     376 * 
     377 * @filter content_edit_pre 
     378 * @filter excerpt_edit_pre 
     379 * @filter title_edit_pre 
     380 * @param int $id post ID 
     381 * @return object post 
     382 */ 
    336383function get_post_to_edit( $id ) { 
    337384 
    338385        $post = get_post( $id ); 
     
    354401        return $post; 
    355402} 
    356403 
    357 // Default post information to use when populating the "Write Post" form. 
     404/** 
     405 * Default post information to use when populating the "Write Post" form. 
     406 * 
     407 * @filter default_content 
     408 * @filter default_title 
     409 * @filter default_excerpt 
     410 * @return object 
     411 */ 
    358412function get_default_post_to_edit() { 
    359413        if ( !empty( $_REQUEST['post_title'] ) ) 
    360414                $post_title = wp_specialchars( stripslashes( $_REQUEST['post_title'] )); 
     
    394448        return $post; 
    395449} 
    396450 
     451/** 
     452 * get a comment and format it for editing 
     453 * 
     454 * @filter comment_edit_pre 
     455 * @return object comment 
     456 */ 
    397457function get_comment_to_edit( $id ) { 
    398458        $comment = get_comment( $id ); 
    399459 
     
    407467        return $comment; 
    408468} 
    409469 
     470/** 
     471 * get a category for editing 
     472 * 
     473 * @param int $id category ID 
     474 * @return object  
     475 */ 
    410476function get_category_to_edit( $id ) { 
    411477        $category = get_category( $id ); 
    412478 
     
    425491} 
    426492 
    427493 
     494/** 
     495 * get user information and format it for editing 
     496 * 
     497 * @param int $user_id user ID 
     498 * @return object 
     499 */ 
    428500function get_user_to_edit( $user_id ) { 
    429501        $user = new WP_User( $user_id ); 
    430502        $user->user_login   = attribute_escape($user->user_login); 
     
    442514        return $user; 
    443515} 
    444516 
    445 // Creates a new user from the "Users" form using $_POST information. 
    446  
     517/** 
     518 * Creates a new user from the "Users" form using $_POST information. 
     519 * 
     520 * @return object 
     521 */ 
    447522function add_user() { 
    448523        if ( func_num_args() ) { // The hackiest hack that ever did hack 
    449524                global $current_user, $wp_roles; 
     
    461536        } 
    462537} 
    463538 
     539/** 
     540 * update user information or create a new user 
     541 * 
     542 * @param int $user_id user ID 
     543 * @return mixed user ID or WP_Error 
     544 */ 
    464545function edit_user( $user_id = 0 ) { 
    465546        global $current_user, $wp_roles, $wpdb; 
    466547        if ( $user_id != 0 ) { 
     
    571652} 
    572653 
    573654 
     655/** 
     656 * get a link and format it for editing 
     657 * 
     658 * @param int $link_id 
     659 * @return object 
     660 */ 
    574661function get_link_to_edit( $link_id ) { 
    575662        $link = get_link( $link_id ); 
    576663 
     
    586673        return $link; 
    587674} 
    588675 
     676/** 
     677 * default information for link editing 
     678 * 
     679 * @return object 
     680 */ 
    589681function get_default_link_to_edit() { 
    590682        if ( isset( $_GET['linkurl'] ) ) 
    591683                $link->link_url = attribute_escape( $_GET['linkurl']); 
     
    606698        return edit_link(); 
    607699} 
    608700 
    609 function edit_link( $link_id = '' ) { 
     701/** 
     702 * update a link information or create  new one 
     703 * 
     704 * @param int $link_id 
     705 * @return mixed link ID or Wp_Error 
     706 */ 
     707function edit_link( $link_id = '' ) { //FIXME this is not very consistent; default for $link_id should be int 
    610708        if (!current_user_can( 'manage_links' )) 
    611709                wp_die( __( 'Cheatin&#8217; uh?' )); 
    612710 
     
    625723        } 
    626724} 
    627725 
     726/** 
     727 * make a short version of the url 
     728 * 
     729 * @param string $url 
     730 * @return string 
     731 */ 
    628732function url_shorten( $url ) { 
    629733        $short_url = str_replace( 'http://', '', stripslashes( $url )); 
    630734        $short_url = str_replace( 'www.', '', $short_url ); 
     
    635739        return $short_url; 
    636740} 
    637741 
     742/** 
     743 * select helper; output selected status 
     744 * 
     745 * @param string $selected value to be selected 
     746 * @param string $current current value 
     747 */ 
    638748function selected( $selected, $current) { 
    639749        if ( $selected == $current) 
    640750                echo ' selected="selected"'; 
    641751} 
    642752 
     753/** 
     754 * input helper; output checked status 
     755 * 
     756 * @param string $checked value to be checked 
     757 * @param string $current current value 
     758 */ 
    643759function checked( $checked, $current) { 
    644760        if ( $checked == $current) 
    645761                echo ' checked="checked"'; 
    646762} 
    647763 
     764/** 
     765 * get a list of categories 
     766 * 
     767 * @param int $parent category parent ID 
     768 * @return array  
     769 */ 
    648770function return_categories_list( $parent = 0 ) { 
    649771        global $wpdb; 
    650772        return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( link_count = 0 OR category_count != 0 OR ( link_count = 0 AND category_count = 0 ) ) ORDER BY category_count DESC" ); 
    651773} 
    652774 
     775/** 
     776 * sorting helper 
     777 * 
     778 * @param string $cat1 
     779 * @param string $cat2 
     780 * @return bool 
     781 */ 
    653782function sort_cats( $cat1, $cat2 ) { 
    654783        if ( $cat1['checked'] || $cat2['checked'] ) 
    655784                return ( $cat1['checked'] && !$cat2['checked'] ) ? -1 : 1; 
     
    657786                return strcasecmp( $cat1['cat_name'], $cat2['cat_name'] ); 
    658787} 
    659788 
     789/** 
     790 * get the (sorted) list of categories as a tree 
     791 * 
     792 * @param int $default default category 
     793 * @param int $parent parent category 
     794 * @return array  
     795 */ 
    660796function get_nested_categories( $default = 0, $parent = 0 ) { 
    661797        global $post_ID, $link_id, $mode, $wpdb; 
    662798 
     
    703839        return $result; 
    704840} 
    705841 
     842/** 
     843 * output category list together with checkboxes for selecting 
     844 * 
     845 * @filter the_category 
     846 * @param array $categories category tree 
     847 */ 
    706848function write_nested_categories( $categories ) { 
    707849        foreach ( $categories as $category ) { 
    708850                echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars( apply_filters('the_category', $category['cat_name'] )), "</label></li>"; 
     
    715857        } 
    716858} 
    717859 
     860/** 
     861 * get the list of categories from the database and display it 
     862 * 
     863 * @param int $default 
     864 */ 
    718865function dropdown_categories( $default = 0 ) { 
    719866        write_nested_categories( get_nested_categories( $default) ); 
    720867} 
    721868 
     869/** 
     870 * get the list of link categories 
     871 * 
     872 * @param array $parent 
     873 * @return array  
     874 */ 
    722875function return_link_categories_list( $parent = 0 ) { 
    723876        global $wpdb; 
    724877        return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( category_count = 0  OR link_count != 0 OR ( link_count = 0 AND category_count = 0 ) ) ORDER BY link_count DESC" ); 
    725878} 
    726879 
     880/** 
     881 * get the link categories as a tree 
     882 * 
     883 * @param int $default 
     884 * @param int $parent 
     885 * @return array  
     886 */ 
    727887function get_nested_link_categories( $default = 0, $parent = 0 ) { 
    728888        global $post_ID, $link_id, $mode, $wpdb; 
    729889 
     
    759919        return $result; 
    760920} 
    761921 
     922/** 
     923 * get the link categories from the database and output them 
     924 * 
     925 * @param int $parent 
     926 */ 
    762927function dropdown_link_categories( $default = 0 ) { 
    763928        write_nested_categories( get_nested_link_categories( $default) ); 
    764929} 
    765930 
    766 // Dandy new recursive multiple category stuff. 
    767 function cat_rows( $parent = 0, $level = 0, $categories = 0 ) { 
     931/** 
     932 * output table rows for the category management page 
     933 * 
     934 * @filter cat_rows 
     935 * @param int $parent 
     936 * @param int $level 
     937 * @param array $categories 
     938 */ 
     939function cat_rows( $parent = 0, $level = 0, $categories = 0 ) { //FIXME categories int or array? 
    768940        if (!$categories ) 
    769941                $categories = get_categories( 'hide_empty=0' ); 
    770942 
     
    787959        } 
    788960} 
    789961 
     962/** 
     963 * output a table row with category information and edit/delete links 
     964 * 
     965 * @param object $category 
     966 * @param int $level indent level 
     967 * @param bool $name_override 
     968 */ 
    790969function _cat_row( $category, $level, $name_override = false ) { 
    791970        global $class; 
    792971 
     
    797976                $default_link_cat_id = get_option( 'default_link_category' ); 
    798977 
    799978                if ( ($category->cat_ID != $default_cat_id ) && ($category->cat_ID != $default_link_cat_id ) ) 
    800                         $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll posts that were only assigned to this category will be assigned to the '%s' category.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->cat_name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."</a>"; 
     979                        $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll of its posts will go into the default category of '%s'\nAll of its bookmarks will go into the default category of '%s'.\n'OK' to delete, 'Cancel' to stop." ), $category->cat_name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."</a>"; 
    801980                else 
    802981                        $edit .= "<td style='text-align:center'>".__( "Default" ); 
    803982        } else 
     
    817996                <td>$edit</td>\n\t</tr>\n"; 
    818997} 
    819998 
     999/** 
     1000 * output table rows for the page management page 
     1001 * 
     1002 * @param int $parent 
     1003 * @param int $level 
     1004 * @param array $pages 
     1005 * @param bool $hierarchy 
     1006 */ 
    8201007function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) { 
    8211008        global $wpdb, $class, $post; 
    8221009 
     
    8531040        } 
    8541041} 
    8551042 
     1043/** 
     1044 * format user information as a table row 
     1045 * 
     1046 * @param object $user_object  
     1047 * @param string $style 
     1048 * @return string 
     1049 */ 
    8561050function user_row( $user_object, $style = '' ) { 
    8571051        if ( !(is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) 
    8581052                $user_object = new WP_User( (int) $user_object ); 
     
    8861080        return $r; 
    8871081} 
    8881082 
    889 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) { 
     1083/** 
     1084 * output category list as select options 
     1085 * 
     1086 * @param int $currentcat 
     1087 * @param int $currentparent 
     1088 * @param int $parent 
     1089 * @param int $level 
     1090 * @param int $categories 
     1091 */ 
     1092function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {//FIXME $categories array or int? 
    8901093        global $wpdb; 
    8911094        if (!$categories ) 
    8921095                $categories = get_categories( 'hide_empty=0' ); 
     
    9081111        } 
    9091112} 
    9101113 
    911 // Some postmeta stuff 
     1114/** 
     1115 * get meta information for post 
     1116 * 
     1117 * @param int $postid 
     1118 * @return array  
     1119 */ 
    9121120function has_meta( $postid ) { 
    9131121        global $wpdb; 
    9141122 
     
    9201128 
    9211129} 
    9221130 
     1131/** 
     1132 * output post meta 
     1133 * 
     1134 * @param array $meta 
     1135 */ 
    9231136function list_meta( $meta ) { 
    9241137        global $post_ID; 
    9251138        // Exit if no meta 
     
    9741187        echo "\n\t</tbody>"; 
    9751188} 
    9761189 
    977 // Get a list of previously defined keys 
     1190/** 
     1191 * Get a list of previously defined keys 
     1192 * 
     1193 * @return array 
     1194 */ 
    9781195function get_meta_keys() { 
    9791196        global $wpdb; 
    9801197 
     
    9871204        return $keys; 
    9881205} 
    9891206 
     1207/** 
     1208 * output meta editing form 
     1209 * 
     1210 * @filter postmeta_form_limit 
     1211 */ 
    9901212function meta_form() { 
    9911213        global $wpdb; 
    9921214        $limit = (int) apply_filters( 'postmeta_form_limit', 30 ); 
     
    10301252 
    10311253} 
    10321254 
     1255/** 
     1256 * add meta from $_POST 
     1257 * 
     1258 * @param int $post_ID 
     1259 * @return mixed meta ID or false 
     1260 */ 
    10331261function add_meta( $post_ID ) { 
    10341262        global $wpdb; 
    10351263        $post_ID = (int) $post_ID; 
     
    10591287        return false; 
    10601288} // add_meta 
    10611289 
     1290/** 
     1291 * delete meta 
     1292 * 
     1293 * @param int $mid meta ID 
     1294 * @return mixed number of accected rows or false 
     1295 */ 
    10621296function delete_meta( $mid ) { 
    10631297        global $wpdb; 
    10641298        $mid = (int) $mid; 
     
    10661300        return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'" ); 
    10671301} 
    10681302 
     1303/** 
     1304 * update meta 
     1305 * 
     1306 * @param int $mid 
     1307 * @param string $mkey 
     1308 * @param mixed $mvalue 
     1309 * @return mixed number of affected rows or false 
     1310 */ 
    10691311function update_meta( $mid, $mkey, $mvalue ) { 
    10701312        global $wpdb; 
    10711313        $mvalue = maybe_serialize( stripslashes( $mvalue )); 
     
    10741316        return $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'" ); 
    10751317} 
    10761318 
     1319/** 
     1320 * get post meta by ID 
     1321 * 
     1322 * @param int $mid 
     1323 * @return object 
     1324 */ 
    10771325function get_post_meta_by_id( $mid ) { 
    10781326        global $wpdb; 
    10791327        $mid = (int) $mid; 
     
    10841332        return $meta; 
    10851333} 
    10861334 
     1335/** 
     1336 * output timestamp editing form 
     1337 * 
     1338 * @param int $edit 
     1339 * @param int $for_post 
     1340 */ 
    10871341function touch_time( $edit = 1, $for_post = 1 ) { 
    10881342        global $wp_locale, $post, $comment; 
    10891343 
     
    11251379 
    11261380} 
    11271381 
    1128 // insert_with_markers: Owen Winkler, fixed by Eric Anderson 
    1129 // Inserts an array of strings into a file (.htaccess ), placing it between 
    1130 // BEGIN and END markers.  Replaces existing marked info.  Retains surrounding 
    1131 // data.  Creates file if none exists. 
    1132 // Returns true on write success, false on failure. 
     1382/** 
     1383 * Inserts an array of strings into a file (.htaccess ), placing it between 
     1384 * BEGIN and END markers.  Replaces existing marked info.  Retains surrounding 
     1385 * data.  Creates file if none exists. 
     1386 * 
     1387 * @param string $filename 
     1388 * @param string $marker 
     1389 * @param string $insertion 
     1390 * @return bool 
     1391 */ 
    11331392function insert_with_markers( $filename, $marker, $insertion ) { 
    11341393        if (!file_exists( $filename ) || is_writeable( $filename ) ) { 
    11351394                if (!file_exists( $filename ) ) { 
     
    11751434        } 
    11761435} 
    11771436 
    1178 // extract_from_markers: Owen Winkler 
    1179 // Returns an array of strings from a file (.htaccess ) from between BEGIN 
    1180 // and END markers. 
     1437/** 
     1438 * extracts text between some markers in a file 
     1439 * 
     1440 * @param string $filename 
     1441 * @param string marker 
     1442 * @return array array of strings from a file (.htaccess ) from between BEGIN 
     1443 * and END markers. 
     1444 */ 
    11811445function extract_from_markers( $filename, $marker ) { 
    11821446        $result = array (); 
    11831447 
     
    12011465        return $result; 
    12021466} 
    12031467 
     1468/** 
     1469 * find out if we have mod_rewrite 
     1470 * 
     1471 * @return bool 
     1472 */ 
    12041473function got_mod_rewrite() { 
    12051474        global $is_apache; 
    12061475 
     
    12161485        return true; 
    12171486} 
    12181487 
     1488/** 
     1489 * save mod_rewrite rules to .htaccess 
     1490 * 
     1491 * @return bool 
     1492 */ 
    12191493function save_mod_rewrite_rules() { 
    12201494        global $is_apache, $wp_rewrite; 
    12211495        $home_path = get_home_path(); 
     
    12331507        return insert_with_markers( $home_path.'.htaccess', 'WordPress', $rules ); 
    12341508} 
    12351509 
     1510/** 
     1511 * get the list of broken themes 
     1512 * 
     1513 * @return array  
     1514 */ 
    12361515function get_broken_themes() { 
    12371516        global $wp_broken_themes; 
    12381517 
     
    12401519        return $wp_broken_themes; 
    12411520} 
    12421521 
     1522/** 
     1523 * build the page template list 
     1524 * 
     1525 * @return array  
     1526 */ 
    12431527function get_page_templates() { 
    12441528        $themes = get_themes(); 
    12451529        $theme = get_current_theme(); 
     
    12641548        return $page_templates; 
    12651549} 
    12661550 
     1551/** 
     1552 * output the template dropdown for the current page 
     1553 * 
     1554 * @param string default the currently selected template 
     1555 */ 
    12671556function page_template_dropdown( $default = '' ) { 
    12681557        $templates = get_page_templates(); 
    12691558        foreach (array_keys( $templates ) as $template ) 
     
    12751564        endforeach; 
    12761565} 
    12771566 
     1567/** 
     1568 * get the page parent dropdown 
     1569 * 
     1570 * @param int $default the ID of the selected item 
     1571 * @param int $parent the ID of the parent 
     1572 * @param int $level the current nesting level 
     1573 */ 
    12781574function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { 
    12791575        global $wpdb, $post_ID; 
    12801576        $items = $wpdb->get_results( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order" ); 
     
    13011597        } 
    13021598} 
    13031599 
     1600/** 
     1601 * check if the user can access the current admin page 
     1602 * 
     1603 * @return bool 
     1604 */ 
    13041605function user_can_access_admin_page() { 
    13051606        global $pagenow; 
    13061607        global $menu; 
     
    13611662        return true; 
    13621663} 
    13631664 
     1665/** 
     1666 * get title of the current admin page 
     1667 * 
     1668 * @return string 
     1669 */ 
    13641670function get_admin_page_title() { 
    13651671        global $title; 
    13661672        global $menu; 
     
    14191725        return $title; 
    14201726} 
    14211727 
     1728/** 
     1729 * get the parent for the current admin page 
     1730 * 
     1731 * @return string 
     1732 */ 
    14221733function get_admin_page_parent() { 
    14231734        global $parent_file; 
    14241735        global $menu; 
     
    14791790        return ''; 
    14801791} 
    14811792 
     1793/** 
     1794 * add a toplevel menu item 
     1795 * 
     1796 * @param string $page_title page title 
     1797 * @param string $menu_title menu item label 
     1798 * @param int $access_level minimum user level 
     1799 * @param string $file filename (relative to wp-content/plugins) 
     1800 * @param callback $function function that generates the page 
     1801 * @return string th page hook name 
     1802 */ 
    14821803function add_menu_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { 
    14831804        global $menu, $admin_page_hooks; 
    14841805 
     
    14951816        return $hookname; 
    14961817} 
    14971818 
     1819/** 
     1820 * add a subpage to the menu 
     1821 *  
     1822 * @param string $parent parent page 
     1823 * @param string $page_title subpage title 
     1824 * @param string $menu_title menu item label 
     1825 * @param int $access_level minimum user level 
     1826 * @param string $file filename (relative to wp-content/plugins) 
     1827 * @param callback $function function that generates the subpage 
     1828 * @return string the page hook name 
     1829 */ 
    14981830function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function = '' ) { 
    14991831        global $submenu; 
    15001832        global $menu; 
     
    15331865        return $hookname; 
    15341866} 
    15351867 
     1868/** 
     1869 * add an options subpage 
     1870 * 
     1871 * @param string $page_title @see add_submenu_page() 
     1872 * @param string $menu_title @see add_submenu_page() 
     1873 * @param int $access_level @see add_submenu_page() 
     1874 * @param string $file @see add_submenu_page() 
     1875 * @param callback $function @see add_submenu_page() 
     1876 * @return string @see add_submenu_page() 
     1877 */ 
    15361878function add_options_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { 
    15371879        return add_submenu_page( 'options-general.php', $page_title, $menu_title, $access_level, $file, $function ); 
    15381880} 
    15391881 
     1882/** 
     1883 * add a management subpage 
     1884 * 
     1885 * @param string $page_title @see add_submenu_page() 
     1886 * @param string $menu_title @see add_submenu_page() 
     1887 * @param int $access_level @see add_submenu_page() 
     1888 * @param string $file @see add_submenu_page() 
     1889 * @param callback $function @see add_submenu_page() 
     1890 * @return string @see add_submenu_page() 
     1891 */ 
    15401892function add_management_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { 
    15411893        return add_submenu_page( 'edit.php', $page_title, $menu_title, $access_level, $file, $function ); 
    15421894} 
    15431895 
     1896/** 
     1897 * add a theme subpage 
     1898 * 
     1899 * @param string $page_title @see add_submenu_page() 
     1900 * @param string $menu_title @see add_submenu_page() 
     1901 * @param int $access_level @see add_submenu_page() 
     1902 * @param string $file @see add_submenu_page() 
     1903 * @param callback $function @see add_submenu_page() 
     1904 * @return string @see add_submenu_page() 
     1905 */ 
    15441906function add_theme_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { 
    15451907        return add_submenu_page( 'themes.php', $page_title, $menu_title, $access_level, $file, $function ); 
    15461908} 
    15471909 
     1910/** 
     1911 * add a users subpage 
     1912 * 
     1913 * @param string $page_title @see add_submenu_page() 
     1914 * @param string $menu_title @see add_submenu_page() 
     1915 * @param int $access_level @see add_submenu_page() 
     1916 * @param string $file @see add_submenu_page() 
     1917 * @param callback $function @see add_submenu_page() 
     1918 * @return string @see add_submenu_page() 
     1919 */ 
    15481920function add_users_page( $page_title, $menu_title, $access_level, $file, $function = '' ) { 
    15491921        if ( current_user_can('edit_users') ) 
    15501922                $parent = 'users.php'; 
     
    15531925        return add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function ); 
    15541926} 
    15551927 
     1928/** 
     1929 * validate a file 
     1930 * 
     1931 * @param string $file 
     1932 * @param array $allowed_files 
     1933 * @return int 
     1934 */ 
    15561935function validate_file( $file, $allowed_files = '' ) { 
    15571936        if ( false !== strpos( $file, './' )) 
    15581937                return 1; 
     
    15661945        return 0; 
    15671946} 
    15681947 
     1948/** 
     1949 * validate a file before editing and abort with a friendly error message 
     1950 * 
     1951 * @param string $file 
     1952 * @param array $allowed_files 
     1953 */ 
    15691954function validate_file_to_edit( $file, $allowed_files = '' ) { 
    15701955        $file = stripslashes( $file ); 
    15711956 
     
    15861971        } 
    15871972} 
    15881973 
     1974/** 
     1975 * get the home path 
     1976 * 
     1977 * @return string 
     1978 */ 
    15891979function get_home_path() { 
    15901980        $home = get_option( 'home' ); 
    15911981        if ( $home != '' && $home != get_option( 'siteurl' ) ) { 
     
    16001990        return $home_path; 
    16011991} 
    16021992 
     1993/** 
     1994 * resolve the file path 
     1995 * 
     1996 * @return string 
     1997 */ 
    16031998function get_real_file_to_edit( $file ) { 
    16041999        if ('index.php' == $file || '.htaccess' == $file ) { 
    16052000                $real_file = get_home_path().$file; 
     
    16142009        // Deprecated files 
    16152010        'wp-layout.css' => __( 'Stylesheet' ), 'wp-comments.php' => __( 'Comments Template' ), 'wp-comments-popup.php' => __( 'Popup Comments Template' )); 
    16162011 
     2012/** 
     2013 * get description for a template file 
     2014 * 
     2015 * @param string $file 
     2016 * @return string 
     2017 */ 
    16172018function get_file_description( $file ) { 
    16182019        global $wp_file_descriptions; 
    16192020 
     
    16292030        return basename( $file ); 
    16302031} 
    16312032 
     2033/** 
     2034 * update the list of recently edited files 
     2035 * 
     2036 * @param string $file 
     2037 */ 
    16322038function update_recently_edited( $file ) { 
    16332039        $oldfiles = (array ) get_option( 'recently_edited' ); 
    16342040        if ( $oldfiles ) { 
     
    16442050        update_option( 'recently_edited', $oldfiles ); 
    16452051} 
    16462052 
     2053/** 
     2054 * read the plugin data 
     2055 * 
     2056 * @param string $plugin_file 
     2057 * @return array  
     2058 */ 
    16472059function get_plugin_data( $plugin_file ) { 
    16482060        $plugin_data = implode( '', file( $plugin_file )); 
    16492061        preg_match( "|Plugin Name:(.*)|i", $plugin_data, $plugin_name ); 
     
    16742086        return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1] ); 
    16752087} 
    16762088 
     2089/** 
     2090 * build the list of plugins in the wp-content/plugins directory 
     2091 * 
     2092 * @return array  
     2093 */ 
    16772094function get_plugins() { 
    16782095        global $wp_plugins; 
    16792096 
     
    17272144        return $wp_plugins; 
    17282145} 
    17292146 
     2147/** 
     2148 * compose a plugin page hook name from the nme of the plugin page and the name of its parent page 
     2149 * 
     2150 * @param string $plugin_page plugin page name 
     2151 * @param string $parent_page parent page name 
     2152 * @return string 
     2153 */ 
    17302154function get_plugin_page_hookname( $plugin_page, $parent_page ) { 
    17312155        global $admin_page_hooks; 
    17322156 
     
    17502174        return $page_type.'_page_'.$plugin_name; 
    17512175} 
    17522176 
     2177/** 
     2178 * the hook name for a plugin page, if it is defined 
     2179 * 
     2180 * @param string $plugin_page @see get_plugin_page_hookname 
     2181 * @param string $parent_page @see get_plugin_page_hookname 
     2182 * @return string 
     2183 */ 
    17532184function get_plugin_page_hook( $plugin_page, $parent_page ) { 
    17542185        global $wp_filter; 
    17552186 
     
    17862217        return $wp_importers; 
    17872218} 
    17882219 
     2220/** 
     2221 * get current theme info 
     2222 * 
     2223 * @return object 
     2224 */ 
    17892225function current_theme_info() { 
    17902226        $themes = get_themes(); 
    17912227        $current_theme = get_current_theme(); 
     
    18032239        return $ct; 
    18042240} 
    18052241 
    1806  
    1807 // array wp_handle_upload ( array &file [, array overrides] ) 
    1808 // file: reference to a single element of $_FILES. Call the function once for each uploaded file. 
    1809 // overrides: an associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ). 
    1810 // On success, returns an associative array of file attributes. 
    1811 // On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). 
     2242/** 
     2243 * handle an uploaded file 
     2244 * 
     2245 * @filter wp_handle_upload 
     2246 * @param array &$file file info; reference to a single element if $_FILES 
     2247 * @param array $overrides associative array of names=>values to override default variables with extract($overrides, EXTR_OVERWRITE) 
     2248 * @return mixed associative array of file attributes on success,  
     2249 * $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ) on failure 
     2250 */ 
    18122251function wp_handle_upload( &$file, $overrides = false ) { 
    18132252        // The default error handler. 
    18142253        if (! function_exists( 'wp_handle_upload_error' ) ) { 
     
    19122351        return $return; 
    19132352} 
    19142353 
     2354/** 
     2355 * compute dimensions for display in the upload list 
     2356 * 
     2357 * @param int $width image width 
     2358 * @param int $height image height 
     2359 * @param int $wmax maximum width of the resized image 
     2360 * @param int $hmax maximum height of the resized image 
     2361 * @return array  
     2362 */ 
    19152363function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) { 
    19162364        if ( $height <= $hmax && $width <= $wmax ) 
    19172365                return array( $width, $height); 
     
    19212369                return array( (int) ($width / $height * $hmax ), $hmax ); 
    19222370} 
    19232371 
     2372/** 
     2373 * delete an attachment 
     2374 * 
     2375 * @param int $id attachment ID 
     2376 */ 
    19242377function wp_import_cleanup( $id ) { 
    19252378        wp_delete_attachment( $id ); 
    19262379} 
    19272380 
     2381/** 
     2382 * outputs the file upload form for importing 
     2383 * 
     2384 * @param string $action form action 
     2385 */ 
    19282386function wp_import_upload_form( $action ) { 
    19292387        $size = strtolower( ini_get( 'upload_max_filesize' ) ); 
    19302388        $bytes = 0; 
     
    19492407<?php 
    19502408} 
    19512409 
     2410/** 
     2411 * handles an import file upload 
     2412 * 
     2413 * @return array array containing attachment data 
     2414 */ 
    19522415function wp_import_handle_upload() { 
    19532416        $overrides = array( 'test_form' => false, 'test_type' => false ); 
    19542417        $file = wp_handle_upload( $_FILES['import'], $overrides ); 
     
    19742437        return array( 'file' => $file, 'id' => $id ); 
    19752438} 
    19762439 
     2440/** 
     2441 * output the attachment links form  
     2442 * 
     2443 * @param int $id attachment ID  
     2444 */ 
    19772445function the_attachment_links( $id = false ) { 
    19782446        $id = (int) $id; 
    19792447        $post = & get_post( $id ); 
     
    20172485<?php 
    20182486} 
    20192487 
     2488/** 
     2489 * compute and return dimensions for displaying a "thumbnail"; apparently not used 
     2490 * 
     2491 * @return array 
     2492 */ 
    20202493function get_udims( $width, $height) { 
    20212494        if ( $height <= 96 && $width <= 128 ) 
    20222495                return array( $width, $height); 
     
    20262499                return array( (int) ($width / $height * 96 ), 96 ); 
    20272500} 
    20282501 
     2502/** 
     2503 * resets the variables passed 
     2504 * 
     2505 * @param array $vars array of variable names 
     2506 */ 
    20292507function wp_reset_vars( $vars ) { 
    20302508        for ( $i=0; $i<count( $vars ); $i += 1 ) { 
    20312509                $var = $vars[$i]; 
     
    20442522        } 
    20452523} 
    20462524 
    2047  
     2525/** 
     2526 * output a hidden input field with the current post slug 
     2527 */ 
    20482528function wp_remember_old_slug() { 
    20492529        global $post; 
    20502530        $name = attribute_escape($post->post_name); // just in case 
     
    20532533} 
    20542534 
    20552535 
    2056 // If siteurl or home changed, reset cookies and flush rewrite rules. 
     2536/** 
     2537 * If siteurl or home changed, reset cookies and flush rewrite rules. 
     2538 * 
     2539 * @param string $old_value 
     2540 * @param string $value 
     2541 */ 
    20572542function update_home_siteurl( $old_value, $value ) { 
    20582543        global $wp_rewrite, $user_login, $user_pass_md5; 
    20592544 
     
    20712556add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); 
    20722557add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); 
    20732558 
     2559/** 
     2560 * crop an image 
     2561 * 
     2562 * @param mixed $src_file filename or attachment ID 
     2563 * @param int $src_x starting x 
     2564 * @param int $src_y starting y 
     2565 * @param int $src_w crop width 
     2566 * @param int $src_h crop height 
     2567 * @param int $dst_w output width 
     2568 * @param int $dst_h output width 
     2569 * @param bool $src_abs whether $src_w and $src_h are absolute coordinates instead of width and height 
     2570 * @param string $dst_file destination filename 
     2571 * @return mixed the path to the cropped file or false on error 
     2572 */ 
    20742573function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) { 
    20752574        if ( ctype_digit( $src_file ) ) // Handle int as attachment ID 
    20762575                $src_file = get_attached_file( $src_file ); 
     
    21032602                return false; 
    21042603} 
    21052604 
     2605/** 
     2606 * load an image 
     2607 * 
     2608 * @param mixed $file file name or attachment ID 
     2609 * @return int resource 
     2610 */ 
    21062611function wp_load_image( $file ) { 
    21072612        if ( ctype_digit( $file ) ) 
    21082613                $file = get_attached_file( $file ); 
     
    21232628        return $image; 
    21242629} 
    21252630 
     2631/** 
     2632 * retrieve metadata for an image attachment 
     2633 * 
     2634 * @filter wp_generate_attachment_metadata 
     2635 * @filter wp_thumbnail_creation_size_limit 
     2636 * @filter wp_thumbnail_max_side_length 
     2637 * @param int $attachment_id attachment ID 
     2638 * @param string $file file path 
     2639 * @return array 
     2640 */ 
    21262641function wp_generate_attachment_metadata( $attachment_id, $file ) { 
    21272642        $attachment = get_post( $attachment_id ); 
    21282643 
     
    21482663        return apply_filters( 'wp_generate_attachment_metadata', $metadata ); 
    21492664} 
    21502665 
     2666/** 
     2667 * create a thumbnail 
     2668 * 
     2669 * @filter thumbnail_filename  
     2670 * @filter wp_create_thumbnail 
     2671 * @param string $file file name 
     2672 * @param int $max_side length of the longest side 
     2673 * @param string $effect apparently unused 
     2674 * @return string thumbnail path 
     2675 */ 
    21512676function wp_create_thumbnail( $file, $max_side, $effect = '' ) { 
    21522677 
    21532678                // 1 = GIF, 2 = JPEG, 3 = PNG