web/wp-admin/edit.php
changeset 194 32102edaa81b
parent 136 bde1974c263b
child 204 09a1c134465b
equal deleted inserted replaced
193:2f6f6f7551ca 194:32102edaa81b
     1 <?php
     1 <?php
     2 /**
     2 /**
     3  * Edit Posts Administration Panel.
     3  * Edit Posts Administration Screen.
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     8 
     8 
     9 /** WordPress Administration Bootstrap */
     9 /** WordPress Administration Bootstrap */
    10 require_once('admin.php');
    10 require_once( './admin.php' );
    11 
    11 
    12 if ( !current_user_can('edit_posts') )
    12 if ( ! $typenow )
    13 	wp_die(__('Cheatin&#8217; uh?'));
    13 	wp_die( __( 'Invalid post type' ) );
       
    14 
       
    15 $post_type = $typenow;
       
    16 $post_type_object = get_post_type_object( $post_type );
       
    17 
       
    18 if ( ! $post_type_object )
       
    19 	wp_die( __( 'Invalid post type' ) );
       
    20 
       
    21 if ( ! current_user_can( $post_type_object->cap->edit_posts ) )
       
    22 	wp_die( __( 'Cheatin&#8217; uh?' ) );
       
    23 
       
    24 $wp_list_table = _get_list_table('WP_Posts_List_Table');
       
    25 $pagenum = $wp_list_table->get_pagenum();
    14 
    26 
    15 // Back-compat for viewing comments of an entry
    27 // Back-compat for viewing comments of an entry
    16 if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['page_id'] ) ) ) {
    28 foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) {
    17 	wp_redirect( admin_url('edit-comments.php?p=' . $_redirect ) );
    29 	if ( ! empty( $_REQUEST[ $_redirect ] ) ) {
    18 	exit;
    30 		wp_redirect( admin_url( 'edit-comments.php?p=' . absint( $_REQUEST[ $_redirect ] ) ) );
       
    31 		exit;
       
    32 	}
       
    33 }
       
    34 unset( $_redirect );
       
    35 
       
    36 if ( 'post' != $post_type ) {
       
    37 	$parent_file = "edit.php?post_type=$post_type";
       
    38 	$submenu_file = "edit.php?post_type=$post_type";
       
    39 	$post_new_file = "post-new.php?post_type=$post_type";
    19 } else {
    40 } else {
    20 	unset( $_redirect );
    41 	$parent_file = 'edit.php';
    21 }
    42 	$submenu_file = 'edit.php';
    22 
    43 	$post_new_file = 'post-new.php';
    23 // Handle bulk actions
    44 }
    24 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) {
    45 
       
    46 $doaction = $wp_list_table->current_action();
       
    47 
       
    48 if ( $doaction ) {
    25 	check_admin_referer('bulk-posts');
    49 	check_admin_referer('bulk-posts');
       
    50 
    26 	$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
    51 	$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
    27 
    52 	if ( ! $sendback )
       
    53 		$sendback = admin_url( $parent_file );
       
    54 	$sendback = add_query_arg( 'paged', $pagenum, $sendback );
    28 	if ( strpos($sendback, 'post.php') !== false )
    55 	if ( strpos($sendback, 'post.php') !== false )
    29 		$sendback = admin_url('post-new.php');
    56 		$sendback = admin_url($post_new_file);
    30 
    57 
    31 	if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
    58 	if ( 'delete_all' == $doaction ) {
    32 		$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']);
    59 		$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);
    33 		$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='post' AND post_status = %s", $post_status ) );
    60 		if ( get_post_status_object($post_status) ) // Check the post status exists first
       
    61 			$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
    34 		$doaction = 'delete';
    62 		$doaction = 'delete';
    35 	} elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['post']) || isset($_GET['ids']) ) ) {
    63 	} elseif ( isset( $_REQUEST['media'] ) ) {
    36 		$post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']);
    64 		$post_ids = $_REQUEST['media'];
    37 		$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
    65 	} elseif ( isset( $_REQUEST['ids'] ) ) {
    38 	} else {
    66 		$post_ids = explode( ',', $_REQUEST['ids'] );
    39 		wp_redirect( admin_url('edit.php') );
    67 	} elseif ( !empty( $_REQUEST['post'] ) ) {
       
    68 		$post_ids = array_map('intval', $_REQUEST['post']);
       
    69 	}
       
    70 
       
    71 	if ( !isset( $post_ids ) ) {
       
    72 		wp_redirect( $sendback );
       
    73 		exit;
    40 	}
    74 	}
    41 
    75 
    42 	switch ( $doaction ) {
    76 	switch ( $doaction ) {
    43 		case 'trash':
    77 		case 'trash':
    44 			$trashed = 0;
    78 			$trashed = 0;
    45 			foreach( (array) $post_ids as $post_id ) {
    79 			foreach( (array) $post_ids as $post_id ) {
    46 				if ( !current_user_can('delete_post', $post_id) )
    80 				if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
    47 					wp_die( __('You are not allowed to move this post to the trash.') );
    81 					wp_die( __('You are not allowed to move this item to the Trash.') );
    48 
    82 
    49 				if ( !wp_trash_post($post_id) )
    83 				if ( !wp_trash_post($post_id) )
    50 					wp_die( __('Error in moving to trash...') );
    84 					wp_die( __('Error in moving to Trash.') );
    51 
    85 
    52 				$trashed++;
    86 				$trashed++;
    53 			}
    87 			}
    54 			$sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids)), $sendback );
    88 			$sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids) ), $sendback );
    55 			break;
    89 			break;
    56 		case 'untrash':
    90 		case 'untrash':
    57 			$untrashed = 0;
    91 			$untrashed = 0;
    58 			foreach( (array) $post_ids as $post_id ) {
    92 			foreach( (array) $post_ids as $post_id ) {
    59 				if ( !current_user_can('delete_post', $post_id) )
    93 				if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
    60 					wp_die( __('You are not allowed to restore this post from the trash.') );
    94 					wp_die( __('You are not allowed to restore this item from the Trash.') );
    61 
    95 
    62 				if ( !wp_untrash_post($post_id) )
    96 				if ( !wp_untrash_post($post_id) )
    63 					wp_die( __('Error in restoring from trash...') );
    97 					wp_die( __('Error in restoring from Trash.') );
    64 
    98 
    65 				$untrashed++;
    99 				$untrashed++;
    66 			}
   100 			}
    67 			$sendback = add_query_arg('untrashed', $untrashed, $sendback);
   101 			$sendback = add_query_arg('untrashed', $untrashed, $sendback);
    68 			break;
   102 			break;
    69 		case 'delete':
   103 		case 'delete':
    70 			$deleted = 0;
   104 			$deleted = 0;
    71 			foreach( (array) $post_ids as $post_id ) {
   105 			foreach( (array) $post_ids as $post_id ) {
    72 				$post_del = & get_post($post_id);
   106 				$post_del = & get_post($post_id);
    73 
   107 
    74 				if ( !current_user_can('delete_post', $post_id) )
   108 				if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
    75 					wp_die( __('You are not allowed to delete this post.') );
   109 					wp_die( __('You are not allowed to delete this item.') );
    76 
   110 
    77 				if ( $post_del->post_type == 'attachment' ) {
   111 				if ( $post_del->post_type == 'attachment' ) {
    78 					if ( ! wp_delete_attachment($post_id) )
   112 					if ( ! wp_delete_attachment($post_id) )
    79 						wp_die( __('Error in deleting...') );
   113 						wp_die( __('Error in deleting...') );
    80 				} else {
   114 				} else {
    84 				$deleted++;
   118 				$deleted++;
    85 			}
   119 			}
    86 			$sendback = add_query_arg('deleted', $deleted, $sendback);
   120 			$sendback = add_query_arg('deleted', $deleted, $sendback);
    87 			break;
   121 			break;
    88 		case 'edit':
   122 		case 'edit':
    89 			$done = bulk_edit_posts($_GET);
   123 			if ( isset($_REQUEST['bulk_edit']) ) {
    90 
   124 				$done = bulk_edit_posts($_REQUEST);
    91 			if ( is_array($done) ) {
   125 
    92 				$done['updated'] = count( $done['updated'] );
   126 				if ( is_array($done) ) {
    93 				$done['skipped'] = count( $done['skipped'] );
   127 					$done['updated'] = count( $done['updated'] );
    94 				$done['locked'] = count( $done['locked'] );
   128 					$done['skipped'] = count( $done['skipped'] );
    95 				$sendback = add_query_arg( $done, $sendback );
   129 					$done['locked'] = count( $done['locked'] );
    96 			}
   130 					$sendback = add_query_arg( $done, $sendback );
    97 			break;
   131 				}
    98 	}
   132 			}
    99 
   133 			break;
   100 	if ( isset($_GET['action']) )
   134 	}
   101 		$sendback = remove_query_arg( array('action', 'action2', 'cat', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status',  'post', 'bulk_edit', 'post_view', 'post_type'), $sendback );
   135 
       
   136 	$sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback );
   102 
   137 
   103 	wp_redirect($sendback);
   138 	wp_redirect($sendback);
   104 	exit();
   139 	exit();
   105 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
   140 } elseif ( ! empty($_REQUEST['_wp_http_referer']) ) {
   106 	 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
   141 	 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
   107 	 exit;
   142 	 exit;
   108 }
   143 }
   109 
   144 
   110 if ( empty($title) )
   145 $wp_list_table->prepare_items();
   111 	$title = __('Edit Posts');
   146 
   112 $parent_file = 'edit.php';
       
   113 wp_enqueue_script('inline-edit-post');
   147 wp_enqueue_script('inline-edit-post');
   114 
   148 
   115 $user_posts = false;
   149 $title = $post_type_object->labels->name;
   116 if ( !current_user_can('edit_others_posts') ) {
   150 
   117 	$user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = 'post' AND post_status != 'trash' AND post_author = %d", $current_user->ID) );
   151 if ( 'post' == $post_type ) {
   118 	$user_posts = true;
   152 	get_current_screen()->add_help_tab( array(
   119 	if ( $user_posts_count && empty($_GET['post_status']) && empty($_GET['all_posts']) && empty($_GET['author']) )
   153 	'id'		=> 'overview',
   120 		$_GET['author'] = $current_user->ID;
   154 	'title'		=> __('Overview'),
   121 }
   155 	'content'	=>
   122 
   156 		'<p>' . __('This screen provides access to all of your posts. You can customize the display of this screen to suit your workflow.') . '</p>'
   123 list($post_stati, $avail_post_stati) = wp_edit_posts_query();
   157 	) );
   124 
   158 	get_current_screen()->add_help_tab( array(
   125 require_once('admin-header.php');
   159 	'id'		=> 'screen-content',
   126 
   160 	'title'		=> __('Screen Content'),
   127 if ( !isset( $_GET['paged'] ) )
   161 	'content'	=>
   128 	$_GET['paged'] = 1;
   162 		'<p>' . __('You can customize the display of this screen&#8217;s contents in a number of ways:') . '</p>' .
   129 
   163 		'<ul>' .
   130 if ( empty($_GET['mode']) )
   164 			'<li>' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '</li>' .
   131 	$mode = 'list';
   165 			'<li>' . __('You can filter the list of posts by post status using the text links in the upper left to show All, Published, Draft, or Trashed posts. The default view is to show all posts.') . '</li>' .
   132 else
   166 			'<li>' . __('You can view posts in a simple title list or with an excerpt. Choose the view you prefer by clicking on the icons at the top of the list on the right.') . '</li>' .
   133 	$mode = esc_attr($_GET['mode']); ?>
   167 			'<li>' . __('You can refine the list to show only posts in a specific category or from a specific month by using the dropdown menus above the posts list. Click the Filter button after making your selection. You also can refine the list by clicking on the post author, category or tag in the posts list.') . '</li>' .
   134 
   168 		'</ul>'
       
   169 	) );
       
   170 	get_current_screen()->add_help_tab( array(
       
   171 	'id'		=> 'action-links',
       
   172 	'title'		=> __('Available Actions'),
       
   173 	'content'	=>
       
   174 		'<p>' . __('Hovering over a row in the posts list will display action links that allow you to manage your post. You can perform the following actions:') . '</p>' .
       
   175 		'<ul>' .
       
   176 			'<li>' . __('<strong>Edit</strong> takes you to the editing screen for that post. You can also reach that screen by clicking on the post title.') . '</li>' .
       
   177 			'<li>' . __('<strong>Quick Edit</strong> provides inline access to the metadata of your post, allowing you to update post details without leaving this screen.') . '</li>' .
       
   178 			'<li>' . __('<strong>Trash</strong> removes your post from this list and places it in the trash, from which you can permanently delete it.') . '</li>' .
       
   179 			'<li>' . __('<strong>Preview</strong> will show you what your draft post will look like if you publish it. View will take you to your live site to view the post. Which link is available depends on your post&#8217;s status.') . '</li>' .
       
   180 		'</ul>'
       
   181 	) );
       
   182 	get_current_screen()->add_help_tab( array(
       
   183 	'id'		=> 'bulk-actions',
       
   184 	'title'		=> __('Bulk Actions'),
       
   185 	'content'	=>
       
   186 		'<p>' . __('You can also edit or move multiple posts to the trash at once. Select the posts you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.') . '</p>' .
       
   187 				'<p>' . __('When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the x next to its name in the Bulk Edit area that appears.') . '</p>'
       
   188 	) );
       
   189 
       
   190 	get_current_screen()->set_help_sidebar(
       
   191 	'<p><strong>' . __('For more information:') . '</strong></p>' .
       
   192 	'<p>' . __('<a href="http://codex.wordpress.org/Posts_Screen" target="_blank">Documentation on Managing Posts</a>') . '</p>' .
       
   193 	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
       
   194 	);
       
   195 
       
   196 } elseif ( 'page' == $post_type ) {
       
   197 	get_current_screen()->add_help_tab( array(
       
   198 	'id'		=> 'overview',
       
   199 	'title'		=> __('Overview'),
       
   200 	'content'	=>
       
   201 		'<p>' . __('Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the &#8220;Parent&#8221; of the other, creating a group of pages.') . '</p>'
       
   202 	) );
       
   203 	get_current_screen()->add_help_tab( array(
       
   204 	'id'		=> 'managing-pages',
       
   205 	'title'		=> __('Managing Pages'),
       
   206 	'content'	=>
       
   207 		'<p>' . __('Managing pages is very similar to managing posts, and the screens can be customized in the same way.') . '</p>' .
       
   208 		'<p>' . __('You can also perform the same types of actions, including narrowing the list by using the filters, acting on a page using the action links that appear when you hover over a row, or using the Bulk Actions menu to edit the metadata for multiple pages at once.') . '</p>'
       
   209 	) );
       
   210 
       
   211 	get_current_screen()->set_help_sidebar(
       
   212 	'<p><strong>' . __('For more information:') . '</strong></p>' .
       
   213 	'<p>' . __('<a href="http://codex.wordpress.org/Pages_Screen" target="_blank">Documentation on Managing Pages</a>') . '</p>' .
       
   214 	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
       
   215 	);
       
   216 }
       
   217 
       
   218 add_screen_option( 'per_page', array('label' => $title, 'default' => 20) );
       
   219 
       
   220 require_once('./admin-header.php');
       
   221 ?>
   135 <div class="wrap">
   222 <div class="wrap">
   136 <?php screen_icon(); ?>
   223 <?php screen_icon(); ?>
   137 <h2><?php echo esc_html( $title ); ?> <a href="post-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'post'); ?></a> <?php
   224 <h2><?php echo esc_html( $post_type_object->labels->name ); ?> <a href="<?php echo $post_new_file ?>" class="add-new-h2"><?php echo esc_html($post_type_object->labels->add_new); ?></a> <?php
   138 if ( isset($_GET['s']) && $_GET['s'] )
   225 if ( ! empty( $_REQUEST['s'] ) )
   139 	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( get_search_query() ) ); ?>
   226 	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', get_search_query() ); ?>
   140 </h2>
   227 </h2>
   141 
   228 
   142 <?php
   229 <?php if ( isset( $_REQUEST['locked'] ) || isset( $_REQUEST['updated'] ) || isset( $_REQUEST['deleted'] ) || isset( $_REQUEST['trashed'] ) || isset( $_REQUEST['untrashed'] ) ) {
   143 if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
   230 	$messages = array();
   144 <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit post'); ?></a></p></div>
   231 ?>
   145 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
   232 <div id="message" class="updated"><p>
   146 endif; ?>
   233 <?php if ( isset( $_REQUEST['updated'] ) && $updated = absint( $_REQUEST['updated'] ) ) {
   147 
   234 	$messages[] = sprintf( _n( '%s post updated.', '%s posts updated.', $updated ), number_format_i18n( $updated ) );
   148 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?>
   235 }
   149 <div id="message" class="updated fade"><p>
   236 
   150 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
   237 if ( isset( $_REQUEST['locked'] ) && $locked = absint( $_REQUEST['locked'] ) ) {
   151 	printf( _n( '%s post updated.', '%s posts updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
   238 	$messages[] = sprintf( _n( '%s item not updated, somebody is editing it.', '%s items not updated, somebody is editing them.', $locked ), number_format_i18n( $locked ) );
   152 	unset($_GET['updated']);
   239 }
   153 }
   240 
   154 
   241 if ( isset( $_REQUEST['deleted'] ) && $deleted = absint( $_REQUEST['deleted'] ) ) {
   155 if ( isset($_GET['skipped']) && (int) $_GET['skipped'] )
   242 	$messages[] = sprintf( _n( 'Item permanently deleted.', '%s items permanently deleted.', $deleted ), number_format_i18n( $deleted ) );
   156 	unset($_GET['skipped']);
   243 }
   157 
   244 
   158 if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
   245 if ( isset( $_REQUEST['trashed'] ) && $trashed = absint( $_REQUEST['trashed'] ) ) {
   159 	printf( _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) );
   246 	$messages[] = sprintf( _n( 'Item moved to the Trash.', '%s items moved to the Trash.', $trashed ), number_format_i18n( $trashed ) );
   160 	unset($_GET['locked']);
   247 	$ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
   161 }
   248 	$messages[] = '<a href="' . esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a>';
   162 
   249 }
   163 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
   250 
   164 	printf( _n( 'Post permanently deleted.', '%s posts permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
   251 if ( isset( $_REQUEST['untrashed'] ) && $untrashed = absint( $_REQUEST['untrashed'] ) ) {
   165 	unset($_GET['deleted']);
   252 	$messages[] = sprintf( _n( 'Item restored from the Trash.', '%s items restored from the Trash.', $untrashed ), number_format_i18n( $untrashed ) );
   166 }
   253 }
   167 
   254 
   168 if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) {
   255 if ( $messages )
   169 	printf( _n( 'Post moved to the trash.', '%s posts moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
   256 	echo join( ' ', $messages );
   170 	$ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
   257 unset( $messages );
   171 	echo ' <a href="' . esc_url( wp_nonce_url( "edit.php?doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a><br />';
   258 
   172 	unset($_GET['trashed']);
   259 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed' ), $_SERVER['REQUEST_URI'] );
   173 }
       
   174 
       
   175 if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {
       
   176 	printf( _n( 'Post restored from the trash.', '%s posts restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );
       
   177 	unset($_GET['undeleted']);
       
   178 }
       
   179 
       
   180 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] );
       
   181 ?>
   260 ?>
   182 </p></div>
   261 </p></div>
   183 <?php } ?>
   262 <?php } ?>
   184 
   263 
   185 <form id="posts-filter" action="<?php echo admin_url('edit.php'); ?>" method="get">
   264 <?php $wp_list_table->views(); ?>
   186 
   265 
   187 <ul class="subsubsub">
   266 <form id="posts-filter" action="" method="get">
       
   267 
       
   268 <?php $wp_list_table->search_box( $post_type_object->labels->search_items, 'post' ); ?>
       
   269 
       
   270 <input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_REQUEST['post_status']) ? esc_attr($_REQUEST['post_status']) : 'all'; ?>" />
       
   271 <input type="hidden" name="post_type" class="post_type_page" value="<?php echo $post_type; ?>" />
       
   272 <?php if ( ! empty( $_REQUEST['show_sticky'] ) ) { ?>
       
   273 <input type="hidden" name="show_sticky" value="1" />
       
   274 <?php } ?>
       
   275 
       
   276 <?php $wp_list_table->display(); ?>
       
   277 
       
   278 </form>
       
   279 
   188 <?php
   280 <?php
   189 if ( empty($locked_post_status) ) :
   281 if ( $wp_list_table->has_items() )
   190 $status_links = array();
   282 	$wp_list_table->inline_edit();
   191 $num_posts = wp_count_posts( 'post', 'readable' );
   283 ?>
   192 $class = '';
       
   193 $allposts = '';
       
   194 
       
   195 if ( $user_posts ) {
       
   196 	if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user->ID ) )
       
   197 		$class = ' class="current"';
       
   198 	$status_links[] = "<li><a href='edit.php?author=$current_user->ID'$class>" . sprintf( _nx( 'My Posts <span class="count">(%s)</span>', 'My Posts <span class="count">(%s)</span>', $user_posts_count, 'posts' ), number_format_i18n( $user_posts_count ) ) . '</a>';
       
   199 	$allposts = '?all_posts=1';
       
   200 }
       
   201 
       
   202 $total_posts = array_sum( (array) $num_posts ) - $num_posts->trash;
       
   203 $class = empty($class) && empty($_GET['post_status']) ? ' class="current"' : '';
       
   204 $status_links[] = "<li><a href='edit.php{$allposts}'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>';
       
   205 
       
   206 foreach ( $post_stati as $status => $label ) {
       
   207 	$class = '';
       
   208 
       
   209 	if ( !in_array( $status, $avail_post_stati ) )
       
   210 		continue;
       
   211 
       
   212 	if ( empty( $num_posts->$status ) )
       
   213 		continue;
       
   214 
       
   215 	if ( isset($_GET['post_status']) && $status == $_GET['post_status'] )
       
   216 		$class = ' class="current"';
       
   217 
       
   218 	$status_links[] = "<li><a href='edit.php?post_status=$status'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';
       
   219 }
       
   220 echo implode( " |</li>\n", $status_links ) . '</li>';
       
   221 unset( $status_links );
       
   222 endif;
       
   223 ?>
       
   224 </ul>
       
   225 
       
   226 <p class="search-box">
       
   227 	<label class="screen-reader-text" for="post-search-input"><?php _e( 'Search Posts' ); ?>:</label>
       
   228 	<input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
       
   229 	<input type="submit" value="<?php esc_attr_e( 'Search Posts' ); ?>" class="button" />
       
   230 </p>
       
   231 
       
   232 <input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_GET['post_status']) ? esc_attr($_GET['post_status']) : 'all'; ?>" />
       
   233 <input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" />
       
   234 
       
   235 <?php if ( have_posts() ) { ?>
       
   236 
       
   237 <div class="tablenav">
       
   238 <?php
       
   239 $page_links = paginate_links( array(
       
   240 	'base' => add_query_arg( 'paged', '%#%' ),
       
   241 	'format' => '',
       
   242 	'prev_text' => __('&laquo;'),
       
   243 	'next_text' => __('&raquo;'),
       
   244 	'total' => $wp_query->max_num_pages,
       
   245 	'current' => $_GET['paged']
       
   246 ));
       
   247 
       
   248 $is_trash = isset($_GET['post_status']) && $_GET['post_status'] == 'trash';
       
   249 
       
   250 ?>
       
   251 
       
   252 <div class="alignleft actions">
       
   253 <select name="action">
       
   254 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
       
   255 <?php if ( $is_trash ) { ?>
       
   256 <option value="untrash"><?php _e('Restore'); ?></option>
       
   257 <?php } else { ?>
       
   258 <option value="edit"><?php _e('Edit'); ?></option>
       
   259 <?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?>
       
   260 <option value="delete"><?php _e('Delete Permanently'); ?></option>
       
   261 <?php } else { ?>
       
   262 <option value="trash"><?php _e('Move to Trash'); ?></option>
       
   263 <?php } ?>
       
   264 </select>
       
   265 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
       
   266 <?php wp_nonce_field('bulk-posts'); ?>
       
   267 
       
   268 <?php // view filters
       
   269 if ( !is_singular() ) {
       
   270 $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC";
       
   271 
       
   272 $arc_result = $wpdb->get_results( $arc_query );
       
   273 
       
   274 $month_count = count($arc_result);
       
   275 
       
   276 if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
       
   277 $m = isset($_GET['m']) ? (int)$_GET['m'] : 0;
       
   278 ?>
       
   279 <select name='m'>
       
   280 <option<?php selected( $m, 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
       
   281 <?php
       
   282 foreach ($arc_result as $arc_row) {
       
   283 	if ( $arc_row->yyear == 0 )
       
   284 		continue;
       
   285 	$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
       
   286 
       
   287 	if ( $arc_row->yyear . $arc_row->mmonth == $m )
       
   288 		$default = ' selected="selected"';
       
   289 	else
       
   290 		$default = '';
       
   291 
       
   292 	echo "<option$default value='" . esc_attr("$arc_row->yyear$arc_row->mmonth") . "'>";
       
   293 	echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
       
   294 	echo "</option>\n";
       
   295 }
       
   296 ?>
       
   297 </select>
       
   298 <?php } ?>
       
   299 
       
   300 <?php
       
   301 $dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1,
       
   302 	'show_count' => 0, 'orderby' => 'name', 'selected' => $cat);
       
   303 wp_dropdown_categories($dropdown_options);
       
   304 do_action('restrict_manage_posts');
       
   305 ?>
       
   306 <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
       
   307 <?php }
       
   308 
       
   309 if ( $is_trash && current_user_can('edit_others_posts') ) { ?>
       
   310 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
       
   311 <?php } ?>
       
   312 </div>
       
   313 
       
   314 <?php if ( $page_links ) { ?>
       
   315 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
       
   316 	number_format_i18n( ( $_GET['paged'] - 1 ) * $wp_query->query_vars['posts_per_page'] + 1 ),
       
   317 	number_format_i18n( min( $_GET['paged'] * $wp_query->query_vars['posts_per_page'], $wp_query->found_posts ) ),
       
   318 	number_format_i18n( $wp_query->found_posts ),
       
   319 	$page_links
       
   320 ); echo $page_links_text; ?></div>
       
   321 <?php } ?>
       
   322 
       
   323 <div class="view-switch">
       
   324 	<a href="<?php echo esc_url(add_query_arg('mode', 'list', $_SERVER['REQUEST_URI'])) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php _e('List View') ?>" alt="<?php _e('List View') ?>" /></a>
       
   325 	<a href="<?php echo esc_url(add_query_arg('mode', 'excerpt', $_SERVER['REQUEST_URI'])) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php _e('Excerpt View') ?>" alt="<?php _e('Excerpt View') ?>" /></a>
       
   326 </div>
       
   327 
       
   328 <div class="clear"></div>
       
   329 </div>
       
   330 
       
   331 <div class="clear"></div>
       
   332 
       
   333 <?php include( 'edit-post-rows.php' ); ?>
       
   334 
       
   335 <div class="tablenav">
       
   336 
       
   337 <?php
       
   338 if ( $page_links )
       
   339 	echo "<div class='tablenav-pages'>$page_links_text</div>";
       
   340 ?>
       
   341 
       
   342 <div class="alignleft actions">
       
   343 <select name="action2">
       
   344 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
       
   345 <?php if ( $is_trash ) { ?>
       
   346 <option value="untrash"><?php _e('Restore'); ?></option>
       
   347 <?php } else { ?>
       
   348 <option value="edit"><?php _e('Edit'); ?></option>
       
   349 <?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?>
       
   350 <option value="delete"><?php _e('Delete Permanently'); ?></option>
       
   351 <?php } else { ?>
       
   352 <option value="trash"><?php _e('Move to Trash'); ?></option>
       
   353 <?php } ?>
       
   354 </select>
       
   355 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
       
   356 <?php if ( $is_trash && current_user_can('edit_others_posts') ) { ?>
       
   357 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
       
   358 <?php } ?>
       
   359 <br class="clear" />
       
   360 </div>
       
   361 <br class="clear" />
       
   362 </div>
       
   363 
       
   364 <?php } else { // have_posts() ?>
       
   365 <div class="clear"></div>
       
   366 <p><?php
       
   367 if ( isset($_GET['post_status']) && 'trash' == $_GET['post_status'] )
       
   368 	_e('No posts found in the trash');
       
   369 else
       
   370 	_e('No posts found');
       
   371 ?></p>
       
   372 <?php } ?>
       
   373 
       
   374 </form>
       
   375 
       
   376 <?php inline_edit_row( 'post' ); ?>
       
   377 
   284 
   378 <div id="ajax-response"></div>
   285 <div id="ajax-response"></div>
   379 <br class="clear" />
   286 <br class="clear" />
   380 </div>
   287 </div>
   381 
   288 
   382 <?php
   289 <?php
   383 include('admin-footer.php');
   290 include('./admin-footer.php');