X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/11be8dc178e77d0b46189bbd8e33a216a9b90942..9c40b4d36daed9e28e48a5fe9205c32557195a4b:/wp-admin/includes/template.php diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 2566a616..13faf106 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -21,8 +21,25 @@ * @param unknown_type $per_page */ function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20 ) { + $count = 0; - _cat_rows($categories, $count, $parent, $level, $page, $per_page); + + if ( empty($categories) ) { + + $args = array('hide_empty' => 0); + if ( !empty($_GET['s']) ) + $args['search'] = $_GET['s']; + + $categories = get_categories( $args ); + + if ( empty($categories) ) + return false; + } + + $children = _get_term_hierarchy('category'); + + _cat_rows( $parent, $level, $categories, $children, $page, $per_page, $count ); + } /** @@ -38,42 +55,32 @@ function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_pag * @param unknown_type $per_page * @return unknown */ -function _cat_rows( $categories, &$count, $parent = 0, $level = 0, $page = 1, $per_page = 20 ) { - if ( empty($categories) ) { - $args = array('hide_empty' => 0); - if ( !empty($_GET['s']) ) - $args['search'] = $_GET['s']; - $categories = get_categories( $args ); - } - - if ( !$categories ) - return false; - - $children = _get_term_hierarchy('category'); +function _cat_rows( $parent = 0, $level = 0, $categories, &$children, $page = 1, $per_page = 20, &$count ) { $start = ($page - 1) * $per_page; $end = $start + $per_page; - $i = -1; ob_start(); - foreach ( $categories as $category ) { + + foreach ( $categories as $key => $category ) { if ( $count >= $end ) break; - $i++; - - if ( $category->parent != $parent ) + if ( $category->parent != $parent && empty($_GET['s']) ) continue; // If the page starts in a subtree, print the parents. if ( $count == $start && $category->parent > 0 ) { + $my_parents = array(); - while ( $my_parent) { - $my_parent = get_category($my_parent); + $p = $category->parent; + while ( $p ) { + $my_parent = get_category( $p ); $my_parents[] = $my_parent; - if ( !$my_parent->parent ) + if ( $my_parent->parent == 0 ) break; - $my_parent = $my_parent->parent; + $p = $my_parent->parent; } + $num_parents = count($my_parents); while( $my_parent = array_pop($my_parents) ) { echo "\t" . _cat_row( $my_parent, $level - $num_parents ); @@ -84,12 +91,12 @@ function _cat_rows( $categories, &$count, $parent = 0, $level = 0, $page = 1, $p if ( $count >= $start ) echo "\t" . _cat_row( $category, $level ); - unset($categories[$i]); // Prune the working set + unset( $categories[ $key ] ); + $count++; if ( isset($children[$category->term_id]) ) - _cat_rows( $categories, $count, $category->term_id, $level + 1, $page, $per_page ); - + _cat_rows( $category->term_id, $level + 1, $categories, $children, $page, $per_page, $count ); } $output = ob_get_contents(); @@ -114,16 +121,17 @@ function _cat_row( $category, $level, $name_override = false ) { $category = get_category( $category, OBJECT, 'display' ); $default_cat_id = (int) get_option( 'default_category' ); - $pad = str_repeat( '— ', $level ); + $pad = str_repeat( '— ', max(0, $level) ); $name = ( $name_override ? $name_override : $pad . ' ' . $category->name ); $edit_link = "categories.php?action=edit&cat_ID=$category->term_id"; if ( current_user_can( 'manage_categories' ) ) { - $edit = "name)) . "'>" . attribute_escape( $name ) . '
'; + $edit = "name)) . "'>" . esc_attr( $name ) . '
'; $actions = array(); $actions['edit'] = '' . __('Edit') . ''; $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; if ( $default_cat_id != $category->term_id ) - $actions['delete'] = "term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . ""; + $actions['delete'] = "term_id) . "'>" . __('Delete') . ""; + $actions = apply_filters('cat_row_actions', $actions, $category); $action_count = count($actions); $i = 0; $edit .= '
'; @@ -181,6 +189,11 @@ function _cat_row( $category, $level, $name_override = false ) { case 'posts': $attributes = 'class="posts column-posts num"' . $style; $output .= "$posts_count\n"; + break; + default: + $output .= ""; + $output .= apply_filters('manage_categories_custom_column', '', $column_name, $category->term_id); + $output .= ""; } } $output .= ''; @@ -251,8 +264,8 @@ function inline_edit_term_row($type) {

- - + +
@@ -283,12 +296,13 @@ function link_cat_row( $category, $name_override = false ) { $name = ( $name_override ? $name_override : $category->name ); $edit_link = "link-category.php?action=edit&cat_ID=$category->term_id"; if ( current_user_can( 'manage_categories' ) ) { - $edit = "name)) . "'>$name
"; + $edit = "name)) . "'>$name
"; $actions = array(); $actions['edit'] = '' . __('Edit') . ''; $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; if ( $default_cat_id != $category->term_id ) - $actions['delete'] = "term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . ""; + $actions['delete'] = "term_id) . "'>" . __('Delete') . ""; + $actions = apply_filters('link_cat_row_actions', $actions, $category); $action_count = count($actions); $i = 0; $edit .= '

'; @@ -345,6 +359,11 @@ function link_cat_row( $category, $name_override = false ) { case 'links': $attributes = 'class="links column-links num"' . $style; $output .= "$count"; + break; + default: + $output .= ""; + $output .= apply_filters('manage_link_categories_custom_column', '', $column_name, $category->term_id); + $output .= ""; } } $output .= ''; @@ -353,29 +372,58 @@ function link_cat_row( $category, $name_override = false ) { } /** - * {@internal Missing Short Description}} + * Outputs the html checked attribute. * - * @since unknown + * Compares the first two arguments and if identical marks as checked + * + * @since 2.8 * - * @param unknown_type $checked - * @param unknown_type $current + * @param any $checked One of the values to compare + * @param any $current (true) The other value to compare if not just true + * @param bool $echo Whether or not to echo or just return the string */ -function checked( $checked, $current) { - if ( $checked == $current) - echo ' checked="checked"'; +function checked( $checked, $current = true, $echo = true) { + return __checked_selected_helper( $checked, $current, $echo, 'checked' ); } /** - * {@internal Missing Short Description}} + * Outputs the html selected attribute. * - * @since unknown + * Compares the first two arguments and if identical marks as selected * - * @param unknown_type $selected - * @param unknown_type $current + * @since 2.8 + * + * @param any selected One of the values to compare + * @param any $current (true) The other value to compare if not just true + * @param bool $echo Whether or not to echo or just return the string */ -function selected( $selected, $current) { - if ( $selected == $current) - echo ' selected="selected"'; +function selected( $selected, $current = true, $echo = true) { + return __checked_selected_helper( $selected, $current, $echo, 'selected' ); +} + +/** + * Private helper function for checked and selected. + * + * Compares the first two arguments and if identical marks as $type + * + * @since 2.8 + * @access private + * + * @param any $helper One of the values to compare + * @param any $current (true) The other value to compare if not just true + * @param bool $echo Whether or not to echo or just return the string + * @param string $type The type of checked|selected we are doing. + */ +function __checked_selected_helper( $helper, $current, $echo, $type) { + if ( $helper == $current) + $result = " $type='$type'"; + else + $result = ''; + + if ($echo) + echo $result; + + return $result; } // @@ -421,7 +469,7 @@ class Walker_Category_Checklist extends Walker { extract($args); $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; - $output .= "\n
  • " . ''; + $output .= "\n
  • " . ''; } function end_el(&$output, $category, $depth, $args) { @@ -469,10 +517,12 @@ function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $select // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) $checked_categories = array(); - for ( $i = 0; isset($categories[$i]); $i++ ) { - if ( in_array($categories[$i]->term_id, $args['selected_cats']) ) { - $checked_categories[] = $categories[$i]; - unset($categories[$i]); + $keys = array_keys( $categories ); + + foreach( $keys as $k ) { + if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) { + $checked_categories[] = $categories[$k]; + unset( $categories[$k] ); } } @@ -512,7 +562,7 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ech
  • @@ -564,7 +614,7 @@ function wp_link_category_checklist( $link_id = 0 ) { foreach ( $categories as $category ) { $cat_id = $category->term_id; - $name = wp_specialchars( apply_filters('the_category', $category->name)); + $name = esc_html( apply_filters('the_category', $category->name)); $checked = in_array( $cat_id, $checked_categories ); echo '"; } @@ -583,13 +633,14 @@ function wp_link_category_checklist( $link_id = 0 ) { * @param unknown_type $class * @return unknown */ -function _tag_row( $tag, $class = '' ) { +function _tag_row( $tag, $class = '', $taxonomy = 'post_tag' ) { $count = number_format_i18n( $tag->count ); - $count = ( $count > 0 ) ? "$count" : $count; + $tagsel = ($taxonomy == 'post_tag' ? 'tag' : $taxonomy); + $count = ( $count > 0 ) ? "$count" : $count; $name = apply_filters( 'term_name', $tag->name ); - $qe_data = get_term($tag->term_id, 'post_tag', object, 'edit'); - $edit_link = "edit-tags.php?action=edit&tag_ID=$tag->term_id"; + $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit'); + $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&tag_ID=$tag->term_id"; $out = ''; $out .= ''; $columns = get_column_headers('edit-tags'); @@ -608,11 +659,12 @@ function _tag_row( $tag, $class = '' ) { $out .= ' '; break; case 'name': - $out .= '' . $name . '
    '; + $out .= '' . $name . '
    '; $actions = array(); $actions['edit'] = '' . __('Edit') . ''; $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; - $actions['delete'] = "term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this tag '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . ""; + $actions['delete'] = "term_id) . "'>" . __('Delete') . ""; + $actions = apply_filters('tag_row_actions', $actions, $tag); $action_count = count($actions); $i = 0; $out .= '
    '; @@ -626,6 +678,9 @@ function _tag_row( $tag, $class = '' ) { $out .= '
    ' . $qe_data->name . '
    '; $out .= '
    ' . $qe_data->slug . '
    '; break; + case 'description': + $out .= "$tag->description"; + break; case 'slug': $out .= "$tag->slug"; break; @@ -633,6 +688,10 @@ function _tag_row( $tag, $class = '' ) { $attributes = 'class="posts column-posts num"' . $style; $out .= "$count"; break; + default: + $out .= ""; + $out .= apply_filters("manage_${taxonomy}_custom_column", '', $column_name, $tag->term_id); + $out .= ""; } } @@ -654,7 +713,7 @@ function _tag_row( $tag, $class = '' ) { * @param unknown_type $searchterms * @return unknown */ -function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) { +function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'post_tag' ) { // Get a page worth of tags $start = ($page - 1) * $pagesize; @@ -665,13 +724,13 @@ function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) { $args['search'] = $searchterms; } - $tags = get_terms( 'post_tag', $args ); + $tags = get_terms( $taxonomy, $args ); // convert it to table rows $out = ''; $count = 0; foreach( $tags as $tag ) - $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"' ); + $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"', $taxonomy ); // filter and send to screen echo $out; @@ -689,7 +748,8 @@ function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) { function wp_manage_posts_columns() { $posts_columns = array(); $posts_columns['cb'] = ''; - $posts_columns['title'] = _c('Post|noun'); + /* translators: manage posts column name */ + $posts_columns['title'] = _x('Post', 'column name'); $posts_columns['author'] = __('Author'); $posts_columns['categories'] = __('Categories'); $posts_columns['tags'] = __('Tags'); @@ -713,13 +773,16 @@ function wp_manage_media_columns() { $posts_columns = array(); $posts_columns['cb'] = ''; $posts_columns['icon'] = ''; - $posts_columns['media'] = _c('File|media column header'); + /* translators: column name */ + $posts_columns['media'] = _x('File', 'column name'); $posts_columns['author'] = __('Author'); - //$posts_columns['tags'] = _c('Tags|media column header'); - $posts_columns['parent'] = _c('Attached to|media column header'); + //$posts_columns['tags'] = _x('Tags', 'column name'); + /* translators: column name */ + $posts_columns['parent'] = _x('Attached to', 'column name'); $posts_columns['comments'] = '
    Comments
    '; //$posts_columns['comments'] = __('Comments'); - $posts_columns['date'] = _c('Date|media column header'); + /* translators: column name */ + $posts_columns['date'] = _x('Date', 'column name'); $posts_columns = apply_filters('manage_media_columns', $posts_columns); return $posts_columns; @@ -777,7 +840,8 @@ function get_column_headers($page) { $_wp_column_headers[$page] = array( 'cb' => '', 'author' => __('Author'), - 'comment' => _c('Comment|noun'), + /* translators: column name */ + 'comment' => _x('Comment', 'column name'), //'date' => __('Submitted'), 'response' => __('In Response To') ); @@ -789,8 +853,9 @@ function get_column_headers($page) { 'name' => __('Name'), 'url' => __('URL'), 'categories' => __('Categories'), - 'rel' => __('rel'), - 'visible' => __('Visible') + 'rel' => __('Relationship'), + 'visible' => __('Visible'), + 'rating' => __('Rating') ); break; @@ -821,6 +886,7 @@ function get_column_headers($page) { $_wp_column_headers[$page] = array( 'cb' => '', 'name' => __('Name'), + 'description' => __('Description'), 'slug' => __('Slug'), 'posts' => __('Posts') ); @@ -1014,8 +1080,12 @@ function inline_edit_row( $type ) { - - + + + @@ -1188,12 +1258,12 @@ function inline_edit_row( $type ) { wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); $update_text = ( $is_page ) ? __( 'Update Page' ) : __( 'Update Post' ); ?> - - + + - +
    @@ -1219,7 +1289,7 @@ function get_inline_data($post) { if ( ! current_user_can('edit_' . $post->post_type, $post->ID) ) return; - $title = attribute_escape($post->post_title); + $title = esc_attr($post->post_title); echo '