-
+ 371F8D02E7129DB277BEB5E47BC9BC2EBCFD2027D8361E13B2EC6E4C50EC3D307144E3A8A8B1D4731A5AEE6C179201A0A59F21FCCF358BE59D9F0BE4A77F6C5E
mp-wp/wp-admin/categories.php
(0 . 0)(1 . 315)
1680 <?php
1681 /**
1682 * Categories Management Panel
1683 *
1684 * @package WordPress
1685 * @subpackage Administration
1686 */
1687
1688 /** Load WordPress Bootstrap */
1689 require_once('admin.php');
1690
1691 $title = __('Categories');
1692
1693 wp_reset_vars( array('action', 'cat') );
1694
1695 if ( isset( $_GET['action'] ) && isset($_GET['delete']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) )
1696 $action = 'bulk-delete';
1697
1698 switch($action) {
1699
1700 case 'addcat':
1701
1702 check_admin_referer('add-category');
1703
1704 if ( !current_user_can('manage_categories') )
1705 wp_die(__('Cheatin’ uh?'));
1706
1707 if( wp_insert_category($_POST ) ) {
1708 wp_redirect('categories.php?message=1#addcat');
1709 } else {
1710 wp_redirect('categories.php?message=4#addcat');
1711 }
1712 exit;
1713 break;
1714
1715 case 'delete':
1716 $cat_ID = (int) $_GET['cat_ID'];
1717 check_admin_referer('delete-category_' . $cat_ID);
1718
1719 if ( !current_user_can('manage_categories') )
1720 wp_die(__('Cheatin’ uh?'));
1721
1722 $cat_name = get_catname($cat_ID);
1723
1724 // Don't delete the default cats.
1725 if ( $cat_ID == get_option('default_category') )
1726 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
1727
1728 wp_delete_category($cat_ID);
1729
1730 wp_redirect('categories.php?message=2');
1731 exit;
1732
1733 break;
1734
1735 case 'bulk-delete':
1736 check_admin_referer('bulk-categories');
1737
1738 if ( !current_user_can('manage_categories') )
1739 wp_die( __('You are not allowed to delete categories.') );
1740
1741 foreach ( (array) $_GET['delete'] as $cat_ID ) {
1742 $cat_name = get_catname($cat_ID);
1743
1744 // Don't delete the default cats.
1745 if ( $cat_ID == get_option('default_category') )
1746 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
1747
1748 wp_delete_category($cat_ID);
1749 }
1750
1751 $sendback = wp_get_referer();
1752
1753 wp_redirect($sendback);
1754 exit();
1755
1756 break;
1757 case 'edit':
1758
1759 $title = __('Edit Category');
1760
1761 require_once ('admin-header.php');
1762 $cat_ID = (int) $_GET['cat_ID'];
1763 $category = get_category_to_edit($cat_ID);
1764 include('edit-category-form.php');
1765
1766 break;
1767
1768 case 'editedcat':
1769 $cat_ID = (int) $_POST['cat_ID'];
1770 check_admin_referer('update-category_' . $cat_ID);
1771
1772 if ( !current_user_can('manage_categories') )
1773 wp_die(__('Cheatin’ uh?'));
1774
1775 $location = 'categories.php';
1776 if ( $referer = wp_get_original_referer() ) {
1777 if ( false !== strpos($referer, 'categories.php') )
1778 $location = $referer;
1779 }
1780
1781 if ( wp_update_category($_POST) )
1782 $location = add_query_arg('message', 3, $location);
1783 else
1784 $location = add_query_arg('message', 5, $location);
1785
1786 wp_redirect($location);
1787
1788 exit;
1789 break;
1790
1791 default:
1792
1793 if ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
1794 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
1795 exit;
1796 }
1797
1798 wp_enqueue_script('admin-categories');
1799 if ( current_user_can('manage_categories') )
1800 wp_enqueue_script('inline-edit-tax');
1801
1802 require_once ('admin-header.php');
1803
1804 $messages[1] = __('Category added.');
1805 $messages[2] = __('Category deleted.');
1806 $messages[3] = __('Category updated.');
1807 $messages[4] = __('Category not added.');
1808 $messages[5] = __('Category not updated.');
1809 ?>
1810
1811 <div class="wrap nosubsub">
1812 <?php screen_icon(); ?>
1813 <h2><?php echo wp_specialchars( $title );
1814 if ( isset($_GET['s']) && $_GET['s'] )
1815 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( stripslashes($_GET['s']) ) ); ?>
1816 </h2>
1817
1818 <?php
1819 if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?>
1820 <div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?></p></div>
1821 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
1822 endif; ?>
1823
1824 <form class="search-form topmargin" action="" method="get">
1825 <p class="search-box">
1826 <label class="hidden" for="category-search-input"><?php _e('Search Categories'); ?>:</label>
1827 <input type="text" class="search-input" id="category-search-input" name="s" value="<?php _admin_search_query(); ?>" />
1828 <input type="submit" value="<?php _e( 'Search Categories' ); ?>" class="button" />
1829 </p>
1830 </form>
1831 <br class="clear" />
1832
1833 <div id="col-container">
1834
1835 <div id="col-right">
1836 <div class="col-wrap">
1837 <form id="posts-filter" action="" method="get">
1838 <div class="tablenav">
1839
1840 <?php
1841 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
1842 if ( empty($pagenum) )
1843 $pagenum = 1;
1844 if( ! isset( $catsperpage ) || $catsperpage < 0 )
1845 $catsperpage = 20;
1846
1847 $page_links = paginate_links( array(
1848 'base' => add_query_arg( 'pagenum', '%#%' ),
1849 'format' => '',
1850 'prev_text' => __('«'),
1851 'next_text' => __('»'),
1852 'total' => ceil(wp_count_terms('category') / $catsperpage),
1853 'current' => $pagenum
1854 ));
1855
1856 if ( $page_links )
1857 echo "<div class='tablenav-pages'>$page_links</div>";
1858 ?>
1859
1860 <div class="alignleft actions">
1861 <select name="action">
1862 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
1863 <option value="delete"><?php _e('Delete'); ?></option>
1864 </select>
1865 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
1866 <?php wp_nonce_field('bulk-categories'); ?>
1867 </div>
1868
1869 <br class="clear" />
1870 </div>
1871
1872 <div class="clear"></div>
1873
1874 <table class="widefat fixed" cellspacing="0">
1875 <thead>
1876 <tr>
1877 <?php print_column_headers('categories'); ?>
1878 </tr>
1879 </thead>
1880
1881 <tfoot>
1882 <tr>
1883 <?php print_column_headers('categories', false); ?>
1884 </tr>
1885 </tfoot>
1886
1887 <tbody id="the-list" class="list:cat">
1888 <?php
1889 cat_rows(0, 0, 0, $pagenum, $catsperpage);
1890 ?>
1891 </tbody>
1892 </table>
1893
1894 <div class="tablenav">
1895 <?php
1896 if ( $page_links )
1897 echo "<div class='tablenav-pages'>$page_links</div>";
1898 ?>
1899
1900 <div class="alignleft actions">
1901 <select name="action2">
1902 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
1903 <option value="delete"><?php _e('Delete'); ?></option>
1904 </select>
1905 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
1906 <?php wp_nonce_field('bulk-categories'); ?>
1907 </div>
1908
1909 <br class="clear" />
1910 </div>
1911
1912 </form>
1913
1914 <div class="form-wrap">
1915 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), apply_filters('the_category', get_catname(get_option('default_category')))) ?></p>
1916 <p><?php printf(__('Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.'), 'admin.php?import=wp-cat2tag') ?></p>
1917 </div>
1918
1919 </div>
1920 </div><!-- /col-right -->
1921
1922 <div id="col-left">
1923 <div class="col-wrap">
1924
1925 <?php if ( current_user_can('manage_categories') ) { ?>
1926 <?php $category = (object) array(); $category->parent = 0; do_action('add_category_form_pre', $category); ?>
1927
1928 <div class="form-wrap">
1929 <h3><?php _e('Add Category'); ?></h3>
1930 <div id="ajax-response"></div>
1931 <form name="addcat" id="addcat" method="post" action="categories.php" class="add:the-list: validate">
1932 <input type="hidden" name="action" value="addcat" />
1933 <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-category'); ?>
1934
1935 <div class="form-field form-required">
1936 <label for="cat_name"><?php _e('Category Name') ?></label>
1937 <input name="cat_name" id="cat_name" type="text" value="" size="40" aria-required="true" />
1938 <p><?php _e('The name is used to identify the category almost everywhere, for example under the post or in the category widget.'); ?></p>
1939 </div>
1940
1941 <div class="form-field">
1942 <label for="category_nicename"><?php _e('Category Slug') ?></label>
1943 <input name="category_nicename" id="category_nicename" type="text" value="" size="40" />
1944 <p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
1945 </div>
1946
1947 <div class="form-field">
1948 <label for="category_parent"><?php _e('Category Parent') ?></label>
1949 <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'category_parent', 'orderby' => 'name', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('None'))); ?>
1950 <p><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p>
1951 </div>
1952
1953 <div class="form-field">
1954 <label for="category_description"><?php _e('Description') ?></label>
1955 <textarea name="category_description" id="category_description" rows="5" cols="40"></textarea>
1956 <p><?php _e('The description is not prominent by default, however some themes may show it.'); ?></p>
1957 </div>
1958
1959 <p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Category'); ?>" /></p>
1960 <?php do_action('edit_category_form', $category); ?>
1961 </form></div>
1962
1963 <?php } ?>
1964
1965 </div>
1966 </div><!-- /col-left -->
1967
1968 </div><!-- /col-container -->
1969 </div><!-- /wrap -->
1970
1971 <script type="text/javascript">
1972 /* <![CDATA[ */
1973 (function($){
1974 $(document).ready(function(){
1975 $('#doaction, #doaction2').click(function(){
1976 if ( $('select[name^="action"]').val() == 'delete' ) {
1977 var m = '<?php echo js_escape(__("You are about to delete the selected categories.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
1978 return showNotice.warn(m);
1979 }
1980 });
1981 });
1982 })(jQuery);
1983 /* ]]> */
1984 </script>
1985
1986 <?php
1987 inline_edit_term_row('categories');
1988
1989 break;
1990 }
1991
1992 include('admin-footer.php');
1993
1994 ?>