-
+ F678938E7127CE73F908A52F25E795E5101EF111E70514309FC9FFDDCBE8ECE5443E0BFF8E216BCB769B0DF72C2BADAFC1B0D087D6AABAD999C9401141665E63
mp-wp/wp-admin/includes/template.php
(0 . 0)(1 . 3449)
40940 <?php
40941 /**
40942 * Template WordPress Administration API.
40943 *
40944 * A Big Mess. Also some neat functions that are nicely written.
40945 *
40946 * @package WordPress
40947 * @subpackage Administration
40948 */
40949
40950 // Ugly recursive category stuff.
40951 /**
40952 * {@internal Missing Short Description}}
40953 *
40954 * @since unknown
40955 *
40956 * @param unknown_type $parent
40957 * @param unknown_type $level
40958 * @param unknown_type $categories
40959 * @param unknown_type $page
40960 * @param unknown_type $per_page
40961 */
40962 function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20 ) {
40963 $count = 0;
40964 _cat_rows($categories, $count, $parent, $level, $page, $per_page);
40965 }
40966
40967 /**
40968 * {@internal Missing Short Description}}
40969 *
40970 * @since unknown
40971 *
40972 * @param unknown_type $categories
40973 * @param unknown_type $count
40974 * @param unknown_type $parent
40975 * @param unknown_type $level
40976 * @param unknown_type $page
40977 * @param unknown_type $per_page
40978 * @return unknown
40979 */
40980 function _cat_rows( $categories, &$count, $parent = 0, $level = 0, $page = 1, $per_page = 20 ) {
40981 if ( empty($categories) ) {
40982 $args = array('hide_empty' => 0);
40983 if ( !empty($_GET['s']) )
40984 $args['search'] = $_GET['s'];
40985 $categories = get_categories( $args );
40986 }
40987
40988 if ( !$categories )
40989 return false;
40990
40991 $children = _get_term_hierarchy('category');
40992
40993 $start = ($page - 1) * $per_page;
40994 $end = $start + $per_page;
40995 $i = -1;
40996 ob_start();
40997 foreach ( $categories as $category ) {
40998 if ( $count >= $end )
40999 break;
41000
41001 $i++;
41002
41003 if ( $category->parent != $parent )
41004 continue;
41005
41006 // If the page starts in a subtree, print the parents.
41007 if ( $count == $start && $category->parent > 0 ) {
41008 $my_parents = array();
41009 while ( $my_parent) {
41010 $my_parent = get_category($my_parent);
41011 $my_parents[] = $my_parent;
41012 if ( !$my_parent->parent )
41013 break;
41014 $my_parent = $my_parent->parent;
41015 }
41016 $num_parents = count($my_parents);
41017 while( $my_parent = array_pop($my_parents) ) {
41018 echo "\t" . _cat_row( $my_parent, $level - $num_parents );
41019 $num_parents--;
41020 }
41021 }
41022
41023 if ( $count >= $start )
41024 echo "\t" . _cat_row( $category, $level );
41025
41026 unset($categories[$i]); // Prune the working set
41027 $count++;
41028
41029 if ( isset($children[$category->term_id]) )
41030 _cat_rows( $categories, $count, $category->term_id, $level + 1, $page, $per_page );
41031
41032 }
41033
41034 $output = ob_get_contents();
41035 ob_end_clean();
41036
41037 echo $output;
41038 }
41039
41040 /**
41041 * {@internal Missing Short Description}}
41042 *
41043 * @since unknown
41044 *
41045 * @param unknown_type $category
41046 * @param unknown_type $level
41047 * @param unknown_type $name_override
41048 * @return unknown
41049 */
41050 function _cat_row( $category, $level, $name_override = false ) {
41051 static $row_class = '';
41052
41053 $category = get_category( $category, OBJECT, 'display' );
41054
41055 $default_cat_id = (int) get_option( 'default_category' );
41056 $pad = str_repeat( '— ', $level );
41057 $name = ( $name_override ? $name_override : $pad . ' ' . $category->name );
41058 $edit_link = "categories.php?action=edit&cat_ID=$category->term_id";
41059 if ( current_user_can( 'manage_categories' ) ) {
41060 $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>" . attribute_escape( $name ) . '</a><br />';
41061 $actions = array();
41062 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
41063 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
41064 if ( $default_cat_id != $category->term_id )
41065 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("categories.php?action=delete&cat_ID=$category->term_id", 'delete-category_' . $category->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') . "</a>";
41066 $action_count = count($actions);
41067 $i = 0;
41068 $edit .= '<div class="row-actions">';
41069 foreach ( $actions as $action => $link ) {
41070 ++$i;
41071 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
41072 $edit .= "<span class='$action'>$link$sep</span>";
41073 }
41074 $edit .= '</div>';
41075 } else {
41076 $edit = $name;
41077 }
41078
41079 $row_class = 'alternate' == $row_class ? '' : 'alternate';
41080 $qe_data = get_category_to_edit($category->term_id);
41081
41082 $category->count = number_format_i18n( $category->count );
41083 $posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count;
41084 $output = "<tr id='cat-$category->term_id' class='iedit $row_class'>";
41085
41086 $columns = get_column_headers('categories');
41087 $hidden = get_hidden_columns('categories');
41088 foreach ( $columns as $column_name => $column_display_name ) {
41089 $class = "class=\"$column_name column-$column_name\"";
41090
41091 $style = '';
41092 if ( in_array($column_name, $hidden) )
41093 $style = ' style="display:none;"';
41094
41095 $attributes = "$class$style";
41096
41097 switch ($column_name) {
41098 case 'cb':
41099 $output .= "<th scope='row' class='check-column'>";
41100 if ( $default_cat_id != $category->term_id ) {
41101 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
41102 } else {
41103 $output .= " ";
41104 }
41105 $output .= '</th>';
41106 break;
41107 case 'name':
41108 $output .= "<td $attributes>$edit";
41109 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
41110 $output .= '<div class="name">' . $qe_data->name . '</div>';
41111 $output .= '<div class="slug">' . $qe_data->slug . '</div>';
41112 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
41113 break;
41114 case 'description':
41115 $output .= "<td $attributes>$category->description</td>";
41116 break;
41117 case 'slug':
41118 $output .= "<td $attributes>$category->slug</td>";
41119 break;
41120 case 'posts':
41121 $attributes = 'class="posts column-posts num"' . $style;
41122 $output .= "<td $attributes>$posts_count</td>\n";
41123 }
41124 }
41125 $output .= '</tr>';
41126
41127 return $output;
41128 }
41129
41130 /**
41131 * {@internal Missing Short Description}}
41132 *
41133 * @since 2.7
41134 *
41135 * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit.
41136 *
41137 * @param string $type "tag", "category" or "link-category"
41138 * @return
41139 */
41140 function inline_edit_term_row($type) {
41141
41142 if ( ! current_user_can( 'manage_categories' ) )
41143 return;
41144
41145 $is_tag = $type == 'edit-tags';
41146 $columns = get_column_headers($type);
41147 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) );
41148 $col_count = count($columns) - count($hidden);
41149 ?>
41150
41151 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
41152 <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $col_count; ?>">
41153
41154 <fieldset><div class="inline-edit-col">
41155 <h4><?php _e( 'Quick Edit' ); ?></h4>
41156
41157 <label>
41158 <span class="title"><?php _e( 'Name' ); ?></span>
41159 <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
41160 </label>
41161
41162 <label>
41163 <span class="title"><?php _e( 'Slug' ); ?></span>
41164 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
41165 </label>
41166
41167 <?php if ( 'category' == $type ) : ?>
41168
41169 <label>
41170 <span class="title"><?php _e( 'Parent' ); ?></span>
41171 <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('None'))); ?>
41172 </label>
41173
41174 <?php endif; // $type ?>
41175
41176 </div></fieldset>
41177
41178 <?php
41179
41180 $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );
41181
41182 foreach ( $columns as $column_name => $column_display_name ) {
41183 if ( isset( $core_columns[$column_name] ) )
41184 continue;
41185 do_action( 'quick_edit_custom_box', $column_name, $type );
41186 }
41187
41188 ?>
41189
41190 <p class="inline-edit-save submit">
41191 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a>
41192 <?php $update_text = ( $is_tag ) ? __( 'Update Tag' ) : __( 'Update Category' ); ?>
41193 <a accesskey="s" href="#inline-edit" title="<?php echo attribute_escape( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a>
41194 <img class="waiting" style="display:none;" src="images/loading.gif" alt="" />
41195 <span class="error" style="display:none;"></span>
41196 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
41197 <br class="clear" />
41198 </p>
41199 </td></tr>
41200 </tbody></table></form>
41201 <?php
41202 }
41203
41204 /**
41205 * {@internal Missing Short Description}}
41206 *
41207 * @since unknown
41208 *
41209 * @param unknown_type $category
41210 * @param unknown_type $name_override
41211 * @return unknown
41212 */
41213 function link_cat_row( $category, $name_override = false ) {
41214 static $row_class = '';
41215
41216 if ( !$category = get_term( $category, 'link_category', OBJECT, 'display' ) )
41217 return false;
41218 if ( is_wp_error( $category ) )
41219 return $category;
41220
41221 $default_cat_id = (int) get_option( 'default_link_category' );
41222 $name = ( $name_override ? $name_override : $category->name );
41223 $edit_link = "link-category.php?action=edit&cat_ID=$category->term_id";
41224 if ( current_user_can( 'manage_categories' ) ) {
41225 $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>$name</a><br />";
41226 $actions = array();
41227 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
41228 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
41229 if ( $default_cat_id != $category->term_id )
41230 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link-category.php?action=delete&cat_ID=$category->term_id", 'delete-link-category_' . $category->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') . "</a>";
41231 $action_count = count($actions);
41232 $i = 0;
41233 $edit .= '<div class="row-actions">';
41234 foreach ( $actions as $action => $link ) {
41235 ++$i;
41236 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
41237 $edit .= "<span class='$action'>$link$sep</span>";
41238 }
41239 $edit .= '</div>';
41240 } else {
41241 $edit = $name;
41242 }
41243
41244 $row_class = 'alternate' == $row_class ? '' : 'alternate';
41245 $qe_data = get_term_to_edit($category->term_id, 'link_category');
41246
41247 $category->count = number_format_i18n( $category->count );
41248 $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
41249 $output = "<tr id='link-cat-$category->term_id' class='iedit $row_class'>";
41250 $columns = get_column_headers('edit-link-categories');
41251 $hidden = get_hidden_columns('edit-link-categories');
41252 foreach ( $columns as $column_name => $column_display_name ) {
41253 $class = "class=\"$column_name column-$column_name\"";
41254
41255 $style = '';
41256 if ( in_array($column_name, $hidden) )
41257 $style = ' style="display:none;"';
41258
41259 $attributes = "$class$style";
41260
41261 switch ($column_name) {
41262 case 'cb':
41263 $output .= "<th scope='row' class='check-column'>";
41264 if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) {
41265 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
41266 } else {
41267 $output .= " ";
41268 }
41269 $output .= "</th>";
41270 break;
41271 case 'name':
41272 $output .= "<td $attributes>$edit";
41273 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
41274 $output .= '<div class="name">' . $qe_data->name . '</div>';
41275 $output .= '<div class="slug">' . $qe_data->slug . '</div>';
41276 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
41277 break;
41278 case 'description':
41279 $output .= "<td $attributes>$category->description</td>";
41280 break;
41281 case 'slug':
41282 $output .= "<td $attributes>$category->slug</td>";
41283 break;
41284 case 'links':
41285 $attributes = 'class="links column-links num"' . $style;
41286 $output .= "<td $attributes>$count</td>";
41287 }
41288 }
41289 $output .= '</tr>';
41290
41291 return $output;
41292 }
41293
41294 /**
41295 * {@internal Missing Short Description}}
41296 *
41297 * @since unknown
41298 *
41299 * @param unknown_type $checked
41300 * @param unknown_type $current
41301 */
41302 function checked( $checked, $current) {
41303 if ( $checked == $current)
41304 echo ' checked="checked"';
41305 }
41306
41307 /**
41308 * {@internal Missing Short Description}}
41309 *
41310 * @since unknown
41311 *
41312 * @param unknown_type $selected
41313 * @param unknown_type $current
41314 */
41315 function selected( $selected, $current) {
41316 if ( $selected == $current)
41317 echo ' selected="selected"';
41318 }
41319
41320 //
41321 // Category Checklists
41322 //
41323
41324 /**
41325 * {@internal Missing Short Description}}
41326 *
41327 * @since unknown
41328 * @deprecated Use {@link wp_link_category_checklist()}
41329 * @see wp_link_category_checklist()
41330 *
41331 * @param unknown_type $default
41332 * @param unknown_type $parent
41333 * @param unknown_type $popular_ids
41334 */
41335 function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
41336 global $post_ID;
41337 wp_category_checklist($post_ID);
41338 }
41339
41340 /**
41341 * {@internal Missing Short Description}}
41342 *
41343 * @since unknown
41344 */
41345 class Walker_Category_Checklist extends Walker {
41346 var $tree_type = 'category';
41347 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
41348
41349 function start_lvl(&$output, $depth, $args) {
41350 $indent = str_repeat("\t", $depth);
41351 $output .= "$indent<ul class='children'>\n";
41352 }
41353
41354 function end_lvl(&$output, $depth, $args) {
41355 $indent = str_repeat("\t", $depth);
41356 $output .= "$indent</ul>\n";
41357 }
41358
41359 function start_el(&$output, $category, $depth, $args) {
41360 extract($args);
41361
41362 $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
41363 $output .= "\n<li id='category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>';
41364 }
41365
41366 function end_el(&$output, $category, $depth, $args) {
41367 $output .= "</li>\n";
41368 }
41369 }
41370
41371 /**
41372 * {@internal Missing Short Description}}
41373 *
41374 * @since unknown
41375 *
41376 * @param unknown_type $post_id
41377 * @param unknown_type $descendants_and_self
41378 * @param unknown_type $selected_cats
41379 * @param unknown_type $popular_cats
41380 */
41381 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false ) {
41382 $walker = new Walker_Category_Checklist;
41383 $descendants_and_self = (int) $descendants_and_self;
41384
41385 $args = array();
41386
41387 if ( is_array( $selected_cats ) )
41388 $args['selected_cats'] = $selected_cats;
41389 elseif ( $post_id )
41390 $args['selected_cats'] = wp_get_post_categories($post_id);
41391 else
41392 $args['selected_cats'] = array();
41393
41394 if ( is_array( $popular_cats ) )
41395 $args['popular_cats'] = $popular_cats;
41396 else
41397 $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
41398
41399 if ( $descendants_and_self ) {
41400 $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" );
41401 $self = get_category( $descendants_and_self );
41402 array_unshift( $categories, $self );
41403 } else {
41404 $categories = get_categories('get=all');
41405 }
41406
41407 // 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)
41408 $checked_categories = array();
41409 for ( $i = 0; isset($categories[$i]); $i++ ) {
41410 if ( in_array($categories[$i]->term_id, $args['selected_cats']) ) {
41411 $checked_categories[] = $categories[$i];
41412 unset($categories[$i]);
41413 }
41414 }
41415
41416 // Put checked cats on top
41417 echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
41418 // Then the rest of them
41419 echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
41420 }
41421
41422 /**
41423 * {@internal Missing Short Description}}
41424 *
41425 * @since unknown
41426 *
41427 * @param unknown_type $taxonomy
41428 * @param unknown_type $default
41429 * @param unknown_type $number
41430 * @param unknown_type $echo
41431 * @return unknown
41432 */
41433 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
41434 global $post_ID;
41435 if ( $post_ID )
41436 $checked_categories = wp_get_post_categories($post_ID);
41437 else
41438 $checked_categories = array();
41439 $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
41440
41441 $popular_ids = array();
41442 foreach ( (array) $categories as $category ) {
41443 $popular_ids[] = $category->term_id;
41444 if ( !$echo ) // hack for AJAX use
41445 continue;
41446 $id = "popular-category-$category->term_id";
41447 ?>
41448
41449 <li id="<?php echo $id; ?>" class="popular-category">
41450 <label class="selectit">
41451 <input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
41452 <?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?>
41453 </label>
41454 </li>
41455
41456 <?php
41457 }
41458 return $popular_ids;
41459 }
41460
41461 /**
41462 * {@internal Missing Short Description}}
41463 *
41464 * @since unknown
41465 * @deprecated Use {@link wp_link_category_checklist()}
41466 * @see wp_link_category_checklist()
41467 *
41468 * @param unknown_type $default
41469 */
41470 function dropdown_link_categories( $default = 0 ) {
41471 global $link_id;
41472
41473 wp_link_category_checklist($link_id);
41474 }
41475
41476 /**
41477 * {@internal Missing Short Description}}
41478 *
41479 * @since unknown
41480 *
41481 * @param unknown_type $link_id
41482 */
41483 function wp_link_category_checklist( $link_id = 0 ) {
41484 $default = 1;
41485
41486 if ( $link_id ) {
41487 $checked_categories = wp_get_link_cats($link_id);
41488
41489 if ( count( $checked_categories ) == 0 ) {
41490 // No selected categories, strange
41491 $checked_categories[] = $default;
41492 }
41493 } else {
41494 $checked_categories[] = $default;
41495 }
41496
41497 $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
41498
41499 if ( empty($categories) )
41500 return;
41501
41502 foreach ( $categories as $category ) {
41503 $cat_id = $category->term_id;
41504 $name = wp_specialchars( apply_filters('the_category', $category->name));
41505 $checked = in_array( $cat_id, $checked_categories );
41506 echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>";
41507 }
41508 }
41509
41510 // Tag stuff
41511
41512 // Returns a single tag row (see tag_rows below)
41513 // Note: this is also used in admin-ajax.php!
41514 /**
41515 * {@internal Missing Short Description}}
41516 *
41517 * @since unknown
41518 *
41519 * @param unknown_type $tag
41520 * @param unknown_type $class
41521 * @return unknown
41522 */
41523 function _tag_row( $tag, $class = '' ) {
41524 $count = number_format_i18n( $tag->count );
41525 $count = ( $count > 0 ) ? "<a href='edit.php?tag=$tag->slug'>$count</a>" : $count;
41526
41527 $name = apply_filters( 'term_name', $tag->name );
41528 $qe_data = get_term($tag->term_id, 'post_tag', object, 'edit');
41529 $edit_link = "edit-tags.php?action=edit&tag_ID=$tag->term_id";
41530 $out = '';
41531 $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>';
41532 $columns = get_column_headers('edit-tags');
41533 $hidden = get_hidden_columns('edit-tags');
41534 foreach ( $columns as $column_name => $column_display_name ) {
41535 $class = "class=\"$column_name column-$column_name\"";
41536
41537 $style = '';
41538 if ( in_array($column_name, $hidden) )
41539 $style = ' style="display:none;"';
41540
41541 $attributes = "$class$style";
41542
41543 switch ($column_name) {
41544 case 'cb':
41545 $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';
41546 break;
41547 case 'name':
41548 $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . attribute_escape(sprintf(__('Edit "%s"'), $name)) . '">' . $name . '</a></strong><br />';
41549 $actions = array();
41550 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
41551 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
41552 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("edit-tags.php?action=delete&tag_ID=$tag->term_id", 'delete-tag_' . $tag->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') . "</a>";
41553 $action_count = count($actions);
41554 $i = 0;
41555 $out .= '<div class="row-actions">';
41556 foreach ( $actions as $action => $link ) {
41557 ++$i;
41558 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
41559 $out .= "<span class='$action'>$link$sep</span>";
41560 }
41561 $out .= '</div>';
41562 $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
41563 $out .= '<div class="name">' . $qe_data->name . '</div>';
41564 $out .= '<div class="slug">' . $qe_data->slug . '</div></div></td>';
41565 break;
41566 case 'slug':
41567 $out .= "<td $attributes>$tag->slug</td>";
41568 break;
41569 case 'posts':
41570 $attributes = 'class="posts column-posts num"' . $style;
41571 $out .= "<td $attributes>$count</td>";
41572 break;
41573 }
41574 }
41575
41576 $out .= '</tr>';
41577
41578 return $out;
41579 }
41580
41581 // Outputs appropriate rows for the Nth page of the Tag Management screen,
41582 // assuming M tags displayed at a time on the page
41583 // Returns the number of tags displayed
41584 /**
41585 * {@internal Missing Short Description}}
41586 *
41587 * @since unknown
41588 *
41589 * @param unknown_type $page
41590 * @param unknown_type $pagesize
41591 * @param unknown_type $searchterms
41592 * @return unknown
41593 */
41594 function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) {
41595
41596 // Get a page worth of tags
41597 $start = ($page - 1) * $pagesize;
41598
41599 $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);
41600
41601 if ( !empty( $searchterms ) ) {
41602 $args['search'] = $searchterms;
41603 }
41604
41605 $tags = get_terms( 'post_tag', $args );
41606
41607 // convert it to table rows
41608 $out = '';
41609 $count = 0;
41610 foreach( $tags as $tag )
41611 $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"' );
41612
41613 // filter and send to screen
41614 echo $out;
41615 return $count;
41616 }
41617
41618 // define the columns to display, the syntax is 'internal name' => 'display name'
41619 /**
41620 * {@internal Missing Short Description}}
41621 *
41622 * @since unknown
41623 *
41624 * @return unknown
41625 */
41626 function wp_manage_posts_columns() {
41627 $posts_columns = array();
41628 $posts_columns['cb'] = '<input type="checkbox" />';
41629 $posts_columns['title'] = _c('Post|noun');
41630 $posts_columns['author'] = __('Author');
41631 $posts_columns['categories'] = __('Categories');
41632 $posts_columns['tags'] = __('Tags');
41633 if ( !isset($_GET['post_status']) || !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
41634 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
41635 $posts_columns['date'] = __('Date');
41636 $posts_columns = apply_filters('manage_posts_columns', $posts_columns);
41637
41638 return $posts_columns;
41639 }
41640
41641 // define the columns to display, the syntax is 'internal name' => 'display name'
41642 /**
41643 * {@internal Missing Short Description}}
41644 *
41645 * @since unknown
41646 *
41647 * @return unknown
41648 */
41649 function wp_manage_media_columns() {
41650 $posts_columns = array();
41651 $posts_columns['cb'] = '<input type="checkbox" />';
41652 $posts_columns['icon'] = '';
41653 $posts_columns['media'] = _c('File|media column header');
41654 $posts_columns['author'] = __('Author');
41655 //$posts_columns['tags'] = _c('Tags|media column header');
41656 $posts_columns['parent'] = _c('Attached to|media column header');
41657 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
41658 //$posts_columns['comments'] = __('Comments');
41659 $posts_columns['date'] = _c('Date|media column header');
41660 $posts_columns = apply_filters('manage_media_columns', $posts_columns);
41661
41662 return $posts_columns;
41663 }
41664
41665 /**
41666 * {@internal Missing Short Description}}
41667 *
41668 * @since unknown
41669 *
41670 * @return unknown
41671 */
41672 function wp_manage_pages_columns() {
41673 $posts_columns = array();
41674 $posts_columns['cb'] = '<input type="checkbox" />';
41675 $posts_columns['title'] = __('Title');
41676 $posts_columns['author'] = __('Author');
41677 $post_status = 'all';
41678 if ( !empty($_GET['post_status']) )
41679 $post_status = $_GET['post_status'];
41680 if ( !in_array($post_status, array('pending', 'draft', 'future')) )
41681 $posts_columns['comments'] = '<div class="vers"><img alt="" src="images/comment-grey-bubble.png" /></div>';
41682 $posts_columns['date'] = __('Date');
41683 $posts_columns = apply_filters('manage_pages_columns', $posts_columns);
41684
41685 return $posts_columns;
41686 }
41687
41688 /**
41689 * {@internal Missing Short Description}}
41690 *
41691 * @since unknown
41692 *
41693 * @param unknown_type $page
41694 * @return unknown
41695 */
41696 function get_column_headers($page) {
41697 global $_wp_column_headers;
41698
41699 if ( !isset($_wp_column_headers) )
41700 $_wp_column_headers = array();
41701
41702 // Store in static to avoid running filters on each call
41703 if ( isset($_wp_column_headers[$page]) )
41704 return $_wp_column_headers[$page];
41705
41706 switch ($page) {
41707 case 'edit':
41708 $_wp_column_headers[$page] = wp_manage_posts_columns();
41709 break;
41710 case 'edit-pages':
41711 $_wp_column_headers[$page] = wp_manage_pages_columns();
41712 break;
41713 case 'edit-comments':
41714 $_wp_column_headers[$page] = array(
41715 'cb' => '<input type="checkbox" />',
41716 'author' => __('Author'),
41717 'comment' => _c('Comment|noun'),
41718 //'date' => __('Submitted'),
41719 'response' => __('In Response To')
41720 );
41721
41722 break;
41723 case 'link-manager':
41724 $_wp_column_headers[$page] = array(
41725 'cb' => '<input type="checkbox" />',
41726 'name' => __('Name'),
41727 'url' => __('URL'),
41728 'categories' => __('Categories'),
41729 'rel' => __('rel'),
41730 'visible' => __('Visible')
41731 );
41732
41733 break;
41734 case 'upload':
41735 $_wp_column_headers[$page] = wp_manage_media_columns();
41736 break;
41737 case 'categories':
41738 $_wp_column_headers[$page] = array(
41739 'cb' => '<input type="checkbox" />',
41740 'name' => __('Name'),
41741 'description' => __('Description'),
41742 'slug' => __('Slug'),
41743 'posts' => __('Posts')
41744 );
41745
41746 break;
41747 case 'edit-link-categories':
41748 $_wp_column_headers[$page] = array(
41749 'cb' => '<input type="checkbox" />',
41750 'name' => __('Name'),
41751 'description' => __('Description'),
41752 'slug' => __('Slug'),
41753 'links' => __('Links')
41754 );
41755
41756 break;
41757 case 'edit-tags':
41758 $_wp_column_headers[$page] = array(
41759 'cb' => '<input type="checkbox" />',
41760 'name' => __('Name'),
41761 'slug' => __('Slug'),
41762 'posts' => __('Posts')
41763 );
41764
41765 break;
41766 case 'users':
41767 $_wp_column_headers[$page] = array(
41768 'cb' => '<input type="checkbox" />',
41769 'username' => __('Username'),
41770 'name' => __('Name'),
41771 'email' => __('E-mail'),
41772 'role' => __('Role'),
41773 'posts' => __('Posts')
41774 );
41775 break;
41776 default :
41777 $_wp_column_headers[$page] = array();
41778 }
41779
41780 $_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]);
41781 return $_wp_column_headers[$page];
41782 }
41783
41784 /**
41785 * {@internal Missing Short Description}}
41786 *
41787 * @since unknown
41788 *
41789 * @param unknown_type $type
41790 * @param unknown_type $id
41791 */
41792 function print_column_headers( $type, $id = true ) {
41793 $type = str_replace('.php', '', $type);
41794 $columns = get_column_headers( $type );
41795 $hidden = get_hidden_columns($type);
41796 $styles = array();
41797 // $styles['tag']['posts'] = 'width: 90px;';
41798 // $styles['link-category']['links'] = 'width: 90px;';
41799 // $styles['category']['posts'] = 'width: 90px;';
41800 // $styles['link']['visible'] = 'text-align: center;';
41801
41802 foreach ( $columns as $column_key => $column_display_name ) {
41803 $class = ' class="manage-column';
41804
41805 $class .= " column-$column_key";
41806
41807 if ( 'cb' == $column_key )
41808 $class .= ' check-column';
41809 elseif ( in_array($column_key, array('posts', 'comments', 'links')) )
41810 $class .= ' num';
41811
41812 $class .= '"';
41813
41814 $style = '';
41815 if ( in_array($column_key, $hidden) )
41816 $style = 'display:none;';
41817
41818 if ( isset($styles[$type]) && isset($styles[$type][$column_key]) )
41819 $style .= ' ' . $styles[$type][$column_key];
41820 $style = ' style="' . $style . '"';
41821 ?>
41822 <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th>
41823 <?php }
41824 }
41825
41826 /**
41827 * Register column headers for a particular screen. The header names will be listed in the Screen Options.
41828 *
41829 * @since 2.7.0
41830 *
41831 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
41832 * @param array $columns An array of columns with column IDs as the keys and translated column names as the values
41833 * @see get_column_headers(), print_column_headers(), get_hidden_columns()
41834 */
41835 function register_column_headers($screen, $columns) {
41836 global $_wp_column_headers;
41837
41838 if ( !isset($_wp_column_headers) )
41839 $_wp_column_headers = array();
41840
41841 $_wp_column_headers[$screen] = $columns;
41842 }
41843
41844 /**
41845 * {@internal Missing Short Description}}
41846 *
41847 * @since unknown
41848 *
41849 * @param unknown_type $page
41850 */
41851 function get_hidden_columns($page) {
41852 $page = str_replace('.php', '', $page);
41853 return (array) get_user_option( 'manage-' . $page . '-columns-hidden', 0, false );
41854 }
41855
41856 /**
41857 * {@internal Missing Short Description}}
41858 *
41859 * Outputs the quick edit and bulk edit table rows for posts and pages
41860 *
41861 * @since 2.7
41862 *
41863 * @param string $type 'post' or 'page'
41864 */
41865 function inline_edit_row( $type ) {
41866 global $current_user, $mode;
41867
41868 $is_page = 'page' == $type;
41869 if ( $is_page ) {
41870 $screen = 'edit-pages';
41871 $post = get_default_page_to_edit();
41872 } else {
41873 $screen = 'edit';
41874 $post = get_default_post_to_edit();
41875 }
41876
41877 $columns = $is_page ? wp_manage_pages_columns() : wp_manage_posts_columns();
41878 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
41879 $col_count = count($columns) - count($hidden);
41880 $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
41881 $can_publish = current_user_can("publish_{$type}s");
41882 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
41883
41884 ?>
41885
41886 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
41887 <?php
41888 $bulk = 0;
41889 while ( $bulk < 2 ) { ?>
41890
41891 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$type ";
41892 echo $bulk ? "bulk-edit-row bulk-edit-row-$type" : "quick-edit-row quick-edit-row-$type";
41893 ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
41894
41895 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
41896 <h4><?php echo $bulk ? ( $is_page ? __( 'Bulk Edit Pages' ) : __( 'Bulk Edit Posts' ) ) : __( 'Quick Edit' ); ?></h4>
41897
41898
41899 <?php if ( $bulk ) : ?>
41900 <div id="bulk-title-div">
41901 <div id="bulk-titles"></div>
41902 </div>
41903
41904 <?php else : // $bulk ?>
41905
41906 <label>
41907 <span class="title"><?php _e( 'Title' ); ?></span>
41908 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
41909 </label>
41910
41911 <?php endif; // $bulk ?>
41912
41913
41914 <?php if ( !$bulk ) : ?>
41915
41916 <label>
41917 <span class="title"><?php _e( 'Slug' ); ?></span>
41918 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
41919 </label>
41920
41921 <label><span class="title"><?php _e( 'Date' ); ?></span></label>
41922 <div class="inline-edit-date">
41923 <?php touch_time(1, 1, 4, 1); ?>
41924 </div>
41925 <br class="clear" />
41926
41927 <?php endif; // $bulk
41928
41929 ob_start();
41930 $authors = get_editable_user_ids( $current_user->id, true, $type ); // TODO: ROLE SYSTEM
41931 if ( $authors && count( $authors ) > 1 ) :
41932 $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1);
41933 if ( $bulk )
41934 $users_opt['show_option_none'] = __('- No Change -');
41935 ?>
41936 <label>
41937 <span class="title"><?php _e( 'Author' ); ?></span>
41938 <?php wp_dropdown_users( $users_opt ); ?>
41939 </label>
41940
41941 <?php
41942 endif; // authors
41943 $authors_dropdown = ob_get_clean();
41944 ?>
41945
41946 <?php if ( !$bulk ) : echo $authors_dropdown; ?>
41947
41948 <div class="inline-edit-group">
41949 <label class="alignleft">
41950 <span class="title"><?php _e( 'Password' ); ?></span>
41951 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
41952 </label>
41953
41954 <em style="margin:5px 10px 0 0" class="alignleft"><?php echo _c( '–OR–|Between password field and private checkbox on post quick edit interface' ); ?></em>
41955
41956 <label class="alignleft inline-edit-private">
41957 <input type="checkbox" name="keep_private" value="private" />
41958 <span class="checkbox-title"><?php echo $is_page ? __('Private page') : __('Private post'); ?></span>
41959 </label>
41960 </div>
41961
41962 <?php endif; ?>
41963
41964 </div></fieldset>
41965
41966 <?php if ( !$is_page && !$bulk ) : ?>
41967
41968 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
41969 <span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?>
41970 <span class="catshow"><?php _e('[more]'); ?></span>
41971 <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span>
41972 </span>
41973 <ul class="cat-checklist">
41974 <?php wp_category_checklist(); ?>
41975 </ul>
41976 </div></fieldset>
41977
41978 <?php endif; // !$is_page && !$bulk ?>
41979
41980 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
41981
41982 <?php
41983 if ( $bulk )
41984 echo $authors_dropdown;
41985 ?>
41986
41987 <?php if ( $is_page ) : ?>
41988
41989 <label>
41990 <span class="title"><?php _e( 'Parent' ); ?></span>
41991 <?php
41992 $dropdown_args = array('selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column'=> 'menu_order, post_title');
41993 if ( $bulk )
41994 $dropdown_args['show_option_no_change'] = __('- No Change -');
41995 $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args);
41996 wp_dropdown_pages($dropdown_args);
41997 ?>
41998 </label>
41999
42000 <?php if ( !$bulk ) : ?>
42001
42002 <label>
42003 <span class="title"><?php _e( 'Order' ); ?></span>
42004 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
42005 </label>
42006
42007 <?php endif; // !$bulk ?>
42008
42009 <label>
42010 <span class="title"><?php _e( 'Template' ); ?></span>
42011 <select name="page_template">
42012 <?php if ( $bulk ) : ?>
42013 <option value="-1"><?php _e('- No Change -'); ?></option>
42014 <?php endif; // $bulk ?>
42015 <option value="default"><?php _e( 'Default Template' ); ?></option>
42016 <?php page_template_dropdown() ?>
42017 </select>
42018 </label>
42019
42020 <?php elseif ( !$bulk ) : // $is_page ?>
42021
42022 <label class="inline-edit-tags">
42023 <span class="title"><?php _e( 'Tags' ); ?></span>
42024 <textarea cols="22" rows="1" name="tags_input" class="tags_input"></textarea>
42025 </label>
42026
42027 <?php endif; // $is_page ?>
42028
42029 <?php if ( $bulk ) : ?>
42030
42031 <div class="inline-edit-group">
42032 <label class="alignleft">
42033 <span class="title"><?php _e( 'Comments' ); ?></span>
42034 <select name="comment_status">
42035 <option value=""><?php _e('- No Change -'); ?></option>
42036 <option value="open"><?php _e('Allow'); ?></option>
42037 <option value="closed"><?php _e('Do not allow'); ?></option>
42038 </select>
42039 </label>
42040
42041 <label class="alignright">
42042 <span class="title"><?php _e( 'Pings' ); ?></span>
42043 <select name="ping_status">
42044 <option value=""><?php _e('- No Change -'); ?></option>
42045 <option value="open"><?php _e('Allow'); ?></option>
42046 <option value="closed"><?php _e('Do not allow'); ?></option>
42047 </select>
42048 </label>
42049 </div>
42050
42051 <?php else : // $bulk ?>
42052
42053 <div class="inline-edit-group">
42054 <label class="alignleft">
42055 <input type="checkbox" name="comment_status" value="open" />
42056 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
42057 </label>
42058
42059 <label class="alignleft">
42060 <input type="checkbox" name="ping_status" value="open" />
42061 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
42062 </label>
42063 </div>
42064
42065 <?php endif; // $bulk ?>
42066
42067
42068 <div class="inline-edit-group">
42069 <label class="inline-edit-status alignleft">
42070 <span class="title"><?php _e( 'Status' ); ?></span>
42071 <select name="_status">
42072 <?php if ( $bulk ) : ?>
42073 <option value="-1"><?php _e('- No Change -'); ?></option>
42074 <?php endif; // $bulk ?>
42075 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
42076 <option value="publish"><?php _e( 'Published' ); ?></option>
42077 <option value="future"><?php _e( 'Scheduled' ); ?></option>
42078 <?php if ( $bulk ) : ?>
42079 <option value="private"><?php _e('Private') ?></option>
42080 <?php endif; // $bulk ?>
42081 <?php endif; ?>
42082 <option value="pending"><?php _e( 'Pending Review' ); ?></option>
42083 <option value="draft"><?php _e( 'Unpublished' ); ?></option>
42084 </select>
42085 </label>
42086
42087 <?php if ( !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?>
42088
42089 <?php if ( $bulk ) : ?>
42090
42091 <label class="alignright">
42092 <span class="title"><?php _e( 'Sticky' ); ?></span>
42093 <select name="sticky">
42094 <option value="-1"><?php _e( '- No Change -' ); ?></option>
42095 <option value="sticky"><?php _e( 'Sticky' ); ?></option>
42096 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
42097 </select>
42098 </label>
42099
42100 <?php else : // $bulk ?>
42101
42102 <label class="alignleft">
42103 <input type="checkbox" name="sticky" value="sticky" />
42104 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
42105 </label>
42106
42107 <?php endif; // $bulk ?>
42108
42109 <?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ?>
42110
42111 </div>
42112
42113 </div></fieldset>
42114
42115 <?php
42116 foreach ( $columns as $column_name => $column_display_name ) {
42117 if ( isset( $core_columns[$column_name] ) )
42118 continue;
42119 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $type);
42120 }
42121 ?>
42122 <p class="submit inline-edit-save">
42123 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a>
42124 <?php if ( ! $bulk ) {
42125 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
42126 $update_text = ( $is_page ) ? __( 'Update Page' ) : __( 'Update Post' );
42127 ?>
42128 <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo attribute_escape( $update_text ); ?></a>
42129 <img class="waiting" style="display:none;" src="images/loading.gif" alt="" />
42130 <?php } else {
42131 $update_text = ( $is_page ) ? __( 'Update Pages' ) : __( 'Update Posts' );
42132 ?>
42133 <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo attribute_escape( $update_text ); ?>" />
42134 <?php } ?>
42135 <input type="hidden" name="post_view" value="<?php echo $m; ?>" />
42136 <br class="clear" />
42137 </p>
42138 </td></tr>
42139 <?php
42140 $bulk++;
42141 } ?>
42142 </tbody></table></form>
42143 <?php
42144 }
42145
42146 // adds hidden fields with the data for use in the inline editor for posts and pages
42147 /**
42148 * {@internal Missing Short Description}}
42149 *
42150 * @since unknown
42151 *
42152 * @param unknown_type $post
42153 */
42154 function get_inline_data($post) {
42155
42156 if ( ! current_user_can('edit_' . $post->post_type, $post->ID) )
42157 return;
42158
42159 $title = attribute_escape($post->post_title);
42160
42161 echo '
42162 <div class="hidden" id="inline_' . $post->ID . '">
42163 <div class="post_title">' . $title . '</div>
42164 <div class="post_name">' . $post->post_name . '</div>
42165 <div class="post_author">' . $post->post_author . '</div>
42166 <div class="comment_status">' . $post->comment_status . '</div>
42167 <div class="ping_status">' . $post->ping_status . '</div>
42168 <div class="_status">' . $post->post_status . '</div>
42169 <div class="jj">' . mysql2date( 'd', $post->post_date ) . '</div>
42170 <div class="mm">' . mysql2date( 'm', $post->post_date ) . '</div>
42171 <div class="aa">' . mysql2date( 'Y', $post->post_date ) . '</div>
42172 <div class="hh">' . mysql2date( 'H', $post->post_date ) . '</div>
42173 <div class="mn">' . mysql2date( 'i', $post->post_date ) . '</div>
42174 <div class="ss">' . mysql2date( 's', $post->post_date ) . '</div>
42175 <div class="post_password">' . wp_specialchars($post->post_password, 1) . '</div>';
42176
42177 if( $post->post_type == 'page' )
42178 echo '
42179 <div class="post_parent">' . $post->post_parent . '</div>
42180 <div class="page_template">' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . '</div>
42181 <div class="menu_order">' . $post->menu_order . '</div>';
42182
42183 if( $post->post_type == 'post' )
42184 echo '
42185 <div class="tags_input">' . wp_specialchars( str_replace( ',', ', ', get_tags_to_edit($post->ID) ), 1) . '</div>
42186 <div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>
42187 <div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
42188
42189 echo '</div>';
42190 }
42191
42192 /**
42193 * {@internal Missing Short Description}}
42194 *
42195 * @since unknown
42196 *
42197 * @param unknown_type $posts
42198 */
42199 function post_rows( $posts = array() ) {
42200 global $wp_query, $post, $mode;
42201
42202 add_filter('the_title','wp_specialchars');
42203
42204 // Create array of post IDs.
42205 $post_ids = array();
42206
42207 if ( empty($posts) )
42208 $posts = &$wp_query->posts;
42209
42210 foreach ( $posts as $a_post )
42211 $post_ids[] = $a_post->ID;
42212
42213 $comment_pending_count = get_pending_comments_num($post_ids);
42214 if ( empty($comment_pending_count) )
42215 $comment_pending_count = array();
42216
42217 foreach ( $posts as $post ) {
42218 if ( empty($comment_pending_count[$post->ID]) )
42219 $comment_pending_count[$post->ID] = 0;
42220
42221 _post_row($post, $comment_pending_count[$post->ID], $mode);
42222 }
42223 }
42224
42225 /**
42226 * {@internal Missing Short Description}}
42227 *
42228 * @since unknown
42229 *
42230 * @param unknown_type $a_post
42231 * @param unknown_type $pending_comments
42232 * @param unknown_type $mode
42233 */
42234 function _post_row($a_post, $pending_comments, $mode) {
42235 global $post;
42236 static $rowclass;
42237
42238 $global_post = $post;
42239 $post = $a_post;
42240 setup_postdata($post);
42241
42242 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
42243 global $current_user;
42244 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
42245 $edit_link = get_edit_post_link( $post->ID );
42246 $title = _draft_or_post_title();
42247 ?>
42248 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
42249 <?php
42250 $posts_columns = get_column_headers('edit');
42251 $hidden = get_hidden_columns('edit');
42252 foreach ( $posts_columns as $column_name=>$column_display_name ) {
42253 $class = "class=\"$column_name column-$column_name\"";
42254
42255 $style = '';
42256 if ( in_array($column_name, $hidden) )
42257 $style = ' style="display:none;"';
42258
42259 $attributes = "$class$style";
42260
42261 switch ($column_name) {
42262
42263 case 'cb':
42264 ?>
42265 <th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>
42266 <?php
42267 break;
42268
42269 case 'date':
42270 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
42271 $t_time = $h_time = __('Unpublished');
42272 } else {
42273 $t_time = get_the_time(__('Y/m/d g:i:s A'));
42274 $m_time = $post->post_date;
42275 $time = get_post_time('G', true, $post);
42276
42277 $time_diff = time() - $time;
42278
42279 if ( ( 'future' == $post->post_status) ) {
42280 if ( $time_diff <= 0 ) {
42281 $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
42282 } else {
42283 $h_time = $t_time;
42284 $missed = true;
42285 }
42286 } else {
42287
42288 if ( $time_diff > 0 && $time_diff < 24*60*60 )
42289 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
42290 else
42291 $h_time = mysql2date(__('Y/m/d'), $m_time);
42292 }
42293 }
42294
42295 echo '<td ' . $attributes . '>';
42296 if ( 'excerpt' == $mode )
42297 echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
42298 else
42299 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
42300 echo '<br />';
42301 if ( 'publish' == $post->post_status ) {
42302 _e('Published');
42303 } elseif ( 'future' == $post->post_status ) {
42304 if ( isset($missed) )
42305 echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
42306 else
42307 _e('Scheduled');
42308 } else {
42309 _e('Last Modified');
42310 }
42311 echo '</td>';
42312 break;
42313
42314 case 'title':
42315 $attributes = 'class="post-title column-title"' . $style;
42316 ?>
42317 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
42318 <?php
42319 if ( 'excerpt' == $mode )
42320 the_excerpt();
42321
42322 $actions = array();
42323 if ( current_user_can('edit_post', $post->ID) ) {
42324 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . attribute_escape(__('Edit this post')) . '">' . __('Edit') . '</a>';
42325 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . attribute_escape(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>';
42326 $actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this post')) . "' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
42327 }
42328 if ( in_array($post->post_status, array('pending', 'draft')) ) {
42329 if ( current_user_can('edit_post', $post->ID) )
42330 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('Preview "%s"'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
42331 } else {
42332 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>';
42333 }
42334 $action_count = count($actions);
42335 $i = 0;
42336 echo '<div class="row-actions">';
42337 foreach ( $actions as $action => $link ) {
42338 ++$i;
42339 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
42340 echo "<span class='$action'>$link$sep</span>";
42341 }
42342 echo '</div>';
42343
42344 get_inline_data($post);
42345 ?>
42346 </td>
42347 <?php
42348 break;
42349
42350 case 'categories':
42351 ?>
42352 <td <?php echo $attributes ?>><?php
42353 $categories = get_the_category();
42354 if ( !empty( $categories ) ) {
42355 $out = array();
42356 foreach ( $categories as $c )
42357 $out[] = "<a href='edit.php?category_name=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
42358 echo join( ', ', $out );
42359 } else {
42360 _e('Uncategorized');
42361 }
42362 ?></td>
42363 <?php
42364 break;
42365
42366 case 'tags':
42367 ?>
42368 <td <?php echo $attributes ?>><?php
42369 $tags = get_the_tags($post->ID);
42370 if ( !empty( $tags ) ) {
42371 $out = array();
42372 foreach ( $tags as $c )
42373 $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
42374 echo join( ', ', $out );
42375 } else {
42376 _e('No Tags');
42377 }
42378 ?></td>
42379 <?php
42380 break;
42381
42382 case 'comments':
42383 ?>
42384 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
42385 <?php
42386 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
42387 if ( $pending_comments )
42388 echo '<strong>';
42389 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
42390 if ( $pending_comments )
42391 echo '</strong>';
42392 ?>
42393 </div></td>
42394 <?php
42395 break;
42396
42397 case 'author':
42398 ?>
42399 <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
42400 <?php
42401 break;
42402
42403 case 'control_view':
42404 ?>
42405 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
42406 <?php
42407 break;
42408
42409 case 'control_edit':
42410 ?>
42411 <td><?php if ( current_user_can('edit_post', $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
42412 <?php
42413 break;
42414
42415 case 'control_delete':
42416 ?>
42417 <td><?php if ( current_user_can('delete_post', $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
42418 <?php
42419 break;
42420
42421 default:
42422 ?>
42423 <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td>
42424 <?php
42425 break;
42426 }
42427 }
42428 ?>
42429 </tr>
42430 <?php
42431 $post = $global_post;
42432 }
42433
42434 /*
42435 * display one row if the page doesn't have any children
42436 * otherwise, display the row and its children in subsequent rows
42437 */
42438 /**
42439 * {@internal Missing Short Description}}
42440 *
42441 * @since unknown
42442 *
42443 * @param unknown_type $page
42444 * @param unknown_type $level
42445 */
42446 function display_page_row( $page, $level = 0 ) {
42447 global $post;
42448 static $rowclass;
42449
42450 $post = $page;
42451 setup_postdata($page);
42452
42453 $page->post_title = wp_specialchars( $page->post_title );
42454 $pad = str_repeat( '— ', $level );
42455 $id = (int) $page->ID;
42456 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
42457 $posts_columns = get_column_headers('edit-pages');
42458 $hidden = get_hidden_columns('edit-pages');
42459 $title = _draft_or_post_title();
42460 ?>
42461 <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
42462 <?php
42463
42464 foreach ($posts_columns as $column_name=>$column_display_name) {
42465 $class = "class=\"$column_name column-$column_name\"";
42466
42467 $style = '';
42468 if ( in_array($column_name, $hidden) )
42469 $style = ' style="display:none;"';
42470
42471 $attributes = "$class$style";
42472
42473 switch ($column_name) {
42474
42475 case 'cb':
42476 ?>
42477 <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /></th>
42478 <?php
42479 break;
42480 case 'date':
42481 if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) {
42482 $t_time = $h_time = __('Unpublished');
42483 } else {
42484 $t_time = get_the_time(__('Y/m/d g:i:s A'));
42485 $m_time = $page->post_date;
42486 $time = get_post_time('G', true);
42487
42488 if ( ( abs(time() - $time) ) < 86400 ) {
42489 if ( ( 'future' == $page->post_status) )
42490 $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
42491 else
42492 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
42493 } else {
42494 $h_time = mysql2date(__('Y/m/d'), $m_time);
42495 }
42496 }
42497 echo '<td ' . $attributes . '>';
42498 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $page, $column_name, '') . '</abbr>';
42499 echo '<br />';
42500 if ( 'publish' == $page->post_status || 'future' == $page->post_status )
42501 _e('Published');
42502 else
42503 _e('Last Modified');
42504 echo '</td>';
42505 break;
42506 case 'title':
42507 $attributes = 'class="post-title page-title column-title"' . $style;
42508 $edit_link = get_edit_post_link( $page->ID );
42509 ?>
42510 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $page->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); ?></strong>
42511 <?php
42512 $actions = array();
42513 if ( current_user_can('edit_page', $page->ID) ) {
42514 $actions['edit'] = '<a href="' . $edit_link . '" title="' . attribute_escape(__('Edit this page')) . '">' . __('Edit') . '</a>';
42515 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
42516 $actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this page')) . "' href='" . wp_nonce_url("page.php?action=delete&post=$page->ID", 'delete-page_' . $page->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $page->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $page->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
42517 }
42518 if ( in_array($post->post_status, array('pending', 'draft')) ) {
42519 if ( current_user_can('edit_page', $page->ID) )
42520 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . attribute_escape(sprintf(__('Preview "%s"'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
42521 } else {
42522 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>';
42523 }
42524 $action_count = count($actions);
42525
42526 $i = 0;
42527 echo '<div class="row-actions">';
42528 foreach ( $actions as $action => $link ) {
42529 ++$i;
42530 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
42531 echo "<span class='$action'>$link$sep</span>";
42532 }
42533 echo '</div>';
42534
42535 get_inline_data($post);
42536 echo '</td>';
42537 break;
42538
42539 case 'comments':
42540 ?>
42541 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
42542 <?php
42543 $left = get_pending_comments_num( $page->ID );
42544 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
42545 if ( $left )
42546 echo '<strong>';
42547 comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
42548 if ( $left )
42549 echo '</strong>';
42550 ?>
42551 </div></td>
42552 <?php
42553 break;
42554
42555 case 'author':
42556 ?>
42557 <td <?php echo $attributes ?>><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
42558 <?php
42559 break;
42560
42561 default:
42562 ?>
42563 <td <?php echo $attributes ?>><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td>
42564 <?php
42565 break;
42566 }
42567 }
42568 ?>
42569
42570 </tr>
42571
42572 <?php
42573 }
42574
42575 /*
42576 * displays pages in hierarchical order with paging support
42577 */
42578 /**
42579 * {@internal Missing Short Description}}
42580 *
42581 * @since unknown
42582 *
42583 * @param unknown_type $pages
42584 * @param unknown_type $pagenum
42585 * @param unknown_type $per_page
42586 * @return unknown
42587 */
42588 function page_rows($pages, $pagenum = 1, $per_page = 20) {
42589 global $wpdb;
42590
42591 $level = 0;
42592
42593 if ( ! $pages ) {
42594 $pages = get_pages( array('sort_column' => 'menu_order') );
42595
42596 if ( ! $pages )
42597 return false;
42598 }
42599
42600 /*
42601 * arrange pages into two parts: top level pages and children_pages
42602 * children_pages is two dimensional array, eg.
42603 * children_pages[10][] contains all sub-pages whose parent is 10.
42604 * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations
42605 * If searching, ignore hierarchy and treat everything as top level
42606 */
42607 if ( empty($_GET['s']) ) {
42608
42609 $top_level_pages = array();
42610 $children_pages = array();
42611
42612 foreach ( $pages as $page ) {
42613
42614 // catch and repair bad pages
42615 if ( $page->post_parent == $page->ID ) {
42616 $page->post_parent = 0;
42617 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) );
42618 clean_page_cache( $page->ID );
42619 }
42620
42621 if ( 0 == $page->post_parent )
42622 $top_level_pages[] = $page;
42623 else
42624 $children_pages[ $page->post_parent ][] = $page;
42625 }
42626
42627 $pages = &$top_level_pages;
42628 }
42629
42630 $count = 0;
42631 $start = ($pagenum - 1) * $per_page;
42632 $end = $start + $per_page;
42633
42634 foreach ( $pages as $page ) {
42635 if ( $count >= $end )
42636 break;
42637
42638 if ( $count >= $start )
42639 echo "\t" . display_page_row( $page, $level );
42640
42641 $count++;
42642
42643 if ( isset($children_pages) )
42644 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
42645 }
42646
42647 // if it is the last pagenum and there are orphaned pages, display them with paging as well
42648 if ( isset($children_pages) && $count < $end ){
42649 foreach( $children_pages as $orphans ){
42650 foreach ( $orphans as $op ) {
42651 if ( $count >= $end )
42652 break;
42653 if ( $count >= $start )
42654 echo "\t" . display_page_row( $op, 0 );
42655 $count++;
42656 }
42657 }
42658 }
42659 }
42660
42661 /*
42662 * Given a top level page ID, display the nested hierarchy of sub-pages
42663 * together with paging support
42664 */
42665 /**
42666 * {@internal Missing Short Description}}
42667 *
42668 * @since unknown
42669 *
42670 * @param unknown_type $children_pages
42671 * @param unknown_type $count
42672 * @param unknown_type $parent
42673 * @param unknown_type $level
42674 * @param unknown_type $pagenum
42675 * @param unknown_type $per_page
42676 */
42677 function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
42678
42679 if ( ! isset( $children_pages[$parent] ) )
42680 return;
42681
42682 $start = ($pagenum - 1) * $per_page;
42683 $end = $start + $per_page;
42684
42685 foreach ( $children_pages[$parent] as $page ) {
42686
42687 if ( $count >= $end )
42688 break;
42689
42690 // If the page starts in a subtree, print the parents.
42691 if ( $count == $start && $page->post_parent > 0 ) {
42692 $my_parents = array();
42693 $my_parent = $page->post_parent;
42694 while ( $my_parent) {
42695 $my_parent = get_post($my_parent);
42696 $my_parents[] = $my_parent;
42697 if ( !$my_parent->post_parent )
42698 break;
42699 $my_parent = $my_parent->post_parent;
42700 }
42701 $num_parents = count($my_parents);
42702 while( $my_parent = array_pop($my_parents) ) {
42703 echo "\t" . display_page_row( $my_parent, $level - $num_parents );
42704 $num_parents--;
42705 }
42706 }
42707
42708 if ( $count >= $start )
42709 echo "\t" . display_page_row( $page, $level );
42710
42711 $count++;
42712
42713 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
42714 }
42715
42716 unset( $children_pages[$parent] ); //required in order to keep track of orphans
42717 }
42718
42719 /**
42720 * {@internal Missing Short Description}}
42721 *
42722 * @since unknown
42723 *
42724 * @param unknown_type $user_object
42725 * @param unknown_type $style
42726 * @param unknown_type $role
42727 * @return unknown
42728 */
42729 function user_row( $user_object, $style = '', $role = '' ) {
42730 global $wp_roles;
42731
42732 $current_user = wp_get_current_user();
42733
42734 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
42735 $user_object = new WP_User( (int) $user_object );
42736 $email = $user_object->user_email;
42737 $url = $user_object->user_url;
42738 $short_url = str_replace( 'http://', '', $url );
42739 $short_url = str_replace( 'www.', '', $short_url );
42740 if ('/' == substr( $short_url, -1 ))
42741 $short_url = substr( $short_url, 0, -1 );
42742 if ( strlen( $short_url ) > 35 )
42743 $short_url = substr( $short_url, 0, 32 ).'...';
42744 $numposts = get_usernumposts( $user_object->ID );
42745 if ( current_user_can( 'edit_user', $user_object->ID ) ) {
42746 if ($current_user->ID == $user_object->ID) {
42747 $edit_link = 'profile.php';
42748 } else {
42749 $edit_link = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) );
42750 }
42751 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
42752 $actions = array();
42753 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
42754 if ( $current_user->ID != $user_object->ID )
42755 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>";
42756 $action_count = count($actions);
42757 $i = 0;
42758 $edit .= '<div class="row-actions">';
42759 foreach ( $actions as $action => $link ) {
42760 ++$i;
42761 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
42762 $edit .= "<span class='$action'>$link$sep</span>";
42763 }
42764 $edit .= '</div>';
42765 } else {
42766 $edit = '<strong>' . $user_object->user_login . '</strong>';
42767 }
42768 $role_name = isset($wp_roles->role_names[$role]) ? translate_with_context($wp_roles->role_names[$role]) : __('None');
42769 $r = "<tr id='user-$user_object->ID'$style>";
42770 $columns = get_column_headers('users');
42771 $hidden = get_hidden_columns('users');
42772 $avatar = get_avatar( $user_object->user_email, 32 );
42773 foreach ( $columns as $column_name => $column_display_name ) {
42774 $class = "class=\"$column_name column-$column_name\"";
42775
42776 $style = '';
42777 if ( in_array($column_name, $hidden) )
42778 $style = ' style="display:none;"';
42779
42780 $attributes = "$class$style";
42781
42782 switch ($column_name) {
42783 case 'cb':
42784 $r .= "<th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /></th>";
42785 break;
42786 case 'username':
42787 $r .= "<td $attributes>$avatar $edit</td>";
42788 break;
42789 case 'name':
42790 $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
42791 break;
42792 case 'email':
42793 $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>";
42794 break;
42795 case 'role':
42796 $r .= "<td $attributes>$role_name</td>";
42797 break;
42798 case 'posts':
42799 $attributes = 'class="posts column-posts num"' . $style;
42800 $r .= "<td $attributes>";
42801 if ( $numposts > 0 ) {
42802 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
42803 $r .= $numposts;
42804 $r .= '</a>';
42805 } else {
42806 $r .= 0;
42807 }
42808 $r .= "</td>";
42809 }
42810 }
42811 $r .= '</tr>';
42812
42813 return $r;
42814 }
42815
42816 /**
42817 * {@internal Missing Short Description}}
42818 *
42819 * @since unknown
42820 *
42821 * @param unknown_type $status
42822 * @param unknown_type $s
42823 * @param unknown_type $start
42824 * @param unknown_type $num
42825 * @param unknown_type $post
42826 * @param unknown_type $type
42827 * @return unknown
42828 */
42829 function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) {
42830 global $wpdb;
42831
42832 $start = abs( (int) $start );
42833 $num = (int) $num;
42834 $post = (int) $post;
42835
42836 if ( 'moderated' == $status )
42837 $approved = "comment_approved = '0'";
42838 elseif ( 'approved' == $status )
42839 $approved = "comment_approved = '1'";
42840 elseif ( 'spam' == $status )
42841 $approved = "comment_approved = 'spam'";
42842 else
42843 $approved = "( comment_approved = '0' OR comment_approved = '1' )";
42844
42845 if ( $post ) {
42846 $post = " AND comment_post_ID = '$post'";
42847 $orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num";
42848 } else {
42849 $post = '';
42850 $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
42851 }
42852
42853 if ( 'comment' == $type )
42854 $typesql = "AND comment_type = ''";
42855 elseif ( 'pingback' == $type )
42856 $typesql = "AND comment_type = 'pingback'";
42857 elseif ( 'trackback' == $type )
42858 $typesql = "AND comment_type = 'trackback'";
42859 elseif ( 'pings' == $type )
42860 $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
42861 else
42862 $typesql = '';
42863
42864 if ( $s ) {
42865 $s = $wpdb->escape($s);
42866 $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE
42867 (comment_author LIKE '%$s%' OR
42868 comment_author_email LIKE '%$s%' OR
42869 comment_author_url LIKE ('%$s%') OR
42870 comment_author_IP LIKE ('%$s%') OR
42871 comment_content LIKE ('%$s%') ) AND
42872 $approved
42873 $typesql
42874 $orderby");
42875 } else {
42876 $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved $post $typesql $orderby" );
42877 }
42878
42879 update_comment_cache($comments);
42880
42881 $total = $wpdb->get_var( "SELECT FOUND_ROWS()" );
42882
42883 return array($comments, $total);
42884 }
42885
42886 /**
42887 * {@internal Missing Short Description}}
42888 *
42889 * @since unknown
42890 *
42891 * @param unknown_type $comment_id
42892 * @param unknown_type $mode
42893 * @param unknown_type $comment_status
42894 * @param unknown_type $checkbox
42895 */
42896 function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {
42897 global $comment, $post, $_comment_pending_count;
42898 $comment = get_comment( $comment_id );
42899 $post = get_post($comment->comment_post_ID);
42900 $the_comment_status = wp_get_comment_status($comment->comment_ID);
42901
42902 $author_url = get_comment_author_url();
42903 if ( 'http://' == $author_url )
42904 $author_url = '';
42905 $author_url_display = $author_url;
42906 $author_url_display = str_replace('http://www.', '', $author_url_display);
42907 $author_url_display = str_replace('http://', '', $author_url_display);
42908 if ( strlen($author_url_display) > 50 )
42909 $author_url_display = substr($author_url_display, 0, 49) . '...';
42910
42911 $ptime = date('G', strtotime( $comment->comment_date ) );
42912 if ( ( abs(time() - $ptime) ) < 86400 )
42913 $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) );
42914 else
42915 $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date );
42916
42917 $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
42918 $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
42919 $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
42920 $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
42921
42922 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
42923 $columns = get_column_headers('edit-comments');
42924 $hidden = get_hidden_columns('edit-comments');
42925 foreach ( $columns as $column_name => $column_display_name ) {
42926 $class = "class=\"$column_name column-$column_name\"";
42927
42928 $style = '';
42929 if ( in_array($column_name, $hidden) )
42930 $style = ' style="display:none;"';
42931
42932 $attributes = "$class$style";
42933
42934 switch ($column_name) {
42935 case 'cb':
42936 if ( !$checkbox ) break;
42937 echo '<th scope="row" class="check-column">';
42938 if ( current_user_can('edit_post', $post->ID) ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
42939 echo '</th>';
42940 break;
42941 case 'comment':
42942 echo "<td $attributes>";
42943 echo '<div id="submitted-on">';
42944 printf(__('Submitted on <a href="%1$s">%2$s at %3$s</a>'), get_comment_link($comment->comment_ID), get_comment_date(__('Y/m/d')), get_comment_date(__('g:ia')));
42945 echo '</div>';
42946 comment_text(); ?>
42947 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
42948 <textarea class="comment" rows="3" cols="10"><?php echo $comment->comment_content; ?></textarea>
42949 <div class="author-email"><?php echo attribute_escape( $comment->comment_author_email ); ?></div>
42950 <div class="author"><?php echo attribute_escape( $comment->comment_author ); ?></div>
42951 <div class="author-url"><?php echo attribute_escape( $comment->comment_author_url ); ?></div>
42952 <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
42953 </div>
42954 <?php
42955 $actions = array();
42956
42957 if ( current_user_can('edit_post', $post->ID) ) {
42958 $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
42959 $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
42960 if ( $comment_status ) { // not looking at all comments
42961 if ( 'approved' == $the_comment_status ) {
42962 $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
42963 unset($actions['approve']);
42964 } else {
42965 $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
42966 unset($actions['unapprove']);
42967 }
42968 }
42969 if ( 'spam' != $the_comment_status )
42970 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . _c( 'Spam|verb' ) . '</a>';
42971 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
42972 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
42973 $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>';
42974 if ( 'spam' != $the_comment_status )
42975 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
42976
42977 $actions = apply_filters( 'comment_row_actions', $actions, $comment );
42978
42979 $i = 0;
42980 echo '<div class="row-actions">';
42981 foreach ( $actions as $action => $link ) {
42982 ++$i;
42983 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
42984
42985 // Reply and quickedit need a hide-if-no-js span when not added with ajax
42986 if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
42987 $action .= ' hide-if-no-js';
42988
42989 echo "<span class='$action'>$sep$link</span>";
42990 }
42991 echo '</div>';
42992 }
42993
42994 echo '</td>';
42995 break;
42996 case 'author':
42997 echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';
42998 if ( !empty($author_url) )
42999 echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
43000 if ( current_user_can( 'edit_post', $post->ID ) ) {
43001 if ( !empty($comment->comment_author_email) ) {
43002 comment_author_email_link();
43003 echo '<br />';
43004 }
43005 echo '<a href="edit-comments.php?s=';
43006 comment_author_IP();
43007 echo '&mode=detail';
43008 if ( 'spam' == $comment_status )
43009 echo '&comment_status=spam';
43010 echo '">';
43011 comment_author_IP();
43012 echo '</a>';
43013 } //current_user_can
43014 echo '</td>';
43015 break;
43016 case 'date':
43017 echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>';
43018 break;
43019 case 'response':
43020 if ( 'single' !== $mode ) {
43021 if ( isset( $_comment_pending_count[$post->ID] ) ) {
43022 $pending_comments = absint( $_comment_pending_count[$post->ID] );
43023 } else {
43024 $_comment_pending_count_temp = (array) get_pending_comments_num( array( $post->ID ) );
43025 $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];
43026 }
43027 if ( current_user_can( 'edit_post', $post->ID ) ) {
43028 $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>";
43029 $post_link .= get_the_title($post->ID) . '</a>';
43030 } else {
43031 $post_link = get_the_title($post->ID);
43032 }
43033 echo "<td $attributes>\n";
43034 echo $post_link;
43035
43036 echo '<div class="response-links"><span class="post-com-count-wrapper">';
43037 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
43038 if ( $pending_comments )
43039 echo '<strong>';
43040 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
43041 if ( $pending_comments )
43042 echo '</strong>';
43043 echo '</span> ';
43044 echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
43045 echo '</div></td>';
43046 }
43047 }
43048 }
43049 echo "</tr>\n";
43050 }
43051
43052 /**
43053 * {@internal Missing Short Description}}
43054 *
43055 * @since unknown
43056 *
43057 * @param unknown_type $position
43058 * @param unknown_type $checkbox
43059 * @param unknown_type $mode
43060 */
43061 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
43062 global $current_user;
43063
43064 // allow plugin to replace the popup content
43065 $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
43066
43067 if ( ! empty($content) ) {
43068 echo $content;
43069 return;
43070 }
43071
43072 $columns = get_column_headers('edit-comments');
43073 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) );
43074 $col_count = count($columns) - count($hidden);
43075
43076 ?>
43077 <form method="get" action="">
43078 <?php if ( $table_row ) : ?>
43079 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow"><td colspan="<?php echo $col_count; ?>">
43080 <?php else : ?>
43081 <div id="com-reply" style="display:none;"><div id="replyrow">
43082 <?php endif; ?>
43083 <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>
43084
43085 <div id="edithead" style="display:none;">
43086 <div class="inside">
43087 <label for="author"><?php _e('Name') ?></label>
43088 <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
43089 </div>
43090
43091 <div class="inside">
43092 <label for="author-email"><?php _e('E-mail') ?></label>
43093 <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
43094 </div>
43095
43096 <div class="inside">
43097 <label for="author-url"><?php _e('URL') ?></label>
43098 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
43099 </div>
43100 <div style="clear:both;"></div>
43101 </div>
43102
43103 <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div>
43104
43105 <p id="replysubmit" class="submit">
43106 <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
43107 <a href="#comments-form" class="save button-primary alignright" tabindex="104">
43108 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
43109 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
43110 <img class="waiting" style="display:none;" src="images/loading.gif" alt="" />
43111 <span class="error" style="display:none;"></span>
43112 <br class="clear" />
43113 </p>
43114
43115 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" />
43116 <input type="hidden" name="action" id="action" value="" />
43117 <input type="hidden" name="comment_ID" id="comment_ID" value="" />
43118 <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
43119 <input type="hidden" name="status" id="status" value="" />
43120 <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
43121 <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
43122 <input type="hidden" name="mode" id="mode" value="<?php echo $mode; ?>" />
43123 <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?>
43124 <?php wp_comment_form_unfiltered_html_nonce(); ?>
43125 <?php if ( $table_row ) : ?>
43126 </td></tr></tbody></table>
43127 <?php else : ?>
43128 </div></div>
43129 <?php endif; ?>
43130 </form>
43131 <?php
43132 }
43133
43134 /**
43135 * {@internal Missing Short Description}}
43136 *
43137 * @since unknown
43138 *
43139 * @param unknown_type $currentcat
43140 * @param unknown_type $currentparent
43141 * @param unknown_type $parent
43142 * @param unknown_type $level
43143 * @param unknown_type $categories
43144 * @return unknown
43145 */
43146 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
43147 if (!$categories )
43148 $categories = get_categories( array('hide_empty' => 0) );
43149
43150 if ( $categories ) {
43151 foreach ( $categories as $category ) {
43152 if ( $currentcat != $category->term_id && $parent == $category->parent) {
43153 $pad = str_repeat( '– ', $level );
43154 $category->name = wp_specialchars( $category->name );
43155 echo "\n\t<option value='$category->term_id'";
43156 if ( $currentparent == $category->term_id )
43157 echo " selected='selected'";
43158 echo ">$pad$category->name</option>";
43159 wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
43160 }
43161 }
43162 } else {
43163 return false;
43164 }
43165 }
43166
43167 /**
43168 * {@internal Missing Short Description}}
43169 *
43170 * @since unknown
43171 *
43172 * @param unknown_type $meta
43173 */
43174 function list_meta( $meta ) {
43175 // Exit if no meta
43176 if ( ! $meta ) {
43177 echo '
43178 <table id="list-table" style="display: none;">
43179 <thead>
43180 <tr>
43181 <th class="left">' . __( 'Name' ) . '</th>
43182 <th>' . __( 'Value' ) . '</th>
43183 </tr>
43184 </thead>
43185 <tbody id="the-list" class="list:meta">
43186 <tr><td></td></tr>
43187 </tbody>
43188 </table>'; //TBODY needed for list-manipulation JS
43189 return;
43190 }
43191 $count = 0;
43192 ?>
43193 <table id="list-table">
43194 <thead>
43195 <tr>
43196 <th class="left"><?php _e( 'Name' ) ?></th>
43197 <th><?php _e( 'Value' ) ?></th>
43198 </tr>
43199 </thead>
43200 <tbody id='the-list' class='list:meta'>
43201 <?php
43202 foreach ( $meta as $entry )
43203 echo _list_meta_row( $entry, $count );
43204 ?>
43205 </tbody>
43206 </table>
43207 <?php
43208 }
43209
43210 /**
43211 * {@internal Missing Short Description}}
43212 *
43213 * @since unknown
43214 *
43215 * @param unknown_type $entry
43216 * @param unknown_type $count
43217 * @return unknown
43218 */
43219 function _list_meta_row( $entry, &$count ) {
43220 static $update_nonce = false;
43221 if ( !$update_nonce )
43222 $update_nonce = wp_create_nonce( 'add-meta' );
43223
43224 $r = '';
43225 ++ $count;
43226 if ( $count % 2 )
43227 $style = 'alternate';
43228 else
43229 $style = '';
43230 if ('_' == $entry['meta_key'] { 0 } )
43231 $style .= ' hidden';
43232
43233 if ( is_serialized( $entry['meta_value'] ) ) {
43234 if ( is_serialized_string( $entry['meta_value'] ) ) {
43235 // this is a serialized string, so we should display it
43236 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
43237 } else {
43238 // this is a serialized array/object so we should NOT display it
43239 --$count;
43240 return;
43241 }
43242 }
43243
43244 $entry['meta_key'] = attribute_escape($entry['meta_key']);
43245 $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea />
43246 $entry['meta_id'] = (int) $entry['meta_id'];
43247
43248 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
43249
43250 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
43251 $r .= "\n\t\t<td class='left'><label class='hidden' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' />";
43252
43253 $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' ";
43254 $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' />";
43255 $r .= "\n\t\t<input name='updatemeta' type='submit' tabindex='6' value='".attribute_escape(__( 'Update' ))."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$update_nonce updatemeta' /></div>";
43256 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
43257 $r .= "</td>";
43258
43259 $r .= "\n\t\t<td><label class='hidden' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
43260 return $r;
43261 }
43262
43263 /**
43264 * {@internal Missing Short Description}}
43265 *
43266 * @since unknown
43267 */
43268 function meta_form() {
43269 global $wpdb;
43270 $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
43271 $keys = $wpdb->get_col( "
43272 SELECT meta_key
43273 FROM $wpdb->postmeta
43274 WHERE meta_key NOT LIKE '\_%'
43275 GROUP BY meta_key
43276 ORDER BY meta_id DESC
43277 LIMIT $limit" );
43278 if ( $keys )
43279 natcasesort($keys);
43280 ?>
43281 <p><strong><?php _e( 'Add new custom field:' ) ?></strong></p>
43282 <table id="newmeta">
43283 <thead>
43284 <tr>
43285 <th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th>
43286 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
43287 </tr>
43288 </thead>
43289
43290 <tbody>
43291 <tr>
43292 <td id="newmetaleft" class="left">
43293 <?php if ( $keys ) { ?>
43294 <select id="metakeyselect" name="metakeyselect" tabindex="7">
43295 <option value="#NONE#"><?php _e( '- Select -' ); ?></option>
43296 <?php
43297
43298 foreach ( $keys as $key ) {
43299 $key = attribute_escape( $key );
43300 echo "\n<option value='$key'>$key</option>";
43301 }
43302 ?>
43303 </select>
43304 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
43305 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
43306 <span id="enternew"><?php _e('Enter new'); ?></span>
43307 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
43308 <?php } else { ?>
43309 <input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
43310 <?php } ?>
43311 </td>
43312 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td>
43313 </tr>
43314
43315 <tr><td colspan="2" class="submit">
43316 <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php _e( 'Add Custom Field' ) ?>" />
43317 <?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?>
43318 </td></tr>
43319 </tbody>
43320 </table>
43321 <?php
43322
43323 }
43324
43325 /**
43326 * {@internal Missing Short Description}}
43327 *
43328 * @since unknown
43329 *
43330 * @param unknown_type $edit
43331 * @param unknown_type $for_post
43332 * @param unknown_type $tab_index
43333 * @param unknown_type $multi
43334 */
43335 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
43336 global $wp_locale, $post, $comment;
43337
43338 if ( $for_post )
43339 $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
43340
43341 $tab_index_attribute = '';
43342 if ( (int) $tab_index > 0 )
43343 $tab_index_attribute = " tabindex=\"$tab_index\"";
43344
43345 // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
43346
43347 $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
43348 $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
43349 $jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj );
43350 $mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj );
43351 $aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj );
43352 $hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj );
43353 $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
43354 $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
43355
43356 $cur_jj = gmdate( 'd', $time_adj );
43357 $cur_mm = gmdate( 'm', $time_adj );
43358 $cur_aa = gmdate( 'Y', $time_adj );
43359 $cur_hh = gmdate( 'H', $time_adj );
43360 $cur_mn = gmdate( 'i', $time_adj );
43361
43362 $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
43363 for ( $i = 1; $i < 13; $i = $i +1 ) {
43364 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
43365 if ( $i == $mm )
43366 $month .= ' selected="selected"';
43367 $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
43368 }
43369 $month .= '</select>';
43370
43371 $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
43372 $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off" />';
43373 $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
43374 $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
43375 printf(_c('%1$s%2$s, %3$s @ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute);
43376
43377 echo '<input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
43378
43379 if ( $multi ) return;
43380
43381 echo "\n\n";
43382 foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
43383 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
43384 $cur_timeunit = 'cur_' . $timeunit;
43385 echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
43386 }
43387 ?>
43388
43389 <input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
43390
43391 <p>
43392 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
43393 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
43394 </p>
43395 <?php
43396 }
43397
43398 /**
43399 * {@internal Missing Short Description}}
43400 *
43401 * @since unknown
43402 *
43403 * @param unknown_type $default
43404 */
43405 function page_template_dropdown( $default = '' ) {
43406 $templates = get_page_templates();
43407 ksort( $templates );
43408 foreach (array_keys( $templates ) as $template )
43409 : if ( $default == $templates[$template] )
43410 $selected = " selected='selected'";
43411 else
43412 $selected = '';
43413 echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
43414 endforeach;
43415 }
43416
43417 /**
43418 * {@internal Missing Short Description}}
43419 *
43420 * @since unknown
43421 *
43422 * @param unknown_type $default
43423 * @param unknown_type $parent
43424 * @param unknown_type $level
43425 * @return unknown
43426 */
43427 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
43428 global $wpdb, $post_ID;
43429 $items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) );
43430
43431 if ( $items ) {
43432 foreach ( $items as $item ) {
43433 // A page cannot be its own parent.
43434 if (!empty ( $post_ID ) ) {
43435 if ( $item->ID == $post_ID ) {
43436 continue;
43437 }
43438 }
43439 $pad = str_repeat( ' ', $level * 3 );
43440 if ( $item->ID == $default)
43441 $current = ' selected="selected"';
43442 else
43443 $current = '';
43444
43445 echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . wp_specialchars($item->post_title) . "</option>";
43446 parent_dropdown( $default, $item->ID, $level +1 );
43447 }
43448 } else {
43449 return false;
43450 }
43451 }
43452
43453 /**
43454 * {@internal Missing Short Description}}
43455 *
43456 * @since unknown
43457 */
43458 function browse_happy() {
43459 $getit = __( 'WordPress recommends a better browser' );
43460 echo '
43461 <div id="bh"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></div>
43462 ';
43463 }
43464
43465 /**
43466 * {@internal Missing Short Description}}
43467 *
43468 * @since unknown
43469 *
43470 * @param unknown_type $id
43471 * @return unknown
43472 */
43473 function the_attachment_links( $id = false ) {
43474 $id = (int) $id;
43475 $post = & get_post( $id );
43476
43477 if ( $post->post_type != 'attachment' )
43478 return false;
43479
43480 $icon = get_attachment_icon( $post->ID );
43481 $attachment_data = wp_get_attachment_metadata( $id );
43482 $thumb = isset( $attachment_data['thumb'] );
43483 ?>
43484 <form id="the-attachment-links">
43485 <table>
43486 <col />
43487 <col class="widefat" />
43488 <tr>
43489 <th scope="row"><?php _e( 'URL' ) ?></th>
43490 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>
43491 </tr>
43492 <?php if ( $icon ) : ?>
43493 <tr>
43494 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
43495 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>"><?php echo $icon ?></a></textarea></td>
43496 </tr>
43497 <tr>
43498 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
43499 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>
43500 </tr>
43501 <?php else : ?>
43502 <tr>
43503 <th scope="row"><?php _e( 'Link to file' ) ?></th>
43504 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>" class="attachmentlink"><?php echo basename( wp_get_attachment_url() ); ?></a></textarea></td>
43505 </tr>
43506 <tr>
43507 <th scope="row"><?php _e( 'Link to page' ) ?></th>
43508 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>
43509 </tr>
43510 <?php endif; ?>
43511 </table>
43512 </form>
43513 <?php
43514 }
43515
43516 /**
43517 * {@internal Missing Short Description}}
43518 *
43519 * @since unknown
43520 *
43521 * @param unknown_type $default
43522 */
43523 function wp_dropdown_roles( $default = false ) {
43524 global $wp_roles;
43525 $p = '';
43526 $r = '';
43527 foreach( $wp_roles->role_names as $role => $name ) {
43528 $name = translate_with_context($name);
43529 if ( $default == $role ) // Make default first in list
43530 $p = "\n\t<option selected='selected' value='$role'>$name</option>";
43531 else
43532 $r .= "\n\t<option value='$role'>$name</option>";
43533 }
43534 echo $p . $r;
43535 }
43536
43537 /**
43538 * {@internal Missing Short Description}}
43539 *
43540 * @since unknown
43541 *
43542 * @param unknown_type $size
43543 * @return unknown
43544 */
43545 function wp_convert_hr_to_bytes( $size ) {
43546 $size = strtolower($size);
43547 $bytes = (int) $size;
43548 if ( strpos($size, 'k') !== false )
43549 $bytes = intval($size) * 1024;
43550 elseif ( strpos($size, 'm') !== false )
43551 $bytes = intval($size) * 1024 * 1024;
43552 elseif ( strpos($size, 'g') !== false )
43553 $bytes = intval($size) * 1024 * 1024 * 1024;
43554 return $bytes;
43555 }
43556
43557 /**
43558 * {@internal Missing Short Description}}
43559 *
43560 * @since unknown
43561 *
43562 * @param unknown_type $bytes
43563 * @return unknown
43564 */
43565 function wp_convert_bytes_to_hr( $bytes ) {
43566 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
43567 $log = log( $bytes, 1024 );
43568 $power = (int) $log;
43569 $size = pow(1024, $log - $power);
43570 return $size . $units[$power];
43571 }
43572
43573 /**
43574 * {@internal Missing Short Description}}
43575 *
43576 * @since unknown
43577 *
43578 * @return unknown
43579 */
43580 function wp_max_upload_size() {
43581 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
43582 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
43583 $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
43584 return $bytes;
43585 }
43586
43587 /**
43588 * {@internal Missing Short Description}}
43589 *
43590 * @since unknown
43591 *
43592 * @param unknown_type $action
43593 */
43594 function wp_import_upload_form( $action ) {
43595 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
43596 $size = wp_convert_bytes_to_hr( $bytes );
43597 ?>
43598 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>">
43599 <p>
43600 <?php wp_nonce_field('import-upload'); ?>
43601 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
43602 <input type="file" id="upload" name="import" size="25" />
43603 <input type="hidden" name="action" value="save" />
43604 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
43605 </p>
43606 <p class="submit">
43607 <input type="submit" class="button" value="<?php _e( 'Upload file and import' ); ?>" />
43608 </p>
43609 </form>
43610 <?php
43611 }
43612
43613 /**
43614 * {@internal Missing Short Description}}
43615 *
43616 * @since unknown
43617 */
43618 function wp_remember_old_slug() {
43619 global $post;
43620 $name = attribute_escape($post->post_name); // just in case
43621 if ( strlen($name) )
43622 echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />';
43623 }
43624
43625 /**
43626 * Add a meta box to an edit form.
43627 *
43628 * @since 2.5.0
43629 *
43630 * @param string $id String for use in the 'id' attribute of tags.
43631 * @param string $title Title of the meta box.
43632 * @param string $callback Function that fills the box with the desired content. The function should echo its output.
43633 * @param string $page The type of edit page on which to show the box (post, page, link).
43634 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
43635 * @param string $priority The priority within the context where the boxes should show ('high', 'low').
43636 */
43637 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default') {
43638 global $wp_meta_boxes;
43639
43640 if ( !isset($wp_meta_boxes) )
43641 $wp_meta_boxes = array();
43642 if ( !isset($wp_meta_boxes[$page]) )
43643 $wp_meta_boxes[$page] = array();
43644 if ( !isset($wp_meta_boxes[$page][$context]) )
43645 $wp_meta_boxes[$page][$context] = array();
43646
43647 foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
43648 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
43649 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
43650 continue;
43651
43652 // If a core box was previously added or removed by a plugin, don't add.
43653 if ( 'core' == $priority ) {
43654 // If core box previously deleted, don't add
43655 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
43656 return;
43657 // If box was added with default priority, give it core priority to maintain sort order
43658 if ( 'default' == $a_priority ) {
43659 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
43660 unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
43661 }
43662 return;
43663 }
43664 // If no priority given and id already present, use existing priority
43665 if ( empty($priority) ) {
43666 $priority = $a_priority;
43667 // else if we're adding to the sorted priortiy, we don't know the title or callback. Glab them from the previously added context/priority.
43668 } elseif ( 'sorted' == $priority ) {
43669 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
43670 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
43671 }
43672 // An id can be in only one priority and one context
43673 if ( $priority != $a_priority || $context != $a_context )
43674 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
43675 }
43676 }
43677
43678 if ( empty($priority) )
43679 $priority = 'low';
43680
43681 if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
43682 $wp_meta_boxes[$page][$context][$priority] = array();
43683
43684 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
43685 }
43686
43687 /**
43688 * {@internal Missing Short Description}}
43689 *
43690 * @since unknown
43691 *
43692 * @param unknown_type $page
43693 * @param unknown_type $context
43694 * @param unknown_type $object
43695 * @return int number of meta_boxes
43696 */
43697 function do_meta_boxes($page, $context, $object) {
43698 global $wp_meta_boxes;
43699 static $already_sorted = false;
43700
43701 //do_action('do_meta_boxes', $page, $context, $object);
43702
43703 $hidden = get_hidden_meta_boxes($page);
43704
43705 echo "<div id='$context-sortables' class='meta-box-sortables'>\n";
43706
43707 $i = 0;
43708 do {
43709 // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
43710 if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) {
43711 foreach ( $sorted as $box_context => $ids )
43712 foreach ( explode(',', $ids) as $id )
43713 if ( $id )
43714 add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
43715 }
43716 $already_sorted = true;
43717
43718 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
43719 break;
43720
43721 foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
43722 if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
43723 foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
43724 if ( false == $box || ! $box['title'] )
43725 continue;
43726 $i++;
43727 $style = '';
43728 if ( in_array($box['id'], $hidden) )
43729 $style = 'style="display:none;"';
43730 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n";
43731 echo '<div class="handlediv" title="' . __('Click to toggle') . '"><br /></div>';
43732 echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
43733 echo '<div class="inside">' . "\n";
43734 call_user_func($box['callback'], $object, $box);
43735 echo "</div>\n";
43736 echo "</div>\n";
43737 }
43738 }
43739 }
43740 } while(0);
43741
43742 echo "</div>";
43743
43744 return $i;
43745
43746 }
43747
43748 /**
43749 * Remove a meta box from an edit form.
43750 *
43751 * @since 2.6.0
43752 *
43753 * @param string $id String for use in the 'id' attribute of tags.
43754 * @param string $page The type of edit page on which to show the box (post, page, link).
43755 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
43756 */
43757 function remove_meta_box($id, $page, $context) {
43758 global $wp_meta_boxes;
43759
43760 if ( !isset($wp_meta_boxes) )
43761 $wp_meta_boxes = array();
43762 if ( !isset($wp_meta_boxes[$page]) )
43763 $wp_meta_boxes[$page] = array();
43764 if ( !isset($wp_meta_boxes[$page][$context]) )
43765 $wp_meta_boxes[$page][$context] = array();
43766
43767 foreach ( array('high', 'core', 'default', 'low') as $priority )
43768 $wp_meta_boxes[$page][$context][$priority][$id] = false;
43769 }
43770
43771 /**
43772 * {@internal Missing Short Description}}
43773 *
43774 * @since unknown
43775 *
43776 * @param unknown_type $page
43777 */
43778 function meta_box_prefs($page) {
43779 global $wp_meta_boxes;
43780
43781 if ( empty($wp_meta_boxes[$page]) )
43782 return;
43783
43784 $hidden = get_hidden_meta_boxes($page);
43785
43786 foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
43787 foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
43788 foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
43789 if ( false == $box || ! $box['title'] )
43790 continue;
43791 // Submit box cannot be hidden
43792 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
43793 continue;
43794 $box_id = $box['id'];
43795 echo '<label for="' . $box_id . '-hide">';
43796 echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />';
43797 echo "{$box['title']}</label>\n";
43798 }
43799 }
43800 }
43801 }
43802
43803 function get_hidden_meta_boxes($page) {
43804 $hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false );
43805
43806 // Hide slug boxes by default
43807 if ( empty($hidden[0]) ) {
43808 if ( 'page' == $page )
43809 $hidden = array('pageslugdiv');
43810 elseif ( 'post' == $page )
43811 $hidden = array('slugdiv');
43812 }
43813
43814 return $hidden;
43815 }
43816
43817 /**
43818 * Add a new section to a settings page.
43819 *
43820 * @since 2.7.0
43821 *
43822 * @param string $id String for use in the 'id' attribute of tags.
43823 * @param string $title Title of the section.
43824 * @param string $callback Function that fills the section with the desired content. The function should echo its output.
43825 * @param string $page The type of settings page on which to show the section (general, reading, writing, ...).
43826 */
43827 function add_settings_section($id, $title, $callback, $page) {
43828 global $wp_settings_sections;
43829
43830 if ( !isset($wp_settings_sections) )
43831 $wp_settings_sections = array();
43832 if ( !isset($wp_settings_sections[$page]) )
43833 $wp_settings_sections[$page] = array();
43834 if ( !isset($wp_settings_sections[$page][$id]) )
43835 $wp_settings_sections[$page][$id] = array();
43836
43837 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
43838 }
43839
43840 /**
43841 * Add a new field to a settings page.
43842 *
43843 * @since 2.7.0
43844 *
43845 * @param string $id String for use in the 'id' attribute of tags.
43846 * @param string $title Title of the field.
43847 * @param string $callback Function that fills the field with the desired content. The function should echo its output.
43848 * @param string $page The type of settings page on which to show the field (general, reading, writing, ...).
43849 * @param string $section The section of the settingss page in which to show the box (default, ...).
43850 * @param array $args Additional arguments
43851 */
43852 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
43853 global $wp_settings_fields;
43854
43855 if ( !isset($wp_settings_fields) )
43856 $wp_settings_fields = array();
43857 if ( !isset($wp_settings_fields[$page]) )
43858 $wp_settings_fields[$page] = array();
43859 if ( !isset($wp_settings_fields[$page][$section]) )
43860 $wp_settings_fields[$page][$section] = array();
43861
43862 $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
43863 }
43864
43865 /**
43866 * {@internal Missing Short Description}}
43867 *
43868 * @since unknown
43869 *
43870 * @param unknown_type $page
43871 */
43872 function do_settings_sections($page) {
43873 global $wp_settings_sections, $wp_settings_fields;
43874
43875 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
43876 return;
43877
43878 foreach ( (array) $wp_settings_sections[$page] as $section ) {
43879 echo "<h3>{$section['title']}</h3>\n";
43880 call_user_func($section['callback'], $section);
43881 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
43882 continue;
43883 echo '<table class="form-table">';
43884 do_settings_fields($page, $section['id']);
43885 echo '</table>';
43886 }
43887 }
43888
43889 /**
43890 * {@internal Missing Short Description}}
43891 *
43892 * @since unknown
43893 *
43894 * @param unknown_type $page
43895 * @param unknown_type $section
43896 */
43897 function do_settings_fields($page, $section) {
43898 global $wp_settings_fields;
43899
43900 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
43901 return;
43902
43903 foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
43904 echo '<tr valign="top">';
43905 if ( !empty($field['args']['label_for']) )
43906 echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
43907 else
43908 echo '<th scope="row">' . $field['title'] . '</th>';
43909 echo '<td>';
43910 call_user_func($field['callback']);
43911 echo '</td>';
43912 echo '</tr>';
43913 }
43914 }
43915
43916 /**
43917 * {@internal Missing Short Description}}
43918 *
43919 * @since unknown
43920 *
43921 * @param unknown_type $page
43922 */
43923 function manage_columns_prefs($page) {
43924 $columns = get_column_headers($page);
43925
43926 $hidden = get_hidden_columns($page);
43927
43928 foreach ( $columns as $column => $title ) {
43929 // Can't hide these
43930 if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column )
43931 continue;
43932 if ( empty($title) )
43933 continue;
43934
43935 if ( 'comments' == $column )
43936 $title = __('Comments');
43937 $id = "$column-hide";
43938 echo '<label for="' . $id . '">';
43939 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />';
43940 echo "$title</label>\n";
43941 }
43942 }
43943
43944 /**
43945 * {@internal Missing Short Description}}
43946 *
43947 * @since unknown
43948 *
43949 * @param unknown_type $found_action
43950 */
43951 function find_posts_div($found_action = '') {
43952 ?>
43953 <div id="find-posts" class="find-box" style="display:none;">
43954 <div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
43955 <div class="find-box-inside">
43956 <div class="find-box-search">
43957 <?php if ( $found_action ) { ?>
43958 <input type="hidden" name="found_action" value="<?php echo $found_action; ?>" />
43959 <?php } ?>
43960
43961 <input type="hidden" name="affected" id="affected" value="" />
43962 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
43963 <label class="hidden" for="find-posts-input"><?php _e( 'Search' ); ?></label>
43964 <input type="text" id="find-posts-input" class="search-input" name="ps" value="" />
43965 <input type="button" onclick="findPosts.send();" value="<?php _e( 'Search' ); ?>" class="button" /><br />
43966
43967 <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" />
43968 <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label>
43969 <input type="radio" name="find-posts-what" id="find-posts-pages" value="pages" />
43970 <label for="find-posts-pages"><?php _e( 'Pages' ); ?></label>
43971 </div>
43972 <div id="find-posts-response"></div>
43973 </div>
43974 <div class="find-box-buttons">
43975 <input type="button" class="button" onclick="findPosts.close();" value="<?php _e('Close'); ?>" />
43976 <input id="find-posts-submit" type="submit" class="button" value="<?php _e('Select'); ?>" />
43977 </div>
43978 </div>
43979 <script type="text/javascript">
43980 /* <![CDATA[ */
43981 (function($){
43982 findPosts = {
43983 open : function(af_name, af_val) {
43984 var st = document.documentElement.scrollTop || $(document).scrollTop();
43985
43986 if ( af_name && af_val )
43987 $('#affected').attr('name', af_name).val(af_val);
43988
43989 $('#find-posts').show().draggable({
43990 handle: '#find-posts-head'
43991 }).resizable({
43992 handles: 'all',
43993 minHeight: 150,
43994 minWidth: 280
43995 }).css({'top':st+'px','left':'50%','marginLeft':'-200px'});
43996
43997 $('.ui-resizable-handle').css({
43998 'backgroundColor': '#e5e5e5'
43999 });
44000
44001 $('.ui-resizable-se').css({
44002 'border': '0 none',
44003 'width': '15px',
44004 'height': '16px',
44005 'background': 'transparent url(images/se.png) no-repeat scroll 0 0'
44006 });
44007
44008 $('#find-posts-input').focus().keyup(function(e){
44009 if (e.which == 27) findPosts.close(); // close on Escape
44010 });
44011
44012 return false;
44013 },
44014
44015 close : function() {
44016 $('#find-posts-response').html('');
44017 $('#find-posts').draggable('destroy').resizable('destroy').hide();
44018 },
44019
44020 send : function() {
44021 var post = {};
44022
44023 post['ps'] = $('#find-posts-input').val();
44024 post['action'] = 'find_posts';
44025 post['_ajax_nonce'] = $('#_ajax_nonce').val();
44026
44027 if ( $('#find-posts-pages:checked').val() )
44028 post['pages'] = 1;
44029 else
44030 post['posts'] = 1;
44031
44032 $.ajax({
44033 type : 'POST',
44034 url : '<?php echo admin_url('admin-ajax.php'); ?>',
44035 data : post,
44036 success : function(x) { findPosts.show(x); },
44037 error : function(r) { findPosts.error(r); }
44038 });
44039 },
44040
44041 show : function(x) {
44042
44043 if ( typeof(x) == 'string' ) {
44044 this.error({'responseText': x});
44045 return;
44046 }
44047
44048 var r = wpAjax.parseAjaxResponse(x);
44049
44050 if ( r.errors )
44051 this.error({'responseText': wpAjax.broken});
44052
44053 r = r.responses[0];
44054 $('#find-posts-response').html(r.data);
44055 },
44056
44057 error : function(r) {
44058 var er = r.statusText;
44059
44060 if ( r.responseText )
44061 er = r.responseText.replace( /<.[^<>]*?>/g, '' );
44062
44063 if ( er )
44064 $('#find-posts-response').html(er);
44065 }
44066 };
44067
44068 $(document).ready(function(){
44069 $('#find-posts-submit').click(function(e) {
44070 if ( '' == $('#find-posts-response').html() )
44071 e.preventDefault();
44072 });
44073 });
44074 })(jQuery);
44075 /* ]]> */
44076 </script>
44077 <?php
44078 }
44079
44080 /**
44081 * Display the post password.
44082 *
44083 * The password is passed through {@link attribute_escape()} to ensure that it
44084 * is safe for placing in an html attribute.
44085 *
44086 * @uses attribute_escape
44087 * @since 2.7.0
44088 */
44089 function the_post_password() {
44090 global $post;
44091 if ( isset( $post->post_password ) ) echo attribute_escape( $post->post_password );
44092 }
44093
44094 /**
44095 * {@internal Missing Short Description}}
44096 *
44097 * @since unknown
44098 */
44099 function favorite_actions() {
44100 $actions = array(
44101 'post-new.php' => array(__('New Post'), 'edit_posts'),
44102 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
44103 'page-new.php' => array(__('New Page'), 'edit_pages'),
44104 'media-new.php' => array(__('Upload'), 'upload_files'),
44105 'edit-comments.php' => array(__('Comments'), 'moderate_comments')
44106 );
44107
44108 $actions = apply_filters('favorite_actions', $actions);
44109
44110 $allowed_actions = array();
44111 foreach ( $actions as $action => $data ) {
44112 if ( current_user_can($data[1]) )
44113 $allowed_actions[$action] = $data[0];
44114 }
44115
44116 if ( empty($allowed_actions) )
44117 return;
44118
44119 $first = array_keys($allowed_actions);
44120 $first = $first[0];
44121 echo '<div id="favorite-actions">';
44122 echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';
44123 echo '<div id="favorite-inside">';
44124
44125 array_shift($allowed_actions);
44126
44127 foreach ( $allowed_actions as $action => $label) {
44128 echo "<div class='favorite-action'><a href='$action'>";
44129 echo $label;
44130 echo "</a></div>\n";
44131 }
44132 echo "</div></div>\n";
44133 }
44134
44135 /**
44136 * Get the post title.
44137 *
44138 * The post title is fetched and if it is blank then a default string is
44139 * returned.
44140 *
44141 * @since 2.7.0
44142 * @param int $id The post id. If not supplied the global $post is used.
44143 *
44144 */
44145 function _draft_or_post_title($post_id = 0)
44146 {
44147 $title = get_the_title($post_id);
44148 if ( empty($title) )
44149 $title = __('(no title)');
44150 return $title;
44151 }
44152
44153 /**
44154 * Display the search query.
44155 *
44156 * A simple wrapper to display the "s" parameter in a GET URI. This function
44157 * should only be used when {@link the_search_query()} cannot.
44158 *
44159 * @uses attribute_escape
44160 * @since 2.7.0
44161 *
44162 */
44163 function _admin_search_query() {
44164 echo isset($_GET['s']) ? attribute_escape( stripslashes( $_GET['s'] ) ) : '';
44165 }
44166
44167 /**
44168 * Generic Iframe header for use with Thickbox
44169 *
44170 * @since 2.7.0
44171 * @param string $title Title of the Iframe page.
44172 * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
44173 *
44174 */
44175 function iframe_header( $title = '', $limit_styles = false) {
44176 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
44177 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
44178 <head>
44179 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
44180 <title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title>
44181 <?php
44182 wp_enqueue_style( 'global' );
44183 wp_enqueue_style( 'colors' );
44184 if ( ! $limit_styles )
44185 wp_enqueue_style( 'wp-admin' );
44186 ?>
44187 <script type="text/javascript">
44188 //<![CDATA[
44189 function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}
44190 //]]>
44191 </script>
44192 <?php
44193 do_action('admin_print_styles');
44194 do_action('admin_print_scripts');
44195 do_action('admin_head');
44196 ?>
44197 </head>
44198 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>
44199 <?php
44200 }
44201
44202 /**
44203 * Generic Iframe footer for use with Thickbox
44204 *
44205 * @since 2.7.0
44206 *
44207 */
44208 function iframe_footer() {
44209 echo '
44210 </body>
44211 </html>';
44212 }
44213
44214 function _post_states($post) {
44215 $post_states = array();
44216 if ( isset($_GET['post_status']) )
44217 $post_status = $_GET['post_status'];
44218 else
44219 $post_status = '';
44220
44221 if ( !empty($post->post_password) )
44222 $post_states[] = __('Password protected');
44223 if ( 'private' == $post->post_status && 'private' != $post_status )
44224 $post_states[] = __('Private');
44225 if ( 'draft' == $post->post_status && 'draft' != $post_status )
44226 $post_states[] = __('Draft');
44227 if ( 'pending' == $post->post_status && 'pending' != $post_status )
44228 $post_states[] = __('Pending');
44229
44230 if ( ! empty($post_states) ) {
44231 $state_count = count($post_states);
44232 $i = 0;
44233 echo ' - ';
44234 foreach ( $post_states as $state ) {
44235 ++$i;
44236 ( $i == $state_count ) ? $sep = '' : $sep = ', ';
44237 echo "<span class='post-state'>$state$sep</span>";
44238 }
44239 }
44240 }
44241
44242 function screen_meta($screen) {
44243 global $wp_meta_boxes, $_wp_contextual_help;
44244
44245 $screen = str_replace('.php', '', $screen);
44246 $screen = str_replace('-new', '', $screen);
44247 $screen = str_replace('-add', '', $screen);
44248 $screen = apply_filters('screen_meta_screen', $screen);
44249
44250 $column_screens = get_column_headers($screen);
44251 $meta_screens = array('index' => 'dashboard');
44252
44253 if ( isset($meta_screens[$screen]) )
44254 $screen = $meta_screens[$screen];
44255 $show_screen = false;
44256 if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) )
44257 $show_screen = true;
44258 ?>
44259 <div id="screen-meta">
44260 <?php
44261 if ( $show_screen ) :
44262 ?>
44263 <div id="screen-options-wrap" class="hidden">
44264 <h5><?php _e('Show on screen') ?></h5>
44265 <form id="adv-settings" action="" method="get">
44266 <div class="metabox-prefs">
44267 <?php
44268 if ( !meta_box_prefs($screen) && isset($column_screens) ) {
44269 manage_columns_prefs($screen);
44270 wp_nonce_field( 'hiddencolumns', 'hiddencolumnsnonce', false );
44271 }
44272 ?>
44273 <br class="clear" />
44274 </div></form>
44275 </div>
44276
44277 <?php
44278 endif;
44279
44280 global $title;
44281
44282 if ( !isset($_wp_contextual_help) )
44283 $_wp_contextual_help = array();
44284
44285 if ( !isset($_wp_contextual_help['post']) ) {
44286 $help = drag_drop_help();
44287 $help .= '<p>' . __('<a href="http://codex.wordpress.org/Writing_Posts" target="_blank">Writing Posts</a>') . '</p>';
44288 $_wp_contextual_help['post'] = $help;
44289 }
44290
44291 if ( !isset($_wp_contextual_help['page']) ) {
44292 $help = drag_drop_help();
44293 $_wp_contextual_help['page'] = $help;
44294 }
44295
44296 if ( !isset($_wp_contextual_help['dashboard']) ) {
44297 $help = drag_drop_help();
44298 $_wp_contextual_help['dashboard'] = $help;
44299 }
44300
44301 if ( !isset($_wp_contextual_help['link']) ) {
44302 $help = drag_drop_help();
44303 $_wp_contextual_help['link'] = $help;
44304 }
44305
44306 if ( !isset($_wp_contextual_help['options-general']) )
44307 $_wp_contextual_help['options-general'] = __('<a href="http://codex.wordpress.org/Settings_General_SubPanel" target="_blank">General Settings</a>');
44308
44309 $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen);
44310 ?>
44311 <div id="contextual-help-wrap" class="hidden">
44312 <?php
44313 $contextual_help = '';
44314 if ( isset($_wp_contextual_help[$screen]) ) {
44315 if ( !empty($title) )
44316 $contextual_help .= '<h5>' . sprintf(__('Get help with "%s"'), $title) . '</h5>';
44317 else
44318 $contextual_help .= '<h5>' . __('Get help with this page') . '</h5>';
44319 $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen] . "</div>\n";
44320
44321 $contextual_help .= '<h5>' . __('Other Help') . '</h5>';
44322 } else {
44323 $contextual_help .= '<h5>' . __('Help') . '</h5>';
44324 }
44325
44326 $contextual_help .= '<div class="metabox-prefs">';
44327 $contextual_help .= __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>');
44328 $contextual_help .= '<br />';
44329 $contextual_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>');
44330 $contextual_help .= "</div>\n";
44331 echo apply_filters('contextual_help', $contextual_help, $screen);
44332 ?>
44333 </div>
44334
44335 <div id="screen-meta-links">
44336 <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
44337 <a href="#contextual-help" id="contextual-help-link" class="show-settings"><?php _e('Help') ?></a>
44338 </div>
44339 <?php if ( $show_screen ) { ?>
44340 <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
44341 <a href="#screen-options" id="show-settings-link" class="show-settings"><?php _e('Screen Options') ?></a>
44342 </div>
44343 <?php } ?>
44344 </div>
44345 </div>
44346 <?php
44347 }
44348
44349 /**
44350 * Add contextual help text for a page
44351 *
44352 * @since 2.7.0
44353 *
44354 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
44355 * @param string $help Arbitrary help text
44356 */
44357 function add_contextual_help($screen, $help) {
44358 global $_wp_contextual_help;
44359
44360 if ( !isset($_wp_contextual_help) )
44361 $_wp_contextual_help = array();
44362
44363 $_wp_contextual_help[$screen] = $help;
44364 }
44365
44366 function drag_drop_help() {
44367 return '
44368 <p>' . __('Most of the modules on this screen can be moved. If you hover your mouse over the title bar of a module you`ll notice the 4 arrow cursor appears to let you know it is movable. Click on it, hold down the mouse button and start dragging the module to a new location. As you drag the module, notice the dotted gray box that also moves. This box indicates where the module will be placed when you release the mouse button.') . '</p>
44369 <p>' . __('The same modules can be expanded and collapsed by clicking once on their title bar and also completely hidden from the Screen Options tab.') . '</p>
44370 ';
44371 }
44372
44373 function screen_icon($name = '') {
44374 global $parent_file, $hook_suffix;
44375
44376 if ( empty($name) ) {
44377 if ( isset($parent_file) && !empty($parent_file) )
44378 $name = substr($parent_file, 0, -4);
44379 else
44380 $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix);
44381 }
44382 unset($hook_suffix);
44383 ?>
44384 <div id="icon-<?php echo $name; ?>" class="icon32"><br /></div>
44385 <?php
44386 }
44387
44388 ?>