Want more features on Pastebin? Sign Up, it's FREE!
Guest

Wordpress 3.2.1 noheader bug demo

By: a guest on Sep 16th, 2011  |  syntax: PHP  |  size: 1.06 KB  |  views: 190  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /*
  3. Plugin Name: Demonstration of noheader bug
  4. Plugin URI:
  5. Description: Demonstration of noheader bug
  6. */
  7.  
  8. add_action('admin_menu', 'test_admin_menus');
  9.  
  10. function test_admin_menus() {
  11.         $pluginPage = add_options_page('noheader test', 'noheader test', 'manage_options', 'noheader-test', 'test_display');
  12.         add_action('admin_head-'.$pluginPage,'test_admin_head');
  13.        
  14. }
  15.  
  16. function test_admin_head() {
  17.         //create a global var, so we know if run
  18.         global $test_variable_to_test;
  19.         $test_variable_to_test = 'PHP included!';
  20. }
  21.  
  22. function test_display() {
  23.         if ($_GET['noheader']) {require_once(ABSPATH.'wp-admin/admin-header.php');} //include the header if not included by WP
  24.        
  25.         global $test_variable_to_test;
  26.        
  27.         echo '<p>$test_variable_to_test was set to: <strong>'.$test_variable_to_test.'</strong></p>';
  28.  
  29.         echo '<form method="POST" action="'.get_bloginfo('url').'/wp-admin/options-general.php?page='.$_GET['page'].'&noheader=1">';
  30.         echo '<p>Submit this form to see the $test_variable_to_test variable disapper</p>';
  31.         echo '<input type="submit" />';
  32.         echo '</form>';
  33. }
clone this paste RAW Paste Data