Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/wp-admin/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@
// Looks like an importer is installed, but not active.
$plugins = get_plugins( '/' . $plugin_slug );
if ( ! empty( $plugins ) ) {
$keys = array_keys( $plugins );
$plugin_file = $plugin_slug . '/' . $keys[0];
$plugin_file = $plugin_slug . '/' . array_key_first( $plugins );
$url = wp_nonce_url(
add_query_arg(
array(
Expand Down
4 changes: 1 addition & 3 deletions src/wp-admin/includes/class-plugin-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,7 @@ public function plugin_info() {
}

// Assume the requested plugin is the first in the list.
$plugin_files = array_keys( $plugin );

return $this->result['destination_name'] . '/' . $plugin_files[0];
return $this->result['destination_name'] . '/' . array_key_first( $plugin );
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/wp-admin/includes/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,7 @@ function media_upload_form_handler() {
$errors = null;

if ( isset( $_POST['send'] ) ) {
$keys = array_keys( $_POST['send'] );
$send_id = (int) reset( $keys );
$send_id = (int) array_key_first( $_POST['send'] );
}

if ( ! empty( $_POST['attachments'] ) ) {
Expand Down Expand Up @@ -1643,8 +1642,7 @@ function get_media_item( $attachment_id, $args = null ) {
$title = esc_attr( $post->post_title );

$post_mime_types = get_post_mime_types();
$keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) );
$type = reset( $keys );
$type = array_key_first( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) );
$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";

$form_fields = get_attachment_fields_to_edit( $post, $parsed_args['errors'] );
Expand Down
3 changes: 1 addition & 2 deletions src/wp-admin/includes/plugin-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,7 @@ function install_plugin_information() {
// Default to the Description tab, Do not translate, API returns English.
$section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description';
if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) {
$section_titles = array_keys( (array) $api->sections );
$section = reset( $section_titles );
$section = array_key_first( (array) $api->sections );
}

iframe_header( __( 'Plugin Installation' ) );
Expand Down
3 changes: 1 addition & 2 deletions src/wp-admin/includes/revision.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,7 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
if ( ! $compare_two_mode ) {
$found = array_search( $selected_revision_id, array_keys( $revisions ), true );
if ( $found ) {
$from = array_keys( array_slice( $revisions, $found - 1, 1, true ) );
$from = reset( $from );
$from = array_key_first( array_slice( $revisions, $found - 1, 1, true ) );
} else {
$from = 0;
}
Expand Down
3 changes: 1 addition & 2 deletions src/wp-admin/plugin-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
$plugin = $file;
}
} else {
$plugin = array_keys( $plugins );
$plugin = $plugin[0];
$plugin = array_key_first( $plugins );
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/wp-admin/widgets-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@

if ( isset( $_GET['addnew'] ) ) {
// Default to the first sidebar.
$keys = array_keys( $wp_registered_sidebars );
$sidebar = reset( $keys );
$sidebar = array_key_first( $wp_registered_sidebars );

if ( isset( $_GET['base'] ) && isset( $_GET['num'] ) ) { // Multi-widget.
// Copy minimal info from an existing instance of this widget to a new instance.
Expand Down
5 changes: 2 additions & 3 deletions src/wp-includes/class-wp-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -4013,9 +4013,8 @@ public function get_queried_object() {
} else {
// For other tax queries, grab the first term from the first clause.
if ( ! empty( $this->tax_query->queried_terms ) ) {
$queried_taxonomies = array_keys( $this->tax_query->queried_terms );
$matched_taxonomy = reset( $queried_taxonomies );
$query = $this->tax_query->queried_terms[ $matched_taxonomy ];
$matched_taxonomy = array_key_first( $this->tax_query->queried_terms );
$query = $this->tax_query->queried_terms[ $matched_taxonomy ];

if ( ! empty( $query['terms'] ) ) {
if ( 'term_id' === $query['field'] ) {
Expand Down
6 changes: 2 additions & 4 deletions src/wp-includes/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,7 @@ function spawn_cron( $gmt_time = 0 ) {
return false;
}

$keys = array_keys( $crons );
if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) {
if ( array_key_first( $crons ) > $gmt_time ) {
return false;
}

Expand Down Expand Up @@ -1059,8 +1058,7 @@ function _wp_cron() {
}

$gmt_time = microtime( true );
$keys = array_keys( $crons );
if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) {
if ( array_key_first( $crons ) > $gmt_time ) {
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ protected function find_plugin_for_slug( $slug ) {
return '';
}

$plugin_files = array_keys( $plugin_files );

return $slug . '/' . reset( $plugin_files );
return $slug . '/' . array_key_first( $plugin_files );
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/wp-includes/widgets/class-wp-widget-tag-cloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ public function form( $instance ) {

// Just a single tag cloud supporting taxonomy found, no need to display a select.
case 1:
$keys = array_keys( $taxonomies );
$taxonomy = reset( $keys );
$taxonomy = array_key_first( $taxonomies );
?>
<input type="hidden" id="<?php echo $this->get_field_id( 'taxonomy' ); ?>" name="<?php echo $this->get_field_name( 'taxonomy' ); ?>" value="<?php echo esc_attr( $taxonomy ); ?>" />
<?php
Expand Down
Loading