249 /** |
249 /** |
250 * Helper to create links to edit.php with params. |
250 * Helper to create links to edit.php with params. |
251 * |
251 * |
252 * @since 4.4.0 |
252 * @since 4.4.0 |
253 * |
253 * |
254 * @param string[] $args Associative array of URL parameters for the link. |
254 * @param string[] $args Associative array of URL parameters for the link. |
255 * @param string $label Link text. |
255 * @param string $link_text Link text. |
256 * @param string $class Optional. Class attribute. Default empty string. |
256 * @param string $css_class Optional. Class attribute. Default empty string. |
257 * @return string The formatted link string. |
257 * @return string The formatted link string. |
258 */ |
258 */ |
259 protected function get_edit_link( $args, $label, $class = '' ) { |
259 protected function get_edit_link( $args, $link_text, $css_class = '' ) { |
260 $url = add_query_arg( $args, 'edit.php' ); |
260 $url = add_query_arg( $args, 'edit.php' ); |
261 |
261 |
262 $class_html = ''; |
262 $class_html = ''; |
263 $aria_current = ''; |
263 $aria_current = ''; |
264 |
264 |
265 if ( ! empty( $class ) ) { |
265 if ( ! empty( $css_class ) ) { |
266 $class_html = sprintf( |
266 $class_html = sprintf( |
267 ' class="%s"', |
267 ' class="%s"', |
268 esc_attr( $class ) |
268 esc_attr( $css_class ) |
269 ); |
269 ); |
270 |
270 |
271 if ( 'current' === $class ) { |
271 if ( 'current' === $css_class ) { |
272 $aria_current = ' aria-current="page"'; |
272 $aria_current = ' aria-current="page"'; |
273 } |
273 } |
274 } |
274 } |
275 |
275 |
276 return sprintf( |
276 return sprintf( |
277 '<a href="%s"%s%s>%s</a>', |
277 '<a href="%s"%s%s>%s</a>', |
278 esc_url( $url ), |
278 esc_url( $url ), |
279 $class_html, |
279 $class_html, |
280 $aria_current, |
280 $aria_current, |
281 $label |
281 $link_text |
282 ); |
282 ); |
283 } |
283 } |
284 |
284 |
285 /** |
285 /** |
286 * @global array $locked_post_status This seems to be deprecated. |
286 * @global array $locked_post_status This seems to be deprecated. |
815 return; |
815 return; |
816 } |
816 } |
817 } |
817 } |
818 |
818 |
819 /* |
819 /* |
820 * Arrange pages into two parts: top level pages and children_pages |
820 * Arrange pages into two parts: top level pages and children_pages. |
821 * children_pages is two dimensional array, eg. |
821 * children_pages is two dimensional array. Example: |
822 * children_pages[10][] contains all sub-pages whose parent is 10. |
822 * children_pages[10][] contains all sub-pages whose parent is 10. |
823 * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations |
823 * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations |
824 * If searching, ignore hierarchy and treat everything as top level |
824 * If searching, ignore hierarchy and treat everything as top level |
825 */ |
825 */ |
826 if ( empty( $_REQUEST['s'] ) ) { |
826 if ( empty( $_REQUEST['s'] ) ) { |
903 * @since 3.1.0 (Standalone function exists since 2.6.0) |
903 * @since 3.1.0 (Standalone function exists since 2.6.0) |
904 * @since 4.2.0 Added the `$to_display` parameter. |
904 * @since 4.2.0 Added the `$to_display` parameter. |
905 * |
905 * |
906 * @param array $children_pages |
906 * @param array $children_pages |
907 * @param int $count |
907 * @param int $count |
908 * @param int $parent |
908 * @param int $parent_page |
909 * @param int $level |
909 * @param int $level |
910 * @param int $pagenum |
910 * @param int $pagenum |
911 * @param int $per_page |
911 * @param int $per_page |
912 * @param array $to_display List of pages to be displayed. Passed by reference. |
912 * @param array $to_display List of pages to be displayed. Passed by reference. |
913 */ |
913 */ |
914 private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) { |
914 private function _page_rows( &$children_pages, &$count, $parent_page, $level, $pagenum, $per_page, &$to_display ) { |
915 if ( ! isset( $children_pages[ $parent ] ) ) { |
915 if ( ! isset( $children_pages[ $parent_page ] ) ) { |
916 return; |
916 return; |
917 } |
917 } |
918 |
918 |
919 $start = ( $pagenum - 1 ) * $per_page; |
919 $start = ( $pagenum - 1 ) * $per_page; |
920 $end = $start + $per_page; |
920 $end = $start + $per_page; |
921 |
921 |
922 foreach ( $children_pages[ $parent ] as $page ) { |
922 foreach ( $children_pages[ $parent_page ] as $page ) { |
923 if ( $count >= $end ) { |
923 if ( $count >= $end ) { |
924 break; |
924 break; |
925 } |
925 } |
926 |
926 |
927 // If the page starts in a subtree, print the parents. |
927 // If the page starts in a subtree, print the parents. |
962 $count++; |
962 $count++; |
963 |
963 |
964 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
964 $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
965 } |
965 } |
966 |
966 |
967 unset( $children_pages[ $parent ] ); // Required in order to keep track of orphans. |
967 unset( $children_pages[ $parent_page ] ); // Required in order to keep track of orphans. |
968 } |
968 } |
969 |
969 |
970 /** |
970 /** |
971 * Handles the checkbox column output. |
971 * Handles the checkbox column output. |
972 * |
972 * |
973 * @since 4.3.0 |
973 * @since 4.3.0 |
974 * |
974 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. |
975 * @param WP_Post $post The current WP_Post object. |
975 * |
976 */ |
976 * @param WP_Post $item The current WP_Post object. |
977 public function column_cb( $post ) { |
977 */ |
|
978 public function column_cb( $item ) { |
|
979 // Restores the more descriptive, specific name for use within this method. |
|
980 $post = $item; |
978 $show = current_user_can( 'edit_post', $post->ID ); |
981 $show = current_user_can( 'edit_post', $post->ID ); |
979 |
982 |
980 /** |
983 /** |
981 * Filters whether to show the bulk edit checkbox for a post in its list table. |
984 * Filters whether to show the bulk edit checkbox for a post in its list table. |
982 * |
985 * |
1233 |
1236 |
1234 /** |
1237 /** |
1235 * Handles the default column output. |
1238 * Handles the default column output. |
1236 * |
1239 * |
1237 * @since 4.3.0 |
1240 * @since 4.3.0 |
1238 * |
1241 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. |
1239 * @param WP_Post $post The current WP_Post object. |
1242 * |
|
1243 * @param WP_Post $item The current WP_Post object. |
1240 * @param string $column_name The current column name. |
1244 * @param string $column_name The current column name. |
1241 */ |
1245 */ |
1242 public function column_default( $post, $column_name ) { |
1246 public function column_default( $item, $column_name ) { |
|
1247 // Restores the more descriptive, specific name for use within this method. |
|
1248 $post = $item; |
|
1249 |
1243 if ( 'categories' === $column_name ) { |
1250 if ( 'categories' === $column_name ) { |
1244 $taxonomy = 'category'; |
1251 $taxonomy = 'category'; |
1245 } elseif ( 'tags' === $column_name ) { |
1252 } elseif ( 'tags' === $column_name ) { |
1246 $taxonomy = 'post_tag'; |
1253 $taxonomy = 'post_tag'; |
1247 } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) { |
1254 } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) { |
1285 * @param string $taxonomy Taxonomy name. |
1292 * @param string $taxonomy Taxonomy name. |
1286 * @param WP_Term[] $terms Array of term objects appearing in the post row. |
1293 * @param WP_Term[] $terms Array of term objects appearing in the post row. |
1287 */ |
1294 */ |
1288 $term_links = apply_filters( 'post_column_taxonomy_links', $term_links, $taxonomy, $terms ); |
1295 $term_links = apply_filters( 'post_column_taxonomy_links', $term_links, $taxonomy, $terms ); |
1289 |
1296 |
1290 /* translators: Used between list items, there is a space after the comma. */ |
1297 echo implode( wp_get_list_item_separator(), $term_links ); |
1291 echo implode( __( ', ' ), $term_links ); |
|
1292 } else { |
1298 } else { |
1293 echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>'; |
1299 echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>'; |
1294 } |
1300 } |
1295 return; |
1301 return; |
1296 } |
1302 } |
1393 |
1399 |
1394 /** |
1400 /** |
1395 * Generates and displays row action links. |
1401 * Generates and displays row action links. |
1396 * |
1402 * |
1397 * @since 4.3.0 |
1403 * @since 4.3.0 |
1398 * |
1404 * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. |
1399 * @param WP_Post $post Post being acted upon. |
1405 * |
|
1406 * @param WP_Post $item Post being acted upon. |
1400 * @param string $column_name Current column name. |
1407 * @param string $column_name Current column name. |
1401 * @param string $primary Primary column name. |
1408 * @param string $primary Primary column name. |
1402 * @return string Row actions output for posts, or an empty string |
1409 * @return string Row actions output for posts, or an empty string |
1403 * if the current column is not the primary column. |
1410 * if the current column is not the primary column. |
1404 */ |
1411 */ |
1405 protected function handle_row_actions( $post, $column_name, $primary ) { |
1412 protected function handle_row_actions( $item, $column_name, $primary ) { |
1406 if ( $primary !== $column_name ) { |
1413 if ( $primary !== $column_name ) { |
1407 return ''; |
1414 return ''; |
1408 } |
1415 } |
1409 |
1416 |
|
1417 // Restores the more descriptive, specific name for use within this method. |
|
1418 $post = $item; |
1410 $post_type_object = get_post_type_object( $post->post_type ); |
1419 $post_type_object = get_post_type_object( $post->post_type ); |
1411 $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
1420 $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
1412 $actions = array(); |
1421 $actions = array(); |
1413 $title = _draft_or_post_title(); |
1422 $title = _draft_or_post_title(); |
1414 |
1423 |
1600 $classes = $inline_edit_classes . ' '; |
1609 $classes = $inline_edit_classes . ' '; |
1601 $classes .= $bulk ? $bulk_edit_classes : $quick_edit_classes; |
1610 $classes .= $bulk ? $bulk_edit_classes : $quick_edit_classes; |
1602 ?> |
1611 ?> |
1603 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="<?php echo $classes; ?>" style="display: none"> |
1612 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="<?php echo $classes; ?>" style="display: none"> |
1604 <td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
1613 <td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
1605 |
1614 <div class="inline-edit-wrapper" role="region" aria-labelledby="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"> |
1606 <fieldset class="inline-edit-col-left"> |
1615 <fieldset class="inline-edit-col-left"> |
1607 <legend class="inline-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend> |
1616 <legend class="inline-edit-legend" id="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend> |
1608 <div class="inline-edit-col"> |
1617 <div class="inline-edit-col"> |
1609 |
1618 |
1610 <?php if ( post_type_supports( $screen->post_type, 'title' ) ) : ?> |
1619 <?php if ( post_type_supports( $screen->post_type, 'title' ) ) : ?> |
1611 |
1620 |
1612 <?php if ( $bulk ) : ?> |
1621 <?php if ( $bulk ) : ?> |
1646 <?php |
1655 <?php |
1647 if ( post_type_supports( $screen->post_type, 'author' ) ) { |
1656 if ( post_type_supports( $screen->post_type, 'author' ) ) { |
1648 $authors_dropdown = ''; |
1657 $authors_dropdown = ''; |
1649 |
1658 |
1650 if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) { |
1659 if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) { |
1651 $users_opt = array( |
1660 $dropdown_name = 'post_author'; |
1652 'hide_if_only_one_author' => false, |
1661 $dropdown_class = 'authors'; |
1653 'who' => 'authors', |
1662 if ( wp_is_large_user_count() ) { |
1654 'name' => 'post_author', |
1663 $authors_dropdown = sprintf( '<select name="%s" class="%s hidden"></select>', esc_attr( $dropdown_name ), esc_attr( $dropdown_class ) ); |
1655 'class' => 'authors', |
1664 } else { |
1656 'multi' => 1, |
1665 $users_opt = array( |
1657 'echo' => 0, |
1666 'hide_if_only_one_author' => false, |
1658 'show' => 'display_name_with_login', |
1667 'capability' => array( $post_type_object->cap->edit_posts ), |
1659 ); |
1668 'name' => $dropdown_name, |
1660 |
1669 'class' => $dropdown_class, |
1661 if ( $bulk ) { |
1670 'multi' => 1, |
1662 $users_opt['show_option_none'] = __( '— No Change —' ); |
1671 'echo' => 0, |
1663 } |
1672 'show' => 'display_name_with_login', |
1664 |
1673 ); |
1665 /** |
1674 |
1666 * Filters the arguments used to generate the Quick Edit authors drop-down. |
1675 if ( $bulk ) { |
1667 * |
1676 $users_opt['show_option_none'] = __( '— No Change —' ); |
1668 * @since 5.6.0 |
1677 } |
1669 * |
1678 |
1670 * @see wp_dropdown_users() |
1679 /** |
1671 * |
1680 * Filters the arguments used to generate the Quick Edit authors drop-down. |
1672 * @param array $users_opt An array of arguments passed to wp_dropdown_users(). |
1681 * |
1673 * @param bool $bulk A flag to denote if it's a bulk action. |
1682 * @since 5.6.0 |
1674 */ |
1683 * |
1675 $users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, $bulk ); |
1684 * @see wp_dropdown_users() |
1676 |
1685 * |
1677 $authors = wp_dropdown_users( $users_opt ); |
1686 * @param array $users_opt An array of arguments passed to wp_dropdown_users(). |
1678 |
1687 * @param bool $bulk A flag to denote if it's a bulk action. |
1679 if ( $authors ) { |
1688 */ |
1680 $authors_dropdown = '<label class="inline-edit-author">'; |
1689 $users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, $bulk ); |
1681 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; |
1690 |
1682 $authors_dropdown .= $authors; |
1691 $authors = wp_dropdown_users( $users_opt ); |
1683 $authors_dropdown .= '</label>'; |
1692 |
|
1693 if ( $authors ) { |
|
1694 $authors_dropdown = '<label class="inline-edit-author">'; |
|
1695 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; |
|
1696 $authors_dropdown .= $authors; |
|
1697 $authors_dropdown .= '</label>'; |
|
1698 } |
1684 } |
1699 } |
1685 } // current_user_can( 'edit_others_posts' ) |
1700 } // current_user_can( 'edit_others_posts' ) |
1686 |
1701 |
1687 if ( ! $bulk ) { |
1702 if ( ! $bulk ) { |
1688 echo $authors_dropdown; |
1703 echo $authors_dropdown; |
1723 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> |
1738 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> |
1724 |
1739 |
1725 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span> |
1740 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span> |
1726 <input type="hidden" name="<?php echo ( 'category' === $taxonomy->name ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> |
1741 <input type="hidden" name="<?php echo ( 'category' === $taxonomy->name ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> |
1727 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist"> |
1742 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist"> |
1728 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ); ?> |
1743 <?php wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name ) ); ?> |
1729 </ul> |
1744 </ul> |
1730 |
1745 |
1731 <?php endforeach; // $hierarchical_taxonomies as $taxonomy ?> |
1746 <?php endforeach; // $hierarchical_taxonomies as $taxonomy ?> |
1732 |
1747 |
1733 </div> |
1748 </div> |
1817 |
1832 |
1818 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?> |
1833 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?> |
1819 |
1834 |
1820 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?> |
1835 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?> |
1821 <?php $taxonomy_name = esc_attr( $taxonomy->name ); ?> |
1836 <?php $taxonomy_name = esc_attr( $taxonomy->name ); ?> |
1822 |
1837 <div class="inline-edit-tags-wrap"> |
1823 <label class="inline-edit-tags"> |
1838 <label class="inline-edit-tags"> |
1824 <span class="title"><?php echo esc_html( $taxonomy->labels->name ); ?></span> |
1839 <span class="title"><?php echo esc_html( $taxonomy->labels->name ); ?></span> |
1825 <textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo $taxonomy_name; ?>]" class="tax_input_<?php echo $taxonomy_name; ?>"></textarea> |
1840 <textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name ); ?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name ); ?>" aria-describedby="inline-edit-<?php echo esc_attr( $taxonomy->name ); ?>-desc"></textarea> |
1826 </label> |
1841 </label> |
1827 |
1842 <p class="howto" id="inline-edit-<?php echo esc_attr( $taxonomy->name ); ?>-desc"><?php echo esc_html( $taxonomy->labels->separate_items_with_commas ); ?></p> |
|
1843 </div> |
1828 <?php endif; // current_user_can( 'assign_terms' ) ?> |
1844 <?php endif; // current_user_can( 'assign_terms' ) ?> |
1829 |
1845 |
1830 <?php endforeach; // $flat_taxonomies as $taxonomy ?> |
1846 <?php endforeach; // $flat_taxonomies as $taxonomy ?> |
1831 |
1847 |
1832 <?php endif; // count( $flat_taxonomies ) && ! $bulk ?> |
1848 <?php endif; // count( $flat_taxonomies ) && ! $bulk ?> |
1996 } |
2012 } |
1997 } |
2013 } |
1998 ?> |
2014 ?> |
1999 |
2015 |
2000 <div class="submit inline-edit-save"> |
2016 <div class="submit inline-edit-save"> |
2001 <button type="button" class="button cancel alignleft"><?php _e( 'Cancel' ); ?></button> |
|
2002 |
|
2003 <?php if ( ! $bulk ) : ?> |
2017 <?php if ( ! $bulk ) : ?> |
2004 <?php wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); ?> |
2018 <?php wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); ?> |
2005 <button type="button" class="button button-primary save alignright"><?php _e( 'Update' ); ?></button> |
2019 <button type="button" class="button button-primary save"><?php _e( 'Update' ); ?></button> |
|
2020 <?php else : ?> |
|
2021 <?php submit_button( __( 'Update' ), 'primary', 'bulk_edit', false ); ?> |
|
2022 <?php endif; ?> |
|
2023 |
|
2024 <button type="button" class="button cancel"><?php _e( 'Cancel' ); ?></button> |
|
2025 |
|
2026 <?php if ( ! $bulk ) : ?> |
2006 <span class="spinner"></span> |
2027 <span class="spinner"></span> |
2007 <?php else : ?> |
|
2008 <?php submit_button( __( 'Update' ), 'primary alignright', 'bulk_edit', false ); ?> |
|
2009 <?php endif; ?> |
2028 <?php endif; ?> |
2010 |
2029 |
2011 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> |
2030 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> |
2012 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> |
2031 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> |
2013 <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) : ?> |
2032 <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) : ?> |
2014 <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> |
2033 <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> |
2015 <?php endif; ?> |
2034 <?php endif; ?> |
2016 <br class="clear" /> |
|
2017 |
2035 |
2018 <div class="notice notice-error notice-alt inline hidden"> |
2036 <div class="notice notice-error notice-alt inline hidden"> |
2019 <p class="error"></p> |
2037 <p class="error"></p> |
2020 </div> |
2038 </div> |
2021 </div> |
2039 </div> |
|
2040 </div> <!-- end of .inline-edit-wrapper --> |
2022 |
2041 |
2023 </td></tr> |
2042 </td></tr> |
2024 |
2043 |
2025 <?php |
2044 <?php |
2026 $bulk++; |
2045 $bulk++; |