Changeset 15746 for trunk/wp-admin/includes/template.php
- Timestamp:
- 10/07/2010 07:34:18 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r15664 r15746 1390 1390 if ( is_string($screen) ) 1391 1391 $screen = convert_to_screen($screen); 1392 1393 if ( $screen->is_user ) 1394 return; 1392 1395 1393 1396 if ( isset($screen->post_type) ) { … … 1636 1639 1637 1640 function screen_meta($screen) { 1638 global $wp_meta_boxes, $_wp_contextual_help, $wp_list_table ;1641 global $wp_meta_boxes, $_wp_contextual_help, $wp_list_table, $wp_current_screen_options; 1639 1642 1640 1643 if ( is_string($screen) ) … … 1670 1673 break; 1671 1674 } 1672 if( ! empty( $settings ) ) 1675 if ( ! empty( $settings ) ) 1676 $show_screen = true; 1677 1678 if ( !empty($wp_current_screen_options) ) 1673 1679 $show_screen = true; 1674 1680 … … 1797 1803 1798 1804 function screen_layout($screen) { 1799 global $screen_layout_columns ;1805 global $screen_layout_columns, $wp_current_screen_options; 1800 1806 1801 1807 if ( is_string($screen) ) 1802 1808 $screen = convert_to_screen($screen); 1803 1809 1804 $columns = array('dashboard' => 4, 'link' => 2); 1805 1806 // Add custom post types 1807 foreach ( get_post_types( array('show_ui' => true) ) as $post_type ) 1808 $columns[$post_type] = 2; 1809 1810 $columns = apply_filters('screen_layout_columns', $columns, $screen->id, $screen); 1811 1812 if ( !isset($columns[$screen->id]) ) { 1810 // Back compat for plugins using the filter instead of add_screen_option() 1811 $columns = apply_filters('screen_layout_columns', array(), $screen->id, $screen); 1812 if ( !empty($columns) && isset($columns[$screen->id]) ) 1813 add_screen_option('layout_columns', array('max' => $columns[$screen->id]) ); 1814 1815 if ( !isset($wp_current_screen_options['layout_columns']) ) { 1813 1816 $screen_layout_columns = 0; 1814 1817 return ''; 1815 1818 } 1816 1819 1817 1820 $screen_layout_columns = get_user_option("screen_layout_$screen->id"); 1818 $num = $columns[$screen->id]; 1819 1820 if ( ! $screen_layout_columns ) 1821 $num = $wp_current_screen_options['layout_columns']['max']; 1822 1823 if ( ! $screen_layout_columns ) { 1824 if ( isset($wp_current_screen_options['layout_columns']['default']) ) 1825 $screen_layout_columns = $wp_current_screen_options['layout_columns']['default']; 1826 else 1821 1827 $screen_layout_columns = 2; 1828 } 1822 1829 1823 1830 $i = 1; … … 1831 1838 } 1832 1839 1840 /** 1841 * Register and configure an admin screen option 1842 * 1843 * @since 3.1.0 1844 * 1845 * @param string $option An option name. 1846 * @param mixed $args Option dependent arguments 1847 * @return void 1848 */ 1849 function add_screen_option( $option, $args = array() ) { 1850 global $wp_current_screen_options; 1851 1852 if ( !isset($wp_current_screen_options) ) 1853 $wp_current_screen_options = array(); 1854 1855 $wp_current_screen_options[$option] = $args; 1856 } 1857 1833 1858 function screen_options($screen) { 1859 global $wp_current_screen_options; 1860 1834 1861 if ( is_string($screen) ) 1835 1862 $screen = convert_to_screen($screen); 1836 1863 1837 switch ( $screen->base ) { 1838 case 'edit': 1839 case 'edit-pages': 1840 $post_type = 'post'; 1841 if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array( 'show_ui' => true ) ) ) ) 1842 $post_type = $_GET['post_type']; 1843 $post_type_object = get_post_type_object($post_type); 1844 $per_page_label = $post_type_object->labels->name; 1845 break; 1846 case 'ms-sites': 1847 $per_page_label = _x( 'Sites', 'sites per page (screen options)' ); 1848 break; 1849 case 'users': 1850 case 'ms-users': 1851 $per_page_label = _x( 'Users', 'users per page (screen options)' ); 1852 break; 1853 case 'edit-comments': 1854 $per_page_label = _x( 'Comments', 'comments per page (screen options)' ); 1855 break; 1856 case 'upload': 1857 $per_page_label = _x( 'Media items', 'items per page (screen options)' ); 1858 break; 1859 case 'edit-tags': 1860 global $tax; 1861 $per_page_label = $tax->labels->name; 1862 break; 1863 case 'plugins': 1864 $per_page_label = _x( 'Plugins', 'plugins per page (screen options)' ); 1865 break; 1866 default: 1867 return ''; 1868 } 1869 1870 $option = str_replace( '-', '_', "{$screen->id}_per_page" ); 1871 if ( 'edit_tags_per_page' == $option ) { 1872 if ( 'category' == $tax->name ) 1873 $option = 'categories_per_page'; 1874 elseif ( 'post_tag' != $tax->name ) 1875 $option = 'edit_' . $tax->name . '_per_page'; 1864 if ( !isset($wp_current_screen_options['per_page']) ) 1865 return ''; 1866 1867 $per_page_label = $wp_current_screen_options['per_page']['label']; 1868 1869 if ( empty($wp_current_screen_options['per_page']['option']) ) { 1870 $option = str_replace( '-', '_', "{$screen->id}_per_page" ); 1871 } else { 1872 $option = $wp_current_screen_options['per_page']['option']; 1876 1873 } 1877 1874 1878 1875 $per_page = (int) get_user_option( $option ); 1879 1876 if ( empty( $per_page ) || $per_page < 1 ) { 1880 if ( 'plugins' == $screen->id)1881 $per_page = 999;1877 if ( isset($wp_current_screen_options['per_page']['default']) ) 1878 $per_page = $wp_current_screen_options['per_page']['default']; 1882 1879 else 1883 1880 $per_page = 20; … … 1996 1993 </script> 1997 1994 <?php 1995 } 1996 1997 /** 1998 * Get the current screen object 1999 * 2000 * @since 3.1.0 2001 * 2002 * @return object Current screen object 2003 */ 2004 function get_current_screen() { 2005 global $current_screen; 2006 2007 if ( !isset($current_screen) ) 2008 return null; 2009 2010 return $current_screen; 1998 2011 } 1999 2012 … … 2061 2074 2062 2075 $current_screen->is_network = is_network_admin() ? true : false; 2076 $current_screen->is_user = is_user_admin() ? true : false; 2077 2078 if ( $current_screen->is_network ) { 2079 $current_screen->base .= '-network'; 2080 $current_screen->id .= '-network'; 2081 } elseif ( $current_screen->is_user ) { 2082 $current_screen->base .= '-user'; 2083 $current_screen->id .= '-user'; 2084 } 2063 2085 2064 2086 $current_screen = apply_filters('current_screen', $current_screen);
Note: See TracChangeset
for help on using the changeset viewer.