| 52 | | global $wp_meta_boxes; |
| 53 | | |
| 54 | | if ( is_string( $screen ) ) |
| 55 | | $screen = convert_to_screen( $screen ); |
| 56 | | |
| 57 | | if ( empty($wp_meta_boxes[$screen->id]) ) |
| 58 | | return; |
| 59 | | |
| 60 | | $hidden = get_hidden_meta_boxes($screen); |
| 61 | | |
| 62 | | foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) { |
| 63 | | foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) { |
| 64 | | foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) { |
| 65 | | if ( false == $box || ! $box['title'] ) |
| 66 | | continue; |
| 67 | | // Submit box cannot be hidden |
| 68 | | if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) |
| 69 | | continue; |
| 70 | | $box_id = $box['id']; |
| 71 | | echo '<label for="' . $box_id . '-hide">'; |
| 72 | | echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />'; |
| 73 | | echo "{$box['title']}</label>\n"; |
| 74 | | } |
| 75 | | } |
| 76 | | } |
| | 52 | return; |
| 891 | | if ( 'dashboard' === $this->id && current_user_can( 'edit_theme_options' ) ) { |
| 892 | | if ( isset( $_GET['welcome'] ) ) { |
| 893 | | $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1; |
| 894 | | update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); |
| 895 | | } else { |
| 896 | | $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); |
| 897 | | if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) |
| 898 | | $welcome_checked = false; |
| 899 | | } |
| 900 | | echo '<label for="wp_welcome_panel-hide">'; |
| 901 | | echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />'; |
| 902 | | echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n"; |
| 903 | | } |
| 904 | | ?> |
| 905 | | <br class="clear" /> |
| 906 | | </div> |
| 907 | | <?php endif; |
| 908 | | if ( $columns ) : |
| 909 | | if ( ! empty( $columns['_title'] ) ) : ?> |
| 910 | | <h5><?php echo $columns['_title']; ?></h5> |
| 911 | | <?php endif; ?> |
| 912 | | <div class="metabox-prefs"> |
| 913 | | <?php |
| 914 | | $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname'); |
| | 869 | function render_show_on_screen( $parent, $wp_admin_bar ) { |
| | 870 | global $wp_meta_boxes; |
| 923 | | if ( 'comments' == $column ) |
| 924 | | $title = __( 'Comments' ); |
| 925 | | $id = "$column-hide"; |
| 926 | | echo '<label for="' . $id . '">'; |
| 927 | | echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />'; |
| 928 | | echo "$title</label>\n"; |
| | 875 | $columns = get_column_headers( $this ); |
| | 876 | |
| | 877 | if ( ! isset( $wp_meta_boxes[ $this->id ] ) && ( ! $columns || isset( $columns['_title'] ) ) ) |
| | 878 | return; |
| | 879 | |
| | 880 | $wp_admin_bar->add_menu( array( |
| | 881 | 'id' => 'show-on-screen', |
| | 882 | 'parent' => $parent, |
| | 883 | 'href' => '', |
| | 884 | 'meta' => array( 'html' => '<h5>' . __( 'Show on screen' ) . '</h5>' ), |
| | 885 | ) ); |
| | 886 | |
| | 887 | // Render meta box show/hide. |
| | 888 | if ( isset( $wp_meta_boxes[ $this->id ] ) ) { |
| | 889 | $hidden = get_hidden_meta_boxes($this); |
| | 890 | |
| | 891 | foreach ( array_keys($wp_meta_boxes[$this->id]) as $context ) { |
| | 892 | foreach ( array_keys($wp_meta_boxes[$this->id][$context]) as $priority ) { |
| | 893 | foreach ( $wp_meta_boxes[$this->id][$context][$priority] as $box ) { |
| | 894 | if ( false == $box || ! $box['title'] ) |
| | 895 | continue; |
| | 896 | // Submit box cannot be hidden |
| | 897 | if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) |
| | 898 | continue; |
| | 899 | $box_id = $box['id']; |
| | 900 | $html = '<label for="' . $box_id . '-hide">' . |
| | 901 | '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />' . |
| | 902 | "{$box['title']}</label>\n"; |
| | 903 | $wp_admin_bar->add_menu( array( |
| | 904 | 'id' => 'show-on-screen-' . $box_id, |
| | 905 | 'parent' => $parent, |
| | 906 | 'href' => '', |
| | 907 | 'meta' => array( 'html' => $html ), |
| | 908 | ) ); |
| | 909 | } |
| 935 | | $this->render_screen_layout(); |
| 936 | | $this->render_per_page_options(); |
| 937 | | echo $this->_screen_settings; |
| | 913 | if ( 'dashboard' === $this->id && current_user_can( 'edit_theme_options' ) ) { |
| | 914 | if ( isset( $_GET['welcome'] ) ) { |
| | 915 | $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1; |
| | 916 | update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); |
| | 917 | } else { |
| | 918 | $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); |
| | 919 | if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) |
| | 920 | $welcome_checked = false; |
| | 921 | } |
| | 922 | $html = '<label for="wp_welcome_panel-hide">' . |
| | 923 | '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />' . |
| | 924 | _x( 'Welcome', 'Welcome panel' ) . "</label>\n"; |
| | 925 | $wp_admin_bar->add_menu( array( |
| | 926 | 'id' => 'show-on-screen-' . $box_id, |
| | 927 | 'parent' => $parent, |
| | 928 | 'href' => '', |
| | 929 | 'meta' => array( 'html' => $html ), |
| | 930 | ) ); |
| | 931 | } |
| | 932 | } |
| 939 | | ?> |
| 940 | | <div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div> |
| 941 | | </form> |
| 942 | | </div> |
| 943 | | <?php |
| | 934 | // Render column show/hide. |
| | 935 | if ( $columns ) { |
| | 936 | $hidden = get_hidden_columns( $this ); |
| | 937 | |
| | 938 | if ( ! empty( $columns['_title'] ) ) { |
| | 939 | echo '<h5>' . $columns['_title'] . '</h5>'; |
| | 940 | } |
| | 941 | |
| | 942 | $special = array( '_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname' ); |
| | 943 | |
| | 944 | foreach ( $columns as $column => $title ) { |
| | 945 | // Can't hide these for they are special |
| | 946 | if ( in_array( $column, $special ) ) |
| | 947 | continue; |
| | 948 | if ( empty( $title ) ) |
| | 949 | continue; |
| | 950 | |
| | 951 | if ( 'comments' == $column ) |
| | 952 | $title = __( 'Comments' ); |
| | 953 | $id = "$column-hide"; |
| | 954 | $html = '<label for="' . $id . '">' . |
| | 955 | '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />' . |
| | 956 | "$title</label>\n"; |
| | 957 | $wp_admin_bar->add_menu( array( |
| | 958 | 'id' => 'show-on-screen-' . $column, |
| | 959 | 'parent' => $parent, |
| | 960 | 'href' => '', |
| | 961 | 'meta' => array( 'html' => $html ), |
| | 962 | ) ); |
| | 963 | } |
| | 964 | } |
| | 967 | function render_layout( $parent, $wp_admin_bar ) { |
| | 968 | if ( ! $this->get_option('layout_columns') ) |
| | 969 | return; |
| | 970 | |
| | 971 | $screen_layout_columns = $this->get_columns(); |
| | 972 | $num = $this->get_option( 'layout_columns', 'max' ); |
| | 973 | |
| | 974 | $wp_admin_bar->add_menu( array( |
| | 975 | 'id' => 'column-layout', |
| | 976 | 'parent' => $parent, |
| | 977 | 'href' => '', |
| | 978 | 'meta' => array( 'html' => '<h5>' . __( 'Column Layout' ) . '</h5>' ), |
| | 979 | ) ); |
| | 980 | |
| | 981 | for ( $i = 1; $i <= $num; ++$i ) { |
| | 982 | $html = '<label class="columns-prefs-' . $i . '">' . |
| | 983 | "<input type='radio' name='screen_columns' value='" . $i . "'" . |
| | 984 | checked( $screen_layout_columns, $i, false ) . '/>' . |
| | 985 | esc_html( $i ) . |
| | 986 | '</label>'; |
| | 987 | |
| | 988 | $wp_admin_bar->add_menu( array( |
| | 989 | 'id' => 'column-layout-' . $i, |
| | 990 | 'parent' => $parent, |
| | 991 | 'href' => '', |
| | 992 | 'meta' => array( 'html' => $html ), |
| | 993 | ) ); |
| | 994 | } |
| | 995 | } |
| | 996 | |