From 65dfa0fbb9bc79d36a77c6b31f9b280f400958c2 Mon Sep 17 00:00:00 2001
From: vairafiq <vairafiq@gmail.com>
Date: Mon, 18 Apr 2022 00:07:10 +0600
Subject: [PATCH] Adding actions before and after 'Add New' button in
edit-form-advanced
---
src/wp-admin/edit-form-advanced.php | 31 +++++++++++++++++++++++++++++
src/wp-admin/edit.php | 9 +++++++--
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/src/wp-admin/edit-form-advanced.php b/src/wp-admin/edit-form-advanced.php
index 907a760e6e..69c8cabb5f 100644
a
|
b
|
echo esc_html( $title ); |
433 | 433 | </h1> |
434 | 434 | |
435 | 435 | <?php |
| 436 | /** |
| 437 | * @global string $pagenow |
| 438 | */ |
| 439 | global $pagenow; |
| 440 | |
436 | 441 | if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create_posts ) ) { |
| 442 | /** |
| 443 | * Fires before the Add New button is added to screen. |
| 444 | * |
| 445 | * The before_add_new- hook fires in a number of contexts. |
| 446 | * |
| 447 | * The dynamic portion of the hook name, `$pagenow`, is a global variable |
| 448 | * referring to the filename of the current page, such as 'edit.php', |
| 449 | * 'post.php' etc. A complete hook for the latter would be |
| 450 | * 'before_add_new-post.php'. |
| 451 | * @since 6.0.0 |
| 452 | */ |
| 453 | do_action('before_add_new-'.$pagenow); |
| 454 | |
437 | 455 | echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new ) . '</a>'; |
| 456 | |
| 457 | /** |
| 458 | * Fires after the Add New button is added to screen. |
| 459 | * |
| 460 | * The after_add_new- hook fires in a number of contexts. |
| 461 | * |
| 462 | * The dynamic portion of the hook name, `$pagenow`, is a global variable |
| 463 | * referring to the filename of the current page, such as 'edit.php', |
| 464 | * 'post.php' etc. A complete hook for the latter would be |
| 465 | * 'before_add_new-post.php'. |
| 466 | * @since 6.0.0 |
| 467 | */ |
| 468 | do_action('after_add_new-'.$pagenow); |
438 | 469 | } |
439 | 470 | ?> |
440 | 471 | |
diff --git a/src/wp-admin/edit.php b/src/wp-admin/edit.php
index 8b38fb9eef..e895ce6914 100644
a
|
b
|
echo esc_html( $post_type_object->labels->name ); |
404 | 404 | </h1> |
405 | 405 | |
406 | 406 | <?php |
| 407 | /** |
| 408 | * @global string $pagenow |
| 409 | */ |
| 410 | global $pagenow; |
| 411 | |
407 | 412 | if ( current_user_can( $post_type_object->cap->create_posts ) ) { |
408 | 413 | /** |
409 | 414 | * Fires before the Add New button is added to screen. |
… |
… |
if ( current_user_can( $post_type_object->cap->create_posts ) ) { |
414 | 419 | * referring to the filename of the current page, such as 'edit.php', |
415 | 420 | * 'post.php' etc. A complete hook for the latter would be |
416 | 421 | * 'before_add_new-post.php'. |
417 | | * @since 6.0 |
| 422 | * @since 6.0.0 |
418 | 423 | */ |
419 | 424 | do_action('before_add_new-'.$pagenow); |
420 | 425 | |
… |
… |
if ( current_user_can( $post_type_object->cap->create_posts ) ) { |
429 | 434 | * referring to the filename of the current page, such as 'edit.php', |
430 | 435 | * 'post.php' etc. A complete hook for the latter would be |
431 | 436 | * 'before_add_new-post.php'. |
432 | | * @since 6.0 |
| 437 | * @since 6.0.0 |
433 | 438 | */ |
434 | 439 | do_action('after_add_new-'.$pagenow); |
435 | 440 | } |