PageRenderTime 70ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 1ms

/msw/dev/wp-admin/includes/template.php

https://github.com/chrissiebrodigan/USC
PHP | 3941 lines | 2725 code | 511 blank | 705 comment | 604 complexity | 6ace5a2cffbf414241be68d8e3af7a25 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * Template WordPress Administration API.
  4. *
  5. * A Big Mess. Also some neat functions that are nicely written.
  6. *
  7. * @package WordPress
  8. * @subpackage Administration
  9. */
  10. /**
  11. * {@internal Missing Short Description}}
  12. *
  13. * @since 2.7
  14. *
  15. * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit.
  16. *
  17. * @param string $type "edit-tags", "categoried" or "edit-link-categories"
  18. * @param string $taxonomy The taxonomy of the row.
  19. * @return
  20. */
  21. function inline_edit_term_row($type, $taxonomy) {
  22. $tax = get_taxonomy($taxonomy);
  23. if ( ! current_user_can( $tax->edit_cap ) )
  24. return;
  25. $columns = get_column_headers($type);
  26. $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) );
  27. $col_count = count($columns) - count($hidden);
  28. ?>
  29. <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
  30. <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $col_count; ?>">
  31. <fieldset><div class="inline-edit-col">
  32. <h4><?php _e( 'Quick Edit' ); ?></h4>
  33. <label>
  34. <span class="title"><?php _e( 'Name' ); ?></span>
  35. <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
  36. </label>
  37. <?php if ( !is_multisite() ) { ?>
  38. <label>
  39. <span class="title"><?php _e( 'Slug' ); ?></span>
  40. <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
  41. </label>
  42. <?php } ?>
  43. </div></fieldset>
  44. <?php
  45. $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );
  46. foreach ( $columns as $column_name => $column_display_name ) {
  47. if ( isset( $core_columns[$column_name] ) )
  48. continue;
  49. do_action( 'quick_edit_custom_box', $column_name, $type, $taxonomy );
  50. }
  51. ?>
  52. <p class="inline-edit-save submit">
  53. <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a>
  54. <?php $update_text = sprintf( __('Update %s'), $tax->singular_label ); ?>
  55. <a accesskey="s" href="#inline-edit" title="<?php echo esc_attr( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a>
  56. <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
  57. <span class="error" style="display:none;"></span>
  58. <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
  59. <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $tax->name ); ?>" />
  60. <br class="clear" />
  61. </p>
  62. </td></tr>
  63. </tbody></table></form>
  64. <?php
  65. }
  66. /**
  67. * {@internal Missing Short Description}}
  68. *
  69. * @since unknown
  70. *
  71. * @param unknown_type $category
  72. * @param unknown_type $name_override
  73. * @return unknown
  74. */
  75. function link_cat_row( $category, $name_override = false ) {
  76. static $row_class = '';
  77. if ( !$category = get_term( $category, 'link_category', OBJECT, 'display' ) )
  78. return false;
  79. if ( is_wp_error( $category ) )
  80. return $category;
  81. $default_cat_id = (int) get_option( 'default_link_category' );
  82. $name = ( $name_override ? $name_override : $category->name );
  83. $edit_link = "link-category.php?action=edit&amp;cat_ID=$category->term_id";
  84. if ( current_user_can( 'manage_categories' ) ) {
  85. $edit = "<a class='row-title' href='$edit_link' title='" . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $category->name)) . "'>$name</a><br />";
  86. $actions = array();
  87. $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
  88. $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
  89. if ( $default_cat_id != $category->term_id )
  90. $actions['delete'] = "<a class='delete:the-list:link-cat-$category->term_id submitdelete' href='" . wp_nonce_url("link-category.php?action=delete&amp;cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id) . "'>" . __('Delete') . "</a>";
  91. $actions = apply_filters('link_cat_row_actions', $actions, $category);
  92. $action_count = count($actions);
  93. $i = 0;
  94. $edit .= '<div class="row-actions">';
  95. foreach ( $actions as $action => $link ) {
  96. ++$i;
  97. ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
  98. $edit .= "<span class='$action'>$link$sep</span>";
  99. }
  100. $edit .= '</div>';
  101. } else {
  102. $edit = $name;
  103. }
  104. $row_class = 'alternate' == $row_class ? '' : 'alternate';
  105. $qe_data = get_term_to_edit($category->term_id, 'link_category');
  106. $category->count = number_format_i18n( $category->count );
  107. $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
  108. $output = "<tr id='link-cat-$category->term_id' class='iedit $row_class'>";
  109. $columns = get_column_headers('edit-link-categories');
  110. $hidden = get_hidden_columns('edit-link-categories');
  111. foreach ( $columns as $column_name => $column_display_name ) {
  112. $class = "class=\"$column_name column-$column_name\"";
  113. $style = '';
  114. if ( in_array($column_name, $hidden) )
  115. $style = ' style="display:none;"';
  116. $attributes = "$class$style";
  117. switch ($column_name) {
  118. case 'cb':
  119. $output .= "<th scope='row' class='check-column'>";
  120. if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) {
  121. $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
  122. } else {
  123. $output .= "&nbsp;";
  124. }
  125. $output .= "</th>";
  126. break;
  127. case 'name':
  128. $output .= "<td $attributes>$edit";
  129. $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
  130. $output .= '<div class="name">' . $qe_data->name . '</div>';
  131. $output .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div>';
  132. $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
  133. break;
  134. case 'description':
  135. $output .= "<td $attributes>$category->description</td>";
  136. break;
  137. case 'slug':
  138. $output .= "<td $attributes>" . apply_filters('editable_slug', $category->slug) . "</td>";
  139. break;
  140. case 'links':
  141. $attributes = 'class="links column-links num"' . $style;
  142. $output .= "<td $attributes>$count</td>";
  143. break;
  144. default:
  145. $output .= "<td $attributes>";
  146. $output .= apply_filters('manage_link_categories_custom_column', '', $column_name, $category->term_id);
  147. $output .= "</td>";
  148. }
  149. }
  150. $output .= '</tr>';
  151. return $output;
  152. }
  153. //
  154. // Category Checklists
  155. //
  156. /**
  157. * {@internal Missing Short Description}}
  158. *
  159. * @since unknown
  160. */
  161. class Walker_Category_Checklist extends Walker {
  162. var $tree_type = 'category';
  163. var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
  164. function start_lvl(&$output, $depth, $args) {
  165. $indent = str_repeat("\t", $depth);
  166. $output .= "$indent<ul class='children'>\n";
  167. }
  168. function end_lvl(&$output, $depth, $args) {
  169. $indent = str_repeat("\t", $depth);
  170. $output .= "$indent</ul>\n";
  171. }
  172. function start_el(&$output, $category, $depth, $args) {
  173. extract($args);
  174. if ( empty($taxonomy) )
  175. $taxonomy = 'category';
  176. if ( $taxonomy == 'category' )
  177. $name = 'post_category';
  178. else
  179. $name = 'tax_input['.$taxonomy.']';
  180. $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
  181. $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
  182. }
  183. function end_el(&$output, $category, $depth, $args) {
  184. $output .= "</li>\n";
  185. }
  186. }
  187. /**
  188. * {@internal Missing Short Description}}
  189. *
  190. * @since unknown
  191. *
  192. * @param unknown_type $post_id
  193. * @param unknown_type $descendants_and_self
  194. * @param unknown_type $selected_cats
  195. * @param unknown_type $popular_cats
  196. */
  197. function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
  198. wp_terms_checklist($post_id,
  199. array(
  200. 'taxonomy' => 'category',
  201. 'descendants_and_self' => $descendants_and_self,
  202. 'selected_cats' => $selected_cats,
  203. 'popular_cats' => $popular_cats,
  204. 'walker' => $walker,
  205. 'checked_ontop' => $checked_ontop
  206. ));
  207. }
  208. /**
  209. * Taxonomy independent version of wp_category_checklist
  210. *
  211. * @param int $post_id
  212. * @param array $args
  213. */
  214. function wp_terms_checklist($post_id = 0, $args = array()) {
  215. $defaults = array(
  216. 'descendants_and_self' => 0,
  217. 'selected_cats' => false,
  218. 'popular_cats' => false,
  219. 'walker' => null,
  220. 'taxonomy' => 'category',
  221. 'checked_ontop' => true
  222. );
  223. extract( wp_parse_args($args, $defaults), EXTR_SKIP );
  224. if ( empty($walker) || !is_a($walker, 'Walker') )
  225. $walker = new Walker_Category_Checklist;
  226. $descendants_and_self = (int) $descendants_and_self;
  227. $args = array('taxonomy' => $taxonomy);
  228. $tax = get_taxonomy($taxonomy);
  229. $args['disabled'] = !current_user_can($tax->assign_cap);
  230. if ( is_array( $selected_cats ) )
  231. $args['selected_cats'] = $selected_cats;
  232. elseif ( $post_id )
  233. $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids')));
  234. else
  235. $args['selected_cats'] = array();
  236. if ( is_array( $popular_cats ) )
  237. $args['popular_cats'] = $popular_cats;
  238. else
  239. $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
  240. if ( $descendants_and_self ) {
  241. $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) );
  242. $self = get_term( $descendants_and_self, $taxonomy );
  243. array_unshift( $categories, $self );
  244. } else {
  245. $categories = (array) get_terms($taxonomy, array('get' => 'all'));
  246. }
  247. if ( $checked_ontop ) {
  248. // 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)
  249. $checked_categories = array();
  250. $keys = array_keys( $categories );
  251. foreach( $keys as $k ) {
  252. if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
  253. $checked_categories[] = $categories[$k];
  254. unset( $categories[$k] );
  255. }
  256. }
  257. // Put checked cats on top
  258. echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
  259. }
  260. // Then the rest of them
  261. echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
  262. }
  263. /**
  264. * {@internal Missing Short Description}}
  265. *
  266. * @since unknown
  267. *
  268. * @param unknown_type $taxonomy
  269. * @param unknown_type $default
  270. * @param unknown_type $number
  271. * @param unknown_type $echo
  272. * @return unknown
  273. */
  274. function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
  275. global $post_ID;
  276. if ( $post_ID )
  277. $checked_terms = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids'));
  278. else
  279. $checked_terms = array();
  280. $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
  281. $tax = get_taxonomy($taxonomy);
  282. if ( ! current_user_can($tax->assign_cap) )
  283. $disabled = 'disabled="disabled"';
  284. else
  285. $disabled = '';
  286. $popular_ids = array();
  287. foreach ( (array) $terms as $term ) {
  288. $popular_ids[] = $term->term_id;
  289. if ( !$echo ) // hack for AJAX use
  290. continue;
  291. $id = "popular-$taxonomy-$term->term_id";
  292. $checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
  293. ?>
  294. <li id="<?php echo $id; ?>" class="popular-category">
  295. <label class="selectit">
  296. <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php echo $disabled ?>/>
  297. <?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?>
  298. </label>
  299. </li>
  300. <?php
  301. }
  302. return $popular_ids;
  303. }
  304. /**
  305. * {@internal Missing Short Description}}
  306. *
  307. * @since unknown
  308. *
  309. * @param unknown_type $link_id
  310. */
  311. function wp_link_category_checklist( $link_id = 0 ) {
  312. $default = 1;
  313. if ( $link_id ) {
  314. $checked_categories = wp_get_link_cats( $link_id );
  315. // No selected categories, strange
  316. if ( ! count( $checked_categories ) )
  317. $checked_categories[] = $default;
  318. } else {
  319. $checked_categories[] = $default;
  320. }
  321. $categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
  322. if ( empty( $categories ) )
  323. return;
  324. foreach ( $categories as $category ) {
  325. $cat_id = $category->term_id;
  326. $name = esc_html( apply_filters( 'the_category', $category->name ) );
  327. $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
  328. 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, '/> ', $name, "</label></li>";
  329. }
  330. }
  331. // Tag stuff
  332. // Returns a single tag row (see tag_rows below)
  333. // Note: this is also used in admin-ajax.php!
  334. /**
  335. * {@internal Missing Short Description}}
  336. *
  337. * @since unknown
  338. *
  339. * @param unknown_type $tag
  340. * @param unknown_type $class
  341. * @return unknown
  342. */
  343. function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) {
  344. global $post_type;
  345. static $row_class = '';
  346. $row_class = ($row_class == '' ? ' class="alternate"' : '');
  347. $count = number_format_i18n( $tag->count );
  348. $tax = get_taxonomy($taxonomy);
  349. if ( 'post_tag' == $taxonomy ) {
  350. $tagsel = 'tag';
  351. } elseif ( 'category' == $taxonomy ) {
  352. $tagsel = 'category_name';
  353. } elseif ( ! empty($tax->query_var) ) {
  354. $tagsel = $tax->query_var;
  355. } else {
  356. $tagsel = $taxonomy;
  357. }
  358. $pad = str_repeat( '&#8212; ', max(0, $level) );
  359. $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
  360. $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit');
  361. $edit_link = "edit-tags.php?action=edit&amp;taxonomy=$taxonomy&amp;post_type=$post_type&amp;tag_ID=$tag->term_id";
  362. $out = '';
  363. $out .= '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>';
  364. $columns = get_column_headers('edit-tags');
  365. $hidden = get_hidden_columns('edit-tags');
  366. $default_term = get_option('default_' . $taxonomy);
  367. foreach ( $columns as $column_name => $column_display_name ) {
  368. $class = "class=\"$column_name column-$column_name\"";
  369. $style = '';
  370. if ( in_array($column_name, $hidden) )
  371. $style = ' style="display:none;"';
  372. $attributes = "$class$style";
  373. switch ($column_name) {
  374. case 'cb':
  375. if ( current_user_can($tax->delete_cap) && $tag->term_id != $default_term )
  376. $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';
  377. else
  378. $out .= '<th scope="row" class="check-column">&nbsp;</th>';
  379. break;
  380. case 'name':
  381. $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $name)) . '">' . $name . '</a></strong><br />';
  382. $actions = array();
  383. if ( current_user_can($tax->edit_cap) ) {
  384. $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
  385. $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
  386. }
  387. if ( current_user_can($tax->delete_cap) && $tag->term_id != $default_term )
  388. $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url("edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";
  389. $actions = apply_filters('tag_row_actions', $actions, $tag);
  390. $actions = apply_filters("${taxonomy}_row_actions", $actions, $tag);
  391. $action_count = count($actions);
  392. $i = 0;
  393. $out .= '<div class="row-actions">';
  394. foreach ( $actions as $action => $link ) {
  395. ++$i;
  396. ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
  397. $out .= "<span class='$action'>$link$sep</span>";
  398. }
  399. $out .= '</div>';
  400. $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
  401. $out .= '<div class="name">' . $qe_data->name . '</div>';
  402. $out .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div>';
  403. $out .= '<div class="parent">' . $qe_data->parent . '</div></div></td>';
  404. break;
  405. case 'description':
  406. $out .= "<td $attributes>$tag->description</td>";
  407. break;
  408. case 'slug':
  409. $out .= "<td $attributes>" . apply_filters('editable_slug', $tag->slug) . "</td>";
  410. break;
  411. case 'posts':
  412. $attributes = 'class="posts column-posts num"' . $style;
  413. $out .= "<td $attributes><a href='edit.php?$tagsel=$tag->slug&amp;post_type=$post_type'>$count</a></td>";
  414. break;
  415. default:
  416. $out .= "<td $attributes>";
  417. $out .= apply_filters("manage_${taxonomy}_custom_column", '', $column_name, $tag->term_id);
  418. $out .= "</td>";
  419. }
  420. }
  421. $out .= "</tr>\n";
  422. return $out;
  423. }
  424. // Outputs appropriate rows for the Nth page of the Tag Management screen,
  425. // assuming M tags displayed at a time on the page
  426. // Returns the number of tags displayed
  427. /**
  428. * {@internal Missing Short Description}}
  429. *
  430. * @since unknown
  431. *
  432. * @param unknown_type $page
  433. * @param unknown_type $pagesize
  434. * @param unknown_type $searchterms
  435. * @return unknown
  436. */
  437. function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'post_tag' ) {
  438. // Get a page worth of tags
  439. $start = ($page - 1) * $pagesize;
  440. $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);
  441. if ( !empty( $searchterms ) )
  442. $args['search'] = $searchterms;
  443. // convert it to table rows
  444. $out = '';
  445. $count = 0;
  446. if ( is_taxonomy_hierarchical($taxonomy) ) {
  447. // We'll need the full set of terms then.
  448. $args['number'] = $args['offset'] = 0;
  449. $terms = get_terms( $taxonomy, $args );
  450. if ( !empty( $searchterms ) ) // Ignore children on searches.
  451. $children = array();
  452. else
  453. $children = _get_term_hierarchy($taxonomy);
  454. // Some funky recursion to get the job done(Paging & parents mainly) is contained within, Skip it for non-hierarchical taxonomies for performance sake
  455. $out .= _term_rows($taxonomy, $terms, $children, $page, $pagesize, $count);
  456. } else {
  457. $terms = get_terms( $taxonomy, $args );
  458. foreach( $terms as $term )
  459. $out .= _tag_row( $term, 0, $taxonomy );
  460. $count = $pagesize; // Only displaying a single page.
  461. }
  462. echo $out;
  463. return $count;
  464. }
  465. function _term_rows( $taxonomy, $terms, &$children, $page = 1, $per_page = 20, &$count, $parent = 0, $level = 0 ) {
  466. $start = ($page - 1) * $per_page;
  467. $end = $start + $per_page;
  468. $output = '';
  469. foreach ( $terms as $key => $term ) {
  470. if ( $count >= $end )
  471. break;
  472. if ( $term->parent != $parent && empty($_GET['s']) )
  473. continue;
  474. // If the page starts in a subtree, print the parents.
  475. if ( $count == $start && $term->parent > 0 && empty($_GET['s']) ) {
  476. $my_parents = $parent_ids = array();
  477. $p = $term->parent;
  478. while ( $p ) {
  479. $my_parent = get_term( $p, $taxonomy );
  480. $my_parents[] = $my_parent;
  481. $p = $my_parent->parent;
  482. if ( in_array($p, $parent_ids) ) // Prevent parent loops.
  483. break;
  484. $parent_ids[] = $p;
  485. }
  486. unset($parent_ids);
  487. $num_parents = count($my_parents);
  488. while ( $my_parent = array_pop($my_parents) ) {
  489. $output .= "\t" . _tag_row( $my_parent, $level - $num_parents, $taxonomy );
  490. $num_parents--;
  491. }
  492. }
  493. if ( $count >= $start )
  494. $output .= "\t" . _tag_row( $term, $level, $taxonomy );
  495. ++$count;
  496. unset($terms[$key]);
  497. if ( isset($children[$term->term_id]) && empty($_GET['s']) )
  498. $output .= _term_rows( $taxonomy, $terms, $children, $page, $per_page, $count, $term->term_id, $level + 1 );
  499. }
  500. return $output;
  501. }
  502. // define the columns to display, the syntax is 'internal name' => 'display name'
  503. /**
  504. * {@internal Missing Short Description}}
  505. *
  506. * @since unknown
  507. *
  508. * @return unknown
  509. */
  510. function wp_manage_posts_columns( $screen = '') {
  511. if ( empty($screen) )
  512. $post_type = 'post';
  513. else
  514. $post_type = $screen->post_type;
  515. $posts_columns = array();
  516. $posts_columns['cb'] = '<input type="checkbox" />';
  517. /* translators: manage posts column name */
  518. $posts_columns['title'] = _x('Title', 'column name');
  519. $posts_columns['author'] = __('Author');
  520. if ( empty($post_type) || is_object_in_taxonomy($post_type, 'category') )
  521. $posts_columns['categories'] = __('Categories');
  522. if ( empty($post_type) || is_object_in_taxonomy($post_type, 'post_tag') )
  523. $posts_columns['tags'] = __('Tags');
  524. $post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';
  525. if ( !in_array( $post_status, array('pending', 'draft', 'future') ) && ( empty($post_type) || post_type_supports($post_type, 'comments') ) )
  526. $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></div>';
  527. $posts_columns['date'] = __('Date');
  528. if ( 'page' == $post_type )
  529. $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );
  530. else
  531. $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );
  532. $posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
  533. return $posts_columns;
  534. }
  535. // define the columns to display, the syntax is 'internal name' => 'display name'
  536. /**
  537. * {@internal Missing Short Description}}
  538. *
  539. * @since unknown
  540. *
  541. * @return unknown
  542. */
  543. function wp_manage_media_columns() {
  544. $posts_columns = array();
  545. $posts_columns['cb'] = '<input type="checkbox" />';
  546. $posts_columns['icon'] = '';
  547. /* translators: column name */
  548. $posts_columns['media'] = _x('File', 'column name');
  549. $posts_columns['author'] = __('Author');
  550. //$posts_columns['tags'] = _x('Tags', 'column name');
  551. /* translators: column name */
  552. $posts_columns['parent'] = _x('Attached to', 'column name');
  553. $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></div>';
  554. //$posts_columns['comments'] = __('Comments');
  555. /* translators: column name */
  556. $posts_columns['date'] = _x('Date', 'column name');
  557. $posts_columns = apply_filters('manage_media_columns', $posts_columns);
  558. return $posts_columns;
  559. }
  560. /**
  561. * {@internal Missing Short Description}}
  562. *
  563. * @since unknown
  564. *
  565. * @return unknown
  566. */
  567. function wp_manage_pages_columns() {
  568. return wp_manage_posts_columns();
  569. }
  570. /**
  571. * {@internal Missing Short Description}}
  572. *
  573. * @since unknown
  574. *
  575. * @param unknown_type $screen
  576. * @return unknown
  577. */
  578. function get_column_headers($screen) {
  579. global $_wp_column_headers;
  580. if ( !isset($_wp_column_headers) )
  581. $_wp_column_headers = array();
  582. if ( is_string($screen) )
  583. $screen = convert_to_screen($screen);
  584. // Store in static to avoid running filters on each call
  585. if ( isset($_wp_column_headers[$screen->id]) )
  586. return $_wp_column_headers[$screen->id];
  587. switch ($screen->base) {
  588. case 'edit':
  589. $_wp_column_headers[$screen->id] = wp_manage_posts_columns( $screen );
  590. break;
  591. case 'edit-comments':
  592. $_wp_column_headers[$screen->id] = array(
  593. 'cb' => '<input type="checkbox" />',
  594. 'author' => __('Author'),
  595. /* translators: column name */
  596. 'comment' => _x('Comment', 'column name'),
  597. //'date' => __('Submitted'),
  598. 'response' => __('In Response To')
  599. );
  600. break;
  601. case 'link-manager':
  602. $_wp_column_headers[$screen->id] = array(
  603. 'cb' => '<input type="checkbox" />',
  604. 'name' => __('Name'),
  605. 'url' => __('URL'),
  606. 'categories' => __('Categories'),
  607. 'rel' => __('Relationship'),
  608. 'visible' => __('Visible'),
  609. 'rating' => __('Rating')
  610. );
  611. break;
  612. case 'upload':
  613. $_wp_column_headers[$screen->id] = wp_manage_media_columns();
  614. break;
  615. case 'categories':
  616. $_wp_column_headers[$screen->id] = array(
  617. 'cb' => '<input type="checkbox" />',
  618. 'name' => __('Name'),
  619. 'description' => __('Description'),
  620. 'slug' => __('Slug'),
  621. 'posts' => __('Posts')
  622. );
  623. break;
  624. case 'edit-link-categories':
  625. $_wp_column_headers[$screen->id] = array(
  626. 'cb' => '<input type="checkbox" />',
  627. 'name' => __('Name'),
  628. 'description' => __('Description'),
  629. 'slug' => __('Slug'),
  630. 'links' => __('Links')
  631. );
  632. break;
  633. case 'edit-tags':
  634. $_wp_column_headers[$screen->id] = array(
  635. 'cb' => '<input type="checkbox" />',
  636. 'name' => __('Name'),
  637. 'description' => __('Description'),
  638. 'slug' => __('Slug'),
  639. 'posts' => __('Posts')
  640. );
  641. break;
  642. case 'users':
  643. $_wp_column_headers[$screen->id] = array(
  644. 'cb' => '<input type="checkbox" />',
  645. 'username' => __('Username'),
  646. 'name' => __('Name'),
  647. 'email' => __('E-mail'),
  648. 'role' => __('Role'),
  649. 'posts' => __('Posts')
  650. );
  651. break;
  652. default :
  653. $_wp_column_headers[$screen->id] = array();
  654. }
  655. $_wp_column_headers[$screen->id] = apply_filters('manage_' . $screen->id . '_columns', $_wp_column_headers[$screen->id]);
  656. return $_wp_column_headers[$screen->id];
  657. }
  658. /**
  659. * {@internal Missing Short Description}}
  660. *
  661. * @since unknown
  662. *
  663. * @param unknown_type $screen
  664. * @param unknown_type $id
  665. */
  666. function print_column_headers( $screen, $id = true ) {
  667. if ( is_string($screen) )
  668. $screen = convert_to_screen($screen);
  669. $columns = get_column_headers( $screen );
  670. $hidden = get_hidden_columns($screen);
  671. $styles = array();
  672. foreach ( $columns as $column_key => $column_display_name ) {
  673. $class = ' class="manage-column';
  674. $class .= " column-$column_key";
  675. if ( 'cb' == $column_key )
  676. $class .= ' check-column';
  677. elseif ( in_array($column_key, array('posts', 'comments', 'links')) )
  678. $class .= ' num';
  679. $class .= '"';
  680. $style = '';
  681. if ( in_array($column_key, $hidden) )
  682. $style = 'display:none;';
  683. if ( isset($styles[$screen->id]) && isset($styles[$screen->id][$column_key]) )
  684. $style .= ' ' . $styles[$screen>id][$column_key];
  685. $style = ' style="' . $style . '"';
  686. ?>
  687. <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th>
  688. <?php }
  689. }
  690. /**
  691. * Register column headers for a particular screen. The header names will be listed in the Screen Options.
  692. *
  693. * @since 2.7.0
  694. *
  695. * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
  696. * @param array $columns An array of columns with column IDs as the keys and translated column names as the values
  697. * @see get_column_headers(), print_column_headers(), get_hidden_columns()
  698. */
  699. function register_column_headers($screen, $columns) {
  700. global $_wp_column_headers;
  701. if ( is_string($screen) )
  702. $screen = convert_to_screen($screen);
  703. if ( !isset($_wp_column_headers) )
  704. $_wp_column_headers = array();
  705. $_wp_column_headers[$screen->id] = $columns;
  706. }
  707. /**
  708. * {@internal Missing Short Description}}
  709. *
  710. * @since unknown
  711. *
  712. * @param unknown_type $screen
  713. */
  714. function get_hidden_columns($screen) {
  715. if ( is_string($screen) )
  716. $screen = convert_to_screen($screen);
  717. return (array) get_user_option( 'manage' . $screen->id. 'columnshidden' );
  718. }
  719. /**
  720. * {@internal Missing Short Description}}
  721. *
  722. * Outputs the quick edit and bulk edit table rows for posts and pages
  723. *
  724. * @since 2.7
  725. *
  726. * @param string $screen
  727. */
  728. function inline_edit_row( $screen ) {
  729. global $current_user, $mode;
  730. if ( is_string($screen) ) {
  731. $screen = array('id' => 'edit-' . $screen, 'base' => 'edit', 'post_type' => $screen );
  732. $screen = (object) $screen;
  733. }
  734. $post = get_default_post_to_edit( $screen->post_type );
  735. $post_type_object = get_post_type_object( $screen->post_type );
  736. $taxonomy_names = get_object_taxonomies( $screen->post_type );
  737. $hierarchical_taxonomies = array();
  738. $flat_taxonomies = array();
  739. foreach ( $taxonomy_names as $taxonomy_name ) {
  740. $taxonomy = get_taxonomy( $taxonomy_name);
  741. if ( !$taxonomy->show_ui )
  742. continue;
  743. if ( $taxonomy->hierarchical )
  744. $hierarchical_taxonomies[] = $taxonomy;
  745. else
  746. $flat_taxonomies[] = $taxonomy;
  747. }
  748. $columns = wp_manage_posts_columns($screen);
  749. $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
  750. $col_count = count($columns) - count($hidden);
  751. $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
  752. $can_publish = current_user_can($post_type_object->publish_cap);
  753. $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
  754. ?>
  755. <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
  756. <?php
  757. $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
  758. $bulk = 0;
  759. while ( $bulk < 2 ) { ?>
  760. <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$screen->post_type ";
  761. echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$screen->post_type";
  762. ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
  763. <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
  764. <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
  765. <?php
  766. if ( post_type_supports( $screen->post_type, 'title' ) ) :
  767. if ( $bulk ) : ?>
  768. <div id="bulk-title-div">
  769. <div id="bulk-titles"></div>
  770. </div>
  771. <?php else : // $bulk ?>
  772. <label>
  773. <span class="title"><?php _e( 'Title' ); ?></span>
  774. <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
  775. </label>
  776. <label>
  777. <span class="title"><?php _e( 'Slug' ); ?></span>
  778. <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
  779. </label>
  780. <?php endif; // $bulk
  781. endif; // post_type_supports title ?>
  782. <?php if ( !$bulk ) : ?>
  783. <label><span class="title"><?php _e( 'Date' ); ?></span></label>
  784. <div class="inline-edit-date">
  785. <?php touch_time(1, 1, 4, 1); ?>
  786. </div>
  787. <br class="clear" />
  788. <?php endif; // $bulk
  789. if ( post_type_supports( $screen->post_type, 'author' ) ) :
  790. $authors = get_editable_user_ids( $current_user->id, true, $screen->post_type ); // TODO: ROLE SYSTEM
  791. $authors_dropdown = '';
  792. if ( $authors && count( $authors ) > 1 ) :
  793. $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1, 'echo' => 0);
  794. if ( $bulk )
  795. $users_opt['show_option_none'] = __('&mdash; No Change &mdash;');
  796. $authors_dropdown = '<label>';
  797. $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
  798. $authors_dropdown .= wp_dropdown_users( $users_opt );
  799. $authors_dropdown .= '</label>';
  800. endif; // authors
  801. ?>
  802. <?php if ( !$bulk ) echo $authors_dropdown;
  803. endif; // post_type_supports author
  804. if ( !$bulk ) :
  805. ?>
  806. <div class="inline-edit-group">
  807. <label class="alignleft">
  808. <span class="title"><?php _e( 'Password' ); ?></span>
  809. <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
  810. </label>
  811. <em style="margin:5px 10px 0 0" class="alignleft">
  812. <?php
  813. /* translators: Between password field and private checkbox on post quick edit interface */
  814. echo __( '&ndash;OR&ndash;' );
  815. ?>
  816. </em>
  817. <label class="alignleft inline-edit-private">
  818. <input type="checkbox" name="keep_private" value="private" />
  819. <span class="checkbox-title"><?php echo __('Private'); ?></span>
  820. </label>
  821. </div>
  822. <?php endif; ?>
  823. </div></fieldset>
  824. <?php if ( count($hierarchical_taxonomies) && !$bulk ) : ?>
  825. <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
  826. <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
  827. <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->label) ?>
  828. <span class="catshow"><?php _e('[more]'); ?></span>
  829. <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span>
  830. </span>
  831. <ul class="cat-checklist <?php echo esc_attr($taxonomy->name)?>-checklist">
  832. <?php wp_terms_checklist(null, array('taxonomy' => $taxonomy->name)) ?>
  833. </ul>
  834. <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
  835. </div></fieldset>
  836. <?php endif; // count($hierarchical_taxonomies) && !$bulk ?>
  837. <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
  838. <?php
  839. if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
  840. echo $authors_dropdown;
  841. ?>
  842. <?php if ( $post_type_object->hierarchical ) : ?>
  843. <label>
  844. <span class="title"><?php _e( 'Parent' ); ?></span>
  845. <?php
  846. $dropdown_args = array('post_type' => $post_type_object->name, 'selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column'=> 'menu_order, post_title');
  847. if ( $bulk )
  848. $dropdown_args['show_option_no_change'] = __('&mdash; No Change &mdash;');
  849. $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args);
  850. wp_dropdown_pages($dropdown_args);
  851. ?>
  852. </label>
  853. <?php if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
  854. if ( !$bulk ) : ?>
  855. <label>
  856. <span class="title"><?php _e( 'Order' ); ?></span>
  857. <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
  858. </label>
  859. <?php endif; // !$bulk ?>
  860. <label>
  861. <span class="title"><?php _e( 'Template' ); ?></span>
  862. <select name="page_template">
  863. <?php if ( $bulk ) : ?>
  864. <option value="-1"><?php _e('&mdash; No Change &mdash;'); ?></option>
  865. <?php endif; // $bulk ?>
  866. <option value="default"><?php _e( 'Default Template' ); ?></option>
  867. <?php page_template_dropdown() ?>
  868. </select>
  869. </label>
  870. <?php
  871. endif; // post_type_supports page-attributes
  872. endif; // $post_type_object->hierarchical ?>
  873. <?php if ( count($flat_taxonomies) && !$bulk ) : ?>
  874. <?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
  875. <label class="inline-edit-tags">
  876. <span class="title"><?php echo esc_html($taxonomy->label) ?></span>
  877. <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr($taxonomy->name)?>]" class="tax_input_<?php echo esc_attr($taxonomy->name)?>"></textarea>
  878. </label>
  879. <?php endforeach; //$flat_taxonomies as $taxonomy ?>
  880. <?php endif; // count($flat_taxonomies) && !$bulk ?>
  881. <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
  882. if ( $bulk ) : ?>
  883. <div class="inline-edit-group">
  884. <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
  885. <label class="alignleft">
  886. <span class="title"><?php _e( 'Comments' ); ?></span>
  887. <select name="comment_status">
  888. <option value=""><?php _e('&mdash; No Change &mdash;'); ?></option>
  889. <option value="open"><?php _e('Allow'); ?></option>
  890. <option value="closed"><?php _e('Do not allow'); ?></option>
  891. </select>
  892. </label>
  893. <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
  894. <label class="alignright">
  895. <span class="title"><?php _e( 'Pings' ); ?></span>
  896. <select name="ping_status">
  897. <option value=""><?php _e('&mdash; No Change &mdash;'); ?></option>
  898. <option value="open"><?php _e('Allow'); ?></option>
  899. <option value="closed"><?php _e('Do not allow'); ?></option>
  900. </select>
  901. </label>
  902. <?php endif; ?>
  903. </div>
  904. <?php else : // $bulk ?>
  905. <div class="inline-edit-group">
  906. <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
  907. <label class="alignleft">
  908. <input type="checkbox" name="comment_status" value="open" />
  909. <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
  910. </label>
  911. <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
  912. <label class="alignleft">
  913. <input type="checkbox" name="ping_status" value="open" />
  914. <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
  915. </label>
  916. <?php endif; ?>
  917. </div>
  918. <?php endif; // $bulk
  919. endif; // post_type_supports comments or pings ?>
  920. <div class="inline-edit-group">
  921. <label class="inline-edit-status alignleft">
  922. <span class="title"><?php _e( 'Status' ); ?></span>
  923. <select name="_status">
  924. <?php if ( $bulk ) : ?>
  925. <option value="-1"><?php _e('&mdash; No Change &mdash;'); ?></option>
  926. <?php endif; // $bulk ?>
  927. <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
  928. <option value="publish"><?php _e( 'Published' ); ?></option>
  929. <option value="future"><?php _e( 'Scheduled' ); ?></option>
  930. <?php if ( $bulk ) : ?>
  931. <option value="private"><?php _e('Private') ?></option>
  932. <?php endif; // $bulk ?>
  933. <?php endif; ?>
  934. <option value="pending"><?php _e( 'Pending Review' ); ?></option>
  935. <option value="draft"><?php _e( 'Draft' ); ?></option>
  936. </select>
  937. </label>
  938. <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->edit_others_cap ) ) : ?>
  939. <?php if ( $bulk ) : ?>
  940. <label class="alignright">
  941. <span class="title"><?php _e( 'Sticky' ); ?></span>
  942. <select name="sticky">
  943. <option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
  944. <option value="sticky"><?php _e( 'Sticky' ); ?></option>
  945. <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
  946. </select>
  947. </label>
  948. <?php else : // $bulk ?>
  949. <label class="alignleft">
  950. <input type="checkbox" name="sticky" value="sticky" />
  951. <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
  952. </label>
  953. <?php endif; // $bulk ?>
  954. <?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_cap' ) ?>
  955. </div>
  956. </div></fieldset>
  957. <?php
  958. foreach ( $columns as $column_name => $column_display_name ) {
  959. if ( isset( $core_columns[$column_name] ) )
  960. continue;
  961. do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type );
  962. }
  963. ?>
  964. <p class="submit inline-edit-save">
  965. <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a>
  966. <?php if ( ! $bulk ) {
  967. wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
  968. $update_text = __( 'Update' );
  969. ?>
  970. <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a>
  971. <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
  972. <?php } else {
  973. $update_text = __( 'Update' );
  974. ?>
  975. <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo esc_attr( $update_text ); ?>" />
  976. <?php } ?>
  977. <input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?>" />
  978. <input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?>" />
  979. <br class="clear" />
  980. </p>
  981. </td></tr>
  982. <?php
  983. $bulk++;
  984. } ?>
  985. </tbody></table></form>
  986. <?php
  987. }
  988. // adds hidden fields with the data for use in the inline editor for posts and pages
  989. /**
  990. * {@internal Missing Short Description}}
  991. *
  992. * @since unknown
  993. *
  994. * @param unknown_type $post
  995. */
  996. function get_inline_data($post) {
  997. $post_type_object = get_post_type_object($post->post_type);
  998. if ( ! current_user_can($post_type_object->edit_cap, $post->ID) )
  999. return;
  1000. $title = esc_attr( get_the_title( $post->ID ) );
  1001. echo '
  1002. <div class="hidden" id="inline_' . $post->ID . '">
  1003. <div class="post_title">' . $title . '</div>
  1004. <div class="post_name">' . apply_filters('editable_slug', $post->post_name) . '</div>
  1005. <div class="post_author">' . $post->post_author . '</div>
  1006. <div class="comment_status">' . $post->comment_status . '</div>
  1007. <div class="ping_status">' . $post->ping_status . '</div>
  1008. <div class="_status">' . $post->post_status . '</div>
  1009. <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div>
  1010. <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div>
  1011. <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div>
  1012. <div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div>
  1013. <div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div>
  1014. <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
  1015. <div class="post_password">' . esc_html( $post->post_password ) . '</div>';
  1016. if ( $post_type_object->hierarchical )
  1017. echo '<div class="post_parent">' . $post->post_parent . '</div>';
  1018. if ( $post->post_type == 'page' )
  1019. echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>';
  1020. if ( $post_type_object->hierarchical )
  1021. echo '<div class="menu_order">' . $post->menu_order . '</div>';
  1022. $taxonomy_names = get_object_taxonomies( $post->post_type );
  1023. foreach ( $taxonomy_names as $taxonomy_name) {
  1024. $taxonomy = get_taxonomy( $taxonomy_name );
  1025. if ( $taxonomy->hierarchical && $taxonomy->show_ui )
  1026. echo '<div class="post_category" id="'.$taxonomy_name.'_'.$post->ID.'">' . implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array('fields'=>'ids')) ) . '</div>';
  1027. elseif ( $taxonomy->show_ui )
  1028. echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">' . esc_html( str_replace( ',', ', ', get_terms_to_edit($post->ID, $taxonomy_name) ) ) . '</div>';
  1029. }
  1030. if ( !$post_type_object->hierarchical )
  1031. echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
  1032. echo '</div>';
  1033. }
  1034. /**
  1035. * {@internal Missing Short Description}}
  1036. *
  1037. * @since unknown
  1038. *
  1039. * @param unknown_type $posts
  1040. */
  1041. function post_rows( $posts = array() ) {
  1042. global $wp_query, $post, $mode;
  1043. add_filter('the_title','esc_html');
  1044. // Create array of post IDs.
  1045. $post_ids = array();
  1046. if ( empty($posts) )
  1047. $posts = &$wp_query->posts;
  1048. foreach ( $posts as $a_post )
  1049. $post_ids[] = $a_post->ID;
  1050. $comment_pending_count = get_pending_comments_num($post_ids);
  1051. foreach ( $posts as $post ) {
  1052. if ( empty($comment_pending_count[$post->ID]) )
  1053. $comment_pending_count[$post->ID] = 0;
  1054. _post_row($post, $comment_pending_count[$post->ID], $mode);
  1055. }
  1056. }
  1057. /**
  1058. * {@internal Missing Short Description}}
  1059. *
  1060. * @since unknown
  1061. *
  1062. * @param unknown_type $a_post
  1063. * @param unknown_type $pending_comments
  1064. * @param unknown_type $mode
  1065. */
  1066. function _post_row($a_post, $pending_comments, $mode) {
  1067. global $post, $current_user, $current_screen;
  1068. static $rowclass;
  1069. $global_post = $post;
  1070. $post = $a_post;
  1071. setup_postdata($post);
  1072. $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
  1073. $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
  1074. $edit_link = get_edit_post_link( $post->ID );
  1075. $title = _draft_or_post_title();
  1076. $post_type_object = get_post_type_object($post->post_type);
  1077. ?>
  1078. <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
  1079. <?php
  1080. $posts_columns = get_column_headers( $current_screen );
  1081. $hidden = get_hidden_columns( $current_screen );
  1082. foreach ( $posts_columns as $column_name=>$column_display_name ) {
  1083. $class = "class=\"$column_name column-$column_name\"";
  1084. $style = '';
  1085. if ( in_array($column_name, $hidden) )
  1086. $style = ' style="display:none;"';
  1087. $attributes = "$class$style";
  1088. switch ($column_name) {
  1089. case 'cb':
  1090. ?>
  1091. <th scope="row" class="check-column"><?php if ( current_user_can( $post_type_object->edit_cap, $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>
  1092. <?php
  1093. break;
  1094. case 'date':
  1095. if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
  1096. $t_time = $h_time = __('Unpublished');
  1097. $time_diff = 0;
  1098. } else {
  1099. $t_time = get_the_time(__('Y/m/d g:i:s A'));
  1100. $m_time = $post->post_date;
  1101. $time = get_post_time('G', true, $post);
  1102. $time_diff = time() - $time;
  1103. if ( $time_diff > 0 && $time_diff < 24*60*60 )
  1104. $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
  1105. else
  1106. $h_time = mysql2date(__('Y/m/d'), $m_time);
  1107. }
  1108. echo '<td ' . $attributes . '>';
  1109. if ( 'excerpt' == $mode )
  1110. echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
  1111. else
  1112. echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
  1113. echo '<br />';
  1114. if ( 'publish' == $post->post_status ) {
  1115. _e('Published');
  1116. } elseif ( 'future' == $post->post_status ) {
  1117. if ( $time_diff > 0 )
  1118. echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
  1119. else
  1120. _e('Scheduled');
  1121. } else {
  1122. _e('Last Modified');
  1123. }
  1124. echo '</td>';
  1125. break;
  1126. case 'title':
  1127. $attributes = 'class="post-title column-title"' . $style;
  1128. ?>
  1129. <td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->edit_cap, $post->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
  1130. <?php
  1131. if ( 'excerpt' == $mode )
  1132. the_excerpt();
  1133. $actions = array();
  1134. if ( current_user_can($post_type_object->edit_cap, $post->ID) && 'trash' != $post->post_status ) {
  1135. $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>';
  1136. $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
  1137. }
  1138. if ( current_user_can($post_type_object->delete_cap, $post->ID) ) {
  1139. if ( 'trash' == $post->post_status )
  1140. $actions['untrash'] = "<a title='" . esc_attr(__('Restore this post from the Trash')) . "' href='" . wp_nonce_url( admin_url( sprintf($post_type_object->_edit_link . '&amp;action=untrash', $post->ID) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __('Restore') . "</a>";
  1141. elseif ( EMPTY_TRASH_DAYS )
  1142. $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>";
  1143. if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
  1144. $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>";
  1145. }
  1146. if ( in_array($post->post_status, array('pending', 'draft')) ) {
  1147. if ( current_user_can($post_type_object->edit_cap, $post->ID) )
  1148. $actions['view'] = '<a href="' . add_query_arg( 'preview', 'true', get_permalink($post->ID) ) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
  1149. } elseif ( 'trash' != $post->post_status ) {
  1150. $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
  1151. }
  1152. $actions = apply_filters('post_row_actions', $actions, $post);
  1153. $action_count = count($actions);
  1154. $i = 0;
  1155. echo '<div class="row-actions">';
  1156. foreach ( $actions as $action => $link ) {
  1157. ++$i;
  1158. ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
  1159. echo "<span class='$action'>$link$sep</span>";
  1160. }
  1161. echo '</div>';
  1162. get_inline_data($post);
  1163. ?>
  1164. </td>
  1165. <?php
  1166. break;
  1167. case 'categories':
  1168. ?>
  1169. <td <?php echo $attributes ?>><?php
  1170. $categories = get_the_category();
  1171. if ( !empty( $categories ) ) {
  1172. $out = array();
  1173. foreach ( $categories as $c )
  1174. $out[] = "<a href='edit.php?category_name=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
  1175. echo join( ', ', $out );
  1176. } else {
  1177. _e('Uncategorized');
  1178. }
  1179. ?></td>
  1180. <?php
  1181. break;
  1182. case 'tags':
  1183. ?>
  1184. <td <?php echo $attributes ?>><?php
  1185. $tags = get_the_tags($post->ID);
  1186. if ( !empty( $tags ) ) {
  1187. $out = array();
  1188. foreach ( $tags as $c )
  1189. $out[] = "<a href='edit.php?tag=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
  1190. echo join( ', ', $out );
  1191. } else {
  1192. _e('No Tags');
  1193. }
  1194. ?></td>
  1195. <?php
  1196. break;
  1197. case 'comments':
  1198. ?>
  1199. <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
  1200. <?php
  1201. $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
  1202. if ( $pending_comments )
  1203. echo '<strong>';
  1204. comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');
  1205. if ( $pending_comments )
  1206. echo '</strong>';
  1207. ?>
  1208. </div></td>
  1209. <?php
  1210. break;
  1211. case 'author':
  1212. ?>
  1213. <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td>
  1214. <?php
  1215. break;
  1216. case 'control_view':
  1217. ?>
  1218. <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
  1219. <?php
  1220. break;
  1221. case 'control_edit':
  1222. ?>
  1223. <td><?php if ( current_user_can($post_type_object->edit_cap, $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
  1224. <?php
  1225. break;
  1226. case 'control_delete':
  1227. ?>
  1228. <td><?php if ( current

Large files files are truncated, but you can click here to view the full file