Update WordPress to 5.2
This commit is contained in:
parent
489b5a5914
commit
e00f87f2f5
599 changed files with 119573 additions and 55990 deletions
|
@ -117,7 +117,10 @@ add_action( 'load-plugins.php', 'wp_plugin_update_rows', 20 ); // After wp_updat
|
|||
add_action( 'load-themes.php', 'wp_theme_update_rows', 20 ); // After wp_update_themes() is called.
|
||||
|
||||
add_action( 'admin_notices', 'update_nag', 3 );
|
||||
add_action( 'admin_notices', 'paused_plugins_notice', 5 );
|
||||
add_action( 'admin_notices', 'paused_themes_notice', 5 );
|
||||
add_action( 'admin_notices', 'maintenance_nag', 10 );
|
||||
add_action( 'admin_notices', 'wp_recovery_mode_nag', 1 );
|
||||
|
||||
add_filter( 'update_footer', 'core_update_footer' );
|
||||
|
||||
|
|
|
@ -460,7 +460,7 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
|
|||
),
|
||||
'i18n_moderation_text' => sprintf(
|
||||
/* translators: %s: number of comments in moderation */
|
||||
_nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ),
|
||||
_n( '%s Comment in moderation', '%s Comments in moderation', $counts->moderated ),
|
||||
number_format_i18n( $counts->moderated )
|
||||
),
|
||||
'comment_link' => $comment_link,
|
||||
|
@ -509,21 +509,27 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
|
|||
// The time since the last comment count.
|
||||
$time = time();
|
||||
$comment = get_comment( $comment_id );
|
||||
$counts = wp_count_comments();
|
||||
|
||||
$x = new WP_Ajax_Response(
|
||||
array(
|
||||
'what' => 'comment',
|
||||
// Here for completeness - not used.
|
||||
'id' => $comment_id,
|
||||
'supplemental' => array(
|
||||
'status' => $comment ? $comment->comment_approved : '',
|
||||
'postId' => $comment ? $comment->comment_post_ID : '',
|
||||
'status' => $comment ? $comment->comment_approved : '',
|
||||
'postId' => $comment ? $comment->comment_post_ID : '',
|
||||
/* translators: %s: number of comments */
|
||||
'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,
|
||||
'time' => $time,
|
||||
'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,
|
||||
'time' => $time,
|
||||
'in_moderation' => $counts->moderated,
|
||||
'i18n_moderation_text' => sprintf(
|
||||
/* translators: %s: number of comments in moderation */
|
||||
_n( '%s Comment in moderation', '%s Comments in moderation', $counts->moderated ),
|
||||
number_format_i18n( $counts->moderated )
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
@ -1021,7 +1027,9 @@ function wp_ajax_add_tag() {
|
|||
|
||||
$wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) );
|
||||
|
||||
$level = 0;
|
||||
$level = 0;
|
||||
$noparents = '';
|
||||
|
||||
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
|
||||
$level = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) );
|
||||
ob_start();
|
||||
|
@ -1291,8 +1299,8 @@ function wp_ajax_replyto_comment( $action ) {
|
|||
number_format_i18n( $counts->approved )
|
||||
),
|
||||
'i18n_moderation_text' => sprintf(
|
||||
/* translators: %s: number of comments moderated */
|
||||
_nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ),
|
||||
/* translators: %s: number of comments in moderation */
|
||||
_n( '%s Comment in moderation', '%s Comments in moderation', $counts->moderated ),
|
||||
number_format_i18n( $counts->moderated )
|
||||
),
|
||||
);
|
||||
|
@ -1466,7 +1474,7 @@ function wp_ajax_add_meta() {
|
|||
$post_data['post_ID'] = $pid;
|
||||
$post_data['post_type'] = $post->post_type;
|
||||
$post_data['post_status'] = 'draft';
|
||||
$now = current_time( 'timestamp', 1 );
|
||||
$now = time();
|
||||
/* translators: 1: Post creation date, 2: Post creation time */
|
||||
$post_data['post_title'] = sprintf( __( 'Draft created on %1$s at %2$s' ), date( __( 'F j, Y' ), $now ), date( __( 'g:i a' ), $now ) );
|
||||
|
||||
|
@ -3260,7 +3268,12 @@ function wp_ajax_query_themes() {
|
|||
wp_unslash( $_REQUEST['request'] ),
|
||||
array(
|
||||
'per_page' => 20,
|
||||
'fields' => $theme_field_defaults,
|
||||
'fields' => array_merge(
|
||||
(array) $theme_field_defaults,
|
||||
array(
|
||||
'reviews_url' => true, // Explicitly request the reviews URL to be linked from the Add Themes screen.
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -3607,7 +3620,7 @@ function wp_ajax_crop_image() {
|
|||
|
||||
switch ( $context ) {
|
||||
case 'site-icon':
|
||||
require_once ABSPATH . '/wp-admin/includes/class-wp-site-icon.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-site-icon.php';
|
||||
$wp_site_icon = new WP_Site_Icon();
|
||||
|
||||
// Skip creating a new attachment if the attachment is a Site Icon.
|
||||
|
@ -3653,13 +3666,13 @@ function wp_ajax_crop_image() {
|
|||
$cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
|
||||
|
||||
$parent_url = wp_get_attachment_url( $attachment_id );
|
||||
$url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
|
||||
$url = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url );
|
||||
|
||||
$size = @getimagesize( $cropped );
|
||||
$image_type = ( $size ) ? $size['mime'] : 'image/jpeg';
|
||||
|
||||
$object = array(
|
||||
'post_title' => basename( $cropped ),
|
||||
'post_title' => wp_basename( $cropped ),
|
||||
'post_content' => $url,
|
||||
'post_mime_type' => $image_type,
|
||||
'guid' => $url,
|
||||
|
@ -4454,7 +4467,7 @@ function wp_ajax_wp_privacy_export_personal_data() {
|
|||
}
|
||||
|
||||
if ( ! current_user_can( 'export_others_personal_data' ) ) {
|
||||
wp_send_json_error( __( 'Invalid request.' ) );
|
||||
wp_send_json_error( __( 'Sorry, you are not allowed to perform this action.' ) );
|
||||
}
|
||||
|
||||
check_ajax_referer( 'wp-privacy-export-personal-data-' . $request_id, 'security' );
|
||||
|
@ -4515,7 +4528,7 @@ function wp_ajax_wp_privacy_export_personal_data() {
|
|||
}
|
||||
|
||||
if ( $exporter_index > count( $exporters ) ) {
|
||||
wp_send_json_error( __( 'Exporter index out of range.' ) );
|
||||
wp_send_json_error( __( 'Exporter index is out of range.' ) );
|
||||
}
|
||||
|
||||
if ( $page < 1 ) {
|
||||
|
@ -4528,33 +4541,35 @@ function wp_ajax_wp_privacy_export_personal_data() {
|
|||
|
||||
if ( ! is_array( $exporter ) ) {
|
||||
wp_send_json_error(
|
||||
/* translators: %s: array index */
|
||||
/* translators: %s: exporter array index */
|
||||
sprintf( __( 'Expected an array describing the exporter at index %s.' ), $exporter_key )
|
||||
);
|
||||
}
|
||||
if ( ! array_key_exists( 'exporter_friendly_name', $exporter ) ) {
|
||||
wp_send_json_error(
|
||||
/* translators: %s: array index */
|
||||
/* translators: %s: exporter array index */
|
||||
sprintf( __( 'Exporter array at index %s does not include a friendly name.' ), $exporter_key )
|
||||
);
|
||||
}
|
||||
|
||||
$exporter_friendly_name = $exporter['exporter_friendly_name'];
|
||||
|
||||
if ( ! array_key_exists( 'callback', $exporter ) ) {
|
||||
wp_send_json_error(
|
||||
/* translators: %s: exporter friendly name */
|
||||
sprintf( __( 'Exporter does not include a callback: %s.' ), esc_html( $exporter['exporter_friendly_name'] ) )
|
||||
sprintf( __( 'Exporter does not include a callback: %s.' ), esc_html( $exporter_friendly_name ) )
|
||||
);
|
||||
}
|
||||
if ( ! is_callable( $exporter['callback'] ) ) {
|
||||
wp_send_json_error(
|
||||
/* translators: %s: exporter friendly name */
|
||||
sprintf( __( 'Exporter callback is not a valid callback: %s.' ), esc_html( $exporter['exporter_friendly_name'] ) )
|
||||
sprintf( __( 'Exporter callback is not a valid callback: %s.' ), esc_html( $exporter_friendly_name ) )
|
||||
);
|
||||
}
|
||||
|
||||
$callback = $exporter['callback'];
|
||||
$exporter_friendly_name = $exporter['exporter_friendly_name'];
|
||||
|
||||
$callback = $exporter['callback'];
|
||||
$response = call_user_func( $callback, $email_address, $page );
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
wp_send_json_error( $response );
|
||||
}
|
||||
|
@ -4636,7 +4651,7 @@ function wp_ajax_wp_privacy_erase_personal_data() {
|
|||
|
||||
// Both capabilities are required to avoid confusion, see `_wp_personal_data_removal_page()`.
|
||||
if ( ! current_user_can( 'erase_others_personal_data' ) || ! current_user_can( 'delete_users' ) ) {
|
||||
wp_send_json_error( __( 'Invalid request.' ) );
|
||||
wp_send_json_error( __( 'Sorry, you are not allowed to perform this action.' ) );
|
||||
}
|
||||
|
||||
check_ajax_referer( 'wp-privacy-erase-personal-data-' . $request_id, 'security' );
|
||||
|
@ -4645,7 +4660,7 @@ function wp_ajax_wp_privacy_erase_personal_data() {
|
|||
$request = wp_get_user_request_data( $request_id );
|
||||
|
||||
if ( ! $request || 'remove_personal_data' !== $request->action_name ) {
|
||||
wp_send_json_error( __( 'Invalid request ID.' ) );
|
||||
wp_send_json_error( __( 'Invalid request type.' ) );
|
||||
}
|
||||
|
||||
$email_address = $request->email;
|
||||
|
@ -4708,28 +4723,38 @@ function wp_ajax_wp_privacy_erase_personal_data() {
|
|||
$eraser = $erasers[ $eraser_key ];
|
||||
|
||||
if ( ! is_array( $eraser ) ) {
|
||||
/* translators: %d: array index */
|
||||
/* translators: %d: eraser array index */
|
||||
wp_send_json_error( sprintf( __( 'Expected an array describing the eraser at index %d.' ), $eraser_index ) );
|
||||
}
|
||||
|
||||
if ( ! array_key_exists( 'callback', $eraser ) ) {
|
||||
/* translators: %d: array index */
|
||||
wp_send_json_error( sprintf( __( 'Eraser array at index %d does not include a callback.' ), $eraser_index ) );
|
||||
}
|
||||
|
||||
if ( ! is_callable( $eraser['callback'] ) ) {
|
||||
/* translators: %d: array index */
|
||||
wp_send_json_error( sprintf( __( 'Eraser callback at index %d is not a valid callback.' ), $eraser_index ) );
|
||||
}
|
||||
|
||||
if ( ! array_key_exists( 'eraser_friendly_name', $eraser ) ) {
|
||||
/* translators: %d: array index */
|
||||
/* translators: %d: eraser array index */
|
||||
wp_send_json_error( sprintf( __( 'Eraser array at index %d does not include a friendly name.' ), $eraser_index ) );
|
||||
}
|
||||
|
||||
$callback = $eraser['callback'];
|
||||
$eraser_friendly_name = $eraser['eraser_friendly_name'];
|
||||
|
||||
if ( ! array_key_exists( 'callback', $eraser ) ) {
|
||||
wp_send_json_error(
|
||||
sprintf(
|
||||
/* translators: %s: eraser friendly name */
|
||||
__( 'Eraser does not include a callback: %s.' ),
|
||||
esc_html( $eraser_friendly_name )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! is_callable( $eraser['callback'] ) ) {
|
||||
wp_send_json_error(
|
||||
sprintf(
|
||||
/* translators: %s: eraser friendly name */
|
||||
__( 'Eraser callback is not valid: %s.' ),
|
||||
esc_html( $eraser_friendly_name )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$callback = $eraser['callback'];
|
||||
$response = call_user_func( $callback, $email_address, $page );
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
|
@ -4739,7 +4764,7 @@ function wp_ajax_wp_privacy_erase_personal_data() {
|
|||
if ( ! is_array( $response ) ) {
|
||||
wp_send_json_error(
|
||||
sprintf(
|
||||
/* translators: 1: eraser friendly name, 2: array index */
|
||||
/* translators: 1: eraser friendly name, 2: eraser array index */
|
||||
__( 'Did not receive array from %1$s eraser (index %2$d).' ),
|
||||
esc_html( $eraser_friendly_name ),
|
||||
$eraser_index
|
||||
|
@ -4750,7 +4775,7 @@ function wp_ajax_wp_privacy_erase_personal_data() {
|
|||
if ( ! array_key_exists( 'items_removed', $response ) ) {
|
||||
wp_send_json_error(
|
||||
sprintf(
|
||||
/* translators: 1: eraser friendly name, 2: array index */
|
||||
/* translators: 1: eraser friendly name, 2: eraser array index */
|
||||
__( 'Expected items_removed key in response array from %1$s eraser (index %2$d).' ),
|
||||
esc_html( $eraser_friendly_name ),
|
||||
$eraser_index
|
||||
|
@ -4761,7 +4786,7 @@ function wp_ajax_wp_privacy_erase_personal_data() {
|
|||
if ( ! array_key_exists( 'items_retained', $response ) ) {
|
||||
wp_send_json_error(
|
||||
sprintf(
|
||||
/* translators: 1: eraser friendly name, 2: array index */
|
||||
/* translators: 1: eraser friendly name, 2: eraser array index */
|
||||
__( 'Expected items_retained key in response array from %1$s eraser (index %2$d).' ),
|
||||
esc_html( $eraser_friendly_name ),
|
||||
$eraser_index
|
||||
|
@ -4772,7 +4797,7 @@ function wp_ajax_wp_privacy_erase_personal_data() {
|
|||
if ( ! array_key_exists( 'messages', $response ) ) {
|
||||
wp_send_json_error(
|
||||
sprintf(
|
||||
/* translators: 1: eraser friendly name, 2: array index */
|
||||
/* translators: 1: eraser friendly name, 2: eraser array index */
|
||||
__( 'Expected messages key in response array from %1$s eraser (index %2$d).' ),
|
||||
esc_html( $eraser_friendly_name ),
|
||||
$eraser_index
|
||||
|
@ -4783,7 +4808,7 @@ function wp_ajax_wp_privacy_erase_personal_data() {
|
|||
if ( ! is_array( $response['messages'] ) ) {
|
||||
wp_send_json_error(
|
||||
sprintf(
|
||||
/* translators: 1: eraser friendly name, 2: array index */
|
||||
/* translators: 1: eraser friendly name, 2: eraser array index */
|
||||
__( 'Expected messages key to reference an array in response array from %1$s eraser (index %2$d).' ),
|
||||
esc_html( $eraser_friendly_name ),
|
||||
$eraser_index
|
||||
|
@ -4794,7 +4819,7 @@ function wp_ajax_wp_privacy_erase_personal_data() {
|
|||
if ( ! array_key_exists( 'done', $response ) ) {
|
||||
wp_send_json_error(
|
||||
sprintf(
|
||||
/* translators: 1: eraser friendly name, 2: array index */
|
||||
/* translators: 1: eraser friendly name, 2: eraser array index */
|
||||
__( 'Expected done flag in response array from %1$s eraser (index %2$d).' ),
|
||||
esc_html( $eraser_friendly_name ),
|
||||
$eraser_index
|
||||
|
@ -4835,3 +4860,154 @@ function wp_ajax_wp_privacy_erase_personal_data() {
|
|||
|
||||
wp_send_json_success( $response );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for site health checks on server communication.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
function wp_ajax_health_check_dotorg_communication() {
|
||||
check_ajax_referer( 'health-check-site-status' );
|
||||
|
||||
if ( ! current_user_can( 'install_plugins' ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WP_Site_Health' ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
|
||||
}
|
||||
|
||||
$site_health = new WP_Site_Health();
|
||||
wp_send_json_success( $site_health->get_test_dotorg_communication() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for site health checks on debug mode.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
function wp_ajax_health_check_is_in_debug_mode() {
|
||||
wp_verify_nonce( 'health-check-site-status' );
|
||||
|
||||
if ( ! current_user_can( 'install_plugins' ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WP_Site_Health' ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
|
||||
}
|
||||
|
||||
$site_health = new WP_Site_Health();
|
||||
wp_send_json_success( $site_health->get_test_is_in_debug_mode() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for site health checks on background updates.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
function wp_ajax_health_check_background_updates() {
|
||||
check_ajax_referer( 'health-check-site-status' );
|
||||
|
||||
if ( ! current_user_can( 'install_plugins' ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WP_Site_Health' ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
|
||||
}
|
||||
|
||||
$site_health = new WP_Site_Health();
|
||||
wp_send_json_success( $site_health->get_test_background_updates() );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ajax handler for site health checks on loopback requests.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
function wp_ajax_health_check_loopback_requests() {
|
||||
check_ajax_referer( 'health-check-site-status' );
|
||||
|
||||
if ( ! current_user_can( 'install_plugins' ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WP_Site_Health' ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
|
||||
}
|
||||
|
||||
$site_health = new WP_Site_Health();
|
||||
wp_send_json_success( $site_health->get_test_loopback_requests() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for site health check to update the result status.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
function wp_ajax_health_check_site_status_result() {
|
||||
check_ajax_referer( 'health-check-site-status-result' );
|
||||
|
||||
if ( ! current_user_can( 'install_plugins' ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
set_transient( 'health-check-site-status-result', wp_json_encode( $_POST['counts'] ) );
|
||||
|
||||
wp_send_json_success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for site health check to get directories and database sizes.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
function wp_ajax_health_check_get_sizes() {
|
||||
check_ajax_referer( 'health-check-site-status-result' );
|
||||
|
||||
if ( ! current_user_can( 'install_plugins' ) || is_multisite() ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WP_Debug_Data' ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-debug-data.php' );
|
||||
}
|
||||
|
||||
$sizes_data = WP_Debug_Data::get_sizes();
|
||||
$all_sizes = array( 'raw' => 0 );
|
||||
|
||||
foreach ( $sizes_data as $name => $value ) {
|
||||
$name = sanitize_text_field( $name );
|
||||
$data = array();
|
||||
|
||||
if ( isset( $value['size'] ) ) {
|
||||
if ( is_string( $value['size'] ) ) {
|
||||
$data['size'] = sanitize_text_field( $value['size'] );
|
||||
} else {
|
||||
$data['size'] = (int) $value['size'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $value['debug'] ) ) {
|
||||
if ( is_string( $value['debug'] ) ) {
|
||||
$data['debug'] = sanitize_text_field( $value['debug'] );
|
||||
} else {
|
||||
$data['debug'] = (int) $value['debug'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $value['raw'] ) ) {
|
||||
$data['raw'] = (int) $value['raw'];
|
||||
}
|
||||
|
||||
$all_sizes[ $name ] = $data;
|
||||
}
|
||||
|
||||
if ( isset( $all_sizes['total_size']['debug'] ) && 'not available' === $all_sizes['total_size']['debug'] ) {
|
||||
wp_send_json_error( $all_sizes );
|
||||
}
|
||||
|
||||
wp_send_json_success( $all_sizes );
|
||||
}
|
||||
|
|
|
@ -121,7 +121,26 @@ class Core_Upgrader extends WP_Upgrader {
|
|||
return new WP_Error( 'locked', $this->strings['locked'] );
|
||||
}
|
||||
|
||||
$download = $this->download_package( $current->packages->$to_download );
|
||||
$download = $this->download_package( $current->packages->$to_download, true );
|
||||
|
||||
// Allow for signature soft-fail.
|
||||
// WARNING: This may be removed in the future.
|
||||
if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) {
|
||||
// Outout the failure error as a normal feedback, and not as an error:
|
||||
apply_filters( 'update_feedback', $download->get_error_message() );
|
||||
|
||||
// Report this failure back to WordPress.org for debugging purposes.
|
||||
wp_version_check(
|
||||
array(
|
||||
'signature_failure_code' => $download->get_error_code(),
|
||||
'signature_failure_data' => $download->get_error_data(),
|
||||
)
|
||||
);
|
||||
|
||||
// Pretend this error didn't happen.
|
||||
$download = $download->get_error_data( 'softfail-filename' );
|
||||
}
|
||||
|
||||
if ( is_wp_error( $download ) ) {
|
||||
WP_Upgrader::release_lock( 'core_updater' );
|
||||
return $download;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* PemFTP - A Ftp implementation in pure PHP
|
||||
* PemFTP - An Ftp implementation in pure PHP
|
||||
*
|
||||
* @package PemFTP
|
||||
* @since 2.5.0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* PemFTP - A Ftp implementation in pure PHP
|
||||
* PemFTP - An Ftp implementation in pure PHP
|
||||
*
|
||||
* @package PemFTP
|
||||
* @since 2.5.0
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* PemFTP - A Ftp implementation in pure PHP
|
||||
* PemFTP - An Ftp implementation in pure PHP
|
||||
*
|
||||
* @package PemFTP
|
||||
* @since 2.5
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @version 1.0
|
||||
* @copyright Alexey Dotsenko
|
||||
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* This can be redefined.
|
||||
*
|
||||
* @since 2.5
|
||||
* @since 2.5.0
|
||||
* @var string
|
||||
*/
|
||||
if(!defined('CRLF')) define('CRLF',"\r\n");
|
||||
|
@ -27,7 +27,7 @@ if(!defined('CRLF')) define('CRLF',"\r\n");
|
|||
*
|
||||
* This can be redefined.
|
||||
*
|
||||
* @since 2.5
|
||||
* @since 2.5.0
|
||||
* @var int
|
||||
*/
|
||||
if(!defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1);
|
||||
|
@ -35,7 +35,7 @@ if(!defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1);
|
|||
/**
|
||||
*
|
||||
* This can be redefined.
|
||||
* @since 2.5
|
||||
* @since 2.5.0
|
||||
* @var int
|
||||
*/
|
||||
if(!defined("FTP_BINARY")) define("FTP_BINARY", 1);
|
||||
|
@ -43,7 +43,7 @@ if(!defined("FTP_BINARY")) define("FTP_BINARY", 1);
|
|||
/**
|
||||
*
|
||||
* This can be redefined.
|
||||
* @since 2.5
|
||||
* @since 2.5.0
|
||||
* @var int
|
||||
*/
|
||||
if(!defined("FTP_ASCII")) define("FTP_ASCII", 0);
|
||||
|
@ -53,25 +53,25 @@ if(!defined("FTP_ASCII")) define("FTP_ASCII", 0);
|
|||
*
|
||||
* This can be redefined.
|
||||
*
|
||||
* @since 2.5
|
||||
* @since 2.5.0
|
||||
* @var bool
|
||||
*/
|
||||
if(!defined('FTP_FORCE')) define('FTP_FORCE', true);
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
* @since 2.5.0
|
||||
* @var string
|
||||
*/
|
||||
define('FTP_OS_Unix','u');
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
* @since 2.5.0
|
||||
* @var string
|
||||
*/
|
||||
define('FTP_OS_Windows','w');
|
||||
|
||||
/**
|
||||
* @since 2.5
|
||||
* @since 2.5.0
|
||||
* @var string
|
||||
*/
|
||||
define('FTP_OS_Mac','m');
|
||||
|
|
|
@ -205,6 +205,13 @@ class WP_Automatic_Updater {
|
|||
}
|
||||
}
|
||||
|
||||
// If updating a plugin, ensure the minimum PHP version requirements are satisfied.
|
||||
if ( 'plugin' === $type ) {
|
||||
if ( ! empty( $item->requires_php ) && version_compare( phpversion(), $item->requires_php, '<' ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -641,18 +648,18 @@ class WP_Automatic_Updater {
|
|||
|
||||
switch ( $type ) {
|
||||
case 'success': // We updated.
|
||||
/* translators: 1: Site name, 2: WordPress version number. */
|
||||
/* translators: Site updated notification email subject. 1: Site title, 2: WordPress version number. */
|
||||
$subject = __( '[%1$s] Your site has updated to WordPress %2$s' );
|
||||
break;
|
||||
|
||||
case 'fail': // We tried to update but couldn't.
|
||||
case 'manual': // We can't update (and made no attempt).
|
||||
/* translators: 1: Site name, 2: WordPress version number. */
|
||||
/* translators: Update available notification email subject. 1: Site title, 2: WordPress version number. */
|
||||
$subject = __( '[%1$s] WordPress %2$s is available. Please update!' );
|
||||
break;
|
||||
|
||||
case 'critical': // We tried to update, started to copy files, then things went wrong.
|
||||
/* translators: 1: Site name. */
|
||||
/* translators: Site down notification email subject. 1: Site title. */
|
||||
$subject = __( '[%1$s] URGENT: Your site may be down due to a failed update' );
|
||||
break;
|
||||
|
||||
|
@ -904,11 +911,11 @@ Thanks! -- The WordPress Team"
|
|||
);
|
||||
$body[] = '';
|
||||
|
||||
/* translators: %s: site title */
|
||||
$subject = sprintf( __( '[%s] There were failures during background updates' ), $site_title );
|
||||
/* translators: Background update failed notification email subject. %s: Site title */
|
||||
$subject = sprintf( __( '[%s] Background Update Failed' ), $site_title );
|
||||
} else {
|
||||
/* translators: %s: site title */
|
||||
$subject = sprintf( __( '[%s] Background updates have finished' ), $site_title );
|
||||
/* translators: Background update finished notification email subject. %s: Site title */
|
||||
$subject = sprintf( __( '[%s] Background Update Finished' ), $site_title );
|
||||
}
|
||||
|
||||
$body[] = trim(
|
||||
|
|
|
@ -618,29 +618,29 @@ 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 ) {
|
||||
$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' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
||||
$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 aria-button-if-js' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
||||
} 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' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
||||
$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 aria-button-if-js' aria-label='" . 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' aria-label='" . 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' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
||||
$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 aria-button-if-js' aria-label='" . 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 aria-button-if-js' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( 'spam' !== $the_comment_status ) {
|
||||
$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
|
||||
$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
|
||||
} elseif ( 'spam' === $the_comment_status ) {
|
||||
$actions['unspam'] = "<a href='$unspam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1' class='vim-z vim-destructive' aria-label='" . esc_attr__( 'Restore this comment from the spam' ) . "'>" . _x( 'Not Spam', 'comment' ) . '</a>';
|
||||
$actions['unspam'] = "<a href='$unspam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1' class='vim-z vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Restore this comment from the spam' ) . "'>" . _x( 'Not Spam', 'comment' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( 'trash' === $the_comment_status ) {
|
||||
$actions['untrash'] = "<a href='$untrash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1' class='vim-z vim-destructive' aria-label='" . esc_attr__( 'Restore this comment from the Trash' ) . "'>" . __( 'Restore' ) . '</a>';
|
||||
$actions['untrash'] = "<a href='$untrash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1' class='vim-z vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Restore this comment from the Trash' ) . "'>" . __( 'Restore' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( 'spam' === $the_comment_status || 'trash' === $the_comment_status || ! EMPTY_TRASH_DAYS ) {
|
||||
$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::delete=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
|
||||
$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::delete=1' class='delete vim-d vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
|
||||
} else {
|
||||
$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
|
||||
$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( 'spam' !== $the_comment_status && 'trash' !== $the_comment_status ) {
|
||||
|
|
1238
wp-admin/includes/class-wp-debug-data.php
Normal file
1238
wp-admin/includes/class-wp-debug-data.php
Normal file
File diff suppressed because it is too large
Load diff
|
@ -7,11 +7,12 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Base WordPress Filesystem class for which Filesystem implementations extend
|
||||
* Base WordPress Filesystem class which Filesystem implementations extend.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
class WP_Filesystem_Base {
|
||||
|
||||
/**
|
||||
* Whether to display debug data for the connection.
|
||||
*
|
||||
|
@ -46,7 +47,7 @@ class WP_Filesystem_Base {
|
|||
public $options = array();
|
||||
|
||||
/**
|
||||
* Return the path on the remote filesystem of ABSPATH.
|
||||
* Returns the path on the remote filesystem of ABSPATH.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
|
@ -62,7 +63,7 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the path on the remote filesystem of WP_CONTENT_DIR.
|
||||
* Returns the path on the remote filesystem of WP_CONTENT_DIR.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
|
@ -73,7 +74,7 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the path on the remote filesystem of WP_PLUGIN_DIR.
|
||||
* Returns the path on the remote filesystem of WP_PLUGIN_DIR.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
|
@ -84,11 +85,12 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the path on the remote filesystem of the Themes Directory.
|
||||
* Returns the path on the remote filesystem of the Themes Directory.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $theme The Theme stylesheet or template for the directory.
|
||||
* @param string|false $theme Optional. The theme stylesheet or template for the directory.
|
||||
* Default false.
|
||||
* @return string The location of the remote path.
|
||||
*/
|
||||
public function wp_themes_dir( $theme = false ) {
|
||||
|
@ -103,7 +105,7 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the path on the remote filesystem of WP_LANG_DIR.
|
||||
* Returns the path on the remote filesystem of WP_LANG_DIR.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
|
@ -114,7 +116,7 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Locate a folder on the remote filesystem.
|
||||
* Locates a folder on the remote filesystem.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() instead.
|
||||
|
@ -136,7 +138,7 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Locate a folder on the remote filesystem.
|
||||
* Locates a folder on the remote filesystem.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.
|
||||
|
@ -157,10 +159,10 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Locate a folder on the remote filesystem.
|
||||
* Locates a folder on the remote filesystem.
|
||||
*
|
||||
* Assumes that on Windows systems, Stripping off the Drive
|
||||
* letter is OK Sanitizes \\ to / in windows filepaths.
|
||||
* letter is OK Sanitizes \\ to / in Windows filepaths.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
|
@ -229,7 +231,7 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Locate a folder on the remote filesystem.
|
||||
* Locates a folder on the remote filesystem.
|
||||
*
|
||||
* Expects Windows sanitized path.
|
||||
*
|
||||
|
@ -267,9 +269,9 @@ class WP_Filesystem_Base {
|
|||
/*
|
||||
* Working from /home/ to /user/ to /wordpress/ see if that file exists within
|
||||
* the current folder, If it's found, change into it and follow through looking
|
||||
* for it. If it cant find WordPress down that route, it'll continue onto the next
|
||||
* for it. If it can't find WordPress down that route, it'll continue onto the next
|
||||
* folder level, and see if that matches, and so on. If it reaches the end, and still
|
||||
* cant find it, it'll return false for the entire function.
|
||||
* can't find it, it'll return false for the entire function.
|
||||
*/
|
||||
if ( isset( $files[ $key ] ) ) {
|
||||
|
||||
|
@ -311,7 +313,7 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the *nix-style file permissions for a file.
|
||||
* Returns the *nix-style file permissions for a file.
|
||||
*
|
||||
* From the PHP documentation page for fileperms().
|
||||
*
|
||||
|
@ -366,18 +368,19 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the permissions of the specified file or filepath in their octal format
|
||||
* Gets the permissions of the specified file or filepath in their octal format.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @param string $file
|
||||
* @return string the last 3 characters of the octal number
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string Mode of the file (the last 3 digits).
|
||||
*/
|
||||
public function getchmod( $file ) {
|
||||
return '777';
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert *nix-style file permissions to a octal number.
|
||||
* Converts *nix-style file permissions to a octal number.
|
||||
*
|
||||
* Converts '-rw-r--r--' to 0644
|
||||
* From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
|
||||
|
@ -417,187 +420,192 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Determine if the string provided contains binary characters.
|
||||
* Determines if the string provided contains binary characters.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $text String to test against.
|
||||
* @return bool true if string is binary, false otherwise.
|
||||
* @return bool True if string is binary, false otherwise.
|
||||
*/
|
||||
public function is_binary( $text ) {
|
||||
return (bool) preg_match( '|[^\x20-\x7E]|', $text ); // chr(32)..chr(127)
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the ownership of a file / folder.
|
||||
* Changes the owner of a file or directory.
|
||||
*
|
||||
* Default behavior is to do nothing, override this in your subclass, if desired.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @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 or directory.
|
||||
* @param string|int $owner A user name or number.
|
||||
* @param bool $recursive Optional. If set to true, changes file owner recursively.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chown( $file, $owner, $recursive = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect filesystem.
|
||||
* Connects filesystem.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
*
|
||||
* @return bool True on success or false on failure (always true for WP_Filesystem_Direct).
|
||||
* @return bool True on success, false on failure (always true for WP_Filesystem_Direct).
|
||||
*/
|
||||
public function connect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read entire file into a string.
|
||||
* Reads entire file into a string.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
*
|
||||
* @param string $file Name of the file to read.
|
||||
* @return mixed|bool Returns the read data or false on failure.
|
||||
* @return string|false Read data on success, false on failure.
|
||||
*/
|
||||
public function get_contents( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read entire file into an array.
|
||||
* Reads 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.
|
||||
* @return array|false File contents in an array on success, false on failure.
|
||||
*/
|
||||
public function get_contents_array( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a string to a file.
|
||||
* Writes 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.
|
||||
* @return bool False on failure.
|
||||
* @param string $file Remote path to the file where to write the data.
|
||||
* @param string $contents The data to write.
|
||||
* @param int|false $mode Optional. The file permissions as octal number, usually 0644.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function put_contents( $file, $contents, $mode = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current working directory.
|
||||
* Gets the current working directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
*
|
||||
* @return string|bool The current working directory on success, or false on failure.
|
||||
* @return string|false The current working directory on success, false on failure.
|
||||
*/
|
||||
public function cwd() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change current directory.
|
||||
* Changes current directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
*
|
||||
* @param string $dir The new current directory.
|
||||
* @return bool|string
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chdir( $dir ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the file group.
|
||||
* Changes 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.
|
||||
* @return bool|string
|
||||
* @param string $file Path to the file.
|
||||
* @param string|int $group A group name or number.
|
||||
* @param bool $recursive Optional. If set to true, changes file group recursively.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chgrp( $file, $group, $recursive = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change filesystem permissions.
|
||||
* Changes 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.
|
||||
* @return bool|string
|
||||
* @param string $file Path to the file.
|
||||
* @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
|
||||
* 0755 for directories. Default false.
|
||||
* @param bool $recursive Optional. If set to true, changes file group recursively.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chmod( $file, $mode = false, $recursive = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file owner.
|
||||
* Gets 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.
|
||||
* @return string|false Username of the owner on success, false on failure.
|
||||
*/
|
||||
public function owner( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file's group.
|
||||
* Gets 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.
|
||||
* @return string|false The group on success, false on failure.
|
||||
*/
|
||||
public function group( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a file.
|
||||
* Copies 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.
|
||||
* Default false.
|
||||
* @param int $mode Optional. The permissions as octal number, usually 0644 for files, 0755 for dirs.
|
||||
* Default false.
|
||||
* @return bool True if file copied successfully, False otherwise.
|
||||
* @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.
|
||||
* Default false.
|
||||
* @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
|
||||
* 0755 for dirs. Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a file.
|
||||
* Moves a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
|
@ -606,36 +614,36 @@ class WP_Filesystem_Base {
|
|||
* @param string $destination Path to the destination file.
|
||||
* @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
|
||||
* Default false.
|
||||
* @return bool True if file copied successfully, False otherwise.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function move( $source, $destination, $overwrite = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file or directory.
|
||||
* Deletes 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.
|
||||
* @param bool $type Type of resource. 'f' for file, 'd' for directory.
|
||||
* Default false.
|
||||
* @return bool True if the file or directory was deleted, false on failure.
|
||||
* @param string $file Path to the file or directory.
|
||||
* @param bool $recursive Optional. If set to true, changes file group recursively.
|
||||
* Default false.
|
||||
* @param string|false $type Type of resource. 'f' for file, 'd' for directory.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function delete( $file, $recursive = false, $type = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file or directory exists.
|
||||
* Checks if a file or directory exists.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
*
|
||||
* @param string $file Path to file/directory.
|
||||
* @param string $file Path to file or directory.
|
||||
* @return bool Whether $file exists or not.
|
||||
*/
|
||||
public function exists( $file ) {
|
||||
|
@ -643,7 +651,7 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if resource is a file.
|
||||
* Checks if resource is a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
|
@ -656,7 +664,7 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if resource is a directory.
|
||||
* Checks if resource is a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
|
@ -669,7 +677,7 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if a file is readable.
|
||||
* Checks if a file is readable.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
|
@ -682,12 +690,12 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if a file or directory is writable.
|
||||
* Checks if a file or directory is writable.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @param string $file Path to file or directory.
|
||||
* @return bool Whether $file is writable.
|
||||
*/
|
||||
public function is_writable( $file ) {
|
||||
|
@ -701,7 +709,7 @@ class WP_Filesystem_Base {
|
|||
* @abstract
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|bool Unix timestamp representing last access time.
|
||||
* @return int|false Unix timestamp representing last access time, false on failure.
|
||||
*/
|
||||
public function atime( $file ) {
|
||||
return false;
|
||||
|
@ -714,7 +722,7 @@ class WP_Filesystem_Base {
|
|||
* @abstract
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|bool Unix timestamp representing modification time.
|
||||
* @return int|false Unix timestamp representing modification time, false on failure.
|
||||
*/
|
||||
public function mtime( $file ) {
|
||||
return false;
|
||||
|
@ -727,14 +735,14 @@ class WP_Filesystem_Base {
|
|||
* @abstract
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|bool Size of the file in bytes.
|
||||
* @return int|false Size of the file in bytes on success, false on failure.
|
||||
*/
|
||||
public function size( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the access and modification times of a file.
|
||||
* Sets the access and modification times of a file.
|
||||
*
|
||||
* Note: If $file doesn't exist, it will be created.
|
||||
*
|
||||
|
@ -746,33 +754,33 @@ class WP_Filesystem_Base {
|
|||
* Default 0.
|
||||
* @param int $atime Optional. Access time to set for file.
|
||||
* Default 0.
|
||||
* @return bool Whether operation was successful or not.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function touch( $file, $time = 0, $atime = 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a directory.
|
||||
* Creates 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.
|
||||
* @param mixed $chown Optional. A user name or number (or False to skip chown)
|
||||
* Default false.
|
||||
* @param mixed $chgrp Optional. A group name or number (or False to skip chgrp).
|
||||
* Default false.
|
||||
* @return bool False if directory cannot be created, true otherwise.
|
||||
* @param string $path Path for new directory.
|
||||
* @param int|false $chmod Optional. The permissions as octal number (or false to skip chmod).
|
||||
* Default false.
|
||||
* @param string|int $chown Optional. A user name or number (or false to skip chown).
|
||||
* Default false.
|
||||
* @param string|int $chgrp Optional. A group name or number (or false to skip chgrp).
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a directory.
|
||||
* Deletes a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
|
@ -780,14 +788,14 @@ class WP_Filesystem_Base {
|
|||
* @param string $path Path to directory.
|
||||
* @param bool $recursive Optional. Whether to recursively remove files/directories.
|
||||
* Default false.
|
||||
* @return bool Whether directory is deleted successfully or not.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function rmdir( $path, $recursive = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get details for files in a directory or a specific file.
|
||||
* Gets details for files in a directory or a specific file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
|
@ -797,10 +805,10 @@ class WP_Filesystem_Base {
|
|||
* Default true.
|
||||
* @param bool $recursive Optional. Whether to recursively include file details in nested directories.
|
||||
* Default false.
|
||||
* @return array|bool {
|
||||
* @return array|false {
|
||||
* Array of files. False if unable to list directory contents.
|
||||
*
|
||||
* @type string $name Name of the file/directory.
|
||||
* @type string $name Name of the file or directory.
|
||||
* @type string $perms *nix representation of permissions.
|
||||
* @type int $permsn Octal representation of permissions.
|
||||
* @type string $owner Owner name or ID.
|
||||
|
|
|
@ -16,9 +16,11 @@
|
|||
class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* Constructor.
|
||||
*
|
||||
* @param mixed $arg ignored argument
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param mixed $arg Not used.
|
||||
*/
|
||||
public function __construct( $arg ) {
|
||||
$this->method = 'direct';
|
||||
|
@ -26,33 +28,39 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Reads entire file into a string
|
||||
* Reads entire file into a string.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Name of the file to read.
|
||||
* @return string|bool The function returns the read data or false on failure.
|
||||
* @return string|false Read data on success, false on failure.
|
||||
*/
|
||||
public function get_contents( $file ) {
|
||||
return @file_get_contents( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads entire file into an array
|
||||
* Reads entire file into an array.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return array|bool the file contents in an array or false on failure.
|
||||
* @return array|false File contents in an array on success, false on failure.
|
||||
*/
|
||||
public function get_contents_array( $file ) {
|
||||
return @file( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a string to a file
|
||||
* Writes a string to a file.
|
||||
*
|
||||
* @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.
|
||||
* Default false.
|
||||
* @return bool False upon failure, true otherwise.
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Remote path to the file where to write the data.
|
||||
* @param string $contents The data to write.
|
||||
* @param int|false $mode Optional. The file permissions as octal number, usually 0644.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function put_contents( $file, $contents, $mode = false ) {
|
||||
$fp = @fopen( $file, 'wb' );
|
||||
|
@ -80,31 +88,38 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the current working directory
|
||||
* Gets the current working directory.
|
||||
*
|
||||
* @return string|bool the current working directory on success, or false on failure.
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @return string|false The current working directory on success, false on failure.
|
||||
*/
|
||||
public function cwd() {
|
||||
return @getcwd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change directory
|
||||
* Changes current directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $dir The new current directory.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chdir( $dir ) {
|
||||
return @chdir( $dir );
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes file group
|
||||
* Changes the 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. Default false.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @param string|int $group A group name or number.
|
||||
* @param bool $recursive Optional. If set to true, changes file group recursively.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chgrp( $file, $group, $recursive = false ) {
|
||||
if ( ! $this->exists( $file ) ) {
|
||||
|
@ -127,13 +142,16 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Changes filesystem permissions
|
||||
* 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. 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.
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
|
||||
* 0755 for directories. Default false.
|
||||
* @param bool $recursive Optional. If set to true, changes file group recursively.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chmod( $file, $mode = false, $recursive = false ) {
|
||||
if ( ! $mode ) {
|
||||
|
@ -160,13 +178,15 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Changes file owner
|
||||
* Changes the owner of a file or directory.
|
||||
*
|
||||
* @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.
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file or directory.
|
||||
* @param string|int $owner A user name or number.
|
||||
* @param bool $recursive Optional. If set to true, changes file owner recursively.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chown( $file, $owner, $recursive = false ) {
|
||||
if ( ! $this->exists( $file ) ) {
|
||||
|
@ -187,10 +207,12 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets file owner
|
||||
* Gets the file owner.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string|bool Username of the user or false on error.
|
||||
* @return string|false Username of the owner on success, false on failure.
|
||||
*/
|
||||
public function owner( $file ) {
|
||||
$owneruid = @fileowner( $file );
|
||||
|
@ -205,20 +227,26 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets file permissions
|
||||
* Gets the permissions of the specified file or filepath in their octal format.
|
||||
*
|
||||
* FIXME does not handle errors in fileperms()
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string Mode of the file (last 3 digits).
|
||||
* @return string Mode of the file (the last 3 digits).
|
||||
*/
|
||||
public function getchmod( $file ) {
|
||||
return substr( decoct( @fileperms( $file ) ), -3 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string|false
|
||||
* Gets the file's group.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string|false The group on success, false on failure.
|
||||
*/
|
||||
public function group( $file ) {
|
||||
$gid = @filegroup( $file );
|
||||
|
@ -233,11 +261,17 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @param int $mode
|
||||
* @return bool
|
||||
* Copies a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @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.
|
||||
* Default false.
|
||||
* @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
|
||||
* 0755 for dirs. Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
|
||||
if ( ! $overwrite && $this->exists( $destination ) ) {
|
||||
|
@ -252,10 +286,15 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @return bool
|
||||
* Moves a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @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.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function move( $source, $destination, $overwrite = false ) {
|
||||
if ( ! $overwrite && $this->exists( $destination ) ) {
|
||||
|
@ -276,10 +315,16 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param bool $recursive
|
||||
* @param string $type
|
||||
* @return bool
|
||||
* Deletes a file or directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file or directory.
|
||||
* @param bool $recursive Optional. If set to true, changes file group recursively.
|
||||
* Default false.
|
||||
* @param string|false $type Type of resource. 'f' for file, 'd' for directory.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
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.
|
||||
|
@ -313,73 +358,116 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if a file or directory exists.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file or directory.
|
||||
* @return bool Whether $file exists or not.
|
||||
*/
|
||||
public function exists( $file ) {
|
||||
return @file_exists( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if resource is a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file File path.
|
||||
* @return bool Whether $file is a file.
|
||||
*/
|
||||
public function is_file( $file ) {
|
||||
return @is_file( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return bool
|
||||
* Checks if resource is a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $path Directory path.
|
||||
* @return bool Whether $path is a directory.
|
||||
*/
|
||||
public function is_dir( $path ) {
|
||||
return @is_dir( $path );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if a file is readable.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return bool Whether $file is readable.
|
||||
*/
|
||||
public function is_readable( $file ) {
|
||||
return @is_readable( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if a file or directory is writable.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file or directory.
|
||||
* @return bool Whether $file is writable.
|
||||
*/
|
||||
public function is_writable( $file ) {
|
||||
return @is_writable( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
* Gets the file's last access time.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|false Unix timestamp representing last access time, false on failure.
|
||||
*/
|
||||
public function atime( $file ) {
|
||||
return @fileatime( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
* Gets the file modification time.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|false Unix timestamp representing modification time, false on failure.
|
||||
*/
|
||||
public function mtime( $file ) {
|
||||
return @filemtime( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
* Gets the file size (in bytes).
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|false Size of the file in bytes on success, false on failure.
|
||||
*/
|
||||
public function size( $file ) {
|
||||
return @filesize( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param int $time
|
||||
* @param int $atime
|
||||
* @return bool
|
||||
* Sets the access and modification times of a file.
|
||||
*
|
||||
* Note: If $file doesn't exist, it will be created.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @param int $time Optional. Modified time to set for file.
|
||||
* Default 0.
|
||||
* @param int $atime Optional. Access time to set for file.
|
||||
* Default 0.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function touch( $file, $time = 0, $atime = 0 ) {
|
||||
if ( $time == 0 ) {
|
||||
|
@ -392,11 +480,18 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param mixed $chmod
|
||||
* @param mixed $chown
|
||||
* @param mixed $chgrp
|
||||
* @return bool
|
||||
* Creates a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $path Path for new directory.
|
||||
* @param int|false $chmod Optional. The permissions as octal number (or false to skip chmod).
|
||||
* Default false.
|
||||
* @param string|int $chown Optional. A user name or number (or false to skip chown).
|
||||
* Default false.
|
||||
* @param string|int $chgrp Optional. A group name or number (or false to skip chgrp).
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
// Safe mode fails with a trailing slash under certain PHP versions.
|
||||
|
@ -423,19 +518,43 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
* Deletes a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $path Path to directory.
|
||||
* @param bool $recursive Optional. Whether to recursively remove files/directories.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function rmdir( $path, $recursive = false ) {
|
||||
return $this->delete( $path, $recursive );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $include_hidden
|
||||
* @param bool $recursive
|
||||
* @return bool|array
|
||||
* Gets details for files in a directory or a specific file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $path Path to directory or file.
|
||||
* @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
|
||||
* Default true.
|
||||
* @param bool $recursive Optional. Whether to recursively include file details in nested directories.
|
||||
* Default false.
|
||||
* @return array|false {
|
||||
* Array of files. False if unable to list directory contents.
|
||||
*
|
||||
* @type string $name Name of the file or 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 ) {
|
||||
if ( $this->is_file( $path ) ) {
|
||||
|
|
|
@ -14,9 +14,18 @@
|
|||
* @see WP_Filesystem_Base
|
||||
*/
|
||||
class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
|
||||
/**
|
||||
* @since 2.5.0
|
||||
* @var resource
|
||||
*/
|
||||
public $link;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param array $opt
|
||||
*/
|
||||
public function __construct( $opt = '' ) {
|
||||
|
@ -67,7 +76,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* Connects filesystem.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function connect() {
|
||||
if ( isset( $this->options['ssl'] ) && $this->options['ssl'] && function_exists( 'ftp_ssl_connect' ) ) {
|
||||
|
@ -110,12 +123,12 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves the file contents.
|
||||
* Reads entire file into a string.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Filename.
|
||||
* @return string|false File contents on success, false if no temp file could be opened,
|
||||
* @param string $file Name of the file to read.
|
||||
* @return string|false Read data on success, false if no temporary file could be opened,
|
||||
* or if the file couldn't be retrieved.
|
||||
*/
|
||||
public function get_contents( $file ) {
|
||||
|
@ -137,7 +150,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
$contents = '';
|
||||
|
||||
while ( ! feof( $temp ) ) {
|
||||
$contents .= fread( $temp, 8192 );
|
||||
$contents .= fread( $temp, 8 * KB_IN_BYTES );
|
||||
}
|
||||
|
||||
fclose( $temp );
|
||||
|
@ -146,18 +159,27 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return array
|
||||
* Reads entire file into an array.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return array|false File contents in an array on success, false on failure.
|
||||
*/
|
||||
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
|
||||
* Writes a string to a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Remote path to the file where to write the data.
|
||||
* @param string $contents The data to write.
|
||||
* @param int|false $mode Optional. The file permissions as octal number, usually 0644.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function put_contents( $file, $contents, $mode = false ) {
|
||||
$tempfile = wp_tempnam( $file );
|
||||
|
@ -194,7 +216,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* Gets the current working directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @return string|false The current working directory on success, false on failure.
|
||||
*/
|
||||
public function cwd() {
|
||||
$cwd = @ftp_pwd( $this->link );
|
||||
|
@ -205,18 +231,28 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $dir
|
||||
* @return bool
|
||||
* Changes current directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $dir The new current directory.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chdir( $dir ) {
|
||||
return @ftp_chdir( $this->link, $dir );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param int $mode
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
* Changes filesystem permissions.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
|
||||
* 0755 for directories. Default false.
|
||||
* @param bool $recursive Optional. If set to true, changes file group recursively.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chmod( $file, $mode = false, $recursive = false ) {
|
||||
if ( ! $mode ) {
|
||||
|
@ -245,16 +281,25 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
* Gets the file owner.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string|false Username of the owner on success, false on failure.
|
||||
*/
|
||||
public function owner( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
return $dir[ $file ]['owner'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
* Gets the permissions of the specified file or filepath in their octal format.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string Mode of the file (the last 3 digits).
|
||||
*/
|
||||
public function getchmod( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
|
@ -262,8 +307,12 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
* Gets the file's group.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string|false The group on success, false on failure.
|
||||
*/
|
||||
public function group( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
|
@ -271,11 +320,17 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @param string|bool $mode
|
||||
* @return bool
|
||||
* Copies a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @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.
|
||||
* Default false.
|
||||
* @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
|
||||
* 0755 for dirs. Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
|
||||
if ( ! $overwrite && $this->exists( $destination ) ) {
|
||||
|
@ -289,20 +344,31 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @return bool
|
||||
* Moves a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @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.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
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
|
||||
* Deletes a file or directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file or directory.
|
||||
* @param bool $recursive Optional. If set to true, changes file group recursively.
|
||||
* Default false.
|
||||
* @param string|false $type Type of resource. 'f' for file, 'd' for directory.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function delete( $file, $recursive = false, $type = false ) {
|
||||
if ( empty( $file ) ) {
|
||||
|
@ -325,8 +391,12 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if a file or directory exists.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file or directory.
|
||||
* @return bool Whether $file exists or not.
|
||||
*/
|
||||
public function exists( $file ) {
|
||||
$list = @ftp_nlist( $this->link, $file );
|
||||
|
@ -339,16 +409,24 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if resource is a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file File path.
|
||||
* @return bool Whether $file is a file.
|
||||
*/
|
||||
public function is_file( $file ) {
|
||||
return $this->exists( $file ) && ! $this->is_dir( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return bool
|
||||
* Checks if resource is a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $path Directory path.
|
||||
* @return bool Whether $path is a directory.
|
||||
*/
|
||||
public function is_dir( $path ) {
|
||||
$cwd = $this->cwd();
|
||||
|
@ -361,59 +439,96 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if a file is readable.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return bool Whether $file is readable.
|
||||
*/
|
||||
public function is_readable( $file ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if a file or directory is writable.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file or directory.
|
||||
* @return bool Whether $file is writable.
|
||||
*/
|
||||
public function is_writable( $file ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Gets the file's last access time.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|false Unix timestamp representing last access time, false on failure.
|
||||
*/
|
||||
public function atime( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
* Gets the file modification time.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|false Unix timestamp representing modification time, false on failure.
|
||||
*/
|
||||
public function mtime( $file ) {
|
||||
return ftp_mdtm( $this->link, $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
* Gets the file size (in bytes).
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|false Size of the file in bytes on success, false on failure.
|
||||
*/
|
||||
public function size( $file ) {
|
||||
return ftp_size( $this->link, $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Sets the access and modification times of a file.
|
||||
*
|
||||
* Note: If $file doesn't exist, it will be created.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @param int $time Optional. Modified time to set for file.
|
||||
* Default 0.
|
||||
* @param int $atime Optional. Access time to set for file.
|
||||
* Default 0.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function touch( $file, $time = 0, $atime = 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param mixed $chmod
|
||||
* @param mixed $chown
|
||||
* @param mixed $chgrp
|
||||
* @return bool
|
||||
* Creates a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $path Path for new directory.
|
||||
* @param int|false $chmod Optional. The permissions as octal number (or false to skip chmod).
|
||||
* Default false.
|
||||
* @param string|int $chown Optional. A user name or number (or false to skip chown).
|
||||
* Default false.
|
||||
* @param string|int $chgrp Optional. A group name or number (or false to skip chgrp).
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
$path = untrailingslashit( $path );
|
||||
|
@ -429,9 +544,14 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
* Deletes a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $path Path to directory.
|
||||
* @param bool $recursive Optional. Whether to recursively remove files/directories.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function rmdir( $path, $recursive = false ) {
|
||||
return $this->delete( $path, $recursive );
|
||||
|
@ -523,10 +643,29 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $include_hidden
|
||||
* @param bool $recursive
|
||||
* @return bool|array
|
||||
* Gets details for files in a directory or a specific file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $path Path to directory or file.
|
||||
* @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
|
||||
* Default true.
|
||||
* @param bool $recursive Optional. Whether to recursively include file details in nested directories.
|
||||
* Default false.
|
||||
* @return array|false {
|
||||
* Array of files. False if unable to list directory contents.
|
||||
*
|
||||
* @type string $name Name of the file or 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 ) {
|
||||
if ( $this->is_file( $path ) ) {
|
||||
|
@ -537,13 +676,13 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
$pwd = @ftp_pwd( $this->link );
|
||||
if ( ! @ftp_chdir( $this->link, $path ) ) { // Cant change to folder = folder doesn't exist
|
||||
if ( ! @ftp_chdir( $this->link, $path ) ) { // Can't change to folder = folder doesn't exist.
|
||||
return false;
|
||||
}
|
||||
$list = @ftp_rawlist( $this->link, '-a', false );
|
||||
@ftp_chdir( $this->link, $pwd );
|
||||
|
||||
if ( empty( $list ) ) { // Empty array = non-existent folder (real folder will show . at least)
|
||||
if ( empty( $list ) ) { // Empty array = non-existent folder (real folder will show . at least).
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -585,6 +724,9 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
public function __destruct() {
|
||||
if ( $this->link ) {
|
||||
|
|
|
@ -14,12 +14,18 @@
|
|||
* @see WP_Filesystem_Base
|
||||
*/
|
||||
class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
|
||||
/**
|
||||
* @since 2.5.0
|
||||
* @var ftp
|
||||
*/
|
||||
public $ftp;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param array $opt
|
||||
*/
|
||||
public function __construct( $opt = '' ) {
|
||||
|
@ -59,7 +65,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* Connects filesystem.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function connect() {
|
||||
if ( ! $this->ftp ) {
|
||||
|
@ -111,13 +121,13 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves the file contents.
|
||||
* Reads entire file into a string.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Filename.
|
||||
* @return string|false File contents on success, false if no temp file could be opened,
|
||||
* or if the file doesn't exist.
|
||||
* @param string $file Name of the file to read.
|
||||
* @return string|false Read data on success, false if no temporary file could be opened,
|
||||
* or if the file couldn't be retrieved.
|
||||
*/
|
||||
public function get_contents( $file ) {
|
||||
if ( ! $this->exists( $file ) ) {
|
||||
|
@ -148,7 +158,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
$contents = '';
|
||||
|
||||
while ( ! feof( $temphandle ) ) {
|
||||
$contents .= fread( $temphandle, 8192 );
|
||||
$contents .= fread( $temphandle, 8 * KB_IN_BYTES );
|
||||
}
|
||||
|
||||
fclose( $temphandle );
|
||||
|
@ -157,18 +167,27 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return array
|
||||
* Reads entire file into an array.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return array|false File contents in an array on success, false on failure.
|
||||
*/
|
||||
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
|
||||
* Writes a string to a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Remote path to the file where to write the data.
|
||||
* @param string $contents The data to write.
|
||||
* @param int|false $mode Optional. The file permissions as octal number, usually 0644.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function put_contents( $file, $contents, $mode = false ) {
|
||||
$temp = wp_tempnam( $file );
|
||||
|
@ -205,7 +224,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* Gets the current working directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @return string|false The current working directory on success, false on failure.
|
||||
*/
|
||||
public function cwd() {
|
||||
$cwd = $this->ftp->pwd();
|
||||
|
@ -216,18 +239,28 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Changes current directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $dir The new current directory.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chdir( $file ) {
|
||||
return $this->ftp->chdir( $file );
|
||||
public function chdir( $dir ) {
|
||||
return $this->ftp->chdir( $dir );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param int|bool $mode
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
* Changes filesystem permissions.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
|
||||
* 0755 for directories. Default false.
|
||||
* @param bool $recursive Optional. If set to true, changes file group recursively.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chmod( $file, $mode = false, $recursive = false ) {
|
||||
if ( ! $mode ) {
|
||||
|
@ -253,8 +286,12 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
* Gets the file owner.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string|false Username of the owner on success, false on failure.
|
||||
*/
|
||||
public function owner( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
|
@ -262,8 +299,12 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
* Gets the permissions of the specified file or filepath in their octal format.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string Mode of the file (the last 3 digits).
|
||||
*/
|
||||
public function getchmod( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
|
@ -271,8 +312,12 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
* Gets the file's group.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string|false The group on success, false on failure.
|
||||
*/
|
||||
public function group( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
|
@ -280,11 +325,17 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @param int|bool $mode
|
||||
* @return bool
|
||||
* Copies a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @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.
|
||||
* Default false.
|
||||
* @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
|
||||
* 0755 for dirs. Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
|
||||
if ( ! $overwrite && $this->exists( $destination ) ) {
|
||||
|
@ -300,20 +351,31 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @return bool
|
||||
* Moves a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @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.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function move( $source, $destination, $overwrite = false ) {
|
||||
return $this->ftp->rename( $source, $destination );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param bool $recursive
|
||||
* @param string $type
|
||||
* @return bool
|
||||
* Deletes a file or directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to the file or directory.
|
||||
* @param bool $recursive Optional. If set to true, changes file group recursively.
|
||||
* Default false.
|
||||
* @param string|false $type Type of resource. 'f' for file, 'd' for directory.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function delete( $file, $recursive = false, $type = false ) {
|
||||
if ( empty( $file ) ) {
|
||||
|
@ -330,8 +392,12 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if a file or directory exists.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file or directory.
|
||||
* @return bool Whether $file exists or not.
|
||||
*/
|
||||
public function exists( $file ) {
|
||||
$list = $this->ftp->nlist( $file );
|
||||
|
@ -345,8 +411,12 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if resource is a file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file File path.
|
||||
* @return bool Whether $file is a file.
|
||||
*/
|
||||
public function is_file( $file ) {
|
||||
if ( $this->is_dir( $file ) ) {
|
||||
|
@ -359,8 +429,12 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return bool
|
||||
* Checks if resource is a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $path Directory path.
|
||||
* @return bool Whether $path is a directory.
|
||||
*/
|
||||
public function is_dir( $path ) {
|
||||
$cwd = $this->cwd();
|
||||
|
@ -372,61 +446,96 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if a file is readable.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return bool Whether $file is readable.
|
||||
*/
|
||||
public function is_readable( $file ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if a file or directory is writable.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file or directory.
|
||||
* @return bool Whether $file is writable.
|
||||
*/
|
||||
public function is_writable( $file ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Gets the file's last access time.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|false Unix timestamp representing last access time, false on failure.
|
||||
*/
|
||||
public function atime( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
* Gets the file modification time.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|false Unix timestamp representing modification time, false on failure.
|
||||
*/
|
||||
public function mtime( $file ) {
|
||||
return $this->ftp->mdtm( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
* Gets the file size (in bytes).
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|false Size of the file in bytes on success, false on failure.
|
||||
*/
|
||||
public function size( $file ) {
|
||||
return $this->ftp->filesize( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param int $time
|
||||
* @param int $atime
|
||||
* @return bool
|
||||
* Sets the access and modification times of a file.
|
||||
*
|
||||
* Note: If $file doesn't exist, it will be created.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @param int $time Optional. Modified time to set for file.
|
||||
* Default 0.
|
||||
* @param int $atime Optional. Access time to set for file.
|
||||
* Default 0.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function touch( $file, $time = 0, $atime = 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param mixed $chmod
|
||||
* @param mixed $chown
|
||||
* @param mixed $chgrp
|
||||
* @return bool
|
||||
* Creates a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $path Path for new directory.
|
||||
* @param int|false $chmod Optional. The permissions as octal number (or false to skip chmod).
|
||||
* Default false.
|
||||
* @param string|int $chown Optional. A user name or number (or false to skip chown).
|
||||
* Default false.
|
||||
* @param string|int $chgrp Optional. A group name or number (or false to skip chgrp).
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
$path = untrailingslashit( $path );
|
||||
|
@ -445,19 +554,43 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
* Deletes a directory.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $path Path to directory.
|
||||
* @param bool $recursive Optional. Whether to recursively remove files/directories.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function rmdir( $path, $recursive = false ) {
|
||||
return $this->delete( $path, $recursive );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $include_hidden
|
||||
* @param bool $recursive
|
||||
* @return bool|array
|
||||
* Gets details for files in a directory or a specific file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $path Path to directory or file.
|
||||
* @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
|
||||
* Default true.
|
||||
* @param bool $recursive Optional. Whether to recursively include file details in nested directories.
|
||||
* Default false.
|
||||
* @return array|false {
|
||||
* Array of files. False if unable to list directory contents.
|
||||
*
|
||||
* @type string $name Name of the file or 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 ) {
|
||||
if ( $this->is_file( $path ) ) {
|
||||
|
@ -517,6 +650,9 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
public function __destruct() {
|
||||
$this->ftp->quit();
|
||||
|
|
|
@ -36,16 +36,28 @@
|
|||
class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
|
||||
/**
|
||||
* @since 2.7.0
|
||||
* @var resource
|
||||
*/
|
||||
public $link = false;
|
||||
|
||||
/**
|
||||
* @since 2.7.0
|
||||
* @var resource
|
||||
*/
|
||||
public $sftp_link;
|
||||
|
||||
/**
|
||||
* @since 2.7.0
|
||||
* @var bool
|
||||
*/
|
||||
public $keys = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param array $opt
|
||||
*/
|
||||
public function __construct( $opt = '' ) {
|
||||
|
@ -109,7 +121,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* Connects filesystem.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function connect() {
|
||||
if ( ! $this->keys ) {
|
||||
|
@ -193,6 +209,8 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $command
|
||||
* @param bool $returnbool
|
||||
* @return bool|string True on success, false on failure. String if the command was executed, `$returnbool`
|
||||
|
@ -228,26 +246,40 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string|false
|
||||
* Reads entire file into a string.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Name of the file to read.
|
||||
* @return string|false Read data on success, false if no temporary file could be opened,
|
||||
* or if the file couldn't be retrieved.
|
||||
*/
|
||||
public function get_contents( $file ) {
|
||||
return file_get_contents( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return array
|
||||
* Reads entire file into an array.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return array|false File contents in an array on success, false on failure.
|
||||
*/
|
||||
public function get_contents_array( $file ) {
|
||||
return file( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param string $contents
|
||||
* @param bool|int $mode
|
||||
* @return bool
|
||||
* Writes a string to a file.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Remote path to the file where to write the data.
|
||||
* @param string $contents The data to write.
|
||||
* @param int|false $mode Optional. The file permissions as octal number, usually 0644.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function put_contents( $file, $contents, $mode = false ) {
|
||||
$ret = file_put_contents( $this->sftp_path( $file ), $contents );
|
||||
|
@ -262,7 +294,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* Gets the current working directory.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @return string|false The current working directory on success, false on failure.
|
||||
*/
|
||||
public function cwd() {
|
||||
$cwd = ssh2_sftp_realpath( $this->sftp_link, '.' );
|
||||
|
@ -273,19 +309,27 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $dir
|
||||
* @return bool|string
|
||||
* Changes current directory.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $dir The new current directory.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chdir( $dir ) {
|
||||
return $this->run_command( 'cd ' . $dir, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param string $group
|
||||
* @param bool $recursive
|
||||
* Changes the file group.
|
||||
*
|
||||
* @return bool
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @param string|int $group A group name or number.
|
||||
* @param bool $recursive Optional. If set to true, changes file group recursively.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chgrp( $file, $group, $recursive = false ) {
|
||||
if ( ! $this->exists( $file ) ) {
|
||||
|
@ -298,10 +342,16 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param int $mode
|
||||
* @param bool $recursive
|
||||
* @return bool|string
|
||||
* Changes filesystem permissions.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
|
||||
* 0755 for directories. Default false.
|
||||
* @param bool $recursive Optional. If set to true, changes file group recursively.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chmod( $file, $mode = false, $recursive = false ) {
|
||||
if ( ! $this->exists( $file ) ) {
|
||||
|
@ -325,12 +375,15 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Change the ownership of a file / folder.
|
||||
* Changes the owner of a file or directory.
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to the file or directory.
|
||||
* @param string|int $owner A user name or number.
|
||||
* @param bool $recursive Optional. If set True changes file owner recursivly. Default False.
|
||||
* @return bool True on success or false on failure.
|
||||
* @param bool $recursive Optional. If set to true, changes file owner recursively.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function chown( $file, $owner, $recursive = false ) {
|
||||
if ( ! $this->exists( $file ) ) {
|
||||
|
@ -343,8 +396,12 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string|false
|
||||
* Gets the file owner.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string|false Username of the owner on success, false on failure.
|
||||
*/
|
||||
public function owner( $file ) {
|
||||
$owneruid = @fileowner( $this->sftp_path( $file ) );
|
||||
|
@ -359,16 +416,24 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string
|
||||
* Gets the permissions of the specified file or filepath in their octal format.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string Mode of the file (the last 3 digits).
|
||||
*/
|
||||
public function getchmod( $file ) {
|
||||
return substr( decoct( @fileperms( $this->sftp_path( $file ) ) ), -3 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return string|false
|
||||
* Gets the file's group.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string|false The group on success, false on failure.
|
||||
*/
|
||||
public function group( $file ) {
|
||||
$gid = @filegroup( $this->sftp_path( $file ) );
|
||||
|
@ -383,11 +448,17 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @param int|bool $mode
|
||||
* @return bool
|
||||
* Copies a file.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @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.
|
||||
* Default false.
|
||||
* @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
|
||||
* 0755 for dirs. Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
|
||||
if ( ! $overwrite && $this->exists( $destination ) ) {
|
||||
|
@ -401,20 +472,31 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @return bool
|
||||
* Moves a file.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @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.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function move( $source, $destination, $overwrite = false ) {
|
||||
return @ssh2_sftp_rename( $this->sftp_link, $source, $destination );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param bool $recursive
|
||||
* @param string|bool $type
|
||||
* @return bool
|
||||
* Deletes a file or directory.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to the file or directory.
|
||||
* @param bool $recursive Optional. If set to true, changes file group recursively.
|
||||
* Default false.
|
||||
* @param string|false $type Type of resource. 'f' for file, 'd' for directory.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function delete( $file, $recursive = false, $type = false ) {
|
||||
if ( 'f' == $type || $this->is_file( $file ) ) {
|
||||
|
@ -433,40 +515,60 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if a file or directory exists.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to file or directory.
|
||||
* @return bool Whether $file exists or not.
|
||||
*/
|
||||
public function exists( $file ) {
|
||||
return file_exists( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if resource is a file.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file File path.
|
||||
* @return bool Whether $file is a file.
|
||||
*/
|
||||
public function is_file( $file ) {
|
||||
return is_file( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return bool
|
||||
* Checks if resource is a directory.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $path Directory path.
|
||||
* @return bool Whether $path is a directory.
|
||||
*/
|
||||
public function is_dir( $path ) {
|
||||
return is_dir( $this->sftp_path( $path ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if a file is readable.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return bool Whether $file is readable.
|
||||
*/
|
||||
public function is_readable( $file ) {
|
||||
return is_readable( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
* Checks if a file or directory is writable.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to file or directory.
|
||||
* @return bool Whether $file is writable.
|
||||
*/
|
||||
public function is_writable( $file ) {
|
||||
// PHP will base it's writable checks on system_user === file_owner, not ssh_user === file_owner
|
||||
|
@ -474,44 +576,71 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
* Gets the file's last access time.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|false Unix timestamp representing last access time, false on failure.
|
||||
*/
|
||||
public function atime( $file ) {
|
||||
return fileatime( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
* Gets the file modification time.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|false Unix timestamp representing modification time, false on failure.
|
||||
*/
|
||||
public function mtime( $file ) {
|
||||
return filemtime( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
* Gets the file size (in bytes).
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @return int|false Size of the file in bytes on success, false on failure.
|
||||
*/
|
||||
public function size( $file ) {
|
||||
return filesize( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param int $time
|
||||
* @param int $atime
|
||||
* Sets the access and modification times of a file.
|
||||
*
|
||||
* Note: Not implemented.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $file Path to file.
|
||||
* @param int $time Optional. Modified time to set for file.
|
||||
* Default 0.
|
||||
* @param int $atime Optional. Access time to set for file.
|
||||
* Default 0.
|
||||
*/
|
||||
public function touch( $file, $time = 0, $atime = 0 ) {
|
||||
//Not implemented.
|
||||
// Not implemented.
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param mixed $chmod
|
||||
* @param mixed $chown
|
||||
* @param mixed $chgrp
|
||||
* @return bool
|
||||
* Creates a directory.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $path Path for new directory.
|
||||
* @param int|false $chmod Optional. The permissions as octal number (or false to skip chmod).
|
||||
* Default false.
|
||||
* @param string|int $chown Optional. A user name or number (or false to skip chown).
|
||||
* Default false.
|
||||
* @param string|int $chgrp Optional. A group name or number (or false to skip chgrp).
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
$path = untrailingslashit( $path );
|
||||
|
@ -535,19 +664,43 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
* Deletes a directory.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $path Path to directory.
|
||||
* @param bool $recursive Optional. Whether to recursively remove files/directories.
|
||||
* Default false.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function rmdir( $path, $recursive = false ) {
|
||||
return $this->delete( $path, $recursive );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param bool $include_hidden
|
||||
* @param bool $recursive
|
||||
* @return bool|array
|
||||
* Gets details for files in a directory or a specific file.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param string $path Path to directory or file.
|
||||
* @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
|
||||
* Default true.
|
||||
* @param bool $recursive Optional. Whether to recursively include file details in nested directories.
|
||||
* Default false.
|
||||
* @return array|false {
|
||||
* Array of files. False if unable to list directory contents.
|
||||
*
|
||||
* @type string $name Name of the file or 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 ) {
|
||||
if ( $this->is_file( $path ) ) {
|
||||
|
|
|
@ -41,7 +41,7 @@ final class WP_Internal_Pointers {
|
|||
* )
|
||||
*/
|
||||
$registered_pointers = array(
|
||||
'index.php' => 'wp496_privacy',
|
||||
//None currently.
|
||||
);
|
||||
|
||||
// Check if screen related pointer is registered
|
||||
|
@ -65,11 +65,7 @@ final class WP_Internal_Pointers {
|
|||
* )
|
||||
*/
|
||||
$caps_required = array(
|
||||
'wp496_privacy' => array(
|
||||
'manage_privacy_options',
|
||||
'export_others_personal_data',
|
||||
'erase_others_personal_data',
|
||||
),
|
||||
// None currently.
|
||||
);
|
||||
|
||||
// Get dismissed pointers
|
||||
|
@ -154,39 +150,7 @@ final class WP_Internal_Pointers {
|
|||
public static function pointer_wp360_locks() {}
|
||||
public static function pointer_wp390_widgets() {}
|
||||
public static function pointer_wp410_dfw() {}
|
||||
|
||||
/**
|
||||
* Display a pointer for the new privacy tools.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*/
|
||||
public static function pointer_wp496_privacy() {
|
||||
$content = '<h3>' . __( 'Personal Data and Privacy' ) . '</h3>';
|
||||
$content .= '<h4>' . __( 'Personal Data Export and Erasure' ) . '</h4>';
|
||||
$content .= '<p>' . __( 'New <strong>Tools</strong> have been added to help you with personal data export and erasure requests.' ) . '</p>';
|
||||
$content .= '<h4>' . __( 'Privacy Policy' ) . '</h4>';
|
||||
$content .= '<p>' . __( 'Create or select your site’s privacy policy page under <strong>Settings > Privacy</strong> to keep your users informed and aware.' ) . '</p>';
|
||||
|
||||
if ( is_rtl() ) {
|
||||
$position = array(
|
||||
'edge' => 'right',
|
||||
'align' => 'bottom',
|
||||
);
|
||||
} else {
|
||||
$position = array(
|
||||
'edge' => 'left',
|
||||
'align' => 'bottom',
|
||||
);
|
||||
}
|
||||
|
||||
$js_args = array(
|
||||
'content' => $content,
|
||||
'position' => $position,
|
||||
'pointerClass' => 'wp-pointer arrow-bottom',
|
||||
'pointerWidth' => 420,
|
||||
);
|
||||
self::print_js( 'wp496_privacy', '#menu-tools', $js_args );
|
||||
}
|
||||
public static function pointer_wp496_privacy() {}
|
||||
|
||||
/**
|
||||
* Prevents new users from seeing existing 'new feature' pointers.
|
||||
|
@ -196,6 +160,6 @@ final class WP_Internal_Pointers {
|
|||
* @param int $user_id User ID.
|
||||
*/
|
||||
public static function dismiss_pointers_for_new_users( $user_id ) {
|
||||
add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp496_privacy' );
|
||||
add_user_meta( $user_id, 'dismissed_wp_pointers', '' );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
$actions['untrash'] = __( 'Restore' );
|
||||
$actions['delete'] = __( 'Delete Permanently' );
|
||||
} else {
|
||||
$actions['trash'] = _x( 'Trash', 'verb' );
|
||||
$actions['trash'] = __( 'Move to Trash' );
|
||||
}
|
||||
} else {
|
||||
$actions['delete'] = __( 'Delete Permanently' );
|
||||
|
|
|
@ -26,11 +26,10 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
/**
|
||||
* @global string $usersearch
|
||||
* @global string $role
|
||||
* @global wpdb $wpdb
|
||||
* @global string $mode
|
||||
*/
|
||||
public function prepare_items() {
|
||||
global $usersearch, $role, $wpdb, $mode;
|
||||
global $usersearch, $role, $mode;
|
||||
|
||||
$usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
|
||||
|
||||
|
@ -56,8 +55,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
if ( $role === 'super' ) {
|
||||
$logins = implode( "', '", get_super_admins() );
|
||||
$args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" );
|
||||
$args['login__in'] = get_super_admins();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -339,8 +337,25 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
continue;
|
||||
}
|
||||
|
||||
$path = ( $val->path === '/' ) ? '' : $val->path;
|
||||
echo '<span class="site-' . $val->site_id . '" >';
|
||||
$path = ( $val->path === '/' ) ? '' : $val->path;
|
||||
$site_classes = array( 'site-' . $val->site_id );
|
||||
/**
|
||||
* Filters the span class for a site listing on the mulisite user list table.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param array $site_classes Class used within the span tag. Default "site-#" with the site's network ID.
|
||||
* @param int $site_id Site ID.
|
||||
* @param int $network_id Network ID.
|
||||
* @param object $user WP_User object.
|
||||
*/
|
||||
$site_classes = apply_filters( 'ms_user_list_site_class', $site_classes, $val->userblog_id, $val->site_id, $user );
|
||||
if ( is_array( $site_classes ) && ! empty( $site_classes ) ) {
|
||||
$site_classes = array_map( 'sanitize_html_class', array_unique( $site_classes ) );
|
||||
echo '<span class="' . esc_attr( implode( ' ', $site_classes ) ) . '">';
|
||||
} else {
|
||||
echo '<span>';
|
||||
}
|
||||
echo '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) . '">' . str_replace( '.' . get_network()->domain, '', $val->domain . $path ) . '</a>';
|
||||
echo ' <small class="row-actions">';
|
||||
$actions = array();
|
||||
|
|
|
@ -502,11 +502,12 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
$author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>';
|
||||
}
|
||||
|
||||
$wp_version = get_bloginfo( 'version' );
|
||||
$requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null;
|
||||
$requires_wp = isset( $plugin['requires'] ) ? $plugin['requires'] : null;
|
||||
|
||||
$compatible_php = ( empty( $plugin['requires_php'] ) || version_compare( phpversion(), $plugin['requires_php'], '>=' ) );
|
||||
$tested_wp = ( empty( $plugin['tested'] ) || version_compare( $wp_version, $plugin['tested'], '<=' ) );
|
||||
$compatible_wp = ( empty( $plugin['requires'] ) || version_compare( $wp_version, $plugin['requires'], '>=' ) );
|
||||
$compatible_php = is_php_version_compatible( $requires_php );
|
||||
$compatible_wp = is_wp_version_compatible( $requires_wp );
|
||||
$tested_wp = ( empty( $plugin['tested'] ) || version_compare( get_bloginfo( 'version' ), $plugin['tested'], '<=' ) );
|
||||
|
||||
$action_links = array();
|
||||
|
||||
|
@ -537,16 +538,23 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
|
||||
case 'update_available':
|
||||
if ( $status['url'] ) {
|
||||
$action_links[] = sprintf(
|
||||
'<a class="update-now button aria-button-if-js" data-plugin="%s" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>',
|
||||
esc_attr( $status['file'] ),
|
||||
esc_attr( $plugin['slug'] ),
|
||||
esc_url( $status['url'] ),
|
||||
/* translators: %s: plugin name and version */
|
||||
esc_attr( sprintf( __( 'Update %s now' ), $name ) ),
|
||||
esc_attr( $name ),
|
||||
__( 'Update Now' )
|
||||
);
|
||||
if ( $compatible_php && $compatible_wp ) {
|
||||
$action_links[] = sprintf(
|
||||
'<a class="update-now button aria-button-if-js" data-plugin="%s" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>',
|
||||
esc_attr( $status['file'] ),
|
||||
esc_attr( $plugin['slug'] ),
|
||||
esc_url( $status['url'] ),
|
||||
/* translators: %s: plugin name and version */
|
||||
esc_attr( sprintf( __( 'Update %s now' ), $name ) ),
|
||||
esc_attr( $name ),
|
||||
__( 'Update Now' )
|
||||
);
|
||||
} else {
|
||||
$action_links[] = sprintf(
|
||||
'<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
|
||||
_x( 'Cannot Update', 'plugin' )
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -642,7 +650,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
self_admin_url( 'update-core.php' ),
|
||||
esc_url( wp_get_update_php_url() )
|
||||
);
|
||||
wp_update_php_annotation();
|
||||
wp_update_php_annotation( '</p><p><em>', '</em>' );
|
||||
} elseif ( current_user_can( 'update_core' ) ) {
|
||||
printf(
|
||||
/* translators: %s: "Update WordPress" screen URL */
|
||||
|
@ -655,7 +663,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
|
||||
esc_url( wp_get_update_php_url() )
|
||||
);
|
||||
wp_update_php_annotation();
|
||||
wp_update_php_annotation( '</p><p><em>', '</em>' );
|
||||
}
|
||||
} elseif ( ! $compatible_wp ) {
|
||||
_e( 'This plugin doesn’t work with your version of WordPress.' );
|
||||
|
@ -674,7 +682,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
|
||||
esc_url( wp_get_update_php_url() )
|
||||
);
|
||||
wp_update_php_annotation();
|
||||
wp_update_php_annotation( '</p><p><em>', '</em>' );
|
||||
}
|
||||
}
|
||||
echo '</p></div>';
|
||||
|
|
|
@ -40,7 +40,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
);
|
||||
|
||||
$status = 'all';
|
||||
if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) ) {
|
||||
if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused' ) ) ) {
|
||||
$status = $_REQUEST['plugin_status'];
|
||||
}
|
||||
|
||||
|
@ -99,6 +99,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
'upgrade' => array(),
|
||||
'mustuse' => array(),
|
||||
'dropins' => array(),
|
||||
'paused' => array(),
|
||||
);
|
||||
|
||||
$screen = $this->screen;
|
||||
|
@ -183,16 +184,18 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
|
||||
// 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 );
|
||||
$plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
|
||||
$plugins['all'][ $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 );
|
||||
$plugins['upgrade'][ $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 );
|
||||
$plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
|
||||
$plugins['all'][ $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 );
|
||||
$plugins['upgrade'][ $plugin_file ] = $plugin_data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,6 +221,10 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
// On the non-network screen, populate the active list with plugins that are individually activated
|
||||
// On the network-admin screen, populate the active list with plugins that are network activated
|
||||
$plugins['active'][ $plugin_file ] = $plugin_data;
|
||||
|
||||
if ( ! $screen->in_admin( 'network' ) && is_plugin_paused( $plugin_file ) ) {
|
||||
$plugins['paused'][ $plugin_file ] = $plugin_data;
|
||||
}
|
||||
} else {
|
||||
if ( isset( $recently_activated[ $plugin_file ] ) ) {
|
||||
// Populate the recently activated list with plugins that have been recently activated
|
||||
|
@ -443,7 +450,11 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
break;
|
||||
case 'dropins':
|
||||
/* translators: %s: plugin count */
|
||||
$text = _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $count );
|
||||
$text = _n( 'Drop-in <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $count );
|
||||
break;
|
||||
case 'paused':
|
||||
/* translators: %s: plugin count */
|
||||
$text = _n( 'Paused <span class="count">(%s)</span>', 'Paused <span class="count">(%s)</span>', $count );
|
||||
break;
|
||||
case 'upgrade':
|
||||
/* translators: %s: plugin count */
|
||||
|
@ -657,6 +668,10 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
/* translators: %s: plugin name */
|
||||
$actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( _x( 'Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
|
||||
}
|
||||
if ( current_user_can( 'resume_plugin', $plugin_file ) && is_plugin_paused( $plugin_file ) ) {
|
||||
/* translators: %s: plugin name */
|
||||
$actions['resume'] = '<a class="resume-link" href="' . wp_nonce_url( 'plugins.php?action=resume&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'resume-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( _x( 'Resume %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Resume' ) . '</a>';
|
||||
}
|
||||
} else {
|
||||
if ( current_user_can( 'activate_plugin', $plugin_file ) ) {
|
||||
/* translators: %s: plugin name */
|
||||
|
@ -746,9 +761,11 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
|
||||
}
|
||||
|
||||
$class = $is_active ? 'active' : 'inactive';
|
||||
$checkbox_id = 'checkbox_' . md5( $plugin_data['Name'] );
|
||||
if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
|
||||
$requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null;
|
||||
$compatible_php = is_php_version_compatible( $requires_php );
|
||||
$class = $is_active ? 'active' : 'inactive';
|
||||
$checkbox_id = 'checkbox_' . md5( $plugin_data['Name'] );
|
||||
if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ) ) || ! $compatible_php ) {
|
||||
$checkbox = '';
|
||||
} else {
|
||||
/* translators: %s: plugin name */
|
||||
|
@ -764,6 +781,12 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
$class .= ' update';
|
||||
}
|
||||
|
||||
$paused = ! $screen->in_admin( 'network' ) && is_plugin_paused( $plugin_file );
|
||||
|
||||
if ( $paused ) {
|
||||
$class .= ' paused';
|
||||
}
|
||||
|
||||
$plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_name );
|
||||
printf(
|
||||
'<tr class="%s" data-slug="%s" data-plugin="%s">',
|
||||
|
@ -845,13 +868,25 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
* @param array $plugin_data An array of plugin data.
|
||||
* @param string $status Status of the plugin. Defaults are 'All', 'Active',
|
||||
* 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
|
||||
* 'Drop-ins', 'Search'.
|
||||
* 'Drop-ins', 'Search', 'Paused'.
|
||||
*/
|
||||
$plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status );
|
||||
echo implode( ' | ', $plugin_meta );
|
||||
|
||||
echo '</div>';
|
||||
|
||||
if ( $paused ) {
|
||||
$notice_text = __( 'This plugin failed to load properly and is paused during recovery mode.' );
|
||||
|
||||
printf( '<p><span class="dashicons dashicons-warning"></span> <strong>%s</strong></p>', $notice_text );
|
||||
|
||||
$error = wp_get_plugin_error( $plugin_file );
|
||||
|
||||
if ( false !== $error ) {
|
||||
printf( '<div class="error-display"><p>%s</p></div>', wp_get_extension_error_description( $error ) );
|
||||
}
|
||||
}
|
||||
|
||||
echo '</td>';
|
||||
break;
|
||||
default:
|
||||
|
@ -885,7 +920,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
* @param array $plugin_data An array of plugin data.
|
||||
* @param string $status Status of the plugin. Defaults are 'All', 'Active',
|
||||
* 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
|
||||
* 'Drop-ins', 'Search'.
|
||||
* 'Drop-ins', 'Search', 'Paused'.
|
||||
*/
|
||||
do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status );
|
||||
|
||||
|
@ -901,7 +936,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
* @param array $plugin_data An array of plugin data.
|
||||
* @param string $status Status of the plugin. Defaults are 'All', 'Active',
|
||||
* 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
|
||||
* 'Drop-ins', 'Search'.
|
||||
* 'Drop-ins', 'Search', 'Paused'.
|
||||
*/
|
||||
do_action( "after_plugin_row_{$plugin_file}", $plugin_file, $plugin_data, $status );
|
||||
}
|
||||
|
|
|
@ -458,6 +458,66 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a formats drop-down for filtering items.
|
||||
*
|
||||
* @since 5.2.0
|
||||
* @access protected
|
||||
*
|
||||
* @param string $post_type Post type key.
|
||||
*/
|
||||
protected function formats_dropdown( $post_type ) {
|
||||
/**
|
||||
* Filters whether to remove the 'Formats' drop-down from the post list table.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param bool $disable Whether to disable the drop-down. Default false.
|
||||
*/
|
||||
if ( apply_filters( 'disable_formats_dropdown', false ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the dropdown shows only formats with a post count greater than 0.
|
||||
$used_post_formats = get_terms(
|
||||
array(
|
||||
'taxonomy' => 'post_format',
|
||||
'hide_empty' => true,
|
||||
)
|
||||
);
|
||||
|
||||
/*
|
||||
* Return if the post type doesn't have post formats, or there are no posts using formats,
|
||||
* or if we're in the trash.
|
||||
*/
|
||||
if ( ! is_object_in_taxonomy( $post_type, 'post_format' ) || ! $used_post_formats || $this->is_trash ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$displayed_post_format = isset( $_GET['post_format'] ) ? $_GET['post_format'] : '';
|
||||
?>
|
||||
<label for="filter-by-format" class="screen-reader-text"><?php _e( 'Filter by post format' ); ?></label>
|
||||
<select name="post_format" id="filter-by-format">
|
||||
<option<?php selected( $displayed_post_format, '' ); ?> value=""><?php _e( 'All formats' ); ?></option>
|
||||
<?php
|
||||
foreach ( $used_post_formats as $used_post_format ) {
|
||||
// Post format slug.
|
||||
$slug = str_replace( 'post-format-', '', $used_post_format->slug );
|
||||
// Pretty, translated version of the post format slug.
|
||||
$pretty_name = get_post_format_string( $slug );
|
||||
// Skip the standard post format.
|
||||
if ( 'standard' === $slug ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<option<?php selected( $displayed_post_format, $slug ); ?> value="<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $pretty_name ); ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $which
|
||||
*/
|
||||
|
@ -470,6 +530,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||
|
||||
$this->months_dropdown( $this->screen->post_type );
|
||||
$this->categories_dropdown( $this->screen->post_type );
|
||||
$this->formats_dropdown( $this->screen->post_type );
|
||||
|
||||
/**
|
||||
* Fires before the Filter button on the Posts and Pages list tables.
|
||||
|
@ -943,20 +1004,6 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||
$pad = str_repeat( '— ', $this->current_level );
|
||||
echo '<strong>';
|
||||
|
||||
$format = get_post_format( $post->ID );
|
||||
if ( $format ) {
|
||||
$label = get_post_format_string( $format );
|
||||
|
||||
$format_class = 'post-state-format post-format-icon post-format-' . $format;
|
||||
|
||||
$format_args = array(
|
||||
'post_format' => $format,
|
||||
'post_type' => $post->post_type,
|
||||
);
|
||||
|
||||
echo $this->get_edit_link( $format_args, $label . ':', $format_class );
|
||||
}
|
||||
|
||||
$title = _draft_or_post_title();
|
||||
|
||||
if ( $can_edit_post && $post->post_status != 'trash' ) {
|
||||
|
@ -969,7 +1016,11 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||
$title
|
||||
);
|
||||
} else {
|
||||
echo $pad . $title;
|
||||
printf(
|
||||
'<span>%s%s</span>',
|
||||
$pad,
|
||||
$title
|
||||
);
|
||||
}
|
||||
_post_states( $post );
|
||||
|
||||
|
@ -1126,7 +1177,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||
$taxonomy_object = get_taxonomy( $taxonomy );
|
||||
$terms = get_the_terms( $post->ID, $taxonomy );
|
||||
if ( is_array( $terms ) ) {
|
||||
$out = array();
|
||||
$term_links = array();
|
||||
foreach ( $terms as $t ) {
|
||||
$posts_in_term_qv = array();
|
||||
if ( 'post' != $post->post_type ) {
|
||||
|
@ -1140,10 +1191,23 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
$label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) );
|
||||
$out[] = $this->get_edit_link( $posts_in_term_qv, $label );
|
||||
|
||||
$term_links[] = $this->get_edit_link( $posts_in_term_qv, $label );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the links in `$taxonomy` column of edit.php.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param array $term_links List of links to edit.php, filtered by the taxonomy term.
|
||||
* @param string $taxonomy Taxonomy name.
|
||||
* @param array $terms Array of terms appearing in the post row.
|
||||
*/
|
||||
$term_links = apply_filters( 'post_column_taxonomy_links', $term_links, $taxonomy, $terms );
|
||||
|
||||
/* translators: used between list items, there is a space after the comma */
|
||||
echo join( __( ', ' ), $out );
|
||||
echo join( __( ', ' ), $term_links );
|
||||
} else {
|
||||
echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>';
|
||||
}
|
||||
|
|
|
@ -202,9 +202,10 @@ final class WP_Screen {
|
|||
return $hook_name;
|
||||
}
|
||||
|
||||
$post_type = $taxonomy = null;
|
||||
$in_admin = false;
|
||||
$action = '';
|
||||
$post_type = $taxonomy = null;
|
||||
$in_admin = false;
|
||||
$action = '';
|
||||
$is_block_editor = false;
|
||||
|
||||
if ( $hook_name ) {
|
||||
$id = $hook_name;
|
||||
|
@ -294,6 +295,13 @@ final class WP_Screen {
|
|||
$post = get_post( $post_id );
|
||||
if ( $post ) {
|
||||
$post_type = $post->post_type;
|
||||
|
||||
/** This filter is documented in wp-admin/post.php */
|
||||
$replace_editor = apply_filters( 'replace_editor', false, $post );
|
||||
|
||||
if ( ! $replace_editor ) {
|
||||
$is_block_editor = use_block_editor_for_post( $post );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -314,6 +322,12 @@ final class WP_Screen {
|
|||
if ( null === $post_type ) {
|
||||
$post_type = 'post';
|
||||
}
|
||||
|
||||
// When creating a new post, use the default block editor support value for the post type.
|
||||
if ( empty( $post_id ) ) {
|
||||
$is_block_editor = use_block_editor_for_post_type( $post_type );
|
||||
}
|
||||
|
||||
$id = $post_type;
|
||||
break;
|
||||
case 'edit':
|
||||
|
@ -357,13 +371,14 @@ final class WP_Screen {
|
|||
$screen->id = $id;
|
||||
}
|
||||
|
||||
$screen->base = $base;
|
||||
$screen->action = $action;
|
||||
$screen->post_type = (string) $post_type;
|
||||
$screen->taxonomy = (string) $taxonomy;
|
||||
$screen->is_user = ( 'user' == $in_admin );
|
||||
$screen->is_network = ( 'network' == $in_admin );
|
||||
$screen->in_admin = $in_admin;
|
||||
$screen->base = $base;
|
||||
$screen->action = $action;
|
||||
$screen->post_type = (string) $post_type;
|
||||
$screen->taxonomy = (string) $taxonomy;
|
||||
$screen->is_user = ( 'user' == $in_admin );
|
||||
$screen->is_network = ( 'network' == $in_admin );
|
||||
$screen->in_admin = $in_admin;
|
||||
$screen->is_block_editor = $is_block_editor;
|
||||
|
||||
self::$_registry[ $id ] = $screen;
|
||||
|
||||
|
|
449
wp-admin/includes/class-wp-site-health-auto-updates.php
Normal file
449
wp-admin/includes/class-wp-site-health-auto-updates.php
Normal file
|
@ -0,0 +1,449 @@
|
|||
<?php
|
||||
/**
|
||||
* Class for testing automatic updates in the WordPress code.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Site_Health
|
||||
* @since 5.2.0
|
||||
*/
|
||||
|
||||
class WP_Site_Health_Auto_Updates {
|
||||
/**
|
||||
* WP_Site_Health_Auto_Updates constructor.
|
||||
* @since 5.2.0
|
||||
*/
|
||||
public function __construct() {
|
||||
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run tests to determine if auto-updates can run.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return array The test results.
|
||||
*/
|
||||
public function run_tests() {
|
||||
$tests = array(
|
||||
$this->test_constants( 'DISALLOW_FILE_MODS', false ),
|
||||
$this->test_constants( 'AUTOMATIC_UPDATER_DISABLED', false ),
|
||||
$this->test_constants( 'WP_AUTO_UPDATE_CORE', true ),
|
||||
$this->test_wp_version_check_attached(),
|
||||
$this->test_filters_automatic_updater_disabled(),
|
||||
$this->test_if_failed_update(),
|
||||
$this->test_vcs_abspath(),
|
||||
$this->test_check_wp_filesystem_method(),
|
||||
$this->test_all_files_writable(),
|
||||
$this->test_accepts_dev_updates(),
|
||||
$this->test_accepts_minor_updates(),
|
||||
);
|
||||
|
||||
$tests = array_filter( $tests );
|
||||
$tests = array_map(
|
||||
function( $test ) {
|
||||
$test = (object) $test;
|
||||
|
||||
if ( empty( $test->severity ) ) {
|
||||
$test->severity = 'warning';
|
||||
}
|
||||
|
||||
return $test;
|
||||
},
|
||||
$tests
|
||||
);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if auto-updates related constants are set correctly.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $constant The name of the constant to check.
|
||||
* @param bool $value The value that the constant should be, if set.
|
||||
* @return array The test results.
|
||||
*/
|
||||
public function test_constants( $constant, $value ) {
|
||||
if ( defined( $constant ) && constant( $constant ) != $value ) {
|
||||
return array(
|
||||
'description' => sprintf(
|
||||
/* translators: %s: Name of the constant used. */
|
||||
__( 'The %s constant is defined and enabled.' ),
|
||||
"<code>$constant</code>"
|
||||
),
|
||||
'severity' => 'fail',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if updates are intercepted by a filter.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return array The test results.
|
||||
*/
|
||||
public function test_wp_version_check_attached() {
|
||||
if ( ! is_main_site() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cookies = wp_unslash( $_COOKIE );
|
||||
$timeout = 10;
|
||||
$headers = array(
|
||||
'Cache-Control' => 'no-cache',
|
||||
);
|
||||
|
||||
// Include Basic auth in loopback requests.
|
||||
if ( isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] ) ) {
|
||||
$headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) );
|
||||
}
|
||||
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'health-check-test-wp_version_check' => true,
|
||||
),
|
||||
admin_url( 'site-health.php' )
|
||||
);
|
||||
|
||||
$test = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout' ) );
|
||||
|
||||
if ( is_wp_error( $test ) ) {
|
||||
return array(
|
||||
'description' => sprintf(
|
||||
/* translators: %s: Name of the filter used. */
|
||||
__( 'Could not confirm that the %s filter is available.' ),
|
||||
'<code>wp_version_check()</code>'
|
||||
),
|
||||
'severity' => 'warning',
|
||||
);
|
||||
}
|
||||
|
||||
$response = wp_remote_retrieve_body( $test );
|
||||
|
||||
if ( 'yes' !== $response ) {
|
||||
return array(
|
||||
'description' => sprintf(
|
||||
/* translators: %s: Name of the filter used. */
|
||||
__( 'A plugin has prevented updates by disabling %s.' ),
|
||||
'<code>wp_version_check()</code>'
|
||||
),
|
||||
'severity' => 'fail',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if automatic updates are disabled by a filter.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return array The test results.
|
||||
*/
|
||||
public function test_filters_automatic_updater_disabled() {
|
||||
if ( apply_filters( 'automatic_updater_disabled', false ) ) {
|
||||
return array(
|
||||
'description' => sprintf(
|
||||
/* translators: %s: Name of the filter used. */
|
||||
__( 'The %s filter is enabled.' ),
|
||||
'<code>automatic_updater_disabled</code>'
|
||||
),
|
||||
'severity' => 'fail',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if automatic updates have tried to run, but failed, previously.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return array|bool The test results. false if the auto updates failed.
|
||||
*/
|
||||
function test_if_failed_update() {
|
||||
$failed = get_site_option( 'auto_core_update_failed' );
|
||||
|
||||
if ( ! $failed ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! empty( $failed['critical'] ) ) {
|
||||
$description = __( 'A previous automatic background update ended with a critical failure, so updates are now disabled.' );
|
||||
$description .= ' ' . __( 'You would have received an email because of this.' );
|
||||
$description .= ' ' . __( "When you've been able to update using the \"Update Now\" button on Dashboard > Updates, we'll clear this error for future update attempts." );
|
||||
$description .= ' ' . sprintf(
|
||||
/* translators: %s: Code of error shown. */
|
||||
__( 'The error code was %s.' ),
|
||||
'<code>' . $failed['error_code'] . '</code>'
|
||||
);
|
||||
return array(
|
||||
'description' => $description,
|
||||
'severity' => 'warning',
|
||||
);
|
||||
}
|
||||
|
||||
$description = __( 'A previous automatic background update could not occur.' );
|
||||
if ( empty( $failed['retry'] ) ) {
|
||||
$description .= ' ' . __( 'You would have received an email because of this.' );
|
||||
}
|
||||
|
||||
$description .= ' ' . __( "We'll try again with the next release." );
|
||||
$description .= ' ' . sprintf(
|
||||
/* translators: %s: Code of error shown. */
|
||||
__( 'The error code was %s.' ),
|
||||
'<code>' . $failed['error_code'] . '</code>'
|
||||
);
|
||||
return array(
|
||||
'description' => $description,
|
||||
'severity' => 'warning',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if WordPress is controlled by a VCS (Git, Subversion etc).
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return array The test results.
|
||||
*/
|
||||
public function test_vcs_abspath() {
|
||||
$context_dirs = array( ABSPATH );
|
||||
$vcs_dirs = array( '.svn', '.git', '.hg', '.bzr' );
|
||||
$check_dirs = array();
|
||||
|
||||
foreach ( $context_dirs as $context_dir ) {
|
||||
// Walk up from $context_dir to the root.
|
||||
do {
|
||||
$check_dirs[] = $context_dir;
|
||||
|
||||
// Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here.
|
||||
if ( dirname( $context_dir ) == $context_dir ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Continue one level at a time.
|
||||
} while ( $context_dir = dirname( $context_dir ) );
|
||||
}
|
||||
|
||||
$check_dirs = array_unique( $check_dirs );
|
||||
|
||||
// Search all directories we've found for evidence of version control.
|
||||
foreach ( $vcs_dirs as $vcs_dir ) {
|
||||
foreach ( $check_dirs as $check_dir ) {
|
||||
// phpcs:ignore
|
||||
if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) {
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $checkout && ! apply_filters( 'automatic_updates_is_vcs_checkout', true, ABSPATH ) ) {
|
||||
return array(
|
||||
'description' => sprintf(
|
||||
// translators: 1: Folder name. 2: Version control directory. 3: Filter name.
|
||||
__( 'The folder %1$s was detected as being under version control (%2$s), but the %3$s filter is allowing updates.' ),
|
||||
'<code>' . $check_dir . '</code>',
|
||||
"<code>$vcs_dir</code>",
|
||||
'<code>automatic_updates_is_vcs_checkout</code>'
|
||||
),
|
||||
'severity' => 'info',
|
||||
);
|
||||
}
|
||||
|
||||
if ( $checkout ) {
|
||||
return array(
|
||||
'description' => sprintf(
|
||||
// translators: 1: Folder name. 2: Version control directory.
|
||||
__( 'The folder %1$s was detected as being under version control (%2$s).' ),
|
||||
'<code>' . $check_dir . '</code>',
|
||||
"<code>$vcs_dir</code>"
|
||||
),
|
||||
'severity' => 'fail',
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'description' => __( 'No version control systems were detected.' ),
|
||||
'severity' => 'pass',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we can access files without providing credentials.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return array The test results.
|
||||
*/
|
||||
function test_check_wp_filesystem_method() {
|
||||
$skin = new Automatic_Upgrader_Skin;
|
||||
$success = $skin->request_filesystem_credentials( false, ABSPATH );
|
||||
|
||||
if ( ! $success ) {
|
||||
$description = __( 'Your installation of WordPress prompts for FTP credentials to perform updates.' );
|
||||
$description .= ' ' . __( '(Your site is performing updates over FTP due to file ownership. Talk to your hosting company.)' );
|
||||
|
||||
return array(
|
||||
'description' => $description,
|
||||
'severity' => 'fail',
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'description' => __( "Your installation of WordPress doesn't require FTP credentials to perform updates." ),
|
||||
'severity' => 'pass',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if core files are writable by the web user/group.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
|
||||
*
|
||||
* @return array|bool The test results. false if they're not writeable.
|
||||
*/
|
||||
function test_all_files_writable() {
|
||||
global $wp_filesystem;
|
||||
|
||||
include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
|
||||
|
||||
$skin = new Automatic_Upgrader_Skin;
|
||||
$success = $skin->request_filesystem_credentials( false, ABSPATH );
|
||||
|
||||
if ( ! $success ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
WP_Filesystem();
|
||||
|
||||
if ( 'direct' != $wp_filesystem->method ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$checksums = get_core_checksums( $wp_version, 'en_US' );
|
||||
$dev = ( false !== strpos( $wp_version, '-' ) );
|
||||
// Get the last stable version's files and test against that
|
||||
if ( ! $checksums && $dev ) {
|
||||
$checksums = get_core_checksums( (float) $wp_version - 0.1, 'en_US' );
|
||||
}
|
||||
|
||||
// There aren't always checksums for development releases, so just skip the test if we still can't find any
|
||||
if ( ! $checksums && $dev ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $checksums ) {
|
||||
$description = sprintf(
|
||||
// translators: %s: WordPress version
|
||||
__( "Couldn't retrieve a list of the checksums for WordPress %s." ),
|
||||
$wp_version
|
||||
);
|
||||
$description .= ' ' . __( 'This could mean that connections are failing to WordPress.org.' );
|
||||
return array(
|
||||
'description' => $description,
|
||||
'severity' => 'warning',
|
||||
);
|
||||
}
|
||||
|
||||
$unwritable_files = array();
|
||||
foreach ( array_keys( $checksums ) as $file ) {
|
||||
if ( 'wp-content' == substr( $file, 0, 10 ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! file_exists( ABSPATH . $file ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! is_writable( ABSPATH . $file ) ) {
|
||||
$unwritable_files[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $unwritable_files ) {
|
||||
if ( count( $unwritable_files ) > 20 ) {
|
||||
$unwritable_files = array_slice( $unwritable_files, 0, 20 );
|
||||
$unwritable_files[] = '...';
|
||||
}
|
||||
return array(
|
||||
'description' => __( 'Some files are not writable by WordPress:' ) . ' <ul><li>' . implode( '</li><li>', $unwritable_files ) . '</li></ul>',
|
||||
'severity' => 'fail',
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
'description' => __( 'All of your WordPress files are writable.' ),
|
||||
'severity' => 'pass',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the install is using a development branch and can use nightly packages.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return array|bool The test results. false if it isn't a development version.
|
||||
*/
|
||||
function test_accepts_dev_updates() {
|
||||
include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
|
||||
// Only for dev versions
|
||||
if ( false === strpos( $wp_version, '-' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( defined( 'WP_AUTO_UPDATE_CORE' ) && ( 'minor' === WP_AUTO_UPDATE_CORE || false === WP_AUTO_UPDATE_CORE ) ) {
|
||||
return array(
|
||||
'description' => sprintf(
|
||||
/* translators: %s: Name of the constant used. */
|
||||
__( 'WordPress development updates are blocked by the %s constant.' ),
|
||||
'<code>WP_AUTO_UPDATE_CORE</code>'
|
||||
),
|
||||
'severity' => 'fail',
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! apply_filters( 'allow_dev_auto_core_updates', $wp_version ) ) {
|
||||
return array(
|
||||
'description' => sprintf(
|
||||
/* translators: %s: Name of the filter used. */
|
||||
__( 'WordPress development updates are blocked by the %s filter.' ),
|
||||
'<code>allow_dev_auto_core_updates</code>'
|
||||
),
|
||||
'severity' => 'fail',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the site supports automatic minor updates.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return array The test results.
|
||||
*/
|
||||
function test_accepts_minor_updates() {
|
||||
if ( defined( 'WP_AUTO_UPDATE_CORE' ) && false === WP_AUTO_UPDATE_CORE ) {
|
||||
return array(
|
||||
'description' => sprintf(
|
||||
/* translators: %s: Name of the constant used. */
|
||||
__( 'WordPress security and maintenance releases are blocked by %s.' ),
|
||||
"<code>define( 'WP_AUTO_UPDATE_CORE', false );</code>"
|
||||
),
|
||||
'severity' => 'fail',
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! apply_filters( 'allow_minor_auto_core_updates', true ) ) {
|
||||
return array(
|
||||
'description' => sprintf(
|
||||
/* translators: %s: Name of the filter used. */
|
||||
__( 'WordPress security and maintenance releases are blocked by the %s filter.' ),
|
||||
'<code>allow_minor_auto_core_updates</code>'
|
||||
),
|
||||
'severity' => 'fail',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
1990
wp-admin/includes/class-wp-site-health.php
Normal file
1990
wp-admin/includes/class-wp-site-health.php
Normal file
File diff suppressed because it is too large
Load diff
|
@ -85,14 +85,14 @@ class WP_Site_Icon {
|
|||
public function create_attachment_object( $cropped, $parent_attachment_id ) {
|
||||
$parent = get_post( $parent_attachment_id );
|
||||
$parent_url = wp_get_attachment_url( $parent->ID );
|
||||
$url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
|
||||
$url = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url );
|
||||
|
||||
$size = @getimagesize( $cropped );
|
||||
$image_type = ( $size ) ? $size['mime'] : 'image/jpeg';
|
||||
|
||||
$object = array(
|
||||
'ID' => $parent_attachment_id,
|
||||
'post_title' => basename( $cropped ),
|
||||
'post_title' => wp_basename( $cropped ),
|
||||
'post_content' => $url,
|
||||
'post_mime_type' => $image_type,
|
||||
'guid' => $url,
|
||||
|
|
|
@ -332,7 +332,14 @@ class WP_Terms_List_Table extends WP_List_Table {
|
|||
|
||||
$this->level = $level;
|
||||
|
||||
echo '<tr id="tag-' . $tag->term_id . '">';
|
||||
if ( $tag->parent ) {
|
||||
$count = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) );
|
||||
$level = 'level-' . $count;
|
||||
} else {
|
||||
$level = 'level-0';
|
||||
}
|
||||
|
||||
echo '<tr id="tag-' . $tag->term_id . '" class="' . $level . '">';
|
||||
$this->single_row_columns( $tag );
|
||||
echo '</tr>';
|
||||
}
|
||||
|
|
|
@ -241,8 +241,9 @@ class WP_Themes_List_Table extends WP_List_Table {
|
|||
<?php
|
||||
if ( $theme->parent() ) {
|
||||
printf(
|
||||
/* translators: %s: link to documentation on child themes */
|
||||
' <p class="howto">' . __( 'This <a href="%1$s">child theme</a> requires its parent theme, %2$s.' ) . '</p>',
|
||||
__( 'https://codex.wordpress.org/Child_Themes' ),
|
||||
__( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ),
|
||||
$theme->parent()->display( 'Name' )
|
||||
);
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ class WP_Upgrader_Skin {
|
|||
} else {
|
||||
echo '<script type="text/javascript">
|
||||
(function( wp ) {
|
||||
if ( wp && wp.updates && wp.updates.decrementCount )
|
||||
if ( wp && wp.updates && wp.updates.decrementCount ) {
|
||||
wp.updates.decrementCount( "' . $type . '" );
|
||||
}
|
||||
})( window.wp );
|
||||
|
|
|
@ -244,11 +244,12 @@ class WP_Upgrader {
|
|||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string $package The URI of the package. If this is the full path to an
|
||||
* existing local file, it will be returned untouched.
|
||||
* @param string $package The URI of the package. If this is the full path to an
|
||||
* existing local file, it will be returned untouched.
|
||||
* @param bool $check_signatures Whether to validate file signatures. Default false.
|
||||
* @return string|WP_Error The full path to the downloaded package file, or a WP_Error object.
|
||||
*/
|
||||
public function download_package( $package ) {
|
||||
public function download_package( $package, $check_signatures = false ) {
|
||||
|
||||
/**
|
||||
* Filters whether to return the package.
|
||||
|
@ -275,9 +276,9 @@ class WP_Upgrader {
|
|||
|
||||
$this->skin->feedback( 'downloading_package', $package );
|
||||
|
||||
$download_file = download_url( $package );
|
||||
$download_file = download_url( $package, 300, $check_signatures );
|
||||
|
||||
if ( is_wp_error( $download_file ) ) {
|
||||
if ( is_wp_error( $download_file ) && ! $download_file->get_error_data( 'softfail-filename' ) ) {
|
||||
return new WP_Error( 'download_failed', $this->strings['download_failed'], $download_file->get_error_message() );
|
||||
}
|
||||
|
||||
|
@ -730,7 +731,30 @@ class WP_Upgrader {
|
|||
* Download the package (Note, This just returns the filename
|
||||
* of the file if the package is a local file)
|
||||
*/
|
||||
$download = $this->download_package( $options['package'] );
|
||||
$download = $this->download_package( $options['package'], true );
|
||||
|
||||
// Allow for signature soft-fail.
|
||||
// WARNING: This may be removed in the future.
|
||||
if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) {
|
||||
|
||||
// Don't output the 'no signature could be found' failure message for now.
|
||||
if ( 'signature_verification_no_signature' != $download->get_error_code() || WP_DEBUG ) {
|
||||
// Outout the failure error as a normal feedback, and not as an error:
|
||||
$this->skin->feedback( $download->get_error_message() );
|
||||
|
||||
// Report this failure back to WordPress.org for debugging purposes.
|
||||
wp_version_check(
|
||||
array(
|
||||
'signature_failure_code' => $download->get_error_code(),
|
||||
'signature_failure_data' => $download->get_error_data(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Pretend this error didn't happen.
|
||||
$download = $download->get_error_data( 'softfail-filename' );
|
||||
}
|
||||
|
||||
if ( is_wp_error( $download ) ) {
|
||||
$this->skin->error( $download );
|
||||
$this->skin->after();
|
||||
|
|
|
@ -291,9 +291,7 @@ function wp_dashboard_right_now() {
|
|||
<?php
|
||||
$moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated );
|
||||
/* translators: %s: number of comments in moderation */
|
||||
$text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
|
||||
/* translators: %s: number of comments in moderation */
|
||||
$aria_label = sprintf( _nx( '%s comment in moderation', '%s comments in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
|
||||
$text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $num_comm->moderated ), $moderated_comments_count_i18n );
|
||||
?>
|
||||
<li class="comment-mod-count
|
||||
<?php
|
||||
|
@ -301,7 +299,7 @@ function wp_dashboard_right_now() {
|
|||
echo ' hidden';
|
||||
}
|
||||
?>
|
||||
"><a href="edit-comments.php?comment_status=moderated" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php echo $text; ?></a></li>
|
||||
"><a href="edit-comments.php?comment_status=moderated" class="comments-in-moderation-text"><?php echo $text; ?></a></li>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
@ -519,8 +517,7 @@ function wp_dashboard_quick_press( $error_msg = false ) {
|
|||
<?php endif; ?>
|
||||
|
||||
<div class="input-text-wrap" id="title-wrap">
|
||||
<label class="screen-reader-text prompt" for="title" id="title-prompt-text">
|
||||
|
||||
<label for="title">
|
||||
<?php
|
||||
/** This filter is documented in wp-admin/edit-form-advanced.php */
|
||||
echo apply_filters( 'enter_title_here', __( 'Title' ), $post );
|
||||
|
@ -530,8 +527,8 @@ function wp_dashboard_quick_press( $error_msg = false ) {
|
|||
</div>
|
||||
|
||||
<div class="textarea-wrap" id="description-wrap">
|
||||
<label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( 'What’s on your mind?' ); ?></label>
|
||||
<textarea name="content" id="content" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea>
|
||||
<label for="content"><?php _e( 'Content' ); ?></label>
|
||||
<textarea name="content" id="content" placeholder="<?php esc_attr_e( 'What’s on your mind?' ); ?>" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea>
|
||||
</div>
|
||||
|
||||
<p class="submit">
|
||||
|
@ -649,16 +646,16 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
|
|||
$trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
|
||||
$delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
|
||||
|
||||
$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' aria-label='" . 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' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
||||
$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 aria-button-if-js' aria-label='" . 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 aria-button-if-js' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
||||
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>" . __( 'Edit' ) . '</a>';
|
||||
$actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\'' . $comment->comment_ID . '\',\'' . $comment->comment_post_ID . '\');return false;" class="vim-r hide-if-no-js" aria-label="' . esc_attr__( 'Reply to this comment' ) . '" href="#">' . __( 'Reply' ) . '</a>';
|
||||
$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
|
||||
$actions['reply'] = '<button type="button" onclick="window.commentReply && commentReply.open(\'' . $comment->comment_ID . '\',\'' . $comment->comment_post_ID . '\');" class="vim-r button-link hide-if-no-js" aria-label="' . esc_attr__( 'Reply to this comment' ) . '">' . __( 'Reply' ) . '</button>';
|
||||
$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
|
||||
|
||||
if ( ! EMPTY_TRASH_DAYS ) {
|
||||
$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
|
||||
$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
|
||||
} else {
|
||||
$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
|
||||
$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
|
||||
}
|
||||
|
||||
$actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '" aria-label="' . esc_attr__( 'View this comment' ) . '">' . __( 'View' ) . '</a>';
|
||||
|
@ -858,8 +855,9 @@ function wp_dashboard_recent_posts( $args ) {
|
|||
|
||||
echo '<ul>';
|
||||
|
||||
$today = date( 'Y-m-d', current_time( 'timestamp' ) );
|
||||
$tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
|
||||
$today = current_time( 'Y-m-d' );
|
||||
$tomorrow = gmdate( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
|
||||
$year = current_time( 'Y' );
|
||||
|
||||
while ( $posts->have_posts() ) {
|
||||
$posts->the_post();
|
||||
|
@ -869,7 +867,7 @@ function wp_dashboard_recent_posts( $args ) {
|
|||
$relative = __( 'Today' );
|
||||
} elseif ( date( 'Y-m-d', $time ) == $tomorrow ) {
|
||||
$relative = __( 'Tomorrow' );
|
||||
} elseif ( date( 'Y', $time ) !== date( 'Y', current_time( 'timestamp' ) ) ) {
|
||||
} elseif ( date( 'Y', $time ) !== $year ) {
|
||||
/* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */
|
||||
$relative = date_i18n( __( 'M jS Y' ), $time );
|
||||
} else {
|
||||
|
|
|
@ -530,22 +530,10 @@ function export_wp( $args = array() ) {
|
|||
// Begin Loop.
|
||||
foreach ( $posts as $post ) {
|
||||
setup_postdata( $post );
|
||||
$is_sticky = is_sticky( $post->ID ) ? 1 : 0;
|
||||
?>
|
||||
<item>
|
||||
<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>
|
||||
<guid isPermaLink="false"><?php the_guid(); ?></guid>
|
||||
<description></description>
|
||||
<content:encoded>
|
||||
<?php
|
||||
$title = apply_filters( 'the_title_rss', $post->post_title );
|
||||
|
||||
/**
|
||||
* Filters the post content used for WXR exports.
|
||||
*
|
||||
|
@ -553,11 +541,8 @@ function export_wp( $args = array() ) {
|
|||
*
|
||||
* @param string $post_content Content of the current post.
|
||||
*/
|
||||
echo wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) );
|
||||
?>
|
||||
</content:encoded>
|
||||
<excerpt:encoded>
|
||||
<?php
|
||||
$content = wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) );
|
||||
|
||||
/**
|
||||
* Filters the post excerpt used for WXR exports.
|
||||
*
|
||||
|
@ -565,9 +550,19 @@ function export_wp( $args = array() ) {
|
|||
*
|
||||
* @param string $post_excerpt Excerpt for the current post.
|
||||
*/
|
||||
echo wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) );
|
||||
$excerpt = wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) );
|
||||
|
||||
$is_sticky = is_sticky( $post->ID ) ? 1 : 0;
|
||||
?>
|
||||
</excerpt:encoded>
|
||||
<item>
|
||||
<title><?php echo $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>
|
||||
<guid isPermaLink="false"><?php the_guid(); ?></guid>
|
||||
<description></description>
|
||||
<content:encoded><?php echo $content; ?></content:encoded>
|
||||
<excerpt:encoded><?php echo $excerpt; ?></excerpt:encoded>
|
||||
<wp:post_id><?php echo intval( $post->ID ); ?></wp:post_id>
|
||||
<wp:post_date><?php echo wxr_cdata( $post->post_date ); ?></wp:post_date>
|
||||
<wp:post_date_gmt><?php echo wxr_cdata( $post->post_date_gmt ); ?></wp:post_date_gmt>
|
||||
|
|
|
@ -36,6 +36,7 @@ $wp_file_descriptions = array(
|
|||
'single.php' => __( 'Single Post' ),
|
||||
'page.php' => __( 'Single Page' ),
|
||||
'front-page.php' => __( 'Homepage' ),
|
||||
'privacy-policy.php' => __( 'Privacy Policy Page' ),
|
||||
// Attachments
|
||||
'attachment.php' => __( 'Attachment Template' ),
|
||||
'image.php' => __( 'Image Attachment Template' ),
|
||||
|
@ -965,12 +966,14 @@ function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
|
|||
* Please note that the calling function must unlink() the file.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @since 5.2.0 Signature Verification with SoftFail was added.
|
||||
*
|
||||
* @param string $url The URL of the file to download.
|
||||
* @param int $timeout The timeout for the request to download the file. Default 300 seconds.
|
||||
* @param string $url The URL of the file to download.
|
||||
* @param int $timeout The timeout for the request to download the file. Default 300 seconds.
|
||||
* @param bool $signature_verification Whether to perform Signature Verification. Default false.
|
||||
* @return string|WP_Error Filename on success, WP_Error on failure.
|
||||
*/
|
||||
function download_url( $url, $timeout = 300 ) {
|
||||
function download_url( $url, $timeout = 300, $signature_verification = false ) {
|
||||
//WARNING: The file is not automatically deleted, The script must unlink() the file.
|
||||
if ( ! $url ) {
|
||||
return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) );
|
||||
|
@ -1034,6 +1037,83 @@ function download_url( $url, $timeout = 300 ) {
|
|||
}
|
||||
}
|
||||
|
||||
// If the caller expects signature verification to occur, check to see if this URL supports it.
|
||||
if ( $signature_verification ) {
|
||||
/**
|
||||
* Filters the list of hosts which should have Signature Verification attempteds on.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param array List of hostnames.
|
||||
*/
|
||||
$signed_hostnames = apply_filters( 'wp_signature_hosts', array( 'wordpress.org', 'downloads.wordpress.org', 's.w.org' ) );
|
||||
$signature_verification = in_array( parse_url( $url, PHP_URL_HOST ), $signed_hostnames, true );
|
||||
}
|
||||
|
||||
// Perform signature valiation if supported.
|
||||
if ( $signature_verification ) {
|
||||
$signature = wp_remote_retrieve_header( $response, 'x-content-signature' );
|
||||
if ( ! $signature ) {
|
||||
// Retrieve signatures from a file if the header wasn't included.
|
||||
// WordPress.org stores signatures at $package_url.sig
|
||||
|
||||
$signature_url = false;
|
||||
$url_path = parse_url( $url, PHP_URL_PATH );
|
||||
if ( substr( $url_path, -4 ) == '.zip' || substr( $url_path, -7 ) == '.tar.gz' ) {
|
||||
$signature_url = str_replace( $url_path, $url_path . '.sig', $url );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the URL where the signature for a file is located.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param false|string $signature_url The URL where signatures can be found for a file, or false if none are known.
|
||||
* @param string $url The URL being verified.
|
||||
*/
|
||||
$signature_url = apply_filters( 'wp_signature_url', $signature_url, $url );
|
||||
|
||||
if ( $signature_url ) {
|
||||
$signature_request = wp_safe_remote_get(
|
||||
$signature_url,
|
||||
array(
|
||||
'limit_response_size' => 10 * 1024, // 10KB should be large enough for quite a few signatures.
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! is_wp_error( $signature_request ) && 200 === wp_remote_retrieve_response_code( $signature_request ) ) {
|
||||
$signature = explode( "\n", wp_remote_retrieve_body( $signature_request ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Perform the checks.
|
||||
$signature_verification = verify_file_signature( $tmpfname, $signature, basename( parse_url( $url, PHP_URL_PATH ) ) );
|
||||
}
|
||||
|
||||
if ( is_wp_error( $signature_verification ) ) {
|
||||
if (
|
||||
/**
|
||||
* Filters whether Signature Verification failures should be allowed to soft fail.
|
||||
*
|
||||
* WARNING: This may be removed from a future release.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param bool $signature_softfail If a softfail is allowed.
|
||||
* @param string $url The url being accessed.
|
||||
*/
|
||||
apply_filters( 'wp_signature_softfail', true, $url )
|
||||
) {
|
||||
$signature_verification->add_data( $tmpfname, 'softfail-filename' );
|
||||
} else {
|
||||
// Hard-fail.
|
||||
unlink( $tmpfname );
|
||||
}
|
||||
|
||||
return $signature_verification;
|
||||
}
|
||||
|
||||
return $tmpfname;
|
||||
}
|
||||
|
||||
|
@ -1066,6 +1146,155 @@ function verify_file_md5( $filename, $expected_md5 ) {
|
|||
return new WP_Error( 'md5_mismatch', sprintf( __( 'The checksum of the file (%1$s) does not match the expected checksum value (%2$s).' ), bin2hex( $file_md5 ), bin2hex( $expected_raw_md5 ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies the contents of a file against its ED25519 signature.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $filename The file to validate.
|
||||
* @param string|array $signatures A Signature provided for the file.
|
||||
* @param string $filename_for_errors A friendly filename for errors. Optional.
|
||||
*
|
||||
* @return bool|WP_Error true on success, false if verificaiton not attempted, or WP_Error describing an error condition.
|
||||
*/
|
||||
function verify_file_signature( $filename, $signatures, $filename_for_errors = false ) {
|
||||
if ( ! $filename_for_errors ) {
|
||||
$filename_for_errors = wp_basename( $filename );
|
||||
}
|
||||
|
||||
// Check we can process signatures.
|
||||
if ( ! function_exists( 'sodium_crypto_sign_verify_detached' ) || ! in_array( 'sha384', array_map( 'strtolower', hash_algos() ) ) ) {
|
||||
return new WP_Error(
|
||||
'signature_verification_unsupported',
|
||||
sprintf(
|
||||
/* translators: %s: The filename of the package. */
|
||||
__( 'The authenticity of %s could not be verified as signature verification is unavailable on this system.' ),
|
||||
'<span class="code">' . esc_html( $filename_for_errors ) . '</span>'
|
||||
),
|
||||
( ! function_exists( 'sodium_crypto_sign_verify_detached' ) ? 'sodium_crypto_sign_verify_detached' : 'sha384' )
|
||||
);
|
||||
}
|
||||
|
||||
// Check for a edge-case affecting PHP Maths abilities
|
||||
if (
|
||||
! extension_loaded( 'sodium' ) &&
|
||||
in_array( PHP_VERSION_ID, [ 70200, 70201, 70202 ], true ) &&
|
||||
extension_loaded( 'opcache' )
|
||||
) {
|
||||
// Sodium_Compat isn't compatible with PHP 7.2.0~7.2.2 due to a bug in the PHP Opcache extension, bail early as it'll fail.
|
||||
// https://bugs.php.net/bug.php?id=75938
|
||||
|
||||
return new WP_Error(
|
||||
'signature_verification_unsupported',
|
||||
sprintf(
|
||||
/* translators: 1: The filename of the package. */
|
||||
__( 'The authenticity of %1$s could not be verified as signature verification is unavailable on this system.' ),
|
||||
'<span class="code">' . esc_html( $filename_for_errors ) . '</span>'
|
||||
),
|
||||
array(
|
||||
'php' => phpversion(),
|
||||
'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ),
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if ( ! $signatures ) {
|
||||
return new WP_Error(
|
||||
'signature_verification_no_signature',
|
||||
sprintf(
|
||||
/* translators: %s: The filename of the package. */
|
||||
__( 'The authenticity of %s could not be verified as no signature was found.' ),
|
||||
'<span class="code">' . esc_html( $filename_for_errors ) . '</span>'
|
||||
),
|
||||
array(
|
||||
'filename' => $filename_for_errors,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$trusted_keys = wp_trusted_keys();
|
||||
$file_hash = hash_file( 'sha384', $filename, true );
|
||||
|
||||
mbstring_binary_safe_encoding();
|
||||
|
||||
$skipped_key = $skipped_signature = 0;
|
||||
|
||||
foreach ( (array) $signatures as $signature ) {
|
||||
$signature_raw = base64_decode( $signature );
|
||||
|
||||
// Ensure only valid-length signatures are considered.
|
||||
if ( SODIUM_CRYPTO_SIGN_BYTES !== strlen( $signature_raw ) ) {
|
||||
$skipped_signature++;
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ( (array) $trusted_keys as $key ) {
|
||||
$key_raw = base64_decode( $key );
|
||||
|
||||
// Only pass valid public keys through.
|
||||
if ( SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES !== strlen( $key_raw ) ) {
|
||||
$skipped_key++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( sodium_crypto_sign_verify_detached( $signature_raw, $file_hash, $key_raw ) ) {
|
||||
reset_mbstring_encoding();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
||||
return new WP_Error(
|
||||
'signature_verification_failed',
|
||||
sprintf(
|
||||
/* translators: %s: The filename of the package. */
|
||||
__( 'The authenticity of %s could not be verified.' ),
|
||||
'<span class="code">' . esc_html( $filename_for_errors ) . '</span>'
|
||||
),
|
||||
// Error data helpful for debugging:
|
||||
array(
|
||||
'filename' => $filename_for_errors,
|
||||
'keys' => $trusted_keys,
|
||||
'signatures' => $signatures,
|
||||
'hash' => bin2hex( $file_hash ),
|
||||
'skipped_key' => $skipped_key,
|
||||
'skipped_sig' => $skipped_signature,
|
||||
'php' => phpversion(),
|
||||
'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the list of signing keys trusted by WordPress.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @return array List of base64-encoded Signing keys.
|
||||
*/
|
||||
function wp_trusted_keys() {
|
||||
$trusted_keys = array();
|
||||
|
||||
if ( time() < 1617235200 ) {
|
||||
// WordPress.org Key #1 - This key is only valid before April 1st, 2021.
|
||||
$trusted_keys[] = 'fRPyrxb/MvVLbdsYi+OOEv4xc+Eqpsj+kkAS6gNOkI0=';
|
||||
}
|
||||
|
||||
// TODO: Add key #2 with longer expiration.
|
||||
|
||||
/**
|
||||
* Filter the valid Signing keys used to verify the contents of files.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param array $trusted_keys The trusted keys that may sign packages.
|
||||
*/
|
||||
return apply_filters( 'wp_trusted_keys', $trusted_keys );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unzips a specified ZIP file to a location on the filesystem via the WordPress
|
||||
* Filesystem Abstraction.
|
||||
|
@ -1097,8 +1326,8 @@ function unzip_file( $file, $to ) {
|
|||
$needed_dirs = array();
|
||||
$to = trailingslashit( $to );
|
||||
|
||||
// Determine any parent dir's needed (of the upgrade directory)
|
||||
if ( ! $wp_filesystem->is_dir( $to ) ) { //Only do parents if no children exist
|
||||
// Determine any parent directories needed (of the upgrade directory).
|
||||
if ( ! $wp_filesystem->is_dir( $to ) ) { // Only do parents if no children exist.
|
||||
$path = preg_split( '![/\\\]!', untrailingslashit( $to ) );
|
||||
for ( $i = count( $path ); $i >= 0; $i-- ) {
|
||||
if ( empty( $path[ $i ] ) ) {
|
||||
|
@ -1113,7 +1342,7 @@ function unzip_file( $file, $to ) {
|
|||
if ( ! $wp_filesystem->is_dir( $dir ) ) {
|
||||
$needed_dirs[] = $dir;
|
||||
} else {
|
||||
break; // A folder exists, therefor, we dont need the check the levels below this
|
||||
break; // A folder exists, therefore we don't need to check the levels below this.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1956,17 +2185,7 @@ function wp_print_request_filesystem_credentials_modal() {
|
|||
* @return string The HTML for this group and its items.
|
||||
*/
|
||||
function wp_privacy_generate_personal_data_export_group_html( $group_data ) {
|
||||
$allowed_tags = array(
|
||||
'a' => array(
|
||||
'href' => array(),
|
||||
'target' => array(),
|
||||
),
|
||||
'br' => array(),
|
||||
);
|
||||
$allowed_protocols = array( 'http', 'https' );
|
||||
$group_html = '';
|
||||
|
||||
$group_html .= '<h2>' . esc_html( $group_data['group_label'] ) . '</h2>';
|
||||
$group_html = '<h2>' . esc_html( $group_data['group_label'] ) . '</h2>';
|
||||
$group_html .= '<div>';
|
||||
|
||||
foreach ( (array) $group_data['items'] as $group_item_id => $group_item_data ) {
|
||||
|
@ -1975,14 +2194,14 @@ function wp_privacy_generate_personal_data_export_group_html( $group_data ) {
|
|||
|
||||
foreach ( (array) $group_item_data as $group_item_datum ) {
|
||||
$value = $group_item_datum['value'];
|
||||
// If it looks like a link, make it a link
|
||||
// If it looks like a link, make it a link.
|
||||
if ( false === strpos( $value, ' ' ) && ( 0 === strpos( $value, 'http://' ) || 0 === strpos( $value, 'https://' ) ) ) {
|
||||
$value = '<a href="' . esc_url( $value ) . '">' . esc_html( $value ) . '</a>';
|
||||
}
|
||||
|
||||
$group_html .= '<tr>';
|
||||
$group_html .= '<th>' . esc_html( $group_item_datum['name'] ) . '</th>';
|
||||
$group_html .= '<td>' . wp_kses( $value, $allowed_tags, $allowed_protocols ) . '</td>';
|
||||
$group_html .= '<td>' . wp_kses( $value, 'personal_data_export' ) . '</td>';
|
||||
$group_html .= '</tr>';
|
||||
}
|
||||
|
||||
|
@ -2051,7 +2270,7 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) {
|
|||
}
|
||||
|
||||
$title = sprintf(
|
||||
/* translators: %s: user's e-mail address */
|
||||
/* translators: %s: user's email address */
|
||||
__( 'Personal Data Export for %s' ),
|
||||
$email_address
|
||||
);
|
||||
|
@ -2197,6 +2416,15 @@ function wp_privacy_send_personal_data_export_email( $request_id ) {
|
|||
return new WP_Error( 'invalid_request', __( 'Invalid request ID when sending personal data export email.' ) );
|
||||
}
|
||||
|
||||
// Localize message content for user; fallback to site default for visitors.
|
||||
if ( ! empty( $request->user_id ) ) {
|
||||
$locale = get_user_locale( $request->user_id );
|
||||
} else {
|
||||
$locale = get_locale();
|
||||
}
|
||||
|
||||
$switched_locale = switch_to_locale( $locale );
|
||||
|
||||
/** This filter is documented in wp-includes/functions.php */
|
||||
$expiration = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS );
|
||||
$expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration );
|
||||
|
@ -2247,12 +2475,17 @@ All at ###SITENAME###
|
|||
$mail_success = wp_mail(
|
||||
$email_address,
|
||||
sprintf(
|
||||
/* translators: Personal data export notification email subject. %s: Site title */
|
||||
__( '[%s] Personal Data Export' ),
|
||||
$site_name
|
||||
),
|
||||
$content
|
||||
);
|
||||
|
||||
if ( $switched_locale ) {
|
||||
restore_previous_locale();
|
||||
}
|
||||
|
||||
if ( ! $mail_success ) {
|
||||
return new WP_Error( 'privacy_email_error', __( 'Unable to send personal data export email.' ) );
|
||||
}
|
||||
|
@ -2370,6 +2603,9 @@ function wp_privacy_process_personal_data_export_page( $response, $exporter_inde
|
|||
if ( is_wp_error( $mail_success ) ) {
|
||||
wp_send_json_error( $mail_success->get_error_message() );
|
||||
}
|
||||
|
||||
// Update the request to completed state when the export email is sent.
|
||||
_wp_privacy_completed_request( $request_id );
|
||||
} else {
|
||||
// Modify the response to include the URL of the export file so the browser can fetch it.
|
||||
$export_file_url = get_post_meta( $request_id, '_export_file_url', true );
|
||||
|
@ -2378,8 +2614,5 @@ function wp_privacy_process_personal_data_export_page( $response, $exporter_inde
|
|||
}
|
||||
}
|
||||
|
||||
// Update the request to completed state.
|
||||
_wp_privacy_completed_request( $request_id );
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ function wp_image_editor( $post_id, $msg = false ) {
|
|||
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
|
||||
$can_restore = false;
|
||||
if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) {
|
||||
$can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] );
|
||||
$can_restore = $backup_sizes['full-orig']['file'] != wp_basename( $meta['file'] );
|
||||
}
|
||||
|
||||
if ( $msg ) {
|
||||
|
|
|
@ -47,7 +47,7 @@ function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $s
|
|||
}
|
||||
|
||||
if ( ! $dst_file ) {
|
||||
$dst_file = str_replace( basename( $src_file ), 'cropped-' . basename( $src_file ), $src_file );
|
||||
$dst_file = str_replace( wp_basename( $src_file ), 'cropped-' . wp_basename( $src_file ), $src_file );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -56,7 +56,7 @@ function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $s
|
|||
*/
|
||||
wp_mkdir_p( dirname( $dst_file ) );
|
||||
|
||||
$dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) );
|
||||
$dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), wp_basename( $dst_file ) );
|
||||
|
||||
$result = $editor->save( $dst_file );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
|
@ -189,7 +189,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
|||
$ext = '.png';
|
||||
break;
|
||||
}
|
||||
$basename = str_replace( '.', '-', basename( $file ) ) . '-image' . $ext;
|
||||
$basename = str_replace( '.', '-', wp_basename( $file ) ) . '-image' . $ext;
|
||||
$uploaded = wp_upload_bits( $basename, '', $metadata['image']['data'] );
|
||||
if ( false === $uploaded['error'] ) {
|
||||
$image_attachment = array(
|
||||
|
@ -711,8 +711,8 @@ function _copy_image_file( $attachment_id ) {
|
|||
}
|
||||
|
||||
if ( $src_file ) {
|
||||
$dst_file = str_replace( basename( $dst_file ), 'copy-' . basename( $dst_file ), $dst_file );
|
||||
$dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) );
|
||||
$dst_file = str_replace( wp_basename( $dst_file ), 'copy-' . wp_basename( $dst_file ), $dst_file );
|
||||
$dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), wp_basename( $dst_file ) );
|
||||
|
||||
/*
|
||||
* The directory containing the original file may no longer
|
||||
|
|
|
@ -99,7 +99,7 @@ function wp_import_handle_upload() {
|
|||
|
||||
// Construct the object array
|
||||
$object = array(
|
||||
'post_title' => basename( $upload['file'] ),
|
||||
'post_title' => wp_basename( $upload['file'] ),
|
||||
'post_content' => $upload['url'],
|
||||
'post_mime_type' => $upload['type'],
|
||||
'guid' => $upload['url'],
|
||||
|
|
|
@ -434,7 +434,7 @@ function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data
|
|||
$url = $file['url'];
|
||||
$type = $file['type'];
|
||||
$file = $file['file'];
|
||||
$title = preg_replace( '/\.[^.]+$/', '', basename( $file ) );
|
||||
$title = preg_replace( '/\.[^.]+$/', '', wp_basename( $file ) );
|
||||
$content = '';
|
||||
|
||||
// Use image exif/iptc data for title and caption defaults if possible.
|
||||
|
@ -826,7 +826,7 @@ function wp_media_upload_handler() {
|
|||
if ( isset( $_POST['media_type'] ) && 'image' != $_POST['media_type'] ) {
|
||||
$title = esc_html( wp_unslash( $_POST['title'] ) );
|
||||
if ( empty( $title ) ) {
|
||||
$title = esc_html( basename( $src ) );
|
||||
$title = esc_html( wp_basename( $src ) );
|
||||
}
|
||||
|
||||
if ( $title && $src ) {
|
||||
|
@ -930,7 +930,7 @@ function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' )
|
|||
}
|
||||
|
||||
$file_array = array();
|
||||
$file_array['name'] = basename( $matches[0] );
|
||||
$file_array['name'] = wp_basename( $matches[0] );
|
||||
|
||||
// Download file to temp location.
|
||||
$file_array['tmp_name'] = download_url( $file );
|
||||
|
@ -2898,7 +2898,11 @@ function media_upload_max_image_resize() {
|
|||
* @since 3.5.0
|
||||
*/
|
||||
function multisite_over_quota_message() {
|
||||
echo '<p>' . sprintf( __( 'Sorry, you have used all of your storage quota of %s MB.' ), get_space_allowed() ) . '</p>';
|
||||
echo '<p>' . sprintf(
|
||||
/* translators: %s: allowed space allocation */
|
||||
__( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ),
|
||||
size_format( get_space_allowed() * MB_IN_BYTES )
|
||||
) . '</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3008,19 +3012,33 @@ function edit_form_image_editor( $post ) {
|
|||
?>
|
||||
</div>
|
||||
<div class="wp_attachment_details edit-form-section">
|
||||
<?php if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) : ?>
|
||||
<p class="attachment-alt-text">
|
||||
<label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
|
||||
<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php echo esc_attr( $alt_text ); ?>" />
|
||||
</p>
|
||||
<p class="attachment-alt-text-description" id="alt-text-description">
|
||||
<?php
|
||||
printf(
|
||||
/* translators: 1: link start tag, 2: accessibility text, 3: link end tag */
|
||||
__( '%1$sDescribe the purpose of the image%2$s%3$s. Leave empty if the image is purely decorative.' ),
|
||||
'<a href="' . esc_url( 'https://www.w3.org/WAI/tutorials/images/decision-tree' ) . '" target="_blank" rel="noopener noreferrer">',
|
||||
sprintf(
|
||||
'<span class="screen-reader-text"> %s</span>',
|
||||
/* translators: accessibility text */
|
||||
__( '(opens in a new tab)' )
|
||||
),
|
||||
'</a>'
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<p>
|
||||
<label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br />
|
||||
<textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
|
||||
</p>
|
||||
|
||||
|
||||
<?php if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) : ?>
|
||||
<p>
|
||||
<label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
|
||||
<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php echo esc_attr( $alt_text ); ?>" />
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
|
||||
$editor_args = array(
|
||||
|
@ -3033,11 +3051,11 @@ function edit_form_image_editor( $post ) {
|
|||
?>
|
||||
|
||||
<label for="attachment_content"><strong><?php _e( 'Description' ); ?></strong>
|
||||
<?php
|
||||
if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
|
||||
echo ': ' . __( 'Displayed on attachment pages.' );
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
|
||||
echo ': ' . __( 'Displayed on attachment pages.' );
|
||||
}
|
||||
?>
|
||||
</label>
|
||||
<?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
|
||||
|
||||
|
|
|
@ -399,7 +399,7 @@ function attachment_submit_meta_box( $post ) {
|
|||
<?php
|
||||
if ( current_user_can( 'delete_post', $post->ID ) ) {
|
||||
if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
|
||||
echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
|
||||
echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Move to Trash' ) . '</a>';
|
||||
} else {
|
||||
$delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
|
||||
echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "'>" . __( 'Delete Permanently' ) . '</a>';
|
||||
|
@ -804,7 +804,7 @@ function post_comment_meta_box_thead( $result ) {
|
|||
function post_comment_meta_box( $post ) {
|
||||
wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
|
||||
?>
|
||||
<p class="hide-if-no-js" id="add-new-comment"><a class="button" href="#commentstatusdiv" onclick="window.commentReply && commentReply.addcomment(<?php echo $post->ID; ?>);return false;"><?php _e( 'Add comment' ); ?></a></p>
|
||||
<p class="hide-if-no-js" id="add-new-comment"><button type="button" class="button" onclick="window.commentReply && commentReply.addcomment(<?php echo $post->ID; ?>);"><?php _e( 'Add comment' ); ?></button></p>
|
||||
<?php
|
||||
|
||||
$total = get_comments(
|
||||
|
|
|
@ -362,7 +362,7 @@ function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) {
|
|||
aria-posinset="<?php echo esc_attr( $index ); ?>">
|
||||
<?php
|
||||
$file_description = esc_html( get_file_description( $filename ) );
|
||||
if ( $file_description !== $filename && basename( $filename ) !== $file_description ) {
|
||||
if ( $file_description !== $filename && wp_basename( $filename ) !== $file_description ) {
|
||||
$file_description .= '<br /><span class="nonessential">(' . esc_html( $filename ) . ')</span>';
|
||||
}
|
||||
|
||||
|
@ -1082,8 +1082,6 @@ function wp_refresh_post_nonces( $response, $data, $screen_id ) {
|
|||
function wp_refresh_heartbeat_nonces( $response ) {
|
||||
// Refresh the Rest API nonce.
|
||||
$response['rest_nonce'] = wp_create_nonce( 'wp_rest' );
|
||||
// TEMPORARY: Compat with api-fetch library
|
||||
$response['rest-nonce'] = $response['rest_nonce'];
|
||||
|
||||
// Refresh the Heartbeat nonce.
|
||||
$response['heartbeat_nonce'] = wp_create_nonce( 'heartbeat-nonce' );
|
||||
|
@ -1291,6 +1289,7 @@ All at ###SITENAME###
|
|||
$content = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content );
|
||||
$content = str_replace( '###SITEURL###', home_url(), $content );
|
||||
|
||||
/* translators: New admin email address notification email subject. %s: Site title */
|
||||
wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ), $content );
|
||||
|
||||
if ( $switched_locale ) {
|
||||
|
@ -1621,7 +1620,11 @@ final class WP_Privacy_Policy_Content {
|
|||
* @param WP_Post|null $post The currently edited post. Default null.
|
||||
*/
|
||||
public static function notice( $post = null ) {
|
||||
$post = get_post( $post );
|
||||
if ( is_null( $post ) ) {
|
||||
global $post;
|
||||
} else {
|
||||
$post = get_post( $post );
|
||||
}
|
||||
|
||||
if ( ! ( $post instanceof WP_Post ) ) {
|
||||
return;
|
||||
|
@ -1633,30 +1636,47 @@ final class WP_Privacy_Policy_Content {
|
|||
|
||||
$policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
|
||||
|
||||
if ( ! $policy_page_id || $policy_page_id != $post->ID ) {
|
||||
if ( ! $policy_page_id || $policy_page_id !== $post->ID ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="notice notice-warning inline wp-pp-notice">
|
||||
<p>
|
||||
<?php
|
||||
/* translators: 1: Privacy Policy guide URL, 2: additional link attributes, 3: accessibility text */
|
||||
printf(
|
||||
__( 'Need help putting together your new Privacy Policy page? <a href="%1$s" %2$s>Check out our guide%3$s</a> for recommendations on what content to include, along with policies suggested by your plugins and theme.' ),
|
||||
admin_url( 'tools.php?wp-privacy-policy-guide=1' ),
|
||||
'target="_blank"',
|
||||
$message = __( 'Need help putting together your new Privacy Policy page? Check out our guide for recommendations on what content to include, along with policies suggested by your plugins and theme.' );
|
||||
$url = esc_url( admin_url( 'tools.php?wp-privacy-policy-guide=1' ) );
|
||||
$label = __( 'View Privacy Policy Guide.' );
|
||||
|
||||
if ( get_current_screen()->is_block_editor() ) {
|
||||
wp_enqueue_script( 'wp-notices' );
|
||||
$action = array(
|
||||
'url' => $url,
|
||||
'label' => $label,
|
||||
);
|
||||
wp_add_inline_script(
|
||||
'wp-notices',
|
||||
sprintf(
|
||||
'<span class="screen-reader-text"> %s</span>',
|
||||
'wp.data.dispatch( "core/notices" ).createWarningNotice( "%s", { actions: [ %s ], isDismissible: false } )',
|
||||
$message,
|
||||
wp_json_encode( $action )
|
||||
),
|
||||
'after'
|
||||
);
|
||||
} else {
|
||||
?>
|
||||
<div class="notice notice-warning inline wp-pp-notice">
|
||||
<p>
|
||||
<?php
|
||||
echo $message;
|
||||
printf(
|
||||
' <a href="%s" target="_blank">%s <span class="screen-reader-text">%s</span></a>',
|
||||
$url,
|
||||
$label,
|
||||
/* translators: accessibility text */
|
||||
__( '(opens in a new tab)' )
|
||||
)
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1841,7 +1861,7 @@ final class WP_Privacy_Policy_Content {
|
|||
/* translators: default privacy policy text. */
|
||||
$strings[] = '<p>' . $suggested_text . __( 'If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year.' ) . '</p>';
|
||||
/* translators: default privacy policy text. */
|
||||
$strings[] = '<p>' . __( 'If you have an account and you log in to this site, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser.' ) . '</p>';
|
||||
$strings[] = '<p>' . __( 'If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser.' ) . '</p>';
|
||||
/* translators: default privacy policy text. */
|
||||
$strings[] = '<p>' . __( 'When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed.' ) . '</p>';
|
||||
/* translators: default privacy policy text. */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* @deprecated 3.0.0
|
||||
*/
|
||||
function wpmu_menu() {
|
||||
_deprecated_function(__FUNCTION__, '3.0.0' );
|
||||
_deprecated_function( __FUNCTION__, '3.0.0' );
|
||||
// Deprecated. See #11763.
|
||||
}
|
||||
|
||||
|
@ -27,10 +27,15 @@ function wpmu_menu() {
|
|||
* @see is_upload_space_available()
|
||||
*/
|
||||
function wpmu_checkAvailableSpace() {
|
||||
_deprecated_function(__FUNCTION__, '3.0.0', 'is_upload_space_available()' );
|
||||
_deprecated_function( __FUNCTION__, '3.0.0', 'is_upload_space_available()' );
|
||||
|
||||
if ( !is_upload_space_available() )
|
||||
wp_die( __('Sorry, you must delete files before you can upload any more.') );
|
||||
if ( ! is_upload_space_available() ) {
|
||||
wp_die( sprintf(
|
||||
/* translators: %s: allowed space allocation */
|
||||
__( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ),
|
||||
size_format( get_space_allowed() * MB_IN_BYTES )
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +44,7 @@ function wpmu_checkAvailableSpace() {
|
|||
* @deprecated 3.0.0
|
||||
*/
|
||||
function mu_options( $options ) {
|
||||
_deprecated_function(__FUNCTION__, '3.0.0' );
|
||||
_deprecated_function( __FUNCTION__, '3.0.0' );
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
@ -50,7 +55,7 @@ function mu_options( $options ) {
|
|||
* @see activate_plugin()
|
||||
*/
|
||||
function activate_sitewide_plugin() {
|
||||
_deprecated_function(__FUNCTION__, '3.0.0', 'activate_plugin()' );
|
||||
_deprecated_function( __FUNCTION__, '3.0.0', 'activate_plugin()' );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -61,7 +66,7 @@ function activate_sitewide_plugin() {
|
|||
* @see deactivate_plugin()
|
||||
*/
|
||||
function deactivate_sitewide_plugin( $plugin = false ) {
|
||||
_deprecated_function(__FUNCTION__, '3.0.0', 'deactivate_plugin()' );
|
||||
_deprecated_function( __FUNCTION__, '3.0.0', 'deactivate_plugin()' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +76,7 @@ function deactivate_sitewide_plugin( $plugin = false ) {
|
|||
* @see is_network_only_plugin()
|
||||
*/
|
||||
function is_wpmu_sitewide_plugin( $file ) {
|
||||
_deprecated_function(__FUNCTION__, '3.0.0', 'is_network_only_plugin()' );
|
||||
_deprecated_function( __FUNCTION__, '3.0.0', 'is_network_only_plugin()' );
|
||||
return is_network_only_plugin( $file );
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,11 @@ function upload_is_user_over_quota( $echo = true ) {
|
|||
|
||||
if ( ( $space_allowed - $space_used ) < 0 ) {
|
||||
if ( $echo ) {
|
||||
_e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' );
|
||||
printf(
|
||||
/* translators: %s: allowed space allocation */
|
||||
__( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ),
|
||||
size_format( $space_allowed * MB_IN_BYTES )
|
||||
);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
|
@ -1130,9 +1134,9 @@ function network_edit_site_nav( $args = array() ) {
|
|||
}
|
||||
|
||||
// All done!
|
||||
echo '<h2 class="nav-tab-wrapper wp-clearfix">';
|
||||
echo '<nav class="nav-tab-wrapper wp-clearfix" aria-label="' . esc_attr__( 'Secondary menu' ) . '">';
|
||||
echo implode( '', $screen_links );
|
||||
echo '</h2>';
|
||||
echo '</nav>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -61,22 +61,31 @@ function options_general_add_js() {
|
|||
if ( "time_format_custom_radio" != $(this).attr("id") )
|
||||
$( 'input[name="time_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
|
||||
});
|
||||
|
||||
$( 'input[name="time_format_custom"]' ).on( 'click input', function() {
|
||||
$( '#time_format_custom_radio' ).prop( 'checked', true );
|
||||
});
|
||||
$("input[name='date_format_custom'], input[name='time_format_custom']").change( function() {
|
||||
|
||||
$( 'input[name="date_format_custom"], input[name="time_format_custom"]' ).on( 'input', function() {
|
||||
var format = $( this ),
|
||||
fieldset = format.closest( 'fieldset' ),
|
||||
example = fieldset.find( '.example' ),
|
||||
spinner = fieldset.find( '.spinner' );
|
||||
|
||||
spinner.addClass( 'is-active' );
|
||||
// Debounce the event callback while users are typing.
|
||||
clearTimeout( $.data( this, 'timer' ) );
|
||||
$( this ).data( 'timer', setTimeout( function() {
|
||||
// If custom date is not empty.
|
||||
if ( format.val() ) {
|
||||
spinner.addClass( 'is-active' );
|
||||
|
||||
$.post( ajaxurl, {
|
||||
action: 'date_format_custom' == format.attr( 'name' ) ? 'date_format' : 'time_format',
|
||||
date : format.val()
|
||||
}, function( d ) { spinner.removeClass( 'is-active' ); example.text( d ); } );
|
||||
});
|
||||
$.post( ajaxurl, {
|
||||
action: 'date_format_custom' == format.attr( 'name' ) ? 'date_format' : 'time_format',
|
||||
date : format.val()
|
||||
}, function( d ) { spinner.removeClass( 'is-active' ); example.text( d ); } );
|
||||
}
|
||||
}, 500 ) );
|
||||
} );
|
||||
|
||||
var languageSelect = $( '#WPLANG' );
|
||||
$( 'form' ).submit( function() {
|
||||
|
@ -107,7 +116,7 @@ function options_reading_add_js() {
|
|||
selects.prop( 'disabled', ! staticPage.prop('checked') );
|
||||
};
|
||||
check_disabled();
|
||||
section.find('input:radio').change(check_disabled);
|
||||
section.find( 'input:radio' ).change( check_disabled );
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
|
|
|
@ -754,11 +754,12 @@ function install_plugin_information() {
|
|||
</div>
|
||||
<div id="section-holder" class="wrap">
|
||||
<?php
|
||||
$wp_version = get_bloginfo( 'version' );
|
||||
$requires_php = isset( $api->requires_php ) ? $api->requires_php : null;
|
||||
$requires_wp = isset( $api->requires ) ? $api->requires : null;
|
||||
|
||||
$compatible_php = ( empty( $api->requires_php ) || version_compare( phpversion(), $api->requires_php, '>=' ) );
|
||||
$tested_wp = ( empty( $api->tested ) || version_compare( $wp_version, $api->tested, '<=' ) );
|
||||
$compatible_wp = ( empty( $api->requires ) || version_compare( $wp_version, $api->requires, '>=' ) );
|
||||
$compatible_php = is_php_version_compatible( $requires_php );
|
||||
$compatible_wp = is_wp_version_compatible( $requires_wp );
|
||||
$tested_wp = ( empty( $api->tested ) || version_compare( get_bloginfo( 'version' ), $api->tested, '<=' ) );
|
||||
|
||||
if ( ! $compatible_php ) {
|
||||
echo '<div class="notice notice-error notice-alt"><p>';
|
||||
|
@ -769,8 +770,8 @@ function install_plugin_information() {
|
|||
' ' . __( '<a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ),
|
||||
esc_url( wp_get_update_php_url() )
|
||||
);
|
||||
echo '</p>';
|
||||
wp_update_php_annotation();
|
||||
|
||||
wp_update_php_annotation( '</p><p><em>', '</em>' );
|
||||
} else {
|
||||
echo '</p>';
|
||||
}
|
||||
|
@ -827,7 +828,14 @@ function install_plugin_information() {
|
|||
break;
|
||||
case 'update_available':
|
||||
if ( $status['url'] ) {
|
||||
echo '<a data-slug="' . esc_attr( $api->slug ) . '" data-plugin="' . esc_attr( $status['file'] ) . '" id="plugin_update_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) . '</a>';
|
||||
if ( $compatible_php ) {
|
||||
echo '<a data-slug="' . esc_attr( $api->slug ) . '" data-plugin="' . esc_attr( $status['file'] ) . '" id="plugin_update_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) . '</a>';
|
||||
} else {
|
||||
printf(
|
||||
'<button type="button" class="button button-primary button-disabled right" disabled="disabled">%s</button>',
|
||||
_x( 'Cannot Update', 'plugin' )
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'newer_installed':
|
||||
|
|
|
@ -468,12 +468,14 @@ function get_dropins() {
|
|||
*/
|
||||
function _get_dropins() {
|
||||
$dropins = array(
|
||||
'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE
|
||||
'db.php' => array( __( 'Custom database class.' ), true ), // auto on load
|
||||
'db-error.php' => array( __( 'Custom database error message.' ), true ), // auto on error
|
||||
'install.php' => array( __( 'Custom installation script.' ), true ), // auto on installation
|
||||
'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance
|
||||
'object-cache.php' => array( __( 'External object cache.' ), true ), // auto on load
|
||||
'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE
|
||||
'db.php' => array( __( 'Custom database class.' ), true ), // auto on load
|
||||
'db-error.php' => array( __( 'Custom database error message.' ), true ), // auto on error
|
||||
'install.php' => array( __( 'Custom installation script.' ), true ), // auto on installation
|
||||
'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance
|
||||
'object-cache.php' => array( __( 'External object cache.' ), true ), // auto on load
|
||||
'php-error.php' => array( __( 'Custom PHP error message.' ), true ), // auto on error
|
||||
'fatal-error-handler.php' => array( __( 'Custom PHP fatal error handler.' ), true ), // auto on error
|
||||
);
|
||||
|
||||
if ( is_multisite() ) {
|
||||
|
@ -595,6 +597,7 @@ function is_network_only_plugin( $plugin ) {
|
|||
* ensure that the success redirection will update the error redirection.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @since 5.2.0 Test for WordPress version and PHP version compatibility.
|
||||
*
|
||||
* @param string $plugin Path to the plugin file relative to the plugins directory.
|
||||
* @param string $redirect Optional. URL to redirect to.
|
||||
|
@ -619,13 +622,22 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen
|
|||
return $valid;
|
||||
}
|
||||
|
||||
$requirements = validate_plugin_requirements( $plugin );
|
||||
if ( is_wp_error( $requirements ) ) {
|
||||
return $requirements;
|
||||
}
|
||||
|
||||
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();
|
||||
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
|
||||
$_wp_plugin_file = $plugin;
|
||||
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
|
||||
define( 'WP_SANDBOX_SCRAPING', true );
|
||||
}
|
||||
include_once( WP_PLUGIN_DIR . '/' . $plugin );
|
||||
$plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin.
|
||||
|
||||
|
@ -758,6 +770,11 @@ function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( $do_blog && wp_is_recovery_mode() ) {
|
||||
list( $extension ) = explode( '/', $plugin );
|
||||
wp_paused_plugins()->delete( $extension );
|
||||
}
|
||||
|
||||
if ( ! $silent ) {
|
||||
/**
|
||||
* Fires as a specific plugin is being deactivated.
|
||||
|
@ -1058,6 +1075,67 @@ function validate_plugin( $plugin ) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the plugin requirements for WP version and PHP version.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $plugin Path to the plugin file relative to the plugins directory.
|
||||
* @return true|WP_Error True if requirements are met, WP_Error on failure.
|
||||
*/
|
||||
function validate_plugin_requirements( $plugin ) {
|
||||
$readme_file = WP_PLUGIN_DIR . '/' . dirname( $plugin ) . '/readme.txt';
|
||||
|
||||
if ( file_exists( $readme_file ) ) {
|
||||
$plugin_data = get_file_data(
|
||||
$readme_file,
|
||||
array(
|
||||
'requires' => 'Requires at least',
|
||||
'requires_php' => 'Requires PHP',
|
||||
),
|
||||
'plugin'
|
||||
);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
$plugin_data['wp_compatible'] = is_wp_version_compatible( $plugin_data['requires'] );
|
||||
$plugin_data['php_compatible'] = is_php_version_compatible( $plugin_data['requires_php'] );
|
||||
|
||||
$plugin_data = array_merge( $plugin_data, get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ) );
|
||||
|
||||
if ( ! $plugin_data['wp_compatible'] && ! $plugin_data['php_compatible'] ) {
|
||||
return new WP_Error(
|
||||
'plugin_wp_php_incompatible',
|
||||
sprintf(
|
||||
/* translators: %s: plugin name */
|
||||
__( '<strong>Error:</strong> Current WordPress and PHP versions do not meet minimum requirements for %s.' ),
|
||||
$plugin_data['Name']
|
||||
)
|
||||
);
|
||||
} elseif ( ! $plugin_data['php_compatible'] ) {
|
||||
return new WP_Error(
|
||||
'plugin_php_incompatible',
|
||||
sprintf(
|
||||
/* translators: %s: plugin name */
|
||||
__( '<strong>Error:</strong> Current PHP version does not meet minimum requirements for %s.' ),
|
||||
$plugin_data['Name']
|
||||
)
|
||||
);
|
||||
} elseif ( ! $plugin_data['wp_compatible'] ) {
|
||||
return new WP_Error(
|
||||
'plugin_wp_incompatible',
|
||||
sprintf(
|
||||
/* translators: %s: plugin name */
|
||||
__( '<strong>Error:</strong> Current WordPress version does not meet minimum requirements for %s.' ),
|
||||
$plugin_data['Name']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the plugin can be uninstalled.
|
||||
*
|
||||
|
@ -1285,8 +1363,8 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability,
|
|||
$_registered_pages[ $hookname ] = true;
|
||||
|
||||
/*
|
||||
* Backward-compatibility for plugins using add_management page.
|
||||
* See wp-admin/admin.php for redirect from edit.php to tools.php
|
||||
* Backward-compatibility for plugins using add_management_page().
|
||||
* See wp-admin/admin.php for redirect from edit.php to tools.php.
|
||||
*/
|
||||
if ( 'tools.php' == $parent_slug ) {
|
||||
$_registered_pages[ get_plugin_page_hookname( $menu_slug, 'edit.php' ) ] = true;
|
||||
|
@ -1644,6 +1722,8 @@ function menu_page_url( $menu_slug, $echo = true ) {
|
|||
* @global array $_wp_real_parent_file
|
||||
* @global array $_wp_menu_nopriv
|
||||
* @global array $_wp_submenu_nopriv
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_admin_page_parent( $parent = '' ) {
|
||||
global $parent_file, $menu, $submenu, $pagenow, $typenow,
|
||||
|
@ -1714,6 +1794,8 @@ function get_admin_page_parent( $parent = '' ) {
|
|||
* @global string $pagenow
|
||||
* @global string $plugin_page
|
||||
* @global string $typenow
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_admin_page_title() {
|
||||
global $title, $menu, $submenu, $pagenow, $plugin_page, $typenow;
|
||||
|
@ -1790,9 +1872,10 @@ function get_admin_page_title() {
|
|||
/**
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param string $plugin_page
|
||||
* @param string $parent_page
|
||||
* @return string|null
|
||||
* @param string $plugin_page The slug name of the plugin page.
|
||||
* @param string $parent_page The slug name for the parent menu (or the file name of a standard
|
||||
* WordPress admin page).
|
||||
* @return string|null Hook attached to the plugin page, null otherwise.
|
||||
*/
|
||||
function get_plugin_page_hook( $plugin_page, $parent_page ) {
|
||||
$hook = get_plugin_page_hookname( $plugin_page, $parent_page );
|
||||
|
@ -1805,8 +1888,11 @@ function get_plugin_page_hook( $plugin_page, $parent_page ) {
|
|||
|
||||
/**
|
||||
* @global array $admin_page_hooks
|
||||
* @param string $plugin_page
|
||||
* @param string $parent_page
|
||||
*
|
||||
* @param string $plugin_page The slug name of the plugin page.
|
||||
* @param string $parent_page The slug name for the parent menu (or the file name of a standard
|
||||
* WordPress admin page).
|
||||
* @return string Hook name for the plugin page.
|
||||
*/
|
||||
function get_plugin_page_hookname( $plugin_page, $parent_page ) {
|
||||
global $admin_page_hooks;
|
||||
|
@ -1837,6 +1923,8 @@ function get_plugin_page_hookname( $plugin_page, $parent_page ) {
|
|||
* @global array $_wp_submenu_nopriv
|
||||
* @global string $plugin_page
|
||||
* @global array $_registered_pages
|
||||
*
|
||||
* @return bool Whether the current user can access the current admin page.
|
||||
*/
|
||||
function user_can_access_admin_page() {
|
||||
global $pagenow, $menu, $submenu, $_wp_menu_nopriv, $_wp_submenu_nopriv,
|
||||
|
@ -2046,6 +2134,9 @@ function wp_clean_plugins_cache( $clear_update_cache = true ) {
|
|||
* @param string $plugin Path to the plugin file relative to the plugins directory.
|
||||
*/
|
||||
function plugin_sandbox_scrape( $plugin ) {
|
||||
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
|
||||
define( 'WP_SANDBOX_SCRAPING', true );
|
||||
}
|
||||
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
|
||||
include( WP_PLUGIN_DIR . '/' . $plugin );
|
||||
}
|
||||
|
@ -2101,3 +2192,132 @@ function wp_add_privacy_policy_content( $plugin_name, $policy_text ) {
|
|||
|
||||
WP_Privacy_Policy_Content::add( $plugin_name, $policy_text );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a plugin is technically active but was paused while
|
||||
* loading.
|
||||
*
|
||||
* For more information on this and similar theme functions, check out
|
||||
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
|
||||
* Conditional Tags} article in the Theme Developer Handbook.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $plugin Path to the plugin file relative to the plugins directory.
|
||||
* @return bool True, if in the list of paused plugins. False, not in the list.
|
||||
*/
|
||||
function is_plugin_paused( $plugin ) {
|
||||
if ( ! isset( $GLOBALS['_paused_plugins'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! is_plugin_active( $plugin ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
list( $plugin ) = explode( '/', $plugin );
|
||||
|
||||
return array_key_exists( $plugin, $GLOBALS['_paused_plugins'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the error that was recorded for a paused plugin.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $plugin Path to the plugin file relative to the plugins
|
||||
* directory.
|
||||
* @return array|false Array of error information as it was returned by
|
||||
* `error_get_last()`, or false if none was recorded.
|
||||
*/
|
||||
function wp_get_plugin_error( $plugin ) {
|
||||
if ( ! isset( $GLOBALS['_paused_plugins'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
list( $plugin ) = explode( '/', $plugin );
|
||||
|
||||
if ( ! array_key_exists( $plugin, $GLOBALS['_paused_plugins'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $GLOBALS['_paused_plugins'][ $plugin ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to resume a single plugin.
|
||||
*
|
||||
* If a redirect was provided, we first ensure the plugin does not throw fatal
|
||||
* errors anymore.
|
||||
*
|
||||
* The way it works is by setting the redirection to the error before trying to
|
||||
* include the plugin file. If the plugin fails, then the redirection will not
|
||||
* be overwritten with the success message and the plugin will not be resumed.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $plugin Single plugin to resume.
|
||||
* @param string $redirect Optional. URL to redirect to. Default empty string.
|
||||
* @return bool|WP_Error True on success, false if `$plugin` was not paused,
|
||||
* `WP_Error` on failure.
|
||||
*/
|
||||
function resume_plugin( $plugin, $redirect = '' ) {
|
||||
/*
|
||||
* We'll override this later if the plugin could be resumed without
|
||||
* creating a fatal error.
|
||||
*/
|
||||
if ( ! empty( $redirect ) ) {
|
||||
wp_redirect(
|
||||
add_query_arg(
|
||||
'_error_nonce',
|
||||
wp_create_nonce( 'plugin-resume-error_' . $plugin ),
|
||||
$redirect
|
||||
)
|
||||
);
|
||||
|
||||
// Load the plugin to test whether it throws a fatal error.
|
||||
ob_start();
|
||||
plugin_sandbox_scrape( $plugin );
|
||||
ob_clean();
|
||||
}
|
||||
|
||||
list( $extension ) = explode( '/', $plugin );
|
||||
|
||||
$result = wp_paused_plugins()->delete( $extension );
|
||||
|
||||
if ( ! $result ) {
|
||||
return new WP_Error(
|
||||
'could_not_resume_plugin',
|
||||
__( 'Could not resume the plugin.' )
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an admin notice in case some plugins have been paused due to errors.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
function paused_plugins_notice() {
|
||||
if ( 'plugins.php' === $GLOBALS['pagenow'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'resume_plugins' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! isset( $GLOBALS['_paused_plugins'] ) || empty( $GLOBALS['_paused_plugins'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(
|
||||
'<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
|
||||
__( 'One or more plugins failed to load properly.' ),
|
||||
__( 'You can find more details and make changes on the Plugins screen.' ),
|
||||
esc_url( admin_url( 'plugins.php?plugin_status=paused' ) ),
|
||||
__( 'Go to the Plugins screen' )
|
||||
);
|
||||
}
|
||||
|
|
|
@ -731,23 +731,26 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
|
|||
}
|
||||
|
||||
/**
|
||||
* Determine if a post exists based on title, content, and date
|
||||
* Determines if a post exists based on title, content, date and type.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @since 5.2.0 Added the `$type` parameter.
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param string $title Post title
|
||||
* @param string $content Optional post content
|
||||
* @param string $date Optional post date
|
||||
* @param string $title Post title.
|
||||
* @param string $content Optional post content.
|
||||
* @param string $date Optional post date.
|
||||
* @param string $type Optional post type.
|
||||
* @return int Post ID if post exists, 0 otherwise.
|
||||
*/
|
||||
function post_exists( $title, $content = '', $date = '' ) {
|
||||
function post_exists( $title, $content = '', $date = '', $type = '' ) {
|
||||
global $wpdb;
|
||||
|
||||
$post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) );
|
||||
$post_content = wp_unslash( sanitize_post_field( 'post_content', $content, 0, 'db' ) );
|
||||
$post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) );
|
||||
$post_type = wp_unslash( sanitize_post_field( 'post_type', $type, 0, 'db' ) );
|
||||
|
||||
$query = "SELECT ID FROM $wpdb->posts WHERE 1=1";
|
||||
$args = array();
|
||||
|
@ -767,6 +770,11 @@ function post_exists( $title, $content = '', $date = '' ) {
|
|||
$args[] = $post_content;
|
||||
}
|
||||
|
||||
if ( ! empty( $type ) ) {
|
||||
$query .= ' AND post_type = %s';
|
||||
$args[] = $post_type;
|
||||
}
|
||||
|
||||
if ( ! empty( $args ) ) {
|
||||
return (int) $wpdb->get_var( $wpdb->prepare( $query, $args ) );
|
||||
}
|
||||
|
@ -1176,23 +1184,6 @@ function wp_edit_posts_query( $q = false ) {
|
|||
return $avail_post_stati;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all available post MIME types for a given post type.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param string $type
|
||||
* @return mixed
|
||||
*/
|
||||
function get_available_post_mime_types( $type = 'attachment' ) {
|
||||
global $wpdb;
|
||||
|
||||
$types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type ) );
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the query variables for the current attachments request.
|
||||
*
|
||||
|
@ -1283,34 +1274,34 @@ function wp_edit_attachments_query( $q = false ) {
|
|||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $page
|
||||
* @return string
|
||||
* @param string $box_id Meta box ID (used in the 'id' attribute for the meta box).
|
||||
* @param string $screen_id The screen on which the meta box is shown.
|
||||
* @return string Space-separated string of class names.
|
||||
*/
|
||||
function postbox_classes( $id, $page ) {
|
||||
if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id ) {
|
||||
function postbox_classes( $box_id, $screen_id ) {
|
||||
if ( isset( $_GET['edit'] ) && $_GET['edit'] == $box_id ) {
|
||||
$classes = array( '' );
|
||||
} elseif ( $closed = get_user_option( 'closedpostboxes_' . $page ) ) {
|
||||
} elseif ( $closed = get_user_option( 'closedpostboxes_' . $screen_id ) ) {
|
||||
if ( ! is_array( $closed ) ) {
|
||||
$classes = array( '' );
|
||||
} else {
|
||||
$classes = in_array( $id, $closed ) ? array( 'closed' ) : array( '' );
|
||||
$classes = in_array( $box_id, $closed ) ? array( 'closed' ) : array( '' );
|
||||
}
|
||||
} else {
|
||||
$classes = array( '' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the postbox classes for a specific screen and screen ID combo.
|
||||
* Filters the postbox classes for a specific screen and box 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, `$screen_id` and `$box_id`, refer to
|
||||
* the screen ID and meta box ID, respectively.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param string[] $classes An array of postbox classes.
|
||||
*/
|
||||
$classes = apply_filters( "postbox_classes_{$page}_{$id}", $classes );
|
||||
$classes = apply_filters( "postbox_classes_{$screen_id}_{$box_id}", $classes );
|
||||
return implode( ' ', $classes );
|
||||
}
|
||||
|
||||
|
@ -2071,7 +2062,7 @@ function use_block_editor_for_post( $post ) {
|
|||
|
||||
// We're in the meta box loader, so don't use the block editor.
|
||||
if ( isset( $_GET['meta-box-loader'] ) ) {
|
||||
check_admin_referer( 'meta-box-loader' );
|
||||
check_admin_referer( 'meta-box-loader', 'meta-box-loader-nonce' );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -708,18 +708,6 @@ function populate_roles() {
|
|||
function populate_roles_160() {
|
||||
// Add roles
|
||||
|
||||
// Dummy gettext calls to get strings in the catalog.
|
||||
/* translators: user role */
|
||||
_x( 'Administrator', 'User role' );
|
||||
/* translators: user role */
|
||||
_x( 'Editor', 'User role' );
|
||||
/* translators: user role */
|
||||
_x( 'Author', 'User role' );
|
||||
/* translators: user role */
|
||||
_x( 'Contributor', 'User role' );
|
||||
/* translators: user role */
|
||||
_x( 'Subscriber', 'User role' );
|
||||
|
||||
add_role( 'administrator', 'Administrator' );
|
||||
add_role( 'editor', 'Editor' );
|
||||
add_role( 'author', 'Author' );
|
||||
|
@ -1316,8 +1304,18 @@ function populate_site_meta( $site_id, array $meta = array() ) {
|
|||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters meta for a site on creation.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param array $meta Associative array of site meta keys and values to be inserted.
|
||||
* @param int $site_id ID of site to populate.
|
||||
*/
|
||||
$site_meta = apply_filters( 'populate_site_meta', $meta, $site_id );
|
||||
|
||||
$insert = '';
|
||||
foreach ( $meta as $meta_key => $meta_value ) {
|
||||
foreach ( $site_meta as $meta_key => $meta_value ) {
|
||||
if ( is_array( $meta_value ) ) {
|
||||
$meta_value = serialize( $meta_value );
|
||||
}
|
||||
|
|
|
@ -479,16 +479,15 @@ function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $
|
|||
</div>
|
||||
|
||||
<div id="replysubmit" class="submit">
|
||||
<p>
|
||||
<a href="#comments-form" class="save button button-primary alignright">
|
||||
<p class="reply-submit-buttons">
|
||||
<button type="button" class="save button button-primary">
|
||||
<span id="addbtn" style="display: none;"><?php _e( 'Add Comment' ); ?></span>
|
||||
<span id="savebtn" style="display: none;"><?php _e( 'Update Comment' ); ?></span>
|
||||
<span id="replybtn" style="display: none;"><?php _e( 'Submit Reply' ); ?></span>
|
||||
</a>
|
||||
<a href="#comments-form" class="cancel button alignleft"><?php _e( 'Cancel' ); ?></a>
|
||||
</button>
|
||||
<button type="button" class="cancel button"><?php _e( 'Cancel' ); ?></button>
|
||||
<span class="waiting spinner"></span>
|
||||
</p>
|
||||
<br class="clear" />
|
||||
<div class="notice notice-error notice-alt inline hidden">
|
||||
<p class="error"></p>
|
||||
</div>
|
||||
|
@ -775,20 +774,19 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
|
|||
// todo: Remove this?
|
||||
// echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
|
||||
|
||||
$time_adj = current_time( 'timestamp' );
|
||||
$post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date;
|
||||
$jj = ( $edit ) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
|
||||
$mm = ( $edit ) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
|
||||
$aa = ( $edit ) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
|
||||
$hh = ( $edit ) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
|
||||
$mn = ( $edit ) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
|
||||
$ss = ( $edit ) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
|
||||
$jj = ( $edit ) ? mysql2date( 'd', $post_date, false ) : current_time( 'd' );
|
||||
$mm = ( $edit ) ? mysql2date( 'm', $post_date, false ) : current_time( 'm' );
|
||||
$aa = ( $edit ) ? mysql2date( 'Y', $post_date, false ) : current_time( 'Y' );
|
||||
$hh = ( $edit ) ? mysql2date( 'H', $post_date, false ) : current_time( 'H' );
|
||||
$mn = ( $edit ) ? mysql2date( 'i', $post_date, false ) : current_time( 'i' );
|
||||
$ss = ( $edit ) ? mysql2date( 's', $post_date, false ) : current_time( 's' );
|
||||
|
||||
$cur_jj = gmdate( 'd', $time_adj );
|
||||
$cur_mm = gmdate( 'm', $time_adj );
|
||||
$cur_aa = gmdate( 'Y', $time_adj );
|
||||
$cur_hh = gmdate( 'H', $time_adj );
|
||||
$cur_mn = gmdate( 'i', $time_adj );
|
||||
$cur_jj = current_time( 'd' );
|
||||
$cur_mm = current_time( 'm' );
|
||||
$cur_aa = current_time( 'Y' );
|
||||
$cur_hh = current_time( 'H' );
|
||||
$cur_mn = current_time( 'i' );
|
||||
|
||||
$month = '<label><span class="screen-reader-text">' . __( 'Month' ) . '</span><select ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n";
|
||||
for ( $i = 1; $i < 13; $i = $i + 1 ) {
|
||||
|
|
|
@ -721,12 +721,12 @@ function customize_themes_print_templates() {
|
|||
<# if ( data.stars && 0 != data.num_ratings ) { #>
|
||||
<div class="theme-rating">
|
||||
{{{ data.stars }}}
|
||||
<span class="num-ratings">
|
||||
<a class="num-ratings" target="_blank" href="{{ data.reviews_url }}">
|
||||
<?php
|
||||
/* translators: %s: number of ratings */
|
||||
echo sprintf( __( '(%s ratings)' ), '{{ data.num_ratings }}' );
|
||||
echo sprintf( __( '(%s ratings) <span class="screen-reader-text">link to view ratings opens in a new tab</span>' ), '{{ data.num_ratings }}' );
|
||||
?>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<# } #>
|
||||
|
||||
|
@ -768,3 +768,140 @@ function customize_themes_print_templates() {
|
|||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a theme is technically active but was paused while
|
||||
* loading.
|
||||
*
|
||||
* For more information on this and similar theme functions, check out
|
||||
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
|
||||
* Conditional Tags} article in the Theme Developer Handbook.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $theme Path to the theme directory relative to the themes directory.
|
||||
* @return bool True, if in the list of paused themes. False, not in the list.
|
||||
*/
|
||||
function is_theme_paused( $theme ) {
|
||||
if ( ! isset( $GLOBALS['_paused_themes'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( get_stylesheet() !== $theme && get_template() !== $theme ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return array_key_exists( $theme, $GLOBALS['_paused_themes'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the error that was recorded for a paused theme.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $theme Path to the theme directory relative to the themes
|
||||
* directory.
|
||||
* @return array|false Array of error information as it was returned by
|
||||
* `error_get_last()`, or false if none was recorded.
|
||||
*/
|
||||
function wp_get_theme_error( $theme ) {
|
||||
if ( ! isset( $GLOBALS['_paused_themes'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! array_key_exists( $theme, $GLOBALS['_paused_themes'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $GLOBALS['_paused_themes'][ $theme ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to resume a single theme.
|
||||
*
|
||||
* If a redirect was provided and a functions.php file was found, we first ensure that
|
||||
* functions.php file does not throw fatal errors anymore.
|
||||
*
|
||||
* The way it works is by setting the redirection to the error before trying to
|
||||
* include the file. If the theme fails, then the redirection will not be overwritten
|
||||
* with the success message and the theme will not be resumed.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
* @param string $theme Single theme to resume.
|
||||
* @param string $redirect Optional. URL to redirect to. Default empty string.
|
||||
* @return bool|WP_Error True on success, false if `$theme` was not paused,
|
||||
* `WP_Error` on failure.
|
||||
*/
|
||||
function resume_theme( $theme, $redirect = '' ) {
|
||||
list( $extension ) = explode( '/', $theme );
|
||||
|
||||
/*
|
||||
* We'll override this later if the theme could be resumed without
|
||||
* creating a fatal error.
|
||||
*/
|
||||
if ( ! empty( $redirect ) ) {
|
||||
$functions_path = '';
|
||||
if ( strpos( STYLESHEETPATH, $extension ) ) {
|
||||
$functions_path = STYLESHEETPATH . '/functions.php';
|
||||
} elseif ( strpos( TEMPLATEPATH, $extension ) ) {
|
||||
$functions_path = TEMPLATEPATH . '/functions.php';
|
||||
}
|
||||
|
||||
if ( ! empty( $functions_path ) ) {
|
||||
wp_redirect(
|
||||
add_query_arg(
|
||||
'_error_nonce',
|
||||
wp_create_nonce( 'theme-resume-error_' . $theme ),
|
||||
$redirect
|
||||
)
|
||||
);
|
||||
|
||||
// Load the theme's functions.php to test whether it throws a fatal error.
|
||||
ob_start();
|
||||
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
|
||||
define( 'WP_SANDBOX_SCRAPING', true );
|
||||
}
|
||||
include $functions_path;
|
||||
ob_clean();
|
||||
}
|
||||
}
|
||||
|
||||
$result = wp_paused_themes()->delete( $extension );
|
||||
|
||||
if ( ! $result ) {
|
||||
return new WP_Error(
|
||||
'could_not_resume_theme',
|
||||
__( 'Could not resume the theme.' )
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an admin notice in case some themes have been paused due to errors.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
function paused_themes_notice() {
|
||||
if ( 'themes.php' === $GLOBALS['pagenow'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'resume_themes' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! isset( $GLOBALS['_paused_themes'] ) || empty( $GLOBALS['_paused_themes'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(
|
||||
'<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
|
||||
__( 'One or more themes failed to load properly.' ),
|
||||
__( 'You can find more details and make changes on the Themes screen.' ),
|
||||
esc_url( admin_url( 'themes.php' ) ),
|
||||
__( 'Go to the Themes screen' )
|
||||
);
|
||||
}
|
||||
|
|
|
@ -400,7 +400,11 @@ function wp_plugin_update_row( $file, $plugin_data ) {
|
|||
$active_class = is_plugin_active( $file ) ? ' active' : '';
|
||||
}
|
||||
|
||||
echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $response->slug . '-update' ) . '" data-slug="' . esc_attr( $response->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>';
|
||||
$requires_php = isset( $response->requires_php ) ? $response->requires_php : null;
|
||||
$compatible_php = is_php_version_compatible( $requires_php );
|
||||
$notice_type = $compatible_php ? 'notice-warning' : 'notice-error';
|
||||
|
||||
echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $response->slug . '-update' ) . '" data-slug="' . esc_attr( $response->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message notice inline ' . $notice_type . ' notice-alt"><p>';
|
||||
|
||||
if ( ! current_user_can( 'update_plugins' ) ) {
|
||||
/* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */
|
||||
|
@ -413,7 +417,7 @@ function wp_plugin_update_row( $file, $plugin_data ) {
|
|||
/* translators: 1: plugin name, 2: version number */
|
||||
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
|
||||
),
|
||||
$response->new_version
|
||||
esc_attr( $response->new_version )
|
||||
);
|
||||
} elseif ( empty( $response->package ) ) {
|
||||
/* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */
|
||||
|
@ -426,27 +430,44 @@ function wp_plugin_update_row( $file, $plugin_data ) {
|
|||
/* translators: 1: plugin name, 2: version number */
|
||||
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
|
||||
),
|
||||
$response->new_version
|
||||
esc_attr( $response->new_version )
|
||||
);
|
||||
} else {
|
||||
/* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */
|
||||
printf(
|
||||
__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ),
|
||||
$plugin_name,
|
||||
esc_url( $details_url ),
|
||||
sprintf(
|
||||
'class="thickbox open-plugin-details-modal" aria-label="%s"',
|
||||
/* translators: 1: plugin name, 2: version number */
|
||||
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
|
||||
),
|
||||
$response->new_version,
|
||||
wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ),
|
||||
sprintf(
|
||||
'class="update-link" aria-label="%s"',
|
||||
/* translators: %s: plugin name */
|
||||
esc_attr( sprintf( __( 'Update %s now' ), $plugin_name ) )
|
||||
)
|
||||
);
|
||||
if ( $compatible_php ) {
|
||||
/* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */
|
||||
printf(
|
||||
__( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ),
|
||||
$plugin_name,
|
||||
esc_url( $details_url ),
|
||||
sprintf(
|
||||
'class="thickbox open-plugin-details-modal" aria-label="%s"',
|
||||
/* translators: 1: plugin name, 2: version number */
|
||||
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
|
||||
),
|
||||
esc_attr( $response->new_version ),
|
||||
wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ),
|
||||
sprintf(
|
||||
'class="update-link" aria-label="%s"',
|
||||
/* translators: %s: plugin name */
|
||||
esc_attr( sprintf( __( 'Update %s now' ), $plugin_name ) )
|
||||
)
|
||||
);
|
||||
} else {
|
||||
/* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number 5: Update PHP page URL */
|
||||
printf(
|
||||
__( 'There is a new version of %1$s available, but it doesn’t work with your version of PHP. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s">learn more about updating PHP</a>.' ),
|
||||
$plugin_name,
|
||||
esc_url( $details_url ),
|
||||
sprintf(
|
||||
'class="thickbox open-plugin-details-modal" aria-label="%s"',
|
||||
/* translators: 1: plugin name, 2: version number */
|
||||
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) )
|
||||
),
|
||||
esc_attr( $response->new_version ),
|
||||
esc_url( wp_get_update_php_url() )
|
||||
);
|
||||
wp_update_php_annotation( '<br><em>', '</em>' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -809,3 +830,22 @@ function wp_print_update_row_templates() {
|
|||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a notice when the user is in recovery mode.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
function wp_recovery_mode_nag() {
|
||||
if ( ! wp_is_recovery_mode() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="notice notice-info">
|
||||
<p>
|
||||
<?php esc_html_e( 'You are in recovery mode. This means there may be an error with a theme or plugin. To exit recovery mode, log out or use the Exit button.' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
|
|
@ -3177,7 +3177,7 @@ function wp_check_mysql_version() {
|
|||
global $wpdb;
|
||||
$result = $wpdb->check_database_version();
|
||||
if ( is_wp_error( $result ) ) {
|
||||
die( $result->get_error_message() );
|
||||
wp_die( $result );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -812,6 +812,15 @@ function _wp_personal_data_export_page() {
|
|||
'screen' => 'export_personal_data',
|
||||
)
|
||||
);
|
||||
|
||||
$requests_table->screen->set_screen_reader_content(
|
||||
array(
|
||||
'heading_views' => __( 'Filter export personal data list' ),
|
||||
'heading_pagination' => __( 'Export personal data list navigation' ),
|
||||
'heading_list' => __( 'Export personal data list' ),
|
||||
)
|
||||
);
|
||||
|
||||
$requests_table->process_bulk_action();
|
||||
$requests_table->prepare_items();
|
||||
?>
|
||||
|
@ -821,7 +830,7 @@ function _wp_personal_data_export_page() {
|
|||
|
||||
<?php settings_errors(); ?>
|
||||
|
||||
<form method="post" class="wp-privacy-request-form">
|
||||
<form action="<?php echo esc_url( admin_url( 'tools.php?page=export_personal_data' ) ); ?>" method="post" class="wp-privacy-request-form">
|
||||
<h2><?php esc_html_e( 'Add Data Export Request' ); ?></h2>
|
||||
<p><?php esc_html_e( 'An email will be sent to the user at this email address asking them to verify the request.' ); ?></p>
|
||||
|
||||
|
@ -887,6 +896,14 @@ function _wp_personal_data_removal_page() {
|
|||
)
|
||||
);
|
||||
|
||||
$requests_table->screen->set_screen_reader_content(
|
||||
array(
|
||||
'heading_views' => __( 'Filter erase personal data list' ),
|
||||
'heading_pagination' => __( 'Erase personal data list navigation' ),
|
||||
'heading_list' => __( 'Erase personal data list' ),
|
||||
)
|
||||
);
|
||||
|
||||
$requests_table->process_bulk_action();
|
||||
$requests_table->prepare_items();
|
||||
|
||||
|
@ -897,7 +914,7 @@ function _wp_personal_data_removal_page() {
|
|||
|
||||
<?php settings_errors(); ?>
|
||||
|
||||
<form method="post" class="wp-privacy-request-form">
|
||||
<form action="<?php echo esc_url( admin_url( 'tools.php?page=remove_personal_data' ) ); ?>" method="post" class="wp-privacy-request-form">
|
||||
<h2><?php esc_html_e( 'Add Data Erasure Request' ); ?></h2>
|
||||
<p><?php esc_html_e( 'An email will be sent to the user at this email address asking them to verify the request.' ); ?></p>
|
||||
|
||||
|
@ -1392,7 +1409,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
|||
return '';
|
||||
}
|
||||
|
||||
$time_diff = current_time( 'timestamp', true ) - $timestamp;
|
||||
$time_diff = time() - $timestamp;
|
||||
|
||||
if ( $time_diff >= 0 && $time_diff < DAY_IN_SECONDS ) {
|
||||
/* translators: human readable timestamp */
|
||||
|
@ -1513,7 +1530,7 @@ class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Requests_Table {
|
|||
$download_data_markup .= '<span class="export-personal-data-idle"><button type="button" class="button-link export-personal-data-handle">' . __( 'Download Personal Data' ) . '</button></span>' .
|
||||
'<span style="display:none" class="export-personal-data-processing" >' . __( 'Downloading Data...' ) . '</span>' .
|
||||
'<span style="display:none" class="export-personal-data-success"><button type="button" class="button-link export-personal-data-handle">' . __( 'Download Personal Data Again' ) . '</button></span>' .
|
||||
'<span style="display:none" class="export-personal-data-failed">' . __( 'Download has failed.' ) . ' <button type="button" class="button-link">' . __( 'Retry' ) . '</button></span>';
|
||||
'<span style="display:none" class="export-personal-data-failed">' . __( 'Download failed.' ) . ' <button type="button" class="button-link">' . __( 'Retry' ) . '</button></span>';
|
||||
|
||||
$download_data_markup .= '</div>';
|
||||
|
||||
|
@ -1553,7 +1570,7 @@ class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Requests_Table {
|
|||
'">';
|
||||
|
||||
?>
|
||||
<span class="export-personal-data-idle"><button type="button" class="button export-personal-data-handle"><?php _e( 'Email Data' ); ?></button></span>
|
||||
<span class="export-personal-data-idle"><button type="button" class="button export-personal-data-handle"><?php _e( 'Send Export Link' ); ?></button></span>
|
||||
<span style="display:none" class="export-personal-data-processing button updating-message" ><?php _e( 'Sending Email...' ); ?></span>
|
||||
<span style="display:none" class="export-personal-data-success success-message" ><?php _e( 'Email sent.' ); ?></span>
|
||||
<span style="display:none" class="export-personal-data-failed"><?php _e( 'Email could not be sent.' ); ?> <button type="button" class="button export-personal-data-handle"><?php _e( 'Retry' ); ?></button></span>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue