--- a/wp/wp-admin/includes/template.php Mon Oct 14 18:06:33 2019 +0200
+++ b/wp/wp-admin/includes/template.php Mon Oct 14 18:28:13 2019 +0200
@@ -29,8 +29,8 @@
* $selected_cats must not be an array. Default 0.
* @param int $descendants_and_self Optional. ID of the category to output along with its descendants.
* Default 0.
- * @param array $selected_cats Optional. List of categories to mark as checked. Default false.
- * @param array $popular_cats Optional. List of categories to receive the "popular-category" class.
+ * @param int[] $selected_cats Optional. Array of category IDs to mark as checked. Default false.
+ * @param int[] $popular_cats Optional. Array of category IDs to receive the "popular-category" class.
* Default false.
* @param object $walker Optional. Walker object to use to build the output.
* Default is a Walker_Category_Checklist instance.
@@ -38,14 +38,17 @@
* the top of the list. Default true.
*/
function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
- wp_terms_checklist( $post_id, array(
- 'taxonomy' => 'category',
- 'descendants_and_self' => $descendants_and_self,
- 'selected_cats' => $selected_cats,
- 'popular_cats' => $popular_cats,
- 'walker' => $walker,
- 'checked_ontop' => $checked_ontop
- ) );
+ wp_terms_checklist(
+ $post_id,
+ array(
+ 'taxonomy' => 'category',
+ 'descendants_and_self' => $descendants_and_self,
+ 'selected_cats' => $selected_cats,
+ 'popular_cats' => $popular_cats,
+ 'walker' => $walker,
+ 'checked_ontop' => $checked_ontop,
+ )
+ );
}
/**
@@ -62,8 +65,8 @@
*
* @type int $descendants_and_self ID of the category to output along with its descendants.
* Default 0.
- * @type array $selected_cats List of categories to mark as checked. Default false.
- * @type array $popular_cats List of categories to receive the "popular-category" class.
+ * @type int[] $selected_cats Array of category IDs to mark as checked. Default false.
+ * @type int[] $popular_cats Array of category IDs to receive the "popular-category" class.
* Default false.
* @type object $walker Walker object to use to build the output.
* Default is a Walker_Category_Checklist instance.
@@ -75,14 +78,14 @@
* }
*/
function wp_terms_checklist( $post_id = 0, $args = array() ) {
- $defaults = array(
+ $defaults = array(
'descendants_and_self' => 0,
- 'selected_cats' => false,
- 'popular_cats' => false,
- 'walker' => null,
- 'taxonomy' => 'category',
- 'checked_ontop' => true,
- 'echo' => true,
+ 'selected_cats' => false,
+ 'popular_cats' => false,
+ 'walker' => null,
+ 'taxonomy' => 'category',
+ 'checked_ontop' => true,
+ 'echo' => true,
);
/**
@@ -105,12 +108,12 @@
$walker = $r['walker'];
}
- $taxonomy = $r['taxonomy'];
+ $taxonomy = $r['taxonomy'];
$descendants_and_self = (int) $r['descendants_and_self'];
$args = array( 'taxonomy' => $taxonomy );
- $tax = get_taxonomy( $taxonomy );
+ $tax = get_taxonomy( $taxonomy );
$args['disabled'] = ! current_user_can( $tax->cap->assign_terms );
$args['list_only'] = ! empty( $r['list_only'] );
@@ -125,21 +128,27 @@
if ( is_array( $r['popular_cats'] ) ) {
$args['popular_cats'] = $r['popular_cats'];
} else {
- $args['popular_cats'] = get_terms( $taxonomy, array(
- 'fields' => 'ids',
- 'orderby' => 'count',
- 'order' => 'DESC',
- 'number' => 10,
- 'hierarchical' => false
- ) );
+ $args['popular_cats'] = get_terms(
+ $taxonomy,
+ array(
+ 'fields' => 'ids',
+ 'orderby' => 'count',
+ 'order' => 'DESC',
+ 'number' => 10,
+ 'hierarchical' => false,
+ )
+ );
}
if ( $descendants_and_self ) {
- $categories = (array) get_terms( $taxonomy, array(
- 'child_of' => $descendants_and_self,
- 'hierarchical' => 0,
- 'hide_empty' => 0
- ) );
- $self = get_term( $descendants_and_self, $taxonomy );
+ $categories = (array) get_terms(
+ $taxonomy,
+ array(
+ 'child_of' => $descendants_and_self,
+ 'hierarchical' => 0,
+ 'hide_empty' => 0,
+ )
+ );
+ $self = get_term( $descendants_and_self, $taxonomy );
array_unshift( $categories, $self );
} else {
$categories = (array) get_terms( $taxonomy, array( 'get' => 'all' ) );
@@ -150,12 +159,12 @@
if ( $r['checked_ontop'] ) {
// Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
$checked_categories = array();
- $keys = array_keys( $categories );
+ $keys = array_keys( $categories );
foreach ( $keys as $k ) {
- if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
- $checked_categories[] = $categories[$k];
- unset( $categories[$k] );
+ if ( in_array( $categories[ $k ]->term_id, $args['selected_cats'] ) ) {
+ $checked_categories[] = $categories[ $k ];
+ unset( $categories[ $k ] );
}
}
@@ -191,21 +200,31 @@
function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
$post = get_post();
- if ( $post && $post->ID )
- $checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids'));
- else
+ if ( $post && $post->ID ) {
+ $checked_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
+ } else {
$checked_terms = array();
+ }
- $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
+ $terms = get_terms(
+ $taxonomy,
+ array(
+ 'orderby' => 'count',
+ 'order' => 'DESC',
+ 'number' => $number,
+ 'hierarchical' => false,
+ )
+ );
- $tax = get_taxonomy($taxonomy);
+ $tax = get_taxonomy( $taxonomy );
$popular_ids = array();
foreach ( (array) $terms as $term ) {
$popular_ids[] = $term->term_id;
- if ( !$echo ) // Hack for Ajax use.
+ if ( ! $echo ) { // Hack for Ajax use.
continue;
- $id = "popular-$taxonomy-$term->term_id";
+ }
+ $id = "popular-$taxonomy-$term->term_id";
$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
?>
@@ -246,18 +265,25 @@
$checked_categories[] = $default;
}
- $categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
+ $categories = get_terms(
+ 'link_category',
+ array(
+ 'orderby' => 'name',
+ 'hide_empty' => 0,
+ )
+ );
- if ( empty( $categories ) )
+ if ( empty( $categories ) ) {
return;
+ }
foreach ( $categories as $category ) {
$cat_id = $category->term_id;
/** This filter is documented in wp-includes/category-template.php */
- $name = esc_html( apply_filters( 'the_category', $category->name, '', '' ) );
+ $name = esc_html( apply_filters( 'the_category', $category->name, '', '' ) );
$checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
- echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, "</label></li>";
+ echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, '</label></li>';
}
}
@@ -268,10 +294,11 @@
*
* @param WP_Post $post Post object.
*/
-function get_inline_data($post) {
- $post_type_object = get_post_type_object($post->post_type);
- if ( ! current_user_can( 'edit_post', $post->ID ) )
+function get_inline_data( $post ) {
+ $post_type_object = get_post_type_object( $post->post_type );
+ if ( ! current_user_can( 'edit_post', $post->ID ) ) {
return;
+ }
$title = esc_textarea( trim( $post->post_title ) );
@@ -304,7 +331,7 @@
}
$taxonomy_names = get_object_taxonomies( $post->post_type );
- foreach ( $taxonomy_names as $taxonomy_name) {
+ foreach ( $taxonomy_names as $taxonomy_name ) {
$taxonomy = get_taxonomy( $taxonomy_name );
if ( $taxonomy->hierarchical && $taxonomy->show_ui ) {
@@ -325,17 +352,19 @@
$terms_to_edit = '';
}
- echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
+ echo '<div class="tags_input" id="' . $taxonomy_name . '_' . $post->ID . '">'
. esc_html( str_replace( ',', ', ', $terms_to_edit ) ) . '</div>';
}
}
- if ( !$post_type_object->hierarchical )
- echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
+ if ( ! $post_type_object->hierarchical ) {
+ echo '<div class="sticky">' . ( is_sticky( $post->ID ) ? 'sticky' : '' ) . '</div>';
+ }
- if ( post_type_supports( $post->post_type, 'post-formats' ) )
+ if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>';
+ }
/**
* Fires after outputting the fields for the inline editor for posts and pages.
@@ -379,24 +408,32 @@
* @param string $content The reply-to form content.
* @param array $args An array of default args.
*/
- $content = apply_filters( 'wp_comment_reply', '', array( 'position' => $position, 'checkbox' => $checkbox, 'mode' => $mode ) );
+ $content = apply_filters(
+ 'wp_comment_reply',
+ '',
+ array(
+ 'position' => $position,
+ 'checkbox' => $checkbox,
+ 'mode' => $mode,
+ )
+ );
- if ( ! empty($content) ) {
+ if ( ! empty( $content ) ) {
echo $content;
return;
}
if ( ! $wp_list_table ) {
if ( $mode == 'single' ) {
- $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
+ $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );
} else {
- $wp_list_table = _get_list_table('WP_Comments_List_Table');
+ $wp_list_table = _get_list_table( 'WP_Comments_List_Table' );
}
}
-?>
+ ?>
<form method="get">
-<?php if ( $table_row ) : ?>
+ <?php if ( $table_row ) : ?>
<table style="display:none;"><tbody id="com-reply"><tr id="replyrow" class="inline-edit-row" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange">
<?php else : ?>
<div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
@@ -412,38 +449,45 @@
<label for="replycontent" class="screen-reader-text"><?php _e( 'Comment' ); ?></label>
<?php
$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
- wp_editor( '', 'replycontent', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings ) );
+ wp_editor(
+ '',
+ 'replycontent',
+ array(
+ 'media_buttons' => false,
+ 'tinymce' => false,
+ 'quicktags' => $quicktags_settings,
+ )
+ );
?>
</div>
<div id="edithead" style="display:none;">
<div class="inside">
- <label for="author-name"><?php _e( 'Name' ) ?></label>
+ <label for="author-name"><?php _e( 'Name' ); ?></label>
<input type="text" name="newcomment_author" size="50" value="" id="author-name" />
</div>
<div class="inside">
- <label for="author-email"><?php _e('Email') ?></label>
+ <label for="author-email"><?php _e( 'Email' ); ?></label>
<input type="text" name="newcomment_author_email" size="50" value="" id="author-email" />
</div>
<div class="inside">
- <label for="author-url"><?php _e('URL') ?></label>
+ <label for="author-url"><?php _e( 'URL' ); ?></label>
<input type="text" id="author-url" name="newcomment_author_url" class="code" size="103" value="" />
</div>
</div>
<div id="replysubmit" class="submit">
- <p>
- <a href="#comments-form" class="save button button-primary alignright">
+ <p class="reply-submit-buttons">
+ <button type="button" class="save button button-primary">
<span id="addbtn" style="display: none;"><?php _e( 'Add Comment' ); ?></span>
<span id="savebtn" style="display: none;"><?php _e( 'Update Comment' ); ?></span>
<span id="replybtn" style="display: none;"><?php _e( 'Submit Reply' ); ?></span>
- </a>
- <a href="#comments-form" class="cancel button alignleft"><?php _e( 'Cancel' ); ?></a>
+ </button>
+ <button type="button" class="cancel button"><?php _e( 'Cancel' ); ?></button>
<span class="waiting spinner"></span>
</p>
- <br class="clear" />
<div class="notice notice-error notice-alt inline hidden">
<p class="error"></p>
</div>
@@ -455,20 +499,21 @@
<input type="hidden" name="status" id="status" value="" />
<input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
<input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
- <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
+ <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr( $mode ); ?>" />
<?php
wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false );
- if ( current_user_can( 'unfiltered_html' ) )
- wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false );
+ if ( current_user_can( 'unfiltered_html' ) ) {
+ wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false );
+ }
?>
</fieldset>
-<?php if ( $table_row ) : ?>
+ <?php if ( $table_row ) : ?>
</td></tr></tbody></table>
-<?php else : ?>
+ <?php else : ?>
</div></div>
-<?php endif; ?>
+ <?php endif; ?>
</form>
-<?php
+ <?php
}
/**
@@ -477,14 +522,14 @@
* @since 2.9.0
*/
function wp_comment_trashnotice() {
-?>
+ ?>
<div class="hidden" id="trash-undo-holder">
- <div class="trash-undo-inside"><?php printf(__('Comment by %s moved to the trash.'), '<strong></strong>'); ?> <span class="undo untrash"><a href="#"><?php _e('Undo'); ?></a></span></div>
+ <div class="trash-undo-inside"><?php printf( __( 'Comment by %s moved to the trash.' ), '<strong></strong>' ); ?> <span class="undo untrash"><a href="#"><?php _e( 'Undo' ); ?></a></span></div>
</div>
<div class="hidden" id="spam-undo-holder">
- <div class="spam-undo-inside"><?php printf(__('Comment by %s marked as spam.'), '<strong></strong>'); ?> <span class="undo unspam"><a href="#"><?php _e('Undo'); ?></a></span></div>
+ <div class="spam-undo-inside"><?php printf( __( 'Comment by %s marked as spam.' ), '<strong></strong>' ); ?> <span class="undo unspam"><a href="#"><?php _e( 'Undo' ); ?></a></span></div>
</div>
-<?php
+ <?php
}
/**
@@ -512,22 +557,23 @@
return;
}
$count = 0;
-?>
+ ?>
<table id="list-table">
<thead>
<tr>
- <th class="left"><?php _ex( 'Name', 'meta name' ) ?></th>
- <th><?php _e( 'Value' ) ?></th>
+ <th class="left"><?php _ex( 'Name', 'meta name' ); ?></th>
+ <th><?php _e( 'Value' ); ?></th>
</tr>
</thead>
<tbody id='the-list' data-wp-lists='list:meta'>
-<?php
- foreach ( $meta as $entry )
+ <?php
+ foreach ( $meta as $entry ) {
echo _list_meta_row( $entry, $count );
-?>
+ }
+ ?>
</tbody>
</table>
-<?php
+ <?php
}
/**
@@ -544,11 +590,13 @@
function _list_meta_row( $entry, &$count ) {
static $update_nonce = '';
- if ( is_protected_meta( $entry['meta_key'], 'post' ) )
+ if ( is_protected_meta( $entry['meta_key'], 'post' ) ) {
return '';
+ }
- if ( ! $update_nonce )
+ if ( ! $update_nonce ) {
$update_nonce = wp_create_nonce( 'add-meta' );
+ }
$r = '';
++ $count;
@@ -564,9 +612,9 @@
}
}
- $entry['meta_key'] = esc_attr($entry['meta_key']);
+ $entry['meta_key'] = esc_attr( $entry['meta_key'] );
$entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a <textarea />
- $entry['meta_id'] = (int) $entry['meta_id'];
+ $entry['meta_id'] = (int) $entry['meta_id'];
$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
@@ -577,9 +625,9 @@
$r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) );
$r .= "\n\t\t";
$r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) );
- $r .= "</div>";
+ $r .= '</div>';
$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
- $r .= "</td>";
+ $r .= '</td>';
$r .= "\n\t\t<td><label class='screen-reader-text' for='meta-{$entry['meta_id']}-value'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta-{$entry['meta_id']}-value' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
return $r;
@@ -621,13 +669,13 @@
* @param int $limit Number of custom fields to retrieve. Default 30.
*/
$limit = apply_filters( 'postmeta_form_limit', 30 );
- $sql = "SELECT DISTINCT meta_key
+ $sql = "SELECT DISTINCT meta_key
FROM $wpdb->postmeta
WHERE meta_key NOT BETWEEN '_' AND '_z'
HAVING meta_key NOT LIKE %s
ORDER BY meta_key
LIMIT %d";
- $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
+ $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
}
if ( $keys ) {
@@ -636,35 +684,36 @@
} else {
$meta_key_input_id = 'metakeyinput';
}
-?>
-<p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p>
+ ?>
+<p><strong><?php _e( 'Add New Custom Field:' ); ?></strong></p>
<table id="newmeta">
<thead>
<tr>
-<th class="left"><label for="<?php echo $meta_key_input_id; ?>"><?php _ex( 'Name', 'meta name' ) ?></label></th>
-<th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
+<th class="left"><label for="<?php echo $meta_key_input_id; ?>"><?php _ex( 'Name', 'meta name' ); ?></label></th>
+<th><label for="metavalue"><?php _e( 'Value' ); ?></label></th>
</tr>
</thead>
<tbody>
<tr>
<td id="newmetaleft" class="left">
-<?php if ( $keys ) { ?>
+ <?php if ( $keys ) { ?>
<select id="metakeyselect" name="metakeyselect">
<option value="#NONE#"><?php _e( '— Select —' ); ?></option>
-<?php
+ <?php
- foreach ( $keys as $key ) {
- if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) )
- continue;
- echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>";
- }
-?>
+ foreach ( $keys as $key ) {
+ if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) ) {
+ continue;
+ }
+ echo "\n<option value='" . esc_attr( $key ) . "'>" . esc_html( $key ) . '</option>';
+ }
+ ?>
</select>
<input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" value="" />
<a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
-<span id="enternew"><?php _e('Enter new'); ?></span>
-<span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
+<span id="enternew"><?php _e( 'Enter new' ); ?></span>
+<span id="cancelnew" class="hidden"><?php _e( 'Cancel' ); ?></span></a>
<?php } else { ?>
<input type="text" id="metakeyinput" name="metakeyinput" value="" />
<?php } ?>
@@ -674,13 +723,24 @@
<tr><td colspan="2">
<div class="submit">
-<?php submit_button( __( 'Add Custom Field' ), '', 'addmeta', false, array( 'id' => 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta' ) ); ?>
+ <?php
+ submit_button(
+ __( 'Add Custom Field' ),
+ '',
+ 'addmeta',
+ false,
+ array(
+ 'id' => 'newmeta-submit',
+ 'data-wp-lists' => 'add:the-list:newmeta',
+ )
+ );
+ ?>
</div>
-<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
+ <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
</td></tr>
</tbody>
</table>
-<?php
+ <?php
}
@@ -702,44 +762,45 @@
global $wp_locale;
$post = get_post();
- if ( $for_post )
- $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
+ if ( $for_post ) {
+ $edit = ! ( in_array( $post->post_status, array( 'draft', 'pending' ) ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
+ }
$tab_index_attribute = '';
- if ( (int) $tab_index > 0 )
+ if ( (int) $tab_index > 0 ) {
$tab_index_attribute = " tabindex=\"$tab_index\"";
+ }
// todo: Remove this?
// echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
- $time_adj = current_time('timestamp');
- $post_date = ($for_post) ? $post->post_date : get_comment()->comment_date;
- $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
- $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
- $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
- $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
- $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
- $ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
+ $post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date;
+ $jj = ( $edit ) ? mysql2date( 'd', $post_date, false ) : current_time( 'd' );
+ $mm = ( $edit ) ? mysql2date( 'm', $post_date, false ) : current_time( 'm' );
+ $aa = ( $edit ) ? mysql2date( 'Y', $post_date, false ) : current_time( 'Y' );
+ $hh = ( $edit ) ? mysql2date( 'H', $post_date, false ) : current_time( 'H' );
+ $mn = ( $edit ) ? mysql2date( 'i', $post_date, false ) : current_time( 'i' );
+ $ss = ( $edit ) ? mysql2date( 's', $post_date, false ) : current_time( 's' );
- $cur_jj = gmdate( 'd', $time_adj );
- $cur_mm = gmdate( 'm', $time_adj );
- $cur_aa = gmdate( 'Y', $time_adj );
- $cur_hh = gmdate( 'H', $time_adj );
- $cur_mn = gmdate( 'i', $time_adj );
+ $cur_jj = current_time( 'd' );
+ $cur_mm = current_time( 'm' );
+ $cur_aa = current_time( 'Y' );
+ $cur_hh = current_time( 'H' );
+ $cur_mn = current_time( 'i' );
$month = '<label><span class="screen-reader-text">' . __( 'Month' ) . '</span><select ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n";
- for ( $i = 1; $i < 13; $i = $i +1 ) {
- $monthnum = zeroise($i, 2);
+ for ( $i = 1; $i < 13; $i = $i + 1 ) {
+ $monthnum = zeroise( $i, 2 );
$monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
- $month .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum, $mm, false ) . '>';
+ $month .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum, $mm, false ) . '>';
/* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
$month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $monthtext ) . "</option>\n";
}
$month .= '</select></label>';
- $day = '<label><span class="screen-reader-text">' . __( 'Day' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
- $year = '<label><span class="screen-reader-text">' . __( 'Year' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" /></label>';
- $hour = '<label><span class="screen-reader-text">' . __( 'Hour' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
+ $day = '<label><span class="screen-reader-text">' . __( 'Day' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
+ $year = '<label><span class="screen-reader-text">' . __( 'Year' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" /></label>';
+ $hour = '<label><span class="screen-reader-text">' . __( 'Hour' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
$minute = '<label><span class="screen-reader-text">' . __( 'Minute' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
echo '<div class="timestamp-wrap">';
@@ -748,7 +809,9 @@
echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
- if ( $multi ) return;
+ if ( $multi ) {
+ return;
+ }
echo "\n\n";
$map = array(
@@ -765,13 +828,13 @@
$cur_timeunit = 'cur_' . $timeunit;
echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n";
}
-?>
+ ?>
<p>
-<a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
-<a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js button-cancel"><?php _e('Cancel'); ?></a>
+<a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e( 'OK' ); ?></a>
+<a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js button-cancel"><?php _e( 'Cancel' ); ?></a>
</p>
-<?php
+ <?php
}
/**
@@ -788,7 +851,7 @@
ksort( $templates );
foreach ( array_keys( $templates ) as $template ) {
$selected = selected( $default, $templates[ $template ], false );
- echo "\n\t<option value='" . esc_attr( $templates[ $template ] ) . "' $selected>" . esc_html( $template ) . "</option>";
+ echo "\n\t<option value='" . esc_attr( $templates[ $template ] ) . "' $selected>" . esc_html( $template ) . '</option>';
}
}
@@ -805,24 +868,25 @@
* @param int $level Optional. Page depth level. Default 0.
* @param int|WP_Post $post Post ID or WP_Post object.
*
- * @return null|false Boolean False if page has no children, otherwise print out html elements
+ * @return null|false Boolean False if page has no children, otherwise print out html elements.
*/
function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = null ) {
global $wpdb;
- $post = get_post( $post );
- $items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) );
+ $post = get_post( $post );
+ $items = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent ) );
if ( $items ) {
foreach ( $items as $item ) {
// A page cannot be its own parent.
- if ( $post && $post->ID && $item->ID == $post->ID )
+ if ( $post && $post->ID && $item->ID == $post->ID ) {
continue;
+ }
- $pad = str_repeat( ' ', $level * 3 );
+ $pad = str_repeat( ' ', $level * 3 );
$selected = selected( $default, $item->ID, false );
- echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html($item->post_title) . "</option>";
- parent_dropdown( $default, $item->ID, $level +1 );
+ echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html( $item->post_title ) . '</option>';
+ parent_dropdown( $default, $item->ID, $level + 1 );
}
} else {
return false;
@@ -842,7 +906,7 @@
$editable_roles = array_reverse( get_editable_roles() );
foreach ( $editable_roles as $role => $details ) {
- $name = translate_user_role($details['name'] );
+ $name = translate_user_role( $details['name'] );
// preselect specified role
if ( $selected == $role ) {
$r .= "\n\t<option selected='selected' value='" . esc_attr( $role ) . "'>$name</option>";
@@ -872,24 +936,26 @@
*
* @param int $max_upload_size Allowed upload size. Default 1 MB.
*/
- $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
- $size = size_format( $bytes );
+ $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
+ $size = size_format( $bytes );
$upload_dir = wp_upload_dir();
if ( ! empty( $upload_dir['error'] ) ) :
- ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
- <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
+ ?>
+ <div class="error"><p><?php _e( 'Before you can upload your import file, you will need to fix the following error:' ); ?></p>
+ <p><strong><?php echo $upload_dir['error']; ?></strong></p></div>
+ <?php
else :
-?>
+ ?>
<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>">
<p>
-<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
+<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __( 'Maximum size: %s' ), $size ); ?>)
<input type="file" id="upload" name="import" size="25" />
<input type="hidden" name="action" value="save" />
<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
</p>
-<?php submit_button( __('Upload file and import'), 'primary' ); ?>
+ <?php submit_button( __( 'Upload file and import' ), 'primary' ); ?>
</form>
-<?php
+ <?php
endif;
}
@@ -943,63 +1009,181 @@
$page = $screen->id;
- if ( !isset($wp_meta_boxes) )
+ if ( ! isset( $wp_meta_boxes ) ) {
$wp_meta_boxes = array();
- if ( !isset($wp_meta_boxes[$page]) )
- $wp_meta_boxes[$page] = array();
- if ( !isset($wp_meta_boxes[$page][$context]) )
- $wp_meta_boxes[$page][$context] = array();
+ }
+ if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
+ $wp_meta_boxes[ $page ] = array();
+ }
+ if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
+ $wp_meta_boxes[ $page ][ $context ] = array();
+ }
- foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
- foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
- if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
+ foreach ( array_keys( $wp_meta_boxes[ $page ] ) as $a_context ) {
+ foreach ( array( 'high', 'core', 'default', 'low' ) as $a_priority ) {
+ if ( ! isset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) ) {
continue;
+ }
// If a core box was previously added or removed by a plugin, don't add.
if ( 'core' == $priority ) {
// If core box previously deleted, don't add
- if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
+ if ( false === $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) {
return;
+ }
/*
* If box was added with default priority, give it core priority to
* maintain sort order.
*/
if ( 'default' == $a_priority ) {
- $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
- unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
+ $wp_meta_boxes[ $page ][ $a_context ]['core'][ $id ] = $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ];
+ unset( $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ] );
}
return;
}
// If no priority given and id already present, use existing priority.
- if ( empty($priority) ) {
+ if ( empty( $priority ) ) {
$priority = $a_priority;
- /*
- * Else, if we're adding to the sorted priority, we don't know the title
- * or callback. Grab them from the previously added context/priority.
- */
+ /*
+ * Else, if we're adding to the sorted priority, we don't know the title
+ * or callback. Grab them from the previously added context/priority.
+ */
} elseif ( 'sorted' == $priority ) {
- $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
- $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
- $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
+ $title = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['title'];
+ $callback = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['callback'];
+ $callback_args = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['args'];
}
// An id can be in only one priority and one context.
- if ( $priority != $a_priority || $context != $a_context )
- unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
+ if ( $priority != $a_priority || $context != $a_context ) {
+ unset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] );
+ }
}
}
- if ( empty($priority) )
+ if ( empty( $priority ) ) {
$priority = 'low';
+ }
+
+ if ( ! isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
+ $wp_meta_boxes[ $page ][ $context ][ $priority ] = array();
+ }
+
+ $wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = array(
+ 'id' => $id,
+ 'title' => $title,
+ 'callback' => $callback,
+ 'args' => $callback_args,
+ );
+}
+
- if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
- $wp_meta_boxes[$page][$context][$priority] = array();
+/**
+ * Function that renders a "fake" meta box with an information message,
+ * shown on the block editor, when an incompatible meta box is found.
+ *
+ * @since 5.0.0
+ *
+ * @param mixed $object The data object being rendered on this screen.
+ * @param array $box {
+ * Custom formats meta box arguments.
+ *
+ * @type string $id Meta box 'id' attribute.
+ * @type string $title Meta box title.
+ * @type callable $old_callback The original callback for this meta box.
+ * @type array $args Extra meta box arguments.
+ * }
+ */
+function do_block_editor_incompatible_meta_box( $object, $box ) {
+ $plugin = _get_plugin_from_callback( $box['old_callback'] );
+ $plugins = get_plugins();
+ echo '<p>';
+ if ( $plugin ) {
+ /* translators: %s: the name of the plugin that generated this meta box. */
+ printf( __( "This meta box, from the %s plugin, isn't compatible with the block editor." ), "<strong>{$plugin['Name']}</strong>" );
+ } else {
+ _e( "This meta box isn't compatible with the block editor." );
+ }
+ echo '</p>';
- $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
+ if ( empty( $plugins['classic-editor/classic-editor.php'] ) ) {
+ if ( current_user_can( 'install_plugins' ) ) {
+ echo '<p>';
+ /* translators: %s: A link to install the Classic Editor plugin. */
+ printf( __( 'Please install the <a href="%s">Classic Editor plugin</a> to use this meta box.' ), esc_url( self_admin_url( 'plugin-install.php?tab=featured' ) ) );
+ echo '</p>';
+ }
+ } elseif ( is_plugin_inactive( 'classic-editor/classic-editor.php' ) ) {
+ if ( current_user_can( 'activate_plugins' ) ) {
+ $activate_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=classic-editor/classic-editor.php' ), 'activate-plugin_classic-editor/classic-editor.php' );
+ echo '<p>';
+ /* translators: %s: A link to activate the Classic Editor plugin. */
+ printf( __( 'Please activate the <a href="%s">Classic Editor plugin</a> to use this meta box.' ), esc_url( $activate_url ) );
+ echo '</p>';
+ }
+ } elseif ( $object instanceof WP_Post ) {
+ $edit_url = add_query_arg(
+ array(
+ 'classic-editor' => '',
+ 'classic-editor__forget' => '',
+ ),
+ get_edit_post_link( $object )
+ );
+ echo '<p>';
+ /* translators: %s: A link to use the Classic Editor plugin. */
+ printf( __( 'Please open the <a href="%s">classic editor</a> to use this meta box.' ), esc_url( $edit_url ) );
+ echo '</p>';
+ }
}
/**
- * Meta-Box template function
+ * Internal helper function to find the plugin from a meta box callback.
+ *
+ * @since 5.0.0
+ *
+ * @access private
+ *
+ * @param callable $callback The callback function to check.
+ * @return array|null The plugin that the callback belongs to, or null if it doesn't belong to a plugin.
+ */
+function _get_plugin_from_callback( $callback ) {
+ try {
+ if ( is_array( $callback ) ) {
+ $reflection = new ReflectionMethod( $callback[0], $callback[1] );
+ } elseif ( is_string( $callback ) && false !== strpos( $callback, '::' ) ) {
+ $reflection = new ReflectionMethod( $callback );
+ } else {
+ $reflection = new ReflectionFunction( $callback );
+ }
+ } catch ( ReflectionException $exception ) {
+ // We could not properly reflect on the callable, so we abort here.
+ return null;
+ }
+
+ // Don't show an error if it's an internal PHP function.
+ if ( ! $reflection->isInternal() ) {
+
+ // Only show errors if the meta box was registered by a plugin.
+ $filename = wp_normalize_path( $reflection->getFileName() );
+ $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
+ if ( strpos( $filename, $plugin_dir ) === 0 ) {
+ $filename = str_replace( $plugin_dir, '', $filename );
+ $filename = preg_replace( '|^/([^/]*/).*$|', '\\1', $filename );
+
+ $plugins = get_plugins();
+ foreach ( $plugins as $name => $plugin ) {
+ if ( strpos( $name, $filename ) === 0 ) {
+ return $plugin;
+ }
+ }
+ }
+ }
+
+ return null;
+}
+
+/**
+ * Meta-Box template function.
*
* @since 2.5.0
*
@@ -1011,18 +1195,21 @@
* add_submenu_page() to create a new screen (and hence screen_id)
* make sure your menu slug conforms to the limits of sanitize_key()
* otherwise the 'screen' menu may not correctly render on your page.
- * @param string $context box context
- * @param mixed $object gets passed to the box callback function as first parameter
+ * @param string $context The screen context for which to display meta boxes.
+ * @param mixed $object Gets passed to the first parameter of the meta box callback function.
+ * Often this is the object that's the focus of the current screen, for
+ * example a `WP_Post` or `WP_Comment` object.
* @return int number of meta_boxes
*/
function do_meta_boxes( $screen, $context, $object ) {
global $wp_meta_boxes;
static $already_sorted = false;
- if ( empty( $screen ) )
+ if ( empty( $screen ) ) {
$screen = get_current_screen();
- elseif ( is_string( $screen ) )
+ } elseif ( is_string( $screen ) ) {
$screen = convert_to_screen( $screen );
+ }
$page = $screen->id;
@@ -1047,20 +1234,47 @@
if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) {
- if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ]) ) {
+ if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
- if ( false == $box || ! $box['title'] )
+ if ( false == $box || ! $box['title'] ) {
continue;
+ }
+
+ $block_compatible = true;
+ if ( is_array( $box['args'] ) ) {
+ // If a meta box is just here for back compat, don't show it in the block editor.
+ if ( $screen->is_block_editor() && isset( $box['args']['__back_compat_meta_box'] ) && $box['args']['__back_compat_meta_box'] ) {
+ continue;
+ }
+
+ if ( isset( $box['args']['__block_editor_compatible_meta_box'] ) ) {
+ $block_compatible = (bool) $box['args']['__block_editor_compatible_meta_box'];
+ unset( $box['args']['__block_editor_compatible_meta_box'] );
+ }
+
+ // If the meta box is declared as incompatible with the block editor, override the callback function.
+ if ( ! $block_compatible && $screen->is_block_editor() ) {
+ $box['old_callback'] = $box['callback'];
+ $box['callback'] = 'do_block_editor_incompatible_meta_box';
+ }
+
+ if ( isset( $box['args']['__back_compat_meta_box'] ) ) {
+ $block_compatible = $block_compatible || (bool) $box['args']['__back_compat_meta_box'];
+ unset( $box['args']['__back_compat_meta_box'] );
+ }
+ }
+
$i++;
- $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
- echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n";
+ // get_hidden_meta_boxes() doesn't apply in the block editor.
+ $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden ) ) ? ' hide-if-js' : '';
+ echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>' . "\n";
if ( 'dashboard_browser_nag' != $box['id'] ) {
- $widget_title = $box[ 'title' ];
+ $widget_title = $box['title'];
- if ( is_array( $box[ 'args' ] ) && isset( $box[ 'args' ][ '__widget_basename' ] ) ) {
- $widget_title = $box[ 'args' ][ '__widget_basename' ];
+ if ( is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) {
+ $widget_title = $box['args']['__widget_basename'];
// Do not pass this parameter to the user callback function.
- unset( $box[ 'args' ][ '__widget_basename' ] );
+ unset( $box['args']['__widget_basename'] );
}
echo '<button type="button" class="handlediv" aria-expanded="true">';
@@ -1068,9 +1282,32 @@
echo '<span class="toggle-indicator" aria-hidden="true"></span>';
echo '</button>';
}
- echo "<h2 class='hndle'><span>{$box['title']}</span></h2>\n";
+ echo '<h2 class="hndle">';
+ if ( 'dashboard_php_nag' === $box['id'] ) {
+ echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>';
+ echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>';
+ }
+ echo "<span>{$box['title']}</span>";
+ echo "</h2>\n";
echo '<div class="inside">' . "\n";
- call_user_func($box['callback'], $object, $box);
+
+ if ( WP_DEBUG && ! $block_compatible && 'edit' === $screen->parent_base && ! $screen->is_block_editor() && ! isset( $_GET['meta-box-loader'] ) ) {
+ $plugin = _get_plugin_from_callback( $box['callback'] );
+ if ( $plugin ) {
+ ?>
+ <div class="error inline">
+ <p>
+ <?php
+ /* translators: %s: the name of the plugin that generated this meta box. */
+ printf( __( "This meta box, from the %s plugin, isn't compatible with the block editor." ), "<strong>{$plugin['Name']}</strong>" );
+ ?>
+ </p>
+ </div>
+ <?php
+ }
+ }
+
+ call_user_func( $box['callback'], $object, $box );
echo "</div>\n";
echo "</div>\n";
}
@@ -1078,7 +1315,7 @@
}
}
- echo "</div>";
+ echo '</div>';
return $i;
@@ -1121,19 +1358,23 @@
$page = $screen->id;
- if ( !isset($wp_meta_boxes) )
+ if ( ! isset( $wp_meta_boxes ) ) {
$wp_meta_boxes = array();
- if ( !isset($wp_meta_boxes[$page]) )
- $wp_meta_boxes[$page] = array();
- if ( !isset($wp_meta_boxes[$page][$context]) )
- $wp_meta_boxes[$page][$context] = array();
+ }
+ if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
+ $wp_meta_boxes[ $page ] = array();
+ }
+ if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
+ $wp_meta_boxes[ $page ][ $context ] = array();
+ }
- foreach ( array('high', 'core', 'default', 'low') as $priority )
- $wp_meta_boxes[$page][$context][$priority][$id] = false;
+ foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
+ $wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false;
+ }
}
/**
- * Meta Box Accordion Template Function
+ * Meta Box Accordion Template Function.
*
* Largely made up of abstracted code from do_meta_boxes(), this
* function serves to build meta boxes as list items for display as
@@ -1153,10 +1394,11 @@
wp_enqueue_script( 'accordion' );
- if ( empty( $screen ) )
+ if ( empty( $screen ) ) {
$screen = get_current_screen();
- elseif ( is_string( $screen ) )
+ } elseif ( is_string( $screen ) ) {
$screen = convert_to_screen( $screen );
+ }
$page = $screen->id;
@@ -1165,15 +1407,16 @@
<div id="side-sortables" class="accordion-container">
<ul class="outer-border">
<?php
- $i = 0;
+ $i = 0;
$first_open = false;
if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
- if ( false == $box || ! $box['title'] )
+ if ( false == $box || ! $box['title'] ) {
continue;
+ }
$i++;
$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
@@ -1211,7 +1454,7 @@
*
* Part of the Settings API. Use this to define new settings sections for an admin page.
* Show settings sections in your admin page callback function with do_settings_sections().
- * Add settings fields to your section with add_settings_field()
+ * Add settings fields to your section with add_settings_field().
*
* The $callback argument should be the name of a function that echoes out any
* content you want to show at the top of the settings section before the actual
@@ -1219,7 +1462,7 @@
*
* @since 2.7.0
*
- * @global $wp_settings_sections Storage array of all settings sections added to admin pages
+ * @global $wp_settings_sections Storage array of all settings sections added to admin pages.
*
* @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags.
* @param string $title Formatted title of the section. Shown as the heading for the section.
@@ -1228,13 +1471,16 @@
* 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using
* add_options_page();
*/
-function add_settings_section($id, $title, $callback, $page) {
+function add_settings_section( $id, $title, $callback, $page ) {
global $wp_settings_sections;
if ( 'misc' == $page ) {
- _deprecated_argument( __FUNCTION__, '3.0.0',
+ _deprecated_argument(
+ __FUNCTION__,
+ '3.0.0',
/* translators: %s: misc */
- sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
+ sprintf(
+ __( 'The "%s" options group has been removed. Use another settings group.' ),
'misc'
)
);
@@ -1242,20 +1488,27 @@
}
if ( 'privacy' == $page ) {
- _deprecated_argument( __FUNCTION__, '3.5.0',
+ _deprecated_argument(
+ __FUNCTION__,
+ '3.5.0',
/* translators: %s: privacy */
- sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
+ sprintf(
+ __( 'The "%s" options group has been removed. Use another settings group.' ),
'privacy'
)
);
$page = 'reading';
}
- $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
+ $wp_settings_sections[ $page ][ $id ] = array(
+ 'id' => $id,
+ 'title' => $title,
+ 'callback' => $callback,
+ );
}
/**
- * Add a new field to a section of a settings page
+ * Add a new field to a section of a settings page.
*
* Part of the Settings API. Use this to define a settings field that will show
* as part of a settings section inside a settings page. The fields are shown using
@@ -1268,7 +1521,7 @@
* @since 2.7.0
* @since 4.2.0 The `$class` argument was added.
*
- * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
+ * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections.
*
* @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
* @param string $title Formatted title of the field. Shown as the label for the field
@@ -1289,13 +1542,16 @@
* field is output.
* }
*/
-function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
+function add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() ) {
global $wp_settings_fields;
if ( 'misc' == $page ) {
- _deprecated_argument( __FUNCTION__, '3.0.0',
+ _deprecated_argument(
+ __FUNCTION__,
+ '3.0.0',
/* translators: %s: misc */
- sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
+ sprintf(
+ __( 'The "%s" options group has been removed. Use another settings group.' ),
'misc'
)
);
@@ -1303,16 +1559,24 @@
}
if ( 'privacy' == $page ) {
- _deprecated_argument( __FUNCTION__, '3.5.0',
+ _deprecated_argument(
+ __FUNCTION__,
+ '3.5.0',
/* translators: %s: privacy */
- sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
+ sprintf(
+ __( 'The "%s" options group has been removed. Use another settings group.' ),
'privacy'
)
);
$page = 'reading';
}
- $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
+ $wp_settings_fields[ $page ][ $section ][ $id ] = array(
+ 'id' => $id,
+ 'title' => $title,
+ 'callback' => $callback,
+ 'args' => $args,
+ );
}
/**
@@ -1322,54 +1586,59 @@
* to output all the sections and fields that were added to that $page with
* add_settings_section() and add_settings_field()
*
- * @global $wp_settings_sections Storage array of all settings sections added to admin pages
- * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
+ * @global $wp_settings_sections Storage array of all settings sections added to admin pages.
+ * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections.
* @since 2.7.0
*
- * @param string $page The slug name of the page whose settings sections you want to output
+ * @param string $page The slug name of the page whose settings sections you want to output.
*/
function do_settings_sections( $page ) {
global $wp_settings_sections, $wp_settings_fields;
- if ( ! isset( $wp_settings_sections[$page] ) )
+ if ( ! isset( $wp_settings_sections[ $page ] ) ) {
return;
+ }
- foreach ( (array) $wp_settings_sections[$page] as $section ) {
- if ( $section['title'] )
+ foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
+ if ( $section['title'] ) {
echo "<h2>{$section['title']}</h2>\n";
+ }
- if ( $section['callback'] )
+ if ( $section['callback'] ) {
call_user_func( $section['callback'], $section );
+ }
- if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) )
+ if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) {
continue;
- echo '<table class="form-table">';
+ }
+ echo '<table class="form-table" role="presentation">';
do_settings_fields( $page, $section['id'] );
echo '</table>';
}
}
/**
- * Print out the settings fields for a particular settings section
+ * Print out the settings fields for a particular settings section.
*
* Part of the Settings API. Use this in a settings page to output
* a specific section. Should normally be called by do_settings_sections()
* rather than directly.
*
- * @global $wp_settings_fields Storage array of settings fields and their pages/sections
+ * @global $wp_settings_fields Storage array of settings fields and their pages/sections.
*
* @since 2.7.0
*
- * @param string $page Slug title of the admin page who's settings fields you want to show.
- * @param string $section Slug title of the settings section who's fields you want to show.
+ * @param string $page Slug title of the admin page whose settings fields you want to show.
+ * @param string $section Slug title of the settings section whose fields you want to show.
*/
-function do_settings_fields($page, $section) {
+function do_settings_fields( $page, $section ) {
global $wp_settings_fields;
- if ( ! isset( $wp_settings_fields[$page][$section] ) )
+ if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
return;
+ }
- foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
+ foreach ( (array) $wp_settings_fields[ $page ][ $section ] as $field ) {
$class = '';
if ( ! empty( $field['args']['class'] ) ) {
@@ -1385,14 +1654,14 @@
}
echo '<td>';
- call_user_func($field['callback'], $field['args']);
+ call_user_func( $field['callback'], $field['args'] );
echo '</td>';
echo '</tr>';
}
}
/**
- * Register a settings error to be displayed to the user
+ * Register a settings error to be displayed to the user.
*
* Part of the Settings API. Use this to show messages to users about settings validation
* problems, missing settings or anything else.
@@ -1408,7 +1677,7 @@
*
* @global array $wp_settings_errors Storage array of errors registered during this pageload
*
- * @param string $setting Slug title of the setting to which this error applies
+ * @param string $setting Slug title of the setting to which this error applies.
* @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
* @param string $message The formatted message text to display to the user (will be shown inside styled
* `<div>` and `<p>` tags).
@@ -1422,12 +1691,12 @@
'setting' => $setting,
'code' => $code,
'message' => $message,
- 'type' => $type
+ 'type' => $type,
);
}
/**
- * Fetch settings errors registered by add_settings_error()
+ * Fetch settings errors registered by add_settings_error().
*
* Checks the $wp_settings_errors array for any errors declared during the current
* pageload and returns them.
@@ -1445,9 +1714,9 @@
*
* @global array $wp_settings_errors Storage array of errors registered during this pageload
*
- * @param string $setting Optional slug title of a specific setting who's errors you want.
+ * @param string $setting Optional slug title of a specific setting whose errors you want.
* @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
- * @return array Array of settings errors
+ * @return array Array of settings errors.
*/
function get_settings_errors( $setting = '', $sanitize = false ) {
global $wp_settings_errors;
@@ -1457,8 +1726,9 @@
* This allows the $sanitize_callback from register_setting() to run, adding
* any settings errors you want to show by default.
*/
- if ( $sanitize )
+ if ( $sanitize ) {
sanitize_option( $setting, get_option( $setting ) );
+ }
// If settings were passed back from options.php then use them.
if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
@@ -1475,8 +1745,9 @@
if ( $setting ) {
$setting_errors = array();
foreach ( (array) $wp_settings_errors as $key => $details ) {
- if ( $setting == $details['setting'] )
- $setting_errors[] = $wp_settings_errors[$key];
+ if ( $setting == $details['setting'] ) {
+ $setting_errors[] = $wp_settings_errors[ $key ];
+ }
}
return $setting_errors;
}
@@ -1506,28 +1777,30 @@
*
* @since 3.0.0
*
- * @param string $setting Optional slug title of a specific setting who's errors you want.
+ * @param string $setting Optional slug title of a specific setting whose errors you want.
* @param bool $sanitize Whether to re-sanitize the setting value before returning errors.
* @param bool $hide_on_update If set to true errors will not be shown if the settings page has
* already been submitted.
*/
function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
- if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) )
+ if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) ) {
return;
+ }
$settings_errors = get_settings_errors( $setting, $sanitize );
- if ( empty( $settings_errors ) )
+ if ( empty( $settings_errors ) ) {
return;
+ }
$output = '';
foreach ( $settings_errors as $key => $details ) {
- $css_id = 'setting-error-' . $details['code'];
+ $css_id = 'setting-error-' . $details['code'];
$css_class = $details['type'] . ' settings-error notice is-dismissible';
- $output .= "<div id='$css_id' class='$css_class'> \n";
- $output .= "<p><strong>{$details['message']}</strong></p>";
- $output .= "</div> \n";
+ $output .= "<div id='$css_id' class='$css_class'> \n";
+ $output .= "<p><strong>{$details['message']}</strong></p>";
+ $output .= "</div> \n";
}
echo $output;
}
@@ -1539,8 +1812,8 @@
*
* @param string $found_action
*/
-function find_posts_div($found_action = '') {
-?>
+function find_posts_div( $found_action = '' ) {
+ ?>
<div id="find-posts" class="find-box" style="display: none;">
<div id="find-posts-head" class="find-box-head">
<?php _e( 'Attach to existing content' ); ?>
@@ -1549,7 +1822,7 @@
<div class="find-box-inside">
<div class="find-box-search">
<?php if ( $found_action ) { ?>
- <input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
+ <input type="hidden" name="found_action" value="<?php echo esc_attr( $found_action ); ?>" />
<?php } ?>
<input type="hidden" name="affected" id="affected" value="" />
<?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
@@ -1566,7 +1839,7 @@
<div class="clear"></div>
</div>
</div>
-<?php
+ <?php
}
/**
@@ -1578,8 +1851,9 @@
*/
function the_post_password() {
$post = get_post();
- if ( isset( $post->post_password ) )
+ if ( isset( $post->post_password ) ) {
echo esc_attr( $post->post_password );
+ }
}
/**
@@ -1595,8 +1869,9 @@
*/
function _draft_or_post_title( $post = 0 ) {
$title = get_the_title( $post );
- if ( empty( $title ) )
+ if ( empty( $title ) ) {
$title = __( '(no title)' );
+ }
return esc_html( $title );
}
@@ -1609,7 +1884,7 @@
* @since 2.7.0
*/
function _admin_search_query() {
- echo isset($_REQUEST['s']) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
+ echo isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
}
/**
@@ -1627,17 +1902,17 @@
function iframe_header( $title = '', $deprecated = false ) {
show_admin_bar( false );
global $hook_suffix, $admin_body_class, $wp_locale;
- $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
+ $admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
$current_screen = get_current_screen();
@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
_wp_admin_html_begin();
-?>
-<title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title>
-<?php
-wp_enqueue_style( 'colors' );
-?>
+ ?>
+<title><?php bloginfo( 'name' ); ?> › <?php echo $title; ?> — <?php _e( 'WordPress' ); ?></title>
+ <?php
+ wp_enqueue_style( 'colors' );
+ ?>
<script type="text/javascript">
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
@@ -1649,44 +1924,51 @@
decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
isRtl = <?php echo (int) is_rtl(); ?>;
</script>
-<?php
-/** This action is documented in wp-admin/admin-header.php */
-do_action( 'admin_enqueue_scripts', $hook_suffix );
+ <?php
+ /** This action is documented in wp-admin/admin-header.php */
+ do_action( 'admin_enqueue_scripts', $hook_suffix );
-/** This action is documented in wp-admin/admin-header.php */
-do_action( "admin_print_styles-$hook_suffix" );
+ /** This action is documented in wp-admin/admin-header.php */
+ do_action( "admin_print_styles-$hook_suffix" );
+
+ /** This action is documented in wp-admin/admin-header.php */
+ do_action( 'admin_print_styles' );
-/** This action is documented in wp-admin/admin-header.php */
-do_action( 'admin_print_styles' );
+ /** This action is documented in wp-admin/admin-header.php */
+ do_action( "admin_print_scripts-$hook_suffix" );
-/** This action is documented in wp-admin/admin-header.php */
-do_action( "admin_print_scripts-$hook_suffix" );
+ /** This action is documented in wp-admin/admin-header.php */
+ do_action( 'admin_print_scripts' );
-/** This action is documented in wp-admin/admin-header.php */
-do_action( 'admin_print_scripts' );
+ /** This action is documented in wp-admin/admin-header.php */
+ do_action( "admin_head-$hook_suffix" );
-/** This action is documented in wp-admin/admin-header.php */
-do_action( "admin_head-$hook_suffix" );
+ /** This action is documented in wp-admin/admin-header.php */
+ do_action( 'admin_head' );
-/** This action is documented in wp-admin/admin-header.php */
-do_action( 'admin_head' );
-
-$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
+ $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
-if ( is_rtl() )
- $admin_body_class .= ' rtl';
+ if ( is_rtl() ) {
+ $admin_body_class .= ' rtl';
+ }
-?>
+ ?>
</head>
-<?php
-/** This filter is documented in wp-admin/admin-header.php */
-$admin_body_classes = apply_filters( 'admin_body_class', '' );
-?>
-<body<?php
-/**
- * @global string $body_id
- */
-if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
+ <?php
+ /** This filter is documented in wp-admin/admin-header.php */
+ $admin_body_classes = apply_filters( 'admin_body_class', '' );
+ $admin_body_classes = ltrim( $admin_body_classes . ' ' . $admin_body_class );
+ ?>
+<body
+ <?php
+ /**
+ * @global string $body_id
+ */
+ if ( isset( $GLOBALS['body_id'] ) ) {
+ echo ' id="' . $GLOBALS['body_id'] . '"';
+ }
+ ?>
+ class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes; ?>">
<script type="text/javascript">
(function(){
var c = document.body.className;
@@ -1694,7 +1976,7 @@
document.body.className = c;
})();
</script>
-<?php
+ <?php
}
/**
@@ -1715,7 +1997,7 @@
global $hook_suffix;
?>
<div class="hidden">
-<?php
+ <?php
/** This action is documented in wp-admin/admin-footer.php */
do_action( 'admin_footer', $hook_suffix );
@@ -1724,29 +2006,31 @@
/** This action is documented in wp-admin/admin-footer.php */
do_action( 'admin_print_footer_scripts' );
-?>
+ ?>
</div>
<script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
</body>
</html>
-<?php
+ <?php
}
/**
- *
* @param WP_Post $post
*/
-function _post_states($post) {
+function _post_states( $post ) {
$post_states = array();
- if ( isset( $_REQUEST['post_status'] ) )
+ if ( isset( $_REQUEST['post_status'] ) ) {
$post_status = $_REQUEST['post_status'];
- else
+ } else {
$post_status = '';
+ }
- if ( !empty($post->post_password) )
- $post_states['protected'] = __('Password protected');
- if ( 'private' == $post->post_status && 'private' != $post_status )
- $post_states['private'] = __('Private');
+ if ( ! empty( $post->post_password ) ) {
+ $post_states['protected'] = __( 'Password protected' );
+ }
+ if ( 'private' == $post->post_status && 'private' != $post_status ) {
+ $post_states['private'] = __( 'Private' );
+ }
if ( 'draft' === $post->post_status ) {
if ( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
$post_states[] = __( 'Customization Draft' );
@@ -1756,10 +2040,12 @@
} elseif ( 'trash' === $post->post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
$post_states[] = __( 'Customization Draft' );
}
- if ( 'pending' == $post->post_status && 'pending' != $post_status )
- $post_states['pending'] = _x('Pending', 'post status');
- if ( is_sticky($post->ID) )
- $post_states['sticky'] = __('Sticky');
+ if ( 'pending' == $post->post_status && 'pending' != $post_status ) {
+ $post_states['pending'] = _x( 'Pending', 'post status' );
+ }
+ if ( is_sticky( $post->ID ) ) {
+ $post_states['sticky'] = __( 'Sticky' );
+ }
if ( 'future' === $post->post_status ) {
$post_states['scheduled'] = __( 'Scheduled' );
@@ -1785,14 +2071,14 @@
* @since 2.8.0
* @since 3.6.0 Added the `$post` parameter.
*
- * @param array $post_states An array of post display states.
- * @param WP_Post $post The current post object.
+ * @param string[] $post_states An array of post display states.
+ * @param WP_Post $post The current post object.
*/
$post_states = apply_filters( 'display_post_states', $post_states, $post );
- if ( ! empty($post_states) ) {
- $state_count = count($post_states);
- $i = 0;
+ if ( ! empty( $post_states ) ) {
+ $state_count = count( $post_states );
+ $i = 0;
echo ' — ';
foreach ( $post_states as $state ) {
++$i;
@@ -1804,15 +2090,14 @@
}
/**
- *
* @param WP_Post $post
*/
function _media_states( $post ) {
$media_states = array();
- $stylesheet = get_option('stylesheet');
+ $stylesheet = get_option( 'stylesheet' );
- if ( current_theme_supports( 'custom-header') ) {
- $meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true );
+ if ( current_theme_supports( 'custom-header' ) ) {
+ $meta_header = get_post_meta( $post->ID, '_wp_attachment_is_custom_header', true );
if ( is_random_header_image() ) {
$header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' );
@@ -1835,8 +2120,8 @@
}
}
- if ( current_theme_supports( 'custom-background') ) {
- $meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true );
+ if ( current_theme_supports( 'custom-background' ) ) {
+ $meta_background = get_post_meta( $post->ID, '_wp_attachment_is_custom_background', true );
if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) {
$media_states[] = __( 'Background Image' );
@@ -1862,15 +2147,15 @@
* @since 3.2.0
* @since 4.8.0 Added the `$post` parameter.
*
- * @param array $media_states An array of media states. Default 'Header Image',
- * 'Background Image', 'Site Icon', 'Logo'.
- * @param WP_Post $post The current attachment object.
+ * @param string[] $media_states An array of media states. Default 'Header Image',
+ * 'Background Image', 'Site Icon', 'Logo'.
+ * @param WP_Post $post The current attachment object.
*/
$media_states = apply_filters( 'display_media_states', $media_states, $post );
if ( ! empty( $media_states ) ) {
$state_count = count( $media_states );
- $i = 0;
+ $i = 0;
echo ' — ';
foreach ( $media_states as $state ) {
++$i;
@@ -1891,7 +2176,7 @@
* @since 2.8.0
*/
function compression_test() {
-?>
+ ?>
<script type="text/javascript">
var compressionNonce = <?php echo wp_json_encode( wp_create_nonce( 'update_can_compress_scripts' ) ); ?>;
var testCompression = {
@@ -1941,7 +2226,7 @@
};
testCompression.check();
</script>
-<?php
+ <?php
}
/**
@@ -1958,7 +2243,7 @@
* id attribute is given in $other_attributes below, $name will be
* used as the button's id.
* @param bool $wrap True if the output button should be wrapped in a paragraph tag,
- * false otherwise. Defaults to true
+ * false otherwise. Defaults to true.
* @param array|string $other_attributes Other attributes that should be output with the button, mapping
* attributes to their values, such as setting tabindex to 1, etc.
* These key/value attribute pairs will be output as attribute="value",
@@ -1992,14 +2277,16 @@
* @return string Submit button HTML.
*/
function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) {
- if ( ! is_array( $type ) )
+ if ( ! is_array( $type ) ) {
$type = explode( ' ', $type );
+ }
$button_shorthand = array( 'primary', 'small', 'large' );
- $classes = array( 'button' );
+ $classes = array( 'button' );
foreach ( $type as $t ) {
- if ( 'secondary' === $t || 'button-secondary' === $t )
+ if ( 'secondary' === $t || 'button-secondary' === $t ) {
continue;
+ }
$classes[] = in_array( $t, $button_shorthand ) ? 'button-' . $t : $t;
}
// Remove empty items, remove duplicate items, and finally build a string.
@@ -2025,10 +2312,10 @@
// Don't output empty name and id attributes.
$name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : '';
- $id_attr = $id ? ' id="' . esc_attr( $id ) . '"' : '';
+ $id_attr = $id ? ' id="' . esc_attr( $id ) . '"' : '';
- $button = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class );
- $button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
+ $button = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class );
+ $button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
if ( $wrap ) {
$button = '<p class="submit">' . $button . '</p>';
@@ -2038,7 +2325,6 @@
}
/**
- *
* @global bool $is_IE
*/
function _wp_admin_html_begin() {
@@ -2046,30 +2332,39 @@
$admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
- if ( $is_IE )
- @header('X-UA-Compatible: IE=edge');
+ if ( $is_IE ) {
+ @header( 'X-UA-Compatible: IE=edge' );
+ }
-?>
+ ?>
<!DOCTYPE html>
<!--[if IE 8]>
-<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" <?php
+<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>"
+ <?php
/**
* Fires inside the HTML tag in the admin header.
*
* @since 2.2.0
*/
do_action( 'admin_xml_ns' );
-?> <?php language_attributes(); ?>>
+
+ language_attributes();
+ ?>
+ >
<![endif]-->
<!--[if !(IE 8) ]><!-->
-<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php
+<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>"
+ <?php
/** This action is documented in wp-admin/includes/template.php */
do_action( 'admin_xml_ns' );
-?> <?php language_attributes(); ?>>
+
+ language_attributes();
+ ?>
+ >
<!--<![endif]-->
<head>
-<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
-<?php
+<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" />
+ <?php
}
/**
@@ -2085,7 +2380,7 @@
_doing_it_wrong(
'convert_to_screen(), add_meta_box()',
sprintf(
- /* translators: 1: wp-admin/includes/template.php 2: add_meta_box() 3: add_meta_boxes */
+ /* translators: 1: wp-admin/includes/template.php, 2: add_meta_box(), 3: add_meta_boxes */
__( 'Likely direct inclusion of %1$s in order to use %2$s. This is very wrong. Hook the %2$s call into the %3$s action instead.' ),
'<code>wp-admin/includes/template.php</code>',
'<code>add_meta_box()</code>',
@@ -2093,7 +2388,10 @@
),
'3.3.0'
);
- return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' );
+ return (object) array(
+ 'id' => '_invalid',
+ 'base' => '_are_belong_to_us',
+ );
}
return WP_Screen::get( $hook_name );
@@ -2110,7 +2408,7 @@
<div id="local-storage-notice" class="hidden notice is-dismissible">
<p class="local-restore">
<?php _e( 'The backup of this post in your browser is different from the version below.' ); ?>
- <button type="button" class="button restore-backup"><?php _e('Restore the backup'); ?></button>
+ <button type="button" class="button restore-backup"><?php _e( 'Restore the backup' ); ?></button>
</p>
<p class="help">
<?php _e( 'This will replace the current editor content with the last backup version. You can use undo and redo in the editor to get the old content back or to return to the restored version.' ); ?>
@@ -2149,7 +2447,7 @@
'number' => 0,
'echo' => true,
);
- $r = wp_parse_args( $args, $defaults );
+ $r = wp_parse_args( $args, $defaults );
// Non-English decimal places when the $rating is coming from a string
$rating = (float) str_replace( ',', '.', $r['rating'] );
@@ -2160,20 +2458,20 @@
}
// Calculate the number of each type of star needed
- $full_stars = floor( $rating );
- $half_stars = ceil( $rating - $full_stars );
+ $full_stars = floor( $rating );
+ $half_stars = ceil( $rating - $full_stars );
$empty_stars = 5 - $full_stars - $half_stars;
if ( $r['number'] ) {
- /* translators: 1: The rating, 2: The number of ratings */
+ /* translators: 1: the rating, 2: the number of ratings */
$format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number'] );
- $title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $r['number'] ) );
+ $title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $r['number'] ) );
} else {
- /* translators: 1: The rating */
+ /* translators: %s: the rating */
$title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
}
- $output = '<div class="star-rating">';
+ $output = '<div class="star-rating">';
$output .= '<span class="screen-reader-text">' . $title . '</span>';
$output .= str_repeat( '<div class="star star-full" aria-hidden="true"></div>', $full_stars );
$output .= str_repeat( '<div class="star star-half" aria-hidden="true"></div>', $half_stars );