Ticket #5635: classes.phpdoc.r6597.diff
| File classes.phpdoc.r6597.diff, 18.8 KB (added by , 18 years ago) |
|---|
-
classes.php
1 1 <?php 2 /** 3 * Holds Most of the WordPress classes 4 * 5 * Some of the other classes are contained in other files. 6 * For example, the WordPress cache is in cache.php and the 7 * WordPress roles API is in capabilities.php. The third 8 * party libraries are contained in their own separate files. 9 * 10 * @package WordPress 11 */ 2 12 13 /** 14 * 15 * 16 * @package WordPress 17 * @since 18 */ 3 19 class WP { 20 /** 21 * {@internal Missing Description}} 22 * 23 * @since 24 * @access public 25 * @var unknown_type 26 */ 4 27 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots'); 5 28 29 /** 30 * {@internal Missing Description}} 31 * 32 * @since 33 * @var unknown_type 34 */ 6 35 var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id'); 36 37 /** 38 * {@internal Missing Description}} 39 * 40 * @since 41 * @var unknown_type 42 */ 7 43 var $extra_query_vars = array(); 8 44 45 /** 46 * {@internal Missing Description}} 47 * 48 * @since 49 * @var unknown_type 50 */ 9 51 var $query_vars; 52 53 /** 54 * {@internal Missing Description}} 55 * 56 * @since 57 * @var unknown_type 58 */ 10 59 var $query_string; 60 61 /** 62 * {@internal Missing Description}} 63 * 64 * @since 65 * @var unknown_type 66 */ 11 67 var $request; 68 69 /** 70 * {@internal Missing Description}} 71 * 72 * @since 73 * @var unknown_type 74 */ 12 75 var $matched_rule; 76 77 /** 78 * {@internal Missing Description}} 79 * 80 * @since 81 * @var unknown_type 82 */ 13 83 var $matched_query; 84 85 /** 86 * {@internal Missing Description}} 87 * 88 * @since 89 * @var unknown_type 90 */ 14 91 var $did_permalink = false; 15 92 93 /** 94 * {@internal Missing Short Description}} 95 * 96 * {@internal Missing Long Description}} 97 * 98 * @since 99 * 100 * @param unknown_type $qv 101 */ 16 102 function add_query_var($qv) { 17 103 $this->public_query_vars[] = $qv; 18 104 } 19 105 106 /** 107 * {@internal Missing Short Description}} 108 * 109 * {@internal Missing Long Description}} 110 * 111 * @since 112 * 113 * @param unknown_type $key 114 * @param unknown_type $value 115 */ 20 116 function set_query_var($key, $value) { 21 117 $this->query_vars[$key] = $value; 22 118 } 23 119 120 /** 121 * {@internal Missing Short Description}} 122 * 123 * {@internal Missing Long Description}} 124 * 125 * @since 126 * 127 * @param unknown_type $extra_query_vars 128 */ 24 129 function parse_request($extra_query_vars = '') { 25 130 global $wp_rewrite; 26 131 … … 172 277 do_action_ref_array('parse_request', array(&$this)); 173 278 } 174 279 280 /** 281 * {@internal Missing Short Description}} 282 * 283 * {@internal Missing Long Description}} 284 * 285 * @since 286 */ 175 287 function send_headers() { 176 288 @header('X-Pingback: '. get_bloginfo('pingback_url')); 177 289 if ( is_user_logged_in() ) … … 226 338 do_action_ref_array('send_headers', array(&$this)); 227 339 } 228 340 341 /** 342 * {@internal Missing Short Description}} 343 * 344 * {@internal Missing Long Description}} 345 * 346 * @since 347 */ 229 348 function build_query_string() { 230 349 $this->query_string = ''; 231 350 foreach (array_keys($this->query_vars) as $wpvar) { … … 244 363 } 245 364 } 246 365 366 /** 367 * {@internal Missing Short Description}} 368 * 369 * {@internal Missing Long Description}} 370 * 371 * @since 372 */ 247 373 function register_globals() { 248 374 global $wp_query; 249 375 // Extract updated query vars back into global namespace. … … 262 388 } 263 389 } 264 390 391 /** 392 * {@internal Missing Short Description}} 393 * 394 * {@internal Missing Long Description}} 395 * 396 * @since 397 */ 265 398 function init() { 266 399 wp_get_current_user(); 267 400 } 268 401 402 /** 403 * {@internal Missing Short Description}} 404 * 405 * {@internal Missing Long Description}} 406 * 407 * @since 408 */ 269 409 function query_posts() { 270 410 global $wp_the_query; 271 411 $this->build_query_string(); 272 412 $wp_the_query->query($this->query_vars); 273 413 } 274 414 415 /** 416 * {@internal Missing Short Description}} 417 * 418 * {@internal Missing Long Description}} 419 * 420 * @since 421 */ 275 422 function handle_404() { 276 423 global $wp_query; 277 424 // Issue a 404 if a permalink request doesn't match any posts. Don't … … 287 434 } 288 435 } 289 436 437 /** 438 * {@internal Missing Short Description}} 439 * 440 * {@internal Missing Long Description}} 441 * 442 * @since 443 * 444 * @param unknown_type $query_args 445 */ 290 446 function main($query_args = '') { 291 447 $this->init(); 292 448 $this->parse_request($query_args); … … 297 453 do_action_ref_array('wp', array(&$this)); 298 454 } 299 455 456 /** 457 * {@internal Missing Short Description}} 458 * 459 * {@internal Missing Long Description}} 460 * 461 * @since 462 * 463 * @return WP 464 */ 300 465 function WP() { 301 466 // Empty. 302 467 } 303 468 } 304 469 470 /** 471 * 472 * 473 * @package WordPress 474 */ 305 475 class WP_Error { 476 /** 477 * {@internal Missing Description}} 478 * 479 * @since 480 * @var unknown_type 481 */ 306 482 var $errors = array(); 483 484 /** 485 * {@internal Missing Description}} 486 * 487 * @since 488 * @var unknown_type 489 */ 307 490 var $error_data = array(); 308 491 492 /** 493 * {@internal Missing Short Description}} 494 * 495 * {@internal Missing Long Description}} 496 * 497 * @since 498 * 499 * @param unknown_type $code 500 * @param unknown_type $message 501 * @param unknown_type $data 502 * @return WP_Error 503 */ 309 504 function WP_Error($code = '', $message = '', $data = '') { 310 505 if ( empty($code) ) 311 506 return; … … 316 511 $this->error_data[$code] = $data; 317 512 } 318 513 514 /** 515 * {@internal Missing Short Description}} 516 * 517 * {@internal Missing Long Description}} 518 * 519 * @since 520 * 521 * @return unknown 522 */ 319 523 function get_error_codes() { 320 524 if ( empty($this->errors) ) 321 525 return array(); … … 323 527 return array_keys($this->errors); 324 528 } 325 529 530 /** 531 * {@internal Missing Short Description}} 532 * 533 * {@internal Missing Long Description}} 534 * 535 * @since 536 * 537 * @return unknown 538 */ 326 539 function get_error_code() { 327 540 $codes = $this->get_error_codes(); 328 541 … … 332 545 return $codes[0]; 333 546 } 334 547 548 /** 549 * {@internal Missing Short Description}} 550 * 551 * {@internal Missing Long Description}} 552 * 553 * @since 554 * 555 * @param unknown_type $code 556 * @return unknown 557 */ 335 558 function get_error_messages($code = '') { 336 559 // Return all messages if no code specified. 337 560 if ( empty($code) ) { … … 348 571 return array(); 349 572 } 350 573 574 /** 575 * {@internal Missing Short Description}} 576 * 577 * {@internal Missing Long Description}} 578 * 579 * @since 580 * 581 * @param unknown_type $code 582 * @return unknown 583 */ 351 584 function get_error_message($code = '') { 352 585 if ( empty($code) ) 353 586 $code = $this->get_error_code(); … … 357 590 return $messages[0]; 358 591 } 359 592 593 /** 594 * {@internal Missing Short Description}} 595 * 596 * {@internal Missing Long Description}} 597 * 598 * @since 599 * 600 * @param unknown_type $code 601 * @return unknown 602 */ 360 603 function get_error_data($code = '') { 361 604 if ( empty($code) ) 362 605 $code = $this->get_error_code(); … … 366 609 return null; 367 610 } 368 611 612 /** 613 * {@internal Missing Short Description}} 614 * 615 * {@internal Missing Long Description}} 616 * 617 * @since 618 * 619 * @param unknown_type $code 620 * @param unknown_type $message 621 * @param unknown_type $data 622 */ 369 623 function add($code, $message, $data = '') { 370 624 $this->errors[$code][] = $message; 371 625 if ( ! empty($data) ) 372 626 $this->error_data[$code] = $data; 373 627 } 374 628 629 /** 630 * {@internal Missing Short Description}} 631 * 632 * {@internal Missing Long Description}} 633 * 634 * @since 635 * 636 * @param unknown_type $data 637 * @param unknown_type $code 638 */ 375 639 function add_data($data, $code = '') { 376 640 if ( empty($code) ) 377 641 $code = $this->get_error_code(); … … 380 644 } 381 645 } 382 646 647 /** 648 * is_wp_error() - {@internal Missing Short Description}} 649 * 650 * {@internal Missing Long Description}} 651 * 652 * @since 653 * 654 * @param unknown_type $thing 655 * @return unknown 656 */ 383 657 function is_wp_error($thing) { 384 658 if ( is_object($thing) && is_a($thing, 'WP_Error') ) 385 659 return true; … … 390 664 * A class for displaying various tree-like structures. 391 665 * Extend the Walker class to use it, see examples at the bottom 392 666 */ 667 /** 668 * 669 * 670 * @package WordPress 671 * @since 672 */ 393 673 class Walker { 674 /** 675 * {@internal Missing Description}} 676 * 677 * @since 678 * @var unknown_type 679 */ 394 680 var $tree_type; 681 682 /** 683 * {@internal Missing Description}} 684 * 685 * @since 686 * @var unknown_type 687 */ 395 688 var $db_fields; 396 689 397 //abstract callbacks 690 /** 691 * {@internal Missing Short Description}} 692 * 693 * {@internal Missing Long Description}} 694 * 695 * @since 696 * @abstract 697 * 698 * @param unknown_type $output 699 * @return unknown 700 */ 398 701 function start_lvl($output) { return $output; } 702 703 /** 704 * {@internal Missing Short Description}} 705 * 706 * {@internal Missing Long Description}} 707 * 708 * @since 709 * @abstract 710 * 711 * @param unknown_type $output 712 * @return unknown 713 */ 399 714 function end_lvl($output) { return $output; } 715 716 /** 717 * {@internal Missing Short Description}} 718 * 719 * {@internal Missing Long Description}} 720 * 721 * @since 722 * @abstract 723 * 724 * @param unknown_type $output 725 * @return unknown 726 */ 400 727 function start_el($output) { return $output; } 728 729 /** 730 * {@internal Missing Short Description}} 731 * 732 * {@internal Missing Long Description}} 733 * 734 * @since 735 * @abstract 736 * 737 * @param unknown_type $output 738 * @return unknown 739 */ 401 740 function end_el($output) { return $output; } 402 741 403 742 /* 404 743 * display one element if the element doesn't have any children 405 744 * otherwise, display the element and its children 406 745 */ 746 /** 747 * {@internal Missing Short Description}} 748 * 749 * {@internal Missing Long Description}} 750 * 751 * @since 752 * 753 * @param unknown_type $element 754 * @param unknown_type $children_elements 755 * @param unknown_type $max_depth 756 * @param unknown_type $depth 757 * @param unknown_type $args 758 * @param unknown_type $output 759 * @return unknown 760 */ 407 761 function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, $output ) { 408 762 409 763 if ( !$element) … … 452 806 } 453 807 454 808 /* 455 * displays array of elements hierarchically 456 * it is a generic function which does not assume any existing order of elements 457 * max_depth = -1 means flatly display every element 458 * max_depth = 0 means display all levels 459 * max_depth > 0 specifies the number of display levels. 460 */ 809 * displays array of elements hierarchically 810 * it is a generic function which does not assume any existing order of elements 811 * max_depth = -1 means flatly display every element 812 * max_depth = 0 means display all levels 813 * max_depth > 0 specifies the number of display levels. 814 */ 815 /** 816 * {@internal Missing Short Description}} 817 * 818 * {@internal Missing Long Description}} 819 * 820 * @since 821 * 822 * @param unknown_type $elements 823 * @param unknown_type $max_depth 824 * @return unknown 825 */ 461 826 function walk( $elements, $max_depth) { 462 827 463 828 $args = array_slice(func_get_args(), 2); … … 514 879 $output = $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); 515 880 516 881 /* 517 * if we are displaying all levels, and remaining children_elements is not empty,518 * then we got orphans, which should be displayed regardless519 */882 * if we are displaying all levels, and remaining children_elements is not empty, 883 * then we got orphans, which should be displayed regardless 884 */ 520 885 if ( ( $max_depth == 0 ) && sizeof( $children_elements ) > 0 ) { 521 886 $empty_array = array(); 522 887 foreach ( $children_elements as $orphan_e ) … … 526 891 } 527 892 } 528 893 894 /** 895 * 896 * 897 * @package WordPress 898 * @since 899 * @uses 900 */ 529 901 class Walker_Page extends Walker { 902 /** 903 * {@internal Missing Description}} 904 * 905 * @since 906 * @var unknown_type 907 */ 530 908 var $tree_type = 'page'; 531 var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this532 909 910 /** 911 * {@internal Missing Description}} 912 * 913 * @since 914 * @todo decouple this 915 * @var unknown_type 916 */ 917 var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); 918 919 /** 920 * {@internal Missing Short Description}} 921 * 922 * {@internal Missing Long Description}} 923 * 924 * @since 925 * 926 * @param unknown_type $output 927 * @param unknown_type $depth 928 * @return unknown 929 */ 533 930 function start_lvl($output, $depth) { 534 931 $indent = str_repeat("\t", $depth); 535 932 $output .= "\n$indent<ul>\n"; 536 933 return $output; 537 934 } 538 935 936 /** 937 * {@internal Missing Short Description}} 938 * 939 * {@internal Missing Long Description}} 940 * 941 * @since 942 * 943 * @param unknown_type $output 944 * @param unknown_type $depth 945 * @return unknown 946 */ 539 947 function end_lvl($output, $depth) { 540 948 $indent = str_repeat("\t", $depth); 541 949 $output .= "$indent</ul>\n"; 542 950 return $output; 543 951 } 544 952 953 /** 954 * {@internal Missing Short Description}} 955 * 956 * {@internal Missing Long Description}} 957 * 958 * @since 959 * 960 * @param unknown_type $output 961 * @param unknown_type $page 962 * @param unknown_type $depth 963 * @param unknown_type $current_page 964 * @param unknown_type $args 965 * @return unknown 966 */ 545 967 function start_el($output, $page, $depth, $current_page, $args) { 546 968 if ( $depth ) 547 969 $indent = str_repeat("\t", $depth); … … 570 992 return $output; 571 993 } 572 994 995 /** 996 * {@internal Missing Short Description}} 997 * 998 * {@internal Missing Long Description}} 999 * 1000 * @since 1001 * 1002 * @param unknown_type $output 1003 * @param unknown_type $page 1004 * @param unknown_type $depth 1005 * @return unknown 1006 */ 573 1007 function end_el($output, $page, $depth) { 574 1008 $output .= "</li>\n"; 575 1009 … … 578 1012 579 1013 } 580 1014 1015 /** 1016 * 1017 * 1018 * @package WordPress 1019 * @since 1020 * @uses Walker 1021 */ 581 1022 class Walker_PageDropdown extends Walker { 1023 /** 1024 * {@internal Missing Description}} 1025 * 1026 * @since 1027 * @var unknown_type 1028 */ 582 1029 var $tree_type = 'page'; 583 var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this584 1030 1031 /** 1032 * {@internal Missing Description}} 1033 * 1034 * @since 1035 * @todo Decouple this 1036 * @var unknown_type 1037 */ 1038 var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); 1039 1040 /** 1041 * {@internal Missing Short Description}} 1042 * 1043 * {@internal Missing Long Description}} 1044 * 1045 * @since 1046 * 1047 * @param unknown_type $output 1048 * @param unknown_type $page 1049 * @param unknown_type $depth 1050 * @param unknown_type $args 1051 * @return unknown 1052 */ 585 1053 function start_el($output, $page, $depth, $args) { 586 1054 $pad = str_repeat(' ', $depth * 3); 587 1055 … … 597 1065 } 598 1066 } 599 1067 1068 /** 1069 * 1070 * 1071 * @package WordPress 1072 * @since 1073 * @uses Walker 1074 */ 600 1075 class Walker_Category extends Walker { 1076 /** 1077 * {@internal Missing Description}} 1078 * 1079 * @since 1080 * @var unknown_type 1081 */ 601 1082 var $tree_type = 'category'; 602 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this603 1083 1084 /** 1085 * {@internal Missing Description}} 1086 * 1087 * @since 1088 * @todo Decouple this 1089 * @var unknown_type 1090 */ 1091 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); 1092 1093 /** 1094 * {@internal Missing Short Description}} 1095 * 1096 * {@internal Missing Long Description}} 1097 * 1098 * @since 1099 * 1100 * @param unknown_type $output 1101 * @param unknown_type $depth 1102 * @param unknown_type $args 1103 * @return unknown 1104 */ 604 1105 function start_lvl($output, $depth, $args) { 605 1106 if ( 'list' != $args['style'] ) 606 1107 return $output; … … 610 1111 return $output; 611 1112 } 612 1113 1114 /** 1115 * {@internal Missing Short Description}} 1116 * 1117 * {@internal Missing Long Description}} 1118 * 1119 * @since 1120 * 1121 * @param unknown_type $output 1122 * @param unknown_type $depth 1123 * @param unknown_type $args 1124 * @return unknown 1125 */ 613 1126 function end_lvl($output, $depth, $args) { 614 1127 if ( 'list' != $args['style'] ) 615 1128 return $output; … … 619 1132 return $output; 620 1133 } 621 1134 1135 /** 1136 * {@internal Missing Short Description}} 1137 * 1138 * {@internal Missing Long Description}} 1139 * 1140 * @since 1141 * 1142 * @param unknown_type $output 1143 * @param unknown_type $category 1144 * @param unknown_type $depth 1145 * @param unknown_type $args 1146 * @return unknown 1147 */ 622 1148 function start_el($output, $category, $depth, $args) { 623 1149 extract($args); 624 1150 … … 686 1212 return $output; 687 1213 } 688 1214 1215 /** 1216 * {@internal Missing Short Description}} 1217 * 1218 * {@internal Missing Long Description}} 1219 * 1220 * @since 1221 * 1222 * @param unknown_type $output 1223 * @param unknown_type $page 1224 * @param unknown_type $depth 1225 * @param unknown_type $args 1226 * @return unknown 1227 */ 689 1228 function end_el($output, $page, $depth, $args) { 690 1229 if ( 'list' != $args['style'] ) 691 1230 return $output; … … 696 1235 697 1236 } 698 1237 1238 /** 1239 * 1240 * 1241 * @package WordPress 1242 * @since 1243 * @uses Walker 1244 */ 699 1245 class Walker_CategoryDropdown extends Walker { 1246 /** 1247 * {@internal Missing Description}} 1248 * 1249 * @since 1250 * @var unknown_type 1251 */ 700 1252 var $tree_type = 'category'; 701 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this702 1253 1254 /** 1255 * {@internal Missing Description}} 1256 * 1257 * @since 1258 * @todo Decouple this 1259 * @var unknown_type 1260 */ 1261 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); 1262 1263 /** 1264 * {@internal Missing Short Description}} 1265 * 1266 * {@internal Missing Long Description}} 1267 * 1268 * @since 1269 * 1270 * @param unknown_type $output 1271 * @param unknown_type $category 1272 * @param unknown_type $depth 1273 * @param unknown_type $args 1274 * @return unknown 1275 */ 703 1276 function start_el($output, $category, $depth, $args) { 704 1277 $pad = str_repeat(' ', $depth * 3); 705 1278 … … 721 1294 } 722 1295 } 723 1296 1297 /** 1298 * 1299 * 1300 * @package WordPress 1301 * @since 1302 */ 724 1303 class WP_Ajax_Response { 1304 /** 1305 * {@internal Missing Description}} 1306 * 1307 * @since 1308 * @var unknown_type 1309 */ 725 1310 var $responses = array(); 726 1311 1312 /** 1313 * {@internal Missing Short Description}} 1314 * 1315 * {@internal Missing Long Description}} 1316 * 1317 * @since 1318 * 1319 * @param unknown_type $args 1320 * @return WP_Ajax_Response 1321 */ 727 1322 function WP_Ajax_Response( $args = '' ) { 728 1323 if ( !empty($args) ) 729 1324 $this->add($args); 730 1325 } 731 1326 732 1327 // a WP_Error object can be passed in 'id' or 'data' 1328 /** 1329 * {@internal Missing Short Description}} 1330 * 1331 * {@internal Missing Long Description}} 1332 * 1333 * @since 1334 * 1335 * @param unknown_type $args 1336 * @return unknown 1337 */ 733 1338 function add( $args = '' ) { 734 1339 $defaults = array( 735 1340 'what' => 'object', 'action' => false, … … 794 1399 return $x; 795 1400 } 796 1401 1402 /** 1403 * {@internal Missing Short Description}} 1404 * 1405 * {@internal Missing Long Description}} 1406 * 1407 * @since 1408 */ 797 1409 function send() { 798 1410 header('Content-Type: text/xml'); 799 1411 echo "<?xml version='1.0' standalone='yes'?><wp_ajax>";