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