]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/meta-boxes.php
WordPress 3.9.1-scripts
[autoinstalls/wordpress.git] / wp-admin / includes / meta-boxes.php
index 2b0b2864fcfd1d69679508b48e6ffc7272766749..9f7f469a427bc6ee48d6ad5088f94368f1b23a8c 100644 (file)
@@ -9,7 +9,7 @@
  *
  * @param object $post
  */
-function post_submit_meta_box($post) {
+function post_submit_meta_box($post, $args = array() ) {
        global $action;
 
        $post_type = $post->post_type;
@@ -42,11 +42,18 @@ if ( 'publish' == $post->post_status ) {
        $preview_button = __( 'Preview Changes' );
 } else {
        $preview_link = set_url_scheme( get_permalink( $post->ID ) );
+       /**
+        * Filter the URI of a post preview in the post submit box.
+        *
+        * @since 2.0.5
+        *
+        * @param string $preview_link URI the user will be directed to for a post preview.
+        */
        $preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ) );
        $preview_button = __( 'Preview' );
 }
 ?>
-<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview"><?php echo $preview_button; ?></a>
+<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview-<?php echo (int) $post->ID; ?>" id="post-preview"><?php echo $preview_button; ?></a>
 <input type="hidden" name="wp-preview" id="wp-preview" value="" />
 </div>
 <?php endif; // public post type ?>
