Make WordPress Core

Changeset 12702


Ignore:
Timestamp:
01/12/2010 12:14:27 AM (15 years ago)
Author:
ryan
Message:

Merge page-new.php into post-new.php. Start abstracting column headers and prefs. see #9674

Location:
trunk/wp-admin
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-header.php

    r12625 r12702  
    5656<?php
    5757
    58 if ( in_array( $pagenow, array('post.php', 'post-new.php', 'page.php', 'page-new.php') ) ) {
     58if ( in_array( $pagenow, array('post.php', 'post-new.php', 'page.php') ) ) {
    5959    add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
    6060    wp_enqueue_script('quicktags');
  • trunk/wp-admin/edit-pages.php

    r12616 r12702  
    1919
    2020    if ( strpos($sendback, 'page.php') !== false )
    21         $sendback = admin_url('page-new.php');
     21        $sendback = admin_url('post-new.php?post_type=page');
    2222
    2323    if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
     
    142142<div class="wrap">
    143143<?php screen_icon(); ?>
    144 <h2><?php echo esc_html( $title ); ?> <a href="page-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'page'); ?></a> <?php
     144<h2><?php echo esc_html( $title ); ?> <a href="post-new.php?post_type=page" class="button add-new-h2"><?php echo esc_html_x('Add New', 'page'); ?></a> <?php
    145145if ( isset($_GET['s']) && $_GET['s'] )
    146146    printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( get_search_query() ) ); ?>
  • trunk/wp-admin/includes/post.php

    r12616 r12702  
    325325 * @since unknown
    326326 *
     327 *@param string A post type string, defaults to 'post'.
    327328 * @return object stdClass object containing all the default post data as attributes
    328329 */
    329 function get_default_post_to_edit() {
     330function get_default_post_to_edit( $post_type = 'post' ) {
    330331
    331332    $post_title = '';
     
    348349    $post->post_password = '';
    349350    $post->post_status = 'draft';
    350     $post->post_type = 'post';
     351    $post->post_type = $post_type;
    351352    $post->to_ping = '';
    352353    $post->pinged = '';
  • trunk/wp-admin/includes/template.php

    r12694 r12702  
    749749 */
    750750function wp_manage_posts_columns() {
     751    global $typenow;
     752
    751753    $posts_columns = array();
    752754    $posts_columns['cb'] = '<input type="checkbox" />';
     
    754756    $posts_columns['title'] = _x('Post', 'column name');
    755757    $posts_columns['author'] = __('Author');
    756     $posts_columns['categories'] = __('Categories');
    757     $posts_columns['tags'] = __('Tags');
     758    if ( empty($typenow) || is_object_in_taxonomy($typenow, 'category') )
     759        $posts_columns['categories'] = __('Categories');
     760    if ( empty($typenow) || is_object_in_taxonomy($typenow, 'category') )
     761        $posts_columns['tags'] = __('Tags');
    758762    $post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';
    759     if ( !in_array( $post_status, array('pending', 'draft', 'future') ) )
     763    if ( !in_array( $post_status, array('pending', 'draft', 'future') ) && ( empty($typenow) || post_type_supports($typenow, 'comments') ) )
    760764        $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
    761765    $posts_columns['date'] = __('Date');
     
    827831        $_wp_column_headers = array();
    828832
     833    $map_screen = $page;
     834    $type = str_replace('edit-', '', $map_screen);
     835    if ( in_array($type, get_post_types()) )
     836        $map_screen = 'edit';
     837
    829838    // Store in static to avoid running filters on each call
    830839    if ( isset($_wp_column_headers[$page]) )
    831840        return $_wp_column_headers[$page];
    832841
    833     switch ($page) {
     842    switch ($map_screen) {
    834843        case 'edit':
    835844             $_wp_column_headers[$page] = wp_manage_posts_columns();
     
    925934    $hidden = get_hidden_columns($type);
    926935    $styles = array();
    927 //  $styles['tag']['posts'] = 'width: 90px;';
    928 //  $styles['link-category']['links'] = 'width: 90px;';
    929 //  $styles['category']['posts'] = 'width: 90px;';
    930 //  $styles['link']['visible'] = 'text-align: center;';
    931936
    932937    foreach ( $columns as $column_key => $column_display_name ) {
     
    34953500            $screen = $typenow;
    34963501    }
     3502    if ( 'edit' == $screen ) {
     3503        if ( !empty($typenow) )
     3504            $screen = 'edit-' . $typenow;
     3505    }
    34973506
    34983507    if ( isset($meta_screens[$screen]) )
     
    37083717
    37093718function screen_options($screen) {
    3710     switch ( $screen ) {
     3719    $map_screen = $screen;
     3720    $type = str_replace('edit-', '', $map_screen);
     3721    if ( in_array($type, get_post_types()) )
     3722        $map_screen = 'edit';
     3723
     3724    switch ( $map_screen ) {
    37113725        case 'edit':
    37123726            $per_page_label = __('Posts per page:');
  • trunk/wp-admin/menu.php

    r12694 r12702  
    7272    $submenu['edit-pages.php'][5] = array( __('Edit'), 'edit_pages', 'edit-pages.php' );
    7373    /* translators: add new page */
    74     $submenu['edit-pages.php'][10] = array( _x('Add New', 'page'), 'edit_pages', 'page-new.php' );
     74    $submenu['edit-pages.php'][10] = array( _x('Add New', 'page'), 'edit_pages', 'post-new.php?post_type=page' );
    7575
    7676$menu[25] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php', '', 'menu-top', 'menu-comments', 'div' );
  • trunk/wp-admin/page.php

    r12695 r12702  
    7474
    7575$sendback = wp_get_referer();
    76 if ( strpos($sendback, 'page.php') !== false || strpos($sendback, 'page-new.php') !== false )
     76if ( strpos($sendback, 'page.php') !== false || strpos($sendback, 'post-new.php') !== false )
    7777    $sendback = admin_url('edit-pages.php');
    7878else
  • trunk/wp-admin/post-new.php

    r12597 r12702  
    1010require_once('admin.php');
    1111
    12 if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) )
     12if ( isset($_GET['post_type']) && ( in_array( $_GET['post_type'], get_post_types( array('_show' => true ) ) ) || in_array( $_GET['post_type'], get_post_types( array('_builtin' => true ) ) ) ) )
    1313    $post_type = $_GET['post_type'];
    1414else
     
    1818    $parent_file = "edit.php?post_type=$post_type";
    1919    $submenu_file = "post-new.php?post_type=$post_type";
     20    if ( 'page' == $post_type )
     21        $parent_file = 'edit-pages.php';
    2022} else {
    2123    $parent_file = 'edit.php';
     
    3638wp_enqueue_script('word-count');
    3739
    38 if ( ! current_user_can('edit_posts') ) {
     40if ( 'post' == $post_type && !current_user_can('edit_posts') ) {
    3941    require_once ('./admin-header.php'); ?>
    4042<div class="wrap">
     
    5052
    5153// Show post form.
    52 $post = get_default_post_to_edit();
    53 $post->post_type = $post_type;
    54 include('edit-form-advanced.php');
     54if ( current_user_can('edit_' . $post_type_object->capability_type . 's') ) {
     55    $post = get_default_post_to_edit( $post_type );
     56    include('edit-form-advanced.php');
     57}
    5558
    5659include('admin-footer.php');
Note: See TracChangeset for help on using the changeset viewer.