PHP 29
Wordpress backend post/page hooks (get_current_screen) By micha on 2nd December 2020 03:16:56 PM
  1. <?php
  2.  
  3. add_action( 'all_admin_notices', function() {
  4.   $screen = get_current_screen();
  5.   //var_dump($screen);
  6.  
  7.   if( 'edit-quiz' === $screen->id ) {
  8.     echo '<p>Greetings from <strong>edit -> overview</strong>!</p>';  
  9.   }
  10.  
  11.   if( 'quiz' === $screen->id ) {
  12.     echo '<p>Greetings from <strong>post -> edit / new</strong>!</p>';
  13.  
  14.     //before content
  15.     add_action( 'edit_form_after_title', 'add_content_before_editor' );
  16.     function add_content_before_editor() {
  17.       echo '<b>After title</b>: Yay we have found the pos';
  18.     }
  19.  
  20.     //before title
  21.     add_action( 'edit_form_top', 'add_content_before_title' );
  22.     function add_content_before_title() {
  23.       echo '<font color="red">Or may b... </font><b>Yaaaaaaay </b>we have a better pos found';
  24.     }
  25.  
  26.   }
  27.                
  28. });

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.