[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * WordPress Administration Meta Boxes API. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 // 10 // Post-related Meta Boxes. 11 // 12 13 /** 14 * Displays post submit form fields. 15 * 16 * @since 2.7.0 17 * 18 * @global string $action 19 * 20 * @param WP_Post $post Current post object. 21 * @param array $args { 22 * Array of arguments for building the post submit meta box. 23 * 24 * @type string $id Meta box 'id' attribute. 25 * @type string $title Meta box title. 26 * @type callable $callback Meta box display callback. 27 * @type array $args Extra meta box arguments. 28 * } 29 */ 30 function post_submit_meta_box( $post, $args = array() ) { 31 global $action; 32 33 $post_id = (int) $post->ID; 34 $post_type = $post->post_type; 35 $post_type_object = get_post_type_object( $post_type ); 36 $can_publish = current_user_can( $post_type_object->cap->publish_posts ); 37 ?> 38 <div class="submitbox" id="submitpost"> 39 40 <div id="minor-publishing"> 41 42 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key. ?> 43 <div style="display:none;"> 44 <?php submit_button( __( 'Save' ), '', 'save' ); ?> 45 </div> 46 47 <div id="minor-publishing-actions"> 48 <div id="save-action"> 49 <?php 50 if ( ! in_array( $post->post_status, array( 'publish', 'future', 'pending' ), true ) ) { 51 $private_style = ''; 52 if ( 'private' === $post->post_status ) { 53 $private_style = 'style="display:none"'; 54 } 55 ?> 56 <input <?php echo $private_style; ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e( 'Save Draft' ); ?>" class="button" /> 57 <span class="spinner"></span> 58 <?php } elseif ( 'pending' === $post->post_status && $can_publish ) { ?> 59 <input type="submit" name="save" id="save-post" value="<?php esc_attr_e( 'Save as Pending' ); ?>" class="button" /> 60 <span class="spinner"></span> 61 <?php } ?> 62 </div> 63 64 <?php 65 if ( is_post_type_viewable( $post_type_object ) ) : 66 ?> 67 <div id="preview-action"> 68 <?php 69 $preview_link = esc_url( get_preview_post_link( $post ) ); 70 if ( 'publish' === $post->post_status ) { 71 $preview_button_text = __( 'Preview Changes' ); 72 } else { 73 $preview_button_text = __( 'Preview' ); 74 } 75 76 $preview_button = sprintf( 77 '%1$s<span class="screen-reader-text"> %2$s</span>', 78 $preview_button_text, 79 /* translators: Accessibility text. */ 80 __( '(opens in a new tab)' ) 81 ); 82 ?> 83 <a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview-<?php echo $post_id; ?>" id="post-preview"><?php echo $preview_button; ?></a> 84 <input type="hidden" name="wp-preview" id="wp-preview" value="" /> 85 </div> 86 <?php 87 endif; 88 89 /** 90 * Fires after the Save Draft (or Save as Pending) and Preview (or Preview Changes) buttons 91 * in the Publish meta box. 92 * 93 * @since 4.4.0 94 * 95 * @param WP_Post $post WP_Post object for the current post. 96 */ 97 do_action( 'post_submitbox_minor_actions', $post ); 98 ?> 99 <div class="clear"></div> 100 </div> 101 102 <div id="misc-publishing-actions"> 103 <div class="misc-pub-section misc-pub-post-status"> 104 <?php _e( 'Status:' ); ?> 105 <span id="post-status-display"> 106 <?php 107 switch ( $post->post_status ) { 108 case 'private': 109 _e( 'Privately Published' ); 110 break; 111 case 'publish': 112 _e( 'Published' ); 113 break; 114 case 'future': 115 _e( 'Scheduled' ); 116 break; 117 case 'pending': 118 _e( 'Pending Review' ); 119 break; 120 case 'draft': 121 case 'auto-draft': 122 _e( 'Draft' ); 123 break; 124 } 125 ?> 126 </span> 127 128 <?php 129 if ( 'publish' === $post->post_status || 'private' === $post->post_status || $can_publish ) { 130 $private_style = ''; 131 if ( 'private' === $post->post_status ) { 132 $private_style = 'style="display:none"'; 133 } 134 ?> 135 <a href="#post_status" <?php echo $private_style; ?> class="edit-post-status hide-if-no-js" role="button"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit status' ); ?></span></a> 136 137 <div id="post-status-select" class="hide-if-js"> 138 <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 ); ?>" /> 139 <label for="post_status" class="screen-reader-text"><?php _e( 'Set status' ); ?></label> 140 <select name="post_status" id="post_status"> 141 <?php if ( 'publish' === $post->post_status ) : ?> 142 <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e( 'Published' ); ?></option> 143 <?php elseif ( 'private' === $post->post_status ) : ?> 144 <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e( 'Privately Published' ); ?></option> 145 <?php elseif ( 'future' === $post->post_status ) : ?> 146 <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e( 'Scheduled' ); ?></option> 147 <?php endif; ?> 148 <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e( 'Pending Review' ); ?></option> 149 <?php if ( 'auto-draft' === $post->post_status ) : ?> 150 <option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e( 'Draft' ); ?></option> 151 <?php else : ?> 152 <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e( 'Draft' ); ?></option> 153 <?php endif; ?> 154 </select> 155 <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e( 'OK' ); ?></a> 156 <a href="#post_status" class="cancel-post-status hide-if-no-js button-cancel"><?php _e( 'Cancel' ); ?></a> 157 </div> 158 <?php 159 } 160 ?> 161 </div> 162 163 <div class="misc-pub-section misc-pub-visibility" id="visibility"> 164 <?php _e( 'Visibility:' ); ?> 165 <span id="post-visibility-display"> 166 <?php 167 if ( 'private' === $post->post_status ) { 168 $post->post_password = ''; 169 $visibility = 'private'; 170 $visibility_trans = __( 'Private' ); 171 } elseif ( ! empty( $post->post_password ) ) { 172 $visibility = 'password'; 173 $visibility_trans = __( 'Password protected' ); 174 } elseif ( 'post' === $post_type && is_sticky( $post_id ) ) { 175 $visibility = 'public'; 176 $visibility_trans = __( 'Public, Sticky' ); 177 } else { 178 $visibility = 'public'; 179 $visibility_trans = __( 'Public' ); 180 } 181 182 echo esc_html( $visibility_trans ); 183 ?> 184 </span> 185 186 <?php if ( $can_publish ) { ?> 187 <a href="#visibility" class="edit-visibility hide-if-no-js" role="button"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit visibility' ); ?></span></a> 188 189 <div id="post-visibility-select" class="hide-if-js"> 190 <input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr( $post->post_password ); ?>" /> 191 <?php if ( 'post' === $post_type ) : ?> 192 <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked( is_sticky( $post_id ) ); ?> /> 193 <?php endif; ?> 194 195 <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" /> 196 <input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e( 'Public' ); ?></label><br /> 197 198 <?php if ( 'post' === $post_type && current_user_can( 'edit_others_posts' ) ) : ?> 199 <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> 200 <?php endif; ?> 201 202 <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 /> 203 <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="255" /><br /></span> 204 205 <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 /> 206 207 <p> 208 <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e( 'OK' ); ?></a> 209 <a href="#visibility" class="cancel-post-visibility hide-if-no-js button-cancel"><?php _e( 'Cancel' ); ?></a> 210 </p> 211 </div> 212 <?php } ?> 213 </div> 214 215 <?php 216 /* translators: Publish box date string. 1: Date, 2: Time. See https://www.php.net/manual/datetime.format.php */ 217 $date_string = __( '%1$s at %2$s' ); 218 /* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */ 219 $date_format = _x( 'M j, Y', 'publish box date format' ); 220 /* translators: Publish box time format, see https://www.php.net/manual/datetime.format.php */ 221 $time_format = _x( 'H:i', 'publish box time format' ); 222 223 if ( 0 !== $post_id ) { 224 if ( 'future' === $post->post_status ) { // Scheduled for publishing at a future date. 225 /* translators: Post date information. %s: Date on which the post is currently scheduled to be published. */ 226 $stamp = __( 'Scheduled for: %s' ); 227 } elseif ( 'publish' === $post->post_status || 'private' === $post->post_status ) { // Already published. 228 /* translators: Post date information. %s: Date on which the post was published. */ 229 $stamp = __( 'Published on: %s' ); 230 } elseif ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { // Draft, 1 or more saves, no date specified. 231 $stamp = __( 'Publish <b>immediately</b>' ); 232 } elseif ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // Draft, 1 or more saves, future date specified. 233 /* translators: Post date information. %s: Date on which the post is to be published. */ 234 $stamp = __( 'Schedule for: %s' ); 235 } else { // Draft, 1 or more saves, date specified. 236 /* translators: Post date information. %s: Date on which the post is to be published. */ 237 $stamp = __( 'Publish on: %s' ); 238 } 239 $date = sprintf( 240 $date_string, 241 date_i18n( $date_format, strtotime( $post->post_date ) ), 242 date_i18n( $time_format, strtotime( $post->post_date ) ) 243 ); 244 } else { // Draft (no saves, and thus no date specified). 245 $stamp = __( 'Publish <b>immediately</b>' ); 246 $date = sprintf( 247 $date_string, 248 date_i18n( $date_format, strtotime( current_time( 'mysql' ) ) ), 249 date_i18n( $time_format, strtotime( current_time( 'mysql' ) ) ) 250 ); 251 } 252 253 if ( ! empty( $args['args']['revisions_count'] ) ) : 254 ?> 255 <div class="misc-pub-section misc-pub-revisions"> 256 <?php 257 /* translators: Post revisions heading. %s: The number of available revisions. */ 258 printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' ); 259 ?> 260 <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> 261 </div> 262 <?php 263 endif; 264 265 if ( $can_publish ) : // Contributors don't get to choose the date of publish. 266 ?> 267 <div class="misc-pub-section curtime misc-pub-curtime"> 268 <span id="timestamp"> 269 <?php printf( $stamp, '<b>' . $date . '</b>' ); ?> 270 </span> 271 <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" role="button"> 272 <span aria-hidden="true"><?php _e( 'Edit' ); ?></span> 273 <span class="screen-reader-text"><?php _e( 'Edit date and time' ); ?></span> 274 </a> 275 <fieldset id="timestampdiv" class="hide-if-js"> 276 <legend class="screen-reader-text"><?php _e( 'Date and time' ); ?></legend> 277 <?php touch_time( ( 'edit' === $action ), 1 ); ?> 278 </fieldset> 279 </div> 280 <?php 281 endif; 282 283 if ( 'draft' === $post->post_status && get_post_meta( $post_id, '_customize_changeset_uuid', true ) ) : 284 ?> 285 <div class="notice notice-info notice-alt inline"> 286 <p> 287 <?php 288 printf( 289 /* translators: %s: URL to the Customizer. */ 290 __( 'This draft comes from your <a href="%s">unpublished customization changes</a>. You can edit, but there is no need to publish now. It will be published automatically with those changes.' ), 291 esc_url( 292 add_query_arg( 293 'changeset_uuid', 294 rawurlencode( get_post_meta( $post_id, '_customize_changeset_uuid', true ) ), 295 admin_url( 'customize.php' ) 296 ) 297 ) 298 ); 299 ?> 300 </p> 301 </div> 302 <?php 303 endif; 304 305 /** 306 * Fires after the post time/date setting in the Publish meta box. 307 * 308 * @since 2.9.0 309 * @since 4.4.0 Added the `$post` parameter. 310 * 311 * @param WP_Post $post WP_Post object for the current post. 312 */ 313 do_action( 'post_submitbox_misc_actions', $post ); 314 ?> 315 </div> 316 <div class="clear"></div> 317 </div> 318 319 <div id="major-publishing-actions"> 320 <?php 321 /** 322 * Fires at the beginning of the publishing actions section of the Publish meta box. 323 * 324 * @since 2.7.0 325 * @since 4.9.0 Added the `$post` parameter. 326 * 327 * @param WP_Post|null $post WP_Post object for the current post on Edit Post screen, 328 * null on Edit Link screen. 329 */ 330 do_action( 'post_submitbox_start', $post ); 331 ?> 332 <div id="delete-action"> 333 <?php 334 if ( current_user_can( 'delete_post', $post_id ) ) { 335 if ( ! EMPTY_TRASH_DAYS ) { 336 $delete_text = __( 'Delete permanently' ); 337 } else { 338 $delete_text = __( 'Move to Trash' ); 339 } 340 ?> 341 <a class="submitdelete deletion" href="<?php echo get_delete_post_link( $post_id ); ?>"><?php echo $delete_text; ?></a> 342 <?php 343 } 344 ?> 345 </div> 346 347 <div id="publishing-action"> 348 <span class="spinner"></span> 349 <?php 350 if ( ! in_array( $post->post_status, array( 'publish', 'future', 'private' ), true ) || 0 === $post_id ) { 351 if ( $can_publish ) : 352 if ( ! empty( $post->post_date_gmt ) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : 353 ?> 354 <input name="original_publish" type="hidden" id="original_publish" value="<?php echo esc_attr_x( 'Schedule', 'post action/button label' ); ?>" /> 355 <?php submit_button( _x( 'Schedule', 'post action/button label' ), 'primary large', 'publish', false ); ?> 356 <?php 357 else : 358 ?> 359 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Publish' ); ?>" /> 360 <?php submit_button( __( 'Publish' ), 'primary large', 'publish', false ); ?> 361 <?php 362 endif; 363 else : 364 ?> 365 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Submit for Review' ); ?>" /> 366 <?php submit_button( __( 'Submit for Review' ), 'primary large', 'publish', false ); ?> 367 <?php 368 endif; 369 } else { 370 ?> 371 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Update' ); ?>" /> 372 <?php submit_button( __( 'Update' ), 'primary large', 'save', false, array( 'id' => 'publish' ) ); ?> 373 <?php 374 } 375 ?> 376 </div> 377 <div class="clear"></div> 378 </div> 379 380 </div> 381 <?php 382 } 383 384 /** 385 * Displays attachment submit form fields. 386 * 387 * @since 3.5.0 388 * 389 * @param WP_Post $post Current post object. 390 */ 391 function attachment_submit_meta_box( $post ) { 392 ?> 393 <div class="submitbox" id="submitpost"> 394 395 <div id="minor-publishing"> 396 397 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key. ?> 398 <div style="display:none;"> 399 <?php submit_button( __( 'Save' ), '', 'save' ); ?> 400 </div> 401 402 403 <div id="misc-publishing-actions"> 404 <div class="misc-pub-section curtime misc-pub-curtime"> 405 <span id="timestamp"> 406 <?php 407 $uploaded_on = sprintf( 408 /* translators: Publish box date string. 1: Date, 2: Time. See https://www.php.net/manual/datetime.format.php */ 409 __( '%1$s at %2$s' ), 410 /* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */ 411 date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $post->post_date ) ), 412 /* translators: Publish box time format, see https://www.php.net/manual/datetime.format.php */ 413 date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $post->post_date ) ) 414 ); 415 /* translators: Attachment information. %s: Date the attachment was uploaded. */ 416 printf( __( 'Uploaded on: %s' ), '<b>' . $uploaded_on . '</b>' ); 417 ?> 418 </span> 419 </div><!-- .misc-pub-section --> 420 421 <?php 422 /** 423 * Fires after the 'Uploaded on' section of the Save meta box 424 * in the attachment editing screen. 425 * 426 * @since 3.5.0 427 * @since 4.9.0 Added the `$post` parameter. 428 * 429 * @param WP_Post $post WP_Post object for the current attachment. 430 */ 431 do_action( 'attachment_submitbox_misc_actions', $post ); 432 ?> 433 </div><!-- #misc-publishing-actions --> 434 <div class="clear"></div> 435 </div><!-- #minor-publishing --> 436 437 <div id="major-publishing-actions"> 438 <div id="delete-action"> 439 <?php 440 if ( current_user_can( 'delete_post', $post->ID ) ) { 441 if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { 442 echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Move to Trash' ) . '</a>'; 443 } else { 444 $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; 445 echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "'>" . __( 'Delete permanently' ) . '</a>'; 446 } 447 } 448 ?> 449 </div> 450 451 <div id="publishing-action"> 452 <span class="spinner"></span> 453 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Update' ); ?>" /> 454 <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ); ?>" /> 455 </div> 456 <div class="clear"></div> 457 </div><!-- #major-publishing-actions --> 458 459 </div> 460 461 <?php 462 } 463 464 /** 465 * Displays post format form elements. 466 * 467 * @since 3.1.0 468 * 469 * @param WP_Post $post Current post object. 470 * @param array $box { 471 * Post formats meta box arguments. 472 * 473 * @type string $id Meta box 'id' attribute. 474 * @type string $title Meta box title. 475 * @type callable $callback Meta box display callback. 476 * @type array $args Extra meta box arguments. 477 * } 478 */ 479 function post_format_meta_box( $post, $box ) { 480 if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) : 481 $post_formats = get_theme_support( 'post-formats' ); 482 483 if ( is_array( $post_formats[0] ) ) : 484 $post_format = get_post_format( $post->ID ); 485 if ( ! $post_format ) { 486 $post_format = '0'; 487 } 488 // Add in the current one if it isn't there yet, in case the active theme doesn't support it. 489 if ( $post_format && ! in_array( $post_format, $post_formats[0], true ) ) { 490 $post_formats[0][] = $post_format; 491 } 492 ?> 493 <div id="post-formats-select"> 494 <fieldset> 495 <legend class="screen-reader-text"><?php _e( 'Post Formats' ); ?></legend> 496 <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> 497 <?php foreach ( $post_formats[0] as $format ) : ?> 498 <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> 499 <?php endforeach; ?> 500 </fieldset> 501 </div> 502 <?php 503 endif; 504 endif; 505 } 506 507 /** 508 * Displays post tags form fields. 509 * 510 * @since 2.6.0 511 * 512 * @todo Create taxonomy-agnostic wrapper for this. 513 * 514 * @param WP_Post $post Current post object. 515 * @param array $box { 516 * Tags meta box arguments. 517 * 518 * @type string $id Meta box 'id' attribute. 519 * @type string $title Meta box title. 520 * @type callable $callback Meta box display callback. 521 * @type array $args { 522 * Extra meta box arguments. 523 * 524 * @type string $taxonomy Taxonomy. Default 'post_tag'. 525 * } 526 * } 527 */ 528 function post_tags_meta_box( $post, $box ) { 529 $defaults = array( 'taxonomy' => 'post_tag' ); 530 if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { 531 $args = array(); 532 } else { 533 $args = $box['args']; 534 } 535 $parsed_args = wp_parse_args( $args, $defaults ); 536 $tax_name = esc_attr( $parsed_args['taxonomy'] ); 537 $taxonomy = get_taxonomy( $parsed_args['taxonomy'] ); 538 $user_can_assign_terms = current_user_can( $taxonomy->cap->assign_terms ); 539 $comma = _x( ',', 'tag delimiter' ); 540 $terms_to_edit = get_terms_to_edit( $post->ID, $tax_name ); 541 if ( ! is_string( $terms_to_edit ) ) { 542 $terms_to_edit = ''; 543 } 544 ?> 545 <div class="tagsdiv" id="<?php echo $tax_name; ?>"> 546 <div class="jaxtag"> 547 <div class="nojs-tags hide-if-js"> 548 <label for="tax-input-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_or_remove_items; ?></label> 549 <p><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 ); ?> aria-describedby="new-tag-<?php echo $tax_name; ?>-desc"><?php echo str_replace( ',', $comma . ' ', $terms_to_edit ); // textarea_escaped by esc_attr() ?></textarea></p> 550 </div> 551 <?php if ( $user_can_assign_terms ) : ?> 552 <div class="ajaxtag hide-if-no-js"> 553 <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label> 554 <input data-wp-taxonomy="<?php echo $tax_name; ?>" type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" aria-describedby="new-tag-<?php echo $tax_name; ?>-desc" value="" /> 555 <input type="button" class="button tagadd" value="<?php esc_attr_e( 'Add' ); ?>" /> 556 </div> 557 <p class="howto" id="new-tag-<?php echo $tax_name; ?>-desc"><?php echo $taxonomy->labels->separate_items_with_commas; ?></p> 558 <?php elseif ( empty( $terms_to_edit ) ) : ?> 559 <p><?php echo $taxonomy->labels->no_terms; ?></p> 560 <?php endif; ?> 561 </div> 562 <ul class="tagchecklist" role="list"></ul> 563 </div> 564 <?php if ( $user_can_assign_terms ) : ?> 565 <p class="hide-if-no-js"><button type="button" class="button-link tagcloud-link" id="link-<?php echo $tax_name; ?>" aria-expanded="false"><?php echo $taxonomy->labels->choose_from_most_used; ?></button></p> 566 <?php endif; ?> 567 <?php 568 } 569 570 /** 571 * Displays post categories form fields. 572 * 573 * @since 2.6.0 574 * 575 * @todo Create taxonomy-agnostic wrapper for this. 576 * 577 * @param WP_Post $post Current post object. 578 * @param array $box { 579 * Categories meta box arguments. 580 * 581 * @type string $id Meta box 'id' attribute. 582 * @type string $title Meta box title. 583 * @type callable $callback Meta box display callback. 584 * @type array $args { 585 * Extra meta box arguments. 586 * 587 * @type string $taxonomy Taxonomy. Default 'category'. 588 * } 589 * } 590 */ 591 function post_categories_meta_box( $post, $box ) { 592 $defaults = array( 'taxonomy' => 'category' ); 593 if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { 594 $args = array(); 595 } else { 596 $args = $box['args']; 597 } 598 $parsed_args = wp_parse_args( $args, $defaults ); 599 $tax_name = esc_attr( $parsed_args['taxonomy'] ); 600 $taxonomy = get_taxonomy( $parsed_args['taxonomy'] ); 601 ?> 602 <div id="taxonomy-<?php echo $tax_name; ?>" class="categorydiv"> 603 <ul id="<?php echo $tax_name; ?>-tabs" class="category-tabs"> 604 <li class="tabs"><a href="#<?php echo $tax_name; ?>-all"><?php echo $taxonomy->labels->all_items; ?></a></li> 605 <li class="hide-if-no-js"><a href="#<?php echo $tax_name; ?>-pop"><?php echo esc_html( $taxonomy->labels->most_used ); ?></a></li> 606 </ul> 607 608 <div id="<?php echo $tax_name; ?>-pop" class="tabs-panel" style="display: none;"> 609 <ul id="<?php echo $tax_name; ?>checklist-pop" class="categorychecklist form-no-clear" > 610 <?php $popular_ids = wp_popular_terms_checklist( $tax_name ); ?> 611 </ul> 612 </div> 613 614 <div id="<?php echo $tax_name; ?>-all" class="tabs-panel"> 615 <?php 616 $name = ( 'category' === $tax_name ) ? 'post_category' : 'tax_input[' . $tax_name . ']'; 617 // Allows for an empty term set to be sent. 0 is an invalid term ID and will be ignored by empty() checks. 618 echo "<input type='hidden' name='{$name}[]' value='0' />"; 619 ?> 620 <ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear"> 621 <?php 622 wp_terms_checklist( 623 $post->ID, 624 array( 625 'taxonomy' => $tax_name, 626 'popular_cats' => $popular_ids, 627 ) 628 ); 629 ?> 630 </ul> 631 </div> 632 <?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?> 633 <div id="<?php echo $tax_name; ?>-adder" class="wp-hidden-children"> 634 <a id="<?php echo $tax_name; ?>-add-toggle" href="#<?php echo $tax_name; ?>-add" class="hide-if-no-js taxonomy-add-new"> 635 <?php 636 /* translators: %s: Add New taxonomy label. */ 637 printf( __( '+ %s' ), $taxonomy->labels->add_new_item ); 638 ?> 639 </a> 640 <p id="<?php echo $tax_name; ?>-add" class="category-add wp-hidden-child"> 641 <label class="screen-reader-text" for="new<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label> 642 <input type="text" name="new<?php echo $tax_name; ?>" id="new<?php echo $tax_name; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" aria-required="true" /> 643 <label class="screen-reader-text" for="new<?php echo $tax_name; ?>_parent"> 644 <?php echo $taxonomy->labels->parent_item_colon; ?> 645 </label> 646 <?php 647 $parent_dropdown_args = array( 648 'taxonomy' => $tax_name, 649 'hide_empty' => 0, 650 'name' => 'new' . $tax_name . '_parent', 651 'orderby' => 'name', 652 'hierarchical' => 1, 653 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', 654 ); 655 656 /** 657 * Filters the arguments for the taxonomy parent dropdown on the Post Edit page. 658 * 659 * @since 4.4.0 660 * 661 * @param array $parent_dropdown_args { 662 * Optional. Array of arguments to generate parent dropdown. 663 * 664 * @type string $taxonomy Name of the taxonomy to retrieve. 665 * @type bool $hide_if_empty True to skip generating markup if no 666 * categories are found. Default 0. 667 * @type string $name Value for the 'name' attribute 668 * of the select element. 669 * Default "new{$tax_name}_parent". 670 * @type string $orderby Which column to use for ordering 671 * terms. Default 'name'. 672 * @type bool|int $hierarchical Whether to traverse the taxonomy 673 * hierarchy. Default 1. 674 * @type string $show_option_none Text to display for the "none" option. 675 * Default "— {$parent} —", 676 * where `$parent` is 'parent_item' 677 * taxonomy label. 678 * } 679 */ 680 $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args ); 681 682 wp_dropdown_categories( $parent_dropdown_args ); 683 ?> 684 <input type="button" id="<?php echo $tax_name; ?>-add-submit" data-wp-lists="add:<?php echo $tax_name; ?>checklist:<?php echo $tax_name; ?>-add" class="button category-add-submit" value="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>" /> 685 <?php wp_nonce_field( 'add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false ); ?> 686 <span id="<?php echo $tax_name; ?>-ajax-response"></span> 687 </p> 688 </div> 689 <?php endif; ?> 690 </div> 691 <?php 692 } 693 694 /** 695 * Displays post excerpt form fields. 696 * 697 * @since 2.6.0 698 * 699 * @param WP_Post $post Current post object. 700 */ 701 function post_excerpt_meta_box( $post ) { 702 ?> 703 <label class="screen-reader-text" for="excerpt"><?php _e( 'Excerpt' ); ?></label><textarea rows="1" cols="40" name="excerpt" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea> 704 <p> 705 <?php 706 printf( 707 /* translators: %s: Documentation URL. */ 708 __( 'Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="%s">Learn more about manual excerpts</a>.' ), 709 __( 'https://wordpress.org/support/article/excerpt/' ) 710 ); 711 ?> 712 </p> 713 <?php 714 } 715 716 /** 717 * Displays trackback links form fields. 718 * 719 * @since 2.6.0 720 * 721 * @param WP_Post $post Current post object. 722 */ 723 function post_trackback_meta_box( $post ) { 724 $form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" value="' . 725 esc_attr( str_replace( "\n", ' ', $post->to_ping ) ) . '" aria-describedby="trackback-url-desc" />'; 726 727 if ( '' !== $post->pinged ) { 728 $pings = '<p>' . __( 'Already pinged:' ) . '</p><ul>'; 729 $already_pinged = explode( "\n", trim( $post->pinged ) ); 730 foreach ( $already_pinged as $pinged_url ) { 731 $pings .= "\n\t<li>" . esc_html( $pinged_url ) . '</li>'; 732 } 733 $pings .= '</ul>'; 734 } 735 736 ?> 737 <p> 738 <label for="trackback_url"><?php _e( 'Send trackbacks to:' ); ?></label> 739 <?php echo $form_trackback; ?> 740 </p> 741 <p id="trackback-url-desc" class="howto"><?php _e( 'Separate multiple URLs with spaces' ); ?></p> 742 <p> 743 <?php 744 printf( 745 /* translators: %s: Documentation URL. */ 746 __( 'Trackbacks are a way to notify legacy blog systems that you’ve linked to them. If you link other WordPress sites, they’ll be notified automatically using <a href="%s">pingbacks</a>, no other action necessary.' ), 747 __( 'https://wordpress.org/support/article/introduction-to-blogging/#comments' ) 748 ); 749 ?> 750 </p> 751 <?php 752 if ( ! empty( $pings ) ) { 753 echo $pings; 754 } 755 } 756 757 /** 758 * Displays custom fields form fields. 759 * 760 * @since 2.6.0 761 * 762 * @param WP_Post $post Current post object. 763 */ 764 function post_custom_meta_box( $post ) { 765 ?> 766 <div id="postcustomstuff"> 767 <div id="ajax-response"></div> 768 <?php 769 $metadata = has_meta( $post->ID ); 770 foreach ( $metadata as $key => $value ) { 771 if ( is_protected_meta( $metadata[ $key ]['meta_key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ]['meta_key'] ) ) { 772 unset( $metadata[ $key ] ); 773 } 774 } 775 list_meta( $metadata ); 776 meta_form( $post ); 777 ?> 778 </div> 779 <p> 780 <?php 781 printf( 782 /* translators: %s: Documentation URL. */ 783 __( 'Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.' ), 784 __( 'https://wordpress.org/support/article/custom-fields/' ) 785 ); 786 ?> 787 </p> 788 <?php 789 } 790 791 /** 792 * Displays comments status form fields. 793 * 794 * @since 2.6.0 795 * 796 * @param WP_Post $post Current post object. 797 */ 798 function post_comment_status_meta_box( $post ) { 799 ?> 800 <input name="advanced_view" type="hidden" value="1" /> 801 <p class="meta-options"> 802 <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 /> 803 <label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked( $post->ping_status, 'open' ); ?> /> 804 <?php 805 printf( 806 /* translators: %s: Documentation URL. */ 807 __( 'Allow <a href="%s">trackbacks and pingbacks</a> on this page' ), 808 __( 'https://wordpress.org/support/article/introduction-to-blogging/#managing-comments' ) 809 ); 810 ?> 811 </label> 812 <?php 813 /** 814 * Fires at the end of the Discussion meta box on the post editing screen. 815 * 816 * @since 3.1.0 817 * 818 * @param WP_Post $post WP_Post object for the current post. 819 */ 820 do_action( 'post_comment_status_meta_box-options', $post ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 821 ?> 822 </p> 823 <?php 824 } 825 826 /** 827 * Displays comments for post table header 828 * 829 * @since 3.0.0 830 * 831 * @param array $result Table header rows. 832 * @return array 833 */ 834 function post_comment_meta_box_thead( $result ) { 835 unset( $result['cb'], $result['response'] ); 836 return $result; 837 } 838 839 /** 840 * Displays comments for post. 841 * 842 * @since 2.8.0 843 * 844 * @param WP_Post $post Current post object. 845 */ 846 function post_comment_meta_box( $post ) { 847 wp_nonce_field( 'get-comments', 'add_comment_nonce', false ); 848 ?> 849 <p class="hide-if-no-js" id="add-new-comment"><button type="button" class="button" onclick="window.commentReply && commentReply.addcomment(<?php echo $post->ID; ?>);"><?php _e( 'Add Comment' ); ?></button></p> 850 <?php 851 852 $total = get_comments( 853 array( 854 'post_id' => $post->ID, 855 'number' => 1, 856 'count' => true, 857 ) 858 ); 859 $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' ); 860 $wp_list_table->display( true ); 861 862 if ( 1 > $total ) { 863 echo '<p id="no-comments">' . __( 'No comments yet.' ) . '</p>'; 864 } else { 865 $hidden = get_hidden_meta_boxes( get_current_screen() ); 866 if ( ! in_array( 'commentsdiv', $hidden, true ) ) { 867 ?> 868 <script type="text/javascript">jQuery(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script> 869 <?php 870 } 871 872 ?> 873 <p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.load(<?php echo $total; ?>);return false;"><?php _e( 'Show comments' ); ?></a> <span class="spinner"></span></p> 874 <?php 875 } 876 877 wp_comment_trashnotice(); 878 } 879 880 /** 881 * Displays slug form fields. 882 * 883 * @since 2.6.0 884 * 885 * @param WP_Post $post Current post object. 886 */ 887 function post_slug_meta_box( $post ) { 888 /** This filter is documented in wp-admin/edit-tag-form.php */ 889 $editable_slug = apply_filters( 'editable_slug', $post->post_name, $post ); 890 ?> 891 <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( $editable_slug ); ?>" /> 892 <?php 893 } 894 895 /** 896 * Displays form field with list of authors. 897 * 898 * @since 2.6.0 899 * 900 * @global int $user_ID 901 * 902 * @param WP_Post $post Current post object. 903 */ 904 function post_author_meta_box( $post ) { 905 global $user_ID; 906 907 $post_type_object = get_post_type_object( $post->post_type ); 908 ?> 909 <label class="screen-reader-text" for="post_author_override"><?php _e( 'Author' ); ?></label> 910 <?php 911 wp_dropdown_users( 912 array( 913 'capability' => array( $post_type_object->cap->edit_posts ), 914 'name' => 'post_author_override', 915 'selected' => empty( $post->ID ) ? $user_ID : $post->post_author, 916 'include_selected' => true, 917 'show' => 'display_name_with_login', 918 ) 919 ); 920 } 921 922 /** 923 * Displays list of revisions. 924 * 925 * @since 2.6.0 926 * 927 * @param WP_Post $post Current post object. 928 */ 929 function post_revisions_meta_box( $post ) { 930 wp_list_post_revisions( $post ); 931 } 932 933 // 934 // Page-related Meta Boxes. 935 // 936 937 /** 938 * Displays page attributes form fields. 939 * 940 * @since 2.7.0 941 * 942 * @param WP_Post $post Current post object. 943 */ 944 function page_attributes_meta_box( $post ) { 945 if ( is_post_type_hierarchical( $post->post_type ) ) : 946 $dropdown_args = array( 947 'post_type' => $post->post_type, 948 'exclude_tree' => $post->ID, 949 'selected' => $post->post_parent, 950 'name' => 'parent_id', 951 'show_option_none' => __( '(no parent)' ), 952 'sort_column' => 'menu_order, post_title', 953 'echo' => 0, 954 ); 955 956 /** 957 * Filters the arguments used to generate a Pages drop-down element. 958 * 959 * @since 3.3.0 960 * 961 * @see wp_dropdown_pages() 962 * 963 * @param array $dropdown_args Array of arguments used to generate the pages drop-down. 964 * @param WP_Post $post The current post. 965 */ 966 $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post ); 967 $pages = wp_dropdown_pages( $dropdown_args ); 968 if ( ! empty( $pages ) ) : 969 ?> 970 <p class="post-attributes-label-wrapper parent-id-label-wrapper"><label class="post-attributes-label" for="parent_id"><?php _e( 'Parent' ); ?></label></p> 971 <?php echo $pages; ?> 972 <?php 973 endif; // End empty pages check. 974 endif; // End hierarchical check. 975 976 if ( count( get_page_templates( $post ) ) > 0 && get_option( 'page_for_posts' ) != $post->ID ) : 977 $template = ! empty( $post->page_template ) ? $post->page_template : false; 978 ?> 979 <p class="post-attributes-label-wrapper page-template-label-wrapper"><label class="post-attributes-label" for="page_template"><?php _e( 'Template' ); ?></label> 980 <?php 981 /** 982 * Fires immediately after the label inside the 'Template' section 983 * of the 'Page Attributes' meta box. 984 * 985 * @since 4.4.0 986 * 987 * @param string|false $template The template used for the current post. 988 * @param WP_Post $post The current post. 989 */ 990 do_action( 'page_attributes_meta_box_template', $template, $post ); 991 ?> 992 </p> 993 <select name="page_template" id="page_template"> 994 <?php 995 /** 996 * Filters the title of the default page template displayed in the drop-down. 997 * 998 * @since 4.1.0 999 * 1000 * @param string $label The display value for the default page template title. 1001 * @param string $context Where the option label is displayed. Possible values 1002 * include 'meta-box' or 'quick-edit'. 1003 */ 1004 $default_title = apply_filters( 'default_page_template_title', __( 'Default template' ), 'meta-box' ); 1005 ?> 1006 <option value="default"><?php echo esc_html( $default_title ); ?></option> 1007 <?php page_template_dropdown( $template, $post->post_type ); ?> 1008 </select> 1009 <?php endif; ?> 1010 <?php if ( post_type_supports( $post->post_type, 'page-attributes' ) ) : ?> 1011 <p class="post-attributes-label-wrapper menu-order-label-wrapper"><label class="post-attributes-label" for="menu_order"><?php _e( 'Order' ); ?></label></p> 1012 <input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr( $post->menu_order ); ?>" /> 1013 <?php 1014 /** 1015 * Fires before the help hint text in the 'Page Attributes' meta box. 1016 * 1017 * @since 4.9.0 1018 * 1019 * @param WP_Post $post The current post. 1020 */ 1021 do_action( 'page_attributes_misc_attributes', $post ); 1022 ?> 1023 <?php if ( 'page' === $post->post_type && get_current_screen()->get_help_tabs() ) : ?> 1024 <p class="post-attributes-help-text"><?php _e( 'Need help? Use the Help tab above the screen title.' ); ?></p> 1025 <?php 1026 endif; 1027 endif; 1028 } 1029 1030 // 1031 // Link-related Meta Boxes. 1032 // 1033 1034 /** 1035 * Displays link create form fields. 1036 * 1037 * @since 2.7.0 1038 * 1039 * @param object $link Current link object. 1040 */ 1041 function link_submit_meta_box( $link ) { 1042 ?> 1043 <div class="submitbox" id="submitlink"> 1044 1045 <div id="minor-publishing"> 1046 1047 <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key. ?> 1048 <div style="display:none;"> 1049 <?php submit_button( __( 'Save' ), '', 'save', false ); ?> 1050 </div> 1051 1052 <div id="minor-publishing-actions"> 1053 <div id="preview-action"> 1054 <?php if ( ! empty( $link->link_id ) ) { ?> 1055 <a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank"><?php _e( 'Visit Link' ); ?></a> 1056 <?php } ?> 1057 </div> 1058 <div class="clear"></div> 1059 </div> 1060 1061 <div id="misc-publishing-actions"> 1062 <div class="misc-pub-section misc-pub-private"> 1063 <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> 1064 </div> 1065 </div> 1066 1067 </div> 1068 1069 <div id="major-publishing-actions"> 1070 <?php 1071 /** This action is documented in wp-admin/includes/meta-boxes.php */ 1072 do_action( 'post_submitbox_start', null ); 1073 ?> 1074 <div id="delete-action"> 1075 <?php 1076 if ( ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] && current_user_can( 'manage_links' ) ) { 1077 printf( 1078 '<a class="submitdelete deletion" href="%s" onclick="return confirm( \'%s\' );">%s</a>', 1079 wp_nonce_url( "link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ), 1080 /* translators: %s: Link name. */ 1081 esc_js( sprintf( __( "You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ), 1082 __( 'Delete' ) 1083 ); 1084 } 1085 ?> 1086 </div> 1087 1088 <div id="publishing-action"> 1089 <?php if ( ! empty( $link->link_id ) ) { ?> 1090 <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update Link' ); ?>" /> 1091 <?php } else { ?> 1092 <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Add Link' ); ?>" /> 1093 <?php } ?> 1094 </div> 1095 <div class="clear"></div> 1096 </div> 1097 <?php 1098 /** 1099 * Fires at the end of the Publish box in the Link editing screen. 1100 * 1101 * @since 2.5.0 1102 */ 1103 do_action( 'submitlink_box' ); 1104 ?> 1105 <div class="clear"></div> 1106 </div> 1107 <?php 1108 } 1109 1110 /** 1111 * Displays link categories form fields. 1112 * 1113 * @since 2.6.0 1114 * 1115 * @param object $link Current link object. 1116 */ 1117 function link_categories_meta_box( $link ) { 1118 ?> 1119 <div id="taxonomy-linkcategory" class="categorydiv"> 1120 <ul id="category-tabs" class="category-tabs"> 1121 <li class="tabs"><a href="#categories-all"><?php _e( 'All categories' ); ?></a></li> 1122 <li class="hide-if-no-js"><a href="#categories-pop"><?php _ex( 'Most Used', 'categories' ); ?></a></li> 1123 </ul> 1124 1125 <div id="categories-all" class="tabs-panel"> 1126 <ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear"> 1127 <?php 1128 if ( isset( $link->link_id ) ) { 1129 wp_link_category_checklist( $link->link_id ); 1130 } else { 1131 wp_link_category_checklist(); 1132 } 1133 ?> 1134 </ul> 1135 </div> 1136 1137 <div id="categories-pop" class="tabs-panel" style="display: none;"> 1138 <ul id="categorychecklist-pop" class="categorychecklist form-no-clear"> 1139 <?php wp_popular_terms_checklist( 'link_category' ); ?> 1140 </ul> 1141 </div> 1142 1143 <div id="category-adder" class="wp-hidden-children"> 1144 <a id="category-add-toggle" href="#category-add" class="taxonomy-add-new"><?php _e( '+ Add New Category' ); ?></a> 1145 <p id="link-category-add" class="wp-hidden-child"> 1146 <label class="screen-reader-text" for="newcat"><?php _e( '+ Add New Category' ); ?></label> 1147 <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" aria-required="true" /> 1148 <input type="button" id="link-category-add-submit" data-wp-lists="add:categorychecklist:link-category-add" class="button" value="<?php esc_attr_e( 'Add' ); ?>" /> 1149 <?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?> 1150 <span id="category-ajax-response"></span> 1151 </p> 1152 </div> 1153 </div> 1154 <?php 1155 } 1156 1157 /** 1158 * Displays form fields for changing link target. 1159 * 1160 * @since 2.6.0 1161 * 1162 * @param object $link Current link object. 1163 */ 1164 function link_target_meta_box( $link ) { 1165 1166 ?> 1167 <fieldset><legend class="screen-reader-text"><span><?php _e( 'Target' ); ?></span></legend> 1168 <p><label for="link_target_blank" class="selectit"> 1169 <input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ( '_blank' === $link->link_target ) ? 'checked="checked"' : '' ); ?> /> 1170 <?php _e( '<code>_blank</code> — new window or tab.' ); ?></label></p> 1171 <p><label for="link_target_top" class="selectit"> 1172 <input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ( '_top' === $link->link_target ) ? 'checked="checked"' : '' ); ?> /> 1173 <?php _e( '<code>_top</code> — current window or tab, with no frames.' ); ?></label></p> 1174 <p><label for="link_target_none" class="selectit"> 1175 <input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ( '' === $link->link_target ) ? 'checked="checked"' : '' ); ?> /> 1176 <?php _e( '<code>_none</code> — same window or tab.' ); ?></label></p> 1177 </fieldset> 1178 <p><?php _e( 'Choose the target frame for your link.' ); ?></p> 1179 <?php 1180 } 1181 1182 /** 1183 * Displays 'checked' checkboxes attribute for XFN microformat options. 1184 * 1185 * @since 1.0.1 1186 * 1187 * @global object $link Current link object. 1188 * 1189 * @param string $xfn_relationship XFN relationship category. Possible values are: 1190 * 'friendship', 'physical', 'professional', 1191 * 'geographical', 'family', 'romantic', 'identity'. 1192 * @param string $xfn_value Optional. The XFN value to mark as checked 1193 * if it matches the current link's relationship. 1194 * Default empty string. 1195 * @param mixed $deprecated Deprecated. Not used. 1196 */ 1197 function xfn_check( $xfn_relationship, $xfn_value = '', $deprecated = '' ) { 1198 global $link; 1199 1200 if ( ! empty( $deprecated ) ) { 1201 _deprecated_argument( __FUNCTION__, '2.5.0' ); // Never implemented. 1202 } 1203 1204 $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; 1205 $link_rels = preg_split( '/\s+/', $link_rel ); 1206 1207 // Mark the specified value as checked if it matches the current link's relationship. 1208 if ( '' !== $xfn_value && in_array( $xfn_value, $link_rels, true ) ) { 1209 echo ' checked="checked"'; 1210 } 1211 1212 if ( '' === $xfn_value ) { 1213 // Mark the 'none' value as checked if the current link does not match the specified relationship. 1214 if ( 'family' === $xfn_relationship 1215 && ! array_intersect( $link_rels, array( 'child', 'parent', 'sibling', 'spouse', 'kin' ) ) 1216 ) { 1217 echo ' checked="checked"'; 1218 } 1219 1220 if ( 'friendship' === $xfn_relationship 1221 && ! array_intersect( $link_rels, array( 'friend', 'acquaintance', 'contact' ) ) 1222 ) { 1223 echo ' checked="checked"'; 1224 } 1225 1226 if ( 'geographical' === $xfn_relationship 1227 && ! array_intersect( $link_rels, array( 'co-resident', 'neighbor' ) ) 1228 ) { 1229 echo ' checked="checked"'; 1230 } 1231 1232 // Mark the 'me' value as checked if it matches the current link's relationship. 1233 if ( 'identity' === $xfn_relationship 1234 && in_array( 'me', $link_rels, true ) 1235 ) { 1236 echo ' checked="checked"'; 1237 } 1238 } 1239 } 1240 1241 /** 1242 * Displays XFN form fields. 1243 * 1244 * @since 2.6.0 1245 * 1246 * @param object $link Current link object. 1247 */ 1248 function link_xfn_meta_box( $link ) { 1249 ?> 1250 <table class="links-table"> 1251 <tr> 1252 <th scope="row"><label for="link_rel"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'rel:' ); ?></label></th> 1253 <td><input type="text" name="link_rel" id="link_rel" value="<?php echo ( isset( $link->link_rel ) ? esc_attr( $link->link_rel ) : '' ); ?>" /></td> 1254 </tr> 1255 <tr> 1256 <th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'identity' ); ?></th> 1257 <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'identity' ); ?></span></legend> 1258 <label for="me"> 1259 <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check( 'identity', 'me' ); ?> /> 1260 <?php _e( 'another web address of mine' ); ?></label> 1261 </fieldset></td> 1262 </tr> 1263 <tr> 1264 <th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'friendship' ); ?></th> 1265 <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'friendship' ); ?></span></legend> 1266 <label for="contact"> 1267 <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check( 'friendship', 'contact' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'contact' ); ?> 1268 </label> 1269 <label for="acquaintance"> 1270 <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check( 'friendship', 'acquaintance' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'acquaintance' ); ?> 1271 </label> 1272 <label for="friend"> 1273 <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check( 'friendship', 'friend' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'friend' ); ?> 1274 </label> 1275 <label for="friendship"> 1276 <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check( 'friendship' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'none' ); ?> 1277 </label> 1278 </fieldset></td> 1279 </tr> 1280 <tr> 1281 <th scope="row"> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'physical' ); ?> </th> 1282 <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'physical' ); ?></span></legend> 1283 <label for="met"> 1284 <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check( 'physical', 'met' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'met' ); ?> 1285 </label> 1286 </fieldset></td> 1287 </tr> 1288 <tr> 1289 <th scope="row"> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'professional' ); ?> </th> 1290 <td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'professional' ); ?></span></legend> 1291 <label for="co-worker"> 1292 <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check( 'professional', 'co-worker' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'co-worker' ); ?> 1293 </label> 1294 <label for="colleague"> 1295 <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check( 'professional', 'colleague' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'colleague' ); ?> 1296 </label> 1297 </fieldset></td> 1298 </tr> 1299 <tr> 1300 <th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'geographical' ); ?></th> 1301 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'geographical' ); ?> </span></legend> 1302 <label for="co-resident"> 1303 <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check( 'geographical', 'co-resident' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'co-resident' ); ?> 1304 </label> 1305 <label for="neighbor"> 1306 <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check( 'geographical', 'neighbor' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'neighbor' ); ?> 1307 </label> 1308 <label for="geographical"> 1309 <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check( 'geographical' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'none' ); ?> 1310 </label> 1311 </fieldset></td> 1312 </tr> 1313 <tr> 1314 <th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'family' ); ?></th> 1315 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'family' ); ?> </span></legend> 1316 <label for="child"> 1317 <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check( 'family', 'child' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'child' ); ?> 1318 </label> 1319 <label for="kin"> 1320 <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check( 'family', 'kin' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'kin' ); ?> 1321 </label> 1322 <label for="parent"> 1323 <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check( 'family', 'parent' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'parent' ); ?> 1324 </label> 1325 <label for="sibling"> 1326 <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check( 'family', 'sibling' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'sibling' ); ?> 1327 </label> 1328 <label for="spouse"> 1329 <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check( 'family', 'spouse' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'spouse' ); ?> 1330 </label> 1331 <label for="family"> 1332 <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check( 'family' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'none' ); ?> 1333 </label> 1334 </fieldset></td> 1335 </tr> 1336 <tr> 1337 <th scope="row"><?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'romantic' ); ?></th> 1338 <td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'romantic' ); ?> </span></legend> 1339 <label for="muse"> 1340 <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check( 'romantic', 'muse' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'muse' ); ?> 1341 </label> 1342 <label for="crush"> 1343 <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check( 'romantic', 'crush' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'crush' ); ?> 1344 </label> 1345 <label for="date"> 1346 <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check( 'romantic', 'date' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'date' ); ?> 1347 </label> 1348 <label for="romantic"> 1349 <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check( 'romantic', 'sweetheart' ); ?> /> <?php /* translators: xfn: https://gmpg.org/xfn/ */ _e( 'sweetheart' ); ?> 1350 </label> 1351 </fieldset></td> 1352 </tr> 1353 1354 </table> 1355 <p><?php _e( 'If the link is to a person, you can specify your relationship with them using the above form. If you would like to learn more about the idea check out <a href="https://gmpg.org/xfn/">XFN</a>.' ); ?></p> 1356 <?php 1357 } 1358 1359 /** 1360 * Displays advanced link options form fields. 1361 * 1362 * @since 2.6.0 1363 * 1364 * @param object $link Current link object. 1365 */ 1366 function link_advanced_meta_box( $link ) { 1367 ?> 1368 <table class="links-table" cellpadding="0"> 1369 <tr> 1370 <th scope="row"><label for="link_image"><?php _e( 'Image Address' ); ?></label></th> 1371 <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> 1372 </tr> 1373 <tr> 1374 <th scope="row"><label for="rss_uri"><?php _e( 'RSS Address' ); ?></label></th> 1375 <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> 1376 </tr> 1377 <tr> 1378 <th scope="row"><label for="link_notes"><?php _e( 'Notes' ); ?></label></th> 1379 <td><textarea name="link_notes" id="link_notes" rows="10"><?php echo ( isset( $link->link_notes ) ? $link->link_notes : '' ); // textarea_escaped ?></textarea></td> 1380 </tr> 1381 <tr> 1382 <th scope="row"><label for="link_rating"><?php _e( 'Rating' ); ?></label></th> 1383 <td><select name="link_rating" id="link_rating" size="1"> 1384 <?php 1385 for ( $rating = 0; $rating <= 10; $rating++ ) { 1386 echo '<option value="' . $rating . '"'; 1387 if ( isset( $link->link_rating ) && $link->link_rating == $rating ) { 1388 echo ' selected="selected"'; 1389 } 1390 echo '>' . $rating . '</option>'; 1391 } 1392 ?> 1393 </select> <?php _e( '(Leave at 0 for no rating.)' ); ?> 1394 </td> 1395 </tr> 1396 </table> 1397 <?php 1398 } 1399 1400 /** 1401 * Displays post thumbnail meta box. 1402 * 1403 * @since 2.9.0 1404 * 1405 * @param WP_Post $post Current post object. 1406 */ 1407 function post_thumbnail_meta_box( $post ) { 1408 $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true ); 1409 echo _wp_post_thumbnail_html( $thumbnail_id, $post->ID ); 1410 } 1411 1412 /** 1413 * Displays fields for ID3 data. 1414 * 1415 * @since 3.9.0 1416 * 1417 * @param WP_Post $post Current post object. 1418 */ 1419 function attachment_id3_data_meta_box( $post ) { 1420 $meta = array(); 1421 if ( ! empty( $post->ID ) ) { 1422 $meta = wp_get_attachment_metadata( $post->ID ); 1423 } 1424 1425 foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) : 1426 $value = ''; 1427 if ( ! empty( $meta[ $key ] ) ) { 1428 $value = $meta[ $key ]; 1429 } 1430 ?> 1431 <p> 1432 <label for="title"><?php echo $label; ?></label><br /> 1433 <input type="text" name="id3_<?php echo esc_attr( $key ); ?>" id="id3_<?php echo esc_attr( $key ); ?>" class="large-text" value="<?php echo esc_attr( $value ); ?>" /> 1434 </p> 1435 <?php 1436 endforeach; 1437 } 1438 1439 /** 1440 * Registers the default post meta boxes, and runs the `do_meta_boxes` actions. 1441 * 1442 * @since 5.0.0 1443 * 1444 * @param WP_Post $post The post object that these meta boxes are being generated for. 1445 */ 1446 function register_and_do_post_meta_boxes( $post ) { 1447 $post_type = $post->post_type; 1448 $post_type_object = get_post_type_object( $post_type ); 1449 1450 $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ); 1451 if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) { 1452 if ( wp_attachment_is( 'audio', $post ) ) { 1453 $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' ); 1454 } elseif ( wp_attachment_is( 'video', $post ) ) { 1455 $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' ); 1456 } 1457 } 1458 1459 $publish_callback_args = array( '__back_compat_meta_box' => true ); 1460 1461 if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' !== $post->post_status ) { 1462 $revisions = wp_get_post_revisions( $post->ID, array( 'fields' => 'ids' ) ); 1463 1464 // We should aim to show the revisions meta box only when there are revisions. 1465 if ( count( $revisions ) > 1 ) { 1466 $publish_callback_args = array( 1467 'revisions_count' => count( $revisions ), 1468 'revision_id' => reset( $revisions ), 1469 '__back_compat_meta_box' => true, 1470 ); 1471 1472 add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1473 } 1474 } 1475 1476 if ( 'attachment' === $post_type ) { 1477 wp_enqueue_script( 'image-edit' ); 1478 wp_enqueue_style( 'imgareaselect' ); 1479 add_meta_box( 'submitdiv', __( 'Save' ), 'attachment_submit_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); 1480 add_action( 'edit_form_after_title', 'edit_form_image_editor' ); 1481 1482 if ( wp_attachment_is( 'audio', $post ) ) { 1483 add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1484 } 1485 } else { 1486 add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args ); 1487 } 1488 1489 if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) { 1490 add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); 1491 } 1492 1493 // All taxonomies. 1494 foreach ( get_object_taxonomies( $post ) as $tax_name ) { 1495 $taxonomy = get_taxonomy( $tax_name ); 1496 if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) { 1497 continue; 1498 } 1499 1500 $label = $taxonomy->labels->name; 1501 1502 if ( ! is_taxonomy_hierarchical( $tax_name ) ) { 1503 $tax_meta_box_id = 'tagsdiv-' . $tax_name; 1504 } else { 1505 $tax_meta_box_id = $tax_name . 'div'; 1506 } 1507 1508 add_meta_box( 1509 $tax_meta_box_id, 1510 $label, 1511 $taxonomy->meta_box_cb, 1512 null, 1513 'side', 1514 'core', 1515 array( 1516 'taxonomy' => $tax_name, 1517 '__back_compat_meta_box' => true, 1518 ) 1519 ); 1520 } 1521 1522 if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( $post ) ) > 0 ) { 1523 add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); 1524 } 1525 1526 if ( $thumbnail_support && current_user_can( 'upload_files' ) ) { 1527 add_meta_box( 'postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low', array( '__back_compat_meta_box' => true ) ); 1528 } 1529 1530 if ( post_type_supports( $post_type, 'excerpt' ) ) { 1531 add_meta_box( 'postexcerpt', __( 'Excerpt' ), 'post_excerpt_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1532 } 1533 1534 if ( post_type_supports( $post_type, 'trackbacks' ) ) { 1535 add_meta_box( 'trackbacksdiv', __( 'Send Trackbacks' ), 'post_trackback_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1536 } 1537 1538 if ( post_type_supports( $post_type, 'custom-fields' ) ) { 1539 add_meta_box( 1540 'postcustom', 1541 __( 'Custom Fields' ), 1542 'post_custom_meta_box', 1543 null, 1544 'normal', 1545 'core', 1546 array( 1547 '__back_compat_meta_box' => ! (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ), 1548 '__block_editor_compatible_meta_box' => true, 1549 ) 1550 ); 1551 } 1552 1553 /** 1554 * Fires in the middle of built-in meta box registration. 1555 * 1556 * @since 2.1.0 1557 * @deprecated 3.7.0 Use {@see 'add_meta_boxes'} instead. 1558 * 1559 * @param WP_Post $post Post object. 1560 */ 1561 do_action_deprecated( 'dbx_post_advanced', array( $post ), '3.7.0', 'add_meta_boxes' ); 1562 1563 // Allow the Discussion meta box to show up if the post type supports comments, 1564 // or if comments or pings are open. 1565 if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) { 1566 add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1567 } 1568 1569 $stati = get_post_stati( array( 'public' => true ) ); 1570 if ( empty( $stati ) ) { 1571 $stati = array( 'publish' ); 1572 } 1573 $stati[] = 'private'; 1574 1575 if ( in_array( get_post_status( $post ), $stati, true ) ) { 1576 // If the post type support comments, or the post has comments, 1577 // allow the Comments meta box. 1578 if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) { 1579 add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1580 } 1581 } 1582 1583 if ( ! ( 'pending' === get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) { 1584 add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1585 } 1586 1587 if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) { 1588 add_meta_box( 'authordiv', __( 'Author' ), 'post_author_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1589 } 1590 1591 /** 1592 * Fires after all built-in meta boxes have been added. 1593 * 1594 * @since 3.0.0 1595 * 1596 * @param string $post_type Post type. 1597 * @param WP_Post $post Post object. 1598 */ 1599 do_action( 'add_meta_boxes', $post_type, $post ); 1600 1601 /** 1602 * Fires after all built-in meta boxes have been added, contextually for the given post type. 1603 * 1604 * The dynamic portion of the hook name, `$post_type`, refers to the post type of the post. 1605 * 1606 * Possible hook names include: 1607 * 1608 * - `add_meta_boxes_post` 1609 * - `add_meta_boxes_page` 1610 * - `add_meta_boxes_attachment` 1611 * 1612 * @since 3.0.0 1613 * 1614 * @param WP_Post $post Post object. 1615 */ 1616 do_action( "add_meta_boxes_{$post_type}", $post ); 1617 1618 /** 1619 * Fires after meta boxes have been added. 1620 * 1621 * Fires once for each of the default meta box contexts: normal, advanced, and side. 1622 * 1623 * @since 3.0.0 1624 * 1625 * @param string $post_type Post type of the post on Edit Post screen, 'link' on Edit Link screen, 1626 * 'dashboard' on Dashboard screen. 1627 * @param string $context Meta box context. Possible values include 'normal', 'advanced', 'side'. 1628 * @param WP_Post|object|string $post Post object on Edit Post screen, link object on Edit Link screen, 1629 * an empty string on Dashboard screen. 1630 */ 1631 do_action( 'do_meta_boxes', $post_type, 'normal', $post ); 1632 /** This action is documented in wp-admin/includes/meta-boxes.php */ 1633 do_action( 'do_meta_boxes', $post_type, 'advanced', $post ); 1634 /** This action is documented in wp-admin/includes/meta-boxes.php */ 1635 do_action( 'do_meta_boxes', $post_type, 'side', $post ); 1636 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Dec 5 01:00:03 2024 | Cross-referenced by PHPXref 0.7.1 |