Archived
Updates
This commit is contained in:
1 parent
70d2335bba
commit
7428b67da5
1086 files changed
+94145
-59082
No files matched your search
@@ -103,17 +103,20 @@ function wp_ajax_fetch_list() {
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function wp_ajax_ajax_tag_search() {
|
||||
if ( isset( $_GET['tax'] ) ) {
|
||||
$taxonomy = sanitize_key( $_GET['tax'] );
|
||||
$tax = get_taxonomy( $taxonomy );
|
||||
if ( ! $tax )
|
||||
wp_die( 0 );
|
||||
if ( ! current_user_can( $tax->cap->assign_terms ) )
|
||||
wp_die( -1 );
|
||||
} else {
|
||||
if ( ! isset( $_GET['tax'] ) ) {
|
||||
wp_die( 0 );
|
||||
}
|
||||
|
||||
$taxonomy = sanitize_key( $_GET['tax'] );
|
||||
$tax = get_taxonomy( $taxonomy );
|
||||
if ( ! $tax ) {
|
||||
wp_die( 0 );
|
||||
}
|
||||
|
||||
if ( ! current_user_can( $tax->cap->assign_terms ) ) {
|
||||
wp_die( -1 );
|
||||
}
|
||||
|
||||
$s = wp_unslash( $_GET['q'] );
|
||||
|
||||
$comma = _x( ',', 'tag delimiter' );
|
||||
@@ -169,7 +172,7 @@ function wp_ajax_wp_compression_test() {
|
||||
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
|
||||
header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
|
||||
header( 'Pragma: no-cache' );
|
||||
header('Content-Type: application/x-javascript; charset=UTF-8');
|
||||
header('Content-Type: application/javascript; charset=UTF-8');
|
||||
$force_gzip = ( defined('ENFORCE_GZIP') && ENFORCE_GZIP );
|
||||
$test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."';
|
||||
|
||||
@@ -286,7 +289,7 @@ function wp_ajax_autocomplete_user() {
|
||||
);
|
||||
}
|
||||
|
||||
wp_die( json_encode( $return ) );
|
||||
wp_die( wp_json_encode( $return ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,7 +379,7 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
|
||||
// Here for completeness - not used.
|
||||
'id' => $comment_id,
|
||||
'supplemental' => array(
|
||||
'total_items_i18n' => sprintf( _n( '1 item', '%s items', $total ), number_format_i18n( $total ) ),
|
||||
'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ),
|
||||
'total_pages' => ceil( $total / $per_page ),
|
||||
'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ),
|
||||
'total' => $total,
|
||||
@@ -419,10 +422,11 @@ function _wp_ajax_add_hierarchical_term() {
|
||||
continue;
|
||||
if ( !$cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) )
|
||||
$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
|
||||
if ( is_wp_error( $cat_id ) )
|
||||
if ( is_wp_error( $cat_id ) ) {
|
||||
continue;
|
||||
else if ( is_array( $cat_id ) )
|
||||
} elseif ( is_array( $cat_id ) ) {
|
||||
$cat_id = $cat_id['term_id'];
|
||||
}
|
||||
$checked_categories[] = $cat_id;
|
||||
if ( $parent ) // Do these all at once in a second
|
||||
continue;
|
||||
@@ -738,10 +742,11 @@ function wp_ajax_add_link_category( $action ) {
|
||||
continue;
|
||||
if ( !$cat_id = term_exists( $cat_name, 'link_category' ) )
|
||||
$cat_id = wp_insert_term( $cat_name, 'link_category' );
|
||||
if ( is_wp_error( $cat_id ) )
|
||||
if ( is_wp_error( $cat_id ) ) {
|
||||
continue;
|
||||
else if ( is_array( $cat_id ) )
|
||||
} elseif ( is_array( $cat_id ) ) {
|
||||
$cat_id = $cat_id['term_id'];
|
||||
}
|
||||
$cat_name = esc_html( $cat_name );
|
||||
$x->add( array(
|
||||
'what' => 'link-category',
|
||||
@@ -788,7 +793,7 @@ function wp_ajax_add_tag() {
|
||||
|
||||
$level = 0;
|
||||
if ( is_taxonomy_hierarchical($taxonomy) ) {
|
||||
$level = count( get_ancestors( $tag->term_id, $taxonomy ) );
|
||||
$level = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) );
|
||||
ob_start();
|
||||
$wp_list_table->single_row( $tag, $level );
|
||||
$noparents = ob_get_clean();
|
||||
@@ -816,17 +821,20 @@ function wp_ajax_add_tag() {
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function wp_ajax_get_tagcloud() {
|
||||
if ( isset( $_POST['tax'] ) ) {
|
||||
$taxonomy = sanitize_key( $_POST['tax'] );
|
||||
$tax = get_taxonomy( $taxonomy );
|
||||
if ( ! $tax )
|
||||
wp_die( 0 );
|
||||
if ( ! current_user_can( $tax->cap->assign_terms ) )
|
||||
wp_die( -1 );
|
||||
} else {
|
||||
if ( ! isset( $_POST['tax'] ) ) {
|
||||
wp_die( 0 );
|
||||
}
|
||||
|
||||
$taxonomy = sanitize_key( $_POST['tax'] );
|
||||
$tax = get_taxonomy( $taxonomy );
|
||||
if ( ! $tax ) {
|
||||
wp_die( 0 );
|
||||
}
|
||||
|
||||
if ( ! current_user_can( $tax->cap->assign_terms ) ) {
|
||||
wp_die( -1 );
|
||||
}
|
||||
|
||||
$tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) );
|
||||
|
||||
if ( empty( $tags ) )
|
||||
@@ -935,7 +943,8 @@ function wp_ajax_replyto_comment( $action ) {
|
||||
$comment_author = wp_slash( $user->display_name );
|
||||
$comment_author_email = wp_slash( $user->user_email );
|
||||
$comment_author_url = wp_slash( $user->user_url );
|
||||
$comment_content = trim($_POST['content']);
|
||||
$comment_content = trim( $_POST['content'] );
|
||||
$comment_type = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : '';
|
||||
if ( current_user_can( 'unfiltered_html' ) ) {
|
||||
if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) )
|
||||
$_POST['_wp_unfiltered_html_comment'] = '';
|
||||
@@ -1082,7 +1091,7 @@ function wp_ajax_add_menu_item() {
|
||||
}
|
||||
|
||||
$_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) );
|
||||
$_menu_item = array_shift( $_menu_items );
|
||||
$_menu_item = reset( $_menu_items );
|
||||
|
||||
// Restore the missing menu item properties
|
||||
$menu_item_data['menu-item-description'] = $_menu_item->description;
|
||||
@@ -1141,6 +1150,8 @@ function wp_ajax_add_meta() {
|
||||
wp_die( -1 );
|
||||
if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) )
|
||||
wp_die( 1 );
|
||||
|
||||
// If the post is an autodraft, save the post as a draft and then attempt to save the meta.
|
||||
if ( $post->post_status == 'auto-draft' ) {
|
||||
$save_POST = $_POST; // Backup $_POST
|
||||
$_POST = array(); // Make it empty for edit_post()
|
||||
@@ -1165,7 +1176,7 @@ function wp_ajax_add_meta() {
|
||||
} else {
|
||||
wp_die( 0 );
|
||||
}
|
||||
} else if ( !$mid = add_meta( $pid ) ) {
|
||||
} elseif ( ! $mid = add_meta( $pid ) ) {
|
||||
wp_die( __( 'Please provide a custom field value.' ) );
|
||||
}
|
||||
|
||||
@@ -1364,7 +1375,7 @@ function wp_ajax_menu_get_metabox() {
|
||||
|
||||
$markup = ob_get_clean();
|
||||
|
||||
echo json_encode(array(
|
||||
echo wp_json_encode(array(
|
||||
'replace-id' => $type . '-' . $item->name,
|
||||
'markup' => $markup,
|
||||
));
|
||||
@@ -1393,7 +1404,7 @@ function wp_ajax_wp_link_ajax() {
|
||||
if ( ! isset( $results ) )
|
||||
wp_die( 0 );
|
||||
|
||||
echo json_encode( $results );
|
||||
echo wp_json_encode( $results );
|
||||
echo "\n";
|
||||
|
||||
wp_die();
|
||||
@@ -1485,7 +1496,7 @@ function wp_ajax_sample_permalink() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for quick edit saving for a post.
|
||||
* Ajax handler for Quick Edit saving a post from a list table.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1539,6 +1550,17 @@ function wp_ajax_inline_save() {
|
||||
if ( empty($data['ping_status']) )
|
||||
$data['ping_status'] = 'closed';
|
||||
|
||||
// Exclude terms from taxonomies that are not supposed to appear in Quick Edit.
|
||||
if ( ! empty( $data['tax_input'] ) ) {
|
||||
foreach ( $data['tax_input'] as $taxonomy => $terms ) {
|
||||
$tax_object = get_taxonomy( $taxonomy );
|
||||
/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
|
||||
if ( ! apply_filters( 'quick_edit_show_taxonomy', $tax_object->show_in_quick_edit, $taxonomy, $post['post_type'] ) ) {
|
||||
unset( $data['tax_input'][ $taxonomy ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hack: wp_unique_post_slug() doesn't work for drafts, so we will fake that our post is published.
|
||||
if ( ! empty( $data['post_name'] ) && in_array( $post['post_status'], array( 'draft', 'pending' ) ) ) {
|
||||
$post['post_status'] = 'publish';
|
||||
@@ -1616,7 +1638,9 @@ function wp_ajax_inline_save_tax() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for finding posts.
|
||||
* Ajax handler for querying posts for the Find Posts modal.
|
||||
*
|
||||
* @see window.findPosts
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1769,7 +1793,7 @@ function wp_ajax_save_widget() {
|
||||
if ( !$multi_number )
|
||||
wp_die( $error );
|
||||
|
||||
$_POST['widget-' . $id_base] = array( $multi_number => array_shift($settings) );
|
||||
$_POST[ 'widget-' . $id_base ] = array( $multi_number => reset( $settings ) );
|
||||
$widget_id = $id_base . '-' . $multi_number;
|
||||
$sidebar[] = $widget_id;
|
||||
}
|
||||
@@ -1821,14 +1845,37 @@ function wp_ajax_update_widget() {
|
||||
*/
|
||||
function wp_ajax_upload_attachment() {
|
||||
check_ajax_referer( 'media-form' );
|
||||
/*
|
||||
* This function does not use wp_send_json_success() / wp_send_json_error()
|
||||
* as the html4 Plupload handler requires a text/html content-type for older IE.
|
||||
* See https://core.trac.wordpress.org/ticket/31037
|
||||
*/
|
||||
|
||||
if ( ! current_user_can( 'upload_files' ) ) {
|
||||
echo wp_json_encode( array(
|
||||
'success' => false,
|
||||
'data' => array(
|
||||
'message' => __( "You don't have permission to upload files." ),
|
||||
'filename' => $_FILES['async-upload']['name'],
|
||||
)
|
||||
) );
|
||||
|
||||
if ( ! current_user_can( 'upload_files' ) )
|
||||
wp_die();
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['post_id'] ) ) {
|
||||
$post_id = $_REQUEST['post_id'];
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) )
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
||||
echo wp_json_encode( array(
|
||||
'success' => false,
|
||||
'data' => array(
|
||||
'message' => __( "You don't have permission to attach files to this post." ),
|
||||
'filename' => $_FILES['async-upload']['name'],
|
||||
)
|
||||
) );
|
||||
|
||||
wp_die();
|
||||
}
|
||||
} else {
|
||||
$post_id = null;
|
||||
}
|
||||
@@ -1837,9 +1884,9 @@ function wp_ajax_upload_attachment() {
|
||||
|
||||
// If the context is custom header or background, make sure the uploaded file is an image.
|
||||
if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) {
|
||||
$wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'], false );
|
||||
$wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'] );
|
||||
if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) {
|
||||
echo json_encode( array(
|
||||
echo wp_json_encode( array(
|
||||
'success' => false,
|
||||
'data' => array(
|
||||
'message' => __( 'The uploaded file is not a valid image. Please try again.' ),
|
||||
@@ -1854,7 +1901,7 @@ function wp_ajax_upload_attachment() {
|
||||
$attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data );
|
||||
|
||||
if ( is_wp_error( $attachment_id ) ) {
|
||||
echo json_encode( array(
|
||||
echo wp_json_encode( array(
|
||||
'success' => false,
|
||||
'data' => array(
|
||||
'message' => $attachment_id->get_error_message(),
|
||||
@@ -1876,7 +1923,7 @@ function wp_ajax_upload_attachment() {
|
||||
if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) )
|
||||
wp_die();
|
||||
|
||||
echo json_encode( array(
|
||||
echo wp_json_encode( array(
|
||||
'success' => true,
|
||||
'data' => $attachment,
|
||||
) );
|
||||
@@ -1901,7 +1948,7 @@ function wp_ajax_image_editor() {
|
||||
switch ( $_POST['do'] ) {
|
||||
case 'save' :
|
||||
$msg = wp_save_image($attachment_id);
|
||||
$msg = json_encode($msg);
|
||||
$msg = wp_json_encode($msg);
|
||||
wp_die( $msg );
|
||||
break;
|
||||
case 'scale' :
|
||||
@@ -2146,7 +2193,7 @@ function wp_ajax_get_attachment() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for querying for attachments.
|
||||
* Ajax handler for querying attachments.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
@@ -2155,11 +2202,17 @@ function wp_ajax_query_attachments() {
|
||||
wp_send_json_error();
|
||||
|
||||
$query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array();
|
||||
$query = array_intersect_key( $query, array_flip( array(
|
||||
$keys = array(
|
||||
's', 'order', 'orderby', 'posts_per_page', 'paged', 'post_mime_type',
|
||||
'post_parent', 'post__in', 'post__not_in', 'year', 'monthnum'
|
||||
) ) );
|
||||
);
|
||||
foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) {
|
||||
if ( $t->query_var && isset( $query[ $t->query_var ] ) ) {
|
||||
$keys[] = $t->query_var;
|
||||
}
|
||||
}
|
||||
|
||||
$query = array_intersect_key( $query, array_flip( $keys ) );
|
||||
$query['post_type'] = 'attachment';
|
||||
if ( MEDIA_TRASH
|
||||
&& ! empty( $_REQUEST['query']['post_status'] )
|
||||
@@ -2192,7 +2245,7 @@ function wp_ajax_query_attachments() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for saving attachment attributes.
|
||||
* Ajax handler for updating attachment attributes.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
@@ -2214,6 +2267,9 @@ function wp_ajax_save_attachment() {
|
||||
if ( 'attachment' != $post['post_type'] )
|
||||
wp_send_json_error();
|
||||
|
||||
if ( isset( $changes['parent'] ) )
|
||||
$post['post_parent'] = $changes['parent'];
|
||||
|
||||
if ( isset( $changes['title'] ) )
|
||||
$post['post_title'] = $changes['title'];
|
||||
|
||||
@@ -2234,7 +2290,7 @@ function wp_ajax_save_attachment() {
|
||||
}
|
||||
}
|
||||
|
||||
if ( 0 === strpos( $post['post_mime_type'], 'audio/' ) ) {
|
||||
if ( wp_attachment_is( 'audio', $post['ID'] ) ) {
|
||||
$changed = false;
|
||||
$id3data = wp_get_attachment_metadata( $post['ID'] );
|
||||
if ( ! is_array( $id3data ) ) {
|
||||
@@ -2389,10 +2445,16 @@ function wp_ajax_send_attachment_to_editor() {
|
||||
$align = isset( $attachment['align'] ) ? $attachment['align'] : 'none';
|
||||
$size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
|
||||
$alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
|
||||
|
||||
// No whitespace-only captions.
|
||||
$caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : '';
|
||||
if ( '' === trim( $caption ) ) {
|
||||
$caption = '';
|
||||
}
|
||||
|
||||
$title = ''; // We no longer insert title tags into <img> tags, as they are redundant.
|
||||
$html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt );
|
||||
} elseif ( 'video' === substr( $post->post_mime_type, 0, 5 ) || 'audio' === substr( $post->post_mime_type, 0, 5 ) ) {
|
||||
} elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post ) ) {
|
||||
$html = stripslashes_deep( $_POST['html'] );
|
||||
}
|
||||
|
||||
@@ -2428,8 +2490,8 @@ function wp_ajax_send_link_to_editor() {
|
||||
if ( ! $src = esc_url_raw( $src ) )
|
||||
wp_send_json_error();
|
||||
|
||||
if ( ! $title = trim( wp_unslash( $_POST['title'] ) ) )
|
||||
$title = wp_basename( $src );
|
||||
if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) )
|
||||
$link_text = wp_basename( $src );
|
||||
|
||||
$post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 );
|
||||
|
||||
@@ -2442,8 +2504,8 @@ function wp_ajax_send_link_to_editor() {
|
||||
if ( $check_embed !== $fallback ) {
|
||||
// TinyMCE view for [embed] will parse this
|
||||
$html = '[embed]' . $src . '[/embed]';
|
||||
} elseif ( $title ) {
|
||||
$html = '<a href="' . esc_url( $src ) . '">' . $title . '</a>';
|
||||
} elseif ( $link_text ) {
|
||||
$html = '<a href="' . esc_url( $src ) . '">' . $link_text . '</a>';
|
||||
} else {
|
||||
$html = '';
|
||||
}
|
||||
@@ -2455,7 +2517,7 @@ function wp_ajax_send_link_to_editor() {
|
||||
$type = $ext_type;
|
||||
|
||||
/** This filter is documented in wp-admin/includes/media.php */
|
||||
$html = apply_filters( $type . '_send_to_editor_url', $html, $src, $title );
|
||||
$html = apply_filters( $type . '_send_to_editor_url', $html, $src, $link_text );
|
||||
|
||||
wp_send_json_success( $html );
|
||||
}
|
||||
@@ -2577,8 +2639,13 @@ function wp_ajax_save_user_color_scheme() {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
$previous_color_scheme = get_user_meta( get_current_user_id(), 'admin_color', true );
|
||||
update_user_meta( get_current_user_id(), 'admin_color', $color_scheme );
|
||||
wp_send_json_success();
|
||||
|
||||
wp_send_json_success( array(
|
||||
'previousScheme' => 'admin-color-' . $previous_color_scheme,
|
||||
'currentScheme' => 'admin-color-' . $color_scheme
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2648,6 +2715,7 @@ function wp_ajax_parse_embed() {
|
||||
|
||||
$shortcode = wp_unslash( $_POST['shortcode'] );
|
||||
$url = str_replace( '[embed]', '', str_replace( '[/embed]', '', $shortcode ) );
|
||||
|
||||
$parsed = false;
|
||||
setup_postdata( $post );
|
||||
|
||||
@@ -2701,7 +2769,7 @@ function wp_ajax_parse_embed() {
|
||||
// Admin is ssl and the embed is not. Iframes, scripts, and other "active content" will be blocked.
|
||||
wp_send_json_error( array(
|
||||
'type' => 'not-ssl',
|
||||
'message' => sprintf( __( 'Preview not available. %s cannot be embedded securely.' ), '<code>' . esc_html( $url ) . '</code>' ),
|
||||
'message' => __( 'This preview is unavailable in the editor.' ),
|
||||
) );
|
||||
}
|
||||
|
||||
@@ -2713,18 +2781,28 @@ function wp_ajax_parse_embed() {
|
||||
function wp_ajax_parse_media_shortcode() {
|
||||
global $post, $wp_scripts;
|
||||
|
||||
if ( ! $post = get_post( (int) $_POST['post_ID'] ) ) {
|
||||
if ( empty( $_POST['shortcode'] ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
if ( empty( $_POST['shortcode'] ) || ! current_user_can( 'edit_post', $post->ID ) ) {
|
||||
wp_send_json_error();
|
||||
$shortcode = wp_unslash( $_POST['shortcode'] );
|
||||
|
||||
if ( ! empty( $_POST['post_ID'] ) ) {
|
||||
$post = get_post( (int) $_POST['post_ID'] );
|
||||
}
|
||||
|
||||
setup_postdata( $post );
|
||||
$shortcode = do_shortcode( wp_unslash( $_POST['shortcode'] ) );
|
||||
// the embed shortcode requires a post
|
||||
if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
|
||||
if ( 'embed' === $shortcode ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
} else {
|
||||
setup_postdata( $post );
|
||||
}
|
||||
|
||||
if ( empty( $shortcode ) ) {
|
||||
$parsed = do_shortcode( $shortcode );
|
||||
|
||||
if ( empty( $parsed ) ) {
|
||||
wp_send_json_error( array(
|
||||
'type' => 'no-items',
|
||||
'message' => __( 'No items found.' ),
|
||||
@@ -2744,14 +2822,14 @@ function wp_ajax_parse_media_shortcode() {
|
||||
|
||||
ob_start();
|
||||
|
||||
echo $shortcode;
|
||||
echo $parsed;
|
||||
|
||||
if ( 'playlist' === $_REQUEST['type'] ) {
|
||||
wp_underscore_playlist_templates();
|
||||
|
||||
wp_print_scripts( 'wp-playlist' );
|
||||
} else {
|
||||
wp_print_scripts( 'wp-mediaelement' );
|
||||
wp_print_scripts( array( 'froogaloop', 'wp-mediaelement' ) );
|
||||
}
|
||||
|
||||
wp_send_json_success( array(
|
||||
@@ -2759,3 +2837,137 @@ function wp_ajax_parse_media_shortcode() {
|
||||
'body' => ob_get_clean()
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX handler for destroying multiple open sessions for a user.
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
function wp_ajax_destroy_sessions() {
|
||||
|
||||
$user = get_userdata( (int) $_POST['user_id'] );
|
||||
if ( $user ) {
|
||||
if ( ! current_user_can( 'edit_user', $user->ID ) ) {
|
||||
$user = false;
|
||||
} elseif ( ! wp_verify_nonce( $_POST['nonce'], 'update-user_' . $user->ID ) ) {
|
||||
$user = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array(
|
||||
'message' => __( 'Could not log out user sessions. Please try again.' ),
|
||||
) );
|
||||
}
|
||||
|
||||
$sessions = WP_Session_Tokens::get_instance( $user->ID );
|
||||
|
||||
if ( $user->ID === get_current_user_id() ) {
|
||||
$sessions->destroy_others( wp_get_session_token() );
|
||||
$message = __( 'You are now logged out everywhere else.' );
|
||||
} else {
|
||||
$sessions->destroy_all();
|
||||
/* translators: 1: User's display name. */
|
||||
$message = sprintf( __( '%s has been logged out.' ), $user->display_name );
|
||||
}
|
||||
|
||||
wp_send_json_success( array( 'message' => $message ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AJAX handler for updating a plugin.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @see Plugin_Upgrader
|
||||
*/
|
||||
function wp_ajax_update_plugin() {
|
||||
$plugin = urldecode( $_POST['plugin'] );
|
||||
|
||||
$status = array(
|
||||
'update' => 'plugin',
|
||||
'plugin' => $plugin,
|
||||
'slug' => sanitize_key( $_POST['slug'] ),
|
||||
'oldVersion' => '',
|
||||
'newVersion' => '',
|
||||
);
|
||||
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
|
||||
if ( $plugin_data['Version'] ) {
|
||||
$status['oldVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'update_plugins' ) ) {
|
||||
$status['error'] = __( 'You do not have sufficient permissions to update plugins on this site.' );
|
||||
wp_send_json_error( $status );
|
||||
}
|
||||
|
||||
check_ajax_referer( 'updates' );
|
||||
|
||||
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
|
||||
|
||||
$current = get_site_transient( 'update_plugins' );
|
||||
if ( empty( $current ) ) {
|
||||
wp_update_plugins();
|
||||
}
|
||||
|
||||
$upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
|
||||
$result = $upgrader->bulk_upgrade( array( $plugin ) );
|
||||
|
||||
if ( is_array( $result ) ) {
|
||||
$plugin_update_data = current( $result );
|
||||
|
||||
/*
|
||||
* If the `update_plugins` site transient is empty (e.g. when you update
|
||||
* two plugins in quick succession before the transient repopulates),
|
||||
* this may be the return.
|
||||
*
|
||||
* Preferably something can be done to ensure `update_plugins` isn't empty.
|
||||
* For now, surface some sort of error here.
|
||||
*/
|
||||
if ( $plugin_update_data === true ) {
|
||||
wp_send_json_error( $status );
|
||||
}
|
||||
|
||||
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
|
||||
|
||||
if ( $plugin_data['Version'] ) {
|
||||
$status['newVersion'] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
|
||||
}
|
||||
|
||||
wp_send_json_success( $status );
|
||||
} else if ( is_wp_error( $result ) ) {
|
||||
$status['error'] = $result->get_error_message();
|
||||
wp_send_json_error( $status );
|
||||
} else if ( is_bool( $result ) && ! $result ) {
|
||||
$status['errorCode'] = 'unable_to_connect_to_filesystem';
|
||||
$status['error'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
||||
wp_send_json_error( $status );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX handler for saving a post from Press This.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
function wp_ajax_press_this_save_post() {
|
||||
if ( empty( $GLOBALS['wp_press_this'] ) ) {
|
||||
include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
|
||||
}
|
||||
|
||||
$GLOBALS['wp_press_this']->save_post();
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX handler for creating new category from Press This.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
function wp_ajax_press_this_add_category() {
|
||||
if ( empty( $GLOBALS['wp_press_this'] ) ) {
|
||||
include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
|
||||
}
|
||||
|
||||
$GLOBALS['wp_press_this']->add_category();
|
||||
}
|
||||
@@ -27,7 +27,7 @@ function add_link() {
|
||||
*/
|
||||
function edit_link( $link_id = 0 ) {
|
||||
if ( !current_user_can( 'manage_links' ) )
|
||||
wp_die( __( 'Cheatin’ uh?' ) );
|
||||
wp_die( __( 'Cheatin’ uh?' ), 403 );
|
||||
|
||||
$_POST['link_url'] = esc_html( $_POST['link_url'] );
|
||||
$_POST['link_url'] = esc_url($_POST['link_url']);
|
||||
@@ -50,7 +50,7 @@ function edit_link( $link_id = 0 ) {
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @return object Default link
|
||||
* @return stdClass Default link
|
||||
*/
|
||||
function get_default_link_to_edit() {
|
||||
$link = new stdClass;
|
||||
|
||||
@@ -504,7 +504,7 @@ class ftp_base {
|
||||
return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "LIST", "rawlist");
|
||||
}
|
||||
|
||||
function nlist($pathname="") {
|
||||
function nlist($pathname="", $arg="") {
|
||||
return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "NLST", "nlist");
|
||||
}
|
||||
|
||||
@@ -903,5 +903,4 @@ if ( ! $mod_sockets && function_exists( 'dl' ) && is_callable( 'dl' ) ) {
|
||||
$mod_sockets = extension_loaded( 'sockets' );
|
||||
}
|
||||
|
||||
require_once "class-ftp-" . ( $mod_sockets ? "sockets" : "pure" ) . ".php";
|
||||
?>
|
||||
require_once dirname( __FILE__ ) . "/class-ftp-" . ( $mod_sockets ? "sockets" : "pure" ) . ".php";
|
||||
@@ -21,6 +21,10 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
|
||||
public $pending_count = array();
|
||||
|
||||
public $extra_items;
|
||||
|
||||
private $user_can;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -242,7 +246,8 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
<?php
|
||||
if ( 'top' == $which ) {
|
||||
?>
|
||||
<select name="comment_type">
|
||||
<label class="screen-reader-text" for="filter-by-comment-type"><?php _e( 'Filter by comment type' ); ?></label>
|
||||
<select id="filter-by-comment-type" name="comment_type">
|
||||
<option value=""><?php _e( 'All comment types' ); ?></option>
|
||||
<?php
|
||||
/**
|
||||
@@ -331,12 +336,6 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<?php $this->print_column_headers( false ); ?>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody id="the-comment-list" data-wp-lists="list:comment">
|
||||
<?php $this->display_rows_or_placeholder(); ?>
|
||||
</tbody>
|
||||
@@ -344,6 +343,13 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
<tbody id="the-extra-comment-list" data-wp-lists="list:comment" style="display: none;">
|
||||
<?php $this->items = $this->extra_items; $this->display_rows(); ?>
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<?php $this->print_column_headers( false ); ?>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
</table>
|
||||
<?php
|
||||
|
||||
@@ -355,6 +361,9 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
|
||||
$comment = $a_comment;
|
||||
$the_comment_class = wp_get_comment_status( $comment->comment_ID );
|
||||
if ( ! $the_comment_class ) {
|
||||
$the_comment_class = '';
|
||||
}
|
||||
$the_comment_class = join( ' ', get_comment_class( $the_comment_class, $comment->comment_ID, $comment->comment_post_ID ) );
|
||||
|
||||
$post = get_post( $comment->comment_post_ID );
|
||||
@@ -378,12 +387,10 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
global $comment_status;
|
||||
$post = get_post();
|
||||
|
||||
$user_can = $this->user_can;
|
||||
|
||||
$comment_url = esc_url( get_comment_link( $comment->comment_ID ) );
|
||||
$the_comment_status = wp_get_comment_status( $comment->comment_ID );
|
||||
|
||||
if ( $user_can ) {
|
||||
if ( $this->user_can ) {
|
||||
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
|
||||
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
|
||||
|
||||
@@ -419,7 +426,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
|
||||
echo '</div>';
|
||||
comment_text();
|
||||
if ( $user_can ) { ?>
|
||||
if ( $this->user_can ) { ?>
|
||||
<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
|
||||
<textarea class="comment" rows="1" cols="1"><?php
|
||||
/** This filter is documented in wp-admin/includes/comment.php */
|
||||
@@ -433,7 +440,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $user_can ) {
|
||||
if ( $this->user_can ) {
|
||||
// Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash.
|
||||
$actions = array(
|
||||
'approve' => '', 'unapprove' => '',
|
||||
@@ -446,10 +453,11 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
|
||||
// Not looking at all comments.
|
||||
if ( $comment_status && 'all' != $comment_status ) {
|
||||
if ( 'approved' == $the_comment_status )
|
||||
if ( 'approved' == $the_comment_status ) {
|
||||
$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved' class='vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
||||
else if ( 'unapproved' == $the_comment_status )
|
||||
} elseif ( 'unapproved' == $the_comment_status ) {
|
||||
$actions['approve'] = "<a href='$approve_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved' class='vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
||||
}
|
||||
} else {
|
||||
$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
||||
$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
||||
@@ -476,7 +484,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
|
||||
$format = '<a data-comment-id="%d" data-post-id="%d" data-action="%s" class="%s" title="%s" href="#">%s</a>';
|
||||
|
||||
$actions['quickedit'] = sprintf( $format, $comment->comment_ID, $post->ID, 'edit', 'vim-q comment-inline', esc_attr__( 'Quick Edit' ), __( 'Quick Edit' ) );
|
||||
$actions['quickedit'] = sprintf( $format, $comment->comment_ID, $post->ID, 'edit', 'vim-q comment-inline',esc_attr__( 'Edit this item inline' ), __( 'Quick Edit' ) );
|
||||
|
||||
$actions['reply'] = sprintf( $format, $comment->comment_ID, $post->ID, 'replyto', 'vim-r comment-inline', esc_attr__( 'Reply to this comment' ), __( 'Reply' ) );
|
||||
}
|
||||
@@ -525,19 +533,20 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
comment_author_email_link();
|
||||
echo '<br />';
|
||||
}
|
||||
echo '<a href="edit-comments.php?s=';
|
||||
comment_author_IP();
|
||||
echo '&mode=detail';
|
||||
if ( 'spam' == $comment_status )
|
||||
echo '&comment_status=spam';
|
||||
echo '">';
|
||||
comment_author_IP();
|
||||
echo '</a>';
|
||||
|
||||
$author_ip = get_comment_author_IP();
|
||||
if ( $author_ip ) {
|
||||
$author_ip_url = add_query_arg( array( 's' => $author_ip, 'mode' => 'detail' ), 'edit-comments.php' );
|
||||
if ( 'spam' == $comment_status ) {
|
||||
$author_ip_url = add_query_arg( 'comment_status', 'spam', $author_ip_url );
|
||||
}
|
||||
printf( '<a href="%s">%s</a>', esc_url( $author_ip_url ), $author_ip );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function column_date() {
|
||||
return get_comment_date( __( 'Y/m/d \a\t g:ia' ) );
|
||||
return get_comment_date( __( 'Y/m/d \a\t g:i a' ) );
|
||||
}
|
||||
|
||||
public function column_response() {
|
||||
@@ -552,9 +561,9 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
|
||||
if ( current_user_can( 'edit_post', $post->ID ) ) {
|
||||
$post_link = "<a href='" . get_edit_post_link( $post->ID ) . "'>";
|
||||
$post_link .= get_the_title( $post->ID ) . '</a>';
|
||||
$post_link .= esc_html( get_the_title( $post->ID ) ) . '</a>';
|
||||
} else {
|
||||
$post_link = get_the_title( $post->ID );
|
||||
$post_link = esc_html( get_the_title( $post->ID ) );
|
||||
}
|
||||
|
||||
echo '<div class="response-links"><span class="post-com-count-wrapper">';
|
||||
@@ -594,16 +603,14 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
class WP_Post_Comments_List_Table extends WP_Comments_List_Table {
|
||||
|
||||
protected function get_column_info() {
|
||||
$this->_column_headers = array(
|
||||
return array(
|
||||
array(
|
||||
'author' => __( 'Author' ),
|
||||
'comment' => _x( 'Comment', 'column name' ),
|
||||
'author' => __( 'Author' ),
|
||||
'comment' => _x( 'Comment', 'column name' ),
|
||||
),
|
||||
array(),
|
||||
array(),
|
||||
);
|
||||
|
||||
return $this->_column_headers;
|
||||
}
|
||||
|
||||
protected function get_table_classes() {
|
||||
|
||||
@@ -24,11 +24,10 @@ class WP_Filesystem_Base {
|
||||
/**
|
||||
* Cached list of local filepaths to mapped remote filepaths.
|
||||
*
|
||||
* @access private
|
||||
* @since 2.7.0
|
||||
* @var array
|
||||
*/
|
||||
private $cache = array();
|
||||
public $cache = array();
|
||||
|
||||
/**
|
||||
* The Access method of the current connection, Set automatically.
|
||||
@@ -39,57 +38,9 @@ class WP_Filesystem_Base {
|
||||
*/
|
||||
public $method = '';
|
||||
|
||||
/**
|
||||
* Make private properties readable for backwards compatibility.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $name Property to get.
|
||||
* @return mixed Property.
|
||||
*/
|
||||
public function __get( $name ) {
|
||||
return $this->$name;
|
||||
}
|
||||
public $errors = null;
|
||||
|
||||
/**
|
||||
* Make private properties settable for backwards compatibility.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $name Property to set.
|
||||
* @param mixed $value Property value.
|
||||
* @return mixed Newly-set property.
|
||||
*/
|
||||
public function __set( $name, $value ) {
|
||||
return $this->$name = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make private properties checkable for backwards compatibility.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $name Property to check if set.
|
||||
* @return bool Whether the property is set.
|
||||
*/
|
||||
public function __isset( $name ) {
|
||||
return isset( $this->$name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Make private properties un-settable for backwards compatibility.
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $name Property to unset.
|
||||
*/
|
||||
public function __unset( $name ) {
|
||||
unset( $this->$name );
|
||||
}
|
||||
public $options = array();
|
||||
|
||||
/**
|
||||
* Return the path on the remote filesystem of ABSPATH.
|
||||
@@ -217,7 +168,7 @@ class WP_Filesystem_Base {
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $folder the folder to locate.
|
||||
* @return string The location of the remote path.
|
||||
* @return string|false The location of the remote path, false on failure.
|
||||
*/
|
||||
public function find_folder( $folder ) {
|
||||
|
||||
@@ -280,13 +231,12 @@ class WP_Filesystem_Base {
|
||||
*
|
||||
* Expects Windows sanitized path.
|
||||
*
|
||||
* @access private
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $folder The folder to locate.
|
||||
* @param string $base The folder to start searching from.
|
||||
* @param bool $loop If the function has recursed, Internal use only.
|
||||
* @return string The location of the remote path.
|
||||
* @return string|false The location of the remote path, false to cease looping.
|
||||
*/
|
||||
public function search_for_folder( $folder, $base = '.', $loop = false ) {
|
||||
if ( empty( $base ) || '.' == $base )
|
||||
@@ -317,7 +267,7 @@ class WP_Filesystem_Base {
|
||||
*/
|
||||
if ( isset($files[ $key ]) ){
|
||||
|
||||
// Lets try that folder:
|
||||
// Let's try that folder:
|
||||
$newdir = trailingslashit(path_join($base, $key));
|
||||
if ( $this->verbose )
|
||||
printf( "\n" . __('Changing to %s') . "<br/>\n", $newdir );
|
||||
@@ -421,9 +371,11 @@ class WP_Filesystem_Base {
|
||||
$legal = array('', 'w', 'r', 'x', '-');
|
||||
$attarray = preg_split('//', $mode);
|
||||
|
||||
for ($i=0; $i < count($attarray); $i++)
|
||||
if ($key = array_search($attarray[$i], $legal))
|
||||
for ( $i = 0, $c = count( $attarray ); $i < $c; $i++ ) {
|
||||
if ($key = array_search($attarray[$i], $legal)) {
|
||||
$realmode .= $legal[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$mode = str_pad($realmode, 10, '-', STR_PAD_LEFT);
|
||||
$trans = array('-'=>'0', 'r'=>'4', 'w'=>'2', 'x'=>'1');
|
||||
@@ -439,7 +391,6 @@ class WP_Filesystem_Base {
|
||||
/**
|
||||
* Determine if the string provided contains binary characters.
|
||||
*
|
||||
* @access private
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $text String to test against.
|
||||
@@ -469,7 +420,7 @@ class WP_Filesystem_Base {
|
||||
* Connect filesystem.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @return bool True on success or false on failure (always true for WP_Filesystem_Direct).
|
||||
*/
|
||||
public function connect() {
|
||||
@@ -480,9 +431,9 @@ class WP_Filesystem_Base {
|
||||
* Read entire file into a string.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Name of the file to read.
|
||||
* @return string|bool Returns the read data or false on failure.
|
||||
* @return mixed|bool Returns the read data or false on failure.
|
||||
*/
|
||||
public function get_contents( $file ) {
|
||||
return false;
|
||||
@@ -492,7 +443,7 @@ class WP_Filesystem_Base {
|
||||
* Read entire file into an array.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Path to the file.
|
||||
* @return array|bool the file contents in an array or false on failure.
|
||||
*/
|
||||
@@ -504,7 +455,7 @@ class WP_Filesystem_Base {
|
||||
* Write a string to a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Remote path to the file where to write the data.
|
||||
* @param string $contents The data to write.
|
||||
* @param int $mode Optional. The file permissions as octal number, usually 0644.
|
||||
@@ -518,7 +469,7 @@ class WP_Filesystem_Base {
|
||||
* Get the current working directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @return string|bool The current working directory on success, or false on failure.
|
||||
*/
|
||||
public function cwd() {
|
||||
@@ -529,7 +480,7 @@ class WP_Filesystem_Base {
|
||||
* Change current directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $dir The new current directory.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
@@ -541,7 +492,7 @@ class WP_Filesystem_Base {
|
||||
* Change the file group.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Path to the file.
|
||||
* @param mixed $group A group name or number.
|
||||
* @param bool $recursive Optional. If set True changes file group recursively. Defaults to False.
|
||||
@@ -555,7 +506,7 @@ class WP_Filesystem_Base {
|
||||
* Change filesystem permissions.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Path to the file.
|
||||
* @param int $mode Optional. The permissions as octal number, usually 0644 for files, 0755 for dirs.
|
||||
* @param bool $recursive Optional. If set True changes file group recursively. Defaults to False.
|
||||
@@ -569,7 +520,7 @@ class WP_Filesystem_Base {
|
||||
* Get the file owner.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Path to the file.
|
||||
* @return string|bool Username of the user or false on error.
|
||||
*/
|
||||
@@ -581,7 +532,7 @@ class WP_Filesystem_Base {
|
||||
* Get the file's group.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Path to the file.
|
||||
* @return string|bool The group or false on error.
|
||||
*/
|
||||
@@ -593,7 +544,7 @@ class WP_Filesystem_Base {
|
||||
* Copy a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $source Path to the source file.
|
||||
* @param string $destination Path to the destination file.
|
||||
* @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
|
||||
@@ -610,7 +561,7 @@ class WP_Filesystem_Base {
|
||||
* Move a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $source Path to the source file.
|
||||
* @param string $destination Path to the destination file.
|
||||
* @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
|
||||
@@ -625,7 +576,7 @@ class WP_Filesystem_Base {
|
||||
* Delete a file or directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Path to the file.
|
||||
* @param bool $recursive Optional. If set True changes file group recursively. Defaults to False.
|
||||
* Default false.
|
||||
@@ -641,7 +592,7 @@ class WP_Filesystem_Base {
|
||||
* Check if a file or directory exists.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Path to file/directory.
|
||||
* @return bool Whether $file exists or not.
|
||||
*/
|
||||
@@ -653,7 +604,7 @@ class WP_Filesystem_Base {
|
||||
* Check if resource is a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file File path.
|
||||
* @return bool Whether $file is a file.
|
||||
*/
|
||||
@@ -665,7 +616,7 @@ class WP_Filesystem_Base {
|
||||
* Check if resource is a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $path Directory path.
|
||||
* @return bool Whether $path is a directory.
|
||||
*/
|
||||
@@ -677,7 +628,7 @@ class WP_Filesystem_Base {
|
||||
* Check if a file is readable.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Path to file.
|
||||
* @return bool Whether $file is readable.
|
||||
*/
|
||||
@@ -689,8 +640,7 @@ class WP_Filesystem_Base {
|
||||
* Check if a file or directory is writable.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $path Path to file/directory.
|
||||
* @abstract
|
||||
* @return bool Whether $file is writable.
|
||||
*/
|
||||
public function is_writable( $file ) {
|
||||
@@ -701,9 +651,9 @@ class WP_Filesystem_Base {
|
||||
* Gets the file's last access time.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Path to file.
|
||||
* @return int Unix timestamp representing last access time.
|
||||
* @return int|bool Unix timestamp representing last access time.
|
||||
*/
|
||||
public function atime( $file ) {
|
||||
return false;
|
||||
@@ -713,9 +663,9 @@ class WP_Filesystem_Base {
|
||||
* Gets the file modification time.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Path to file.
|
||||
* @return int Unix timestamp representing modification time.
|
||||
* @return int|bool Unix timestamp representing modification time.
|
||||
*/
|
||||
public function mtime( $file ) {
|
||||
return false;
|
||||
@@ -725,9 +675,9 @@ class WP_Filesystem_Base {
|
||||
* Gets the file size (in bytes).
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Path to file.
|
||||
* @return int Size of the file in bytes.
|
||||
* @return int|bool Size of the file in bytes.
|
||||
*/
|
||||
public function size( $file ) {
|
||||
return false;
|
||||
@@ -739,7 +689,7 @@ class WP_Filesystem_Base {
|
||||
* Note: If $file doesn't exist, it will be created.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $file Path to file.
|
||||
* @param int $time Optional. Modified time to set for file.
|
||||
* Default 0.
|
||||
@@ -755,7 +705,7 @@ class WP_Filesystem_Base {
|
||||
* Create a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $path Path for new directory.
|
||||
* @param mixed $chmod Optional. The permissions as octal number, (or False to skip chmod)
|
||||
* Default false.
|
||||
@@ -773,7 +723,7 @@ class WP_Filesystem_Base {
|
||||
* Delete a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @abstract
|
||||
* @param string $path Path to directory.
|
||||
* @param bool $recursive Optional. Whether to recursively remove files/directories.
|
||||
* Default false.
|
||||
@@ -787,6 +737,7 @@ class WP_Filesystem_Base {
|
||||
* Get details for files in a directory or a specific file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
*
|
||||
* @param string $path Path to directory or file.
|
||||
* @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
|
||||
@@ -796,16 +747,16 @@ class WP_Filesystem_Base {
|
||||
* @return array|bool {
|
||||
* Array of files. False if unable to list directory contents.
|
||||
*
|
||||
* @type string 'name' Name of the file/directory.
|
||||
* @type string 'perms' *nix representation of permissions.
|
||||
* @type int 'permsn' Octal representation of permissions.
|
||||
* @type string 'owner' Owner name or ID.
|
||||
* @type int 'size' Size of file in bytes.
|
||||
* @type int 'lastmodunix' Last modified unix timestamp.
|
||||
* @type mixed 'lastmod' Last modified month (3 letter) and day (without leading 0).
|
||||
* @type int 'time' Last modified time.
|
||||
* @type string 'type' Type of resource. 'f' for file, 'd' for directory.
|
||||
* @type mixed 'files' If a directory and $recursive is true, contains another array of files.
|
||||
* @type string $name Name of the file/directory.
|
||||
* @type string $perms *nix representation of permissions.
|
||||
* @type int $permsn Octal representation of permissions.
|
||||
* @type string $owner Owner name or ID.
|
||||
* @type int $size Size of file in bytes.
|
||||
* @type int $lastmodunix Last modified unix timestamp.
|
||||
* @type mixed $lastmod Last modified month (3 letter) and day (without leading 0).
|
||||
* @type int $time Last modified time.
|
||||
* @type string $type Type of resource. 'f' for file, 'd' for directory.
|
||||
* @type mixed $files If a directory and $recursive is true, contains another array of files.
|
||||
* }
|
||||
*/
|
||||
public function dirlist( $path, $include_hidden = true, $recursive = false ) {
|
||||
|
||||
@@ -49,10 +49,11 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
/**
|
||||
* Write a string to a file
|
||||
*
|
||||
* @param string $file Remote path to the file where to write the data.
|
||||
* @param string $file Remote path to the file where to write the data.
|
||||
* @param string $contents The data to write.
|
||||
* @param int $mode (optional) The file permissions as octal number, usually 0644.
|
||||
* @return bool False upon failure.
|
||||
* @param int $mode Optional. The file permissions as octal number, usually 0644.
|
||||
* Default false.
|
||||
* @return bool False upon failure, true otherwise.
|
||||
*/
|
||||
public function put_contents( $file, $contents, $mode = false ) {
|
||||
$fp = @fopen( $file, 'wb' );
|
||||
@@ -99,9 +100,9 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
/**
|
||||
* Changes file group
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @param mixed $group A group name or number.
|
||||
* @param bool $recursive (optional) If set True changes file group recursively. Defaults to False.
|
||||
* @param string $file Path to the file.
|
||||
* @param mixed $group A group name or number.
|
||||
* @param bool $recursive Optional. If set True changes file group recursively. Default false.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
public function chgrp($file, $group, $recursive = false) {
|
||||
@@ -123,9 +124,10 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
/**
|
||||
* Changes filesystem permissions
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @param int $mode (optional) The permissions as octal number, usually 0644 for files, 0755 for dirs.
|
||||
* @param bool $recursive (optional) If set True changes file group recursively. Defaults to False.
|
||||
* @param string $file Path to the file.
|
||||
* @param int $mode Optional. The permissions as octal number, usually 0644 for files,
|
||||
* 0755 for dirs. Default false.
|
||||
* @param bool $recursive Optional. If set True changes file group recursively. Default false.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
public function chmod($file, $mode = false, $recursive = false) {
|
||||
@@ -152,9 +154,10 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
/**
|
||||
* Changes file owner
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @param mixed $owner A user name or number.
|
||||
* @param bool $recursive (optional) If set True changes file owner recursively. Defaults to False.
|
||||
* @param string $file Path to the file.
|
||||
* @param mixed $owner A user name or number.
|
||||
* @param bool $recursive Optional. If set True changes file owner recursively.
|
||||
* Default false.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
public function chown($file, $owner, $recursive = false) {
|
||||
@@ -200,6 +203,10 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
return substr( decoct( @fileperms( $file ) ), -3 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string|false
|
||||
*/
|
||||
public function group($file) {
|
||||
$gid = @filegroup($file);
|
||||
if ( ! $gid )
|
||||
@@ -210,6 +217,13 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
return $grouparray['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @param int $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function copy($source, $destination, $overwrite = false, $mode = false) {
|
||||
if ( ! $overwrite && $this->exists($destination) )
|
||||
return false;
|
||||
@@ -220,6 +234,12 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
return $rtval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @return bool
|
||||
*/
|
||||
public function move($source, $destination, $overwrite = false) {
|
||||
if ( ! $overwrite && $this->exists($destination) )
|
||||
return false;
|
||||
@@ -236,6 +256,12 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param bool $recursive
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($file, $recursive = false, $type = false) {
|
||||
if ( empty( $file ) ) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
|
||||
return false;
|
||||
@@ -263,39 +289,74 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($file) {
|
||||
return @file_exists($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_file($file) {
|
||||
return @is_file($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function is_dir($path) {
|
||||
return @is_dir($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_readable($file) {
|
||||
return @is_readable($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_writable($file) {
|
||||
return @is_writable($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function atime($file) {
|
||||
return @fileatime($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function mtime($file) {
|
||||
return @filemtime($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function size($file) {
|
||||
return @filesize($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param int $time
|
||||
* @param int $atime
|
||||
* @return bool
|
||||
*/
|
||||
public function touch($file, $time = 0, $atime = 0) {
|
||||
if ($time == 0)
|
||||
$time = time();
|
||||
@@ -304,6 +365,13 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
return @touch($file, $time, $atime);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param mixed $chmod
|
||||
* @param mixed $chown
|
||||
* @param mixed $chgrp
|
||||
* @return bool
|
||||
*/
|
||||
public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
|
||||
// Safe mode fails with a trailing slash under certain PHP versions.
|
||||
$path = untrailingslashit($path);
|
||||
@@ -323,10 +391,21 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
*/
|
||||
public function rmdir($path, $recursive = false) {
|
||||
return $this->delete($path, $recursive);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $include_hidden
|
||||
* @param bool $recursive
|
||||
* @return bool|array
|
||||
*/
|
||||
public function dirlist($path, $include_hidden = true, $recursive = false) {
|
||||
if ( $this->is_file($path) ) {
|
||||
$limit_file = basename($path);
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
*/
|
||||
class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
public $link;
|
||||
public $errors = null;
|
||||
public $options = array();
|
||||
|
||||
public function __construct($opt='') {
|
||||
$this->method = 'ftpext';
|
||||
@@ -26,7 +24,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
// Check if possible to use ftp functions.
|
||||
if ( ! extension_loaded('ftp') ) {
|
||||
$this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available'));
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
// This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
|
||||
@@ -44,9 +42,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
else
|
||||
$this->options['hostname'] = $opt['hostname'];
|
||||
|
||||
if ( ! empty($opt['base']) )
|
||||
$this->wp_base = $opt['base'];
|
||||
|
||||
// Check if the options provided are OK.
|
||||
if ( empty($opt['username']) )
|
||||
$this->errors->add('empty_username', __('FTP username is required'));
|
||||
@@ -87,6 +82,10 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return false|string
|
||||
*/
|
||||
public function get_contents( $file ) {
|
||||
$tempfile = wp_tempnam($file);
|
||||
$temp = fopen($tempfile, 'w+');
|
||||
@@ -108,10 +107,20 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return array
|
||||
*/
|
||||
public function get_contents_array($file) {
|
||||
return explode("\n", $this->get_contents($file));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param string $contents
|
||||
* @param bool|int $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function put_contents($file, $contents, $mode = false ) {
|
||||
$tempfile = wp_tempnam($file);
|
||||
$temp = fopen( $tempfile, 'wb+' );
|
||||
@@ -143,6 +152,9 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function cwd() {
|
||||
$cwd = @ftp_pwd($this->link);
|
||||
if ( $cwd )
|
||||
@@ -150,14 +162,20 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
return $cwd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dir
|
||||
* @return bool
|
||||
*/
|
||||
public function chdir($dir) {
|
||||
return @ftp_chdir($this->link, $dir);
|
||||
}
|
||||
|
||||
public function chgrp($file, $group, $recursive = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param int $mode
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
*/
|
||||
public function chmod($file, $mode = false, $recursive = false) {
|
||||
if ( ! $mode ) {
|
||||
if ( $this->is_file($file) )
|
||||
@@ -181,21 +199,39 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
return (bool)@ftp_chmod($this->link, $mode, $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
public function owner($file) {
|
||||
$dir = $this->dirlist($file);
|
||||
return $dir[$file]['owner'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
public function getchmod($file) {
|
||||
$dir = $this->dirlist($file);
|
||||
return $dir[$file]['permsn'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
public function group($file) {
|
||||
$dir = $this->dirlist($file);
|
||||
return $dir[$file]['group'];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @param string|bool $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function copy($source, $destination, $overwrite = false, $mode = false) {
|
||||
if ( ! $overwrite && $this->exists($destination) )
|
||||
return false;
|
||||
@@ -204,11 +240,21 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
return false;
|
||||
return $this->put_contents($destination, $content, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @return bool
|
||||
*/
|
||||
public function move($source, $destination, $overwrite = false) {
|
||||
return ftp_rename($this->link, $source, $destination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param bool $recursive
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($file, $recursive = false, $type = false) {
|
||||
if ( empty($file) )
|
||||
return false;
|
||||
@@ -223,16 +269,30 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
$this->delete( trailingslashit($file) . $delete_file['name'], $recursive, $delete_file['type'] );
|
||||
return @ftp_rmdir($this->link, $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($file) {
|
||||
$list = @ftp_nlist($this->link, $file);
|
||||
|
||||
if ( empty( $list ) && $this->is_dir( $file ) ) {
|
||||
return true; // File is an empty directory.
|
||||
}
|
||||
|
||||
return !empty($list); //empty list = no file, so invert.
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_file($file) {
|
||||
return $this->exists($file) && !$this->is_dir($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function is_dir($path) {
|
||||
$cwd = $this->cwd();
|
||||
$result = @ftp_chdir($this->link, trailingslashit($path) );
|
||||
@@ -243,30 +303,56 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_readable($file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_writable($file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function atime($file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function mtime($file) {
|
||||
return ftp_mdtm($this->link, $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function size($file) {
|
||||
return ftp_size($this->link, $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function touch($file, $time = 0, $atime = 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param mixed $chmod
|
||||
* @param mixed $chown
|
||||
* @param mixed $chgrp
|
||||
* @return bool
|
||||
*/
|
||||
public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
|
||||
$path = untrailingslashit($path);
|
||||
if ( empty($path) )
|
||||
@@ -275,17 +361,23 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
if ( !@ftp_mkdir($this->link, $path) )
|
||||
return false;
|
||||
$this->chmod($path, $chmod);
|
||||
if ( $chown )
|
||||
$this->chown($path, $chown);
|
||||
if ( $chgrp )
|
||||
$this->chgrp($path, $chgrp);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
*/
|
||||
public function rmdir($path, $recursive = false) {
|
||||
return $this->delete($path, $recursive);
|
||||
}
|
||||
|
||||
/**
|
||||
* @staticvar bool $is_windows
|
||||
* @param string $line
|
||||
* @return string
|
||||
*/
|
||||
public function parselisting($line) {
|
||||
static $is_windows;
|
||||
if ( is_null($is_windows) )
|
||||
@@ -359,6 +451,12 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
return $b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $include_hidden
|
||||
* @param bool $recursive
|
||||
* @return bool|array
|
||||
*/
|
||||
public function dirlist($path = '.', $include_hidden = true, $recursive = false) {
|
||||
if ( $this->is_file($path) ) {
|
||||
$limit_file = basename($path);
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
* @uses WP_Filesystem_Base Extends class
|
||||
*/
|
||||
class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
public $ftp = false;
|
||||
public $errors = null;
|
||||
public $options = array();
|
||||
/**
|
||||
* @var ftp
|
||||
*/
|
||||
public $ftp;
|
||||
|
||||
public function __construct($opt = '') {
|
||||
$this->method = 'ftpsockets';
|
||||
@@ -25,7 +26,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
|
||||
// Check if possible to use ftp functions.
|
||||
if ( ! @include_once( ABSPATH . 'wp-admin/includes/class-ftp.php' ) ) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
$this->ftp = new ftp();
|
||||
|
||||
@@ -39,9 +40,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
else
|
||||
$this->options['hostname'] = $opt['hostname'];
|
||||
|
||||
if ( ! empty($opt['base']) )
|
||||
$this->wp_base = $opt['base'];
|
||||
|
||||
// Check if the options provided are OK.
|
||||
if ( empty ($opt['username']) )
|
||||
$this->errors->add('empty_username', __('FTP username is required'));
|
||||
@@ -81,6 +79,10 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return false|string
|
||||
*/
|
||||
public function get_contents( $file ) {
|
||||
if ( ! $this->exists($file) )
|
||||
return false;
|
||||
@@ -113,11 +115,20 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
unlink($temp);
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return array
|
||||
*/
|
||||
public function get_contents_array($file) {
|
||||
return explode("\n", $this->get_contents($file) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param string $contents
|
||||
* @param int|bool $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function put_contents($file, $contents, $mode = false ) {
|
||||
$temp = wp_tempnam( $file );
|
||||
if ( ! $temphandle = @fopen($temp, 'w+') ) {
|
||||
@@ -163,10 +174,12 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
return $this->ftp->chdir($file);
|
||||
}
|
||||
|
||||
public function chgrp($file, $group, $recursive = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param int|bool $mode
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
*/
|
||||
public function chmod($file, $mode = false, $recursive = false ) {
|
||||
if ( ! $mode ) {
|
||||
if ( $this->is_file($file) )
|
||||
@@ -188,21 +201,37 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
return $this->ftp->chmod($file, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
public function owner($file) {
|
||||
$dir = $this->dirlist($file);
|
||||
return $dir[$file]['owner'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
public function getchmod($file) {
|
||||
$dir = $this->dirlist($file);
|
||||
return $dir[$file]['permsn'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
public function group($file) {
|
||||
$dir = $this->dirlist($file);
|
||||
return $dir[$file]['group'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @param int|bool $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function copy($source, $destination, $overwrite = false, $mode = false) {
|
||||
if ( ! $overwrite && $this->exists($destination) )
|
||||
return false;
|
||||
@@ -213,11 +242,21 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
|
||||
return $this->put_contents($destination, $content, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @return bool
|
||||
*/
|
||||
public function move($source, $destination, $overwrite = false ) {
|
||||
return $this->ftp->rename($source, $destination);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param bool $recursive
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($file, $recursive = false, $type = false) {
|
||||
if ( empty($file) )
|
||||
return false;
|
||||
@@ -229,12 +268,25 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
return $this->ftp->mdel($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function exists( $file ) {
|
||||
$list = $this->ftp->nlist( $file );
|
||||
|
||||
if ( empty( $list ) && $this->is_dir( $file ) ) {
|
||||
return true; // File is an empty directory.
|
||||
}
|
||||
|
||||
return !empty( $list ); //empty list = no file, so invert.
|
||||
// Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server.
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_file($file) {
|
||||
if ( $this->is_dir($file) )
|
||||
return false;
|
||||
@@ -243,6 +295,10 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function is_dir($path) {
|
||||
$cwd = $this->cwd();
|
||||
if ( $this->chdir($path) ) {
|
||||
@@ -252,30 +308,62 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_readable($file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_writable($file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function atime($file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function mtime($file) {
|
||||
return $this->ftp->mdtm($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function size($file) {
|
||||
return $this->ftp->filesize($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param int $time
|
||||
* @param int $atime
|
||||
* @return bool
|
||||
*/
|
||||
public function touch($file, $time = 0, $atime = 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param mixed $chmod
|
||||
* @param mixed $chown
|
||||
* @param mixed $chgrp
|
||||
* @return bool
|
||||
*/
|
||||
public function mkdir($path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
$path = untrailingslashit($path);
|
||||
if ( empty($path) )
|
||||
@@ -286,17 +374,23 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
if ( ! $chmod )
|
||||
$chmod = FS_CHMOD_DIR;
|
||||
$this->chmod($path, $chmod);
|
||||
if ( $chown )
|
||||
$this->chown($path, $chown);
|
||||
if ( $chgrp )
|
||||
$this->chgrp($path, $chgrp);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sting $path
|
||||
* @param bool $recursive
|
||||
*/
|
||||
public function rmdir($path, $recursive = false ) {
|
||||
$this->delete($path, $recursive);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $include_hidden
|
||||
* @param bool $recursive
|
||||
* @return bool|array
|
||||
*/
|
||||
public function dirlist($path = '.', $include_hidden = true, $recursive = false ) {
|
||||
if ( $this->is_file($path) ) {
|
||||
$limit_file = basename($path);
|
||||
|
||||
@@ -36,10 +36,11 @@
|
||||
class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
|
||||
public $link = false;
|
||||
public $sftp_link = false;
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
public $sftp_link;
|
||||
public $keys = false;
|
||||
public $errors = array();
|
||||
public $options = array();
|
||||
|
||||
public function __construct($opt='') {
|
||||
$this->method = 'ssh2';
|
||||
@@ -48,11 +49,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
//Check if possible to use ssh2 functions.
|
||||
if ( ! extension_loaded('ssh2') ) {
|
||||
$this->errors->add('no_ssh2_ext', __('The ssh2 PHP extension is not available'));
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
if ( !function_exists('stream_get_contents') ) {
|
||||
$this->errors->add('ssh2_php_requirement', __('The ssh2 PHP extension is available, however, we require the PHP5 function <code>stream_get_contents()</code>'));
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Set defaults:
|
||||
@@ -66,9 +67,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
else
|
||||
$this->options['hostname'] = $opt['hostname'];
|
||||
|
||||
if ( ! empty($opt['base']) )
|
||||
$this->wp_base = $opt['base'];
|
||||
|
||||
// Check if the options provided are OK.
|
||||
if ( !empty ($opt['public_key']) && !empty ($opt['private_key']) ) {
|
||||
$this->options['public_key'] = $opt['public_key'];
|
||||
@@ -123,6 +121,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $command
|
||||
* @param bool $returnbool
|
||||
* @return bool|string
|
||||
*/
|
||||
public function run_command( $command, $returnbool = false) {
|
||||
|
||||
if ( ! $this->link )
|
||||
@@ -144,16 +147,30 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string|false
|
||||
*/
|
||||
public function get_contents( $file ) {
|
||||
$file = ltrim($file, '/');
|
||||
return file_get_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return array
|
||||
*/
|
||||
public function get_contents_array($file) {
|
||||
$file = ltrim($file, '/');
|
||||
return file('ssh2.sftp://' . $this->sftp_link . '/' . $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param string $contents
|
||||
* @param bool|int $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function put_contents($file, $contents, $mode = false ) {
|
||||
$ret = file_put_contents( 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $file, '/' ), $contents );
|
||||
|
||||
@@ -167,15 +184,25 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
|
||||
public function cwd() {
|
||||
$cwd = $this->run_command('pwd');
|
||||
if ( $cwd )
|
||||
$cwd = trailingslashit($cwd);
|
||||
if ( $cwd ) {
|
||||
$cwd = trailingslashit( trim( $cwd ) );
|
||||
}
|
||||
return $cwd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dir
|
||||
* @return bool|string
|
||||
*/
|
||||
public function chdir($dir) {
|
||||
return $this->run_command('cd ' . $dir, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param string $group
|
||||
* @param bool $recursive
|
||||
*/
|
||||
public function chgrp($file, $group, $recursive = false ) {
|
||||
if ( ! $this->exists($file) )
|
||||
return false;
|
||||
@@ -184,6 +211,12 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
return $this->run_command(sprintf('chgrp -R %s %s', escapeshellarg($group), escapeshellarg($file)), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param int $mode
|
||||
* @param bool $recursive
|
||||
* @return bool|string
|
||||
*/
|
||||
public function chmod($file, $mode = false, $recursive = false) {
|
||||
if ( ! $this->exists($file) )
|
||||
return false;
|
||||
@@ -207,10 +240,10 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
*
|
||||
* @since Unknown
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @param mixed $owner A user name or number.
|
||||
* @param bool $recursive Optional. If set True changes file owner recursivly. Defaults to False.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
* @param string $file Path to the file.
|
||||
* @param string|int $owner A user name or number.
|
||||
* @param bool $recursive Optional. If set True changes file owner recursivly. Defaults to False.
|
||||
* @return bool|string Returns true on success or false on failure.
|
||||
*/
|
||||
public function chown( $file, $owner, $recursive = false ) {
|
||||
if ( ! $this->exists($file) )
|
||||
@@ -220,6 +253,10 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
return $this->run_command(sprintf('chown -R %s %s', escapeshellarg($owner), escapeshellarg($file)), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string|false
|
||||
*/
|
||||
public function owner($file) {
|
||||
$owneruid = @fileowner('ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/'));
|
||||
if ( ! $owneruid )
|
||||
@@ -229,11 +266,18 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
$ownerarray = posix_getpwuid($owneruid);
|
||||
return $ownerarray['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
public function getchmod($file) {
|
||||
return substr( decoct( @fileperms( 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $file, '/' ) ) ), -3 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string|false
|
||||
*/
|
||||
public function group($file) {
|
||||
$gid = @filegroup('ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/'));
|
||||
if ( ! $gid )
|
||||
@@ -244,6 +288,13 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
return $grouparray['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @param int|bool $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function copy($source, $destination, $overwrite = false, $mode = false) {
|
||||
if ( ! $overwrite && $this->exists($destination) )
|
||||
return false;
|
||||
@@ -253,10 +304,22 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
return $this->put_contents($destination, $content, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @return bool
|
||||
*/
|
||||
public function move($source, $destination, $overwrite = false) {
|
||||
return @ssh2_sftp_rename($this->link, $source, $destination);
|
||||
return @ssh2_sftp_rename( $this->sftp_link, $source, $destination );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param bool $recursive
|
||||
* @param string|bool $type
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($file, $recursive = false, $type = false) {
|
||||
if ( 'f' == $type || $this->is_file($file) )
|
||||
return ssh2_sftp_unlink($this->sftp_link, $file);
|
||||
@@ -271,50 +334,89 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
return ssh2_sftp_rmdir($this->sftp_link, $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($file) {
|
||||
$file = ltrim($file, '/');
|
||||
return file_exists('ssh2.sftp://' . $this->sftp_link . '/' . $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_file($file) {
|
||||
$file = ltrim($file, '/');
|
||||
return is_file('ssh2.sftp://' . $this->sftp_link . '/' . $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function is_dir($path) {
|
||||
$path = ltrim($path, '/');
|
||||
return is_dir('ssh2.sftp://' . $this->sftp_link . '/' . $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_readable($file) {
|
||||
$file = ltrim($file, '/');
|
||||
return is_readable('ssh2.sftp://' . $this->sftp_link . '/' . $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_writable($file) {
|
||||
$file = ltrim($file, '/');
|
||||
return is_writable('ssh2.sftp://' . $this->sftp_link . '/' . $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function atime($file) {
|
||||
$file = ltrim($file, '/');
|
||||
return fileatime('ssh2.sftp://' . $this->sftp_link . '/' . $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function mtime($file) {
|
||||
$file = ltrim($file, '/');
|
||||
return filemtime('ssh2.sftp://' . $this->sftp_link . '/' . $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function size($file) {
|
||||
$file = ltrim($file, '/');
|
||||
return filesize('ssh2.sftp://' . $this->sftp_link . '/' . $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param int $time
|
||||
* @param int $atime
|
||||
*/
|
||||
public function touch($file, $time = 0, $atime = 0) {
|
||||
//Not implemented.
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param mixed $chmod
|
||||
* @param mixed $chown
|
||||
* @param mixed $chgrp
|
||||
* @return bool
|
||||
*/
|
||||
public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
|
||||
$path = untrailingslashit($path);
|
||||
if ( empty($path) )
|
||||
@@ -331,10 +433,21 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
*/
|
||||
public function rmdir($path, $recursive = false) {
|
||||
return $this->delete($path, $recursive);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $include_hidden
|
||||
* @param bool $recursive
|
||||
* @return bool|array
|
||||
*/
|
||||
public function dirlist($path, $include_hidden = true, $recursive = false) {
|
||||
if ( $this->is_file($path) ) {
|
||||
$limit_file = basename($path);
|
||||
|
||||
@@ -6,7 +6,6 @@ class WP_Importer {
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {}
|
||||
|
||||
@@ -210,7 +209,7 @@ class WP_Importer {
|
||||
*/
|
||||
public function is_user_over_quota() {
|
||||
if ( function_exists( 'upload_is_user_over_quota' ) ) {
|
||||
if ( upload_is_user_over_quota( 1 ) ) {
|
||||
if ( upload_is_user_over_quota() ) {
|
||||
echo "Sorry, you have used your upload quota.\n";
|
||||
return true;
|
||||
}
|
||||
@@ -273,14 +272,14 @@ function get_cli_args( $param, $required = false ) {
|
||||
}
|
||||
|
||||
$last_arg = $key;
|
||||
} else if ( (bool) preg_match( "/^-([a-zA-Z0-9]+)/", $args[$i], $match ) ) {
|
||||
} elseif ( (bool) preg_match( "/^-([a-zA-Z0-9]+)/", $args[$i], $match ) ) {
|
||||
for ( $j = 0, $jl = strlen( $match[1] ); $j < $jl; $j++ ) {
|
||||
$key = $match[1]{$j};
|
||||
$out[$key] = true;
|
||||
}
|
||||
|
||||
$last_arg = $key;
|
||||
} else if ( $last_arg !== null ) {
|
||||
} elseif ( $last_arg !== null ) {
|
||||
$out[$last_arg] = $args[$i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,12 +72,14 @@ class WP_Links_List_Table extends WP_List_Table {
|
||||
'selected' => $cat_id,
|
||||
'name' => 'cat_id',
|
||||
'taxonomy' => 'link_category',
|
||||
'show_option_all' => __( 'View all categories' ),
|
||||
'show_option_all' => __( 'All categories' ),
|
||||
'hide_empty' => true,
|
||||
'hierarchical' => 1,
|
||||
'show_count' => 0,
|
||||
'orderby' => 'name',
|
||||
);
|
||||
|
||||
echo '<label class="screen-reader-text" for="cat_id">' . __( 'Filter by category' ) . '</label>';
|
||||
wp_dropdown_categories( $dropdown_options );
|
||||
submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
|
||||
?>
|
||||
@@ -109,8 +111,6 @@ class WP_Links_List_Table extends WP_List_Table {
|
||||
public function display_rows() {
|
||||
global $cat_id;
|
||||
|
||||
$alt = 0;
|
||||
|
||||
foreach ( $this->items as $link ) {
|
||||
$link = sanitize_bookmark( $link );
|
||||
$link->link_name = esc_attr( $link->link_name );
|
||||
@@ -120,11 +120,10 @@ class WP_Links_List_Table extends WP_List_Table {
|
||||
|
||||
$visible = ( $link->link_visible == 'Y' ) ? __( 'Yes' ) : __( 'No' );
|
||||
$rating = $link->link_rating;
|
||||
$style = ( $alt++ % 2 ) ? '' : ' class="alternate"';
|
||||
|
||||
$edit_link = get_edit_bookmark_link( $link );
|
||||
?>
|
||||
<tr id="link-<?php echo $link->link_id; ?>" <?php echo $style; ?>>
|
||||
<tr id="link-<?php echo $link->link_id; ?>">
|
||||
<?php
|
||||
|
||||
list( $columns, $hidden ) = $this->get_column_info();
|
||||
@@ -185,16 +184,18 @@ class WP_Links_List_Table extends WP_List_Table {
|
||||
?><td <?php echo $attributes ?>><?php echo $rating; ?></td><?php
|
||||
break;
|
||||
default:
|
||||
/**
|
||||
* Fires for each registered custom link column.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $column_name Name of the custom column.
|
||||
* @param int $link_id Link ID.
|
||||
*/
|
||||
?>
|
||||
<td <?php echo $attributes ?>><?php do_action( 'manage_link_custom_column', $column_name, $link->link_id ); ?></td>
|
||||
<td <?php echo $attributes ?>><?php
|
||||
/**
|
||||
* Fires for each registered custom link column.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $column_name Name of the custom column.
|
||||
* @param int $link_id Link ID.
|
||||
*/
|
||||
do_action( 'manage_link_custom_column', $column_name, $link->link_id );
|
||||
?></td>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -24,18 +24,17 @@ class WP_List_Table {
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @var array
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
private $_args;
|
||||
protected $_args;
|
||||
|
||||
/**
|
||||
* Various information needed for displaying the pagination
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $_pagination_args = array();
|
||||
protected $_pagination_args = array();
|
||||
|
||||
/**
|
||||
* The current screen
|
||||
@@ -64,6 +63,29 @@ class WP_List_Table {
|
||||
*/
|
||||
private $_pagination;
|
||||
|
||||
/**
|
||||
* The view switcher modes.
|
||||
*
|
||||
* @since 4.1.0
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $modes = array();
|
||||
|
||||
/**
|
||||
* Stores the value returned by ->get_column_info()
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_column_headers;
|
||||
|
||||
protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' );
|
||||
|
||||
protected $compat_methods = array( 'set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions',
|
||||
'row_actions', 'months_dropdown', 'view_switcher', 'comments_bubble', 'get_items_per_page', 'pagination',
|
||||
'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav',
|
||||
'single_row_columns' );
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -114,6 +136,13 @@ class WP_List_Table {
|
||||
// wp_enqueue_script( 'list-table' );
|
||||
add_action( 'admin_footer', array( $this, '_js_vars' ) );
|
||||
}
|
||||
|
||||
if ( empty( $this->modes ) ) {
|
||||
$this->modes = array(
|
||||
'list' => __( 'List View' ),
|
||||
'excerpt' => __( 'Excerpt View' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +155,9 @@ class WP_List_Table {
|
||||
* @return mixed Property.
|
||||
*/
|
||||
public function __get( $name ) {
|
||||
return $this->$name;
|
||||
if ( in_array( $name, $this->compat_fields ) ) {
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,12 +166,14 @@ class WP_List_Table {
|
||||
* @since 4.0.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $name Property to set.
|
||||
* @param string $name Property to check if set.
|
||||
* @param mixed $value Property value.
|
||||
* @return mixed Newly-set property.
|
||||
*/
|
||||
public function __set( $name, $value ) {
|
||||
return $this->$name = $value;
|
||||
if ( in_array( $name, $this->compat_fields ) ) {
|
||||
return $this->$name = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +186,9 @@ class WP_List_Table {
|
||||
* @return bool Whether the property is set.
|
||||
*/
|
||||
public function __isset( $name ) {
|
||||
return isset( $this->$name );
|
||||
if ( in_array( $name, $this->compat_fields ) ) {
|
||||
return isset( $this->$name );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +200,9 @@ class WP_List_Table {
|
||||
* @param string $name Property to unset.
|
||||
*/
|
||||
public function __unset( $name ) {
|
||||
unset( $this->$name );
|
||||
if ( in_array( $name, $this->compat_fields ) ) {
|
||||
unset( $this->$name );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,12 +216,14 @@ class WP_List_Table {
|
||||
* @return mixed|bool Return value of the callback, false otherwise.
|
||||
*/
|
||||
public function __call( $name, $arguments ) {
|
||||
return call_user_func_array( array( $this, $name ), $arguments );
|
||||
if ( in_array( $name, $this->compat_methods ) ) {
|
||||
return call_user_func_array( array( $this, $name ), $arguments );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the current user's permissions
|
||||
* @uses wp_die()
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access public
|
||||
@@ -232,13 +271,14 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the pagination args
|
||||
* Access the pagination args.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $key
|
||||
* @return array
|
||||
* @param string $key Pagination argument to retrieve. Common values include 'total_items',
|
||||
* 'total_pages', 'per_page', or 'infinite_scroll'.
|
||||
* @return int Number of items that correspond to the given pagination argument.
|
||||
*/
|
||||
public function get_pagination_arg( $key ) {
|
||||
if ( 'page' == $key )
|
||||
@@ -297,7 +337,7 @@ class WP_List_Table {
|
||||
<p class="search-box">
|
||||
<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
|
||||
<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
|
||||
<?php submit_button( $text, 'button', false, false, array('id' => 'search-submit') ); ?>
|
||||
<?php submit_button( $text, 'button', '', false, array('id' => 'search-submit') ); ?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
@@ -326,7 +366,7 @@ class WP_List_Table {
|
||||
/**
|
||||
* Filter the list of available list table views.
|
||||
*
|
||||
* The dynamic portion of the hook name, $this->screen->id, refers
|
||||
* The dynamic portion of the hook name, `$this->screen->id`, refers
|
||||
* to the ID of the current screen, usually a string.
|
||||
*
|
||||
* @since 3.5.0
|
||||
@@ -374,7 +414,7 @@ class WP_List_Table {
|
||||
/**
|
||||
* Filter the list table Bulk Actions drop-down.
|
||||
*
|
||||
* The dynamic portion of the hook name, $this->screen->id, refers
|
||||
* The dynamic portion of the hook name, `$this->screen->id`, refers
|
||||
* to the ID of the current screen, usually a string.
|
||||
*
|
||||
* This filter can currently only be used to remove bulk actions.
|
||||
@@ -405,7 +445,7 @@ class WP_List_Table {
|
||||
|
||||
echo "</select>\n";
|
||||
|
||||
submit_button( __( 'Apply' ), 'action', false, false, array( 'id' => "doaction$two" ) );
|
||||
submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
@@ -463,10 +503,24 @@ class WP_List_Table {
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @param string $post_type
|
||||
*/
|
||||
protected function months_dropdown( $post_type ) {
|
||||
global $wpdb, $wp_locale;
|
||||
|
||||
/**
|
||||
* Filter whether to remove the 'Months' drop-down from the post list table.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param bool $disable Whether to disable the drop-down. Default false.
|
||||
* @param string $post_type The post type.
|
||||
*/
|
||||
if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$months = $wpdb->get_results( $wpdb->prepare( "
|
||||
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
||||
FROM $wpdb->posts
|
||||
@@ -519,18 +573,15 @@ class WP_List_Table {
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @param string $current_mode
|
||||
*/
|
||||
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 ) {
|
||||
foreach ( $this->modes as $mode => $title ) {
|
||||
$classes = array( 'view-' . $mode );
|
||||
if ( $current_mode == $mode )
|
||||
$classes[] = 'current';
|
||||
@@ -590,6 +641,8 @@ class WP_List_Table {
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @param string $option
|
||||
* @param int $default
|
||||
* @return int
|
||||
*/
|
||||
protected function get_items_per_page( $option, $default = 20 ) {
|
||||
@@ -600,10 +653,11 @@ class WP_List_Table {
|
||||
/**
|
||||
* Filter the number of items to be displayed on each page of the list table.
|
||||
*
|
||||
* The dynamic hook name, $option, refers to the per page option depending
|
||||
* on the type of list table in use. Possible values may include:
|
||||
* 'edit_comments_per_page', 'sites_network_per_page', 'site_themes_network_per_page',
|
||||
* 'themes_netework_per_page', 'users_network_per_page', 'edit_{$post_type}', etc.
|
||||
* The dynamic hook name, $option, refers to the `per_page` option depending
|
||||
* on the type of list table in use. Possible values include: 'edit_comments_per_page',
|
||||
* 'sites_network_per_page', 'site_themes_network_per_page', 'themes_network_per_page',
|
||||
* 'users_network_per_page', 'edit_post_per_page', 'edit_page_per_page',
|
||||
* 'edit_{$post_type}_per_page', etc.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
@@ -617,6 +671,8 @@ class WP_List_Table {
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @param string $which
|
||||
*/
|
||||
protected function pagination( $which ) {
|
||||
if ( empty( $this->_pagination_args ) ) {
|
||||
@@ -754,7 +810,7 @@ class WP_List_Table {
|
||||
/**
|
||||
* Filter the list table sortable columns for a specific screen.
|
||||
*
|
||||
* The dynamic portion of the hook name, $this->screen->id, refers
|
||||
* The dynamic portion of the hook name, `$this->screen->id`, refers
|
||||
* to the ID of the current screen, usually a string.
|
||||
*
|
||||
* @since 3.5.0
|
||||
@@ -883,33 +939,34 @@ class WP_List_Table {
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<?php $this->print_column_headers( false ); ?>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody id="the-list"<?php
|
||||
if ( $singular ) {
|
||||
echo " data-wp-lists='list:$singular'";
|
||||
} ?>>
|
||||
<?php $this->display_rows_or_placeholder(); ?>
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<?php $this->print_column_headers( false ); ?>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
</table>
|
||||
<?php
|
||||
$this->display_tablenav( 'bottom' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of CSS classes for the <table> tag
|
||||
* Get a list of CSS classes for the list table table tag.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @return array
|
||||
* @return array List of CSS classes for the table tag.
|
||||
*/
|
||||
protected function get_table_classes() {
|
||||
return array( 'widefat', 'fixed', $this->_args['plural'] );
|
||||
return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -917,6 +974,7 @@ class WP_List_Table {
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
* @param string $which
|
||||
*/
|
||||
protected function display_tablenav( $which ) {
|
||||
if ( 'top' == $which )
|
||||
@@ -942,11 +1000,13 @@ class WP_List_Table {
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*
|
||||
* @param string $which
|
||||
*/
|
||||
protected function extra_tablenav( $which ) {}
|
||||
|
||||
/**
|
||||
* Generate the <tbody> part of the table
|
||||
* Generate the tbody element for the list table.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access public
|
||||
@@ -981,14 +1041,15 @@ class WP_List_Table {
|
||||
* @param object $item The current item
|
||||
*/
|
||||
public function single_row( $item ) {
|
||||
static $row_class = '';
|
||||
$row_class = ( $row_class == '' ? ' class="alternate"' : '' );
|
||||
|
||||
echo '<tr' . $row_class . '>';
|
||||
echo '<tr>';
|
||||
$this->single_row_columns( $item );
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
protected function column_default( $item, $column_name ) {}
|
||||
|
||||
protected function column_cb( $item ) {}
|
||||
|
||||
/**
|
||||
* Generates the columns for a single row of the table
|
||||
*
|
||||
@@ -1058,7 +1119,7 @@ class WP_List_Table {
|
||||
$response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
|
||||
}
|
||||
|
||||
die( json_encode( $response ) );
|
||||
die( wp_json_encode( $response ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1075,6 +1136,6 @@ class WP_List_Table {
|
||||
)
|
||||
);
|
||||
|
||||
printf( "<script type='text/javascript'>list_args = %s;</script>\n", json_encode( $args ) );
|
||||
printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) );
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,10 @@
|
||||
*/
|
||||
class WP_Media_List_Table extends WP_List_Table {
|
||||
|
||||
private $detached;
|
||||
|
||||
private $is_trash;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -22,6 +26,11 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
public function __construct( $args = array() ) {
|
||||
$this->detached = ( isset( $_REQUEST['attachment-filter'] ) && 'detached' === $_REQUEST['attachment-filter'] );
|
||||
|
||||
$this->modes = array(
|
||||
'list' => __( 'List View' ),
|
||||
'grid' => __( 'Grid View' )
|
||||
);
|
||||
|
||||
parent::__construct( array(
|
||||
'plural' => 'media',
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
@@ -70,7 +79,7 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
if ( !empty( $_GET['attachment-filter'] ) && strpos( $_GET['attachment-filter'], 'post_mime_type:' ) === 0 && wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $_GET['attachment-filter'] ) ) )
|
||||
$selected = ' selected="selected"';
|
||||
if ( !empty( $num_posts[$mime_type] ) )
|
||||
$type_links[$mime_type] = '<option value="post_mime_type:' . urlencode( $mime_type ) . '"' . $selected . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</option>';
|
||||
$type_links[$mime_type] = '<option value="post_mime_type:' . esc_attr( $mime_type ) . '"' . $selected . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</option>';
|
||||
}
|
||||
$type_links['detached'] = '<option value="detached"' . ( $this->detached ? ' selected="selected"' : '' ) . '>' . sprintf( _nx( 'Unattached (%s)', 'Unattached (%s)', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</option>';
|
||||
|
||||
@@ -82,13 +91,26 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
|
||||
protected function get_bulk_actions() {
|
||||
$actions = array();
|
||||
$actions['delete'] = __( 'Delete Permanently' );
|
||||
if ( MEDIA_TRASH ) {
|
||||
if ( $this->is_trash ) {
|
||||
$actions['untrash'] = __( 'Restore' );
|
||||
$actions['delete'] = __( 'Delete Permanently' );
|
||||
} else {
|
||||
$actions['trash'] = __( 'Trash' );
|
||||
}
|
||||
} else {
|
||||
$actions['delete'] = __( 'Delete Permanently' );
|
||||
}
|
||||
|
||||
if ( $this->detached )
|
||||
$actions['attach'] = __( 'Attach to a post' );
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $which
|
||||
*/
|
||||
protected function extra_tablenav( $which ) {
|
||||
if ( 'bar' !== $which ) {
|
||||
return;
|
||||
@@ -117,6 +139,9 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) )
|
||||
return 'attach';
|
||||
|
||||
if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) )
|
||||
return 'detach';
|
||||
|
||||
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
|
||||
return 'delete_all';
|
||||
|
||||
@@ -131,44 +156,6 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
_e( 'No media attachments found.' );
|
||||
}
|
||||
|
||||
protected function pagination( $which ) {
|
||||
global $mode;
|
||||
|
||||
parent::pagination( $which );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a view switcher
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access protected
|
||||
*/
|
||||
protected function view_switcher( $current_mode ) {
|
||||
$modes = array(
|
||||
'list' => __( 'List View' ),
|
||||
'grid' => __( 'Grid View' )
|
||||
);
|
||||
|
||||
?>
|
||||
<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
|
||||
<div class="view-switch">
|
||||
<?php
|
||||
foreach ( $modes as $mode => $title ) {
|
||||
$classes = array( 'view-' . $mode );
|
||||
if ( $current_mode == $mode )
|
||||
$classes[] = 'current';
|
||||
printf(
|
||||
"<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
|
||||
esc_url( add_query_arg( 'mode', $mode ) ),
|
||||
implode( ' ', $classes ),
|
||||
$title
|
||||
);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Override parent views so we can use the filter bar display.
|
||||
*/
|
||||
@@ -178,33 +165,36 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
$views = $this->get_views();
|
||||
?>
|
||||
<div class="wp-filter">
|
||||
<?php $this->view_switcher( $mode ); ?>
|
||||
<div class="filter-items">
|
||||
<?php $this->view_switcher( $mode ); ?>
|
||||
|
||||
<select class="attachment-filters" name="attachment-filter">
|
||||
<?php
|
||||
if ( ! empty( $views ) ) {
|
||||
foreach ( $views as $class => $view ) {
|
||||
echo "\t$view\n";
|
||||
<label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label>
|
||||
<select class="attachment-filters" name="attachment-filter" id="attachment-filter">
|
||||
<?php
|
||||
if ( ! empty( $views ) ) {
|
||||
foreach ( $views as $class => $view ) {
|
||||
echo "\t$view\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
?>
|
||||
</select>
|
||||
|
||||
<?php
|
||||
$this->extra_tablenav( 'bar' );
|
||||
$this->extra_tablenav( 'bar' );
|
||||
|
||||
/** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
|
||||
$views = apply_filters( "views_{$this->screen->id}", array() );
|
||||
/** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
|
||||
$views = apply_filters( "views_{$this->screen->id}", array() );
|
||||
|
||||
// Back compat for pre-4.0 view links.
|
||||
if ( ! empty( $views ) ) {
|
||||
echo '<ul class="filter-links">';
|
||||
foreach ( $views as $class => $view ) {
|
||||
echo "<li class='$class'>$view</li>";
|
||||
// Back compat for pre-4.0 view links.
|
||||
if ( ! empty( $views ) ) {
|
||||
echo '<ul class="filter-links">';
|
||||
foreach ( $views as $class => $view ) {
|
||||
echo "<li class='$class'>$view</li>";
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="search-form">
|
||||
<label for="media-search-input" class="screen-reader-text"><?php esc_html_e( 'Search Media' ); ?></label>
|
||||
@@ -282,7 +272,6 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
global $post;
|
||||
|
||||
add_filter( 'the_title','esc_html' );
|
||||
$alt = '';
|
||||
|
||||
while ( have_posts() ) : the_post();
|
||||
$user_can_edit = current_user_can( 'edit_post', $post->ID );
|
||||
@@ -291,11 +280,10 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
|| !$this->is_trash && $post->post_status == 'trash' )
|
||||
continue;
|
||||
|
||||
$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
|
||||
$post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other';
|
||||
$att_title = _draft_or_post_title();
|
||||
?>
|
||||
<tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>">
|
||||
<tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>">
|
||||
<?php
|
||||
|
||||
list( $columns, $hidden ) = $this->get_column_info();
|
||||
@@ -331,7 +319,7 @@ foreach ( $columns as $column_name => $column_display_name ) {
|
||||
echo $thumb;
|
||||
} else {
|
||||
?>
|
||||
<a href="<?php echo get_edit_post_link( $post->ID, true ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ); ?>">
|
||||
<a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ); ?>">
|
||||
<?php echo $thumb; ?>
|
||||
</a>
|
||||
|
||||
@@ -348,19 +336,12 @@ foreach ( $columns as $column_name => $column_display_name ) {
|
||||
<?php if ( $this->is_trash || ! $user_can_edit ) {
|
||||
echo $att_title;
|
||||
} else { ?>
|
||||
<a href="<?php echo get_edit_post_link( $post->ID, true ); ?>"
|
||||
<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>
|
||||
<?php };
|
||||
_media_states( $post ); ?></strong>
|
||||
<p>
|
||||
<?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() ) );
|
||||
?>
|
||||
</p>
|
||||
<p class="filename"><?php echo wp_basename( $post->guid ); ?></p>
|
||||
<?php
|
||||
echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) );
|
||||
?>
|
||||
@@ -422,7 +403,16 @@ foreach ( $columns as $column_name => $column_display_name ) {
|
||||
} else {
|
||||
echo $title;
|
||||
} ?></strong>,
|
||||
<?php echo get_the_time( __( 'Y/m/d' ) ); ?>
|
||||
<?php echo get_the_time( __( 'Y/m/d' ) ); ?><br />
|
||||
<?php
|
||||
if ( $user_can_edit ):
|
||||
$detach_url = add_query_arg( array(
|
||||
'parent_post_id' => $post->post_parent,
|
||||
'media[]' => $post->ID,
|
||||
'_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] )
|
||||
), 'upload.php' ); ?>
|
||||
<a class="hide-if-no-js detach-from-parent" href="<?php echo $detach_url ?>"><?php _e( 'Detach' ); ?></a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php
|
||||
} else {
|
||||
@@ -486,21 +476,19 @@ foreach ( $columns as $column_name => $column_display_name ) {
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<td <?php echo $attributes ?>>
|
||||
<?php
|
||||
/**
|
||||
* Fires for each custom column in the Media list table.
|
||||
*
|
||||
* Custom columns are registered using the 'manage_media_columns' filter.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $column_name Name of the custom column.
|
||||
* @param int $post_id Attachment ID.
|
||||
*/
|
||||
?>
|
||||
<?php do_action( 'manage_media_custom_column', $column_name, $post->ID ); ?>
|
||||
</td>
|
||||
<td <?php echo $attributes ?>><?php
|
||||
/**
|
||||
* Fires for each custom column in the Media list table.
|
||||
*
|
||||
* Custom columns are registered using the 'manage_media_columns' filter.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $column_name Name of the custom column.
|
||||
* @param int $post_id Attachment ID.
|
||||
*/
|
||||
do_action( 'manage_media_custom_column', $column_name, $post->ID );
|
||||
?></td>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
@@ -510,12 +498,16 @@ foreach ( $columns as $column_name => $column_display_name ) {
|
||||
<?php endwhile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WP_Post $post
|
||||
* @param string $att_title
|
||||
*/
|
||||
private function _get_row_actions( $post, $att_title ) {
|
||||
$actions = array();
|
||||
|
||||
if ( $this->detached ) {
|
||||
if ( current_user_can( 'edit_post', $post->ID ) )
|
||||
$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '">' . __( 'Edit' ) . '</a>';
|
||||
$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '">' . __( '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-post_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
|
||||
@@ -529,7 +521,7 @@ foreach ( $columns as $column_name => $column_display_name ) {
|
||||
}
|
||||
else {
|
||||
if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash )
|
||||
$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '">' . __( 'Edit' ) . '</a>';
|
||||
$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '">' . __( 'Edit' ) . '</a>';
|
||||
if ( current_user_can( 'delete_post', $post->ID ) ) {
|
||||
if ( $this->is_trash )
|
||||
$actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
|
||||
|
||||
@@ -146,6 +146,9 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $which
|
||||
*/
|
||||
protected function pagination( $which ) {
|
||||
global $mode;
|
||||
|
||||
@@ -200,20 +203,19 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
);
|
||||
|
||||
if ( 'list' == $mode ) {
|
||||
$date = 'Y/m/d';
|
||||
$date = __( 'Y/m/d' );
|
||||
} else {
|
||||
$date = 'Y/m/d \<\b\r \/\> g:i:s a';
|
||||
$date = __( 'Y/m/d g:i:s a' );
|
||||
}
|
||||
|
||||
$class = '';
|
||||
foreach ( $this->items as $blog ) {
|
||||
$class = ( 'alternate' == $class ) ? '' : 'alternate';
|
||||
$class = '';
|
||||
reset( $status_list );
|
||||
|
||||
$blog_states = array();
|
||||
foreach ( $status_list as $status => $col ) {
|
||||
if ( get_blog_status( $blog['blog_id'], $status ) == 1 ) {
|
||||
$class = $col[0];
|
||||
$class = " class='{$col[0]}'";
|
||||
$blog_states[] = $col[1];
|
||||
}
|
||||
}
|
||||
@@ -228,7 +230,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
$blog_state .= "<span class='post-state'>$state$sep</span>";
|
||||
}
|
||||
}
|
||||
echo "<tr class='$class'>";
|
||||
echo "<tr{$class}>";
|
||||
|
||||
$blogname = ( is_subdomain_install() ) ? str_replace( '.' . get_current_site()->domain, '', $blog['domain'] ) : $blog['path'];
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||
public $site_id;
|
||||
public $is_site_themes;
|
||||
|
||||
private $has_items;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -142,6 +144,11 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @staticvar string $term
|
||||
* @param WP_Theme $theme
|
||||
* @return bool
|
||||
*/
|
||||
public function _search_callback( $theme ) {
|
||||
static $term;
|
||||
if ( is_null( $term ) )
|
||||
@@ -163,6 +170,13 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
// Not used by any core columns.
|
||||
/**
|
||||
* @global string $orderby
|
||||
* @global string $order
|
||||
* @param array $theme_a
|
||||
* @param array $theme_b
|
||||
* @return int
|
||||
*/
|
||||
public function _order_callback( $theme_a, $theme_b ) {
|
||||
global $orderby, $order;
|
||||
|
||||
@@ -266,6 +280,13 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||
$this->single_row( $theme );
|
||||
}
|
||||
|
||||
/**
|
||||
* @global string $status
|
||||
* @global int $page
|
||||
* @global string $s
|
||||
* @global array $totals
|
||||
* @param WP_Theme $theme
|
||||
*/
|
||||
public function single_row( $theme ) {
|
||||
global $status, $page, $s, $totals;
|
||||
|
||||
@@ -331,7 +352,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||
* Filter the action links of a specific theme in the Multisite themes
|
||||
* list table.
|
||||
*
|
||||
* The dynamic portion of the hook name, $stylesheet, refers to the
|
||||
* The dynamic portion of the hook name, `$stylesheet`, refers to the
|
||||
* directory name of the theme, which in most cases is synonymous
|
||||
* with the template name.
|
||||
*
|
||||
@@ -444,7 +465,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Fires after each specific row in the Multisite themes list table.
|
||||
*
|
||||
* The dynamic portion of the hook name, $stylesheet, refers to the
|
||||
* The dynamic portion of the hook name, `$stylesheet`, refers to the
|
||||
* directory name of the theme, most often synonymous with the template
|
||||
* name of the theme.
|
||||
*
|
||||
|
||||
@@ -102,6 +102,10 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
||||
return $role_links;
|
||||
}
|
||||
|
||||
/**
|
||||
* @global string $mode
|
||||
* @param string $which
|
||||
*/
|
||||
protected function pagination( $which ) {
|
||||
global $mode;
|
||||
|
||||
@@ -145,20 +149,19 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
||||
public function display_rows() {
|
||||
global $mode;
|
||||
|
||||
$alt = '';
|
||||
$super_admins = get_super_admins();
|
||||
foreach ( $this->items as $user ) {
|
||||
$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
|
||||
$class = '';
|
||||
|
||||
$status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
|
||||
|
||||
foreach ( $status_list as $status => $col ) {
|
||||
if ( $user->$status )
|
||||
$alt .= " $col";
|
||||
$class .= " $col";
|
||||
}
|
||||
|
||||
?>
|
||||
<tr class="<?php echo $alt; ?>">
|
||||
<tr class="<?php echo trim( $class ); ?>">
|
||||
<?php
|
||||
|
||||
list( $columns, $hidden ) = $this->get_column_info();
|
||||
@@ -226,9 +229,9 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
||||
|
||||
case 'registered':
|
||||
if ( 'list' == $mode )
|
||||
$date = 'Y/m/d';
|
||||
$date = __( 'Y/m/d' );
|
||||
else
|
||||
$date = 'Y/m/d \<\b\r \/\> g:i:s a';
|
||||
$date = __( 'Y/m/d g:i:s a' );
|
||||
|
||||
echo "<td $attributes>" . mysql2date( $date, $user->user_registered ) . "</td>";
|
||||
break;
|
||||
|
||||
@@ -9,9 +9,11 @@
|
||||
*/
|
||||
class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
|
||||
var $order = 'ASC';
|
||||
var $orderby = null;
|
||||
var $groups = array();
|
||||
public $order = 'ASC';
|
||||
public $orderby = null;
|
||||
public $groups = array();
|
||||
|
||||
private $error;
|
||||
|
||||
public function ajax_user_can() {
|
||||
return current_user_can('install_plugins');
|
||||
@@ -64,6 +66,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
$tabs['search'] = __( 'Search Results' );
|
||||
$tabs['featured'] = _x( 'Featured', 'Plugin Installer' );
|
||||
$tabs['popular'] = _x( 'Popular', 'Plugin Installer' );
|
||||
$tabs['recommended'] = _x( 'Recommended', 'Plugin Installer' );
|
||||
$tabs['favorites'] = _x( 'Favorites', 'Plugin Installer' );
|
||||
if ( $tab === 'beta' || false !== strpos( $GLOBALS['wp_version'], '-' ) ) {
|
||||
$tabs['beta'] = _x( 'Beta Testing', 'Plugin Installer' );
|
||||
@@ -81,8 +84,8 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param array $tabs The tabs shown on the Plugin Install screen. Defaults are 'dashboard', 'search',
|
||||
* 'upload', 'featured', 'popular', 'new', and 'favorites'.
|
||||
* @param array $tabs The tabs shown on the Plugin Install screen. Defaults include 'featured', 'popular',
|
||||
* 'recommended', 'favorites', and 'upload'.
|
||||
*/
|
||||
$tabs = apply_filters( 'install_plugins_tabs', $tabs );
|
||||
|
||||
@@ -102,7 +105,11 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
$args = array(
|
||||
'page' => $paged,
|
||||
'per_page' => $per_page,
|
||||
'fields' => array( 'last_updated' => true, 'downloaded' => true, 'icons' => true ),
|
||||
'fields' => array(
|
||||
'last_updated' => true,
|
||||
'icons' => true,
|
||||
'active_installs' => true
|
||||
),
|
||||
// Send the locale and installed plugin slugs to the API so it can provide context-sensitive results.
|
||||
'locale' => get_locale(),
|
||||
'installed_plugins' => $this->get_installed_plugin_slugs(),
|
||||
@@ -134,6 +141,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
case 'popular':
|
||||
case 'new':
|
||||
case 'beta':
|
||||
case 'recommended':
|
||||
$args['browse'] = $tab;
|
||||
break;
|
||||
|
||||
@@ -156,9 +164,8 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Filter API request arguments for each Plugin Install screen tab.
|
||||
*
|
||||
* The dynamic portion of the hook name, $tab, refers to the plugin install tabs.
|
||||
* Default tabs are 'dashboard', 'search', 'upload', 'featured', 'popular', 'new',
|
||||
* and 'favorites'.
|
||||
* The dynamic portion of the hook name, `$tab`, refers to the plugin install tabs.
|
||||
* Default tabs include 'featured', 'popular', 'recommended', 'favorites', and 'upload'.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
@@ -268,6 +275,9 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
$this->display_tablenav( 'bottom' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $which
|
||||
*/
|
||||
protected function display_tablenav( $which ) {
|
||||
if ( $GLOBALS['tab'] === 'featured' ) {
|
||||
return;
|
||||
@@ -306,6 +316,11 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $plugin_a
|
||||
* @param object $plugin_b
|
||||
* @return int
|
||||
*/
|
||||
private function order_callback( $plugin_a, $plugin_b ) {
|
||||
$orderby = $this->orderby;
|
||||
if ( ! isset( $plugin_a->$orderby, $plugin_b->$orderby ) ) {
|
||||
@@ -391,14 +406,14 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
case 'install':
|
||||
if ( $status['url'] ) {
|
||||
/* translators: 1: Plugin name and version. */
|
||||
$action_links[] = '<a class="install-now button" href="' . $status['url'] . '" aria-label="' . esc_attr( sprintf( __( 'Install %s now' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>';
|
||||
$action_links[] = '<a class="install-now button" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Install %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Install Now' ) . '</a>';
|
||||
}
|
||||
|
||||
break;
|
||||
case 'update_available':
|
||||
if ( $status['url'] ) {
|
||||
/* translators: 1: Plugin name and version */
|
||||
$action_links[] = '<a class="button" href="' . $status['url'] . '" aria-label="' . esc_attr( sprintf( __( 'Update %s now' ), $name ) ) . '">' . __( 'Update Now' ) . '</a>';
|
||||
$action_links[] = '<a class="update-now button" data-plugin="' . esc_attr( $status['file'] ) . '" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Update %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Update Now' ) . '</a>';
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -434,8 +449,11 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
* @param array $plugin The plugin currently being listed.
|
||||
*/
|
||||
$action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin );
|
||||
|
||||
$date_format = __( 'M j, Y @ H:i' );
|
||||
$last_updated_timestamp = strtotime( $plugin['last_updated'] );
|
||||
?>
|
||||
<div class="plugin-card">
|
||||
<div class="plugin-card plugin-card-<?php echo sanitize_html_class( $plugin['slug'] ); ?>">
|
||||
<div class="plugin-card-top">
|
||||
<a href="<?php echo esc_url( $details_link ); ?>" class="thickbox plugin-icon"><img src="<?php echo esc_attr( $plugin_icon_url ) ?>" /></a>
|
||||
<div class="name column-name">
|
||||
@@ -459,17 +477,24 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
<span class="num-ratings">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span>
|
||||
</div>
|
||||
<div class="column-updated">
|
||||
<strong><?php _e( 'Last Updated:' ); ?></strong> <span title="<?php echo esc_attr( $plugin['last_updated'] ); ?>">
|
||||
<?php printf( __( '%s ago' ), human_time_diff( strtotime( $plugin['last_updated'] ) ) ); ?>
|
||||
<strong><?php _e( 'Last Updated:' ); ?></strong> <span title="<?php echo esc_attr( date_i18n( $date_format, $last_updated_timestamp ) ); ?>">
|
||||
<?php printf( __( '%s ago' ), human_time_diff( $last_updated_timestamp ) ); ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="column-downloaded">
|
||||
<?php echo sprintf( _n( '%s download', '%s downloads', $plugin['downloaded'] ), number_format_i18n( $plugin['downloaded'] ) ); ?>
|
||||
<?php
|
||||
if ( $plugin['active_installs'] >= 1000000 ) {
|
||||
$active_installs_text = _x( '1+ Million', 'Active plugin installs' );
|
||||
} else {
|
||||
$active_installs_text = number_format_i18n( $plugin['active_installs'] ) . '+';
|
||||
}
|
||||
printf( __( '%s Active Installs' ), $active_installs_text );
|
||||
?>
|
||||
</div>
|
||||
<div class="column-compatibility">
|
||||
<?php
|
||||
if ( ! empty( $plugin['tested'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '>' ) ) {
|
||||
echo '<span class="compatibility-untested">' . __( '<strong>Untested</strong> with your version of WordPress' ) . '</span>';
|
||||
echo '<span class="compatibility-untested">' . __( 'Untested with your version of WordPress' ) . '</span>';
|
||||
} elseif ( ! empty( $plugin['requires'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['requires'] ) ), $plugin['requires'], '<' ) ) {
|
||||
echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>';
|
||||
} else {
|
||||
|
||||
@@ -125,8 +125,17 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
// Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide.
|
||||
if ( isset( $plugin_info->response[ $plugin_file ] ) ) {
|
||||
$plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
|
||||
// Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
|
||||
if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
|
||||
$plugins['upgrade'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
|
||||
}
|
||||
|
||||
} elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) {
|
||||
$plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
|
||||
// Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
|
||||
if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
|
||||
$plugins['upgrade'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
|
||||
}
|
||||
}
|
||||
|
||||
// Filter into individual sections
|
||||
@@ -191,6 +200,11 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @staticvar string $term
|
||||
* @param array $plugin
|
||||
* @return boolean
|
||||
*/
|
||||
public function _search_callback( $plugin ) {
|
||||
static $term;
|
||||
if ( is_null( $term ) )
|
||||
@@ -205,6 +219,13 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @global string $orderby
|
||||
* @global string $order
|
||||
* @param array $plugin_a
|
||||
* @param array $plugin_b
|
||||
* @return int
|
||||
*/
|
||||
public function _order_callback( $plugin_a, $plugin_b ) {
|
||||
global $orderby, $order;
|
||||
|
||||
@@ -308,6 +329,11 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @global string $status
|
||||
* @param string $which
|
||||
* @return null
|
||||
*/
|
||||
public function bulk_actions( $which = '' ) {
|
||||
global $status;
|
||||
|
||||
@@ -317,6 +343,11 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
parent::bulk_actions( $which );
|
||||
}
|
||||
|
||||
/**
|
||||
* @global string $status
|
||||
* @param string $which
|
||||
* @return null
|
||||
*/
|
||||
protected function extra_tablenav( $which ) {
|
||||
global $status;
|
||||
|
||||
@@ -352,6 +383,13 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
$this->single_row( array( $plugin_file, $plugin_data ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @global string $status
|
||||
* @global int $page
|
||||
* @global string $s
|
||||
* @global array $totals
|
||||
* @param array $item
|
||||
*/
|
||||
public function single_row( $item ) {
|
||||
global $status, $page, $s, $totals;
|
||||
|
||||
@@ -424,7 +462,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Filter the action links displayed for each plugin in the Plugins list table.
|
||||
*
|
||||
* The dynamic portion of the hook name, $prefix, refers to the context the
|
||||
* The dynamic portion of the hook name, `$prefix`, refers to the context the
|
||||
* action links are displayed in. The 'network_admin_' prefix is used if the
|
||||
* current screen is the Network plugins list table. The prefix is empty ('')
|
||||
* if the current screen is the site plugins list table.
|
||||
@@ -486,7 +524,12 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) )
|
||||
$class .= ' update';
|
||||
|
||||
echo "<tr id='$id' class='$class'>";
|
||||
$plugin_slug = ( isset( $plugin_data['slug'] ) ) ? $plugin_data['slug'] : '';
|
||||
printf( "<tr id='%s' class='%s' data-slug='%s'>",
|
||||
$id,
|
||||
$class,
|
||||
$plugin_slug
|
||||
);
|
||||
|
||||
list( $columns, $hidden ) = $this->get_column_info();
|
||||
|
||||
@@ -589,7 +632,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Fires after each specific row in the Plugins list table.
|
||||
*
|
||||
* The dynamic portion of the hook name, $plugin_file, refers to the path
|
||||
* The dynamic portion of the hook name, `$plugin_file`, refers to the path
|
||||
* to the plugin file, relative to the plugins directory.
|
||||
*
|
||||
* @since 2.7.0
|
||||
|
||||
@@ -45,6 +45,8 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
*/
|
||||
private $sticky_posts_count = 0;
|
||||
|
||||
private $is_trash;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -84,6 +86,17 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the table layout should be hierarchical or not.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param bool $display Whether the table layout should be hierarchical.
|
||||
*/
|
||||
public function set_hierarchical_display( $display ) {
|
||||
$this->hierarchical_display = $display;
|
||||
}
|
||||
|
||||
public function ajax_user_can() {
|
||||
return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts );
|
||||
}
|
||||
@@ -93,7 +106,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
|
||||
$avail_post_stati = wp_edit_posts_query();
|
||||
|
||||
$this->hierarchical_display = ( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] );
|
||||
$this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] );
|
||||
|
||||
$total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts;
|
||||
|
||||
@@ -135,6 +148,21 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
echo get_post_type_object( $this->screen->post_type )->labels->not_found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current view is the "All" view.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @return bool Whether the current ivew is the "All" view.
|
||||
*/
|
||||
protected function is_base_request() {
|
||||
if ( empty( $_GET ) ) {
|
||||
return true;
|
||||
} elseif ( 1 === count( $_GET ) && ! empty( $_GET['post_type'] ) ) {
|
||||
return $this->screen->post_type === $_GET['post_type'];
|
||||
}
|
||||
}
|
||||
|
||||
protected function get_views() {
|
||||
global $locked_post_status, $avail_post_stati;
|
||||
|
||||
@@ -155,6 +183,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
$class = ' class="current"';
|
||||
$status_links['mine'] = "<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>', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . '</a>';
|
||||
$allposts = '&all_posts=1';
|
||||
$class = '';
|
||||
}
|
||||
|
||||
$total_posts = array_sum( (array) $num_posts );
|
||||
@@ -163,8 +192,21 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state )
|
||||
$total_posts -= $num_posts->$state;
|
||||
|
||||
$class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
|
||||
$status_links['all'] = "<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>';
|
||||
if ( empty( $class ) && $this->is_base_request() && ! $this->user_posts_count ) {
|
||||
$class = ' class="current"';
|
||||
}
|
||||
|
||||
$all_inner_html = sprintf(
|
||||
_nx(
|
||||
'All <span class="count">(%s)</span>',
|
||||
'All <span class="count">(%s)</span>',
|
||||
$total_posts,
|
||||
'posts'
|
||||
),
|
||||
number_format_i18n( $total_posts )
|
||||
);
|
||||
|
||||
$status_links['all'] = "<a href='edit.php?post_type=$post_type{$allposts}'$class>" . $all_inner_html . '</a>';
|
||||
|
||||
foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
|
||||
$class = '';
|
||||
@@ -198,20 +240,29 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
|
||||
protected function get_bulk_actions() {
|
||||
$actions = array();
|
||||
$post_type_obj = get_post_type_object( $this->screen->post_type );
|
||||
|
||||
if ( $this->is_trash )
|
||||
if ( $this->is_trash ) {
|
||||
$actions['untrash'] = __( 'Restore' );
|
||||
else
|
||||
} else {
|
||||
$actions['edit'] = __( 'Edit' );
|
||||
}
|
||||
|
||||
if ( $this->is_trash || !EMPTY_TRASH_DAYS )
|
||||
$actions['delete'] = __( 'Delete Permanently' );
|
||||
else
|
||||
$actions['trash'] = __( 'Move to Trash' );
|
||||
if ( current_user_can( $post_type_obj->cap->delete_posts ) ) {
|
||||
if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) {
|
||||
$actions['delete'] = __( 'Delete Permanently' );
|
||||
} else {
|
||||
$actions['trash'] = __( 'Move to Trash' );
|
||||
}
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @global int $cat
|
||||
* @param string $which
|
||||
*/
|
||||
protected function extra_tablenav( $which ) {
|
||||
global $cat;
|
||||
?>
|
||||
@@ -223,13 +274,15 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
|
||||
if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) {
|
||||
$dropdown_options = array(
|
||||
'show_option_all' => __( 'View all categories' ),
|
||||
'show_option_all' => __( 'All categories' ),
|
||||
'hide_empty' => 0,
|
||||
'hierarchical' => 1,
|
||||
'show_count' => 0,
|
||||
'orderby' => 'name',
|
||||
'selected' => $cat
|
||||
);
|
||||
|
||||
echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>';
|
||||
wp_dropdown_categories( $dropdown_options );
|
||||
}
|
||||
|
||||
@@ -261,6 +314,10 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
return parent::current_action();
|
||||
}
|
||||
|
||||
/**
|
||||
* @global string $mode
|
||||
* @param string $which
|
||||
*/
|
||||
protected function pagination( $which ) {
|
||||
global $mode;
|
||||
|
||||
@@ -271,7 +328,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
protected function get_table_classes() {
|
||||
return array( 'widefat', 'fixed', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
|
||||
return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
|
||||
}
|
||||
|
||||
public function get_columns() {
|
||||
@@ -294,7 +351,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Filter the taxonomy columns in the Posts list table.
|
||||
*
|
||||
* The dynamic portion of the hook name, $post_type, refers to the post
|
||||
* The dynamic portion of the hook name, `$post_type`, refers to the post
|
||||
* type slug.
|
||||
*
|
||||
* @since 3.5.0
|
||||
@@ -318,7 +375,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
|
||||
$post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
|
||||
if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
|
||||
$posts_columns['comments'] = '<span class="vers"><span title="' . esc_attr__( 'Comments' ) . '" class="comment-grey-bubble"></span></span>';
|
||||
$posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
|
||||
|
||||
$posts_columns['date'] = __( 'Date' );
|
||||
|
||||
@@ -348,7 +405,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Filter the columns displayed in the Posts list table for a specific post type.
|
||||
*
|
||||
* The dynamic portion of the hook name, $post_type, refers to the post type slug.
|
||||
* The dynamic portion of the hook name, `$post_type`, refers to the post type slug.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
@@ -368,6 +425,12 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @global WP_Query $wp_query
|
||||
* @global int $per_page
|
||||
* @param array $posts
|
||||
* @param int $level
|
||||
*/
|
||||
public function display_rows( $posts = array(), $level = 0 ) {
|
||||
global $wp_query, $per_page;
|
||||
|
||||
@@ -383,6 +446,11 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @global string $mode
|
||||
* @param array $posts
|
||||
* @param int $level
|
||||
*/
|
||||
private function _display_rows( $posts, $level = 0 ) {
|
||||
global $mode;
|
||||
|
||||
@@ -398,6 +466,13 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
$this->single_row( $post, $level );
|
||||
}
|
||||
|
||||
/**
|
||||
* @global wpdb $wpdb
|
||||
* @param array $pages
|
||||
* @param int $pagenum
|
||||
* @param int $per_page
|
||||
* @return false|null
|
||||
*/
|
||||
private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
|
||||
global $wpdb;
|
||||
|
||||
@@ -443,20 +518,20 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
$count = 0;
|
||||
$start = ( $pagenum - 1 ) * $per_page;
|
||||
$end = $start + $per_page;
|
||||
$to_display = array();
|
||||
|
||||
foreach ( $pages as $page ) {
|
||||
if ( $count >= $end )
|
||||
break;
|
||||
|
||||
if ( $count >= $start ) {
|
||||
echo "\t";
|
||||
$this->single_row( $page, $level );
|
||||
$to_display[$page->ID] = $level;
|
||||
}
|
||||
|
||||
$count++;
|
||||
|
||||
if ( isset( $children_pages ) )
|
||||
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
|
||||
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
|
||||
}
|
||||
|
||||
// If it is the last pagenum and there are orphaned pages, display them with paging as well.
|
||||
@@ -467,14 +542,25 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
break;
|
||||
|
||||
if ( $count >= $start ) {
|
||||
echo "\t";
|
||||
$this->single_row( $op, 0 );
|
||||
$to_display[$op->ID] = 0;
|
||||
}
|
||||
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ids = array_keys( $to_display );
|
||||
_prime_post_caches( $ids );
|
||||
|
||||
if ( ! isset( $GLOBALS['post'] ) ) {
|
||||
$GLOBALS['post'] = reset( $ids );
|
||||
}
|
||||
|
||||
foreach ( $to_display as $page_id => $level ) {
|
||||
echo "\t";
|
||||
$this->single_row( $page_id, $level );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,6 +568,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
* together with paging support
|
||||
*
|
||||
* @since 3.1.0 (Standalone function exists since 2.6.0)
|
||||
* @since 4.2.0 Added the `$to_display` parameter.
|
||||
*
|
||||
* @param array $children_pages
|
||||
* @param int $count
|
||||
@@ -489,8 +576,9 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
* @param int $level
|
||||
* @param int $pagenum
|
||||
* @param int $per_page
|
||||
* @param array $to_display List of pages to be displayed. Passed by reference.
|
||||
*/
|
||||
private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
|
||||
private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) {
|
||||
|
||||
if ( ! isset( $children_pages[$parent] ) )
|
||||
return;
|
||||
@@ -508,7 +596,13 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
$my_parents = array();
|
||||
$my_parent = $page->post_parent;
|
||||
while ( $my_parent ) {
|
||||
$my_parent = get_post( $my_parent );
|
||||
// Get the ID from the list or the attribute if my_parent is an object
|
||||
$parent_id = $my_parent;
|
||||
if ( is_object( $my_parent ) ) {
|
||||
$parent_id = $my_parent->ID;
|
||||
}
|
||||
|
||||
$my_parent = get_post( $parent_id );
|
||||
$my_parents[] = $my_parent;
|
||||
if ( !$my_parent->post_parent )
|
||||
break;
|
||||
@@ -516,30 +610,35 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
}
|
||||
$num_parents = count( $my_parents );
|
||||
while ( $my_parent = array_pop( $my_parents ) ) {
|
||||
echo "\t";
|
||||
$this->single_row( $my_parent, $level - $num_parents );
|
||||
$to_display[$my_parent->ID] = $level - $num_parents;
|
||||
$num_parents--;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $count >= $start ) {
|
||||
echo "\t";
|
||||
$this->single_row( $page, $level );
|
||||
$to_display[$page->ID] = $level;
|
||||
}
|
||||
|
||||
$count++;
|
||||
|
||||
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
|
||||
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
|
||||
}
|
||||
|
||||
unset( $children_pages[$parent] ); //required in order to keep track of orphans
|
||||
}
|
||||
|
||||
/**
|
||||
* @global string $mode
|
||||
* @param WP_Post $post
|
||||
* @param int $level
|
||||
*/
|
||||
public function single_row( $post, $level = 0 ) {
|
||||
global $mode;
|
||||
static $alternate;
|
||||
|
||||
$global_post = get_post();
|
||||
|
||||
$post = get_post( $post );
|
||||
|
||||
$GLOBALS['post'] = $post;
|
||||
setup_postdata( $post );
|
||||
|
||||
@@ -548,8 +647,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
$post_type_object = get_post_type_object( $post->post_type );
|
||||
$can_edit_post = current_user_can( 'edit_post', $post->ID );
|
||||
|
||||
$alternate = 'alternate' == $alternate ? '' : 'alternate';
|
||||
$classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
|
||||
$classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
|
||||
|
||||
$lock_holder = wp_check_post_lock( $post->ID );
|
||||
if ( $lock_holder ) {
|
||||
@@ -657,16 +755,16 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
|
||||
$actions = array();
|
||||
if ( $can_edit_post && 'trash' != $post->post_status ) {
|
||||
$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
|
||||
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick Edit' ) . '</a>';
|
||||
$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . esc_attr__( 'Edit this item' ) . '">' . __( 'Edit' ) . '</a>';
|
||||
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__( 'Edit this item inline' ) . '">' . __( 'Quick Edit' ) . '</a>';
|
||||
}
|
||||
if ( current_user_can( 'delete_post', $post->ID ) ) {
|
||||
if ( 'trash' == $post->post_status )
|
||||
$actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
|
||||
$actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
|
||||
elseif ( EMPTY_TRASH_DAYS )
|
||||
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
|
||||
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
|
||||
if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
|
||||
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
|
||||
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
|
||||
}
|
||||
if ( $post_type_object->public ) {
|
||||
if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
|
||||
@@ -724,7 +822,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
$t_time = $h_time = __( 'Unpublished' );
|
||||
$time_diff = 0;
|
||||
} else {
|
||||
$t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
|
||||
$t_time = get_the_time( __( 'Y/m/d g:i:s a' ) );
|
||||
$m_time = $post->post_date;
|
||||
$time = get_post_time( 'G', true, $post );
|
||||
|
||||
@@ -870,7 +968,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Fires for each custom column of a specific post type in the Posts list table.
|
||||
*
|
||||
* The dynamic portion of the hook name, $post->post_type, refers to the post type.
|
||||
* The dynamic portion of the hook name, `$post->post_type`, refers to the post type.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -906,10 +1004,23 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
$hierarchical_taxonomies = array();
|
||||
$flat_taxonomies = array();
|
||||
foreach ( $taxonomy_names as $taxonomy_name ) {
|
||||
|
||||
$taxonomy = get_taxonomy( $taxonomy_name );
|
||||
|
||||
if ( !$taxonomy->show_ui )
|
||||
$show_in_quick_edit = $taxonomy->show_in_quick_edit;
|
||||
|
||||
/**
|
||||
* Filter whether the current taxonomy should be shown in the Quick Edit panel.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param bool $show_in_quick_edit Whether to show the current taxonomy in Quick Edit.
|
||||
* @param string $taxonomy_name Taxonomy name.
|
||||
* @param string $post_type Post type of current Quick Edit post.
|
||||
*/
|
||||
if ( ! apply_filters( 'quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $taxonomy->hierarchical )
|
||||
$hierarchical_taxonomies[] = $taxonomy;
|
||||
@@ -923,7 +1034,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
|
||||
?>
|
||||
|
||||
<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
|
||||
<form method="get"><table style="display: none"><tbody id="inlineedit">
|
||||
<?php
|
||||
$hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
|
||||
$bulk = 0;
|
||||
@@ -1002,7 +1113,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
<span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
|
||||
</label>
|
||||
|
||||
<em style="margin:5px 10px 0 0" class="alignleft">
|
||||
<em class="alignleft inline-edit-or">
|
||||
<?php
|
||||
/* translators: Between password field and private checkbox on post quick edit interface */
|
||||
echo __( '–OR–' );
|
||||
@@ -1097,7 +1208,11 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
<?php if ( $bulk ) : ?>
|
||||
<option value="-1"><?php _e( '— No Change —' ); ?></option>
|
||||
<?php endif; // $bulk ?>
|
||||
<option value="default"><?php _e( 'Default Template' ); ?></option>
|
||||
<?php
|
||||
/** This filter is documented in wp-admin/includes/meta-boxes.php */
|
||||
$default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' );
|
||||
?>
|
||||
<option value="default"><?php echo esc_html( $default_title ); ?></option>
|
||||
<?php page_template_dropdown() ?>
|
||||
</select>
|
||||
</label>
|
||||
@@ -1273,14 +1388,14 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
}
|
||||
?>
|
||||
<p class="submit inline-edit-save">
|
||||
<a accesskey="c" href="#inline-edit" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
|
||||
<a href="#inline-edit" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
|
||||
<?php if ( ! $bulk ) {
|
||||
wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
|
||||
?>
|
||||
<a accesskey="s" href="#inline-edit" class="button-primary save alignright"><?php _e( 'Update' ); ?></a>
|
||||
<a href="#inline-edit" class="button-primary save alignright"><?php _e( 'Update' ); ?></a>
|
||||
<span class="spinner"></span>
|
||||
<?php } else {
|
||||
submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
|
||||
submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false );
|
||||
} ?>
|
||||
<input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
|
||||
<input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -11,6 +11,8 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
|
||||
public $callback_args;
|
||||
|
||||
private $level;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -112,6 +114,10 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function no_items() {
|
||||
echo get_taxonomy( $this->screen->taxonomy )->labels->not_found;
|
||||
}
|
||||
|
||||
protected function get_bulk_actions() {
|
||||
$actions = array();
|
||||
$actions['delete'] = __( 'Delete' );
|
||||
@@ -202,6 +208,16 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $taxonomy
|
||||
* @param array $terms
|
||||
* @param array $children
|
||||
* @param int $start
|
||||
* @param int $per_page
|
||||
* @param int $count
|
||||
* @param int $parent
|
||||
* @param int $level
|
||||
*/
|
||||
private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0 ) {
|
||||
|
||||
$end = $start + $per_page;
|
||||
@@ -250,20 +266,26 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @global string $taxonomy
|
||||
* @param object $tag
|
||||
* @param int $level
|
||||
*/
|
||||
public function single_row( $tag, $level = 0 ) {
|
||||
global $taxonomy;
|
||||
$tag = sanitize_term( $tag, $taxonomy );
|
||||
|
||||
static $row_class = '';
|
||||
$row_class = ( $row_class == '' ? ' class="alternate"' : '' );
|
||||
|
||||
$this->level = $level;
|
||||
|
||||
echo '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>';
|
||||
echo '<tr id="tag-' . $tag->term_id . '">';
|
||||
$this->single_row_columns( $tag );
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $tag
|
||||
* @return string
|
||||
*/
|
||||
public function column_cb( $tag ) {
|
||||
$default_term = get_option( 'default_' . $this->screen->taxonomy );
|
||||
|
||||
@@ -274,6 +296,10 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
return ' ';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $tag
|
||||
* @return string
|
||||
*/
|
||||
public function column_name( $tag ) {
|
||||
$taxonomy = $this->screen->taxonomy;
|
||||
$tax = get_taxonomy( $taxonomy );
|
||||
@@ -327,7 +353,7 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* Filter the action links displayed for each term in the terms list table.
|
||||
*
|
||||
* The dynamic portion of the hook name, $taxonomy, refers to the taxonomy slug.
|
||||
* The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
@@ -348,15 +374,27 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $tag
|
||||
* @return string
|
||||
*/
|
||||
public function column_description( $tag ) {
|
||||
return $tag->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $tag
|
||||
* @return string
|
||||
*/
|
||||
public function column_slug( $tag ) {
|
||||
/** This filter is documented in wp-admin/edit-tag-form.php */
|
||||
return apply_filters( 'editable_slug', $tag->slug );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $tag
|
||||
* @return string
|
||||
*/
|
||||
public function column_posts( $tag ) {
|
||||
$count = number_format_i18n( $tag->count );
|
||||
|
||||
@@ -381,6 +419,10 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $tag
|
||||
* @return string
|
||||
*/
|
||||
public function column_links( $tag ) {
|
||||
$count = number_format_i18n( $tag->count );
|
||||
if ( $count )
|
||||
@@ -388,11 +430,16 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $tag
|
||||
* @param string $column_name
|
||||
* @return string
|
||||
*/
|
||||
public function column_default( $tag, $column_name ) {
|
||||
/**
|
||||
* Filter the displayed columns in the terms list table.
|
||||
*
|
||||
* The dynamic portion of the hook name, $this->screen->taxonomy,
|
||||
* The dynamic portion of the hook name, `$this->screen->taxonomy`,
|
||||
* refers to the slug of the current taxonomy.
|
||||
*
|
||||
* @since 2.8.0
|
||||
@@ -416,7 +463,7 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
return;
|
||||
?>
|
||||
|
||||
<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
|
||||
<form method="get"><table style="display: none"><tbody id="inlineedit">
|
||||
<tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
|
||||
|
||||
<fieldset><div class="inline-edit-col">
|
||||
@@ -450,8 +497,8 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
?>
|
||||
|
||||
<p class="inline-edit-save submit">
|
||||
<a accesskey="c" href="#inline-edit" class="cancel button-secondary alignleft"><?php _e( 'Cancel' ); ?></a>
|
||||
<a accesskey="s" href="#inline-edit" class="save button-primary alignright"><?php echo $tax->labels->update_item; ?></a>
|
||||
<a href="#inline-edit" class="cancel button-secondary alignleft"><?php _e( 'Cancel' ); ?></a>
|
||||
<a href="#inline-edit" class="save button-primary alignright"><?php echo $tax->labels->update_item; ?></a>
|
||||
<span class="spinner"></span>
|
||||
<span class="error" style="display:none;"></span>
|
||||
<?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
|
||||
|
||||
@@ -106,7 +106,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
||||
/**
|
||||
* Filter API request arguments for each Install Themes screen tab.
|
||||
*
|
||||
* The dynamic portion of the hook name, $tab, refers to the theme install
|
||||
* The dynamic portion of the hook name, `$tab`, refers to the theme install
|
||||
* tabs. Default tabs are 'dashboard', 'search', 'upload', 'featured',
|
||||
* 'new', and 'updated'.
|
||||
*
|
||||
@@ -173,7 +173,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
||||
</div>
|
||||
|
||||
<?php
|
||||
parent::tablenav( 'bottom' );
|
||||
$this->tablenav( 'bottom' );
|
||||
}
|
||||
|
||||
public function display_rows() {
|
||||
|
||||
@@ -95,6 +95,10 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||
printf( __( 'Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.' ), get_site_option( 'site_name' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $which
|
||||
* @return null
|
||||
*/
|
||||
public function tablenav( $which = 'top' ) {
|
||||
if ( $this->get_pagination_arg( 'total_pages' ) <= 1 )
|
||||
return;
|
||||
@@ -205,11 +209,11 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||
</div>
|
||||
|
||||
<div class="themedetaildiv hide-if-js">
|
||||
<p><strong><?php _e('Version: '); ?></strong><?php echo $version; ?></p>
|
||||
<p><strong><?php _e('Version:'); ?></strong> <?php echo $version; ?></p>
|
||||
<p><?php echo $theme->display('Description'); ?></p>
|
||||
<?php if ( $theme->parent() ) {
|
||||
printf( ' <p class="howto">' . __( 'This <a href="%1$s">child theme</a> requires its parent theme, %2$s.' ) . '</p>',
|
||||
__( 'http://codex.wordpress.org/Child_Themes' ),
|
||||
__( 'https://codex.wordpress.org/Child_Themes' ),
|
||||
$theme->parent()->display( 'Name' ) );
|
||||
} ?>
|
||||
</div>
|
||||
@@ -219,6 +223,10 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||
endforeach;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WP_Theme $theme
|
||||
* @return bool
|
||||
*/
|
||||
public function search_theme( $theme ) {
|
||||
// Search the features
|
||||
foreach ( $this->features as $word ) {
|
||||
@@ -256,9 +264,7 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||
* @since 3.4.0
|
||||
* @access public
|
||||
*
|
||||
* @uses $this->features Array of all feature search terms.
|
||||
* @uses get_pagenum()
|
||||
* @uses _pagination_args['total_pages']
|
||||
* @param array $extra_args
|
||||
*/
|
||||
public function _js_vars( $extra_args = array() ) {
|
||||
$search_string = isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
|
||||
@@ -273,7 +279,7 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||
if ( is_array( $extra_args ) )
|
||||
$args = array_merge( $args, $extra_args );
|
||||
|
||||
printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", json_encode( $args ) );
|
||||
printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode( $args ) );
|
||||
parent::_js_vars();
|
||||
}
|
||||
}
|
||||
@@ -20,12 +20,16 @@ class WP_Upgrader_Skin {
|
||||
public $done_header = false;
|
||||
public $done_footer = false;
|
||||
public $result = false;
|
||||
public $options = array();
|
||||
|
||||
public function __construct($args = array()) {
|
||||
$defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
|
||||
$this->options = wp_parse_args($args, $defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WP_Upgrader $upgrader
|
||||
*/
|
||||
public function set_upgrader(&$upgrader) {
|
||||
if ( is_object($upgrader) )
|
||||
$this->upgrader =& $upgrader;
|
||||
@@ -39,12 +43,18 @@ class WP_Upgrader_Skin {
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
public function request_filesystem_credentials($error = false) {
|
||||
public function request_filesystem_credentials( $error = false, $context = false, $allow_relaxed_file_ownership = false ) {
|
||||
$url = $this->options['url'];
|
||||
$context = $this->options['context'];
|
||||
if ( !empty($this->options['nonce']) )
|
||||
if ( ! $context ) {
|
||||
$context = $this->options['context'];
|
||||
}
|
||||
if ( !empty($this->options['nonce']) ) {
|
||||
$url = wp_nonce_url($url, $this->options['nonce']);
|
||||
return request_filesystem_credentials($url, '', $error, $context); //Possible to bring inline, Leaving as is for now.
|
||||
}
|
||||
|
||||
$extra_fields = array();
|
||||
|
||||
return request_filesystem_credentials( $url, '', $error, $context, $extra_fields, $allow_relaxed_file_ownership );
|
||||
}
|
||||
|
||||
public function header() {
|
||||
@@ -127,6 +137,9 @@ class WP_Upgrader_Skin {
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
|
||||
public function bulk_header() {}
|
||||
public function bulk_footer() {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,6 +205,9 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
*/
|
||||
class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
public $in_loop = false;
|
||||
/**
|
||||
* @var string|false
|
||||
*/
|
||||
public $error = false;
|
||||
|
||||
public function __construct($args = array()) {
|
||||
@@ -205,10 +221,13 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
$this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
|
||||
$this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: <strong>%2$s</strong>');
|
||||
$this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
|
||||
$this->upgrader->strings['skin_update_successful'] = __('%1$s updated successfully.').' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>'.__('Show Details').'</span><span class="hidden">'.__('Hide Details').'</span>.</a>';
|
||||
$this->upgrader->strings['skin_update_successful'] = __( '%1$s updated successfully.' ) . ' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>' . __( 'Show Details' ) . '</span><span class="hidden">' . __( 'Hide Details' ) . '</span></a>';
|
||||
$this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
*/
|
||||
public function feedback($string) {
|
||||
if ( isset( $this->upgrader->strings[$string] ) )
|
||||
$string = $this->upgrader->strings[$string];
|
||||
@@ -304,10 +323,6 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
|
||||
public $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in.
|
||||
|
||||
public function __construct($args = array()) {
|
||||
parent::__construct($args);
|
||||
}
|
||||
|
||||
public function add_strings() {
|
||||
parent::add_strings();
|
||||
$this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
|
||||
@@ -348,10 +363,6 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
|
||||
class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
|
||||
public $theme_info = array(); // Theme_Upgrader::bulk() will fill this in.
|
||||
|
||||
public function __construct($args = array()) {
|
||||
parent::__construct($args);
|
||||
}
|
||||
|
||||
public function add_strings() {
|
||||
parent::add_strings();
|
||||
$this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)');
|
||||
@@ -434,12 +445,13 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
|
||||
unset( $install_actions['activate_plugin'] );
|
||||
}
|
||||
|
||||
if ( 'import' == $from )
|
||||
if ( 'import' == $from ) {
|
||||
$install_actions['importers_page'] = '<a href="' . admin_url('import.php') . '" title="' . esc_attr__('Return to Importers') . '" target="_parent">' . __('Return to Importers') . '</a>';
|
||||
else if ( $this->type == 'web' )
|
||||
} elseif ( $this->type == 'web' ) {
|
||||
$install_actions['plugins_page'] = '<a href="' . self_admin_url('plugin-install.php') . '" title="' . esc_attr__('Return to Plugin Installer') . '" target="_parent">' . __('Return to Plugin Installer') . '</a>';
|
||||
else
|
||||
} else {
|
||||
$install_actions['plugins_page'] = '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Return to Plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>';
|
||||
}
|
||||
|
||||
if ( ! $this->result || is_wp_error($this->result) ) {
|
||||
unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
|
||||
@@ -698,13 +710,14 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
protected $messages = array();
|
||||
|
||||
public function request_filesystem_credentials( $error = false, $context = '' ) {
|
||||
if ( $context )
|
||||
public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) {
|
||||
if ( $context ) {
|
||||
$this->options['context'] = $context;
|
||||
}
|
||||
// TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version
|
||||
// This will output a credentials form in event of failure, We don't want that, so just hide with a buffer
|
||||
ob_start();
|
||||
$result = parent::request_filesystem_credentials( $error );
|
||||
$result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership );
|
||||
ob_end_clean();
|
||||
return $result;
|
||||
}
|
||||
@@ -713,14 +726,17 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
return $this->messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array|WP_Error $data
|
||||
*/
|
||||
public function feedback( $data ) {
|
||||
if ( is_wp_error( $data ) )
|
||||
if ( is_wp_error( $data ) ) {
|
||||
$string = $data->get_error_message();
|
||||
else if ( is_array( $data ) )
|
||||
} elseif ( is_array( $data ) ) {
|
||||
return;
|
||||
else
|
||||
} else {
|
||||
$string = $data;
|
||||
|
||||
}
|
||||
if ( ! empty( $this->upgrader->strings[ $string ] ) )
|
||||
$string = $this->upgrader->strings[ $string ];
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -120,7 +120,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
* @access public
|
||||
*/
|
||||
public function no_items() {
|
||||
_e( 'No matching users were found.' );
|
||||
_e( 'No users found.' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,7 +306,6 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
|
||||
$editable_roles = array_keys( get_editable_roles() );
|
||||
|
||||
$style = '';
|
||||
foreach ( $this->items as $userid => $user_object ) {
|
||||
if ( count( $user_object->roles ) <= 1 ) {
|
||||
$role = reset( $user_object->roles );
|
||||
@@ -319,8 +318,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
if ( is_multisite() && empty( $user_object->allcaps ) )
|
||||
continue;
|
||||
|
||||
$style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
|
||||
echo "\n\t" . $this->single_row( $user_object, $style, $role, isset( $post_counts ) ? $post_counts[ $userid ] : 0 );
|
||||
echo "\n\t" . $this->single_row( $user_object, $style = '', $role, isset( $post_counts ) ? $post_counts[ $userid ] : 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,11 +326,13 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
* Generate HTML for a single row on the users.php admin panel.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @since 4.2.0 The `$style` argument was deprecated.
|
||||
* @access public
|
||||
*
|
||||
* @global WP_Roles $wp_roles User roles object.
|
||||
*
|
||||
* @param object $user_object The current user object.
|
||||
* @param string $style Optional. Style attributes added to the <tr> element.
|
||||
* Must be sanitized. Default empty.
|
||||
* @param string $style Deprecated. Not used.
|
||||
* @param string $role Optional. Key for the $wp_roles array. Default empty.
|
||||
* @param int $numposts Optional. Post count to display for this user. Defaults
|
||||
* to zero, as in, a new user has made zero posts.
|
||||
@@ -341,8 +341,9 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
public function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) {
|
||||
global $wp_roles;
|
||||
|
||||
if ( !( is_object( $user_object ) && is_a( $user_object, 'WP_User' ) ) )
|
||||
if ( ! ( $user_object instanceof WP_User ) ) {
|
||||
$user_object = get_userdata( (int) $user_object );
|
||||
}
|
||||
$user_object->filter = 'display';
|
||||
$email = $user_object->user_email;
|
||||
|
||||
@@ -386,7 +387,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
$edit .= $this->row_actions( $actions );
|
||||
|
||||
// Set up the checkbox ( because the user is editable, otherwise it's empty )
|
||||
$checkbox = '<label class="screen-reader-text" for="cb-select-' . $user_object->ID . '">' . sprintf( __( 'Select %s' ), $user_object->user_login ) . '</label>'
|
||||
$checkbox = '<label class="screen-reader-text" for="user_' . $user_object->ID . '">' . sprintf( __( 'Select %s' ), $user_object->user_login ) . '</label>'
|
||||
. "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />";
|
||||
|
||||
} else {
|
||||
@@ -395,7 +396,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
$role_name = isset( $wp_roles->role_names[$role] ) ? translate_user_role( $wp_roles->role_names[$role] ) : __( 'None' );
|
||||
$avatar = get_avatar( $user_object->ID, 32 );
|
||||
|
||||
$r = "<tr id='user-$user_object->ID'$style>";
|
||||
$r = "<tr id='user-$user_object->ID'>";
|
||||
|
||||
list( $columns, $hidden ) = $this->get_column_info();
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
* Determine if a comment exists based on author and date.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @uses $wpdb
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param string $comment_author Author of the comment
|
||||
* @param string $comment_date Date of the comment
|
||||
@@ -110,7 +111,8 @@ function get_comment_to_edit( $id ) {
|
||||
* Get the number of pending comments on a post or posts
|
||||
*
|
||||
* @since 2.3.0
|
||||
* @uses $wpdb
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param int|array $post_id Either a single Post ID or an array of Post IDs
|
||||
* @return int|array Either a single Posts pending comments as an int or an array of ints keyed on the Post IDs
|
||||
|
||||
@@ -155,7 +155,7 @@ function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_
|
||||
}
|
||||
|
||||
function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
|
||||
echo '<form action="" method="post" class="dashboard-widget-control-form">';
|
||||
echo '<form method="post" class="dashboard-widget-control-form">';
|
||||
wp_dashboard_trigger_widget_control( $meta_box['id'] );
|
||||
wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' );
|
||||
echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />';
|
||||
@@ -235,8 +235,8 @@ function wp_dashboard_right_now() {
|
||||
}
|
||||
// Comments
|
||||
$num_comm = wp_count_comments();
|
||||
if ( $num_comm && $num_comm->total_comments ) {
|
||||
$text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->total_comments ), number_format_i18n( $num_comm->total_comments ) );
|
||||
if ( $num_comm && $num_comm->approved ) {
|
||||
$text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) );
|
||||
?>
|
||||
<li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li>
|
||||
<?php
|
||||
@@ -379,14 +379,16 @@ function wp_network_dashboard_right_now() {
|
||||
|
||||
<form action="<?php echo network_admin_url('users.php'); ?>" method="get">
|
||||
<p>
|
||||
<input type="search" name="s" value="" size="30" autocomplete="off" />
|
||||
<label class="screen-reader-text" for="search-users"><?php _e( 'Search Users' ); ?></label>
|
||||
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/>
|
||||
<?php submit_button( __( 'Search Users' ), 'button', 'submit', false, array( 'id' => 'submit_users' ) ); ?>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<form action="<?php echo network_admin_url('sites.php'); ?>" method="get">
|
||||
<p>
|
||||
<input type="search" name="s" value="" size="30" autocomplete="off" />
|
||||
<label class="screen-reader-text" for="search-sites"><?php _e( 'Search Sites' ); ?></label>
|
||||
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/>
|
||||
<?php submit_button( __( 'Search Sites' ), 'button', 'submit', false, array( 'id' => 'submit_sites' ) ); ?>
|
||||
</p>
|
||||
</form>
|
||||
@@ -518,7 +520,7 @@ function wp_dashboard_recent_drafts( $drafts = false ) {
|
||||
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
|
||||
$GLOBALS['comment'] =& $comment;
|
||||
|
||||
$comment_post_title = strip_tags(get_the_title( $comment->comment_post_ID ));
|
||||
$comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
|
||||
|
||||
if ( current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
|
||||
$comment_post_url = get_edit_post_link( $comment->comment_post_ID );
|
||||
@@ -689,6 +691,15 @@ function wp_dashboard_recent_posts( $args ) {
|
||||
'cache_results' => false,
|
||||
'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
|
||||
);
|
||||
|
||||
/**
|
||||
* Filter the query arguments used for the Recent Posts widget.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param array $query_args The arguments passed to WP_Query to produce the list of posts.
|
||||
*/
|
||||
$query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args );
|
||||
$posts = new WP_Query( $query_args );
|
||||
|
||||
if ( $posts->have_posts() ) {
|
||||
@@ -715,15 +726,12 @@ function wp_dashboard_recent_posts( $args ) {
|
||||
$relative = date_i18n( __( 'M jS' ), $time );
|
||||
}
|
||||
|
||||
if ( current_user_can( 'edit_post', get_the_ID() ) ) {
|
||||
/* translators: 1: relative date, 2: time, 3: post edit link, 4: post title */
|
||||
$format = __( '<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>' );
|
||||
printf( "<li>$format</li>", $relative, get_the_time(), get_edit_post_link(), _draft_or_post_title() );
|
||||
} else {
|
||||
/* translators: 1: relative date, 2: time, 3: post title */
|
||||
$format = __( '<span>%1$s, %2$s</span> %3$s' );
|
||||
printf( "<li>$format</li>", $relative, get_the_time(), _draft_or_post_title() );
|
||||
}
|
||||
// Use the post edit link for those who can edit, the permalink otherwise.
|
||||
$recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink();
|
||||
|
||||
/* translators: 1: relative date, 2: time, 3: post edit link or permalink, 4: post title */
|
||||
$format = __( '<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>' );
|
||||
printf( "<li>$format</li>", $relative, get_the_time(), $recent_post_link, _draft_or_post_title() );
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
@@ -967,7 +975,7 @@ function wp_dashboard_primary() {
|
||||
*
|
||||
* @param string $link The widget's secondary link URL.
|
||||
*/
|
||||
'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ),
|
||||
'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ),
|
||||
|
||||
/**
|
||||
* Filter the secondary feed URL for the 'WordPress News' dashboard widget.
|
||||
@@ -976,7 +984,7 @@ function wp_dashboard_primary() {
|
||||
*
|
||||
* @param string $url The widget's secondary feed URL.
|
||||
*/
|
||||
'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ),
|
||||
'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ),
|
||||
|
||||
/**
|
||||
* Filter the secondary link title for the 'WordPress News' dashboard widget.
|
||||
@@ -1111,7 +1119,7 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) {
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return bool True if not multisite, user can't upload files, or the space check option is disabled.
|
||||
* @return bool|null True if not multisite, user can't upload files, or the space check option is disabled.
|
||||
*/
|
||||
function wp_dashboard_quota() {
|
||||
if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) )
|
||||
@@ -1324,7 +1332,7 @@ function wp_welcome_panel() {
|
||||
<?php if ( current_user_can( 'manage_options' ) ) : ?>
|
||||
<li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>
|
||||
<?php endif; ?>
|
||||
<li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'http://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li>
|
||||
<li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'https://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -33,7 +33,6 @@ function tinymce_include() {
|
||||
*/
|
||||
function documentation_link() {
|
||||
_deprecated_function( __FUNCTION__, '2.5' );
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,9 +79,9 @@ function get_udims( $width, $height ) {
|
||||
* @deprecated Use wp_category_checklist()
|
||||
* @see wp_category_checklist()
|
||||
*
|
||||
* @param unknown_type $default
|
||||
* @param unknown_type $parent
|
||||
* @param unknown_type $popular_ids
|
||||
* @param int $default
|
||||
* @param int $parent
|
||||
* @param array $popular_ids
|
||||
*/
|
||||
function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
|
||||
_deprecated_function( __FUNCTION__, '2.6', 'wp_category_checklist()' );
|
||||
@@ -98,7 +97,7 @@ function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array()
|
||||
* @deprecated Use wp_link_category_checklist()
|
||||
* @see wp_link_category_checklist()
|
||||
*
|
||||
* @param unknown_type $default
|
||||
* @param int $default
|
||||
*/
|
||||
function dropdown_link_categories( $default = 0 ) {
|
||||
_deprecated_function( __FUNCTION__, '2.6', 'wp_link_category_checklist()' );
|
||||
@@ -130,12 +129,12 @@ function get_real_file_to_edit( $file ) {
|
||||
* @deprecated Use wp_dropdown_categories()
|
||||
* @see wp_dropdown_categories()
|
||||
*
|
||||
* @param unknown_type $currentcat
|
||||
* @param unknown_type $currentparent
|
||||
* @param unknown_type $parent
|
||||
* @param unknown_type $level
|
||||
* @param unknown_type $categories
|
||||
* @return unknown
|
||||
* @param int $currentcat
|
||||
* @param int $currentparent
|
||||
* @param int $parent
|
||||
* @param int $level
|
||||
* @param array $categories
|
||||
* @return bool|null
|
||||
*/
|
||||
function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
|
||||
_deprecated_function( __FUNCTION__, '3.0', 'wp_dropdown_categories()' );
|
||||
@@ -170,12 +169,11 @@ function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $le
|
||||
* @param string $option_group A settings group name. Should correspond to a whitelisted option key name.
|
||||
* Default whitelisted option key names include "general," "discussion," and "reading," among others.
|
||||
* @param string $option_name The name of an option to sanitize and save.
|
||||
* @param unknown_type $sanitize_callback A callback function that sanitizes the option's value.
|
||||
* @return unknown
|
||||
* @param callable $sanitize_callback A callback function that sanitizes the option's value.
|
||||
*/
|
||||
function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
|
||||
_deprecated_function( __FUNCTION__, '3.0', 'register_setting()' );
|
||||
return register_setting( $option_group, $option_name, $sanitize_callback );
|
||||
register_setting( $option_group, $option_name, $sanitize_callback );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,14 +184,13 @@ function add_option_update_handler( $option_group, $option_name, $sanitize_callb
|
||||
* @deprecated Use unregister_setting()
|
||||
* @see unregister_setting()
|
||||
*
|
||||
* @param unknown_type $option_group
|
||||
* @param unknown_type $option_name
|
||||
* @param unknown_type $sanitize_callback
|
||||
* @return unknown
|
||||
* @param string $option_group
|
||||
* @param string $option_name
|
||||
* @param callable $sanitize_callback
|
||||
*/
|
||||
function remove_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
|
||||
_deprecated_function( __FUNCTION__, '3.0', 'unregister_setting()' );
|
||||
return unregister_setting( $option_group, $option_name, $sanitize_callback );
|
||||
unregister_setting( $option_group, $option_name, $sanitize_callback );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,18 +203,16 @@ function remove_option_update_handler( $option_group, $option_name, $sanitize_ca
|
||||
**/
|
||||
function codepress_get_lang( $filename ) {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Javascript required to make CodePress work on the theme/plugin editors.
|
||||
* Adds JavaScript required to make CodePress work on the theme/plugin editors.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @deprecated 3.0.0
|
||||
**/
|
||||
function codepress_footer_js() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,7 +223,6 @@ function codepress_footer_js() {
|
||||
**/
|
||||
function use_codepress() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,7 +270,7 @@ function get_editable_authors( $user_id ) {
|
||||
*
|
||||
* @param int $user_id User ID.
|
||||
* @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros.
|
||||
* @return unknown
|
||||
* @return mixed
|
||||
*/
|
||||
function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
|
||||
_deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
|
||||
@@ -336,7 +330,7 @@ class WP_User_Search {
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @access private
|
||||
* @var unknown_type
|
||||
* @var mixed
|
||||
*/
|
||||
var $results;
|
||||
|
||||
@@ -345,7 +339,7 @@ class WP_User_Search {
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @access private
|
||||
* @var unknown_type
|
||||
* @var string
|
||||
*/
|
||||
var $search_term;
|
||||
|
||||
@@ -390,7 +384,7 @@ class WP_User_Search {
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @access private
|
||||
* @var unknown_type
|
||||
* @var int
|
||||
*/
|
||||
var $first_user;
|
||||
|
||||
@@ -462,7 +456,7 @@ class WP_User_Search {
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @access private
|
||||
* @var unknown_type
|
||||
* @var WP_Error
|
||||
*/
|
||||
var $search_errors;
|
||||
|
||||
@@ -471,7 +465,7 @@ class WP_User_Search {
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @access private
|
||||
* @var unknown_type
|
||||
* @var string
|
||||
*/
|
||||
var $paging_text;
|
||||
|
||||
@@ -554,7 +548,7 @@ class WP_User_Search {
|
||||
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!'));
|
||||
$this->search_errors = new WP_Error('no_matching_users_found', __('No users found.'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -609,7 +603,7 @@ class WP_User_Search {
|
||||
* @since 2.1.0
|
||||
* @access public
|
||||
*
|
||||
* @return unknown
|
||||
* @return array
|
||||
*/
|
||||
function get_results() {
|
||||
return (array) $this->results;
|
||||
@@ -942,7 +936,7 @@ function get_allowed_themes() {
|
||||
* @since 1.5.0
|
||||
* @deprecated 3.4.0
|
||||
*
|
||||
* @return unknown
|
||||
* @return array
|
||||
*/
|
||||
function get_broken_themes() {
|
||||
_deprecated_function( __FUNCTION__, '3.4', "wp_get_themes( array( 'errors' => true )" );
|
||||
@@ -966,7 +960,7 @@ function get_broken_themes() {
|
||||
* @since 2.0.0
|
||||
* @deprecated 3.4.0
|
||||
*
|
||||
* @return unknown
|
||||
* @return WP_Theme
|
||||
*/
|
||||
function current_theme_info() {
|
||||
_deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' );
|
||||
@@ -1128,8 +1122,7 @@ function wp_update_theme($theme, $feedback = '') {
|
||||
* @since 2.0.0
|
||||
* @deprecated 3.7.0
|
||||
*
|
||||
* @param unknown_type $id
|
||||
* @return unknown
|
||||
* @param int|bool $id
|
||||
*/
|
||||
function the_attachment_links( $id = false ) {
|
||||
_deprecated_function( __FUNCTION__, '3.7' );
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
define( 'WXR_VERSION', '1.2' );
|
||||
|
||||
/**
|
||||
* Generates the WXR export file for download
|
||||
* Generates the WXR export file for download.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param array $args Filters defining what should be included in the export
|
||||
* @param array $args Filters defining what should be included in the export.
|
||||
*/
|
||||
function export_wp( $args = array() ) {
|
||||
global $wpdb, $post;
|
||||
@@ -95,7 +95,7 @@ function export_wp( $args = array() ) {
|
||||
$cat = get_term( $term['term_id'], 'category' );
|
||||
$cats = array( $cat->term_id => $cat );
|
||||
unset( $term, $cat );
|
||||
} else if ( 'all' == $args['content'] ) {
|
||||
} elseif ( 'all' == $args['content'] ) {
|
||||
$categories = (array) get_categories( array( 'get' => 'all' ) );
|
||||
$tags = (array) get_tags( array( 'get' => 'all' ) );
|
||||
|
||||
@@ -391,8 +391,10 @@ function export_wp( $args = array() ) {
|
||||
$is_sticky = is_sticky( $post->ID ) ? 1 : 0;
|
||||
?>
|
||||
<item>
|
||||
<?php /** This filter is documented in wp-includes/feed.php */ ?>
|
||||
<title><?php echo apply_filters( 'the_title_rss', $post->post_title ); ?></title>
|
||||
<title><?php
|
||||
/** This filter is documented in wp-includes/feed.php */
|
||||
echo apply_filters( 'the_title_rss', $post->post_title );
|
||||
?></title>
|
||||
<link><?php the_permalink_rss() ?></link>
|
||||
<pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>
|
||||
<dc:creator><?php echo wxr_cdata( get_the_author_meta( 'login' ) ); ?></dc:creator>
|
||||
|
||||
+191
-112
@@ -50,7 +50,6 @@ $wp_file_descriptions = array(
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @uses _cleanup_header_comment
|
||||
* @uses $wp_file_descriptions
|
||||
* @param string $file Filesystem path or filename
|
||||
* @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist
|
||||
@@ -75,7 +74,6 @@ function get_file_description( $file ) {
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @uses get_option
|
||||
* @return string Full filesystem path to the root of the WordPress installation
|
||||
*/
|
||||
function get_home_path() {
|
||||
@@ -99,8 +97,8 @@ function get_home_path() {
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param string $folder Full path to folder
|
||||
* @param int $levels (optional) Levels of folders to follow, Default: 100 (PHP Loop limit).
|
||||
* @param string $folder Optional. Full path to folder. Default empty.
|
||||
* @param int $levels Optional. Levels of folders to follow, Default 100 (PHP Loop limit).
|
||||
* @return bool|array False on failure, Else array of files
|
||||
*/
|
||||
function list_files( $folder = '', $levels = 100 ) {
|
||||
@@ -139,21 +137,33 @@ function list_files( $folder = '', $levels = 100 ) {
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param string $filename (optional) Filename to base the Unique file off
|
||||
* @param string $dir (optional) Directory to store the file in
|
||||
* @param string $filename Optional. Filename to base the Unique file off. Default empty.
|
||||
* @param string $dir Optional. Directory to store the file in. Default empty.
|
||||
* @return string a writable filename
|
||||
*/
|
||||
function wp_tempnam($filename = '', $dir = '') {
|
||||
if ( empty($dir) )
|
||||
function wp_tempnam( $filename = '', $dir = '' ) {
|
||||
if ( empty( $dir ) ) {
|
||||
$dir = get_temp_dir();
|
||||
$filename = basename($filename);
|
||||
if ( empty($filename) )
|
||||
$filename = time();
|
||||
}
|
||||
|
||||
$filename = preg_replace('|\..*$|', '.tmp', $filename);
|
||||
$filename = $dir . wp_unique_filename($dir, $filename);
|
||||
touch($filename);
|
||||
return $filename;
|
||||
if ( empty( $filename ) || '.' == $filename ) {
|
||||
$filename = time();
|
||||
}
|
||||
|
||||
// Use the basename of the given file without the extension as the name for the temporary directory
|
||||
$temp_filename = basename( $filename );
|
||||
$temp_filename = preg_replace( '|\.[^.]*$|', '', $temp_filename );
|
||||
|
||||
// If the folder is falsey, use it's parent directory name instead
|
||||
if ( ! $temp_filename ) {
|
||||
return wp_tempnam( dirname( $filename ), $dir );
|
||||
}
|
||||
|
||||
$temp_filename .= '.tmp';
|
||||
$temp_filename = $dir . wp_unique_filename( $dir, $temp_filename );
|
||||
touch( $temp_filename );
|
||||
|
||||
return $temp_filename;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,11 +173,9 @@ function wp_tempnam($filename = '', $dir = '') {
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @uses wp_die
|
||||
* @uses validate_file
|
||||
* @param string $file file the users is attempting to edit
|
||||
* @param array $allowed_files Array of allowed files to edit, $file must match an entry exactly
|
||||
* @return null
|
||||
* @return string|null
|
||||
*/
|
||||
function validate_file_to_edit( $file, $allowed_files = '' ) {
|
||||
$code = validate_file( $file, $allowed_files );
|
||||
@@ -195,11 +203,10 @@ function validate_file_to_edit( $file, $allowed_files = '' ) {
|
||||
*
|
||||
* @see wp_handle_upload_error
|
||||
*
|
||||
* @param array $file Reference to a single element of $_FILES. Call the function once for
|
||||
* each uploaded file.
|
||||
* @param array $overrides An associative array of names => values to override default variables.
|
||||
* @param string $time Time formatted in 'yyyy/mm'.
|
||||
* @param string $action Expected value for $_POST['action'].
|
||||
* @param array $file Reference to a single element of $_FILES. Call the function once for each uploaded file.
|
||||
* @param array|false $overrides An associative array of names => values to override default variables. Default false.
|
||||
* @param string $time Time formatted in 'yyyy/mm'.
|
||||
* @param string $action Expected value for $_POST['action'].
|
||||
* @return array On success, returns an associative array of file attributes. On failure, returns
|
||||
* $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
|
||||
*/
|
||||
@@ -212,10 +219,12 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The dynamic portion of the hook name, $action, refers to the post action.
|
||||
* Filter the data for a file before it is uploaded to WordPress.
|
||||
*
|
||||
* @since 2.9.0 as 'wp_handle_upload_prefilter'
|
||||
* @since 4.0.0 Converted to a dynamic hook with $action
|
||||
* The dynamic portion of the hook name, `$action`, refers to the post action.
|
||||
*
|
||||
* @since 2.9.0 as 'wp_handle_upload_prefilter'.
|
||||
* @since 4.0.0 Converted to a dynamic hook with `$action`.
|
||||
*
|
||||
* @param array $file An array of data for a single file.
|
||||
*/
|
||||
@@ -269,8 +278,6 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
|
||||
$test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true;
|
||||
$mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false;
|
||||
|
||||
$test_upload = isset( $overrides['test_upload'] ) ? $overrides['test_upload'] : true;
|
||||
|
||||
// A correct form post will pass this test.
|
||||
if ( $test_form && ( ! isset( $_POST['action'] ) || ( $_POST['action'] != $action ) ) ) {
|
||||
return call_user_func( $upload_error_handler, $file, __( 'Invalid form submission.' ) );
|
||||
@@ -293,7 +300,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
|
||||
|
||||
// A properly uploaded file will pass this test. There should be no reason to override this one.
|
||||
$test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_file( $file['tmp_name'] );
|
||||
if ( $test_upload && ! $test_uploaded_file ) {
|
||||
if ( ! $test_uploaded_file ) {
|
||||
return call_user_func( $upload_error_handler, $file, __( 'Specified file failed upload test.' ) );
|
||||
}
|
||||
|
||||
@@ -632,8 +639,10 @@ function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
|
||||
|
||||
// Create those directories if need be:
|
||||
foreach ( $needed_dirs as $_dir ) {
|
||||
if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir) ) // Only check to see if the Dir exists upon creation failure. Less I/O this way.
|
||||
// Only check to see if the Dir exists upon creation failure. Less I/O this way.
|
||||
if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) {
|
||||
return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
|
||||
}
|
||||
}
|
||||
unset($needed_dirs);
|
||||
|
||||
@@ -809,20 +818,25 @@ function copy_dir($from, $to, $skip_list = array() ) {
|
||||
* Initialises and connects the WordPress Filesystem Abstraction classes.
|
||||
* This function will include the chosen transport and attempt connecting.
|
||||
*
|
||||
* Plugins may add extra transports, And force WordPress to use them by returning the filename via the 'filesystem_method_file' filter.
|
||||
* Plugins may add extra transports, And force WordPress to use them by returning
|
||||
* the filename via the {@see 'filesystem_method_file'} filter.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param array $args (optional) Connection args, These are passed directly to the WP_Filesystem_*() classes.
|
||||
* @param string $context (optional) Context for get_filesystem_method(), See function declaration for more information.
|
||||
* @return boolean false on failure, true on success
|
||||
* @param array $args Optional. Connection args, These are passed directly to
|
||||
* the `WP_Filesystem_*()` classes. Default false.
|
||||
* @param string $context Optional. Context for {@see get_filesystem_method()}.
|
||||
* Default false.
|
||||
* @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable.
|
||||
* Default false.
|
||||
* @return null|boolean false on failure, true on success.
|
||||
*/
|
||||
function WP_Filesystem( $args = false, $context = false ) {
|
||||
function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_ownership = false ) {
|
||||
global $wp_filesystem;
|
||||
|
||||
require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
|
||||
|
||||
$method = get_filesystem_method($args, $context);
|
||||
$method = get_filesystem_method( $args, $context, $allow_relaxed_file_ownership );
|
||||
|
||||
if ( ! $method )
|
||||
return false;
|
||||
@@ -872,38 +886,68 @@ function WP_Filesystem( $args = false, $context = false ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which Filesystem Method to use.
|
||||
* The priority of the Transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets (Via Sockets class, or fsockopen())
|
||||
* Determines which method to use for reading, writing, modifying, or deleting
|
||||
* files on the filesystem.
|
||||
*
|
||||
* Note that the return value of this function can be overridden in 2 ways
|
||||
* - By defining FS_METHOD in your <code>wp-config.php</code> file
|
||||
* - By using the filesystem_method filter
|
||||
* Valid values for these are: 'direct', 'ssh2', 'ftpext' or 'ftpsockets'
|
||||
* Plugins may also define a custom transport handler, See the WP_Filesystem function for more information.
|
||||
* The priority of the transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets
|
||||
* (Via Sockets class, or `fsockopen()`). Valid values for these are: 'direct', 'ssh2',
|
||||
* 'ftpext' or 'ftpsockets'.
|
||||
*
|
||||
* The return value can be overridden by defining the `FS_METHOD` constant in `wp-config.php`,
|
||||
* or filtering via {@see 'filesystem_method'}.
|
||||
*
|
||||
* @link https://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants
|
||||
*
|
||||
* Plugins may define a custom transport handler, See WP_Filesystem().
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param array $args Connection details.
|
||||
* @param string $context Full path to the directory that is tested for being writable.
|
||||
* @param array $args Optional. Connection details. Default empty array.
|
||||
* @param string $context Optional. Full path to the directory that is tested
|
||||
* for being writable. Default false.
|
||||
* @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable.
|
||||
* Default false.
|
||||
* @return string The transport to use, see description for valid return values.
|
||||
*/
|
||||
function get_filesystem_method($args = array(), $context = false) {
|
||||
function get_filesystem_method( $args = array(), $context = false, $allow_relaxed_file_ownership = false ) {
|
||||
$method = defined('FS_METHOD') ? FS_METHOD : false; // Please ensure that this is either 'direct', 'ssh2', 'ftpext' or 'ftpsockets'
|
||||
|
||||
if ( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){
|
||||
if ( !$context )
|
||||
$context = WP_CONTENT_DIR;
|
||||
if ( ! $context ) {
|
||||
$context = WP_CONTENT_DIR;
|
||||
}
|
||||
|
||||
// If the directory doesn't exist (wp-content/languages) then use the parent directory as we'll create it.
|
||||
if ( WP_LANG_DIR == $context && ! is_dir( $context ) )
|
||||
$context = dirname( $context );
|
||||
// If the directory doesn't exist (wp-content/languages) then use the parent directory as we'll create it.
|
||||
if ( WP_LANG_DIR == $context && ! is_dir( $context ) ) {
|
||||
$context = dirname( $context );
|
||||
}
|
||||
|
||||
$context = trailingslashit( $context );
|
||||
|
||||
if ( ! $method ) {
|
||||
|
||||
$context = trailingslashit($context);
|
||||
$temp_file_name = $context . 'temp-write-test-' . time();
|
||||
$temp_handle = @fopen($temp_file_name, 'w');
|
||||
if ( $temp_handle ) {
|
||||
if ( getmyuid() == @fileowner($temp_file_name) )
|
||||
|
||||
// Attempt to determine the file owner of the WordPress files, and that of newly created files
|
||||
$wp_file_owner = $temp_file_owner = false;
|
||||
if ( function_exists('fileowner') ) {
|
||||
$wp_file_owner = @fileowner( __FILE__ );
|
||||
$temp_file_owner = @fileowner( $temp_file_name );
|
||||
}
|
||||
|
||||
if ( $wp_file_owner !== false && $wp_file_owner === $temp_file_owner ) {
|
||||
// WordPress is creating files as the same owner as the WordPress files,
|
||||
// this means it's safe to modify & create new files via PHP.
|
||||
$method = 'direct';
|
||||
$GLOBALS['_wp_filesystem_direct_method'] = 'file_owner';
|
||||
} elseif ( $allow_relaxed_file_ownership ) {
|
||||
// The $context directory is writable, and $allow_relaxed_file_ownership is set, this means we can modify files
|
||||
// safely in this directory. This mode doesn't create new files, only alter existing ones.
|
||||
$method = 'direct';
|
||||
$GLOBALS['_wp_filesystem_direct_method'] = 'relaxed_ownership';
|
||||
}
|
||||
|
||||
@fclose($temp_handle);
|
||||
@unlink($temp_file_name);
|
||||
}
|
||||
@@ -918,30 +962,39 @@ function get_filesystem_method($args = array(), $context = false) {
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @param string $method Filesystem method to return.
|
||||
* @param array $args An array of connection details for the method.
|
||||
* @param string $method Filesystem method to return.
|
||||
* @param array $args An array of connection details for the method.
|
||||
* @param string $context Full path to the directory that is tested for being writable.
|
||||
* @param bool $allow_relaxed_file_ownership Whether to allow Group/World writable.
|
||||
*/
|
||||
return apply_filters( 'filesystem_method', $method, $args );
|
||||
return apply_filters( 'filesystem_method', $method, $args, $context, $allow_relaxed_file_ownership );
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a form to the user to request for their FTP/SSH details in order to connect to the filesystem.
|
||||
* Displays a form to the user to request for their FTP/SSH details in order
|
||||
* to connect to the filesystem.
|
||||
*
|
||||
* All chosen/entered details are saved, Excluding the Password.
|
||||
*
|
||||
* Hostnames may be in the form of hostname:portnumber (eg: wordpress.org:2467) to specify an alternate FTP/SSH port.
|
||||
* Hostnames may be in the form of hostname:portnumber (eg: wordpress.org:2467)
|
||||
* to specify an alternate FTP/SSH port.
|
||||
*
|
||||
* Plugins may override this form by returning true|false via the <code>request_filesystem_credentials</code> filter.
|
||||
* Plugins may override this form by returning true|false via the
|
||||
* {@see 'request_filesystem_credentials'} filter.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @since 2.5.
|
||||
*
|
||||
* @todo Properly mark optional arguments as such
|
||||
*
|
||||
* @param string $form_post the URL to post the form to
|
||||
* @param string $type the chosen Filesystem method in use
|
||||
* @param boolean $error if the current request has failed to connect
|
||||
* @param string $context The directory which is needed access to, The write-test will be performed on this directory by get_filesystem_method()
|
||||
* @param string $extra_fields Extra POST fields which should be checked for to be included in the post.
|
||||
* @param array $extra_fields Extra POST fields which should be checked for to be included in the post.
|
||||
* @param bool $allow_relaxed_file_ownership Whether to allow Group/World writable.
|
||||
* @return boolean False on failure. True on success.
|
||||
*/
|
||||
function request_filesystem_credentials($form_post, $type = '', $error = false, $context = false, $extra_fields = null) {
|
||||
function request_filesystem_credentials($form_post, $type = '', $error = false, $context = false, $extra_fields = null, $allow_relaxed_file_ownership = false ) {
|
||||
|
||||
/**
|
||||
* Filter the filesystem credentials form output.
|
||||
@@ -958,14 +1011,16 @@ function request_filesystem_credentials($form_post, $type = '', $error = false,
|
||||
* Default false.
|
||||
* @param string $context Full path to the directory that is tested for
|
||||
* being writable.
|
||||
* @param bool $allow_relaxed_file_ownership Whether to allow Group/World writable.
|
||||
* @param array $extra_fields Extra POST fields.
|
||||
*/
|
||||
$req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields );
|
||||
$req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership );
|
||||
if ( '' !== $req_cred )
|
||||
return $req_cred;
|
||||
|
||||
if ( empty($type) )
|
||||
$type = get_filesystem_method(array(), $context);
|
||||
if ( empty($type) ) {
|
||||
$type = get_filesystem_method( array(), $context, $allow_relaxed_file_ownership );
|
||||
}
|
||||
|
||||
if ( 'direct' == $type )
|
||||
return true;
|
||||
@@ -995,15 +1050,15 @@ function request_filesystem_credentials($form_post, $type = '', $error = false,
|
||||
unset($credentials['port']);
|
||||
}
|
||||
|
||||
if ( ( defined('FTP_SSH') && FTP_SSH ) || ( defined('FS_METHOD') && 'ssh2' == FS_METHOD ) )
|
||||
if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) {
|
||||
$credentials['connection_type'] = 'ssh';
|
||||
else if ( (defined('FTP_SSL') && FTP_SSL) && 'ftpext' == $type ) //Only the FTP Extension understands SSL
|
||||
} elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { //Only the FTP Extension understands SSL
|
||||
$credentials['connection_type'] = 'ftps';
|
||||
else if ( !empty($_POST['connection_type']) )
|
||||
} elseif ( ! empty( $_POST['connection_type'] ) ) {
|
||||
$credentials['connection_type'] = wp_unslash( $_POST['connection_type'] );
|
||||
else if ( !isset($credentials['connection_type']) ) //All else fails (And it's not defaulted to something else saved), Default to FTP
|
||||
} elseif ( ! isset( $credentials['connection_type'] ) ) { //All else fails (And it's not defaulted to something else saved), Default to FTP
|
||||
$credentials['connection_type'] = 'ftp';
|
||||
|
||||
}
|
||||
if ( ! $error &&
|
||||
(
|
||||
( !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) ||
|
||||
@@ -1014,7 +1069,9 @@ function request_filesystem_credentials($form_post, $type = '', $error = false,
|
||||
$stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
|
||||
|
||||
unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']);
|
||||
update_option('ftp_credentials', $stored_credentials);
|
||||
if ( ! defined( 'WP_INSTALLING' ) ) {
|
||||
update_option( 'ftp_credentials', $stored_credentials );
|
||||
}
|
||||
return $credentials;
|
||||
}
|
||||
$hostname = isset( $credentials['hostname'] ) ? $credentials['hostname'] : '';
|
||||
@@ -1063,14 +1120,14 @@ jQuery(function($){
|
||||
jQuery("#ftp, #ftps").click(function () {
|
||||
jQuery("#ssh_keys").hide();
|
||||
});
|
||||
jQuery('form input[value=""]:first').focus();
|
||||
jQuery('#request-filesystem-credentials-form input[value=""]:first').focus();
|
||||
});
|
||||
-->
|
||||
</script>
|
||||
<form action="<?php echo esc_url( $form_post ) ?>" method="post">
|
||||
<div>
|
||||
<h3><?php _e('Connection Information') ?></h3>
|
||||
<p><?php
|
||||
<div id="request-filesystem-credentials-form" class="request-filesystem-credentials-form">
|
||||
<h3 id="request-filesystem-credentials-title"><?php _e( 'Connection Information' ) ?></h3>
|
||||
<p id="request-filesystem-credentials-desc"><?php
|
||||
$label_user = __('Username');
|
||||
$label_pass = __('Password');
|
||||
_e('To perform the requested action, WordPress needs to access your web server.');
|
||||
@@ -1089,39 +1146,36 @@ jQuery(function($){
|
||||
}
|
||||
_e('If you do not remember your credentials, you should contact your web host.');
|
||||
?></p>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row"><label for="hostname"><?php _e('Hostname') ?></label></th>
|
||||
<td><input name="hostname" type="text" id="hostname" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> size="40" /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for="username"><?php echo $label_user; ?></label></th>
|
||||
<td><input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled( defined('FTP_USER') ); ?> size="40" /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for="password"><?php echo $label_pass; ?></label></th>
|
||||
<td><div><input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php disabled( defined('FTP_PASS') ); ?> size="40" /></div>
|
||||
<div><em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em></div></td>
|
||||
</tr>
|
||||
|
||||
<label for="hostname">
|
||||
<span class="field-title"><?php _e( 'Hostname' ) ?></span>
|
||||
<input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> />
|
||||
</label>
|
||||
<div class="ftp-username">
|
||||
<label for="username">
|
||||
<span class="field-title"><?php echo $label_user; ?></span>
|
||||
<input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled( defined('FTP_USER') ); ?> />
|
||||
</label>
|
||||
</div>
|
||||
<div class="ftp-password">
|
||||
<label for="password">
|
||||
<span class="field-title"><?php echo $label_pass; ?></span>
|
||||
<input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php disabled( defined('FTP_PASS') ); ?> />
|
||||
<em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em>
|
||||
</label>
|
||||
</div>
|
||||
<?php if ( isset($types['ssh']) ) : ?>
|
||||
<tr id="ssh_keys" style="<?php if ( 'ssh' != $connection_type ) echo 'display:none' ?>">
|
||||
<th scope="row"><?php _e('Authentication Keys') ?>
|
||||
<div class="key-labels textright">
|
||||
<label for="public_key"><?php _e('Public Key:') ?></label ><br />
|
||||
<label for="private_key"><?php _e('Private Key:') ?></label>
|
||||
</div></th>
|
||||
<td><br /><input name="public_key" type="text" id="public_key" value="<?php echo esc_attr($public_key) ?>"<?php disabled( defined('FTP_PUBKEY') ); ?> size="40" />
|
||||
<br /><input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> size="40" />
|
||||
<div><?php _e('Enter the location on the server where the keys are located. If a passphrase is needed, enter that in the password field above.') ?></div></td>
|
||||
</tr>
|
||||
<h4><?php _e('Authentication Keys') ?></h4>
|
||||
<label for="public_key">
|
||||
<span class="field-title"><?php _e('Public Key:') ?></span>
|
||||
<input name="public_key" type="text" id="public_key" aria-describedby="auth-keys-desc" value="<?php echo esc_attr($public_key) ?>"<?php disabled( defined('FTP_PUBKEY') ); ?> />
|
||||
</label>
|
||||
<label for="private_key">
|
||||
<span class="field-title"><?php _e('Private Key:') ?></span>
|
||||
<input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> />
|
||||
</label>
|
||||
<span id="auth-keys-desc"><?php _e('Enter the location on the server where the public and private keys are located. If a passphrase is needed, enter that in the password field above.') ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Connection Type') ?></th>
|
||||
<td>
|
||||
<h4><?php _e('Connection Type') ?></h4>
|
||||
<fieldset><legend class="screen-reader-text"><span><?php _e('Connection Type') ?></span></legend>
|
||||
<?php
|
||||
$disabled = disabled( (defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH), true, false );
|
||||
@@ -1132,19 +1186,44 @@ jQuery(function($){
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
foreach ( (array) $extra_fields as $field ) {
|
||||
if ( isset( $_POST[ $field ] ) )
|
||||
echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />';
|
||||
}
|
||||
submit_button( __( 'Proceed' ), 'button', 'upgrade' );
|
||||
?>
|
||||
<p class="request-filesystem-credentials-action-buttons">
|
||||
<button class="button cancel-button" data-js-action="close" type="button"><?php _e( 'Cancel' ); ?></button>
|
||||
<?php submit_button( __( 'Proceed' ), 'button', 'upgrade', false ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the filesystem credentials modal when needed.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
function wp_print_request_filesystem_credentials_modal() {
|
||||
$filesystem_method = get_filesystem_method();
|
||||
ob_start();
|
||||
$filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() );
|
||||
ob_end_clean();
|
||||
$request_filesystem_credentials = ( $filesystem_method != 'direct' && ! $filesystem_credentials_are_stored );
|
||||
if ( ! $request_filesystem_credentials ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div id="request-filesystem-credentials-dialog" class="notification-dialog-wrap request-filesystem-credentials-dialog">
|
||||
<div class="notification-dialog-background"></div>
|
||||
<div class="notification-dialog" role="dialog" aria-labelledby="request-filesystem-credentials-title" tabindex="0">
|
||||
<div class="request-filesystem-credentials-dialog-content">
|
||||
<?php request_filesystem_credentials( site_url() ); ?>
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
@@ -6,6 +6,13 @@
|
||||
* @subpackage Administration
|
||||
*/
|
||||
|
||||
/**
|
||||
* Loads the WP image-editing interface.
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
* @param bool|object $msg Optional. Message to display for image editor updates or errors.
|
||||
* Default false.
|
||||
*/
|
||||
function wp_image_editor($post_id, $msg = false) {
|
||||
$nonce = wp_create_nonce("image_editor-$post_id");
|
||||
$meta = wp_get_attachment_metadata($post_id);
|
||||
@@ -326,12 +333,31 @@ function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Image preview ratio. Internal use only.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @ignore
|
||||
* @param int $w Image width in pixels.
|
||||
* @param int $h Image height in pixels.
|
||||
* @return float|int Image preview ratio.
|
||||
*/
|
||||
function _image_get_preview_ratio($w, $h) {
|
||||
$max = max($w, $h);
|
||||
return $max > 400 ? (400 / $max) : 1;
|
||||
}
|
||||
|
||||
// @TODO: Returns GD resource, but is NOT public
|
||||
/**
|
||||
* Returns an image resource. Internal use only.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @ignore
|
||||
* @param resource $img Image resource.
|
||||
* @param float|int $angle Image rotation angle, in degrees.
|
||||
* @return resource|false GD image resource, false otherwise.
|
||||
*/
|
||||
function _rotate_image_resource($img, $angle) {
|
||||
_deprecated_function( __FUNCTION__, '3.5', __( 'Use WP_Image_Editor::rotate' ) );
|
||||
if ( function_exists('imagerotate') ) {
|
||||
@@ -345,14 +371,15 @@ function _rotate_image_resource($img, $angle) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @TODO: Only used within image_edit_apply_changes
|
||||
* and receives/returns GD Resource.
|
||||
* Consider removal.
|
||||
* Flips an image resource. Internal use only.
|
||||
*
|
||||
* @param GD_Resource $img
|
||||
* @param boolean $horz
|
||||
* @param boolean $vert
|
||||
* @return GD_Resource
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @ignore
|
||||
* @param resource $img Image resource.
|
||||
* @param bool $horz Whether to flip horizontally.
|
||||
* @param bool $vert Whether to flip vertically.
|
||||
* @return resource (maybe) flipped image resource.
|
||||
*/
|
||||
function _flip_image_resource($img, $horz, $vert) {
|
||||
_deprecated_function( __FUNCTION__, '3.5', __( 'Use WP_Image_Editor::flip' ) );
|
||||
@@ -374,16 +401,17 @@ function _flip_image_resource($img, $horz, $vert) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @TODO: Only used within image_edit_apply_changes
|
||||
* and receives/returns GD Resource.
|
||||
* Consider removal.
|
||||
* Crops an image resource. Internal use only.
|
||||
*
|
||||
* @param GD_Resource $img
|
||||
* @param float $x
|
||||
* @param float $y
|
||||
* @param float $w
|
||||
* @param float $h
|
||||
* @return GD_Resource
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @ignore
|
||||
* @param resource $img Image resource.
|
||||
* @param float $x Source point x-coordinate.
|
||||
* @param float $y Source point y-cooredinate.
|
||||
* @param float $w Source width.
|
||||
* @param float $h Source height.
|
||||
* @return resource (maybe) cropped image resource.
|
||||
*/
|
||||
function _crop_image_resource($img, $x, $y, $w, $h) {
|
||||
$dst = wp_imagecreatetruecolor($w, $h);
|
||||
@@ -399,9 +427,11 @@ function _crop_image_resource($img, $x, $y, $w, $h) {
|
||||
/**
|
||||
* Performs group of changes on Editor specified.
|
||||
*
|
||||
* @param WP_Image_Editor $image
|
||||
* @param type $changes
|
||||
* @return WP_Image_Editor
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param WP_Image_Editor $image {@see WP_Image_Editor} instance.
|
||||
* @param array $changes Array of change operations.
|
||||
* @return WP_Image_Editor {@see WP_Image_Editor} instance with changes applied.
|
||||
*/
|
||||
function image_edit_apply_changes( $image, $changes ) {
|
||||
if ( is_resource( $image ) )
|
||||
@@ -431,7 +461,7 @@ function image_edit_apply_changes( $image, $changes ) {
|
||||
// Combine operations.
|
||||
if ( count($changes) > 1 ) {
|
||||
$filtered = array($changes[0]);
|
||||
for ( $i = 0, $j = 1; $j < count($changes); $j++ ) {
|
||||
for ( $i = 0, $j = 1, $c = count( $changes ); $j < $c; $j++ ) {
|
||||
$combined = false;
|
||||
if ( $filtered[$i]->type == $changes[$j]->type ) {
|
||||
switch ( $filtered[$i]->type ) {
|
||||
@@ -554,10 +584,18 @@ function stream_preview_image( $post_id ) {
|
||||
return wp_stream_image( $img, $post->post_mime_type, $post_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the metadata for a given attachment.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param int $post_id Attachment post ID.
|
||||
* @return stdClass Image restoration message object.
|
||||
*/
|
||||
function wp_restore_image($post_id) {
|
||||
$meta = wp_get_attachment_metadata($post_id);
|
||||
$file = get_attached_file($post_id);
|
||||
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
|
||||
$backup_sizes = $old_backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
|
||||
$restored = false;
|
||||
$msg = new stdClass;
|
||||
|
||||
@@ -578,10 +616,7 @@ function wp_restore_image($post_id) {
|
||||
|
||||
// Delete only if it's edited image.
|
||||
if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) {
|
||||
|
||||
/** This filter is documented in wp-admin/custom-header.php */
|
||||
$delpath = apply_filters( 'wp_delete_file', $file );
|
||||
@unlink($delpath);
|
||||
wp_delete_file( $file );
|
||||
}
|
||||
} elseif ( isset( $meta['width'], $meta['height'] ) ) {
|
||||
$backup_sizes["full-$suffix"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $parts['basename']);
|
||||
@@ -604,9 +639,8 @@ function wp_restore_image($post_id) {
|
||||
|
||||
// Delete only if it's edited image
|
||||
if ( preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file']) ) {
|
||||
/** This filter is documented in wp-admin/custom-header.php */
|
||||
$delpath = apply_filters( 'wp_delete_file', path_join($parts['dirname'], $meta['sizes'][$default_size]['file']) );
|
||||
@unlink($delpath);
|
||||
$delete_file = path_join( $parts['dirname'], $meta['sizes'][$default_size]['file'] );
|
||||
wp_delete_file( $delete_file );
|
||||
}
|
||||
} else {
|
||||
$backup_sizes["$default_size-{$suffix}"] = $meta['sizes'][$default_size];
|
||||
@@ -619,7 +653,9 @@ function wp_restore_image($post_id) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( !wp_update_attachment_metadata($post_id, $meta) || !update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes) ) {
|
||||
if ( ! wp_update_attachment_metadata( $post_id, $meta ) ||
|
||||
( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) ) ) {
|
||||
|
||||
$msg->error = __('Cannot save image metadata.');
|
||||
return $msg;
|
||||
}
|
||||
@@ -738,7 +774,7 @@ function wp_save_image( $post_id ) {
|
||||
if ( $tag )
|
||||
$backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $path_parts['basename']);
|
||||
|
||||
$success = update_attached_file( $post_id, $new_path );
|
||||
$success = ( $path === $new_path ) || update_attached_file( $post_id, $new_path );
|
||||
|
||||
$meta['file'] = _wp_relative_upload_path( $new_path );
|
||||
|
||||
@@ -817,10 +853,7 @@ function wp_save_image( $post_id ) {
|
||||
}
|
||||
|
||||
if ( $delete ) {
|
||||
|
||||
/** This filter is documented in wp-admin/custom-header.php */
|
||||
$delpath = apply_filters( 'wp_delete_file', $new_path );
|
||||
@unlink( $delpath );
|
||||
wp_delete_file( $new_path );
|
||||
}
|
||||
|
||||
$return->msg = esc_js( __('Image saved') );
|
||||
|
||||
+19
-23
@@ -127,10 +127,10 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
||||
if ( $image_meta )
|
||||
$metadata['image_meta'] = $image_meta;
|
||||
|
||||
} elseif ( preg_match( '#^video/#', get_post_mime_type( $attachment ) ) ) {
|
||||
} elseif ( wp_attachment_is( 'video', $attachment ) ) {
|
||||
$metadata = wp_read_video_metadata( $file );
|
||||
$support = current_theme_supports( 'post-thumbnails', 'attachment:video' ) || post_type_supports( 'attachment:video', 'thumbnail' );
|
||||
} elseif ( preg_match( '#^audio/#', get_post_mime_type( $attachment ) ) ) {
|
||||
} elseif ( wp_attachment_is( 'audio', $attachment ) ) {
|
||||
$metadata = wp_read_audio_metadata( $file );
|
||||
$support = current_theme_supports( 'post-thumbnails', 'attachment:audio' ) || post_type_supports( 'attachment:audio', 'thumbnail' );
|
||||
}
|
||||
@@ -299,20 +299,17 @@ function wp_read_image_metadata( $file ) {
|
||||
|
||||
if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption
|
||||
$caption = trim( $iptc['2#120'][0] );
|
||||
if ( empty( $meta['title'] ) ) {
|
||||
mbstring_binary_safe_encoding();
|
||||
$caption_length = strlen( $caption );
|
||||
reset_mbstring_encoding();
|
||||
|
||||
mbstring_binary_safe_encoding();
|
||||
$caption_length = strlen( $caption );
|
||||
reset_mbstring_encoding();
|
||||
|
||||
if ( empty( $meta['title'] ) && $caption_length < 80 ) {
|
||||
// Assume the title is stored in 2:120 if it's short.
|
||||
if ( $caption_length < 80 ) {
|
||||
$meta['title'] = $caption;
|
||||
} else {
|
||||
$meta['caption'] = $caption;
|
||||
}
|
||||
} elseif ( $caption != $meta['title'] ) {
|
||||
$meta['caption'] = $caption;
|
||||
$meta['title'] = $caption;
|
||||
}
|
||||
|
||||
$meta['caption'] = $caption;
|
||||
}
|
||||
|
||||
if ( ! empty( $iptc['2#110'][0] ) ) // credit
|
||||
@@ -320,7 +317,7 @@ function wp_read_image_metadata( $file ) {
|
||||
elseif ( ! empty( $iptc['2#080'][0] ) ) // creator / legacy byline
|
||||
$meta['credit'] = trim( $iptc['2#080'][0] );
|
||||
|
||||
if ( ! empty( $iptc['2#055'][0] ) and ! empty( $iptc['2#060'][0] ) ) // created date and time
|
||||
if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) // created date and time
|
||||
$meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] );
|
||||
|
||||
if ( ! empty( $iptc['2#116'][0] ) ) // copyright
|
||||
@@ -338,10 +335,6 @@ function wp_read_image_metadata( $file ) {
|
||||
if ( is_callable( 'exif_read_data' ) && in_array( $sourceImageType, apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) ) ) ) {
|
||||
$exif = @exif_read_data( $file );
|
||||
|
||||
if ( empty( $meta['title'] ) && ! empty( $exif['Title'] ) ) {
|
||||
$meta['title'] = trim( $exif['Title'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $exif['ImageDescription'] ) ) {
|
||||
mbstring_binary_safe_encoding();
|
||||
$description_length = strlen( $exif['ImageDescription'] );
|
||||
@@ -350,13 +343,16 @@ function wp_read_image_metadata( $file ) {
|
||||
if ( empty( $meta['title'] ) && $description_length < 80 ) {
|
||||
// Assume the title is stored in ImageDescription
|
||||
$meta['title'] = trim( $exif['ImageDescription'] );
|
||||
if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) && trim( $exif['COMPUTED']['UserComment'] ) != $meta['title'] ) {
|
||||
$meta['caption'] = trim( $exif['COMPUTED']['UserComment'] );
|
||||
}
|
||||
} elseif ( empty( $meta['caption'] ) && trim( $exif['ImageDescription'] ) != $meta['title'] ) {
|
||||
}
|
||||
|
||||
if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) ) {
|
||||
$meta['caption'] = trim( $exif['COMPUTED']['UserComment'] );
|
||||
}
|
||||
|
||||
if ( empty( $meta['caption'] ) ) {
|
||||
$meta['caption'] = trim( $exif['ImageDescription'] );
|
||||
}
|
||||
} elseif ( empty( $meta['caption'] ) && ! empty( $exif['Comments'] ) && trim( $exif['Comments'] ) != $meta['title'] ) {
|
||||
} elseif ( empty( $meta['caption'] ) && ! empty( $exif['Comments'] ) ) {
|
||||
$meta['caption'] = trim( $exif['Comments'] );
|
||||
}
|
||||
|
||||
|
||||
@@ -76,34 +76,32 @@ function wp_import_cleanup( $id ) {
|
||||
* @return array Uploaded file's details on success, error message on failure
|
||||
*/
|
||||
function wp_import_handle_upload() {
|
||||
if ( !isset($_FILES['import']) ) {
|
||||
$file['error'] = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' );
|
||||
return $file;
|
||||
if ( ! isset( $_FILES['import'] ) ) {
|
||||
return array(
|
||||
'error' => __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' )
|
||||
);
|
||||
}
|
||||
|
||||
$overrides = array( 'test_form' => false, 'test_type' => false );
|
||||
$_FILES['import']['name'] .= '.txt';
|
||||
$file = wp_handle_upload( $_FILES['import'], $overrides );
|
||||
$upload = wp_handle_upload( $_FILES['import'], $overrides );
|
||||
|
||||
if ( isset( $file['error'] ) )
|
||||
return $file;
|
||||
|
||||
$url = $file['url'];
|
||||
$type = $file['type'];
|
||||
$file = $file['file'];
|
||||
$filename = basename( $file );
|
||||
if ( isset( $upload['error'] ) ) {
|
||||
return $upload;
|
||||
}
|
||||
|
||||
// Construct the object array
|
||||
$object = array( 'post_title' => $filename,
|
||||
'post_content' => $url,
|
||||
'post_mime_type' => $type,
|
||||
'guid' => $url,
|
||||
$object = array(
|
||||
'post_title' => basename( $upload['file'] ),
|
||||
'post_content' => $upload['url'],
|
||||
'post_mime_type' => $upload['type'],
|
||||
'guid' => $upload['url'],
|
||||
'context' => 'import',
|
||||
'post_status' => 'private'
|
||||
);
|
||||
|
||||
// Save the data
|
||||
$id = wp_insert_attachment( $object, $file );
|
||||
$id = wp_insert_attachment( $object, $upload['file'] );
|
||||
|
||||
/*
|
||||
* Schedule a cleanup for one day from now in case of failed
|
||||
@@ -111,7 +109,7 @@ function wp_import_handle_upload() {
|
||||
*/
|
||||
wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) );
|
||||
|
||||
return array( 'file' => $file, 'id' => $id );
|
||||
return array( 'file' => $upload['file'], 'id' => $id );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+191
-96
@@ -158,6 +158,22 @@ function get_image_send_to_editor($id, $caption, $title, $align, $url='', $rel =
|
||||
*/
|
||||
function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) {
|
||||
|
||||
/**
|
||||
* Filter the caption text.
|
||||
*
|
||||
* Note: If the caption text is empty, the caption shortcode will not be appended
|
||||
* to the image HTML when inserted into the editor.
|
||||
*
|
||||
* Passing an empty value also prevents the {@see 'image_add_caption_shortcode'}
|
||||
* filter from being evaluated at the end of {@see image_add_caption()}.
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param string $caption The original caption text.
|
||||
* @param int $id The attachment ID.
|
||||
*/
|
||||
$caption = apply_filters( 'image_add_caption_text', $caption, $id );
|
||||
|
||||
/**
|
||||
* Filter whether to disable captions.
|
||||
*
|
||||
@@ -223,24 +239,23 @@ function _cleanup_image_add_caption( $matches ) {
|
||||
function media_send_to_editor($html) {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
var win = window.dialogArguments || opener || parent || top;
|
||||
win.send_to_editor('<?php echo addslashes($html); ?>');
|
||||
/* ]]> */
|
||||
</script>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* This handles the file upload POST itself, creating the attachment post.
|
||||
* Save a file submitted from a POST request and create an attachment post for it.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file_id Index into the {@link $_FILES} array of the upload
|
||||
* @param int $post_id The post ID the media is associated with
|
||||
* @param array $post_data allows you to overwrite some of the attachment
|
||||
* @param array $overrides allows you to override the {@link wp_handle_upload()} behavior
|
||||
* @param string $file_id Index of the {@link $_FILES} array that the file was sent. Required.
|
||||
* @param int $post_id The post ID of a post to attach the media item to. Required, but can
|
||||
* be set to 0, creating a media item that has no relationship to a post.
|
||||
* @param array $post_data Overwrite some of the attachment. Optional.
|
||||
* @param array $overrides Override the {@link wp_handle_upload()} behavior. Optional.
|
||||
* @return int|WP_Error ID of the attachment or a WP_Error object on failure.
|
||||
*/
|
||||
function media_handle_upload($file_id, $post_id, $post_data = array(), $overrides = array( 'test_form' => false )) {
|
||||
@@ -265,31 +280,31 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override
|
||||
$file = $file['file'];
|
||||
$title = $name;
|
||||
$content = '';
|
||||
$excerpt = '';
|
||||
|
||||
if ( preg_match( '#^audio#', $type ) ) {
|
||||
$meta = wp_read_audio_metadata( $file );
|
||||
|
||||
if ( ! empty( $meta['title'] ) )
|
||||
if ( ! empty( $meta['title'] ) ) {
|
||||
$title = $meta['title'];
|
||||
|
||||
$content = '';
|
||||
}
|
||||
|
||||
if ( ! empty( $title ) ) {
|
||||
|
||||
if ( ! empty( $meta['album'] ) && ! empty( $meta['artist'] ) ) {
|
||||
/* translators: 1: audio track title, 2: album title, 3: artist name */
|
||||
$content .= sprintf( __( '"%1$s" from %2$s by %3$s.' ), $title, $meta['album'], $meta['artist'] );
|
||||
} else if ( ! empty( $meta['album'] ) ) {
|
||||
} elseif ( ! empty( $meta['album'] ) ) {
|
||||
/* translators: 1: audio track title, 2: album title */
|
||||
$content .= sprintf( __( '"%1$s" from %2$s.' ), $title, $meta['album'] );
|
||||
} else if ( ! empty( $meta['artist'] ) ) {
|
||||
} elseif ( ! empty( $meta['artist'] ) ) {
|
||||
/* translators: 1: audio track title, 2: artist name */
|
||||
$content .= sprintf( __( '"%1$s" by %2$s.' ), $title, $meta['artist'] );
|
||||
} else {
|
||||
$content .= sprintf( __( '"%s".' ), $title );
|
||||
}
|
||||
|
||||
} else if ( ! empty( $meta['album'] ) ) {
|
||||
} elseif ( ! empty( $meta['album'] ) ) {
|
||||
|
||||
if ( ! empty( $meta['artist'] ) ) {
|
||||
/* translators: 1: audio album title, 2: artist name */
|
||||
@@ -298,7 +313,7 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override
|
||||
$content .= $meta['album'] . '.';
|
||||
}
|
||||
|
||||
} else if ( ! empty( $meta['artist'] ) ) {
|
||||
} elseif ( ! empty( $meta['artist'] ) ) {
|
||||
|
||||
$content .= $meta['artist'] . '.';
|
||||
|
||||
@@ -319,11 +334,14 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override
|
||||
$content .= ' ' . sprintf( __( 'Genre: %s.' ), $meta['genre'] );
|
||||
|
||||
// Use image exif/iptc data for title and caption defaults if possible.
|
||||
} elseif ( $image_meta = @wp_read_image_metadata( $file ) ) {
|
||||
if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) )
|
||||
} elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = @wp_read_image_metadata( $file ) ) {
|
||||
if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
|
||||
$title = $image_meta['title'];
|
||||
if ( trim( $image_meta['caption'] ) )
|
||||
$content = $image_meta['caption'];
|
||||
}
|
||||
|
||||
if ( trim( $image_meta['caption'] ) ) {
|
||||
$excerpt = $image_meta['caption'];
|
||||
}
|
||||
}
|
||||
|
||||
// Construct the attachment array
|
||||
@@ -333,6 +351,7 @@ function media_handle_upload($file_id, $post_id, $post_data = array(), $override
|
||||
'post_parent' => $post_id,
|
||||
'post_title' => $title,
|
||||
'post_content' => $content,
|
||||
'post_excerpt' => $excerpt,
|
||||
), $post_data );
|
||||
|
||||
// This should never be set as it would then overwrite an existing attachment.
|
||||
@@ -416,7 +435,7 @@ function media_handle_sideload($file_array, $post_id, $desc = null, $post_data =
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param array $content_func
|
||||
* @param string|callable $content_func
|
||||
*/
|
||||
function wp_iframe($content_func /* ... */) {
|
||||
_wp_admin_html_begin();
|
||||
@@ -432,11 +451,9 @@ if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos(
|
||||
wp_enqueue_style( 'ie' );
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
|
||||
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
|
||||
isRtl = <?php echo (int) is_rtl(); ?>;
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
/** This action is documented in wp-admin/admin-header.php */
|
||||
@@ -478,7 +495,7 @@ if ( is_string( $content_func ) ) {
|
||||
* Fires in the admin header for each specific form tab in the legacy
|
||||
* (pre-3.5.0) media upload popup.
|
||||
*
|
||||
* The dynamic portion of the hook, $content_func, refers to the form
|
||||
* The dynamic portion of the hook, `$content_func`, refers to the form
|
||||
* callback for the media upload type. Possible values include
|
||||
* 'media_upload_type_form', 'media_upload_type_url_form', and
|
||||
* 'media_upload_library_form'.
|
||||
@@ -554,6 +571,14 @@ function media_buttons($editor_id = 'content') {
|
||||
}
|
||||
add_action( 'media_buttons', 'media_buttons' );
|
||||
|
||||
/**
|
||||
*
|
||||
* @global int $post_ID
|
||||
* @param string $type
|
||||
* @param int $post_id
|
||||
* @param string $tab
|
||||
* @return string
|
||||
*/
|
||||
function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) {
|
||||
global $post_ID;
|
||||
|
||||
@@ -571,7 +596,7 @@ function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) {
|
||||
/**
|
||||
* Filter the upload iframe source URL for a specific media type.
|
||||
*
|
||||
* The dynamic portion of the hook name, $type, refers to the type
|
||||
* The dynamic portion of the hook name, `$type`, refers to the type
|
||||
* of media uploaded.
|
||||
*
|
||||
* @since 3.0.0
|
||||
@@ -596,8 +621,8 @@ function media_upload_form_handler() {
|
||||
$errors = null;
|
||||
|
||||
if ( isset($_POST['send']) ) {
|
||||
$keys = array_keys($_POST['send']);
|
||||
$send_id = (int) array_shift($keys);
|
||||
$keys = array_keys( $_POST['send'] );
|
||||
$send_id = (int) reset( $keys );
|
||||
}
|
||||
|
||||
if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
|
||||
@@ -658,10 +683,8 @@ function media_upload_form_handler() {
|
||||
|
||||
if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?>
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
var win = window.dialogArguments || opener || parent || top;
|
||||
win.tb_remove();
|
||||
/* ]]> */
|
||||
</script>
|
||||
<?php
|
||||
exit;
|
||||
@@ -701,7 +724,7 @@ function media_upload_form_handler() {
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @return mixed
|
||||
* @return null|string
|
||||
*/
|
||||
function wp_media_upload_handler() {
|
||||
$errors = array();
|
||||
@@ -739,7 +762,7 @@ function wp_media_upload_handler() {
|
||||
/**
|
||||
* Filter the URL sent to the editor for a specific media type.
|
||||
*
|
||||
* The dynamic portion of the hook name, $type, refers to the type
|
||||
* The dynamic portion of the hook name, `$type`, refers to the type
|
||||
* of media being sent.
|
||||
*
|
||||
* @since 3.3.0
|
||||
@@ -806,9 +829,10 @@ function wp_media_upload_handler() {
|
||||
* @param string $file The URL of the image to download
|
||||
* @param int $post_id The post ID the media is to be associated with
|
||||
* @param string $desc Optional. Description of the image
|
||||
* @param string $return Optional. What to return: an image tag (default) or only the src.
|
||||
* @return string|WP_Error Populated HTML img tag on success
|
||||
*/
|
||||
function media_sideload_image( $file, $post_id, $desc = null ) {
|
||||
function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) {
|
||||
if ( ! empty( $file ) ) {
|
||||
// Set variables for storage, fix file filename for query strings.
|
||||
preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
|
||||
@@ -837,9 +861,15 @@ function media_sideload_image( $file, $post_id, $desc = null ) {
|
||||
|
||||
// Finally check to make sure the file has been saved, then return the HTML.
|
||||
if ( ! empty( $src ) ) {
|
||||
if ( $return === 'src' ) {
|
||||
return $src;
|
||||
}
|
||||
|
||||
$alt = isset( $desc ) ? esc_attr( $desc ) : '';
|
||||
$html = "<img src='$src' alt='$alt' />";
|
||||
return $html;
|
||||
} else {
|
||||
return new WP_Error( 'image_sideload_failed' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -848,7 +878,7 @@ function media_sideload_image( $file, $post_id, $desc = null ) {
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @return unknown
|
||||
* @return string|null
|
||||
*/
|
||||
function media_upload_gallery() {
|
||||
$errors = array();
|
||||
@@ -871,7 +901,7 @@ function media_upload_gallery() {
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @return unknown
|
||||
* @return string|null
|
||||
*/
|
||||
function media_upload_library() {
|
||||
$errors = array();
|
||||
@@ -892,7 +922,7 @@ function media_upload_library() {
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param object $post
|
||||
* @param WP_Post $post
|
||||
* @param string $checked
|
||||
* @return string
|
||||
*/
|
||||
@@ -920,12 +950,11 @@ function image_align_input_fields( $post, $checked = '' ) {
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param object $post
|
||||
* @param WP_Post $post
|
||||
* @param bool|string $check
|
||||
* @return array
|
||||
*/
|
||||
function image_size_input_fields( $post, $check = '' ) {
|
||||
|
||||
/**
|
||||
* Filter the names and labels of the default image sizes.
|
||||
*
|
||||
@@ -941,50 +970,53 @@ function image_size_input_fields( $post, $check = '' ) {
|
||||
'full' => __( 'Full Size' )
|
||||
) );
|
||||
|
||||
if ( empty($check) )
|
||||
$check = get_user_setting('imgsize', 'medium');
|
||||
if ( empty( $check ) ) {
|
||||
$check = get_user_setting('imgsize', 'medium');
|
||||
}
|
||||
$out = array();
|
||||
|
||||
foreach ( $size_names as $size => $label ) {
|
||||
$downsize = image_downsize($post->ID, $size);
|
||||
$checked = '';
|
||||
foreach ( $size_names as $size => $label ) {
|
||||
$downsize = image_downsize( $post->ID, $size );
|
||||
$checked = '';
|
||||
|
||||
// Is this size selectable?
|
||||
$enabled = ( $downsize[3] || 'full' == $size );
|
||||
$css_id = "image-size-{$size}-{$post->ID}";
|
||||
// Is this size selectable?
|
||||
$enabled = ( $downsize[3] || 'full' == $size );
|
||||
$css_id = "image-size-{$size}-{$post->ID}";
|
||||
|
||||
// If this size is the default but that's not available, don't select it.
|
||||
if ( $size == $check ) {
|
||||
if ( $enabled )
|
||||
$checked = " checked='checked'";
|
||||
else
|
||||
$check = '';
|
||||
} elseif ( !$check && $enabled && 'thumbnail' != $size ) {
|
||||
/*
|
||||
* If $check is not enabled, default to the first available size
|
||||
* that's bigger than a thumbnail.
|
||||
*/
|
||||
$check = $size;
|
||||
// If this size is the default but that's not available, don't select it.
|
||||
if ( $size == $check ) {
|
||||
if ( $enabled ) {
|
||||
$checked = " checked='checked'";
|
||||
} else {
|
||||
$check = '';
|
||||
}
|
||||
|
||||
$html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
|
||||
|
||||
$html .= "<label for='{$css_id}'>$label</label>";
|
||||
|
||||
// Only show the dimensions if that choice is available.
|
||||
if ( $enabled )
|
||||
$html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d × %d)", $downsize[1], $downsize[2] ). "</label>";
|
||||
|
||||
$html .= '</div>';
|
||||
|
||||
$out[] = $html;
|
||||
} elseif ( ! $check && $enabled && 'thumbnail' != $size ) {
|
||||
/*
|
||||
* If $check is not enabled, default to the first available size
|
||||
* that's bigger than a thumbnail.
|
||||
*/
|
||||
$check = $size;
|
||||
$checked = " checked='checked'";
|
||||
}
|
||||
|
||||
return array(
|
||||
'label' => __('Size'),
|
||||
'input' => 'html',
|
||||
'html' => join("\n", $out),
|
||||
);
|
||||
$html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
|
||||
|
||||
$html .= "<label for='{$css_id}'>$label</label>";
|
||||
|
||||
// Only show the dimensions if that choice is available.
|
||||
if ( $enabled ) {
|
||||
$html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d × %d)", $downsize[1], $downsize[2] ). "</label>";
|
||||
}
|
||||
$html .= '</div>';
|
||||
|
||||
$out[] = $html;
|
||||
}
|
||||
|
||||
return array(
|
||||
'label' => __( 'Size' ),
|
||||
'input' => 'html',
|
||||
'html' => join( "\n", $out ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -992,7 +1024,7 @@ function image_size_input_fields( $post, $check = '' ) {
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param object $post
|
||||
* @param WP_Post $post
|
||||
* @param string $url_type
|
||||
* @return string
|
||||
*/
|
||||
@@ -1075,8 +1107,8 @@ function media_post_single_attachment_fields_to_edit( $form_fields, $post ) {
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param WP_Post $post The WP_Post attachment object.
|
||||
* @param array $attachment An array of attachment metadata.
|
||||
* @param array $post The WP_Post attachment object converted to an array.
|
||||
* @param array $attachment An array of attachment metadata.
|
||||
* @return array Filtered attachment post object.
|
||||
*/
|
||||
function image_attachment_fields_to_save( $post, $attachment ) {
|
||||
@@ -1101,7 +1133,7 @@ add_filter( 'attachment_fields_to_save', 'image_attachment_fields_to_save', 10,
|
||||
* @param string $html
|
||||
* @param integer $attachment_id
|
||||
* @param array $attachment
|
||||
* @return array
|
||||
* @return string
|
||||
*/
|
||||
function image_media_send_to_editor($html, $attachment_id, $attachment) {
|
||||
$post = get_post($attachment_id);
|
||||
@@ -1125,7 +1157,7 @@ add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3);
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param object $post
|
||||
* @param WP_Post $post
|
||||
* @param array $errors
|
||||
* @return array
|
||||
*/
|
||||
@@ -1325,7 +1357,7 @@ function get_media_item( $attachment_id, $args = null ) {
|
||||
|
||||
$post_mime_types = get_post_mime_types();
|
||||
$keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) );
|
||||
$type = array_shift( $keys );
|
||||
$type = reset( $keys );
|
||||
$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
|
||||
|
||||
$form_fields = get_attachment_fields_to_edit( $post, $r['errors'] );
|
||||
@@ -1696,13 +1728,13 @@ function media_upload_header() {
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param unknown_type $errors
|
||||
* @param array $errors
|
||||
*/
|
||||
function media_upload_form( $errors = null ) {
|
||||
global $type, $tab, $is_IE, $is_opera;
|
||||
|
||||
if ( ! _device_can_upload() ) {
|
||||
echo '<p>' . sprintf( __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'http://apps.wordpress.org/' ) . '</p>';
|
||||
echo '<p>' . sprintf( __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'https://apps.wordpress.org/' ) . '</p>';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1780,6 +1812,14 @@ $plupload_init = array(
|
||||
'multipart_params' => $post_params,
|
||||
);
|
||||
|
||||
// Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos
|
||||
// when enabled. See #29602.
|
||||
if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false &&
|
||||
strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) {
|
||||
|
||||
$plupload_init['multi_selection'] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the default Plupload settings.
|
||||
*
|
||||
@@ -1802,7 +1842,7 @@ if( !$large_size_w )
|
||||
$large_size_w = 1024;
|
||||
?>
|
||||
var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>,
|
||||
wpUploaderInit = <?php echo json_encode($plupload_init); ?>;
|
||||
wpUploaderInit = <?php echo wp_json_encode( $plupload_init ); ?>;
|
||||
</script>
|
||||
|
||||
<div id="plupload-upload-ui" class="hide-if-no-js">
|
||||
@@ -1912,7 +1952,6 @@ function media_upload_type_form($type = 'file', $errors = null, $id = null) {
|
||||
<?php media_upload_form( $errors ); ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
jQuery(function($){
|
||||
var preloaded = $(".media-item.preloaded");
|
||||
if ( preloaded.length > 0 ) {
|
||||
@@ -1920,7 +1959,6 @@ jQuery(function($){
|
||||
}
|
||||
updateMediaForm();
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
<div id="media-items"><?php
|
||||
|
||||
@@ -1975,7 +2013,6 @@ function media_upload_type_url_form($type = null, $errors = null, $id = null) {
|
||||
<h3 class="media-title"><?php _e('Insert media from another website'); ?></h3>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var addExtImage = {
|
||||
|
||||
width : '',
|
||||
@@ -2052,21 +2089,19 @@ var addExtImage = {
|
||||
return false;
|
||||
}
|
||||
|
||||
document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" width="16" />';
|
||||
document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ); ?>" alt="" width="16" height="16" />';
|
||||
t.preloadImg = new Image();
|
||||
t.preloadImg.onload = t.updateImageData;
|
||||
t.preloadImg.onerror = t.resetImageData;
|
||||
t.preloadImg.src = src;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jQuery(document).ready( function($) {
|
||||
$('.media-types input').click( function() {
|
||||
$('table.describe').toggleClass('not-image', $('#not-image').prop('checked') );
|
||||
});
|
||||
});
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<div id="media-items">
|
||||
@@ -2269,7 +2304,7 @@ function media_upload_library_form($errors) {
|
||||
|
||||
?>
|
||||
|
||||
<form id="filter" action="" method="get">
|
||||
<form id="filter" method="get">
|
||||
<input type="hidden" name="type" value="<?php echo esc_attr( $type ); ?>" />
|
||||
<input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" />
|
||||
<input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
|
||||
@@ -2317,7 +2352,7 @@ foreach ( $post_mime_types as $mime_type => $label ) {
|
||||
/**
|
||||
* Filter the media upload mime type list items.
|
||||
*
|
||||
* Returned values should begin with an <li> tag.
|
||||
* Returned values should begin with an `<li>` tag.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -2629,13 +2664,13 @@ function edit_form_image_editor( $post ) {
|
||||
<?php if ( $open ) wp_image_editor( $attachment_id ); ?>
|
||||
</div>
|
||||
<?php
|
||||
elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'audio/' ) ):
|
||||
elseif ( $attachment_id && wp_attachment_is( 'audio', $post ) ):
|
||||
|
||||
wp_maybe_generate_attachment_metadata( $post );
|
||||
|
||||
echo wp_audio_shortcode( array( 'src' => $att_url ) );
|
||||
|
||||
elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'video/' ) ):
|
||||
elseif ( $attachment_id && wp_attachment_is( 'video', $post ) ):
|
||||
|
||||
wp_maybe_generate_attachment_metadata( $post );
|
||||
|
||||
@@ -2860,7 +2895,7 @@ function wp_add_id3_tag_data( &$metadata, $data ) {
|
||||
foreach ( array( 'id3v2', 'id3v1' ) as $version ) {
|
||||
if ( ! empty( $data[$version]['comments'] ) ) {
|
||||
foreach ( $data[$version]['comments'] as $key => $list ) {
|
||||
if ( ! empty( $list ) ) {
|
||||
if ( 'length' !== $key && ! empty( $list ) ) {
|
||||
$metadata[$key] = reset( $list );
|
||||
// Fix bug in byte stream analysis.
|
||||
if ( 'terms_of_use' === $key && 0 === strpos( $metadata[$key], 'yright notice.' ) )
|
||||
@@ -2898,7 +2933,7 @@ function wp_add_id3_tag_data( &$metadata, $data ) {
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return array|boolean Returns array of metadata, if found.
|
||||
* @return array|bool Returns array of metadata, if found.
|
||||
*/
|
||||
function wp_read_video_metadata( $file ) {
|
||||
if ( ! file_exists( $file ) )
|
||||
@@ -2922,7 +2957,7 @@ function wp_read_video_metadata( $file ) {
|
||||
if ( ! empty( $data['mime_type'] ) )
|
||||
$metadata['mime_type'] = $data['mime_type'];
|
||||
if ( ! empty( $data['playtime_seconds'] ) )
|
||||
$metadata['length'] = (int) ceil( $data['playtime_seconds'] );
|
||||
$metadata['length'] = (int) round( $data['playtime_seconds'] );
|
||||
if ( ! empty( $data['playtime_string'] ) )
|
||||
$metadata['length_formatted'] = $data['playtime_string'];
|
||||
if ( ! empty( $data['video']['resolution_x'] ) )
|
||||
@@ -2978,7 +3013,7 @@ function wp_read_audio_metadata( $file ) {
|
||||
if ( ! empty( $data['mime_type'] ) )
|
||||
$metadata['mime_type'] = $data['mime_type'];
|
||||
if ( ! empty( $data['playtime_seconds'] ) )
|
||||
$metadata['length'] = (int) ceil( $data['playtime_seconds'] );
|
||||
$metadata['length'] = (int) round( $data['playtime_seconds'] );
|
||||
if ( ! empty( $data['playtime_string'] ) )
|
||||
$metadata['length_formatted'] = $data['playtime_string'];
|
||||
|
||||
@@ -2986,3 +3021,63 @@ function wp_read_audio_metadata( $file ) {
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulate logic for Attach/Detach actions
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param int $parent_id Attachment parent ID.
|
||||
* @param string $action Optional. Attach/detach action. Accepts 'attach' or 'detach'.
|
||||
* Default 'attach'.
|
||||
*/
|
||||
function wp_media_attach_action( $parent_id, $action = 'attach' ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! $parent_id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'edit_post', $parent_id ) ) {
|
||||
wp_die( __( 'You are not allowed to edit this post.' ) );
|
||||
}
|
||||
$ids = array();
|
||||
foreach ( (array) $_REQUEST['media'] as $att_id ) {
|
||||
$att_id = (int) $att_id;
|
||||
|
||||
if ( ! current_user_can( 'edit_post', $att_id ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ids[] = $att_id;
|
||||
}
|
||||
|
||||
if ( ! empty( $ids ) ) {
|
||||
$ids_string = implode( ',', $ids );
|
||||
if ( 'attach' === $action ) {
|
||||
$result = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ( $ids_string )", $parent_id ) );
|
||||
} else {
|
||||
$result = $wpdb->query( "UPDATE $wpdb->posts SET post_parent = 0 WHERE post_type = 'attachment' AND ID IN ( $ids_string )" );
|
||||
}
|
||||
|
||||
foreach ( $ids as $att_id ) {
|
||||
clean_attachment_cache( $att_id );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $result ) ) {
|
||||
$location = 'upload.php';
|
||||
if ( $referer = wp_get_referer() ) {
|
||||
if ( false !== strpos( $referer, 'upload.php' ) ) {
|
||||
$location = remove_query_arg( array( 'attached', 'detach' ), $referer );
|
||||
}
|
||||
}
|
||||
|
||||
$key = 'attach' === $action ? 'attached' : 'detach';
|
||||
$location = add_query_arg( array( $key => $result ), $location );
|
||||
wp_redirect( $location );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ foreach ( $menu as $id => $data ) {
|
||||
if ( empty($submenu[$data[2]]) )
|
||||
continue;
|
||||
$subs = $submenu[$data[2]];
|
||||
$first_sub = array_shift($subs);
|
||||
$first_sub = reset( $subs );
|
||||
$old_parent = $data[2];
|
||||
$new_parent = $first_sub[2];
|
||||
/*
|
||||
@@ -163,7 +163,7 @@ foreach ( $menu as $id => $data ) {
|
||||
*/
|
||||
if ( ! empty( $submenu[$data[2]] ) && 1 == count ( $submenu[$data[2]] ) ) {
|
||||
$subs = $submenu[$data[2]];
|
||||
$first_sub = array_shift($subs);
|
||||
$first_sub = reset( $subs );
|
||||
if ( $data[2] == $first_sub[2] )
|
||||
unset( $submenu[$data[2]] );
|
||||
}
|
||||
@@ -316,7 +316,7 @@ if ( !user_can_access_admin_page() ) {
|
||||
*/
|
||||
do_action( 'admin_page_access_denied' );
|
||||
|
||||
wp_die( __('You do not have sufficient permissions to access this page.') );
|
||||
wp_die( __( 'You do not have sufficient permissions to access this page.' ), 403 );
|
||||
}
|
||||
|
||||
$menu = add_menu_classes($menu);
|
||||
@@ -162,15 +162,15 @@ echo esc_html( $visibility_trans ); ?></span>
|
||||
|
||||
<?php
|
||||
/* translators: Publish box date format, see http://php.net/date */
|
||||
$datef = __( 'M j, Y @ G:i' );
|
||||
$datef = __( 'M j, Y @ H:i' );
|
||||
if ( 0 != $post->ID ) {
|
||||
if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
|
||||
$stamp = __('Scheduled for: <b>%1$s</b>');
|
||||
} else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
|
||||
} elseif ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
|
||||
$stamp = __('Published on: <b>%1$s</b>');
|
||||
} else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
|
||||
} elseif ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
|
||||
$stamp = __('Publish <b>immediately</b>');
|
||||
} else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
|
||||
} elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
|
||||
$stamp = __('Schedule for: <b>%1$s</b>');
|
||||
} else { // draft, 1 or more saves, date specified
|
||||
$stamp = __('Publish on: <b>%1$s</b>');
|
||||
@@ -248,19 +248,19 @@ if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0
|
||||
if ( $can_publish ) :
|
||||
if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" />
|
||||
<?php submit_button( __( 'Schedule' ), 'primary button-large', 'publish', false, array( 'accesskey' => 'p' ) ); ?>
|
||||
<?php submit_button( __( 'Schedule' ), 'primary button-large', 'publish', false ); ?>
|
||||
<?php else : ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" />
|
||||
<?php submit_button( __( 'Publish' ), 'primary button-large', 'publish', false, array( 'accesskey' => 'p' ) ); ?>
|
||||
<?php submit_button( __( 'Publish' ), 'primary button-large', 'publish', false ); ?>
|
||||
<?php endif;
|
||||
else : ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" />
|
||||
<?php submit_button( __( 'Submit for Review' ), 'primary button-large', 'publish', false, array( 'accesskey' => 'p' ) ); ?>
|
||||
<?php submit_button( __( 'Submit for Review' ), 'primary button-large', 'publish', false ); ?>
|
||||
<?php
|
||||
endif;
|
||||
} else { ?>
|
||||
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" />
|
||||
<input name="save" type="submit" class="button button-primary button-large" id="publish" accesskey="p" value="<?php esc_attr_e('Update') ?>" />
|
||||
<input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ) ?>" />
|
||||
<?php
|
||||
} ?>
|
||||
</div>
|
||||
@@ -293,7 +293,7 @@ function attachment_submit_meta_box( $post ) {
|
||||
<div id="misc-publishing-actions">
|
||||
<?php
|
||||
/* translators: Publish box date format, see http://php.net/date */
|
||||
$datef = __( 'M j, Y @ G:i' );
|
||||
$datef = __( 'M j, Y @ H:i' );
|
||||
$stamp = __('Uploaded on: <b>%1$s</b>');
|
||||
$date = date_i18n( $datef, strtotime( $post->post_date ) );
|
||||
?>
|
||||
@@ -330,7 +330,7 @@ function attachment_submit_meta_box( $post ) {
|
||||
<div id="publishing-action">
|
||||
<span class="spinner"></span>
|
||||
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" />
|
||||
<input name="save" type="submit" class="button-primary button-large" id="publish" accesskey="p" value="<?php esc_attr_e('Update') ?>" />
|
||||
<input name="save" type="submit" class="button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ) ?>" />
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div><!-- #major-publishing-actions -->
|
||||
@@ -418,7 +418,6 @@ function post_tags_meta_box( $post, $box ) {
|
||||
<?php if ( $user_can_assign_terms ) : ?>
|
||||
<div class="ajaxtag hide-if-no-js">
|
||||
<label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label>
|
||||
<div class="taghint"><?php echo $taxonomy->labels->add_new_item; ?></div>
|
||||
<p><input type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
|
||||
<input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" /></p>
|
||||
</div>
|
||||
@@ -523,7 +522,7 @@ function post_categories_meta_box( $post, $box ) {
|
||||
function post_excerpt_meta_box($post) {
|
||||
?>
|
||||
<label class="screen-reader-text" for="excerpt"><?php _e('Excerpt') ?></label><textarea rows="1" cols="40" name="excerpt" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
|
||||
<p><?php _e('Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="http://codex.wordpress.org/Excerpt" target="_blank">Learn more about manual excerpts.</a>'); ?></p>
|
||||
<p><?php _e('Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="https://codex.wordpress.org/Excerpt" target="_blank">Learn more about manual excerpts.</a>'); ?></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -547,7 +546,7 @@ function post_trackback_meta_box($post) {
|
||||
|
||||
?>
|
||||
<p><label for="trackback_url"><?php _e('Send trackbacks to:'); ?></label> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p>
|
||||
<p><?php _e('Trackbacks are a way to notify legacy blog systems that you’ve linked to them. If you link other WordPress sites they’ll be notified automatically using <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">pingbacks</a>, no other action necessary.'); ?></p>
|
||||
<p><?php _e('Trackbacks are a way to notify legacy blog systems that you’ve linked to them. If you link other WordPress sites, they’ll be notified automatically using <a href="https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">pingbacks</a>, no other action necessary.'); ?></p>
|
||||
<?php
|
||||
if ( ! empty($pings) )
|
||||
echo $pings;
|
||||
@@ -573,7 +572,7 @@ foreach ( $metadata as $key => $value ) {
|
||||
list_meta( $metadata );
|
||||
meta_form( $post ); ?>
|
||||
</div>
|
||||
<p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p>
|
||||
<p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="https://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -589,7 +588,7 @@ function post_comment_status_meta_box($post) {
|
||||
<input name="advanced_view" type="hidden" value="1" />
|
||||
<p class="meta-options">
|
||||
<label for="comment_status" class="selectit"><input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e( 'Allow comments.' ) ?></label><br />
|
||||
<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php printf( __( 'Allow <a href="%s" target="_blank">trackbacks and pingbacks</a> on this page.' ), __( 'http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' ) ); ?></label>
|
||||
<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php printf( __( 'Allow <a href="%s" target="_blank">trackbacks and pingbacks</a> on this page.' ), __( 'https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' ) ); ?></label>
|
||||
<?php
|
||||
/**
|
||||
* Fires at the end of the Discussion meta box on the post editing screen.
|
||||
@@ -739,20 +738,34 @@ function page_attributes_meta_box($post) {
|
||||
<?php
|
||||
} // end empty pages check
|
||||
} // end hierarchical check.
|
||||
if ( 'page' == $post->post_type && 0 != count( get_page_templates( $post ) ) ) {
|
||||
if ( 'page' == $post->post_type && 0 != count( get_page_templates( $post ) ) && get_option( 'page_for_posts' ) != $post->ID ) {
|
||||
$template = !empty($post->page_template) ? $post->page_template : false;
|
||||
?>
|
||||
<p><strong><?php _e('Template') ?></strong></p>
|
||||
<label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template">
|
||||
<option value='default'><?php _e('Default Template'); ?></option>
|
||||
<?php
|
||||
/**
|
||||
* Filter the title of the default page template displayed in the drop-down.
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param string $label The display value for the default page template title.
|
||||
* @param string $context Where the option label is displayed. Possible values
|
||||
* include 'meta-box' or 'quick-edit'.
|
||||
*/
|
||||
$default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'meta-box' );
|
||||
?>
|
||||
<option value="default"><?php echo esc_html( $default_title ); ?></option>
|
||||
<?php page_template_dropdown($template); ?>
|
||||
</select>
|
||||
<?php
|
||||
} ?>
|
||||
<p><strong><?php _e('Order') ?></strong></p>
|
||||
<p><label class="screen-reader-text" for="menu_order"><?php _e('Order') ?></label><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr($post->menu_order) ?>" /></p>
|
||||
<p><?php if ( 'page' == $post->post_type ) _e( 'Need help? Use the Help tab in the upper right of your screen.' ); ?></p>
|
||||
<?php if ( 'page' == $post->post_type && get_current_screen()->get_help_tabs() ) { ?>
|
||||
<p><?php _e( 'Need help? Use the Help tab in the upper right of your screen.' ); ?></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
// -- Link related Meta Boxes
|
||||
@@ -806,9 +819,9 @@ if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('m
|
||||
|
||||
<div id="publishing-action">
|
||||
<?php if ( !empty($link->link_id) ) { ?>
|
||||
<input name="save" type="submit" class="button-large button-primary" id="publish" accesskey="p" value="<?php esc_attr_e('Update Link') ?>" />
|
||||
<input name="save" type="submit" class="button-large button-primary" id="publish" value="<?php esc_attr_e( 'Update Link' ) ?>" />
|
||||
<?php } else { ?>
|
||||
<input name="save" type="submit" class="button-large button-primary" id="publish" accesskey="p" value="<?php esc_attr_e('Add Link') ?>" />
|
||||
<input name="save" type="submit" class="button-large button-primary" id="publish" value="<?php esc_attr_e( 'Add Link' ) ?>" />
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
|
||||
+55
-11
@@ -58,8 +58,8 @@ function got_url_rewrite() {
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param unknown_type $filename
|
||||
* @param unknown_type $marker
|
||||
* @param string $filename
|
||||
* @param string $marker
|
||||
* @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers.
|
||||
*/
|
||||
function extract_from_markers( $filename, $marker ) {
|
||||
@@ -94,9 +94,9 @@ function extract_from_markers( $filename, $marker ) {
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param unknown_type $filename
|
||||
* @param unknown_type $marker
|
||||
* @param unknown_type $insertion
|
||||
* @param string $filename
|
||||
* @param string $marker
|
||||
* @param array $insertion
|
||||
* @return bool True on write success, false on failure.
|
||||
*/
|
||||
function insert_with_markers( $filename, $marker, $insertion ) {
|
||||
@@ -211,7 +211,7 @@ function iis7_save_url_rewrite_rules(){
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param unknown_type $file
|
||||
* @param string $file
|
||||
*/
|
||||
function update_recently_edited( $file ) {
|
||||
$oldfiles = (array ) get_option( 'recently_edited' );
|
||||
@@ -294,7 +294,7 @@ function wp_reset_vars( $vars ) {
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param unknown_type $message
|
||||
* @param string|WP_Error $message
|
||||
*/
|
||||
function show_message($message) {
|
||||
if ( is_wp_error($message) ){
|
||||
@@ -621,7 +621,7 @@ function admin_color_scheme_picker( $user_id ) {
|
||||
<div class="color-option <?php echo ( $color == $current_color ) ? 'selected' : ''; ?>">
|
||||
<input name="admin_color" id="admin_color_<?php echo esc_attr( $color ); ?>" type="radio" value="<?php echo esc_attr( $color ); ?>" class="tog" <?php checked( $color, $current_color ); ?> />
|
||||
<input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" />
|
||||
<input type="hidden" class="icon_colors" value="<?php echo esc_attr( json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" />
|
||||
<input type="hidden" class="icon_colors" value="<?php echo esc_attr( wp_json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" />
|
||||
<label for="admin_color_<?php echo esc_attr( $color ); ?>"><?php echo esc_html( $color_info->name ); ?></label>
|
||||
<table class="color-palette">
|
||||
<tr>
|
||||
@@ -662,10 +662,10 @@ function wp_color_scheme_settings() {
|
||||
$icon_colors = $_wp_admin_css_colors['fresh']->icon_colors;
|
||||
} else {
|
||||
// Fall back to the default set of icon colors if the default scheme is missing.
|
||||
$icon_colors = array( 'base' => '#999', 'focus' => '#2ea2cc', 'current' => '#fff' );
|
||||
$icon_colors = array( 'base' => '#999', 'focus' => '#00a0d2', 'current' => '#fff' );
|
||||
}
|
||||
|
||||
echo '<script type="text/javascript">var _wpColorScheme = ' . json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";
|
||||
echo '<script type="text/javascript">var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";
|
||||
}
|
||||
add_action( 'admin_head', 'wp_color_scheme_settings' );
|
||||
|
||||
@@ -841,5 +841,49 @@ function post_form_autocomplete_off() {
|
||||
echo ' autocomplete="off"';
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'post_edit_form_tag', 'post_form_autocomplete_off' );
|
||||
|
||||
/**
|
||||
* Remove single-use URL parameters and create canonical link based on new URL.
|
||||
*
|
||||
* Remove specific query string parameters from a URL, create the canonical link,
|
||||
* put it in the admin header, and change the current URL to match.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
function wp_admin_canonical_url() {
|
||||
$removable_query_args = array(
|
||||
'message', 'settings-updated', 'saved',
|
||||
'update', 'updated', 'activated',
|
||||
'activate', 'deactivate', 'locked',
|
||||
'deleted', 'trashed', 'untrashed',
|
||||
'enabled', 'disabled', 'skipped',
|
||||
'spammed', 'unspammed',
|
||||
);
|
||||
|
||||
/**
|
||||
* Filter the list of URL parameters to remove.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param array $removable_query_args An array of parameters to remove from the URL.
|
||||
*/
|
||||
$removable_query_args = apply_filters( 'removable_query_args', $removable_query_args );
|
||||
|
||||
if ( empty( $removable_query_args ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure we're using an absolute URL.
|
||||
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
|
||||
$filtered_url = remove_query_arg( $removable_query_args, $current_url );
|
||||
?>
|
||||
<link id="wp-admin-canonical" rel="canonical" href="<?php echo esc_url( $filtered_url ); ?>" />
|
||||
<script>
|
||||
if ( window.history.replaceState ) {
|
||||
window.history.replaceState( null, null, document.getElementById( 'wp-admin-canonical' ).href + window.location.hash );
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
add_action( 'admin_head', 'wp_admin_canonical_url' );
|
||||
@@ -53,7 +53,6 @@ function activate_sitewide_plugin() {
|
||||
*/
|
||||
function deactivate_sitewide_plugin( $plugin = false ) {
|
||||
_deprecated_function(__FUNCTION__, '3.0', 'deactivate_plugin()' );
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+197
-40
@@ -35,21 +35,21 @@ function check_upload_size( $file ) {
|
||||
if ( upload_is_user_over_quota( false ) ) {
|
||||
$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
|
||||
}
|
||||
if ( $file['error'] != '0' && !isset($_POST['html-upload']) )
|
||||
if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
|
||||
wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' );
|
||||
|
||||
/**
|
||||
* Delete a blog
|
||||
* Delete a blog.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param int $blog_id Blog ID
|
||||
* @param bool $drop True if blog's table should be dropped. Default is false.
|
||||
* @return void
|
||||
* @param int $blog_id Blog ID.
|
||||
* @param bool $drop True if blog's table should be dropped. Default is false.
|
||||
*/
|
||||
function wpmu_delete_blog( $blog_id, $drop = false ) {
|
||||
global $wpdb;
|
||||
@@ -84,11 +84,26 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
|
||||
|
||||
$current_site = get_current_site();
|
||||
|
||||
// Don't destroy the initial, main, or root blog.
|
||||
if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_site->path && $blog->domain == $current_site->domain ) ) )
|
||||
// If a full blog object is not available, do not destroy anything.
|
||||
if ( $drop && ! $blog ) {
|
||||
$drop = false;
|
||||
}
|
||||
|
||||
// Don't destroy the initial, main, or root blog.
|
||||
if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_site->path && $blog->domain == $current_site->domain ) ) ) {
|
||||
$drop = false;
|
||||
}
|
||||
|
||||
$upload_path = trim( get_option( 'upload_path' ) );
|
||||
|
||||
// If ms_files_rewriting is enabled and upload_path is empty, wp_upload_dir is not reliable.
|
||||
if ( $drop && get_site_option( 'ms_files_rewriting' ) && empty( $upload_path ) ) {
|
||||
$drop = false;
|
||||
}
|
||||
|
||||
if ( $drop ) {
|
||||
$uploads = wp_upload_dir();
|
||||
|
||||
$tables = $wpdb->tables( 'blog' );
|
||||
/**
|
||||
* Filter the tables to drop when the blog is deleted.
|
||||
@@ -106,7 +121,6 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
|
||||
|
||||
$wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
|
||||
|
||||
$uploads = wp_upload_dir();
|
||||
/**
|
||||
* Filter the upload base directory to delete when the blog is deleted.
|
||||
*
|
||||
@@ -122,7 +136,7 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
|
||||
$index = 0;
|
||||
|
||||
while ( $index < count( $stack ) ) {
|
||||
# Get indexed directory from stack
|
||||
// Get indexed directory from stack
|
||||
$dir = $stack[$index];
|
||||
|
||||
$dh = @opendir( $dir );
|
||||
@@ -131,10 +145,11 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
|
||||
if ( $file == '.' || $file == '..' )
|
||||
continue;
|
||||
|
||||
if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) )
|
||||
if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) {
|
||||
$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
|
||||
else if ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) )
|
||||
} elseif ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) {
|
||||
@unlink( $dir . DIRECTORY_SEPARATOR . $file );
|
||||
}
|
||||
}
|
||||
@closedir( $dh );
|
||||
}
|
||||
@@ -154,7 +169,16 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
|
||||
restore_current_blog();
|
||||
}
|
||||
|
||||
// @todo Merge with wp_delete_user() ?
|
||||
/**
|
||||
* Delete a user from the network and remove from all sites.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @todo Merge with wp_delete_user() ?
|
||||
*
|
||||
* @param int $id The user ID.
|
||||
* @return bool True if the user was deleted, otherwise false.
|
||||
*/
|
||||
function wpmu_delete_user( $id ) {
|
||||
global $wpdb;
|
||||
|
||||
@@ -210,6 +234,14 @@ function wpmu_delete_user( $id ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an email when a site administrator email address is changed.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $old_value The old email address. Not currently used.
|
||||
* @param string $value The new email address.
|
||||
*/
|
||||
function update_option_new_admin_email( $old_value, $value ) {
|
||||
if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
|
||||
return;
|
||||
@@ -221,10 +253,11 @@ function update_option_new_admin_email( $old_value, $value ) {
|
||||
);
|
||||
update_option( 'adminhash', $new_admin_email );
|
||||
|
||||
$email_text = __( 'Dear user,
|
||||
$email_text = __( 'Howdy ###USERNAME###,
|
||||
|
||||
You recently requested to have the administration email address on
|
||||
your site changed.
|
||||
|
||||
If this is correct, please click on the following link to change it:
|
||||
###ADMIN_URL###
|
||||
|
||||
@@ -241,7 +274,8 @@ All at ###SITENAME###
|
||||
* Filter the email text sent when the site admin email is changed.
|
||||
*
|
||||
* The following strings have a special meaning and will get replaced dynamically:
|
||||
* ###ADMIN_URL### The link to click on to confirm the email change. Required otherwise this functunalty is will break.
|
||||
* ###USERNAME### The current user's username.
|
||||
* ###ADMIN_URL### The link to click on to confirm the email change.
|
||||
* ###EMAIL### The new email.
|
||||
* ###SITENAME### The name of the site.
|
||||
* ###SITEURL### The URL to the site.
|
||||
@@ -253,6 +287,7 @@ All at ###SITENAME###
|
||||
*/
|
||||
$content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email );
|
||||
|
||||
$content = str_replace( '###USERNAME###', $current_user->user_login, $content );
|
||||
$content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'options.php?adminhash='.$hash ) ), $content );
|
||||
$content = str_replace( '###EMAIL###', $value, $content );
|
||||
$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
|
||||
@@ -263,6 +298,14 @@ All at ###SITENAME###
|
||||
add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
|
||||
add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
|
||||
|
||||
/**
|
||||
* Sends an email when an email address change is requested.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @global object $errors WP_Error object.
|
||||
* @global object $wpdb WordPress database object.
|
||||
*/
|
||||
function send_confirmation_on_profile_email() {
|
||||
global $errors, $wpdb;
|
||||
$current_user = wp_get_current_user();
|
||||
@@ -291,9 +334,10 @@ function send_confirmation_on_profile_email() {
|
||||
);
|
||||
update_option( $current_user->ID . '_new_email', $new_user_email );
|
||||
|
||||
$email_text = __( 'Dear user,
|
||||
$email_text = __( 'Howdy ###USERNAME###,
|
||||
|
||||
You recently requested to have the email address on your account changed.
|
||||
|
||||
If this is correct, please click on the following link to change it:
|
||||
###ADMIN_URL###
|
||||
|
||||
@@ -310,10 +354,11 @@ All at ###SITENAME###
|
||||
* Filter the email text sent when a user changes emails.
|
||||
*
|
||||
* The following strings have a special meaning and will get replaced dynamically:
|
||||
* ###ADMIN_URL### The link to click on to confirm the email change. Required otherwise this functunalty is will break.
|
||||
* ###EMAIL### The new email.
|
||||
* ###SITENAME### The name of the site.
|
||||
* ###SITEURL### The URL to the site.
|
||||
* ###USERNAME### The current user's username.
|
||||
* ###ADMIN_URL### The link to click on to confirm the email change.
|
||||
* ###EMAIL### The new email.
|
||||
* ###SITENAME### The name of the site.
|
||||
* ###SITEURL### The URL to the site.
|
||||
*
|
||||
* @since MU
|
||||
*
|
||||
@@ -322,6 +367,7 @@ All at ###SITENAME###
|
||||
*/
|
||||
$content = apply_filters( 'new_user_email_content', $email_text, $new_user_email );
|
||||
|
||||
$content = str_replace( '###USERNAME###', $current_user->user_login, $content );
|
||||
$content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'profile.php?newuseremail='.$hash ) ), $content );
|
||||
$content = str_replace( '###EMAIL###', $_POST['email'], $content);
|
||||
$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
|
||||
@@ -333,6 +379,12 @@ All at ###SITENAME###
|
||||
}
|
||||
add_action( 'personal_options_update', 'send_confirmation_on_profile_email' );
|
||||
|
||||
/**
|
||||
* Adds an admin notice alerting the user to check for confirmation email
|
||||
* after email address change.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function new_user_email_admin_notice() {
|
||||
if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) )
|
||||
echo "<div class='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>";
|
||||
@@ -345,7 +397,7 @@ add_action( 'admin_notices', 'new_user_email_admin_notice' );
|
||||
* @since MU
|
||||
*
|
||||
* @param bool $echo Optional. If $echo is set and the quota is exceeded, a warning message is echoed. Default is true.
|
||||
* @return int
|
||||
* @return bool True if user is over upload space quota, otherwise false.
|
||||
*/
|
||||
function upload_is_user_over_quota( $echo = true ) {
|
||||
if ( get_site_option( 'upload_space_check_disabled' ) )
|
||||
@@ -395,9 +447,6 @@ function display_space_usage() {
|
||||
* Get the remaining upload space for this blog.
|
||||
*
|
||||
* @since MU
|
||||
* @uses upload_is_user_over_quota()
|
||||
* @uses get_space_allowed()
|
||||
* @uses get_upload_space_available()
|
||||
*
|
||||
* @param int $size Current max size in bytes
|
||||
* @return int Max size in bytes
|
||||
@@ -410,7 +459,13 @@ function fix_import_form_size( $size ) {
|
||||
return min( $size, $available );
|
||||
}
|
||||
|
||||
// Edit blog upload space setting on Edit Blog page
|
||||
/**
|
||||
* Displays the edit blog upload space setting form on the Edit Blog screen.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param int $id The ID of the blog to display the setting for.
|
||||
*/
|
||||
function upload_space_setting( $id ) {
|
||||
switch_to_blog( $id );
|
||||
$quota = get_option( 'blog_upload_space' );
|
||||
@@ -421,13 +476,30 @@ function upload_space_setting( $id ) {
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<th><?php _e( 'Site Upload Space Quota '); ?></th>
|
||||
<td><input type="number" step="1" min="0" style="width: 100px" name="option[blog_upload_space]" value="<?php echo $quota; ?>" /> <?php _e( 'MB (Leave blank for network default)' ); ?></td>
|
||||
<th><label for="blog-upload-space-number"><?php _e( 'Site Upload Space Quota' ); ?></label></th>
|
||||
<td>
|
||||
<input type="number" step="1" min="0" style="width: 100px" name="option[blog_upload_space]" id="blog-upload-space-number" aria-describedby="blog-upload-space-desc" value="<?php echo $quota; ?>" />
|
||||
<span id="blog-upload-space-desc"><span class="screen-reader-text"><?php _e( 'Size in megabytes' ); ?></span> <?php _e( 'MB (Leave blank for network default)' ); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
add_action( 'wpmueditblogaction', 'upload_space_setting' );
|
||||
|
||||
/**
|
||||
* Update the status of a user in the database.
|
||||
*
|
||||
* Used in core to mark a user as spam or "ham" (not spam) in Multisite.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param int $id The user ID.
|
||||
* @param string $pref The column in the wp_users table to update the user's status
|
||||
* in (presumably user_status, spam, or deleted).
|
||||
* @param int $value The new status for the user.
|
||||
* @param null $deprecated Deprecated as of 3.0.2 and should not be used.
|
||||
* @return int The initially passed $value.
|
||||
*/
|
||||
function update_user_status( $id, $pref, $value, $deprecated = null ) {
|
||||
global $wpdb;
|
||||
|
||||
@@ -464,6 +536,14 @@ function update_user_status( $id, $pref, $value, $deprecated = null ) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the user cache for a specific user.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param int $id The user ID.
|
||||
* @return bool|int The ID of the refreshed user or false if the user does not exist.
|
||||
*/
|
||||
function refresh_user_details( $id ) {
|
||||
$id = (int) $id;
|
||||
|
||||
@@ -475,6 +555,15 @@ function refresh_user_details( $id ) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the language for a language code.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $code Optional. The two-letter language code. Default empty.
|
||||
* @return string The language corresponding to $code if it exists. If it does not exist,
|
||||
* then the first two letters of $code is returned.
|
||||
*/
|
||||
function format_code_lang( $code = '' ) {
|
||||
$code = strtolower( substr( $code, 0, 2 ) );
|
||||
$lang_codes = array(
|
||||
@@ -502,6 +591,18 @@ function format_code_lang( $code = '' ) {
|
||||
return strtr( $code, $lang_codes );
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronize category and post tag slugs when global terms are enabled.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param object $term The term.
|
||||
* @param string $taxonomy The taxonomy for $term. Should be 'category' or 'post_tag', as these are
|
||||
* the only taxonomies which are processed by this function; anything else
|
||||
* will be returned untouched.
|
||||
* @return object|array Returns `$term`, after filtering the 'slug' field with {@see sanitize_title()}
|
||||
* if $taxonomy is 'category' or 'post_tag'.
|
||||
*/
|
||||
function sync_category_tag_slugs( $term, $taxonomy ) {
|
||||
if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
|
||||
if ( is_object( $term ) ) {
|
||||
@@ -514,6 +615,13 @@ function sync_category_tag_slugs( $term, $taxonomy ) {
|
||||
}
|
||||
add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
|
||||
|
||||
/**
|
||||
* Displays an access denied message when a user tries to view a site's dashboard they
|
||||
* do not have access to.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @access private
|
||||
*/
|
||||
function _access_denied_splash() {
|
||||
if ( ! is_user_logged_in() || is_network_admin() )
|
||||
return;
|
||||
@@ -526,7 +634,7 @@ function _access_denied_splash() {
|
||||
$blog_name = get_bloginfo( 'name' );
|
||||
|
||||
if ( empty( $blogs ) )
|
||||
wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) );
|
||||
wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 );
|
||||
|
||||
$output = '<p>' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>';
|
||||
$output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '</p>';
|
||||
@@ -544,10 +652,18 @@ function _access_denied_splash() {
|
||||
|
||||
$output .= '</table>';
|
||||
|
||||
wp_die( $output );
|
||||
wp_die( $output, 403 );
|
||||
}
|
||||
add_action( 'admin_page_access_denied', '_access_denied_splash', 99 );
|
||||
|
||||
/**
|
||||
* Checks if the current user has permissions to import new users.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $permission A permission to be checked. Currently not used.
|
||||
* @return bool True if the user has proper permissions, false if they do not.
|
||||
*/
|
||||
function check_import_new_users( $permission ) {
|
||||
if ( !is_super_admin() )
|
||||
return false;
|
||||
@@ -556,6 +672,14 @@ function check_import_new_users( $permission ) {
|
||||
add_filter( 'import_allow_create_users', 'check_import_new_users' );
|
||||
// See "import_allow_fetch_attachments" and "import_attachment_size_limit" filters too.
|
||||
|
||||
/**
|
||||
* Generates and displays a drop-down of available languages.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param array $lang_files Optional. An array of the language files. Default empty array.
|
||||
* @param string $current Optional. The current language code. Default empty.
|
||||
*/
|
||||
function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
|
||||
$flag = false;
|
||||
$output = array();
|
||||
@@ -583,6 +707,7 @@ function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
|
||||
|
||||
// Order by name
|
||||
uksort( $output, 'strnatcasecmp' );
|
||||
|
||||
/**
|
||||
* Filter the languages available in the dropdown.
|
||||
*
|
||||
@@ -593,9 +718,17 @@ function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
|
||||
* @param string $current The current language code.
|
||||
*/
|
||||
$output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current );
|
||||
|
||||
echo implode( "\n\t", $output );
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays an admin notice to upgrade all sites after a core upgrade.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @global int $wp_db_version The version number of the database.
|
||||
*/
|
||||
function site_admin_notice() {
|
||||
global $wp_db_version;
|
||||
if ( !is_super_admin() )
|
||||
@@ -606,6 +739,18 @@ function site_admin_notice() {
|
||||
add_action( 'admin_notices', 'site_admin_notice' );
|
||||
add_action( 'network_admin_notices', 'site_admin_notice' );
|
||||
|
||||
/**
|
||||
* Avoids a collision between a site slug and a permalink slug.
|
||||
*
|
||||
* In a subdirectory install this will make sure that a site and a post do not use the
|
||||
* same subdirectory by checking for a site with the same name as a new post.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param array $data An array of post data.
|
||||
* @param array $postarr An array of posts. Not currently used.
|
||||
* @return array The new array of post data after checking for collisions.
|
||||
*/
|
||||
function avoid_blog_page_permalink_collision( $data, $postarr ) {
|
||||
if ( is_subdomain_install() )
|
||||
return $data;
|
||||
@@ -629,12 +774,20 @@ function avoid_blog_page_permalink_collision( $data, $postarr ) {
|
||||
}
|
||||
add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 );
|
||||
|
||||
/**
|
||||
* Handles the display of choosing a user's primary site.
|
||||
*
|
||||
* This displays the user's primary site and allows the user to choose
|
||||
* which site is primary.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function choose_primary_blog() {
|
||||
?>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<?php /* translators: My sites label */ ?>
|
||||
<th scope="row"><?php _e( 'Primary Site' ); ?></th>
|
||||
<th scope="row"><label for="primary_blog"><?php _e( 'Primary Site' ); ?></label></th>
|
||||
<td>
|
||||
<?php
|
||||
$all_blogs = get_blogs_of_user( get_current_user_id() );
|
||||
@@ -642,7 +795,7 @@ function choose_primary_blog() {
|
||||
if ( count( $all_blogs ) > 1 ) {
|
||||
$found = false;
|
||||
?>
|
||||
<select name="primary_blog">
|
||||
<select name="primary_blog" id="primary_blog">
|
||||
<?php foreach( (array) $all_blogs as $blog ) {
|
||||
if ( $primary_blog == $blog->userblog_id )
|
||||
$found = true;
|
||||
@@ -651,11 +804,11 @@ function choose_primary_blog() {
|
||||
</select>
|
||||
<?php
|
||||
if ( !$found ) {
|
||||
$blog = array_shift( $all_blogs );
|
||||
$blog = reset( $all_blogs );
|
||||
update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
|
||||
}
|
||||
} elseif ( count( $all_blogs ) == 1 ) {
|
||||
$blog = array_shift( $all_blogs );
|
||||
$blog = reset( $all_blogs );
|
||||
echo $blog->domain;
|
||||
if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
|
||||
update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
|
||||
@@ -684,9 +837,10 @@ function choose_primary_blog() {
|
||||
* Grants Super Admin privileges.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param int $user_id ID of the user to be granted Super Admin privileges.
|
||||
* @return bool True on success, false on failure. This can fail when the user is
|
||||
* already a super admin or when the $super_admins global is defined.
|
||||
* already a super admin or when the `$super_admins` global is defined.
|
||||
*/
|
||||
function grant_super_admin( $user_id ) {
|
||||
// If global super_admins override is defined, there is nothing to do here.
|
||||
@@ -728,9 +882,10 @@ function grant_super_admin( $user_id ) {
|
||||
* Revokes Super Admin privileges.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param int $user_id ID of the user Super Admin privileges to be revoked from.
|
||||
* @return bool True on success, false on failure. This can fail when the user's email
|
||||
* is the network admin email or when the $super_admins global is defined.
|
||||
* is the network admin email or when the `$super_admins` global is defined.
|
||||
*/
|
||||
function revoke_super_admin( $user_id ) {
|
||||
// If global super_admins override is defined, there is nothing to do here.
|
||||
@@ -771,12 +926,15 @@ function revoke_super_admin( $user_id ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not we can edit this network from this page
|
||||
* Whether or not we can edit this network from this page.
|
||||
*
|
||||
* By default editing of network is restricted to the Network Admin for that site_id this allows for this to be overridden
|
||||
* By default editing of network is restricted to the Network Admin for that `$site_id`
|
||||
* this allows for this to be overridden.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param integer $site_id The network/site ID to check.
|
||||
*
|
||||
* @param int $site_id The network/site ID to check.
|
||||
* @return bool True if network can be edited, otherwise false.
|
||||
*/
|
||||
function can_edit_network( $site_id ) {
|
||||
global $wpdb;
|
||||
@@ -801,14 +959,13 @@ function can_edit_network( $site_id ) {
|
||||
* Thickbox image paths for Network Admin.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _thickbox_path_admin_subfolder() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var tb_pathToImage = "../../wp-includes/js/thickbox/loadingAnimation.gif";
|
||||
//]]>
|
||||
var tb_pathToImage = "<?php echo includes_url( 'js/thickbox/loadingAnimation.gif', 'relative' ); ?>";
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
@@ -186,11 +186,11 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
||||
<p class="field-move hide-if-no-js description description-wide">
|
||||
<label>
|
||||
<span><?php _e( 'Move' ); ?></span>
|
||||
<a href="#" class="menus-move-up"><?php _e( 'Up one' ); ?></a>
|
||||
<a href="#" class="menus-move-down"><?php _e( 'Down one' ); ?></a>
|
||||
<a href="#" class="menus-move-left"></a>
|
||||
<a href="#" class="menus-move-right"></a>
|
||||
<a href="#" class="menus-move-top"><?php _e( 'To the top' ); ?></a>
|
||||
<a href="#" class="menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' ); ?></a>
|
||||
<a href="#" class="menus-move menus-move-down" data-dir="down"><?php _e( 'Down one' ); ?></a>
|
||||
<a href="#" class="menus-move menus-move-left" data-dir="left"></a>
|
||||
<a href="#" class="menus-move menus-move-right" data-dir="right"></a>
|
||||
<a href="#" class="menus-move menus-move-top" data-dir="top"><?php _e( 'To the top' ); ?></a>
|
||||
</label>
|
||||
</p>
|
||||
|
||||
@@ -356,7 +356,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
|
||||
if ( 'markup' == $response_format ) {
|
||||
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args );
|
||||
} elseif ( 'json' == $response_format ) {
|
||||
echo json_encode(
|
||||
echo wp_json_encode(
|
||||
array(
|
||||
'ID' => $object_id,
|
||||
'post_title' => get_the_title( $object_id ),
|
||||
@@ -373,7 +373,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
|
||||
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args );
|
||||
} elseif ( 'json' == $response_format ) {
|
||||
$post_obj = get_term( $object_id, $object_type );
|
||||
echo json_encode(
|
||||
echo wp_json_encode(
|
||||
array(
|
||||
'ID' => $object_id,
|
||||
'post_title' => $post_obj->name,
|
||||
@@ -401,7 +401,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
|
||||
$var_by_ref = get_the_ID();
|
||||
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args );
|
||||
} elseif ( 'json' == $response_format ) {
|
||||
echo json_encode(
|
||||
echo wp_json_encode(
|
||||
array(
|
||||
'ID' => get_the_ID(),
|
||||
'post_title' => get_the_title(),
|
||||
@@ -422,7 +422,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
|
||||
if ( 'markup' == $response_format ) {
|
||||
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
|
||||
} elseif ( 'json' == $response_format ) {
|
||||
echo json_encode(
|
||||
echo wp_json_encode(
|
||||
array(
|
||||
'ID' => $term->term_id,
|
||||
'post_title' => $term->name,
|
||||
@@ -444,7 +444,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
|
||||
function wp_nav_menu_setup() {
|
||||
// Register meta boxes
|
||||
wp_nav_menu_post_type_meta_boxes();
|
||||
add_meta_box( 'add-custom-links', __( 'Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
|
||||
add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
|
||||
wp_nav_menu_taxonomy_meta_boxes();
|
||||
|
||||
// Register advanced menu items (columns)
|
||||
@@ -550,7 +550,6 @@ function wp_nav_menu_taxonomy_meta_boxes() {
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @uses global $one_theme_location_no_menus to determine if no menus exist
|
||||
* @uses disabled() to output the disabled attribute in $other_attributes param in submit_button()
|
||||
*
|
||||
* @param int|string $nav_menu_selected_id (id, name or slug) of the currently-selected menu
|
||||
* @return string Disabled attribute if at least one menu exists, false if not
|
||||
@@ -793,8 +792,8 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
|
||||
* Filter the posts displayed in the 'View All' tab of the current
|
||||
* post type's menu items meta box.
|
||||
*
|
||||
* The dynamic portion of the hook name, $post_type_name,
|
||||
* refers to the slug of the current post type.
|
||||
* The dynamic portion of the hook name, `$post_type_name`, refers
|
||||
* to the slug of the current post type.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
@@ -1149,7 +1148,7 @@ function _wp_nav_menu_meta_box_object( $object = null ) {
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $menu_id The ID of the menu to format.
|
||||
* @param int $menu_id Optional. The ID of the menu to format. Default 0.
|
||||
* @return string|WP_Error $output The menu formatted to edit or error object on failure.
|
||||
*/
|
||||
function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
|
||||
@@ -1247,16 +1246,13 @@ add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items');
|
||||
*
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @uses wp_get_nav_menu_items() to retrieve the nav menu's menu items
|
||||
* @uses wp_defer_term_counter() to enable then disable term counting
|
||||
*
|
||||
* @param int|string $nav_menu_selected_id (id, slug, or name ) of the currently-selected menu
|
||||
* @param string $nav_menu_selected_title Title of the currently-selected menu
|
||||
* @return array $messages The menu updated message
|
||||
*/
|
||||
function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) {
|
||||
$unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) );
|
||||
|
||||
$messages = array();
|
||||
$menu_items = array();
|
||||
// Index menu items by db ID
|
||||
foreach ( $unsorted_menu_items as $_item )
|
||||
@@ -1321,7 +1317,7 @@ function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_select
|
||||
/** This action is documented in wp-includes/nav-menu.php */
|
||||
do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
|
||||
|
||||
$messages[] = '<div id="message" class="updated"><p>' . sprintf( __( '<strong>%1$s</strong> has been updated.' ), $nav_menu_selected_title ) . '</p></div>';
|
||||
$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( __( '<strong>%1$s</strong> has been updated.' ), $nav_menu_selected_title ) . '</p></div>';
|
||||
unset( $menu_items, $unsorted_menu_items );
|
||||
|
||||
return $messages;
|
||||
|
||||
@@ -28,11 +28,17 @@
|
||||
*/
|
||||
function plugins_api($action, $args = null) {
|
||||
|
||||
if ( is_array($args) )
|
||||
$args = (object)$args;
|
||||
if ( is_array( $args ) ) {
|
||||
$args = (object) $args;
|
||||
}
|
||||
|
||||
if ( !isset($args->per_page) )
|
||||
if ( ! isset( $args->per_page ) ) {
|
||||
$args->per_page = 24;
|
||||
}
|
||||
|
||||
if ( ! isset( $args->locale ) ) {
|
||||
$args->locale = get_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the Plugin Install API arguments.
|
||||
@@ -64,18 +70,18 @@ function plugins_api($action, $args = null) {
|
||||
if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
|
||||
$args = array(
|
||||
$http_args = array(
|
||||
'timeout' => 15,
|
||||
'body' => array(
|
||||
'action' => $action,
|
||||
'request' => serialize( $args )
|
||||
)
|
||||
);
|
||||
$request = wp_remote_post( $url, $args );
|
||||
$request = wp_remote_post( $url, $http_args );
|
||||
|
||||
if ( $ssl && is_wp_error( $request ) ) {
|
||||
trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
|
||||
$request = wp_remote_post( $http_url, $args );
|
||||
$request = wp_remote_post( $http_url, $http_args );
|
||||
}
|
||||
|
||||
if ( is_wp_error($request) ) {
|
||||
@@ -170,7 +176,7 @@ function install_search_form( $type_selector = true ) {
|
||||
$input_attrs = 'class="wp-filter-search" placeholder="' . esc_attr__( 'Search Plugins' ) . '" ';
|
||||
}
|
||||
|
||||
?><form class="search-form search-plugins" method="get" action="">
|
||||
?><form class="search-form search-plugins" method="get">
|
||||
<input type="hidden" name="tab" value="search" />
|
||||
<?php if ( $type_selector ) : ?>
|
||||
<select name="type" id="typeselector">
|
||||
@@ -189,10 +195,8 @@ function install_search_form( $type_selector = true ) {
|
||||
/**
|
||||
* Upload from zip
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string $page
|
||||
*/
|
||||
function install_plugins_upload( $page = 1 ) {
|
||||
function install_plugins_upload() {
|
||||
?>
|
||||
<div class="upload-plugin">
|
||||
<p class="install-help"><?php _e('If you have a plugin in a .zip format, you may install it by uploading it here.'); ?></p>
|
||||
@@ -205,7 +209,7 @@ function install_plugins_upload( $page = 1 ) {
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
add_action('install_plugins_upload', 'install_plugins_upload', 10, 1);
|
||||
add_action('install_plugins_upload', 'install_plugins_upload' );
|
||||
|
||||
/**
|
||||
* Show a username form for the favorites page
|
||||
@@ -216,7 +220,7 @@ function install_plugins_favorites_form() {
|
||||
$user = ! empty( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' );
|
||||
?>
|
||||
<p class="install-help"><?php _e( 'If you have marked plugins as favorites on WordPress.org, you can browse them here.' ); ?></p>
|
||||
<form method="get" action="">
|
||||
<form method="get">
|
||||
<input type="hidden" name="tab" value="favorites" />
|
||||
<p>
|
||||
<label for="user"><?php _e( 'Your WordPress.org username:' ); ?></label>
|
||||
@@ -235,21 +239,29 @@ function install_plugins_favorites_form() {
|
||||
function display_plugins_table() {
|
||||
global $wp_list_table;
|
||||
|
||||
if ( current_filter() == 'install_plugins_favorites' && empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) ) {
|
||||
return;
|
||||
switch ( current_filter() ) {
|
||||
case 'install_plugins_favorites' :
|
||||
if ( empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) ) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 'install_plugins_recommended' :
|
||||
echo '<p>' . __( 'These suggestions are based on the plugins you and other users have installed.' ) . '</p>';
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
<form id="plugin-filter" action="" method="post">
|
||||
<form id="plugin-filter" method="post">
|
||||
<?php $wp_list_table->display(); ?>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
add_action( 'install_plugins_search', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_popular', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_new', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_beta', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_favorites', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_search', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_popular', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_recommended', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_new', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_beta', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_favorites', 'display_plugins_table' );
|
||||
|
||||
/**
|
||||
* Determine the status we can perform on a plugin.
|
||||
@@ -264,6 +276,7 @@ function install_plugin_install_status($api, $loop = false) {
|
||||
// Default to a "new" plugin
|
||||
$status = 'install';
|
||||
$url = false;
|
||||
$update_file = false;
|
||||
|
||||
/*
|
||||
* Check to see if this plugin is known to be installed,
|
||||
@@ -291,7 +304,8 @@ function install_plugin_install_status($api, $loop = false) {
|
||||
$url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug);
|
||||
} else {
|
||||
$key = array_keys( $installed_plugin );
|
||||
$key = array_shift( $key ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
|
||||
$key = reset( $key ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
|
||||
$update_file = $api->slug . '/' . $key;
|
||||
if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '=') ){
|
||||
$status = 'latest_installed';
|
||||
} elseif ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '<') ) {
|
||||
@@ -315,7 +329,8 @@ function install_plugin_install_status($api, $loop = false) {
|
||||
if ( isset($_GET['from']) )
|
||||
$url .= '&from=' . urlencode( wp_unslash( $_GET['from'] ) );
|
||||
|
||||
return compact('status', 'url', 'version');
|
||||
$file = $update_file;
|
||||
return compact( 'status', 'url', 'version', 'file' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -326,10 +341,19 @@ function install_plugin_install_status($api, $loop = false) {
|
||||
function install_plugin_information() {
|
||||
global $tab;
|
||||
|
||||
if ( empty( $_REQUEST['plugin'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$api = plugins_api( 'plugin_information', array(
|
||||
'slug' => wp_unslash( $_REQUEST['plugin'] ),
|
||||
'is_ssl' => is_ssl(),
|
||||
'fields' => array( 'banners' => true, 'reviews' => true )
|
||||
'fields' => array(
|
||||
'banners' => true,
|
||||
'reviews' => true,
|
||||
'downloaded' => false,
|
||||
'active_installs' => true
|
||||
)
|
||||
) );
|
||||
|
||||
if ( is_wp_error( $api ) ) {
|
||||
@@ -372,7 +396,7 @@ function install_plugin_information() {
|
||||
$section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English.
|
||||
if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) {
|
||||
$section_titles = array_keys( (array) $api->sections );
|
||||
$section = array_shift( $section_titles );
|
||||
$section = reset( $section_titles );
|
||||
}
|
||||
|
||||
iframe_header( __( 'Plugin Install' ) );
|
||||
@@ -421,6 +445,8 @@ function install_plugin_information() {
|
||||
|
||||
echo "</div>\n";
|
||||
|
||||
$date_format = __( 'M j, Y @ H:i' );
|
||||
$last_updated_timestamp = strtotime( $api->last_updated );
|
||||
?>
|
||||
<div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'>
|
||||
<div class="fyi">
|
||||
@@ -430,15 +456,21 @@ function install_plugin_information() {
|
||||
<?php } if ( ! empty( $api->author ) ) { ?>
|
||||
<li><strong><?php _e( 'Author:' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?></li>
|
||||
<?php } if ( ! empty( $api->last_updated ) ) { ?>
|
||||
<li><strong><?php _e( 'Last Updated:' ); ?></strong> <span title="<?php echo $api->last_updated; ?>">
|
||||
<?php printf( __( '%s ago' ), human_time_diff( strtotime( $api->last_updated ) ) ); ?>
|
||||
<li><strong><?php _e( 'Last Updated:' ); ?></strong> <span title="<?php echo esc_attr( date_i18n( $date_format, $last_updated_timestamp ) ); ?>">
|
||||
<?php printf( __( '%s ago' ), human_time_diff( $last_updated_timestamp ) ); ?>
|
||||
</span></li>
|
||||
<?php } if ( ! empty( $api->requires ) ) { ?>
|
||||
<li><strong><?php _e( 'Requires WordPress Version:' ); ?></strong> <?php printf( __( '%s or higher' ), $api->requires ); ?></li>
|
||||
<?php } if ( ! empty( $api->tested ) ) { ?>
|
||||
<li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li>
|
||||
<?php } if ( ! empty( $api->downloaded ) ) { ?>
|
||||
<li><strong><?php _e( 'Downloaded:' ); ?></strong> <?php printf( _n( '%s time', '%s times', $api->downloaded ), number_format_i18n( $api->downloaded ) ); ?></li>
|
||||
<?php } if ( ! empty( $api->active_installs ) ) { ?>
|
||||
<li><strong><?php _e( 'Active Installs:' ); ?></strong> <?php
|
||||
if ( $api->active_installs >= 1000000 ) {
|
||||
_ex( '1+ Million', 'Active plugin installs' );
|
||||
} else {
|
||||
echo number_format_i18n( $api->active_installs ) . '+';
|
||||
}
|
||||
?></li>
|
||||
<?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?>
|
||||
<li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page »' ); ?></a></li>
|
||||
<?php } if ( ! empty( $api->homepage ) ) { ?>
|
||||
@@ -459,13 +491,12 @@ function install_plugin_information() {
|
||||
$_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0;
|
||||
?>
|
||||
<div class="counter-container">
|
||||
<a href="<?php echo esc_url( self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $api->slug . '&section=reviews' ) ); ?>"
|
||||
title="<?php echo esc_attr( sprintf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $key ), $key ) ); ?>">
|
||||
<span class="counter-label"><?php printf( _n( '%d star', '%d stars', $key ), $key ); ?></span>
|
||||
<span class="counter-back">
|
||||
<span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span>
|
||||
</span>
|
||||
</a>
|
||||
<span class="counter-label"><a href="https://wordpress.org/support/view/plugin-reviews/<?php echo $api->slug; ?>?filter=<?php echo $key; ?>"
|
||||
target="_blank"
|
||||
title="<?php echo esc_attr( sprintf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $key ), $key ) ); ?>"><?php printf( _n( '%d star', '%d stars', $key ), $key ); ?></a></span>
|
||||
<span class="counter-back">
|
||||
<span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span>
|
||||
</span>
|
||||
<span class="counter-count"><?php echo number_format_i18n( $ratecount ); ?></span>
|
||||
</div>
|
||||
<?php
|
||||
@@ -499,9 +530,9 @@ function install_plugin_information() {
|
||||
<div id="section-holder" class="wrap">
|
||||
<?php
|
||||
if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
|
||||
echo '<div class="error"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>';
|
||||
} else if ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
|
||||
echo '<div class="error"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.') . '</p></div>';
|
||||
echo '<div class="notice notice-warning"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>';
|
||||
} elseif ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
|
||||
echo '<div class="notice notice-warning"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.') . '</p></div>';
|
||||
}
|
||||
|
||||
foreach ( (array) $api->sections as $section_name => $content ) {
|
||||
@@ -530,7 +561,7 @@ function install_plugin_information() {
|
||||
break;
|
||||
case 'update_available':
|
||||
if ( $status['url'] ) {
|
||||
echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) .'</a>';
|
||||
echo '<a data-slug="' . esc_attr( $api->slug ) . '" id="plugin_update_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) .'</a>';
|
||||
}
|
||||
break;
|
||||
case 'newer_installed':
|
||||
|
||||
+108
-94
@@ -14,39 +14,38 @@
|
||||
* must not have any newlines or only parts of the description will be displayed
|
||||
* and the same goes for the plugin data. The below is formatted for printing.
|
||||
*
|
||||
* <code>
|
||||
* /*
|
||||
* Plugin Name: Name of Plugin
|
||||
* Plugin URI: Link to plugin information
|
||||
* Description: Plugin Description
|
||||
* Author: Plugin author's name
|
||||
* Author URI: Link to the author's web site
|
||||
* Version: Must be set in the plugin for WordPress 2.3+
|
||||
* Text Domain: Optional. Unique identifier, should be same as the one used in
|
||||
* plugin_text_domain()
|
||||
* Domain Path: Optional. Only useful if the translations are located in a
|
||||
* folder above the plugin's base path. For example, if .mo files are
|
||||
* located in the locale folder then Domain Path will be "/locale/" and
|
||||
* must have the first slash. Defaults to the base folder the plugin is
|
||||
* located in.
|
||||
* Network: Optional. Specify "Network: true" to require that a plugin is activated
|
||||
* across all sites in an installation. This will prevent a plugin from being
|
||||
* activated on a single site when Multisite is enabled.
|
||||
* * / # Remove the space to close comment
|
||||
* </code>
|
||||
* /*
|
||||
* Plugin Name: Name of Plugin
|
||||
* Plugin URI: Link to plugin information
|
||||
* Description: Plugin Description
|
||||
* Author: Plugin author's name
|
||||
* Author URI: Link to the author's web site
|
||||
* Version: Must be set in the plugin for WordPress 2.3+
|
||||
* Text Domain: Optional. Unique identifier, should be same as the one used in
|
||||
* load_plugin_textdomain()
|
||||
* Domain Path: Optional. Only useful if the translations are located in a
|
||||
* folder above the plugin's base path. For example, if .mo files are
|
||||
* located in the locale folder then Domain Path will be "/locale/" and
|
||||
* must have the first slash. Defaults to the base folder the plugin is
|
||||
* located in.
|
||||
* Network: Optional. Specify "Network: true" to require that a plugin is activated
|
||||
* across all sites in an installation. This will prevent a plugin from being
|
||||
* activated on a single site when Multisite is enabled.
|
||||
* * / # Remove the space to close comment
|
||||
*
|
||||
* Plugin data returned array contains the following:
|
||||
* 'Name' - Name of the plugin, must be unique.
|
||||
* 'Title' - Title of the plugin and the link to the plugin's web site.
|
||||
* 'Description' - Description of what the plugin does and/or notes
|
||||
* from the author.
|
||||
* 'Author' - The author's name
|
||||
* 'AuthorURI' - The authors web site address.
|
||||
* 'Version' - The plugin version number.
|
||||
* 'PluginURI' - Plugin web site address.
|
||||
* 'TextDomain' - Plugin's text domain for localization.
|
||||
* 'DomainPath' - Plugin's relative directory path to .mo files.
|
||||
* 'Network' - Boolean. Whether the plugin can only be activated network wide.
|
||||
*
|
||||
* - 'Name' - Name of the plugin, must be unique.
|
||||
* - 'Title' - Title of the plugin and the link to the plugin's web site.
|
||||
* - 'Description' - Description of what the plugin does and/or notes
|
||||
* - from the author.
|
||||
* - 'Author' - The author's name
|
||||
* - 'AuthorURI' - The authors web site address.
|
||||
* - 'Version' - The plugin version number.
|
||||
* - 'PluginURI' - Plugin web site address.
|
||||
* - 'TextDomain' - Plugin's text domain for localization.
|
||||
* - 'DomainPath' - Plugin's relative directory path to .mo files.
|
||||
* - 'Network' - Boolean. Whether the plugin can only be activated network wide.
|
||||
*
|
||||
* Some users have issues with opening large files and manipulating the contents
|
||||
* for want is usually the first 1kiB or 2kiB. This function stops pulling in
|
||||
@@ -60,8 +59,9 @@
|
||||
* the file. This is not checked however and the file is only opened for
|
||||
* reading.
|
||||
*
|
||||
* @link http://trac.wordpress.org/ticket/5651 Previous Optimizations.
|
||||
* @link http://trac.wordpress.org/ticket/7372 Further and better Optimizations.
|
||||
* @link https://core.trac.wordpress.org/ticket/5651 Previous Optimizations.
|
||||
* @link https://core.trac.wordpress.org/ticket/7372 Further and better Optimizations.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param string $plugin_file Path to the plugin file
|
||||
@@ -533,7 +533,7 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen
|
||||
if ( is_wp_error($valid) )
|
||||
return $valid;
|
||||
|
||||
if ( !in_array($plugin, $current) ) {
|
||||
if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current ) ) ) {
|
||||
if ( !empty($redirect) )
|
||||
wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error
|
||||
ob_start();
|
||||
@@ -558,11 +558,11 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen
|
||||
do_action( 'activate_plugin', $plugin, $network_wide );
|
||||
|
||||
/**
|
||||
* Fires as a specific plugin is being deactivated.
|
||||
* Fires as a specific plugin is being activated.
|
||||
*
|
||||
* This hook is the "deactivation" hook used internally by
|
||||
* register_deactivation_hook(). The dynamic portion of the
|
||||
* hook name, $plugin. refers to the plugin basename.
|
||||
* This hook is the "activation" hook used internally by
|
||||
* {@see register_activation_hook()}. The dynamic portion of the
|
||||
* hook name, `$plugin`, refers to the plugin basename.
|
||||
*
|
||||
* If a plugin is silently activated (such as during an update),
|
||||
* this hook does not fire.
|
||||
@@ -674,8 +674,8 @@ function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
|
||||
* Fires as a specific plugin is being deactivated.
|
||||
*
|
||||
* This hook is the "deactivation" hook used internally by
|
||||
* register_deactivation_hook(). The dynamic portion of the
|
||||
* hook name, $plugin. refers to the plugin basename.
|
||||
* {@see register_deactivation_hook()}. The dynamic portion of the
|
||||
* hook name, `$plugin`, refers to the plugin basename.
|
||||
*
|
||||
* If a plugin is silently deactivated (such as during an update),
|
||||
* this hook does not fire.
|
||||
@@ -797,29 +797,47 @@ function delete_plugins( $plugins, $deprecated = '' ) {
|
||||
if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
|
||||
return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors);
|
||||
|
||||
//Get the base plugin folder
|
||||
// Get the base plugin folder.
|
||||
$plugins_dir = $wp_filesystem->wp_plugins_dir();
|
||||
if ( empty($plugins_dir) )
|
||||
return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.'));
|
||||
if ( empty( $plugins_dir ) ) {
|
||||
return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress Plugin directory.' ) );
|
||||
}
|
||||
|
||||
$plugins_dir = trailingslashit( $plugins_dir );
|
||||
|
||||
$plugin_translations = wp_get_installed_translations( 'plugins' );
|
||||
|
||||
$errors = array();
|
||||
|
||||
foreach( $plugins as $plugin_file ) {
|
||||
// Run Uninstall hook
|
||||
if ( is_uninstallable_plugin( $plugin_file ) )
|
||||
// Run Uninstall hook.
|
||||
if ( is_uninstallable_plugin( $plugin_file ) ) {
|
||||
uninstall_plugin($plugin_file);
|
||||
}
|
||||
|
||||
$this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin_file) );
|
||||
$this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) );
|
||||
// If plugin is in its own directory, recursively delete the directory.
|
||||
if ( strpos($plugin_file, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory separator AND that it's not the root plugin folder
|
||||
$deleted = $wp_filesystem->delete($this_plugin_dir, true);
|
||||
else
|
||||
$deleted = $wp_filesystem->delete($plugins_dir . $plugin_file);
|
||||
if ( strpos( $plugin_file, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder
|
||||
$deleted = $wp_filesystem->delete( $this_plugin_dir, true );
|
||||
} else {
|
||||
$deleted = $wp_filesystem->delete( $plugins_dir . $plugin_file );
|
||||
}
|
||||
|
||||
if ( ! $deleted )
|
||||
if ( ! $deleted ) {
|
||||
$errors[] = $plugin_file;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove language files, silently.
|
||||
$plugin_slug = dirname( $plugin_file );
|
||||
if ( '.' !== $plugin_slug && ! empty( $plugin_translations[ $plugin_slug ] ) ) {
|
||||
$translations = $plugin_translations[ $plugin_slug ];
|
||||
|
||||
foreach ( $translations as $translation => $data ) {
|
||||
$wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.po' );
|
||||
$wp_filesystem->delete( WP_LANG_DIR . '/plugins/' . $plugin_slug . '-' . $translation . '.mo' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove deleted plugins from the plugin updates list.
|
||||
@@ -863,7 +881,7 @@ function validate_active_plugins() {
|
||||
}
|
||||
|
||||
if ( empty( $plugins ) )
|
||||
return;
|
||||
return array();
|
||||
|
||||
$invalid = array();
|
||||
|
||||
@@ -1098,7 +1116,7 @@ function add_utility_page( $page_title, $menu_title, $capability, $menu_slug, $f
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
|
||||
* @param callback $function The function to be called to output the content for this page.
|
||||
*
|
||||
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
|
||||
global $submenu;
|
||||
@@ -1168,7 +1186,7 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability,
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
|
||||
* @param callback $function The function to be called to output the content for this page.
|
||||
*
|
||||
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
|
||||
return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function );
|
||||
@@ -1189,7 +1207,7 @@ function add_management_page( $page_title, $menu_title, $capability, $menu_slug,
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
|
||||
* @param callback $function The function to be called to output the content for this page.
|
||||
*
|
||||
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
|
||||
return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function );
|
||||
@@ -1210,7 +1228,7 @@ function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $f
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
|
||||
* @param callback $function The function to be called to output the content for this page.
|
||||
*
|
||||
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
|
||||
return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function );
|
||||
@@ -1231,7 +1249,7 @@ function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $fun
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
|
||||
* @param callback $function The function to be called to output the content for this page.
|
||||
*
|
||||
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
|
||||
return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function );
|
||||
@@ -1252,7 +1270,7 @@ function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $f
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
|
||||
* @param callback $function The function to be called to output the content for this page.
|
||||
*
|
||||
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
|
||||
if ( current_user_can('edit_users') )
|
||||
@@ -1276,7 +1294,7 @@ function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $fun
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
|
||||
* @param callback $function The function to be called to output the content for this page.
|
||||
*
|
||||
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
|
||||
return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function );
|
||||
@@ -1297,7 +1315,7 @@ function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug,
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
|
||||
* @param callback $function The function to be called to output the content for this page.
|
||||
*
|
||||
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
|
||||
return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function );
|
||||
@@ -1318,7 +1336,7 @@ function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $fun
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
|
||||
* @param callback $function The function to be called to output the content for this page.
|
||||
*
|
||||
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
|
||||
return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function );
|
||||
@@ -1339,7 +1357,7 @@ function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $fun
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
|
||||
* @param callback $function The function to be called to output the content for this page.
|
||||
*
|
||||
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
|
||||
return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function );
|
||||
@@ -1360,7 +1378,7 @@ function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $fun
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
|
||||
* @param callback $function The function to be called to output the content for this page.
|
||||
*
|
||||
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
|
||||
return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function );
|
||||
@@ -1381,7 +1399,7 @@ function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $fun
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
|
||||
* @param callback $function The function to be called to output the content for this page.
|
||||
*
|
||||
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
|
||||
return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function );
|
||||
@@ -1521,11 +1539,10 @@ function get_admin_page_parent( $parent = '' ) {
|
||||
} elseif ( $submenu_array[2] == $pagenow && empty($typenow) && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) {
|
||||
$parent_file = $parent;
|
||||
return $parent;
|
||||
} else
|
||||
if ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) {
|
||||
$parent_file = $parent;
|
||||
return $parent;
|
||||
}
|
||||
} elseif ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) {
|
||||
$parent_file = $parent;
|
||||
return $parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1555,11 +1572,10 @@ function get_admin_page_title() {
|
||||
if ( $menu_array[2] == $pagenow ) {
|
||||
$title = $menu_array[3];
|
||||
return $menu_array[3];
|
||||
} else
|
||||
if ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) {
|
||||
$title = $menu_array[3];
|
||||
return $menu_array[3];
|
||||
}
|
||||
} elseif ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) {
|
||||
$title = $menu_array[3];
|
||||
return $menu_array[3];
|
||||
}
|
||||
} else {
|
||||
$title = $menu_array[0];
|
||||
return $title;
|
||||
@@ -1626,12 +1642,12 @@ function get_plugin_page_hookname( $plugin_page, $parent_page ) {
|
||||
|
||||
$page_type = 'admin';
|
||||
if ( empty ( $parent_page ) || 'admin.php' == $parent_page || isset( $admin_page_hooks[$plugin_page] ) ) {
|
||||
if ( isset( $admin_page_hooks[$plugin_page] ) )
|
||||
if ( isset( $admin_page_hooks[$plugin_page] ) ) {
|
||||
$page_type = 'toplevel';
|
||||
else
|
||||
if ( isset( $admin_page_hooks[$parent] ))
|
||||
$page_type = $admin_page_hooks[$parent];
|
||||
} else if ( isset( $admin_page_hooks[$parent] ) ) {
|
||||
} elseif ( isset( $admin_page_hooks[$parent] )) {
|
||||
$page_type = $admin_page_hooks[$parent];
|
||||
}
|
||||
} elseif ( isset( $admin_page_hooks[$parent] ) ) {
|
||||
$page_type = $admin_page_hooks[$parent];
|
||||
}
|
||||
|
||||
@@ -1692,7 +1708,7 @@ function user_can_access_admin_page() {
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
} else if ( $submenu_array[2] == $pagenow ) {
|
||||
} elseif ( $submenu_array[2] == $pagenow ) {
|
||||
if ( current_user_can( $submenu_array[1] ))
|
||||
return true;
|
||||
else
|
||||
@@ -1723,8 +1739,7 @@ function user_can_access_admin_page() {
|
||||
* @param string $option_group A settings group name. Should correspond to a whitelisted option key name.
|
||||
* Default whitelisted option key names include "general," "discussion," and "reading," among others.
|
||||
* @param string $option_name The name of an option to sanitize and save.
|
||||
* @param unknown_type $sanitize_callback A callback function that sanitizes the option's value.
|
||||
* @return unknown
|
||||
* @param callable $sanitize_callback A callback function that sanitizes the option's value.
|
||||
*/
|
||||
function register_setting( $option_group, $option_name, $sanitize_callback = '' ) {
|
||||
global $new_whitelist_options;
|
||||
@@ -1749,10 +1764,9 @@ function register_setting( $option_group, $option_name, $sanitize_callback = ''
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param unknown_type $option_group
|
||||
* @param unknown_type $option_name
|
||||
* @param unknown_type $sanitize_callback
|
||||
* @return unknown
|
||||
* @param string $option_group
|
||||
* @param string $option_name
|
||||
* @param callable $sanitize_callback
|
||||
*/
|
||||
function unregister_setting( $option_group, $option_name, $sanitize_callback = '' ) {
|
||||
global $new_whitelist_options;
|
||||
@@ -1779,8 +1793,8 @@ function unregister_setting( $option_group, $option_name, $sanitize_callback = '
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param unknown_type $options
|
||||
* @return unknown
|
||||
* @param array $options
|
||||
* @return array
|
||||
*/
|
||||
function option_update_filter( $options ) {
|
||||
global $new_whitelist_options;
|
||||
@@ -1797,9 +1811,9 @@ add_filter( 'whitelist_options', 'option_update_filter' );
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param unknown_type $new_options
|
||||
* @param unknown_type $options
|
||||
* @return unknown
|
||||
* @param array $new_options
|
||||
* @param string|array $options
|
||||
* @return array
|
||||
*/
|
||||
function add_option_whitelist( $new_options, $options = '' ) {
|
||||
if ( $options == '' )
|
||||
@@ -1828,9 +1842,9 @@ function add_option_whitelist( $new_options, $options = '' ) {
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param unknown_type $del_options
|
||||
* @param unknown_type $options
|
||||
* @return unknown
|
||||
* @param array $del_options
|
||||
* @param string|array $options
|
||||
* @return array
|
||||
*/
|
||||
function remove_option_whitelist( $del_options, $options = '' ) {
|
||||
if ( $options == '' )
|
||||
|
||||
+158
-83
@@ -177,6 +177,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
|
||||
* @return int Post ID.
|
||||
*/
|
||||
function edit_post( $post_data = null ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( empty($post_data) )
|
||||
$post_data = &$_POST;
|
||||
@@ -313,11 +314,69 @@ function edit_post( $post_data = null ) {
|
||||
$post_data = apply_filters( 'attachment_fields_to_save', $post_data, $attachment_data );
|
||||
}
|
||||
|
||||
// Convert taxonomy input to term IDs, to avoid ambiguity.
|
||||
if ( isset( $post_data['tax_input'] ) ) {
|
||||
foreach ( (array) $post_data['tax_input'] as $taxonomy => $terms ) {
|
||||
// Hierarchical taxonomy data is already sent as term IDs, so no conversion is necessary.
|
||||
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Assume that a 'tax_input' string is a comma-separated list of term names.
|
||||
* Some languages may use a character other than a comma as a delimiter, so we standardize on
|
||||
* commas before parsing the list.
|
||||
*/
|
||||
if ( ! is_array( $terms ) ) {
|
||||
$comma = _x( ',', 'tag delimiter' );
|
||||
if ( ',' !== $comma ) {
|
||||
$terms = str_replace( $comma, ',', $terms );
|
||||
}
|
||||
$terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
|
||||
}
|
||||
|
||||
$clean_terms = array();
|
||||
foreach ( $terms as $term ) {
|
||||
// Empty terms are invalid input.
|
||||
if ( empty( $term ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$_term = get_terms( $taxonomy, array(
|
||||
'name' => $term,
|
||||
'fields' => 'ids',
|
||||
'hide_empty' => false,
|
||||
) );
|
||||
|
||||
if ( ! empty( $_term ) ) {
|
||||
$clean_terms[] = intval( $_term[0] );
|
||||
} else {
|
||||
// No existing term was found, so pass the string. A new term will be created.
|
||||
$clean_terms[] = $term;
|
||||
}
|
||||
}
|
||||
|
||||
$post_data['tax_input'][ $taxonomy ] = $clean_terms;
|
||||
}
|
||||
}
|
||||
|
||||
add_meta( $post_ID );
|
||||
|
||||
update_post_meta( $post_ID, '_edit_last', get_current_user_id() );
|
||||
|
||||
wp_update_post( $post_data );
|
||||
$success = wp_update_post( $post_data );
|
||||
// If the save failed, see if we can sanity check the main fields and try again
|
||||
if ( ! $success && is_callable( array( $wpdb, 'strip_invalid_text_for_column' ) ) ) {
|
||||
$fields = array( 'post_title', 'post_content', 'post_excerpt' );
|
||||
|
||||
foreach( $fields as $field ) {
|
||||
if ( isset( $post_data[ $field ] ) ) {
|
||||
$post_data[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->posts, $field, $post_data[ $field ] );
|
||||
}
|
||||
}
|
||||
|
||||
wp_update_post( $post_data );
|
||||
}
|
||||
|
||||
// Now that we have an ID we can fix any attachment anchor hrefs
|
||||
_fix_attachment_links( $post_ID );
|
||||
@@ -542,6 +601,7 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
|
||||
$post->post_date = '';
|
||||
$post->post_date_gmt = '';
|
||||
$post->post_password = '';
|
||||
$post->post_name = '';
|
||||
$post->post_type = $post_type;
|
||||
$post->post_status = 'draft';
|
||||
$post->to_ping = '';
|
||||
@@ -585,7 +645,6 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
|
||||
* @param WP_Post $post Post object.
|
||||
*/
|
||||
$post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
|
||||
$post->post_name = '';
|
||||
|
||||
return $post;
|
||||
}
|
||||
@@ -636,7 +695,7 @@ function post_exists($title, $content = '', $date = '') {
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @return unknown
|
||||
* @return int|WP_Error
|
||||
*/
|
||||
function wp_write_post() {
|
||||
if ( isset($_POST['post_type']) )
|
||||
@@ -704,11 +763,8 @@ function wp_write_post() {
|
||||
* Calls wp_write_post() and handles the errors.
|
||||
*
|
||||
* @since 2.0.0
|
||||
|
||||
* @uses wp_write_post()
|
||||
* @uses is_wp_error()
|
||||
* @uses wp_die()
|
||||
* @return unknown
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
function write_post() {
|
||||
$result = wp_write_post();
|
||||
@@ -723,12 +779,12 @@ function write_post() {
|
||||
//
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Add post meta data defined in $_POST superglobal for post with given ID.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @param unknown_type $post_ID
|
||||
* @return unknown
|
||||
* @param int $post_ID
|
||||
* @return int|bool
|
||||
*/
|
||||
function add_meta( $post_ID ) {
|
||||
$post_ID = (int) $post_ID;
|
||||
@@ -762,12 +818,12 @@ function add_meta( $post_ID ) {
|
||||
} // add_meta
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Delete post meta data by meta ID.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @param unknown_type $mid
|
||||
* @return unknown
|
||||
* @param int $mid
|
||||
* @return bool
|
||||
*/
|
||||
function delete_meta( $mid ) {
|
||||
return delete_metadata_by_mid( 'post' , $mid );
|
||||
@@ -778,7 +834,7 @@ function delete_meta( $mid ) {
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return unknown
|
||||
* @return mixed
|
||||
*/
|
||||
function get_meta_keys() {
|
||||
global $wpdb;
|
||||
@@ -793,26 +849,24 @@ function get_meta_keys() {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Get post meta data by meta ID.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param unknown_type $mid
|
||||
* @return unknown
|
||||
* @param int $mid
|
||||
* @return object|bool
|
||||
*/
|
||||
function get_post_meta_by_id( $mid ) {
|
||||
return get_metadata_by_mid( 'post', $mid );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
* Some postmeta stuff.
|
||||
* Get meta data for the given post ID.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @param unknown_type $postid
|
||||
* @return unknown
|
||||
* @param int $postid
|
||||
* @return mixed
|
||||
*/
|
||||
function has_meta( $postid ) {
|
||||
global $wpdb;
|
||||
@@ -823,14 +877,14 @@ function has_meta( $postid ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Update post meta data by meta ID.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @param unknown_type $meta_id
|
||||
* @param unknown_type $meta_key Expect Slashed
|
||||
* @param unknown_type $meta_value Expect Slashed
|
||||
* @return unknown
|
||||
* @param int $meta_id
|
||||
* @param string $meta_key Expect Slashed
|
||||
* @param string $meta_value Expect Slashed
|
||||
* @return bool
|
||||
*/
|
||||
function update_meta( $meta_id, $meta_key, $meta_value ) {
|
||||
$meta_key = wp_unslash( $meta_key );
|
||||
@@ -955,7 +1009,7 @@ function wp_edit_posts_query( $q = false ) {
|
||||
/**
|
||||
* Filter the number of items per page to show for a specific 'per_page' type.
|
||||
*
|
||||
* The dynamic portion of the hook name, $post_type, refers to the post type.
|
||||
* The dynamic portion of the hook name, `$post_type`, refers to the post type.
|
||||
*
|
||||
* Some examples of filter hooks generated here include: 'edit_attachment_per_page',
|
||||
* 'edit_post_per_page', 'edit_page_per_page', etc.
|
||||
@@ -985,6 +1039,7 @@ function wp_edit_posts_query( $q = false ) {
|
||||
$query['order'] = 'asc';
|
||||
$query['posts_per_page'] = -1;
|
||||
$query['posts_per_archive_page'] = -1;
|
||||
$query['fields'] = 'id=>parent';
|
||||
}
|
||||
|
||||
if ( ! empty( $q['show_sticky'] ) )
|
||||
@@ -996,12 +1051,12 @@ function wp_edit_posts_query( $q = false ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Get all available post MIME types for a given post type.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param unknown_type $type
|
||||
* @return unknown
|
||||
* @param string $type
|
||||
* @return mixed
|
||||
*/
|
||||
function get_available_post_mime_types($type = 'attachment') {
|
||||
global $wpdb;
|
||||
@@ -1011,32 +1066,34 @@ function get_available_post_mime_types($type = 'attachment') {
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a query for attachments. An array of WP_Query arguments
|
||||
* can be passed in, which will override the arguments set by this function.
|
||||
* Get the query variables for the current attachments request.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal.
|
||||
* @return array
|
||||
* @param array|false $q Optional. Array of query variables to use to build the query or false
|
||||
* to use $_GET superglobal. Default false.
|
||||
* @return array The parsed query vars.
|
||||
*/
|
||||
function wp_edit_attachments_query( $q = false ) {
|
||||
if ( false === $q )
|
||||
function wp_edit_attachments_query_vars( $q = false ) {
|
||||
if ( false === $q ) {
|
||||
$q = $_GET;
|
||||
|
||||
}
|
||||
$q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0;
|
||||
$q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
|
||||
$q['post_type'] = 'attachment';
|
||||
$post_type = get_post_type_object( 'attachment' );
|
||||
$states = 'inherit';
|
||||
if ( current_user_can( $post_type->cap->read_private_posts ) )
|
||||
if ( current_user_can( $post_type->cap->read_private_posts ) ) {
|
||||
$states .= ',private';
|
||||
}
|
||||
|
||||
$q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states;
|
||||
$q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' == $q['attachment-filter'] ? 'trash' : $states;
|
||||
|
||||
$media_per_page = (int) get_user_option( 'upload_per_page' );
|
||||
if ( empty( $media_per_page ) || $media_per_page < 1 )
|
||||
if ( empty( $media_per_page ) || $media_per_page < 1 ) {
|
||||
$media_per_page = 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the number of items to list per page when listing media items.
|
||||
@@ -1048,10 +1105,9 @@ function wp_edit_attachments_query( $q = false ) {
|
||||
$q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page );
|
||||
|
||||
$post_mime_types = get_post_mime_types();
|
||||
$avail_post_mime_types = get_available_post_mime_types('attachment');
|
||||
|
||||
if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) )
|
||||
if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) {
|
||||
unset($q['post_mime_type']);
|
||||
}
|
||||
|
||||
foreach( array_keys( $post_mime_types ) as $type ) {
|
||||
if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" == $q['attachment-filter'] ) {
|
||||
@@ -1064,20 +1120,35 @@ function wp_edit_attachments_query( $q = false ) {
|
||||
$q['post_parent'] = 0;
|
||||
}
|
||||
|
||||
wp( $q );
|
||||
return $q;
|
||||
}
|
||||
|
||||
return array($post_mime_types, $avail_post_mime_types);
|
||||
/**
|
||||
* Executes a query for attachments. An array of WP_Query arguments
|
||||
* can be passed in, which will override the arguments set by this function.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param array|false $q Array of query variables to use to build the query or false to use $_GET superglobal.
|
||||
* @return array
|
||||
*/
|
||||
function wp_edit_attachments_query( $q = false ) {
|
||||
wp( wp_edit_attachments_query_vars( $q ) );
|
||||
|
||||
$post_mime_types = get_post_mime_types();
|
||||
$avail_post_mime_types = get_available_post_mime_types( 'attachment' );
|
||||
|
||||
return array( $post_mime_types, $avail_post_mime_types );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of classes to be used by a metabox
|
||||
*
|
||||
* @uses get_user_option()
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param unknown_type $id
|
||||
* @param unknown_type $page
|
||||
* @return unknown
|
||||
* @param string $id
|
||||
* @param string $page
|
||||
* @return string
|
||||
*/
|
||||
function postbox_classes( $id, $page ) {
|
||||
if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id ) {
|
||||
@@ -1095,8 +1166,8 @@ function postbox_classes( $id, $page ) {
|
||||
/**
|
||||
* Filter the postbox classes for a specific screen and screen ID combo.
|
||||
*
|
||||
* The dynamic portions of the hook name, $page, and $id, refer to
|
||||
* the screen, and screen ID, respectively.
|
||||
* The dynamic portions of the hook name, `$page` and `$id`, refer to
|
||||
* the screen and screen ID, respectively.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
@@ -1107,14 +1178,14 @@ function postbox_classes( $id, $page ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Get a sample permalink based off of the post name.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param int|object $id Post ID or post object.
|
||||
* @param string $title (optional) Title
|
||||
* @param string $name (optional) Name
|
||||
* @return array With two entries of type string
|
||||
* @param int $id Post ID or post object.
|
||||
* @param string $title Optional. Title. Default null.
|
||||
* @param string $name Optional. Name. Default null.
|
||||
* @return array Array with two entries of type string.
|
||||
*/
|
||||
function get_sample_permalink($id, $title = null, $name = null) {
|
||||
$post = get_post( $id );
|
||||
@@ -1128,7 +1199,7 @@ function get_sample_permalink($id, $title = null, $name = null) {
|
||||
$original_name = $post->post_name;
|
||||
|
||||
// Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published.
|
||||
if ( in_array( $post->post_status, array( 'draft', 'pending' ) ) ) {
|
||||
if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ) ) ) {
|
||||
$post->post_status = 'publish';
|
||||
$post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);
|
||||
}
|
||||
@@ -1150,9 +1221,11 @@ function get_sample_permalink($id, $title = null, $name = null) {
|
||||
// Handle page hierarchy
|
||||
if ( $ptype->hierarchical ) {
|
||||
$uri = get_page_uri($post);
|
||||
$uri = untrailingslashit($uri);
|
||||
$uri = strrev( stristr( strrev( $uri ), '/' ) );
|
||||
$uri = untrailingslashit($uri);
|
||||
if ( $uri ) {
|
||||
$uri = untrailingslashit($uri);
|
||||
$uri = strrev( stristr( strrev( $uri ), '/' ) );
|
||||
$uri = untrailingslashit($uri);
|
||||
}
|
||||
|
||||
/** This filter is documented in wp-admin/edit-tag-form.php */
|
||||
$uri = apply_filters( 'editable_slug', $uri );
|
||||
@@ -1176,9 +1249,9 @@ function get_sample_permalink($id, $title = null, $name = null) {
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param int|object $id Post ID or post object.
|
||||
* @param string $new_title Optional. New title.
|
||||
* @param string $new_slug Optional. New slug.
|
||||
* @param int $id Post ID or post object.
|
||||
* @param string $new_title Optional. New title. Default null.
|
||||
* @param string $new_slug Optional. New slug. Default null.
|
||||
* @return string The HTML of the sample permalink slug editor.
|
||||
*/
|
||||
function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
|
||||
@@ -1220,7 +1293,8 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
|
||||
}
|
||||
|
||||
$post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';
|
||||
$display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, $permalink );
|
||||
$display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, urldecode( $permalink ) );
|
||||
$pretty_permalink = str_replace( array( '%pagename%', '%postname%' ), $post_name, urldecode( $permalink ) );
|
||||
|
||||
$return = '<strong>' . __( 'Permalink:' ) . "</strong>\n";
|
||||
$return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n";
|
||||
@@ -1236,7 +1310,11 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
|
||||
$preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
|
||||
$return .= "<span id='view-post-btn'><a href='" . esc_url( $preview_link ) . "' class='button button-small' target='wp-preview-{$post->ID}'>$view_post</a></span>\n";
|
||||
} else {
|
||||
$return .= "<span id='view-post-btn'><a href='" . get_permalink( $post ) . "' class='button button-small'>$view_post</a></span>\n";
|
||||
if ( empty( $pretty_permalink ) ) {
|
||||
$pretty_permalink = $permalink;
|
||||
}
|
||||
|
||||
$return .= "<span id='view-post-btn'><a href='" . $pretty_permalink . "' class='button button-small'>$view_post</a></span>\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1305,7 +1383,7 @@ function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param int $post_id ID of the post to check for editing
|
||||
* @return bool|int False: not locked or locked by current user. Int: user ID of user with lock.
|
||||
* @return integer False: not locked or locked by current user. Int: user ID of user with lock.
|
||||
*/
|
||||
function wp_check_post_lock( $post_id ) {
|
||||
if ( !$post = get_post( $post_id ) )
|
||||
@@ -1478,7 +1556,7 @@ function _admin_notice_post_locked() {
|
||||
<div class="post-locked-avatar"></div>
|
||||
<p class="wp-tab-first" tabindex="0">
|
||||
<span class="currently-editing"></span><br />
|
||||
<span class="locked-saving hidden"><img src="images/wpspin_light-2x.gif" width="16" height="16" /> <?php _e('Saving revision...'); ?></span>
|
||||
<span class="locked-saving hidden"><img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ); ?>" width="16" height="16" /> <?php _e('Saving revision...'); ?></span>
|
||||
<span class="locked-saved hidden"><?php _e('Your latest changes were saved as a revision.'); ?></span>
|
||||
</p>
|
||||
<?php
|
||||
@@ -1509,9 +1587,6 @@ function _admin_notice_post_locked() {
|
||||
* @subpackage Post_Revisions
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @uses _wp_translate_postdata()
|
||||
* @uses _wp_post_revision_fields()
|
||||
*
|
||||
* @param mixed $post_data Associative array containing the post data or int post ID.
|
||||
* @return mixed The autosave revision ID. WP_Error or 0 on error.
|
||||
*/
|
||||
@@ -1550,6 +1625,15 @@ function wp_create_post_autosave( $post_data ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires before an autosave is stored.
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param array $new_autosave Post array - the autosave that is about to be saved.
|
||||
*/
|
||||
do_action( 'wp_creating_autosave', $new_autosave );
|
||||
|
||||
return wp_update_post( $new_autosave );
|
||||
}
|
||||
|
||||
@@ -1566,15 +1650,6 @@ function wp_create_post_autosave( $post_data ) {
|
||||
* @package WordPress
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @uses get_post_status()
|
||||
* @uses edit_post()
|
||||
* @uses get_post()
|
||||
* @uses current_user_can()
|
||||
* @uses wp_die()
|
||||
* @uses wp_create_post_autosave()
|
||||
* @uses add_query_arg()
|
||||
* @uses wp_create_nonce()
|
||||
*
|
||||
* @return str URL to redirect to show the preview
|
||||
*/
|
||||
function post_preview() {
|
||||
@@ -1597,7 +1672,7 @@ function post_preview() {
|
||||
} else {
|
||||
$is_autosave = true;
|
||||
|
||||
if ( 'auto-draft' == $_POST['post_status'] )
|
||||
if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] )
|
||||
$_POST['post_status'] = 'draft';
|
||||
|
||||
$saved_post_id = wp_create_post_autosave( $post->ID );
|
||||
@@ -1629,7 +1704,7 @@ function post_preview() {
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param $post_data Associative array of the submitted post data.
|
||||
* @param array $post_data Associative array of the submitted post data.
|
||||
* @return mixed The value 0 or WP_Error on failure. The saved post ID on success.
|
||||
* Te ID can be the draft post_id or the autosave revision post_id.
|
||||
*/
|
||||
|
||||
@@ -58,7 +58,7 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
|
||||
/**
|
||||
* Contextually filter a post revision field.
|
||||
*
|
||||
* The dynamic portion of the hook name, $field, corresponds to each of the post
|
||||
* The dynamic portion of the hook name, `$field`, corresponds to each of the post
|
||||
* fields of the revision object being iterated over in a foreach statement.
|
||||
*
|
||||
* @since 3.6.0
|
||||
@@ -66,14 +66,38 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
|
||||
* @param string $compare_from->$field The current revision field to compare to or from.
|
||||
* @param string $field The current revision field.
|
||||
* @param WP_Post $compare_from The revision post object to compare to or from.
|
||||
* @param string null The context of whether the current revision is the old or the new one. Values are 'to' or 'from'.
|
||||
* @param string null The context of whether the current revision is the old
|
||||
* or the new one. Values are 'to' or 'from'.
|
||||
*/
|
||||
$content_from = $compare_from ? apply_filters( "_wp_post_revision_field_$field", $compare_from->$field, $field, $compare_from, 'from' ) : '';
|
||||
|
||||
/** This filter is documented in wp-admin/includes/revision.php */
|
||||
$content_to = apply_filters( "_wp_post_revision_field_$field", $compare_to->$field, $field, $compare_to, 'to' );
|
||||
|
||||
$diff = wp_text_diff( $content_from, $content_to, array( 'show_split_view' => true ) );
|
||||
$args = array(
|
||||
'show_split_view' => true
|
||||
);
|
||||
|
||||
/**
|
||||
* Filter revisions text diff options.
|
||||
*
|
||||
* Filter the options passed to {@see wp_text_diff()} when viewing a post revision.
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param array $args {
|
||||
* Associative array of options to pass to {@see wp_text_diff()}.
|
||||
*
|
||||
* @type bool $show_split_view True for split view (two columns), false for
|
||||
* un-split view (single column). Default true.
|
||||
* }
|
||||
* @param string $field The current revision field.
|
||||
* @param WP_Post $compare_from The revision post to compare from.
|
||||
* @param WP_Post $compare_to The revision post to compare to.
|
||||
*/
|
||||
$args = apply_filters( 'revision_text_diff_options', $args, $field, $compare_from, $compare_to );
|
||||
|
||||
$diff = wp_text_diff( $content_from, $content_to, $args );
|
||||
|
||||
if ( ! $diff && 'post_title' === $field ) {
|
||||
// It's a better user experience to still show the Title, even if it didn't change.
|
||||
@@ -92,7 +116,18 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
|
||||
);
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
|
||||
/**
|
||||
* Filter the fields displayed in the post revision diff UI.
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param array $return Revision UI fields. Each item is an array of id, name and diff.
|
||||
* @param WP_Post $compare_from The revision post to compare from.
|
||||
* @param WP_Post $compare_to The revision post to compare to.
|
||||
*/
|
||||
return apply_filters( 'wp_get_revision_ui_diff', $return, $compare_from, $compare_to );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,8 +203,8 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
|
||||
'id' => $revision->ID,
|
||||
'title' => get_the_title( $post->ID ),
|
||||
'author' => $authors[ $revision->post_author ],
|
||||
'date' => date_i18n( __( 'M j, Y @ G:i' ), $modified ),
|
||||
'dateShort' => date_i18n( _x( 'j M @ G:i', 'revision date short format' ), $modified ),
|
||||
'date' => date_i18n( __( 'M j, Y @ H:i' ), $modified ),
|
||||
'dateShort' => date_i18n( _x( 'j M @ H:i', 'revision date short format' ), $modified ),
|
||||
'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ),
|
||||
'autosave' => $autosave,
|
||||
'current' => $current,
|
||||
@@ -177,6 +212,25 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* If we only have one revision, the initial revision is missing; This happens
|
||||
* when we have an autsosave and the user has clicked 'View the Autosave'
|
||||
*/
|
||||
if ( 1 === sizeof( $revisions ) ) {
|
||||
$revisions[ $post->ID ] = array(
|
||||
'id' => $post->ID,
|
||||
'title' => get_the_title( $post->ID ),
|
||||
'author' => $authors[ $post->post_author ],
|
||||
'date' => date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_modified ) ),
|
||||
'dateShort' => date_i18n( _x( 'j M @ H:i', 'revision date short format' ), strtotime( $post->post_modified ) ),
|
||||
'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( strtotime( $post->post_modified_gmt ), $now_gmt ) ),
|
||||
'autosave' => false,
|
||||
'current' => true,
|
||||
'restoreUrl' => false,
|
||||
);
|
||||
$current_id = $post->ID;
|
||||
}
|
||||
|
||||
/*
|
||||
* If a post has been saved since the last revision (no revisioned fields
|
||||
* were changed), we may not have a "current" revision. Mark the latest
|
||||
@@ -226,3 +280,99 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
|
||||
'revisionIds' => array_keys( $revisions ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print JavaScript templates required for the revisions experience.
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @global WP_Post $post The global `$post` object.
|
||||
*/
|
||||
function wp_print_revision_templates() {
|
||||
global $post;
|
||||
?><script id="tmpl-revisions-frame" type="text/html">
|
||||
<div class="revisions-control-frame"></div>
|
||||
<div class="revisions-diff-frame"></div>
|
||||
</script>
|
||||
|
||||
<script id="tmpl-revisions-buttons" type="text/html">
|
||||
<div class="revisions-previous">
|
||||
<input class="button" type="button" value="<?php echo esc_attr_x( 'Previous', 'Button label for a previous revision' ); ?>" />
|
||||
</div>
|
||||
|
||||
<div class="revisions-next">
|
||||
<input class="button" type="button" value="<?php echo esc_attr_x( 'Next', 'Button label for a next revision' ); ?>" />
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script id="tmpl-revisions-checkbox" type="text/html">
|
||||
<div class="revision-toggle-compare-mode">
|
||||
<label>
|
||||
<input type="checkbox" class="compare-two-revisions"
|
||||
<#
|
||||
if ( 'undefined' !== typeof data && data.model.attributes.compareTwoMode ) {
|
||||
#> checked="checked"<#
|
||||
}
|
||||
#>
|
||||
/>
|
||||
<?php esc_attr_e( 'Compare any two revisions' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script id="tmpl-revisions-meta" type="text/html">
|
||||
<# if ( ! _.isUndefined( data.attributes ) ) { #>
|
||||
<div class="diff-title">
|
||||
<# if ( 'from' === data.type ) { #>
|
||||
<strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
|
||||
<# } else if ( 'to' === data.type ) { #>
|
||||
<strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
|
||||
<# } #>
|
||||
<div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>">
|
||||
{{{ data.attributes.author.avatar }}}
|
||||
<div class="author-info">
|
||||
<# if ( data.attributes.autosave ) { #>
|
||||
<span class="byline"><?php printf( __( 'Autosave by %s' ),
|
||||
'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
|
||||
<# } else if ( data.attributes.current ) { #>
|
||||
<span class="byline"><?php printf( __( 'Current Revision by %s' ),
|
||||
'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
|
||||
<# } else { #>
|
||||
<span class="byline"><?php printf( __( 'Revision by %s' ),
|
||||
'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
|
||||
<# } #>
|
||||
<span class="time-ago">{{ data.attributes.timeAgo }}</span>
|
||||
<span class="date">({{ data.attributes.dateShort }})</span>
|
||||
</div>
|
||||
<# if ( 'to' === data.type && data.attributes.restoreUrl ) { #>
|
||||
<input <?php if ( wp_check_post_lock( $post->ID ) ) { ?>
|
||||
disabled="disabled"
|
||||
<?php } else { ?>
|
||||
<# if ( data.attributes.current ) { #>
|
||||
disabled="disabled"
|
||||
<# } #>
|
||||
<?php } ?>
|
||||
<# if ( data.attributes.autosave ) { #>
|
||||
type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" />
|
||||
<# } else { #>
|
||||
type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />
|
||||
<# } #>
|
||||
<# } #>
|
||||
</div>
|
||||
<# if ( 'tooltip' === data.type ) { #>
|
||||
<div class="revisions-tooltip-arrow"><span></span></div>
|
||||
<# } #>
|
||||
<# } #>
|
||||
</script>
|
||||
|
||||
<script id="tmpl-revisions-diff" type="text/html">
|
||||
<div class="loading-indicator"><span class="spinner"></span></div>
|
||||
<div class="diff-error"><?php _e( 'Sorry, something went wrong. The requested comparison could not be loaded.' ); ?></div>
|
||||
<div class="diff">
|
||||
<# _.each( data.fields, function( field ) { #>
|
||||
<h3>{{ field.name }}</h3>
|
||||
{{{ field.diff }}}
|
||||
<# }); #>
|
||||
</div>
|
||||
</script><?php
|
||||
}
|
||||
@@ -44,6 +44,13 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
|
||||
// Engage multisite if in the middle of turning it on from network.php.
|
||||
$is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK );
|
||||
|
||||
/*
|
||||
* Indexes have a maximum size of 767 bytes. Historically, we haven't need to be concerned about that.
|
||||
* As of 4.2, however, we moved to utf8mb4, which uses 4 bytes per character. This means that an index which
|
||||
* used to have room for floor(767/3) = 255 characters, now only has room for floor(767/4) = 191 characters.
|
||||
*/
|
||||
$max_index_length = 191;
|
||||
|
||||
// Blog specific tables.
|
||||
$blog_tables = "CREATE TABLE $wpdb->terms (
|
||||
term_id bigint(20) unsigned NOT NULL auto_increment,
|
||||
@@ -51,8 +58,8 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
|
||||
slug varchar(200) NOT NULL default '',
|
||||
term_group bigint(10) NOT NULL default 0,
|
||||
PRIMARY KEY (term_id),
|
||||
UNIQUE KEY slug (slug),
|
||||
KEY name (name)
|
||||
KEY slug (slug($max_index_length)),
|
||||
KEY name (name($max_index_length))
|
||||
) $charset_collate;
|
||||
CREATE TABLE $wpdb->term_taxonomy (
|
||||
term_taxonomy_id bigint(20) unsigned NOT NULL auto_increment,
|
||||
@@ -79,7 +86,7 @@ CREATE TABLE $wpdb->commentmeta (
|
||||
meta_value longtext,
|
||||
PRIMARY KEY (meta_id),
|
||||
KEY comment_id (comment_id),
|
||||
KEY meta_key (meta_key)
|
||||
KEY meta_key (meta_key($max_index_length))
|
||||
) $charset_collate;
|
||||
CREATE TABLE $wpdb->comments (
|
||||
comment_ID bigint(20) unsigned NOT NULL auto_increment,
|
||||
@@ -136,7 +143,7 @@ CREATE TABLE $wpdb->postmeta (
|
||||
meta_value longtext,
|
||||
PRIMARY KEY (meta_id),
|
||||
KEY post_id (post_id),
|
||||
KEY meta_key (meta_key)
|
||||
KEY meta_key (meta_key($max_index_length))
|
||||
) $charset_collate;
|
||||
CREATE TABLE $wpdb->posts (
|
||||
ID bigint(20) unsigned NOT NULL auto_increment,
|
||||
@@ -163,7 +170,7 @@ CREATE TABLE $wpdb->posts (
|
||||
post_mime_type varchar(100) NOT NULL default '',
|
||||
comment_count bigint(20) NOT NULL default '0',
|
||||
PRIMARY KEY (ID),
|
||||
KEY post_name (post_name),
|
||||
KEY post_name (post_name($max_index_length)),
|
||||
KEY type_status_date (post_type,post_status,post_date,ID),
|
||||
KEY post_parent (post_parent),
|
||||
KEY post_author (post_author)
|
||||
@@ -213,7 +220,7 @@ CREATE TABLE $wpdb->posts (
|
||||
meta_value longtext,
|
||||
PRIMARY KEY (umeta_id),
|
||||
KEY user_id (user_id),
|
||||
KEY meta_key (meta_key)
|
||||
KEY meta_key (meta_key($max_index_length))
|
||||
) $charset_collate;\n";
|
||||
|
||||
// Global tables
|
||||
@@ -261,7 +268,7 @@ CREATE TABLE $wpdb->site (
|
||||
domain varchar(200) NOT NULL default '',
|
||||
path varchar(100) NOT NULL default '',
|
||||
PRIMARY KEY (id),
|
||||
KEY domain (domain,path)
|
||||
KEY domain (domain(140),path(51))
|
||||
) $charset_collate;
|
||||
CREATE TABLE $wpdb->sitemeta (
|
||||
meta_id bigint(20) NOT NULL auto_increment,
|
||||
@@ -269,7 +276,7 @@ CREATE TABLE $wpdb->sitemeta (
|
||||
meta_key varchar(255) default NULL,
|
||||
meta_value longtext,
|
||||
PRIMARY KEY (meta_id),
|
||||
KEY meta_key (meta_key),
|
||||
KEY meta_key (meta_key($max_index_length)),
|
||||
KEY site_id (site_id)
|
||||
) $charset_collate;
|
||||
CREATE TABLE $wpdb->signups (
|
||||
@@ -288,7 +295,7 @@ CREATE TABLE $wpdb->signups (
|
||||
KEY activation_key (activation_key),
|
||||
KEY user_email (user_email),
|
||||
KEY user_login_email (user_login,user_email),
|
||||
KEY domain_path (domain,path)
|
||||
KEY domain_path (domain(140),path(51))
|
||||
) $charset_collate;";
|
||||
|
||||
switch ( $scope ) {
|
||||
@@ -324,7 +331,8 @@ $wp_queries = wp_get_db_schema( 'all' );
|
||||
* Create WordPress options and set the default values.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @uses $wpdb
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
* @uses $wp_db_version
|
||||
*/
|
||||
function populate_options() {
|
||||
@@ -909,12 +917,13 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
|
||||
$site_admins = get_site_option( 'site_admins' );
|
||||
}
|
||||
|
||||
$welcome_email = __( 'Dear User,
|
||||
$welcome_email = __( 'Howdy USERNAME,
|
||||
|
||||
Your new SITE_NAME site has been successfully set up at:
|
||||
BLOG_URL
|
||||
|
||||
You can log in to the administrator account with the following information:
|
||||
|
||||
Username: USERNAME
|
||||
Password: PASSWORD
|
||||
Log in here: BLOG_URLwp-login.php
|
||||
|
||||
@@ -25,7 +25,7 @@ function get_column_headers( $screen ) {
|
||||
/**
|
||||
* Filter the column headers for a list table on a specific screen.
|
||||
*
|
||||
* The dynamic portion of the hook name, $screen->id, refers to the
|
||||
* The dynamic portion of the hook name, `$screen->id`, refers to the
|
||||
* ID of a specific screen. For example, the screen ID for the Posts
|
||||
* list table is edit-post, so the filter for that screen would be
|
||||
* manage_edit-post_columns.
|
||||
@@ -60,7 +60,7 @@ function get_hidden_columns( $screen ) {
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string|WP_Screen $screen
|
||||
* @param WP_Screen $screen
|
||||
*/
|
||||
function meta_box_prefs( $screen ) {
|
||||
global $wp_meta_boxes;
|
||||
@@ -177,7 +177,6 @@ function get_current_screen() {
|
||||
* Set the current screen object
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @uses $current_screen
|
||||
*
|
||||
* @param mixed $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen,
|
||||
* or an existing screen object.
|
||||
@@ -369,14 +368,15 @@ final class WP_Screen {
|
||||
* @since 3.3.0
|
||||
* @access public
|
||||
*
|
||||
* @param string $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen.
|
||||
* @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen.
|
||||
* Defaults to the current $hook_suffix global.
|
||||
* @return WP_Screen Screen object.
|
||||
*/
|
||||
public static function get( $hook_name = '' ) {
|
||||
|
||||
if ( is_a( $hook_name, 'WP_Screen' ) )
|
||||
if ( $hook_name instanceof WP_Screen ) {
|
||||
return $hook_name;
|
||||
}
|
||||
|
||||
$post_type = $taxonomy = null;
|
||||
$in_admin = false;
|
||||
@@ -648,8 +648,10 @@ final class WP_Screen {
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param string $option Option ID.
|
||||
* @param mixed $key Optional. Specific array key for when the option is an array.
|
||||
* @param string $option Option name.
|
||||
* @param string $key Optional. Specific array key for when the option is an array.
|
||||
* Default false.
|
||||
* @return string The option value if set, null otherwise.
|
||||
*/
|
||||
public function get_option( $option, $key = false ) {
|
||||
if ( ! isset( $this->_options[ $option ] ) )
|
||||
@@ -974,7 +976,7 @@ final class WP_Screen {
|
||||
case 'post' :
|
||||
$expand = '<div class="editor-expand hidden"><label for="editor-expand-toggle">';
|
||||
$expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';
|
||||
$expand .= __( 'Expand the editor to match the window height.' ) . '</label></div>';
|
||||
$expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></div>';
|
||||
$this->_screen_settings = $expand;
|
||||
break;
|
||||
default:
|
||||
@@ -1024,7 +1026,7 @@ final class WP_Screen {
|
||||
|
||||
?>
|
||||
<div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="<?php esc_attr_e('Screen Options Tab'); ?>">
|
||||
<form id="adv-settings" action="" method="post">
|
||||
<form id="adv-settings" method="post">
|
||||
<?php if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page' ) || ( $columns && empty( $columns['_title'] ) ) ) : ?>
|
||||
<h5><?php _e( 'Show on screen' ); ?></h5>
|
||||
<?php
|
||||
@@ -1125,20 +1127,26 @@ final class WP_Screen {
|
||||
* @since 3.3.0
|
||||
*/
|
||||
public function render_per_page_options() {
|
||||
if ( ! $this->get_option( 'per_page' ) )
|
||||
if ( null === $this->get_option( 'per_page' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$per_page_label = $this->get_option( 'per_page', 'label' );
|
||||
if ( null === $per_page_label ) {
|
||||
$per_page_label = __( 'Number of items per page:' );
|
||||
}
|
||||
|
||||
$option = $this->get_option( 'per_page', 'option' );
|
||||
if ( ! $option )
|
||||
if ( ! $option ) {
|
||||
$option = str_replace( '-', '_', "{$this->id}_per_page" );
|
||||
}
|
||||
|
||||
$per_page = (int) get_user_option( $option );
|
||||
if ( empty( $per_page ) || $per_page < 1 ) {
|
||||
$per_page = $this->get_option( 'per_page', 'default' );
|
||||
if ( ! $per_page )
|
||||
if ( ! $per_page ) {
|
||||
$per_page = 20;
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'edit_comments_per_page' == $option ) {
|
||||
@@ -1163,16 +1171,14 @@ final class WP_Screen {
|
||||
?>
|
||||
<div class="screen-options">
|
||||
<?php if ( $per_page_label ) : ?>
|
||||
<label for="<?php echo esc_attr( $option ); ?>"><?php echo $per_page_label; ?></label>
|
||||
<input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]"
|
||||
id="<?php echo esc_attr( $option ); ?>" maxlength="3"
|
||||
value="<?php echo esc_attr( $per_page ); ?>" />
|
||||
<label for="<?php echo esc_attr( $option ); ?>">
|
||||
<?php echo esc_html( $per_page_label ); ?>
|
||||
</label>
|
||||
<?php endif;
|
||||
|
||||
echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?>
|
||||
<input type='hidden' name='wp_screen_options[option]' value='<?php echo esc_attr($option); ?>' />
|
||||
<input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" />
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -11,14 +11,17 @@
|
||||
//
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Check whether a category exists.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param unknown_type $cat_name
|
||||
* @return unknown
|
||||
* @see term_exists()
|
||||
*
|
||||
* @param int|string $cat_name Category name.
|
||||
* @param int $parent Optional. ID of parent term.
|
||||
* @return mixed
|
||||
*/
|
||||
function category_exists($cat_name, $parent = 0) {
|
||||
function category_exists( $cat_name, $parent = null ) {
|
||||
$id = term_exists($cat_name, 'category', $parent);
|
||||
if ( is_array($id) )
|
||||
$id = $id['term_id'];
|
||||
@@ -26,12 +29,12 @@ function category_exists($cat_name, $parent = 0) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Get category object for given ID and 'edit' filter context.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param unknown_type $id
|
||||
* @return unknown
|
||||
* @param int $id
|
||||
* @return object
|
||||
*/
|
||||
function get_category_to_edit( $id ) {
|
||||
$category = get_term( $id, 'category', OBJECT, 'edit' );
|
||||
@@ -40,13 +43,13 @@ function get_category_to_edit( $id ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Add a new category to the database if it does not already exist.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param unknown_type $cat_name
|
||||
* @param unknown_type $parent
|
||||
* @return unknown
|
||||
* @param int|string $cat_name
|
||||
* @param int $parent
|
||||
* @return int|WP_Error
|
||||
*/
|
||||
function wp_create_category( $cat_name, $parent = 0 ) {
|
||||
if ( $id = category_exists($cat_name, $parent) )
|
||||
@@ -66,12 +69,12 @@ function wp_create_category( $cat_name, $parent = 0 ) {
|
||||
*/
|
||||
function wp_create_categories( $categories, $post_id = '' ) {
|
||||
$cat_ids = array ();
|
||||
foreach ($categories as $category) {
|
||||
if ($id = category_exists($category))
|
||||
foreach ( $categories as $category ) {
|
||||
if ( $id = category_exists( $category ) ) {
|
||||
$cat_ids[] = $id;
|
||||
else
|
||||
if ($id = wp_create_category($category))
|
||||
$cat_ids[] = $id;
|
||||
} elseif ( $id = wp_create_category( $category ) ) {
|
||||
$cat_ids[] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $post_id )
|
||||
@@ -186,48 +189,50 @@ function wp_update_category($catarr) {
|
||||
//
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Check whether a post tag with a given name exists.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param unknown_type $tag_name
|
||||
* @return unknown
|
||||
* @param int|string $tag_name
|
||||
* @return mixed
|
||||
*/
|
||||
function tag_exists($tag_name) {
|
||||
return term_exists($tag_name, 'post_tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Add a new tag to the database if it does not already exist.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param unknown_type $tag_name
|
||||
* @return unknown
|
||||
* @param int|string $tag_name
|
||||
* @return array|WP_Error
|
||||
*/
|
||||
function wp_create_tag($tag_name) {
|
||||
return wp_create_term( $tag_name, 'post_tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Get comma-separated list of tags available to edit.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param unknown_type $post_id
|
||||
* @return unknown
|
||||
* @param int $post_id
|
||||
* @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
|
||||
* @return string|bool|WP_Error
|
||||
*/
|
||||
function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) {
|
||||
return get_terms_to_edit( $post_id, $taxonomy);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Get comma-separated list of terms available to edit for the given post ID.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param unknown_type $post_id
|
||||
* @return unknown
|
||||
* @param int $post_id
|
||||
* @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
|
||||
* @return string|bool|WP_Error
|
||||
*/
|
||||
function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {
|
||||
$post_id = (int) $post_id;
|
||||
@@ -269,12 +274,13 @@ function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Add a new term to the database if it does not already exist.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param unknown_type $tag_name
|
||||
* @return unknown
|
||||
* @param int|string $tag_name
|
||||
* @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
|
||||
* @return array|WP_Error
|
||||
*/
|
||||
function wp_create_term($tag_name, $taxonomy = 'post_tag') {
|
||||
if ( $id = term_exists($tag_name, $taxonomy) )
|
||||
|
||||
+269
-178
@@ -13,12 +13,13 @@
|
||||
//
|
||||
|
||||
/**
|
||||
* Walker to output an unordered list of category checkbox <input> elements.
|
||||
* Walker to output an unordered list of category checkbox input elements.
|
||||
*
|
||||
* @since 2.5.1
|
||||
*
|
||||
* @see Walker
|
||||
* @see wp_category_checklist()
|
||||
* @see wp_terms_checklist()
|
||||
* @since 2.5.1
|
||||
*/
|
||||
class Walker_Category_Checklist extends Walker {
|
||||
public $tree_type = 'category';
|
||||
@@ -81,17 +82,33 @@ class Walker_Category_Checklist extends Walker {
|
||||
} else {
|
||||
$name = 'tax_input[' . $taxonomy . ']';
|
||||
}
|
||||
|
||||
$args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
|
||||
$class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
|
||||
|
||||
$args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
|
||||
|
||||
/** This filter is documented in wp-includes/category-template.php */
|
||||
$output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
|
||||
'<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' .
|
||||
checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) .
|
||||
disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
|
||||
esc_html( apply_filters( 'the_category', $category->name ) ) . '</label>';
|
||||
if ( ! empty( $args['list_only'] ) ) {
|
||||
$aria_cheched = 'false';
|
||||
$inner_class = 'category';
|
||||
|
||||
if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
|
||||
$inner_class .= ' selected';
|
||||
$aria_cheched = 'true';
|
||||
}
|
||||
|
||||
$output .= "\n" . '<li' . $class . '>' .
|
||||
'<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
|
||||
' tabindex="0" role="checkbox" aria-checked="' . $aria_cheched . '">' .
|
||||
esc_html( apply_filters( 'the_category', $category->name ) ) . '</div>';
|
||||
} else {
|
||||
$output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
|
||||
'<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' .
|
||||
checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) .
|
||||
disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
|
||||
esc_html( apply_filters( 'the_category', $category->name ) ) . '</label>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,18 +129,23 @@ class Walker_Category_Checklist extends Walker {
|
||||
}
|
||||
|
||||
/**
|
||||
* Output an unordered list of checkbox <input> elements labelled
|
||||
* with category names.
|
||||
* Output an unordered list of checkbox input elements labeled with category names.
|
||||
*
|
||||
* @see wp_terms_checklist()
|
||||
* @since 2.5.1
|
||||
*
|
||||
* @param int $post_id Mark categories associated with this post as checked. $selected_cats must not be an array.
|
||||
* @param int $descendants_and_self ID of the category to output along with its descendents.
|
||||
* @param bool|array $selected_cats List of categories to mark as checked.
|
||||
* @param bool|array $popular_cats Override the list of categories that receive the "popular-category" class.
|
||||
* @param object $walker Walker object to use to build the output.
|
||||
* @param bool $checked_ontop Move checked items out of the hierarchy and to the top of the list.
|
||||
* @see wp_terms_checklist()
|
||||
*
|
||||
* @param int $post_id Optional. Post to generate a categories checklist for. Default 0.
|
||||
* $selected_cats must not be an array. Default 0.
|
||||
* @param int $descendants_and_self Optional. ID of the category to output along with its descendants.
|
||||
* Default 0.
|
||||
* @param array $selected_cats Optional. List of categories to mark as checked. Default false.
|
||||
* @param array $popular_cats Optional. List of categories to receive the "popular-category" class.
|
||||
* Default false.
|
||||
* @param object $walker Optional. Walker object to use to build the output.
|
||||
* Default is a Walker_Category_Checklist instance.
|
||||
* @param bool $checked_ontop Optional. Whether to move checked items out of the hierarchy and to
|
||||
* the top of the list. Default true.
|
||||
*/
|
||||
function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
|
||||
wp_terms_checklist( $post_id, array(
|
||||
@@ -137,13 +159,27 @@ function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $select
|
||||
}
|
||||
|
||||
/**
|
||||
* Output an unordered list of checkbox <input> elements labelled
|
||||
* with term names. Taxonomy independent version of wp_category_checklist().
|
||||
* Output an unordered list of checkbox input elements labelled with term names.
|
||||
*
|
||||
* Taxonomy-independent version of wp_category_checklist().
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param int $post_id
|
||||
* @param array $args
|
||||
* @param int $post_id Optional. Post ID. Default 0.
|
||||
* @param array|string $args {
|
||||
* Optional. Array or string of arguments for generating a terms checklist. Default empty array.
|
||||
*
|
||||
* @type int $descendants_and_self ID of the category to output along with its descendants.
|
||||
* Default 0.
|
||||
* @type array $selected_cats List of categories to mark as checked. Default false.
|
||||
* @type array $popular_cats List of categories to receive the "popular-category" class.
|
||||
* Default false.
|
||||
* @type object $walker Walker object to use to build the output.
|
||||
* Default is a Walker_Category_Checklist instance.
|
||||
* @type string $taxonomy Taxonomy to generate the checklist for. Default 'category'.
|
||||
* @type bool $checked_ontop Whether to move checked items out of the hierarchy and to
|
||||
* the top of the list. Default true.
|
||||
* }
|
||||
*/
|
||||
function wp_terms_checklist( $post_id = 0, $args = array() ) {
|
||||
$defaults = array(
|
||||
@@ -169,7 +205,7 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
|
||||
|
||||
$r = wp_parse_args( $params, $defaults );
|
||||
|
||||
if ( empty( $r['walker'] ) || ! is_a( $r['walker'], 'Walker' ) ) {
|
||||
if ( empty( $r['walker'] ) || ! ( $r['walker'] instanceof Walker ) ) {
|
||||
$walker = new Walker_Category_Checklist;
|
||||
} else {
|
||||
$walker = $r['walker'];
|
||||
@@ -183,6 +219,8 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
|
||||
$tax = get_taxonomy( $taxonomy );
|
||||
$args['disabled'] = ! current_user_can( $tax->cap->assign_terms );
|
||||
|
||||
$args['list_only'] = ! empty( $r['list_only'] );
|
||||
|
||||
if ( is_array( $r['selected_cats'] ) ) {
|
||||
$args['selected_cats'] = $r['selected_cats'];
|
||||
} elseif ( $post_id ) {
|
||||
@@ -236,14 +274,14 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
|
||||
* Retrieve a list of the most popular terms from the specified taxonomy.
|
||||
*
|
||||
* If the $echo argument is true then the elements for a list of checkbox
|
||||
* <input> elements labelled with the names of the selected terms is output.
|
||||
* `<input>` elements labelled with the names of the selected terms is output.
|
||||
* If the $post_ID global isn't empty then the terms associated with that
|
||||
* post will be marked as checked.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $taxonomy Taxonomy to retrieve terms from.
|
||||
* @param int $default Unused.
|
||||
* @param int $default Not used.
|
||||
* @param int $number Number of terms to retrieve. Defaults to 10.
|
||||
* @param bool $echo Optionally output the list as well. Defaults to true.
|
||||
* @return array List of popular term IDs.
|
||||
@@ -289,16 +327,19 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ech
|
||||
*
|
||||
* @since 2.5.1
|
||||
*
|
||||
* @param unknown_type $link_id
|
||||
* @param int $link_id
|
||||
*/
|
||||
function wp_link_category_checklist( $link_id = 0 ) {
|
||||
$default = 1;
|
||||
|
||||
$checked_categories = array();
|
||||
|
||||
if ( $link_id ) {
|
||||
$checked_categories = wp_get_link_cats( $link_id );
|
||||
// No selected categories, strange
|
||||
if ( ! count( $checked_categories ) )
|
||||
if ( ! count( $checked_categories ) ) {
|
||||
$checked_categories[] = $default;
|
||||
}
|
||||
} else {
|
||||
$checked_categories[] = $default;
|
||||
}
|
||||
@@ -318,13 +359,12 @@ function wp_link_category_checklist( $link_id = 0 ) {
|
||||
}
|
||||
}
|
||||
|
||||
// adds hidden fields with the data for use in the inline editor for posts and pages
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Adds hidden fields with the data for use in the inline editor for posts and pages.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param unknown_type $post
|
||||
* @param WP_Post $post Post object.
|
||||
*/
|
||||
function get_inline_data($post) {
|
||||
$post_type_object = get_post_type_object($post->post_type);
|
||||
@@ -396,12 +436,13 @@ function get_inline_data($post) {
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param unknown_type $position
|
||||
* @param unknown_type $checkbox
|
||||
* @param unknown_type $mode
|
||||
* @param int $position
|
||||
* @param bool $checkbox
|
||||
* @param string $mode
|
||||
* @param bool $table_row
|
||||
*/
|
||||
function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
|
||||
|
||||
function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $table_row = true ) {
|
||||
global $wp_list_table;
|
||||
/**
|
||||
* Filter the in-line comment reply-to form output in the Comments
|
||||
* list table.
|
||||
@@ -424,14 +465,16 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single',
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $mode == 'single' ) {
|
||||
$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
|
||||
} else {
|
||||
$wp_list_table = _get_list_table('WP_Comments_List_Table');
|
||||
if ( ! $wp_list_table ) {
|
||||
if ( $mode == 'single' ) {
|
||||
$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
|
||||
} else {
|
||||
$wp_list_table = _get_list_table('WP_Comments_List_Table');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<form method="get" action="">
|
||||
<form method="get">
|
||||
<?php if ( $table_row ) : ?>
|
||||
<table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange">
|
||||
<?php else : ?>
|
||||
@@ -475,7 +518,6 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single',
|
||||
<br class="clear" />
|
||||
</p>
|
||||
|
||||
<input type="hidden" name="user_ID" id="user_ID" value="<?php echo get_current_user_id(); ?>" />
|
||||
<input type="hidden" name="action" id="action" value="" />
|
||||
<input type="hidden" name="comment_ID" id="comment_ID" value="" />
|
||||
<input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
|
||||
@@ -518,7 +560,7 @@ function wp_comment_trashnotice() {
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @param unknown_type $meta
|
||||
* @param array $meta
|
||||
*/
|
||||
function list_meta( $meta ) {
|
||||
// Exit if no meta
|
||||
@@ -561,25 +603,21 @@ function list_meta( $meta ) {
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param unknown_type $entry
|
||||
* @param unknown_type $count
|
||||
* @return unknown
|
||||
* @param array $entry
|
||||
* @param int $count
|
||||
* @return string
|
||||
*/
|
||||
function _list_meta_row( $entry, &$count ) {
|
||||
static $update_nonce = false;
|
||||
|
||||
if ( is_protected_meta( $entry['meta_key'], 'post' ) )
|
||||
return;
|
||||
return '';
|
||||
|
||||
if ( !$update_nonce )
|
||||
$update_nonce = wp_create_nonce( 'add-meta' );
|
||||
|
||||
$r = '';
|
||||
++ $count;
|
||||
if ( $count % 2 )
|
||||
$style = 'alternate';
|
||||
else
|
||||
$style = '';
|
||||
|
||||
if ( is_serialized( $entry['meta_value'] ) ) {
|
||||
if ( is_serialized_string( $entry['meta_value'] ) ) {
|
||||
@@ -588,7 +626,7 @@ function _list_meta_row( $entry, &$count ) {
|
||||
} else {
|
||||
// This is a serialized array/object so we should NOT display it.
|
||||
--$count;
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,7 +636,7 @@ function _list_meta_row( $entry, &$count ) {
|
||||
|
||||
$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
|
||||
|
||||
$r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
|
||||
$r .= "\n\t<tr id='meta-{$entry['meta_id']}'>";
|
||||
$r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta-{$entry['meta_id']}-key'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta-{$entry['meta_id']}-key' type='text' size='20' value='{$entry['meta_key']}' />";
|
||||
|
||||
$r .= "\n\t\t<div class='submit'>";
|
||||
@@ -701,7 +739,7 @@ function meta_form( $post = null ) {
|
||||
*
|
||||
* @param int|bool $edit Accepts 1|true for editing the date, 0|false for adding the date.
|
||||
* @param int|bool $for_post Accepts 1|true for applying the date to a post, 0|false for a comment.
|
||||
* @param int|bool $tab_index The tabindex attribute to add. Default 0.
|
||||
* @param int $tab_index The tabindex attribute to add. Default 0.
|
||||
* @param int|bool $multi Optional. Whether the additional fields and buttons should be added.
|
||||
* Default 0|false.
|
||||
*/
|
||||
@@ -781,7 +819,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out <option> HTML elements for the page templates drop-down.
|
||||
* Print out option HTML elements for the page templates drop-down.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
@@ -797,7 +835,7 @@ function page_template_dropdown( $default = '' ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out <option> HTML elements for the page parents drop-down.
|
||||
* Print out option HTML elements for the page parents drop-down.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
@@ -805,7 +843,7 @@ function page_template_dropdown( $default = '' ) {
|
||||
* @param int $parent Optional. The parent page ID. Default 0.
|
||||
* @param int $level Optional. Page depth level. Default 0.
|
||||
*
|
||||
* @return void|bool Boolean False if page has no children, otherwise print out html elements
|
||||
* @return null|false Boolean False if page has no children, otherwise print out html elements
|
||||
*/
|
||||
function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
|
||||
global $wpdb;
|
||||
@@ -830,13 +868,13 @@ function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out <option> html elements for role selectors
|
||||
* Print out option html elements for role selectors.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $selected slug for the role that should be already selected
|
||||
* @param string $selected Slug for the role that should be already selected.
|
||||
*/
|
||||
function wp_dropdown_roles( $selected = false ) {
|
||||
function wp_dropdown_roles( $selected = '' ) {
|
||||
$p = '';
|
||||
$r = '';
|
||||
|
||||
@@ -984,7 +1022,8 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string|object $screen Screen identifier
|
||||
* @staticvar bool $already_sorted
|
||||
* @param string|WP_Screen $screen Screen identifier
|
||||
* @param string $context box context
|
||||
* @param mixed $object gets passed to the box callback function as first parameter
|
||||
* @return int number of meta_boxes
|
||||
@@ -1004,25 +1043,25 @@ function do_meta_boxes( $screen, $context, $object ) {
|
||||
|
||||
printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context));
|
||||
|
||||
$i = 0;
|
||||
do {
|
||||
// Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
|
||||
if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
|
||||
foreach ( $sorted as $box_context => $ids ) {
|
||||
foreach ( explode(',', $ids ) as $id ) {
|
||||
if ( $id && 'dashboard_browser_nag' !== $id )
|
||||
add_meta_box( $id, null, null, $screen, $box_context, 'sorted' );
|
||||
// Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
|
||||
if ( ! $already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
|
||||
foreach ( $sorted as $box_context => $ids ) {
|
||||
foreach ( explode( ',', $ids ) as $id ) {
|
||||
if ( $id && 'dashboard_browser_nag' !== $id ) {
|
||||
add_meta_box( $id, null, null, $screen, $box_context, 'sorted' );
|
||||
}
|
||||
}
|
||||
}
|
||||
$already_sorted = true;
|
||||
}
|
||||
|
||||
if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
|
||||
break;
|
||||
$already_sorted = true;
|
||||
|
||||
foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
|
||||
if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
|
||||
foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
|
||||
$i = 0;
|
||||
|
||||
if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
|
||||
foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) {
|
||||
if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ]) ) {
|
||||
foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
|
||||
if ( false == $box || ! $box['title'] )
|
||||
continue;
|
||||
$i++;
|
||||
@@ -1038,7 +1077,7 @@ function do_meta_boxes( $screen, $context, $object ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(0);
|
||||
}
|
||||
|
||||
echo "</div>";
|
||||
|
||||
@@ -1111,13 +1150,11 @@ function do_accordion_sections( $screen, $context, $object ) {
|
||||
<?php
|
||||
$i = 0;
|
||||
$first_open = false;
|
||||
do {
|
||||
if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) )
|
||||
break;
|
||||
|
||||
if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
|
||||
foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
|
||||
if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) {
|
||||
foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
|
||||
if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
|
||||
foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
|
||||
if ( false == $box || ! $box['title'] )
|
||||
continue;
|
||||
$i++;
|
||||
@@ -1144,7 +1181,7 @@ function do_accordion_sections( $screen, $context, $object ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(0);
|
||||
}
|
||||
?>
|
||||
</ul><!-- .outer-border -->
|
||||
</div><!-- .accordion-container -->
|
||||
@@ -1200,15 +1237,28 @@ function add_settings_section($id, $title, $callback, $page) {
|
||||
* values to show.
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @since 4.2.0 The `$class` argument was added.
|
||||
*
|
||||
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
|
||||
*
|
||||
* @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
|
||||
* @param string $title Formatted title of the field. Shown as the label for the field during output.
|
||||
* @param string $callback Function that fills the field with the desired form inputs. The function should echo its output.
|
||||
* @param string $page The slug-name of the settings page on which to show the section (general, reading, writing, ...).
|
||||
* @param string $section The slug-name of the section of the settings page in which to show the box (default, ...).
|
||||
* @param array $args Additional arguments
|
||||
* @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
|
||||
* @param string $title Formatted title of the field. Shown as the label for the field
|
||||
* during output.
|
||||
* @param string $callback Function that fills the field with the desired form inputs. The
|
||||
* function should echo its output.
|
||||
* @param string $page The slug-name of the settings page on which to show the section
|
||||
* (general, reading, writing, ...).
|
||||
* @param string $section Optional. The slug-name of the section of the settings page
|
||||
* in which to show the box. Default 'default'.
|
||||
* @param array $args {
|
||||
* Optional. Extra arguments used when outputting the field.
|
||||
*
|
||||
* @type string $label_for When supplied, the setting title will be wrapped
|
||||
* in a `<label>` element, its `for` attribute populated
|
||||
* with this value.
|
||||
* @type string $class CSS Class to be added to the `<tr>` element when the
|
||||
* field is output.
|
||||
* }
|
||||
*/
|
||||
function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
|
||||
global $wp_settings_fields;
|
||||
@@ -1272,7 +1322,7 @@ function do_settings_sections( $page ) {
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $page Slug title of the admin page who's settings fields you want to show.
|
||||
* @param section $section Slug title of the settings section who's fields you want to show.
|
||||
* @param string $section Slug title of the settings section who's fields you want to show.
|
||||
*/
|
||||
function do_settings_fields($page, $section) {
|
||||
global $wp_settings_fields;
|
||||
@@ -1281,11 +1331,20 @@ function do_settings_fields($page, $section) {
|
||||
return;
|
||||
|
||||
foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
|
||||
echo '<tr>';
|
||||
if ( !empty($field['args']['label_for']) )
|
||||
$class = '';
|
||||
|
||||
if ( ! empty( $field['args']['class'] ) ) {
|
||||
$class = ' class="' . esc_attr( $field['args']['class'] ) . '"';
|
||||
}
|
||||
|
||||
echo "<tr{$class}>";
|
||||
|
||||
if ( ! empty( $field['args']['label_for'] ) ) {
|
||||
echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>';
|
||||
else
|
||||
} else {
|
||||
echo '<th scope="row">' . $field['title'] . '</th>';
|
||||
}
|
||||
|
||||
echo '<td>';
|
||||
call_user_func($field['callback'], $field['args']);
|
||||
echo '</td>';
|
||||
@@ -1311,9 +1370,11 @@ function do_settings_fields($page, $section) {
|
||||
* @global array $wp_settings_errors Storage array of errors registered during this pageload
|
||||
*
|
||||
* @param string $setting Slug title of the setting to which this error applies
|
||||
* @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
|
||||
* @param string $message The formatted message text to display to the user (will be shown inside styled <div> and <p>)
|
||||
* @param string $type The type of message it is, controls HTML class. Use 'error' or 'updated'.
|
||||
* @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
|
||||
* @param string $message The formatted message text to display to the user (will be shown inside styled
|
||||
* `<div>` and `<p>` tags).
|
||||
* @param string $type Optional. Message type, controls HTML class. Accepts 'error' or 'updated'.
|
||||
* Default 'error'.
|
||||
*/
|
||||
function add_settings_error( $setting, $code, $message, $type = 'error' ) {
|
||||
global $wp_settings_errors;
|
||||
@@ -1383,20 +1444,24 @@ function get_settings_errors( $setting = '', $sanitize = false ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Display settings errors registered by add_settings_error()
|
||||
* Display settings errors registered by {@see add_settings_error()}.
|
||||
*
|
||||
* Part of the Settings API. Outputs a <div> for each error retrieved by get_settings_errors().
|
||||
* Part of the Settings API. Outputs a div for each error retrieved by
|
||||
* {@see get_settings_errors()}.
|
||||
*
|
||||
* This is called automatically after a settings page based on the Settings API is submitted.
|
||||
* Errors should be added during the validation callback function for a setting defined in register_setting()
|
||||
* This is called automatically after a settings page based on the
|
||||
* Settings API is submitted. Errors should be added during the validation
|
||||
* callback function for a setting defined in {@see register_setting()}
|
||||
*
|
||||
* The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization
|
||||
* The $sanitize option is passed into {@see get_settings_errors()} and will
|
||||
* re-run the setting sanitization
|
||||
* on its current value.
|
||||
*
|
||||
* The $hide_on_update option will cause errors to only show when the settings page is first loaded.
|
||||
* if the user has already saved new values it will be hidden to avoid repeating messages already
|
||||
* shown in the default error reporting after submission. This is useful to show general errors like missing
|
||||
* settings when the user arrives at the settings page.
|
||||
* The $hide_on_update option will cause errors to only show when the settings
|
||||
* page is first loaded. if the user has already saved new values it will be
|
||||
* hidden to avoid repeating messages already shown in the default error
|
||||
* reporting after submission. This is useful to show general errors like
|
||||
* missing settings when the user arrives at the settings page.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
@@ -1417,7 +1482,7 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa
|
||||
$output = '';
|
||||
foreach ( $settings_errors as $key => $details ) {
|
||||
$css_id = 'setting-error-' . $details['code'];
|
||||
$css_class = $details['type'] . ' settings-error';
|
||||
$css_class = $details['type'] . ' settings-error notice is-dismissible';
|
||||
$output .= "<div id='$css_id' class='$css_class'> \n";
|
||||
$output .= "<p><strong>{$details['message']}</strong></p>";
|
||||
$output .= "</div> \n";
|
||||
@@ -1430,7 +1495,7 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param unknown_type $found_action
|
||||
* @param string $found_action
|
||||
*/
|
||||
function find_posts_div($found_action = '') {
|
||||
?>
|
||||
@@ -1468,7 +1533,6 @@ function find_posts_div($found_action = '') {
|
||||
* The password is passed through {@link esc_attr()} to ensure that it
|
||||
* is safe for placing in an html attribute.
|
||||
*
|
||||
* @uses attr
|
||||
* @since 2.7.0
|
||||
*/
|
||||
function the_post_password() {
|
||||
@@ -1492,7 +1556,7 @@ function _draft_or_post_title( $post = 0 ) {
|
||||
$title = get_the_title( $post );
|
||||
if ( empty( $title ) )
|
||||
$title = __( '(no title)' );
|
||||
return $title;
|
||||
return esc_html( $title );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1501,9 +1565,7 @@ function _draft_or_post_title( $post = 0 ) {
|
||||
* A simple wrapper to display the "s" parameter in a GET URI. This function
|
||||
* should only be used when {@link the_search_query()} cannot.
|
||||
*
|
||||
* @uses attr
|
||||
* @since 2.7.0
|
||||
*
|
||||
*/
|
||||
function _admin_search_query() {
|
||||
echo isset($_REQUEST['s']) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
|
||||
@@ -1513,13 +1575,13 @@ function _admin_search_query() {
|
||||
* Generic Iframe header for use with Thickbox
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @param string $title Title of the Iframe page.
|
||||
* @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
|
||||
*
|
||||
* @param string $title Optional. Title of the Iframe page. Default empty.
|
||||
* @param bool $deprecated Not used.
|
||||
*/
|
||||
function iframe_header( $title = '', $limit_styles = false ) {
|
||||
function iframe_header( $title = '', $deprecated = false ) {
|
||||
show_admin_bar( false );
|
||||
global $hook_suffix, $current_user, $admin_body_class, $wp_locale;
|
||||
global $hook_suffix, $admin_body_class, $wp_locale;
|
||||
$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
|
||||
|
||||
$current_screen = get_current_screen();
|
||||
@@ -1532,7 +1594,6 @@ function iframe_header( $title = '', $limit_styles = false ) {
|
||||
wp_enqueue_style( 'colors' );
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
|
||||
function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
|
||||
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
|
||||
@@ -1542,7 +1603,6 @@ var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
|
||||
thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
|
||||
decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
|
||||
isRtl = <?php echo (int) is_rtl(); ?>;
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
/** This action is documented in wp-admin/admin-header.php */
|
||||
@@ -1573,16 +1633,17 @@ if ( is_rtl() )
|
||||
|
||||
?>
|
||||
</head>
|
||||
<?php /** This filter is documented in wp-admin/admin-header.php */ ?>
|
||||
<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo apply_filters( 'admin_body_class', '' ) . ' ' . $admin_body_class; ?>">
|
||||
<?php
|
||||
/** This filter is documented in wp-admin/admin-header.php */
|
||||
$admin_body_classes = apply_filters( 'admin_body_class', '' );
|
||||
?>
|
||||
<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
(function(){
|
||||
var c = document.body.className;
|
||||
c = c.replace(/no-js/, 'js');
|
||||
document.body.className = c;
|
||||
})();
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
@@ -1591,12 +1652,11 @@ document.body.className = c;
|
||||
* Generic Iframe footer for use with Thickbox
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
*/
|
||||
function iframe_footer() {
|
||||
/*
|
||||
* We're going to hide any footer output on iFrame pages,
|
||||
* but run the hooks anyway since they output Javascript
|
||||
* but run the hooks anyway since they output JavaScript
|
||||
* or other needed content.
|
||||
*/
|
||||
?>
|
||||
@@ -1634,13 +1694,20 @@ function _post_states($post) {
|
||||
if ( is_sticky($post->ID) )
|
||||
$post_states['sticky'] = __('Sticky');
|
||||
|
||||
if ( get_option( 'page_on_front' ) == $post->ID ) {
|
||||
$post_states['page_on_front'] = __( 'Front Page' );
|
||||
}
|
||||
|
||||
if ( get_option( 'page_for_posts' ) == $post->ID ) {
|
||||
$post_states['page_for_posts'] = __( 'Posts Page' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the default post display states used in the Posts list table.
|
||||
* Filter the default post display states used in the posts list table.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param array $post_states An array of post display states. Values include 'Password protected',
|
||||
* 'Private', 'Draft', 'Pending', and 'Sticky'.
|
||||
* @param array $post_states An array of post display states.
|
||||
* @param int $post The post ID.
|
||||
*/
|
||||
$post_states = apply_filters( 'display_post_states', $post_states, $post );
|
||||
@@ -1709,7 +1776,6 @@ function _media_states( $post ) {
|
||||
function compression_test() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
var testCompression = {
|
||||
get : function(test) {
|
||||
var x;
|
||||
@@ -1727,7 +1793,7 @@ function compression_test() {
|
||||
h = x.getResponseHeader('Content-Encoding');
|
||||
testCompression.check(r, h, test);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
x.open('GET', ajaxurl + '?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);
|
||||
x.send('');
|
||||
@@ -1756,7 +1822,6 @@ function compression_test() {
|
||||
}
|
||||
};
|
||||
testCompression.check();
|
||||
/* ]]> */
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
@@ -1792,19 +1857,23 @@ function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param string $text The text of the button (defaults to 'Save Changes')
|
||||
* @param string $type The type of button. One of: primary, secondary, delete
|
||||
* @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
|
||||
* is given in $other_attributes below, $name will be used as the button's id.
|
||||
* @param bool $wrap True if the output button should be wrapped in a paragraph tag,
|
||||
* false otherwise. Defaults to true
|
||||
* @param array|string $other_attributes Other attributes that should be output with the button,
|
||||
* mapping attributes to their values, such as array( 'tabindex' => '1' ).
|
||||
* These attributes will be output as attribute="value", such as tabindex="1".
|
||||
* Defaults to no other attributes. Other attributes can also be provided as a
|
||||
* string such as 'tabindex="1"', though the array format is typically cleaner.
|
||||
* @param string $text Optional. The text of the button. Default 'Save Changes'.
|
||||
* @param string $type Optional. The type of button. Accepts 'primary', 'secondary',
|
||||
* or 'delete'. Default 'primary large'.
|
||||
* @param string $name Optional. The HTML name of the submit button. Defaults to "submit".
|
||||
* If no id attribute is given in $other_attributes below, `$name` will
|
||||
* be used as the button's id. Default 'submit'.
|
||||
* @param bool $wrap Optional. True if the output button should be wrapped in a paragraph
|
||||
* tag, false otherwise. Default true.
|
||||
* @param array|string $other_attributes Optional. Other attributes that should be output with the button,
|
||||
* mapping attributes to their values, such as `array( 'tabindex' => '1' )`.
|
||||
* These attributes will be output as `attribute="value"`, such as
|
||||
* `tabindex="1"`. Other attributes can also be provided as a string such
|
||||
* as `tabindex="1"`, though the array format is typically cleaner.
|
||||
* Default empty.
|
||||
* @return string Submit button HTML.
|
||||
*/
|
||||
function get_submit_button( $text = null, $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = null ) {
|
||||
function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) {
|
||||
if ( ! is_array( $type ) )
|
||||
$type = explode( ' ', $type );
|
||||
|
||||
@@ -1834,11 +1903,15 @@ function get_submit_button( $text = null, $type = 'primary large', $name = 'subm
|
||||
foreach ( $other_attributes as $attribute => $value ) {
|
||||
$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important
|
||||
}
|
||||
} else if ( !empty( $other_attributes ) ) { // Attributes provided as a string
|
||||
} elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string
|
||||
$attributes = $other_attributes;
|
||||
}
|
||||
|
||||
$button = '<input type="submit" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class );
|
||||
// Don't output empty name and id attributes.
|
||||
$name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : '';
|
||||
$id_attr = $id ? ' id="' . esc_attr( $id ) . '"' : '';
|
||||
|
||||
$button = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class );
|
||||
$button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
|
||||
|
||||
if ( $wrap ) {
|
||||
@@ -1856,19 +1929,23 @@ function _wp_admin_html_begin() {
|
||||
if ( $is_IE )
|
||||
@header('X-UA-Compatible: IE=edge');
|
||||
|
||||
/**
|
||||
* Fires inside the HTML tag in the admin header.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" <?php do_action( 'admin_xml_ns' ); ?> <?php language_attributes(); ?>>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" <?php
|
||||
/**
|
||||
* Fires inside the HTML tag in the admin header.
|
||||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
do_action( 'admin_xml_ns' );
|
||||
?> <?php language_attributes(); ?>>
|
||||
<![endif]-->
|
||||
<!--[if !(IE 8) ]><!-->
|
||||
<?php /** This action is documented in wp-admin/includes/template.php */ ?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php do_action( 'admin_xml_ns' ); ?> <?php language_attributes(); ?>>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php
|
||||
/** This action is documented in wp-admin/includes/template.php */
|
||||
do_action( 'admin_xml_ns' );
|
||||
?> <?php language_attributes(); ?>>
|
||||
<!--<![endif]-->
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
|
||||
@@ -1886,6 +1963,8 @@ final class WP_Internal_Pointers {
|
||||
*
|
||||
* Individual pointers (e.g. wp390_widgets) can be disabled using the following:
|
||||
* remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp390_widgets' ) );
|
||||
*
|
||||
* @param string $hook_suffix The current admin page.
|
||||
*/
|
||||
public static function enqueue_scripts( $hook_suffix ) {
|
||||
/*
|
||||
@@ -1894,8 +1973,8 @@ final class WP_Internal_Pointers {
|
||||
*/
|
||||
|
||||
$registered_pointers = array(
|
||||
'post-new.php' => 'wp350_media',
|
||||
'post.php' => array( 'wp350_media', 'wp360_revisions' ),
|
||||
'post-new.php' => 'wp410_dfw',
|
||||
'post.php' => 'wp410_dfw',
|
||||
'edit.php' => 'wp360_locks',
|
||||
'widgets.php' => 'wp390_widgets',
|
||||
'themes.php' => 'wp390_widgets',
|
||||
@@ -1908,7 +1987,6 @@ final class WP_Internal_Pointers {
|
||||
$pointers = (array) $registered_pointers[ $hook_suffix ];
|
||||
|
||||
$caps_required = array(
|
||||
'wp350_media' => array( 'upload_files' ),
|
||||
'wp390_widgets' => array( 'edit_theme_options' ),
|
||||
);
|
||||
|
||||
@@ -1938,7 +2016,7 @@ final class WP_Internal_Pointers {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the pointer javascript data.
|
||||
* Print the pointer JavaScript data.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
@@ -1952,9 +2030,8 @@ final class WP_Internal_Pointers {
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
(function($){
|
||||
var options = <?php echo json_encode( $args ); ?>, setup;
|
||||
var options = <?php echo wp_json_encode( $args ); ?>, setup;
|
||||
|
||||
if ( ! options )
|
||||
return;
|
||||
@@ -1978,7 +2055,6 @@ final class WP_Internal_Pointers {
|
||||
$(document).ready( setup );
|
||||
|
||||
})( jQuery );
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
@@ -1988,26 +2064,8 @@ final class WP_Internal_Pointers {
|
||||
public static function pointer_wp330_saving_widgets() {}
|
||||
public static function pointer_wp340_customize_current_theme_link() {}
|
||||
public static function pointer_wp340_choose_image_from_library() {}
|
||||
|
||||
public static function pointer_wp350_media() {
|
||||
$content = '<h3>' . __( 'New Media Manager' ) . '</h3>';
|
||||
$content .= '<p>' . __( 'Uploading files and creating image galleries has a whole new look. Check it out!' ) . '</p>';
|
||||
|
||||
self::print_js( 'wp350_media', '.insert-media', array(
|
||||
'content' => $content,
|
||||
'position' => array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' ),
|
||||
) );
|
||||
}
|
||||
|
||||
public static function pointer_wp360_revisions() {
|
||||
$content = '<h3>' . __( 'Compare Revisions' ) . '</h3>';
|
||||
$content .= '<p>' . __( 'View, compare, and restore other versions of this content on the improved revisions screen.' ) . '</p>';
|
||||
|
||||
self::print_js( 'wp360_revisions', '.misc-pub-section.misc-pub-revisions', array(
|
||||
'content' => $content,
|
||||
'position' => array( 'edge' => is_rtl() ? 'left' : 'right', 'align' => 'center' ),
|
||||
) );
|
||||
}
|
||||
public static function pointer_wp350_media() {}
|
||||
public static function pointer_wp360_revisions() {}
|
||||
|
||||
public static function pointer_wp360_locks() {
|
||||
if ( ! is_multi_author() ) {
|
||||
@@ -2029,13 +2087,13 @@ final class WP_Internal_Pointers {
|
||||
}
|
||||
|
||||
$content = '<h3>' . __( 'New Feature: Live Widget Previews' ) . '</h3>';
|
||||
$content .= '<p>' . __( 'Add, edit, and play around with your widgets from the theme customizer.' ) . ' ' . __( 'Preview your changes in real-time and only save them when you’re ready.' ) . '</p>';
|
||||
$content .= '<p>' . __( 'Add, edit, and play around with your widgets from the Customizer.' ) . ' ' . __( 'Preview your changes in real-time and only save them when you’re ready.' ) . '</p>';
|
||||
|
||||
if ( 'themes' === get_current_screen()->id ) {
|
||||
$selector = '.theme.active .customize';
|
||||
$position = array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' );
|
||||
} else {
|
||||
$selector = 'a[href="customize.php"]';
|
||||
$selector = 'a[href^="customize.php"]';
|
||||
if ( is_rtl() ) {
|
||||
$position = array( 'edge' => 'right', 'align' => 'center', 'my' => 'right-5px' );
|
||||
} else {
|
||||
@@ -2049,13 +2107,36 @@ final class WP_Internal_Pointers {
|
||||
) );
|
||||
}
|
||||
|
||||
public static function pointer_wp410_dfw() {
|
||||
// Don't show when editor-scrolling is not used.
|
||||
if ( empty( $GLOBALS['_wp_editor_expand'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$content = '<h3>' . __( 'Distraction-Free Writing' ) . '</h3>';
|
||||
$content .= '<p>' . __( 'Enable distraction-free writing mode, and everything surrounding the editor will fade away when you start typing. Move your mouse out of the editor to reveal everything again.' ) . '</p>';
|
||||
|
||||
if ( is_rtl() ) {
|
||||
$position = array( 'edge' => 'left', 'align' => 'center', 'my' => 'left+40 top-11', 'at' => 'left top' );
|
||||
} else {
|
||||
$position = array( 'edge' => 'right', 'align' => 'center', 'my' => 'right-40 top-11', 'at' => 'right top' );
|
||||
}
|
||||
|
||||
self::print_js( 'wp410_dfw', '#wp-content-wrap', array(
|
||||
'content' => $content,
|
||||
'position' => $position,
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents new users from seeing existing 'new feature' pointers.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param int $user_id User ID.
|
||||
*/
|
||||
public static function dismiss_pointers_for_new_users( $user_id ) {
|
||||
add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp350_media,wp360_revisions,wp360_locks,wp390_widgets' );
|
||||
add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp360_locks,wp390_widgets' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2087,7 +2168,7 @@ function convert_to_screen( $hook_name ) {
|
||||
*/
|
||||
function _local_storage_notice() {
|
||||
?>
|
||||
<div id="local-storage-notice" class="hidden">
|
||||
<div id="local-storage-notice" class="hidden notice">
|
||||
<p class="local-restore">
|
||||
<?php _e('The backup of this post in your browser is different from the version below.'); ?>
|
||||
<a class="restore-backup" href="#"><?php _e('Restore the backup.'); ?></a>
|
||||
@@ -2155,3 +2236,13 @@ function wp_star_rating( $args = array() ) {
|
||||
echo str_repeat( '<div class="star star-empty"></div>', $empty_stars);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a notice when editing the page for posts (internal use only).
|
||||
*
|
||||
* @ignore
|
||||
* @since 4.2.0
|
||||
*/
|
||||
function _wp_posts_page_notice() {
|
||||
echo '<div class="notice notice-warning inline"><p>' . __( 'You are currently editing the page that shows your latest posts.' ) . '</p></div>';
|
||||
}
|
||||
@@ -57,7 +57,7 @@ function install_theme_search_form( $type_selector = true ) {
|
||||
if ( ! $type_selector )
|
||||
echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
|
||||
?>
|
||||
<form id="search-themes" method="get" action="">
|
||||
<form id="search-themes" method="get">
|
||||
<input type="hidden" name="tab" value="search" />
|
||||
<?php if ( $type_selector ) : ?>
|
||||
<label class="screen-reader-text" for="typeselector"><?php _e('Type of search'); ?></label>
|
||||
@@ -99,7 +99,7 @@ function install_themes_dashboard() {
|
||||
<h4><?php _e('Feature Filter') ?></h4>
|
||||
<p class="install-help"><?php _e( 'Find a theme based on specific features.' ); ?></p>
|
||||
|
||||
<form method="get" action="">
|
||||
<form method="get">
|
||||
<input type="hidden" name="tab" value="search" />
|
||||
<?php
|
||||
$feature_list = get_theme_feature_list();
|
||||
|
||||
+132
-25
@@ -55,20 +55,34 @@ function delete_theme($stylesheet, $redirect = '') {
|
||||
if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
|
||||
return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors);
|
||||
|
||||
//Get the base plugin folder
|
||||
// Get the base plugin folder.
|
||||
$themes_dir = $wp_filesystem->wp_themes_dir();
|
||||
if ( empty($themes_dir) )
|
||||
return new WP_Error('fs_no_themes_dir', __('Unable to locate WordPress theme directory.'));
|
||||
if ( empty( $themes_dir ) ) {
|
||||
return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) );
|
||||
}
|
||||
|
||||
$themes_dir = trailingslashit( $themes_dir );
|
||||
$theme_dir = trailingslashit($themes_dir . $stylesheet);
|
||||
$deleted = $wp_filesystem->delete($theme_dir, true);
|
||||
$theme_dir = trailingslashit( $themes_dir . $stylesheet );
|
||||
$deleted = $wp_filesystem->delete( $theme_dir, true );
|
||||
|
||||
if ( ! $deleted )
|
||||
return new WP_Error('could_not_remove_theme', sprintf(__('Could not fully remove the theme %s.'), $stylesheet) );
|
||||
if ( ! $deleted ) {
|
||||
return new WP_Error( 'could_not_remove_theme', sprintf( __( 'Could not fully remove the theme %s.' ), $stylesheet ) );
|
||||
}
|
||||
|
||||
// Force refresh of theme update information
|
||||
delete_site_transient('update_themes');
|
||||
$theme_translations = wp_get_installed_translations( 'themes' );
|
||||
|
||||
// Remove language files, silently.
|
||||
if ( ! empty( $theme_translations[ $stylesheet ] ) ) {
|
||||
$translations = $theme_translations[ $stylesheet ];
|
||||
|
||||
foreach ( $translations as $translation => $data ) {
|
||||
$wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.po' );
|
||||
$wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.mo' );
|
||||
}
|
||||
}
|
||||
|
||||
// Force refresh of theme update information.
|
||||
delete_site_transient( 'update_themes' );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -121,7 +135,7 @@ function theme_update_available( $theme ) {
|
||||
* @since 3.8.0
|
||||
*
|
||||
* @param WP_Theme $theme WP_Theme object.
|
||||
* @return string|bool HTML for the update link, or false if invalid info was passed.
|
||||
* @return false|string HTML for the update link, or false if invalid info was passed.
|
||||
*/
|
||||
function get_theme_update_available( $theme ) {
|
||||
static $themes_update;
|
||||
@@ -132,8 +146,9 @@ function get_theme_update_available( $theme ) {
|
||||
if ( !isset($themes_update) )
|
||||
$themes_update = get_site_transient('update_themes');
|
||||
|
||||
if ( ! is_a( $theme, 'WP_Theme' ) )
|
||||
if ( ! ( $theme instanceof WP_Theme ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$stylesheet = $theme->get_stylesheet();
|
||||
|
||||
@@ -150,7 +165,7 @@ function get_theme_update_available( $theme ) {
|
||||
if ( ! current_user_can('update_themes') ) {
|
||||
$html = sprintf( '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.' ) . '</strong></p>',
|
||||
$theme_name, esc_url( $details_url ), esc_attr( $theme['Name'] ), $update['new_version'] );
|
||||
} else if ( empty( $update['package'] ) ) {
|
||||
} elseif ( empty( $update['package'] ) ) {
|
||||
$html = sprintf( '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ) . '</strong></p>',
|
||||
$theme_name, esc_url( $details_url ), esc_attr( $theme['Name'] ), $update['new_version'] );
|
||||
} else {
|
||||
@@ -297,13 +312,20 @@ function get_theme_feature_list( $api = true ) {
|
||||
* @param array|object $args Optional. Arguments to serialize for the Theme Info API.
|
||||
* @return mixed
|
||||
*/
|
||||
function themes_api( $action, $args = null ) {
|
||||
function themes_api( $action, $args = null ) {
|
||||
|
||||
if ( is_array($args) )
|
||||
$args = (object)$args;
|
||||
if ( is_array( $args ) ) {
|
||||
$args = (object) $args;
|
||||
}
|
||||
|
||||
if ( !isset($args->per_page) )
|
||||
if ( ! isset( $args->per_page ) ) {
|
||||
$args->per_page = 24;
|
||||
}
|
||||
|
||||
if ( ! isset( $args->locale ) ) {
|
||||
$args->locale = get_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter arguments used to query for installer pages from the WordPress.org Themes API.
|
||||
*
|
||||
@@ -314,7 +336,7 @@ function get_theme_feature_list( $api = true ) {
|
||||
* @param object $args Arguments used to query for installer pages from the WordPress.org Themes API.
|
||||
* @param string $action Requested action. Likely values are 'theme_information',
|
||||
* 'feature_list', or 'query_themes'.
|
||||
*/
|
||||
*/
|
||||
$args = apply_filters( 'themes_api_args', $args, $action );
|
||||
|
||||
/**
|
||||
@@ -337,19 +359,19 @@ function get_theme_feature_list( $api = true ) {
|
||||
if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
|
||||
$args = array(
|
||||
$http_args = array(
|
||||
'body' => array(
|
||||
'action' => $action,
|
||||
'request' => serialize( $args )
|
||||
)
|
||||
);
|
||||
$request = wp_remote_post( $url, $args );
|
||||
$request = wp_remote_post( $url, $http_args );
|
||||
|
||||
if ( $ssl && is_wp_error( $request ) ) {
|
||||
if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
|
||||
trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
|
||||
}
|
||||
$request = wp_remote_post( $http_url, $args );
|
||||
$request = wp_remote_post( $http_url, $http_args );
|
||||
}
|
||||
|
||||
if ( is_wp_error($request) ) {
|
||||
@@ -387,8 +409,26 @@ function get_theme_feature_list( $api = true ) {
|
||||
function wp_prepare_themes_for_js( $themes = null ) {
|
||||
$current_theme = get_stylesheet();
|
||||
|
||||
/**
|
||||
* Filter theme data before it is prepared for JavaScript.
|
||||
*
|
||||
* Passing a non-empty array will result in wp_prepare_themes_for_js() returning
|
||||
* early with that value instead.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param array $prepared_themes An associative array of theme data. Default empty array.
|
||||
* @param null|array $themes An array of WP_Theme objects to prepare, if any.
|
||||
* @param string $current_theme The current theme slug.
|
||||
*/
|
||||
$prepared_themes = (array) apply_filters( 'pre_prepare_themes_for_js', array(), $themes, $current_theme );
|
||||
|
||||
if ( ! empty( $prepared_themes ) ) {
|
||||
return $prepared_themes;
|
||||
}
|
||||
|
||||
// Make sure the current theme is listed first.
|
||||
$prepared_themes = array( $current_theme => array() );
|
||||
$prepared_themes[ $current_theme ] = array();
|
||||
|
||||
if ( null === $themes ) {
|
||||
$themes = wp_get_themes( array( 'allowed' => true ) );
|
||||
@@ -406,15 +446,19 @@ function wp_prepare_themes_for_js( $themes = null ) {
|
||||
}
|
||||
|
||||
WP_Theme::sort_by_name( $themes );
|
||||
|
||||
$parents = array();
|
||||
|
||||
foreach ( $themes as $theme ) {
|
||||
$slug = $theme->get_stylesheet();
|
||||
$encoded_slug = urlencode( $slug );
|
||||
|
||||
$parent = false;
|
||||
if ( $theme->parent() ) {
|
||||
$parent = $theme->parent()->display( 'Name' );
|
||||
$parents[ $slug ] = $theme->parent()->get_stylesheet();
|
||||
}
|
||||
|
||||
$slug = $theme->get_stylesheet();
|
||||
$encoded_slug = urlencode( $slug );
|
||||
|
||||
$prepared_themes[ $slug ] = array(
|
||||
'id' => $slug,
|
||||
'name' => $theme->display( 'Name' ),
|
||||
@@ -443,6 +487,11 @@ function wp_prepare_themes_for_js( $themes = null ) {
|
||||
);
|
||||
}
|
||||
|
||||
// Remove 'delete' action if theme has an active child
|
||||
if ( ! empty( $parents ) && array_key_exists( $current_theme, $parents ) ) {
|
||||
unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the themes prepared for JavaScript, for themes.php.
|
||||
*
|
||||
@@ -453,5 +502,63 @@ function wp_prepare_themes_for_js( $themes = null ) {
|
||||
* @param array $prepared_themes Array of themes.
|
||||
*/
|
||||
$prepared_themes = apply_filters( 'wp_prepare_themes_for_js', $prepared_themes );
|
||||
return array_values( $prepared_themes );
|
||||
$prepared_themes = array_values( $prepared_themes );
|
||||
return array_filter( $prepared_themes );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print JS templates for the theme-browsing UI in the Customizer.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
function customize_themes_print_templates() {
|
||||
$preview_url = esc_url( add_query_arg( 'theme', '__THEME__' ) ); // Token because esc_url() strips curly braces.
|
||||
$preview_url = str_replace( '__THEME__', '{{ data.id }}', $preview_url );
|
||||
?>
|
||||
<script type="text/html" id="tmpl-customize-themes-details-view">
|
||||
<div class="theme-backdrop"></div>
|
||||
<div class="theme-wrap">
|
||||
<div class="theme-header">
|
||||
<button type="button" class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show previous theme' ); ?></span></button>
|
||||
<button type="button" class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show next theme' ); ?></span></button>
|
||||
<button type="button" class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close details dialog' ); ?></span></button>
|
||||
</div>
|
||||
<div class="theme-about">
|
||||
<div class="theme-screenshots">
|
||||
<# if ( data.screenshot[0] ) { #>
|
||||
<div class="screenshot"><img src="{{ data.screenshot[0] }}" alt="" /></div>
|
||||
<# } else { #>
|
||||
<div class="screenshot blank"></div>
|
||||
<# } #>
|
||||
</div>
|
||||
|
||||
<div class="theme-info">
|
||||
<# if ( data.active ) { #>
|
||||
<span class="current-label"><?php _e( 'Current Theme' ); ?></span>
|
||||
<# } #>
|
||||
<h3 class="theme-name">{{{ data.name }}}<span class="theme-version"><?php printf( __( 'Version: %s' ), '{{ data.version }}' ); ?></span></h3>
|
||||
<h4 class="theme-author"><?php printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' ); ?></h4>
|
||||
<p class="theme-description">{{{ data.description }}}</p>
|
||||
|
||||
<# if ( data.parent ) { #>
|
||||
<p class="parent-theme"><?php printf( __( 'This is a child theme of %s.' ), '<strong>{{{ data.parent }}}</strong>' ); ?></p>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.tags ) { #>
|
||||
<p class="theme-tags"><span><?php _e( 'Tags:' ); ?></span> {{ data.tags }}</p>
|
||||
<# } #>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<# if ( ! data.active ) { #>
|
||||
<div class="theme-actions">
|
||||
<div class="inactive-theme">
|
||||
<a href="<?php echo $preview_url; ?>" target="_top" class="button button-primary"><?php _e( 'Live Preview' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<# } #>
|
||||
</div>
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
add_action( 'customize_controls_print_footer_scripts', 'customize_themes_print_templates' );
|
||||
@@ -141,7 +141,7 @@ function wp_install_language_form( $languages ) {
|
||||
$language = $languages[ $wp_local_package ];
|
||||
printf( '<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
|
||||
esc_attr( $language['language'] ),
|
||||
esc_attr( $language['iso'][1] ),
|
||||
esc_attr( current( $language['iso'] ) ),
|
||||
esc_attr( $language['strings']['continue'] ),
|
||||
in_array( $language['language'], $installed_languages ) ? ' data-installed="1"' : '',
|
||||
esc_html( $language['native_name'] ) );
|
||||
@@ -153,7 +153,7 @@ function wp_install_language_form( $languages ) {
|
||||
foreach ( $languages as $language ) {
|
||||
printf( '<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
|
||||
esc_attr( $language['language'] ),
|
||||
esc_attr( $language['iso'][1] ),
|
||||
esc_attr( current( $language['iso'] ) ),
|
||||
esc_attr( $language['strings']['continue'] ),
|
||||
in_array( $language['language'], $installed_languages ) ? ' data-installed="1"' : '',
|
||||
esc_html( $language['native_name'] ) );
|
||||
@@ -229,6 +229,7 @@ function wp_can_install_language_pack() {
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
$skin = new Automatic_Upgrader_Skin;
|
||||
$upgrader = new Language_Pack_Upgrader( $skin );
|
||||
$upgrader->init();
|
||||
|
||||
$check = $upgrader->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );
|
||||
|
||||
|
||||
@@ -659,6 +659,42 @@ $_old_files = array(
|
||||
'wp-includes/js/tinymce/plugins/paste/editor_plugin_src.js',
|
||||
'wp-includes/js/tinymce/plugins/paste/pastetext.htm',
|
||||
'wp-includes/js/tinymce/langs/wp-langs.php',
|
||||
// 4.1
|
||||
'wp-includes/js/jquery/ui/jquery.ui.accordion.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.autocomplete.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.button.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.core.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.datepicker.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.dialog.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.draggable.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.droppable.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect-blind.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect-bounce.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect-clip.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect-drop.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect-explode.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect-fade.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect-fold.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect-highlight.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect-pulsate.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect-scale.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect-shake.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect-slide.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect-transfer.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.effect.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.menu.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.mouse.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.position.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.progressbar.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.resizable.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.selectable.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.slider.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.sortable.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.spinner.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.tabs.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.tooltip.min.js',
|
||||
'wp-includes/js/jquery/ui/jquery.ui.widget.min.js',
|
||||
'wp-includes/js/tinymce/skins/wordpress/images/dashicon-no-alt.png'
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -687,6 +723,7 @@ $_new_bundled_files = array(
|
||||
'themes/twentytwelve/' => '3.5',
|
||||
'themes/twentythirteen/' => '3.6',
|
||||
'themes/twentyfourteen/' => '3.8',
|
||||
'themes/twentyfifteen/' => '4.1',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -775,6 +812,8 @@ function update_core($from, $to) {
|
||||
|
||||
// Import $wp_version, $required_php_version, and $required_mysql_version from the new version
|
||||
// $wp_filesystem->wp_content_dir() returned unslashed pre-2.8
|
||||
global $wp_version, $required_php_version, $required_mysql_version;
|
||||
|
||||
$versions_file = trailingslashit( $wp_filesystem->wp_content_dir() ) . 'upgrade/version-current.php';
|
||||
if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $versions_file ) ) {
|
||||
$wp_filesystem->delete( $from, true );
|
||||
@@ -787,7 +826,7 @@ function update_core($from, $to) {
|
||||
|
||||
$php_version = phpversion();
|
||||
$mysql_version = $wpdb->db_version();
|
||||
$old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from
|
||||
$old_wp_version = $wp_version; // The version of WordPress we're updating from
|
||||
$development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // a dash in the version indicates a Development release
|
||||
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
|
||||
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
|
||||
|
||||
@@ -205,9 +205,9 @@ function update_nag() {
|
||||
return false;
|
||||
|
||||
if ( current_user_can('update_core') ) {
|
||||
$msg = sprintf( __('<a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s">Please update now</a>.'), $cur->current, network_admin_url( 'update-core.php' ) );
|
||||
$msg = sprintf( __('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s">Please update now</a>.'), $cur->current, network_admin_url( 'update-core.php' ) );
|
||||
} else {
|
||||
$msg = sprintf( __('<a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.'), $cur->current );
|
||||
$msg = sprintf( __('<a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.'), $cur->current );
|
||||
}
|
||||
echo "<div class='update-nag'>$msg</div>";
|
||||
}
|
||||
@@ -221,15 +221,17 @@ function update_right_now_message() {
|
||||
$theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name );
|
||||
}
|
||||
|
||||
$msg = sprintf( __( 'WordPress %1$s running %2$s theme.' ), get_bloginfo( 'version', 'display' ), $theme_name );
|
||||
$msg = '';
|
||||
|
||||
if ( current_user_can('update_core') ) {
|
||||
$cur = get_preferred_from_update_core();
|
||||
|
||||
if ( isset( $cur->response ) && $cur->response == 'upgrade' )
|
||||
$msg .= " <a href='" . network_admin_url( 'update-core.php' ) . "' class='button'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>';
|
||||
$msg .= '<a href="' . network_admin_url( 'update-core.php' ) . '" class="button" aria-describedby="wp-version">' . sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a> ';
|
||||
}
|
||||
|
||||
$msg .= sprintf( '<span id="wp-version">' . __( 'WordPress %1$s running %2$s theme.' ) . '</span>', get_bloginfo( 'version', 'display' ), $theme_name );
|
||||
|
||||
echo "<p id='wp-version-message'>$msg</p>";
|
||||
}
|
||||
|
||||
@@ -276,20 +278,21 @@ function wp_plugin_update_row( $file, $plugin_data ) {
|
||||
$wp_list_table = _get_list_table('WP_Plugins_List_Table');
|
||||
|
||||
if ( is_network_admin() || !is_multisite() ) {
|
||||
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
|
||||
$active_class = ( is_plugin_active( $plugin_data['plugin'] ) ) ? ' active' : '';
|
||||
echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $r->slug . '-update' ) . '" data-slug="' . esc_attr( $r->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">';
|
||||
|
||||
if ( ! current_user_can('update_plugins') )
|
||||
if ( ! current_user_can( 'update_plugins' ) ) {
|
||||
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version );
|
||||
else if ( empty($r->package) )
|
||||
} elseif ( empty($r->package) ) {
|
||||
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version );
|
||||
else
|
||||
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file) );
|
||||
|
||||
} else {
|
||||
printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s" class="update-link">update now</a>.' ), $plugin_name, esc_url( $details_url ), esc_attr( $plugin_name ), $r->new_version, wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ) );
|
||||
}
|
||||
/**
|
||||
* Fires at the end of the update message container in each
|
||||
* row of the plugins list table.
|
||||
*
|
||||
* The dynamic portion of the hook name, $file, refers to the path
|
||||
* The dynamic portion of the hook name, `$file`, refers to the path
|
||||
* of the plugin's primary file relative to the plugins directory.
|
||||
*
|
||||
* @since 2.8.0
|
||||
@@ -367,18 +370,18 @@ function wp_theme_update_row( $theme_key, $theme ) {
|
||||
$wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
|
||||
|
||||
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
|
||||
if ( ! current_user_can('update_themes') )
|
||||
if ( ! current_user_can('update_themes') ) {
|
||||
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r->new_version );
|
||||
else if ( empty( $r['package'] ) )
|
||||
} elseif ( empty( $r['package'] ) ) {
|
||||
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'] );
|
||||
else
|
||||
} else {
|
||||
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'], wp_nonce_url( self_admin_url('update.php?action=upgrade-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key) );
|
||||
|
||||
}
|
||||
/**
|
||||
* Fires at the end of the update message container in each
|
||||
* row of the themes list table.
|
||||
*
|
||||
* The dynamic portion of the hook name, $theme_key, refers to
|
||||
* The dynamic portion of the hook name, `$theme_key`, refers to
|
||||
* the theme slug as found in the WordPress.org themes repository.
|
||||
*
|
||||
* @since 3.1.0
|
||||
|
||||
+313
-89
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* WordPress Upgrade API
|
||||
*
|
||||
* Most of the functions are pluggable and can be overwritten
|
||||
* Most of the functions are pluggable and can be overwritten.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Administration
|
||||
@@ -20,20 +20,21 @@ require_once(ABSPATH . 'wp-admin/includes/schema.php');
|
||||
|
||||
if ( !function_exists('wp_install') ) :
|
||||
/**
|
||||
* Installs the blog
|
||||
* Installs the site.
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
* Runs the required functions to set up and populate the database,
|
||||
* including primary admin user and initial options.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $blog_title Blog title.
|
||||
* @param string $user_name User's username.
|
||||
* @param string $user_email User's email.
|
||||
* @param bool $public Whether blog is public.
|
||||
* @param null $deprecated Optional. Not used.
|
||||
* @param string $user_password Optional. User's chosen password. Will default to a random password.
|
||||
* @param string $language Optional. Language chosen.
|
||||
* @return array Array keys 'url', 'user_id', 'password', 'password_message'.
|
||||
* @param string $blog_title Blog title.
|
||||
* @param string $user_name User's username.
|
||||
* @param string $user_email User's email.
|
||||
* @param bool $public Whether blog is public.
|
||||
* @param string $deprecated Optional. Not used.
|
||||
* @param string $user_password Optional. User's chosen password. Default empty (random password).
|
||||
* @param string $language Optional. Language chosen. Default empty.
|
||||
* @return array Array keys 'url', 'user_id', 'password', and 'password_message'.
|
||||
*/
|
||||
function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) {
|
||||
if ( !empty( $deprecated ) )
|
||||
@@ -74,7 +75,7 @@ function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated
|
||||
$user_id = wp_create_user($user_name, $user_password, $user_email);
|
||||
update_user_option($user_id, 'default_password_nag', true, true);
|
||||
$email_password = true;
|
||||
} else if ( !$user_id ) {
|
||||
} elseif ( ! $user_id ) {
|
||||
// Password has been provided
|
||||
$message = '<em>'.__('Your chosen password.').'</em>';
|
||||
$user_id = wp_create_user($user_name, $user_password, $user_email);
|
||||
@@ -87,6 +88,8 @@ function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated
|
||||
|
||||
wp_install_defaults($user_id);
|
||||
|
||||
wp_install_maybe_enable_pretty_permalinks();
|
||||
|
||||
flush_rewrite_rules();
|
||||
|
||||
wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.') ) );
|
||||
@@ -108,9 +111,10 @@ endif;
|
||||
|
||||
if ( !function_exists('wp_install_defaults') ) :
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Creates the initial content for a newly-installed site.
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
* Adds the default "Uncategorized" category, the first post (with comment),
|
||||
* first page, and default widgets for default theme for the current version.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
@@ -140,9 +144,9 @@ function wp_install_defaults( $user_id ) {
|
||||
$cat_tt_id = $wpdb->insert_id;
|
||||
|
||||
// First post
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$now_gmt = gmdate('Y-m-d H:i:s');
|
||||
$first_post_guid = get_option('home') . '/?p=1';
|
||||
$now = current_time( 'mysql' );
|
||||
$now_gmt = current_time( 'mysql', 1 );
|
||||
$first_post_guid = get_option( 'home' ) . '/?p=1';
|
||||
|
||||
if ( is_multisite() ) {
|
||||
$first_post = get_site_option( 'first_post' );
|
||||
@@ -234,7 +238,7 @@ As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to d
|
||||
update_option( 'widget_archives', array ( 2 => array ( 'title' => '', 'count' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
|
||||
update_option( 'widget_categories', array ( 2 => array ( 'title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
|
||||
update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
|
||||
update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array (), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'sidebar-2' => array (), 'sidebar-3' => array (), 'array_version' => 3 ) );
|
||||
update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array (), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'array_version' => 3 ) );
|
||||
|
||||
if ( ! is_multisite() )
|
||||
update_user_meta( $user_id, 'show_welcome_panel', 1 );
|
||||
@@ -260,24 +264,100 @@ As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to d
|
||||
}
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Maybe enable pretty permalinks on install.
|
||||
*
|
||||
* If after enabling pretty permalinks don't work, fallback to query-string permalinks.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @global WP_Rewrite $wp_rewrite WordPress rewrite component.
|
||||
*
|
||||
* @return bool Whether pretty permalinks are enabled. False otherwise.
|
||||
*/
|
||||
function wp_install_maybe_enable_pretty_permalinks() {
|
||||
global $wp_rewrite;
|
||||
|
||||
// Bail if a permalink structure is already enabled.
|
||||
if ( get_option( 'permalink_structure' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* The Permalink structures to attempt.
|
||||
*
|
||||
* The first is designed for mod_rewrite or nginx rewriting.
|
||||
*
|
||||
* The second is PATHINFO-based permalinks for web server configurations
|
||||
* without a true rewrite module enabled.
|
||||
*/
|
||||
$permalink_structures = array(
|
||||
'/%year%/%monthnum%/%day%/%postname%/',
|
||||
'/index.php/%year%/%monthnum%/%day%/%postname%/'
|
||||
);
|
||||
|
||||
foreach ( (array) $permalink_structures as $permalink_structure ) {
|
||||
$wp_rewrite->set_permalink_structure( $permalink_structure );
|
||||
|
||||
/*
|
||||
* Flush rules with the hard option to force refresh of the web-server's
|
||||
* rewrite config file (e.g. .htaccess or web.config).
|
||||
*/
|
||||
$wp_rewrite->flush_rules( true );
|
||||
|
||||
// Test against a real WordPress Post, or if none were created, a random 404 page.
|
||||
$test_url = get_permalink( 1 );
|
||||
|
||||
if ( ! $test_url ) {
|
||||
$test_url = home_url( '/wordpress-check-for-rewrites/' );
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a request to the site, and check whether
|
||||
* the 'x-pingback' header is returned as expected.
|
||||
*
|
||||
* Uses wp_remote_get() instead of wp_remote_head() because web servers
|
||||
* can block head requests.
|
||||
*/
|
||||
$response = wp_remote_get( $test_url, array( 'timeout' => 5 ) );
|
||||
$x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' );
|
||||
$pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo( 'pingback_url' );
|
||||
|
||||
if ( $pretty_permalinks ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If it makes it this far, pretty permalinks failed.
|
||||
* Fallback to query-string permalinks.
|
||||
*/
|
||||
$wp_rewrite->set_permalink_structure( '' );
|
||||
$wp_rewrite->flush_rules( true );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !function_exists('wp_new_blog_notification') ) :
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Notifies the site admin that the setup is complete.
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
* Sends an email with wp_mail to the new administrator that the site setup is complete,
|
||||
* and provides them with a record of their login credentials.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $blog_title Blog title.
|
||||
* @param string $blog_url Blog url.
|
||||
* @param int $user_id User ID.
|
||||
* @param string $password User's Password.
|
||||
* @param string $blog_url Blog url.
|
||||
* @param int $user_id User ID.
|
||||
* @param string $password User's Password.
|
||||
*/
|
||||
function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
|
||||
$user = new WP_User( $user_id );
|
||||
$email = $user->user_email;
|
||||
$name = $user->user_login;
|
||||
$message = sprintf(__("Your new WordPress site has been successfully set up at:
|
||||
$login_url = wp_login_url();
|
||||
$message = sprintf( __( "Your new WordPress site has been successfully set up at:
|
||||
|
||||
%1\$s
|
||||
|
||||
@@ -285,12 +365,13 @@ You can log in to the administrator account with the following information:
|
||||
|
||||
Username: %2\$s
|
||||
Password: %3\$s
|
||||
Log in here: %4\$s
|
||||
|
||||
We hope you enjoy your new site. Thanks!
|
||||
|
||||
--The WordPress Team
|
||||
https://wordpress.org/
|
||||
"), $blog_url, $name, $password);
|
||||
"), $blog_url, $name, $password, $login_url );
|
||||
|
||||
@wp_mail($email, __('New WordPress Site'), $message);
|
||||
}
|
||||
@@ -298,13 +379,13 @@ endif;
|
||||
|
||||
if ( !function_exists('wp_upgrade') ) :
|
||||
/**
|
||||
* Run WordPress Upgrade functions.
|
||||
* Runs WordPress Upgrade functions.
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
* Upgrades the database if needed during a site update.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @return null
|
||||
* @return null If no update is necessary or site isn't completely installed, null.
|
||||
*/
|
||||
function wp_upgrade() {
|
||||
global $wp_current_db_version, $wp_db_version, $wpdb;
|
||||
@@ -349,9 +430,12 @@ endif;
|
||||
/**
|
||||
* Functions to be called in install and upgrade scripts.
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
* Contains conditional checks to determine which upgrade scripts to run,
|
||||
* based on database version and WP version being updated-to.
|
||||
*
|
||||
* @since 1.0.1
|
||||
*
|
||||
* @return null If no update is necessary, null.
|
||||
*/
|
||||
function upgrade_all() {
|
||||
global $wp_current_db_version, $wp_db_version;
|
||||
@@ -440,6 +524,12 @@ function upgrade_all() {
|
||||
if ( $wp_current_db_version < 29630 )
|
||||
upgrade_400();
|
||||
|
||||
if ( $wp_current_db_version < 31351 )
|
||||
upgrade_420();
|
||||
|
||||
if ( $wp_current_db_version < 31533 )
|
||||
upgrade_421();
|
||||
|
||||
maybe_disable_link_manager();
|
||||
|
||||
maybe_disable_automattic_widgets();
|
||||
@@ -483,6 +573,7 @@ function upgrade_100() {
|
||||
|
||||
$done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
|
||||
if ($done_ids) :
|
||||
$done_posts = array();
|
||||
foreach ($done_ids as $done_id) :
|
||||
$done_posts[] = $done_id->post_id;
|
||||
endforeach;
|
||||
@@ -767,7 +858,7 @@ function upgrade_210() {
|
||||
if ( 'static' == $status ) {
|
||||
$status = 'publish';
|
||||
$type = 'page';
|
||||
} else if ( 'attachment' == $status ) {
|
||||
} elseif ( 'attachment' == $status ) {
|
||||
$status = 'inherit';
|
||||
$type = 'attachment';
|
||||
}
|
||||
@@ -1327,7 +1418,55 @@ function upgrade_400() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute network level changes
|
||||
* Execute changes made in WordPress 4.2.0.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*/
|
||||
function upgrade_420() {
|
||||
global $wp_current_db_version, $wpdb;
|
||||
|
||||
if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) {
|
||||
if ( is_multisite() ) {
|
||||
$tables = $wpdb->tables( 'blog' );
|
||||
} else {
|
||||
$tables = $wpdb->tables( 'all' );
|
||||
}
|
||||
|
||||
foreach ( $tables as $table ) {
|
||||
maybe_convert_table_to_utf8mb4( $table );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute changes made in WordPress 4.2.1.
|
||||
*
|
||||
* @since 4.2.1
|
||||
*/
|
||||
function upgrade_421() {
|
||||
global $wp_current_db_version, $wpdb;
|
||||
|
||||
if ( $wp_current_db_version < 31533 ) {
|
||||
$content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
|
||||
if ( ! $content_length ) {
|
||||
$content_length = 65535;
|
||||
}
|
||||
|
||||
$comments = $wpdb->get_results(
|
||||
"SELECT comment_ID FROM $wpdb->comments
|
||||
WHERE comment_date_gmt > '2015-04-26'
|
||||
AND CHAR_LENGTH( comment_content ) >= $content_length
|
||||
AND ( comment_content LIKE '%<%' OR comment_content LIKE '%>%' )"
|
||||
);
|
||||
|
||||
foreach ( $comments as $comment ) {
|
||||
wp_delete_comment( $comment->comment_ID, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes network-level upgrade routines.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
@@ -1422,16 +1561,34 @@ function upgrade_network() {
|
||||
update_site_option( 'illegal_names', $illegal_names );
|
||||
}
|
||||
}
|
||||
|
||||
// 4.2
|
||||
if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) {
|
||||
if ( ! ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) && DO_NOT_UPGRADE_GLOBAL_TABLES ) ) {
|
||||
$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" );
|
||||
|
||||
$tables = $wpdb->tables( 'global' );
|
||||
|
||||
foreach ( $tables as $table ) {
|
||||
maybe_convert_table_to_utf8mb4( $table );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The functions we use to actually do stuff
|
||||
|
||||
// General
|
||||
//
|
||||
// General functions we use to actually do stuff
|
||||
//
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Creates a table in the database if it doesn't already exist.
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
* This method checks for an existing database and creates a new one if it's not
|
||||
* already present. It doesn't rely on MySQL's "IF NOT EXISTS" statement, but chooses
|
||||
* to query all tables first and then run the SQL statement creating the table.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
@@ -1459,9 +1616,7 @@ function maybe_create_table($table_name, $create_ddl) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
* Drops a specified index from a table.
|
||||
*
|
||||
* @since 1.0.1
|
||||
*
|
||||
@@ -1482,9 +1637,7 @@ function drop_index($table, $index) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
* Adds an index to a specified table.
|
||||
*
|
||||
* @since 1.0.1
|
||||
*
|
||||
@@ -1500,10 +1653,14 @@ function add_clean_index($table, $index) {
|
||||
}
|
||||
|
||||
/**
|
||||
** maybe_add_column()
|
||||
** Add column to db table if it doesn't exist.
|
||||
** Returns: true if already exists or on successful completion
|
||||
** false on error
|
||||
* Adds column to a database table if it doesn't already exist.
|
||||
*
|
||||
* @since 1.3.0
|
||||
*
|
||||
* @param string $table_name The table name to modify.
|
||||
* @param string $column_name The column name to add to the table.
|
||||
* @param string $create_ddl The SQL statement used to add the column.
|
||||
* @return True if already exists or on successful completion, false on error.
|
||||
*/
|
||||
function maybe_add_column($table_name, $column_name, $create_ddl) {
|
||||
global $wpdb;
|
||||
@@ -1525,12 +1682,42 @@ function maybe_add_column($table_name, $column_name, $create_ddl) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a table only contains utf8 or utf8mb4 columns, convert it to utf8mb4.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
* @param string $table The table to convert.
|
||||
* @return bool true if the table was converted, false if it wasn't.
|
||||
*/
|
||||
function maybe_convert_table_to_utf8mb4( $table ) {
|
||||
global $wpdb;
|
||||
|
||||
$results = $wpdb->get_results( "SHOW FULL COLUMNS FROM `$table`" );
|
||||
if ( ! $results ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $results as $column ) {
|
||||
if ( $column->Collation ) {
|
||||
list( $charset ) = explode( '_', $column->Collation );
|
||||
$charset = strtolower( $charset );
|
||||
if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) {
|
||||
// Don't upgrade tables that have non-utf8 columns.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all options as it was for 1.2.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*
|
||||
* @return array List of options.
|
||||
* @return stdClass List of options.
|
||||
*/
|
||||
function get_alloptions_110() {
|
||||
global $wpdb;
|
||||
@@ -1546,8 +1733,9 @@ function get_alloptions_110() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of get_option that is private to install/upgrade.
|
||||
* Utility version of get_option that is private to install/upgrade.
|
||||
*
|
||||
* @ignore
|
||||
* @since 1.5.1
|
||||
* @access private
|
||||
*
|
||||
@@ -1575,14 +1763,12 @@ function __get_option($setting) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
* Filters for content to remove unnecessary slashes.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param string $content
|
||||
* @return string
|
||||
* @param string $content The content to modify.
|
||||
* @return string The de-slashed content.
|
||||
*/
|
||||
function deslash($content) {
|
||||
// Note: \\\ inside a regex denotes a single backslash.
|
||||
@@ -1606,15 +1792,18 @@ function deslash($content) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Modifies the database based on specified SQL statements.
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
* Useful for creating new tables and updating existing tables to a new structure.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param unknown_type $queries
|
||||
* @param unknown_type $execute
|
||||
* @return unknown
|
||||
* @param string|array $queries Optional. The query to run. Can be multiple queries
|
||||
* in an array, or a string of queries separated by
|
||||
* semicolons. Default empty.
|
||||
* @param bool $execute Optional. Whether or not to execute the query right away.
|
||||
* Default true.
|
||||
* @return array Strings containing the results of the various update queries.
|
||||
*/
|
||||
function dbDelta( $queries = '', $execute = true ) {
|
||||
global $wpdb;
|
||||
@@ -1643,14 +1832,14 @@ function dbDelta( $queries = '', $execute = true ) {
|
||||
|
||||
// Create a tablename index for an array ($cqueries) of queries
|
||||
foreach($queries as $qry) {
|
||||
if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
|
||||
if ( preg_match( "|CREATE TABLE ([^ ]*)|", $qry, $matches ) ) {
|
||||
$cqueries[ trim( $matches[1], '`' ) ] = $qry;
|
||||
$for_update[$matches[1]] = 'Created table '.$matches[1];
|
||||
} else if (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
|
||||
array_unshift($cqueries, $qry);
|
||||
} else if (preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
|
||||
} elseif ( preg_match( "|CREATE DATABASE ([^ ]*)|", $qry, $matches ) ) {
|
||||
array_unshift( $cqueries, $qry );
|
||||
} elseif ( preg_match( "|INSERT INTO ([^ ]*)|", $qry, $matches ) ) {
|
||||
$iqueries[] = $qry;
|
||||
} else if (preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
|
||||
} elseif ( preg_match( "|UPDATE ([^ ]*)|", $qry, $matches ) ) {
|
||||
$iqueries[] = $qry;
|
||||
} else {
|
||||
// Unrecognized query type
|
||||
@@ -1784,7 +1973,7 @@ function dbDelta( $queries = '', $execute = true ) {
|
||||
|
||||
if ($tableindices) {
|
||||
// Clear the index array.
|
||||
unset($index_ary);
|
||||
$index_ary = array();
|
||||
|
||||
// For every index in the table.
|
||||
foreach ($tableindices as $tableindex) {
|
||||
@@ -1802,7 +1991,7 @@ function dbDelta( $queries = '', $execute = true ) {
|
||||
$index_string = '';
|
||||
if ($index_name == 'PRIMARY') {
|
||||
$index_string .= 'PRIMARY ';
|
||||
} else if($index_data['unique']) {
|
||||
} elseif ( $index_data['unique'] ) {
|
||||
$index_string .= 'UNIQUE ';
|
||||
}
|
||||
$index_string .= 'KEY ';
|
||||
@@ -1821,12 +2010,23 @@ function dbDelta( $queries = '', $execute = true ) {
|
||||
$index_columns .= '('.$column_data['subpart'].')';
|
||||
}
|
||||
}
|
||||
|
||||
// The alternative index string doesn't care about subparts
|
||||
$alt_index_columns = preg_replace( '/\([^)]*\)/', '', $index_columns );
|
||||
|
||||
// Add the column list to the index create string.
|
||||
$index_string .= ' ('.$index_columns.')';
|
||||
if (!(($aindex = array_search($index_string, $indices)) === false)) {
|
||||
unset($indices[$aindex]);
|
||||
// todo: Remove this?
|
||||
//echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
|
||||
$index_strings = array(
|
||||
"$index_string ($index_columns)",
|
||||
"$index_string ($alt_index_columns)",
|
||||
);
|
||||
|
||||
foreach( $index_strings as $index_string ) {
|
||||
if ( ! ( ( $aindex = array_search( $index_string, $indices ) ) === false ) ) {
|
||||
unset( $indices[ $aindex ] );
|
||||
break;
|
||||
// todo: Remove this?
|
||||
//echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
|
||||
}
|
||||
}
|
||||
// todo: Remove this?
|
||||
//else echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br /><b>Did not find index:</b>".$index_string."<br />".print_r($indices, true)."</pre>\n";
|
||||
@@ -1857,11 +2057,16 @@ function dbDelta( $queries = '', $execute = true ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Updates the database tables to a new schema.
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
* By default, updates all the tables to use the latest defined schema, but can also
|
||||
* be used to update a specific set of tables in wp_get_db_schema().
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @uses dbDelta
|
||||
*
|
||||
* @param string $tables Optional. Which set of tables to update. Default is 'all'.
|
||||
*/
|
||||
function make_db_current( $tables = 'all' ) {
|
||||
$alterations = dbDelta( $tables );
|
||||
@@ -1871,26 +2076,31 @@ function make_db_current( $tables = 'all' ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Updates the database tables to a new schema, but without displaying results.
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
* By default, updates all the tables to use the latest defined schema, but can
|
||||
* also be used to update a specific set of tables in wp_get_db_schema().
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @see make_db_current()
|
||||
*
|
||||
* @param string $tables Optional. Which set of tables to update. Default is 'all'.
|
||||
*/
|
||||
function make_db_current_silent( $tables = 'all' ) {
|
||||
dbDelta( $tables );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Creates a site theme from an existing theme.
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param unknown_type $theme_name
|
||||
* @param unknown_type $template
|
||||
* @return unknown
|
||||
* @param string $theme_name The name of the theme.
|
||||
* @param string $template The directory name of the theme.
|
||||
* @return bool
|
||||
*/
|
||||
function make_site_theme_from_oldschool($theme_name, $template) {
|
||||
$home_path = get_home_path();
|
||||
@@ -1965,15 +2175,15 @@ function make_site_theme_from_oldschool($theme_name, $template) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Creates a site theme from the default theme.
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param unknown_type $theme_name
|
||||
* @param unknown_type $template
|
||||
* @return unknown
|
||||
* @param string $theme_name The name of the theme.
|
||||
* @param string $template The directory name of the theme.
|
||||
* @return null|false
|
||||
*/
|
||||
function make_site_theme_from_default($theme_name, $template) {
|
||||
$site_dir = WP_CONTENT_DIR . "/themes/$template";
|
||||
@@ -2029,15 +2239,14 @@ function make_site_theme_from_default($theme_name, $template) {
|
||||
@closedir($images_dir);
|
||||
}
|
||||
|
||||
// Create a site theme from the default theme.
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
* Creates a site theme.
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @return unknown
|
||||
* @return false|string
|
||||
*/
|
||||
function make_site_theme() {
|
||||
// Name the theme after the blog.
|
||||
@@ -2110,9 +2319,7 @@ function translate_level_to_role($level) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
* Checks the version of the installed MySQL binary.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@@ -2141,7 +2348,7 @@ function maybe_disable_automattic_widgets() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the Link Manager on upgrade, if at the time of upgrade, no links exist in the DB.
|
||||
* Disables the Link Manager on upgrade if, at the time of upgrade, no links exist in the DB.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
@@ -2188,6 +2395,23 @@ function pre_schema_upgrade() {
|
||||
$wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $wp_current_db_version < 30133 ) {
|
||||
// dbDelta() can recreate but can't drop the index.
|
||||
$wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug" );
|
||||
}
|
||||
|
||||
// Upgrade versions prior to 4.2.
|
||||
if ( $wp_current_db_version < 31351 ) {
|
||||
if ( ! is_multisite() ) {
|
||||
$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
|
||||
}
|
||||
$wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,7 +63,7 @@ function edit_user( $user_id = 0 ) {
|
||||
}
|
||||
|
||||
if ( isset( $_POST['email'] ))
|
||||
$user->user_email = sanitize_text_field( $_POST['email'] );
|
||||
$user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) );
|
||||
if ( isset( $_POST['url'] ) ) {
|
||||
if ( empty ( $_POST['url'] ) || $_POST['url'] == 'http://' ) {
|
||||
$user->user_url = '';
|
||||
@@ -195,7 +195,7 @@ function edit_user( $user_id = 0 ) {
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @return unknown
|
||||
* @return array
|
||||
*/
|
||||
function get_editable_roles() {
|
||||
global $wp_roles;
|
||||
@@ -257,7 +257,7 @@ function get_users_drafts( $user_id ) {
|
||||
/**
|
||||
* Remove user and optionally reassign posts and links to another user.
|
||||
*
|
||||
* If the $reassign parameter is not assigned to an User ID, then all posts will
|
||||
* If the $reassign parameter is not assigned to a User ID, then all posts will
|
||||
* be deleted of that user. The action 'delete_user' that is passed the User ID
|
||||
* being deleted will be run after the posts are either reassigned or deleted.
|
||||
* The user meta will also be deleted that are for that User ID.
|
||||
|
||||
@@ -205,7 +205,7 @@ function wp_widget_control( $sidebar_args ) {
|
||||
</div>
|
||||
|
||||
<div class="widget-inside">
|
||||
<form action="" method="post">
|
||||
<form method="post">
|
||||
<div class="widget-content">
|
||||
<?php
|
||||
if ( isset($control['callback']) )
|
||||
|
||||
Reference in new issue
Block a user