Created
November 27, 2010 02:56
-
-
Save mikeschinkel/717514 to your computer and use it in GitHub Desktop.
Plugin for WordPress: Adds a 'admin_parse_output' hook to allow you to parse and modify the HTML generated by the admin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Admin Parse Output | |
Description: Adds a 'admin_parse_output' hook to allow you to parse and modify the HTML generated by the admin when other hooks are not available. Starts HTML capture with the 'admin_init' hook and ends with the 'admin_footer' hook so it will miss anything that comes after 'admin_footer' (see the last lines of /wp-admin/admin-footer.php to see what this hook will miss.) | |
Version: 0.1 | |
Author: Mike Schinkel | |
Author URI: http://mikeschinkel.com | |
Notes: Written for http://lists.automattic.com/pipermail/wp-hackers/2010-November/036150.html | |
Example Usage: See https://gist.github.com/717515 | |
*/ | |
if (!class_exists('Admin_Parse_Output')) { | |
class Admin_Parse_Output { | |
static function on_load() { | |
add_action('admin_init',array(__CLASS__,'admin_init'),1000); | |
add_action('admin_footer',array(__CLASS__,'admin_footer'),1000); | |
} | |
static function admin_init() { | |
if (has_action('admin_parse_output')) { | |
ob_start(); | |
} | |
} | |
static function admin_footer() { | |
if (has_action('admin_parse_output')) { | |
$html = ob_get_clean(); | |
$html = apply_filters('admin_parse_output',$html); | |
echo $html; | |
} | |
} | |
} | |
} | |
Admin_Parse_Output::on_load(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment