| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
require_once('admin.php'); |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
if ( !empty($_GET['action']) && $_GET['action'] != 'Actions' ) { |
|---|
| 14 |
switch ( $_GET['action'] ) { |
|---|
| 15 |
case 'delete': |
|---|
| 16 |
if ( isset($_GET['post']) ) { |
|---|
| 17 |
check_admin_referer('bulk-posts'); |
|---|
| 18 |
foreach( (array) $_GET['post'] as $post_id_del ) { |
|---|
| 19 |
$post_del = & get_post($post_id_del); |
|---|
| 20 |
|
|---|
| 21 |
if ( !current_user_can('delete_post', $post_id_del) ) |
|---|
| 22 |
wp_die( __('You are not allowed to delete this post.') ); |
|---|
| 23 |
|
|---|
| 24 |
if ( $post_del->post_type == 'attachment' ) { |
|---|
| 25 |
if ( ! wp_delete_attachment($post_id_del) ) |
|---|
| 26 |
wp_die( __('Error in deleting...') ); |
|---|
| 27 |
} else { |
|---|
| 28 |
if ( !wp_delete_post($post_id_del) ) |
|---|
| 29 |
wp_die( __('Error in deleting...') ); |
|---|
| 30 |
} |
|---|
| 31 |
} |
|---|
| 32 |
} |
|---|
| 33 |
break; |
|---|
| 34 |
case 'edit': |
|---|
| 35 |
|
|---|
| 36 |
break; |
|---|
| 37 |
} |
|---|
| 38 |
$sendback = wp_get_referer(); |
|---|
| 39 |
if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('post-new.php'); |
|---|
| 40 |
elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); |
|---|
| 41 |
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); |
|---|
| 42 |
|
|---|
| 43 |
wp_redirect($sendback); |
|---|
| 44 |
exit(); |
|---|
| 45 |
} elseif ( !empty($_GET['_wp_http_referer']) ) { |
|---|
| 46 |
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); |
|---|
| 47 |
exit; |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
$title = __('Posts'); |
|---|
| 51 |
$parent_file = 'edit.php'; |
|---|
| 52 |
wp_enqueue_script('admin-forms'); |
|---|
| 53 |
|
|---|
| 54 |
list($post_stati, $avail_post_stati) = wp_edit_posts_query(); |
|---|
| 55 |
|
|---|
| 56 |
if ( 1 == count($posts) && is_singular() ) { |
|---|
| 57 |
wp_enqueue_script( 'admin-comments' ); |
|---|
| 58 |
wp_enqueue_script( 'jquery-table-hotkeys' ); |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
require_once('admin-header.php'); |
|---|
| 62 |
|
|---|
| 63 |
if ( !isset( $_GET['paged'] ) ) |
|---|
| 64 |
$_GET['paged'] = 1; |
|---|
| 65 |
|
|---|
| 66 |
if ( empty($_GET['mode']) ) |
|---|
| 67 |
$mode = 'list'; |
|---|
| 68 |
else |
|---|
| 69 |
$mode = attribute_escape($_GET['mode']); |
|---|
| 70 |
?> |
|---|
| 71 |
|
|---|
| 72 |
<div class="wrap"> |
|---|
| 73 |
|
|---|
| 74 |
<form id="posts-filter" action="" method="get"> |
|---|
| 75 |
<h2><?php |
|---|
| 76 |
if ( is_single() ) { |
|---|
| 77 |
printf(__('Comments on %s'), apply_filters( "the_title", $post->post_title)); |
|---|
| 78 |
} else { |
|---|
| 79 |
$post_status_label = _c('Posts|manage posts header'); |
|---|
| 80 |
if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) |
|---|
| 81 |
$post_status_label = $post_stati[$_GET['post_status']][1]; |
|---|
| 82 |
|
|---|
| 83 |
// $h2_noun = is_paged() ? sprintf(__( 'Previous %s' ), $post_status_label) : sprintf(__('Latest %s'), $post_status_label); |
|---|
| 84 |
//else |
|---|
| 85 |
$h2_noun = $post_status_label; |
|---|
| 86 |
|
|---|
| 87 |
$h2_author = ''; |
|---|
| 88 |
$_GET['author'] = isset($_GET['author']) ? (int) $_GET['author'] : 0; |
|---|
| 89 |
if ( $_GET['author'] != 0 ) { |
|---|
| 90 |
if ( $_GET['author'] == '-' . $user_ID ) { |
|---|
| 91 |
$h2_author = ' ' . __('by other authors'); |
|---|
| 92 |
} else { |
|---|
| 93 |
$author_user = get_userdata( get_query_var( 'author' ) ); |
|---|
| 94 |
$h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name )); |
|---|
| 95 |
} |
|---|
| 96 |
} |
|---|
| 97 |
$h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( get_search_query() ) ) : ''; |
|---|
| 98 |
$h2_cat = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in “%s”'), single_cat_title('', false) ) : ''; |
|---|
| 99 |
$h2_tag = isset($_GET['tag']) && $_GET['tag'] ? ' ' . sprintf( __('tagged with “%s”'), single_tag_title('', false) ) : ''; |
|---|
| 100 |
$h2_month = isset($_GET['m']) && $_GET['m'] ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : ''; |
|---|
| 101 |
printf( _c( '%1$s%2$s%3$s%4$s%5$s%6$s (<a href="%7$s">Add New</a>)|You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: tagged with {s}, 6: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_tag, $h2_month, 'post-new.php' ); |
|---|
| 102 |
} |
|---|
| 103 |
?></h2> |
|---|
| 104 |
|
|---|
| 105 |
<ul class="subsubsub"> |
|---|
| 106 |
<?php |
|---|
| 107 |
$status_links = array(); |
|---|
| 108 |
$num_posts = wp_count_posts( 'post', 'readable' ); |
|---|
| 109 |
$class = empty( $_GET['post_status'] ) ? ' class="current"' : ''; |
|---|
| 110 |
$status_links[] = "<li><a href='edit.php' $class>" . __('All Posts') . '</a>'; |
|---|
| 111 |
foreach ( $post_stati as $status => $label ) { |
|---|
| 112 |
$class = ''; |
|---|
| 113 |
|
|---|
| 114 |
if ( !in_array( $status, $avail_post_stati ) ) |
|---|
| 115 |
continue; |
|---|
| 116 |
|
|---|
| 117 |
if ( empty( $num_posts->$status ) ) |
|---|
| 118 |
continue; |
|---|
| 119 |
if ( isset($_GET['post_status']) && $status == $_GET['post_status'] ) |
|---|
| 120 |
$class = ' class="current"'; |
|---|
| 121 |
|
|---|
| 122 |
$status_links[] = "<li><a href='edit.php?post_status=$status' $class>" . |
|---|
| 123 |
sprintf( __ngettext( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>'; |
|---|
| 124 |
} |
|---|
| 125 |
echo implode( ' |</li>', $status_links ) . '</li>'; |
|---|
| 126 |
unset( $status_links ); |
|---|
| 127 |
?> |
|---|
| 128 |
</ul> |
|---|
| 129 |
|
|---|
| 130 |
<?php if ( isset($_GET['post_status'] ) ) : ?> |
|---|
| 131 |
<input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" /> |
|---|
| 132 |
<?php |
|---|
| 133 |
endif; |
|---|
| 134 |
|
|---|
| 135 |
if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?> |
|---|
| 136 |
<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> |
|---|
| 137 |
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); |
|---|
| 138 |
endif; |
|---|
| 139 |
?> |
|---|
| 140 |
|
|---|
| 141 |
<p id="post-search"> |
|---|
| 142 |
<label class="hidden" for="post-search-input"><?php _e( 'Search Posts' ); ?>:</label> |
|---|
| 143 |
<input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" /> |
|---|
| 144 |
<input type="submit" value="<?php _e( 'Search Posts' ); ?>" class="button" /> |
|---|
| 145 |
</p> |
|---|
| 146 |
|
|---|
| 147 |
<input type="hidden" name="mode" value="<?php echo $mode; ?>" /> |
|---|
| 148 |
|
|---|
| 149 |
<ul class="view-switch"> |
|---|
| 150 |
<li <?php if ( 'list' == $mode ) echo "class='current'" ?>><a href="<?php echo clean_url(add_query_arg('mode', 'list', $_SERVER['REQUEST_URI'])) ?>"><?php _e('List View') ?></a></li> |
|---|
| 151 |
<li <?php if ( 'excerpt' == $mode ) echo "class='current'" ?>><a href="<?php echo clean_url(add_query_arg('mode', 'excerpt', $_SERVER['REQUEST_URI'])) ?>"><?php _e('Excerpt View') ?></a></li> |
|---|
| 152 |
</ul> |
|---|
| 153 |
|
|---|
| 154 |
<div class="tablenav"> |
|---|
| 155 |
|
|---|
| 156 |
<?php |
|---|
| 157 |
$page_links = paginate_links( array( |
|---|
| 158 |
'base' => add_query_arg( 'paged', '%#%' ), |
|---|
| 159 |
'format' => '', |
|---|
| 160 |
'total' => $wp_query->max_num_pages, |
|---|
| 161 |
'current' => $_GET['paged'] |
|---|
| 162 |
)); |
|---|
| 163 |
|
|---|
| 164 |
if ( $page_links ) |
|---|
| 165 |
echo "<div class='tablenav-pages'>$page_links</div>"; |
|---|
| 166 |
?> |
|---|
| 167 |
|
|---|
| 168 |
<div class="alignleft"> |
|---|
| 169 |
<select name="action"> |
|---|
| 170 |
<option value="" selected><?php _e('Actions'); ?></option> |
|---|
| 171 |
<option value="delete"><?php _e('Delete'); ?></option> |
|---|
| 172 |
<option value="edit"><?php _e('Edit'); ?></option> |
|---|
| 173 |
</select> |
|---|
| 174 |
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" /> |
|---|
| 175 |
<?php wp_nonce_field('bulk-posts'); ?> |
|---|
| 176 |
<?php |
|---|
| 177 |
if ( !is_singular() ) { |
|---|
| 178 |
$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"; |
|---|
| 179 |
|
|---|
| 180 |
$arc_result = $wpdb->get_results( $arc_query ); |
|---|
| 181 |
|
|---|
| 182 |
$month_count = count($arc_result); |
|---|
| 183 |
|
|---|
| 184 |
if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { |
|---|
| 185 |
$m = isset($_GET['m']) ? (int)$_GET['m'] : 0; |
|---|
| 186 |
?> |
|---|
| 187 |
<select name='m'> |
|---|
| 188 |
<option<?php selected( $m, 0 ); ?> value='0'><?php _e('Show all dates'); ?></option> |
|---|
| 189 |
<?php |
|---|
| 190 |
foreach ($arc_result as $arc_row) { |
|---|
| 191 |
if ( $arc_row->yyear == 0 ) |
|---|
| 192 |
continue; |
|---|
| 193 |
$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); |
|---|
| 194 |
|
|---|
| 195 |
if ( $arc_row->yyear . $arc_row->mmonth == $m ) |
|---|
| 196 |
$default = ' selected="selected"'; |
|---|
| 197 |
else |
|---|
| 198 |
$default = ''; |
|---|
| 199 |
|
|---|
| 200 |
echo "<option$default value='$arc_row->yyear$arc_row->mmonth'>"; |
|---|
| 201 |
echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear"; |
|---|
| 202 |
echo "</option>\n"; |
|---|
| 203 |
} |
|---|
| 204 |
?> |
|---|
| 205 |
</select> |
|---|
| 206 |
<?php } ?> |
|---|
| 207 |
|
|---|
| 208 |
<?php |
|---|
| 209 |
$dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1, |
|---|
| 210 |
'show_count' => 0, 'orderby' => 'name', 'selected' => $cat); |
|---|
| 211 |
wp_dropdown_categories($dropdown_options); |
|---|
| 212 |
do_action('restrict_manage_posts'); |
|---|
| 213 |
?> |
|---|
| 214 |
<input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" /> |
|---|
| 215 |
|
|---|
| 216 |
<?php } ?> |
|---|
| 217 |
</div> |
|---|
| 218 |
|
|---|
| 219 |
<br class="clear" /> |
|---|
| 220 |
</div> |
|---|
| 221 |
|
|---|
| 222 |
<br class="clear" /> |
|---|
| 223 |
|
|---|
| 224 |
<?php include( 'edit-post-rows.php' ); ?> |
|---|
| 225 |
|
|---|
| 226 |
</form> |
|---|
| 227 |
|
|---|
| 228 |
<div id="ajax-response"></div> |
|---|
| 229 |
|
|---|
| 230 |
<div class="tablenav"> |
|---|
| 231 |
|
|---|
| 232 |
<?php |
|---|
| 233 |
if ( $page_links ) |
|---|
| 234 |
echo "<div class='tablenav-pages'>$page_links</div>"; |
|---|
| 235 |
?> |
|---|
| 236 |
|
|---|
| 237 |
<br class="clear" /> |
|---|
| 238 |
</div> |
|---|
| 239 |
|
|---|
| 240 |
<br class="clear" /> |
|---|
| 241 |
|
|---|
| 242 |
<?php |
|---|
| 243 |
|
|---|
| 244 |
if ( 1 == count($posts) && is_singular() ) : |
|---|
| 245 |
|
|---|
| 246 |
$comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved != 'spam' ORDER BY comment_date", $id) ); |
|---|
| 247 |
if ( $comments ) : |
|---|
| 248 |
|
|---|
| 249 |
update_comment_cache($comments); |
|---|
| 250 |
$post = get_post($id); |
|---|
| 251 |
$authordata = get_userdata($post->post_author); |
|---|
| 252 |
?> |
|---|
| 253 |
|
|---|
| 254 |
<br class="clear" /> |
|---|
| 255 |
|
|---|
| 256 |
<table class="widefat" style="margin-top: .5em"> |
|---|
| 257 |
<thead> |
|---|
| 258 |
<tr> |
|---|
| 259 |
<th scope="col"><?php _e('Comment') ?></th> |
|---|
| 260 |
<th scope="col"><?php _e('Author') ?></th> |
|---|
| 261 |
<th scope="col"><?php _e('Submitted') ?></th> |
|---|
| 262 |
</tr> |
|---|
| 263 |
</thead> |
|---|
| 264 |
<tbody id="the-comment-list" class="list:comment"> |
|---|
| 265 |
<?php |
|---|
| 266 |
foreach ($comments as $comment) |
|---|
| 267 |
_wp_comment_row( $comment->comment_ID, 'single', false, false ); |
|---|
| 268 |
?> |
|---|
| 269 |
</tbody> |
|---|
| 270 |
</table> |
|---|
| 271 |
|
|---|
| 272 |
<?php |
|---|
| 273 |
wp_comment_reply(); |
|---|
| 274 |
endif; |
|---|
| 275 |
endif; |
|---|
| 276 |
|
|---|
| 277 |
?> |
|---|
| 278 |
|
|---|
| 279 |
</div> |
|---|
| 280 |
|
|---|
| 281 |
<?php include('admin-footer.php'); ?> |
|---|
| 282 |
|
|---|