@@ -55,7 +62,7 @@ if ( 'publish' == $post->post_status ) {
 
 <div id="misc-publishing-actions">
 
-<div class="misc-pub-section"><label for="post_status"><?php _e('Status:') ?></label>
+<div class="misc-pub-section misc-pub-post-status"><label for="post_status"><?php _e('Status:') ?></label>
 <span id="post-status-display">
 <?php
 switch ( $post->post_status ) {
@@ -79,7 +86,7 @@ switch ( $post->post_status ) {
 ?>
 </span>
 <?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
-<a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js"><?php _e('Edit') ?></a>
+<a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit status' ); ?></span></a>
 
 <div id="post-status-select" class="hide-if-js">
 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ('auto-draft' == $post->post_status ) ? 'draft' : $post->post_status); ?>" />
@@ -99,13 +106,13 @@ switch ( $post->post_status ) {
 <?php endif; ?>
 </select>
  <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
- <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a>
+ <a href="#post_status" class="cancel-post-status hide-if-no-js button-cancel"><?php _e('Cancel'); ?></a>
 </div>
 
 <?php } ?>
 </div><!-- .misc-pub-section -->
 
-<div class="misc-pub-section" id="visibility">
+<div class="misc-pub-section misc-pub-visibility" id="visibility">
 <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
 
 if ( 'private' == $post->post_status ) {
@@ -125,7 +132,7 @@ if ( 'private' == $post->post_status ) {
 
 echo esc_html( $visibility_trans ); ?></span>
 <?php if ( $can_publish ) { ?>
-<a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
+<a href="#visibility" class="edit-visibility hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit visibility' ); ?></span></a>
 
 <div id="post-visibility-select" class="hide-if-js">
 <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" />
@@ -138,12 +145,12 @@ echo esc_html( $visibility_trans ); ?></span>
 <span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked( is_sticky( $post->ID ) ); ?> /> <label for="sticky" class="selectit"><?php _e( 'Stick this post to the front page' ); ?></label><br /></span>
 <?php endif; ?>
 <input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br />
-<span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>" /><br /></span>
+<span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>"  maxlength="20" /><br /></span>
 <input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />
 
 <p>
  <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
- <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
+ <a href="#visibility" class="cancel-post-visibility hide-if-no-js button-cancel"><?php _e('Cancel'); ?></a>
 </p>
 </div>
 <?php } ?>
@@ -151,7 +158,7 @@ echo esc_html( $visibility_trans ); ?></span>
 </div><!-- .misc-pub-section -->
 
 <?php
-// translators: Publish box date format, see http://php.net/date
+/* translators: Publish box date format, see http://php.net/date */
 $datef = __( 'M j, Y @ G:i' );
 if ( 0 != $post->ID ) {
        if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
@@ -171,22 +178,54 @@ if ( 0 != $post->ID ) {
        $date = date_i18n( $datef, strtotime( current_time('mysql') ) );
 }
 
+if ( ! empty( $args['args']['revisions_count'] ) ) :
+       $revisions_to_keep = wp_revisions_to_keep( $post );
+?>
+<div class="misc-pub-section misc-pub-revisions">
+<?php
+       if ( $revisions_to_keep > 0 && $revisions_to_keep <= $args['args']['revisions_count'] ) {
+               echo '<span title="' . esc_attr( sprintf( __( 'Your site is configured to keep only the last %s revisions.' ),
+                       number_format_i18n( $revisions_to_keep ) ) ) . '">';
+               printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '+</b>' );
+               echo '</span>';
+       } else {
+               printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' );
+       }
+?>
+       <a class="hide-if-no-js" href="<?php echo esc_url( get_edit_post_link( $args['args']['revision_id'] ) ); ?>"><span aria-hidden="true"><?php _ex( 'Browse', 'revisions' ); ?></span> <span class="screen-reader-text"><?php _e( 'Browse revisions' ); ?></span></a>
+</div>
+<?php endif;
+
 if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
-<div class="misc-pub-section curtime">
+<div class="misc-pub-section curtime misc-pub-curtime">
        <span id="timestamp">
        <?php printf($stamp, $date); ?></span>
-       <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><?php _e('Edit') ?></a>
+       <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit date and time' ); ?></span></a>
        <div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'), 1); ?></div>
 </div><?php // /misc-pub-section ?>
 <?php endif; ?>
 
-<?php do_action('post_submitbox_misc_actions'); ?>
+<?php
+/**
+ * Fires after the post time/date setting in the Publish meta box.
+ *
+ * @since 2.9.0
+ */
+do_action( 'post_submitbox_misc_actions' );
+?>
 </div>
 <div class="clear"></div>
 </div>
 
 <div id="major-publishing-actions">
-<?php do_action('post_submitbox_start'); ?>
+<?php
+/**
+ * Fires at the beginning of the publishing actions section of the Publish meta box.
+ *
+ * @since 2.7.0
+ */
+do_action( 'post_submitbox_start' );
+?>
 <div id="delete-action">
 <?php
 if ( current_user_can( "delete_post", $post->ID ) ) {
@@ -255,16 +294,24 @@ function attachment_submit_meta_box( $post ) {
 
 <div id="misc-publishing-actions">
        <?php
-       // translators: Publish box date format, see http://php.net/date
+       /* translators: Publish box date format, see http://php.net/date */
        $datef = __( 'M j, Y @ G:i' );
        $stamp = __('Uploaded on: <b>%1$s</b>');
        $date = date_i18n( $datef, strtotime( $post->post_date ) );
        ?>
-       <div class="misc-pub-section curtime">
+       <div class="misc-pub-section curtime misc-pub-curtime">
                <span id="timestamp"><?php printf($stamp, $date); ?></span>
        </div><!-- .misc-pub-section -->
 
-       <?php do_action('attachment_submitbox_misc_actions'); ?>
+       <?php
+       /**
+        * Fires after the 'Uploaded on' section of the Save meta box
+        * in the attachment editing screen.
+        *
+        * @since 3.5.0
+        */
+       do_action( 'attachment_submitbox_misc_actions' );
+       ?>
 </div><!-- #misc-publishing-actions -->
 <div class="clear"></div>
 </div><!-- #minor-publishing -->
@@ -315,9 +362,9 @@ function post_format_meta_box( $post, $box ) {
                        $post_formats[0][] = $post_format;
        ?>
        <div id="post-formats-select">
-               <input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0"><?php _e('Standard'); ?></label>
+               <input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string( 'standard' ); ?></label>
                <?php foreach ( $post_formats[0] as $format ) : ?>
-               <br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label>
+               <br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label>
                <?php endforeach; ?><br />
        </div>
        <?php endif; endif;
@@ -339,27 +386,27 @@ function post_tags_meta_box($post, $box) {
        extract( wp_parse_args($args, $defaults), EXTR_SKIP );
        $tax_name = esc_attr($taxonomy);
        $taxonomy = get_taxonomy($taxonomy);
-       $disabled = !current_user_can($taxonomy->cap->assign_terms) ? 'disabled="disabled"' : '';
+       $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms );
        $comma = _x( ',', 'tag delimiter' );
 ?>
 <div class="tagsdiv" id="<?php echo $tax_name; ?>">
        <div class="jaxtag">
        <div class="nojs-tags hide-if-js">
        <p><?php echo $taxonomy->labels->add_or_remove_items; ?></p>
-       <textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php echo $disabled; ?>><?php echo str_replace( ',', $comma . ' ', get_terms_to_edit( $post->ID, $tax_name ) ); // textarea_escaped by esc_attr() ?></textarea></div>
-       <?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
+       <textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php disabled( ! $user_can_assign_terms ); ?>><?php echo str_replace( ',', $comma . ' ', get_terms_to_edit( $post->ID, $tax_name ) ); // textarea_escaped by esc_attr() ?></textarea></div>
+       <?php if ( $user_can_assign_terms ) : ?>
        <div class="ajaxtag hide-if-no-js">
                <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label>
                <div class="taghint"><?php echo $taxonomy->labels->add_new_item; ?></div>
                <p><input type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
                <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" /></p>
        </div>
-       <p class="howto"><?php echo esc_attr( $taxonomy->labels->separate_items_with_commas ); ?></p>
+       <p class="howto"><?php echo $taxonomy->labels->separate_items_with_commas; ?></p>
        <?php endif; ?>
        </div>
        <div class="tagchecklist"></div>
 </div>
-<?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
+<?php if ( $user_can_assign_terms ) : ?>
 <p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->choose_from_most_used; ?></a></p>
 <?php endif; ?>
 <?php
@@ -488,7 +535,7 @@ foreach ( $metadata as $key => $value ) {
                unset( $metadata[ $key ] );
 }
 list_meta( $metadata );
-meta_form(); ?>
+meta_form( $post ); ?>
 </div>
 <p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p>
 <?php
@@ -507,7 +554,16 @@ function post_comment_status_meta_box($post) {
 <p class="meta-options">
        <label for="comment_status" class="selectit"><input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e( 'Allow comments.' ) ?></label><br />
        <label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php printf( __( 'Allow <a href="%s" target="_blank">trackbacks and pingbacks</a> on this page.' ), __( 'http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' ) ); ?></label>
-       <?php do_action('post_comment_status_meta_box-options', $post); ?>
+       <?php
+       /**
+        * Fires at the end of the Discussion meta box on the post editing screen.
+        *
+        * @since 3.1.0
+        *
+        * @param WP_Post $post WP_Post object of the current post.
+        */
+       do_action( 'post_comment_status_meta_box-options', $post );
+       ?>
 </p>
 <?php
 }
@@ -537,7 +593,7 @@ function post_comment_meta_box( $post ) {
 
        wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
        ?>
-       <p class="hide-if-no-js" id="add-new-comment"><a href="#commentstatusdiv" onclick="commentReply.addcomment(<?php echo $post->ID; ?>);return false;"><?php _e('Add comment'); ?></a></p>
+       <p class="hide-if-no-js" id="add-new-comment"><a class="button" href="#commentstatusdiv" onclick="window.commentReply && commentReply.addcomment(<?php echo $post->ID; ?>);return false;"><?php _e('Add comment'); ?></a></p>
        <?php
 
        $total = get_comments( array( 'post_id' => $post->ID, 'number' => 1, 'count' => true ) );
@@ -570,8 +626,9 @@ function post_comment_meta_box( $post ) {
  * @param object $post
  */
 function post_slug_meta_box($post) {
+/** This filter is documented in wp-admin/edit-tag-form.php */
 ?>
-<label class="screen-reader-text" for="post_name"><?php _e('Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( apply_filters('editable_slug', $post->post_name) ); ?>" />
+<label class="screen-reader-text" for="post_name"><?php _e('Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( apply_filters( 'editable_slug', $post->post_name ) ); ?>" />
 <?php
 }
 
@@ -602,8 +659,8 @@ function post_author_meta_box($post) {
  *
  * @param object $post
  */
-function post_revisions_meta_box($post) {
-       wp_list_post_revisions();
+function post_revisions_meta_box( $post ) {
+       wp_list_post_revisions( $post );
 }
 
 // -- Page related Meta Boxes
@@ -628,6 +685,16 @@ function page_attributes_meta_box($post) {
                        'echo'             => 0,
                );
 
+               /**
+                * Filter the arguments used to generate a Pages drop-down element.
+                *
+                * @since 3.3.0
+                *
+                * @see wp_dropdown_pages()
+                *
+                * @param array   $dropdown_args Array of arguments used to generate the pages drop-down.
+                * @param WP_Post $post          The current WP_Post object.
+                */
                $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post );
                $pages = wp_dropdown_pages( $dropdown_args );
                if ( ! empty($pages) ) {
@@ -638,7 +705,7 @@ function page_attributes_meta_box($post) {
 <?php
                } // end empty pages check
        } // end hierarchical check.
-       if ( 'page' == $post->post_type && 0 != count( get_page_templates() ) ) {
+       if ( 'page' == $post->post_type && 0 != count( get_page_templates( $post ) ) ) {
                $template = !empty($post->page_template) ? $post->page_template : false;
                ?>
 <p><strong><?php _e('Template') ?></strong></p>
@@ -684,7 +751,7 @@ function link_submit_meta_box($link) {
 </div>
 
 <div id="misc-publishing-actions">
-<div class="misc-pub-section">
+<div class="misc-pub-section misc-pub-private">
        <label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked($link->link_visible, 'N'); ?> /> <?php _e('Keep this link private') ?></label>
 </div>
 </div>
@@ -692,7 +759,10 @@ function link_submit_meta_box($link) {
 </div>
 
 <div id="major-publishing-actions">
-<?php do_action('post_submitbox_start'); ?>
+<?php
+/** This action is documented in wp-admin/includes/meta-boxes.php */
+do_action( 'post_submitbox_start' );
+?>
 <div id="delete-action">
 <?php
 if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links') ) { ?>
@@ -709,7 +779,14 @@ if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('m
 </div>
 <div class="clear"></div>
 </div>
-<?php do_action('submitlink_box'); ?>
+<?php
+/**
+ * Fires at the end of the Publish box in the Link editing screen.
+ *
+ * @since 2.5.0
+ */
+do_action( 'submitlink_box' );
+?>
 <div class="clear"></div>
 </div>
 <?php
@@ -823,7 +900,7 @@ function xfn_check( $class, $value = '', $deprecated = '' ) {
  */
 function link_xfn_meta_box($link) {
 ?>
-<table class="links-table" cellspacing="0">
+<table class="links-table">
        <tr>
                <th scope="row"><label for="link_rel"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('rel:') ?></label></th>
                <td><input type="text" name="link_rel" id="link_rel" value="<?php echo ( isset( $link->link_rel ) ? esc_attr($link->link_rel) : ''); ?>" /></td>
@@ -944,11 +1021,11 @@ function link_advanced_meta_box($link) {
 <table class="links-table" cellpadding="0">
        <tr>
                <th scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th>
-               <td><input type="text" name="link_image" class="code" id="link_image" value="<?php echo ( isset( $link->link_image ) ? esc_attr($link->link_image) : ''); ?>" /></td>
+               <td><input type="text" name="link_image" class="code" id="link_image" maxlength="255" value="<?php echo ( isset( $link->link_image ) ? esc_attr($link->link_image) : ''); ?>" /></td>
        </tr>
        <tr>
                <th scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th>
-               <td><input name="link_rss" class="code" type="text" id="rss_uri" value="<?php echo ( isset( $link->link_rss ) ? esc_attr($link->link_rss) : ''); ?>" /></td>
+               <td><input name="link_rss" class="code" type="text" id="rss_uri" maxlength="255" value="<?php echo ( isset( $link->link_rss ) ? esc_attr($link->link_rss) : ''); ?>" /></td>
        </tr>
        <tr>
                <th scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th>
@@ -979,4 +1056,30 @@ function link_advanced_meta_box($link) {
 function post_thumbnail_meta_box( $post ) {
        $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
        echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID );
-}
\ No newline at end of file
+}
+
+/**
+ * Display fields for ID3 data
+ *
+ * @since 3.9.0
+ *
+ * @param WP_Post $post
+ */
+function attachment_id3_data_meta_box( $post ) {
+       $meta = array();
+       if ( ! empty( $post->ID ) ) {
+               $meta = wp_get_attachment_metadata( $post->ID );
+       }
+
+       foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) : ?>
+       <p>
+               <label for="title"><?php echo $label ?></label><br />
+               <input type="text" name="id3_<?php echo esc_attr( $key ) ?>" id="id3_<?php echo esc_attr( $key ) ?>" class="large-text" value="<?php
+                       if ( ! empty( $meta[ $key ] ) ) {
+                               echo esc_attr( $meta[ $key ] );
+                       }
+               ?>" />
+       </p>
+       <?php
+       endforeach;
+}