Make WordPress Core

Ticket #55583: 55583.diff

File 55583.diff, 2.9 KB (added by rafiq91, 2 years ago)
  • src/wp-admin/edit-form-advanced.php

    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 ); 
    433433</h1>
    434434
    435435<?php
     436/**
     437 * @global string       $pagenow
     438 */
     439global $pagenow;
     440
    436441if ( 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
    437455        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);
    438469}
    439470?>
    440471
  • src/wp-admin/edit.php

    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 ); 
    404404</h1>
    405405
    406406<?php
     407/**
     408 * @global string       $pagenow
     409 */
     410global $pagenow;
     411
    407412if ( current_user_can( $post_type_object->cap->create_posts ) ) {
    408413        /**
    409414         * Fires before the Add New button is added to screen.
    if ( current_user_can( $post_type_object->cap->create_posts ) ) { 
    414419         * referring to the filename of the current page, such as 'edit.php',
    415420         * 'post.php' etc. A complete hook for the latter would be
    416421         * 'before_add_new-post.php'.
    417          * @since 6.0
     422         * @since 6.0.0
    418423         */
    419424        do_action('before_add_new-'.$pagenow);
    420425
    if ( current_user_can( $post_type_object->cap->create_posts ) ) { 
    429434         * referring to the filename of the current page, such as 'edit.php',
    430435         * 'post.php' etc. A complete hook for the latter would be
    431436         * 'before_add_new-post.php'.
    432          * @since 6.0
     437         * @since 6.0.0
    433438         */
    434439        do_action('after_add_new-'.$pagenow);
    435440}