-
+
-
-
http://wordpress.org/ — don’t forget the http://
'); ?>
+
+
http://wordpress.org/ — don’t forget the http://
' ); ?>
@@ -133,19 +144,20 @@ $side_meta_boxes = do_meta_boxes( 'link', 'side', $link );
+if ( $link_id ) :
+?>
-
-
+
+
diff --git a/wp-admin/edit-tag-form.php b/wp-admin/edit-tag-form.php
index f8c83feac3..9b29553c3a 100644
--- a/wp-admin/edit-tag-form.php
+++ b/wp-admin/edit-tag-form.php
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
// Back compat hooks
if ( 'category' == $taxonomy ) {
/**
- * Fires before the Edit Category form.
+ * Fires before the Edit Category form.
*
* @since 2.1.0
* @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
@@ -74,16 +74,19 @@ do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?>
-
-
-
+
+
search_box( $tax->labels->search_items, 'tag' ); ?>
@@ -324,10 +358,10 @@ endif; ?>
cap->edit_terms) ) {
+if ( current_user_can( $tax->cap->edit_terms ) ) {
if ( 'category' == $taxonomy ) {
/**
- * Fires before the Add Category form.
+ * Fires before the Add Category form.
*
* @since 2.1.0
* @deprecated 3.0.0 Use {$taxonomy}_pre_add_form instead.
@@ -371,7 +405,8 @@ if ( current_user_can($tax->cap->edit_terms) ) {
- true ) ) ) ) {
wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ) );
@@ -28,11 +29,12 @@ if ( 'attachment' === $typenow ) {
*/
global $post_type, $post_type_object;
-$post_type = $typenow;
+$post_type = $typenow;
$post_type_object = get_post_type_object( $post_type );
-if ( ! $post_type_object )
+if ( ! $post_type_object ) {
wp_die( __( 'Invalid post type.' ) );
+}
if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) {
wp_die(
@@ -42,8 +44,8 @@ if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) {
);
}
-$wp_list_table = _get_list_table('WP_Posts_List_Table');
-$pagenum = $wp_list_table->get_pagenum();
+$wp_list_table = _get_list_table( 'WP_Posts_List_Table' );
+$pagenum = $wp_list_table->get_pagenum();
// Back-compat for viewing comments of an entry
foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) {
@@ -55,30 +57,32 @@ foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) {
unset( $_redirect );
if ( 'post' != $post_type ) {
- $parent_file = "edit.php?post_type=$post_type";
- $submenu_file = "edit.php?post_type=$post_type";
+ $parent_file = "edit.php?post_type=$post_type";
+ $submenu_file = "edit.php?post_type=$post_type";
$post_new_file = "post-new.php?post_type=$post_type";
} else {
- $parent_file = 'edit.php';
- $submenu_file = 'edit.php';
+ $parent_file = 'edit.php';
+ $submenu_file = 'edit.php';
$post_new_file = 'post-new.php';
}
$doaction = $wp_list_table->current_action();
if ( $doaction ) {
- check_admin_referer('bulk-posts');
+ check_admin_referer( 'bulk-posts' );
- $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'locked', 'ids'), wp_get_referer() );
- if ( ! $sendback )
+ $sendback = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'locked', 'ids' ), wp_get_referer() );
+ if ( ! $sendback ) {
$sendback = admin_url( $parent_file );
+ }
$sendback = add_query_arg( 'paged', $pagenum, $sendback );
- if ( strpos($sendback, 'post.php') !== false )
- $sendback = admin_url($post_new_file);
+ if ( strpos( $sendback, 'post.php' ) !== false ) {
+ $sendback = admin_url( $post_new_file );
+ }
if ( 'delete_all' == $doaction ) {
// Prepare for deletion of all posts with a specified post status (i.e. Empty trash).
- $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);
+ $post_status = preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['post_status'] );
// Validate the post status exists.
if ( get_post_status_object( $post_status ) ) {
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
@@ -88,11 +92,11 @@ if ( $doaction ) {
$post_ids = $_REQUEST['media'];
} elseif ( isset( $_REQUEST['ids'] ) ) {
$post_ids = explode( ',', $_REQUEST['ids'] );
- } elseif ( !empty( $_REQUEST['post'] ) ) {
- $post_ids = array_map('intval', $_REQUEST['post']);
+ } elseif ( ! empty( $_REQUEST['post'] ) ) {
+ $post_ids = array_map( 'intval', $_REQUEST['post'] );
}
- if ( !isset( $post_ids ) ) {
+ if ( ! isset( $post_ids ) ) {
wp_redirect( $sendback );
exit;
}
@@ -102,63 +106,76 @@ if ( $doaction ) {
$trashed = $locked = 0;
foreach ( (array) $post_ids as $post_id ) {
- if ( !current_user_can( 'delete_post', $post_id) )
- wp_die( __('Sorry, you are not allowed to move this item to the Trash.') );
+ if ( ! current_user_can( 'delete_post', $post_id ) ) {
+ wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) );
+ }
if ( wp_check_post_lock( $post_id ) ) {
$locked++;
continue;
}
- if ( !wp_trash_post($post_id) )
- wp_die( __('Error in moving to Trash.') );
+ if ( ! wp_trash_post( $post_id ) ) {
+ wp_die( __( 'Error in moving to Trash.' ) );
+ }
$trashed++;
}
- $sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids), 'locked' => $locked ), $sendback );
+ $sendback = add_query_arg(
+ array(
+ 'trashed' => $trashed,
+ 'ids' => join( ',', $post_ids ),
+ 'locked' => $locked,
+ ), $sendback
+ );
break;
case 'untrash':
$untrashed = 0;
foreach ( (array) $post_ids as $post_id ) {
- if ( !current_user_can( 'delete_post', $post_id) )
- wp_die( __('Sorry, you are not allowed to restore this item from the Trash.') );
+ if ( ! current_user_can( 'delete_post', $post_id ) ) {
+ wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) );
+ }
- if ( !wp_untrash_post($post_id) )
- wp_die( __('Error in restoring from Trash.') );
+ if ( ! wp_untrash_post( $post_id ) ) {
+ wp_die( __( 'Error in restoring from Trash.' ) );
+ }
$untrashed++;
}
- $sendback = add_query_arg('untrashed', $untrashed, $sendback);
+ $sendback = add_query_arg( 'untrashed', $untrashed, $sendback );
break;
case 'delete':
$deleted = 0;
foreach ( (array) $post_ids as $post_id ) {
- $post_del = get_post($post_id);
+ $post_del = get_post( $post_id );
- if ( !current_user_can( 'delete_post', $post_id ) )
- wp_die( __('Sorry, you are not allowed to delete this item.') );
+ if ( ! current_user_can( 'delete_post', $post_id ) ) {
+ wp_die( __( 'Sorry, you are not allowed to delete this item.' ) );
+ }
if ( $post_del->post_type == 'attachment' ) {
- if ( ! wp_delete_attachment($post_id) )
- wp_die( __('Error in deleting.') );
+ if ( ! wp_delete_attachment( $post_id ) ) {
+ wp_die( __( 'Error in deleting.' ) );
+ }
} else {
- if ( !wp_delete_post($post_id) )
- wp_die( __('Error in deleting.') );
+ if ( ! wp_delete_post( $post_id ) ) {
+ wp_die( __( 'Error in deleting.' ) );
+ }
}
$deleted++;
}
- $sendback = add_query_arg('deleted', $deleted, $sendback);
+ $sendback = add_query_arg( 'deleted', $deleted, $sendback );
break;
case 'edit':
- if ( isset($_REQUEST['bulk_edit']) ) {
- $done = bulk_edit_posts($_REQUEST);
+ if ( isset( $_REQUEST['bulk_edit'] ) ) {
+ $done = bulk_edit_posts( $_REQUEST );
- if ( is_array($done) ) {
+ if ( is_array( $done ) ) {
$done['updated'] = count( $done['updated'] );
$done['skipped'] = count( $done['skipped'] );
- $done['locked'] = count( $done['locked'] );
- $sendback = add_query_arg( $done, $sendback );
+ $done['locked'] = count( $done['locked'] );
+ $sendback = add_query_arg( $done, $sendback );
}
}
break;
@@ -168,107 +185,126 @@ if ( $doaction ) {
break;
}
- $sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback );
+ $sendback = remove_query_arg( array( 'action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view' ), $sendback );
- wp_redirect($sendback);
+ wp_redirect( $sendback );
exit();
-} elseif ( ! empty($_REQUEST['_wp_http_referer']) ) {
- wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']) ) );
+} elseif ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
+ wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
exit;
}
$wp_list_table->prepare_items();
-wp_enqueue_script('inline-edit-post');
-wp_enqueue_script('heartbeat');
+wp_enqueue_script( 'inline-edit-post' );
+wp_enqueue_script( 'heartbeat' );
$title = $post_type_object->labels->name;
if ( 'post' == $post_type ) {
- get_current_screen()->add_help_tab( array(
- 'id' => 'overview',
- 'title' => __('Overview'),
- 'content' =>
- '' . __('This screen provides access to all of your posts. You can customize the display of this screen to suit your workflow.') . '
'
- ) );
- get_current_screen()->add_help_tab( array(
- 'id' => 'screen-content',
- 'title' => __('Screen Content'),
- 'content' =>
- '' . __('You can customize the display of this screen’s contents in a number of ways:') . '
' .
- '' .
- '' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . ' ' .
- '' . __( 'You can filter the list of posts by post status using the text links above the posts list to only show posts with that status. The default view is to show all posts.' ) . ' ' .
- '' . __('You can view posts in a simple title list or with an excerpt using the Screen Options tab.') . ' ' .
- '' . __('You can refine the list to show only posts in a specific category or from a specific month by using the dropdown menus above the posts list. Click the Filter button after making your selection. You also can refine the list by clicking on the post author, category or tag in the posts list.') . ' ' .
- ' '
- ) );
- get_current_screen()->add_help_tab( array(
- 'id' => 'action-links',
- 'title' => __('Available Actions'),
- 'content' =>
- '' . __('Hovering over a row in the posts list will display action links that allow you to manage your post. You can perform the following actions:') . '
' .
- '' .
- '' . __('Edit takes you to the editing screen for that post. You can also reach that screen by clicking on the post title.') . ' ' .
- '' . __('Quick Edit provides inline access to the metadata of your post, allowing you to update post details without leaving this screen.') . ' ' .
- '' . __('Trash removes your post from this list and places it in the trash, from which you can permanently delete it.') . ' ' .
- '' . __('Preview will show you what your draft post will look like if you publish it. View will take you to your live site to view the post. Which link is available depends on your post’s status.') . ' ' .
- ' '
- ) );
- get_current_screen()->add_help_tab( array(
- 'id' => 'bulk-actions',
- 'title' => __('Bulk Actions'),
- 'content' =>
- '' . __('You can also edit or move multiple posts to the trash at once. Select the posts you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.') . '
' .
- '' . __('When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the x next to its name in the Bulk Edit area that appears.') . '
'
- ) );
+ get_current_screen()->add_help_tab(
+ array(
+ 'id' => 'overview',
+ 'title' => __( 'Overview' ),
+ 'content' =>
+ '' . __( 'This screen provides access to all of your posts. You can customize the display of this screen to suit your workflow.' ) . '
',
+ )
+ );
+ get_current_screen()->add_help_tab(
+ array(
+ 'id' => 'screen-content',
+ 'title' => __( 'Screen Content' ),
+ 'content' =>
+ '' . __( 'You can customize the display of this screen’s contents in a number of ways:' ) . '
' .
+ '' .
+ '' . __( 'You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.' ) . ' ' .
+ '' . __( 'You can filter the list of posts by post status using the text links above the posts list to only show posts with that status. The default view is to show all posts.' ) . ' ' .
+ '' . __( 'You can view posts in a simple title list or with an excerpt using the Screen Options tab.' ) . ' ' .
+ '' . __( 'You can refine the list to show only posts in a specific category or from a specific month by using the dropdown menus above the posts list. Click the Filter button after making your selection. You also can refine the list by clicking on the post author, category or tag in the posts list.' ) . ' ' .
+ ' ',
+ )
+ );
+ get_current_screen()->add_help_tab(
+ array(
+ 'id' => 'action-links',
+ 'title' => __( 'Available Actions' ),
+ 'content' =>
+ '' . __( 'Hovering over a row in the posts list will display action links that allow you to manage your post. You can perform the following actions:' ) . '
' .
+ '' .
+ '' . __( 'Edit takes you to the editing screen for that post. You can also reach that screen by clicking on the post title.' ) . ' ' .
+ '' . __( 'Quick Edit provides inline access to the metadata of your post, allowing you to update post details without leaving this screen.' ) . ' ' .
+ '' . __( 'Trash removes your post from this list and places it in the trash, from which you can permanently delete it.' ) . ' ' .
+ '' . __( 'Preview will show you what your draft post will look like if you publish it. View will take you to your live site to view the post. Which link is available depends on your post’s status.' ) . ' ' .
+ ' ',
+ )
+ );
+ get_current_screen()->add_help_tab(
+ array(
+ 'id' => 'bulk-actions',
+ 'title' => __( 'Bulk Actions' ),
+ 'content' =>
+ '' . __( 'You can also edit or move multiple posts to the trash at once. Select the posts you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.' ) . '
' .
+ '' . __( 'When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the x next to its name in the Bulk Edit area that appears.' ) . '
',
+ )
+ );
get_current_screen()->set_help_sidebar(
- '' . __('For more information:') . '
' .
- '' . __('Documentation on Managing Posts ') . '
' .
- '' . __('Support Forums ') . '
'
+ '' . __( 'For more information:' ) . '
' .
+ '' . __( 'Documentation on Managing Posts ' ) . '
' .
+ '' . __( 'Support Forums ' ) . '
'
);
} elseif ( 'page' == $post_type ) {
- get_current_screen()->add_help_tab( array(
- 'id' => 'overview',
- 'title' => __('Overview'),
- 'content' =>
- '' . __('Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the “Parent” of the other, creating a group of pages.') . '
'
- ) );
- get_current_screen()->add_help_tab( array(
- 'id' => 'managing-pages',
- 'title' => __('Managing Pages'),
- 'content' =>
- '' . __('Managing pages is very similar to managing posts, and the screens can be customized in the same way.') . '
' .
- '' . __('You can also perform the same types of actions, including narrowing the list by using the filters, acting on a page using the action links that appear when you hover over a row, or using the Bulk Actions menu to edit the metadata for multiple pages at once.') . '
'
- ) );
+ get_current_screen()->add_help_tab(
+ array(
+ 'id' => 'overview',
+ 'title' => __( 'Overview' ),
+ 'content' =>
+ '' . __( 'Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the “Parent” of the other, creating a group of pages.' ) . '
',
+ )
+ );
+ get_current_screen()->add_help_tab(
+ array(
+ 'id' => 'managing-pages',
+ 'title' => __( 'Managing Pages' ),
+ 'content' =>
+ '' . __( 'Managing pages is very similar to managing posts, and the screens can be customized in the same way.' ) . '
' .
+ '' . __( 'You can also perform the same types of actions, including narrowing the list by using the filters, acting on a page using the action links that appear when you hover over a row, or using the Bulk Actions menu to edit the metadata for multiple pages at once.' ) . '
',
+ )
+ );
get_current_screen()->set_help_sidebar(
- '' . __('For more information:') . '
' .
- '' . __('Documentation on Managing Pages ') . '
' .
- '' . __('Support Forums ') . '
'
+ '' . __( 'For more information:' ) . '
' .
+ '' . __( 'Documentation on Managing Pages ' ) . '
' .
+ '' . __( 'Support Forums ' ) . '
'
);
}
-get_current_screen()->set_screen_reader_content( array(
- 'heading_views' => $post_type_object->labels->filter_items_list,
- 'heading_pagination' => $post_type_object->labels->items_list_navigation,
- 'heading_list' => $post_type_object->labels->items_list,
-) );
+get_current_screen()->set_screen_reader_content(
+ array(
+ 'heading_views' => $post_type_object->labels->filter_items_list,
+ 'heading_pagination' => $post_type_object->labels->items_list_navigation,
+ 'heading_list' => $post_type_object->labels->items_list,
+ )
+);
-add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $post_type . '_per_page' ) );
+add_screen_option(
+ 'per_page', array(
+ 'default' => 20,
+ 'option' => 'edit_' . $post_type . '_per_page',
+ )
+);
$bulk_counts = array(
- 'updated' => isset( $_REQUEST['updated'] ) ? absint( $_REQUEST['updated'] ) : 0,
- 'locked' => isset( $_REQUEST['locked'] ) ? absint( $_REQUEST['locked'] ) : 0,
- 'deleted' => isset( $_REQUEST['deleted'] ) ? absint( $_REQUEST['deleted'] ) : 0,
- 'trashed' => isset( $_REQUEST['trashed'] ) ? absint( $_REQUEST['trashed'] ) : 0,
+ 'updated' => isset( $_REQUEST['updated'] ) ? absint( $_REQUEST['updated'] ) : 0,
+ 'locked' => isset( $_REQUEST['locked'] ) ? absint( $_REQUEST['locked'] ) : 0,
+ 'deleted' => isset( $_REQUEST['deleted'] ) ? absint( $_REQUEST['deleted'] ) : 0,
+ 'trashed' => isset( $_REQUEST['trashed'] ) ? absint( $_REQUEST['trashed'] ) : 0,
'untrashed' => isset( $_REQUEST['untrashed'] ) ? absint( $_REQUEST['untrashed'] ) : 0,
);
-$bulk_messages = array();
+$bulk_messages = array();
$bulk_messages['post'] = array(
'updated' => _n( '%s post updated.', '%s posts updated.', $bulk_counts['updated'] ),
'locked' => ( 1 == $bulk_counts['locked'] ) ? __( '1 post not updated, somebody is editing it.' ) :
@@ -298,14 +334,16 @@ $bulk_messages['page'] = array(
* @param array $bulk_counts Array of item counts for each message, used to build internationalized strings.
*/
$bulk_messages = apply_filters( 'bulk_post_updated_messages', $bulk_messages, $bulk_counts );
-$bulk_counts = array_filter( $bulk_counts );
+$bulk_counts = array_filter( $bulk_counts );
require_once( ABSPATH . 'wp-admin/admin-header.php' );
?>
-
+labels->name );
-?>
+?>
+
cap->create_posts ) ) {
@@ -324,19 +362,21 @@ if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
// If we have a bulk message to issue:
$messages = array();
foreach ( $bulk_counts as $message => $count ) {
- if ( isset( $bulk_messages[ $post_type ][ $message ] ) )
+ if ( isset( $bulk_messages[ $post_type ][ $message ] ) ) {
$messages[] = sprintf( $bulk_messages[ $post_type ][ $message ], number_format_i18n( $count ) );
- elseif ( isset( $bulk_messages['post'][ $message ] ) )
+ } elseif ( isset( $bulk_messages['post'][ $message ] ) ) {
$messages[] = sprintf( $bulk_messages['post'][ $message ], number_format_i18n( $count ) );
+ }
if ( $message == 'trashed' && isset( $_REQUEST['ids'] ) ) {
- $ids = preg_replace( '/[^0-9,]/', '', $_REQUEST['ids'] );
- $messages[] = '
' . __('Undo') . ' ';
+ $ids = preg_replace( '/[^0-9,]/', '', $_REQUEST['ids'] );
+ $messages[] = '
' . __( 'Undo' ) . ' ';
}
}
-if ( $messages )
+if ( $messages ) {
echo '
' . join( ' ', $messages ) . '
';
+}
unset( $messages );
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed' ), $_SERVER['REQUEST_URI'] );
@@ -348,7 +388,7 @@ $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated
search_box( $post_type_object->labels->search_items, 'post' ); ?>
-
+
@@ -364,8 +404,9 @@ $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated
has_items() )
+if ( $wp_list_table->has_items() ) {
$wp_list_table->inline_edit();
+}
?>
diff --git a/wp-admin/export.php b/wp-admin/export.php
index c1d4d8b529..89e5d34da6 100644
--- a/wp-admin/export.php
+++ b/wp-admin/export.php
@@ -9,12 +9,13 @@
/** Load WordPress Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
-if ( !current_user_can('export') )
- wp_die(__('Sorry, you are not allowed to export the content of this site.'));
+if ( ! current_user_can( 'export' ) ) {
+ wp_die( __( 'Sorry, you are not allowed to export the content of this site.' ) );
+}
/** Load WordPress export API */
require_once( ABSPATH . 'wp-admin/includes/export.php' );
-$title = __('Export');
+$title = __( 'Export' );
/**
* Display JavaScript on the page.
@@ -25,34 +26,36 @@ function export_add_js() {
?>
add_help_tab( array(
- 'id' => 'overview',
- 'title' => __('Overview'),
- 'content' => '
' . __('You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.') . '
' .
- '
' . __('Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.') . '
',
-) );
+get_current_screen()->add_help_tab(
+ array(
+ 'id' => 'overview',
+ 'title' => __( 'Overview' ),
+ 'content' => '
' . __( 'You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.' ) . '
' .
+ '
' . __( 'Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.' ) . '
',
+ )
+);
get_current_screen()->set_help_sidebar(
- '
' . __('For more information:') . '
' .
- '
' . __('Documentation on Export ') . '
' .
- '
' . __('Support Forums ') . '
'
+ '
' . __( 'For more information:' ) . '
' .
+ '
' . __( 'Documentation on Export ' ) . '
' .
+ '
' . __( 'Support Forums ' ) . '
'
);
// If the 'download' URL parameter is set, a WXR export file is baked and returned.
@@ -64,41 +67,45 @@ if ( isset( $_GET['download'] ) ) {
} elseif ( 'posts' == $_GET['content'] ) {
$args['content'] = 'post';
- if ( $_GET['cat'] )
+ if ( $_GET['cat'] ) {
$args['category'] = (int) $_GET['cat'];
+ }
- if ( $_GET['post_author'] )
+ if ( $_GET['post_author'] ) {
$args['author'] = (int) $_GET['post_author'];
+ }
if ( $_GET['post_start_date'] || $_GET['post_end_date'] ) {
$args['start_date'] = $_GET['post_start_date'];
- $args['end_date'] = $_GET['post_end_date'];
+ $args['end_date'] = $_GET['post_end_date'];
}
- if ( $_GET['post_status'] )
+ if ( $_GET['post_status'] ) {
$args['status'] = $_GET['post_status'];
+ }
} elseif ( 'pages' == $_GET['content'] ) {
$args['content'] = 'page';
- if ( $_GET['page_author'] )
+ if ( $_GET['page_author'] ) {
$args['author'] = (int) $_GET['page_author'];
+ }
if ( $_GET['page_start_date'] || $_GET['page_end_date'] ) {
$args['start_date'] = $_GET['page_start_date'];
- $args['end_date'] = $_GET['page_end_date'];
+ $args['end_date'] = $_GET['page_end_date'];
}
- if ( $_GET['page_status'] )
+ if ( $_GET['page_status'] ) {
$args['status'] = $_GET['page_status'];
+ }
} elseif ( 'attachment' == $_GET['content'] ) {
$args['content'] = 'attachment';
if ( $_GET['attachment_start_date'] || $_GET['attachment_end_date'] ) {
$args['start_date'] = $_GET['attachment_start_date'];
- $args['end_date'] = $_GET['attachment_end_date'];
+ $args['end_date'] = $_GET['attachment_end_date'];
}
- }
- else {
+ } else {
$args['content'] = $_GET['content'];
}
@@ -130,20 +137,26 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
function export_date_options( $post_type = 'post' ) {
global $wpdb, $wp_locale;
- $months = $wpdb->get_results( $wpdb->prepare( "
+ $months = $wpdb->get_results(
+ $wpdb->prepare(
+ "
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
FROM $wpdb->posts
WHERE post_type = %s AND post_status != 'auto-draft'
ORDER BY post_date DESC
- ", $post_type ) );
+ ", $post_type
+ )
+ );
$month_count = count( $months );
- if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
+ if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
return;
+ }
foreach ( $months as $date ) {
- if ( 0 == $date->year )
+ if ( 0 == $date->year ) {
continue;
+ }
$month = zeroise( $date->month, 2 );
echo '
' . $wp_locale->get_month( $month ) . ' ' . $date->year . ' ';
@@ -154,9 +167,9 @@ function export_date_options( $post_type = 'post' ) {
-
-
-
+
+
+
@@ -170,20 +183,23 @@ function export_date_options( $post_type = 'post' ) {
- __('All') ) ); ?>
+ __( 'All' ) ) ); ?>
get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'" );
- wp_dropdown_users( array(
- 'include' => $authors,
- 'name' => 'post_author',
- 'multi' => true,
- 'show_option_all' => __( 'All' ),
- 'show' => 'display_name_with_login',
- ) ); ?>
+ wp_dropdown_users(
+ array(
+ 'include' => $authors,
+ 'name' => 'post_author',
+ 'multi' => true,
+ 'show_option_all' => __( 'All' ),
+ 'show' => 'display_name_with_login',
+ )
+ );
+ ?>
@@ -205,8 +221,10 @@ function export_date_options( $post_type = 'post' ) {
- false ), 'objects' );
- foreach ( $post_stati as $status ) : ?>
+ false ), 'objects' );
+ foreach ( $post_stati as $status ) :
+ ?>
label ); ?>
@@ -219,13 +237,16 @@ function export_date_options( $post_type = 'post' ) {
get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'page'" );
- wp_dropdown_users( array(
- 'include' => $authors,
- 'name' => 'page_author',
- 'multi' => true,
- 'show_option_all' => __( 'All' ),
- 'show' => 'display_name_with_login',
- ) ); ?>
+ wp_dropdown_users(
+ array(
+ 'include' => $authors,
+ 'name' => 'page_author',
+ 'multi' => true,
+ 'show_option_all' => __( 'All' ),
+ 'show' => 'display_name_with_login',
+ )
+ );
+ ?>
@@ -254,7 +275,14 @@ function export_date_options( $post_type = 'post' ) {
- false, 'can_export' => true ), 'objects' ) as $post_type ) : ?>
+ false,
+ 'can_export' => true,
+ ), 'objects'
+) as $post_type ) :
+?>
label ); ?>
@@ -287,7 +315,7 @@ function export_date_options( $post_type = 'post' ) {
do_action( 'export_filters' );
?>
-
+
diff --git a/wp-admin/freedoms.php b/wp-admin/freedoms.php
index 28c16461b7..e3fd29ff79 100644
--- a/wp-admin/freedoms.php
+++ b/wp-admin/freedoms.php
@@ -42,12 +42,15 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
check out our trademark guidelines first.' ), 'https://wordpressfoundation.org/trademark-policy/' ); ?>
-
+ plugins and themes there. If you get a plugin or theme from another source, make sure to ask them if it’s GPL first. If they don’t respect the WordPress license, we don’t recommend them.' ), $plugins_url, $themes_url, 'https://wordpress.org/about/license/' ); ?>
+ printf( __( 'Every plugin and theme in WordPress.org’s directory is 100%% GPL or a similarly free and compatible license, so you can feel safe finding
plugins and
themes there. If you get a plugin or theme from another source, make sure to
ask them if it’s GPL first. If they don’t respect the WordPress license, we don’t recommend them.' ), $plugins_url, $themes_url, 'https://wordpress.org/about/license/' );
+ ?>
+
Free Software Foundation.' ); ?>
diff --git a/wp-admin/import.php b/wp-admin/import.php
index 1aa682ae9b..48051c940e 100644
--- a/wp-admin/import.php
+++ b/wp-admin/import.php
@@ -6,7 +6,7 @@
* @subpackage Administration
*/
-define('WP_LOAD_IMPORTERS', true);
+define( 'WP_LOAD_IMPORTERS', true );
/** Load WordPress Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
@@ -15,26 +15,28 @@ if ( ! current_user_can( 'import' ) ) {
wp_die( __( 'Sorry, you are not allowed to import content.' ) );
}
-$title = __('Import');
+$title = __( 'Import' );
-get_current_screen()->add_help_tab( array(
- 'id' => 'overview',
- 'title' => __('Overview'),
- 'content' => '' . __('This screen lists links to plugins to import data from blogging/content management platforms. Choose the platform you want to import from, and click Install Now when you are prompted in the popup window. If your platform is not listed, click the link to search the plugin directory for other importer plugins to see if there is one for your platform.') . '
' .
- '' . __('In previous versions of WordPress, all importers were built-in. They have been turned into plugins since most people only use them once or infrequently.') . '
',
-) );
+get_current_screen()->add_help_tab(
+ array(
+ 'id' => 'overview',
+ 'title' => __( 'Overview' ),
+ 'content' => '' . __( 'This screen lists links to plugins to import data from blogging/content management platforms. Choose the platform you want to import from, and click Install Now when you are prompted in the popup window. If your platform is not listed, click the link to search the plugin directory for other importer plugins to see if there is one for your platform.' ) . '
' .
+ '' . __( 'In previous versions of WordPress, all importers were built-in. They have been turned into plugins since most people only use them once or infrequently.' ) . '
',
+ )
+);
get_current_screen()->set_help_sidebar(
- '' . __('For more information:') . '
' .
- '' . __('Documentation on Import ') . '
' .
- '' . __('Support Forums ') . '
'
+ '' . __( 'For more information:' ) . '
' .
+ '' . __( 'Documentation on Import ' ) . '
' .
+ '' . __( 'Support Forums ' ) . '
'
);
if ( current_user_can( 'install_plugins' ) ) {
// List of popular importer plugins from the WordPress.org API.
$popular_importers = wp_get_popular_importers();
} else {
- $popular_importers = array();
+ $popular_importers = array();
}
// Detect and redirect invalid importers like 'movabletype', which is registered as 'mt'
@@ -59,13 +61,15 @@ $parent_file = 'tools.php';
-
' . esc_html( $_GET['invalid'] ) . '' );
- ?>
+
+ ' . esc_html( $_GET['invalid'] ) . '' );
+ ?>
+
-
+
$pop_data ) {
- if ( isset( $importers[ $pop_importer ] ) )
+ if ( isset( $importers[ $pop_importer ] ) ) {
continue;
- if ( isset( $importers[ $pop_data['importer-id'] ] ) )
+ }
+ if ( isset( $importers[ $pop_data['importer-id'] ] ) ) {
continue;
+ }
// Fill the array of registered (already installed) importers with data of the popular importers from the WordPress.org API.
- $importers[ $pop_data['importer-id'] ] = array( $pop_data['name'], $pop_data['description'], 'install' => $pop_data['plugin-slug'] );
+ $importers[ $pop_data['importer-id'] ] = array(
+ $pop_data['name'],
+ $pop_data['description'],
+ 'install' => $pop_data['plugin-slug'],
+ );
}
if ( empty( $importers ) ) {
- echo '' . __('No importers are available.') . '
'; // TODO: make more helpful
+ echo '' . __( 'No importers are available.' ) . '
'; // TODO: make more helpful
} else {
uasort( $importers, '_usort_by_first_member' );
?>
@@ -91,7 +101,7 @@ if ( empty( $importers ) ) {
$data ) {
- $plugin_slug = $action = '';
+ $plugin_slug = $action = '';
$is_plugin_installed = false;
if ( isset( $data['install'] ) ) {
@@ -101,14 +111,18 @@ if ( empty( $importers ) ) {
// Looks like an importer is installed, but not active.
$plugins = get_plugins( '/' . $plugin_slug );
if ( ! empty( $plugins ) ) {
- $keys = array_keys( $plugins );
+ $keys = array_keys( $plugins );
$plugin_file = $plugin_slug . '/' . $keys[0];
- $url = wp_nonce_url( add_query_arg( array(
- 'action' => 'activate',
- 'plugin' => $plugin_file,
- 'from' => 'import',
- ), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_file );
- $action = sprintf(
+ $url = wp_nonce_url(
+ add_query_arg(
+ array(
+ 'action' => 'activate',
+ 'plugin' => $plugin_file,
+ 'from' => 'import',
+ ), admin_url( 'plugins.php' )
+ ), 'activate-plugin_' . $plugin_file
+ );
+ $action = sprintf(
'%s ',
esc_url( $url ),
/* translators: %s: Importer name */
@@ -122,11 +136,15 @@ if ( empty( $importers ) ) {
if ( empty( $action ) ) {
if ( is_main_site() ) {
- $url = wp_nonce_url( add_query_arg( array(
- 'action' => 'install-plugin',
- 'plugin' => $plugin_slug,
- 'from' => 'import',
- ), self_admin_url( 'update.php' ) ), 'install-plugin_' . $plugin_slug );
+ $url = wp_nonce_url(
+ add_query_arg(
+ array(
+ 'action' => 'install-plugin',
+ 'plugin' => $plugin_slug,
+ 'from' => 'import',
+ ), self_admin_url( 'update.php' )
+ ), 'install-plugin_' . $plugin_slug
+ );
$action = sprintf(
'%5$s ',
esc_url( $url ),
@@ -145,9 +163,11 @@ if ( empty( $importers ) ) {
}
}
} else {
- $url = add_query_arg( array(
- 'import' => $importer_id,
- ), self_admin_url( 'admin.php' ) );
+ $url = add_query_arg(
+ array(
+ 'import' => $importer_id,
+ ), self_admin_url( 'admin.php' )
+ );
$action = sprintf(
'%3$s ',
esc_url( $url ),
@@ -160,14 +180,16 @@ if ( empty( $importers ) ) {
}
if ( ! $is_plugin_installed && is_main_site() ) {
- $url = add_query_arg( array(
- 'tab' => 'plugin-information',
- 'plugin' => $plugin_slug,
- 'from' => 'import',
- 'TB_iframe' => 'true',
- 'width' => 600,
- 'height' => 550,
- ), network_admin_url( 'plugin-install.php' ) );
+ $url = add_query_arg(
+ array(
+ 'tab' => 'plugin-information',
+ 'plugin' => $plugin_slug,
+ 'from' => 'import',
+ 'TB_iframe' => 'true',
+ 'width' => 600,
+ 'height' => 550,
+ ), network_admin_url( 'plugin-install.php' )
+ );
$action .= sprintf(
' | %3$s ',
esc_url( $url ),
@@ -193,8 +215,9 @@ if ( empty( $importers ) ) {
' . sprintf( __('If the importer you need is not listed, search the plugin directory to see if an importer is available.'), esc_url( network_admin_url( 'plugin-install.php?tab=search&type=tag&s=importer' ) ) ) . '';
+if ( current_user_can( 'install_plugins' ) ) {
+ echo '' . sprintf( __( 'If the importer you need is not listed, search the plugin directory to see if an importer is available.' ), esc_url( network_admin_url( 'plugin-install.php?tab=search&type=tag&s=importer' ) ) ) . '
';
+}
?>
diff --git a/wp-admin/includes/admin-filters.php b/wp-admin/includes/admin-filters.php
index 79751a4ef6..62e6c4cfc4 100644
--- a/wp-admin/includes/admin-filters.php
+++ b/wp-admin/includes/admin-filters.php
@@ -19,16 +19,16 @@ add_action( 'attachment_submitbox_misc_actions', 'attachment_submitbox_metadata'
add_action( 'media_upload_image', 'wp_media_upload_handler' );
add_action( 'media_upload_audio', 'wp_media_upload_handler' );
add_action( 'media_upload_video', 'wp_media_upload_handler' );
-add_action( 'media_upload_file', 'wp_media_upload_handler' );
+add_action( 'media_upload_file', 'wp_media_upload_handler' );
add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' );
-add_action( 'post-html-upload-ui', 'media_upload_html_bypass' );
+add_action( 'post-html-upload-ui', 'media_upload_html_bypass' );
add_filter( 'async_upload_image', 'get_media_item', 10, 2 );
add_filter( 'async_upload_audio', 'get_media_item', 10, 2 );
add_filter( 'async_upload_video', 'get_media_item', 10, 2 );
-add_filter( 'async_upload_file', 'get_media_item', 10, 2 );
+add_filter( 'async_upload_file', 'get_media_item', 10, 2 );
add_filter( 'attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2 );
@@ -38,33 +38,33 @@ add_filter( 'media_upload_library', 'media_upload_library' );
add_filter( 'media_upload_tabs', 'update_gallery_tab' );
// Misc hooks.
-add_action( 'admin_init', 'wp_admin_headers' );
-add_action( 'login_init', 'wp_admin_headers' );
-add_action( 'admin_head', 'wp_admin_canonical_url' );
+add_action( 'admin_init', 'wp_admin_headers' );
+add_action( 'login_init', 'wp_admin_headers' );
+add_action( 'admin_head', 'wp_admin_canonical_url' );
add_action( 'admin_head', 'wp_color_scheme_settings' );
-add_action( 'admin_head', 'wp_site_icon' );
-add_action( 'admin_head', '_ipad_meta' );
+add_action( 'admin_head', 'wp_site_icon' );
+add_action( 'admin_head', '_ipad_meta' );
// Prerendering.
if ( ! is_customize_preview() ) {
add_filter( 'admin_print_styles', 'wp_resource_hints', 1 );
}
-add_action( 'admin_print_scripts-post.php', 'wp_page_reload_on_back_button_js' );
+add_action( 'admin_print_scripts-post.php', 'wp_page_reload_on_back_button_js' );
add_action( 'admin_print_scripts-post-new.php', 'wp_page_reload_on_back_button_js' );
-add_action( 'update_option_home', 'update_home_siteurl', 10, 2 );
-add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 );
+add_action( 'update_option_home', 'update_home_siteurl', 10, 2 );
+add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 );
add_action( 'update_option_page_on_front', 'update_home_siteurl', 10, 2 );
-add_action( 'update_option_admin_email', 'wp_site_admin_email_change_notification', 10, 3 );
+add_action( 'update_option_admin_email', 'wp_site_admin_email_change_notification', 10, 3 );
-add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
+add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
-add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 );
-add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 );
-add_filter( 'wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3 );
-add_filter( 'heartbeat_received', 'heartbeat_autosave', 500, 2 );
+add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 );
+add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 );
+add_filter( 'wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3 );
+add_filter( 'heartbeat_received', 'heartbeat_autosave', 500, 2 );
add_filter( 'heartbeat_settings', 'wp_heartbeat_set_suspension' );
@@ -75,19 +75,19 @@ add_action( 'admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items' )
add_filter( 'whitelist_options', 'option_update_filter' );
// Plugin Install hooks.
-add_action( 'install_plugins_featured', 'install_dashboard' );
-add_action( 'install_plugins_upload', 'install_plugins_upload' );
-add_action( 'install_plugins_search', 'display_plugins_table' );
-add_action( 'install_plugins_popular', 'display_plugins_table' );
-add_action( 'install_plugins_recommended', 'display_plugins_table' );
-add_action( 'install_plugins_new', 'display_plugins_table' );
-add_action( 'install_plugins_beta', 'display_plugins_table' );
-add_action( 'install_plugins_favorites', 'display_plugins_table' );
+add_action( 'install_plugins_featured', 'install_dashboard' );
+add_action( 'install_plugins_upload', 'install_plugins_upload' );
+add_action( 'install_plugins_search', 'display_plugins_table' );
+add_action( 'install_plugins_popular', 'display_plugins_table' );
+add_action( 'install_plugins_recommended', 'display_plugins_table' );
+add_action( 'install_plugins_new', 'display_plugins_table' );
+add_action( 'install_plugins_beta', 'display_plugins_table' );
+add_action( 'install_plugins_favorites', 'display_plugins_table' );
add_action( 'install_plugins_pre_plugin-information', 'install_plugin_information' );
// Template hooks.
-add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
-add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) );
+add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
+add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) );
// Theme hooks.
add_action( 'customize_controls_print_footer_scripts', 'customize_themes_print_templates' );
@@ -115,7 +115,7 @@ add_action( 'personal_options_update', 'send_confirmation_on_profile_email' );
add_action( 'load-plugins.php', 'wp_plugin_update_rows', 20 ); // After wp_update_plugins() is called.
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', 'update_nag', 3 );
add_action( 'admin_notices', 'maintenance_nag', 10 );
add_filter( 'update_footer', 'core_update_footer' );
diff --git a/wp-admin/includes/admin.php b/wp-admin/includes/admin.php
index ee197714ad..af4f7cc04c 100644
--- a/wp-admin/includes/admin.php
+++ b/wp-admin/includes/admin.php
@@ -7,7 +7,7 @@
* @since 2.3.0
*/
-if ( ! defined('WP_ADMIN') ) {
+if ( ! defined( 'WP_ADMIN' ) ) {
/*
* This file is being included from a file other than wp-admin/admin.php, so
* some setup was skipped. Make sure the admin message catalog is loaded since
@@ -17,71 +17,71 @@ if ( ! defined('WP_ADMIN') ) {
}
/** WordPress Administration Hooks */
-require_once(ABSPATH . 'wp-admin/includes/admin-filters.php');
+require_once( ABSPATH . 'wp-admin/includes/admin-filters.php' );
/** WordPress Bookmark Administration API */
-require_once(ABSPATH . 'wp-admin/includes/bookmark.php');
+require_once( ABSPATH . 'wp-admin/includes/bookmark.php' );
/** WordPress Comment Administration API */
-require_once(ABSPATH . 'wp-admin/includes/comment.php');
+require_once( ABSPATH . 'wp-admin/includes/comment.php' );
/** WordPress Administration File API */
-require_once(ABSPATH . 'wp-admin/includes/file.php');
+require_once( ABSPATH . 'wp-admin/includes/file.php' );
/** WordPress Image Administration API */
-require_once(ABSPATH . 'wp-admin/includes/image.php');
+require_once( ABSPATH . 'wp-admin/includes/image.php' );
/** WordPress Media Administration API */
-require_once(ABSPATH . 'wp-admin/includes/media.php');
+require_once( ABSPATH . 'wp-admin/includes/media.php' );
/** WordPress Import Administration API */
-require_once(ABSPATH . 'wp-admin/includes/import.php');
+require_once( ABSPATH . 'wp-admin/includes/import.php' );
/** WordPress Misc Administration API */
-require_once(ABSPATH . 'wp-admin/includes/misc.php');
+require_once( ABSPATH . 'wp-admin/includes/misc.php' );
/** WordPress Options Administration API */
-require_once(ABSPATH . 'wp-admin/includes/options.php');
+require_once( ABSPATH . 'wp-admin/includes/options.php' );
/** WordPress Plugin Administration API */
-require_once(ABSPATH . 'wp-admin/includes/plugin.php');
+require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
/** WordPress Post Administration API */
-require_once(ABSPATH . 'wp-admin/includes/post.php');
+require_once( ABSPATH . 'wp-admin/includes/post.php' );
/** WordPress Administration Screen API */
-require_once(ABSPATH . 'wp-admin/includes/class-wp-screen.php');
-require_once(ABSPATH . 'wp-admin/includes/screen.php');
+require_once( ABSPATH . 'wp-admin/includes/class-wp-screen.php' );
+require_once( ABSPATH . 'wp-admin/includes/screen.php' );
/** WordPress Taxonomy Administration API */
-require_once(ABSPATH . 'wp-admin/includes/taxonomy.php');
+require_once( ABSPATH . 'wp-admin/includes/taxonomy.php' );
/** WordPress Template Administration API */
-require_once(ABSPATH . 'wp-admin/includes/template.php');
+require_once( ABSPATH . 'wp-admin/includes/template.php' );
/** WordPress List Table Administration API and base class */
-require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
-require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table-compat.php');
-require_once(ABSPATH . 'wp-admin/includes/list-table.php');
+require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
+require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table-compat.php' );
+require_once( ABSPATH . 'wp-admin/includes/list-table.php' );
/** WordPress Theme Administration API */
-require_once(ABSPATH . 'wp-admin/includes/theme.php');
+require_once( ABSPATH . 'wp-admin/includes/theme.php' );
/** WordPress User Administration API */
-require_once(ABSPATH . 'wp-admin/includes/user.php');
+require_once( ABSPATH . 'wp-admin/includes/user.php' );
/** WordPress Site Icon API */
-require_once(ABSPATH . 'wp-admin/includes/class-wp-site-icon.php');
+require_once( ABSPATH . 'wp-admin/includes/class-wp-site-icon.php' );
/** WordPress Update Administration API */
-require_once(ABSPATH . 'wp-admin/includes/update.php');
+require_once( ABSPATH . 'wp-admin/includes/update.php' );
/** WordPress Deprecated Administration API */
-require_once(ABSPATH . 'wp-admin/includes/deprecated.php');
+require_once( ABSPATH . 'wp-admin/includes/deprecated.php' );
/** WordPress Multisite support API */
if ( is_multisite() ) {
- require_once(ABSPATH . 'wp-admin/includes/ms-admin-filters.php');
- require_once(ABSPATH . 'wp-admin/includes/ms.php');
- require_once(ABSPATH . 'wp-admin/includes/ms-deprecated.php');
+ require_once( ABSPATH . 'wp-admin/includes/ms-admin-filters.php' );
+ require_once( ABSPATH . 'wp-admin/includes/ms.php' );
+ require_once( ABSPATH . 'wp-admin/includes/ms-deprecated.php' );
}
diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php
index 230da6a958..e05ec0a273 100644
--- a/wp-admin/includes/ajax-actions.php
+++ b/wp-admin/includes/ajax-actions.php
@@ -23,12 +23,13 @@ function wp_ajax_nopriv_heartbeat() {
$response = array();
// screen_id is the same as $current_screen->id and the JS global 'pagenow'.
- if ( ! empty($_POST['screen_id']) )
- $screen_id = sanitize_key($_POST['screen_id']);
- else
+ if ( ! empty( $_POST['screen_id'] ) ) {
+ $screen_id = sanitize_key( $_POST['screen_id'] );
+ } else {
$screen_id = 'front';
+ }
- if ( ! empty($_POST['data']) ) {
+ if ( ! empty( $_POST['data'] ) ) {
$data = wp_unslash( (array) $_POST['data'] );
/**
@@ -68,7 +69,7 @@ function wp_ajax_nopriv_heartbeat() {
// Send the current time according to the server.
$response['server_time'] = time();
- wp_send_json($response);
+ wp_send_json( $response );
}
//
@@ -109,7 +110,7 @@ function wp_ajax_ajax_tag_search() {
}
$taxonomy = sanitize_key( $_GET['tax'] );
- $tax = get_taxonomy( $taxonomy );
+ $tax = get_taxonomy( $taxonomy );
if ( ! $tax ) {
wp_die( 0 );
}
@@ -121,11 +122,12 @@ function wp_ajax_ajax_tag_search() {
$s = wp_unslash( $_GET['q'] );
$comma = _x( ',', 'tag delimiter' );
- if ( ',' !== $comma )
+ if ( ',' !== $comma ) {
$s = str_replace( $comma, ',', $s );
+ }
if ( false !== strpos( $s, ',' ) ) {
$s = explode( ',', $s );
- $s = $s[count( $s ) - 1];
+ $s = $s[ count( $s ) - 1 ];
}
$s = trim( $s );
@@ -144,11 +146,17 @@ function wp_ajax_ajax_tag_search() {
* Require $term_search_min_chars chars for matching (default: 2)
* ensure it's a non-negative, non-zero integer.
*/
- if ( ( $term_search_min_chars == 0 ) || ( strlen( $s ) < $term_search_min_chars ) ){
+ if ( ( $term_search_min_chars == 0 ) || ( strlen( $s ) < $term_search_min_chars ) ) {
wp_die();
}
- $results = get_terms( $taxonomy, array( 'name__like' => $s, 'fields' => 'names', 'hide_empty' => false ) );
+ $results = get_terms(
+ $taxonomy, array(
+ 'name__like' => $s,
+ 'fields' => 'names',
+ 'hide_empty' => false,
+ )
+ );
echo join( $results, "\n" );
wp_die();
@@ -160,33 +168,35 @@ function wp_ajax_ajax_tag_search() {
* @since 3.1.0
*/
function wp_ajax_wp_compression_test() {
- if ( !current_user_can( 'manage_options' ) )
+ if ( ! current_user_can( 'manage_options' ) ) {
wp_die( -1 );
+ }
- if ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ) {
- update_site_option('can_compress_scripts', 0);
+ if ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' == ini_get( 'output_handler' ) ) {
+ update_site_option( 'can_compress_scripts', 0 );
wp_die( 0 );
}
- if ( isset($_GET['test']) ) {
+ if ( isset( $_GET['test'] ) ) {
header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
- header('Content-Type: application/javascript; charset=UTF-8');
- $force_gzip = ( defined('ENFORCE_GZIP') && ENFORCE_GZIP );
- $test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."';
+ header( 'Content-Type: application/javascript; charset=UTF-8' );
+ $force_gzip = ( defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP );
+ $test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."';
if ( 1 == $_GET['test'] ) {
- echo $test_str;
- wp_die();
+ echo $test_str;
+ wp_die();
} elseif ( 2 == $_GET['test'] ) {
- if ( !isset($_SERVER['HTTP_ACCEPT_ENCODING']) )
+ if ( ! isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
wp_die( -1 );
- if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
- header('Content-Encoding: deflate');
+ }
+ if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate' ) && function_exists( 'gzdeflate' ) && ! $force_gzip ) {
+ header( 'Content-Encoding: deflate' );
$out = gzdeflate( $test_str, 1 );
- } elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
- header('Content-Encoding: gzip');
+ } elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && function_exists( 'gzencode' ) ) {
+ header( 'Content-Encoding: gzip' );
$out = gzencode( $test_str, 1 );
} else {
wp_die( -1 );
@@ -195,10 +205,10 @@ function wp_ajax_wp_compression_test() {
wp_die();
} elseif ( 'no' == $_GET['test'] ) {
check_ajax_referer( 'update_can_compress_scripts' );
- update_site_option('can_compress_scripts', 0);
+ update_site_option( 'can_compress_scripts', 0 );
} elseif ( 'yes' == $_GET['test'] ) {
check_ajax_referer( 'update_can_compress_scripts' );
- update_site_option('can_compress_scripts', 1);
+ update_site_option( 'can_compress_scripts', 1 );
}
}
@@ -211,15 +221,17 @@ function wp_ajax_wp_compression_test() {
* @since 3.1.0
*/
function wp_ajax_imgedit_preview() {
- $post_id = intval($_GET['postid']);
- if ( empty($post_id) || !current_user_can('edit_post', $post_id) )
+ $post_id = intval( $_GET['postid'] );
+ if ( empty( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) {
wp_die( -1 );
+ }
check_ajax_referer( "image_editor-$post_id" );
include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
- if ( ! stream_preview_image($post_id) )
+ if ( ! stream_preview_image( $post_id ) ) {
wp_die( -1 );
+ }
wp_die();
}
@@ -242,12 +254,14 @@ function wp_ajax_oembed_cache() {
* @since 3.4.0
*/
function wp_ajax_autocomplete_user() {
- if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) )
+ if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) ) {
wp_die( -1 );
+ }
/** This filter is documented in wp-admin/user-new.php */
- if ( ! current_user_can( 'manage_network_users' ) && ! apply_filters( 'autocomplete_users_for_site_admins', false ) )
+ if ( ! current_user_can( 'manage_network_users' ) && ! apply_filters( 'autocomplete_users_for_site_admins', false ) ) {
wp_die( -1 );
+ }
$return = array();
@@ -274,16 +288,28 @@ function wp_ajax_autocomplete_user() {
$id = get_current_blog_id();
}
- $include_blog_users = ( $type == 'search' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() );
- $exclude_blog_users = ( $type == 'add' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() );
+ $include_blog_users = ( $type == 'search' ? get_users(
+ array(
+ 'blog_id' => $id,
+ 'fields' => 'ID',
+ )
+ ) : array() );
+ $exclude_blog_users = ( $type == 'add' ? get_users(
+ array(
+ 'blog_id' => $id,
+ 'fields' => 'ID',
+ )
+ ) : array() );
- $users = get_users( array(
- 'blog_id' => false,
- 'search' => '*' . $_REQUEST['term'] . '*',
- 'include' => $include_blog_users,
- 'exclude' => $exclude_blog_users,
- 'search_columns' => array( 'user_login', 'user_nicename', 'user_email' ),
- ) );
+ $users = get_users(
+ array(
+ 'blog_id' => false,
+ 'search' => '*' . $_REQUEST['term'] . '*',
+ 'include' => $include_blog_users,
+ 'exclude' => $exclude_blog_users,
+ 'search_columns' => array( 'user_login', 'user_nicename', 'user_email' ),
+ )
+ );
foreach ( $users as $user ) {
$return[] = array(
@@ -315,9 +341,11 @@ function wp_ajax_get_community_events() {
$ip_changed = false;
if ( is_wp_error( $events ) ) {
- wp_send_json_error( array(
- 'error' => $events->get_error_message(),
- ) );
+ wp_send_json_error(
+ array(
+ 'error' => $events->get_error_message(),
+ )
+ );
} else {
if ( empty( $saved_location['ip'] ) && ! empty( $events['location']['ip'] ) ) {
$ip_changed = true;
@@ -360,7 +388,7 @@ function wp_ajax_dashboard_widgets() {
}
switch ( $_GET['widget'] ) {
- case 'dashboard_primary' :
+ case 'dashboard_primary':
wp_dashboard_primary();
break;
}
@@ -392,10 +420,10 @@ function wp_ajax_logged_in() {
* @param int $delta
*/
function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
- $total = isset( $_POST['_total'] ) ? (int) $_POST['_total'] : 0;
+ $total = isset( $_POST['_total'] ) ? (int) $_POST['_total'] : 0;
$per_page = isset( $_POST['_per_page'] ) ? (int) $_POST['_per_page'] : 0;
- $page = isset( $_POST['_page'] ) ? (int) $_POST['_page'] : 0;
- $url = isset( $_POST['_url'] ) ? esc_url_raw( $_POST['_url'] ) : '';
+ $page = isset( $_POST['_page'] ) ? (int) $_POST['_page'] : 0;
+ $url = isset( $_POST['_url'] ) ? esc_url_raw( $_POST['_url'] ) : '';
// JS didn't send us everything we need to know. Just die with success message
if ( ! $total || ! $per_page || ! $page || ! $url ) {
@@ -414,32 +442,35 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
$counts = wp_count_comments();
- $x = new WP_Ajax_Response( array(
- 'what' => 'comment',
- // Here for completeness - not used.
- 'id' => $comment_id,
- 'supplemental' => array(
- 'status' => $comment_status,
- 'postId' => $comment ? $comment->comment_post_ID : '',
- 'time' => $time,
- 'in_moderation' => $counts->moderated,
- 'i18n_comments_text' => sprintf(
- _n( '%s Comment', '%s Comments', $counts->approved ),
- number_format_i18n( $counts->approved )
+ $x = new WP_Ajax_Response(
+ array(
+ 'what' => 'comment',
+ // Here for completeness - not used.
+ 'id' => $comment_id,
+ 'supplemental' => array(
+ 'status' => $comment_status,
+ 'postId' => $comment ? $comment->comment_post_ID : '',
+ 'time' => $time,
+ 'in_moderation' => $counts->moderated,
+ 'i18n_comments_text' => sprintf(
+ _n( '%s Comment', '%s Comments', $counts->approved ),
+ number_format_i18n( $counts->approved )
+ ),
+ 'i18n_moderation_text' => sprintf(
+ _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ),
+ number_format_i18n( $counts->moderated )
+ ),
+ 'comment_link' => $comment_link,
),
- 'i18n_moderation_text' => sprintf(
- _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ),
- number_format_i18n( $counts->moderated )
- ),
- 'comment_link' => $comment_link,
)
- ) );
+ );
$x->send();
}
$total += $delta;
- if ( $total < 0 )
+ if ( $total < 0 ) {
$total = 0;
+ }
// Only do the expensive stuff on a page-break, and about 1 other time per page
if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {
@@ -449,17 +480,20 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
$parsed = parse_url( $url );
if ( isset( $parsed['query'] ) ) {
parse_str( $parsed['query'], $query_vars );
- if ( !empty( $query_vars['comment_status'] ) )
+ if ( ! empty( $query_vars['comment_status'] ) ) {
$status = $query_vars['comment_status'];
- if ( !empty( $query_vars['p'] ) )
+ }
+ if ( ! empty( $query_vars['p'] ) ) {
$post_id = (int) $query_vars['p'];
- if ( ! empty( $query_vars['comment_type'] ) )
+ }
+ if ( ! empty( $query_vars['comment_type'] ) ) {
$type = $query_vars['comment_type'];
+ }
}
if ( empty( $type ) ) {
// Only use the comment count if not filtering by a comment_type.
- $comment_count = wp_count_comments($post_id);
+ $comment_count = wp_count_comments( $post_id );
// We're looking for a known type of comment count.
if ( isset( $comment_count->$status ) ) {
@@ -470,23 +504,25 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
}
// The time since the last comment count.
- $time = time();
+ $time = time();
$comment = get_comment( $comment_id );
- $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 : '',
- '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
+ $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 : '',
+ '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,
+ ),
)
- ) );
+ );
$x->send();
}
@@ -501,27 +537,31 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
* @since 3.1.0
*/
function _wp_ajax_add_hierarchical_term() {
- $action = $_POST['action'];
- $taxonomy = get_taxonomy(substr($action, 4));
+ $action = $_POST['action'];
+ $taxonomy = get_taxonomy( substr( $action, 4 ) );
check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name );
- if ( !current_user_can( $taxonomy->cap->edit_terms ) )
+ if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) {
wp_die( -1 );
- $names = explode(',', $_POST['new'.$taxonomy->name]);
- $parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0;
- if ( 0 > $parent )
+ }
+ $names = explode( ',', $_POST[ 'new' . $taxonomy->name ] );
+ $parent = isset( $_POST[ 'new' . $taxonomy->name . '_parent' ] ) ? (int) $_POST[ 'new' . $taxonomy->name . '_parent' ] : 0;
+ if ( 0 > $parent ) {
$parent = 0;
- if ( $taxonomy->name == 'category' )
- $post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array();
- else
- $post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array();
+ }
+ if ( $taxonomy->name == 'category' ) {
+ $post_category = isset( $_POST['post_category'] ) ? (array) $_POST['post_category'] : array();
+ } else {
+ $post_category = ( isset( $_POST['tax_input'] ) && isset( $_POST['tax_input'][ $taxonomy->name ] ) ) ? (array) $_POST['tax_input'][ $taxonomy->name ] : array();
+ }
$checked_categories = array_map( 'absint', (array) $post_category );
- $popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false);
+ $popular_ids = wp_popular_terms_checklist( $taxonomy->name, 0, 10, false );
foreach ( $names as $cat_name ) {
- $cat_name = trim($cat_name);
- $category_nicename = sanitize_title($cat_name);
- if ( '' === $category_nicename )
+ $cat_name = trim( $cat_name );
+ $category_nicename = sanitize_title( $cat_name );
+ if ( '' === $category_nicename ) {
continue;
+ }
$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
if ( ! $cat_id || is_wp_error( $cat_id ) ) {
@@ -530,54 +570,76 @@ function _wp_ajax_add_hierarchical_term() {
$cat_id = $cat_id['term_id'];
}
$checked_categories[] = $cat_id;
- if ( $parent ) // Do these all at once in a second
+ if ( $parent ) { // Do these all at once in a second
continue;
+ }
ob_start();
- wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids ));
+ wp_terms_checklist(
+ 0, array(
+ 'taxonomy' => $taxonomy->name,
+ 'descendants_and_self' => $cat_id,
+ 'selected_cats' => $checked_categories,
+ 'popular_cats' => $popular_ids,
+ )
+ );
$data = ob_get_clean();
$add = array(
- 'what' => $taxonomy->name,
- 'id' => $cat_id,
- 'data' => str_replace( array("\n", "\t"), '', $data),
- 'position' => -1
+ 'what' => $taxonomy->name,
+ 'id' => $cat_id,
+ 'data' => str_replace( array( "\n", "\t" ), '', $data ),
+ 'position' => -1,
);
}
if ( $parent ) { // Foncy - replace the parent and all its children
- $parent = get_term( $parent, $taxonomy->name );
+ $parent = get_term( $parent, $taxonomy->name );
$term_id = $parent->term_id;
while ( $parent->parent ) { // get the top parent
$parent = get_term( $parent->parent, $taxonomy->name );
- if ( is_wp_error( $parent ) )
+ if ( is_wp_error( $parent ) ) {
break;
+ }
$term_id = $parent->term_id;
}
ob_start();
- wp_terms_checklist( 0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids));
+ wp_terms_checklist(
+ 0, array(
+ 'taxonomy' => $taxonomy->name,
+ 'descendants_and_self' => $term_id,
+ 'selected_cats' => $checked_categories,
+ 'popular_cats' => $popular_ids,
+ )
+ );
$data = ob_get_clean();
$add = array(
- 'what' => $taxonomy->name,
- 'id' => $term_id,
- 'data' => str_replace( array("\n", "\t"), '', $data),
- 'position' => -1
+ 'what' => $taxonomy->name,
+ 'id' => $term_id,
+ 'data' => str_replace( array( "\n", "\t" ), '', $data ),
+ 'position' => -1,
);
}
ob_start();
- wp_dropdown_categories( array(
- 'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name',
- 'hierarchical' => 1, 'show_option_none' => '— '.$taxonomy->labels->parent_item.' —'
- ) );
+ wp_dropdown_categories(
+ array(
+ 'taxonomy' => $taxonomy->name,
+ 'hide_empty' => 0,
+ 'name' => 'new' . $taxonomy->name . '_parent',
+ 'orderby' => 'name',
+ 'hierarchical' => 1,
+ 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —',
+ )
+ );
$sup = ob_get_clean();
@@ -595,43 +657,52 @@ function _wp_ajax_add_hierarchical_term() {
function wp_ajax_delete_comment() {
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
- if ( !$comment = get_comment( $id ) )
+ if ( ! $comment = get_comment( $id ) ) {
wp_die( time() );
- if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) )
+ }
+ if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
wp_die( -1 );
+ }
check_ajax_referer( "delete-comment_$id" );
$status = wp_get_comment_status( $comment );
$delta = -1;
- if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
- if ( 'trash' == $status )
+ if ( isset( $_POST['trash'] ) && 1 == $_POST['trash'] ) {
+ if ( 'trash' == $status ) {
wp_die( time() );
+ }
$r = wp_trash_comment( $comment );
- } elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
- if ( 'trash' != $status )
+ } elseif ( isset( $_POST['untrash'] ) && 1 == $_POST['untrash'] ) {
+ if ( 'trash' != $status ) {
wp_die( time() );
+ }
$r = wp_untrash_comment( $comment );
- if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash
+ if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) { // undo trash, not in trash
$delta = 1;
- } elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
- if ( 'spam' == $status )
+ }
+ } elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) {
+ if ( 'spam' == $status ) {
wp_die( time() );
+ }
$r = wp_spam_comment( $comment );
- } elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) {
- if ( 'spam' != $status )
+ } elseif ( isset( $_POST['unspam'] ) && 1 == $_POST['unspam'] ) {
+ if ( 'spam' != $status ) {
wp_die( time() );
+ }
$r = wp_unspam_comment( $comment );
- if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam
+ if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) { // undo spam, not in spam
$delta = 1;
- } elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
+ }
+ } elseif ( isset( $_POST['delete'] ) && 1 == $_POST['delete'] ) {
$r = wp_delete_comment( $comment );
} else {
wp_die( -1 );
}
- if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
+ if ( $r ) { // Decide if we need to send back '1' or a more complicated response including page links and comment counts
_wp_ajax_delete_comment_response( $comment->comment_ID, $delta );
+ }
wp_die( 0 );
}
@@ -648,15 +719,17 @@ function wp_ajax_delete_tag() {
wp_die( -1 );
}
- $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
- $tag = get_term( $tag_id, $taxonomy );
- if ( !$tag || is_wp_error( $tag ) )
+ $taxonomy = ! empty( $_POST['taxonomy'] ) ? $_POST['taxonomy'] : 'post_tag';
+ $tag = get_term( $tag_id, $taxonomy );
+ if ( ! $tag || is_wp_error( $tag ) ) {
wp_die( 1 );
+ }
- if ( wp_delete_term($tag_id, $taxonomy))
+ if ( wp_delete_term( $tag_id, $taxonomy ) ) {
wp_die( 1 );
- else
+ } else {
wp_die( 0 );
+ }
}
/**
@@ -668,17 +741,20 @@ function wp_ajax_delete_link() {
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
check_ajax_referer( "delete-bookmark_$id" );
- if ( !current_user_can( 'manage_links' ) )
+ if ( ! current_user_can( 'manage_links' ) ) {
wp_die( -1 );
+ }
$link = get_bookmark( $id );
- if ( !$link || is_wp_error( $link ) )
+ if ( ! $link || is_wp_error( $link ) ) {
wp_die( 1 );
+ }
- if ( wp_delete_link( $id ) )
+ if ( wp_delete_link( $id ) ) {
wp_die( 1 );
- else
+ } else {
wp_die( 0 );
+ }
}
/**
@@ -690,13 +766,16 @@ function wp_ajax_delete_meta() {
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
check_ajax_referer( "delete-meta_$id" );
- if ( !$meta = get_metadata_by_mid( 'post', $id ) )
+ if ( ! $meta = get_metadata_by_mid( 'post', $id ) ) {
wp_die( 1 );
+ }
- if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $meta->post_id, $meta->meta_key ) )
+ if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $meta->post_id, $meta->meta_key ) ) {
wp_die( -1 );
- if ( delete_meta( $meta->meta_id ) )
+ }
+ if ( delete_meta( $meta->meta_id ) ) {
wp_die( 1 );
+ }
wp_die( 0 );
}
@@ -708,21 +787,25 @@ function wp_ajax_delete_meta() {
* @param string $action Action to perform.
*/
function wp_ajax_delete_post( $action ) {
- if ( empty( $action ) )
+ if ( empty( $action ) ) {
$action = 'delete-post';
+ }
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
check_ajax_referer( "{$action}_$id" );
- if ( !current_user_can( 'delete_post', $id ) )
+ if ( ! current_user_can( 'delete_post', $id ) ) {
wp_die( -1 );
+ }
- if ( !get_post( $id ) )
+ if ( ! get_post( $id ) ) {
wp_die( 1 );
+ }
- if ( wp_delete_post( $id ) )
+ if ( wp_delete_post( $id ) ) {
wp_die( 1 );
- else
+ } else {
wp_die( 0 );
+ }
}
/**
@@ -733,24 +816,29 @@ function wp_ajax_delete_post( $action ) {
* @param string $action Action to perform.
*/
function wp_ajax_trash_post( $action ) {
- if ( empty( $action ) )
+ if ( empty( $action ) ) {
$action = 'trash-post';
+ }
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
check_ajax_referer( "{$action}_$id" );
- if ( !current_user_can( 'delete_post', $id ) )
+ if ( ! current_user_can( 'delete_post', $id ) ) {
wp_die( -1 );
+ }
- if ( !get_post( $id ) )
+ if ( ! get_post( $id ) ) {
wp_die( 1 );
+ }
- if ( 'trash-post' == $action )
+ if ( 'trash-post' == $action ) {
$done = wp_trash_post( $id );
- else
+ } else {
$done = wp_untrash_post( $id );
+ }
- if ( $done )
+ if ( $done ) {
wp_die( 1 );
+ }
wp_die( 0 );
}
@@ -763,8 +851,9 @@ function wp_ajax_trash_post( $action ) {
* @param string $action Action to perform.
*/
function wp_ajax_untrash_post( $action ) {
- if ( empty( $action ) )
+ if ( empty( $action ) ) {
$action = 'untrash-post';
+ }
wp_ajax_trash_post( $action );
}
@@ -774,21 +863,25 @@ function wp_ajax_untrash_post( $action ) {
* @param string $action
*/
function wp_ajax_delete_page( $action ) {
- if ( empty( $action ) )
+ if ( empty( $action ) ) {
$action = 'delete-page';
+ }
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
check_ajax_referer( "{$action}_$id" );
- if ( !current_user_can( 'delete_page', $id ) )
+ if ( ! current_user_can( 'delete_page', $id ) ) {
wp_die( -1 );
+ }
- if ( ! get_post( $id ) )
+ if ( ! get_post( $id ) ) {
wp_die( 1 );
+ }
- if ( wp_delete_post( $id ) )
+ if ( wp_delete_post( $id ) ) {
wp_die( 1 );
- else
+ } else {
wp_die( 0 );
+ }
}
/**
@@ -799,20 +892,24 @@ function wp_ajax_delete_page( $action ) {
function wp_ajax_dim_comment() {
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
- if ( !$comment = get_comment( $id ) ) {
- $x = new WP_Ajax_Response( array(
- 'what' => 'comment',
- 'id' => new WP_Error('invalid_comment', sprintf(__('Comment %d does not exist'), $id))
- ) );
+ if ( ! $comment = get_comment( $id ) ) {
+ $x = new WP_Ajax_Response(
+ array(
+ 'what' => 'comment',
+ 'id' => new WP_Error( 'invalid_comment', sprintf( __( 'Comment %d does not exist' ), $id ) ),
+ )
+ );
$x->send();
}
- if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) )
+ if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) ) {
wp_die( -1 );
+ }
$current = wp_get_comment_status( $comment );
- if ( isset( $_POST['new'] ) && $_POST['new'] == $current )
+ if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) {
wp_die( time() );
+ }
check_ajax_referer( "approve-comment_$id" );
if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) {
@@ -821,11 +918,13 @@ function wp_ajax_dim_comment() {
$result = wp_set_comment_status( $comment, 'hold', true );
}
- if ( is_wp_error($result) ) {
- $x = new WP_Ajax_Response( array(
- 'what' => 'comment',
- 'id' => $result
- ) );
+ if ( is_wp_error( $result ) ) {
+ $x = new WP_Ajax_Response(
+ array(
+ 'what' => 'comment',
+ 'id' => $result,
+ )
+ );
$x->send();
}
@@ -842,20 +941,22 @@ function wp_ajax_dim_comment() {
* @param string $action Action to perform.
*/
function wp_ajax_add_link_category( $action ) {
- if ( empty( $action ) )
+ if ( empty( $action ) ) {
$action = 'add-link-category';
+ }
check_ajax_referer( $action );
$tax = get_taxonomy( 'link_category' );
if ( ! current_user_can( $tax->cap->manage_terms ) ) {
wp_die( -1 );
}
- $names = explode(',', wp_unslash( $_POST['newcat'] ) );
- $x = new WP_Ajax_Response();
+ $names = explode( ',', wp_unslash( $_POST['newcat'] ) );
+ $x = new WP_Ajax_Response();
foreach ( $names as $cat_name ) {
- $cat_name = trim($cat_name);
- $slug = sanitize_title($cat_name);
- if ( '' === $slug )
+ $cat_name = trim( $cat_name );
+ $slug = sanitize_title( $cat_name );
+ if ( '' === $slug ) {
continue;
+ }
$cat_id = wp_insert_term( $cat_name, 'link_category' );
if ( ! $cat_id || is_wp_error( $cat_id ) ) {
@@ -864,12 +965,14 @@ function wp_ajax_add_link_category( $action ) {
$cat_id = $cat_id['term_id'];
}
$cat_name = esc_html( $cat_name );
- $x->add( array(
- 'what' => 'link-category',
- 'id' => $cat_id,
- 'data' => "
$cat_name",
- 'position' => -1
- ) );
+ $x->add(
+ array(
+ 'what' => 'link-category',
+ 'id' => $cat_id,
+ 'data' => "
$cat_name",
+ 'position' => -1,
+ )
+ );
}
$x->send();
}
@@ -881,32 +984,36 @@ function wp_ajax_add_link_category( $action ) {
*/
function wp_ajax_add_tag() {
check_ajax_referer( 'add-tag', '_wpnonce_add-tag' );
- $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
- $tax = get_taxonomy($taxonomy);
+ $taxonomy = ! empty( $_POST['taxonomy'] ) ? $_POST['taxonomy'] : 'post_tag';
+ $tax = get_taxonomy( $taxonomy );
- if ( !current_user_can( $tax->cap->edit_terms ) )
+ if ( ! current_user_can( $tax->cap->edit_terms ) ) {
wp_die( -1 );
+ }
$x = new WP_Ajax_Response();
- $tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST );
+ $tag = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );
- if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) {
- $message = __('An error has occurred. Please reload the page and try again.');
- if ( is_wp_error($tag) && $tag->get_error_message() )
+ if ( ! $tag || is_wp_error( $tag ) || ( ! $tag = get_term( $tag['term_id'], $taxonomy ) ) ) {
+ $message = __( 'An error has occurred. Please reload the page and try again.' );
+ if ( is_wp_error( $tag ) && $tag->get_error_message() ) {
$message = $tag->get_error_message();
+ }
- $x->add( array(
- 'what' => 'taxonomy',
- 'data' => new WP_Error('error', $message )
- ) );
+ $x->add(
+ array(
+ 'what' => 'taxonomy',
+ 'data' => new WP_Error( 'error', $message ),
+ )
+ );
$x->send();
}
$wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) );
$level = 0;
- if ( is_taxonomy_hierarchical($taxonomy) ) {
+ if ( is_taxonomy_hierarchical( $taxonomy ) ) {
$level = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) );
ob_start();
$wp_list_table->single_row( $tag, $level );
@@ -917,15 +1024,19 @@ function wp_ajax_add_tag() {
$wp_list_table->single_row( $tag );
$parents = ob_get_clean();
- $x->add( array(
- 'what' => 'taxonomy',
- 'supplemental' => compact('parents', 'noparents')
- ) );
- $x->add( array(
- 'what' => 'term',
- 'position' => $level,
- 'supplemental' => (array) $tag
- ) );
+ $x->add(
+ array(
+ 'what' => 'taxonomy',
+ 'supplemental' => compact( 'parents', 'noparents' ),
+ )
+ );
+ $x->add(
+ array(
+ 'what' => 'term',
+ 'position' => $level,
+ 'supplemental' => (array) $tag,
+ )
+ );
$x->send();
}
@@ -940,7 +1051,7 @@ function wp_ajax_get_tagcloud() {
}
$taxonomy = sanitize_key( $_POST['tax'] );
- $tax = get_taxonomy( $taxonomy );
+ $tax = get_taxonomy( $taxonomy );
if ( ! $tax ) {
wp_die( 0 );
}
@@ -949,24 +1060,38 @@ function wp_ajax_get_tagcloud() {
wp_die( -1 );
}
- $tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) );
+ $tags = get_terms(
+ $taxonomy, array(
+ 'number' => 45,
+ 'orderby' => 'count',
+ 'order' => 'DESC',
+ )
+ );
- if ( empty( $tags ) )
+ if ( empty( $tags ) ) {
wp_die( $tax->labels->not_found );
+ }
- if ( is_wp_error( $tags ) )
+ if ( is_wp_error( $tags ) ) {
wp_die( $tags->get_error_message() );
+ }
foreach ( $tags as $key => $tag ) {
$tags[ $key ]->link = '#';
- $tags[ $key ]->id = $tag->term_id;
+ $tags[ $key ]->id = $tag->term_id;
}
// We need raw tag names here, so don't filter the output
- $return = wp_generate_tag_cloud( $tags, array( 'filter' => 0, 'format' => 'list' ) );
+ $return = wp_generate_tag_cloud(
+ $tags, array(
+ 'filter' => 0,
+ 'format' => 'list',
+ )
+ );
- if ( empty($return) )
+ if ( empty( $return ) ) {
wp_die( 0 );
+ }
echo $return;
@@ -1015,17 +1140,20 @@ function wp_ajax_get_comments( $action ) {
$x = new WP_Ajax_Response();
ob_start();
foreach ( $wp_list_table->items as $comment ) {
- if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && 0 === $comment->comment_approved )
+ if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && 0 === $comment->comment_approved ) {
continue;
+ }
get_comment( $comment );
$wp_list_table->single_row( $comment );
}
$comment_list_item = ob_get_clean();
- $x->add( array(
- 'what' => 'comments',
- 'data' => $comment_list_item
- ) );
+ $x->add(
+ array(
+ 'what' => 'comments',
+ 'data' => $comment_list_item,
+ )
+ );
$x->send();
}
@@ -1037,35 +1165,40 @@ function wp_ajax_get_comments( $action ) {
* @param string $action Action to perform.
*/
function wp_ajax_replyto_comment( $action ) {
- if ( empty( $action ) )
+ if ( empty( $action ) ) {
$action = 'replyto-comment';
+ }
check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
$comment_post_ID = (int) $_POST['comment_post_ID'];
- $post = get_post( $comment_post_ID );
- if ( ! $post )
+ $post = get_post( $comment_post_ID );
+ if ( ! $post ) {
wp_die( -1 );
+ }
- if ( !current_user_can( 'edit_post', $comment_post_ID ) )
+ if ( ! current_user_can( 'edit_post', $comment_post_ID ) ) {
wp_die( -1 );
+ }
- if ( empty( $post->post_status ) )
+ if ( empty( $post->post_status ) ) {
wp_die( 1 );
- elseif ( in_array($post->post_status, array('draft', 'pending', 'trash') ) )
- wp_die( __('ERROR: you are replying to a comment on a draft post.') );
+ } elseif ( in_array( $post->post_status, array( 'draft', 'pending', 'trash' ) ) ) {
+ wp_die( __( 'ERROR: you are replying to a comment on a draft post.' ) );
+ }
$user = wp_get_current_user();
if ( $user->exists() ) {
- $user_ID = $user->ID;
+ $user_ID = $user->ID;
$comment_author = wp_slash( $user->display_name );
$comment_author_email = wp_slash( $user->user_email );
$comment_author_url = wp_slash( $user->user_url );
$comment_content = trim( $_POST['content'] );
$comment_type = isset( $_POST['comment_type'] ) ? trim( $_POST['comment_type'] ) : '';
if ( current_user_can( 'unfiltered_html' ) ) {
- if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) )
+ if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) {
$_POST['_wp_unfiltered_html_comment'] = '';
+ }
if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) {
kses_remove_filters(); // start with a clean slate
@@ -1076,17 +1209,19 @@ function wp_ajax_replyto_comment( $action ) {
wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) );
}
- if ( '' == $comment_content )
+ if ( '' == $comment_content ) {
wp_die( __( 'ERROR: please type a comment.' ) );
+ }
$comment_parent = 0;
- if ( isset( $_POST['comment_ID'] ) )
+ if ( isset( $_POST['comment_ID'] ) ) {
$comment_parent = absint( $_POST['comment_ID'] );
+ }
$comment_auto_approved = false;
- $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
+ $commentdata = compact( 'comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID' );
// Automatically approve parent comment.
- if ( !empty($_POST['approve_parent']) ) {
+ if ( ! empty( $_POST['approve_parent'] ) ) {
$parent = get_comment( $comment_parent );
if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) {
@@ -1094,8 +1229,9 @@ function wp_ajax_replyto_comment( $action ) {
wp_die( -1 );
}
- if ( wp_set_comment_status( $parent, 'approve' ) )
+ if ( wp_set_comment_status( $parent, 'approve' ) ) {
$comment_auto_approved = true;
+ }
}
}
@@ -1105,10 +1241,12 @@ function wp_ajax_replyto_comment( $action ) {
wp_die( $comment_id->get_error_message() );
}
- $comment = get_comment($comment_id);
- if ( ! $comment ) wp_die( 1 );
+ $comment = get_comment( $comment_id );
+ if ( ! $comment ) {
+ wp_die( 1 );
+ }
- $position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
+ $position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
ob_start();
if ( isset( $_REQUEST['mode'] ) && 'dashboard' == $_REQUEST['mode'] ) {
@@ -1116,37 +1254,37 @@ function wp_ajax_replyto_comment( $action ) {
_wp_dashboard_recent_comments_row( $comment );
} else {
if ( isset( $_REQUEST['mode'] ) && 'single' == $_REQUEST['mode'] ) {
- $wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
+ $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
} else {
- $wp_list_table = _get_list_table('WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
+ $wp_list_table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
}
$wp_list_table->single_row( $comment );
}
$comment_list_item = ob_get_clean();
- $response = array(
- 'what' => 'comment',
- 'id' => $comment->comment_ID,
- 'data' => $comment_list_item,
- 'position' => $position
+ $response = array(
+ 'what' => 'comment',
+ 'id' => $comment->comment_ID,
+ 'data' => $comment_list_item,
+ 'position' => $position,
);
- $counts = wp_count_comments();
+ $counts = wp_count_comments();
$response['supplemental'] = array(
- 'in_moderation' => $counts->moderated,
- 'i18n_comments_text' => sprintf(
+ 'in_moderation' => $counts->moderated,
+ 'i18n_comments_text' => sprintf(
_n( '%s Comment', '%s Comments', $counts->approved ),
number_format_i18n( $counts->approved )
),
'i18n_moderation_text' => sprintf(
_nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ),
number_format_i18n( $counts->moderated )
- )
+ ),
);
if ( $comment_auto_approved ) {
$response['supplemental']['parent_approved'] = $parent->comment_ID;
- $response['supplemental']['parent_post_id'] = $parent->comment_post_ID;
+ $response['supplemental']['parent_post_id'] = $parent->comment_post_ID;
}
$x = new WP_Ajax_Response();
@@ -1163,23 +1301,27 @@ function wp_ajax_edit_comment() {
check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' );
$comment_id = (int) $_POST['comment_ID'];
- if ( ! current_user_can( 'edit_comment', $comment_id ) )
+ if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
wp_die( -1 );
+ }
- if ( '' == $_POST['content'] )
+ if ( '' == $_POST['content'] ) {
wp_die( __( 'ERROR: please type a comment.' ) );
+ }
- if ( isset( $_POST['status'] ) )
+ if ( isset( $_POST['status'] ) ) {
$_POST['comment_status'] = $_POST['status'];
+ }
edit_comment();
- $position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
- $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
+ $position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
+ $checkbox = ( isset( $_POST['checkbox'] ) && true == $_POST['checkbox'] ) ? 1 : 0;
$wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );
$comment = get_comment( $comment_id );
- if ( empty( $comment->comment_ID ) )
+ if ( empty( $comment->comment_ID ) ) {
wp_die( -1 );
+ }
ob_start();
$wp_list_table->single_row( $comment );
@@ -1187,12 +1329,14 @@ function wp_ajax_edit_comment() {
$x = new WP_Ajax_Response();
- $x->add( array(
- 'what' => 'edit_comment',
- 'id' => $comment->comment_ID,
- 'data' => $comment_list_item,
- 'position' => $position
- ));
+ $x->add(
+ array(
+ 'what' => 'edit_comment',
+ 'id' => $comment->comment_ID,
+ 'data' => $comment_list_item,
+ 'position' => $position,
+ )
+ );
$x->send();
}
@@ -1205,8 +1349,9 @@ function wp_ajax_edit_comment() {
function wp_ajax_add_menu_item() {
check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
- if ( ! current_user_can( 'edit_theme_options' ) )
+ if ( ! current_user_can( 'edit_theme_options' ) ) {
wp_die( -1 );
+ }
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
@@ -1220,22 +1365,22 @@ function wp_ajax_add_menu_item() {
'custom' != $menu_item_data['menu-item-type'] &&
! empty( $menu_item_data['menu-item-object-id'] )
) {
- switch( $menu_item_data['menu-item-type'] ) {
- case 'post_type' :
+ switch ( $menu_item_data['menu-item-type'] ) {
+ case 'post_type':
$_object = get_post( $menu_item_data['menu-item-object-id'] );
- break;
+ break;
- case 'post_type_archive' :
+ case 'post_type_archive':
$_object = get_post_type_object( $menu_item_data['menu-item-object'] );
- break;
+ break;
- case 'taxonomy' :
+ case 'taxonomy':
$_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] );
- break;
+ break;
}
$_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) );
- $_menu_item = reset( $_menu_items );
+ $_menu_item = reset( $_menu_items );
// Restore the missing menu item properties
$menu_item_data['menu-item-description'] = $_menu_item->description;
@@ -1245,33 +1390,35 @@ function wp_ajax_add_menu_item() {
}
$item_ids = wp_save_nav_menu_items( 0, $menu_items_data );
- if ( is_wp_error( $item_ids ) )
+ if ( is_wp_error( $item_ids ) ) {
wp_die( 0 );
+ }
$menu_items = array();
foreach ( (array) $item_ids as $menu_item_id ) {
$menu_obj = get_post( $menu_item_id );
if ( ! empty( $menu_obj->ID ) ) {
- $menu_obj = wp_setup_nav_menu_item( $menu_obj );
+ $menu_obj = wp_setup_nav_menu_item( $menu_obj );
$menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items
- $menu_items[] = $menu_obj;
+ $menu_items[] = $menu_obj;
}
}
/** This filter is documented in wp-admin/includes/nav-menu.php */
$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] );
- if ( ! class_exists( $walker_class_name ) )
+ if ( ! class_exists( $walker_class_name ) ) {
wp_die( 0 );
+ }
if ( ! empty( $menu_items ) ) {
$args = array(
- 'after' => '',
- 'before' => '',
- 'link_after' => '',
+ 'after' => '',
+ 'before' => '',
+ 'link_after' => '',
'link_before' => '',
- 'walker' => new $walker_class_name,
+ 'walker' => new $walker_class_name,
);
echo walk_nav_menu_tree( $menu_items, 0, (object) $args );
}
@@ -1285,39 +1432,44 @@ function wp_ajax_add_menu_item() {
*/
function wp_ajax_add_meta() {
check_ajax_referer( 'add-meta', '_ajax_nonce-add-meta' );
- $c = 0;
- $pid = (int) $_POST['post_id'];
+ $c = 0;
+ $pid = (int) $_POST['post_id'];
$post = get_post( $pid );
- if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) {
- if ( !current_user_can( 'edit_post', $pid ) )
+ if ( isset( $_POST['metakeyselect'] ) || isset( $_POST['metakeyinput'] ) ) {
+ if ( ! current_user_can( 'edit_post', $pid ) ) {
wp_die( -1 );
- if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) )
+ }
+ if ( isset( $_POST['metakeyselect'] ) && '#NONE#' == $_POST['metakeyselect'] && empty( $_POST['metakeyinput'] ) ) {
wp_die( 1 );
+ }
// If the post is an autodraft, save the post as a draft and then attempt to save the meta.
if ( $post->post_status == 'auto-draft' ) {
- $post_data = array();
- $post_data['action'] = 'draft'; // Warning fix
- $post_data['post_ID'] = $pid;
- $post_data['post_type'] = $post->post_type;
+ $post_data = array();
+ $post_data['action'] = 'draft'; // Warning fix
+ $post_data['post_ID'] = $pid;
+ $post_data['post_type'] = $post->post_type;
$post_data['post_status'] = 'draft';
- $now = current_time('timestamp', 1);
+ $now = current_time( 'timestamp', 1 );
/* 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 ) );
$pid = edit_post( $post_data );
if ( $pid ) {
if ( is_wp_error( $pid ) ) {
- $x = new WP_Ajax_Response( array(
- 'what' => 'meta',
- 'data' => $pid
- ) );
+ $x = new WP_Ajax_Response(
+ array(
+ 'what' => 'meta',
+ 'data' => $pid,
+ )
+ );
$x->send();
}
- if ( !$mid = add_meta( $pid ) )
+ if ( ! $mid = add_meta( $pid ) ) {
wp_die( __( 'Please provide a custom field value.' ) );
+ }
} else {
wp_die( 0 );
}
@@ -1326,45 +1478,57 @@ function wp_ajax_add_meta() {
}
$meta = get_metadata_by_mid( 'post', $mid );
- $pid = (int) $meta->post_id;
+ $pid = (int) $meta->post_id;
$meta = get_object_vars( $meta );
- $x = new WP_Ajax_Response( array(
- 'what' => 'meta',
- 'id' => $mid,
- 'data' => _list_meta_row( $meta, $c ),
- 'position' => 1,
- 'supplemental' => array('postid' => $pid)
- ) );
+ $x = new WP_Ajax_Response(
+ array(
+ 'what' => 'meta',
+ 'id' => $mid,
+ 'data' => _list_meta_row( $meta, $c ),
+ 'position' => 1,
+ 'supplemental' => array( 'postid' => $pid ),
+ )
+ );
} else { // Update?
- $mid = (int) key( $_POST['meta'] );
- $key = wp_unslash( $_POST['meta'][$mid]['key'] );
- $value = wp_unslash( $_POST['meta'][$mid]['value'] );
- if ( '' == trim($key) )
+ $mid = (int) key( $_POST['meta'] );
+ $key = wp_unslash( $_POST['meta'][ $mid ]['key'] );
+ $value = wp_unslash( $_POST['meta'][ $mid ]['value'] );
+ if ( '' == trim( $key ) ) {
wp_die( __( 'Please provide a custom field name.' ) );
- if ( '' == trim($value) )
+ }
+ if ( '' == trim( $value ) ) {
wp_die( __( 'Please provide a custom field value.' ) );
- if ( ! $meta = get_metadata_by_mid( 'post', $mid ) )
+ }
+ if ( ! $meta = get_metadata_by_mid( 'post', $mid ) ) {
wp_die( 0 ); // if meta doesn't exist
+ }
if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) ||
! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) ||
- ! current_user_can( 'edit_post_meta', $meta->post_id, $key ) )
+ ! current_user_can( 'edit_post_meta', $meta->post_id, $key ) ) {
wp_die( -1 );
+ }
if ( $meta->meta_value != $value || $meta->meta_key != $key ) {
- if ( !$u = update_metadata_by_mid( 'post', $mid, $value, $key ) )
+ if ( ! $u = update_metadata_by_mid( 'post', $mid, $value, $key ) ) {
wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
+ }
}
- $x = new WP_Ajax_Response( array(
- 'what' => 'meta',
- 'id' => $mid, 'old_id' => $mid,
- 'data' => _list_meta_row( array(
- 'meta_key' => $key,
- 'meta_value' => $value,
- 'meta_id' => $mid
- ), $c ),
- 'position' => 0,
- 'supplemental' => array('postid' => $meta->post_id)
- ) );
+ $x = new WP_Ajax_Response(
+ array(
+ 'what' => 'meta',
+ 'id' => $mid,
+ 'old_id' => $mid,
+ 'data' => _list_meta_row(
+ array(
+ 'meta_key' => $key,
+ 'meta_value' => $value,
+ 'meta_id' => $mid,
+ ), $c
+ ),
+ 'position' => 0,
+ 'supplemental' => array( 'postid' => $meta->post_id ),
+ )
+ );
}
$x->send();
}
@@ -1382,36 +1546,41 @@ function wp_ajax_add_user( $action ) {
}
check_ajax_referer( $action );
- if ( ! current_user_can('create_users') )
+ if ( ! current_user_can( 'create_users' ) ) {
wp_die( -1 );
+ }
if ( ! $user_id = edit_user() ) {
wp_die( 0 );
} elseif ( is_wp_error( $user_id ) ) {
- $x = new WP_Ajax_Response( array(
- 'what' => 'user',
- 'id' => $user_id
- ) );
+ $x = new WP_Ajax_Response(
+ array(
+ 'what' => 'user',
+ 'id' => $user_id,
+ )
+ );
$x->send();
}
$user_object = get_userdata( $user_id );
- $wp_list_table = _get_list_table('WP_Users_List_Table');
+ $wp_list_table = _get_list_table( 'WP_Users_List_Table' );
$role = current( $user_object->roles );
- $x = new WP_Ajax_Response( array(
- 'what' => 'user',
- 'id' => $user_id,
- 'data' => $wp_list_table->single_row( $user_object, '', $role ),
- 'supplemental' => array(
- 'show-link' => sprintf(
- /* translators: %s: the new user */
- __( 'User %s added' ),
- '
' . $user_object->user_login . ' '
+ $x = new WP_Ajax_Response(
+ array(
+ 'what' => 'user',
+ 'id' => $user_id,
+ 'data' => $wp_list_table->single_row( $user_object, '', $role ),
+ 'supplemental' => array(
+ 'show-link' => sprintf(
+ /* translators: %s: the new user */
+ __( 'User %s added' ),
+ '
' . $user_object->user_login . ' '
+ ),
+ 'role' => $role,
),
- 'role' => $role,
)
- ) );
+ );
$x->send();
}
@@ -1422,26 +1591,29 @@ function wp_ajax_add_user( $action ) {
*/
function wp_ajax_closed_postboxes() {
check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' );
- $closed = isset( $_POST['closed'] ) ? explode( ',', $_POST['closed']) : array();
- $closed = array_filter($closed);
+ $closed = isset( $_POST['closed'] ) ? explode( ',', $_POST['closed'] ) : array();
+ $closed = array_filter( $closed );
- $hidden = isset( $_POST['hidden'] ) ? explode( ',', $_POST['hidden']) : array();
- $hidden = array_filter($hidden);
+ $hidden = isset( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array();
+ $hidden = array_filter( $hidden );
$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
- if ( $page != sanitize_key( $page ) )
+ if ( $page != sanitize_key( $page ) ) {
wp_die( 0 );
+ }
- if ( ! $user = wp_get_current_user() )
+ if ( ! $user = wp_get_current_user() ) {
wp_die( -1 );
+ }
- if ( is_array($closed) )
- update_user_option($user->ID, "closedpostboxes_$page", $closed, true);
+ if ( is_array( $closed ) ) {
+ update_user_option( $user->ID, "closedpostboxes_$page", $closed, true );
+ }
- if ( is_array($hidden) ) {
- $hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu') ); // postboxes that are always shown
- update_user_option($user->ID, "metaboxhidden_$page", $hidden, true);
+ if ( is_array( $hidden ) ) {
+ $hidden = array_diff( $hidden, array( 'submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu' ) ); // postboxes that are always shown
+ update_user_option( $user->ID, "metaboxhidden_$page", $hidden, true );
}
wp_die( 1 );
@@ -1456,11 +1628,13 @@ function wp_ajax_hidden_columns() {
check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' );
$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
- if ( $page != sanitize_key( $page ) )
+ if ( $page != sanitize_key( $page ) ) {
wp_die( 0 );
+ }
- if ( ! $user = wp_get_current_user() )
+ if ( ! $user = wp_get_current_user() ) {
wp_die( -1 );
+ }
$hidden = ! empty( $_POST['hidden'] ) ? explode( ',', $_POST['hidden'] ) : array();
update_user_option( $user->ID, "manage{$page}columnshidden", $hidden, true );
@@ -1476,8 +1650,9 @@ function wp_ajax_hidden_columns() {
function wp_ajax_update_welcome_panel() {
check_ajax_referer( 'welcome-panel-nonce', 'welcomepanelnonce' );
- if ( ! current_user_can( 'edit_theme_options' ) )
+ if ( ! current_user_can( 'edit_theme_options' ) ) {
wp_die( -1 );
+ }
update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 );
@@ -1490,43 +1665,48 @@ function wp_ajax_update_welcome_panel() {
* @since 3.1.0
*/
function wp_ajax_menu_get_metabox() {
- if ( ! current_user_can( 'edit_theme_options' ) )
+ if ( ! current_user_can( 'edit_theme_options' ) ) {
wp_die( -1 );
+ }
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
if ( isset( $_POST['item-type'] ) && 'post_type' == $_POST['item-type'] ) {
- $type = 'posttype';
+ $type = 'posttype';
$callback = 'wp_nav_menu_item_post_type_meta_box';
- $items = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
+ $items = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
} elseif ( isset( $_POST['item-type'] ) && 'taxonomy' == $_POST['item-type'] ) {
- $type = 'taxonomy';
+ $type = 'taxonomy';
$callback = 'wp_nav_menu_item_taxonomy_meta_box';
- $items = (array) get_taxonomies( array( 'show_ui' => true ), 'object' );
+ $items = (array) get_taxonomies( array( 'show_ui' => true ), 'object' );
}
- if ( ! empty( $_POST['item-object'] ) && isset( $items[$_POST['item-object']] ) ) {
+ if ( ! empty( $_POST['item-object'] ) && isset( $items[ $_POST['item-object'] ] ) ) {
$menus_meta_box_object = $items[ $_POST['item-object'] ];
/** This filter is documented in wp-admin/includes/nav-menu.php */
$item = apply_filters( 'nav_menu_meta_box_object', $menus_meta_box_object );
ob_start();
- call_user_func_array($callback, array(
- null,
- array(
- 'id' => 'add-' . $item->name,
- 'title' => $item->labels->name,
- 'callback' => $callback,
- 'args' => $item,
+ call_user_func_array(
+ $callback, array(
+ null,
+ array(
+ 'id' => 'add-' . $item->name,
+ 'title' => $item->labels->name,
+ 'callback' => $callback,
+ 'args' => $item,
+ ),
)
- ));
+ );
$markup = ob_get_clean();
- echo wp_json_encode(array(
- 'replace-id' => $type . '-' . $item->name,
- 'markup' => $markup,
- ));
+ echo wp_json_encode(
+ array(
+ 'replace-id' => $type . '-' . $item->name,
+ 'markup' => $markup,
+ )
+ );
}
wp_die();
@@ -1558,8 +1738,9 @@ function wp_ajax_wp_link_ajax() {
$results = _WP_Editors::wp_link_query( $args );
- if ( ! isset( $results ) )
+ if ( ! isset( $results ) ) {
wp_die( 0 );
+ }
echo wp_json_encode( $results );
echo "\n";
@@ -1573,11 +1754,13 @@ function wp_ajax_wp_link_ajax() {
* @since 3.1.0
*/
function wp_ajax_menu_locations_save() {
- if ( ! current_user_can( 'edit_theme_options' ) )
+ if ( ! current_user_can( 'edit_theme_options' ) ) {
wp_die( -1 );
+ }
check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
- if ( ! isset( $_POST['menu-locations'] ) )
+ if ( ! isset( $_POST['menu-locations'] ) ) {
wp_die( 0 );
+ }
set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) );
wp_die( 1 );
}
@@ -1589,25 +1772,30 @@ function wp_ajax_menu_locations_save() {
*/
function wp_ajax_meta_box_order() {
check_ajax_referer( 'meta-box-order' );
- $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
+ $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
$page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto';
- if ( $page_columns != 'auto' )
+ if ( $page_columns != 'auto' ) {
$page_columns = (int) $page_columns;
+ }
$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
- if ( $page != sanitize_key( $page ) )
+ if ( $page != sanitize_key( $page ) ) {
wp_die( 0 );
+ }
- if ( ! $user = wp_get_current_user() )
+ if ( ! $user = wp_get_current_user() ) {
wp_die( -1 );
+ }
- if ( $order )
- update_user_option($user->ID, "meta-box-order_$page", $order, true);
+ if ( $order ) {
+ update_user_option( $user->ID, "meta-box-order_$page", $order, true );
+ }
- if ( $page_columns )
- update_user_option($user->ID, "screen_layout_$page", $page_columns, true);
+ if ( $page_columns ) {
+ update_user_option( $user->ID, "screen_layout_$page", $page_columns, true );
+ }
wp_die( 1 );
}
@@ -1618,8 +1806,9 @@ function wp_ajax_meta_box_order() {
* @since 3.1.0
*/
function wp_ajax_menu_quick_search() {
- if ( ! current_user_can( 'edit_theme_options' ) )
+ if ( ! current_user_can( 'edit_theme_options' ) ) {
wp_die( -1 );
+ }
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
@@ -1635,7 +1824,7 @@ function wp_ajax_menu_quick_search() {
*/
function wp_ajax_get_permalink() {
check_ajax_referer( 'getpermalink', 'getpermalinknonce' );
- $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
+ $post_id = isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : 0;
wp_die( get_preview_post_link( $post_id ) );
}
@@ -1646,9 +1835,9 @@ function wp_ajax_get_permalink() {
*/
function wp_ajax_sample_permalink() {
check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' );
- $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
- $title = isset($_POST['new_title'])? $_POST['new_title'] : '';
- $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null;
+ $post_id = isset( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : 0;
+ $title = isset( $_POST['new_title'] ) ? $_POST['new_title'] : '';
+ $slug = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null;
wp_die( get_sample_permalink_html( $post_id, $title, $slug ) );
}
@@ -1664,21 +1853,24 @@ function wp_ajax_inline_save() {
check_ajax_referer( 'inlineeditnonce', '_inline_edit' );
- if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) )
+ if ( ! isset( $_POST['post_ID'] ) || ! ( $post_ID = (int) $_POST['post_ID'] ) ) {
wp_die();
+ }
if ( 'page' == $_POST['post_type'] ) {
- if ( ! current_user_can( 'edit_page', $post_ID ) )
+ if ( ! current_user_can( 'edit_page', $post_ID ) ) {
wp_die( __( 'Sorry, you are not allowed to edit this page.' ) );
+ }
} else {
- if ( ! current_user_can( 'edit_post', $post_ID ) )
+ if ( ! current_user_can( 'edit_post', $post_ID ) ) {
wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
+ }
}
if ( $last = wp_check_post_lock( $post_ID ) ) {
- $last_user = get_userdata( $last );
+ $last_user = get_userdata( $last );
$last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
- printf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ), esc_html( $last_user_name ) );
+ printf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ), esc_html( $last_user_name ) );
wp_die();
}
@@ -1687,7 +1879,7 @@ function wp_ajax_inline_save() {
$post = get_post( $post_ID, ARRAY_A );
// Since it's coming from the database.
- $post = wp_slash($post);
+ $post = wp_slash( $post );
$data['content'] = $post['post_content'];
$data['excerpt'] = $post['post_excerpt'];
@@ -1695,8 +1887,9 @@ function wp_ajax_inline_save() {
// Rename.
$data['user_ID'] = get_current_user_id();
- if ( isset($data['post_parent']) )
+ if ( isset( $data['post_parent'] ) ) {
$data['parent_id'] = $data['post_parent'];
+ }
// Status.
if ( isset( $data['keep_private'] ) && 'private' == $data['keep_private'] ) {
@@ -1706,10 +1899,12 @@ function wp_ajax_inline_save() {
$data['post_status'] = $data['_status'];
}
- if ( empty($data['comment_status']) )
+ if ( empty( $data['comment_status'] ) ) {
$data['comment_status'] = 'closed';
- if ( empty($data['ping_status']) )
+ }
+ if ( empty( $data['ping_status'] ) ) {
$data['ping_status'] = 'closed';
+ }
// Exclude terms from taxonomies that are not supposed to appear in Quick Edit.
if ( ! empty( $data['tax_input'] ) ) {
@@ -1725,7 +1920,7 @@ function wp_ajax_inline_save() {
// Hack: wp_unique_post_slug() doesn't work for drafts, so we will fake that our post is published.
if ( ! empty( $data['post_name'] ) && in_array( $post['post_status'], array( 'draft', 'pending' ) ) ) {
$post['post_status'] = 'publish';
- $data['post_name'] = wp_unique_post_slug( $data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent'] );
+ $data['post_name'] = wp_unique_post_slug( $data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent'] );
}
// Update the post.
@@ -1761,9 +1956,10 @@ function wp_ajax_inline_save_tax() {
check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' );
$taxonomy = sanitize_key( $_POST['taxonomy'] );
- $tax = get_taxonomy( $taxonomy );
- if ( ! $tax )
+ $tax = get_taxonomy( $taxonomy );
+ if ( ! $tax ) {
wp_die( 0 );
+ }
if ( ! isset( $_POST['tax_ID'] ) || ! ( $id = (int) $_POST['tax_ID'] ) ) {
wp_die( -1 );
@@ -1775,27 +1971,29 @@ function wp_ajax_inline_save_tax() {
$wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) );
- $tag = get_term( $id, $taxonomy );
+ $tag = get_term( $id, $taxonomy );
$_POST['description'] = $tag->description;
- $updated = wp_update_term($id, $taxonomy, $_POST);
- if ( $updated && !is_wp_error($updated) ) {
+ $updated = wp_update_term( $id, $taxonomy, $_POST );
+ if ( $updated && ! is_wp_error( $updated ) ) {
$tag = get_term( $updated['term_id'], $taxonomy );
- if ( !$tag || is_wp_error( $tag ) ) {
- if ( is_wp_error($tag) && $tag->get_error_message() )
+ if ( ! $tag || is_wp_error( $tag ) ) {
+ if ( is_wp_error( $tag ) && $tag->get_error_message() ) {
wp_die( $tag->get_error_message() );
+ }
wp_die( __( 'Item not updated.' ) );
}
} else {
- if ( is_wp_error($updated) && $updated->get_error_message() )
+ if ( is_wp_error( $updated ) && $updated->get_error_message() ) {
wp_die( $updated->get_error_message() );
+ }
wp_die( __( 'Item not updated.' ) );
}
- $level = 0;
+ $level = 0;
$parent = $tag->parent;
while ( $parent > 0 ) {
$parent_tag = get_term( $parent, $taxonomy );
- $parent = $parent_tag->parent;
+ $parent = $parent_tag->parent;
$level++;
}
$wp_list_table->single_row( $tag, $level );
@@ -1815,14 +2013,15 @@ function wp_ajax_find_posts() {
$post_types = get_post_types( array( 'public' => true ), 'objects' );
unset( $post_types['attachment'] );
- $s = wp_unslash( $_POST['ps'] );
+ $s = wp_unslash( $_POST['ps'] );
$args = array(
- 'post_type' => array_keys( $post_types ),
- 'post_status' => 'any',
+ 'post_type' => array_keys( $post_types ),
+ 'post_status' => 'any',
'posts_per_page' => 50,
);
- if ( '' !== $s )
+ if ( '' !== $s ) {
$args['s'] = $s;
+ }
$posts = get_posts( $args );
@@ -1830,25 +2029,25 @@ function wp_ajax_find_posts() {
wp_send_json_error( __( 'No items found.' ) );
}
- $html = '
'.__('Title').' '.__('Type').' '.__('Date').' '.__('Status').' ';
- $alt = '';
+ $html = '';
@@ -1876,28 +2075,30 @@ function wp_ajax_find_posts() {
function wp_ajax_widgets_order() {
check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
- if ( !current_user_can('edit_theme_options') )
+ if ( ! current_user_can( 'edit_theme_options' ) ) {
wp_die( -1 );
+ }
unset( $_POST['savewidgets'], $_POST['action'] );
// Save widgets order for all sidebars.
- if ( is_array($_POST['sidebars']) ) {
+ if ( is_array( $_POST['sidebars'] ) ) {
$sidebars = array();
foreach ( wp_unslash( $_POST['sidebars'] ) as $key => $val ) {
$sb = array();
- if ( !empty($val) ) {
- $val = explode(',', $val);
+ if ( ! empty( $val ) ) {
+ $val = explode( ',', $val );
foreach ( $val as $k => $v ) {
- if ( strpos($v, 'widget-') === false )
+ if ( strpos( $v, 'widget-' ) === false ) {
continue;
+ }
- $sb[$k] = substr($v, strpos($v, '_') + 1);
+ $sb[ $k ] = substr( $v, strpos( $v, '_' ) + 1 );
}
}
- $sidebars[$key] = $sb;
+ $sidebars[ $key ] = $sb;
}
- wp_set_sidebars_widgets($sidebars);
+ wp_set_sidebars_widgets( $sidebars );
wp_die( 1 );
}
@@ -1918,8 +2119,9 @@ function wp_ajax_save_widget() {
check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
- if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) )
+ if ( ! current_user_can( 'edit_theme_options' ) || ! isset( $_POST['id_base'] ) ) {
wp_die( -1 );
+ }
unset( $_POST['savewidgets'], $_POST['action'] );
@@ -1940,43 +2142,51 @@ function wp_ajax_save_widget() {
/** This action is documented in wp-admin/widgets.php */
do_action( 'sidebar_admin_setup' );
- $id_base = wp_unslash( $_POST['id_base'] );
- $widget_id = wp_unslash( $_POST['widget-id'] );
- $sidebar_id = $_POST['sidebar'];
- $multi_number = !empty($_POST['multi_number']) ? (int) $_POST['multi_number'] : 0;
- $settings = isset($_POST['widget-' . $id_base]) && is_array($_POST['widget-' . $id_base]) ? $_POST['widget-' . $id_base] : false;
- $error = '' . __('An error has occurred. Please reload the page and try again.') . '
';
+ $id_base = wp_unslash( $_POST['id_base'] );
+ $widget_id = wp_unslash( $_POST['widget-id'] );
+ $sidebar_id = $_POST['sidebar'];
+ $multi_number = ! empty( $_POST['multi_number'] ) ? (int) $_POST['multi_number'] : 0;
+ $settings = isset( $_POST[ 'widget-' . $id_base ] ) && is_array( $_POST[ 'widget-' . $id_base ] ) ? $_POST[ 'widget-' . $id_base ] : false;
+ $error = '' . __( 'An error has occurred. Please reload the page and try again.' ) . '
';
$sidebars = wp_get_sidebars_widgets();
- $sidebar = isset($sidebars[$sidebar_id]) ? $sidebars[$sidebar_id] : array();
+ $sidebar = isset( $sidebars[ $sidebar_id ] ) ? $sidebars[ $sidebar_id ] : array();
// Delete.
- if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
+ if ( isset( $_POST['delete_widget'] ) && $_POST['delete_widget'] ) {
- if ( !isset($wp_registered_widgets[$widget_id]) )
+ if ( ! isset( $wp_registered_widgets[ $widget_id ] ) ) {
wp_die( $error );
+ }
- $sidebar = array_diff( $sidebar, array($widget_id) );
- $_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1');
+ $sidebar = array_diff( $sidebar, array( $widget_id ) );
+ $_POST = array(
+ 'sidebar' => $sidebar_id,
+ 'widget-' . $id_base => array(),
+ 'the-widget-id' => $widget_id,
+ 'delete_widget' => '1',
+ );
/** This action is documented in wp-admin/widgets.php */
do_action( 'delete_widget', $widget_id, $sidebar_id, $id_base );
- } elseif ( $settings && preg_match( '/__i__|%i%/', key($settings) ) ) {
- if ( !$multi_number )
+ } elseif ( $settings && preg_match( '/__i__|%i%/', key( $settings ) ) ) {
+ if ( ! $multi_number ) {
wp_die( $error );
+ }
$_POST[ 'widget-' . $id_base ] = array( $multi_number => reset( $settings ) );
- $widget_id = $id_base . '-' . $multi_number;
- $sidebar[] = $widget_id;
+ $widget_id = $id_base . '-' . $multi_number;
+ $sidebar[] = $widget_id;
}
$_POST['widget-id'] = $sidebar;
foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
if ( $name == $id_base ) {
- if ( !is_callable( $control['callback'] ) )
+ if ( ! is_callable( $control['callback'] ) ) {
continue;
+ }
ob_start();
call_user_func_array( $control['callback'], $control['params'] );
@@ -1985,18 +2195,20 @@ function wp_ajax_save_widget() {
}
}
- if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
- $sidebars[$sidebar_id] = $sidebar;
- wp_set_sidebars_widgets($sidebars);
+ if ( isset( $_POST['delete_widget'] ) && $_POST['delete_widget'] ) {
+ $sidebars[ $sidebar_id ] = $sidebar;
+ wp_set_sidebars_widgets( $sidebars );
echo "deleted:$widget_id";
wp_die();
}
- if ( !empty($_POST['add_new']) )
+ if ( ! empty( $_POST['add_new'] ) ) {
wp_die();
+ }
- if ( $form = $wp_registered_widget_controls[$widget_id] )
+ if ( $form = $wp_registered_widget_controls[ $widget_id ] ) {
call_user_func_array( $form['callback'], $form['params'] );
+ }
wp_die();
}
@@ -2036,13 +2248,13 @@ function wp_ajax_delete_inactive_widgets() {
$sidebars_widgets = wp_get_sidebars_widgets();
foreach ( $sidebars_widgets['wp_inactive_widgets'] as $key => $widget_id ) {
- $pieces = explode( '-', $widget_id );
+ $pieces = explode( '-', $widget_id );
$multi_number = array_pop( $pieces );
- $id_base = implode( '-', $pieces );
- $widget = get_option( 'widget_' . $id_base );
- unset( $widget[$multi_number] );
+ $id_base = implode( '-', $pieces );
+ $widget = get_option( 'widget_' . $id_base );
+ unset( $widget[ $multi_number ] );
update_option( 'widget_' . $id_base, $widget );
- unset( $sidebars_widgets['wp_inactive_widgets'][$key] );
+ unset( $sidebars_widgets['wp_inactive_widgets'][ $key ] );
}
wp_set_sidebars_widgets( $sidebars_widgets );
@@ -2064,13 +2276,15 @@ function wp_ajax_upload_attachment() {
*/
if ( ! current_user_can( 'upload_files' ) ) {
- echo wp_json_encode( array(
- 'success' => false,
- 'data' => array(
- 'message' => __( 'Sorry, you are not allowed to upload files.' ),
- 'filename' => $_FILES['async-upload']['name'],
+ echo wp_json_encode(
+ array(
+ 'success' => false,
+ 'data' => array(
+ 'message' => __( 'Sorry, you are not allowed to upload files.' ),
+ 'filename' => $_FILES['async-upload']['name'],
+ ),
)
- ) );
+ );
wp_die();
}
@@ -2078,13 +2292,15 @@ function wp_ajax_upload_attachment() {
if ( isset( $_REQUEST['post_id'] ) ) {
$post_id = $_REQUEST['post_id'];
if ( ! current_user_can( 'edit_post', $post_id ) ) {
- echo wp_json_encode( array(
- 'success' => false,
- 'data' => array(
- 'message' => __( 'Sorry, you are not allowed to attach files to this post.' ),
- 'filename' => $_FILES['async-upload']['name'],
+ echo wp_json_encode(
+ array(
+ 'success' => false,
+ 'data' => array(
+ 'message' => __( 'Sorry, you are not allowed to attach files to this post.' ),
+ 'filename' => $_FILES['async-upload']['name'],
+ ),
)
- ) );
+ );
wp_die();
}
@@ -2098,13 +2314,15 @@ function wp_ajax_upload_attachment() {
if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) {
$wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'] );
if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) {
- echo wp_json_encode( array(
- 'success' => false,
- 'data' => array(
- 'message' => __( 'The uploaded file is not a valid image. Please try again.' ),
- 'filename' => $_FILES['async-upload']['name'],
+ echo wp_json_encode(
+ array(
+ 'success' => false,
+ 'data' => array(
+ 'message' => __( 'The uploaded file is not a valid image. Please try again.' ),
+ 'filename' => $_FILES['async-upload']['name'],
+ ),
)
- ) );
+ );
wp_die();
}
@@ -2113,32 +2331,39 @@ function wp_ajax_upload_attachment() {
$attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data );
if ( is_wp_error( $attachment_id ) ) {
- echo wp_json_encode( array(
- 'success' => false,
- 'data' => array(
- 'message' => $attachment_id->get_error_message(),
- 'filename' => $_FILES['async-upload']['name'],
+ echo wp_json_encode(
+ array(
+ 'success' => false,
+ 'data' => array(
+ 'message' => $attachment_id->get_error_message(),
+ 'filename' => $_FILES['async-upload']['name'],
+ ),
)
- ) );
+ );
wp_die();
}
if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) {
- if ( 'custom-background' === $post_data['context'] )
+ if ( 'custom-background' === $post_data['context'] ) {
update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] );
+ }
- if ( 'custom-header' === $post_data['context'] )
+ if ( 'custom-header' === $post_data['context'] ) {
update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] );
+ }
}
- if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) )
+ if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) ) {
wp_die();
+ }
- echo wp_json_encode( array(
- 'success' => true,
- 'data' => $attachment,
- ) );
+ echo wp_json_encode(
+ array(
+ 'success' => true,
+ 'data' => $attachment,
+ )
+ );
wp_die();
}
@@ -2149,29 +2374,30 @@ function wp_ajax_upload_attachment() {
* @since 3.1.0
*/
function wp_ajax_image_editor() {
- $attachment_id = intval($_POST['postid']);
- if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) )
+ $attachment_id = intval( $_POST['postid'] );
+ if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) ) {
wp_die( -1 );
+ }
check_ajax_referer( "image_editor-$attachment_id" );
include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
$msg = false;
switch ( $_POST['do'] ) {
- case 'save' :
- $msg = wp_save_image($attachment_id);
- $msg = wp_json_encode($msg);
+ case 'save':
+ $msg = wp_save_image( $attachment_id );
+ $msg = wp_json_encode( $msg );
wp_die( $msg );
break;
- case 'scale' :
- $msg = wp_save_image($attachment_id);
+ case 'scale':
+ $msg = wp_save_image( $attachment_id );
break;
- case 'restore' :
- $msg = wp_restore_image($attachment_id);
+ case 'restore':
+ $msg = wp_restore_image( $attachment_id );
break;
}
- wp_image_editor($attachment_id, $msg);
+ wp_image_editor( $attachment_id, $msg );
wp_die();
}
@@ -2184,15 +2410,17 @@ function wp_ajax_set_post_thumbnail() {
$json = ! empty( $_REQUEST['json'] ); // New-style request
$post_ID = intval( $_POST['post_id'] );
- if ( ! current_user_can( 'edit_post', $post_ID ) )
+ if ( ! current_user_can( 'edit_post', $post_ID ) ) {
wp_die( -1 );
+ }
$thumbnail_id = intval( $_POST['thumbnail_id'] );
- if ( $json )
+ if ( $json ) {
check_ajax_referer( "update-post_$post_ID" );
- else
+ } else {
check_ajax_referer( "set_post_thumbnail-$post_ID" );
+ }
if ( $thumbnail_id == '-1' ) {
if ( delete_post_thumbnail( $post_ID ) ) {
@@ -2316,10 +2544,11 @@ function wp_ajax_wp_fullscreen_save_post() {
$post = null;
- if ( $post_id )
+ if ( $post_id ) {
$post = get_post( $post_id );
+ }
- check_ajax_referer('update-post_' . $post_id, '_wpnonce');
+ check_ajax_referer( 'update-post_' . $post_id, '_wpnonce' );
$post_id = edit_post();
@@ -2336,10 +2565,10 @@ function wp_ajax_wp_fullscreen_save_post() {
}
if ( $last_id = get_post_meta( $post_id, '_edit_last', true ) ) {
- $last_user = get_userdata( $last_id );
- $last_edited = sprintf( __('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), $last_date, $last_time );
+ $last_user = get_userdata( $last_id );
+ $last_edited = sprintf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), $last_date, $last_time );
} else {
- $last_edited = sprintf( __('Last edited on %1$s at %2$s'), $last_date, $last_time );
+ $last_edited = sprintf( __( 'Last edited on %1$s at %2$s' ), $last_date, $last_time );
}
wp_send_json_success( array( 'last_edited' => $last_edited ) );
@@ -2351,20 +2580,24 @@ function wp_ajax_wp_fullscreen_save_post() {
* @since 3.1.0
*/
function wp_ajax_wp_remove_post_lock() {
- if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) )
+ if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) {
wp_die( 0 );
+ }
$post_id = (int) $_POST['post_ID'];
- if ( ! $post = get_post( $post_id ) )
+ if ( ! $post = get_post( $post_id ) ) {
wp_die( 0 );
+ }
check_ajax_referer( 'update-post_' . $post_id );
- if ( ! current_user_can( 'edit_post', $post_id ) )
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
wp_die( -1 );
+ }
$active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
- if ( $active_lock[1] != get_current_user_id() )
+ if ( $active_lock[1] != get_current_user_id() ) {
wp_die( 0 );
+ }
/**
* Filters the post lock window duration.
@@ -2386,18 +2619,20 @@ function wp_ajax_wp_remove_post_lock() {
*/
function wp_ajax_dismiss_wp_pointer() {
$pointer = $_POST['pointer'];
- if ( $pointer != sanitize_key( $pointer ) )
+ if ( $pointer != sanitize_key( $pointer ) ) {
wp_die( 0 );
+ }
-// check_ajax_referer( 'dismiss-pointer_' . $pointer );
+ // check_ajax_referer( 'dismiss-pointer_' . $pointer );
$dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) );
- if ( in_array( $pointer, $dismissed ) )
+ if ( in_array( $pointer, $dismissed ) ) {
wp_die( 0 );
+ }
$dismissed[] = $pointer;
- $dismissed = implode( ',', $dismissed );
+ $dismissed = implode( ',', $dismissed );
update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed );
wp_die( 1 );
@@ -2409,23 +2644,29 @@ function wp_ajax_dismiss_wp_pointer() {
* @since 3.5.0
*/
function wp_ajax_get_attachment() {
- if ( ! isset( $_REQUEST['id'] ) )
+ if ( ! isset( $_REQUEST['id'] ) ) {
wp_send_json_error();
+ }
- if ( ! $id = absint( $_REQUEST['id'] ) )
+ if ( ! $id = absint( $_REQUEST['id'] ) ) {
wp_send_json_error();
+ }
- if ( ! $post = get_post( $id ) )
+ if ( ! $post = get_post( $id ) ) {
wp_send_json_error();
+ }
- if ( 'attachment' != $post->post_type )
+ if ( 'attachment' != $post->post_type ) {
wp_send_json_error();
+ }
- if ( ! current_user_can( 'upload_files' ) )
+ if ( ! current_user_can( 'upload_files' ) ) {
wp_send_json_error();
+ }
- if ( ! $attachment = wp_prepare_attachment_for_js( $id ) )
+ if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) {
wp_send_json_error();
+ }
wp_send_json_success( $attachment );
}
@@ -2436,13 +2677,23 @@ function wp_ajax_get_attachment() {
* @since 3.5.0
*/
function wp_ajax_query_attachments() {
- if ( ! current_user_can( 'upload_files' ) )
+ if ( ! current_user_can( 'upload_files' ) ) {
wp_send_json_error();
+ }
$query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array();
- $keys = array(
- 's', 'order', 'orderby', 'posts_per_page', 'paged', 'post_mime_type',
- 'post_parent', 'post__in', 'post__not_in', 'year', 'monthnum'
+ $keys = array(
+ 's',
+ 'order',
+ 'orderby',
+ 'posts_per_page',
+ 'paged',
+ 'post_mime_type',
+ 'post_parent',
+ 'post__in',
+ 'post__not_in',
+ 'year',
+ 'monthnum',
);
foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) {
if ( $t->query_var && isset( $query[ $t->query_var ] ) ) {
@@ -2450,7 +2701,7 @@ function wp_ajax_query_attachments() {
}
}
- $query = array_intersect_key( $query, array_flip( $keys ) );
+ $query = array_intersect_key( $query, array_flip( $keys ) );
$query['post_type'] = 'attachment';
if ( MEDIA_TRASH
&& ! empty( $_REQUEST['query']['post_status'] )
@@ -2460,8 +2711,9 @@ function wp_ajax_query_attachments() {
$query['post_status'] = 'inherit';
}
- if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) )
+ if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) ) {
$query['post_status'] .= ',private';
+ }
// Filter query clauses to include filenames.
if ( isset( $query['s'] ) ) {
@@ -2493,37 +2745,46 @@ function wp_ajax_query_attachments() {
* @since 3.5.0
*/
function wp_ajax_save_attachment() {
- if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) )
+ if ( ! isset( $_REQUEST['id'] ) || ! isset( $_REQUEST['changes'] ) ) {
wp_send_json_error();
+ }
- if ( ! $id = absint( $_REQUEST['id'] ) )
+ if ( ! $id = absint( $_REQUEST['id'] ) ) {
wp_send_json_error();
+ }
check_ajax_referer( 'update-post_' . $id, 'nonce' );
- if ( ! current_user_can( 'edit_post', $id ) )
+ if ( ! current_user_can( 'edit_post', $id ) ) {
wp_send_json_error();
+ }
$changes = $_REQUEST['changes'];
$post = get_post( $id, ARRAY_A );
- if ( 'attachment' != $post['post_type'] )
+ if ( 'attachment' != $post['post_type'] ) {
wp_send_json_error();
+ }
- if ( isset( $changes['parent'] ) )
+ if ( isset( $changes['parent'] ) ) {
$post['post_parent'] = $changes['parent'];
+ }
- if ( isset( $changes['title'] ) )
+ if ( isset( $changes['title'] ) ) {
$post['post_title'] = $changes['title'];
+ }
- if ( isset( $changes['caption'] ) )
+ if ( isset( $changes['caption'] ) ) {
$post['post_excerpt'] = $changes['caption'];
+ }
- if ( isset( $changes['description'] ) )
+ if ( isset( $changes['description'] ) ) {
$post['post_content'] = $changes['description'];
+ }
- if ( MEDIA_TRASH && isset( $changes['status'] ) )
+ if ( MEDIA_TRASH && isset( $changes['status'] ) ) {
$post['post_status'] = $changes['status'];
+ }
if ( isset( $changes['alt'] ) ) {
$alt = wp_unslash( $changes['alt'] );
@@ -2542,7 +2803,7 @@ function wp_ajax_save_attachment() {
}
foreach ( wp_get_attachment_id3_keys( (object) $post, 'edit' ) as $key => $label ) {
if ( isset( $changes[ $key ] ) ) {
- $changed = true;
+ $changed = true;
$id3data[ $key ] = sanitize_text_field( wp_unslash( $changes[ $key ] ) );
}
}
@@ -2567,25 +2828,30 @@ function wp_ajax_save_attachment() {
* @since 3.5.0
*/
function wp_ajax_save_attachment_compat() {
- if ( ! isset( $_REQUEST['id'] ) )
+ if ( ! isset( $_REQUEST['id'] ) ) {
wp_send_json_error();
+ }
- if ( ! $id = absint( $_REQUEST['id'] ) )
+ if ( ! $id = absint( $_REQUEST['id'] ) ) {
wp_send_json_error();
+ }
- if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) )
+ if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) ) {
wp_send_json_error();
+ }
$attachment_data = $_REQUEST['attachments'][ $id ];
check_ajax_referer( 'update-post_' . $id, 'nonce' );
- if ( ! current_user_can( 'edit_post', $id ) )
+ if ( ! current_user_can( 'edit_post', $id ) ) {
wp_send_json_error();
+ }
$post = get_post( $id, ARRAY_A );
- if ( 'attachment' != $post['post_type'] )
+ if ( 'attachment' != $post['post_type'] ) {
wp_send_json_error();
+ }
/** This filter is documented in wp-admin/includes/media.php */
$post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data );
@@ -2598,12 +2864,14 @@ function wp_ajax_save_attachment_compat() {
wp_update_post( $post );
foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) {
- if ( isset( $attachment_data[ $taxonomy ] ) )
+ if ( isset( $attachment_data[ $taxonomy ] ) ) {
wp_set_object_terms( $id, array_map( 'trim', preg_split( '/,+/', $attachment_data[ $taxonomy ] ) ), $taxonomy, false );
+ }
}
- if ( ! $attachment = wp_prepare_attachment_for_js( $id ) )
+ if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) {
wp_send_json_error();
+ }
wp_send_json_success( $attachment );
}
@@ -2614,31 +2882,43 @@ function wp_ajax_save_attachment_compat() {
* @since 3.5.0
*/
function wp_ajax_save_attachment_order() {
- if ( ! isset( $_REQUEST['post_id'] ) )
+ if ( ! isset( $_REQUEST['post_id'] ) ) {
wp_send_json_error();
+ }
- if ( ! $post_id = absint( $_REQUEST['post_id'] ) )
+ if ( ! $post_id = absint( $_REQUEST['post_id'] ) ) {
wp_send_json_error();
+ }
- if ( empty( $_REQUEST['attachments'] ) )
+ if ( empty( $_REQUEST['attachments'] ) ) {
wp_send_json_error();
+ }
check_ajax_referer( 'update-post_' . $post_id, 'nonce' );
$attachments = $_REQUEST['attachments'];
- if ( ! current_user_can( 'edit_post', $post_id ) )
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
wp_send_json_error();
+ }
foreach ( $attachments as $attachment_id => $menu_order ) {
- if ( ! current_user_can( 'edit_post', $attachment_id ) )
+ if ( ! current_user_can( 'edit_post', $attachment_id ) ) {
continue;
- if ( ! $attachment = get_post( $attachment_id ) )
+ }
+ if ( ! $attachment = get_post( $attachment_id ) ) {
continue;
- if ( 'attachment' != $attachment->post_type )
+ }
+ if ( 'attachment' != $attachment->post_type ) {
continue;
+ }
- wp_update_post( array( 'ID' => $attachment_id, 'menu_order' => $menu_order ) );
+ wp_update_post(
+ array(
+ 'ID' => $attachment_id,
+ 'menu_order' => $menu_order,
+ )
+ );
}
wp_send_json_success();
@@ -2660,28 +2940,35 @@ function wp_ajax_send_attachment_to_editor() {
$id = intval( $attachment['id'] );
- if ( ! $post = get_post( $id ) )
+ if ( ! $post = get_post( $id ) ) {
wp_send_json_error();
+ }
- if ( 'attachment' != $post->post_type )
+ if ( 'attachment' != $post->post_type ) {
wp_send_json_error();
+ }
if ( current_user_can( 'edit_post', $id ) ) {
// If this attachment is unattached, attach it. Primarily a back compat thing.
if ( 0 == $post->post_parent && $insert_into_post_id = intval( $_POST['post_id'] ) ) {
- wp_update_post( array( 'ID' => $id, 'post_parent' => $insert_into_post_id ) );
+ wp_update_post(
+ array(
+ 'ID' => $id,
+ 'post_parent' => $insert_into_post_id,
+ )
+ );
}
}
$url = empty( $attachment['url'] ) ? '' : $attachment['url'];
- $rel = ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url );
+ $rel = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $id ) == $url );
remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' );
if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) {
$align = isset( $attachment['align'] ) ? $attachment['align'] : 'none';
- $size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
- $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
+ $size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
+ $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
// No whitespace-only captions.
$caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : '';
@@ -2690,12 +2977,12 @@ function wp_ajax_send_attachment_to_editor() {
}
$title = ''; // We no longer insert title tags into tags, as they are redundant.
- $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt );
- } elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post ) ) {
+ $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt );
+ } elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post ) ) {
$html = stripslashes_deep( $_POST['html'] );
} else {
$html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
- $rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized
+ $rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized
if ( ! empty( $url ) ) {
$html = '' . $html . ' ';
@@ -2728,22 +3015,26 @@ function wp_ajax_send_link_to_editor() {
check_ajax_referer( 'media-send-to-editor', 'nonce' );
- if ( ! $src = wp_unslash( $_POST['src'] ) )
+ if ( ! $src = wp_unslash( $_POST['src'] ) ) {
wp_send_json_error();
+ }
- if ( ! strpos( $src, '://' ) )
+ if ( ! strpos( $src, '://' ) ) {
$src = 'http://' . $src;
+ }
- if ( ! $src = esc_url_raw( $src ) )
+ if ( ! $src = esc_url_raw( $src ) ) {
wp_send_json_error();
+ }
- if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) )
+ if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) ) {
$link_text = wp_basename( $src );
+ }
$post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 );
// Ping WordPress for an embed.
- $check_embed = $wp_embed->run_shortcode( '[embed]'. $src .'[/embed]' );
+ $check_embed = $wp_embed->run_shortcode( '[embed]' . $src . '[/embed]' );
// Fallback that WordPress creates when no oEmbed was found.
$fallback = $wp_embed->maybe_make_link( $src );
@@ -2760,8 +3051,9 @@ function wp_ajax_send_link_to_editor() {
// Figure out what filter to run:
$type = 'file';
if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) )
- && ( 'audio' == $ext_type || 'video' == $ext_type ) )
+ && ( 'audio' == $ext_type || 'video' == $ext_type ) ) {
$type = $ext_type;
+ }
/** This filter is documented in wp-admin/includes/media.php */
$html = apply_filters( "{$type}_send_to_editor_url", $html, $src, $link_text );
@@ -2781,12 +3073,12 @@ function wp_ajax_heartbeat() {
wp_send_json_error();
}
- $response = $data = array();
+ $response = $data = array();
$nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' );
// screen_id is the same as $current_screen->id and the JS global 'pagenow'.
if ( ! empty( $_POST['screen_id'] ) ) {
- $screen_id = sanitize_key($_POST['screen_id']);
+ $screen_id = sanitize_key( $_POST['screen_id'] );
} else {
$screen_id = 'front';
}
@@ -2854,15 +3146,18 @@ function wp_ajax_heartbeat() {
function wp_ajax_get_revision_diffs() {
require ABSPATH . 'wp-admin/includes/revision.php';
- if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) )
+ if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) ) {
wp_send_json_error();
+ }
- if ( ! current_user_can( 'edit_post', $post->ID ) )
+ if ( ! current_user_can( 'edit_post', $post->ID ) ) {
wp_send_json_error();
+ }
// Really just pre-loading the cache here.
- if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) )
+ if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) ) {
wp_send_json_error();
+ }
$return = array();
@set_time_limit( 0 );
@@ -2871,7 +3166,7 @@ function wp_ajax_get_revision_diffs() {
list( $compare_from, $compare_to ) = explode( ':', $compare_key ); // from:to
$return[] = array(
- 'id' => $compare_key,
+ 'id' => $compare_key,
'fields' => wp_get_revision_ui_diff( $post, $compare_from, $compare_to ),
);
}
@@ -2900,10 +3195,12 @@ function wp_ajax_save_user_color_scheme() {
$previous_color_scheme = get_user_meta( get_current_user_id(), 'admin_color', true );
update_user_meta( get_current_user_id(), 'admin_color', $color_scheme );
- wp_send_json_success( array(
- 'previousScheme' => 'admin-color-' . $previous_color_scheme,
- 'currentScheme' => 'admin-color-' . $color_scheme
- ) );
+ wp_send_json_success(
+ array(
+ 'previousScheme' => 'admin-color-' . $previous_color_scheme,
+ 'currentScheme' => 'admin-color-' . $color_scheme,
+ )
+ );
}
/**
@@ -2921,10 +3218,12 @@ function wp_ajax_query_themes() {
wp_send_json_error();
}
- $args = wp_parse_args( wp_unslash( $_REQUEST['request'] ), array(
- 'per_page' => 20,
- 'fields' => $theme_field_defaults
- ) );
+ $args = wp_parse_args(
+ wp_unslash( $_REQUEST['request'] ), array(
+ 'per_page' => 20,
+ 'fields' => $theme_field_defaults,
+ )
+ );
if ( isset( $args['browse'] ) && 'favorites' === $args['browse'] && ! isset( $args['user'] ) ) {
$user = get_user_option( 'wporg_favorites' );
@@ -2946,38 +3245,53 @@ function wp_ajax_query_themes() {
$update_php = network_admin_url( 'update.php?action=install-theme' );
foreach ( $api->themes as &$theme ) {
- $theme->install_url = add_query_arg( array(
- 'theme' => $theme->slug,
- '_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug )
- ), $update_php );
+ $theme->install_url = add_query_arg(
+ array(
+ 'theme' => $theme->slug,
+ '_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ),
+ ), $update_php
+ );
if ( current_user_can( 'switch_themes' ) ) {
if ( is_multisite() ) {
- $theme->activate_url = add_query_arg( array(
- 'action' => 'enable',
- '_wpnonce' => wp_create_nonce( 'enable-theme_' . $theme->slug ),
- 'theme' => $theme->slug,
- ), network_admin_url( 'themes.php' ) );
+ $theme->activate_url = add_query_arg(
+ array(
+ 'action' => 'enable',
+ '_wpnonce' => wp_create_nonce( 'enable-theme_' . $theme->slug ),
+ 'theme' => $theme->slug,
+ ), network_admin_url( 'themes.php' )
+ );
} else {
- $theme->activate_url = add_query_arg( array(
- 'action' => 'activate',
- '_wpnonce' => wp_create_nonce( 'switch-theme_' . $theme->slug ),
- 'stylesheet' => $theme->slug,
- ), admin_url( 'themes.php' ) );
+ $theme->activate_url = add_query_arg(
+ array(
+ 'action' => 'activate',
+ '_wpnonce' => wp_create_nonce( 'switch-theme_' . $theme->slug ),
+ 'stylesheet' => $theme->slug,
+ ), admin_url( 'themes.php' )
+ );
}
}
if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
- $theme->customize_url = add_query_arg( array(
- 'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ),
- ), wp_customize_url( $theme->slug ) );
+ $theme->customize_url = add_query_arg(
+ array(
+ 'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ),
+ ), wp_customize_url( $theme->slug )
+ );
}
$theme->name = wp_kses( $theme->name, $themes_allowedtags );
$theme->author = wp_kses( $theme->author, $themes_allowedtags );
$theme->version = wp_kses( $theme->version, $themes_allowedtags );
$theme->description = wp_kses( $theme->description, $themes_allowedtags );
- $theme->stars = wp_star_rating( array( 'rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings, 'echo' => false ) );
+ $theme->stars = wp_star_rating(
+ array(
+ 'rating' => $theme->rating,
+ 'type' => 'percent',
+ 'number' => $theme->num_ratings,
+ 'echo' => false,
+ )
+ );
$theme->num_ratings = number_format_i18n( $theme->num_ratings );
$theme->preview_url = set_url_scheme( $theme->preview_url );
}
@@ -3001,7 +3315,7 @@ function wp_ajax_parse_embed() {
if ( empty( $_POST['shortcode'] ) ) {
wp_send_json_error();
}
- $post_id = isset( $_POST[ 'post_ID' ] ) ? intval( $_POST[ 'post_ID' ] ) : 0;
+ $post_id = isset( $_POST['post_ID'] ) ? intval( $_POST['post_ID'] ) : 0;
if ( $post_id > 0 ) {
$post = get_post( $post_id );
if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
@@ -3024,7 +3338,7 @@ function wp_ajax_parse_embed() {
$url = '';
}
- $parsed = false;
+ $parsed = false;
$wp_embed->return_false_on_fail = true;
if ( 0 === $post_id ) {
@@ -3040,7 +3354,7 @@ function wp_ajax_parse_embed() {
// Admin is ssl and the user pasted non-ssl URL.
// Check if the provider supports ssl embeds and use that for the preview.
$ssl_shortcode = preg_replace( '%^(\\[embed[^\\]]*\\])http://%i', '$1https://', $shortcode );
- $parsed = $wp_embed->run_shortcode( $ssl_shortcode );
+ $parsed = $wp_embed->run_shortcode( $ssl_shortcode );
if ( ! $parsed ) {
$no_ssl_support = true;
@@ -3061,14 +3375,16 @@ function wp_ajax_parse_embed() {
}
if ( ! $parsed ) {
- wp_send_json_error( array(
- 'type' => 'not-embeddable',
- 'message' => sprintf( __( '%s failed to embed.' ), '' . esc_html( $url ) . '
' ),
- ) );
+ wp_send_json_error(
+ array(
+ 'type' => 'not-embeddable',
+ 'message' => sprintf( __( '%s failed to embed.' ), '' . esc_html( $url ) . '
' ),
+ )
+ );
}
if ( has_shortcode( $parsed, 'audio' ) || has_shortcode( $parsed, 'video' ) ) {
- $styles = '';
+ $styles = '';
$mce_styles = wpview_media_sandbox_styles();
foreach ( $mce_styles as $style ) {
$styles .= sprintf( ' ', $style );
@@ -3090,15 +3406,17 @@ function wp_ajax_parse_embed() {
if ( ! empty( $no_ssl_support ) || ( is_ssl() && ( preg_match( '%<(iframe|script|embed) [^>]*src="http://%', $parsed ) ||
preg_match( '% ]*href="http://%', $parsed ) ) ) ) {
// Admin is ssl and the embed is not. Iframes, scripts, and other "active content" will be blocked.
- wp_send_json_error( array(
- 'type' => 'not-ssl',
- 'message' => __( 'This preview is unavailable in the editor.' ),
- ) );
+ wp_send_json_error(
+ array(
+ 'type' => 'not-ssl',
+ 'message' => __( 'This preview is unavailable in the editor.' ),
+ )
+ );
}
$return = array(
'body' => $parsed,
- 'attr' => $wp_embed->last_attr
+ 'attr' => $wp_embed->last_attr,
);
if ( strpos( $parsed, 'class="wp-embedded-content' ) ) {
@@ -3108,7 +3426,7 @@ function wp_ajax_parse_embed() {
$script_src = includes_url( 'js/wp-embed.min.js' );
}
- $return['head'] = '';
+ $return['head'] = '';
$return['sandbox'] = true;
}
@@ -3143,16 +3461,18 @@ function wp_ajax_parse_media_shortcode() {
setup_postdata( $post );
}
- $parsed = do_shortcode( $shortcode );
+ $parsed = do_shortcode( $shortcode );
if ( empty( $parsed ) ) {
- wp_send_json_error( array(
- 'type' => 'no-items',
- 'message' => __( 'No items found.' ),
- ) );
+ wp_send_json_error(
+ array(
+ 'type' => 'no-items',
+ 'message' => __( 'No items found.' ),
+ )
+ );
}
- $head = '';
+ $head = '';
$styles = wpview_media_sandbox_styles();
foreach ( $styles as $style ) {
@@ -3175,10 +3495,12 @@ function wp_ajax_parse_media_shortcode() {
wp_print_scripts( array( 'mediaelement-vimeo', 'wp-mediaelement' ) );
}
- wp_send_json_success( array(
- 'head' => $head,
- 'body' => ob_get_clean()
- ) );
+ wp_send_json_success(
+ array(
+ 'head' => $head,
+ 'body' => ob_get_clean(),
+ )
+ );
}
/**
@@ -3197,9 +3519,11 @@ function wp_ajax_destroy_sessions() {
}
if ( ! $user ) {
- wp_send_json_error( array(
- 'message' => __( 'Could not log out user sessions. Please try again.' ),
- ) );
+ wp_send_json_error(
+ array(
+ 'message' => __( 'Could not log out user sessions. Please try again.' ),
+ )
+ );
}
$sessions = WP_Session_Tokens::get_instance( $user->ID );
@@ -3268,7 +3592,6 @@ function wp_ajax_crop_image() {
break;
default:
-
/**
* Fires before a cropped image is saved.
*
@@ -3300,7 +3623,7 @@ function wp_ajax_crop_image() {
);
$attachment_id = wp_insert_attachment( $object, $cropped );
- $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped );
+ $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped );
/**
* Filters the cropped image attachment metadata.
@@ -3371,11 +3694,13 @@ function wp_ajax_install_theme() {
check_ajax_referer( 'updates' );
if ( empty( $_POST['slug'] ) ) {
- wp_send_json_error( array(
- 'slug' => '',
- 'errorCode' => 'no_theme_specified',
- 'errorMessage' => __( 'No theme specified.' ),
- ) );
+ wp_send_json_error(
+ array(
+ 'slug' => '',
+ 'errorCode' => 'no_theme_specified',
+ 'errorMessage' => __( 'No theme specified.' ),
+ )
+ );
}
$slug = sanitize_key( wp_unslash( $_POST['slug'] ) );
@@ -3393,10 +3718,12 @@ function wp_ajax_install_theme() {
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
include_once( ABSPATH . 'wp-admin/includes/theme.php' );
- $api = themes_api( 'theme_information', array(
- 'slug' => $slug,
- 'fields' => array( 'sections' => false ),
- ) );
+ $api = themes_api(
+ 'theme_information', array(
+ 'slug' => $slug,
+ 'fields' => array( 'sections' => false ),
+ )
+ );
if ( is_wp_error( $api ) ) {
$status['errorMessage'] = $api->get_error_message();
@@ -3440,24 +3767,30 @@ function wp_ajax_install_theme() {
if ( current_user_can( 'switch_themes' ) ) {
if ( is_multisite() ) {
- $status['activateUrl'] = add_query_arg( array(
- 'action' => 'enable',
- '_wpnonce' => wp_create_nonce( 'enable-theme_' . $slug ),
- 'theme' => $slug,
- ), network_admin_url( 'themes.php' ) );
+ $status['activateUrl'] = add_query_arg(
+ array(
+ 'action' => 'enable',
+ '_wpnonce' => wp_create_nonce( 'enable-theme_' . $slug ),
+ 'theme' => $slug,
+ ), network_admin_url( 'themes.php' )
+ );
} else {
- $status['activateUrl'] = add_query_arg( array(
- 'action' => 'activate',
- '_wpnonce' => wp_create_nonce( 'switch-theme_' . $slug ),
- 'stylesheet' => $slug,
- ), admin_url( 'themes.php' ) );
+ $status['activateUrl'] = add_query_arg(
+ array(
+ 'action' => 'activate',
+ '_wpnonce' => wp_create_nonce( 'switch-theme_' . $slug ),
+ 'stylesheet' => $slug,
+ ), admin_url( 'themes.php' )
+ );
}
}
if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
- $status['customizeUrl'] = add_query_arg( array(
- 'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ),
- ), wp_customize_url( $slug ) );
+ $status['customizeUrl'] = add_query_arg(
+ array(
+ 'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ),
+ ), wp_customize_url( $slug )
+ );
}
/*
@@ -3480,11 +3813,13 @@ function wp_ajax_update_theme() {
check_ajax_referer( 'updates' );
if ( empty( $_POST['slug'] ) ) {
- wp_send_json_error( array(
- 'slug' => '',
- 'errorCode' => 'no_theme_specified',
- 'errorMessage' => __( 'No theme specified.' ),
- ) );
+ wp_send_json_error(
+ array(
+ 'slug' => '',
+ 'errorCode' => 'no_theme_specified',
+ 'errorMessage' => __( 'No theme specified.' ),
+ )
+ );
}
$stylesheet = preg_replace( '/[^A-z0-9_\-]/', '', wp_unslash( $_POST['slug'] ) );
@@ -3573,11 +3908,13 @@ function wp_ajax_delete_theme() {
check_ajax_referer( 'updates' );
if ( empty( $_POST['slug'] ) ) {
- wp_send_json_error( array(
- 'slug' => '',
- 'errorCode' => 'no_theme_specified',
- 'errorMessage' => __( 'No theme specified.' ),
- ) );
+ wp_send_json_error(
+ array(
+ 'slug' => '',
+ 'errorCode' => 'no_theme_specified',
+ 'errorMessage' => __( 'No theme specified.' ),
+ )
+ );
}
$stylesheet = preg_replace( '/[^A-z0-9_\-]/', '', wp_unslash( $_POST['slug'] ) );
@@ -3643,11 +3980,13 @@ function wp_ajax_install_plugin() {
check_ajax_referer( 'updates' );
if ( empty( $_POST['slug'] ) ) {
- wp_send_json_error( array(
- 'slug' => '',
- 'errorCode' => 'no_plugin_specified',
- 'errorMessage' => __( 'No plugin specified.' ),
- ) );
+ wp_send_json_error(
+ array(
+ 'slug' => '',
+ 'errorCode' => 'no_plugin_specified',
+ 'errorMessage' => __( 'No plugin specified.' ),
+ )
+ );
}
$status = array(
@@ -3663,12 +4002,14 @@ function wp_ajax_install_plugin() {
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
- $api = plugins_api( 'plugin_information', array(
- 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ),
- 'fields' => array(
- 'sections' => false,
- ),
- ) );
+ $api = plugins_api(
+ 'plugin_information', array(
+ 'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ),
+ 'fields' => array(
+ 'sections' => false,
+ ),
+ )
+ );
if ( is_wp_error( $api ) ) {
$status['errorMessage'] = $api->get_error_message();
@@ -3711,17 +4052,19 @@ function wp_ajax_install_plugin() {
}
$install_status = install_plugin_install_status( $api );
- $pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : '';
+ $pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : '';
// If installation request is coming from import page, do not return network activation link.
$plugins_url = ( 'import' === $pagenow ) ? admin_url( 'plugins.php' ) : network_admin_url( 'plugins.php' );
if ( current_user_can( 'activate_plugin', $install_status['file'] ) && is_plugin_inactive( $install_status['file'] ) ) {
- $status['activateUrl'] = add_query_arg( array(
- '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $install_status['file'] ),
- 'action' => 'activate',
- 'plugin' => $install_status['file'],
- ), $plugins_url );
+ $status['activateUrl'] = add_query_arg(
+ array(
+ '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $install_status['file'] ),
+ 'action' => 'activate',
+ 'plugin' => $install_status['file'],
+ ), $plugins_url
+ );
}
if ( is_multisite() && current_user_can( 'manage_network_plugins' ) && 'import' !== $pagenow ) {
@@ -3744,11 +4087,13 @@ function wp_ajax_update_plugin() {
check_ajax_referer( 'updates' );
if ( empty( $_POST['plugin'] ) || empty( $_POST['slug'] ) ) {
- wp_send_json_error( array(
- 'slug' => '',
- 'errorCode' => 'no_plugin_specified',
- 'errorMessage' => __( 'No plugin specified.' ),
- ) );
+ wp_send_json_error(
+ array(
+ 'slug' => '',
+ 'errorCode' => 'no_plugin_specified',
+ 'errorMessage' => __( 'No plugin specified.' ),
+ )
+ );
}
$plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) );
@@ -3849,11 +4194,13 @@ function wp_ajax_delete_plugin() {
check_ajax_referer( 'updates' );
if ( empty( $_POST['slug'] ) || empty( $_POST['plugin'] ) ) {
- wp_send_json_error( array(
- 'slug' => '',
- 'errorCode' => 'no_plugin_specified',
- 'errorMessage' => __( 'No plugin specified.' ),
- ) );
+ wp_send_json_error(
+ array(
+ 'slug' => '',
+ 'errorCode' => 'no_plugin_specified',
+ 'errorMessage' => __( 'No plugin specified.' ),
+ )
+ );
}
$plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) );
@@ -3925,9 +4272,11 @@ function wp_ajax_search_plugins() {
}
/** @var WP_Plugins_List_Table $wp_list_table */
- $wp_list_table = _get_list_table( 'WP_Plugins_List_Table', array(
- 'screen' => get_current_screen(),
- ) );
+ $wp_list_table = _get_list_table(
+ 'WP_Plugins_List_Table', array(
+ 'screen' => get_current_screen(),
+ )
+ );
$status = array();
@@ -3937,10 +4286,14 @@ function wp_ajax_search_plugins() {
}
// Set the correct requester, so pagination works.
- $_SERVER['REQUEST_URI'] = add_query_arg( array_diff_key( $_POST, array(
- '_ajax_nonce' => null,
- 'action' => null,
- ) ), network_admin_url( 'plugins.php', 'relative' ) );
+ $_SERVER['REQUEST_URI'] = add_query_arg(
+ array_diff_key(
+ $_POST, array(
+ '_ajax_nonce' => null,
+ 'action' => null,
+ )
+ ), network_admin_url( 'plugins.php', 'relative' )
+ );
$GLOBALS['s'] = wp_unslash( $_POST['s'] );
@@ -3968,9 +4321,11 @@ function wp_ajax_search_install_plugins() {
}
/** @var WP_Plugin_Install_List_Table $wp_list_table */
- $wp_list_table = _get_list_table( 'WP_Plugin_Install_List_Table', array(
- 'screen' => get_current_screen(),
- ) );
+ $wp_list_table = _get_list_table(
+ 'WP_Plugin_Install_List_Table', array(
+ 'screen' => get_current_screen(),
+ )
+ );
$status = array();
@@ -3980,10 +4335,14 @@ function wp_ajax_search_install_plugins() {
}
// Set the correct requester, so pagination works.
- $_SERVER['REQUEST_URI'] = add_query_arg( array_diff_key( $_POST, array(
- '_ajax_nonce' => null,
- 'action' => null,
- ) ), network_admin_url( 'plugin-install.php', 'relative' ) );
+ $_SERVER['REQUEST_URI'] = add_query_arg(
+ array_diff_key(
+ $_POST, array(
+ '_ajax_nonce' => null,
+ 'action' => null,
+ )
+ ), network_admin_url( 'plugin-install.php', 'relative' )
+ );
$wp_list_table->prepare_items();
@@ -4004,16 +4363,20 @@ function wp_ajax_search_install_plugins() {
function wp_ajax_edit_theme_plugin_file() {
$r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) ); // Validation of args is done in wp_edit_theme_plugin_file().
if ( is_wp_error( $r ) ) {
- wp_send_json_error( array_merge(
- array(
- 'code' => $r->get_error_code(),
- 'message' => $r->get_error_message(),
- ),
- (array) $r->get_error_data()
- ) );
+ wp_send_json_error(
+ array_merge(
+ array(
+ 'code' => $r->get_error_code(),
+ 'message' => $r->get_error_message(),
+ ),
+ (array) $r->get_error_data()
+ )
+ );
} else {
- wp_send_json_success( array(
- 'message' => __( 'File edited successfully.' ),
- ) );
+ wp_send_json_success(
+ array(
+ 'message' => __( 'File edited successfully.' ),
+ )
+ );
}
}
diff --git a/wp-admin/includes/bookmark.php b/wp-admin/includes/bookmark.php
index 0f7365ee24..285d716c2a 100644
--- a/wp-admin/includes/bookmark.php
+++ b/wp-admin/includes/bookmark.php
@@ -34,15 +34,16 @@ function edit_link( $link_id = 0 ) {
);
}
- $_POST['link_url'] = esc_html( $_POST['link_url'] );
- $_POST['link_url'] = esc_url($_POST['link_url']);
- $_POST['link_name'] = esc_html( $_POST['link_name'] );
+ $_POST['link_url'] = esc_html( $_POST['link_url'] );
+ $_POST['link_url'] = esc_url( $_POST['link_url'] );
+ $_POST['link_name'] = esc_html( $_POST['link_name'] );
$_POST['link_image'] = esc_html( $_POST['link_image'] );
- $_POST['link_rss'] = esc_url($_POST['link_rss']);
- if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] )
+ $_POST['link_rss'] = esc_url( $_POST['link_rss'] );
+ if ( ! isset( $_POST['link_visible'] ) || 'N' != $_POST['link_visible'] ) {
$_POST['link_visible'] = 'Y';
+ }
- if ( !empty( $link_id ) ) {
+ if ( ! empty( $link_id ) ) {
$_POST['link_id'] = $link_id;
return wp_update_link( $_POST );
} else {
@@ -59,15 +60,17 @@ function edit_link( $link_id = 0 ) {
*/
function get_default_link_to_edit() {
$link = new stdClass;
- if ( isset( $_GET['linkurl'] ) )
+ if ( isset( $_GET['linkurl'] ) ) {
$link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) );
- else
+ } else {
$link->link_url = '';
+ }
- if ( isset( $_GET['name'] ) )
+ if ( isset( $_GET['name'] ) ) {
$link->link_name = esc_attr( wp_unslash( $_GET['name'] ) );
- else
+ } else {
$link->link_name = '';
+ }
$link->link_visible = 'Y';
@@ -122,7 +125,7 @@ function wp_delete_link( $link_id ) {
* @return array The requested link's categories
*/
function wp_get_link_cats( $link_id = 0 ) {
- $cats = wp_get_object_terms( $link_id, 'link_category', array('fields' => 'ids') );
+ $cats = wp_get_object_terms( $link_id, 'link_category', array( 'fields' => 'ids' ) );
return array_unique( $cats );
}
@@ -152,10 +155,15 @@ function get_link_to_edit( $link ) {
function wp_insert_link( $linkdata, $wp_error = false ) {
global $wpdb;
- $defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );
+ $defaults = array(
+ 'link_id' => 0,
+ 'link_name' => '',
+ 'link_url' => '',
+ 'link_rating' => 0,
+ );
$args = wp_parse_args( $linkdata, $defaults );
- $r = wp_unslash( sanitize_bookmark( $args, 'db' ) );
+ $r = wp_unslash( sanitize_bookmark( $args, 'db' ) );
$link_id = $r['link_id'];
$link_name = $r['link_name'];
@@ -249,8 +257,9 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
*/
function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
// If $link_categories isn't already an array, make it one:
- if ( !is_array( $link_categories ) || 0 == count( $link_categories ) )
+ if ( ! is_array( $link_categories ) || 0 == count( $link_categories ) ) {
$link_categories = array( get_option( 'default_link_category' ) );
+ }
$link_categories = array_map( 'intval', $link_categories );
$link_categories = array_unique( $link_categories );
@@ -277,13 +286,14 @@ function wp_update_link( $linkdata ) {
$link = wp_slash( $link );
// Passed link category list overwrites existing category list if not empty.
- if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] ) && 0 != count( $linkdata['link_category'] ) )
+ if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] ) && 0 != count( $linkdata['link_category'] ) ) {
$link_cats = $linkdata['link_category'];
- else
+ } else {
$link_cats = $link['link_category'];
+ }
// Merge old and new fields with new fields overwriting old ones.
- $linkdata = array_merge( $link, $linkdata );
+ $linkdata = array_merge( $link, $linkdata );
$linkdata['link_category'] = $link_cats;
return wp_insert_link( $linkdata );
@@ -299,8 +309,9 @@ function wp_update_link( $linkdata ) {
*/
function wp_link_manager_disabled_message() {
global $pagenow;
- if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow )
+ if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow ) {
return;
+ }
add_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
$really_can_manage_links = current_user_can( 'manage_links' );
diff --git a/wp-admin/includes/class-automatic-upgrader-skin.php b/wp-admin/includes/class-automatic-upgrader-skin.php
index dd37da96db..571068d691 100644
--- a/wp-admin/includes/class-automatic-upgrader-skin.php
+++ b/wp-admin/includes/class-automatic-upgrader-skin.php
@@ -50,7 +50,6 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
}
/**
- *
* @return array
*/
public function get_upgrade_messages() {
@@ -58,7 +57,6 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
}
/**
- *
* @param string|array|WP_Error $data
*/
public function feedback( $data ) {
@@ -69,30 +67,35 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
} else {
$string = $data;
}
- if ( ! empty( $this->upgrader->strings[ $string ] ) )
+ if ( ! empty( $this->upgrader->strings[ $string ] ) ) {
$string = $this->upgrader->strings[ $string ];
+ }
if ( strpos( $string, '%' ) !== false ) {
$args = func_get_args();
$args = array_splice( $args, 1 );
- if ( ! empty( $args ) )
+ if ( ! empty( $args ) ) {
$string = vsprintf( $string, $args );
+ }
}
$string = trim( $string );
// Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
- $string = wp_kses( $string, array(
- 'a' => array(
- 'href' => true
- ),
- 'br' => true,
- 'em' => true,
- 'strong' => true,
- ) );
+ $string = wp_kses(
+ $string, array(
+ 'a' => array(
+ 'href' => true,
+ ),
+ 'br' => true,
+ 'em' => true,
+ 'strong' => true,
+ )
+ );
- if ( empty( $string ) )
+ if ( empty( $string ) ) {
return;
+ }
$this->messages[] = $string;
}
@@ -107,7 +110,8 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
*/
public function footer() {
$output = ob_get_clean();
- if ( ! empty( $output ) )
+ if ( ! empty( $output ) ) {
$this->feedback( $output );
+ }
}
}
diff --git a/wp-admin/includes/class-bulk-plugin-upgrader-skin.php b/wp-admin/includes/class-bulk-plugin-upgrader-skin.php
index 34dcbd441f..bb85e88be2 100644
--- a/wp-admin/includes/class-bulk-plugin-upgrader-skin.php
+++ b/wp-admin/includes/class-bulk-plugin-upgrader-skin.php
@@ -20,23 +20,21 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
public function add_strings() {
parent::add_strings();
- $this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
+ $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)' );
}
/**
- *
* @param string $title
*/
- public function before($title = '') {
- parent::before($this->plugin_info['Title']);
+ public function before( $title = '' ) {
+ parent::before( $this->plugin_info['Title'] );
}
/**
- *
* @param string $title
*/
- public function after($title = '') {
- parent::after($this->plugin_info['Title']);
+ public function after( $title = '' ) {
+ parent::after( $this->plugin_info['Title'] );
$this->decrement_update_count( 'plugin' );
}
@@ -44,12 +42,13 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
*/
public function bulk_footer() {
parent::bulk_footer();
- $update_actions = array(
+ $update_actions = array(
'plugins_page' => '' . __( 'Return to Plugins page' ) . ' ',
- 'updates_page' => '' . __( 'Return to WordPress Updates page' ) . ' '
+ 'updates_page' => '' . __( 'Return to WordPress Updates page' ) . ' ',
);
- if ( ! current_user_can( 'activate_plugins' ) )
+ if ( ! current_user_can( 'activate_plugins' ) ) {
unset( $update_actions['plugins_page'] );
+ }
/**
* Filters the list of action links available following bulk plugin updates.
@@ -61,7 +60,8 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
*/
$update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
- if ( ! empty($update_actions) )
- $this->feedback(implode(' | ', (array)$update_actions));
+ if ( ! empty( $update_actions ) ) {
+ $this->feedback( implode( ' | ', (array) $update_actions ) );
+ }
}
}
diff --git a/wp-admin/includes/class-bulk-theme-upgrader-skin.php b/wp-admin/includes/class-bulk-theme-upgrader-skin.php
index 85ee6f2e54..8f01c314a3 100644
--- a/wp-admin/includes/class-bulk-theme-upgrader-skin.php
+++ b/wp-admin/includes/class-bulk-theme-upgrader-skin.php
@@ -20,23 +20,21 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
public function add_strings() {
parent::add_strings();
- $this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)');
+ $this->upgrader->strings['skin_before_update_header'] = __( 'Updating Theme %1$s (%2$d/%3$d)' );
}
/**
- *
* @param string $title
*/
- public function before($title = '') {
- parent::before( $this->theme_info->display('Name') );
+ public function before( $title = '' ) {
+ parent::before( $this->theme_info->display( 'Name' ) );
}
/**
- *
* @param string $title
*/
- public function after($title = '') {
- parent::after( $this->theme_info->display('Name') );
+ public function after( $title = '' ) {
+ parent::after( $this->theme_info->display( 'Name' ) );
$this->decrement_update_count( 'theme' );
}
@@ -44,12 +42,13 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
*/
public function bulk_footer() {
parent::bulk_footer();
- $update_actions = array(
- 'themes_page' => '' . __( 'Return to Themes page' ) . ' ',
- 'updates_page' => '' . __( 'Return to WordPress Updates page' ) . ' '
+ $update_actions = array(
+ 'themes_page' => '' . __( 'Return to Themes page' ) . ' ',
+ 'updates_page' => '' . __( 'Return to WordPress Updates page' ) . ' ',
);
- if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) )
+ if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) {
unset( $update_actions['themes_page'] );
+ }
/**
* Filters the list of action links available following bulk theme updates.
@@ -61,7 +60,8 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
*/
$update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
- if ( ! empty($update_actions) )
- $this->feedback(implode(' | ', (array)$update_actions));
+ if ( ! empty( $update_actions ) ) {
+ $this->feedback( implode( ' | ', (array) $update_actions ) );
+ }
}
}
diff --git a/wp-admin/includes/class-bulk-upgrader-skin.php b/wp-admin/includes/class-bulk-upgrader-skin.php
index 6541de925b..2b2ebd00d5 100644
--- a/wp-admin/includes/class-bulk-upgrader-skin.php
+++ b/wp-admin/includes/class-bulk-upgrader-skin.php
@@ -23,52 +23,56 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
public $error = false;
/**
- *
* @param array $args
*/
- public function __construct($args = array()) {
- $defaults = array( 'url' => '', 'nonce' => '' );
- $args = wp_parse_args($args, $defaults);
+ public function __construct( $args = array() ) {
+ $defaults = array(
+ 'url' => '',
+ 'nonce' => '',
+ );
+ $args = wp_parse_args( $args, $defaults );
- parent::__construct($args);
+ parent::__construct( $args );
}
/**
*/
public function add_strings() {
- $this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
+ $this->upgrader->strings['skin_upgrade_start'] = __( 'The update process is starting. This process may take a while on some hosts, so please be patient.' );
/* translators: 1: Title of an update, 2: Error message */
- $this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: %2$s');
+ $this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while updating %1$s: %2$s' );
/* translators: 1: Title of an update */
- $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
+ $this->upgrader->strings['skin_update_failed'] = __( 'The update of %1$s failed.' );
/* translators: 1: Title of an update */
$this->upgrader->strings['skin_update_successful'] = __( '%1$s updated successfully.' );
- $this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
+ $this->upgrader->strings['skin_upgrade_end'] = __( 'All updates have been completed.' );
}
/**
- *
* @param string $string
*/
- public function feedback($string) {
- if ( isset( $this->upgrader->strings[$string] ) )
- $string = $this->upgrader->strings[$string];
+ public function feedback( $string ) {
+ if ( isset( $this->upgrader->strings[ $string ] ) ) {
+ $string = $this->upgrader->strings[ $string ];
+ }
- if ( strpos($string, '%') !== false ) {
+ if ( strpos( $string, '%' ) !== false ) {
$args = func_get_args();
- $args = array_splice($args, 1);
+ $args = array_splice( $args, 1 );
if ( $args ) {
- $args = array_map( 'strip_tags', $args );
- $args = array_map( 'esc_html', $args );
- $string = vsprintf($string, $args);
+ $args = array_map( 'strip_tags', $args );
+ $args = array_map( 'esc_html', $args );
+ $string = vsprintf( $string, $args );
}
}
- if ( empty($string) )
+ if ( empty( $string ) ) {
return;
- if ( $this->in_loop )
+ }
+ if ( $this->in_loop ) {
echo "$string \n";
- else
+ } else {
echo "$string
\n";
+ }
}
/**
@@ -84,65 +88,64 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
}
/**
- *
* @param string|WP_Error $error
*/
- public function error($error) {
- if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
- $this->error = $this->upgrader->strings[$error];
+ public function error( $error ) {
+ if ( is_string( $error ) && isset( $this->upgrader->strings[ $error ] ) ) {
+ $this->error = $this->upgrader->strings[ $error ];
+ }
- if ( is_wp_error($error) ) {
+ if ( is_wp_error( $error ) ) {
$messages = array();
foreach ( $error->get_error_messages() as $emessage ) {
- if ( $error->get_error_data() && is_string( $error->get_error_data() ) )
+ if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) {
$messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
- else
+ } else {
$messages[] = $emessage;
+ }
}
- $this->error = implode(', ', $messages);
+ $this->error = implode( ', ', $messages );
}
- echo '';
+ echo '';
}
/**
*/
public function bulk_header() {
- $this->feedback('skin_upgrade_start');
+ $this->feedback( 'skin_upgrade_start' );
}
/**
*/
public function bulk_footer() {
- $this->feedback('skin_upgrade_end');
+ $this->feedback( 'skin_upgrade_end' );
}
/**
- *
* @param string $title
*/
- public function before($title = '') {
+ public function before( $title = '' ) {
$this->in_loop = true;
printf( '' . $this->upgrader->strings['skin_before_update_header'] . ' ', $title, $this->upgrader->update_current, $this->upgrader->update_count );
- echo '';
+ echo '';
// This progress messages div gets moved via JavaScript when clicking on "Show details.".
- echo '';
+ echo '
';
$this->flush_output();
}
/**
- *
* @param string $title
*/
- public function after($title = '') {
+ public function after( $title = '' ) {
echo '
';
if ( $this->error || ! $this->result ) {
if ( $this->error ) {
- echo '
' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, '' . $this->error . ' ' ) . '
';
+ echo '
' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $title, '' . $this->error . ' ' ) . '
';
} else {
- echo '
' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '
';
+ echo '
' . sprintf( $this->upgrader->strings['skin_update_failed'], $title ) . '
';
}
- echo '';
+ echo '';
}
if ( $this->result && ! is_wp_error( $this->result ) ) {
if ( ! $this->error ) {
@@ -152,7 +155,7 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
'
';
}
- echo '';
+ echo '';
}
$this->reset();
@@ -163,7 +166,7 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
*/
public function reset() {
$this->in_loop = false;
- $this->error = false;
+ $this->error = false;
}
/**
diff --git a/wp-admin/includes/class-core-upgrader.php b/wp-admin/includes/class-core-upgrader.php
index 195e5885e5..0bbf43303f 100644
--- a/wp-admin/includes/class-core-upgrader.php
+++ b/wp-admin/includes/class-core-upgrader.php
@@ -26,15 +26,15 @@ class Core_Upgrader extends WP_Upgrader {
* @since 2.8.0
*/
public function upgrade_strings() {
- $this->strings['up_to_date'] = __('WordPress is at the latest version.');
- $this->strings['locked'] = __('Another update is currently in progress.');
- $this->strings['no_package'] = __('Update package not available.');
+ $this->strings['up_to_date'] = __( 'WordPress is at the latest version.' );
+ $this->strings['locked'] = __( 'Another update is currently in progress.' );
+ $this->strings['no_package'] = __( 'Update package not available.' );
/* translators: %s: package URL */
- $this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '%s ' );
- $this->strings['unpack_package'] = __('Unpacking the update…');
- $this->strings['copy_failed'] = __('Could not copy files.');
- $this->strings['copy_failed_space'] = __('Could not copy files. You may have run out of disk space.' );
- $this->strings['start_rollback'] = __( 'Attempting to roll back to previous version.' );
+ $this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '%s ' );
+ $this->strings['unpack_package'] = __( 'Unpacking the update…' );
+ $this->strings['copy_failed'] = __( 'Could not copy files.' );
+ $this->strings['copy_failed_space'] = __( 'Could not copy files. You may have run out of disk space.' );
+ $this->strings['start_rollback'] = __( 'Attempting to roll back to previous version.' );
$this->strings['rollback_was_required'] = __( 'Due to an error during updating, WordPress has rolled back to your previous version.' );
}
@@ -66,10 +66,10 @@ class Core_Upgrader extends WP_Upgrader {
$start_time = time();
- $defaults = array(
- 'pre_check_md5' => true,
- 'attempt_rollback' => false,
- 'do_rollback' => false,
+ $defaults = array(
+ 'pre_check_md5' => true,
+ 'attempt_rollback' => false,
+ 'do_rollback' => false,
'allow_relaxed_file_ownership' => false,
);
$parsed_args = wp_parse_args( $args, $defaults );
@@ -78,21 +78,23 @@ class Core_Upgrader extends WP_Upgrader {
$this->upgrade_strings();
// Is an update available?
- if ( !isset( $current->response ) || $current->response == 'latest' )
- return new WP_Error('up_to_date', $this->strings['up_to_date']);
+ if ( ! isset( $current->response ) || $current->response == 'latest' ) {
+ return new WP_Error( 'up_to_date', $this->strings['up_to_date'] );
+ }
$res = $this->fs_connect( array( ABSPATH, WP_CONTENT_DIR ), $parsed_args['allow_relaxed_file_ownership'] );
if ( ! $res || is_wp_error( $res ) ) {
return $res;
}
- $wp_dir = trailingslashit($wp_filesystem->abspath());
+ $wp_dir = trailingslashit( $wp_filesystem->abspath() );
$partial = true;
- if ( $parsed_args['do_rollback'] )
+ if ( $parsed_args['do_rollback'] ) {
$partial = false;
- elseif ( $parsed_args['pre_check_md5'] && ! $this->check_files() )
+ } elseif ( $parsed_args['pre_check_md5'] && ! $this->check_files() ) {
$partial = false;
+ }
/*
* If partial update is returned from the API, use that, unless we're doing
@@ -100,17 +102,18 @@ class Core_Upgrader extends WP_Upgrader {
* the new_bundled zip. Don't though if the constant is set to skip bundled items.
* If the API returns a no_content zip, go with it. Finally, default to the full zip.
*/
- if ( $parsed_args['do_rollback'] && $current->packages->rollback )
+ if ( $parsed_args['do_rollback'] && $current->packages->rollback ) {
$to_download = 'rollback';
- elseif ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && $partial )
+ } elseif ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && $partial ) {
$to_download = 'partial';
- elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' )
- && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) )
+ } elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' )
+ && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
$to_download = 'new_bundled';
- elseif ( $current->packages->no_content )
+ } elseif ( $current->packages->no_content ) {
$to_download = 'no_content';
- else
+ } else {
$to_download = 'full';
+ }
// Lock to prevent multiple Core Updates occurring
$lock = WP_Upgrader::create_lock( 'core_updater', 15 * MINUTE_IN_SECONDS );
@@ -131,12 +134,12 @@ class Core_Upgrader extends WP_Upgrader {
}
// Copy update-core.php from the new version into place.
- if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) {
- $wp_filesystem->delete($working_dir, true);
+ if ( ! $wp_filesystem->copy( $working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true ) ) {
+ $wp_filesystem->delete( $working_dir, true );
WP_Upgrader::release_lock( 'core_updater' );
return new WP_Error( 'copy_failed_for_update_core_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-admin/includes/update-core.php' );
}
- $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
+ $wp_filesystem->chmod( $wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE );
require_once( ABSPATH . 'wp-admin/includes/update-core.php' );
@@ -157,12 +160,13 @@ class Core_Upgrader extends WP_Upgrader {
* mkdir_failed__copy_dir, copy_failed__copy_dir_retry, and disk_full.
* do_rollback allows for update_core() to trigger a rollback if needed.
*/
- if ( false !== strpos( $error_code, 'do_rollback' ) )
+ if ( false !== strpos( $error_code, 'do_rollback' ) ) {
$try_rollback = true;
- elseif ( false !== strpos( $error_code, '__copy_dir' ) )
+ } elseif ( false !== strpos( $error_code, '__copy_dir' ) ) {
$try_rollback = true;
- elseif ( 'disk_full' === $error_code )
+ } elseif ( 'disk_full' === $error_code ) {
$try_rollback = true;
+ }
}
if ( $try_rollback ) {
@@ -175,12 +179,22 @@ class Core_Upgrader extends WP_Upgrader {
$rollback_result = $this->upgrade( $current, array_merge( $parsed_args, array( 'do_rollback' => true ) ) );
$original_result = $result;
- $result = new WP_Error( 'rollback_was_required', $this->strings['rollback_was_required'], (object) array( 'update' => $original_result, 'rollback' => $rollback_result ) );
+ $result = new WP_Error(
+ 'rollback_was_required', $this->strings['rollback_was_required'], (object) array(
+ 'update' => $original_result,
+ 'rollback' => $rollback_result,
+ )
+ );
}
}
/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
- do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'core' ) );
+ do_action(
+ 'upgrader_process_complete', $this, array(
+ 'action' => 'update',
+ 'type' => 'core',
+ )
+ );
// Clear the current updates
delete_site_transient( 'update_core' );
@@ -191,7 +205,7 @@ class Core_Upgrader extends WP_Upgrader {
'success' => true,
'fs_method' => $wp_filesystem->method,
'fs_method_forced' => defined( 'FS_METHOD' ) || has_filter( 'filesystem_method' ),
- 'fs_method_direct' => !empty( $GLOBALS['_wp_filesystem_direct_method'] ) ? $GLOBALS['_wp_filesystem_direct_method'] : '',
+ 'fs_method_direct' => ! empty( $GLOBALS['_wp_filesystem_direct_method'] ) ? $GLOBALS['_wp_filesystem_direct_method'] : '',
'time_taken' => time() - $start_time,
'reported' => $wp_version,
'attempted' => $current->version,
@@ -236,8 +250,8 @@ class Core_Upgrader extends WP_Upgrader {
public static function should_update_to_version( $offered_ver ) {
include( ABSPATH . WPINC . '/version.php' ); // $wp_version; // x.y.z
- $current_branch = implode( '.', array_slice( preg_split( '/[.-]/', $wp_version ), 0, 2 ) ); // x.y
- $new_branch = implode( '.', array_slice( preg_split( '/[.-]/', $offered_ver ), 0, 2 ) ); // x.y
+ $current_branch = implode( '.', array_slice( preg_split( '/[.-]/', $wp_version ), 0, 2 ) ); // x.y
+ $new_branch = implode( '.', array_slice( preg_split( '/[.-]/', $offered_ver ), 0, 2 ) ); // x.y
$current_is_development_version = (bool) strpos( $wp_version, '-' );
// Defaults:
@@ -255,34 +269,39 @@ class Core_Upgrader extends WP_Upgrader {
$upgrade_dev = $upgrade_minor = $upgrade_major = true;
} elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) {
// Only minor updates for core
- $upgrade_dev = $upgrade_major = false;
+ $upgrade_dev = $upgrade_major = false;
$upgrade_minor = true;
}
}
// 1: If we're already on that version, not much point in updating?
- if ( $offered_ver == $wp_version )
+ if ( $offered_ver == $wp_version ) {
return false;
+ }
// 2: If we're running a newer version, that's a nope
- if ( version_compare( $wp_version, $offered_ver, '>' ) )
+ if ( version_compare( $wp_version, $offered_ver, '>' ) ) {
return false;
+ }
$failure_data = get_site_option( 'auto_core_update_failed' );
if ( $failure_data ) {
// If this was a critical update failure, cannot update.
- if ( ! empty( $failure_data['critical'] ) )
+ if ( ! empty( $failure_data['critical'] ) ) {
return false;
+ }
// Don't claim we can update on update-core.php if we have a non-critical failure logged.
- if ( $wp_version == $failure_data['current'] && false !== strpos( $offered_ver, '.1.next.minor' ) )
+ if ( $wp_version == $failure_data['current'] && false !== strpos( $offered_ver, '.1.next.minor' ) ) {
return false;
+ }
// Cannot update if we're retrying the same A to B update that caused a non-critical failure.
// Some non-critical failures do allow retries, like download_failed.
// 3.7.1 => 3.7.2 resulted in files_not_writable, if we are still on 3.7.1 and still trying to update to 3.7.2.
- if ( empty( $failure_data['retry'] ) && $wp_version == $failure_data['current'] && $offered_ver == $failure_data['attempted'] )
+ if ( empty( $failure_data['retry'] ) && $wp_version == $failure_data['current'] && $offered_ver == $failure_data['attempted'] ) {
return false;
+ }
}
// 3: 3.7-alpha-25000 -> 3.7-alpha-25678 -> 3.7-beta1 -> 3.7-beta2
@@ -296,8 +315,9 @@ class Core_Upgrader extends WP_Upgrader {
* @param bool $upgrade_dev Whether to enable automatic updates for
* development versions.
*/
- if ( ! apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ) )
+ if ( ! apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ) ) {
return false;
+ }
// Else fall through to minor + major branches below.
}
@@ -346,15 +366,18 @@ class Core_Upgrader extends WP_Upgrader {
$checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
- if ( ! is_array( $checksums ) )
+ if ( ! is_array( $checksums ) ) {
return false;
+ }
foreach ( $checksums as $file => $checksum ) {
// Skip files which get updated
- if ( 'wp-content' == substr( $file, 0, 10 ) )
+ if ( 'wp-content' == substr( $file, 0, 10 ) ) {
continue;
- if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum )
+ }
+ if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum ) {
return false;
+ }
}
return true;
diff --git a/wp-admin/includes/class-file-upload-upgrader.php b/wp-admin/includes/class-file-upload-upgrader.php
index a182b62ccd..c3d8a79552 100644
--- a/wp-admin/includes/class-file-upload-upgrader.php
+++ b/wp-admin/includes/class-file-upload-upgrader.php
@@ -52,28 +52,33 @@ class File_Upload_Upgrader {
*/
public function __construct( $form, $urlholder ) {
- if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) )
- wp_die(__('Please select a file'));
+ if ( empty( $_FILES[ $form ]['name'] ) && empty( $_GET[ $urlholder ] ) ) {
+ wp_die( __( 'Please select a file' ) );
+ }
//Handle a newly uploaded file, Else assume it's already been uploaded
- if ( ! empty($_FILES) ) {
- $overrides = array( 'test_form' => false, 'test_type' => false );
- $file = wp_handle_upload( $_FILES[$form], $overrides );
+ if ( ! empty( $_FILES ) ) {
+ $overrides = array(
+ 'test_form' => false,
+ 'test_type' => false,
+ );
+ $file = wp_handle_upload( $_FILES[ $form ], $overrides );
- if ( isset( $file['error'] ) )
+ if ( isset( $file['error'] ) ) {
wp_die( $file['error'] );
+ }
- $this->filename = $_FILES[$form]['name'];
- $this->package = $file['file'];
+ $this->filename = $_FILES[ $form ]['name'];
+ $this->package = $file['file'];
// Construct the object array
$object = array(
- 'post_title' => $this->filename,
- 'post_content' => $file['url'],
+ 'post_title' => $this->filename,
+ 'post_content' => $file['url'],
'post_mime_type' => $file['type'],
- 'guid' => $file['url'],
- 'context' => 'upgrader',
- 'post_status' => 'private'
+ 'guid' => $file['url'],
+ 'context' => 'upgrader',
+ 'post_status' => 'private',
);
// Save the data.
@@ -82,22 +87,24 @@ class File_Upload_Upgrader {
// Schedule a cleanup for 2 hours from now in case of failed installation.
wp_schedule_single_event( time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array( $this->id ) );
- } elseif ( is_numeric( $_GET[$urlholder] ) ) {
+ } elseif ( is_numeric( $_GET[ $urlholder ] ) ) {
// Numeric Package = previously uploaded file, see above.
- $this->id = (int) $_GET[$urlholder];
+ $this->id = (int) $_GET[ $urlholder ];
$attachment = get_post( $this->id );
- if ( empty($attachment) )
- wp_die(__('Please select a file'));
+ if ( empty( $attachment ) ) {
+ wp_die( __( 'Please select a file' ) );
+ }
$this->filename = $attachment->post_title;
- $this->package = get_attached_file( $attachment->ID );
+ $this->package = get_attached_file( $attachment->ID );
} else {
// Else, It's set to something, Back compat for plugins using the old (pre-3.3) File_Uploader handler.
- if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
+ if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) {
wp_die( $uploads['error'] );
+ }
$this->filename = sanitize_file_name( $_GET[ $urlholder ] );
- $this->package = $uploads['basedir'] . '/' . $this->filename;
+ $this->package = $uploads['basedir'] . '/' . $this->filename;
if ( 0 !== strpos( realpath( $this->package ), realpath( $uploads['basedir'] ) ) ) {
wp_die( __( 'Please select a file' ) );
@@ -113,11 +120,12 @@ class File_Upload_Upgrader {
* @return bool Whether the cleanup was successful.
*/
public function cleanup() {
- if ( $this->id )
+ if ( $this->id ) {
wp_delete_attachment( $this->id );
- elseif ( file_exists( $this->package ) )
+ } elseif ( file_exists( $this->package ) ) {
return @unlink( $this->package );
+ }
return true;
}
diff --git a/wp-admin/includes/class-language-pack-upgrader-skin.php b/wp-admin/includes/class-language-pack-upgrader-skin.php
index 9efc877ef0..4fa1f29d38 100644
--- a/wp-admin/includes/class-language-pack-upgrader-skin.php
+++ b/wp-admin/includes/class-language-pack-upgrader-skin.php
@@ -16,21 +16,25 @@
* @see WP_Upgrader_Skin
*/
class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
- public $language_update = null;
- public $done_header = false;
- public $done_footer = false;
+ public $language_update = null;
+ public $done_header = false;
+ public $done_footer = false;
public $display_footer_actions = true;
/**
- *
* @param array $args
*/
public function __construct( $args = array() ) {
- $defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false );
- $args = wp_parse_args( $args, $defaults );
+ $defaults = array(
+ 'url' => '',
+ 'nonce' => '',
+ 'title' => __( 'Update Translations' ),
+ 'skip_header_footer' => false,
+ );
+ $args = wp_parse_args( $args, $defaults );
if ( $args['skip_header_footer'] ) {
- $this->done_header = true;
- $this->done_footer = true;
+ $this->done_header = true;
+ $this->done_footer = true;
$this->display_footer_actions = false;
}
parent::__construct( $args );
@@ -47,7 +51,6 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
}
/**
- *
* @param string|WP_Error $error
*/
public function error( $error ) {
@@ -66,7 +69,7 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
*/
public function bulk_footer() {
$this->decrement_update_count( 'translation' );
- $update_actions = array();
+ $update_actions = array();
$update_actions['updates_page'] = '' . __( 'Return to WordPress Updates page' ) . ' ';
/**
@@ -78,7 +81,8 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
*/
$update_actions = apply_filters( 'update_translations_complete_actions', $update_actions );
- if ( $update_actions && $this->display_footer_actions )
+ if ( $update_actions && $this->display_footer_actions ) {
$this->feedback( implode( ' | ', $update_actions ) );
+ }
}
}
diff --git a/wp-admin/includes/class-language-pack-upgrader.php b/wp-admin/includes/class-language-pack-upgrader.php
index 404c4a2771..6eff004b8a 100644
--- a/wp-admin/includes/class-language-pack-upgrader.php
+++ b/wp-admin/includes/class-language-pack-upgrader.php
@@ -94,9 +94,11 @@ class Language_Pack_Upgrader extends WP_Upgrader {
if ( $upgrader && $upgrader->skin instanceof Automatic_Upgrader_Skin ) {
$skin = $upgrader->skin;
} else {
- $skin = new Language_Pack_Upgrader_Skin( array(
- 'skip_header_footer' => true,
- ) );
+ $skin = new Language_Pack_Upgrader_Skin(
+ array(
+ 'skip_header_footer' => true,
+ )
+ );
}
$lp_upgrader = new Language_Pack_Upgrader( $skin );
@@ -110,13 +112,13 @@ class Language_Pack_Upgrader extends WP_Upgrader {
*/
public function upgrade_strings() {
$this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while we update them as well.' );
- $this->strings['up_to_date'] = __( 'The translations are up to date.' );
- $this->strings['no_package'] = __( 'Update package not available.' );
+ $this->strings['up_to_date'] = __( 'The translations are up to date.' );
+ $this->strings['no_package'] = __( 'Update package not available.' );
/* translators: %s: package URL */
$this->strings['downloading_package'] = sprintf( __( 'Downloading translation from %s…' ), '%s ' );
- $this->strings['unpack_package'] = __( 'Unpacking the update…' );
- $this->strings['process_failed'] = __( 'Translation update failed.' );
- $this->strings['process_success'] = __( 'Translation updated successfully.' );
+ $this->strings['unpack_package'] = __( 'Unpacking the update…' );
+ $this->strings['process_failed'] = __( 'Translation update failed.' );
+ $this->strings['process_success'] = __( 'Translation updated successfully.' );
}
/**
@@ -163,7 +165,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
public function bulk_upgrade( $language_updates = array(), $args = array() ) {
global $wp_filesystem;
- $defaults = array(
+ $defaults = array(
'clear_update_cache' => true,
);
$parsed_args = wp_parse_args( $args, $defaults );
@@ -171,8 +173,9 @@ class Language_Pack_Upgrader extends WP_Upgrader {
$this->init();
$this->upgrade_strings();
- if ( ! $language_updates )
+ if ( ! $language_updates ) {
$language_updates = wp_get_translation_updates();
+ }
if ( empty( $language_updates ) ) {
$this->skin->header();
@@ -183,8 +186,9 @@ class Language_Pack_Upgrader extends WP_Upgrader {
return true;
}
- if ( 'upgrader_process_complete' == current_filter() )
+ if ( 'upgrader_process_complete' == current_filter() ) {
$this->skin->feedback( 'starting_upgrade' );
+ }
// Remove any existing upgrade filters from the plugin/theme upgraders #WP29425 & #WP29230
remove_all_filters( 'upgrader_pre_install' );
@@ -205,7 +209,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
$results = array();
- $this->update_count = count( $language_updates );
+ $this->update_count = count( $language_updates );
$this->update_current = 0;
/*
@@ -213,9 +217,11 @@ class Language_Pack_Upgrader extends WP_Upgrader {
* as we then may need to create a /plugins or /themes directory inside of it.
*/
$remote_destination = $wp_filesystem->find_folder( WP_LANG_DIR );
- if ( ! $wp_filesystem->exists( $remote_destination ) )
- if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) )
+ if ( ! $wp_filesystem->exists( $remote_destination ) ) {
+ if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) {
return new WP_Error( 'mkdir_failed_lang_dir', $this->strings['mkdir_failed'], $remote_destination );
+ }
+ }
$language_updates_results = array();
@@ -224,24 +230,25 @@ class Language_Pack_Upgrader extends WP_Upgrader {
$this->skin->language_update = $language_update;
$destination = WP_LANG_DIR;
- if ( 'plugin' == $language_update->type )
+ if ( 'plugin' == $language_update->type ) {
$destination .= '/plugins';
- elseif ( 'theme' == $language_update->type )
+ } elseif ( 'theme' == $language_update->type ) {
$destination .= '/themes';
+ }
$this->update_current++;
$options = array(
- 'package' => $language_update->package,
- 'destination' => $destination,
- 'clear_destination' => false,
+ 'package' => $language_update->package,
+ 'destination' => $destination,
+ 'clear_destination' => false,
'abort_if_destination_exists' => false, // We expect the destination to exist.
- 'clear_working' => true,
- 'is_multi' => true,
- 'hook_extra' => array(
+ 'clear_working' => true,
+ 'is_multi' => true,
+ 'hook_extra' => array(
'language_update_type' => $language_update->type,
- 'language_update' => $language_update,
- )
+ 'language_update' => $language_update,
+ ),
);
$result = $this->run( $options );
@@ -268,12 +275,14 @@ class Language_Pack_Upgrader extends WP_Upgrader {
remove_action( 'upgrader_process_complete', 'wp_update_themes' );
/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
- do_action( 'upgrader_process_complete', $this, array(
- 'action' => 'update',
- 'type' => 'translation',
- 'bulk' => true,
- 'translations' => $language_updates_results
- ) );
+ do_action(
+ 'upgrader_process_complete', $this, array(
+ 'action' => 'update',
+ 'type' => 'translation',
+ 'bulk' => true,
+ 'translations' => $language_updates_results,
+ )
+ );
// Re-add upgrade hooks.
add_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
@@ -311,8 +320,9 @@ class Language_Pack_Upgrader extends WP_Upgrader {
public function check_package( $source, $remote_source ) {
global $wp_filesystem;
- if ( is_wp_error( $source ) )
+ if ( is_wp_error( $source ) ) {
return $source;
+ }
// Check that the folder contains a valid language.
$files = $wp_filesystem->dirlist( $remote_source );
@@ -320,16 +330,19 @@ class Language_Pack_Upgrader extends WP_Upgrader {
// Check to see if a .po and .mo exist in the folder.
$po = $mo = false;
foreach ( (array) $files as $file => $filedata ) {
- if ( '.po' == substr( $file, -3 ) )
+ if ( '.po' == substr( $file, -3 ) ) {
$po = true;
- elseif ( '.mo' == substr( $file, -3 ) )
+ } elseif ( '.mo' == substr( $file, -3 ) ) {
$mo = true;
+ }
}
if ( ! $mo || ! $po ) {
- return new WP_Error( 'incompatible_archive_pomo', $this->strings['incompatible_archive'],
+ return new WP_Error(
+ 'incompatible_archive_pomo', $this->strings['incompatible_archive'],
/* translators: 1: .po 2: .mo */
- sprintf( __( 'The language pack is missing either the %1$s or %2$s files.' ),
+ sprintf(
+ __( 'The language pack is missing either the %1$s or %2$s files.' ),
'.po
',
'.mo
'
)
@@ -354,14 +367,16 @@ class Language_Pack_Upgrader extends WP_Upgrader {
case 'theme':
$theme = wp_get_theme( $update->slug );
- if ( $theme->exists() )
+ if ( $theme->exists() ) {
return $theme->Get( 'Name' );
+ }
break;
case 'plugin':
$plugin_data = get_plugins( '/' . $update->slug );
$plugin_data = reset( $plugin_data );
- if ( $plugin_data )
+ if ( $plugin_data ) {
return $plugin_data['Name'];
+ }
break;
}
return '';
diff --git a/wp-admin/includes/class-plugin-installer-skin.php b/wp-admin/includes/class-plugin-installer-skin.php
index 66f406227b..300d6684d9 100644
--- a/wp-admin/includes/class-plugin-installer-skin.php
+++ b/wp-admin/includes/class-plugin-installer-skin.php
@@ -20,24 +20,30 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
public $type;
/**
- *
* @param array $args
*/
- public function __construct($args = array()) {
- $defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
- $args = wp_parse_args($args, $defaults);
+ public function __construct( $args = array() ) {
+ $defaults = array(
+ 'type' => 'web',
+ 'url' => '',
+ 'plugin' => '',
+ 'nonce' => '',
+ 'title' => '',
+ );
+ $args = wp_parse_args( $args, $defaults );
$this->type = $args['type'];
- $this->api = isset($args['api']) ? $args['api'] : array();
+ $this->api = isset( $args['api'] ) ? $args['api'] : array();
- parent::__construct($args);
+ parent::__construct( $args );
}
/**
*/
public function before() {
- if ( !empty($this->api) )
- $this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin %s %s .'), $this->api->name, $this->api->version);
+ if ( ! empty( $this->api ) ) {
+ $this->upgrader->strings['process_success'] = sprintf( __( 'Successfully installed the plugin %1$s %2$s .' ), $this->api->name, $this->api->version );
+ }
}
/**
@@ -47,11 +53,11 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
$install_actions = array();
- $from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins';
+ $from = isset( $_GET['from'] ) ? wp_unslash( $_GET['from'] ) : 'plugins';
if ( 'import' == $from ) {
$install_actions['activate_plugin'] = '' . __( 'Activate Plugin & Run Importer' ) . ' ';
- } else if ( 'press-this' == $from ) {
+ } elseif ( 'press-this' == $from ) {
$install_actions['activate_plugin'] = '' . __( 'Activate Plugin & Return to Press This' ) . ' ';
} else {
$install_actions['activate_plugin'] = '' . __( 'Activate Plugin' ) . ' ';
@@ -72,7 +78,7 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
$install_actions['plugins_page'] = '' . __( 'Return to Plugins page' ) . ' ';
}
- if ( ! $this->result || is_wp_error($this->result) ) {
+ if ( ! $this->result || is_wp_error( $this->result ) ) {
unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
} elseif ( ! current_user_can( 'activate_plugin', $plugin_file ) ) {
unset( $install_actions['activate_plugin'] );
diff --git a/wp-admin/includes/class-plugin-upgrader-skin.php b/wp-admin/includes/class-plugin-upgrader-skin.php
index ba8c30fbc4..036166a2b0 100644
--- a/wp-admin/includes/class-plugin-upgrader-skin.php
+++ b/wp-admin/includes/class-plugin-upgrader-skin.php
@@ -16,43 +16,48 @@
* @see WP_Upgrader_Skin
*/
class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
- public $plugin = '';
- public $plugin_active = false;
+ public $plugin = '';
+ public $plugin_active = false;
public $plugin_network_active = false;
/**
- *
* @param array $args
*/
public function __construct( $args = array() ) {
- $defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
- $args = wp_parse_args($args, $defaults);
+ $defaults = array(
+ 'url' => '',
+ 'plugin' => '',
+ 'nonce' => '',
+ 'title' => __( 'Update Plugin' ),
+ );
+ $args = wp_parse_args( $args, $defaults );
$this->plugin = $args['plugin'];
- $this->plugin_active = is_plugin_active( $this->plugin );
+ $this->plugin_active = is_plugin_active( $this->plugin );
$this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
- parent::__construct($args);
+ parent::__construct( $args );
}
/**
*/
public function after() {
$this->plugin = $this->upgrader->plugin_info();
- if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
+ if ( ! empty( $this->plugin ) && ! is_wp_error( $this->result ) && $this->plugin_active ) {
// Currently used only when JS is off for a single plugin update?
echo '';
}
$this->decrement_update_count( 'plugin' );
- $update_actions = array(
- 'activate_plugin' => '' . __( 'Activate Plugin' ) . ' ',
- 'plugins_page' => '' . __( 'Return to Plugins page' ) . ' '
+ $update_actions = array(
+ 'activate_plugin' => '' . __( 'Activate Plugin' ) . ' ',
+ 'plugins_page' => '' . __( 'Return to Plugins page' ) . ' ',
);
- if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugin', $this->plugin ) )
+ if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugin', $this->plugin ) ) {
unset( $update_actions['activate_plugin'] );
+ }
/**
* Filters the list of action links available following a single plugin update.
@@ -64,7 +69,8 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
*/
$update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin );
- if ( ! empty($update_actions) )
- $this->feedback(implode(' | ', (array)$update_actions));
+ if ( ! empty( $update_actions ) ) {
+ $this->feedback( implode( ' | ', (array) $update_actions ) );
+ }
}
}
diff --git a/wp-admin/includes/class-plugin-upgrader.php b/wp-admin/includes/class-plugin-upgrader.php
index 3c05353bc1..c7bdc58799 100644
--- a/wp-admin/includes/class-plugin-upgrader.php
+++ b/wp-admin/includes/class-plugin-upgrader.php
@@ -44,16 +44,16 @@ class Plugin_Upgrader extends WP_Upgrader {
* @since 2.8.0
*/
public function upgrade_strings() {
- $this->strings['up_to_date'] = __('The plugin is at the latest version.');
- $this->strings['no_package'] = __('Update package not available.');
+ $this->strings['up_to_date'] = __( 'The plugin is at the latest version.' );
+ $this->strings['no_package'] = __( 'Update package not available.' );
/* translators: %s: package URL */
- $this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '%s ' );
- $this->strings['unpack_package'] = __('Unpacking the update…');
- $this->strings['remove_old'] = __('Removing the old version of the plugin…');
- $this->strings['remove_old_failed'] = __('Could not remove the old plugin.');
- $this->strings['process_failed'] = __('Plugin update failed.');
- $this->strings['process_success'] = __('Plugin updated successfully.');
- $this->strings['process_bulk_success'] = __('Plugins updated successfully.');
+ $this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '%s ' );
+ $this->strings['unpack_package'] = __( 'Unpacking the update…' );
+ $this->strings['remove_old'] = __( 'Removing the old version of the plugin…' );
+ $this->strings['remove_old_failed'] = __( 'Could not remove the old plugin.' );
+ $this->strings['process_failed'] = __( 'Plugin update failed.' );
+ $this->strings['process_success'] = __( 'Plugin updated successfully.' );
+ $this->strings['process_bulk_success'] = __( 'Plugins updated successfully.' );
}
/**
@@ -62,14 +62,14 @@ class Plugin_Upgrader extends WP_Upgrader {
* @since 2.8.0
*/
public function install_strings() {
- $this->strings['no_package'] = __('Installation package not available.');
+ $this->strings['no_package'] = __( 'Installation package not available.' );
/* translators: %s: package URL */
$this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '%s ' );
- $this->strings['unpack_package'] = __('Unpacking the package…');
- $this->strings['installing_package'] = __('Installing the plugin…');
- $this->strings['no_files'] = __('The plugin contains no files.');
- $this->strings['process_failed'] = __('Plugin installation failed.');
- $this->strings['process_success'] = __('Plugin installed successfully.');
+ $this->strings['unpack_package'] = __( 'Unpacking the package…' );
+ $this->strings['installing_package'] = __( 'Installing the plugin…' );
+ $this->strings['no_files'] = __( 'The plugin contains no files.' );
+ $this->strings['process_failed'] = __( 'Plugin installation failed.' );
+ $this->strings['process_success'] = __( 'Plugin installed successfully.' );
}
/**
@@ -89,7 +89,7 @@ class Plugin_Upgrader extends WP_Upgrader {
*/
public function install( $package, $args = array() ) {
- $defaults = array(
+ $defaults = array(
'clear_update_cache' => true,
);
$parsed_args = wp_parse_args( $args, $defaults );
@@ -97,28 +97,31 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->init();
$this->install_strings();
- add_filter('upgrader_source_selection', array($this, 'check_package') );
+ add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
if ( $parsed_args['clear_update_cache'] ) {
// Clear cache so wp_update_plugins() knows about the new plugin.
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
}
- $this->run( array(
- 'package' => $package,
- 'destination' => WP_PLUGIN_DIR,
- 'clear_destination' => false, // Do not overwrite files.
- 'clear_working' => true,
- 'hook_extra' => array(
- 'type' => 'plugin',
- 'action' => 'install',
+ $this->run(
+ array(
+ 'package' => $package,
+ 'destination' => WP_PLUGIN_DIR,
+ 'clear_destination' => false, // Do not overwrite files.
+ 'clear_working' => true,
+ 'hook_extra' => array(
+ 'type' => 'plugin',
+ 'action' => 'install',
+ ),
)
- ) );
+ );
remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 );
- remove_filter('upgrader_source_selection', array($this, 'check_package') );
+ remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
- if ( ! $this->result || is_wp_error($this->result) )
+ if ( ! $this->result || is_wp_error( $this->result ) ) {
return $this->result;
+ }
// Force refresh of plugin update information
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
@@ -143,7 +146,7 @@ class Plugin_Upgrader extends WP_Upgrader {
*/
public function upgrade( $plugin, $args = array() ) {
- $defaults = array(
+ $defaults = array(
'clear_update_cache' => true,
);
$parsed_args = wp_parse_args( $args, $defaults );
@@ -152,10 +155,10 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->upgrade_strings();
$current = get_site_transient( 'update_plugins' );
- if ( !isset( $current->response[ $plugin ] ) ) {
+ if ( ! isset( $current->response[ $plugin ] ) ) {
$this->skin->before();
- $this->skin->set_result(false);
- $this->skin->error('up_to_date');
+ $this->skin->set_result( false );
+ $this->skin->error( 'up_to_date' );
$this->skin->after();
return false;
}
@@ -163,33 +166,36 @@ class Plugin_Upgrader extends WP_Upgrader {
// Get the URL to the zip file
$r = $current->response[ $plugin ];
- add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2);
- add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4);
+ add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 );
+ add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 );
//'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins.
if ( $parsed_args['clear_update_cache'] ) {
// Clear cache so wp_update_plugins() knows about the new plugin.
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
}
- $this->run( array(
- 'package' => $r->package,
- 'destination' => WP_PLUGIN_DIR,
- 'clear_destination' => true,
- 'clear_working' => true,
- 'hook_extra' => array(
- 'plugin' => $plugin,
- 'type' => 'plugin',
- 'action' => 'update',
- ),
- ) );
+ $this->run(
+ array(
+ 'package' => $r->package,
+ 'destination' => WP_PLUGIN_DIR,
+ 'clear_destination' => true,
+ 'clear_working' => true,
+ 'hook_extra' => array(
+ 'plugin' => $plugin,
+ 'type' => 'plugin',
+ 'action' => 'update',
+ ),
+ )
+ );
// Cleanup our hooks, in case something else does a upgrade on this connection.
remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 );
- remove_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'));
- remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'));
+ remove_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ) );
+ remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) );
- if ( ! $this->result || is_wp_error($this->result) )
+ if ( ! $this->result || is_wp_error( $this->result ) ) {
return $this->result;
+ }
// Force refresh of plugin update information
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
@@ -214,7 +220,7 @@ class Plugin_Upgrader extends WP_Upgrader {
*/
public function bulk_upgrade( $plugins, $args = array() ) {
- $defaults = array(
+ $defaults = array(
'clear_update_cache' => true,
);
$parsed_args = wp_parse_args( $args, $defaults );
@@ -225,12 +231,12 @@ class Plugin_Upgrader extends WP_Upgrader {
$current = get_site_transient( 'update_plugins' );
- add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4);
+ add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 );
$this->skin->header();
// Connect to the Filesystem first.
- $res = $this->fs_connect( array(WP_CONTENT_DIR, WP_PLUGIN_DIR) );
+ $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
if ( ! $res ) {
$this->skin->footer();
return false;
@@ -245,70 +251,77 @@ class Plugin_Upgrader extends WP_Upgrader {
* @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible.
*/
$maintenance = ( is_multisite() && ! empty( $plugins ) );
- foreach ( $plugins as $plugin )
- $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) );
- if ( $maintenance )
- $this->maintenance_mode(true);
+ foreach ( $plugins as $plugin ) {
+ $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin ] ) );
+ }
+ if ( $maintenance ) {
+ $this->maintenance_mode( true );
+ }
$results = array();
- $this->update_count = count($plugins);
+ $this->update_count = count( $plugins );
$this->update_current = 0;
foreach ( $plugins as $plugin ) {
$this->update_current++;
- $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true);
+ $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true );
- if ( !isset( $current->response[ $plugin ] ) ) {
- $this->skin->set_result('up_to_date');
+ if ( ! isset( $current->response[ $plugin ] ) ) {
+ $this->skin->set_result( 'up_to_date' );
$this->skin->before();
- $this->skin->feedback('up_to_date');
+ $this->skin->feedback( 'up_to_date' );
$this->skin->after();
- $results[$plugin] = true;
+ $results[ $plugin ] = true;
continue;
}
// Get the URL to the zip file.
$r = $current->response[ $plugin ];
- $this->skin->plugin_active = is_plugin_active($plugin);
+ $this->skin->plugin_active = is_plugin_active( $plugin );
- $result = $this->run( array(
- 'package' => $r->package,
- 'destination' => WP_PLUGIN_DIR,
- 'clear_destination' => true,
- 'clear_working' => true,
- 'is_multi' => true,
- 'hook_extra' => array(
- 'plugin' => $plugin
+ $result = $this->run(
+ array(
+ 'package' => $r->package,
+ 'destination' => WP_PLUGIN_DIR,
+ 'clear_destination' => true,
+ 'clear_working' => true,
+ 'is_multi' => true,
+ 'hook_extra' => array(
+ 'plugin' => $plugin,
+ ),
)
- ) );
+ );
- $results[$plugin] = $this->result;
+ $results[ $plugin ] = $this->result;
// Prevent credentials auth screen from displaying multiple times
- if ( false === $result )
+ if ( false === $result ) {
break;
+ }
} //end foreach $plugins
- $this->maintenance_mode(false);
+ $this->maintenance_mode( false );
// Force refresh of plugin update information.
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
- do_action( 'upgrader_process_complete', $this, array(
- 'action' => 'update',
- 'type' => 'plugin',
- 'bulk' => true,
- 'plugins' => $plugins,
- ) );
+ do_action(
+ 'upgrader_process_complete', $this, array(
+ 'action' => 'update',
+ 'type' => 'plugin',
+ 'bulk' => true,
+ 'plugins' => $plugins,
+ )
+ );
$this->skin->bulk_footer();
$this->skin->footer();
// Cleanup our hooks, in case something else does a upgrade on this connection.
- remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'));
+ remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) );
return $results;
}
@@ -327,19 +340,21 @@ class Plugin_Upgrader extends WP_Upgrader {
* @return string|WP_Error The source as passed, or a WP_Error object
* if no plugins were found.
*/
- public function check_package($source) {
+ public function check_package( $source ) {
global $wp_filesystem;
- if ( is_wp_error($source) )
+ if ( is_wp_error( $source ) ) {
return $source;
+ }
- $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source);
- if ( ! is_dir($working_directory) ) // Sanity check, if the above fails, let's not prevent installation.
+ $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source );
+ if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation.
return $source;
+ }
// Check the folder contains at least 1 valid plugin.
$plugins_found = false;
- $files = glob( $working_directory . '*.php' );
+ $files = glob( $working_directory . '*.php' );
if ( $files ) {
foreach ( $files as $file ) {
$info = get_plugin_data( $file, false, false );
@@ -350,8 +365,9 @@ class Plugin_Upgrader extends WP_Upgrader {
}
}
- if ( ! $plugins_found )
+ if ( ! $plugins_found ) {
return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __( 'No valid plugins were found.' ) );
+ }
return $source;
}
@@ -366,16 +382,19 @@ class Plugin_Upgrader extends WP_Upgrader {
* @return string|false The full path to the main plugin file, or false.
*/
public function plugin_info() {
- if ( ! is_array($this->result) )
+ if ( ! is_array( $this->result ) ) {
return false;
- if ( empty($this->result['destination_name']) )
+ }
+ if ( empty( $this->result['destination_name'] ) ) {
return false;
+ }
- $plugin = get_plugins('/' . $this->result['destination_name']); //Ensure to pass with leading slash
- if ( empty($plugin) )
+ $plugin = get_plugins( '/' . $this->result['destination_name'] ); //Ensure to pass with leading slash
+ if ( empty( $plugin ) ) {
return false;
+ }
- $pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
+ $pluginfiles = array_keys( $plugin ); //Assume the requested plugin is the first in the list
return $this->result['destination_name'] . '/' . $pluginfiles[0];
}
@@ -392,22 +411,25 @@ class Plugin_Upgrader extends WP_Upgrader {
* @param array $plugin Plugin package arguments.
* @return bool|WP_Error The passed in $return param or WP_Error.
*/
- public function deactivate_plugin_before_upgrade($return, $plugin) {
+ public function deactivate_plugin_before_upgrade( $return, $plugin ) {
- if ( is_wp_error($return) ) //Bypass.
+ if ( is_wp_error( $return ) ) { //Bypass.
return $return;
+ }
// When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it
- if ( wp_doing_cron() )
+ if ( wp_doing_cron() ) {
return $return;
+ }
- $plugin = isset($plugin['plugin']) ? $plugin['plugin'] : '';
- if ( empty($plugin) )
- return new WP_Error('bad_request', $this->strings['bad_request']);
+ $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
+ if ( empty( $plugin ) ) {
+ return new WP_Error( 'bad_request', $this->strings['bad_request'] );
+ }
- if ( is_plugin_active($plugin) ) {
+ if ( is_plugin_active( $plugin ) ) {
//Deactivate the plugin silently, Prevent deactivation hooks from running.
- deactivate_plugins($plugin, true);
+ deactivate_plugins( $plugin, true );
}
return $return;
@@ -422,37 +444,42 @@ class Plugin_Upgrader extends WP_Upgrader {
* @since 2.8.0
*
* @global WP_Filesystem_Base $wp_filesystem Subclass
- *
+ *
* @param bool|WP_Error $removed
* @param string $local_destination
* @param string $remote_destination
* @param array $plugin
* @return WP_Error|bool
*/
- public function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) {
+ public function delete_old_plugin( $removed, $local_destination, $remote_destination, $plugin ) {
global $wp_filesystem;
- if ( is_wp_error($removed) )
+ if ( is_wp_error( $removed ) ) {
return $removed; //Pass errors through.
+ }
- $plugin = isset($plugin['plugin']) ? $plugin['plugin'] : '';
- if ( empty($plugin) )
- return new WP_Error('bad_request', $this->strings['bad_request']);
+ $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
+ if ( empty( $plugin ) ) {
+ return new WP_Error( 'bad_request', $this->strings['bad_request'] );
+ }
- $plugins_dir = $wp_filesystem->wp_plugins_dir();
- $this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin) );
+ $plugins_dir = $wp_filesystem->wp_plugins_dir();
+ $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin ) );
- if ( ! $wp_filesystem->exists($this_plugin_dir) ) //If it's already vanished.
+ if ( ! $wp_filesystem->exists( $this_plugin_dir ) ) { //If it's already vanished.
return $removed;
+ }
// If plugin is in its own directory, recursively delete the directory.
- if ( strpos($plugin, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory separator AND that it's not the root plugin folder
- $deleted = $wp_filesystem->delete($this_plugin_dir, true);
- else
- $deleted = $wp_filesystem->delete($plugins_dir . $plugin);
+ if ( strpos( $plugin, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder
+ $deleted = $wp_filesystem->delete( $this_plugin_dir, true );
+ } else {
+ $deleted = $wp_filesystem->delete( $plugins_dir . $plugin );
+ }
- if ( ! $deleted )
- return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
+ if ( ! $deleted ) {
+ return new WP_Error( 'remove_old_failed', $this->strings['remove_old_failed'] );
+ }
return true;
}
diff --git a/wp-admin/includes/class-theme-installer-skin.php b/wp-admin/includes/class-theme-installer-skin.php
index 3d39492226..32302fea5d 100644
--- a/wp-admin/includes/class-theme-installer-skin.php
+++ b/wp-admin/includes/class-theme-installer-skin.php
@@ -20,53 +20,63 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
public $type;
/**
- *
* @param array $args
*/
- public function __construct($args = array()) {
- $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
- $args = wp_parse_args($args, $defaults);
+ public function __construct( $args = array() ) {
+ $defaults = array(
+ 'type' => 'web',
+ 'url' => '',
+ 'theme' => '',
+ 'nonce' => '',
+ 'title' => '',
+ );
+ $args = wp_parse_args( $args, $defaults );
$this->type = $args['type'];
- $this->api = isset($args['api']) ? $args['api'] : array();
+ $this->api = isset( $args['api'] ) ? $args['api'] : array();
- parent::__construct($args);
+ parent::__construct( $args );
}
/**
*/
public function before() {
- if ( !empty($this->api) )
- $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version);
+ if ( ! empty( $this->api ) ) {
+ $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version );
+ }
}
/**
*/
public function after() {
- if ( empty($this->upgrader->result['destination_name']) )
+ if ( empty( $this->upgrader->result['destination_name'] ) ) {
return;
+ }
$theme_info = $this->upgrader->theme_info();
- if ( empty( $theme_info ) )
+ if ( empty( $theme_info ) ) {
return;
+ }
- $name = $theme_info->display('Name');
+ $name = $theme_info->display( 'Name' );
$stylesheet = $this->upgrader->result['destination_name'];
$template = $theme_info->get_template();
- $activate_link = add_query_arg( array(
- 'action' => 'activate',
- 'template' => urlencode( $template ),
- 'stylesheet' => urlencode( $stylesheet ),
- ), admin_url('themes.php') );
+ $activate_link = add_query_arg(
+ array(
+ 'action' => 'activate',
+ 'template' => urlencode( $template ),
+ 'stylesheet' => urlencode( $stylesheet ),
+ ), admin_url( 'themes.php' )
+ );
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
$install_actions = array();
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
- $customize_url = add_query_arg(
+ $customize_url = add_query_arg(
array(
- 'theme' => urlencode( $stylesheet ),
+ 'theme' => urlencode( $stylesheet ),
'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ),
),
admin_url( 'customize.php' )
@@ -75,16 +85,19 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
}
$install_actions['activate'] = '' . __( 'Activate' ) . ' ' . sprintf( __( 'Activate “%s”' ), $name ) . ' ';
- if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
+ if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) {
$install_actions['network_enable'] = '' . __( 'Network Enable' ) . ' ';
+ }
- if ( $this->type == 'web' )
+ if ( $this->type == 'web' ) {
$install_actions['themes_page'] = '' . __( 'Return to Theme Installer' ) . ' ';
- elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
+ } elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) {
$install_actions['themes_page'] = '' . __( 'Return to Themes page' ) . ' ';
+ }
- if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) )
+ if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) {
unset( $install_actions['activate'], $install_actions['preview'] );
+ }
/**
* Filters the list of action links available following a single theme installation.
@@ -97,7 +110,8 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
* @param WP_Theme $theme_info Theme object.
*/
$install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info );
- if ( ! empty($install_actions) )
- $this->feedback(implode(' | ', (array)$install_actions));
+ if ( ! empty( $install_actions ) ) {
+ $this->feedback( implode( ' | ', (array) $install_actions ) );
+ }
}
}
diff --git a/wp-admin/includes/class-theme-upgrader-skin.php b/wp-admin/includes/class-theme-upgrader-skin.php
index f92375745f..b5f03017ca 100644
--- a/wp-admin/includes/class-theme-upgrader-skin.php
+++ b/wp-admin/includes/class-theme-upgrader-skin.php
@@ -19,16 +19,20 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
public $theme = '';
/**
- *
* @param array $args
*/
- public function __construct($args = array()) {
- $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') );
- $args = wp_parse_args($args, $defaults);
+ public function __construct( $args = array() ) {
+ $defaults = array(
+ 'url' => '',
+ 'theme' => '',
+ 'nonce' => '',
+ 'title' => __( 'Update Theme' ),
+ );
+ $args = wp_parse_args( $args, $defaults );
$this->theme = $args['theme'];
- parent::__construct($args);
+ parent::__construct( $args );
}
/**
@@ -38,27 +42,29 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
$update_actions = array();
if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
- $name = $theme_info->display('Name');
+ $name = $theme_info->display( 'Name' );
$stylesheet = $this->upgrader->result['destination_name'];
$template = $theme_info->get_template();
- $activate_link = add_query_arg( array(
- 'action' => 'activate',
- 'template' => urlencode( $template ),
- 'stylesheet' => urlencode( $stylesheet ),
- ), admin_url('themes.php') );
+ $activate_link = add_query_arg(
+ array(
+ 'action' => 'activate',
+ 'template' => urlencode( $template ),
+ 'stylesheet' => urlencode( $stylesheet ),
+ ), admin_url( 'themes.php' )
+ );
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
$customize_url = add_query_arg(
array(
- 'theme' => urlencode( $stylesheet ),
+ 'theme' => urlencode( $stylesheet ),
'return' => urlencode( admin_url( 'themes.php' ) ),
),
admin_url( 'customize.php' )
);
if ( get_stylesheet() == $stylesheet ) {
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
- $update_actions['preview'] = '' . __( 'Customize' ) . ' ' . sprintf( __( 'Customize “%s”' ), $name ) . ' ';
+ $update_actions['preview'] = '' . __( 'Customize' ) . ' ' . sprintf( __( 'Customize “%s”' ), $name ) . ' ';
}
} elseif ( current_user_can( 'switch_themes' ) ) {
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
@@ -67,8 +73,9 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
$update_actions['activate'] = '' . __( 'Activate' ) . ' ' . sprintf( __( 'Activate “%s”' ), $name ) . ' ';
}
- if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() )
+ if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) {
unset( $update_actions['preview'], $update_actions['activate'] );
+ }
}
$update_actions['themes_page'] = '' . __( 'Return to Themes page' ) . ' ';
@@ -83,7 +90,8 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
*/
$update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme );
- if ( ! empty($update_actions) )
- $this->feedback(implode(' | ', (array)$update_actions));
+ if ( ! empty( $update_actions ) ) {
+ $this->feedback( implode( ' | ', (array) $update_actions ) );
+ }
}
}
diff --git a/wp-admin/includes/class-theme-upgrader.php b/wp-admin/includes/class-theme-upgrader.php
index 7e46b5f5a2..390398a8d4 100644
--- a/wp-admin/includes/class-theme-upgrader.php
+++ b/wp-admin/includes/class-theme-upgrader.php
@@ -43,15 +43,15 @@ class Theme_Upgrader extends WP_Upgrader {
* @since 2.8.0
*/
public function upgrade_strings() {
- $this->strings['up_to_date'] = __('The theme is at the latest version.');
- $this->strings['no_package'] = __('Update package not available.');
+ $this->strings['up_to_date'] = __( 'The theme is at the latest version.' );
+ $this->strings['no_package'] = __( 'Update package not available.' );
/* translators: %s: package URL */
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '%s ' );
- $this->strings['unpack_package'] = __('Unpacking the update…');
- $this->strings['remove_old'] = __('Removing the old version of the theme…');
- $this->strings['remove_old_failed'] = __('Could not remove the old theme.');
- $this->strings['process_failed'] = __('Theme update failed.');
- $this->strings['process_success'] = __('Theme updated successfully.');
+ $this->strings['unpack_package'] = __( 'Unpacking the update…' );
+ $this->strings['remove_old'] = __( 'Removing the old version of the theme…' );
+ $this->strings['remove_old_failed'] = __( 'Could not remove the old theme.' );
+ $this->strings['process_failed'] = __( 'Theme update failed.' );
+ $this->strings['process_success'] = __( 'Theme updated successfully.' );
}
/**
@@ -60,23 +60,23 @@ class Theme_Upgrader extends WP_Upgrader {
* @since 2.8.0
*/
public function install_strings() {
- $this->strings['no_package'] = __('Installation package not available.');
+ $this->strings['no_package'] = __( 'Installation package not available.' );
/* translators: %s: package URL */
$this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '%s ' );
- $this->strings['unpack_package'] = __('Unpacking the package…');
- $this->strings['installing_package'] = __('Installing the theme…');
- $this->strings['no_files'] = __('The theme contains no files.');
- $this->strings['process_failed'] = __('Theme installation failed.');
- $this->strings['process_success'] = __('Theme installed successfully.');
+ $this->strings['unpack_package'] = __( 'Unpacking the package…' );
+ $this->strings['installing_package'] = __( 'Installing the theme…' );
+ $this->strings['no_files'] = __( 'The theme contains no files.' );
+ $this->strings['process_failed'] = __( 'Theme installation failed.' );
+ $this->strings['process_success'] = __( 'Theme installed successfully.' );
/* translators: 1: theme name, 2: version */
- $this->strings['process_success_specific'] = __('Successfully installed the theme %1$s %2$s .');
- $this->strings['parent_theme_search'] = __('This theme requires a parent theme. Checking if it is installed…');
+ $this->strings['process_success_specific'] = __( 'Successfully installed the theme %1$s %2$s .' );
+ $this->strings['parent_theme_search'] = __( 'This theme requires a parent theme. Checking if it is installed…' );
/* translators: 1: theme name, 2: version */
- $this->strings['parent_theme_prepare_install'] = __('Preparing to install %1$s %2$s …');
+ $this->strings['parent_theme_prepare_install'] = __( 'Preparing to install %1$s %2$s …' );
/* translators: 1: theme name, 2: version */
- $this->strings['parent_theme_currently_installed'] = __('The parent theme, %1$s %2$s , is currently installed.');
+ $this->strings['parent_theme_currently_installed'] = __( 'The parent theme, %1$s %2$s , is currently installed.' );
/* translators: 1: theme name, 2: version */
- $this->strings['parent_theme_install_success'] = __('Successfully installed the parent theme, %1$s %2$s .');
+ $this->strings['parent_theme_install_success'] = __( 'Successfully installed the parent theme, %1$s %2$s .' );
/* translators: %s: theme name */
$this->strings['parent_theme_not_found'] = sprintf( __( 'The parent theme could not be found. You will need to install the parent theme, %s, before you can use this child theme.' ), '%s ' );
}
@@ -97,56 +97,68 @@ class Theme_Upgrader extends WP_Upgrader {
// Check to see if we need to install a parent theme
$theme_info = $this->theme_info();
- if ( ! $theme_info->parent() )
+ if ( ! $theme_info->parent() ) {
return $install_result;
+ }
$this->skin->feedback( 'parent_theme_search' );
if ( ! $theme_info->parent()->errors() ) {
- $this->skin->feedback( 'parent_theme_currently_installed', $theme_info->parent()->display('Name'), $theme_info->parent()->display('Version') );
+ $this->skin->feedback( 'parent_theme_currently_installed', $theme_info->parent()->display( 'Name' ), $theme_info->parent()->display( 'Version' ) );
// We already have the theme, fall through.
return $install_result;
}
// We don't have the parent theme, let's install it.
- $api = themes_api('theme_information', array('slug' => $theme_info->get('Template'), 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth.
+ $api = themes_api(
+ 'theme_information', array(
+ 'slug' => $theme_info->get( 'Template' ),
+ 'fields' => array(
+ 'sections' => false,
+ 'tags' => false,
+ ),
+ )
+ ); //Save on a bit of bandwidth.
- if ( ! $api || is_wp_error($api) ) {
- $this->skin->feedback( 'parent_theme_not_found', $theme_info->get('Template') );
+ if ( ! $api || is_wp_error( $api ) ) {
+ $this->skin->feedback( 'parent_theme_not_found', $theme_info->get( 'Template' ) );
// Don't show activate or preview actions after installation
- add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions') );
+ add_filter( 'install_theme_complete_actions', array( $this, 'hide_activate_preview_actions' ) );
return $install_result;
}
// Backup required data we're going to override:
- $child_api = $this->skin->api;
+ $child_api = $this->skin->api;
$child_success_message = $this->strings['process_success'];
// Override them
- $this->skin->api = $api;
+ $this->skin->api = $api;
$this->strings['process_success_specific'] = $this->strings['parent_theme_install_success'];//, $api->name, $api->version);
- $this->skin->feedback('parent_theme_prepare_install', $api->name, $api->version);
+ $this->skin->feedback( 'parent_theme_prepare_install', $api->name, $api->version );
- add_filter('install_theme_complete_actions', '__return_false', 999); // Don't show any actions after installing the theme.
+ add_filter( 'install_theme_complete_actions', '__return_false', 999 ); // Don't show any actions after installing the theme.
// Install the parent theme
- $parent_result = $this->run( array(
- 'package' => $api->download_link,
- 'destination' => get_theme_root(),
- 'clear_destination' => false, //Do not overwrite files.
- 'clear_working' => true
- ) );
+ $parent_result = $this->run(
+ array(
+ 'package' => $api->download_link,
+ 'destination' => get_theme_root(),
+ 'clear_destination' => false, //Do not overwrite files.
+ 'clear_working' => true,
+ )
+ );
- if ( is_wp_error($parent_result) )
- add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions') );
+ if ( is_wp_error( $parent_result ) ) {
+ add_filter( 'install_theme_complete_actions', array( $this, 'hide_activate_preview_actions' ) );
+ }
// Start cleaning up after the parents installation
- remove_filter('install_theme_complete_actions', '__return_false', 999);
+ remove_filter( 'install_theme_complete_actions', '__return_false', 999 );
// Reset child's result and data
- $this->result = $child_result;
- $this->skin->api = $child_api;
+ $this->result = $child_result;
+ $this->skin->api = $child_api;
$this->strings['process_success'] = $child_success_message;
return $install_result;
@@ -165,7 +177,7 @@ class Theme_Upgrader extends WP_Upgrader {
* @return array
*/
public function hide_activate_preview_actions( $actions ) {
- unset($actions['activate'], $actions['preview']);
+ unset( $actions['activate'], $actions['preview'] );
return $actions;
}
@@ -187,7 +199,7 @@ class Theme_Upgrader extends WP_Upgrader {
*/
public function install( $package, $args = array() ) {
- $defaults = array(
+ $defaults = array(
'clear_update_cache' => true,
);
$parsed_args = wp_parse_args( $args, $defaults );
@@ -195,30 +207,33 @@ class Theme_Upgrader extends WP_Upgrader {
$this->init();
$this->install_strings();
- add_filter('upgrader_source_selection', array($this, 'check_package') );
- add_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'), 10, 3);
+ add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
+ add_filter( 'upgrader_post_install', array( $this, 'check_parent_theme_filter' ), 10, 3 );
if ( $parsed_args['clear_update_cache'] ) {
// Clear cache so wp_update_themes() knows about the new theme.
add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
}
- $this->run( array(
- 'package' => $package,
- 'destination' => get_theme_root(),
- 'clear_destination' => false, //Do not overwrite files.
- 'clear_working' => true,
- 'hook_extra' => array(
- 'type' => 'theme',
- 'action' => 'install',
- ),
- ) );
+ $this->run(
+ array(
+ 'package' => $package,
+ 'destination' => get_theme_root(),
+ 'clear_destination' => false, //Do not overwrite files.
+ 'clear_working' => true,
+ 'hook_extra' => array(
+ 'type' => 'theme',
+ 'action' => 'install',
+ ),
+ )
+ );
remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );
- remove_filter('upgrader_source_selection', array($this, 'check_package') );
- remove_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'));
+ remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
+ remove_filter( 'upgrader_post_install', array( $this, 'check_parent_theme_filter' ) );
- if ( ! $this->result || is_wp_error($this->result) )
+ if ( ! $this->result || is_wp_error( $this->result ) ) {
return $this->result;
+ }
// Refresh the Theme Update information
wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
@@ -243,7 +258,7 @@ class Theme_Upgrader extends WP_Upgrader {
*/
public function upgrade( $theme, $args = array() ) {
- $defaults = array(
+ $defaults = array(
'clear_update_cache' => true,
);
$parsed_args = wp_parse_args( $args, $defaults );
@@ -253,9 +268,9 @@ class Theme_Upgrader extends WP_Upgrader {
// Is an update available?
$current = get_site_transient( 'update_themes' );
- if ( !isset( $current->response[ $theme ] ) ) {
+ if ( ! isset( $current->response[ $theme ] ) ) {
$this->skin->before();
- $this->skin->set_result(false);
+ $this->skin->set_result( false );
$this->skin->error( 'up_to_date' );
$this->skin->after();
return false;
@@ -263,33 +278,36 @@ class Theme_Upgrader extends WP_Upgrader {
$r = $current->response[ $theme ];
- add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2);
- add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2);
- add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4);
+ add_filter( 'upgrader_pre_install', array( $this, 'current_before' ), 10, 2 );
+ add_filter( 'upgrader_post_install', array( $this, 'current_after' ), 10, 2 );
+ add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ), 10, 4 );
if ( $parsed_args['clear_update_cache'] ) {
// Clear cache so wp_update_themes() knows about the new theme.
add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
}
- $this->run( array(
- 'package' => $r['package'],
- 'destination' => get_theme_root( $theme ),
- 'clear_destination' => true,
- 'clear_working' => true,
- 'hook_extra' => array(
- 'theme' => $theme,
- 'type' => 'theme',
- 'action' => 'update',
- ),
- ) );
+ $this->run(
+ array(
+ 'package' => $r['package'],
+ 'destination' => get_theme_root( $theme ),
+ 'clear_destination' => true,
+ 'clear_working' => true,
+ 'hook_extra' => array(
+ 'theme' => $theme,
+ 'type' => 'theme',
+ 'action' => 'update',
+ ),
+ )
+ );
remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );
- remove_filter('upgrader_pre_install', array($this, 'current_before'));
- remove_filter('upgrader_post_install', array($this, 'current_after'));
- remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme'));
+ remove_filter( 'upgrader_pre_install', array( $this, 'current_before' ) );
+ remove_filter( 'upgrader_post_install', array( $this, 'current_after' ) );
+ remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ) );
- if ( ! $this->result || is_wp_error($this->result) )
+ if ( ! $this->result || is_wp_error( $this->result ) ) {
return $this->result;
+ }
wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
@@ -313,7 +331,7 @@ class Theme_Upgrader extends WP_Upgrader {
*/
public function bulk_upgrade( $themes, $args = array() ) {
- $defaults = array(
+ $defaults = array(
'clear_update_cache' => true,
);
$parsed_args = wp_parse_args( $args, $defaults );
@@ -324,14 +342,14 @@ class Theme_Upgrader extends WP_Upgrader {
$current = get_site_transient( 'update_themes' );
- add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2);
- add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2);
- add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4);
+ add_filter( 'upgrader_pre_install', array( $this, 'current_before' ), 10, 2 );
+ add_filter( 'upgrader_post_install', array( $this, 'current_after' ), 10, 2 );
+ add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ), 10, 4 );
$this->skin->header();
// Connect to the Filesystem first.
- $res = $this->fs_connect( array(WP_CONTENT_DIR) );
+ $res = $this->fs_connect( array( WP_CONTENT_DIR ) );
if ( ! $res ) {
$this->skin->footer();
return false;
@@ -344,71 +362,78 @@ class Theme_Upgrader extends WP_Upgrader {
// - a theme with an update available is currently in use.
// @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible.
$maintenance = ( is_multisite() && ! empty( $themes ) );
- foreach ( $themes as $theme )
+ foreach ( $themes as $theme ) {
$maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template();
- if ( $maintenance )
- $this->maintenance_mode(true);
+ }
+ if ( $maintenance ) {
+ $this->maintenance_mode( true );
+ }
$results = array();
- $this->update_count = count($themes);
+ $this->update_count = count( $themes );
$this->update_current = 0;
foreach ( $themes as $theme ) {
$this->update_current++;
- $this->skin->theme_info = $this->theme_info($theme);
+ $this->skin->theme_info = $this->theme_info( $theme );
- if ( !isset( $current->response[ $theme ] ) ) {
- $this->skin->set_result(true);
+ if ( ! isset( $current->response[ $theme ] ) ) {
+ $this->skin->set_result( true );
$this->skin->before();
$this->skin->feedback( 'up_to_date' );
$this->skin->after();
- $results[$theme] = true;
+ $results[ $theme ] = true;
continue;
}
// Get the URL to the zip file
$r = $current->response[ $theme ];
- $result = $this->run( array(
- 'package' => $r['package'],
- 'destination' => get_theme_root( $theme ),
- 'clear_destination' => true,
- 'clear_working' => true,
- 'is_multi' => true,
- 'hook_extra' => array(
- 'theme' => $theme
- ),
- ) );
+ $result = $this->run(
+ array(
+ 'package' => $r['package'],
+ 'destination' => get_theme_root( $theme ),
+ 'clear_destination' => true,
+ 'clear_working' => true,
+ 'is_multi' => true,
+ 'hook_extra' => array(
+ 'theme' => $theme,
+ ),
+ )
+ );
- $results[$theme] = $this->result;
+ $results[ $theme ] = $this->result;
// Prevent credentials auth screen from displaying multiple times
- if ( false === $result )
+ if ( false === $result ) {
break;
+ }
} //end foreach $plugins
- $this->maintenance_mode(false);
+ $this->maintenance_mode( false );
// Refresh the Theme Update information
wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
- do_action( 'upgrader_process_complete', $this, array(
- 'action' => 'update',
- 'type' => 'theme',
- 'bulk' => true,
- 'themes' => $themes,
- ) );
+ do_action(
+ 'upgrader_process_complete', $this, array(
+ 'action' => 'update',
+ 'type' => 'theme',
+ 'bulk' => true,
+ 'themes' => $themes,
+ )
+ );
$this->skin->bulk_footer();
$this->skin->footer();
// Cleanup our hooks, in case something else does a upgrade on this connection.
- remove_filter('upgrader_pre_install', array($this, 'current_before'));
- remove_filter('upgrader_post_install', array($this, 'current_after'));
- remove_filter('upgrader_clear_destination', array($this, 'delete_old_theme'));
+ remove_filter( 'upgrader_pre_install', array( $this, 'current_before' ) );
+ remove_filter( 'upgrader_post_install', array( $this, 'current_after' ) );
+ remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ) );
return $results;
}
@@ -430,30 +455,41 @@ class Theme_Upgrader extends WP_Upgrader {
public function check_package( $source ) {
global $wp_filesystem;
- if ( is_wp_error($source) )
+ if ( is_wp_error( $source ) ) {
return $source;
+ }
// Check the folder contains a valid theme
- $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source);
- if ( ! is_dir($working_directory) ) // Sanity check, if the above fails, let's not prevent installation.
+ $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source );
+ if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation.
return $source;
+ }
// A proper archive should have a style.css file in the single subdirectory
if ( ! file_exists( $working_directory . 'style.css' ) ) {
- return new WP_Error( 'incompatible_archive_theme_no_style', $this->strings['incompatible_archive'],
+ return new WP_Error(
+ 'incompatible_archive_theme_no_style', $this->strings['incompatible_archive'],
/* translators: %s: style.css */
- sprintf( __( 'The theme is missing the %s stylesheet.' ),
+ sprintf(
+ __( 'The theme is missing the %s stylesheet.' ),
'style.css
'
)
);
}
- $info = get_file_data( $working_directory . 'style.css', array( 'Name' => 'Theme Name', 'Template' => 'Template' ) );
+ $info = get_file_data(
+ $working_directory . 'style.css', array(
+ 'Name' => 'Theme Name',
+ 'Template' => 'Template',
+ )
+ );
if ( empty( $info['Name'] ) ) {
- return new WP_Error( 'incompatible_archive_theme_no_name', $this->strings['incompatible_archive'],
+ return new WP_Error(
+ 'incompatible_archive_theme_no_name', $this->strings['incompatible_archive'],
/* translators: %s: style.css */
- sprintf( __( 'The %s stylesheet doesn’t contain a valid theme header.' ),
+ sprintf(
+ __( 'The %s stylesheet doesn’t contain a valid theme header.' ),
'style.css
'
)
);
@@ -461,9 +497,11 @@ class Theme_Upgrader extends WP_Upgrader {
// If it's not a child theme, it must have at least an index.php to be legit.
if ( empty( $info['Template'] ) && ! file_exists( $working_directory . 'index.php' ) ) {
- return new WP_Error( 'incompatible_archive_theme_no_index', $this->strings['incompatible_archive'],
+ return new WP_Error(
+ 'incompatible_archive_theme_no_index', $this->strings['incompatible_archive'],
/* translators: %s: index.php */
- sprintf( __( 'The theme is missing the %s file.' ),
+ sprintf(
+ __( 'The theme is missing the %s file.' ),
'index.php
'
)
);
@@ -484,17 +522,20 @@ class Theme_Upgrader extends WP_Upgrader {
* @param array $theme
* @return bool|WP_Error
*/
- public function current_before($return, $theme) {
- if ( is_wp_error($return) )
+ public function current_before( $return, $theme ) {
+ if ( is_wp_error( $return ) ) {
return $return;
+ }
- $theme = isset($theme['theme']) ? $theme['theme'] : '';
+ $theme = isset( $theme['theme'] ) ? $theme['theme'] : '';
- if ( $theme != get_stylesheet() ) //If not current
+ if ( $theme != get_stylesheet() ) { //If not current
return $return;
+ }
//Change to maintenance mode now.
- if ( ! $this->bulk )
- $this->maintenance_mode(true);
+ if ( ! $this->bulk ) {
+ $this->maintenance_mode( true );
+ }
return $return;
}
@@ -511,14 +552,16 @@ class Theme_Upgrader extends WP_Upgrader {
* @param array $theme
* @return bool|WP_Error
*/
- public function current_after($return, $theme) {
- if ( is_wp_error($return) )
+ public function current_after( $return, $theme ) {
+ if ( is_wp_error( $return ) ) {
return $return;
+ }
- $theme = isset($theme['theme']) ? $theme['theme'] : '';
+ $theme = isset( $theme['theme'] ) ? $theme['theme'] : '';
- if ( $theme != get_stylesheet() ) // If not current
+ if ( $theme != get_stylesheet() ) { // If not current
return $return;
+ }
// Ensure stylesheet name hasn't changed after the upgrade:
if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) {
@@ -528,8 +571,9 @@ class Theme_Upgrader extends WP_Upgrader {
}
//Time to remove maintenance mode
- if ( ! $this->bulk )
- $this->maintenance_mode(false);
+ if ( ! $this->bulk ) {
+ $this->maintenance_mode( false );
+ }
return $return;
}
@@ -552,17 +596,20 @@ class Theme_Upgrader extends WP_Upgrader {
public function delete_old_theme( $removed, $local_destination, $remote_destination, $theme ) {
global $wp_filesystem;
- if ( is_wp_error( $removed ) )
+ if ( is_wp_error( $removed ) ) {
return $removed; // Pass errors through.
+ }
- if ( ! isset( $theme['theme'] ) )
+ if ( ! isset( $theme['theme'] ) ) {
return $removed;
+ }
- $theme = $theme['theme'];
+ $theme = $theme['theme'];
$themes_dir = trailingslashit( $wp_filesystem->wp_themes_dir( $theme ) );
if ( $wp_filesystem->exists( $themes_dir . $theme ) ) {
- if ( ! $wp_filesystem->delete( $themes_dir . $theme, true ) )
+ if ( ! $wp_filesystem->delete( $themes_dir . $theme, true ) ) {
return false;
+ }
}
return true;
@@ -579,13 +626,14 @@ class Theme_Upgrader extends WP_Upgrader {
* @return WP_Theme|false The theme's info object, or false `$theme` is not supplied
* and the last result isn't set.
*/
- public function theme_info($theme = null) {
+ public function theme_info( $theme = null ) {
- if ( empty($theme) ) {
- if ( !empty($this->result['destination_name']) )
+ if ( empty( $theme ) ) {
+ if ( ! empty( $this->result['destination_name'] ) ) {
$theme = $this->result['destination_name'];
- else
+ } else {
return false;
+ }
}
return wp_get_theme( $theme );
}
diff --git a/wp-admin/includes/class-walker-category-checklist.php b/wp-admin/includes/class-walker-category-checklist.php
index cd5e1572c6..d8719debf4 100644
--- a/wp-admin/includes/class-walker-category-checklist.php
+++ b/wp-admin/includes/class-walker-category-checklist.php
@@ -18,7 +18,10 @@
*/
class Walker_Category_Checklist extends Walker {
public $tree_type = 'category';
- public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
+ public $db_fields = array(
+ 'parent' => 'parent',
+ 'id' => 'term_id',
+ ); //TODO: decouple this
/**
* Starts the list before the elements are added.
@@ -32,7 +35,7 @@ class Walker_Category_Checklist extends Walker {
* @param array $args An array of arguments. @see wp_terms_checklist()
*/
public function start_lvl( &$output, $depth = 0, $args = array() ) {
- $indent = str_repeat("\t", $depth);
+ $indent = str_repeat( "\t", $depth );
$output .= "$indent\n";
}
@@ -48,7 +51,7 @@ class Walker_Category_Checklist extends Walker {
* @param array $args An array of arguments. @see wp_terms_checklist()
*/
public function end_lvl( &$output, $depth = 0, $args = array() ) {
- $indent = str_repeat("\t", $depth);
+ $indent = str_repeat( "\t", $depth );
$output .= "$indent \n";
}
@@ -79,13 +82,13 @@ class Walker_Category_Checklist extends Walker {
}
$args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
- $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
+ $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
$args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
if ( ! empty( $args['list_only'] ) ) {
$aria_checked = 'false';
- $inner_class = 'category';
+ $inner_class = 'category';
if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
$inner_class .= ' selected';
@@ -100,7 +103,7 @@ class Walker_Category_Checklist extends Walker {
} else {
/** This filter is documented in wp-includes/category-template.php */
$output .= "\n" .
- ' term_id, $args['selected_cats'] ), true, false ) .
disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . ' ';
diff --git a/wp-admin/includes/class-walker-nav-menu-checklist.php b/wp-admin/includes/class-walker-nav-menu-checklist.php
index a4d8018dcc..881e9e7192 100644
--- a/wp-admin/includes/class-walker-nav-menu-checklist.php
+++ b/wp-admin/includes/class-walker-nav-menu-checklist.php
@@ -15,7 +15,6 @@
*/
class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
/**
- *
* @param array $fields
*/
public function __construct( $fields = false ) {
@@ -36,7 +35,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
* @param array $args Not used.
*/
public function start_lvl( &$output, $depth = 0, $args = array() ) {
- $indent = str_repeat( "\t", $depth );
+ $indent = str_repeat( "\t", $depth );
$output .= "\n$indent\n";
}
@@ -52,7 +51,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
* @param array $args Not used.
*/
public function end_lvl( &$output, $depth = 0, $args = array() ) {
- $indent = str_repeat( "\t", $depth );
+ $indent = str_repeat( "\t", $depth );
$output .= "\n$indent ";
}
@@ -74,9 +73,9 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
global $_nav_menu_placeholder;
- $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
- $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
- $possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
+ $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1;
+ $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
+ $possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
@@ -84,34 +83,36 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
$output .= '';
+ $output .= '';
// Menu item hidden fields
$output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
- $output .= '';
+ $output .= '';
+ $output .= '';
+ $output .= '';
+ $output .= '';
+ $output .= '';
+ $output .= '';
+ $output .= '';
+ $output .= '';
+ $output .= '';
}
} // Walker_Nav_Menu_Checklist
diff --git a/wp-admin/includes/class-walker-nav-menu-edit.php b/wp-admin/includes/class-walker-nav-menu-edit.php
index 36ced4034d..d53c0c8988 100644
--- a/wp-admin/includes/class-walker-nav-menu-edit.php
+++ b/wp-admin/includes/class-walker-nav-menu-edit.php
@@ -60,7 +60,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
ob_start();
- $item_id = esc_attr( $item->ID );
+ $item_id = esc_attr( $item->ID );
$removed_args = array(
'action',
'customlink-tab',
@@ -73,11 +73,12 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
$original_title = false;
if ( 'taxonomy' == $item->type ) {
$original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
- if ( is_wp_error( $original_title ) )
+ if ( is_wp_error( $original_title ) ) {
$original_title = false;
+ }
} elseif ( 'post_type' == $item->type ) {
$original_object = get_post( $item->object_id );
- $original_title = get_the_title( $original_object->ID );
+ $original_title = get_the_title( $original_object->ID );
} elseif ( 'post_type_archive' == $item->type ) {
$original_object = get_post_type_object( $item->object );
if ( $original_object ) {
@@ -88,7 +89,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
$classes = array(
'menu-item menu-item-depth-' . $depth,
'menu-item-' . esc_attr( $item->object ),
- 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'),
+ 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive' ),
);
$title = $item->title;
@@ -100,52 +101,59 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
} elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
$classes[] = 'pending';
/* translators: %s: title of menu item in draft status */
- $title = sprintf( __('%s (Pending)'), $item->title );
+ $title = sprintf( __( '%s (Pending)' ), $item->title );
}
$title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
$submenu_text = '';
- if ( 0 == $depth )
+ if ( 0 == $depth ) {
$submenu_text = 'style="display: none;"';
+ }
?>
-