wp/wp-admin/includes/template.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
    27  *
    27  *
    28  * @param int    $post_id              Optional. Post to generate a categories checklist for. Default 0.
    28  * @param int    $post_id              Optional. Post to generate a categories checklist for. Default 0.
    29  *                                     $selected_cats must not be an array. Default 0.
    29  *                                     $selected_cats must not be an array. Default 0.
    30  * @param int    $descendants_and_self Optional. ID of the category to output along with its descendants.
    30  * @param int    $descendants_and_self Optional. ID of the category to output along with its descendants.
    31  *                                     Default 0.
    31  *                                     Default 0.
    32  * @param array  $selected_cats        Optional. List of categories to mark as checked. Default false.
    32  * @param int[]  $selected_cats        Optional. Array of category IDs to mark as checked. Default false.
    33  * @param array  $popular_cats         Optional. List of categories to receive the "popular-category" class.
    33  * @param int[]  $popular_cats         Optional. Array of category IDs to receive the "popular-category" class.
    34  *                                     Default false.
    34  *                                     Default false.
    35  * @param object $walker               Optional. Walker object to use to build the output.
    35  * @param object $walker               Optional. Walker object to use to build the output.
    36  *                                     Default is a Walker_Category_Checklist instance.
    36  *                                     Default is a Walker_Category_Checklist instance.
    37  * @param bool   $checked_ontop        Optional. Whether to move checked items out of the hierarchy and to
    37  * @param bool   $checked_ontop        Optional. Whether to move checked items out of the hierarchy and to
    38  *                                     the top of the list. Default true.
    38  *                                     the top of the list. Default true.
    39  */
    39  */
    40 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
    40 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
    41 	wp_terms_checklist( $post_id, array(
    41 	wp_terms_checklist(
    42 		'taxonomy' => 'category',
    42 		$post_id,
    43 		'descendants_and_self' => $descendants_and_self,
    43 		array(
    44 		'selected_cats' => $selected_cats,
    44 			'taxonomy'             => 'category',
    45 		'popular_cats' => $popular_cats,
    45 			'descendants_and_self' => $descendants_and_self,
    46 		'walker' => $walker,
    46 			'selected_cats'        => $selected_cats,
    47 		'checked_ontop' => $checked_ontop
    47 			'popular_cats'         => $popular_cats,
    48 	) );
    48 			'walker'               => $walker,
       
    49 			'checked_ontop'        => $checked_ontop,
       
    50 		)
       
    51 	);
    49 }
    52 }
    50 
    53 
    51 /**
    54 /**
    52  * Output an unordered list of checkbox input elements labelled with term names.
    55  * Output an unordered list of checkbox input elements labelled with term names.
    53  *
    56  *
    60  * @param array|string $args {
    63  * @param array|string $args {
    61  *     Optional. Array or string of arguments for generating a terms checklist. Default empty array.
    64  *     Optional. Array or string of arguments for generating a terms checklist. Default empty array.
    62  *
    65  *
    63  *     @type int    $descendants_and_self ID of the category to output along with its descendants.
    66  *     @type int    $descendants_and_self ID of the category to output along with its descendants.
    64  *                                        Default 0.
    67  *                                        Default 0.
    65  *     @type array  $selected_cats        List of categories to mark as checked. Default false.
    68  *     @type int[]  $selected_cats        Array of category IDs to mark as checked. Default false.
    66  *     @type array  $popular_cats         List of categories to receive the "popular-category" class.
    69  *     @type int[]  $popular_cats         Array of category IDs to receive the "popular-category" class.
    67  *                                        Default false.
    70  *                                        Default false.
    68  *     @type object $walker               Walker object to use to build the output.
    71  *     @type object $walker               Walker object to use to build the output.
    69  *                                        Default is a Walker_Category_Checklist instance.
    72  *                                        Default is a Walker_Category_Checklist instance.
    70  *     @type string $taxonomy             Taxonomy to generate the checklist for. Default 'category'.
    73  *     @type string $taxonomy             Taxonomy to generate the checklist for. Default 'category'.
    71  *     @type bool   $checked_ontop        Whether to move checked items out of the hierarchy and to
    74  *     @type bool   $checked_ontop        Whether to move checked items out of the hierarchy and to
    73  *     @type bool   $echo                 Whether to echo the generated markup. False to return the markup instead
    76  *     @type bool   $echo                 Whether to echo the generated markup. False to return the markup instead
    74  *                                        of echoing it. Default true.
    77  *                                        of echoing it. Default true.
    75  * }
    78  * }
    76  */
    79  */
    77 function wp_terms_checklist( $post_id = 0, $args = array() ) {
    80 function wp_terms_checklist( $post_id = 0, $args = array() ) {
    78  	$defaults = array(
    81 	$defaults = array(
    79 		'descendants_and_self' => 0,
    82 		'descendants_and_self' => 0,
    80 		'selected_cats' => false,
    83 		'selected_cats'        => false,
    81 		'popular_cats' => false,
    84 		'popular_cats'         => false,
    82 		'walker' => null,
    85 		'walker'               => null,
    83 		'taxonomy' => 'category',
    86 		'taxonomy'             => 'category',
    84 		'checked_ontop' => true,
    87 		'checked_ontop'        => true,
    85 		'echo' => true,
    88 		'echo'                 => true,
    86 	);
    89 	);
    87 
    90 
    88 	/**
    91 	/**
    89 	 * Filters the taxonomy terms checklist arguments.
    92 	 * Filters the taxonomy terms checklist arguments.
    90 	 *
    93 	 *
   103 		$walker = new Walker_Category_Checklist;
   106 		$walker = new Walker_Category_Checklist;
   104 	} else {
   107 	} else {
   105 		$walker = $r['walker'];
   108 		$walker = $r['walker'];
   106 	}
   109 	}
   107 
   110 
   108 	$taxonomy = $r['taxonomy'];
   111 	$taxonomy             = $r['taxonomy'];
   109 	$descendants_and_self = (int) $r['descendants_and_self'];
   112 	$descendants_and_self = (int) $r['descendants_and_self'];
   110 
   113 
   111 	$args = array( 'taxonomy' => $taxonomy );
   114 	$args = array( 'taxonomy' => $taxonomy );
   112 
   115 
   113 	$tax = get_taxonomy( $taxonomy );
   116 	$tax              = get_taxonomy( $taxonomy );
   114 	$args['disabled'] = ! current_user_can( $tax->cap->assign_terms );
   117 	$args['disabled'] = ! current_user_can( $tax->cap->assign_terms );
   115 
   118 
   116 	$args['list_only'] = ! empty( $r['list_only'] );
   119 	$args['list_only'] = ! empty( $r['list_only'] );
   117 
   120 
   118 	if ( is_array( $r['selected_cats'] ) ) {
   121 	if ( is_array( $r['selected_cats'] ) ) {
   123 		$args['selected_cats'] = array();
   126 		$args['selected_cats'] = array();
   124 	}
   127 	}
   125 	if ( is_array( $r['popular_cats'] ) ) {
   128 	if ( is_array( $r['popular_cats'] ) ) {
   126 		$args['popular_cats'] = $r['popular_cats'];
   129 		$args['popular_cats'] = $r['popular_cats'];
   127 	} else {
   130 	} else {
   128 		$args['popular_cats'] = get_terms( $taxonomy, array(
   131 		$args['popular_cats'] = get_terms(
   129 			'fields' => 'ids',
   132 			$taxonomy,
   130 			'orderby' => 'count',
   133 			array(
   131 			'order' => 'DESC',
   134 				'fields'       => 'ids',
   132 			'number' => 10,
   135 				'orderby'      => 'count',
   133 			'hierarchical' => false
   136 				'order'        => 'DESC',
   134 		) );
   137 				'number'       => 10,
       
   138 				'hierarchical' => false,
       
   139 			)
       
   140 		);
   135 	}
   141 	}
   136 	if ( $descendants_and_self ) {
   142 	if ( $descendants_and_self ) {
   137 		$categories = (array) get_terms( $taxonomy, array(
   143 		$categories = (array) get_terms(
   138 			'child_of' => $descendants_and_self,
   144 			$taxonomy,
   139 			'hierarchical' => 0,
   145 			array(
   140 			'hide_empty' => 0
   146 				'child_of'     => $descendants_and_self,
   141 		) );
   147 				'hierarchical' => 0,
   142 		$self = get_term( $descendants_and_self, $taxonomy );
   148 				'hide_empty'   => 0,
       
   149 			)
       
   150 		);
       
   151 		$self       = get_term( $descendants_and_self, $taxonomy );
   143 		array_unshift( $categories, $self );
   152 		array_unshift( $categories, $self );
   144 	} else {
   153 	} else {
   145 		$categories = (array) get_terms( $taxonomy, array( 'get' => 'all' ) );
   154 		$categories = (array) get_terms( $taxonomy, array( 'get' => 'all' ) );
   146 	}
   155 	}
   147 
   156 
   148 	$output = '';
   157 	$output = '';
   149 
   158 
   150 	if ( $r['checked_ontop'] ) {
   159 	if ( $r['checked_ontop'] ) {
   151 		// 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)
   160 		// 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)
   152 		$checked_categories = array();
   161 		$checked_categories = array();
   153 		$keys = array_keys( $categories );
   162 		$keys               = array_keys( $categories );
   154 
   163 
   155 		foreach ( $keys as $k ) {
   164 		foreach ( $keys as $k ) {
   156 			if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
   165 			if ( in_array( $categories[ $k ]->term_id, $args['selected_cats'] ) ) {
   157 				$checked_categories[] = $categories[$k];
   166 				$checked_categories[] = $categories[ $k ];
   158 				unset( $categories[$k] );
   167 				unset( $categories[ $k ] );
   159 			}
   168 			}
   160 		}
   169 		}
   161 
   170 
   162 		// Put checked cats on top
   171 		// Put checked cats on top
   163 		$output .= call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) );
   172 		$output .= call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) );
   189  * @return array List of popular term IDs.
   198  * @return array List of popular term IDs.
   190  */
   199  */
   191 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
   200 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
   192 	$post = get_post();
   201 	$post = get_post();
   193 
   202 
   194 	if ( $post && $post->ID )
   203 	if ( $post && $post->ID ) {
   195 		$checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids'));
   204 		$checked_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
   196 	else
   205 	} else {
   197 		$checked_terms = array();
   206 		$checked_terms = array();
   198 
   207 	}
   199 	$terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
   208 
   200 
   209 	$terms = get_terms(
   201 	$tax = get_taxonomy($taxonomy);
   210 		$taxonomy,
       
   211 		array(
       
   212 			'orderby'      => 'count',
       
   213 			'order'        => 'DESC',
       
   214 			'number'       => $number,
       
   215 			'hierarchical' => false,
       
   216 		)
       
   217 	);
       
   218 
       
   219 	$tax = get_taxonomy( $taxonomy );
   202 
   220 
   203 	$popular_ids = array();
   221 	$popular_ids = array();
   204 	foreach ( (array) $terms as $term ) {
   222 	foreach ( (array) $terms as $term ) {
   205 		$popular_ids[] = $term->term_id;
   223 		$popular_ids[] = $term->term_id;
   206 		if ( !$echo ) // Hack for Ajax use.
   224 		if ( ! $echo ) { // Hack for Ajax use.
   207 			continue;
   225 			continue;
   208 		$id = "popular-$taxonomy-$term->term_id";
   226 		}
       
   227 		$id      = "popular-$taxonomy-$term->term_id";
   209 		$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
   228 		$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
   210 		?>
   229 		?>
   211 
   230 
   212 		<li id="<?php echo $id; ?>" class="popular-category">
   231 		<li id="<?php echo $id; ?>" class="popular-category">
   213 			<label class="selectit">
   232 			<label class="selectit">
   244 		}
   263 		}
   245 	} else {
   264 	} else {
   246 		$checked_categories[] = $default;
   265 		$checked_categories[] = $default;
   247 	}
   266 	}
   248 
   267 
   249 	$categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
   268 	$categories = get_terms(
   250 
   269 		'link_category',
   251 	if ( empty( $categories ) )
   270 		array(
       
   271 			'orderby'    => 'name',
       
   272 			'hide_empty' => 0,
       
   273 		)
       
   274 	);
       
   275 
       
   276 	if ( empty( $categories ) ) {
   252 		return;
   277 		return;
       
   278 	}
   253 
   279 
   254 	foreach ( $categories as $category ) {
   280 	foreach ( $categories as $category ) {
   255 		$cat_id = $category->term_id;
   281 		$cat_id = $category->term_id;
   256 
   282 
   257 		/** This filter is documented in wp-includes/category-template.php */
   283 		/** This filter is documented in wp-includes/category-template.php */
   258 		$name = esc_html( apply_filters( 'the_category', $category->name, '', '' ) );
   284 		$name    = esc_html( apply_filters( 'the_category', $category->name, '', '' ) );
   259 		$checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
   285 		$checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
   260 		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>";
   286 		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>';
   261 	}
   287 	}
   262 }
   288 }
   263 
   289 
   264 /**
   290 /**
   265  * Adds hidden fields with the data for use in the inline editor for posts and pages.
   291  * Adds hidden fields with the data for use in the inline editor for posts and pages.
   266  *
   292  *
   267  * @since 2.7.0
   293  * @since 2.7.0
   268  *
   294  *
   269  * @param WP_Post $post Post object.
   295  * @param WP_Post $post Post object.
   270  */
   296  */
   271 function get_inline_data($post) {
   297 function get_inline_data( $post ) {
   272 	$post_type_object = get_post_type_object($post->post_type);
   298 	$post_type_object = get_post_type_object( $post->post_type );
   273 	if ( ! current_user_can( 'edit_post', $post->ID ) )
   299 	if ( ! current_user_can( 'edit_post', $post->ID ) ) {
   274 		return;
   300 		return;
       
   301 	}
   275 
   302 
   276 	$title = esc_textarea( trim( $post->post_title ) );
   303 	$title = esc_textarea( trim( $post->post_title ) );
   277 
   304 
   278 	/** This filter is documented in wp-admin/edit-tag-form.php */
   305 	/** This filter is documented in wp-admin/edit-tag-form.php */
   279 	echo '
   306 	echo '
   302 	if ( post_type_supports( $post->post_type, 'page-attributes' ) ) {
   329 	if ( post_type_supports( $post->post_type, 'page-attributes' ) ) {
   303 		echo '<div class="menu_order">' . $post->menu_order . '</div>';
   330 		echo '<div class="menu_order">' . $post->menu_order . '</div>';
   304 	}
   331 	}
   305 
   332 
   306 	$taxonomy_names = get_object_taxonomies( $post->post_type );
   333 	$taxonomy_names = get_object_taxonomies( $post->post_type );
   307 	foreach ( $taxonomy_names as $taxonomy_name) {
   334 	foreach ( $taxonomy_names as $taxonomy_name ) {
   308 		$taxonomy = get_taxonomy( $taxonomy_name );
   335 		$taxonomy = get_taxonomy( $taxonomy_name );
   309 
   336 
   310 		if ( $taxonomy->hierarchical && $taxonomy->show_ui ) {
   337 		if ( $taxonomy->hierarchical && $taxonomy->show_ui ) {
   311 
   338 
   312 			$terms = get_object_term_cache( $post->ID, $taxonomy_name );
   339 			$terms = get_object_term_cache( $post->ID, $taxonomy_name );
   323 			$terms_to_edit = get_terms_to_edit( $post->ID, $taxonomy_name );
   350 			$terms_to_edit = get_terms_to_edit( $post->ID, $taxonomy_name );
   324 			if ( ! is_string( $terms_to_edit ) ) {
   351 			if ( ! is_string( $terms_to_edit ) ) {
   325 				$terms_to_edit = '';
   352 				$terms_to_edit = '';
   326 			}
   353 			}
   327 
   354 
   328 			echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
   355 			echo '<div class="tags_input" id="' . $taxonomy_name . '_' . $post->ID . '">'
   329 				. esc_html( str_replace( ',', ', ', $terms_to_edit ) ) . '</div>';
   356 				. esc_html( str_replace( ',', ', ', $terms_to_edit ) ) . '</div>';
   330 
   357 
   331 		}
   358 		}
   332 	}
   359 	}
   333 
   360 
   334 	if ( !$post_type_object->hierarchical )
   361 	if ( ! $post_type_object->hierarchical ) {
   335 		echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
   362 		echo '<div class="sticky">' . ( is_sticky( $post->ID ) ? 'sticky' : '' ) . '</div>';
   336 
   363 	}
   337 	if ( post_type_supports( $post->post_type, 'post-formats' ) )
   364 
       
   365 	if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
   338 		echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>';
   366 		echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>';
       
   367 	}
   339 
   368 
   340 	/**
   369 	/**
   341 	 * Fires after outputting the fields for the inline editor for posts and pages.
   370 	 * Fires after outputting the fields for the inline editor for posts and pages.
   342 	 *
   371 	 *
   343 	 * @since 4.9.8
   372 	 * @since 4.9.8
   377 	 * @see wp_comment_reply()
   406 	 * @see wp_comment_reply()
   378 	 *
   407 	 *
   379 	 * @param string $content The reply-to form content.
   408 	 * @param string $content The reply-to form content.
   380 	 * @param array  $args    An array of default args.
   409 	 * @param array  $args    An array of default args.
   381 	 */
   410 	 */
   382 	$content = apply_filters( 'wp_comment_reply', '', array( 'position' => $position, 'checkbox' => $checkbox, 'mode' => $mode ) );
   411 	$content = apply_filters(
   383 
   412 		'wp_comment_reply',
   384 	if ( ! empty($content) ) {
   413 		'',
       
   414 		array(
       
   415 			'position' => $position,
       
   416 			'checkbox' => $checkbox,
       
   417 			'mode'     => $mode,
       
   418 		)
       
   419 	);
       
   420 
       
   421 	if ( ! empty( $content ) ) {
   385 		echo $content;
   422 		echo $content;
   386 		return;
   423 		return;
   387 	}
   424 	}
   388 
   425 
   389 	if ( ! $wp_list_table ) {
   426 	if ( ! $wp_list_table ) {
   390 		if ( $mode == 'single' ) {
   427 		if ( $mode == 'single' ) {
   391 			$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
   428 			$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );
   392 		} else {
   429 		} else {
   393 			$wp_list_table = _get_list_table('WP_Comments_List_Table');
   430 			$wp_list_table = _get_list_table( 'WP_Comments_List_Table' );
   394 		}
   431 		}
   395 	}
   432 	}
   396 
   433 
   397 ?>
   434 	?>
   398 <form method="get">
   435 <form method="get">
   399 <?php if ( $table_row ) : ?>
   436 	<?php if ( $table_row ) : ?>
   400 <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">
   437 <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">
   401 <?php else : ?>
   438 <?php else : ?>
   402 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
   439 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
   403 <?php endif; ?>
   440 <?php endif; ?>
   404 	<fieldset class="comment-reply">
   441 	<fieldset class="comment-reply">
   410 
   447 
   411 	<div id="replycontainer">
   448 	<div id="replycontainer">
   412 	<label for="replycontent" class="screen-reader-text"><?php _e( 'Comment' ); ?></label>
   449 	<label for="replycontent" class="screen-reader-text"><?php _e( 'Comment' ); ?></label>
   413 	<?php
   450 	<?php
   414 	$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
   451 	$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
   415 	wp_editor( '', 'replycontent', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings ) );
   452 	wp_editor(
       
   453 		'',
       
   454 		'replycontent',
       
   455 		array(
       
   456 			'media_buttons' => false,
       
   457 			'tinymce'       => false,
       
   458 			'quicktags'     => $quicktags_settings,
       
   459 		)
       
   460 	);
   416 	?>
   461 	?>
   417 	</div>
   462 	</div>
   418 
   463 
   419 	<div id="edithead" style="display:none;">
   464 	<div id="edithead" style="display:none;">
   420 		<div class="inside">
   465 		<div class="inside">
   421 		<label for="author-name"><?php _e( 'Name' ) ?></label>
   466 		<label for="author-name"><?php _e( 'Name' ); ?></label>
   422 		<input type="text" name="newcomment_author" size="50" value="" id="author-name" />
   467 		<input type="text" name="newcomment_author" size="50" value="" id="author-name" />
   423 		</div>
   468 		</div>
   424 
   469 
   425 		<div class="inside">
   470 		<div class="inside">
   426 		<label for="author-email"><?php _e('Email') ?></label>
   471 		<label for="author-email"><?php _e( 'Email' ); ?></label>
   427 		<input type="text" name="newcomment_author_email" size="50" value="" id="author-email" />
   472 		<input type="text" name="newcomment_author_email" size="50" value="" id="author-email" />
   428 		</div>
   473 		</div>
   429 
   474 
   430 		<div class="inside">
   475 		<div class="inside">
   431 		<label for="author-url"><?php _e('URL') ?></label>
   476 		<label for="author-url"><?php _e( 'URL' ); ?></label>
   432 		<input type="text" id="author-url" name="newcomment_author_url" class="code" size="103" value="" />
   477 		<input type="text" id="author-url" name="newcomment_author_url" class="code" size="103" value="" />
   433 		</div>
   478 		</div>
   434 	</div>
   479 	</div>
   435 
   480 
   436 	<div id="replysubmit" class="submit">
   481 	<div id="replysubmit" class="submit">
   437 		<p>
   482 		<p class="reply-submit-buttons">
   438 			<a href="#comments-form" class="save button button-primary alignright">
   483 			<button type="button" class="save button button-primary">
   439 				<span id="addbtn" style="display: none;"><?php _e( 'Add Comment' ); ?></span>
   484 				<span id="addbtn" style="display: none;"><?php _e( 'Add Comment' ); ?></span>
   440 				<span id="savebtn" style="display: none;"><?php _e( 'Update Comment' ); ?></span>
   485 				<span id="savebtn" style="display: none;"><?php _e( 'Update Comment' ); ?></span>
   441 				<span id="replybtn" style="display: none;"><?php _e( 'Submit Reply' ); ?></span>
   486 				<span id="replybtn" style="display: none;"><?php _e( 'Submit Reply' ); ?></span>
   442 			</a>
   487 			</button>
   443 			<a href="#comments-form" class="cancel button alignleft"><?php _e( 'Cancel' ); ?></a>
   488 			<button type="button" class="cancel button"><?php _e( 'Cancel' ); ?></button>
   444 			<span class="waiting spinner"></span>
   489 			<span class="waiting spinner"></span>
   445 		</p>
   490 		</p>
   446 		<br class="clear" />
       
   447 		<div class="notice notice-error notice-alt inline hidden">
   491 		<div class="notice notice-error notice-alt inline hidden">
   448 			<p class="error"></p>
   492 			<p class="error"></p>
   449 		</div>
   493 		</div>
   450 	</div>
   494 	</div>
   451 
   495 
   453 	<input type="hidden" name="comment_ID" id="comment_ID" value="" />
   497 	<input type="hidden" name="comment_ID" id="comment_ID" value="" />
   454 	<input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
   498 	<input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
   455 	<input type="hidden" name="status" id="status" value="" />
   499 	<input type="hidden" name="status" id="status" value="" />
   456 	<input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
   500 	<input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
   457 	<input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
   501 	<input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
   458 	<input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
   502 	<input type="hidden" name="mode" id="mode" value="<?php echo esc_attr( $mode ); ?>" />
   459 	<?php
   503 	<?php
   460 		wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false );
   504 		wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false );
   461 		if ( current_user_can( 'unfiltered_html' ) )
   505 	if ( current_user_can( 'unfiltered_html' ) ) {
   462 			wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false );
   506 		wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false );
       
   507 	}
   463 	?>
   508 	?>
   464 	</fieldset>
   509 	</fieldset>
   465 <?php if ( $table_row ) : ?>
   510 	<?php if ( $table_row ) : ?>
   466 </td></tr></tbody></table>
   511 </td></tr></tbody></table>
   467 <?php else : ?>
   512 	<?php else : ?>
   468 </div></div>
   513 </div></div>
   469 <?php endif; ?>
   514 	<?php endif; ?>
   470 </form>
   515 </form>
   471 <?php
   516 	<?php
   472 }
   517 }
   473 
   518 
   474 /**
   519 /**
   475  * Output 'undo move to trash' text for comments
   520  * Output 'undo move to trash' text for comments
   476  *
   521  *
   477  * @since 2.9.0
   522  * @since 2.9.0
   478  */
   523  */
   479 function wp_comment_trashnotice() {
   524 function wp_comment_trashnotice() {
   480 ?>
   525 	?>
   481 <div class="hidden" id="trash-undo-holder">
   526 <div class="hidden" id="trash-undo-holder">
   482 	<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>
   527 	<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>
   483 </div>
   528 </div>
   484 <div class="hidden" id="spam-undo-holder">
   529 <div class="hidden" id="spam-undo-holder">
   485 	<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>
   530 	<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>
   486 </div>
   531 </div>
   487 <?php
   532 	<?php
   488 }
   533 }
   489 
   534 
   490 /**
   535 /**
   491  * Outputs a post's public meta data in the Custom Fields meta box.
   536  * Outputs a post's public meta data in the Custom Fields meta box.
   492  *
   537  *
   510 	</tbody>
   555 	</tbody>
   511 </table>'; //TBODY needed for list-manipulation JS
   556 </table>'; //TBODY needed for list-manipulation JS
   512 		return;
   557 		return;
   513 	}
   558 	}
   514 	$count = 0;
   559 	$count = 0;
   515 ?>
   560 	?>
   516 <table id="list-table">
   561 <table id="list-table">
   517 	<thead>
   562 	<thead>
   518 	<tr>
   563 	<tr>
   519 		<th class="left"><?php _ex( 'Name', 'meta name' ) ?></th>
   564 		<th class="left"><?php _ex( 'Name', 'meta name' ); ?></th>
   520 		<th><?php _e( 'Value' ) ?></th>
   565 		<th><?php _e( 'Value' ); ?></th>
   521 	</tr>
   566 	</tr>
   522 	</thead>
   567 	</thead>
   523 	<tbody id='the-list' data-wp-lists='list:meta'>
   568 	<tbody id='the-list' data-wp-lists='list:meta'>
   524 <?php
   569 	<?php
   525 	foreach ( $meta as $entry )
   570 	foreach ( $meta as $entry ) {
   526 		echo _list_meta_row( $entry, $count );
   571 		echo _list_meta_row( $entry, $count );
   527 ?>
   572 	}
       
   573 	?>
   528 	</tbody>
   574 	</tbody>
   529 </table>
   575 </table>
   530 <?php
   576 	<?php
   531 }
   577 }
   532 
   578 
   533 /**
   579 /**
   534  * Outputs a single row of public meta data in the Custom Fields meta box.
   580  * Outputs a single row of public meta data in the Custom Fields meta box.
   535  *
   581  *
   542  * @return string
   588  * @return string
   543  */
   589  */
   544 function _list_meta_row( $entry, &$count ) {
   590 function _list_meta_row( $entry, &$count ) {
   545 	static $update_nonce = '';
   591 	static $update_nonce = '';
   546 
   592 
   547 	if ( is_protected_meta( $entry['meta_key'], 'post' ) )
   593 	if ( is_protected_meta( $entry['meta_key'], 'post' ) ) {
   548 		return '';
   594 		return '';
   549 
   595 	}
   550 	if ( ! $update_nonce )
   596 
       
   597 	if ( ! $update_nonce ) {
   551 		$update_nonce = wp_create_nonce( 'add-meta' );
   598 		$update_nonce = wp_create_nonce( 'add-meta' );
       
   599 	}
   552 
   600 
   553 	$r = '';
   601 	$r = '';
   554 	++ $count;
   602 	++ $count;
   555 
   603 
   556 	if ( is_serialized( $entry['meta_value'] ) ) {
   604 	if ( is_serialized( $entry['meta_value'] ) ) {
   562 			--$count;
   610 			--$count;
   563 			return '';
   611 			return '';
   564 		}
   612 		}
   565 	}
   613 	}
   566 
   614 
   567 	$entry['meta_key'] = esc_attr($entry['meta_key']);
   615 	$entry['meta_key']   = esc_attr( $entry['meta_key'] );
   568 	$entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a <textarea />
   616 	$entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a <textarea />
   569 	$entry['meta_id'] = (int) $entry['meta_id'];
   617 	$entry['meta_id']    = (int) $entry['meta_id'];
   570 
   618 
   571 	$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
   619 	$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
   572 
   620 
   573 	$r .= "\n\t<tr id='meta-{$entry['meta_id']}'>";
   621 	$r .= "\n\t<tr id='meta-{$entry['meta_id']}'>";
   574 	$r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta-{$entry['meta_id']}-key'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta-{$entry['meta_id']}-key' type='text' size='20' value='{$entry['meta_key']}' />";
   622 	$r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta-{$entry['meta_id']}-key'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta-{$entry['meta_id']}-key' type='text' size='20' value='{$entry['meta_key']}' />";
   575 
   623 
   576 	$r .= "\n\t\t<div class='submit'>";
   624 	$r .= "\n\t\t<div class='submit'>";
   577 	$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" ) );
   625 	$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" ) );
   578 	$r .= "\n\t\t";
   626 	$r .= "\n\t\t";
   579 	$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" ) );
   627 	$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" ) );
   580 	$r .= "</div>";
   628 	$r .= '</div>';
   581 	$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
   629 	$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
   582 	$r .= "</td>";
   630 	$r .= '</td>';
   583 
   631 
   584 	$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>";
   632 	$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>";
   585 	return $r;
   633 	return $r;
   586 }
   634 }
   587 
   635 
   619 		 * @since 2.1.0
   667 		 * @since 2.1.0
   620 		 *
   668 		 *
   621 		 * @param int $limit Number of custom fields to retrieve. Default 30.
   669 		 * @param int $limit Number of custom fields to retrieve. Default 30.
   622 		 */
   670 		 */
   623 		$limit = apply_filters( 'postmeta_form_limit', 30 );
   671 		$limit = apply_filters( 'postmeta_form_limit', 30 );
   624 		$sql = "SELECT DISTINCT meta_key
   672 		$sql   = "SELECT DISTINCT meta_key
   625 			FROM $wpdb->postmeta
   673 			FROM $wpdb->postmeta
   626 			WHERE meta_key NOT BETWEEN '_' AND '_z'
   674 			WHERE meta_key NOT BETWEEN '_' AND '_z'
   627 			HAVING meta_key NOT LIKE %s
   675 			HAVING meta_key NOT LIKE %s
   628 			ORDER BY meta_key
   676 			ORDER BY meta_key
   629 			LIMIT %d";
   677 			LIMIT %d";
   630 		$keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
   678 		$keys  = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
   631 	}
   679 	}
   632 
   680 
   633 	if ( $keys ) {
   681 	if ( $keys ) {
   634 		natcasesort( $keys );
   682 		natcasesort( $keys );
   635 		$meta_key_input_id = 'metakeyselect';
   683 		$meta_key_input_id = 'metakeyselect';
   636 	} else {
   684 	} else {
   637 		$meta_key_input_id = 'metakeyinput';
   685 		$meta_key_input_id = 'metakeyinput';
   638 	}
   686 	}
   639 ?>
   687 	?>
   640 <p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p>
   688 <p><strong><?php _e( 'Add New Custom Field:' ); ?></strong></p>
   641 <table id="newmeta">
   689 <table id="newmeta">
   642 <thead>
   690 <thead>
   643 <tr>
   691 <tr>
   644 <th class="left"><label for="<?php echo $meta_key_input_id; ?>"><?php _ex( 'Name', 'meta name' ) ?></label></th>
   692 <th class="left"><label for="<?php echo $meta_key_input_id; ?>"><?php _ex( 'Name', 'meta name' ); ?></label></th>
   645 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
   693 <th><label for="metavalue"><?php _e( 'Value' ); ?></label></th>
   646 </tr>
   694 </tr>
   647 </thead>
   695 </thead>
   648 
   696 
   649 <tbody>
   697 <tbody>
   650 <tr>
   698 <tr>
   651 <td id="newmetaleft" class="left">
   699 <td id="newmetaleft" class="left">
   652 <?php if ( $keys ) { ?>
   700 	<?php if ( $keys ) { ?>
   653 <select id="metakeyselect" name="metakeyselect">
   701 <select id="metakeyselect" name="metakeyselect">
   654 <option value="#NONE#"><?php _e( '&mdash; Select &mdash;' ); ?></option>
   702 <option value="#NONE#"><?php _e( '&mdash; Select &mdash;' ); ?></option>
   655 <?php
   703 		<?php
   656 
   704 
   657 	foreach ( $keys as $key ) {
   705 		foreach ( $keys as $key ) {
   658 		if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) )
   706 			if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) ) {
   659 			continue;
   707 				continue;
   660 		echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>";
   708 			}
   661 	}
   709 			echo "\n<option value='" . esc_attr( $key ) . "'>" . esc_html( $key ) . '</option>';
   662 ?>
   710 		}
       
   711 		?>
   663 </select>
   712 </select>
   664 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" value="" />
   713 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" value="" />
   665 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
   714 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
   666 <span id="enternew"><?php _e('Enter new'); ?></span>
   715 <span id="enternew"><?php _e( 'Enter new' ); ?></span>
   667 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
   716 <span id="cancelnew" class="hidden"><?php _e( 'Cancel' ); ?></span></a>
   668 <?php } else { ?>
   717 <?php } else { ?>
   669 <input type="text" id="metakeyinput" name="metakeyinput" value="" />
   718 <input type="text" id="metakeyinput" name="metakeyinput" value="" />
   670 <?php } ?>
   719 <?php } ?>
   671 </td>
   720 </td>
   672 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25"></textarea></td>
   721 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25"></textarea></td>
   673 </tr>
   722 </tr>
   674 
   723 
   675 <tr><td colspan="2">
   724 <tr><td colspan="2">
   676 <div class="submit">
   725 <div class="submit">
   677 <?php submit_button( __( 'Add Custom Field' ), '', 'addmeta', false, array( 'id' => 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta' ) ); ?>
   726 	<?php
       
   727 	submit_button(
       
   728 		__( 'Add Custom Field' ),
       
   729 		'',
       
   730 		'addmeta',
       
   731 		false,
       
   732 		array(
       
   733 			'id'            => 'newmeta-submit',
       
   734 			'data-wp-lists' => 'add:the-list:newmeta',
       
   735 		)
       
   736 	);
       
   737 	?>
   678 </div>
   738 </div>
   679 <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
   739 	<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
   680 </td></tr>
   740 </td></tr>
   681 </tbody>
   741 </tbody>
   682 </table>
   742 </table>
   683 <?php
   743 	<?php
   684 
   744 
   685 }
   745 }
   686 
   746 
   687 /**
   747 /**
   688  * Print out HTML form date elements for editing post or comment publish date.
   748  * Print out HTML form date elements for editing post or comment publish date.
   700  */
   760  */
   701 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
   761 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
   702 	global $wp_locale;
   762 	global $wp_locale;
   703 	$post = get_post();
   763 	$post = get_post();
   704 
   764 
   705 	if ( $for_post )
   765 	if ( $for_post ) {
   706 		$edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
   766 		$edit = ! ( in_array( $post->post_status, array( 'draft', 'pending' ) ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
       
   767 	}
   707 
   768 
   708 	$tab_index_attribute = '';
   769 	$tab_index_attribute = '';
   709 	if ( (int) $tab_index > 0 )
   770 	if ( (int) $tab_index > 0 ) {
   710 		$tab_index_attribute = " tabindex=\"$tab_index\"";
   771 		$tab_index_attribute = " tabindex=\"$tab_index\"";
       
   772 	}
   711 
   773 
   712 	// todo: Remove this?
   774 	// todo: Remove this?
   713 	// 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 />';
   775 	// 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 />';
   714 
   776 
   715 	$time_adj = current_time('timestamp');
   777 	$post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date;
   716 	$post_date = ($for_post) ? $post->post_date : get_comment()->comment_date;
   778 	$jj        = ( $edit ) ? mysql2date( 'd', $post_date, false ) : current_time( 'd' );
   717 	$jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
   779 	$mm        = ( $edit ) ? mysql2date( 'm', $post_date, false ) : current_time( 'm' );
   718 	$mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
   780 	$aa        = ( $edit ) ? mysql2date( 'Y', $post_date, false ) : current_time( 'Y' );
   719 	$aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
   781 	$hh        = ( $edit ) ? mysql2date( 'H', $post_date, false ) : current_time( 'H' );
   720 	$hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
   782 	$mn        = ( $edit ) ? mysql2date( 'i', $post_date, false ) : current_time( 'i' );
   721 	$mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
   783 	$ss        = ( $edit ) ? mysql2date( 's', $post_date, false ) : current_time( 's' );
   722 	$ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
   784 
   723 
   785 	$cur_jj = current_time( 'd' );
   724 	$cur_jj = gmdate( 'd', $time_adj );
   786 	$cur_mm = current_time( 'm' );
   725 	$cur_mm = gmdate( 'm', $time_adj );
   787 	$cur_aa = current_time( 'Y' );
   726 	$cur_aa = gmdate( 'Y', $time_adj );
   788 	$cur_hh = current_time( 'H' );
   727 	$cur_hh = gmdate( 'H', $time_adj );
   789 	$cur_mn = current_time( 'i' );
   728 	$cur_mn = gmdate( 'i', $time_adj );
       
   729 
   790 
   730 	$month = '<label><span class="screen-reader-text">' . __( 'Month' ) . '</span><select ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n";
   791 	$month = '<label><span class="screen-reader-text">' . __( 'Month' ) . '</span><select ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n";
   731 	for ( $i = 1; $i < 13; $i = $i +1 ) {
   792 	for ( $i = 1; $i < 13; $i = $i + 1 ) {
   732 		$monthnum = zeroise($i, 2);
   793 		$monthnum  = zeroise( $i, 2 );
   733 		$monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
   794 		$monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
   734 		$month .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum, $mm, false ) . '>';
   795 		$month    .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum, $mm, false ) . '>';
   735 		/* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
   796 		/* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
   736 		$month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $monthtext ) . "</option>\n";
   797 		$month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $monthtext ) . "</option>\n";
   737 	}
   798 	}
   738 	$month .= '</select></label>';
   799 	$month .= '</select></label>';
   739 
   800 
   740 	$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>';
   801 	$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>';
   741 	$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>';
   802 	$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>';
   742 	$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>';
   803 	$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>';
   743 	$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>';
   804 	$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>';
   744 
   805 
   745 	echo '<div class="timestamp-wrap">';
   806 	echo '<div class="timestamp-wrap">';
   746 	/* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
   807 	/* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
   747 	printf( __( '%1$s %2$s, %3$s @ %4$s:%5$s' ), $month, $day, $year, $hour, $minute );
   808 	printf( __( '%1$s %2$s, %3$s @ %4$s:%5$s' ), $month, $day, $year, $hour, $minute );
   748 
   809 
   749 	echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
   810 	echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
   750 
   811 
   751 	if ( $multi ) return;
   812 	if ( $multi ) {
       
   813 		return;
       
   814 	}
   752 
   815 
   753 	echo "\n\n";
   816 	echo "\n\n";
   754 	$map = array(
   817 	$map = array(
   755 		'mm' => array( $mm, $cur_mm ),
   818 		'mm' => array( $mm, $cur_mm ),
   756 		'jj' => array( $jj, $cur_jj ),
   819 		'jj' => array( $jj, $cur_jj ),
   763 
   826 
   764 		echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $unit . '" />' . "\n";
   827 		echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $unit . '" />' . "\n";
   765 		$cur_timeunit = 'cur_' . $timeunit;
   828 		$cur_timeunit = 'cur_' . $timeunit;
   766 		echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n";
   829 		echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n";
   767 	}
   830 	}
   768 ?>
   831 	?>
   769 
   832 
   770 <p>
   833 <p>
   771 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
   834 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e( 'OK' ); ?></a>
   772 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js button-cancel"><?php _e('Cancel'); ?></a>
   835 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js button-cancel"><?php _e( 'Cancel' ); ?></a>
   773 </p>
   836 </p>
   774 <?php
   837 	<?php
   775 }
   838 }
   776 
   839 
   777 /**
   840 /**
   778  * Print out option HTML elements for the page templates drop-down.
   841  * Print out option HTML elements for the page templates drop-down.
   779  *
   842  *
   786 function page_template_dropdown( $default = '', $post_type = 'page' ) {
   849 function page_template_dropdown( $default = '', $post_type = 'page' ) {
   787 	$templates = get_page_templates( null, $post_type );
   850 	$templates = get_page_templates( null, $post_type );
   788 	ksort( $templates );
   851 	ksort( $templates );
   789 	foreach ( array_keys( $templates ) as $template ) {
   852 	foreach ( array_keys( $templates ) as $template ) {
   790 		$selected = selected( $default, $templates[ $template ], false );
   853 		$selected = selected( $default, $templates[ $template ], false );
   791 		echo "\n\t<option value='" . esc_attr( $templates[ $template ] ) . "' $selected>" . esc_html( $template ) . "</option>";
   854 		echo "\n\t<option value='" . esc_attr( $templates[ $template ] ) . "' $selected>" . esc_html( $template ) . '</option>';
   792 	}
   855 	}
   793 }
   856 }
   794 
   857 
   795 /**
   858 /**
   796  * Print out option HTML elements for the page parents drop-down.
   859  * Print out option HTML elements for the page parents drop-down.
   803  * @param int         $default Optional. The default page ID to be pre-selected. Default 0.
   866  * @param int         $default Optional. The default page ID to be pre-selected. Default 0.
   804  * @param int         $parent  Optional. The parent page ID. Default 0.
   867  * @param int         $parent  Optional. The parent page ID. Default 0.
   805  * @param int         $level   Optional. Page depth level. Default 0.
   868  * @param int         $level   Optional. Page depth level. Default 0.
   806  * @param int|WP_Post $post    Post ID or WP_Post object.
   869  * @param int|WP_Post $post    Post ID or WP_Post object.
   807  *
   870  *
   808  * @return null|false Boolean False if page has no children, otherwise print out html elements
   871  * @return null|false Boolean False if page has no children, otherwise print out html elements.
   809  */
   872  */
   810 function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = null ) {
   873 function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = null ) {
   811 	global $wpdb;
   874 	global $wpdb;
   812 	$post = get_post( $post );
   875 	$post  = get_post( $post );
   813 	$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) );
   876 	$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 ) );
   814 
   877 
   815 	if ( $items ) {
   878 	if ( $items ) {
   816 		foreach ( $items as $item ) {
   879 		foreach ( $items as $item ) {
   817 			// A page cannot be its own parent.
   880 			// A page cannot be its own parent.
   818 			if ( $post && $post->ID && $item->ID == $post->ID )
   881 			if ( $post && $post->ID && $item->ID == $post->ID ) {
   819 				continue;
   882 				continue;
   820 
   883 			}
   821 			$pad = str_repeat( '&nbsp;', $level * 3 );
   884 
       
   885 			$pad      = str_repeat( '&nbsp;', $level * 3 );
   822 			$selected = selected( $default, $item->ID, false );
   886 			$selected = selected( $default, $item->ID, false );
   823 
   887 
   824 			echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html($item->post_title) . "</option>";
   888 			echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html( $item->post_title ) . '</option>';
   825 			parent_dropdown( $default, $item->ID, $level +1 );
   889 			parent_dropdown( $default, $item->ID, $level + 1 );
   826 		}
   890 		}
   827 	} else {
   891 	} else {
   828 		return false;
   892 		return false;
   829 	}
   893 	}
   830 }
   894 }
   840 	$r = '';
   904 	$r = '';
   841 
   905 
   842 	$editable_roles = array_reverse( get_editable_roles() );
   906 	$editable_roles = array_reverse( get_editable_roles() );
   843 
   907 
   844 	foreach ( $editable_roles as $role => $details ) {
   908 	foreach ( $editable_roles as $role => $details ) {
   845 		$name = translate_user_role($details['name'] );
   909 		$name = translate_user_role( $details['name'] );
   846 		// preselect specified role
   910 		// preselect specified role
   847 		if ( $selected == $role ) {
   911 		if ( $selected == $role ) {
   848 			$r .= "\n\t<option selected='selected' value='" . esc_attr( $role ) . "'>$name</option>";
   912 			$r .= "\n\t<option selected='selected' value='" . esc_attr( $role ) . "'>$name</option>";
   849 		} else {
   913 		} else {
   850 			$r .= "\n\t<option value='" . esc_attr( $role ) . "'>$name</option>";
   914 			$r .= "\n\t<option value='" . esc_attr( $role ) . "'>$name</option>";
   870 	 *
   934 	 *
   871 	 * @see wp_max_upload_size()
   935 	 * @see wp_max_upload_size()
   872 	 *
   936 	 *
   873 	 * @param int $max_upload_size Allowed upload size. Default 1 MB.
   937 	 * @param int $max_upload_size Allowed upload size. Default 1 MB.
   874 	 */
   938 	 */
   875 	$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
   939 	$bytes      = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
   876 	$size = size_format( $bytes );
   940 	$size       = size_format( $bytes );
   877 	$upload_dir = wp_upload_dir();
   941 	$upload_dir = wp_upload_dir();
   878 	if ( ! empty( $upload_dir['error'] ) ) :
   942 	if ( ! empty( $upload_dir['error'] ) ) :
   879 		?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
   943 		?>
   880 		<p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
   944 		<div class="error"><p><?php _e( 'Before you can upload your import file, you will need to fix the following error:' ); ?></p>
       
   945 		<p><strong><?php echo $upload_dir['error']; ?></strong></p></div>
       
   946 								<?php
   881 	else :
   947 	else :
   882 ?>
   948 		?>
   883 <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' ) ); ?>">
   949 <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' ) ); ?>">
   884 <p>
   950 <p>
   885 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
   951 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __( 'Maximum size: %s' ), $size ); ?>)
   886 <input type="file" id="upload" name="import" size="25" />
   952 <input type="file" id="upload" name="import" size="25" />
   887 <input type="hidden" name="action" value="save" />
   953 <input type="hidden" name="action" value="save" />
   888 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
   954 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
   889 </p>
   955 </p>
   890 <?php submit_button( __('Upload file and import'), 'primary' ); ?>
   956 		<?php submit_button( __( 'Upload file and import' ), 'primary' ); ?>
   891 </form>
   957 </form>
   892 <?php
   958 		<?php
   893 	endif;
   959 	endif;
   894 }
   960 }
   895 
   961 
   896 /**
   962 /**
   897  * Adds a meta box to one or more screens.
   963  * Adds a meta box to one or more screens.
   941 		return;
  1007 		return;
   942 	}
  1008 	}
   943 
  1009 
   944 	$page = $screen->id;
  1010 	$page = $screen->id;
   945 
  1011 
   946 	if ( !isset($wp_meta_boxes) )
  1012 	if ( ! isset( $wp_meta_boxes ) ) {
   947 		$wp_meta_boxes = array();
  1013 		$wp_meta_boxes = array();
   948 	if ( !isset($wp_meta_boxes[$page]) )
  1014 	}
   949 		$wp_meta_boxes[$page] = array();
  1015 	if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
   950 	if ( !isset($wp_meta_boxes[$page][$context]) )
  1016 		$wp_meta_boxes[ $page ] = array();
   951 		$wp_meta_boxes[$page][$context] = array();
  1017 	}
   952 
  1018 	if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
   953 	foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
  1019 		$wp_meta_boxes[ $page ][ $context ] = array();
   954 		foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
  1020 	}
   955 			if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
  1021 
       
  1022 	foreach ( array_keys( $wp_meta_boxes[ $page ] ) as $a_context ) {
       
  1023 		foreach ( array( 'high', 'core', 'default', 'low' ) as $a_priority ) {
       
  1024 			if ( ! isset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) ) {
   956 				continue;
  1025 				continue;
       
  1026 			}
   957 
  1027 
   958 			// If a core box was previously added or removed by a plugin, don't add.
  1028 			// If a core box was previously added or removed by a plugin, don't add.
   959 			if ( 'core' == $priority ) {
  1029 			if ( 'core' == $priority ) {
   960 				// If core box previously deleted, don't add
  1030 				// If core box previously deleted, don't add
   961 				if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
  1031 				if ( false === $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) {
   962 					return;
  1032 					return;
       
  1033 				}
   963 
  1034 
   964 				/*
  1035 				/*
   965 				 * If box was added with default priority, give it core priority to
  1036 				 * If box was added with default priority, give it core priority to
   966 				 * maintain sort order.
  1037 				 * maintain sort order.
   967 				 */
  1038 				 */
   968 				if ( 'default' == $a_priority ) {
  1039 				if ( 'default' == $a_priority ) {
   969 					$wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
  1040 					$wp_meta_boxes[ $page ][ $a_context ]['core'][ $id ] = $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ];
   970 					unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
  1041 					unset( $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ] );
   971 				}
  1042 				}
   972 				return;
  1043 				return;
   973 			}
  1044 			}
   974 			// If no priority given and id already present, use existing priority.
  1045 			// If no priority given and id already present, use existing priority.
   975 			if ( empty($priority) ) {
  1046 			if ( empty( $priority ) ) {
   976 				$priority = $a_priority;
  1047 				$priority = $a_priority;
   977 			/*
  1048 				/*
   978 			 * Else, if we're adding to the sorted priority, we don't know the title
  1049 				* Else, if we're adding to the sorted priority, we don't know the title
   979 			 * or callback. Grab them from the previously added context/priority.
  1050 				* or callback. Grab them from the previously added context/priority.
   980 			 */
  1051 				*/
   981 			} elseif ( 'sorted' == $priority ) {
  1052 			} elseif ( 'sorted' == $priority ) {
   982 				$title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
  1053 				$title         = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['title'];
   983 				$callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
  1054 				$callback      = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['callback'];
   984 				$callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
  1055 				$callback_args = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['args'];
   985 			}
  1056 			}
   986 			// An id can be in only one priority and one context.
  1057 			// An id can be in only one priority and one context.
   987 			if ( $priority != $a_priority || $context != $a_context )
  1058 			if ( $priority != $a_priority || $context != $a_context ) {
   988 				unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
  1059 				unset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] );
   989 		}
  1060 			}
   990 	}
  1061 		}
   991 
  1062 	}
   992 	if ( empty($priority) )
  1063 
       
  1064 	if ( empty( $priority ) ) {
   993 		$priority = 'low';
  1065 		$priority = 'low';
   994 
  1066 	}
   995 	if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
  1067 
   996 		$wp_meta_boxes[$page][$context][$priority] = array();
  1068 	if ( ! isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
   997 
  1069 		$wp_meta_boxes[ $page ][ $context ][ $priority ] = array();
   998 	$wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
  1070 	}
   999 }
  1071 
  1000 
  1072 	$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = array(
  1001 /**
  1073 		'id'       => $id,
  1002  * Meta-Box template function
  1074 		'title'    => $title,
       
  1075 		'callback' => $callback,
       
  1076 		'args'     => $callback_args,
       
  1077 	);
       
  1078 }
       
  1079 
       
  1080 
       
  1081 /**
       
  1082  * Function that renders a "fake" meta box with an information message,
       
  1083  * shown on the block editor, when an incompatible meta box is found.
       
  1084  *
       
  1085  * @since 5.0.0
       
  1086  *
       
  1087  * @param mixed $object The data object being rendered on this screen.
       
  1088  * @param array $box    {
       
  1089  *     Custom formats meta box arguments.
       
  1090  *
       
  1091  *     @type string   $id           Meta box 'id' attribute.
       
  1092  *     @type string   $title        Meta box title.
       
  1093  *     @type callable $old_callback The original callback for this meta box.
       
  1094  *     @type array    $args         Extra meta box arguments.
       
  1095  * }
       
  1096  */
       
  1097 function do_block_editor_incompatible_meta_box( $object, $box ) {
       
  1098 	$plugin  = _get_plugin_from_callback( $box['old_callback'] );
       
  1099 	$plugins = get_plugins();
       
  1100 	echo '<p>';
       
  1101 	if ( $plugin ) {
       
  1102 		/* translators: %s: the name of the plugin that generated this meta box. */
       
  1103 		printf( __( "This meta box, from the %s plugin, isn't compatible with the block editor." ), "<strong>{$plugin['Name']}</strong>" );
       
  1104 	} else {
       
  1105 		_e( "This meta box isn't compatible with the block editor." );
       
  1106 	}
       
  1107 	echo '</p>';
       
  1108 
       
  1109 	if ( empty( $plugins['classic-editor/classic-editor.php'] ) ) {
       
  1110 		if ( current_user_can( 'install_plugins' ) ) {
       
  1111 			echo '<p>';
       
  1112 			/* translators: %s: A link to install the Classic Editor plugin. */
       
  1113 			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' ) ) );
       
  1114 			echo '</p>';
       
  1115 		}
       
  1116 	} elseif ( is_plugin_inactive( 'classic-editor/classic-editor.php' ) ) {
       
  1117 		if ( current_user_can( 'activate_plugins' ) ) {
       
  1118 			$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' );
       
  1119 			echo '<p>';
       
  1120 			/* translators: %s: A link to activate the Classic Editor plugin. */
       
  1121 			printf( __( 'Please activate the <a href="%s">Classic Editor plugin</a> to use this meta box.' ), esc_url( $activate_url ) );
       
  1122 			echo '</p>';
       
  1123 		}
       
  1124 	} elseif ( $object instanceof WP_Post ) {
       
  1125 		$edit_url = add_query_arg(
       
  1126 			array(
       
  1127 				'classic-editor'         => '',
       
  1128 				'classic-editor__forget' => '',
       
  1129 			),
       
  1130 			get_edit_post_link( $object )
       
  1131 		);
       
  1132 		echo '<p>';
       
  1133 		/* translators: %s: A link to use the Classic Editor plugin. */
       
  1134 		printf( __( 'Please open the <a href="%s">classic editor</a> to use this meta box.' ), esc_url( $edit_url ) );
       
  1135 		echo '</p>';
       
  1136 	}
       
  1137 }
       
  1138 
       
  1139 /**
       
  1140  * Internal helper function to find the plugin from a meta box callback.
       
  1141  *
       
  1142  * @since 5.0.0
       
  1143  *
       
  1144  * @access private
       
  1145  *
       
  1146  * @param callable $callback The callback function to check.
       
  1147  * @return array|null The plugin that the callback belongs to, or null if it doesn't belong to a plugin.
       
  1148  */
       
  1149 function _get_plugin_from_callback( $callback ) {
       
  1150 	try {
       
  1151 		if ( is_array( $callback ) ) {
       
  1152 			$reflection = new ReflectionMethod( $callback[0], $callback[1] );
       
  1153 		} elseif ( is_string( $callback ) && false !== strpos( $callback, '::' ) ) {
       
  1154 			$reflection = new ReflectionMethod( $callback );
       
  1155 		} else {
       
  1156 			$reflection = new ReflectionFunction( $callback );
       
  1157 		}
       
  1158 	} catch ( ReflectionException $exception ) {
       
  1159 		// We could not properly reflect on the callable, so we abort here.
       
  1160 		return null;
       
  1161 	}
       
  1162 
       
  1163 	// Don't show an error if it's an internal PHP function.
       
  1164 	if ( ! $reflection->isInternal() ) {
       
  1165 
       
  1166 		// Only show errors if the meta box was registered by a plugin.
       
  1167 		$filename   = wp_normalize_path( $reflection->getFileName() );
       
  1168 		$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
       
  1169 		if ( strpos( $filename, $plugin_dir ) === 0 ) {
       
  1170 			$filename = str_replace( $plugin_dir, '', $filename );
       
  1171 			$filename = preg_replace( '|^/([^/]*/).*$|', '\\1', $filename );
       
  1172 
       
  1173 			$plugins = get_plugins();
       
  1174 			foreach ( $plugins as $name => $plugin ) {
       
  1175 				if ( strpos( $name, $filename ) === 0 ) {
       
  1176 					return $plugin;
       
  1177 				}
       
  1178 			}
       
  1179 		}
       
  1180 	}
       
  1181 
       
  1182 	return null;
       
  1183 }
       
  1184 
       
  1185 /**
       
  1186  * Meta-Box template function.
  1003  *
  1187  *
  1004  * @since 2.5.0
  1188  * @since 2.5.0
  1005  *
  1189  *
  1006  * @global array $wp_meta_boxes
  1190  * @global array $wp_meta_boxes
  1007  *
  1191  *
  1009  *
  1193  *
  1010  * @param string|WP_Screen $screen  Screen identifier. If you have used add_menu_page() or
  1194  * @param string|WP_Screen $screen  Screen identifier. If you have used add_menu_page() or
  1011  *                                  add_submenu_page() to create a new screen (and hence screen_id)
  1195  *                                  add_submenu_page() to create a new screen (and hence screen_id)
  1012  *                                  make sure your menu slug conforms to the limits of sanitize_key()
  1196  *                                  make sure your menu slug conforms to the limits of sanitize_key()
  1013  *                                  otherwise the 'screen' menu may not correctly render on your page.
  1197  *                                  otherwise the 'screen' menu may not correctly render on your page.
  1014  * @param string           $context box context
  1198  * @param string           $context The screen context for which to display meta boxes.
  1015  * @param mixed            $object  gets passed to the box callback function as first parameter
  1199  * @param mixed            $object  Gets passed to the first parameter of the meta box callback function.
       
  1200  *                                  Often this is the object that's the focus of the current screen, for
       
  1201  *                                  example a `WP_Post` or `WP_Comment` object.
  1016  * @return int number of meta_boxes
  1202  * @return int number of meta_boxes
  1017  */
  1203  */
  1018 function do_meta_boxes( $screen, $context, $object ) {
  1204 function do_meta_boxes( $screen, $context, $object ) {
  1019 	global $wp_meta_boxes;
  1205 	global $wp_meta_boxes;
  1020 	static $already_sorted = false;
  1206 	static $already_sorted = false;
  1021 
  1207 
  1022 	if ( empty( $screen ) )
  1208 	if ( empty( $screen ) ) {
  1023 		$screen = get_current_screen();
  1209 		$screen = get_current_screen();
  1024 	elseif ( is_string( $screen ) )
  1210 	} elseif ( is_string( $screen ) ) {
  1025 		$screen = convert_to_screen( $screen );
  1211 		$screen = convert_to_screen( $screen );
       
  1212 	}
  1026 
  1213 
  1027 	$page = $screen->id;
  1214 	$page = $screen->id;
  1028 
  1215 
  1029 	$hidden = get_hidden_meta_boxes( $screen );
  1216 	$hidden = get_hidden_meta_boxes( $screen );
  1030 
  1217 
  1045 
  1232 
  1046 	$i = 0;
  1233 	$i = 0;
  1047 
  1234 
  1048 	if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
  1235 	if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
  1049 		foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) {
  1236 		foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) {
  1050 			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ]) ) {
  1237 			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
  1051 				foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
  1238 				foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
  1052 					if ( false == $box || ! $box['title'] )
  1239 					if ( false == $box || ! $box['title'] ) {
  1053 						continue;
  1240 						continue;
       
  1241 					}
       
  1242 
       
  1243 					$block_compatible = true;
       
  1244 					if ( is_array( $box['args'] ) ) {
       
  1245 						// If a meta box is just here for back compat, don't show it in the block editor.
       
  1246 						if ( $screen->is_block_editor() && isset( $box['args']['__back_compat_meta_box'] ) && $box['args']['__back_compat_meta_box'] ) {
       
  1247 							continue;
       
  1248 						}
       
  1249 
       
  1250 						if ( isset( $box['args']['__block_editor_compatible_meta_box'] ) ) {
       
  1251 							$block_compatible = (bool) $box['args']['__block_editor_compatible_meta_box'];
       
  1252 							unset( $box['args']['__block_editor_compatible_meta_box'] );
       
  1253 						}
       
  1254 
       
  1255 						// If the meta box is declared as incompatible with the block editor, override the callback function.
       
  1256 						if ( ! $block_compatible && $screen->is_block_editor() ) {
       
  1257 							$box['old_callback'] = $box['callback'];
       
  1258 							$box['callback']     = 'do_block_editor_incompatible_meta_box';
       
  1259 						}
       
  1260 
       
  1261 						if ( isset( $box['args']['__back_compat_meta_box'] ) ) {
       
  1262 							$block_compatible = $block_compatible || (bool) $box['args']['__back_compat_meta_box'];
       
  1263 							unset( $box['args']['__back_compat_meta_box'] );
       
  1264 						}
       
  1265 					}
       
  1266 
  1054 					$i++;
  1267 					$i++;
  1055 					$hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
  1268 					// get_hidden_meta_boxes() doesn't apply in the block editor.
  1056 					echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n";
  1269 					$hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden ) ) ? ' hide-if-js' : '';
       
  1270 					echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>' . "\n";
  1057 					if ( 'dashboard_browser_nag' != $box['id'] ) {
  1271 					if ( 'dashboard_browser_nag' != $box['id'] ) {
  1058 						$widget_title = $box[ 'title' ];
  1272 						$widget_title = $box['title'];
  1059 
  1273 
  1060 						if ( is_array( $box[ 'args' ] ) && isset( $box[ 'args' ][ '__widget_basename' ] ) ) {
  1274 						if ( is_array( $box['args'] ) && isset( $box['args']['__widget_basename'] ) ) {
  1061 							$widget_title = $box[ 'args' ][ '__widget_basename' ];
  1275 							$widget_title = $box['args']['__widget_basename'];
  1062 							// Do not pass this parameter to the user callback function.
  1276 							// Do not pass this parameter to the user callback function.
  1063 							unset( $box[ 'args' ][ '__widget_basename' ] );
  1277 							unset( $box['args']['__widget_basename'] );
  1064 						}
  1278 						}
  1065 
  1279 
  1066 						echo '<button type="button" class="handlediv" aria-expanded="true">';
  1280 						echo '<button type="button" class="handlediv" aria-expanded="true">';
  1067 						echo '<span class="screen-reader-text">' . sprintf( __( 'Toggle panel: %s' ), $widget_title ) . '</span>';
  1281 						echo '<span class="screen-reader-text">' . sprintf( __( 'Toggle panel: %s' ), $widget_title ) . '</span>';
  1068 						echo '<span class="toggle-indicator" aria-hidden="true"></span>';
  1282 						echo '<span class="toggle-indicator" aria-hidden="true"></span>';
  1069 						echo '</button>';
  1283 						echo '</button>';
  1070 					}
  1284 					}
  1071 					echo "<h2 class='hndle'><span>{$box['title']}</span></h2>\n";
  1285 					echo '<h2 class="hndle">';
       
  1286 					if ( 'dashboard_php_nag' === $box['id'] ) {
       
  1287 						echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>';
       
  1288 						echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>';
       
  1289 					}
       
  1290 					echo "<span>{$box['title']}</span>";
       
  1291 					echo "</h2>\n";
  1072 					echo '<div class="inside">' . "\n";
  1292 					echo '<div class="inside">' . "\n";
  1073 					call_user_func($box['callback'], $object, $box);
  1293 
       
  1294 					if ( WP_DEBUG && ! $block_compatible && 'edit' === $screen->parent_base && ! $screen->is_block_editor() && ! isset( $_GET['meta-box-loader'] ) ) {
       
  1295 						$plugin = _get_plugin_from_callback( $box['callback'] );
       
  1296 						if ( $plugin ) {
       
  1297 							?>
       
  1298 							<div class="error inline">
       
  1299 								<p>
       
  1300 									<?php
       
  1301 										/* translators: %s: the name of the plugin that generated this meta box. */
       
  1302 										printf( __( "This meta box, from the %s plugin, isn't compatible with the block editor." ), "<strong>{$plugin['Name']}</strong>" );
       
  1303 									?>
       
  1304 								</p>
       
  1305 							</div>
       
  1306 							<?php
       
  1307 						}
       
  1308 					}
       
  1309 
       
  1310 					call_user_func( $box['callback'], $object, $box );
  1074 					echo "</div>\n";
  1311 					echo "</div>\n";
  1075 					echo "</div>\n";
  1312 					echo "</div>\n";
  1076 				}
  1313 				}
  1077 			}
  1314 			}
  1078 		}
  1315 		}
  1079 	}
  1316 	}
  1080 
  1317 
  1081 	echo "</div>";
  1318 	echo '</div>';
  1082 
  1319 
  1083 	return $i;
  1320 	return $i;
  1084 
  1321 
  1085 }
  1322 }
  1086 
  1323 
  1119 		return;
  1356 		return;
  1120 	}
  1357 	}
  1121 
  1358 
  1122 	$page = $screen->id;
  1359 	$page = $screen->id;
  1123 
  1360 
  1124 	if ( !isset($wp_meta_boxes) )
  1361 	if ( ! isset( $wp_meta_boxes ) ) {
  1125 		$wp_meta_boxes = array();
  1362 		$wp_meta_boxes = array();
  1126 	if ( !isset($wp_meta_boxes[$page]) )
  1363 	}
  1127 		$wp_meta_boxes[$page] = array();
  1364 	if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
  1128 	if ( !isset($wp_meta_boxes[$page][$context]) )
  1365 		$wp_meta_boxes[ $page ] = array();
  1129 		$wp_meta_boxes[$page][$context] = array();
  1366 	}
  1130 
  1367 	if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
  1131 	foreach ( array('high', 'core', 'default', 'low') as $priority )
  1368 		$wp_meta_boxes[ $page ][ $context ] = array();
  1132 		$wp_meta_boxes[$page][$context][$priority][$id] = false;
  1369 	}
  1133 }
  1370 
  1134 
  1371 	foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
  1135 /**
  1372 		$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false;
  1136  * Meta Box Accordion Template Function
  1373 	}
       
  1374 }
       
  1375 
       
  1376 /**
       
  1377  * Meta Box Accordion Template Function.
  1137  *
  1378  *
  1138  * Largely made up of abstracted code from do_meta_boxes(), this
  1379  * Largely made up of abstracted code from do_meta_boxes(), this
  1139  * function serves to build meta boxes as list items for display as
  1380  * function serves to build meta boxes as list items for display as
  1140  * a collapsible accordion.
  1381  * a collapsible accordion.
  1141  *
  1382  *
  1151 function do_accordion_sections( $screen, $context, $object ) {
  1392 function do_accordion_sections( $screen, $context, $object ) {
  1152 	global $wp_meta_boxes;
  1393 	global $wp_meta_boxes;
  1153 
  1394 
  1154 	wp_enqueue_script( 'accordion' );
  1395 	wp_enqueue_script( 'accordion' );
  1155 
  1396 
  1156 	if ( empty( $screen ) )
  1397 	if ( empty( $screen ) ) {
  1157 		$screen = get_current_screen();
  1398 		$screen = get_current_screen();
  1158 	elseif ( is_string( $screen ) )
  1399 	} elseif ( is_string( $screen ) ) {
  1159 		$screen = convert_to_screen( $screen );
  1400 		$screen = convert_to_screen( $screen );
       
  1401 	}
  1160 
  1402 
  1161 	$page = $screen->id;
  1403 	$page = $screen->id;
  1162 
  1404 
  1163 	$hidden = get_hidden_meta_boxes( $screen );
  1405 	$hidden = get_hidden_meta_boxes( $screen );
  1164 	?>
  1406 	?>
  1165 	<div id="side-sortables" class="accordion-container">
  1407 	<div id="side-sortables" class="accordion-container">
  1166 		<ul class="outer-border">
  1408 		<ul class="outer-border">
  1167 	<?php
  1409 	<?php
  1168 	$i = 0;
  1410 	$i          = 0;
  1169 	$first_open = false;
  1411 	$first_open = false;
  1170 
  1412 
  1171 	if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
  1413 	if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
  1172 		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
  1414 		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
  1173 			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
  1415 			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
  1174 				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
  1416 				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
  1175 					if ( false == $box || ! $box['title'] )
  1417 					if ( false == $box || ! $box['title'] ) {
  1176 						continue;
  1418 						continue;
       
  1419 					}
  1177 					$i++;
  1420 					$i++;
  1178 					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
  1421 					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
  1179 
  1422 
  1180 					$open_class = '';
  1423 					$open_class = '';
  1181 					if ( ! $first_open && empty( $hidden_class ) ) {
  1424 					if ( ! $first_open && empty( $hidden_class ) ) {
  1209 /**
  1452 /**
  1210  * Add a new section to a settings page.
  1453  * Add a new section to a settings page.
  1211  *
  1454  *
  1212  * Part of the Settings API. Use this to define new settings sections for an admin page.
  1455  * Part of the Settings API. Use this to define new settings sections for an admin page.
  1213  * Show settings sections in your admin page callback function with do_settings_sections().
  1456  * Show settings sections in your admin page callback function with do_settings_sections().
  1214  * Add settings fields to your section with add_settings_field()
  1457  * Add settings fields to your section with add_settings_field().
  1215  *
  1458  *
  1216  * The $callback argument should be the name of a function that echoes out any
  1459  * The $callback argument should be the name of a function that echoes out any
  1217  * content you want to show at the top of the settings section before the actual
  1460  * content you want to show at the top of the settings section before the actual
  1218  * fields. It can output nothing if you want.
  1461  * fields. It can output nothing if you want.
  1219  *
  1462  *
  1220  * @since 2.7.0
  1463  * @since 2.7.0
  1221  *
  1464  *
  1222  * @global $wp_settings_sections Storage array of all settings sections added to admin pages
  1465  * @global $wp_settings_sections Storage array of all settings sections added to admin pages.
  1223  *
  1466  *
  1224  * @param string   $id       Slug-name to identify the section. Used in the 'id' attribute of tags.
  1467  * @param string   $id       Slug-name to identify the section. Used in the 'id' attribute of tags.
  1225  * @param string   $title    Formatted title of the section. Shown as the heading for the section.
  1468  * @param string   $title    Formatted title of the section. Shown as the heading for the section.
  1226  * @param callable $callback Function that echos out any content at the top of the section (between heading and fields).
  1469  * @param callable $callback Function that echos out any content at the top of the section (between heading and fields).
  1227  * @param string   $page     The slug-name of the settings page on which to show the section. Built-in pages include
  1470  * @param string   $page     The slug-name of the settings page on which to show the section. Built-in pages include
  1228  *                           'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using
  1471  *                           'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using
  1229  *                           add_options_page();
  1472  *                           add_options_page();
  1230  */
  1473  */
  1231 function add_settings_section($id, $title, $callback, $page) {
  1474 function add_settings_section( $id, $title, $callback, $page ) {
  1232 	global $wp_settings_sections;
  1475 	global $wp_settings_sections;
  1233 
  1476 
  1234 	if ( 'misc' == $page ) {
  1477 	if ( 'misc' == $page ) {
  1235 		_deprecated_argument( __FUNCTION__, '3.0.0',
  1478 		_deprecated_argument(
       
  1479 			__FUNCTION__,
       
  1480 			'3.0.0',
  1236 			/* translators: %s: misc */
  1481 			/* translators: %s: misc */
  1237 			sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
  1482 			sprintf(
       
  1483 				__( 'The "%s" options group has been removed. Use another settings group.' ),
  1238 				'misc'
  1484 				'misc'
  1239 			)
  1485 			)
  1240 		);
  1486 		);
  1241 		$page = 'general';
  1487 		$page = 'general';
  1242 	}
  1488 	}
  1243 
  1489 
  1244 	if ( 'privacy' == $page ) {
  1490 	if ( 'privacy' == $page ) {
  1245 		_deprecated_argument( __FUNCTION__, '3.5.0',
  1491 		_deprecated_argument(
       
  1492 			__FUNCTION__,
       
  1493 			'3.5.0',
  1246 			/* translators: %s: privacy */
  1494 			/* translators: %s: privacy */
  1247 			sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
  1495 			sprintf(
       
  1496 				__( 'The "%s" options group has been removed. Use another settings group.' ),
  1248 				'privacy'
  1497 				'privacy'
  1249 			)
  1498 			)
  1250 		);
  1499 		);
  1251 		$page = 'reading';
  1500 		$page = 'reading';
  1252 	}
  1501 	}
  1253 
  1502 
  1254 	$wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
  1503 	$wp_settings_sections[ $page ][ $id ] = array(
  1255 }
  1504 		'id'       => $id,
  1256 
  1505 		'title'    => $title,
  1257 /**
  1506 		'callback' => $callback,
  1258  * Add a new field to a section of a settings page
  1507 	);
       
  1508 }
       
  1509 
       
  1510 /**
       
  1511  * Add a new field to a section of a settings page.
  1259  *
  1512  *
  1260  * Part of the Settings API. Use this to define a settings field that will show
  1513  * Part of the Settings API. Use this to define a settings field that will show
  1261  * as part of a settings section inside a settings page. The fields are shown using
  1514  * as part of a settings section inside a settings page. The fields are shown using
  1262  * do_settings_fields() in do_settings-sections()
  1515  * do_settings_fields() in do_settings-sections()
  1263  *
  1516  *
  1266  * values to show.
  1519  * values to show.
  1267  *
  1520  *
  1268  * @since 2.7.0
  1521  * @since 2.7.0
  1269  * @since 4.2.0 The `$class` argument was added.
  1522  * @since 4.2.0 The `$class` argument was added.
  1270  *
  1523  *
  1271  * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
  1524  * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections.
  1272  *
  1525  *
  1273  * @param string   $id       Slug-name to identify the field. Used in the 'id' attribute of tags.
  1526  * @param string   $id       Slug-name to identify the field. Used in the 'id' attribute of tags.
  1274  * @param string   $title    Formatted title of the field. Shown as the label for the field
  1527  * @param string   $title    Formatted title of the field. Shown as the label for the field
  1275  *                           during output.
  1528  *                           during output.
  1276  * @param callable $callback Function that fills the field with the desired form inputs. The
  1529  * @param callable $callback Function that fills the field with the desired form inputs. The
  1287  *                             with this value.
  1540  *                             with this value.
  1288  *     @type string $class     CSS Class to be added to the `<tr>` element when the
  1541  *     @type string $class     CSS Class to be added to the `<tr>` element when the
  1289  *                             field is output.
  1542  *                             field is output.
  1290  * }
  1543  * }
  1291  */
  1544  */
  1292 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
  1545 function add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() ) {
  1293 	global $wp_settings_fields;
  1546 	global $wp_settings_fields;
  1294 
  1547 
  1295 	if ( 'misc' == $page ) {
  1548 	if ( 'misc' == $page ) {
  1296 		_deprecated_argument( __FUNCTION__, '3.0.0',
  1549 		_deprecated_argument(
       
  1550 			__FUNCTION__,
       
  1551 			'3.0.0',
  1297 			/* translators: %s: misc */
  1552 			/* translators: %s: misc */
  1298 			sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
  1553 			sprintf(
       
  1554 				__( 'The "%s" options group has been removed. Use another settings group.' ),
  1299 				'misc'
  1555 				'misc'
  1300 			)
  1556 			)
  1301 		);
  1557 		);
  1302 		$page = 'general';
  1558 		$page = 'general';
  1303 	}
  1559 	}
  1304 
  1560 
  1305 	if ( 'privacy' == $page ) {
  1561 	if ( 'privacy' == $page ) {
  1306 		_deprecated_argument( __FUNCTION__, '3.5.0',
  1562 		_deprecated_argument(
       
  1563 			__FUNCTION__,
       
  1564 			'3.5.0',
  1307 			/* translators: %s: privacy */
  1565 			/* translators: %s: privacy */
  1308 			sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
  1566 			sprintf(
       
  1567 				__( 'The "%s" options group has been removed. Use another settings group.' ),
  1309 				'privacy'
  1568 				'privacy'
  1310 			)
  1569 			)
  1311 		);
  1570 		);
  1312 		$page = 'reading';
  1571 		$page = 'reading';
  1313 	}
  1572 	}
  1314 
  1573 
  1315 	$wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
  1574 	$wp_settings_fields[ $page ][ $section ][ $id ] = array(
       
  1575 		'id'       => $id,
       
  1576 		'title'    => $title,
       
  1577 		'callback' => $callback,
       
  1578 		'args'     => $args,
       
  1579 	);
  1316 }
  1580 }
  1317 
  1581 
  1318 /**
  1582 /**
  1319  * Prints out all settings sections added to a particular settings page
  1583  * Prints out all settings sections added to a particular settings page
  1320  *
  1584  *
  1321  * Part of the Settings API. Use this in a settings page callback function
  1585  * Part of the Settings API. Use this in a settings page callback function
  1322  * to output all the sections and fields that were added to that $page with
  1586  * to output all the sections and fields that were added to that $page with
  1323  * add_settings_section() and add_settings_field()
  1587  * add_settings_section() and add_settings_field()
  1324  *
  1588  *
  1325  * @global $wp_settings_sections Storage array of all settings sections added to admin pages
  1589  * @global $wp_settings_sections Storage array of all settings sections added to admin pages.
  1326  * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
  1590  * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections.
  1327  * @since 2.7.0
  1591  * @since 2.7.0
  1328  *
  1592  *
  1329  * @param string $page The slug name of the page whose settings sections you want to output
  1593  * @param string $page The slug name of the page whose settings sections you want to output.
  1330  */
  1594  */
  1331 function do_settings_sections( $page ) {
  1595 function do_settings_sections( $page ) {
  1332 	global $wp_settings_sections, $wp_settings_fields;
  1596 	global $wp_settings_sections, $wp_settings_fields;
  1333 
  1597 
  1334 	if ( ! isset( $wp_settings_sections[$page] ) )
  1598 	if ( ! isset( $wp_settings_sections[ $page ] ) ) {
  1335 		return;
  1599 		return;
  1336 
  1600 	}
  1337 	foreach ( (array) $wp_settings_sections[$page] as $section ) {
  1601 
  1338 		if ( $section['title'] )
  1602 	foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
       
  1603 		if ( $section['title'] ) {
  1339 			echo "<h2>{$section['title']}</h2>\n";
  1604 			echo "<h2>{$section['title']}</h2>\n";
  1340 
  1605 		}
  1341 		if ( $section['callback'] )
  1606 
       
  1607 		if ( $section['callback'] ) {
  1342 			call_user_func( $section['callback'], $section );
  1608 			call_user_func( $section['callback'], $section );
  1343 
  1609 		}
  1344 		if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) )
  1610 
       
  1611 		if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) {
  1345 			continue;
  1612 			continue;
  1346 		echo '<table class="form-table">';
  1613 		}
       
  1614 		echo '<table class="form-table" role="presentation">';
  1347 		do_settings_fields( $page, $section['id'] );
  1615 		do_settings_fields( $page, $section['id'] );
  1348 		echo '</table>';
  1616 		echo '</table>';
  1349 	}
  1617 	}
  1350 }
  1618 }
  1351 
  1619 
  1352 /**
  1620 /**
  1353  * Print out the settings fields for a particular settings section
  1621  * Print out the settings fields for a particular settings section.
  1354  *
  1622  *
  1355  * Part of the Settings API. Use this in a settings page to output
  1623  * Part of the Settings API. Use this in a settings page to output
  1356  * a specific section. Should normally be called by do_settings_sections()
  1624  * a specific section. Should normally be called by do_settings_sections()
  1357  * rather than directly.
  1625  * rather than directly.
  1358  *
  1626  *
  1359  * @global $wp_settings_fields Storage array of settings fields and their pages/sections
  1627  * @global $wp_settings_fields Storage array of settings fields and their pages/sections.
  1360  *
  1628  *
  1361  * @since 2.7.0
  1629  * @since 2.7.0
  1362  *
  1630  *
  1363  * @param string $page Slug title of the admin page who's settings fields you want to show.
  1631  * @param string $page Slug title of the admin page whose settings fields you want to show.
  1364  * @param string $section Slug title of the settings section who's fields you want to show.
  1632  * @param string $section Slug title of the settings section whose fields you want to show.
  1365  */
  1633  */
  1366 function do_settings_fields($page, $section) {
  1634 function do_settings_fields( $page, $section ) {
  1367 	global $wp_settings_fields;
  1635 	global $wp_settings_fields;
  1368 
  1636 
  1369 	if ( ! isset( $wp_settings_fields[$page][$section] ) )
  1637 	if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
  1370 		return;
  1638 		return;
  1371 
  1639 	}
  1372 	foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
  1640 
       
  1641 	foreach ( (array) $wp_settings_fields[ $page ][ $section ] as $field ) {
  1373 		$class = '';
  1642 		$class = '';
  1374 
  1643 
  1375 		if ( ! empty( $field['args']['class'] ) ) {
  1644 		if ( ! empty( $field['args']['class'] ) ) {
  1376 			$class = ' class="' . esc_attr( $field['args']['class'] ) . '"';
  1645 			$class = ' class="' . esc_attr( $field['args']['class'] ) . '"';
  1377 		}
  1646 		}
  1383 		} else {
  1652 		} else {
  1384 			echo '<th scope="row">' . $field['title'] . '</th>';
  1653 			echo '<th scope="row">' . $field['title'] . '</th>';
  1385 		}
  1654 		}
  1386 
  1655 
  1387 		echo '<td>';
  1656 		echo '<td>';
  1388 		call_user_func($field['callback'], $field['args']);
  1657 		call_user_func( $field['callback'], $field['args'] );
  1389 		echo '</td>';
  1658 		echo '</td>';
  1390 		echo '</tr>';
  1659 		echo '</tr>';
  1391 	}
  1660 	}
  1392 }
  1661 }
  1393 
  1662 
  1394 /**
  1663 /**
  1395  * Register a settings error to be displayed to the user
  1664  * Register a settings error to be displayed to the user.
  1396  *
  1665  *
  1397  * Part of the Settings API. Use this to show messages to users about settings validation
  1666  * Part of the Settings API. Use this to show messages to users about settings validation
  1398  * problems, missing settings or anything else.
  1667  * problems, missing settings or anything else.
  1399  *
  1668  *
  1400  * Settings errors should be added inside the $sanitize_callback function defined in
  1669  * Settings errors should be added inside the $sanitize_callback function defined in
  1406  *
  1675  *
  1407  * @since 3.0.0
  1676  * @since 3.0.0
  1408  *
  1677  *
  1409  * @global array $wp_settings_errors Storage array of errors registered during this pageload
  1678  * @global array $wp_settings_errors Storage array of errors registered during this pageload
  1410  *
  1679  *
  1411  * @param string $setting Slug title of the setting to which this error applies
  1680  * @param string $setting Slug title of the setting to which this error applies.
  1412  * @param string $code    Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
  1681  * @param string $code    Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
  1413  * @param string $message The formatted message text to display to the user (will be shown inside styled
  1682  * @param string $message The formatted message text to display to the user (will be shown inside styled
  1414  *                        `<div>` and `<p>` tags).
  1683  *                        `<div>` and `<p>` tags).
  1415  * @param string $type    Optional. Message type, controls HTML class. Accepts 'error' or 'updated'.
  1684  * @param string $type    Optional. Message type, controls HTML class. Accepts 'error' or 'updated'.
  1416  *                        Default 'error'.
  1685  *                        Default 'error'.
  1420 
  1689 
  1421 	$wp_settings_errors[] = array(
  1690 	$wp_settings_errors[] = array(
  1422 		'setting' => $setting,
  1691 		'setting' => $setting,
  1423 		'code'    => $code,
  1692 		'code'    => $code,
  1424 		'message' => $message,
  1693 		'message' => $message,
  1425 		'type'    => $type
  1694 		'type'    => $type,
  1426 	);
  1695 	);
  1427 }
  1696 }
  1428 
  1697 
  1429 /**
  1698 /**
  1430  * Fetch settings errors registered by add_settings_error()
  1699  * Fetch settings errors registered by add_settings_error().
  1431  *
  1700  *
  1432  * Checks the $wp_settings_errors array for any errors declared during the current
  1701  * Checks the $wp_settings_errors array for any errors declared during the current
  1433  * pageload and returns them.
  1702  * pageload and returns them.
  1434  *
  1703  *
  1435  * If changes were just submitted ($_GET['settings-updated']) and settings errors were saved
  1704  * If changes were just submitted ($_GET['settings-updated']) and settings errors were saved
  1443  *
  1712  *
  1444  * @since 3.0.0
  1713  * @since 3.0.0
  1445  *
  1714  *
  1446  * @global array $wp_settings_errors Storage array of errors registered during this pageload
  1715  * @global array $wp_settings_errors Storage array of errors registered during this pageload
  1447  *
  1716  *
  1448  * @param string $setting Optional slug title of a specific setting who's errors you want.
  1717  * @param string $setting Optional slug title of a specific setting whose errors you want.
  1449  * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
  1718  * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
  1450  * @return array Array of settings errors
  1719  * @return array Array of settings errors.
  1451  */
  1720  */
  1452 function get_settings_errors( $setting = '', $sanitize = false ) {
  1721 function get_settings_errors( $setting = '', $sanitize = false ) {
  1453 	global $wp_settings_errors;
  1722 	global $wp_settings_errors;
  1454 
  1723 
  1455 	/*
  1724 	/*
  1456 	 * If $sanitize is true, manually re-run the sanitization for this option
  1725 	 * If $sanitize is true, manually re-run the sanitization for this option
  1457 	 * This allows the $sanitize_callback from register_setting() to run, adding
  1726 	 * This allows the $sanitize_callback from register_setting() to run, adding
  1458 	 * any settings errors you want to show by default.
  1727 	 * any settings errors you want to show by default.
  1459 	 */
  1728 	 */
  1460 	if ( $sanitize )
  1729 	if ( $sanitize ) {
  1461 		sanitize_option( $setting, get_option( $setting ) );
  1730 		sanitize_option( $setting, get_option( $setting ) );
       
  1731 	}
  1462 
  1732 
  1463 	// If settings were passed back from options.php then use them.
  1733 	// If settings were passed back from options.php then use them.
  1464 	if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
  1734 	if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
  1465 		$wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) );
  1735 		$wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) );
  1466 		delete_transient( 'settings_errors' );
  1736 		delete_transient( 'settings_errors' );
  1473 
  1743 
  1474 	// Filter the results to those of a specific setting if one was set.
  1744 	// Filter the results to those of a specific setting if one was set.
  1475 	if ( $setting ) {
  1745 	if ( $setting ) {
  1476 		$setting_errors = array();
  1746 		$setting_errors = array();
  1477 		foreach ( (array) $wp_settings_errors as $key => $details ) {
  1747 		foreach ( (array) $wp_settings_errors as $key => $details ) {
  1478 			if ( $setting == $details['setting'] )
  1748 			if ( $setting == $details['setting'] ) {
  1479 				$setting_errors[] = $wp_settings_errors[$key];
  1749 				$setting_errors[] = $wp_settings_errors[ $key ];
       
  1750 			}
  1480 		}
  1751 		}
  1481 		return $setting_errors;
  1752 		return $setting_errors;
  1482 	}
  1753 	}
  1483 
  1754 
  1484 	return $wp_settings_errors;
  1755 	return $wp_settings_errors;
  1504  * reporting after submission. This is useful to show general errors like
  1775  * reporting after submission. This is useful to show general errors like
  1505  * missing settings when the user arrives at the settings page.
  1776  * missing settings when the user arrives at the settings page.
  1506  *
  1777  *
  1507  * @since 3.0.0
  1778  * @since 3.0.0
  1508  *
  1779  *
  1509  * @param string $setting        Optional slug title of a specific setting who's errors you want.
  1780  * @param string $setting        Optional slug title of a specific setting whose errors you want.
  1510  * @param bool   $sanitize       Whether to re-sanitize the setting value before returning errors.
  1781  * @param bool   $sanitize       Whether to re-sanitize the setting value before returning errors.
  1511  * @param bool   $hide_on_update If set to true errors will not be shown if the settings page has
  1782  * @param bool   $hide_on_update If set to true errors will not be shown if the settings page has
  1512  *                               already been submitted.
  1783  *                               already been submitted.
  1513  */
  1784  */
  1514 function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
  1785 function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
  1515 
  1786 
  1516 	if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) )
  1787 	if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) ) {
  1517 		return;
  1788 		return;
       
  1789 	}
  1518 
  1790 
  1519 	$settings_errors = get_settings_errors( $setting, $sanitize );
  1791 	$settings_errors = get_settings_errors( $setting, $sanitize );
  1520 
  1792 
  1521 	if ( empty( $settings_errors ) )
  1793 	if ( empty( $settings_errors ) ) {
  1522 		return;
  1794 		return;
       
  1795 	}
  1523 
  1796 
  1524 	$output = '';
  1797 	$output = '';
  1525 	foreach ( $settings_errors as $key => $details ) {
  1798 	foreach ( $settings_errors as $key => $details ) {
  1526 		$css_id = 'setting-error-' . $details['code'];
  1799 		$css_id    = 'setting-error-' . $details['code'];
  1527 		$css_class = $details['type'] . ' settings-error notice is-dismissible';
  1800 		$css_class = $details['type'] . ' settings-error notice is-dismissible';
  1528 		$output .= "<div id='$css_id' class='$css_class'> \n";
  1801 		$output   .= "<div id='$css_id' class='$css_class'> \n";
  1529 		$output .= "<p><strong>{$details['message']}</strong></p>";
  1802 		$output   .= "<p><strong>{$details['message']}</strong></p>";
  1530 		$output .= "</div> \n";
  1803 		$output   .= "</div> \n";
  1531 	}
  1804 	}
  1532 	echo $output;
  1805 	echo $output;
  1533 }
  1806 }
  1534 
  1807 
  1535 /**
  1808 /**
  1537  *
  1810  *
  1538  * @since 2.7.0
  1811  * @since 2.7.0
  1539  *
  1812  *
  1540  * @param string $found_action
  1813  * @param string $found_action
  1541  */
  1814  */
  1542 function find_posts_div($found_action = '') {
  1815 function find_posts_div( $found_action = '' ) {
  1543 ?>
  1816 	?>
  1544 	<div id="find-posts" class="find-box" style="display: none;">
  1817 	<div id="find-posts" class="find-box" style="display: none;">
  1545 		<div id="find-posts-head" class="find-box-head">
  1818 		<div id="find-posts-head" class="find-box-head">
  1546 			<?php _e( 'Attach to existing content' ); ?>
  1819 			<?php _e( 'Attach to existing content' ); ?>
  1547 			<button type="button" id="find-posts-close"><span class="screen-reader-text"><?php _e( 'Close media attachment panel' ); ?></span></button>
  1820 			<button type="button" id="find-posts-close"><span class="screen-reader-text"><?php _e( 'Close media attachment panel' ); ?></span></button>
  1548 		</div>
  1821 		</div>
  1549 		<div class="find-box-inside">
  1822 		<div class="find-box-inside">
  1550 			<div class="find-box-search">
  1823 			<div class="find-box-search">
  1551 				<?php if ( $found_action ) { ?>
  1824 				<?php if ( $found_action ) { ?>
  1552 					<input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
  1825 					<input type="hidden" name="found_action" value="<?php echo esc_attr( $found_action ); ?>" />
  1553 				<?php } ?>
  1826 				<?php } ?>
  1554 				<input type="hidden" name="affected" id="affected" value="" />
  1827 				<input type="hidden" name="affected" id="affected" value="" />
  1555 				<?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
  1828 				<?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
  1556 				<label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
  1829 				<label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
  1557 				<input type="text" id="find-posts-input" name="ps" value="" />
  1830 				<input type="text" id="find-posts-input" name="ps" value="" />
  1564 		<div class="find-box-buttons">
  1837 		<div class="find-box-buttons">
  1565 			<?php submit_button( __( 'Select' ), 'primary alignright', 'find-posts-submit', false ); ?>
  1838 			<?php submit_button( __( 'Select' ), 'primary alignright', 'find-posts-submit', false ); ?>
  1566 			<div class="clear"></div>
  1839 			<div class="clear"></div>
  1567 		</div>
  1840 		</div>
  1568 	</div>
  1841 	</div>
  1569 <?php
  1842 	<?php
  1570 }
  1843 }
  1571 
  1844 
  1572 /**
  1845 /**
  1573  * Displays the post password.
  1846  * Displays the post password.
  1574  *
  1847  *
  1576  *
  1849  *
  1577  * @since 2.7.0
  1850  * @since 2.7.0
  1578  */
  1851  */
  1579 function the_post_password() {
  1852 function the_post_password() {
  1580 	$post = get_post();
  1853 	$post = get_post();
  1581 	if ( isset( $post->post_password ) )
  1854 	if ( isset( $post->post_password ) ) {
  1582 		echo esc_attr( $post->post_password );
  1855 		echo esc_attr( $post->post_password );
       
  1856 	}
  1583 }
  1857 }
  1584 
  1858 
  1585 /**
  1859 /**
  1586  * Get the post title.
  1860  * Get the post title.
  1587  *
  1861  *
  1593  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
  1867  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
  1594  * @return string The post title if set.
  1868  * @return string The post title if set.
  1595  */
  1869  */
  1596 function _draft_or_post_title( $post = 0 ) {
  1870 function _draft_or_post_title( $post = 0 ) {
  1597 	$title = get_the_title( $post );
  1871 	$title = get_the_title( $post );
  1598 	if ( empty( $title ) )
  1872 	if ( empty( $title ) ) {
  1599 		$title = __( '(no title)' );
  1873 		$title = __( '(no title)' );
       
  1874 	}
  1600 	return esc_html( $title );
  1875 	return esc_html( $title );
  1601 }
  1876 }
  1602 
  1877 
  1603 /**
  1878 /**
  1604  * Displays the search query.
  1879  * Displays the search query.
  1607  * should only be used when the_search_query() cannot.
  1882  * should only be used when the_search_query() cannot.
  1608  *
  1883  *
  1609  * @since 2.7.0
  1884  * @since 2.7.0
  1610  */
  1885  */
  1611 function _admin_search_query() {
  1886 function _admin_search_query() {
  1612 	echo isset($_REQUEST['s']) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
  1887 	echo isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
  1613 }
  1888 }
  1614 
  1889 
  1615 /**
  1890 /**
  1616  * Generic Iframe header for use with Thickbox
  1891  * Generic Iframe header for use with Thickbox
  1617  *
  1892  *
  1625  * @param bool   $deprecated Not used.
  1900  * @param bool   $deprecated Not used.
  1626  */
  1901  */
  1627 function iframe_header( $title = '', $deprecated = false ) {
  1902 function iframe_header( $title = '', $deprecated = false ) {
  1628 	show_admin_bar( false );
  1903 	show_admin_bar( false );
  1629 	global $hook_suffix, $admin_body_class, $wp_locale;
  1904 	global $hook_suffix, $admin_body_class, $wp_locale;
  1630 	$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
  1905 	$admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
  1631 
  1906 
  1632 	$current_screen = get_current_screen();
  1907 	$current_screen = get_current_screen();
  1633 
  1908 
  1634 	@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
  1909 	@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
  1635 	_wp_admin_html_begin();
  1910 	_wp_admin_html_begin();
  1636 ?>
  1911 	?>
  1637 <title><?php bloginfo('name') ?> &rsaquo; <?php echo $title ?> &#8212; <?php _e('WordPress'); ?></title>
  1912 <title><?php bloginfo( 'name' ); ?> &rsaquo; <?php echo $title; ?> &#8212; <?php _e( 'WordPress' ); ?></title>
  1638 <?php
  1913 	<?php
  1639 wp_enqueue_style( 'colors' );
  1914 	wp_enqueue_style( 'colors' );
  1640 ?>
  1915 	?>
  1641 <script type="text/javascript">
  1916 <script type="text/javascript">
  1642 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();}}};
  1917 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();}}};
  1643 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
  1918 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
  1644 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
  1919 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
  1645 	pagenow = '<?php echo $current_screen->id; ?>',
  1920 	pagenow = '<?php echo $current_screen->id; ?>',
  1647 	adminpage = '<?php echo $admin_body_class; ?>',
  1922 	adminpage = '<?php echo $admin_body_class; ?>',
  1648 	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
  1923 	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
  1649 	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
  1924 	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
  1650 	isRtl = <?php echo (int) is_rtl(); ?>;
  1925 	isRtl = <?php echo (int) is_rtl(); ?>;
  1651 </script>
  1926 </script>
  1652 <?php
  1927 	<?php
  1653 /** This action is documented in wp-admin/admin-header.php */
  1928 	/** This action is documented in wp-admin/admin-header.php */
  1654 do_action( 'admin_enqueue_scripts', $hook_suffix );
  1929 	do_action( 'admin_enqueue_scripts', $hook_suffix );
  1655 
  1930 
  1656 /** This action is documented in wp-admin/admin-header.php */
  1931 	/** This action is documented in wp-admin/admin-header.php */
  1657 do_action( "admin_print_styles-$hook_suffix" );
  1932 	do_action( "admin_print_styles-$hook_suffix" );
  1658 
  1933 
  1659 /** This action is documented in wp-admin/admin-header.php */
  1934 	/** This action is documented in wp-admin/admin-header.php */
  1660 do_action( 'admin_print_styles' );
  1935 	do_action( 'admin_print_styles' );
  1661 
  1936 
  1662 /** This action is documented in wp-admin/admin-header.php */
  1937 	/** This action is documented in wp-admin/admin-header.php */
  1663 do_action( "admin_print_scripts-$hook_suffix" );
  1938 	do_action( "admin_print_scripts-$hook_suffix" );
  1664 
  1939 
  1665 /** This action is documented in wp-admin/admin-header.php */
  1940 	/** This action is documented in wp-admin/admin-header.php */
  1666 do_action( 'admin_print_scripts' );
  1941 	do_action( 'admin_print_scripts' );
  1667 
  1942 
  1668 /** This action is documented in wp-admin/admin-header.php */
  1943 	/** This action is documented in wp-admin/admin-header.php */
  1669 do_action( "admin_head-$hook_suffix" );
  1944 	do_action( "admin_head-$hook_suffix" );
  1670 
  1945 
  1671 /** This action is documented in wp-admin/admin-header.php */
  1946 	/** This action is documented in wp-admin/admin-header.php */
  1672 do_action( 'admin_head' );
  1947 	do_action( 'admin_head' );
  1673 
  1948 
  1674 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
  1949 	$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
  1675 
  1950 
  1676 if ( is_rtl() )
  1951 	if ( is_rtl() ) {
  1677 	$admin_body_class .= ' rtl';
  1952 		$admin_body_class .= ' rtl';
  1678 
  1953 	}
  1679 ?>
  1954 
       
  1955 	?>
  1680 </head>
  1956 </head>
  1681 <?php
  1957 	<?php
  1682 /** This filter is documented in wp-admin/admin-header.php */
  1958 	/** This filter is documented in wp-admin/admin-header.php */
  1683 $admin_body_classes = apply_filters( 'admin_body_class', '' );
  1959 	$admin_body_classes = apply_filters( 'admin_body_class', '' );
  1684 ?>
  1960 	$admin_body_classes = ltrim( $admin_body_classes . ' ' . $admin_body_class );
  1685 <body<?php
  1961 	?>
  1686 /**
  1962 <body
  1687  * @global string $body_id
  1963 	<?php
  1688  */
  1964 	/**
  1689 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; ?>">
  1965 	 * @global string $body_id
       
  1966 	 */
       
  1967 	if ( isset( $GLOBALS['body_id'] ) ) {
       
  1968 		echo ' id="' . $GLOBALS['body_id'] . '"';
       
  1969 	}
       
  1970 	?>
       
  1971  class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes; ?>">
  1690 <script type="text/javascript">
  1972 <script type="text/javascript">
  1691 (function(){
  1973 (function(){
  1692 var c = document.body.className;
  1974 var c = document.body.className;
  1693 c = c.replace(/no-js/, 'js');
  1975 c = c.replace(/no-js/, 'js');
  1694 document.body.className = c;
  1976 document.body.className = c;
  1695 })();
  1977 })();
  1696 </script>
  1978 </script>
  1697 <?php
  1979 	<?php
  1698 }
  1980 }
  1699 
  1981 
  1700 /**
  1982 /**
  1701  * Generic Iframe footer for use with Thickbox
  1983  * Generic Iframe footer for use with Thickbox
  1702  *
  1984  *
  1713 	 * @global string $hook_suffix
  1995 	 * @global string $hook_suffix
  1714 	 */
  1996 	 */
  1715 	global $hook_suffix;
  1997 	global $hook_suffix;
  1716 	?>
  1998 	?>
  1717 	<div class="hidden">
  1999 	<div class="hidden">
  1718 <?php
  2000 	<?php
  1719 	/** This action is documented in wp-admin/admin-footer.php */
  2001 	/** This action is documented in wp-admin/admin-footer.php */
  1720 	do_action( 'admin_footer', $hook_suffix );
  2002 	do_action( 'admin_footer', $hook_suffix );
  1721 
  2003 
  1722 	/** This action is documented in wp-admin/admin-footer.php */
  2004 	/** This action is documented in wp-admin/admin-footer.php */
  1723 	do_action( "admin_print_footer_scripts-$hook_suffix" );
  2005 	do_action( "admin_print_footer_scripts-$hook_suffix" );
  1724 
  2006 
  1725 	/** This action is documented in wp-admin/admin-footer.php */
  2007 	/** This action is documented in wp-admin/admin-footer.php */
  1726 	do_action( 'admin_print_footer_scripts' );
  2008 	do_action( 'admin_print_footer_scripts' );
  1727 ?>
  2009 	?>
  1728 	</div>
  2010 	</div>
  1729 <script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
  2011 <script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
  1730 </body>
  2012 </body>
  1731 </html>
  2013 </html>
  1732 <?php
  2014 	<?php
  1733 }
  2015 }
  1734 
  2016 
  1735 /**
  2017 /**
  1736  *
       
  1737  * @param WP_Post $post
  2018  * @param WP_Post $post
  1738  */
  2019  */
  1739 function _post_states($post) {
  2020 function _post_states( $post ) {
  1740 	$post_states = array();
  2021 	$post_states = array();
  1741 	if ( isset( $_REQUEST['post_status'] ) )
  2022 	if ( isset( $_REQUEST['post_status'] ) ) {
  1742 		$post_status = $_REQUEST['post_status'];
  2023 		$post_status = $_REQUEST['post_status'];
  1743 	else
  2024 	} else {
  1744 		$post_status = '';
  2025 		$post_status = '';
  1745 
  2026 	}
  1746 	if ( !empty($post->post_password) )
  2027 
  1747 		$post_states['protected'] = __('Password protected');
  2028 	if ( ! empty( $post->post_password ) ) {
  1748 	if ( 'private' == $post->post_status && 'private' != $post_status )
  2029 		$post_states['protected'] = __( 'Password protected' );
  1749 		$post_states['private'] = __('Private');
  2030 	}
       
  2031 	if ( 'private' == $post->post_status && 'private' != $post_status ) {
       
  2032 		$post_states['private'] = __( 'Private' );
       
  2033 	}
  1750 	if ( 'draft' === $post->post_status ) {
  2034 	if ( 'draft' === $post->post_status ) {
  1751 		if ( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
  2035 		if ( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
  1752 			$post_states[] = __( 'Customization Draft' );
  2036 			$post_states[] = __( 'Customization Draft' );
  1753 		} elseif ( 'draft' !== $post_status ) {
  2037 		} elseif ( 'draft' !== $post_status ) {
  1754 			$post_states['draft'] = __( 'Draft' );
  2038 			$post_states['draft'] = __( 'Draft' );
  1755 		}
  2039 		}
  1756 	} elseif ( 'trash' === $post->post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
  2040 	} elseif ( 'trash' === $post->post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
  1757 		$post_states[] = __( 'Customization Draft' );
  2041 		$post_states[] = __( 'Customization Draft' );
  1758 	}
  2042 	}
  1759 	if ( 'pending' == $post->post_status && 'pending' != $post_status )
  2043 	if ( 'pending' == $post->post_status && 'pending' != $post_status ) {
  1760 		$post_states['pending'] = _x('Pending', 'post status');
  2044 		$post_states['pending'] = _x( 'Pending', 'post status' );
  1761 	if ( is_sticky($post->ID) )
  2045 	}
  1762 		$post_states['sticky'] = __('Sticky');
  2046 	if ( is_sticky( $post->ID ) ) {
       
  2047 		$post_states['sticky'] = __( 'Sticky' );
       
  2048 	}
  1763 
  2049 
  1764 	if ( 'future' === $post->post_status ) {
  2050 	if ( 'future' === $post->post_status ) {
  1765 		$post_states['scheduled'] = __( 'Scheduled' );
  2051 		$post_states['scheduled'] = __( 'Scheduled' );
  1766 	}
  2052 	}
  1767 
  2053 
  1783 	 * Filters the default post display states used in the posts list table.
  2069 	 * Filters the default post display states used in the posts list table.
  1784 	 *
  2070 	 *
  1785 	 * @since 2.8.0
  2071 	 * @since 2.8.0
  1786 	 * @since 3.6.0 Added the `$post` parameter.
  2072 	 * @since 3.6.0 Added the `$post` parameter.
  1787 	 *
  2073 	 *
  1788 	 * @param array   $post_states An array of post display states.
  2074 	 * @param string[] $post_states An array of post display states.
  1789 	 * @param WP_Post $post        The current post object.
  2075 	 * @param WP_Post  $post        The current post object.
  1790 	 */
  2076 	 */
  1791 	$post_states = apply_filters( 'display_post_states', $post_states, $post );
  2077 	$post_states = apply_filters( 'display_post_states', $post_states, $post );
  1792 
  2078 
  1793 	if ( ! empty($post_states) ) {
  2079 	if ( ! empty( $post_states ) ) {
  1794 		$state_count = count($post_states);
  2080 		$state_count = count( $post_states );
  1795 		$i = 0;
  2081 		$i           = 0;
  1796 		echo ' &mdash; ';
  2082 		echo ' &mdash; ';
  1797 		foreach ( $post_states as $state ) {
  2083 		foreach ( $post_states as $state ) {
  1798 			++$i;
  2084 			++$i;
  1799 			( $i == $state_count ) ? $sep = '' : $sep = ', ';
  2085 			( $i == $state_count ) ? $sep = '' : $sep = ', ';
  1800 			echo "<span class='post-state'>$state$sep</span>";
  2086 			echo "<span class='post-state'>$state$sep</span>";
  1802 	}
  2088 	}
  1803 
  2089 
  1804 }
  2090 }
  1805 
  2091 
  1806 /**
  2092 /**
  1807  *
       
  1808  * @param WP_Post $post
  2093  * @param WP_Post $post
  1809  */
  2094  */
  1810 function _media_states( $post ) {
  2095 function _media_states( $post ) {
  1811 	$media_states = array();
  2096 	$media_states = array();
  1812 	$stylesheet = get_option('stylesheet');
  2097 	$stylesheet   = get_option( 'stylesheet' );
  1813 
  2098 
  1814 	if ( current_theme_supports( 'custom-header') ) {
  2099 	if ( current_theme_supports( 'custom-header' ) ) {
  1815 		$meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true );
  2100 		$meta_header = get_post_meta( $post->ID, '_wp_attachment_is_custom_header', true );
  1816 
  2101 
  1817 		if ( is_random_header_image() ) {
  2102 		if ( is_random_header_image() ) {
  1818 			$header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' );
  2103 			$header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' );
  1819 
  2104 
  1820 			if ( $meta_header == $stylesheet && in_array( $post->ID, $header_images ) ) {
  2105 			if ( $meta_header == $stylesheet && in_array( $post->ID, $header_images ) ) {
  1833 				$media_states[] = __( 'Current Header Image' );
  2118 				$media_states[] = __( 'Current Header Image' );
  1834 			}
  2119 			}
  1835 		}
  2120 		}
  1836 	}
  2121 	}
  1837 
  2122 
  1838 	if ( current_theme_supports( 'custom-background') ) {
  2123 	if ( current_theme_supports( 'custom-background' ) ) {
  1839 		$meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true );
  2124 		$meta_background = get_post_meta( $post->ID, '_wp_attachment_is_custom_background', true );
  1840 
  2125 
  1841 		if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) {
  2126 		if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) {
  1842 			$media_states[] = __( 'Background Image' );
  2127 			$media_states[] = __( 'Background Image' );
  1843 
  2128 
  1844 			$background_image = get_background_image();
  2129 			$background_image = get_background_image();
  1860 	 * Filters the default media display states for items in the Media list table.
  2145 	 * Filters the default media display states for items in the Media list table.
  1861 	 *
  2146 	 *
  1862 	 * @since 3.2.0
  2147 	 * @since 3.2.0
  1863 	 * @since 4.8.0 Added the `$post` parameter.
  2148 	 * @since 4.8.0 Added the `$post` parameter.
  1864 	 *
  2149 	 *
  1865 	 * @param array   $media_states An array of media states. Default 'Header Image',
  2150 	 * @param string[] $media_states An array of media states. Default 'Header Image',
  1866 	 *                              'Background Image', 'Site Icon', 'Logo'.
  2151 	 *                               'Background Image', 'Site Icon', 'Logo'.
  1867 	 * @param WP_Post $post         The current attachment object.
  2152 	 * @param WP_Post  $post         The current attachment object.
  1868 	 */
  2153 	 */
  1869 	$media_states = apply_filters( 'display_media_states', $media_states, $post );
  2154 	$media_states = apply_filters( 'display_media_states', $media_states, $post );
  1870 
  2155 
  1871 	if ( ! empty( $media_states ) ) {
  2156 	if ( ! empty( $media_states ) ) {
  1872 		$state_count = count( $media_states );
  2157 		$state_count = count( $media_states );
  1873 		$i = 0;
  2158 		$i           = 0;
  1874 		echo ' &mdash; ';
  2159 		echo ' &mdash; ';
  1875 		foreach ( $media_states as $state ) {
  2160 		foreach ( $media_states as $state ) {
  1876 			++$i;
  2161 			++$i;
  1877 			( $i == $state_count ) ? $sep = '' : $sep = ', ';
  2162 			( $i == $state_count ) ? $sep = '' : $sep = ', ';
  1878 			echo "<span class='post-state'>$state$sep</span>";
  2163 			echo "<span class='post-state'>$state$sep</span>";
  1889  * has to be deleted.
  2174  * has to be deleted.
  1890  *
  2175  *
  1891  * @since 2.8.0
  2176  * @since 2.8.0
  1892  */
  2177  */
  1893 function compression_test() {
  2178 function compression_test() {
  1894 ?>
  2179 	?>
  1895 	<script type="text/javascript">
  2180 	<script type="text/javascript">
  1896 	var compressionNonce = <?php echo wp_json_encode( wp_create_nonce( 'update_can_compress_scripts' ) ); ?>;
  2181 	var compressionNonce = <?php echo wp_json_encode( wp_create_nonce( 'update_can_compress_scripts' ) ); ?>;
  1897 	var testCompression = {
  2182 	var testCompression = {
  1898 		get : function(test) {
  2183 		get : function(test) {
  1899 			var x;
  2184 			var x;
  1939 			}
  2224 			}
  1940 		}
  2225 		}
  1941 	};
  2226 	};
  1942 	testCompression.check();
  2227 	testCompression.check();
  1943 	</script>
  2228 	</script>
  1944 <?php
  2229 	<?php
  1945 }
  2230 }
  1946 
  2231 
  1947 /**
  2232 /**
  1948  * Echoes a submit button, with provided text and appropriate class(es).
  2233  * Echoes a submit button, with provided text and appropriate class(es).
  1949  *
  2234  *
  1956  *                                       include 'primary', 'small', and 'large'. Default 'primary'.
  2241  *                                       include 'primary', 'small', and 'large'. Default 'primary'.
  1957  * @param string       $name             The HTML name of the submit button. Defaults to "submit". If no
  2242  * @param string       $name             The HTML name of the submit button. Defaults to "submit". If no
  1958  *                                       id attribute is given in $other_attributes below, $name will be
  2243  *                                       id attribute is given in $other_attributes below, $name will be
  1959  *                                       used as the button's id.
  2244  *                                       used as the button's id.
  1960  * @param bool         $wrap             True if the output button should be wrapped in a paragraph tag,
  2245  * @param bool         $wrap             True if the output button should be wrapped in a paragraph tag,
  1961  *                                       false otherwise. Defaults to true
  2246  *                                       false otherwise. Defaults to true.
  1962  * @param array|string $other_attributes Other attributes that should be output with the button, mapping
  2247  * @param array|string $other_attributes Other attributes that should be output with the button, mapping
  1963  *                                       attributes to their values, such as setting tabindex to 1, etc.
  2248  *                                       attributes to their values, such as setting tabindex to 1, etc.
  1964  *                                       These key/value attribute pairs will be output as attribute="value",
  2249  *                                       These key/value attribute pairs will be output as attribute="value",
  1965  *                                       where attribute is the key. Other attributes can also be provided
  2250  *                                       where attribute is the key. Other attributes can also be provided
  1966  *                                       as a string such as 'tabindex="1"', though the array format is
  2251  *                                       as a string such as 'tabindex="1"', though the array format is
  1990  *                                       as `tabindex="1"`, though the array format is typically cleaner.
  2275  *                                       as `tabindex="1"`, though the array format is typically cleaner.
  1991  *                                       Default empty.
  2276  *                                       Default empty.
  1992  * @return string Submit button HTML.
  2277  * @return string Submit button HTML.
  1993  */
  2278  */
  1994 function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) {
  2279 function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) {
  1995 	if ( ! is_array( $type ) )
  2280 	if ( ! is_array( $type ) ) {
  1996 		$type = explode( ' ', $type );
  2281 		$type = explode( ' ', $type );
       
  2282 	}
  1997 
  2283 
  1998 	$button_shorthand = array( 'primary', 'small', 'large' );
  2284 	$button_shorthand = array( 'primary', 'small', 'large' );
  1999 	$classes = array( 'button' );
  2285 	$classes          = array( 'button' );
  2000 	foreach ( $type as $t ) {
  2286 	foreach ( $type as $t ) {
  2001 		if ( 'secondary' === $t || 'button-secondary' === $t )
  2287 		if ( 'secondary' === $t || 'button-secondary' === $t ) {
  2002 			continue;
  2288 			continue;
       
  2289 		}
  2003 		$classes[] = in_array( $t, $button_shorthand ) ? 'button-' . $t : $t;
  2290 		$classes[] = in_array( $t, $button_shorthand ) ? 'button-' . $t : $t;
  2004 	}
  2291 	}
  2005 	// Remove empty items, remove duplicate items, and finally build a string.
  2292 	// Remove empty items, remove duplicate items, and finally build a string.
  2006 	$class = implode( ' ', array_unique( array_filter( $classes ) ) );
  2293 	$class = implode( ' ', array_unique( array_filter( $classes ) ) );
  2007 
  2294 
  2023 		$attributes = $other_attributes;
  2310 		$attributes = $other_attributes;
  2024 	}
  2311 	}
  2025 
  2312 
  2026 	// Don't output empty name and id attributes.
  2313 	// Don't output empty name and id attributes.
  2027 	$name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : '';
  2314 	$name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : '';
  2028 	$id_attr = $id ? ' id="' . esc_attr( $id ) . '"' : '';
  2315 	$id_attr   = $id ? ' id="' . esc_attr( $id ) . '"' : '';
  2029 
  2316 
  2030 	$button = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class );
  2317 	$button  = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class );
  2031 	$button	.= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
  2318 	$button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
  2032 
  2319 
  2033 	if ( $wrap ) {
  2320 	if ( $wrap ) {
  2034 		$button = '<p class="submit">' . $button . '</p>';
  2321 		$button = '<p class="submit">' . $button . '</p>';
  2035 	}
  2322 	}
  2036 
  2323 
  2037 	return $button;
  2324 	return $button;
  2038 }
  2325 }
  2039 
  2326 
  2040 /**
  2327 /**
  2041  *
       
  2042  * @global bool $is_IE
  2328  * @global bool $is_IE
  2043  */
  2329  */
  2044 function _wp_admin_html_begin() {
  2330 function _wp_admin_html_begin() {
  2045 	global $is_IE;
  2331 	global $is_IE;
  2046 
  2332 
  2047 	$admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
  2333 	$admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
  2048 
  2334 
  2049 	if ( $is_IE )
  2335 	if ( $is_IE ) {
  2050 		@header('X-UA-Compatible: IE=edge');
  2336 		@header( 'X-UA-Compatible: IE=edge' );
  2051 
  2337 	}
  2052 ?>
  2338 
       
  2339 	?>
  2053 <!DOCTYPE html>
  2340 <!DOCTYPE html>
  2054 <!--[if IE 8]>
  2341 <!--[if IE 8]>
  2055 <html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" <?php
  2342 <html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>"
       
  2343 	<?php
  2056 	/**
  2344 	/**
  2057 	 * Fires inside the HTML tag in the admin header.
  2345 	 * Fires inside the HTML tag in the admin header.
  2058 	 *
  2346 	 *
  2059 	 * @since 2.2.0
  2347 	 * @since 2.2.0
  2060 	 */
  2348 	 */
  2061 	do_action( 'admin_xml_ns' );
  2349 	do_action( 'admin_xml_ns' );
  2062 ?> <?php language_attributes(); ?>>
  2350 
       
  2351 	language_attributes();
       
  2352 	?>
       
  2353 	>
  2063 <![endif]-->
  2354 <![endif]-->
  2064 <!--[if !(IE 8) ]><!-->
  2355 <!--[if !(IE 8) ]><!-->
  2065 <html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php
  2356 <html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>"
       
  2357 	<?php
  2066 	/** This action is documented in wp-admin/includes/template.php */
  2358 	/** This action is documented in wp-admin/includes/template.php */
  2067 	do_action( 'admin_xml_ns' );
  2359 	do_action( 'admin_xml_ns' );
  2068 ?> <?php language_attributes(); ?>>
  2360 
       
  2361 	language_attributes();
       
  2362 	?>
       
  2363 	>
  2069 <!--<![endif]-->
  2364 <!--<![endif]-->
  2070 <head>
  2365 <head>
  2071 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
  2366 <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" />
  2072 <?php
  2367 	<?php
  2073 }
  2368 }
  2074 
  2369 
  2075 /**
  2370 /**
  2076  * Convert a screen string to a screen object
  2371  * Convert a screen string to a screen object
  2077  *
  2372  *
  2083 function convert_to_screen( $hook_name ) {
  2378 function convert_to_screen( $hook_name ) {
  2084 	if ( ! class_exists( 'WP_Screen' ) ) {
  2379 	if ( ! class_exists( 'WP_Screen' ) ) {
  2085 		_doing_it_wrong(
  2380 		_doing_it_wrong(
  2086 			'convert_to_screen(), add_meta_box()',
  2381 			'convert_to_screen(), add_meta_box()',
  2087 			sprintf(
  2382 			sprintf(
  2088 				/* translators: 1: wp-admin/includes/template.php 2: add_meta_box() 3: add_meta_boxes */
  2383 				/* translators: 1: wp-admin/includes/template.php, 2: add_meta_box(), 3: add_meta_boxes */
  2089 				__( '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.' ),
  2384 				__( '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.' ),
  2090 				'<code>wp-admin/includes/template.php</code>',
  2385 				'<code>wp-admin/includes/template.php</code>',
  2091 				'<code>add_meta_box()</code>',
  2386 				'<code>add_meta_box()</code>',
  2092 				'<code>add_meta_boxes</code>'
  2387 				'<code>add_meta_boxes</code>'
  2093 			),
  2388 			),
  2094 			'3.3.0'
  2389 			'3.3.0'
  2095 		);
  2390 		);
  2096 		return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' );
  2391 		return (object) array(
       
  2392 			'id'   => '_invalid',
       
  2393 			'base' => '_are_belong_to_us',
       
  2394 		);
  2097 	}
  2395 	}
  2098 
  2396 
  2099 	return WP_Screen::get( $hook_name );
  2397 	return WP_Screen::get( $hook_name );
  2100 }
  2398 }
  2101 
  2399 
  2108 function _local_storage_notice() {
  2406 function _local_storage_notice() {
  2109 	?>
  2407 	?>
  2110 	<div id="local-storage-notice" class="hidden notice is-dismissible">
  2408 	<div id="local-storage-notice" class="hidden notice is-dismissible">
  2111 	<p class="local-restore">
  2409 	<p class="local-restore">
  2112 		<?php _e( 'The backup of this post in your browser is different from the version below.' ); ?>
  2410 		<?php _e( 'The backup of this post in your browser is different from the version below.' ); ?>
  2113 		<button type="button" class="button restore-backup"><?php _e('Restore the backup'); ?></button>
  2411 		<button type="button" class="button restore-backup"><?php _e( 'Restore the backup' ); ?></button>
  2114 	</p>
  2412 	</p>
  2115 	<p class="help">
  2413 	<p class="help">
  2116 		<?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.' ); ?>
  2414 		<?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.' ); ?>
  2117 	</p>
  2415 	</p>
  2118 	</div>
  2416 	</div>
  2147 		'rating' => 0,
  2445 		'rating' => 0,
  2148 		'type'   => 'rating',
  2446 		'type'   => 'rating',
  2149 		'number' => 0,
  2447 		'number' => 0,
  2150 		'echo'   => true,
  2448 		'echo'   => true,
  2151 	);
  2449 	);
  2152 	$r = wp_parse_args( $args, $defaults );
  2450 	$r        = wp_parse_args( $args, $defaults );
  2153 
  2451 
  2154 	// Non-English decimal places when the $rating is coming from a string
  2452 	// Non-English decimal places when the $rating is coming from a string
  2155 	$rating = (float) str_replace( ',', '.', $r['rating'] );
  2453 	$rating = (float) str_replace( ',', '.', $r['rating'] );
  2156 
  2454 
  2157 	// Convert Percentage to star rating, 0..5 in .5 increments
  2455 	// Convert Percentage to star rating, 0..5 in .5 increments
  2158 	if ( 'percent' === $r['type'] ) {
  2456 	if ( 'percent' === $r['type'] ) {
  2159 		$rating = round( $rating / 10, 0 ) / 2;
  2457 		$rating = round( $rating / 10, 0 ) / 2;
  2160 	}
  2458 	}
  2161 
  2459 
  2162 	// Calculate the number of each type of star needed
  2460 	// Calculate the number of each type of star needed
  2163 	$full_stars = floor( $rating );
  2461 	$full_stars  = floor( $rating );
  2164 	$half_stars = ceil( $rating - $full_stars );
  2462 	$half_stars  = ceil( $rating - $full_stars );
  2165 	$empty_stars = 5 - $full_stars - $half_stars;
  2463 	$empty_stars = 5 - $full_stars - $half_stars;
  2166 
  2464 
  2167 	if ( $r['number'] ) {
  2465 	if ( $r['number'] ) {
  2168 		/* translators: 1: The rating, 2: The number of ratings */
  2466 		/* translators: 1: the rating, 2: the number of ratings */
  2169 		$format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number'] );
  2467 		$format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number'] );
  2170 		$title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $r['number'] ) );
  2468 		$title  = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $r['number'] ) );
  2171 	} else {
  2469 	} else {
  2172 		/* translators: 1: The rating */
  2470 		/* translators: %s: the rating */
  2173 		$title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
  2471 		$title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
  2174 	}
  2472 	}
  2175 
  2473 
  2176 	$output = '<div class="star-rating">';
  2474 	$output  = '<div class="star-rating">';
  2177 	$output .= '<span class="screen-reader-text">' . $title . '</span>';
  2475 	$output .= '<span class="screen-reader-text">' . $title . '</span>';
  2178 	$output .= str_repeat( '<div class="star star-full" aria-hidden="true"></div>', $full_stars );
  2476 	$output .= str_repeat( '<div class="star star-full" aria-hidden="true"></div>', $full_stars );
  2179 	$output .= str_repeat( '<div class="star star-half" aria-hidden="true"></div>', $half_stars );
  2477 	$output .= str_repeat( '<div class="star star-half" aria-hidden="true"></div>', $half_stars );
  2180 	$output .= str_repeat( '<div class="star star-empty" aria-hidden="true"></div>', $empty_stars );
  2478 	$output .= str_repeat( '<div class="star star-empty" aria-hidden="true"></div>', $empty_stars );
  2181 	$output .= '</div>';
  2479 	$output .= '</div>';