true ), 'object' ); $options = get_option( 'posts_by_type_access' ); if( $options['version'] != PBTA_VER ) { $options['version'] = PBTA_VER; if( !isset( $options['published'] ) ) { $options['published'] = 1; } if( !isset( $options['scheduled'] ) ) { $options['scheduled'] = 1; } if( !isset( $options['drafts'] ) ) { $options['drafts'] = 1; } if( !isset( $options['numbers'] ) ) { $options['numbers'] = 1; } if( !isset( $options['zeros'] ) ) { $options['zeros'] = 1; } update_option( 'posts_by_type_access', $options ); } foreach( $post_types as $post_type ) { $name = $post_type->name; $num_posts = wp_count_posts( $name, 'readable' ); $path = 'edit.php'; if( 'post' != $name ) // edit.php?post_type=post doesn't work $path .= '?post_type=' . $name; if( $options['published'] == 1 ) { $post_status = null; $post_status = get_post_status_object( 'publish' ); $menu_name = __( "Published" ); if( $options['numbers'] == 1 ) { if( $options['zeros'] == 1 || $num_posts->publish > 0 ) { $menu_name .= " (" . number_format_i18n( $num_posts->publish ) . ")"; } } add_submenu_page( $path, __( 'Published' ), $menu_name, $post_type->cap->edit_posts, "edit.php?post_type=$name&post_status=publish" ); } if( $options['scheduled'] == 1 ) { $post_status = null; $post_status = get_post_status_object( 'future' ); $menu_name = __( "Scheduled" ); if( $options['numbers'] == 1 ) { if( $options['zeros'] == 1 || $num_posts->future > 0 ) { $menu_name .= " (" . number_format_i18n( $num_posts->future ) . ")"; } } add_submenu_page( $path, __( 'Scheduled' ), $menu_name, $post_type->cap->edit_posts, "edit.php?post_type=$name&post_status=future" ); } if( $options['drafts'] == 1 ) { $post_status = null; $post_status = get_post_status_object( 'draft' ); $menu_name = sprintf( translate_nooped_plural( $post_status->label_count, $num_posts->draft ), number_format_i18n( $num_posts->draft ) ); $menu_name = __( "Drafts" ); if( $options['numbers'] == 1 ) { if( $options['zeros'] == 1 || $num_posts->draft > 0 ) { $menu_name .= " (" . number_format_i18n( $num_posts->draft ) . ")"; } } add_submenu_page( $path, __( 'Drafts' ), $menu_name, $post_type->cap->edit_posts, "edit.php?post_type=$name&post_status=draft" ); } } } function posts_by_type_access_admin_page() { if( $_POST['posts_by_type_access'] ) { if( $_POST['posts_by_type_access']['numbers'] != 1 ) $_POST['posts_by_type_access']['zeros'] = 0; if( !isset( $_POST['posts_by_type_access']['published'] ) ) { $_POST['posts_by_type_access']['published'] = 0; } if( !isset( $_POST['posts_by_type_access']['scheduled'] ) ) { $_POST['posts_by_type_access']['scheduled'] = 0; } if( !isset( $_POST['posts_by_type_access']['drafts'] ) ) { $_POST['posts_by_type_access']['drafts'] = 0; } if( !isset( $_POST['posts_by_type_access']['numbers'] ) ) { $_POST['posts_by_type_access']['numbers'] = 0; } if( !isset( $_POST['posts_by_type_access']['zeros'] ) ) { $_POST['posts_by_type_access']['zeros'] = 0; } update_option( 'posts_by_type_access', $_POST['posts_by_type_access'] ); } $options = get_option( 'posts_by_type_access' ); //***** Start HTML ?>

Posts by Type Access Options

/>
/>
/>
 
/>
/>