Changeset 44214
- Timestamp:
- 12/16/2018 01:18:22 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/5.0 merged: 43837
- Property svn:mergeinfo changed
-
trunk/src/wp-admin/edit-form-advanced.php
r44132 r44214 244 244 require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' ); 245 245 246 247 $publish_callback_args = array( '__back_compat_meta_box' => true ); 248 if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' != $post->post_status ) { 249 $revisions = wp_get_post_revisions( $post_ID ); 250 251 // We should aim to show the revisions meta box only when there are revisions. 252 if ( count( $revisions ) > 1 ) { 253 reset( $revisions ); // Reset pointer for key() 254 $publish_callback_args = array( 255 'revisions_count' => count( $revisions ), 256 'revision_id' => key( $revisions ), 257 '__back_compat_meta_box' => true, 258 ); 259 add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 260 } 261 } 262 263 if ( 'attachment' == $post_type ) { 264 wp_enqueue_script( 'image-edit' ); 265 wp_enqueue_style( 'imgareaselect' ); 266 add_meta_box( 'submitdiv', __( 'Save' ), 'attachment_submit_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); 267 add_action( 'edit_form_after_title', 'edit_form_image_editor' ); 268 269 if ( wp_attachment_is( 'audio', $post ) ) { 270 add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 271 } 272 } else { 273 add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args ); 274 } 275 276 if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) { 277 add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); 278 } 279 280 // all taxonomies 281 foreach ( get_object_taxonomies( $post ) as $tax_name ) { 282 $taxonomy = get_taxonomy( $tax_name ); 283 if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) { 284 continue; 285 } 286 287 $label = $taxonomy->labels->name; 288 289 if ( ! is_taxonomy_hierarchical( $tax_name ) ) { 290 $tax_meta_box_id = 'tagsdiv-' . $tax_name; 291 } else { 292 $tax_meta_box_id = $tax_name . 'div'; 293 } 294 295 add_meta_box( 296 $tax_meta_box_id, 297 $label, 298 $taxonomy->meta_box_cb, 299 null, 300 'side', 301 'core', 302 array( 303 'taxonomy' => $tax_name, 304 '__back_compat_meta_box' => true, 305 ) 306 ); 307 } 308 309 if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( $post ) ) > 0 ) { 310 add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); 311 } 312 313 if ( $thumbnail_support && current_user_can( 'upload_files' ) ) { 314 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 ) ); 315 } 316 317 if ( post_type_supports( $post_type, 'excerpt' ) ) { 318 add_meta_box( 'postexcerpt', __( 'Excerpt' ), 'post_excerpt_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 319 } 320 321 if ( post_type_supports( $post_type, 'trackbacks' ) ) { 322 add_meta_box( 'trackbacksdiv', __( 'Send Trackbacks' ), 'post_trackback_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 323 } 324 325 if ( post_type_supports( $post_type, 'custom-fields' ) ) { 326 add_meta_box( 'postcustom', __( 'Custom Fields' ), 'post_custom_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 327 } 328 329 /** 330 * Fires in the middle of built-in meta box registration. 331 * 332 * @since 2.1.0 333 * @deprecated 3.7.0 Use 'add_meta_boxes' instead. 334 * 335 * @param WP_Post $post Post object. 336 */ 337 do_action( 'dbx_post_advanced', $post ); 338 339 // Allow the Discussion meta box to show up if the post type supports comments, 340 // or if comments or pings are open. 341 if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) { 342 add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 343 } 344 345 $stati = get_post_stati( array( 'public' => true ) ); 346 if ( empty( $stati ) ) { 347 $stati = array( 'publish' ); 348 } 349 $stati[] = 'private'; 350 351 if ( in_array( get_post_status( $post ), $stati ) ) { 352 // If the post type support comments, or the post has comments, allow the 353 // Comments meta box. 354 if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) { 355 add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 356 } 357 } 358 359 if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) { 360 add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 361 } 362 363 if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) { 364 add_meta_box( 'authordiv', __( 'Author' ), 'post_author_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 365 } 366 367 /** 368 * Fires after all built-in meta boxes have been added. 369 * 370 * @since 3.0.0 371 * 372 * @param string $post_type Post type for posts, 'comment' for comments, 373 * 'link' for links. 374 * @param WP_Post|WP_Comment|object $post Post, comment, or link object. 375 */ 376 do_action( 'add_meta_boxes', $post_type, $post ); 377 378 /** 379 * Fires after all built-in meta boxes have been added, contextually for the given post type. 380 * 381 * The dynamic portion of the hook, `$post_type`, refers to the post type of the post. 382 * 383 * @since 3.0.0 384 * 385 * @param WP_Post $post Post object. 386 */ 387 do_action( "add_meta_boxes_{$post_type}", $post ); 388 389 /** 390 * Fires after meta boxes have been added. 391 * 392 * Fires once for each of the default meta box contexts: normal, advanced, and side. 393 * 394 * @since 3.0.0 395 * 396 * @param string $post_type Post type for posts, 'dashboard' for dashboard widgets, 397 * 'link' for links. 398 * @param string $context Meta box context. Accepts 'normal', 'advanced', 'side'. 399 * @param WP_Post|string|object $post Post object for posts, empty string for dashboard widgets, 400 * link object for links. 401 */ 402 do_action( 'do_meta_boxes', $post_type, 'normal', $post ); 403 /** This action is documented in wp-admin/edit-form-advanced.php */ 404 do_action( 'do_meta_boxes', $post_type, 'advanced', $post ); 405 /** This action is documented in wp-admin/edit-form-advanced.php */ 406 do_action( 'do_meta_boxes', $post_type, 'side', $post ); 246 register_and_do_post_meta_boxes( $post ); 407 247 408 248 add_screen_option( -
trunk/src/wp-admin/edit-form-blocks.php
r44177 r44214 364 364 do_action( 'enqueue_block_editor_assets' ); 365 365 366 // In order to duplicate classic meta box behaviour, we need to run the classic meta box actions. 367 require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' ); 368 register_and_do_post_meta_boxes( $post ); 369 370 // Some meta boxes hook into the 'edit_form_advanced' filter. 371 /** This action is documented in wp-admin/edit-form-advanced.php */ 372 do_action( 'edit_form_advanced', $post ); 373 366 374 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 367 375 ?> -
trunk/src/wp-admin/edit-form-comment.php
r43571 r44214 196 196 <div id="postbox-container-2" class="postbox-container"> 197 197 <?php 198 /** This action is documented in wp-admin/ edit-form-advanced.php */198 /** This action is documented in wp-admin/includes/meta-boxes.php */ 199 199 do_action( 'add_meta_boxes', 'comment', $comment ); 200 200 -
trunk/src/wp-admin/edit-link-form.php
r43571 r44214 32 32 add_meta_box( 'linkadvanceddiv', __( 'Advanced' ), 'link_advanced_meta_box', null, 'normal', 'core' ); 33 33 34 /** This action is documented in wp-admin/ edit-form-advanced.php */34 /** This action is documented in wp-admin/includes/meta-boxes.php */ 35 35 do_action( 'add_meta_boxes', 'link', $link ); 36 36 … … 44 44 do_action( 'add_meta_boxes_link', $link ); 45 45 46 /** This action is documented in wp-admin/ edit-form-advanced.php */46 /** This action is documented in wp-admin/includes/meta-boxes.php */ 47 47 do_action( 'do_meta_boxes', 'link', 'normal', $link ); 48 /** This action is documented in wp-admin/ edit-form-advanced.php */48 /** This action is documented in wp-admin/includes/meta-boxes.php */ 49 49 do_action( 'do_meta_boxes', 'link', 'advanced', $link ); 50 /** This action is documented in wp-admin/ edit-form-advanced.php */50 /** This action is documented in wp-admin/includes/meta-boxes.php */ 51 51 do_action( 'do_meta_boxes', 'link', 'side', $link ); 52 52 -
trunk/src/wp-admin/includes/dashboard.php
r43571 r44214 133 133 } 134 134 135 /** This action is documented in wp-admin/ edit-form-advanced.php */135 /** This action is documented in wp-admin/includes/meta-boxes.php */ 136 136 do_action( 'do_meta_boxes', $screen->id, 'normal', '' ); 137 137 138 /** This action is documented in wp-admin/ edit-form-advanced.php */138 /** This action is documented in wp-admin/includes/meta-boxes.php */ 139 139 do_action( 'do_meta_boxes', $screen->id, 'side', '' ); 140 140 } -
trunk/src/wp-admin/includes/meta-boxes.php
r43571 r44214 1364 1364 endforeach; 1365 1365 } 1366 1367 /** 1368 * Registers the default post meta boxes, and runs the `do_meta_boxes` actions. 1369 * 1370 * @since 5.0.0 1371 * 1372 * @param WP_Post $post The post object that these meta boxes are being generated for. 1373 */ 1374 function register_and_do_post_meta_boxes( $post ) { 1375 $post_type = $post->post_type; 1376 $post_type_object = get_post_type_object( $post_type ); 1377 1378 $thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' ); 1379 if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) { 1380 if ( wp_attachment_is( 'audio', $post ) ) { 1381 $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' ); 1382 } elseif ( wp_attachment_is( 'video', $post ) ) { 1383 $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' ); 1384 } 1385 } 1386 1387 $publish_callback_args = array( '__back_compat_meta_box' => true ); 1388 if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' != $post->post_status ) { 1389 $revisions = wp_get_post_revisions( $post->ID ); 1390 1391 // We should aim to show the revisions meta box only when there are revisions. 1392 if ( count( $revisions ) > 1 ) { 1393 reset( $revisions ); // Reset pointer for key() 1394 $publish_callback_args = array( 1395 'revisions_count' => count( $revisions ), 1396 'revision_id' => key( $revisions ), 1397 '__back_compat_meta_box' => true, 1398 ); 1399 add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1400 } 1401 } 1402 1403 if ( 'attachment' == $post_type ) { 1404 wp_enqueue_script( 'image-edit' ); 1405 wp_enqueue_style( 'imgareaselect' ); 1406 add_meta_box( 'submitdiv', __( 'Save' ), 'attachment_submit_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); 1407 add_action( 'edit_form_after_title', 'edit_form_image_editor' ); 1408 1409 if ( wp_attachment_is( 'audio', $post ) ) { 1410 add_meta_box( 'attachment-id3', __( 'Metadata' ), 'attachment_id3_data_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1411 } 1412 } else { 1413 add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args ); 1414 } 1415 1416 if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) { 1417 add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); 1418 } 1419 1420 // all taxonomies 1421 foreach ( get_object_taxonomies( $post ) as $tax_name ) { 1422 $taxonomy = get_taxonomy( $tax_name ); 1423 if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) { 1424 continue; 1425 } 1426 1427 $label = $taxonomy->labels->name; 1428 1429 if ( ! is_taxonomy_hierarchical( $tax_name ) ) { 1430 $tax_meta_box_id = 'tagsdiv-' . $tax_name; 1431 } else { 1432 $tax_meta_box_id = $tax_name . 'div'; 1433 } 1434 1435 add_meta_box( 1436 $tax_meta_box_id, 1437 $label, 1438 $taxonomy->meta_box_cb, 1439 null, 1440 'side', 1441 'core', 1442 array( 1443 'taxonomy' => $tax_name, 1444 '__back_compat_meta_box' => true, 1445 ) 1446 ); 1447 } 1448 1449 if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_templates( $post ) ) > 0 ) { 1450 add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core', array( '__back_compat_meta_box' => true ) ); 1451 } 1452 1453 if ( $thumbnail_support && current_user_can( 'upload_files' ) ) { 1454 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 ) ); 1455 } 1456 1457 if ( post_type_supports( $post_type, 'excerpt' ) ) { 1458 add_meta_box( 'postexcerpt', __( 'Excerpt' ), 'post_excerpt_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1459 } 1460 1461 if ( post_type_supports( $post_type, 'trackbacks' ) ) { 1462 add_meta_box( 'trackbacksdiv', __( 'Send Trackbacks' ), 'post_trackback_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1463 } 1464 1465 if ( post_type_supports( $post_type, 'custom-fields' ) ) { 1466 add_meta_box( 'postcustom', __( 'Custom Fields' ), 'post_custom_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1467 } 1468 1469 /** 1470 * Fires in the middle of built-in meta box registration. 1471 * 1472 * @since 2.1.0 1473 * @deprecated 3.7.0 Use 'add_meta_boxes' instead. 1474 * 1475 * @param WP_Post $post Post object. 1476 */ 1477 do_action( 'dbx_post_advanced', $post ); 1478 1479 // Allow the Discussion meta box to show up if the post type supports comments, 1480 // or if comments or pings are open. 1481 if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) { 1482 add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1483 } 1484 1485 $stati = get_post_stati( array( 'public' => true ) ); 1486 if ( empty( $stati ) ) { 1487 $stati = array( 'publish' ); 1488 } 1489 $stati[] = 'private'; 1490 1491 if ( in_array( get_post_status( $post ), $stati ) ) { 1492 // If the post type support comments, or the post has comments, allow the 1493 // Comments meta box. 1494 if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) { 1495 add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1496 } 1497 } 1498 1499 if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) { 1500 add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1501 } 1502 1503 if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) { 1504 add_meta_box( 'authordiv', __( 'Author' ), 'post_author_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) ); 1505 } 1506 1507 /** 1508 * Fires after all built-in meta boxes have been added. 1509 * 1510 * @since 3.0.0 1511 * 1512 * @param string $post_type Post type. 1513 * @param WP_Post $post Post object. 1514 */ 1515 do_action( 'add_meta_boxes', $post_type, $post ); 1516 1517 /** 1518 * Fires after all built-in meta boxes have been added, contextually for the given post type. 1519 * 1520 * The dynamic portion of the hook, `$post_type`, refers to the post type of the post. 1521 * 1522 * @since 3.0.0 1523 * 1524 * @param WP_Post $post Post object. 1525 */ 1526 do_action( "add_meta_boxes_{$post_type}", $post ); 1527 1528 /** 1529 * Fires after meta boxes have been added. 1530 * 1531 * Fires once for each of the default meta box contexts: normal, advanced, and side. 1532 * 1533 * @since 3.0.0 1534 * 1535 * @param string $post_type Post type of the post. 1536 * @param string $context string Meta box context. 1537 * @param WP_Post $post Post object. 1538 */ 1539 do_action( 'do_meta_boxes', $post_type, 'normal', $post ); 1540 /** This action is documented in wp-admin/includes/meta-boxes.php */ 1541 do_action( 'do_meta_boxes', $post_type, 'advanced', $post ); 1542 /** This action is documented in wp-admin/includes/meta-boxes.php */ 1543 do_action( 'do_meta_boxes', $post_type, 'side', $post ); 1544 }
Note: See TracChangeset
for help on using the changeset viewer.