Ticket #43848: 43848.2.diff
File 43848.2.diff, 3.3 KB (added by , 6 years ago) |
---|
-
src/wp-admin/includes/plugin.php
1795 1795 } 1796 1796 1797 1797 /** 1798 * Returns boolean on user access to admin page. 1799 * In short, determines if the user can access the admin page or not. 1800 * 1798 1801 * @global string $pagenow 1799 1802 * @global array $menu 1800 1803 * @global array $submenu … … 1802 1805 * @global array $_wp_submenu_nopriv 1803 1806 * @global string $plugin_page 1804 1807 * @global array $_registered_pages 1808 * 1809 * @return bool 1805 1810 */ 1806 1811 function user_can_access_admin_page() { 1807 1812 global $pagenow, $menu, $submenu, $_wp_menu_nopriv, $_wp_submenu_nopriv, 1808 $plugin_page, $_registered_pages;1813 $plugin_page, $_registered_pages; 1809 1814 1810 1815 $parent = get_admin_page_parent(); 1811 1816 1812 if ( ! isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $parent ][ $pagenow ] ) ) { 1817 if ( 1818 ! isset( $plugin_page ) 1819 && isset( $_wp_submenu_nopriv[ $parent ][ $pagenow ] ) 1820 ) { 1813 1821 return false; 1814 1822 } 1815 1823 … … 1826 1834 } 1827 1835 1828 1836 if ( empty( $parent ) ) { 1829 if ( isset( $_wp_menu_nopriv[ $pagenow ] ) ) { 1837 if ( 1838 isset( $_wp_menu_nopriv[ $pagenow ] ) 1839 || isset( $_wp_submenu_nopriv[ $pagenow ][ $pagenow ] ) 1840 || ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $pagenow ][ $plugin_page ] ) ) 1841 || ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[ $plugin_page ] ) ) 1842 ) { 1830 1843 return false; 1831 1844 } 1832 if ( isset( $_wp_submenu_nopriv[ $pagenow ][ $pagenow ] ) ) { 1833 return false; 1834 } 1835 if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $pagenow ][ $plugin_page ] ) ) { 1836 return false; 1837 } 1838 if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[ $plugin_page ] ) ) { 1839 return false; 1840 } 1845 1841 1846 foreach ( array_keys( $_wp_submenu_nopriv ) as $key ) { 1842 if ( isset( $_wp_submenu_nopriv[ $key ][ $pagenow ] ) ) { 1847 if ( 1848 isset( $_wp_submenu_nopriv[ $key ][ $pagenow ] ) 1849 || ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $key ][ $plugin_page ] ) ) 1850 ) { 1843 1851 return false; 1844 1852 } 1845 if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $key ][ $plugin_page ] ) ) {1846 return false;1847 }1848 1853 } 1849 1854 return true; 1850 1855 } 1851 1856 1852 if ( isset( $plugin_page ) && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[ $plugin_page ] ) ) { 1857 if ( 1858 isset( $plugin_page ) 1859 && ( $plugin_page === $parent ) 1860 && isset( $_wp_menu_nopriv[ $plugin_page ] ) 1861 ) { 1853 1862 return false; 1854 1863 } 1855 1864 1856 1865 if ( isset( $submenu[ $parent ] ) ) { 1857 1866 foreach ( $submenu[ $parent ] as $submenu_array ) { 1858 if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) { 1867 if ( 1868 ( isset( $plugin_page ) && ( $submenu_array[2] === $plugin_page ) ) 1869 || $submenu_array[2] === $pagenow 1870 ) { 1859 1871 if ( current_user_can( $submenu_array[1] ) ) { 1860 1872 return true; 1861 } else {1862 return false;1863 1873 } 1864 } elseif ( $submenu_array[2] == $pagenow ) { 1865 if ( current_user_can( $submenu_array[1] ) ) { 1866 return true; 1867 } else { 1868 return false; 1869 } 1874 1875 return false; 1870 1876 } 1871 1877 } 1872 1878 } 1873 1879 1874 1880 foreach ( $menu as $menu_array ) { 1875 if ( $menu_array[2] == $parent ) { 1876 if ( current_user_can( $menu_array[1] ) ) { 1877 return true; 1878 } else { 1879 return false; 1880 } 1881 if ( 1882 $menu_array[2] === $parent 1883 && current_user_can( $menu_array[1] ) 1884 ) { 1885 return true; 1881 1886 } 1887 1888 return false; 1882 1889 } 1883 1890 1884 1891 return true;