Ajaxify list-type screens in the admin. See #14579
git-svn-id: http://svn.automattic.com/wordpress/trunk@15491 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
113a5038ce
commit
020ce73746
|
@ -50,6 +50,20 @@ if ( ! is_user_logged_in() ) {
|
|||
|
||||
if ( isset( $_GET['action'] ) ) :
|
||||
switch ( $action = $_GET['action'] ) :
|
||||
case 'fetch-list' :
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
|
||||
$class = $_GET['list_args']['class'];
|
||||
|
||||
if ( class_exists( $class ) ) {
|
||||
global $current_screen;
|
||||
$current_screen = (object) $_GET['list_args']['screen'];
|
||||
$table = new $class;
|
||||
$table->ajax_response();
|
||||
}
|
||||
|
||||
die('-1');
|
||||
break;
|
||||
case 'ajax-tag-search' :
|
||||
if ( !current_user_can( 'edit_posts' ) )
|
||||
die('-1');
|
||||
|
@ -515,52 +529,17 @@ case 'add-link-category' : // On the Fly
|
|||
}
|
||||
$x->send();
|
||||
break;
|
||||
case 'add-link-cat' : // From Blogroll -> Categories
|
||||
check_ajax_referer( 'add-link-category' );
|
||||
if ( !current_user_can( 'manage_categories' ) )
|
||||
die('-1');
|
||||
|
||||
if ( '' === trim($_POST['name']) ) {
|
||||
$x = new WP_Ajax_Response( array(
|
||||
'what' => 'link-cat',
|
||||
'id' => new WP_Error( 'name', __('You did not enter a category name.') )
|
||||
) );
|
||||
$x->send();
|
||||
}
|
||||
|
||||
$r = wp_insert_term($_POST['name'], 'link_category', $_POST );
|
||||
if ( is_wp_error( $r ) ) {
|
||||
$x = new WP_AJAX_Response( array(
|
||||
'what' => 'link-cat',
|
||||
'id' => $r
|
||||
) );
|
||||
$x->send();
|
||||
}
|
||||
|
||||
extract($r, EXTR_SKIP);
|
||||
|
||||
if ( !$link_cat = link_cat_row( $term_id ) )
|
||||
die('0');
|
||||
|
||||
$x = new WP_Ajax_Response( array(
|
||||
'what' => 'link-cat',
|
||||
'id' => $term_id,
|
||||
'position' => -1,
|
||||
'data' => $link_cat
|
||||
) );
|
||||
$x->send();
|
||||
break;
|
||||
case 'add-tag' : // From Manage->Tags
|
||||
case 'add-tag' :
|
||||
check_ajax_referer( 'add-tag' );
|
||||
$post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post';
|
||||
$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
|
||||
$tax = get_taxonomy($taxonomy);
|
||||
|
||||
$x = new WP_Ajax_Response();
|
||||
|
||||
if ( !current_user_can( $tax->cap->edit_terms ) )
|
||||
die('-1');
|
||||
|
||||
$x = new WP_Ajax_Response();
|
||||
|
||||
$tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST );
|
||||
|
||||
if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) {
|
||||
|
@ -578,6 +557,9 @@ case 'add-tag' : // From Manage->Tags
|
|||
if ( isset($_POST['screen']) )
|
||||
set_current_screen($_POST['screen']);
|
||||
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
$table = new WP_Terms_Table( 'ajax' );
|
||||
|
||||
$level = 0;
|
||||
$tag_full_name = false;
|
||||
$tag_full_name = $tag->name;
|
||||
|
@ -588,10 +570,10 @@ case 'add-tag' : // From Manage->Tags
|
|||
$tag_full_name = $_tag->name . ' — ' . $tag_full_name;
|
||||
$level++;
|
||||
}
|
||||
$noparents = _tag_row( $tag, $level, $taxonomy );
|
||||
$noparents = $table->single_row( $tag, $level, $taxonomy );
|
||||
}
|
||||
$tag->name = $tag_full_name;
|
||||
$parents = _tag_row( $tag, 0, $taxonomy);
|
||||
$parents = $table->single_row( $tag, 0, $taxonomy);
|
||||
|
||||
$x->add( array(
|
||||
'what' => 'taxonomy',
|
||||
|
@ -642,28 +624,23 @@ case 'add-comment' :
|
|||
check_ajax_referer( $action );
|
||||
if ( !current_user_can( 'edit_posts' ) )
|
||||
die('-1');
|
||||
$search = isset($_POST['s']) ? $_POST['s'] : false;
|
||||
$status = isset($_POST['comment_status']) ? $_POST['comment_status'] : 'all';
|
||||
$per_page = isset($_POST['per_page']) ? (int) $_POST['per_page'] + 8 : 28;
|
||||
$start = isset($_POST['page']) ? ( intval($_POST['page']) * $per_page ) -1 : $per_page - 1;
|
||||
if ( 1 > $start )
|
||||
$start = 27;
|
||||
|
||||
$mode = isset($_POST['mode']) ? $_POST['mode'] : 'detail';
|
||||
$p = isset($_POST['p']) ? $_POST['p'] : 0;
|
||||
$comment_type = isset($_POST['comment_type']) ? $_POST['comment_type'] : '';
|
||||
list($comments, $total) = _wp_get_comment_list( $status, $search, $start, 1, $p, $comment_type );
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
$table = new WP_Comments_Table( 'ajax' );
|
||||
|
||||
global $comments;
|
||||
|
||||
if ( !$comments )
|
||||
die('1');
|
||||
|
||||
if ( get_option('show_avatars') )
|
||||
add_filter( 'comment_author', 'floated_admin_avatar' );
|
||||
|
||||
if ( !$comments )
|
||||
die('1');
|
||||
$x = new WP_Ajax_Response();
|
||||
foreach ( (array) $comments as $comment ) {
|
||||
get_comment( $comment );
|
||||
ob_start();
|
||||
_wp_comment_row( $comment->comment_ID, $mode, $status, true, true );
|
||||
$table->single_row( $comment->comment_ID, $mode, $status, true, true );
|
||||
$comment_list_item = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$x->add( array(
|
||||
|
@ -681,10 +658,10 @@ case 'get-comments' :
|
|||
if ( !current_user_can( 'edit_post', $post_ID ) )
|
||||
die('-1');
|
||||
|
||||
$start = isset($_POST['start']) ? intval($_POST['start']) : 0;
|
||||
$num = isset($_POST['num']) ? intval($_POST['num']) : 10;
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
$table = new WP_Comments_Table( 'ajax' );
|
||||
|
||||
list($comments, $total) = _wp_get_comment_list( false, false, $start, $num, $post_ID );
|
||||
global $comments;
|
||||
|
||||
if ( !$comments )
|
||||
die('1');
|
||||
|
@ -694,7 +671,7 @@ case 'get-comments' :
|
|||
foreach ( (array) $comments as $comment ) {
|
||||
get_comment( $comment );
|
||||
ob_start();
|
||||
_wp_comment_row( $comment->comment_ID, 'single', false, false );
|
||||
$table->single_row( $comment->comment_ID, 'single', false, false );
|
||||
$comment_list_item .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
|
@ -707,6 +684,9 @@ case 'get-comments' :
|
|||
case 'replyto-comment' :
|
||||
check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
|
||||
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
$table = new WP_Comments_Table( 'ajax' );
|
||||
|
||||
$comment_post_ID = (int) $_POST['comment_post_ID'];
|
||||
if ( !current_user_can( 'edit_post', $comment_post_ID ) )
|
||||
die('-1');
|
||||
|
@ -759,7 +739,7 @@ case 'replyto-comment' :
|
|||
require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
|
||||
_wp_dashboard_recent_comments_row( $comment, false );
|
||||
} else {
|
||||
_wp_comment_row( $comment->comment_ID, $mode, false, $checkbox );
|
||||
$table->single_row( $comment->comment_ID, $mode, false, $checkbox );
|
||||
}
|
||||
$comment_list_item = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
@ -795,13 +775,16 @@ case 'edit-comment' :
|
|||
if ( get_option('show_avatars') && 'single' != $mode )
|
||||
add_filter( 'comment_author', 'floated_admin_avatar' );
|
||||
|
||||
$x = new WP_Ajax_Response();
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
$table = new WP_Comments_Table( 'ajax' );
|
||||
|
||||
ob_start();
|
||||
_wp_comment_row( $comment_id, $mode, $comments_listing, $checkbox );
|
||||
$table->single_row( $comment_id, $mode, $comments_listing, $checkbox );
|
||||
$comment_list_item = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$x = new WP_Ajax_Response();
|
||||
|
||||
$x->add( array(
|
||||
'what' => 'edit_comment',
|
||||
'id' => $comment->comment_ID,
|
||||
|
@ -941,10 +924,13 @@ case 'add-user' :
|
|||
}
|
||||
$user_object = new WP_User( $user_id );
|
||||
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
$table = new WP_Users_Table( 'ajax' );
|
||||
|
||||
$x = new WP_Ajax_Response( array(
|
||||
'what' => 'user',
|
||||
'id' => $user_id,
|
||||
'data' => user_row( $user_object, '', $user_object->roles[0] ),
|
||||
'data' => $table->single_row( $user_object, '', $user_object->roles[0] ),
|
||||
'supplemental' => array(
|
||||
'show-link' => sprintf(__( 'User <a href="#%s">%s</a> added' ), "user-$user_id", $user_object->user_login),
|
||||
'role' => $user_object->roles[0]
|
||||
|
@ -1231,16 +1217,11 @@ case 'inline-save':
|
|||
// update the post
|
||||
edit_post();
|
||||
|
||||
if ( in_array( $_POST['post_type'], get_post_types( array( 'show_ui' => true ) ) ) ) {
|
||||
$post = array();
|
||||
$post[] = get_post($_POST['post_ID']);
|
||||
if ( is_post_type_hierarchical( $_POST['post_type'] ) ) {
|
||||
page_rows( $post );
|
||||
} else {
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
$table = new WP_Posts_Table( 'ajax' );
|
||||
|
||||
$mode = $_POST['post_view'];
|
||||
post_rows( $post );
|
||||
}
|
||||
}
|
||||
$table->display_rows( array( get_post( $_POST['post_ID'] ) ) );
|
||||
|
||||
exit;
|
||||
break;
|
||||
|
@ -1258,17 +1239,6 @@ case 'inline-save-tax':
|
|||
if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
|
||||
die(-1);
|
||||
|
||||
switch ($_POST['tax_type']) {
|
||||
case 'link-cat' :
|
||||
$updated = wp_update_term($id, 'link_category', $_POST);
|
||||
|
||||
if ( $updated && !is_wp_error($updated) )
|
||||
echo link_cat_row($updated['term_id']);
|
||||
else
|
||||
die( __('Category not updated.') );
|
||||
|
||||
break;
|
||||
case 'tag' :
|
||||
$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
|
||||
|
||||
$tag = get_term( $id, $taxonomy );
|
||||
|
@ -1285,16 +1255,16 @@ case 'inline-save-tax':
|
|||
|
||||
set_current_screen( 'edit-' . $taxonomy );
|
||||
|
||||
echo _tag_row($tag, 0, $taxonomy);
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
$table = new WP_Terms_Table( 'ajax' );
|
||||
|
||||
echo $table->single_row( $tag, 0, $taxonomy );
|
||||
} else {
|
||||
if ( is_wp_error($updated) && $updated->get_error_message() )
|
||||
die( $updated->get_error_message() );
|
||||
die( __('Item not updated.') );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
exit;
|
||||
break;
|
||||
case 'find_posts':
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1592,7 +1592,7 @@ fieldset.inline-edit-col-right .inline-edit-col {
|
|||
background: transparent url(../images/list-vs.png) no-repeat 0 0;
|
||||
}
|
||||
|
||||
.view-switch #view-switch-list.current {
|
||||
.view-switch .current #view-switch-list {
|
||||
background: transparent url(../images/list-vs.png) no-repeat -40px 0;
|
||||
}
|
||||
|
||||
|
@ -1600,7 +1600,7 @@ fieldset.inline-edit-col-right .inline-edit-col {
|
|||
background: transparent url(../images/list-vs.png) no-repeat -20px 0;
|
||||
}
|
||||
|
||||
.view-switch #view-switch-excerpt.current {
|
||||
.view-switch .current #view-switch-excerpt {
|
||||
background: transparent url(../images/list-vs.png) no-repeat -60px 0;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1575,7 +1575,7 @@ fieldset.inline-edit-col-right .inline-edit-col {
|
|||
background: transparent url(../images/list.png) no-repeat 0 0;
|
||||
}
|
||||
|
||||
.view-switch #view-switch-list.current {
|
||||
.view-switch .current #view-switch-list {
|
||||
background: transparent url(../images/list.png) no-repeat -40px 0;
|
||||
}
|
||||
|
||||
|
@ -1583,7 +1583,7 @@ fieldset.inline-edit-col-right .inline-edit-col {
|
|||
background: transparent url(../images/list.png) no-repeat -20px 0;
|
||||
}
|
||||
|
||||
.view-switch #view-switch-excerpt.current {
|
||||
.view-switch .current #view-switch-excerpt {
|
||||
background: transparent url(../images/list.png) no-repeat -60px 0;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -27,6 +27,8 @@ select option {
|
|||
padding: 2px;
|
||||
}
|
||||
|
||||
.plugins #name {width: 33%}
|
||||
|
||||
.plugins .name,
|
||||
#pass-strength-result.strong,
|
||||
#pass-strength-result.short,
|
||||
|
@ -67,12 +69,11 @@ input.button-highlighted,
|
|||
padding: 0;
|
||||
}
|
||||
|
||||
.widefat tbody.plugins th.check-column {
|
||||
.plugins tbody th.check-column {
|
||||
padding: 7px 0;
|
||||
}
|
||||
|
||||
.widefat .plugins td,
|
||||
.widefat .plugins th {
|
||||
.plugins td, .plugins th {
|
||||
border-bottom: 0 none;
|
||||
}
|
||||
|
||||
|
@ -115,6 +116,16 @@ input.button-highlighted,
|
|||
margin: 10px 20px 10px 20px;
|
||||
}
|
||||
|
||||
#loading-items {
|
||||
position: absolute;
|
||||
z-index: 9999;
|
||||
padding: 10px;
|
||||
background-color: #fff;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
table#availablethemes {
|
||||
border-spacing: 0;
|
||||
border-width: 1px 0;
|
||||
|
@ -714,13 +725,19 @@ div.nav {
|
|||
padding: 2px 4px;
|
||||
}
|
||||
|
||||
a.page-numbers {
|
||||
.tablenav-pages a {
|
||||
border-bottom-style: solid;
|
||||
border-bottom-width: 2px;
|
||||
font-weight: bold;
|
||||
margin-right: 1px;
|
||||
padding: 0 2px;
|
||||
}
|
||||
.tablenav-pages .current-page {
|
||||
text-align: center;
|
||||
}
|
||||
.tablenav-pages .next-page {
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
p.pagenav {
|
||||
margin: 0;
|
||||
|
@ -1346,12 +1363,12 @@ textarea.large-text {
|
|||
width: 99%;
|
||||
}
|
||||
|
||||
.form-table input.regular-text,
|
||||
input.regular-text,
|
||||
#adduser .form-field input {
|
||||
width: 25em;
|
||||
}
|
||||
|
||||
.form-table input.small-text {
|
||||
input.small-text {
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
|
@ -3240,6 +3257,13 @@ table.fixed {
|
|||
.fixed .column-comments {
|
||||
width: 4em;
|
||||
padding-top: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
.fixed .column-comments .vers {
|
||||
padding-left: 3px;
|
||||
}
|
||||
.fixed .column-comments a {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.fixed .column-slug {
|
||||
|
@ -3274,6 +3298,25 @@ table .column-rating {
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
.sorting-indicator {
|
||||
display: none;
|
||||
float: left;
|
||||
width: 21px;
|
||||
height: 4px;
|
||||
margin-top: 5px;
|
||||
}
|
||||
th.sortable a, th.sorted-asc a, th.sorted-desc a {
|
||||
float: left;
|
||||
}
|
||||
th.sorted-asc .sorting-indicator, th.sorted-desc:hover .sorting-indicator, th.sortable:hover .sorting-indicator {
|
||||
display: block;
|
||||
background: url(../images/sort_asc.gif) no-repeat scroll 0 0;
|
||||
}
|
||||
th.sorted-desc .sorting-indicator, th.sorted-asc:hover .sorting-indicator {
|
||||
display: block;
|
||||
background: url(../images/sort_desc.gif) no-repeat scroll 0 0;
|
||||
}
|
||||
|
||||
.icon32 {
|
||||
float: left;
|
||||
height: 36px;
|
||||
|
|
|
@ -12,11 +12,6 @@ require_once('./admin.php');
|
|||
if ( !current_user_can('edit_posts') )
|
||||
wp_die(__('Cheatin’ uh?'));
|
||||
|
||||
wp_enqueue_script('admin-comments');
|
||||
enqueue_comment_hotkeys_js();
|
||||
|
||||
$post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
|
||||
|
||||
if ( isset( $_REQUEST['doaction'] ) || isset( $_REQUEST['doaction2'] ) || isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
|
||||
check_admin_referer( 'bulk-comments' );
|
||||
|
||||
|
@ -95,11 +90,18 @@ if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_R
|
|||
|
||||
wp_redirect( $redirect_to );
|
||||
exit;
|
||||
} elseif ( ! empty($_GET['_wp_http_referer']) ) {
|
||||
} elseif ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
||||
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
|
||||
$table = new WP_Comments_Table;
|
||||
|
||||
wp_enqueue_script('admin-comments');
|
||||
enqueue_comment_hotkeys_js();
|
||||
|
||||
if ( $post_id )
|
||||
$title = sprintf(__('Comments on “%s”'), wp_html_excerpt(_draft_or_post_title($post_id), 50));
|
||||
else
|
||||
|
@ -118,28 +120,18 @@ add_contextual_help( $current_screen, '<p>' . __('You can manage comments made o
|
|||
'<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
|
||||
);
|
||||
require_once('./admin-header.php');
|
||||
|
||||
$mode = ( empty($_GET['mode']) ) ? 'detail' : esc_attr($_GET['mode']);
|
||||
|
||||
$comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all';
|
||||
if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'trash')) )
|
||||
$comment_status = 'all';
|
||||
|
||||
$comment_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : '';
|
||||
|
||||
$search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : '';
|
||||
$search = esc_attr( $search_dirty ); ?>
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<?php screen_icon(); ?>
|
||||
<h2><?php echo esc_html( $title );
|
||||
if ( isset($_GET['s']) && $_GET['s'] )
|
||||
printf( '<span class="subtitle">' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( esc_html( stripslashes( $_GET['s'] ) ), 50 ) ) . '</span>' ); ?>
|
||||
if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
|
||||
printf( '<span class="subtitle">' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ) . '</span>' ); ?>
|
||||
</h2>
|
||||
|
||||
<?php
|
||||
if ( isset( $_GET['error'] ) ) {
|
||||
$error = (int) $_GET['error'];
|
||||
if ( isset( $_REQUEST['error'] ) ) {
|
||||
$error = (int) $_REQUEST['error'];
|
||||
$error_msg = '';
|
||||
switch ( $error ) {
|
||||
case 1 :
|
||||
|
@ -153,21 +145,21 @@ if ( isset( $_GET['error'] ) ) {
|
|||
echo '<div id="moderated" class="error"><p>' . $error_msg . '</p></div>';
|
||||
}
|
||||
|
||||
if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spammed']) || isset($_GET['unspammed']) || isset($_GET['same']) ) {
|
||||
$approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0;
|
||||
$deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0;
|
||||
$trashed = isset( $_GET['trashed'] ) ? (int) $_GET['trashed'] : 0;
|
||||
$untrashed = isset( $_GET['untrashed'] ) ? (int) $_GET['untrashed'] : 0;
|
||||
$spammed = isset( $_GET['spammed'] ) ? (int) $_GET['spammed'] : 0;
|
||||
$unspammed = isset( $_GET['unspammed'] ) ? (int) $_GET['unspammed'] : 0;
|
||||
$same = isset( $_GET['same'] ) ? (int) $_GET['same'] : 0;
|
||||
if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQUEST['trashed']) || isset($_REQUEST['untrashed']) || isset($_REQUEST['spammed']) || isset($_REQUEST['unspammed']) || isset($_REQUEST['same']) ) {
|
||||
$approved = isset( $_REQUEST['approved'] ) ? (int) $_REQUEST['approved'] : 0;
|
||||
$deleted = isset( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0;
|
||||
$trashed = isset( $_REQUEST['trashed'] ) ? (int) $_REQUEST['trashed'] : 0;
|
||||
$untrashed = isset( $_REQUEST['untrashed'] ) ? (int) $_REQUEST['untrashed'] : 0;
|
||||
$spammed = isset( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0;
|
||||
$unspammed = isset( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0;
|
||||
$same = isset( $_REQUEST['same'] ) ? (int) $_REQUEST['same'] : 0;
|
||||
|
||||
if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) {
|
||||
if ( $approved > 0 )
|
||||
$messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
|
||||
|
||||
if ( $spammed > 0 ) {
|
||||
$ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
|
||||
$ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
|
||||
$messages[] = sprintf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';
|
||||
}
|
||||
|
||||
|
@ -175,7 +167,7 @@ if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed
|
|||
$messages[] = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed );
|
||||
|
||||
if ( $trashed > 0 ) {
|
||||
$ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
|
||||
$ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
|
||||
$messages[] = sprintf( _n( '%s comment moved to the Trash.', '%s comments moved to the Trash.', $trashed ), $trashed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';
|
||||
}
|
||||
|
||||
|
@ -204,7 +196,7 @@ if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed
|
|||
}
|
||||
?>
|
||||
|
||||
<form id="comments-form" action="" method="get">
|
||||
<form id="comments-form" action="" method="post">
|
||||
<ul class="subsubsub">
|
||||
<?php
|
||||
$status_links = array();
|
||||
|
@ -233,11 +225,11 @@ foreach ( $stati as $status => $label ) {
|
|||
$num_comments->$status = 10;
|
||||
$link = add_query_arg( 'comment_status', $status, $link );
|
||||
if ( $post_id )
|
||||
$link = add_query_arg( 'p', absint( $post_id ), $link );
|
||||
$link = add_query_arg( 'post_ID', absint( $post_id ), $link );
|
||||
/*
|
||||
// I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
|
||||
if ( !empty( $_GET['s'] ) )
|
||||
$link = add_query_arg( 's', esc_attr( stripslashes( $_GET['s'] ) ), $link );
|
||||
if ( !empty( $_REQUEST['s'] ) )
|
||||
$link = add_query_arg( 's', esc_attr( stripslashes( $_REQUEST['s'] ) ), $link );
|
||||
*/
|
||||
$status_links[] = "<li class='$status'><a href='$link'$class>" . sprintf(
|
||||
_n( $label[0], $label[1], $num_comments->$status ),
|
||||
|
@ -258,196 +250,24 @@ unset($status_links);
|
|||
<input type="submit" value="<?php esc_attr_e( 'Search Comments' ); ?>" class="button" />
|
||||
</p>
|
||||
|
||||
<?php
|
||||
$comments_per_page = (int) get_user_option( 'edit_comments_per_page' );
|
||||
if ( empty( $comments_per_page ) || $comments_per_page < 1 )
|
||||
$comments_per_page = 20;
|
||||
$comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
|
||||
|
||||
if ( isset( $_GET['apage'] ) )
|
||||
$page = abs( (int) $_GET['apage'] );
|
||||
else
|
||||
$page = 1;
|
||||
|
||||
$start = $offset = ( $page - 1 ) * $comments_per_page;
|
||||
|
||||
list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 8, $post_id, $comment_type ); // Grab a few extra
|
||||
|
||||
$_comment_post_ids = array();
|
||||
foreach ( $_comments as $_c ) {
|
||||
$_comment_post_ids[] = $_c->comment_post_ID;
|
||||
}
|
||||
|
||||
$_comment_pending_count = get_pending_comments_num($_comment_post_ids);
|
||||
|
||||
$comments = array_slice($_comments, 0, $comments_per_page);
|
||||
$extra_comments = array_slice($_comments, $comments_per_page);
|
||||
|
||||
$page_links = paginate_links( array(
|
||||
'base' => add_query_arg( 'apage', '%#%' ),
|
||||
'format' => '',
|
||||
'prev_text' => __('«'),
|
||||
'next_text' => __('»'),
|
||||
'total' => ceil($total / $comments_per_page),
|
||||
'current' => $page
|
||||
));
|
||||
|
||||
?>
|
||||
|
||||
<input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" />
|
||||
<?php if ( $post_id ) : ?>
|
||||
<input type="hidden" name="p" value="<?php echo esc_attr( intval( $post_id ) ); ?>" />
|
||||
<input type="hidden" name="post_ID" value="<?php echo esc_attr( intval( $post_id ) ); ?>" />
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="comment_status" value="<?php echo esc_attr($comment_status); ?>" />
|
||||
<input type="hidden" name="pagegen_timestamp" value="<?php echo esc_attr(current_time('mysql', 1)); ?>" />
|
||||
|
||||
<div class="tablenav">
|
||||
|
||||
<?php if ( $page_links ) : ?>
|
||||
<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
|
||||
number_format_i18n( $start + 1 ),
|
||||
number_format_i18n( min( $page * $comments_per_page, $total ) ),
|
||||
'<span class="total-type-count">' . number_format_i18n( $total ) . '</span>',
|
||||
$page_links
|
||||
); echo $page_links_text; ?></div>
|
||||
<input type="hidden" name="_total" value="<?php echo esc_attr($total); ?>" />
|
||||
<input type="hidden" name="_per_page" value="<?php echo esc_attr($comments_per_page); ?>" />
|
||||
<input type="hidden" name="_page" value="<?php echo esc_attr($page); ?>" />
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $comments ) : ?>
|
||||
<div class="alignleft actions">
|
||||
<select name="action">
|
||||
<option value="-1" selected="selected"><?php _e('Bulk Actions') ?></option>
|
||||
<?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
|
||||
<option value="unapprove"><?php _e('Unapprove'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
|
||||
<option value="approve"><?php _e('Approve'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?>
|
||||
<option value="spam"><?php _ex('Mark as Spam', 'comment'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'trash' == $comment_status ): ?>
|
||||
<option value="untrash"><?php _e('Restore'); ?></option>
|
||||
<?php elseif ( 'spam' == $comment_status ): ?>
|
||||
<option value="unspam"><?php _ex('Not Spam', 'comment'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'trash' == $comment_status || 'spam' == $comment_status || !EMPTY_TRASH_DAYS ): ?>
|
||||
<option value="delete"><?php _e('Delete Permanently'); ?></option>
|
||||
<?php else: ?>
|
||||
<option value="trash"><?php _e('Move to Trash'); ?></option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<input type="submit" name="doaction" id="doaction" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
|
||||
<?php wp_nonce_field('bulk-comments'); ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<select name="comment_type">
|
||||
<option value="all"><?php _e('Show all comment types'); ?></option>
|
||||
<?php
|
||||
$comment_types = apply_filters( 'admin_comment_types_dropdown', array(
|
||||
'comment' => __('Comments'),
|
||||
'pings' => __('Pings'),
|
||||
) );
|
||||
|
||||
foreach ( $comment_types as $type => $label ) {
|
||||
echo " <option value='" . esc_attr($type) . "'";
|
||||
selected( $comment_type, $type );
|
||||
echo ">$label</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
|
||||
|
||||
<?php if ( isset($_GET['apage']) ) { ?>
|
||||
<input type="hidden" name="apage" value="<?php echo esc_attr( absint( $_GET['apage'] ) ); ?>" />
|
||||
<?php }
|
||||
|
||||
if ( ( 'spam' == $comment_status || 'trash' == $comment_status) && current_user_can ('moderate_comments') ) {
|
||||
wp_nonce_field('bulk-destroy', '_destroy_nonce');
|
||||
if ( 'spam' == $comment_status && current_user_can('moderate_comments') ) { ?>
|
||||
<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" />
|
||||
<?php } elseif ( 'trash' == $comment_status && current_user_can('moderate_comments') ) { ?>
|
||||
<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
<?php }
|
||||
} ?>
|
||||
<?php do_action('manage_comments_nav', $comment_status); ?>
|
||||
</div>
|
||||
|
||||
<br class="clear" />
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
<?php if ( $comments ) { ?>
|
||||
|
||||
<table class="widefat comments fixed" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php print_column_headers('edit-comments'); ?>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<?php print_column_headers('edit-comments', false); ?>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody id="the-comment-list" class="list:comment">
|
||||
<?php
|
||||
foreach ($comments as $comment)
|
||||
_wp_comment_row( $comment->comment_ID, $mode, $comment_status );
|
||||
?>
|
||||
</tbody>
|
||||
<tbody id="the-extra-comment-list" class="list:comment" style="display: none;">
|
||||
<?php
|
||||
foreach ($extra_comments as $comment)
|
||||
_wp_comment_row( $comment->comment_ID, $mode, $comment_status );
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="tablenav">
|
||||
<?php
|
||||
if ( $page_links )
|
||||
echo "<div class='tablenav-pages'>$page_links_text</div>";
|
||||
?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<select name="action2">
|
||||
<option value="-1" selected="selected"><?php _e('Bulk Actions') ?></option>
|
||||
<?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
|
||||
<option value="unapprove"><?php _e('Unapprove'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
|
||||
<option value="approve"><?php _e('Approve'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?>
|
||||
<option value="spam"><?php _ex('Mark as Spam', 'comment'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'trash' == $comment_status ): ?>
|
||||
<option value="untrash"><?php _e('Restore'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'trash' == $comment_status || 'spam' == $comment_status || !EMPTY_TRASH_DAYS ): ?>
|
||||
<option value="delete"><?php _e('Delete Permanently'); ?></option>
|
||||
<?php elseif ( 'spam' == $comment_status ): ?>
|
||||
<option value="unspam"><?php _ex('Not Spam', 'comment'); ?></option>
|
||||
<?php else: ?>
|
||||
<option value="trash"><?php _e('Move to Trash'); ?></option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
|
||||
|
||||
<?php if ( 'spam' == $comment_status && current_user_can('moderate_comments') ) { ?>
|
||||
<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" />
|
||||
<?php } elseif ( 'trash' == $comment_status && current_user_can('moderate_comments') ) { ?>
|
||||
<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
<?php if ( isset($_REQUEST['paged']) ) { ?>
|
||||
<input type="hidden" name="paged" value="<?php echo esc_attr( absint( $_REQUEST['paged'] ) ); ?>" />
|
||||
<?php } ?>
|
||||
<?php do_action('manage_comments_nav', $comment_status); ?>
|
||||
</div>
|
||||
|
||||
<?php if ( $table->has_items() ) { ?>
|
||||
|
||||
<?php $table->display_table(); ?>
|
||||
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
@ -460,7 +280,7 @@ if ( $page_links )
|
|||
<input type="hidden" name="comment_status" value="<?php echo esc_attr($comment_status); ?>" />
|
||||
<input type="hidden" name="page" value="<?php echo esc_attr($page); ?>" />
|
||||
<input type="hidden" name="per_page" value="<?php echo esc_attr($comments_per_page); ?>" />
|
||||
<input type="hidden" name="p" value="<?php echo esc_attr( $post_id ); ?>" />
|
||||
<input type="hidden" name="post_ID" value="<?php echo esc_attr( $post_id ); ?>" />
|
||||
<input type="hidden" name="comment_type" value="<?php echo esc_attr( $comment_type ); ?>" />
|
||||
<?php wp_nonce_field( 'add-comment', '_ajax_nonce', false ); ?>
|
||||
</form>
|
||||
|
|
|
@ -9,24 +9,12 @@
|
|||
/** WordPress Administration Bootstrap */
|
||||
require_once('./admin.php');
|
||||
|
||||
wp_reset_vars( array('action', 'tag', 'taxonomy', 'post_type') );
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
|
||||
if ( empty($taxonomy) )
|
||||
$taxonomy = 'post_tag';
|
||||
|
||||
if ( !taxonomy_exists($taxonomy) )
|
||||
wp_die(__('Invalid taxonomy'));
|
||||
|
||||
$tax = get_taxonomy($taxonomy);
|
||||
|
||||
if ( ! current_user_can($tax->cap->manage_terms) )
|
||||
wp_die(__('Cheatin’ uh?'));
|
||||
$table = new WP_Terms_Table;
|
||||
|
||||
$title = $tax->labels->name;
|
||||
|
||||
if ( empty($post_type) || !in_array( $post_type, get_post_types( array('public' => true) ) ) )
|
||||
$post_type = 'post';
|
||||
|
||||
if ( 'post' != $post_type ) {
|
||||
$parent_file = "edit.php?post_type=$post_type";
|
||||
$submenu_file = "edit-tags.php?taxonomy=$taxonomy&post_type=$post_type";
|
||||
|
@ -35,7 +23,7 @@ if ( 'post' != $post_type ) {
|
|||
$submenu_file = "edit-tags.php?taxonomy=$taxonomy";
|
||||
}
|
||||
|
||||
if ( isset( $_GET['action'] ) && isset($_GET['delete_tags']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) )
|
||||
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) )
|
||||
$action = 'bulk-delete';
|
||||
|
||||
switch ( $action ) {
|
||||
|
@ -74,12 +62,12 @@ case 'delete':
|
|||
$location = $referer;
|
||||
}
|
||||
|
||||
if ( !isset( $_GET['tag_ID'] ) ) {
|
||||
if ( !isset( $_REQUEST['tag_ID'] ) ) {
|
||||
wp_redirect( $location );
|
||||
exit;
|
||||
}
|
||||
|
||||
$tag_ID = (int) $_GET['tag_ID'];
|
||||
$tag_ID = (int) $_REQUEST['tag_ID'];
|
||||
check_admin_referer( 'delete-tag_' . $tag_ID );
|
||||
|
||||
if ( !current_user_can( $tax->cap->delete_terms ) )
|
||||
|
@ -99,7 +87,7 @@ case 'bulk-delete':
|
|||
if ( !current_user_can( $tax->cap->delete_terms ) )
|
||||
wp_die( __( 'Cheatin’ uh?' ) );
|
||||
|
||||
$tags = (array) $_GET['delete_tags'];
|
||||
$tags = (array) $_REQUEST['delete_tags'];
|
||||
foreach ( $tags as $tag_ID ) {
|
||||
wp_delete_term( $tag_ID, $taxonomy );
|
||||
}
|
||||
|
@ -122,10 +110,7 @@ case 'edit':
|
|||
$title = $tax->labels->edit_item;
|
||||
|
||||
require_once ( 'admin-header.php' );
|
||||
$tag_ID = (int) $_GET['tag_ID'];
|
||||
|
||||
if ( !current_user_can($tax->cap->edit_terms) )
|
||||
wp_die( __('You are not allowed to edit this item.') );
|
||||
$tag_ID = (int) $_REQUEST['tag_ID'];
|
||||
|
||||
$tag = get_term( $tag_ID, $taxonomy, OBJECT, 'edit' );
|
||||
include( './edit-tag-form.php' );
|
||||
|
@ -161,7 +146,7 @@ break;
|
|||
|
||||
default:
|
||||
|
||||
if ( ! empty($_GET['_wp_http_referer']) ) {
|
||||
if ( ! empty($_REQUEST['_wp_http_referer']) ) {
|
||||
wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
|
||||
exit;
|
||||
}
|
||||
|
@ -209,6 +194,9 @@ if ( 'category' == $taxonomy || 'post_tag' == $taxonomy ) {
|
|||
|
||||
require_once ('admin-header.php');
|
||||
|
||||
if ( !current_user_can($tax->cap->edit_terms) )
|
||||
wp_die( __('You are not allowed to edit this item.') );
|
||||
|
||||
$messages[1] = __('Item added.');
|
||||
$messages[2] = __('Item deleted.');
|
||||
$messages[3] = __('Item updated.');
|
||||
|
@ -221,11 +209,11 @@ $messages[6] = __('Items deleted.');
|
|||
<div class="wrap nosubsub">
|
||||
<?php screen_icon(); ?>
|
||||
<h2><?php echo esc_html( $title );
|
||||
if ( !empty($_GET['s']) )
|
||||
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_GET['s']) ) ); ?>
|
||||
if ( !empty($_REQUEST['s']) )
|
||||
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?>
|
||||
</h2>
|
||||
|
||||
<?php if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?>
|
||||
<?php if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) ) : ?>
|
||||
<div id="message" class="updated"><p><?php echo $messages[$msg]; ?></p></div>
|
||||
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
|
||||
endif; ?>
|
||||
|
@ -246,91 +234,11 @@ endif; ?>
|
|||
|
||||
<div id="col-right">
|
||||
<div class="col-wrap">
|
||||
<form id="posts-filter" action="" method="get">
|
||||
<form id="posts-filter" action="" method="post">
|
||||
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
|
||||
<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
|
||||
<div class="tablenav">
|
||||
<?php
|
||||
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
|
||||
if ( empty($pagenum) )
|
||||
$pagenum = 1;
|
||||
|
||||
$tags_per_page = (int) get_user_option( 'edit_' . $taxonomy . '_per_page' );
|
||||
|
||||
if ( empty($tags_per_page) || $tags_per_page < 1 )
|
||||
$tags_per_page = 20;
|
||||
|
||||
if ( 'post_tag' == $taxonomy ) {
|
||||
$tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );
|
||||
$tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter
|
||||
} elseif ( 'category' == $taxonomy ) {
|
||||
$tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); // Old filter
|
||||
} else {
|
||||
$tags_per_page = apply_filters( 'edit_' . $taxonomy . '_per_page', $tags_per_page );
|
||||
}
|
||||
|
||||
$searchterms = !empty($_GET['s']) ? trim(stripslashes($_GET['s'])) : '';
|
||||
|
||||
$page_links = paginate_links( array(
|
||||
'base' => add_query_arg( 'pagenum', '%#%' ),
|
||||
'format' => '',
|
||||
'prev_text' => __('«'),
|
||||
'next_text' => __('»'),
|
||||
'total' => ceil(wp_count_terms($taxonomy, array('search' => $searchterms)) / $tags_per_page),
|
||||
'current' => $pagenum
|
||||
));
|
||||
|
||||
if ( $page_links )
|
||||
echo "<div class='tablenav-pages'>$page_links</div>";
|
||||
?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<select name="action">
|
||||
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||
<option value="delete"><?php _e('Delete'); ?></option>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
|
||||
<?php wp_nonce_field('bulk-tags'); ?>
|
||||
</div>
|
||||
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
<table class="widefat tag fixed" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php print_column_headers($current_screen); ?>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<?php print_column_headers($current_screen, false); ?>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody id="the-list" class="list:tag">
|
||||
<?php tag_rows( $pagenum, $tags_per_page, $searchterms, $taxonomy ); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="tablenav">
|
||||
<?php
|
||||
if ( $page_links )
|
||||
echo "<div class='tablenav-pages'>$page_links</div>";
|
||||
?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<select name="action2">
|
||||
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||
<option value="delete"><?php _e('Delete'); ?></option>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
||||
</div>
|
||||
|
||||
<br class="clear" />
|
||||
</div>
|
||||
<?php $table->display_table(); ?>
|
||||
|
||||
<br class="clear" />
|
||||
</form>
|
||||
|
@ -358,7 +266,7 @@ do_action('after-' . $taxonomy . '-table', $taxonomy);
|
|||
|
||||
<?php
|
||||
|
||||
if ( !is_taxonomy_hierarchical($taxonomy) ) {
|
||||
if ( !is_null( $tax->labels->popular_items ) ) {
|
||||
if ( current_user_can( $tax->cap->edit_terms ) )
|
||||
$tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false, 'link' => 'edit' ) );
|
||||
else
|
||||
|
@ -440,7 +348,7 @@ do_action($taxonomy . '_add_form', $taxonomy);
|
|||
</div><!-- /col-container -->
|
||||
</div><!-- /wrap -->
|
||||
|
||||
<?php inline_edit_term_row('edit-tags', $taxonomy); ?>
|
||||
<?php $table->inline_edit(); ?>
|
||||
|
||||
<?php
|
||||
break;
|
||||
|
|
|
@ -9,63 +9,33 @@
|
|||
/** WordPress Administration Bootstrap */
|
||||
require_once( './admin.php' );
|
||||
|
||||
if ( !isset($_GET['post_type']) )
|
||||
$post_type = 'post';
|
||||
elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) )
|
||||
$post_type = $_GET['post_type'];
|
||||
else
|
||||
wp_die( __('Invalid post type') );
|
||||
$_GET['post_type'] = $post_type;
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
|
||||
$post_type_object = get_post_type_object($post_type);
|
||||
|
||||
if ( !current_user_can($post_type_object->cap->edit_posts) )
|
||||
wp_die(__('Cheatin’ uh?'));
|
||||
$table = new WP_Posts_Table;
|
||||
|
||||
// Back-compat for viewing comments of an entry
|
||||
if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['page_id'] ) ) ) {
|
||||
if ( $_redirect = intval( max( @$_REQUEST['p'], @$_REQUEST['attachment_id'], @$_REQUEST['page_id'] ) ) ) {
|
||||
wp_redirect( admin_url('edit-comments.php?p=' . $_redirect ) );
|
||||
exit;
|
||||
} else {
|
||||
unset( $_redirect );
|
||||
}
|
||||
|
||||
if ( 'post' != $post_type ) {
|
||||
$parent_file = "edit.php?post_type=$post_type";
|
||||
$submenu_file = "edit.php?post_type=$post_type";
|
||||
$post_new_file = "post-new.php?post_type=$post_type";
|
||||
} else {
|
||||
$parent_file = 'edit.php';
|
||||
$submenu_file = 'edit.php';
|
||||
$post_new_file = 'post-new.php';
|
||||
}
|
||||
|
||||
$pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0;
|
||||
if ( empty($pagenum) )
|
||||
$pagenum = 1;
|
||||
$edit_per_page = 'edit_' . $post_type . '_per_page';
|
||||
$per_page = (int) get_user_option( $edit_per_page );
|
||||
if ( empty( $per_page ) || $per_page < 1 )
|
||||
$per_page = 20;
|
||||
|
||||
$per_page = apply_filters( $edit_per_page, $per_page );
|
||||
$per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
|
||||
|
||||
// Handle bulk actions
|
||||
if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) {
|
||||
if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) || isset($_REQUEST['bulk_edit']) ) {
|
||||
check_admin_referer('bulk-posts');
|
||||
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
|
||||
|
||||
if ( strpos($sendback, 'post.php') !== false )
|
||||
$sendback = admin_url($post_new_file);
|
||||
|
||||
if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
|
||||
$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']);
|
||||
if ( isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) ) {
|
||||
$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);
|
||||
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
|
||||
$doaction = 'delete';
|
||||
} elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['post']) || isset($_GET['ids']) ) ) {
|
||||
$post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']);
|
||||
$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
|
||||
} elseif ( ( $_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1 ) && ( isset($_REQUEST['post']) || isset($_REQUEST['ids']) ) ) {
|
||||
$post_ids = isset($_REQUEST['post']) ? array_map( 'intval', (array) $_REQUEST['post'] ) : explode(',', $_REQUEST['ids']);
|
||||
$doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2'];
|
||||
} else {
|
||||
wp_redirect( admin_url("edit.php?post_type=$post_type") );
|
||||
}
|
||||
|
@ -117,7 +87,7 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet
|
|||
$sendback = add_query_arg('deleted', $deleted, $sendback);
|
||||
break;
|
||||
case 'edit':
|
||||
$done = bulk_edit_posts($_GET);
|
||||
$done = bulk_edit_posts($_REQUEST);
|
||||
|
||||
if ( is_array($done) ) {
|
||||
$done['updated'] = count( $done['updated'] );
|
||||
|
@ -128,32 +98,27 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet
|
|||
break;
|
||||
}
|
||||
|
||||
if ( isset($_GET['action']) )
|
||||
if ( isset($_REQUEST['action']) )
|
||||
$sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback );
|
||||
|
||||
wp_redirect($sendback);
|
||||
exit();
|
||||
} elseif ( ! empty($_GET['_wp_http_referer']) ) {
|
||||
} elseif ( ! empty($_REQUEST['_wp_http_referer']) ) {
|
||||
wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
wp_enqueue_script('inline-edit-post');
|
||||
|
||||
$user_posts = false;
|
||||
if ( !current_user_can($post_type_object->cap->edit_others_posts) ) {
|
||||
$user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = '%s' AND post_status NOT IN ('trash', 'auto-draft') AND post_author = %d", $post_type, $current_user->ID) );
|
||||
$user_posts = true;
|
||||
if ( $user_posts_count && empty($_GET['post_status']) && empty($_GET['all_posts']) && empty($_GET['author']) )
|
||||
$_GET['author'] = $current_user->ID;
|
||||
if ( 'post' != $post_type ) {
|
||||
$parent_file = "edit.php?post_type=$post_type";
|
||||
$submenu_file = "edit.php?post_type=$post_type";
|
||||
$post_new_file = "post-new.php?post_type=$post_type";
|
||||
} else {
|
||||
$parent_file = 'edit.php';
|
||||
$submenu_file = 'edit.php';
|
||||
$post_new_file = 'post-new.php';
|
||||
}
|
||||
|
||||
$avail_post_stati = wp_edit_posts_query();
|
||||
|
||||
if ( $post_type_object->hierarchical )
|
||||
$num_pages = ceil($wp_query->post_count / $per_page);
|
||||
else
|
||||
$num_pages = $wp_query->max_num_pages;
|
||||
wp_enqueue_script('inline-edit-post');
|
||||
|
||||
$title = $post_type_object->labels->name;
|
||||
|
||||
|
@ -190,55 +155,50 @@ if ( 'post' == $post_type ) {
|
|||
}
|
||||
|
||||
require_once('./admin-header.php');
|
||||
|
||||
if ( empty($_GET['mode']) )
|
||||
$mode = 'list';
|
||||
else
|
||||
$mode = esc_attr($_GET['mode']); ?>
|
||||
|
||||
?>
|
||||
<div class="wrap">
|
||||
<?php screen_icon(); ?>
|
||||
<h2><?php echo esc_html( $post_type_object->labels->name ); ?> <a href="<?php echo $post_new_file ?>" class="button add-new-h2"><?php echo esc_html($post_type_object->labels->add_new); ?></a> <?php
|
||||
if ( isset($_GET['s']) && $_GET['s'] )
|
||||
if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
|
||||
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', get_search_query() ); ?>
|
||||
</h2>
|
||||
|
||||
<?php
|
||||
if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
|
||||
<div id="message" class="updated"><p><strong><?php _e('This 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>
|
||||
if ( isset($_REQUEST['posted']) && $_REQUEST['posted'] ) : $_REQUEST['posted'] = (int) $_REQUEST['posted']; ?>
|
||||
<div id="message" class="updated"><p><strong><?php _e('This has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_REQUEST['posted'] ); ?>"><?php _e('View Post'); ?></a> | <a href="<?php echo get_edit_post_link( $_REQUEST['posted'] ); ?>"><?php _e('Edit Post'); ?></a></p></div>
|
||||
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
|
||||
endif; ?>
|
||||
|
||||
<?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?>
|
||||
<?php if ( isset($_REQUEST['locked']) || isset($_REQUEST['skipped']) || isset($_REQUEST['updated']) || isset($_REQUEST['deleted']) || isset($_REQUEST['trashed']) || isset($_REQUEST['untrashed']) ) { ?>
|
||||
<div id="message" class="updated"><p>
|
||||
<?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
|
||||
printf( _n( '%s post updated.', '%s posts updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
|
||||
unset($_GET['updated']);
|
||||
<?php if ( isset($_REQUEST['updated']) && (int) $_REQUEST['updated'] ) {
|
||||
printf( _n( '%s post updated.', '%s posts updated.', $_REQUEST['updated'] ), number_format_i18n( $_REQUEST['updated'] ) );
|
||||
unset($_REQUEST['updated']);
|
||||
}
|
||||
|
||||
if ( isset($_GET['skipped']) && (int) $_GET['skipped'] )
|
||||
unset($_GET['skipped']);
|
||||
if ( isset($_REQUEST['skipped']) && (int) $_REQUEST['skipped'] )
|
||||
unset($_REQUEST['skipped']);
|
||||
|
||||
if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
|
||||
printf( _n( '%s item not updated, somebody is editing it.', '%s items not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) );
|
||||
unset($_GET['locked']);
|
||||
if ( isset($_REQUEST['locked']) && (int) $_REQUEST['locked'] ) {
|
||||
printf( _n( '%s item not updated, somebody is editing it.', '%s items not updated, somebody is editing them.', $_REQUEST['locked'] ), number_format_i18n( $_REQUEST['locked'] ) );
|
||||
unset($_REQUEST['locked']);
|
||||
}
|
||||
|
||||
if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
|
||||
printf( _n( 'Item permanently deleted.', '%s items permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
|
||||
unset($_GET['deleted']);
|
||||
if ( isset($_REQUEST['deleted']) && (int) $_REQUEST['deleted'] ) {
|
||||
printf( _n( 'Item permanently deleted.', '%s items permanently deleted.', $_REQUEST['deleted'] ), number_format_i18n( $_REQUEST['deleted'] ) );
|
||||
unset($_REQUEST['deleted']);
|
||||
}
|
||||
|
||||
if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) {
|
||||
printf( _n( 'Item moved to the Trash.', '%s items moved to the Trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
|
||||
$ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
|
||||
if ( isset($_REQUEST['trashed']) && (int) $_REQUEST['trashed'] ) {
|
||||
printf( _n( 'Item moved to the Trash.', '%s items moved to the Trash.', $_REQUEST['trashed'] ), number_format_i18n( $_REQUEST['trashed'] ) );
|
||||
$ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
|
||||
echo ' <a href="' . esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a><br />';
|
||||
unset($_GET['trashed']);
|
||||
unset($_REQUEST['trashed']);
|
||||
}
|
||||
|
||||
if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {
|
||||
printf( _n( 'Item restored from the Trash.', '%s items restored from the Trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );
|
||||
unset($_GET['undeleted']);
|
||||
if ( isset($_REQUEST['untrashed']) && (int) $_REQUEST['untrashed'] ) {
|
||||
printf( _n( 'Item restored from the Trash.', '%s items restored from the Trash.', $_REQUEST['untrashed'] ), number_format_i18n( $_REQUEST['untrashed'] ) );
|
||||
unset($_REQUEST['undeleted']);
|
||||
}
|
||||
|
||||
$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] );
|
||||
|
@ -246,7 +206,7 @@ $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated'
|
|||
</p></div>
|
||||
<?php } ?>
|
||||
|
||||
<form id="posts-filter" action="<?php echo admin_url('edit.php'); ?>" method="get">
|
||||
<form id="posts-filter" action="" method="post">
|
||||
|
||||
<ul class="subsubsub">
|
||||
<?php
|
||||
|
@ -256,8 +216,22 @@ $num_posts = wp_count_posts( $post_type, 'readable' );
|
|||
$class = '';
|
||||
$allposts = '';
|
||||
|
||||
$user_posts = false;
|
||||
if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) {
|
||||
$user_posts = true;
|
||||
|
||||
$user_posts_count = $wpdb->get_var( $wpdb->prepare( "
|
||||
SELECT COUNT( 1 ) FROM $wpdb->posts
|
||||
WHERE post_type = '%s' AND post_status NOT IN ( 'trash', 'auto-draft' )
|
||||
AND post_author = %d
|
||||
", $post_type, get_current_user_id() ) );
|
||||
|
||||
if ( $user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) )
|
||||
$_REQUEST['author'] = get_current_user_id();
|
||||
}
|
||||
|
||||
if ( $user_posts ) {
|
||||
if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user->ID ) )
|
||||
if ( isset( $_REQUEST['author'] ) && ( $_REQUEST['author'] == $current_user->ID ) )
|
||||
$class = ' class="current"';
|
||||
$status_links[] = "<li><a href='edit.php?post_type=$post_type&author=$current_user->ID'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $user_posts_count, 'posts' ), number_format_i18n( $user_posts_count ) ) . '</a>';
|
||||
$allposts = '&all_posts=1';
|
||||
|
@ -269,7 +243,7 @@ $total_posts = array_sum( (array) $num_posts );
|
|||
foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state )
|
||||
$total_posts -= $num_posts->$state;
|
||||
|
||||
$class = empty($class) && empty($_GET['post_status']) ? ' class="current"' : '';
|
||||
$class = empty($class) && empty($_REQUEST['post_status']) ? ' class="current"' : '';
|
||||
$status_links[] = "<li><a href='edit.php?post_type=$post_type{$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>';
|
||||
|
||||
foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
|
||||
|
@ -283,7 +257,7 @@ foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects')
|
|||
if ( empty( $num_posts->$status_name ) )
|
||||
continue;
|
||||
|
||||
if ( isset($_GET['post_status']) && $status_name == $_GET['post_status'] )
|
||||
if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] )
|
||||
$class = ' class="current"';
|
||||
|
||||
$status_links[] = "<li><a href='edit.php?post_status=$status_name&post_type=$post_type'$class>" . sprintf( _n( $status->label_count[0], $status->label_count[1], $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . '</a>';
|
||||
|
@ -300,163 +274,14 @@ endif;
|
|||
<input type="submit" value="<?php echo esc_attr( $post_type_object->labels->search_items ); ?>" class="button" />
|
||||
</p>
|
||||
|
||||
<input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_GET['post_status']) ? esc_attr($_GET['post_status']) : 'all'; ?>" />
|
||||
<input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_REQUEST['post_status']) ? esc_attr($_REQUEST['post_status']) : 'all'; ?>" />
|
||||
<input type="hidden" name="post_type" class="post_type_page" value="<?php echo $post_type; ?>" />
|
||||
<input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" />
|
||||
|
||||
<?php if ( have_posts() ) { ?>
|
||||
|
||||
<div class="tablenav">
|
||||
<?php
|
||||
$page_links = paginate_links( array(
|
||||
'base' => add_query_arg( 'paged', '%#%' ),
|
||||
'format' => '',
|
||||
'prev_text' => __('«'),
|
||||
'next_text' => __('»'),
|
||||
'total' => $num_pages,
|
||||
'current' => $pagenum
|
||||
));
|
||||
|
||||
$is_trash = isset($_GET['post_status']) && $_GET['post_status'] == 'trash';
|
||||
|
||||
?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<select name="action">
|
||||
<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||
<?php if ( $is_trash ) { ?>
|
||||
<option value="untrash"><?php _e('Restore'); ?></option>
|
||||
<?php } else { ?>
|
||||
<option value="edit"><?php _e('Edit'); ?></option>
|
||||
<?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?>
|
||||
<option value="delete"><?php _e('Delete Permanently'); ?></option>
|
||||
<?php } else { ?>
|
||||
<option value="trash"><?php _e('Move to Trash'); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
|
||||
<?php wp_nonce_field('bulk-posts'); ?>
|
||||
|
||||
<?php // view filters
|
||||
if ( !is_singular() ) {
|
||||
$arc_query = $wpdb->prepare("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = %s ORDER BY post_date DESC", $post_type);
|
||||
|
||||
$arc_result = $wpdb->get_results( $arc_query );
|
||||
|
||||
$month_count = count($arc_result);
|
||||
|
||||
if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
|
||||
$m = isset($_GET['m']) ? (int)$_GET['m'] : 0;
|
||||
?>
|
||||
<select name='m'>
|
||||
<option<?php selected( $m, 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
|
||||
<?php
|
||||
foreach ($arc_result as $arc_row) {
|
||||
if ( $arc_row->yyear == 0 )
|
||||
continue;
|
||||
$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
|
||||
|
||||
if ( $arc_row->yyear . $arc_row->mmonth == $m )
|
||||
$default = ' selected="selected"';
|
||||
else
|
||||
$default = '';
|
||||
|
||||
echo "<option$default value='" . esc_attr("$arc_row->yyear$arc_row->mmonth") . "'>";
|
||||
echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
|
||||
echo "</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
if ( is_object_in_taxonomy($post_type, 'category') ) {
|
||||
$dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1,
|
||||
'show_count' => 0, 'orderby' => 'name', 'selected' => $cat);
|
||||
wp_dropdown_categories($dropdown_options);
|
||||
}
|
||||
do_action('restrict_manage_posts');
|
||||
?>
|
||||
<input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
|
||||
<?php }
|
||||
|
||||
if ( $is_trash && current_user_can($post_type_object->cap->edit_others_posts) ) { ?>
|
||||
<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php if ( $page_links ) { ?>
|
||||
<div class="tablenav-pages"><?php
|
||||
$count_posts = $post_type_object->hierarchical ? $wp_query->post_count : $wp_query->found_posts;
|
||||
$page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
|
||||
number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
|
||||
number_format_i18n( min( $pagenum * $per_page, $count_posts ) ),
|
||||
number_format_i18n( $count_posts ),
|
||||
$page_links
|
||||
);
|
||||
echo $page_links_text;
|
||||
?></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( !$post_type_object->hierarchical ) {
|
||||
?>
|
||||
|
||||
<div class="view-switch">
|
||||
<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="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e('List View') ?>" alt="<?php _e('List View') ?>" /></a>
|
||||
<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="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e('Excerpt View') ?>" alt="<?php _e('Excerpt View') ?>" /></a>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php include( './edit-post-rows.php' ); ?>
|
||||
|
||||
<div class="tablenav">
|
||||
|
||||
<?php
|
||||
if ( $page_links )
|
||||
echo "<div class='tablenav-pages'>$page_links_text</div>";
|
||||
?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<select name="action2">
|
||||
<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||
<?php if ( $is_trash ) { ?>
|
||||
<option value="untrash"><?php _e('Restore'); ?></option>
|
||||
<?php } else { ?>
|
||||
<option value="edit"><?php _e('Edit'); ?></option>
|
||||
<?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?>
|
||||
<option value="delete"><?php _e('Delete Permanently'); ?></option>
|
||||
<?php } else { ?>
|
||||
<option value="trash"><?php _e('Move to Trash'); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
||||
<?php if ( $is_trash && current_user_can($post_type_object->cap->edit_others_posts) ) { ?>
|
||||
<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
<?php } ?>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<?php } else { // have_posts() ?>
|
||||
<div class="clear"></div>
|
||||
<p><?php
|
||||
if ( isset($_GET['post_status']) && 'trash' == $_GET['post_status'] )
|
||||
echo $post_type_object->labels->not_found_in_trash;
|
||||
else
|
||||
echo $post_type_object->labels->not_found;
|
||||
?></p>
|
||||
<?php } ?>
|
||||
<?php $table->display(); ?>
|
||||
|
||||
</form>
|
||||
|
||||
<?php inline_edit_row( $current_screen ); ?>
|
||||
<?php $table->inline_edit(); ?>
|
||||
|
||||
<div id="ajax-response"></div>
|
||||
<br class="clear" />
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 54 B |
Binary file not shown.
After Width: | Height: | Size: 54 B |
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,599 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Base class for displaying a list of items as an ajaxified html table
|
||||
*
|
||||
* @package WordPress
|
||||
* @since 3.1.0
|
||||
*/
|
||||
class WP_List_Table {
|
||||
|
||||
/**
|
||||
* The current list of items
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
var $items;
|
||||
|
||||
/**
|
||||
* Various information about the current table
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_args;
|
||||
|
||||
/**
|
||||
* Various information needed for displaying the pagination
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_pagination_args = array();
|
||||
|
||||
/**
|
||||
* The current screen
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @var object
|
||||
* @access private
|
||||
*/
|
||||
var $_screen;
|
||||
|
||||
/**
|
||||
* Cached bulk actions
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_actions;
|
||||
|
||||
/**
|
||||
* Cached pagination output
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_pagination;
|
||||
|
||||
/**
|
||||
* Constructor. The child class should call this constructor from it's own constructor
|
||||
*
|
||||
* @param array $args An associative array with information about the current table
|
||||
* @access protected
|
||||
*/
|
||||
function WP_List_Table( $args ) {
|
||||
|
||||
$args = wp_parse_args( $args, array(
|
||||
'screen' => '',
|
||||
'plural' => '',
|
||||
'singular' => '',
|
||||
'ajax' => true
|
||||
) );
|
||||
|
||||
$this->_screen = $args['screen'];
|
||||
|
||||
if ( is_string( $this->_screen ) )
|
||||
$this->_screen = convert_to_screen( $this->_screen );
|
||||
|
||||
if ( !$args['plural'] )
|
||||
$args['plural'] = $this->_screen->base;
|
||||
|
||||
$this->_args = $args;
|
||||
|
||||
if ( $args['ajax'] ) {
|
||||
wp_enqueue_script( 'admin-table' );
|
||||
add_action( 'admin_footer', array( $this, '_js_vars' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An internal method that sets all the necessary pagination arguments
|
||||
*
|
||||
* @param array $args An associative array with information about the pagination
|
||||
* @access protected
|
||||
*/
|
||||
function set_pagination_args( $args ) {
|
||||
$args = wp_parse_args( $args, array(
|
||||
'query_var' => 'paged',
|
||||
'total_items' => 0,
|
||||
'total_pages' => 0,
|
||||
'per_page' => 0,
|
||||
) );
|
||||
|
||||
if ( !$args['total_pages'] && $args['per_page'] > 0 )
|
||||
$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
|
||||
|
||||
$this->_pagination_args = $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wether the table has items to display or not
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access public
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function has_items() {
|
||||
return !empty( $this->items );
|
||||
}
|
||||
|
||||
/**
|
||||
* Message to be displayed when there are no items
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access public
|
||||
*/
|
||||
function no_items() {
|
||||
_e( 'No items found.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an associative array ( option_name => option_title ) with the list
|
||||
* of bulk actions available on this table.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_bulk_actions() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the bulk actions dropdown.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access public
|
||||
*/
|
||||
function bulk_actions() {
|
||||
|
||||
if ( is_null( $this->_actions ) ) {
|
||||
$this->_actions = $this->get_bulk_actions();
|
||||
$this->_actions = apply_filters( 'bulk_actions-' . $this->_screen->base, $this->_actions );
|
||||
$two = '';
|
||||
}
|
||||
else {
|
||||
$two = '2';
|
||||
}
|
||||
|
||||
if ( empty( $this->_actions ) )
|
||||
return;
|
||||
|
||||
echo "<select name='action$two'>\n";
|
||||
echo "<option value='-1' selected='selected'>" . __( 'Bulk Actions' ) . "</option>\n";
|
||||
foreach ( $this->_actions as $name => $title )
|
||||
echo "\t<option value='$name'>$title</option>\n";
|
||||
echo "</select>\n";
|
||||
|
||||
echo "<input type='submit' value='" . esc_attr__( 'Apply' ) . "' name='doaction$two' id='doaction$two' class='button-secondary action' />\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a monthly dropdown for filtering items
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*/
|
||||
function months_dropdown( $post_type ) {
|
||||
global $wpdb, $wp_locale;
|
||||
|
||||
$months = $wpdb->get_results( $wpdb->prepare( "
|
||||
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = %s
|
||||
ORDER BY post_date DESC
|
||||
", $post_type ) );
|
||||
|
||||
$month_count = count( $months );
|
||||
|
||||
if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
|
||||
return;
|
||||
|
||||
$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
|
||||
?>
|
||||
<select name='m'>
|
||||
<option<?php selected( $m, 0 ); ?> value='0'><?php _e( 'Show all dates' ); ?></option>
|
||||
<?php
|
||||
foreach ( $months as $arc_row ) {
|
||||
if ( 0 == $arc_row->year )
|
||||
continue;
|
||||
|
||||
$month = zeroise( $arc_row->month, 2 );
|
||||
$year = $arc_row->year;
|
||||
|
||||
printf( "<option %s value='%s'>%s</option>\n",
|
||||
selected( $m, $year . $month, false ),
|
||||
esc_attr( $arc_row->year . $month ),
|
||||
$wp_locale->get_month( $month ) . " $year"
|
||||
);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a view switcher
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*/
|
||||
function view_switcher( $current_mode ) {
|
||||
$modes = array(
|
||||
'list' => __( 'List View' ),
|
||||
'excerpt' => __( 'Excerpt View' )
|
||||
);
|
||||
|
||||
?>
|
||||
<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
|
||||
<div class="view-switch">
|
||||
<?php
|
||||
foreach ( $modes as $mode => $title ) {
|
||||
$class = ( $current_mode == $mode ) ? 'class="current"' : '';
|
||||
echo "<a href='" . esc_url( add_query_arg( 'mode', $mode, $_SERVER['REQUEST_URI'] ) ) . "' $class><img id='view-switch-$mode' src='" . esc_url( includes_url( 'images/blank.gif' ) ) . "' width='20' height='20' title='$title' alt='$title' /></a>\n";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current page number
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function get_pagenum( $query_var = 'paged' ) {
|
||||
$pagenum = isset( $_REQUEST[$query_var] ) ? absint( $_REQUEST[$query_var] ) : 0;
|
||||
|
||||
return max( 1, $pagenum );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the pagination.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*/
|
||||
function pagination() {
|
||||
if ( $this->_pagination ) {
|
||||
echo $this->_pagination;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( empty( $this->_pagination_args ) )
|
||||
return;
|
||||
|
||||
extract( $this->_pagination_args );
|
||||
|
||||
if ( $total_pages < 2 )
|
||||
return;
|
||||
|
||||
$output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
|
||||
|
||||
$current = $this->get_pagenum( $query_var );
|
||||
|
||||
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
|
||||
$page_links = array();
|
||||
|
||||
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
||||
'first-page',
|
||||
esc_attr__( 'Go to the first page' ),
|
||||
esc_url( remove_query_arg( $query_var, $current_url ) ),
|
||||
'««'
|
||||
);
|
||||
|
||||
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
||||
'prev-page',
|
||||
esc_attr__( 'Go to the previous page' ),
|
||||
esc_url( add_query_arg( $query_var, max( 1, $current-1 ), $current_url ) ),
|
||||
'«'
|
||||
);
|
||||
|
||||
$html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='%s' value='%s' size='%d' />",
|
||||
esc_attr__( 'Current page' ),
|
||||
esc_attr( $query_var ),
|
||||
number_format_i18n( $current ),
|
||||
strlen( $total_pages )
|
||||
);
|
||||
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
|
||||
$page_links[] = sprintf( _x( '%s of %s', 'paging' ), $html_current_page, $html_total_pages );
|
||||
|
||||
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
||||
'next-page',
|
||||
esc_attr__( 'Go to the next page' ),
|
||||
esc_url( add_query_arg( $query_var, min( $total_pages, $current+1 ), $current_url ) ),
|
||||
'»'
|
||||
);
|
||||
|
||||
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
|
||||
'last-page',
|
||||
esc_attr__( 'Go to the last page' ),
|
||||
esc_url( add_query_arg( $query_var, $total_pages, $current_url ) ),
|
||||
'»»'
|
||||
);
|
||||
|
||||
$output .= join( "\n", $page_links );
|
||||
|
||||
$this->_pagination = "<div class='tablenav-pages'>$output</div>";
|
||||
|
||||
echo $this->_pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of columns. The format is internal_name => title
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_columns() {
|
||||
die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of sortable columns. The format is internal_name => orderby
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_sortable_columns() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of hidden columns.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access private
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_hidden_columns() {
|
||||
return (array) get_user_option( 'manage' . $this->_screen->id. 'columnshidden' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all, hidden and sortable columns, with filter applied
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_column_headers() {
|
||||
if ( !isset( $this->_column_headers ) ) {
|
||||
$columns = apply_filters( 'manage_' . $this->_screen->id . '_columns', $this->get_columns() );
|
||||
$sortable = apply_filters( 'manage_' . $this->_screen->id . '_sortable_columns', $this->get_sortable_columns() );
|
||||
$hidden = $this->get_hidden_columns();
|
||||
|
||||
$this->_column_headers = array( $columns, $hidden, $sortable );
|
||||
}
|
||||
|
||||
return $this->_column_headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print column headers, accounting for hidden and sortable columns.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*/
|
||||
function print_column_headers( $with_id = true ) {
|
||||
$screen = $this->_screen;
|
||||
|
||||
list( $columns, $hidden, $sortable ) = $this->get_column_headers();
|
||||
|
||||
$styles = array();
|
||||
|
||||
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
|
||||
if ( isset( $_GET['orderby'] ) )
|
||||
$current_orderby = $_GET['orderby'];
|
||||
else
|
||||
$current_orderby = '';
|
||||
|
||||
if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] )
|
||||
$current_order = 'desc';
|
||||
else
|
||||
$current_order = 'asc';
|
||||
|
||||
foreach ( $columns as $column_key => $column_display_name ) {
|
||||
$class = array( 'manage-column', "column-$column_key" );
|
||||
|
||||
$style = '';
|
||||
if ( in_array( $column_key, $hidden ) )
|
||||
$style = 'display:none;';
|
||||
|
||||
if ( isset( $styles[$screen->id] ) && isset( $styles[$screen->id][$column_key] ) )
|
||||
$style .= ' ' . $styles[$screen->id][$column_key];
|
||||
$style = ' style="' . $style . '"';
|
||||
|
||||
if ( 'cb' == $column_key )
|
||||
$class[] = 'check-column';
|
||||
elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) )
|
||||
$class[] = 'num';
|
||||
|
||||
if ( isset( $sortable[$column_key] ) ) {
|
||||
$orderby = $sortable[$column_key];
|
||||
if ( $current_orderby == $orderby ) {
|
||||
$order = 'asc' == $current_order ? 'desc' : 'asc';
|
||||
$class[] = "sorted-$current_order";
|
||||
} else {
|
||||
$order = 'asc';
|
||||
$class[] = 'sortable';
|
||||
}
|
||||
$column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '">' . $column_display_name . '</a>';
|
||||
$column_display_name .= '<div class="sorting-indicator"></div>';
|
||||
}
|
||||
|
||||
$id = $with_id ? "id='$column_key'" : '';
|
||||
|
||||
if ( !empty( $class ) )
|
||||
$class = "class='" . join( ' ', $class ) . "'";
|
||||
|
||||
echo "<th scope='col' $id $class $style>$column_display_name</th>";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the table or a message if there are no items
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access public
|
||||
*/
|
||||
function display() {
|
||||
if ( $this->has_items() ) {
|
||||
$this->display_table();
|
||||
} else {
|
||||
echo '<br class="clear">';
|
||||
echo '<p>';
|
||||
$this->no_items();
|
||||
echo '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of CSS classes for the <table> tag
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_table_classes() {
|
||||
extract( $this->_args );
|
||||
|
||||
return array( 'widefat', 'fixed', $plural );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the full table
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access public
|
||||
*/
|
||||
function display_table() {
|
||||
extract( $this->_args );
|
||||
|
||||
$this->display_tablenav( 'top' );
|
||||
|
||||
?>
|
||||
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php $this->print_column_headers(); ?>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<?php $this->print_column_headers( false ); ?>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody id="the-list"<?php if ( $singular ) echo " class='list:$singular'"; ?>>
|
||||
<?php $this->display_rows(); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
|
||||
$this->display_tablenav( 'bottom' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the table navigation above or below the table
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*/
|
||||
function display_tablenav( $which ) {
|
||||
if ( 'top' == $which )
|
||||
wp_nonce_field( 'bulk-' . $this->_args['plural'] );
|
||||
?>
|
||||
<div class="tablenav">
|
||||
|
||||
<div class="alignleft actions">
|
||||
<?php $this->bulk_actions( $which ); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$this->extra_tablenav( $which );
|
||||
$this->pagination( $which );
|
||||
?>
|
||||
|
||||
<br class="clear">
|
||||
</div>
|
||||
|
||||
<br class="clear">
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Extra controls to be displayed between bulk actions and pagination
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*/
|
||||
function extra_tablenav( $which ) {}
|
||||
|
||||
/**
|
||||
* Generate the <tbody> part of the table
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*/
|
||||
function display_rows() {
|
||||
die( 'function WP_List_Table::display_rows() must be over-ridden in a sub-class.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming ajax request ( called from admin-ajax.php )
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function ajax_response() {
|
||||
extract( $this->_args );
|
||||
extract( $this->_pagination_args );
|
||||
|
||||
ob_start();
|
||||
$this->display_rows();
|
||||
$rows = ob_get_clean();
|
||||
|
||||
die( json_encode( array(
|
||||
'rows' => $rows,
|
||||
'total_items' => sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ),
|
||||
'total_pages' => $total_pages
|
||||
) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Send required variables to JavaScript land
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _js_vars() {
|
||||
extract( $this->_args );
|
||||
|
||||
$class = get_class( $this );
|
||||
|
||||
printf( "<script type='text/javascript'>list_args = %s;</script>\n",
|
||||
json_encode( compact( 'screen', 'class' ) )
|
||||
);
|
||||
}
|
||||
}
|
|
@ -344,6 +344,7 @@ function set_screen_options() {
|
|||
switch ( $map_option ) {
|
||||
case 'edit_per_page':
|
||||
case 'ms_sites_per_page':
|
||||
case 'users_per_page':
|
||||
case 'ms_users_per_page':
|
||||
case 'edit_comments_per_page':
|
||||
case 'upload_per_page':
|
||||
|
|
|
@ -78,48 +78,7 @@ function install_popular_tags( $args = array() ) {
|
|||
|
||||
return $tags;
|
||||
}
|
||||
add_action('install_plugins_search', 'install_search', 10, 1);
|
||||
|
||||
/**
|
||||
* Display search results and display as tag cloud.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $page
|
||||
*/
|
||||
function install_search($page) {
|
||||
$type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';
|
||||
$term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';
|
||||
|
||||
$args = array();
|
||||
|
||||
switch( $type ){
|
||||
case 'tag':
|
||||
$args['tag'] = sanitize_title_with_dashes($term);
|
||||
break;
|
||||
case 'term':
|
||||
$args['search'] = $term;
|
||||
break;
|
||||
case 'author':
|
||||
$args['author'] = $term;
|
||||
break;
|
||||
}
|
||||
|
||||
$args['page'] = $page;
|
||||
|
||||
$api = plugins_api('query_plugins', $args);
|
||||
|
||||
if ( is_wp_error($api) )
|
||||
wp_die($api);
|
||||
|
||||
add_action('install_plugins_table_header', 'install_search_form');
|
||||
|
||||
display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
add_action('install_plugins_dashboard', 'install_dashboard');
|
||||
function install_dashboard() {
|
||||
?>
|
||||
<p><?php _e('Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> or upload a plugin in .zip format via this page.') ?></p>
|
||||
|
@ -150,6 +109,7 @@ function install_dashboard() {
|
|||
}
|
||||
echo '</p><br class="clear" />';
|
||||
}
|
||||
add_action('install_plugins_dashboard', 'install_dashboard');
|
||||
|
||||
/**
|
||||
* Display search form for searching plugins.
|
||||
|
@ -160,7 +120,8 @@ function install_search_form(){
|
|||
$type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';
|
||||
$term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';
|
||||
|
||||
?><form id="search-plugins" method="post" action="<?php echo admin_url('plugin-install.php?tab=search'); ?>">
|
||||
?><form id="search-plugins" method="get" action="">
|
||||
<input type="hidden" name="tab" value="search" />
|
||||
<select name="type" id="typeselector">
|
||||
<option value="term"<?php selected('term', $type) ?>><?php _e('Term'); ?></option>
|
||||
<option value="author"<?php selected('author', $type) ?>><?php _e('Author'); ?></option>
|
||||
|
@ -168,43 +129,10 @@ function install_search_form(){
|
|||
</select>
|
||||
<input type="text" name="s" value="<?php echo esc_attr($term) ?>" />
|
||||
<label class="screen-reader-text" for="plugin-search-input"><?php _e('Search Plugins'); ?></label>
|
||||
<input type="submit" id="plugin-search-input" name="search" value="<?php esc_attr_e('Search Plugins'); ?>" class="button" />
|
||||
<input type="submit" id="plugin-search-input" value="<?php esc_attr_e('Search Plugins'); ?>" class="button" />
|
||||
</form><?php
|
||||
}
|
||||
|
||||
add_action('install_plugins_featured', 'install_featured', 10, 1);
|
||||
/**
|
||||
* Display featured plugins.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $page
|
||||
*/
|
||||
function install_featured($page = 1) {
|
||||
$args = array('browse' => 'featured', 'page' => $page);
|
||||
$api = plugins_api('query_plugins', $args);
|
||||
if ( is_wp_error($api) )
|
||||
wp_die($api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __('Try again') . '</a>');
|
||||
display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
|
||||
}
|
||||
|
||||
add_action('install_plugins_popular', 'install_popular', 10, 1);
|
||||
/**
|
||||
* Display popular plugins.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $page
|
||||
*/
|
||||
function install_popular($page = 1) {
|
||||
$args = array('browse' => 'popular', 'page' => $page);
|
||||
$api = plugins_api('query_plugins', $args);
|
||||
if ( is_wp_error($api) )
|
||||
wp_die($api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __('Try again') . '</a>');
|
||||
display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
|
||||
}
|
||||
|
||||
add_action('install_plugins_upload', 'install_plugins_upload', 10, 1);
|
||||
/**
|
||||
* Upload from zip
|
||||
* @since 2.8.0
|
||||
|
@ -223,39 +151,7 @@ function install_plugins_upload( $page = 1 ) {
|
|||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action('install_plugins_new', 'install_new', 10, 1);
|
||||
/**
|
||||
* Display new plugins.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $page
|
||||
*/
|
||||
function install_new($page = 1) {
|
||||
$args = array('browse' => 'new', 'page' => $page);
|
||||
$api = plugins_api('query_plugins', $args);
|
||||
if ( is_wp_error($api) )
|
||||
wp_die($api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __('Try again') . '</a>');
|
||||
display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
|
||||
}
|
||||
add_action('install_plugins_updated', 'install_updated', 10, 1);
|
||||
|
||||
|
||||
/**
|
||||
* Display recently updated plugins.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $page
|
||||
*/
|
||||
function install_updated($page = 1) {
|
||||
$args = array('browse' => 'updated', 'page' => $page);
|
||||
$api = plugins_api('query_plugins', $args);
|
||||
if ( is_wp_error($api) )
|
||||
wp_die($api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __('Try again') . '</a>');
|
||||
display_plugins_table($api->plugins, $api->info['page'], $api->info['pages']);
|
||||
}
|
||||
add_action('install_plugins_upload', 'install_plugins_upload', 10, 1);
|
||||
|
||||
/**
|
||||
* Display plugin content based on plugin list.
|
||||
|
@ -263,153 +159,18 @@ function install_updated($page = 1) {
|
|||
* @since 2.7.0
|
||||
*
|
||||
* @param array $plugins List of plugins.
|
||||
* @param string $page
|
||||
* @param int $totalpages Number of pages.
|
||||
* @param int $total_plugins Number of plugins.
|
||||
*/
|
||||
function display_plugins_table($plugins, $page = 1, $totalpages = 1){
|
||||
$type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';
|
||||
$term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';
|
||||
function display_plugins_table() {
|
||||
global $table;
|
||||
|
||||
$plugins_allowedtags = array('a' => array('href' => array(),'title' => array(), 'target' => array()),
|
||||
'abbr' => array('title' => array()),'acronym' => array('title' => array()),
|
||||
'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array(),
|
||||
'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array());
|
||||
|
||||
?>
|
||||
<div class="tablenav">
|
||||
<div class="alignleft actions">
|
||||
<?php do_action('install_plugins_table_header'); ?>
|
||||
</div>
|
||||
<?php
|
||||
$url = esc_url($_SERVER['REQUEST_URI']);
|
||||
if ( ! empty($term) )
|
||||
$url = add_query_arg('s', $term, $url);
|
||||
if ( ! empty($type) )
|
||||
$url = add_query_arg('type', $type, $url);
|
||||
|
||||
$page_links = paginate_links( array(
|
||||
'base' => add_query_arg('paged', '%#%', $url),
|
||||
'format' => '',
|
||||
'prev_text' => __('«'),
|
||||
'next_text' => __('»'),
|
||||
'total' => $totalpages,
|
||||
'current' => $page
|
||||
));
|
||||
|
||||
if ( $page_links )
|
||||
echo "\t\t<div class='tablenav-pages'>$page_links</div>";
|
||||
?>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
<table class="widefat" id="install-plugins" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="name"><?php _e('Name'); ?></th>
|
||||
<th scope="col" class="num"><?php _e('Version'); ?></th>
|
||||
<th scope="col" class="num"><?php _e('Rating'); ?></th>
|
||||
<th scope="col" class="desc"><?php _e('Description'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th scope="col" class="name"><?php _e('Name'); ?></th>
|
||||
<th scope="col" class="num"><?php _e('Version'); ?></th>
|
||||
<th scope="col" class="num"><?php _e('Rating'); ?></th>
|
||||
<th scope="col" class="desc"><?php _e('Description'); ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody class="plugins">
|
||||
<?php
|
||||
if ( empty($plugins) )
|
||||
echo '<tr><td colspan="5">', __('No plugins match your request.'), '</td></tr>';
|
||||
|
||||
foreach ( (array) $plugins as $plugin ){
|
||||
if ( is_object($plugin) )
|
||||
$plugin = (array) $plugin;
|
||||
|
||||
$title = wp_kses($plugin['name'], $plugins_allowedtags);
|
||||
//Limit description to 400char, and remove any HTML.
|
||||
$description = strip_tags($plugin['description']);
|
||||
if ( strlen($description) > 400 )
|
||||
$description = mb_substr($description, 0, 400) . '…';
|
||||
//remove any trailing entities
|
||||
$description = preg_replace('/&[^;\s]{0,6}$/', '', $description);
|
||||
//strip leading/trailing & multiple consecutive lines
|
||||
$description = trim($description);
|
||||
$description = preg_replace("|(\r?\n)+|", "\n", $description);
|
||||
//\n => <br>
|
||||
$description = nl2br($description);
|
||||
$version = wp_kses($plugin['version'], $plugins_allowedtags);
|
||||
|
||||
$name = strip_tags($title . ' ' . $version);
|
||||
|
||||
$author = $plugin['author'];
|
||||
if ( ! empty($plugin['author']) )
|
||||
$author = ' <cite>' . sprintf( __('By %s'), $author ) . '.</cite>';
|
||||
|
||||
$author = wp_kses($author, $plugins_allowedtags);
|
||||
|
||||
$action_links = array();
|
||||
$action_links[] = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] .
|
||||
'&TB_iframe=true&width=600&height=550') . '" class="thickbox" title="' .
|
||||
esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '">' . __('Details') . '</a>';
|
||||
|
||||
if ( current_user_can('install_plugins') || current_user_can('update_plugins') ) {
|
||||
$status = install_plugin_install_status($plugin);
|
||||
|
||||
switch ( $status['status'] ) {
|
||||
case 'install':
|
||||
if ( $status['url'] )
|
||||
$action_links[] = '<a class="install-now" href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __('Install Now') . '</a>';
|
||||
break;
|
||||
case 'update_available':
|
||||
if ( $status['url'] )
|
||||
$action_links[] = '<a href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $status['version'] ) ) . '">' . sprintf( __('Update Now'), $status['version'] ) . '</a>';
|
||||
break;
|
||||
case 'latest_installed':
|
||||
case 'newer_installed':
|
||||
$action_links[] = '<span title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . __('Installed') . '</span>';
|
||||
break;
|
||||
$table->display();
|
||||
}
|
||||
}
|
||||
|
||||
$action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin );
|
||||
?>
|
||||
<tr>
|
||||
<td class="name"><strong><?php echo $title; ?></strong>
|
||||
<div class="action-links"><?php if ( !empty($action_links) ) echo implode(' | ', $action_links); ?></div>
|
||||
</td>
|
||||
<td class="vers"><?php echo $version; ?></td>
|
||||
<td class="vers">
|
||||
<div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $plugin['num_ratings']), number_format_i18n($plugin['num_ratings'])) ?>">
|
||||
<div class="star star-rating" style="width: <?php echo esc_attr($plugin['rating']) ?>px"></div>
|
||||
<div class="star star5"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('5 stars') ?>" /></div>
|
||||
<div class="star star4"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('4 stars') ?>" /></div>
|
||||
<div class="star star3"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('3 stars') ?>" /></div>
|
||||
<div class="star star2"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('2 stars') ?>" /></div>
|
||||
<div class="star star1"><img src="<?php echo admin_url('images/star.gif'); ?>" alt="<?php _e('1 star') ?>" /></div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="desc"><?php echo $description, $author; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="tablenav">
|
||||
<?php if ( $page_links )
|
||||
echo "\t\t<div class='tablenav-pages'>$page_links</div>"; ?>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action('install_plugins_pre_plugin-information', 'install_plugin_information');
|
||||
add_action('install_plugins_search', 'display_plugins_table');
|
||||
add_action('install_plugins_featured', 'display_plugins_table');
|
||||
add_action('install_plugins_popular', 'display_plugins_table');
|
||||
add_action('install_plugins_new', 'display_plugins_table');
|
||||
add_action('install_plugins_updated', 'display_plugins_table');
|
||||
|
||||
/**
|
||||
* Determine the status we can perform on a plugin.
|
||||
|
@ -608,3 +369,5 @@ function install_plugin_information() {
|
|||
iframe_footer();
|
||||
exit;
|
||||
}
|
||||
add_action('install_plugins_pre_plugin-information', 'install_plugin_information');
|
||||
|
||||
|
|
|
@ -880,16 +880,15 @@ function wp_edit_posts_query( $q = false ) {
|
|||
$perm = 'readable';
|
||||
}
|
||||
|
||||
if ( isset($q['post_status']) && 'pending' === $q['post_status'] ) {
|
||||
if ( isset($q['orderby']) )
|
||||
$orderby = $q['orderby'];
|
||||
elseif ( isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft')) )
|
||||
$orderby = 'modified';
|
||||
|
||||
if ( isset($q['order']) )
|
||||
$order = $q['order'];
|
||||
elseif ( isset($q['post_status']) && 'pending' == $q['post_status'] )
|
||||
$order = 'ASC';
|
||||
$orderby = 'modified';
|
||||
} elseif ( isset($q['post_status']) && 'draft' === $q['post_status'] ) {
|
||||
$order = 'DESC';
|
||||
$orderby = 'modified';
|
||||
} else {
|
||||
$order = 'DESC';
|
||||
$orderby = 'date';
|
||||
}
|
||||
|
||||
$per_page = 'edit_' . $post_type . '_per_page';
|
||||
$posts_per_page = (int) get_user_option( $per_page );
|
||||
|
@ -902,7 +901,7 @@ function wp_edit_posts_query( $q = false ) {
|
|||
$query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page');
|
||||
|
||||
// Hierarchical types require special args.
|
||||
if ( is_post_type_hierarchical( $post_type ) ) {
|
||||
if ( is_post_type_hierarchical( $post_type ) && !isset($orderby) ) {
|
||||
$query['orderby'] = 'menu_order title';
|
||||
$query['order'] = 'asc';
|
||||
$query['posts_per_page'] = -1;
|
||||
|
@ -973,11 +972,21 @@ function wp_edit_attachments_query( $q = false ) {
|
|||
if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) )
|
||||
unset($q['post_mime_type']);
|
||||
|
||||
if ( isset($q['detached']) )
|
||||
add_filter('posts_where', '_edit_attachments_query_helper');
|
||||
|
||||
wp($q);
|
||||
|
||||
if ( isset($q['detached']) )
|
||||
remove_filter('posts_where', '_edit_attachments_query_helper');
|
||||
|
||||
return array($post_mime_types, $avail_post_mime_types);
|
||||
}
|
||||
|
||||
function _edit_attachments_query_helper($where) {
|
||||
return $where .= ' AND post_parent < 1';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -88,59 +88,6 @@ function install_themes_feature_list( ) {
|
|||
return $feature_list;
|
||||
}
|
||||
|
||||
add_action('install_themes_search', 'install_theme_search', 10, 1);
|
||||
/**
|
||||
* Display theme search results
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string $page
|
||||
*/
|
||||
function install_theme_search($page) {
|
||||
global $theme_field_defaults;
|
||||
|
||||
$type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';
|
||||
$term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';
|
||||
|
||||
$args = array();
|
||||
|
||||
switch( $type ){
|
||||
case 'tag':
|
||||
$terms = explode(',', $term);
|
||||
$terms = array_map('trim', $terms);
|
||||
$terms = array_map('sanitize_title_with_dashes', $terms);
|
||||
$args['tag'] = $terms;
|
||||
break;
|
||||
case 'term':
|
||||
$args['search'] = $term;
|
||||
break;
|
||||
case 'author':
|
||||
$args['author'] = $term;
|
||||
break;
|
||||
}
|
||||
|
||||
$args['page'] = $page;
|
||||
$args['fields'] = $theme_field_defaults;
|
||||
|
||||
if ( !empty( $_POST['features'] ) ) {
|
||||
$terms = $_POST['features'];
|
||||
$terms = array_map( 'trim', $terms );
|
||||
$terms = array_map( 'sanitize_title_with_dashes', $terms );
|
||||
$args['tag'] = $terms;
|
||||
$_REQUEST['s'] = implode( ',', $terms );
|
||||
$_REQUEST['type'] = 'tag';
|
||||
}
|
||||
|
||||
$api = themes_api('query_themes', $args);
|
||||
|
||||
if ( is_wp_error($api) )
|
||||
wp_die($api);
|
||||
|
||||
add_action('install_themes_table_header', 'install_theme_search_form');
|
||||
|
||||
display_themes($api->themes, $api->info['page'], $api->info['pages']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display search form for searching themes.
|
||||
*
|
||||
|
@ -152,7 +99,8 @@ function install_theme_search_form() {
|
|||
?>
|
||||
<p class="install-help"><?php _e('Search for themes by keyword, author, or tag.') ?></p>
|
||||
|
||||
<form id="search-themes" method="post" action="<?php echo admin_url( 'theme-install.php?tab=search' ); ?>">
|
||||
<form id="search-themes" method="get" action="">
|
||||
<input type="hidden" name="tab" value="search" />
|
||||
<select name="type" id="typeselector">
|
||||
<option value="term" <?php selected('term', $type) ?>><?php _e('Term'); ?></option>
|
||||
<option value="author" <?php selected('author', $type) ?>><?php _e('Author'); ?></option>
|
||||
|
@ -164,7 +112,6 @@ function install_theme_search_form() {
|
|||
<?php
|
||||
}
|
||||
|
||||
add_action('install_themes_dashboard', 'install_themes_dashboard');
|
||||
/**
|
||||
* Display tags filter for themes.
|
||||
*
|
||||
|
@ -222,57 +169,8 @@ function install_themes_dashboard() {
|
|||
</form>
|
||||
<?php
|
||||
}
|
||||
add_action('install_themes_dashboard', 'install_themes_dashboard');
|
||||
|
||||
add_action('install_themes_featured', 'install_themes_featured', 10, 1);
|
||||
/**
|
||||
* Display featured themes.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string $page
|
||||
*/
|
||||
function install_themes_featured($page = 1) {
|
||||
global $theme_field_defaults;
|
||||
$args = array('browse' => 'featured', 'page' => $page, 'fields' => $theme_field_defaults);
|
||||
$api = themes_api('query_themes', $args);
|
||||
if ( is_wp_error($api) )
|
||||
wp_die($api);
|
||||
display_themes($api->themes, $api->info['page'], $api->info['pages']);
|
||||
}
|
||||
|
||||
add_action('install_themes_new', 'install_themes_new', 10, 1);
|
||||
/**
|
||||
* Display new themes/
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string $page
|
||||
*/
|
||||
function install_themes_new($page = 1) {
|
||||
global $theme_field_defaults;
|
||||
$args = array('browse' => 'new', 'page' => $page, 'fields' => $theme_field_defaults);
|
||||
$api = themes_api('query_themes', $args);
|
||||
if ( is_wp_error($api) )
|
||||
wp_die($api);
|
||||
display_themes($api->themes, $api->info['page'], $api->info['pages']);
|
||||
}
|
||||
|
||||
add_action('install_themes_updated', 'install_themes_updated', 10, 1);
|
||||
/**
|
||||
* Display recently updated themes.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string $page
|
||||
*/
|
||||
function install_themes_updated($page = 1) {
|
||||
global $theme_field_defaults;
|
||||
$args = array('browse' => 'updated', 'page' => $page, 'fields' => $theme_field_defaults);
|
||||
$api = themes_api('query_themes', $args);
|
||||
display_themes($api->themes, $api->info['page'], $api->info['pages']);
|
||||
}
|
||||
|
||||
add_action('install_themes_upload', 'install_themes_upload', 10, 1);
|
||||
function install_themes_upload($page = 1) {
|
||||
?>
|
||||
<h4><?php _e('Install a theme in .zip format') ?></h4>
|
||||
|
@ -285,6 +183,7 @@ function install_themes_upload($page = 1) {
|
|||
</form>
|
||||
<?php
|
||||
}
|
||||
add_action('install_themes_upload', 'install_themes_upload', 10, 1);
|
||||
|
||||
function display_theme($theme, $actions = null, $show_details = true) {
|
||||
global $themes_allowedtags;
|
||||
|
@ -360,83 +259,16 @@ function display_theme($theme, $actions = null, $show_details = true) {
|
|||
* Display theme content based on theme list.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param array $themes List of themes.
|
||||
* @param string $page
|
||||
* @param int $totalpages Number of pages.
|
||||
*/
|
||||
function display_themes($themes, $page = 1, $totalpages = 1) {
|
||||
$type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';
|
||||
$term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';
|
||||
?>
|
||||
<div class="tablenav">
|
||||
<div class="alignleft actions"><?php do_action('install_themes_table_header'); ?></div>
|
||||
<?php
|
||||
$url = esc_url($_SERVER['REQUEST_URI']);
|
||||
if ( ! empty($term) )
|
||||
$url = add_query_arg('s', $term, $url);
|
||||
if ( ! empty($type) )
|
||||
$url = add_query_arg('type', $type, $url);
|
||||
function display_themes() {
|
||||
global $table;
|
||||
|
||||
$page_links = paginate_links( array(
|
||||
'base' => add_query_arg('paged', '%#%', $url),
|
||||
'format' => '',
|
||||
'prev_text' => __('«'),
|
||||
'next_text' => __('»'),
|
||||
'total' => $totalpages,
|
||||
'current' => $page
|
||||
));
|
||||
|
||||
if ( $page_links )
|
||||
echo "\t\t<div class='tablenav-pages'>$page_links</div>";
|
||||
?>
|
||||
</div>
|
||||
<br class="clear" />
|
||||
<?php
|
||||
if ( empty($themes) ) {
|
||||
_e('No themes found');
|
||||
return;
|
||||
$table->display();
|
||||
}
|
||||
?>
|
||||
<table id="availablethemes" cellspacing="0" cellpadding="0">
|
||||
<?php
|
||||
$rows = ceil(count($themes) / 3);
|
||||
$table = array();
|
||||
$theme_keys = array_keys($themes);
|
||||
for ( $row = 1; $row <= $rows; $row++ )
|
||||
for ( $col = 1; $col <= 3; $col++ )
|
||||
$table[$row][$col] = array_shift($theme_keys);
|
||||
|
||||
foreach ( $table as $row => $cols ) {
|
||||
?>
|
||||
<tr>
|
||||
<?php
|
||||
|
||||
foreach ( $cols as $col => $theme_index ) {
|
||||
$class = array('available-theme');
|
||||
if ( $row == 1 ) $class[] = 'top';
|
||||
if ( $col == 1 ) $class[] = 'left';
|
||||
if ( $row == $rows ) $class[] = 'bottom';
|
||||
if ( $col == 3 ) $class[] = 'right';
|
||||
?>
|
||||
<td class="<?php echo join(' ', $class); ?>"><?php
|
||||
if ( isset($themes[$theme_index]) )
|
||||
display_theme($themes[$theme_index]);
|
||||
?></td>
|
||||
<?php } // end foreach $cols ?>
|
||||
</tr>
|
||||
<?php } // end foreach $table ?>
|
||||
</table>
|
||||
|
||||
<div class="tablenav"><?php if ( $page_links )
|
||||
echo "\t\t<div class='tablenav-pages'>$page_links</div>"; ?> <br
|
||||
class="clear" />
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action('install_themes_pre_theme-information', 'install_theme_information');
|
||||
add_action('install_themes_search', 'display_themes');
|
||||
add_action('install_themes_featured', 'display_themes');
|
||||
add_action('install_themes_new', 'display_themes');
|
||||
add_action('install_themes_updated', 'display_themes');
|
||||
|
||||
/**
|
||||
* Display theme information in dialog box form.
|
||||
|
@ -546,3 +378,5 @@ case 'latest_installed':
|
|||
iframe_footer();
|
||||
exit;
|
||||
}
|
||||
add_action('install_themes_pre_theme-information', 'install_theme_information');
|
||||
|
||||
|
|
|
@ -482,343 +482,6 @@ function wp_revoke_user($id) {
|
|||
$user->remove_all_caps();
|
||||
}
|
||||
|
||||
if ( !class_exists('WP_User_Search') ) :
|
||||
/**
|
||||
* WordPress User Search class.
|
||||
*
|
||||
* @since unknown
|
||||
*/
|
||||
class WP_User_Search {
|
||||
|
||||
/**
|
||||
* {@internal Missing Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access private
|
||||
* @var unknown_type
|
||||
*/
|
||||
var $results;
|
||||
|
||||
/**
|
||||
* {@internal Missing Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access private
|
||||
* @var unknown_type
|
||||
*/
|
||||
var $search_term;
|
||||
|
||||
/**
|
||||
* Page number.
|
||||
*
|
||||
* @since unknown
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
var $page;
|
||||
|
||||
/**
|
||||
* Role name that users have.
|
||||
*
|
||||
* @since unknown
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
var $role;
|
||||
|
||||
/**
|
||||
* Raw page number.
|
||||
*
|
||||
* @since unknown
|
||||
* @access private
|
||||
* @var int|bool
|
||||
*/
|
||||
var $raw_page;
|
||||
|
||||
/**
|
||||
* Amount of users to display per page.
|
||||
*
|
||||
* @since unknown
|
||||
* @access public
|
||||
* @var int
|
||||
*/
|
||||
var $users_per_page = 50;
|
||||
|
||||
/**
|
||||
* {@internal Missing Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access private
|
||||
* @var unknown_type
|
||||
*/
|
||||
var $first_user;
|
||||
|
||||
/**
|
||||
* {@internal Missing Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
var $last_user;
|
||||
|
||||
/**
|
||||
* {@internal Missing Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
var $query_limit;
|
||||
|
||||
/**
|
||||
* {@internal Missing Description}}
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
var $query_orderby;
|
||||
|
||||
/**
|
||||
* {@internal Missing Description}}
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
var $query_from;
|
||||
|
||||
/**
|
||||
* {@internal Missing Description}}
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
var $query_where;
|
||||
|
||||
/**
|
||||
* {@internal Missing Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
var $total_users_for_query = 0;
|
||||
|
||||
/**
|
||||
* {@internal Missing Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access private
|
||||
* @var bool
|
||||
*/
|
||||
var $too_many_total_users = false;
|
||||
|
||||
/**
|
||||
* {@internal Missing Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access private
|
||||
* @var unknown_type
|
||||
*/
|
||||
var $search_errors;
|
||||
|
||||
/**
|
||||
* {@internal Missing Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access private
|
||||
* @var unknown_type
|
||||
*/
|
||||
var $paging_text;
|
||||
|
||||
/**
|
||||
* PHP4 Constructor - Sets up the object properties.
|
||||
*
|
||||
* @since unknown
|
||||
*
|
||||
* @param string $search_term Search terms string.
|
||||
* @param int $page Optional. Page ID.
|
||||
* @param string $role Role name.
|
||||
* @return WP_User_Search
|
||||
*/
|
||||
function WP_User_Search ($search_term = '', $page = '', $role = '') {
|
||||
$this->search_term = $search_term;
|
||||
$this->raw_page = ( '' == $page ) ? false : (int) $page;
|
||||
$this->page = (int) ( '' == $page ) ? 1 : $page;
|
||||
$this->role = $role;
|
||||
|
||||
$this->prepare_query();
|
||||
$this->query();
|
||||
$this->prepare_vars_for_template_usage();
|
||||
$this->do_paging();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access public
|
||||
*/
|
||||
function prepare_query() {
|
||||
global $wpdb;
|
||||
$this->first_user = ($this->page - 1) * $this->users_per_page;
|
||||
|
||||
$this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page);
|
||||
$this->query_orderby = ' ORDER BY user_login';
|
||||
|
||||
$search_sql = '';
|
||||
if ( $this->search_term ) {
|
||||
$searches = array();
|
||||
$search_sql = 'AND (';
|
||||
foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
|
||||
$searches[] = $col . " LIKE '%$this->search_term%'";
|
||||
$search_sql .= implode(' OR ', $searches);
|
||||
$search_sql .= ')';
|
||||
}
|
||||
|
||||
$this->query_from = " FROM $wpdb->users";
|
||||
$this->query_where = " WHERE 1=1 $search_sql";
|
||||
|
||||
if ( $this->role ) {
|
||||
$this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
|
||||
$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
|
||||
} elseif ( is_multisite() ) {
|
||||
$level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
|
||||
$this->query_from .= ", $wpdb->usermeta";
|
||||
$this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
|
||||
}
|
||||
|
||||
do_action_ref_array( 'pre_user_search', array( &$this ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access public
|
||||
*/
|
||||
function query() {
|
||||
global $wpdb;
|
||||
|
||||
$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
|
||||
|
||||
if ( $this->results )
|
||||
$this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
|
||||
else
|
||||
$this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access public
|
||||
*/
|
||||
function prepare_vars_for_template_usage() {
|
||||
$this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access public
|
||||
*/
|
||||
function do_paging() {
|
||||
if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
|
||||
$args = array();
|
||||
if( ! empty($this->search_term) )
|
||||
$args['usersearch'] = urlencode($this->search_term);
|
||||
if( ! empty($this->role) )
|
||||
$args['role'] = urlencode($this->role);
|
||||
|
||||
$this->paging_text = paginate_links( array(
|
||||
'total' => ceil($this->total_users_for_query / $this->users_per_page),
|
||||
'current' => $this->page,
|
||||
'base' => 'users.php?%_%',
|
||||
'format' => 'userspage=%#%',
|
||||
'add_args' => $args
|
||||
) );
|
||||
if ( $this->paging_text ) {
|
||||
$this->paging_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
|
||||
number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
|
||||
number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
|
||||
number_format_i18n( $this->total_users_for_query ),
|
||||
$this->paging_text
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
*
|
||||
* @since unknown
|
||||
* @access public
|
||||
*
|
||||
* @return unknown
|
||||
*/
|
||||
function get_results() {
|
||||
return (array) $this->results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displaying paging text.
|
||||
*
|
||||
* @see do_paging() Builds paging text.
|
||||
*
|
||||
* @since unknown
|
||||
* @access public
|
||||
*/
|
||||
function page_links() {
|
||||
echo $this->paging_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether paging is enabled.
|
||||
*
|
||||
* @see do_paging() Builds paging text.
|
||||
*
|
||||
* @since unknown
|
||||
* @access public
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function results_are_paged() {
|
||||
if ( $this->paging_text )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether there are search terms.
|
||||
*
|
||||
* @since unknown
|
||||
* @access public
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_search() {
|
||||
if ( $this->search_term )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
add_action('admin_init', 'default_password_nag_handler');
|
||||
function default_password_nag_handler($errors = false) {
|
||||
global $user_ID;
|
||||
|
|
|
@ -0,0 +1,243 @@
|
|||
jQuery(document).ready(function($) {
|
||||
$('form').each(function() {
|
||||
this.reset();
|
||||
});
|
||||
|
||||
if ( '' == $.query.GET('paged') )
|
||||
$.query.SET('paged', 1);
|
||||
|
||||
var total_pages;
|
||||
var set_total_pages = function() {
|
||||
total_pages = parseInt($('.total-pages').eq(0).text());
|
||||
}
|
||||
|
||||
set_total_pages();
|
||||
|
||||
var loading = false,
|
||||
$tbody = $('#the-list, #the-comment-list'),
|
||||
$overlay = $('<div id="loading-items>')
|
||||
.html(adminTableL10n.loading)
|
||||
.hide()
|
||||
.prependTo($('body'));
|
||||
|
||||
var show_overlay = function() {
|
||||
loading = true;
|
||||
|
||||
$('.error.ajax').remove();
|
||||
|
||||
$overlay
|
||||
.css({
|
||||
width: $tbody.width() + 'px',
|
||||
height: $tbody.height() - 20 + 'px'
|
||||
})
|
||||
.css($tbody.offset())
|
||||
.show();
|
||||
}
|
||||
|
||||
var hide_overlay = function() {
|
||||
loading = false;
|
||||
$overlay.hide();
|
||||
}
|
||||
|
||||
var handle_error = function() {
|
||||
hide_overlay();
|
||||
|
||||
$('h2').after('<div class="error ajax below-h2"><p>' + adminTableL10n.error + '</p></div>');
|
||||
}
|
||||
|
||||
var update_rows = function(args, reset_paging, callback) {
|
||||
if ( loading )
|
||||
return false;
|
||||
|
||||
var different = false;
|
||||
|
||||
$.each(args, function(key, val) {
|
||||
if ( val != $.query.GET(key) ) {
|
||||
$.query.SET(key, val);
|
||||
different = true;
|
||||
}
|
||||
});
|
||||
|
||||
if ( !different )
|
||||
return false;
|
||||
|
||||
show_overlay();
|
||||
|
||||
if ( reset_paging )
|
||||
$.query.SET('paged', 1);
|
||||
|
||||
var data = $.query.get();
|
||||
|
||||
data['action'] = 'fetch-list';
|
||||
data['list_args'] = list_args;
|
||||
|
||||
$.ajax({
|
||||
url: 'admin-ajax.php',
|
||||
global: false,
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
success: function(response) {
|
||||
if ( 'object' != typeof response ) {
|
||||
handle_error();
|
||||
} else {
|
||||
hide_overlay();
|
||||
|
||||
$tbody.html(response.rows);
|
||||
|
||||
$('.displaying-num').html(response.total_items);
|
||||
|
||||
$('.total-pages').html(response.total_pages);
|
||||
set_total_pages();
|
||||
|
||||
$('.current-page').val($.query.GET('paged'));
|
||||
|
||||
if ( callback )
|
||||
callback();
|
||||
}
|
||||
},
|
||||
error: handle_error
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// paging
|
||||
var change_page = function(paged) {
|
||||
if ( paged < 1 || paged > total_pages )
|
||||
return false;
|
||||
|
||||
update_rows({'paged': paged});
|
||||
}
|
||||
|
||||
$('.tablenav-pages a').click(function() {
|
||||
var paged = $.query.GET('paged');
|
||||
|
||||
switch ( $(this).attr('class') ) {
|
||||
case 'first-page':
|
||||
paged = 1;
|
||||
break;
|
||||
case 'prev-page':
|
||||
paged -= 1;
|
||||
break;
|
||||
case 'next-page':
|
||||
paged += 1;
|
||||
break;
|
||||
case 'last-page':
|
||||
paged = total_pages;
|
||||
break;
|
||||
}
|
||||
|
||||
change_page(paged);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.current-page').keypress(function(e) {
|
||||
if ( 13 != e.keyCode )
|
||||
return;
|
||||
|
||||
change_page(parseInt($(this).val()));
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// sorting
|
||||
$('th a').click(function() {
|
||||
var orderby = $.query.GET('orderby'),
|
||||
order = $.query.GET('order'),
|
||||
$th = $(this).parent('th');
|
||||
|
||||
if ( $th.hasClass('sortable') ) {
|
||||
orderby = $.query.load($(this).attr('href')).get('orderby');
|
||||
order = 'asc';
|
||||
|
||||
$('th.sorted-desc, th.sorted-asc')
|
||||
.removeClass('sorted-asc')
|
||||
.removeClass('sorted-desc')
|
||||
.addClass('sortable');
|
||||
|
||||
$th.removeClass('sortable').addClass('sorted-asc');
|
||||
}
|
||||
else if ( $th.hasClass('sorted-asc') ) {
|
||||
order = 'desc';
|
||||
$th.removeClass('sorted-asc').addClass('sorted-desc');
|
||||
}
|
||||
else if ( $th.hasClass('sorted-desc') ) {
|
||||
order = 'asc';
|
||||
$th.removeClass('sorted-desc').addClass('sorted-asc');
|
||||
}
|
||||
|
||||
update_rows({'orderby': orderby, 'order': order}, true);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// searching
|
||||
var htmlencode = function(value) {
|
||||
return $('<div/>').text(value).html();
|
||||
}
|
||||
|
||||
var change_search = function(s) {
|
||||
update_rows({'s': s}, true, function() {
|
||||
$('h2 .subtitle').remove();
|
||||
|
||||
if ( s )
|
||||
$('h2').eq(0).append($('<span class="subtitle">').html(adminTableL10n.search.replace('%s', htmlencode(s))));
|
||||
});
|
||||
}
|
||||
|
||||
$('.search-box :submit').click(function() {
|
||||
change_search($(this).parent('.search-box').find(':text').val());
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.search-box :text').keypress(function(e) {
|
||||
if ( 13 != e.keyCode )
|
||||
return;
|
||||
|
||||
change_search($(this).val());
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// tablenav dropdowns
|
||||
$('#post-query-submit').click(function() {
|
||||
var $this = $(this), key, val, args = {};
|
||||
|
||||
$this.parents('.actions').find('select[name!="action"]').each(function() {
|
||||
args[$this.attr('name')] = $this.val();
|
||||
});
|
||||
|
||||
update_rows(args, true);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// view switch
|
||||
$('.view-switch a').click(function() {
|
||||
var $this = $(this);
|
||||
|
||||
update_rows({'mode': $.query.load($this.attr('href')).get('mode')}, false, function() {
|
||||
$('.view-switch .current').removeClass('current');
|
||||
$this.addClass('current');
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/*
|
||||
// problem: when switching from one to the other, columns are not always the same
|
||||
$('.subsubsub a').click(function() {
|
||||
var $this = $(this);
|
||||
|
||||
update_rows($.query.load($this.attr('href')).get(), true, function() {
|
||||
$('.subsubsub .current').removeClass('current');
|
||||
$this.addClass('current');
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
/**/
|
||||
});
|
||||
|
|
@ -0,0 +1 @@
|
|||
jQuery(document).ready(function($){$("form").each(function(){this.reset()});if(""==$.query.GET("paged")){$.query.SET("paged",1)}var total_pages;var set_total_pages=function(){total_pages=parseInt($(".total-pages").eq(0).text())};set_total_pages();var loading=false,$tbody=$("#the-list, #the-comment-list"),$overlay=$('<div id="loading-items>').html(adminTableL10n.loading).hide().prependTo($("body"));var show_overlay=function(){loading=true;$(".error.ajax").remove();$overlay.css({width:$tbody.width()+"px",height:$tbody.height()-20+"px"}).css($tbody.offset()).show()};var hide_overlay=function(){loading=false;$overlay.hide()};var handle_error=function(){hide_overlay();$("h2").after('<div class="error ajax below-h2"><p>'+adminTableL10n.error+"</p></div>")};var update_rows=function(args,reset_paging,callback){if(loading){return false}var different=false;$.each(args,function(key,val){if(val!=$.query.GET(key)){$.query.SET(key,val);different=true}});if(!different){return false}show_overlay();if(reset_paging){$.query.SET("paged",1)}var data=$.query.get();data.action="fetch-list";data.list_args=list_args;$.ajax({url:"admin-ajax.php",global:false,dataType:"json",data:data,success:function(response){if("object"!=typeof response){handle_error()}else{hide_overlay();$tbody.html(response.rows);$(".displaying-num").html(response.total_items);$(".total-pages").html(response.total_pages);set_total_pages();$(".current-page").val($.query.GET("paged"));if(callback){callback()}}},error:handle_error});return true};var change_page=function(paged){if(paged<1||paged>total_pages){return false}update_rows({paged:paged})};$(".tablenav-pages a").click(function(){var paged=$.query.GET("paged");switch($(this).attr("class")){case"first-page":paged=1;break;case"prev-page":paged-=1;break;case"next-page":paged+=1;break;case"last-page":paged=total_pages;break}change_page(paged);return false});$(".current-page").keypress(function(e){if(13!=e.keyCode){return}change_page(parseInt($(this).val()));return false});$("th a").click(function(){var orderby=$.query.GET("orderby"),order=$.query.GET("order"),$th=$(this).parent("th");if($th.hasClass("sortable")){orderby=$.query.load($(this).attr("href")).get("orderby");order="asc";$("th.sorted-desc, th.sorted-asc").removeClass("sorted-asc").removeClass("sorted-desc").addClass("sortable");$th.removeClass("sortable").addClass("sorted-asc")}else{if($th.hasClass("sorted-asc")){order="desc";$th.removeClass("sorted-asc").addClass("sorted-desc")}else{if($th.hasClass("sorted-desc")){order="asc";$th.removeClass("sorted-desc").addClass("sorted-asc")}}}update_rows({orderby:orderby,order:order},true);return false});var htmlencode=function(value){return $("<div/>").text(value).html()};var change_search=function(s){update_rows({s:s},true,function(){$("h2 .subtitle").remove();if(s){$("h2").eq(0).append($('<span class="subtitle">').html(adminTableL10n.search.replace("%s",htmlencode(s))))}})};$(".search-box :submit").click(function(){change_search($(this).parent(".search-box").find(":text").val());return false});$(".search-box :text").keypress(function(e){if(13!=e.keyCode){return}change_search($(this).val());return false});$("#post-query-submit").click(function(){var $this=$(this),key,val,args={};$this.parents(".actions").find('select[name!="action"]').each(function(){args[$this.attr("name")]=$this.val()});update_rows(args,true);return false});$(".view-switch a").click(function(){var $this=$(this);update_rows({mode:$.query.load($this.attr("href")).get("mode")},false,function(){$(".view-switch .current").removeClass("current");$this.addClass("current")});return false})});
|
|
@ -1,22 +1,36 @@
|
|||
|
||||
(function($) {
|
||||
inlineEditPost = {
|
||||
|
||||
init : function(){
|
||||
var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
|
||||
|
||||
t.type = $('table.widefat').hasClass('page') ? 'page' : 'post';
|
||||
t.what = '#'+t.type+'-';
|
||||
t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post';
|
||||
t.what = '#post-';
|
||||
|
||||
// prepare the edit rows
|
||||
qeRow.keyup(function(e) { if(e.which == 27) return inlineEditPost.revert(); });
|
||||
bulkRow.keyup(function(e) { if (e.which == 27) return inlineEditPost.revert(); });
|
||||
qeRow.keyup(function(e){
|
||||
if (e.which == 27)
|
||||
return inlineEditPost.revert();
|
||||
});
|
||||
bulkRow.keyup(function(e){
|
||||
if (e.which == 27)
|
||||
return inlineEditPost.revert();
|
||||
});
|
||||
|
||||
$('a.cancel', qeRow).click(function() { return inlineEditPost.revert(); });
|
||||
$('a.save', qeRow).click(function() { return inlineEditPost.save(this); });
|
||||
$('td', qeRow).keydown(function(e) { if ( e.which == 13 ) return inlineEditPost.save(this); });
|
||||
$('a.cancel', qeRow).click(function(){
|
||||
return inlineEditPost.revert();
|
||||
});
|
||||
$('a.save', qeRow).click(function(){
|
||||
return inlineEditPost.save(this);
|
||||
});
|
||||
$('td', qeRow).keydown(function(e){
|
||||
if ( e.which == 13 )
|
||||
return inlineEditPost.save(this);
|
||||
});
|
||||
|
||||
$('a.cancel', bulkRow).click(function() { return inlineEditPost.revert(); });
|
||||
$('a.cancel', bulkRow).click(function(){
|
||||
return inlineEditPost.revert();
|
||||
});
|
||||
|
||||
$('#inline-edit .inline-edit-private input[value=private]').click( function(){
|
||||
var pw = $('input.inline-edit-password-input');
|
||||
|
@ -28,7 +42,10 @@ inlineEditPost = {
|
|||
});
|
||||
|
||||
// add events
|
||||
$('a.editinline').live('click', function() { inlineEditPost.edit(this); return false; });
|
||||
$('a.editinline').live('click', function(){
|
||||
inlineEditPost.edit(this);
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#bulk-title-div').parents('fieldset').after(
|
||||
$('#inline-edit fieldset.inline-edit-categories').clone()
|
||||
|
@ -61,7 +78,6 @@ inlineEditPost = {
|
|||
if ( $('form#posts-filter tr.inline-editor').length > 0 )
|
||||
t.revert();
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
toggle : function(el){
|
||||
|
@ -98,7 +114,7 @@ inlineEditPost = {
|
|||
});
|
||||
|
||||
// enable autocomplete for tags
|
||||
if ( type == 'post' ) {
|
||||
if ( 'post' == type ) {
|
||||
// support multi taxonomies?
|
||||
tax = 'post_tag';
|
||||
$('tr.inline-editor textarea[name="tags_input"]').suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+tax, { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
|
||||
|
@ -106,14 +122,15 @@ inlineEditPost = {
|
|||
},
|
||||
|
||||
edit : function(id) {
|
||||
var t = this, fields, editRow, rowData, cats, status, pageOpt, f, pageLevel, nextPage, pageLoop = true, nextLevel, tax;
|
||||
var t = this, fields, editRow, rowData, cats, status, pageOpt, pageLevel, nextPage, pageLoop = true, nextLevel, tax;
|
||||
t.revert();
|
||||
|
||||
if ( typeof(id) == 'object' )
|
||||
id = t.getId(id);
|
||||
|
||||
fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password'];
|
||||
if ( t.type == 'page' ) fields.push('post_parent', 'menu_order', 'page_template');
|
||||
if ( t.type == 'page' )
|
||||
fields.push('post_parent', 'menu_order', 'page_template');
|
||||
|
||||
// add the new blank row
|
||||
editRow = $('#inline-edit').clone(true);
|
||||
|
@ -130,7 +147,7 @@ inlineEditPost = {
|
|||
$(':input[name="post_author"]', editRow).prepend('<option value="' + $('.post_author', rowData).text() + '">' + $('#' + t.type + '-' + id + ' .author').text() + '</option>');
|
||||
}
|
||||
|
||||
for ( f = 0; f < fields.length; f++ ) {
|
||||
for ( var f = 0; f < fields.length; f++ ) {
|
||||
$(':input[name="'+fields[f]+'"]', editRow).val( $('.'+fields[f], rowData).text() );
|
||||
}
|
||||
|
||||
|
@ -143,16 +160,18 @@ inlineEditPost = {
|
|||
|
||||
// hierarchical taxonomies
|
||||
$('.post_category', rowData).each(function(){
|
||||
if( term_ids = $(this).text() )
|
||||
{
|
||||
var term_ids = $(this).text();
|
||||
|
||||
if ( term_ids ) {
|
||||
taxname = $(this).attr('id').replace('_'+id, '');
|
||||
$('ul.'+taxname+'-checklist :checkbox', editRow).val(term_ids.split(','));
|
||||
}
|
||||
});
|
||||
//flat taxonomies
|
||||
$('.tags_input', rowData).each(function(){
|
||||
if( terms = $(this).text() )
|
||||
{
|
||||
var terms = $(this).text();
|
||||
|
||||
if ( terms ) {
|
||||
taxname = $(this).attr('id').replace('_'+id, '');
|
||||
$('textarea.tax_input_'+taxname, editRow).val(terms);
|
||||
$('textarea.tax_input_'+taxname, editRow).suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+taxname, { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } );
|
||||
|
@ -162,8 +181,10 @@ inlineEditPost = {
|
|||
|
||||
// handle the post status
|
||||
status = $('._status', rowData).text();
|
||||
if ( status != 'future' ) $('select[name="_status"] option[value="future"]', editRow).remove();
|
||||
if ( status == 'private' ) {
|
||||
if ( 'future' != status )
|
||||
$('select[name="_status"] option[value="future"]', editRow).remove();
|
||||
|
||||
if ( 'private' == status ) {
|
||||
$('input[name="keep_private"]', editRow).attr("checked", "checked");
|
||||
$('input.inline-edit-password-input').val('').attr('disabled', 'disabled');
|
||||
}
|
||||
|
@ -235,9 +256,9 @@ inlineEditPost = {
|
|||
},
|
||||
|
||||
revert : function(){
|
||||
var id;
|
||||
var id = $('table.widefat tr.inline-editor').attr('id');
|
||||
|
||||
if ( id = $('table.widefat tr.inline-editor').attr('id') ) {
|
||||
if ( id ) {
|
||||
$('table.widefat .inline-edit-save .waiting').hide();
|
||||
|
||||
if ( 'bulk-edit' == id ) {
|
||||
|
@ -255,7 +276,8 @@ inlineEditPost = {
|
|||
},
|
||||
|
||||
getId : function(o) {
|
||||
var id = o.tagName == 'TR' ? o.id : $(o).parents('tr').attr('id'), parts = id.split('-');
|
||||
var id = $(o).closest('tr').attr('id'),
|
||||
parts = id.split('-');
|
||||
return parts[parts.length - 1];
|
||||
}
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -41,9 +41,9 @@ jQuery(document).ready(function($) {
|
|||
var parent = form.find('select#parent').val();
|
||||
|
||||
if ( parent > 0 && $('#tag-' + parent ).length > 0 ) // If the parent exists on this page, insert it below. Else insert it at the top of the list.
|
||||
$('#the-list #tag-' + parent).after( res.responses[0].supplemental['noparents'] ); // As the parent exists, Insert the version with - - - prefixed
|
||||
$('.tags #tag-' + parent).after( res.responses[0].supplemental['noparents'] ); // As the parent exists, Insert the version with - - - prefixed
|
||||
else
|
||||
$('#the-list').prepend( res.responses[0].supplemental['parents'] ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm
|
||||
$('.tags').prepend( res.responses[0].supplemental['parents'] ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm
|
||||
|
||||
if ( form.find('select#parent') ) {
|
||||
// Parents field exists, Add new term to the list.
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(document).ready(function(a){a(".delete-tag").live("click",function(g){var b=a(this),f=b.parents("tr"),c=true,d;if("undefined"!=showNotice){c=showNotice.warn()}if(c){d=b.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag");a.post(ajaxurl,d,function(e){if("1"==e){a("#ajax-response").empty();f.fadeOut("normal",function(){f.remove()});a("select#parent option[value="+d.match(/tag_ID=(\d+)/)[1]+"]").remove();a("a.tag-link-"+d.match(/tag_ID=(\d+)/)[1]).remove()}else{if("-1"==e){a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.noPerm+"</p></div>");f.children().css("backgroundColor","")}else{a("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.broken+"</p></div>");f.children().css("backgroundColor","")}}});f.children().css("backgroundColor","#f33")}return false});a("#submit").click(function(){var b=a(this).parents("form");if(!validateForm(b)){return false}a.post(ajaxurl,a("#addtag").serialize(),function(h){a("#ajax-response").empty();var f=wpAjax.parseAjaxResponse(h,"ajax-response");if(!f){return}var g=b.find("select#parent").val();if(g>0&&a("#tag-"+g).length>0){a("#the-list #tag-"+g).after(f.responses[0].supplemental.noparents)}else{a("#the-list").prepend(f.responses[0].supplemental.parents)}if(b.find("select#parent")){var e=f.responses[1].supplemental;var c="";for(var d=0;d<f.responses[1].position;d++){c+=" "}b.find("select#parent option:selected").after('<option value="'+e.term_id+'">'+c+e.name+"</option>")}a('input[type="text"]:visible, textarea:visible',b).val("")});return false})});
|
||||
jQuery(document).ready(function($){$(".delete-tag").live("click",function(e){var t=$(this),tr=t.parents("tr"),r=true,data;if("undefined"!=showNotice){r=showNotice.warn()}if(r){data=t.attr("href").replace(/[^?]*\?/,"").replace(/action=delete/,"action=delete-tag");$.post(ajaxurl,data,function(r){if("1"==r){$("#ajax-response").empty();tr.fadeOut("normal",function(){tr.remove()});$("select#parent option[value="+data.match(/tag_ID=(\d+)/)[1]+"]").remove();$("a.tag-link-"+data.match(/tag_ID=(\d+)/)[1]).remove()}else{if("-1"==r){$("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.noPerm+"</p></div>");tr.children().css("backgroundColor","")}else{$("#ajax-response").empty().append('<div class="error"><p>'+tagsl10n.broken+"</p></div>");tr.children().css("backgroundColor","")}}});tr.children().css("backgroundColor","#f33")}return false});$("#submit").click(function(){var form=$(this).parents("form");if(!validateForm(form)){return false}$.post(ajaxurl,$("#addtag").serialize(),function(r){$("#ajax-response").empty();var res=wpAjax.parseAjaxResponse(r,"ajax-response");if(!res){return}var parent=form.find("select#parent").val();if(parent>0&&$("#tag-"+parent).length>0){$(".tags #tag-"+parent).after(res.responses[0].supplemental.noparents)}else{$(".tags").prepend(res.responses[0].supplemental.parents)}if(form.find("select#parent")){var term=res.responses[1].supplemental;var indent="";for(var i=0;i<res.responses[1].position;i++){indent+=" "}form.find("select#parent option:selected").after('<option value="'+term.term_id+'">'+indent+term.name+"</option>")}$('input[type="text"]:visible, textarea:visible',form).val("")});return false})});
|
|
@ -10,36 +10,32 @@
|
|||
require_once ('admin.php');
|
||||
|
||||
// Handle bulk deletes
|
||||
if ( isset($_GET['action']) && isset($_GET['linkcheck']) ) {
|
||||
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['linkcheck'] ) ) {
|
||||
check_admin_referer( 'bulk-bookmarks' );
|
||||
$doaction = $_GET['action'] ? $_GET['action'] : $_GET['action2'];
|
||||
|
||||
$doaction = $_REQUEST['action'] ? $_REQUEST['action'] : $_REQUEST['action2'];
|
||||
|
||||
if ( ! current_user_can( 'manage_links' ) )
|
||||
wp_die( __( 'You do not have sufficient permissions to edit the links for this site.' ) );
|
||||
|
||||
if ( 'delete' == $doaction ) {
|
||||
$bulklinks = (array) $_GET['linkcheck'];
|
||||
$bulklinks = (array) $_REQUEST['linkcheck'];
|
||||
foreach ( $bulklinks as $link_id ) {
|
||||
$link_id = (int) $link_id;
|
||||
|
||||
wp_delete_link( $link_id );
|
||||
}
|
||||
|
||||
wp_safe_redirect( wp_get_referer() );
|
||||
exit;
|
||||
wp_redirect( add_query_arg('deleted', count( $bulklinks ), admin_url( 'link-manager.php' ) ) );
|
||||
}
|
||||
} elseif ( ! empty($_GET['_wp_http_referer']) ) {
|
||||
} elseif ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
||||
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
|
||||
if ( empty($cat_id) )
|
||||
$cat_id = 'all';
|
||||
|
||||
if ( empty($order_by) )
|
||||
$order_by = 'order_name';
|
||||
$table = new WP_Links_Table;
|
||||
|
||||
$title = __('Links');
|
||||
$this_file = $parent_file = 'link-manager.php';
|
||||
|
@ -59,39 +55,19 @@ include_once ('./admin-header.php');
|
|||
if ( ! current_user_can('manage_links') )
|
||||
wp_die(__("You do not have sufficient permissions to edit the links for this site."));
|
||||
|
||||
switch ($order_by) {
|
||||
case 'order_id' :
|
||||
$sqlorderby = 'id';
|
||||
break;
|
||||
case 'order_url' :
|
||||
$sqlorderby = 'url';
|
||||
break;
|
||||
case 'order_desc' :
|
||||
$sqlorderby = 'description';
|
||||
break;
|
||||
case 'order_owner' :
|
||||
$sqlorderby = 'owner';
|
||||
break;
|
||||
case 'order_rating' :
|
||||
$sqlorderby = 'rating';
|
||||
break;
|
||||
case 'order_name' :
|
||||
default :
|
||||
$sqlorderby = 'name';
|
||||
break;
|
||||
} ?>
|
||||
?>
|
||||
|
||||
<div class="wrap nosubsub">
|
||||
<?php screen_icon(); ?>
|
||||
<h2><?php echo esc_html( $title ); ?> <a href="link-add.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'link'); ?></a> <?php
|
||||
if ( !empty($_GET['s']) )
|
||||
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_GET['s']) ) ); ?>
|
||||
if ( !empty($_REQUEST['s']) )
|
||||
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?>
|
||||
</h2>
|
||||
|
||||
<?php
|
||||
if ( isset($_GET['deleted']) ) {
|
||||
if ( isset($_REQUEST['deleted']) ) {
|
||||
echo '<div id="message" class="updated"><p>';
|
||||
$deleted = (int) $_GET['deleted'];
|
||||
$deleted = (int) $_REQUEST['deleted'];
|
||||
printf(_n('%s link deleted.', '%s links deleted', $deleted), $deleted);
|
||||
echo '</p></div>';
|
||||
$_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
|
||||
|
@ -107,184 +83,10 @@ if ( isset($_GET['deleted']) ) {
|
|||
</form>
|
||||
<br class="clear" />
|
||||
|
||||
<form id="posts-filter" action="" method="get">
|
||||
<div class="tablenav">
|
||||
|
||||
<?php
|
||||
if ( 'all' == $cat_id )
|
||||
$cat_id = '';
|
||||
$args = array( 'category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0 );
|
||||
if ( ! empty( $_GET['s'] ) )
|
||||
$args['search'] = $_GET['s'];
|
||||
$links = get_bookmarks( $args );
|
||||
if ( $links ) {
|
||||
?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<select name="action">
|
||||
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||
<option value="delete"><?php _e('Delete'); ?></option>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
|
||||
|
||||
<?php
|
||||
$categories = get_terms('link_category', array("hide_empty" => 1));
|
||||
$select_cat = "<select name=\"cat_id\">\n";
|
||||
$select_cat .= '<option value="all"' . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('View all Categories') . "</option>\n";
|
||||
foreach ((array) $categories as $cat)
|
||||
$select_cat .= '<option value="' . esc_attr($cat->term_id) . '"' . (($cat->term_id == $cat_id) ? " selected='selected'" : '') . '>' . sanitize_term_field('name', $cat->name, $cat->term_id, 'link_category', 'display') . "</option>\n";
|
||||
$select_cat .= "</select>\n";
|
||||
|
||||
$select_order = "<select name=\"order_by\">\n";
|
||||
$select_order .= '<option value="order_id"' . (($order_by == 'order_id') ? " selected='selected'" : '') . '>' . __('Order by Link ID') . "</option>\n";
|
||||
$select_order .= '<option value="order_name"' . (($order_by == 'order_name') ? " selected='selected'" : '') . '>' . __('Order by Name') . "</option>\n";
|
||||
$select_order .= '<option value="order_url"' . (($order_by == 'order_url') ? " selected='selected'" : '') . '>' . __('Order by Address') . "</option>\n";
|
||||
$select_order .= '<option value="order_rating"' . (($order_by == 'order_rating') ? " selected='selected'" : '') . '>' . __('Order by Rating') . "</option>\n";
|
||||
$select_order .= "</select>\n";
|
||||
|
||||
echo $select_cat;
|
||||
echo $select_order;
|
||||
|
||||
?>
|
||||
<input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php
|
||||
$link_columns = get_column_headers('link-manager');
|
||||
$hidden = get_hidden_columns('link-manager');
|
||||
?>
|
||||
|
||||
<?php wp_nonce_field('bulk-bookmarks') ?>
|
||||
<table class="widefat fixed" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php print_column_headers('link-manager'); ?>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<?php print_column_headers('link-manager', false); ?>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
$alt = 0;
|
||||
|
||||
foreach ($links as $link) {
|
||||
$link = sanitize_bookmark($link);
|
||||
$link->link_name = esc_attr($link->link_name);
|
||||
$link->link_category = wp_get_link_cats($link->link_id);
|
||||
$short_url = str_replace('http://', '', $link->link_url);
|
||||
$short_url = preg_replace('/^www\./i', '', $short_url);
|
||||
if ('/' == substr($short_url, -1))
|
||||
$short_url = substr($short_url, 0, -1);
|
||||
if (strlen($short_url) > 35)
|
||||
$short_url = substr($short_url, 0, 32).'...';
|
||||
$visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
|
||||
$rating = $link->link_rating;
|
||||
$style = ($alt % 2) ? '' : ' class="alternate"';
|
||||
++ $alt;
|
||||
$edit_link = get_edit_bookmark_link();
|
||||
?><tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>><?php
|
||||
foreach($link_columns as $column_name=>$column_display_name) {
|
||||
$class = "class=\"column-$column_name\"";
|
||||
|
||||
$style = '';
|
||||
if ( in_array($column_name, $hidden) )
|
||||
$style = ' style="display:none;"';
|
||||
|
||||
$attributes = "$class$style";
|
||||
|
||||
switch($column_name) {
|
||||
case 'cb':
|
||||
echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'. esc_attr($link->link_id) .'" /></th>';
|
||||
break;
|
||||
case 'name':
|
||||
|
||||
echo "<td $attributes><strong><a class='row-title' href='$edit_link' title='" . esc_attr(sprintf(__('Edit “%s”'), $link->link_name)) . "'>$link->link_name</a></strong><br />";
|
||||
$actions = array();
|
||||
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
|
||||
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm('" . esc_js(sprintf( __("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
|
||||
$action_count = count($actions);
|
||||
$i = 0;
|
||||
echo '<div class="row-actions">';
|
||||
foreach ( $actions as $action => $linkaction ) {
|
||||
++$i;
|
||||
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
||||
echo "<span class='$action'>$linkaction$sep</span>";
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</td>';
|
||||
break;
|
||||
case 'url':
|
||||
echo "<td $attributes><a href='$link->link_url' title='".sprintf(__('Visit %s'), $link->link_name)."'>$short_url</a></td>";
|
||||
break;
|
||||
case 'categories':
|
||||
?><td <?php echo $attributes ?>><?php
|
||||
$cat_names = array();
|
||||
foreach ($link->link_category as $category) {
|
||||
$cat = get_term($category, 'link_category', OBJECT, 'display');
|
||||
if ( is_wp_error( $cat ) )
|
||||
echo $cat->get_error_message();
|
||||
$cat_name = $cat->name;
|
||||
if ( $cat_id != $category )
|
||||
$cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
|
||||
$cat_names[] = $cat_name;
|
||||
}
|
||||
echo implode(', ', $cat_names);
|
||||
?></td><?php
|
||||
break;
|
||||
case 'rel':
|
||||
?><td <?php echo $attributes ?>><?php echo empty($link->link_rel) ? '<br />' : $link->link_rel; ?></td><?php
|
||||
break;
|
||||
case 'visible':
|
||||
?><td <?php echo $attributes ?>><?php echo $visible; ?></td><?php
|
||||
break;
|
||||
case 'rating':
|
||||
?><td <?php echo $attributes ?>><?php echo $rating; ?></td><?php
|
||||
break;
|
||||
default:
|
||||
?>
|
||||
<td <?php echo $attributes ?>><?php do_action('manage_link_custom_column', $column_name, $link->link_id); ?></td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
echo "\n </tr>\n";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="tablenav">
|
||||
|
||||
<div class="alignleft actions">
|
||||
<select name="action2">
|
||||
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||
<option value="delete"><?php _e('Delete'); ?></option>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
||||
</div>
|
||||
|
||||
<?php } else { ?>
|
||||
<p><?php _e( 'No links found.' ) ?></p>
|
||||
<?php } ?>
|
||||
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<form id="posts-filter" action="" method="post">
|
||||
<?php $table->display(); ?>
|
||||
<div id="ajax-response"></div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-to
|
|||
$submenu['link-manager.php'][5] = array( __('Links'), 'manage_links', 'link-manager.php' );
|
||||
/* translators: add new links */
|
||||
$submenu['link-manager.php'][10] = array( _x('Add New', 'link'), 'manage_links', 'link-add.php' );
|
||||
$submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-link-categories.php' );
|
||||
$submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-tags.php?taxonomy=link_category' );
|
||||
|
||||
$menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top menu-icon-page', 'menu-pages', 'div' );
|
||||
$submenu['edit.php?post_type=page'][5] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page' );
|
||||
|
|
|
@ -18,7 +18,7 @@ if ( ! current_user_can( 'manage_sites' ) )
|
|||
$title = __( 'Sites' );
|
||||
$parent_file = 'sites.php';
|
||||
|
||||
if ( isset( $_GET['action'] ) && 'editblog' == $_GET['action'] ) {
|
||||
if ( isset( $_REQUEST['action'] ) && 'editblog' == $_REQUEST['action'] ) {
|
||||
add_contextual_help($current_screen,
|
||||
'<p>' . __('This extensive list of options has five modules: Site Info, Site Options, allowing Site Themes for this given site, changing user roles and passwords for that site, adding a new user, and Miscellaneous Site Actions (upload size limits).') . '</p>' .
|
||||
'<p>' . __('Note that some fields in Site Options are grayed out and say Serialized Data. These are stored values in the database which you cannot change from here.') . '</p>' .
|
||||
|
@ -46,17 +46,13 @@ if ( isset( $_GET['action'] ) && 'editblog' == $_GET['action'] ) {
|
|||
);
|
||||
}
|
||||
|
||||
wp_enqueue_script( 'admin-forms' );
|
||||
$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
|
||||
|
||||
require_once( '../admin-header.php' );
|
||||
|
||||
$id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0;
|
||||
|
||||
if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['action'] ) ) {
|
||||
if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
|
||||
?>
|
||||
<div id="message" class="updated"><p>
|
||||
<?php
|
||||
switch ( $_GET['action'] ) {
|
||||
switch ( $_REQUEST['action'] ) {
|
||||
case 'all_notspam':
|
||||
_e( 'Sites removed from spam.' );
|
||||
break;
|
||||
|
@ -99,7 +95,7 @@ if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['
|
|||
<?php
|
||||
}
|
||||
|
||||
$action = isset( $_GET['action'] ) ? $_GET['action'] : 'list';
|
||||
$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'list';
|
||||
|
||||
switch ( $action ) {
|
||||
// Edit site
|
||||
|
@ -112,11 +108,13 @@ switch ( $action ) {
|
|||
|
||||
$editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" );
|
||||
$is_main_site = is_main_site( $id );
|
||||
|
||||
require_once( './admin-header.php' );
|
||||
?>
|
||||
<div class="wrap">
|
||||
<?php screen_icon(); ?>
|
||||
<h2><?php _e( 'Edit Site' ); ?> - <a href="<?php echo esc_url( get_home_url( $id ) ); ?>"><?php echo esc_url( get_home_url( $id ) ); ?></a></h2>
|
||||
<form method="post" action="edit.php?action=updateblog">
|
||||
<form method="post" action="ms-edit.php?action=updateblog">
|
||||
<?php wp_nonce_field( 'editblog' ); ?>
|
||||
<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
|
||||
<div class="metabox-holder" style="width:49%;float:left;">
|
||||
|
@ -350,82 +348,23 @@ switch ( $action ) {
|
|||
// List sites
|
||||
case 'list':
|
||||
default:
|
||||
$pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0;
|
||||
if ( empty($pagenum) )
|
||||
$pagenum = 1;
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
|
||||
$per_page = (int) get_user_option( 'ms_sites_per_page' );
|
||||
if ( empty( $per_page ) || $per_page < 1 )
|
||||
$per_page = 15;
|
||||
$table = new WP_Sites_Table;
|
||||
|
||||
$per_page = apply_filters( 'ms_sites_per_page', $per_page );
|
||||
|
||||
$s = isset( $_GET['s'] ) ? stripslashes( trim( $_GET[ 's' ] ) ) : '';
|
||||
$like_s = esc_sql( like_escape( $s ) );
|
||||
|
||||
$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
|
||||
|
||||
if ( isset( $_GET['searchaction'] ) ) {
|
||||
if ( 'name' == $_GET['searchaction'] ) {
|
||||
$query .= " AND ( {$wpdb->blogs}.domain LIKE '%{$like_s}%' OR {$wpdb->blogs}.path LIKE '%{$like_s}%' ) ";
|
||||
} elseif ( 'id' == $_GET['searchaction'] ) {
|
||||
$query .= " AND {$wpdb->blogs}.blog_id = '{$like_s}' ";
|
||||
} elseif ( 'ip' == $_GET['searchaction'] ) {
|
||||
$query = "SELECT *
|
||||
FROM {$wpdb->blogs}, {$wpdb->registration_log}
|
||||
WHERE site_id = '{$wpdb->siteid}'
|
||||
AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id
|
||||
AND {$wpdb->registration_log}.IP LIKE ('%{$like_s}%')";
|
||||
}
|
||||
}
|
||||
|
||||
$order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id';
|
||||
if ( $order_by == 'registered' ) {
|
||||
$query .= ' ORDER BY registered ';
|
||||
} elseif ( $order_by == 'lastupdated' ) {
|
||||
$query .= ' ORDER BY last_updated ';
|
||||
} elseif ( $order_by == 'blogname' ) {
|
||||
$query .= ' ORDER BY domain ';
|
||||
} else {
|
||||
$order_by = 'id';
|
||||
$query .= " ORDER BY {$wpdb->blogs}.blog_id ";
|
||||
}
|
||||
|
||||
$order = ( isset( $_GET['order'] ) && 'DESC' == $_GET['order'] ) ? "DESC" : "ASC";
|
||||
$query .= $order;
|
||||
|
||||
$total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT(blog_id)', $query ) );
|
||||
|
||||
$query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page );
|
||||
$blog_list = $wpdb->get_results( $query, ARRAY_A );
|
||||
|
||||
$num_pages = ceil($total / $per_page);
|
||||
$page_links = paginate_links( array(
|
||||
'base' => add_query_arg( 'paged', '%#%' ),
|
||||
'format' => '',
|
||||
'prev_text' => __( '«' ),
|
||||
'next_text' => __( '»' ),
|
||||
'total' => $num_pages,
|
||||
'current' => $pagenum
|
||||
));
|
||||
|
||||
if ( empty( $_GET['mode'] ) )
|
||||
$mode = 'list';
|
||||
else
|
||||
$mode = esc_attr( $_GET['mode'] );
|
||||
require_once( './admin-header.php' );
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<?php screen_icon(); ?>
|
||||
<h2><?php _e('Sites') ?>
|
||||
<a href="#form-add-site" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'sites' ); ?></a>
|
||||
<?php
|
||||
if ( isset( $_GET['s'] ) && $_GET['s'] )
|
||||
<?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) {
|
||||
printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) );
|
||||
?>
|
||||
} ?>
|
||||
</h2>
|
||||
|
||||
<form action="sites.php" method="get" id="ms-search">
|
||||
<form action="ms-sites.php" method="get" id="ms-search">
|
||||
<p class="search-box">
|
||||
<input type="hidden" name="action" value="blogs" />
|
||||
<input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" />
|
||||
|
@ -438,278 +377,14 @@ switch ( $action ) {
|
|||
</p>
|
||||
</form>
|
||||
|
||||
<form id="form-site-list" action="edit.php?action=allblogs" method="post">
|
||||
<input type="hidden" name="mode" value="<?php echo esc_attr( $mode ); ?>" />
|
||||
<div class="tablenav">
|
||||
<div class="alignleft actions">
|
||||
<select name="action">
|
||||
<option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
|
||||
<option value="delete"><?php _e( 'Delete' ); ?></option>
|
||||
<option value="spam"><?php _ex( 'Mark as Spam', 'site' ); ?></option>
|
||||
<option value="notspam"><?php _ex( 'Not Spam', 'site' ); ?></option>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" />
|
||||
<?php wp_nonce_field( 'bulk-ms-sites', '_wpnonce_bulk-ms-sites' ); ?>
|
||||
</div>
|
||||
|
||||
<?php if ( $page_links ) { ?>
|
||||
<div class="tablenav-pages">
|
||||
<?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
|
||||
number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
|
||||
number_format_i18n( min( $pagenum * $per_page, $total ) ),
|
||||
number_format_i18n( $total ),
|
||||
$page_links
|
||||
); echo $page_links_text; ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="view-switch">
|
||||
<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="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'List View' ) ?>" alt="<?php _e( 'List View' ) ?>" /></a>
|
||||
<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="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'Excerpt View' ) ?>" alt="<?php _e( 'Excerpt View' ) ?>" /></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php
|
||||
// define the columns to display, the syntax is 'internal name' => 'display name'
|
||||
$blogname_columns = ( is_subdomain_install() ) ? __( 'Domain' ) : __( 'Path' );
|
||||
$sites_columns = array(
|
||||
'id' => __( 'ID' ),
|
||||
'blogname' => $blogname_columns,
|
||||
'lastupdated' => __( 'Last Updated'),
|
||||
'registered' => _x( 'Registered', 'site' ),
|
||||
'users' => __( 'Users' )
|
||||
);
|
||||
|
||||
if ( has_filter( 'wpmublogsaction' ) )
|
||||
$sites_columns['plugins'] = __( 'Actions' );
|
||||
|
||||
$sites_columns = apply_filters( 'wpmu_blogs_columns', $sites_columns );
|
||||
?>
|
||||
|
||||
<table class="widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="manage-column column-cb check-column" id="cb" scope="col">
|
||||
<input type="checkbox" />
|
||||
</th>
|
||||
<?php
|
||||
$col_url = '';
|
||||
foreach($sites_columns as $column_id => $column_display_name) {
|
||||
$column_link = "<a href='";
|
||||
$order2 = '';
|
||||
if ( $order_by == $column_id )
|
||||
$order2 = ( $order == 'DESC' ) ? 'ASC' : 'DESC';
|
||||
|
||||
$column_link .= esc_url( add_query_arg( array( 'order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array('action', 'updated'), $_SERVER['REQUEST_URI'] ) ) );
|
||||
$column_link .= "'>{$column_display_name}</a>";
|
||||
$col_url .= '<th scope="col">' . ( ( $column_id == 'users' || $column_id == 'plugins' ) ? $column_display_name : $column_link ) . '</th>';
|
||||
}
|
||||
echo $col_url ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th class="manage-column column-cb check-column" id="cb1" scope="col">
|
||||
<input type="checkbox" />
|
||||
</th>
|
||||
<?php echo $col_url ?>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody id="the-site-list" class="list:site">
|
||||
<?php
|
||||
$status_list = array( 'archived' => array( 'site-archived', __( 'Archived' ) ), 'spam' => array( 'site-spammed', _x( 'Spam', 'site' ) ), 'deleted' => array( 'site-deleted', __( 'Deleted' ) ), 'mature' => array( 'site-mature', __( 'Mature' ) ) );
|
||||
if ( $blog_list ) {
|
||||
$class = '';
|
||||
foreach ( $blog_list as $blog ) {
|
||||
$class = ( 'alternate' == $class ) ? '' : 'alternate';
|
||||
reset( $status_list );
|
||||
|
||||
$blog_states = array();
|
||||
foreach ( $status_list as $status => $col ) {
|
||||
if ( get_blog_status( $blog['blog_id'], $status ) == 1 ) {
|
||||
$class = $col[0];
|
||||
$blog_states[] = $col[1];
|
||||
}
|
||||
}
|
||||
$blog_state = '';
|
||||
if ( ! empty( $blog_states ) ) {
|
||||
$state_count = count( $blog_states );
|
||||
$i = 0;
|
||||
$blog_state .= ' - ';
|
||||
foreach ( $blog_states as $state ) {
|
||||
++$i;
|
||||
( $i == $state_count ) ? $sep = '' : $sep = ', ';
|
||||
$blog_state .= "<span class='post-state'>$state$sep</span>";
|
||||
}
|
||||
}
|
||||
echo "<tr class='$class'>";
|
||||
|
||||
$blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path'];
|
||||
foreach ( $sites_columns as $column_name=>$column_display_name ) {
|
||||
switch ( $column_name ) {
|
||||
case 'id': ?>
|
||||
<th scope="row" class="check-column">
|
||||
<input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" />
|
||||
</th>
|
||||
<th valign="top" scope="row">
|
||||
<?php echo $blog['blog_id'] ?>
|
||||
</th>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'blogname': ?>
|
||||
<td class="column-title">
|
||||
<a href="<?php echo esc_url( network_admin_url( 'sites.php?action=editblog&id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a>
|
||||
<?php
|
||||
if ( 'list' != $mode )
|
||||
echo '<p>' . sprintf( _x( '%1$s – <em>%2$s</em>', '%1$s: site name. %2$s: site tagline.' ), get_blog_option( $blog['blog_id'], 'blogname' ), get_blog_option( $blog['blog_id'], 'blogdescription ' ) ) . '</p>';
|
||||
|
||||
// Preordered.
|
||||
$actions = array(
|
||||
'edit' => '', 'backend' => '',
|
||||
'activate' => '', 'deactivate' => '',
|
||||
'archive' => '', 'unarchive' => '',
|
||||
'spam' => '', 'unspam' => '',
|
||||
'delete' => '',
|
||||
'visit' => '',
|
||||
);
|
||||
|
||||
$actions['edit'] = '<span class="edit"><a href="' . esc_url( network_admin_url( 'sites.php?action=editblog&id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
|
||||
$actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url($blog['blog_id']) ) . "' class='edit'>" . __( 'Backend' ) . '</a></span>';
|
||||
if ( $current_site->blog_id != $blog['blog_id'] ) {
|
||||
if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' )
|
||||
$actions['activate'] = '<span class="activate"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ) ) . '">' . __( 'Activate' ) . '</a></span>';
|
||||
else
|
||||
$actions['deactivate'] = '<span class="activate"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ) ) . '">' . __( 'Deactivate' ) . '</a></span>';
|
||||
|
||||
if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' )
|
||||
$actions['unarchive'] = '<span class="archive"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ) ) . '">' . __( 'Unarchive' ) . '</a></span>';
|
||||
else
|
||||
$actions['archive'] = '<span class="archive"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
|
||||
|
||||
if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' )
|
||||
$actions['unspam'] = '<span class="spam"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
|
||||
else
|
||||
$actions['spam'] = '<span class="spam"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ) ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
|
||||
|
||||
$actions['delete'] = '<span class="delete"><a href="' . esc_url( network_admin_url( 'edit.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ) ) . '">' . __( 'Delete' ) . '</a></span>';
|
||||
}
|
||||
|
||||
$actions['visit'] = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'] ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
|
||||
$actions = array_filter( $actions );
|
||||
if ( count( $actions ) ) : ?>
|
||||
<div class="row-actions">
|
||||
<?php echo implode( ' | ', $actions ); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'lastupdated': ?>
|
||||
<td valign="top">
|
||||
<?php
|
||||
if ( 'list' == $mode )
|
||||
$date = 'Y/m/d';
|
||||
else
|
||||
$date = 'Y/m/d \<\b\r \/\> g:i:s a';
|
||||
echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( __( $date ), $blog['last_updated'] ); ?>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
case 'registered': ?>
|
||||
<td valign="top">
|
||||
<?php
|
||||
if ( $blog['registered'] == '0000-00-00 00:00:00' )
|
||||
echo '—';
|
||||
else
|
||||
echo mysql2date( __( $date ), $blog['registered'] );
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
case 'users': ?>
|
||||
<td valign="top">
|
||||
<?php
|
||||
$blogusers = get_users_of_blog( $blog['blog_id'] );
|
||||
if ( is_array( $blogusers ) ) {
|
||||
$blogusers_warning = '';
|
||||
if ( count( $blogusers ) > 5 ) {
|
||||
$blogusers = array_slice( $blogusers, 0, 5 );
|
||||
$blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . esc_url( get_admin_url( $blog['blog_id'], 'users.php' ) ) . '">' . __( 'More' ) . '</a>';
|
||||
}
|
||||
foreach ( $blogusers as $key => $val ) {
|
||||
echo '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $val->user_id ) ) . '">' . esc_html( $val->user_login ) . '</a> ';
|
||||
if ( 'list' != $mode )
|
||||
echo '(' . $val->user_email . ')';
|
||||
echo '<br />';
|
||||
}
|
||||
if ( $blogusers_warning != '' )
|
||||
echo '<strong>' . $blogusers_warning . '</strong><br />';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'plugins': ?>
|
||||
<?php if ( has_filter( 'wpmublogsaction' ) ) { ?>
|
||||
<td valign="top">
|
||||
<?php do_action( 'wpmublogsaction', $blog['blog_id'] ); ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?php break;
|
||||
|
||||
default: ?>
|
||||
<?php if ( has_filter( 'manage_blogs_custom_column' ) ) { ?>
|
||||
<td valign="top">
|
||||
<?php do_action( 'manage_blogs_custom_column', $column_name, $blog['blog_id'] ); ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?php break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
} else { ?>
|
||||
<tr>
|
||||
<td colspan="<?php echo (int) count( $sites_columns ); ?>"><?php _e( 'No sites found.' ) ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
} // end if ($blogs)
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="tablenav">
|
||||
<?php
|
||||
if ( $page_links )
|
||||
echo "<div class='tablenav-pages'>$page_links_text</div>";
|
||||
?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<select name="action2">
|
||||
<option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
|
||||
<option value="delete"><?php _e( 'Delete' ); ?></option>
|
||||
<option value="spam"><?php _ex( 'Mark as Spam', 'site' ); ?></option>
|
||||
<option value="notspam"><?php _ex( 'Not Spam', 'site' ); ?></option>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
||||
</div>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<form id="form-site-list" action="ms-edit.php?action=allblogs" method="post">
|
||||
<?php $table->display(); ?>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="form-add-site" class="wrap">
|
||||
<h3><?php _e( 'Add Site' ) ?></h3>
|
||||
<form method="post" action="edit.php?action=addblog">
|
||||
<form method="post" action="ms-edit.php?action=addblog">
|
||||
<?php wp_nonce_field( 'add-blog', '_wpnonce_add-blog' ) ?>
|
||||
<table class="form-table">
|
||||
<tr class="form-field form-required">
|
||||
|
@ -744,4 +419,4 @@ switch ( $action ) {
|
|||
break;
|
||||
} // end switch( $action )
|
||||
|
||||
include( '../admin-footer.php' ); ?>
|
||||
include( './admin-footer.php' ); ?>
|
||||
|
|
|
@ -32,15 +32,17 @@ add_contextual_help($current_screen,
|
|||
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
|
||||
);
|
||||
|
||||
wp_enqueue_script( 'admin-forms' );
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
|
||||
require_once( '../admin-header.php' );
|
||||
$table = new WP_MS_Users_Table;
|
||||
|
||||
if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['action'] ) ) {
|
||||
require_once( './admin-header.php' );
|
||||
|
||||
if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
|
||||
?>
|
||||
<div id="message" class="updated"><p>
|
||||
<?php
|
||||
switch ( $_GET['action'] ) {
|
||||
switch ( $_REQUEST['action'] ) {
|
||||
case 'delete':
|
||||
_e( 'User deleted.' );
|
||||
break;
|
||||
|
@ -61,291 +63,26 @@ if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['
|
|||
</p></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
$pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0;
|
||||
if ( empty( $pagenum ) )
|
||||
$pagenum = 1;
|
||||
|
||||
$per_page = (int) get_user_option( 'ms_users_per_page' );
|
||||
if ( empty( $per_page ) || $per_page < 1 )
|
||||
$per_page = 15;
|
||||
|
||||
$per_page = apply_filters( 'ms_users_per_page', $per_page );
|
||||
|
||||
$s = isset( $_GET['s'] ) ? stripslashes( trim( $_GET[ 's' ] ) ) : '';
|
||||
$like_s = esc_sql( like_escape( $s ) );
|
||||
|
||||
$query = "SELECT * FROM {$wpdb->users}";
|
||||
|
||||
if ( !empty( $like_s ) ) {
|
||||
$query .= " WHERE user_login LIKE '%$like_s%' OR user_email LIKE '%$like_s%'";
|
||||
}
|
||||
|
||||
$order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id';
|
||||
if ( $order_by == 'email' ) {
|
||||
$query .= ' ORDER BY user_email ';
|
||||
} elseif ( $order_by == 'login' ) {
|
||||
$query .= ' ORDER BY user_login ';
|
||||
} elseif ( $order_by == 'name' ) {
|
||||
$query .= ' ORDER BY display_name ';
|
||||
} elseif ( $order_by == 'registered' ) {
|
||||
$query .= ' ORDER BY user_registered ';
|
||||
} else {
|
||||
$order_by = 'id';
|
||||
$query .= ' ORDER BY ID ';
|
||||
}
|
||||
|
||||
$order = ( isset( $_GET['order'] ) && 'DESC' == $_GET['order'] ) ? 'DESC' : 'ASC';
|
||||
$query .= $order;
|
||||
|
||||
$total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT(ID)', $query ) );
|
||||
|
||||
$query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page) . ", " . intval( $per_page );
|
||||
|
||||
$user_list = $wpdb->get_results( $query, ARRAY_A );
|
||||
|
||||
$num_pages = ceil( $total / $per_page );
|
||||
$page_links = paginate_links( array(
|
||||
'base' => add_query_arg( 'paged', '%#%' ),
|
||||
'format' => '',
|
||||
'prev_text' => __( '«' ),
|
||||
'next_text' => __( '»' ),
|
||||
'total' => $num_pages,
|
||||
'current' => $pagenum
|
||||
));
|
||||
|
||||
if ( empty( $_GET['mode'] ) )
|
||||
$mode = 'list';
|
||||
else
|
||||
$mode = esc_attr( $_GET['mode'] );
|
||||
|
||||
?>
|
||||
<div class="wrap">
|
||||
<?php screen_icon(); ?>
|
||||
<h2><?php esc_html_e( 'Users' ); ?>
|
||||
<a href="#form-add-user" class="button add-new-h2"><?php echo esc_html_x( 'Add New' , 'users'); ?></a>
|
||||
<?php
|
||||
if ( isset( $_GET['s'] ) && $_GET['s'] )
|
||||
if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] )
|
||||
printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) );
|
||||
?>
|
||||
</h2>
|
||||
|
||||
<form action="users.php" method="get" class="search-form">
|
||||
<form action="ms-users.php" method="get" class="search-form">
|
||||
<p class="search-box">
|
||||
<input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" class="search-input" id="user-search-input" />
|
||||
<input type="submit" id="post-query-submit" value="<?php esc_attr_e( 'Search Users' ) ?>" class="button" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<form id="form-user-list" action='edit.php?action=allusers' method='post'>
|
||||
<input type="hidden" name="mode" value="<?php echo esc_attr( $mode ); ?>" />
|
||||
<div class="tablenav">
|
||||
<div class="alignleft actions">
|
||||
<select name="action">
|
||||
<option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
|
||||
<option value="delete"><?php _e( 'Delete' ); ?></option>
|
||||
<option value="spam"><?php _ex( 'Mark as Spam', 'user' ); ?></option>
|
||||
<option value="notspam"><?php _ex( 'Not Spam', 'user' ); ?></option>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" />
|
||||
<?php wp_nonce_field( 'bulk-ms-users', '_wpnonce_bulk-ms-users' ); ?>
|
||||
</div>
|
||||
|
||||
<?php if ( $page_links ) { ?>
|
||||
<div class="tablenav-pages">
|
||||
<?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
|
||||
number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
|
||||
number_format_i18n( min( $pagenum * $per_page, $total ) ),
|
||||
number_format_i18n( $total ),
|
||||
$page_links
|
||||
); echo $page_links_text; ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="view-switch">
|
||||
<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="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'List View' ) ?>" alt="<?php _e( 'List View' ) ?>" /></a>
|
||||
<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="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'Excerpt View' ) ?>" alt="<?php _e( 'Excerpt View' ) ?>" /></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php
|
||||
// define the columns to display, the syntax is 'internal name' => 'display name'
|
||||
$users_columns = array(
|
||||
'id' => __( 'ID' ),
|
||||
'login' => __( 'Username' ),
|
||||
'name' => __( 'Name' ),
|
||||
'email' => __( 'E-mail' ),
|
||||
'registered' => _x( 'Registered', 'user' ),
|
||||
'blogs' => __( 'Sites' )
|
||||
);
|
||||
$users_columns = apply_filters( 'wpmu_users_columns', $users_columns );
|
||||
?>
|
||||
<table class="widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="manage-column column-cb check-column" scope="col">
|
||||
<input type="checkbox" />
|
||||
</th>
|
||||
<?php
|
||||
$col_url = '';
|
||||
foreach($users_columns as $column_id => $column_display_name) {
|
||||
$column_link = "<a href='";
|
||||
$order2 = '';
|
||||
if ( $order_by == $column_id )
|
||||
$order2 = ( $order == 'DESC' ) ? 'ASC' : 'DESC';
|
||||
|
||||
$column_link .= esc_url( add_query_arg( array( 'order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array( 'action', 'updated' ), $_SERVER['REQUEST_URI'] ) ) );
|
||||
$column_link .= "'>{$column_display_name}</a>";
|
||||
$col_url .= '<th scope="col">' . ( $column_id == 'blogs' ? $column_display_name : $column_link ) . '</th>';
|
||||
}
|
||||
echo $col_url; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th class="manage-column column-cb check-column" scope="col">
|
||||
<input type="checkbox" />
|
||||
</th>
|
||||
<?php echo $col_url; ?>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody id="the-user-list" class="list:user">
|
||||
<?php if ( $user_list ) {
|
||||
$class = '';
|
||||
$super_admins = get_super_admins();
|
||||
foreach ( (array) $user_list as $user ) {
|
||||
$class = ( 'alternate' == $class ) ? '' : 'alternate';
|
||||
|
||||
$status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
|
||||
|
||||
foreach ( $status_list as $status => $col ) {
|
||||
if ( $user[$status] )
|
||||
$class = $col;
|
||||
}
|
||||
|
||||
?>
|
||||
<tr class="<?php echo $class; ?>">
|
||||
<?php
|
||||
foreach( (array) $users_columns as $column_name=>$column_display_name ) :
|
||||
switch( $column_name ) {
|
||||
case 'id': ?>
|
||||
<th scope="row" class="check-column">
|
||||
<input type="checkbox" id="blog_<?php echo $user['ID'] ?>" name="allusers[]" value="<?php echo esc_attr( $user['ID'] ) ?>" />
|
||||
</th>
|
||||
<th valign="top" scope="row">
|
||||
<?php echo $user['ID'] ?>
|
||||
</th>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'login':
|
||||
$avatar = get_avatar( $user['user_email'], 32 );
|
||||
$edit_link = ( $current_user->ID == $user['ID'] ) ? 'profile.php' : 'user-edit.php?user_id=' . $user['ID'];
|
||||
?>
|
||||
<td class="username column-username">
|
||||
<?php echo $avatar; ?><strong><a href="<?php echo esc_url( network_admin_url( $edit_link ) ); ?>" class="edit"><?php echo stripslashes( $user['user_login'] ); ?></a><?php
|
||||
if ( in_array( $user['user_login'], $super_admins ) )
|
||||
echo ' - ' . __( 'Super admin' );
|
||||
?></strong>
|
||||
<br/>
|
||||
<div class="row-actions">
|
||||
<span class="edit"><a href="<?php echo esc_url( network_admin_url( $edit_link ) ); ?>"><?php _e( 'Edit' ); ?></a></span>
|
||||
<?php if ( ! in_array( $user['user_login'], $super_admins ) ) { ?>
|
||||
| <span class="delete"><a href="<?php echo $delete = esc_url( admin_url( add_query_arg( '_wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'edit.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user['ID'] ) ) ); ?>" class="delete"><?php _e( 'Delete' ); ?></a></span>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'name': ?>
|
||||
<td class="name column-name"><?php echo $user['display_name'] ?></td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'email': ?>
|
||||
<td class="email column-email"><a href="mailto:<?php echo $user['user_email'] ?>"><?php echo $user['user_email'] ?></a></td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'registered':
|
||||
if ( 'list' == $mode )
|
||||
$date = 'Y/m/d';
|
||||
else
|
||||
$date = 'Y/m/d \<\b\r \/\> g:i:s a';
|
||||
?>
|
||||
<td><?php echo mysql2date( __( $date ), $user['user_registered'] ); ?></td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'blogs':
|
||||
$blogs = get_blogs_of_user( $user['ID'], true );
|
||||
?>
|
||||
<td>
|
||||
<?php
|
||||
if ( is_array( $blogs ) ) {
|
||||
foreach ( (array) $blogs as $key => $val ) {
|
||||
$path = ( $val->path == '/' ) ? '' : $val->path;
|
||||
echo '<a href="'. esc_url( network_admin_url( 'sites.php?action=editblog&id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . '</a>';
|
||||
echo ' <small class="row-actions">';
|
||||
|
||||
// Edit
|
||||
echo '<a href="'. esc_url( network_admin_url( 'sites.php?action=editblog&id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a> | ';
|
||||
|
||||
// View
|
||||
echo '<a ';
|
||||
if ( get_blog_status( $val->userblog_id, 'spam' ) == 1 )
|
||||
echo 'style="background-color: #faa" ';
|
||||
echo 'href="' . esc_url( get_home_url( $val->userblog_id ) ) . '">' . __( 'View' ) . '</a>';
|
||||
|
||||
echo '</small><br />';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
default: ?>
|
||||
<td><?php do_action( 'manage_users_custom_column', $column_name, $user['ID'] ); ?></td>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
endforeach
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="<?php echo (int) count($users_columns); ?>"><?php _e( 'No users found.' ) ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
} // end if ($users)
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="tablenav">
|
||||
<?php
|
||||
if ( $page_links )
|
||||
echo "<div class='tablenav-pages'>$page_links_text</div>";
|
||||
?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<select name="action2">
|
||||
<option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
|
||||
<option value="delete"><?php _e( 'Delete' ); ?></option>
|
||||
<option value="spam"><?php _ex( 'Mark as Spam', 'user' ); ?></option>
|
||||
<option value="notspam"><?php _ex( 'Not Spam', 'user' ); ?></option>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
||||
</div>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<form id="form-user-list" action='ms-edit.php?action=allusers' method='post'>
|
||||
<?php $table->display(); ?>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
@ -354,7 +91,7 @@ if ( apply_filters( 'show_adduser_fields', true ) ) :
|
|||
?>
|
||||
<div class="wrap" id="form-add-user">
|
||||
<h3><?php _e( 'Add User' ) ?></h3>
|
||||
<form action="edit.php?action=adduser" method="post">
|
||||
<form action="ms-edit.php?action=adduser" method="post">
|
||||
<table class="form-table">
|
||||
<tr class="form-field form-required">
|
||||
<th scope="row"><?php _e( 'Username' ) ?></th>
|
||||
|
@ -375,4 +112,4 @@ if ( apply_filters( 'show_adduser_fields', true ) ) :
|
|||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php include( '../admin-footer.php' ); ?>
|
||||
<?php include( './admin-footer.php' ); ?>
|
||||
|
|
|
@ -12,37 +12,13 @@ require_once('./admin.php');
|
|||
if ( ! current_user_can('install_plugins') )
|
||||
wp_die(__('You do not have sufficient permissions to install plugins on this site.'));
|
||||
|
||||
include(ABSPATH . 'wp-admin/includes/plugin-install.php');
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
|
||||
$table = new WP_Plugin_Install_Table;
|
||||
|
||||
$title = __('Install Plugins');
|
||||
$parent_file = 'plugins.php';
|
||||
|
||||
wp_reset_vars( array('tab', 'paged') );
|
||||
|
||||
//These are the tabs which are shown on the page,
|
||||
$tabs = array();
|
||||
$tabs['dashboard'] = __('Search');
|
||||
if ( 'search' == $tab )
|
||||
$tabs['search'] = __('Search Results');
|
||||
$tabs['upload'] = __('Upload');
|
||||
$tabs['featured'] = _x('Featured','Plugin Installer');
|
||||
$tabs['popular'] = _x('Popular','Plugin Installer');
|
||||
$tabs['new'] = _x('Newest','Plugin Installer');
|
||||
$tabs['updated'] = _x('Recently Updated','Plugin Installer');
|
||||
|
||||
$nonmenu_tabs = array('plugin-information'); //Valid actions to perform which do not have a Menu item.
|
||||
|
||||
$tabs = apply_filters('install_plugins_tabs', $tabs );
|
||||
$nonmenu_tabs = apply_filters('install_plugins_nonmenu_tabs', $nonmenu_tabs);
|
||||
|
||||
//If a non-valid menu tab has been selected, And its not a non-menu action.
|
||||
if ( empty($tab) || ( ! isset($tabs[ $tab ]) && ! in_array($tab, (array)$nonmenu_tabs) ) ) {
|
||||
$tab_actions = array_keys($tabs);
|
||||
$tab = $tab_actions[0];
|
||||
}
|
||||
if ( empty($paged) )
|
||||
$paged = 1;
|
||||
|
||||
wp_enqueue_style( 'plugin-install' );
|
||||
wp_enqueue_script( 'plugin-install' );
|
||||
if ( 'plugin-information' != $tab )
|
||||
|
|
|
@ -31,17 +31,6 @@ else
|
|||
|
||||
$plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
|
||||
|
||||
$default_status = get_user_option('plugins_last_view');
|
||||
if ( empty($default_status) )
|
||||
$default_status = 'all';
|
||||
$status = isset($_REQUEST['plugin_status']) ? $_REQUEST['plugin_status'] : $default_status;
|
||||
if ( !in_array($status, array('all', 'active', 'inactive', 'recent', 'upgrade', 'network', 'mustuse', 'dropins', 'search')) )
|
||||
$status = 'all';
|
||||
if ( $status != $default_status && 'search' != $status )
|
||||
update_user_meta($current_user->ID, 'plugins_last_view', $status);
|
||||
|
||||
$page = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : 1;
|
||||
|
||||
//Clean up request URI from temporary args for screen options/paging uri's to work as expected.
|
||||
$_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
|
||||
|
||||
|
@ -85,7 +74,7 @@ if ( !empty($action) ) {
|
|||
if ( ! current_user_can('activate_plugins') )
|
||||
wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
|
||||
|
||||
check_admin_referer('bulk-manage-plugins');
|
||||
check_admin_referer('bulk-plugins');
|
||||
|
||||
$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
|
||||
$plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); // Only activate plugins which are not already active.
|
||||
|
@ -108,7 +97,7 @@ if ( !empty($action) ) {
|
|||
break;
|
||||
case 'update-selected' :
|
||||
|
||||
check_admin_referer( 'bulk-manage-plugins' );
|
||||
check_admin_referer( 'bulk-plugins' );
|
||||
|
||||
if ( isset( $_GET['plugins'] ) )
|
||||
$plugins = explode( ',', $_GET['plugins'] );
|
||||
|
@ -132,7 +121,7 @@ if ( !empty($action) ) {
|
|||
|
||||
echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
|
||||
echo '</div>';
|
||||
require_once( './admin-footer.php' );
|
||||
require_once(ABSPATH . 'wp-admin/admin-footer.php');
|
||||
exit;
|
||||
break;
|
||||
case 'error_scrape':
|
||||
|
@ -178,7 +167,7 @@ if ( !empty($action) ) {
|
|||
if ( ! current_user_can('activate_plugins') )
|
||||
wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.'));
|
||||
|
||||
check_admin_referer('bulk-manage-plugins');
|
||||
check_admin_referer('bulk-plugins');
|
||||
|
||||
$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
|
||||
$plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated.
|
||||
|
@ -201,7 +190,7 @@ if ( !empty($action) ) {
|
|||
if ( ! current_user_can('delete_plugins') )
|
||||
wp_die(__('You do not have sufficient permissions to delete plugins for this site.'));
|
||||
|
||||
check_admin_referer('bulk-manage-plugins');
|
||||
check_admin_referer('bulk-plugins');
|
||||
|
||||
//$_POST = from the plugin form; $_GET = from the FTP details screen.
|
||||
$plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
|
||||
|
@ -236,8 +225,8 @@ if ( !empty($action) ) {
|
|||
$files_to_delete = array_merge($files_to_delete, $files);
|
||||
}
|
||||
// Get plugins list from that folder
|
||||
if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) ) {
|
||||
foreach( $folder_plugins as $plugin_file => $data ) {
|
||||
if ( $plugins['folder'] = get_plugins( '/' . dirname($plugin)) ) {
|
||||
foreach( $plugins['folder'] as $plugin_file => $data ) {
|
||||
$plugin_info[ $plugin_file ] = $data;
|
||||
$plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
|
||||
}
|
||||
|
@ -277,7 +266,7 @@ if ( !empty($action) ) {
|
|||
foreach ( (array) $plugins as $plugin )
|
||||
echo '<input type="hidden" name="checked[]" value="' . esc_attr($plugin) . '" />';
|
||||
?>
|
||||
<?php wp_nonce_field('bulk-manage-plugins') ?>
|
||||
<?php wp_nonce_field('bulk-plugins') ?>
|
||||
<input type="submit" name="submit" value="<?php $data_to_delete ? esc_attr_e('Yes, Delete these files and data') : esc_attr_e('Yes, Delete these files') ?>" class="button" />
|
||||
</form>
|
||||
<form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;">
|
||||
|
@ -295,7 +284,7 @@ if ( !empty($action) ) {
|
|||
</div>
|
||||
</div>
|
||||
<?php
|
||||
require_once('./admin-footer.php');
|
||||
require_once(ABSPATH . 'wp-admin/admin-footer.php');
|
||||
exit;
|
||||
} //Endif verify-delete
|
||||
$delete_result = delete_plugins($plugins);
|
||||
|
@ -310,6 +299,19 @@ if ( !empty($action) ) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( is_multisite() && is_super_admin() ) {
|
||||
$menu_perms = get_site_option('menu_items', array());
|
||||
if ( empty($menu_perms['plugins']) )
|
||||
add_action( 'admin_notices', '_admin_notice_multisite_activate_plugins_page' );
|
||||
unset($menu_perms);
|
||||
}
|
||||
|
||||
$invalid = validate_active_plugins();
|
||||
|
||||
require_once( ABSPATH . 'wp-admin/includes/default-list-tables.php' );
|
||||
|
||||
$table = new WP_Plugins_Table;
|
||||
|
||||
wp_enqueue_script('plugin-install');
|
||||
add_thickbox();
|
||||
|
||||
|
@ -328,7 +330,6 @@ $parent_file = 'plugins.php';
|
|||
|
||||
require_once(ABSPATH . 'wp-admin/admin-header.php');
|
||||
|
||||
$invalid = validate_active_plugins();
|
||||
if ( !empty($invalid) )
|
||||
foreach ( $invalid as $plugin_file => $error )
|
||||
echo '<div id="message" class="error"><p>' . sprintf(__('The plugin <code>%s</code> has been <strong>deactivated</strong> due to an error: %s'), esc_html($plugin_file), $error->get_error_message()) . '</p></div>';
|
||||
|
@ -374,325 +375,6 @@ if ( !empty($invalid) )
|
|||
<?php screen_icon(); ?>
|
||||
<h2><?php echo esc_html( $title ); if ( current_user_can('install_plugins') ) { ?> <a href="plugin-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a><?php } ?></h2>
|
||||
|
||||
<?php
|
||||
|
||||
$all_plugins = apply_filters( 'all_plugins', get_plugins() );
|
||||
$search_plugins = array();
|
||||
$active_plugins = array();
|
||||
$inactive_plugins = array();
|
||||
$recent_plugins = array();
|
||||
$recently_activated = get_option('recently_activated', array());
|
||||
$upgrade_plugins = array();
|
||||
$mustuse_plugins = $dropins_plugins = array();
|
||||
if ( ! is_multisite() || ( is_network_admin() && current_user_can('manage_network_plugins') ) ) {
|
||||
if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) )
|
||||
$mustuse_plugins = get_mu_plugins();
|
||||
if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) )
|
||||
$dropins_plugins = get_dropins();
|
||||
}
|
||||
|
||||
set_transient( 'plugin_slugs', array_keys($all_plugins), 86400 );
|
||||
|
||||
// Clean out any plugins which were deactivated over a week ago.
|
||||
foreach ( $recently_activated as $key => $time )
|
||||
if ( $time + (7*24*60*60) < time() ) //1 week
|
||||
unset($recently_activated[ $key ]);
|
||||
if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
|
||||
update_option('recently_activated', $recently_activated);
|
||||
$current = get_site_transient( 'update_plugins' );
|
||||
|
||||
foreach ( array( 'all_plugins', 'mustuse_plugins', 'dropins_plugins' ) as $plugin_array_name) {
|
||||
foreach ( (array) $$plugin_array_name as $plugin_file => $plugin_data ) {
|
||||
// Translate, Apply Markup, Sanitize HTML
|
||||
$plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
|
||||
${$plugin_array_name}[ $plugin_file ] = $plugin_data;
|
||||
}
|
||||
}
|
||||
unset( $plugin_array_name );
|
||||
|
||||
foreach ( (array) $all_plugins as $plugin_file => $plugin_data) {
|
||||
if ( is_network_admin() )
|
||||
$is_active = is_plugin_active_for_network($plugin_file);
|
||||
else
|
||||
$is_active = is_plugin_active($plugin_file);
|
||||
// Filter into individual sections
|
||||
if ( is_plugin_active_for_network($plugin_file) && !is_network_admin() ) {
|
||||
unset( $all_plugins[ $plugin_file ] );
|
||||
continue;
|
||||
} elseif ( is_multisite() && is_network_only_plugin( $plugin_file ) && !current_user_can( 'manage_network_plugins' ) ) {
|
||||
unset( $all_plugins[ $plugin_file ] );
|
||||
continue;
|
||||
} elseif ( $is_active ) {
|
||||
$active_plugins[ $plugin_file ] = $plugin_data;
|
||||
} else {
|
||||
if ( !is_network_admin() && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
|
||||
$recent_plugins[ $plugin_file ] = $plugin_data;
|
||||
$inactive_plugins[ $plugin_file ] = $plugin_data;
|
||||
}
|
||||
|
||||
if ( isset( $current->response[ $plugin_file ] ) )
|
||||
$upgrade_plugins[ $plugin_file ] = $plugin_data;
|
||||
}
|
||||
|
||||
if ( !current_user_can('update_plugins') )
|
||||
$upgrade_plugins = array();
|
||||
|
||||
$total_all_plugins = count($all_plugins);
|
||||
$total_inactive_plugins = count($inactive_plugins);
|
||||
$total_active_plugins = count($active_plugins);
|
||||
$total_recent_plugins = count($recent_plugins);
|
||||
$total_upgrade_plugins = count($upgrade_plugins);
|
||||
$total_mustuse_plugins = count($mustuse_plugins);
|
||||
$total_dropins_plugins = count($dropins_plugins);
|
||||
|
||||
// Searching.
|
||||
if ( !empty($_GET['s']) ) {
|
||||
function _search_plugins_filter_callback($plugin) {
|
||||
static $term;
|
||||
if ( is_null($term) )
|
||||
$term = stripslashes($_GET['s']);
|
||||
if ( stripos($plugin['Name'], $term) !== false ||
|
||||
stripos($plugin['Description'], $term) !== false ||
|
||||
stripos($plugin['Author'], $term) !== false ||
|
||||
stripos($plugin['PluginURI'], $term) !== false ||
|
||||
stripos($plugin['AuthorURI'], $term) !== false ||
|
||||
stripos($plugin['Version'], $term) !== false )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
$status = 'search';
|
||||
$search_plugins = array_filter($all_plugins, '_search_plugins_filter_callback');
|
||||
$total_search_plugins = count($search_plugins);
|
||||
}
|
||||
|
||||
$plugin_array_name = "${status}_plugins";
|
||||
if ( empty($$plugin_array_name) && !in_array($status, array('all', 'search')) ) {
|
||||
$status = 'all';
|
||||
$plugin_array_name = "${status}_plugins";
|
||||
}
|
||||
|
||||
$plugins = &$$plugin_array_name;
|
||||
|
||||
// Paging.
|
||||
$total_this_page = "total_{$status}_plugins";
|
||||
$total_this_page = $$total_this_page;
|
||||
$plugins_per_page = (int) get_user_option( 'plugins_per_page' );
|
||||
if ( empty( $plugins_per_page ) || $plugins_per_page < 1 )
|
||||
$plugins_per_page = 999;
|
||||
$plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page );
|
||||
|
||||
$start = ($page - 1) * $plugins_per_page;
|
||||
|
||||
$page_links = paginate_links( array(
|
||||
'base' => add_query_arg( 'paged', '%#%' ),
|
||||
'format' => '',
|
||||
'prev_text' => __('«'),
|
||||
'next_text' => __('»'),
|
||||
'total' => ceil($total_this_page / $plugins_per_page),
|
||||
'current' => $page
|
||||
));
|
||||
$page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
|
||||
number_format_i18n( $start + 1 ),
|
||||
number_format_i18n( min( $page * $plugins_per_page, $total_this_page ) ),
|
||||
'<span class="total-type-count">' . number_format_i18n( $total_this_page ) . '</span>',
|
||||
$page_links
|
||||
);
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*
|
||||
* @param array $plugins
|
||||
* @param string $context
|
||||
*/
|
||||
function print_plugins_table($plugins, $context = '') {
|
||||
global $page;
|
||||
$checkbox = ! in_array( $context, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '';
|
||||
?>
|
||||
<table class="widefat" cellspacing="0" id="<?php echo $context ?>-plugins-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="manage-column check-column"><?php echo $checkbox; ?></th>
|
||||
<th scope="col" class="manage-column"><?php _e('Plugin'); ?></th>
|
||||
<th scope="col" class="manage-column"><?php _e('Description'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th scope="col" class="manage-column check-column"><?php echo $checkbox; ?></th>
|
||||
<th scope="col" class="manage-column"><?php _e('Plugin'); ?></th>
|
||||
<th scope="col" class="manage-column"><?php _e('Description'); ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody class="plugins">
|
||||
<?php
|
||||
|
||||
if ( empty($plugins) ) {
|
||||
echo '<tr>
|
||||
<td colspan="3">' . __('No plugins to show') . '</td>
|
||||
</tr>';
|
||||
}
|
||||
foreach ( (array)$plugins as $plugin_file => $plugin_data) {
|
||||
// preorder
|
||||
$actions = array(
|
||||
'network_deactivate' => '', 'deactivate' => '',
|
||||
'network_only' => '', 'activate' => '',
|
||||
'network_activate' => '',
|
||||
'edit' => '',
|
||||
'delete' => '',
|
||||
);
|
||||
|
||||
if ( 'mustuse' == $context ) {
|
||||
if ( is_multisite() && !is_network_admin() )
|
||||
continue;
|
||||
$is_active = true;
|
||||
} elseif ( 'dropins' == $context ) {
|
||||
if ( is_multisite() && !is_network_admin() )
|
||||
continue;
|
||||
$dropins = _get_dropins();
|
||||
$plugin_name = $plugin_file;
|
||||
if ( $plugin_file != $plugin_data['Name'] )
|
||||
$plugin_name .= '<br/>' . $plugin_data['Name'];
|
||||
if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant
|
||||
$is_active = true;
|
||||
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
|
||||
} elseif ( constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true
|
||||
$is_active = true;
|
||||
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
|
||||
} else {
|
||||
$is_active = false;
|
||||
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="attention">' . __('Inactive:') . '</span></strong> ' . sprintf( __( 'Requires <code>%s</code> in <code>wp-config.php</code>.' ), "define('" . $dropins[ $plugin_file ][1] . "', true);" ) . '</p>';
|
||||
}
|
||||
if ( $plugin_data['Description'] )
|
||||
$description .= '<p>' . $plugin_data['Description'] . '</p>';
|
||||
} else {
|
||||
$is_active_for_network = is_plugin_active_for_network($plugin_file);
|
||||
if ( is_network_admin() )
|
||||
$is_active = $is_active_for_network;
|
||||
else
|
||||
$is_active = is_plugin_active( $plugin_file );
|
||||
|
||||
if ( $is_active_for_network && !is_super_admin() && !is_network_admin() )
|
||||
continue;
|
||||
|
||||
if ( is_network_admin() ) {
|
||||
if ( $is_active_for_network ) {
|
||||
if ( current_user_can( 'manage_network_plugins' ) )
|
||||
$actions['network_deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&networkwide=1&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>';
|
||||
} else {
|
||||
if ( current_user_can( 'manage_network_plugins' ) )
|
||||
$actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&networkwide=1&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
|
||||
if ( current_user_can('delete_plugins') )
|
||||
$actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
|
||||
}
|
||||
} else {
|
||||
if ( $is_active ) {
|
||||
$actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
|
||||
} else {
|
||||
if ( is_network_only_plugin( $plugin_file ) && !is_network_admin() )
|
||||
continue;
|
||||
|
||||
$actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';
|
||||
|
||||
if ( current_user_can('delete_plugins') )
|
||||
$actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'bulk-manage-plugins') . '" title="' . __('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
|
||||
} // end if $is_active
|
||||
} // end if is_network_admin()
|
||||
|
||||
if ( current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
|
||||
$actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . __('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>';
|
||||
} // end if $context
|
||||
|
||||
$actions = apply_filters( 'plugin_action_links', array_filter( $actions ), $plugin_file, $plugin_data, $context );
|
||||
$actions = apply_filters( "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context );
|
||||
|
||||
$class = $is_active ? 'active' : 'inactive';
|
||||
$checkbox = in_array( $context, array( 'mustuse', 'dropins' ) ) ? '' : "<input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' />";
|
||||
if ( 'dropins' != $context ) {
|
||||
$description = '<p>' . $plugin_data['Description'] . '</p>';
|
||||
$plugin_name = $plugin_data['Name'];
|
||||
}
|
||||
echo "
|
||||
<tr class='$class'>
|
||||
<th scope='row' class='check-column'>$checkbox</th>
|
||||
<td class='plugin-title'><strong>$plugin_name</strong></td>
|
||||
<td class='desc'>$description</td>
|
||||
</tr>
|
||||
<tr class='$class second'>
|
||||
<td></td>
|
||||
<td class='plugin-title'>";
|
||||
echo '<div class="row-actions-visible">';
|
||||
foreach ( $actions as $action => $link ) {
|
||||
$sep = end($actions) == $link ? '' : ' | ';
|
||||
echo "<span class='$action'>$link$sep</span>";
|
||||
}
|
||||
echo "</div></td>
|
||||
<td class='desc'>";
|
||||
$plugin_meta = array();
|
||||
if ( !empty($plugin_data['Version']) )
|
||||
$plugin_meta[] = sprintf(__('Version %s'), $plugin_data['Version']);
|
||||
if ( !empty($plugin_data['Author']) ) {
|
||||
$author = $plugin_data['Author'];
|
||||
if ( !empty($plugin_data['AuthorURI']) )
|
||||
$author = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>';
|
||||
$plugin_meta[] = sprintf( __('By %s'), $author );
|
||||
}
|
||||
if ( ! empty($plugin_data['PluginURI']) )
|
||||
$plugin_meta[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin site' ) . '">' . __('Visit plugin site') . '</a>';
|
||||
|
||||
$plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $context);
|
||||
echo implode(' | ', $plugin_meta);
|
||||
echo "</td>
|
||||
</tr>\n";
|
||||
|
||||
do_action( 'after_plugin_row', $plugin_file, $plugin_data, $context );
|
||||
do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $context );
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
} //End print_plugins_table()
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*
|
||||
* @param string $context
|
||||
*/
|
||||
function print_plugin_actions($context, $field_name = 'action' ) {
|
||||
if ( in_array( $context, array( 'mustuse', 'dropins' ) ) )
|
||||
return;
|
||||
?>
|
||||
<div class="alignleft actions">
|
||||
<select name="<?php echo $field_name; ?>">
|
||||
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||
<?php if ( 'active' != $context ) : ?>
|
||||
<option value="activate-selected"><?php _e('Activate'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( is_multisite() && 'network' != $context ) : ?>
|
||||
<option value="network-activate-selected"><?php _e('Network Activate'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'inactive' != $context && 'recent' != $context ) : ?>
|
||||
<option value="deactivate-selected"><?php _e('Deactivate'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( current_user_can( 'update_plugins' ) ) : ?>
|
||||
<option value="update-selected"><?php _e( 'Upgrade' ); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( current_user_can('delete_plugins') && ( 'active' != $context ) ) : ?>
|
||||
<option value="delete-selected"><?php _e('Delete'); ?></option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<input type="submit" name="doaction_active" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary action" />
|
||||
<?php if ( 'recent' == $context ) : ?>
|
||||
<input type="submit" name="clear-recent-list" value="<?php esc_attr_e('Clear List') ?>" class="button-secondary" />
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<form method="get" action="">
|
||||
<p class="search-box">
|
||||
<label class="screen-reader-text" for="plugin-search-input"><?php _e( 'Search Plugins' ); ?>:</label>
|
||||
|
@ -701,50 +383,55 @@ function print_plugin_actions($context, $field_name = 'action' ) {
|
|||
</p>
|
||||
</form>
|
||||
|
||||
<?php do_action( 'pre_current_active_plugins', $all_plugins ) ?>
|
||||
<?php do_action( 'pre_current_active_plugins', $plugins['all'] ) ?>
|
||||
|
||||
<form method="post" action="plugins.php">
|
||||
<?php wp_nonce_field('bulk-manage-plugins') ?>
|
||||
<form method="post" action="">
|
||||
<input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
|
||||
<input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
|
||||
|
||||
<ul class="subsubsub">
|
||||
<?php
|
||||
|
||||
$status_links = array();
|
||||
$class = ( 'all' == $status ) ? ' class="current"' : '';
|
||||
$status_links[] = "<li><a href='plugins.php?plugin_status=all' $class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_all_plugins, 'plugins' ), number_format_i18n( $total_all_plugins ) ) . '</a>';
|
||||
if ( ! empty($active_plugins) ) {
|
||||
$class = ( 'active' == $status ) ? ' class="current"' : '';
|
||||
$status_links[] = "<li><a href='plugins.php?plugin_status=active' $class>" . sprintf( _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $total_active_plugins ), number_format_i18n( $total_active_plugins ) ) . '</a>';
|
||||
foreach ( $totals as $type => $count ) {
|
||||
if ( !$count )
|
||||
continue;
|
||||
|
||||
switch ( $type ) {
|
||||
case 'all':
|
||||
$text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins' );
|
||||
break;
|
||||
case 'active':
|
||||
$text = _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $count );
|
||||
break;
|
||||
case 'recently_activated':
|
||||
$text = _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count );
|
||||
break;
|
||||
case 'inactive':
|
||||
$text = _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count );
|
||||
break;
|
||||
case 'network':
|
||||
$text = _n( 'Network <span class="count">(%s)</span>', 'Network <span class="count">(%s)</span>', $count );
|
||||
break;
|
||||
case 'mustuse':
|
||||
$text = _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $count );
|
||||
break;
|
||||
case 'dropins':
|
||||
$text = _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $count );
|
||||
break;
|
||||
case 'upgrade':
|
||||
$text = _n( 'Upgrade Available <span class="count">(%s)</span>', 'Upgrade Available <span class="count">(%s)</span>', $count );
|
||||
break;
|
||||
case 'search':
|
||||
$text = _n( 'Search Results <span class="count">(%s)</span>', 'Search Results <span class="count">(%s)</span>', $count );
|
||||
break;
|
||||
}
|
||||
if ( ! empty($recent_plugins) ) {
|
||||
$class = ( 'recent' == $status ) ? ' class="current"' : '';
|
||||
$status_links[] = "<li><a href='plugins.php?plugin_status=recent' $class>" . sprintf( _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $total_recent_plugins ), number_format_i18n( $total_recent_plugins ) ) . '</a>';
|
||||
}
|
||||
if ( ! empty($inactive_plugins) ) {
|
||||
$class = ( 'inactive' == $status ) ? ' class="current"' : '';
|
||||
$status_links[] = "<li><a href='plugins.php?plugin_status=inactive' $class>" . sprintf( _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $total_inactive_plugins ), number_format_i18n( $total_inactive_plugins ) ) . '</a>';
|
||||
}
|
||||
if ( ! empty($network_plugins) ) {
|
||||
$class = ( 'network' == $status ) ? ' class="current"' : '';
|
||||
$status_links[] = "<li><a href='plugins.php?plugin_status=network' $class>" . sprintf( _n( 'Network <span class="count">(%s)</span>', 'Network <span class="count">(%s)</span>', $total_network_plugins ), number_format_i18n( $total_network_plugins ) ) . '</a>';
|
||||
}
|
||||
if ( ! empty($mustuse_plugins) ) {
|
||||
$class = ( 'mustuse' == $status ) ? ' class="current"' : '';
|
||||
$status_links[] = "<li><a href='plugins.php?plugin_status=mustuse' $class>" . sprintf( _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $total_mustuse_plugins ), number_format_i18n( $total_mustuse_plugins ) ) . '</a>';
|
||||
}
|
||||
if ( ! empty($dropins_plugins) ) {
|
||||
$class = ( 'dropins' == $status ) ? ' class="current"' : '';
|
||||
$status_links[] = "<li><a href='plugins.php?plugin_status=dropins' $class>" . sprintf( _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $total_dropins_plugins ), number_format_i18n( $total_dropins_plugins ) ) . '</a>';
|
||||
}
|
||||
if ( ! empty($upgrade_plugins) ) {
|
||||
$class = ( 'upgrade' == $status ) ? ' class="current"' : '';
|
||||
$status_links[] = "<li><a href='plugins.php?plugin_status=upgrade' $class>" . sprintf( _n( 'Upgrade Available <span class="count">(%s)</span>', 'Upgrade Available <span class="count">(%s)</span>', $total_upgrade_plugins ), number_format_i18n( $total_upgrade_plugins ) ) . '</a>';
|
||||
}
|
||||
if ( ! empty($search_plugins) ) {
|
||||
$class = ( 'search' == $status ) ? ' class="current"' : '';
|
||||
$term = isset($_REQUEST['s']) ? urlencode(stripslashes($_REQUEST['s'])) : '';
|
||||
$status_links[] = "<li><a href='plugins.php?s=$term' $class>" . sprintf( _n( 'Search Results <span class="count">(%s)</span>', 'Search Results <span class="count">(%s)</span>', $total_search_plugins ), number_format_i18n( $total_search_plugins ) ) . '</a>';
|
||||
|
||||
$status_links[] = sprintf( "<li><a href='%s' %s>%s</a>",
|
||||
add_query_arg('plugin_status', $type, 'plugins.php'),
|
||||
( $type == $status ) ? ' class="current"' : '',
|
||||
sprintf( $text, number_format_i18n( $count ) )
|
||||
);
|
||||
}
|
||||
echo implode( " |</li>\n", $status_links ) . '</li>';
|
||||
unset( $status_links );
|
||||
|
@ -753,49 +440,15 @@ unset( $status_links );
|
|||
|
||||
<?php
|
||||
if ( 'mustuse' == $status )
|
||||
echo '<div class="clear"></div><p>' . __( 'Files in the <code>/wp-content/mu-plugins</code> directory are executed automatically.' ) . '</p>';
|
||||
echo '<br class="clear"><p>' . __( 'Files in the <code>/wp-content/mu-plugins</code> directory are executed automatically.' ) . '</p>';
|
||||
elseif ( 'dropins' == $status )
|
||||
echo '<div class="clear"></div><p>' . __( 'Drop-ins are advanced plugins in the <code>/wp-content</code> directory that replace WordPress functionality when present.' ) . '</p>';
|
||||
|
||||
if ( !empty( $plugins ) && ( ! in_array( $status, array( 'mustuse', 'dropins' ) ) || $page_links ) ) :
|
||||
echo '<br class="clear"><p>' . __( 'Drop-ins are advanced plugins in the <code>/wp-content</code> directory that replace WordPress functionality when present.' ) . '</p>';
|
||||
?>
|
||||
<div class="tablenav">
|
||||
<?php
|
||||
if ( $page_links )
|
||||
echo '<div class="tablenav-pages">', $page_links_text, '</div>';
|
||||
|
||||
print_plugin_actions($status);
|
||||
?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
if ( $total_this_page > $plugins_per_page )
|
||||
$plugins = array_slice($plugins, $start, $plugins_per_page);
|
||||
|
||||
print_plugins_table($plugins, $status);
|
||||
|
||||
if ( !empty( $plugins ) && ! in_array( $status, array( 'mustuse', 'dropins' ) ) || $page_links ) {
|
||||
?>
|
||||
<div class="tablenav">
|
||||
<?php
|
||||
if ( $page_links )
|
||||
echo "<div class='tablenav-pages'>$page_links_text</div>";
|
||||
|
||||
print_plugin_actions($status, "action2");
|
||||
?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php $table->display(); ?>
|
||||
</form>
|
||||
|
||||
<?php if ( empty($all_plugins) ) : ?>
|
||||
<br class="clear" />
|
||||
<p><?php _e('You do not appear to have any plugins available at this time.') ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
include(ABSPATH . 'wp-admin/admin-footer.php');
|
||||
?>
|
||||
|
|
|
@ -12,43 +12,20 @@ require_once('./admin.php');
|
|||
if ( ! current_user_can('install_themes') )
|
||||
wp_die(__('You do not have sufficient permissions to install themes on this site.'));
|
||||
|
||||
include(ABSPATH . 'wp-admin/includes/theme-install.php');
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
|
||||
$table = new WP_Theme_Install_Table;
|
||||
|
||||
$title = __('Install Themes');
|
||||
$parent_file = 'themes.php';
|
||||
$submenu_file = 'themes.php';
|
||||
|
||||
wp_reset_vars( array('tab', 'paged') );
|
||||
wp_enqueue_style( 'theme-install' );
|
||||
wp_enqueue_script( 'theme-install' );
|
||||
|
||||
add_thickbox();
|
||||
wp_enqueue_script( 'theme-preview' );
|
||||
|
||||
//These are the tabs which are shown on the page,
|
||||
$tabs = array();
|
||||
$tabs['dashboard'] = __('Search');
|
||||
if ( 'search' == $tab )
|
||||
$tabs['search'] = __('Search Results');
|
||||
$tabs['upload'] = __('Upload');
|
||||
$tabs['featured'] = _x('Featured','Theme Installer');
|
||||
//$tabs['popular'] = _x('Popular','Theme Installer');
|
||||
$tabs['new'] = _x('Newest','Theme Installer');
|
||||
$tabs['updated'] = _x('Recently Updated','Theme Installer');
|
||||
|
||||
$nonmenu_tabs = array('theme-information'); //Valid actions to perform which do not have a Menu item.
|
||||
|
||||
$tabs = apply_filters('install_themes_tabs', $tabs );
|
||||
$nonmenu_tabs = apply_filters('install_themes_nonmenu_tabs', $nonmenu_tabs);
|
||||
|
||||
//If a non-valid menu tab has been selected, And its not a non-menu action.
|
||||
if ( empty($tab) || ( ! isset($tabs[ $tab ]) && ! in_array($tab, (array)$nonmenu_tabs) ) ) {
|
||||
$tab_actions = array_keys($tabs);
|
||||
$tab = $tab_actions[0];
|
||||
}
|
||||
if ( empty($paged) )
|
||||
$paged = 1;
|
||||
|
||||
$body_id = $tab;
|
||||
|
||||
do_action('install_themes_pre_' . $tab); //Used to override the general interface, Eg, install or theme information.
|
||||
|
@ -83,3 +60,4 @@ foreach ( (array)$tabs as $action => $text ) {
|
|||
</div>
|
||||
<?php
|
||||
include('./admin-footer.php');
|
||||
|
||||
|
|
|
@ -28,6 +28,10 @@ if ( current_user_can('switch_themes') && isset($_GET['action']) ) {
|
|||
}
|
||||
}
|
||||
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
|
||||
$table = new WP_Themes_Table;
|
||||
|
||||
$title = __('Manage Themes');
|
||||
$parent_file = 'themes.php';
|
||||
|
||||
|
@ -65,34 +69,6 @@ if ( is_multisite() && current_user_can('edit_themes') ) {
|
|||
elseif ( isset($_GET['deleted']) ) : ?>
|
||||
<div id="message3" class="updated"><p><?php _e('Theme deleted.') ?></p></div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
$themes = get_allowed_themes();
|
||||
$ct = current_theme_info();
|
||||
unset($themes[$ct->name]);
|
||||
|
||||
uksort( $themes, "strnatcasecmp" );
|
||||
$theme_total = count( $themes );
|
||||
$per_page = 15;
|
||||
|
||||
if ( isset( $_GET['pagenum'] ) )
|
||||
$page = absint( $_GET['pagenum'] );
|
||||
|
||||
if ( empty($page) )
|
||||
$page = 1;
|
||||
|
||||
$start = $offset = ( $page - 1 ) * $per_page;
|
||||
|
||||
$page_links = paginate_links( array(
|
||||
'base' => add_query_arg( 'pagenum', '%#%' ) . '#themenav',
|
||||
'format' => '',
|
||||
'prev_text' => __('«'),
|
||||
'next_text' => __('»'),
|
||||
'total' => ceil($theme_total / $per_page),
|
||||
'current' => $page
|
||||
));
|
||||
|
||||
$themes = array_slice( $themes, $start, $per_page );
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<?php screen_icon(); ?>
|
||||
|
@ -119,7 +95,7 @@ $themes = array_slice( $themes, $start, $per_page );
|
|||
|
||||
</div>
|
||||
|
||||
<div class="clear"></div>
|
||||
<br class="clear">
|
||||
<?php
|
||||
if ( ! current_user_can( 'switch_themes' ) ) {
|
||||
echo '</div>';
|
||||
|
@ -128,119 +104,8 @@ if ( ! current_user_can( 'switch_themes' ) ) {
|
|||
}
|
||||
?>
|
||||
<h3><?php _e('Available Themes'); ?></h3>
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php if ( $theme_total ) { ?>
|
||||
|
||||
<?php if ( $page_links ) : ?>
|
||||
<div class="tablenav">
|
||||
<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
|
||||
number_format_i18n( $start + 1 ),
|
||||
number_format_i18n( min( $page * $per_page, $theme_total ) ),
|
||||
number_format_i18n( $theme_total ),
|
||||
$page_links
|
||||
); echo $page_links_text; ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<table id="availablethemes" cellspacing="0" cellpadding="0">
|
||||
<?php
|
||||
$style = '';
|
||||
|
||||
$theme_names = array_keys($themes);
|
||||
natcasesort($theme_names);
|
||||
|
||||
$table = array();
|
||||
$rows = ceil(count($theme_names) / 3);
|
||||
for ( $row = 1; $row <= $rows; $row++ )
|
||||
for ( $col = 1; $col <= 3; $col++ )
|
||||
$table[$row][$col] = array_shift($theme_names);
|
||||
|
||||
foreach ( $table as $row => $cols ) {
|
||||
?>
|
||||
<tr>
|
||||
<?php
|
||||
foreach ( $cols as $col => $theme_name ) {
|
||||
$class = array('available-theme');
|
||||
if ( $row == 1 ) $class[] = 'top';
|
||||
if ( $col == 1 ) $class[] = 'left';
|
||||
if ( $row == $rows ) $class[] = 'bottom';
|
||||
if ( $col == 3 ) $class[] = 'right';
|
||||
?>
|
||||
<td class="<?php echo join(' ', $class); ?>">
|
||||
<?php if ( !empty($theme_name) ) :
|
||||
$template = $themes[$theme_name]['Template'];
|
||||
$stylesheet = $themes[$theme_name]['Stylesheet'];
|
||||
$title = $themes[$theme_name]['Title'];
|
||||
$version = $themes[$theme_name]['Version'];
|
||||
$description = $themes[$theme_name]['Description'];
|
||||
$author = $themes[$theme_name]['Author'];
|
||||
$screenshot = $themes[$theme_name]['Screenshot'];
|
||||
$stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
|
||||
$template_dir = $themes[$theme_name]['Template Dir'];
|
||||
$parent_theme = $themes[$theme_name]['Parent Theme'];
|
||||
$theme_root = $themes[$theme_name]['Theme Root'];
|
||||
$theme_root_uri = $themes[$theme_name]['Theme Root URI'];
|
||||
$preview_link = esc_url(get_option('home') . '/');
|
||||
if ( is_ssl() )
|
||||
$preview_link = str_replace( 'http://', 'https://', $preview_link );
|
||||
$preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true' ), $preview_link ) );
|
||||
$preview_text = esc_attr( sprintf( __('Preview of “%s”'), $title ) );
|
||||
$tags = $themes[$theme_name]['Tags'];
|
||||
$thickbox_class = 'thickbox thickbox-preview';
|
||||
$activate_link = wp_nonce_url("themes.php?action=activate&template=".urlencode($template)."&stylesheet=".urlencode($stylesheet), 'switch-theme_' . $template);
|
||||
$activate_text = esc_attr( sprintf( __('Activate “%s”'), $title ) );
|
||||
$actions = array();
|
||||
$actions[] = '<a href="' . $activate_link . '" class="activatelink" title="' . $activate_text . '">' . __('Activate') . '</a>';
|
||||
$actions[] = '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview “%s”'), $theme_name)) . '">' . __('Preview') . '</a>';
|
||||
if ( current_user_can('delete_themes') )
|
||||
$actions[] = '<a class="submitdelete deletion" href="' . wp_nonce_url("themes.php?action=delete&template=$stylesheet", 'delete-theme_' . $stylesheet) . '" onclick="' . "return confirm('" . esc_js(sprintf( __("You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete."), $theme_name )) . "');" . '">' . __('Delete') . '</a>';
|
||||
$actions = apply_filters('theme_action_links', $actions, $themes[$theme_name]);
|
||||
|
||||
$actions = implode ( ' | ', $actions );
|
||||
?>
|
||||
<a href="<?php echo $preview_link; ?>" class="<?php echo $thickbox_class; ?> screenshot">
|
||||
<?php if ( $screenshot ) : ?>
|
||||
<img src="<?php echo $theme_root_uri . '/' . $stylesheet . '/' . $screenshot; ?>" alt="" />
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<h3><?php
|
||||
/* translators: 1: theme title, 2: theme version, 3: theme author */
|
||||
printf(__('%1$s %2$s by %3$s'), $title, $version, $author) ; ?></h3>
|
||||
<p class="description"><?php echo $description; ?></p>
|
||||
<span class='action-links'><?php echo $actions ?></span>
|
||||
<?php if ( current_user_can('edit_themes') && $parent_theme ) {
|
||||
/* translators: 1: theme title, 2: template dir, 3: stylesheet_dir, 4: theme title, 5: parent_theme */ ?>
|
||||
<p><?php printf(__('The template files are located in <code>%2$s</code>. The stylesheet files are located in <code>%3$s</code>. <strong>%4$s</strong> uses templates from <strong>%5$s</strong>. Changes made to the templates will affect both themes.'), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ), $title, $parent_theme); ?></p>
|
||||
<?php } else { ?>
|
||||
<p><?php printf(__('All of this theme’s files are located in <code>%2$s</code>.'), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ) ); ?></p>
|
||||
<?php } ?>
|
||||
<?php if ( $tags ) : ?>
|
||||
<p><?php _e('Tags:'); ?> <?php echo join(', ', $tags); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php theme_update_available( $themes[$theme_name] ); ?>
|
||||
<?php endif; // end if not empty theme_name ?>
|
||||
</td>
|
||||
<?php } // end foreach $cols ?>
|
||||
</tr>
|
||||
<?php } // end foreach $table ?>
|
||||
</table>
|
||||
<?php } else { ?>
|
||||
<p><?php
|
||||
if ( current_user_can('install_themes') )
|
||||
printf(__('You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress.org Theme Directory at any time: just click on the <em><a href="%s">Install Themes</a></em> tab above.'), 'theme-install.php');
|
||||
else
|
||||
printf(__('Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.'), get_site_option('site_name'));
|
||||
?></p>
|
||||
<?php } // end if $theme_total?>
|
||||
<br class="clear" />
|
||||
|
||||
<?php if ( $page_links ) : ?>
|
||||
<div class="tablenav">
|
||||
<?php echo "<div class='tablenav-pages'>$page_links_text</div>"; ?>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php $table->display(); ?>
|
||||
|
||||
<br class="clear" />
|
||||
|
||||
|
|
|
@ -8,26 +8,16 @@
|
|||
|
||||
/** WordPress Administration Bootstrap */
|
||||
require_once( './admin.php' );
|
||||
wp_enqueue_script( 'wp-ajax-response' );
|
||||
wp_enqueue_script( 'jquery-ui-draggable' );
|
||||
|
||||
if ( !current_user_can('upload_files') )
|
||||
wp_die(__('You do not have permission to upload files.'));
|
||||
|
||||
if ( isset($_GET['find_detached']) ) {
|
||||
// Handle bulk actions
|
||||
if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) {
|
||||
check_admin_referer( 'bulk-media' );
|
||||
|
||||
if ( !current_user_can('edit_posts') )
|
||||
wp_die( __('You are not allowed to scan for lost attachments.') );
|
||||
|
||||
$lost = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent > '0' and post_parent NOT IN ( SELECT ID FROM $wpdb->posts WHERE post_type NOT IN ('attachment', '" . join("', '", get_post_types( array( 'public' => false ) ) ) . "') )");
|
||||
|
||||
$_GET['detached'] = 1;
|
||||
|
||||
} elseif ( isset($_GET['found_post_id']) && isset($_GET['media']) ) {
|
||||
check_admin_referer('bulk-media');
|
||||
|
||||
if ( ! ( $parent_id = (int) $_GET['found_post_id'] ) )
|
||||
$parent_id = (int) $_REQUEST['found_post_id'];
|
||||
if ( !$parent_id )
|
||||
return;
|
||||
|
||||
$parent = &get_post( $parent_id );
|
||||
|
@ -35,7 +25,7 @@ if ( isset($_GET['find_detached']) ) {
|
|||
wp_die( __( 'You are not allowed to edit this post.' ) );
|
||||
|
||||
$attach = array();
|
||||
foreach( (array) $_GET['media'] as $att_id ) {
|
||||
foreach ( (array) $_REQUEST['media'] as $att_id ) {
|
||||
$att_id = (int) $att_id;
|
||||
|
||||
if ( !current_user_can( 'edit_post', $att_id ) )
|
||||
|
@ -62,15 +52,15 @@ if ( isset($_GET['find_detached']) ) {
|
|||
exit;
|
||||
}
|
||||
|
||||
} elseif ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
|
||||
} elseif ( isset( $_REQUEST['doaction'] ) || isset( $_REQUEST['doaction2'] ) || isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
|
||||
check_admin_referer( 'bulk-media' );
|
||||
|
||||
if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
|
||||
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
|
||||
$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
|
||||
$doaction = 'delete';
|
||||
} elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['media']) || isset($_GET['ids']) ) ) {
|
||||
$post_ids = isset($_GET['media']) ? $_GET['media'] : explode(',', $_GET['ids']);
|
||||
$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
|
||||
} elseif ( ( $_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1 ) && ( isset( $_REQUEST['media'] ) || isset( $_REQUEST['ids'] ) ) ) {
|
||||
$post_ids = isset( $_REQUEST['media'] ) ? $_REQUEST['media'] : explode( ',', $_REQUEST['ids'] );
|
||||
$doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2'];
|
||||
} else {
|
||||
wp_redirect( $_SERVER['HTTP_REFERER'] );
|
||||
}
|
||||
|
@ -116,51 +106,20 @@ if ( isset($_GET['find_detached']) ) {
|
|||
|
||||
wp_redirect( $location );
|
||||
exit;
|
||||
} elseif ( ! empty($_GET['_wp_http_referer']) ) {
|
||||
} elseif ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
||||
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
|
||||
$table = new WP_Media_Table;
|
||||
|
||||
$title = __('Media Library');
|
||||
$parent_file = 'upload.php';
|
||||
|
||||
if ( ! isset( $_GET['paged'] ) || $_GET['paged'] < 1 )
|
||||
$_GET['paged'] = 1;
|
||||
|
||||
if ( isset($_GET['detached']) ) {
|
||||
|
||||
$media_per_page = (int) get_user_option( 'upload_per_page' );
|
||||
if ( empty($media_per_page) || $media_per_page < 1 )
|
||||
$media_per_page = 20;
|
||||
$media_per_page = apply_filters( 'upload_per_page', $media_per_page );
|
||||
|
||||
if ( !empty($lost) ) {
|
||||
$start = ( (int) $_GET['paged'] - 1 ) * $media_per_page;
|
||||
$page_links_total = ceil(count($lost) / $media_per_page);
|
||||
$lost = implode(',', $lost);
|
||||
|
||||
$orphans = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' AND ID IN (%s) LIMIT %d, %d", $lost, $start, $media_per_page ) );
|
||||
} else {
|
||||
$start = ( (int) $_GET['paged'] - 1 ) * $media_per_page;
|
||||
$orphans = $wpdb->get_results( $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1 LIMIT %d, %d", $start, $media_per_page ) );
|
||||
$total_orphans = $wpdb->get_var( "SELECT FOUND_ROWS()" );
|
||||
$page_links_total = ceil( $total_orphans / $media_per_page );
|
||||
$wp_query->found_posts = $total_orphans;
|
||||
$wp_query->query_vars['posts_per_page'] = $media_per_page;
|
||||
}
|
||||
|
||||
$post_mime_types = get_post_mime_types();
|
||||
$avail_post_mime_types = get_available_post_mime_types('attachment');
|
||||
|
||||
if ( isset($_GET['post_mime_type']) && !array_intersect( (array) $_GET['post_mime_type'], array_keys($post_mime_types) ) )
|
||||
unset($_GET['post_mime_type']);
|
||||
|
||||
} else {
|
||||
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
|
||||
}
|
||||
|
||||
$is_trash = ( isset($_GET['status']) && $_GET['status'] == 'trash' );
|
||||
|
||||
wp_enqueue_script( 'wp-ajax-response' );
|
||||
wp_enqueue_script( 'jquery-ui-draggable' );
|
||||
wp_enqueue_script( 'media' );
|
||||
|
||||
add_contextual_help( $current_screen,
|
||||
|
@ -239,7 +198,7 @@ foreach ( $matches as $type => $reals )
|
|||
foreach ( $reals as $real )
|
||||
$num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
|
||||
|
||||
$class = ( empty($_GET['post_mime_type']) && !isset($_GET['detached']) && !isset($_GET['status']) ) ? ' class="current"' : '';
|
||||
$class = ( empty($_GET['post_mime_type']) && !$detached && !isset($_GET['status']) ) ? ' class="current"' : '';
|
||||
$type_links[] = "<li><a href='upload.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '</a>';
|
||||
foreach ( $post_mime_types as $mime_type => $label ) {
|
||||
$class = '';
|
||||
|
@ -252,7 +211,7 @@ foreach ( $post_mime_types as $mime_type => $label ) {
|
|||
if ( !empty( $num_posts[$mime_type] ) )
|
||||
$type_links[] = "<li><a href='upload.php?post_mime_type=$mime_type'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</a>';
|
||||
}
|
||||
$type_links[] = '<li><a href="upload.php?detached=1"' . ( isset($_GET['detached']) ? ' class="current"' : '' ) . '>' . sprintf( _nx( 'Unattached <span class="count">(%s)</span>', 'Unattached <span class="count">(%s)</span>', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</a>';
|
||||
$type_links[] = '<li><a href="upload.php?detached=1"' . ( $detached ? ' class="current"' : '' ) . '>' . sprintf( _nx( 'Unattached <span class="count">(%s)</span>', 'Unattached <span class="count">(%s)</span>', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</a>';
|
||||
|
||||
if ( !empty($_num_posts['trash']) )
|
||||
$type_links[] = '<li><a href="upload.php?status=trash"' . ( (isset($_GET['status']) && $_GET['status'] == 'trash' ) ? ' class="current"' : '') . '>' . sprintf( _nx( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '</a>';
|
||||
|
@ -270,234 +229,12 @@ unset($type_links);
|
|||
</p>
|
||||
</form>
|
||||
|
||||
<form id="posts-filter" action="" method="get">
|
||||
<?php wp_nonce_field('bulk-media'); ?>
|
||||
<?php if ( have_posts() || isset( $orphans ) ) { ?>
|
||||
<div class="tablenav">
|
||||
<?php
|
||||
if ( ! isset($page_links_total) )
|
||||
$page_links_total = $wp_query->max_num_pages;
|
||||
|
||||
$page_links = paginate_links( array(
|
||||
'base' => add_query_arg( 'paged', '%#%' ),
|
||||
'format' => '',
|
||||
'prev_text' => __('«'),
|
||||
'next_text' => __('»'),
|
||||
'total' => $page_links_total,
|
||||
'current' => $_GET['paged']
|
||||
));
|
||||
|
||||
if ( $page_links ) : ?>
|
||||
<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
|
||||
number_format_i18n( ( $_GET['paged'] - 1 ) * $wp_query->query_vars['posts_per_page'] + 1 ),
|
||||
number_format_i18n( min( $_GET['paged'] * $wp_query->query_vars['posts_per_page'], $wp_query->found_posts ) ),
|
||||
number_format_i18n( $wp_query->found_posts ),
|
||||
$page_links
|
||||
); echo $page_links_text; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<?php if ( ! isset( $orphans ) || ! empty( $orphans ) ) { ?>
|
||||
<select name="action" class="select-action">
|
||||
<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||
<?php if ( $is_trash ) { ?>
|
||||
<option value="untrash"><?php _e('Restore'); ?></option>
|
||||
<?php } if ( $is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) { ?>
|
||||
<option value="delete"><?php _e('Delete Permanently'); ?></option>
|
||||
<?php } else { ?>
|
||||
<option value="trash"><?php _e('Move to Trash'); ?></option>
|
||||
<?php } if ( isset($orphans) ) { ?>
|
||||
<option value="attach"><?php _e('Attach to a post'); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
|
||||
|
||||
<?php
|
||||
if ( !is_singular() && !isset($_GET['detached']) && !$is_trash ) {
|
||||
$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
|
||||
|
||||
$arc_result = $wpdb->get_results( $arc_query );
|
||||
|
||||
$month_count = count($arc_result);
|
||||
|
||||
if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) : ?>
|
||||
<select name='m'>
|
||||
<option value='0'><?php _e('Show all dates'); ?></option>
|
||||
<?php
|
||||
foreach ($arc_result as $arc_row) {
|
||||
if ( $arc_row->yyear == 0 )
|
||||
continue;
|
||||
$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
|
||||
|
||||
if ( isset($_GET['m']) && ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) )
|
||||
$default = ' selected="selected"';
|
||||
else
|
||||
$default = '';
|
||||
|
||||
echo "<option$default value='" . esc_attr("$arc_row->yyear$arc_row->mmonth") . "'>";
|
||||
echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
|
||||
echo "</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php endif; // month_count ?>
|
||||
|
||||
<?php do_action('restrict_manage_posts'); ?>
|
||||
|
||||
<input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
|
||||
|
||||
<?php } // ! is_singular ?>
|
||||
|
||||
<?php
|
||||
|
||||
} // ! empty( $orphans )
|
||||
|
||||
if ( isset($_GET['detached']) ) { ?>
|
||||
<input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" />
|
||||
<?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' && current_user_can('edit_others_posts') ) { ?>
|
||||
<input type="submit" id="delete_all" name="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<?php } // have_posts() || !empty( $orphans ) ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php if ( ! empty( $orphans ) ) { ?>
|
||||
<table class="widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="check-column"><input type="checkbox" /></th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col"><?php /* translators: column name in media */ _ex('Media', 'media column name'); ?></th>
|
||||
<th scope="col"><?php /* translators: column name in media */ _ex('Author', 'media column name'); ?></th>
|
||||
<th scope="col"><?php /* translators: column name in media */ _ex('Date Added', 'media column name'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th scope="col" class="check-column"><input type="checkbox" /></th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col"><?php /* translators: column name in media */ _ex('Media', 'media column name'); ?></th>
|
||||
<th scope="col"><?php /* translators: column name in media */ _ex('Author', 'media column name'); ?></th>
|
||||
<th scope="col"><?php /* translators: column name in media */ _ex('Date Added', 'media column name'); ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody id="the-list" class="list:post">
|
||||
<?php
|
||||
foreach ( $orphans as $post ) {
|
||||
$class = 'alternate' == $class ? '' : 'alternate';
|
||||
$att_title = esc_html( _draft_or_post_title($post->ID) );
|
||||
?>
|
||||
<tr id='post-<?php echo $post->ID; ?>' class='<?php echo $class; ?>' valign="top">
|
||||
<th scope="row" class="check-column"><?php if ( current_user_can('edit_post', $post->ID) ) { ?><input type="checkbox" name="media[]" value="<?php echo esc_attr($post->ID); ?>" /><?php } ?></th>
|
||||
|
||||
<td class="media-icon"><?php
|
||||
if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) { ?>
|
||||
<a href="media.php?action=edit&attachment_id=<?php echo $post->ID; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?>"><?php echo $thumb; ?></a>
|
||||
<?php } ?></td>
|
||||
|
||||
<td class="media column-media"><strong><a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $att_title)); ?>"><?php echo $att_title; ?></a></strong><br />
|
||||
<?php
|
||||
if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) )
|
||||
echo esc_html( strtoupper( $matches[1] ) );
|
||||
else
|
||||
echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) );
|
||||
?>
|
||||
|
||||
<div class="row-actions">
|
||||
<?php
|
||||
$actions = array();
|
||||
if ( current_user_can('edit_post', $post->ID) )
|
||||
$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
|
||||
if ( current_user_can('delete_post', $post->ID) )
|
||||
if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
|
||||
$actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-attachment_' . $post->ID) . "'>" . __('Trash') . "</a>";
|
||||
} else {
|
||||
$delete_ays = !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
|
||||
$actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-attachment_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
|
||||
}
|
||||
$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>';
|
||||
if ( current_user_can('edit_post', $post->ID) )
|
||||
$actions['attach'] = '<a href="#the-list" onclick="findPosts.open(\'media[]\',\''.$post->ID.'\');return false;" class="hide-if-no-js">'.__('Attach').'</a>';
|
||||
$actions = apply_filters( 'media_row_actions', $actions, $post );
|
||||
$action_count = count($actions);
|
||||
$i = 0;
|
||||
foreach ( $actions as $action => $link ) {
|
||||
++$i;
|
||||
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
||||
echo "<span class='$action'>$link$sep</span>";
|
||||
} ?>
|
||||
</div></td>
|
||||
<td class="author column-author"><?php $author = get_userdata($post->post_author); echo $author->display_name; ?></td>
|
||||
<?php if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
|
||||
$t_time = $h_time = __('Unpublished');
|
||||
} else {
|
||||
$t_time = get_the_time(__('Y/m/d g:i:s A'));
|
||||
$m_time = $post->post_date;
|
||||
$time = get_post_time( 'G', true );
|
||||
if ( ( abs($t_diff = time() - $time) ) < 86400 ) {
|
||||
if ( $t_diff < 0 )
|
||||
$h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
|
||||
else
|
||||
$h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
|
||||
} else {
|
||||
$h_time = mysql2date(__('Y/m/d'), $m_time);
|
||||
}
|
||||
} ?>
|
||||
<td class="date column-date"><?php echo $h_time ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
|
||||
} else {
|
||||
include( './edit-attachment-rows.php' );
|
||||
} ?>
|
||||
|
||||
<form id="posts-filter" action="" method="post">
|
||||
<?php $table->display(); ?>
|
||||
<div id="ajax-response"></div>
|
||||
|
||||
<div class="tablenav">
|
||||
|
||||
<?php
|
||||
if ( have_posts() || ! empty( $orphans ) ) {
|
||||
|
||||
if ( $page_links )
|
||||
echo "<div class='tablenav-pages'>$page_links_text</div>";
|
||||
?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<select name="action2" class="select-action">
|
||||
<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||
<?php if ($is_trash) { ?>
|
||||
<option value="untrash"><?php _e('Restore'); ?></option>
|
||||
<?php } if ( $is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) { ?>
|
||||
<option value="delete"><?php _e('Delete Permanently'); ?></option>
|
||||
<?php } else { ?>
|
||||
<option value="trash"><?php _e('Move to Trash'); ?></option>
|
||||
<?php } if (isset($orphans)) { ?>
|
||||
<option value="attach"><?php _e('Attach to a post'); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
||||
|
||||
<?php if ( isset($_GET['status']) && $_GET['status'] == 'trash' && current_user_can('edit_others_posts') ) { ?>
|
||||
<input type="submit" id="delete_all2" name="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
<?php find_posts_div(); ?>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
<?php find_posts_div(); ?>
|
||||
</form>
|
||||
<br class="clear" />
|
||||
|
||||
|
|
|
@ -306,21 +306,12 @@ default:
|
|||
exit;
|
||||
}
|
||||
|
||||
require_once( './includes/default-list-tables.php' );
|
||||
|
||||
$table = new WP_Users_Table;
|
||||
|
||||
include('./admin-header.php');
|
||||
|
||||
$usersearch = isset($_GET['usersearch']) ? $_GET['usersearch'] : null;
|
||||
$userspage = isset($_GET['userspage']) ? $_GET['userspage'] : null;
|
||||
$role = isset($_GET['role']) ? $_GET['role'] : null;
|
||||
|
||||
// Query the user IDs for this page
|
||||
$wp_user_search = new WP_User_Search($usersearch, $userspage, $role);
|
||||
|
||||
// Query the post counts for this page
|
||||
$post_counts = count_many_users_posts($wp_user_search->get_results());
|
||||
|
||||
// Query the users for this page
|
||||
cache_users($wp_user_search->get_results());
|
||||
|
||||
$messages = array();
|
||||
if ( isset($_GET['update']) ) :
|
||||
switch($_GET['update']) {
|
||||
|
@ -372,8 +363,8 @@ if ( ! empty($messages) ) {
|
|||
<div class="wrap">
|
||||
<?php screen_icon(); ?>
|
||||
<h2><?php echo esc_html( $title ); if ( current_user_can( 'create_users' ) ) { ?> <a href="user-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'user'); ?></a><?php }
|
||||
if ( isset($_GET['usersearch']) && $_GET['usersearch'] )
|
||||
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $_GET['usersearch'] ) ); ?>
|
||||
if ( $usersearch )
|
||||
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $usersearch ) ); ?>
|
||||
</h2>
|
||||
|
||||
<div class="filter">
|
||||
|
@ -415,109 +406,14 @@ unset($role_links);
|
|||
<form class="search-form" action="" method="get">
|
||||
<p class="search-box">
|
||||
<label class="screen-reader-text" for="user-search-input"><?php _e( 'Search Users' ); ?>:</label>
|
||||
<input type="text" id="user-search-input" name="usersearch" value="<?php echo esc_attr($wp_user_search->search_term); ?>" />
|
||||
<input type="text" id="user-search-input" name="usersearch" value="<?php echo esc_attr($usersearch); ?>" />
|
||||
<input type="submit" value="<?php esc_attr_e( 'Search Users' ); ?>" class="button" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<form id="posts-filter" action="" method="get">
|
||||
<div class="tablenav">
|
||||
|
||||
<?php if ( $wp_user_search->results_are_paged() ) : ?>
|
||||
<div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<select name="action">
|
||||
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||
<?php if ( !is_multisite() && current_user_can('delete_users') ) { ?>
|
||||
<option value="delete"><?php _e('Delete'); ?></option>
|
||||
<?php } else { ?>
|
||||
<option value="remove"><?php _e('Remove'); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
|
||||
<label class="screen-reader-text" for="new_role"><?php _e('Change role to…') ?></label><select name="new_role" id="new_role"><option value=''><?php _e('Change role to…') ?></option><?php wp_dropdown_roles(); ?></select>
|
||||
<input type="submit" value="<?php esc_attr_e('Change'); ?>" name="changeit" class="button-secondary" />
|
||||
<?php wp_nonce_field('bulk-users'); ?>
|
||||
</div>
|
||||
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<?php if ( is_wp_error( $wp_user_search->search_errors ) ) : ?>
|
||||
<div class="error">
|
||||
<ul>
|
||||
<?php
|
||||
foreach ( $wp_user_search->search_errors->get_error_messages() as $message )
|
||||
echo "<li>$message</li>";
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if ( $wp_user_search->get_results() ) : ?>
|
||||
|
||||
<?php if ( $wp_user_search->is_search() ) : ?>
|
||||
<p><a href="users.php"><?php _e('← Back to All Users'); ?></a></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<table class="widefat fixed" cellspacing="0">
|
||||
<thead>
|
||||
<tr class="thead">
|
||||
<?php print_column_headers('users') ?>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr class="thead">
|
||||
<?php print_column_headers('users', false) ?>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody id="users" class="list:user user-list">
|
||||
<?php
|
||||
$style = '';
|
||||
foreach ( $wp_user_search->get_results() as $userid ) {
|
||||
$user_object = new WP_User($userid);
|
||||
$roles = $user_object->roles;
|
||||
$role = array_shift($roles);
|
||||
|
||||
if ( is_multisite() && empty( $role ) )
|
||||
continue;
|
||||
|
||||
$style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
|
||||
echo "\n\t", user_row( $user_object, $style, $role, $post_counts[ $userid ] );
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="tablenav">
|
||||
|
||||
<?php if ( $wp_user_search->results_are_paged() ) : ?>
|
||||
<div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="alignleft actions">
|
||||
<select name="action2">
|
||||
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||
<?php if ( !is_multisite() && current_user_can('delete_users') ) { ?>
|
||||
<option value="delete"><?php _e('Delete'); ?></option>
|
||||
<?php } else { ?>
|
||||
<option value="remove"><?php _e('Remove'); ?></option>
|
||||
<?php } ?></select>
|
||||
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
||||
</div>
|
||||
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<form id="posts-filter" action="" method="post">
|
||||
<?php $table->display(); ?>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ( is_multisite() ) {
|
||||
|
@ -536,4 +432,3 @@ break;
|
|||
} // end of the $doaction switch
|
||||
|
||||
include('./admin-footer.php');
|
||||
?>
|
||||
|
|
|
@ -204,6 +204,8 @@ function get_comments( $args = '' ) {
|
|||
'status' => '',
|
||||
'type' => '',
|
||||
'user_id' => '',
|
||||
'search' => '',
|
||||
'count' => false
|
||||
);
|
||||
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
@ -235,7 +237,7 @@ function get_comments( $args = '' ) {
|
|||
else
|
||||
$approved = "( comment_approved = '0' OR comment_approved = '1' )";
|
||||
|
||||
$order = ( 'ASC' == $order ) ? 'ASC' : 'DESC';
|
||||
$order = ( 'ASC' == strtoupper($order) ) ? 'ASC' : 'DESC';
|
||||
|
||||
if ( ! empty( $orderby ) ) {
|
||||
$ordersby = is_array($orderby) ? $orderby : preg_split('/[,\s]/', $orderby);
|
||||
|
@ -269,32 +271,37 @@ function get_comments( $args = '' ) {
|
|||
|
||||
if ( !empty($number) ) {
|
||||
if ( $offset )
|
||||
$number = 'LIMIT ' . $offset . ',' . $number;
|
||||
$limit = 'LIMIT ' . $offset . ',' . $number;
|
||||
else
|
||||
$number = 'LIMIT ' . $number;
|
||||
|
||||
$limit = 'LIMIT ' . $number;
|
||||
} else {
|
||||
$number = '';
|
||||
$limit = '';
|
||||
}
|
||||
|
||||
$post_where = '';
|
||||
$post_where = "WHERE $approved";
|
||||
|
||||
if ( ! empty($post_id) )
|
||||
$post_where .= $wpdb->prepare( 'comment_post_ID = %d AND ', $post_id );
|
||||
$post_where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
|
||||
if ( '' !== $author_email )
|
||||
$post_where .= $wpdb->prepare( 'comment_author_email = %s AND ', $author_email );
|
||||
$post_where .= $wpdb->prepare( 'AND comment_author_email = %s', $author_email );
|
||||
if ( '' !== $karma )
|
||||
$post_where .= $wpdb->prepare( 'comment_karma = %d AND ', $karma );
|
||||
$post_where .= $wpdb->prepare( 'AND comment_karma = %d', $karma );
|
||||
if ( 'comment' == $type )
|
||||
$post_where .= "comment_type = '' AND ";
|
||||
$post_where .= " AND comment_type = ''";
|
||||
elseif ( ! empty( $type ) )
|
||||
$post_where .= $wpdb->prepare( 'comment_type = %s AND ', $type );
|
||||
$post_where .= $wpdb->prepare( ' AND comment_type = %s', $type );
|
||||
if ( '' !== $parent )
|
||||
$post_where .= $wpdb->prepare( 'comment_parent = %d AND ', $parent );
|
||||
$post_where .= $wpdb->prepare( ' AND comment_parent = %d', $parent );
|
||||
if ( '' !== $user_id )
|
||||
$post_where .= $wpdb->prepare( 'user_id = %d AND ', $user_id );
|
||||
$post_where .= $wpdb->prepare( ' AND user_id = %d', $user_id );
|
||||
if ( '' !== $search )
|
||||
$post_where .= _wp_search_sql($search, array('comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content'));
|
||||
|
||||
if ( $count )
|
||||
return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments $post_where ORDER BY $orderby $order $limit" );
|
||||
|
||||
$comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments $post_where ORDER BY $orderby $order $limit" );
|
||||
|
||||
$comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE $post_where $approved ORDER BY $orderby $order $number" );
|
||||
wp_cache_add( $cache_key, $comments, 'comment' );
|
||||
|
||||
return $comments;
|
||||
|
@ -1282,7 +1289,7 @@ function wp_new_comment( $commentdata ) {
|
|||
$post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment
|
||||
|
||||
if ( get_option('comments_notify') && $commentdata['comment_approved'] && ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) )
|
||||
wp_notify_postauthor($comment_ID, empty( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' );
|
||||
wp_notify_postauthor($comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' );
|
||||
}
|
||||
|
||||
return $comment_ID;
|
||||
|
|
|
@ -4194,6 +4194,27 @@ function get_file_data( $file, $default_headers, $context = '' ) {
|
|||
|
||||
return $file_data;
|
||||
}
|
||||
|
||||
/*
|
||||
* Used internally to generate an SQL string for searching across multiple columns
|
||||
*
|
||||
* @access private
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param string $string
|
||||
* @param array $cols
|
||||
* @return string
|
||||
*/
|
||||
function _wp_search_sql($string, $cols) {
|
||||
$string = esc_sql($string);
|
||||
|
||||
$searches = array();
|
||||
foreach ( $cols as $col )
|
||||
$searches[] = "$col LIKE '%$string%'";
|
||||
|
||||
return ' AND (' . implode(' OR ', $searches) . ')';
|
||||
}
|
||||
|
||||
/*
|
||||
* Used internally to tidy up the search terms
|
||||
*
|
||||
|
|
|
@ -0,0 +1,224 @@
|
|||
/**
|
||||
* jQuery.query - Query String Modification and Creation for jQuery
|
||||
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
|
||||
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
|
||||
* Date: 2009/8/13
|
||||
*
|
||||
* @author Blair Mitchelmore
|
||||
* @version 2.1.7
|
||||
*
|
||||
**/
|
||||
new function(settings) {
|
||||
// Various Settings
|
||||
var $separator = settings.separator || '&';
|
||||
var $spaces = settings.spaces === false ? false : true;
|
||||
var $suffix = settings.suffix === false ? '' : '[]';
|
||||
var $prefix = settings.prefix === false ? false : true;
|
||||
var $hash = $prefix ? settings.hash === true ? "#" : "?" : "";
|
||||
var $numbers = settings.numbers === false ? false : true;
|
||||
|
||||
jQuery.query = new function() {
|
||||
var is = function(o, t) {
|
||||
return o != undefined && o !== null && (!!t ? o.constructor == t : true);
|
||||
};
|
||||
var parse = function(path) {
|
||||
var m, rx = /\[([^[]*)\]/g, match = /^([^[]+)(\[.*\])?$/.exec(path), base = match[1], tokens = [];
|
||||
while (m = rx.exec(match[2])) tokens.push(m[1]);
|
||||
return [base, tokens];
|
||||
};
|
||||
var set = function(target, tokens, value) {
|
||||
var o, token = tokens.shift();
|
||||
if (typeof target != 'object') target = null;
|
||||
if (token === "") {
|
||||
if (!target) target = [];
|
||||
if (is(target, Array)) {
|
||||
target.push(tokens.length == 0 ? value : set(null, tokens.slice(0), value));
|
||||
} else if (is(target, Object)) {
|
||||
var i = 0;
|
||||
while (target[i++] != null);
|
||||
target[--i] = tokens.length == 0 ? value : set(target[i], tokens.slice(0), value);
|
||||
} else {
|
||||
target = [];
|
||||
target.push(tokens.length == 0 ? value : set(null, tokens.slice(0), value));
|
||||
}
|
||||
} else if (token && token.match(/^\s*[0-9]+\s*$/)) {
|
||||
var index = parseInt(token, 10);
|
||||
if (!target) target = [];
|
||||
target[index] = tokens.length == 0 ? value : set(target[index], tokens.slice(0), value);
|
||||
} else if (token) {
|
||||
var index = token.replace(/^\s*|\s*$/g, "");
|
||||
if (!target) target = {};
|
||||
if (is(target, Array)) {
|
||||
var temp = {};
|
||||
for (var i = 0; i < target.length; ++i) {
|
||||
temp[i] = target[i];
|
||||
}
|
||||
target = temp;
|
||||
}
|
||||
target[index] = tokens.length == 0 ? value : set(target[index], tokens.slice(0), value);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return target;
|
||||
};
|
||||
|
||||
var queryObject = function(a) {
|
||||
var self = this;
|
||||
self.keys = {};
|
||||
|
||||
if (a.queryObject) {
|
||||
jQuery.each(a.get(), function(key, val) {
|
||||
self.SET(key, val);
|
||||
});
|
||||
} else {
|
||||
jQuery.each(arguments, function() {
|
||||
var q = "" + this;
|
||||
q = q.replace(/^[?#]/,''); // remove any leading ? || #
|
||||
q = q.replace(/[;&]$/,''); // remove any trailing & || ;
|
||||
if ($spaces) q = q.replace(/[+]/g,' '); // replace +'s with spaces
|
||||
|
||||
jQuery.each(q.split(/[&;]/), function(){
|
||||
var key = decodeURIComponent(this.split('=')[0] || "");
|
||||
var val = decodeURIComponent(this.split('=')[1] || "");
|
||||
|
||||
if (!key) return;
|
||||
|
||||
if ($numbers) {
|
||||
if (/^[+-]?[0-9]+\.[0-9]*$/.test(val)) // simple float regex
|
||||
val = parseFloat(val);
|
||||
else if (/^[+-]?[0-9]+$/.test(val)) // simple int regex
|
||||
val = parseInt(val, 10);
|
||||
}
|
||||
|
||||
val = (!val && val !== 0) ? true : val;
|
||||
|
||||
if (val !== false && val !== true && typeof val != 'number')
|
||||
val = val;
|
||||
|
||||
self.SET(key, val);
|
||||
});
|
||||
});
|
||||
}
|
||||
return self;
|
||||
};
|
||||
|
||||
queryObject.prototype = {
|
||||
queryObject: true,
|
||||
has: function(key, type) {
|
||||
var value = this.get(key);
|
||||
return is(value, type);
|
||||
},
|
||||
GET: function(key) {
|
||||
if (!is(key)) return this.keys;
|
||||
var parsed = parse(key), base = parsed[0], tokens = parsed[1];
|
||||
var target = this.keys[base];
|
||||
while (target != null && tokens.length != 0) {
|
||||
target = target[tokens.shift()];
|
||||
}
|
||||
return typeof target == 'number' ? target : target || "";
|
||||
},
|
||||
get: function(key) {
|
||||
var target = this.GET(key);
|
||||
if (is(target, Object))
|
||||
return jQuery.extend(true, {}, target);
|
||||
else if (is(target, Array))
|
||||
return target.slice(0);
|
||||
return target;
|
||||
},
|
||||
SET: function(key, val) {
|
||||
var value = !is(val) ? null : val;
|
||||
var parsed = parse(key), base = parsed[0], tokens = parsed[1];
|
||||
var target = this.keys[base];
|
||||
this.keys[base] = set(target, tokens.slice(0), value);
|
||||
return this;
|
||||
},
|
||||
set: function(key, val) {
|
||||
return this.copy().SET(key, val);
|
||||
},
|
||||
REMOVE: function(key) {
|
||||
return this.SET(key, null).COMPACT();
|
||||
},
|
||||
remove: function(key) {
|
||||
return this.copy().REMOVE(key);
|
||||
},
|
||||
EMPTY: function() {
|
||||
var self = this;
|
||||
jQuery.each(self.keys, function(key, value) {
|
||||
delete self.keys[key];
|
||||
});
|
||||
return self;
|
||||
},
|
||||
load: function(url) {
|
||||
var hash = url.replace(/^.*?[#](.+?)(?:\?.+)?$/, "$1");
|
||||
var search = url.replace(/^.*?[?](.+?)(?:#.+)?$/, "$1");
|
||||
return new queryObject(url.length == search.length ? '' : search, url.length == hash.length ? '' : hash);
|
||||
},
|
||||
empty: function() {
|
||||
return this.copy().EMPTY();
|
||||
},
|
||||
copy: function() {
|
||||
return new queryObject(this);
|
||||
},
|
||||
COMPACT: function() {
|
||||
function build(orig) {
|
||||
var obj = typeof orig == "object" ? is(orig, Array) ? [] : {} : orig;
|
||||
if (typeof orig == 'object') {
|
||||
function add(o, key, value) {
|
||||
if (is(o, Array))
|
||||
o.push(value);
|
||||
else
|
||||
o[key] = value;
|
||||
}
|
||||
jQuery.each(orig, function(key, value) {
|
||||
if (!is(value)) return true;
|
||||
add(obj, key, build(value));
|
||||
});
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
this.keys = build(this.keys);
|
||||
return this;
|
||||
},
|
||||
compact: function() {
|
||||
return this.copy().COMPACT();
|
||||
},
|
||||
toString: function() {
|
||||
var i = 0, queryString = [], chunks = [], self = this;
|
||||
var encode = function(str) {
|
||||
str = str + "";
|
||||
if ($spaces) str = str.replace(/ /g, "+");
|
||||
return encodeURIComponent(str);
|
||||
};
|
||||
var addFields = function(arr, key, value) {
|
||||
if (!is(value) || value === false) return;
|
||||
var o = [encode(key)];
|
||||
if (value !== true) {
|
||||
o.push("=");
|
||||
o.push(encode(value));
|
||||
}
|
||||
arr.push(o.join(""));
|
||||
};
|
||||
var build = function(obj, base) {
|
||||
var newKey = function(key) {
|
||||
return !base || base == "" ? [key].join("") : [base, "[", key, "]"].join("");
|
||||
};
|
||||
jQuery.each(obj, function(key, value) {
|
||||
if (typeof value == 'object')
|
||||
build(value, newKey(key));
|
||||
else
|
||||
addFields(chunks, newKey(key), value);
|
||||
});
|
||||
};
|
||||
|
||||
build(this.keys);
|
||||
|
||||
if (chunks.length > 0) queryString.push($hash);
|
||||
queryString.push(chunks.join($separator));
|
||||
|
||||
return queryString.join("");
|
||||
}
|
||||
};
|
||||
|
||||
return new queryObject(location.search, location.hash);
|
||||
};
|
||||
}(jQuery.query || {}); // Pass in jQuery.query as settings object
|
|
@ -155,6 +155,9 @@ function wp_default_scripts( &$scripts ) {
|
|||
$scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20m');
|
||||
$scripts->add_data( 'schedule', 'group', 1 );
|
||||
|
||||
$scripts->add( 'jquery-query', "/wp-includes/js/jquery/jquery.query.js", array('jquery'), '2.1.7' );
|
||||
$scripts->add_data( 'jquery-query', 'group', 1 );
|
||||
|
||||
$scripts->add( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m' );
|
||||
$scripts->add_data( 'jquery-hotkeys', 'group', 1 );
|
||||
|
||||
|
@ -335,7 +338,15 @@ function wp_default_scripts( &$scripts ) {
|
|||
$scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20100407' );
|
||||
$scripts->add_data( 'theme-preview', 'group', 1 );
|
||||
|
||||
$scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), '20091202' );
|
||||
$scripts->add( 'admin-table', "/wp-admin/js/admin-table$suffix.js", array( 'jquery', 'jquery-query' ), '20100626' );
|
||||
$scripts->add_data( 'admin-table', 'group', 1 );
|
||||
$scripts->localize( 'admin-table', 'adminTableL10n', array(
|
||||
'loading' => __('Loading...'),
|
||||
'error' => __('An error has occured while loading the items.'),
|
||||
'search' => __('Search results for “%s”')
|
||||
) );
|
||||
|
||||
$scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'suggest' ), '20100707' );
|
||||
$scripts->add_data( 'inline-edit-post', 'group', 1 );
|
||||
$scripts->localize( 'inline-edit-post', 'inlineEditL10n', array(
|
||||
'error' => __('Error while saving the changes.'),
|
||||
|
@ -344,7 +355,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
|
||||
) );
|
||||
|
||||
$scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), '20090623' );
|
||||
$scripts->add( 'inline-edit-tax', "/wp-admin/js/inline-edit-tax$suffix.js", array( 'jquery' ), '20100615' );
|
||||
$scripts->add_data( 'inline-edit-tax', 'group', 1 );
|
||||
$scripts->localize( 'inline-edit-tax', 'inlineEditL10n', array(
|
||||
'error' => __('Error while saving the changes.'),
|
||||
|
@ -430,7 +441,7 @@ function wp_default_styles( &$styles ) {
|
|||
// Any rtl stylesheets that don't have a .dev version for ltr
|
||||
$no_suffix = array( 'farbtastic' );
|
||||
|
||||
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20100614' );
|
||||
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20100624' );
|
||||
|
||||
$styles->add( 'ie', "/wp-admin/css/ie$suffix.css", array(), '20100610' );
|
||||
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );
|
||||
|
|
|
@ -51,9 +51,18 @@ function create_initial_taxonomies() {
|
|||
register_taxonomy( 'link_category', 'link', array(
|
||||
'hierarchical' => false,
|
||||
'labels' => array(
|
||||
'name' => __( 'Categories' ),
|
||||
'singular_name' => __( 'Category' ),
|
||||
'update_item' => __( 'Update Category' ),
|
||||
'name' => __( 'Link Categories' ),
|
||||
'singular_name' => __( 'Link Category' ),
|
||||
'search_items' => __( 'Search Link Categories' ),
|
||||
'popular_items' => null,
|
||||
'all_items' => __( 'All Link Categories' ),
|
||||
'edit_item' => __( 'Edit Link Category' ),
|
||||
'update_item' => __( 'Update Link Category' ),
|
||||
'add_new_item' => __( 'Add New Link Category' ),
|
||||
'new_item_name' => __( 'New Link Category Name' ),
|
||||
'separate_items_with_commas' => null,
|
||||
'add_or_remove_items' => null,
|
||||
'choose_from_most_used' => null,
|
||||
),
|
||||
'query_var' => false,
|
||||
'rewrite' => false,
|
||||
|
|
|
@ -325,6 +325,222 @@ function delete_user_option( $user_id, $option_name, $global = false ) {
|
|||
return delete_user_meta( $user_id, $option_name );
|
||||
}
|
||||
|
||||
/**
|
||||
* WordPress User Query class.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
class WP_User_Query {
|
||||
|
||||
/**
|
||||
* {@internal Missing Description}}
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
var $results;
|
||||
|
||||
/**
|
||||
* The total number of users for the current query
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
var $total_users = 0;
|
||||
|
||||
var $query_from;
|
||||
var $query_where;
|
||||
var $query_orderby;
|
||||
var $query_limit;
|
||||
|
||||
/**
|
||||
* Sets up the object properties.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param string|array $args The query variables
|
||||
* @return WP_User_Query
|
||||
*/
|
||||
function WP_User_Query( $query ) {
|
||||
$this->query_vars = wp_parse_args( $query, array(
|
||||
'search' => '', 'role' => '',
|
||||
'offset' => '', 'number' => '', 'count_total' => true,
|
||||
'orderby' => 'login', 'order' => 'ASC',
|
||||
'meta_key' => '', 'meta_value' => '',
|
||||
'include' => array(), 'exclude' => array(),
|
||||
'fields' => 'all'
|
||||
) );
|
||||
|
||||
$this->prepare_query();
|
||||
$this->query();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the query variables
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access private
|
||||
*/
|
||||
function prepare_query() {
|
||||
global $wpdb;
|
||||
|
||||
$qv = &$this->query_vars;
|
||||
|
||||
$this->query_from = " FROM $wpdb->users";
|
||||
$this->query_where = " WHERE 1=1";
|
||||
|
||||
// sorting
|
||||
if ( in_array( $qv['orderby'], array('email', 'url', 'registered') ) ) {
|
||||
$orderby = 'user_' . $qv['orderby'];
|
||||
}
|
||||
elseif ( 'name' == $qv['orderby'] ) {
|
||||
$orderby = 'display_name';
|
||||
}
|
||||
elseif ( 'post_count' == $qv['orderby'] ) {
|
||||
$where = get_posts_by_author_sql('post');
|
||||
$this->query_from .= " LEFT OUTER JOIN (
|
||||
SELECT post_author, COUNT(*) as post_count
|
||||
FROM wp_posts
|
||||
$where
|
||||
GROUP BY post_author
|
||||
) p ON (wp_users.ID = p.post_author)
|
||||
";
|
||||
$orderby = 'post_count';
|
||||
}
|
||||
else {
|
||||
$orderby = 'user_login';
|
||||
}
|
||||
|
||||
$qv['order'] = strtoupper( $qv['order'] );
|
||||
if ( 'ASC' == $qv['order'] )
|
||||
$order = 'ASC';
|
||||
else
|
||||
$order = 'DESC';
|
||||
$this->query_orderby = " ORDER BY $orderby $order";
|
||||
|
||||
// limit
|
||||
if ( $qv['number'] ) {
|
||||
if ( $qv['offset'] )
|
||||
$this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $qv['offset'], $qv['offset'] + $qv['number']);
|
||||
else
|
||||
$this->query_limit = $wpdb->prepare(" LIMIT %d", $qv['number']);
|
||||
}
|
||||
|
||||
$search = trim( $qv['search'] );
|
||||
if ( $search ) {
|
||||
$this->query_where .= _wp_search_sql( $search, array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') );
|
||||
}
|
||||
|
||||
$role = trim( $qv['role'] );
|
||||
if ( $role ) {
|
||||
$this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
|
||||
$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $role . '%');
|
||||
} elseif ( is_multisite() ) {
|
||||
$level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
|
||||
$this->query_from .= ", $wpdb->usermeta";
|
||||
$this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
|
||||
}
|
||||
|
||||
$meta_key = trim( $qv['meta_key'] );
|
||||
$meta_value = trim( $qv['meta_value'] );
|
||||
if ( $meta_key ) {
|
||||
if ( empty( $meta_value ) ) {
|
||||
$subquery = $wpdb->prepare( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = %s", $meta_key );
|
||||
}
|
||||
else {
|
||||
$subquery = $wpdb->prepare( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = %s AND meta_value = %s", $meta_key, $meta_value );
|
||||
}
|
||||
|
||||
$this->query_where .= " AND $wpdb->users.ID IN ($subquery)";
|
||||
}
|
||||
|
||||
if ( !empty($qv['include']) ) {
|
||||
$ids = implode( ',', wp_parse_id_list( $qv['include'] ) );
|
||||
$this->query_where .= " AND $wpdb->users.ID IN ($ids)";
|
||||
}
|
||||
elseif ( !empty($qv['exclude']) ) {
|
||||
$ids = implode( ',', wp_parse_id_list( $qv['exclude'] ) );
|
||||
$this->query_where .= " AND $wpdb->users.ID NOT IN ($ids)";
|
||||
}
|
||||
|
||||
do_action_ref_array( 'pre_user_query', array( &$this ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the query, with the current variables
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access private
|
||||
*/
|
||||
function query() {
|
||||
global $wpdb;
|
||||
|
||||
$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
|
||||
|
||||
if ( !$this->results )
|
||||
return;
|
||||
|
||||
if ( $this->query_vars['count_total'] )
|
||||
$this->total_users = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where);
|
||||
|
||||
if ( 'all' == $this->query_vars['fields'] ) {
|
||||
cache_users($this->results);
|
||||
|
||||
$r = array();
|
||||
foreach ( $this->results as $userid )
|
||||
$r[ $userid ] = new WP_User( $userid );
|
||||
|
||||
$this->results = $r;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of users
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access public
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_results() {
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total number of users for the current query
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access public
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_total() {
|
||||
return $this->total_users;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve list of users matching criteria.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @uses $wpdb
|
||||
* @uses WP_User_Query See for default arguments and information.
|
||||
*
|
||||
* @param array $args
|
||||
* @return array List of users.
|
||||
*/
|
||||
function get_users( $args ) {
|
||||
|
||||
$args = wp_parse_args( $args );
|
||||
$args['count_total'] = false;
|
||||
|
||||
$user_search = new WP_User_Query($args);
|
||||
|
||||
return (array) $user_search->get_results();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get users for the blog.
|
||||
*
|
||||
|
@ -429,7 +645,7 @@ function update_user_meta($user_id, $meta_key, $meta_value, $prev_value = '') {
|
|||
* Count number of users who have each of the user roles.
|
||||
*
|
||||
* Assumes there are neither duplicated nor orphaned capabilities meta_values.
|
||||
* Assumes role names are unique phrases. Same assumption made by WP_User_Search::prepare_query()
|
||||
* Assumes role names are unique phrases. Same assumption made by WP_User_Query::prepare_query()
|
||||
* Using $strategy = 'time' this is CPU-intensive and should handle around 10^7 users.
|
||||
* Using $strategy = 'memory' this is memory-intensive and should handle around 10^5 users, but see WP Bug #12257.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue