Make WordPress Core


Ignore:
Timestamp:
11/23/2011 09:29:33 PM (15 years ago)
Author:
ryan
Message:

Move convert_to_screen() back to template.php to avoid fatal errors with plugins and themes that direct include template.php into the front end. Flag this bad behavior with _doing_it_wrong(). Props nacin. fixes #19342

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r19419 r19428  
    17971797
    17981798add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
     1799
     1800/**
     1801 * Convert a screen string to a screen object
     1802 *
     1803 * @since 3.0.0
     1804 *
     1805 * @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen.
     1806 * @return WP_Screen Screen object.
     1807 */
     1808function convert_to_screen( $hook_name ) {
     1809    if ( ! is_admin() ) {
     1810        _doing_it_wrong( 'convert_to_screen(), add_meta_box()', __( "Likely direct inclusion of wp-admin/includes/template.php in order to use add_meta_box(). This is very wrong. Hook the add_meta_box() call into the add_meta_boxes action instead." ), '3.3' );
     1811        return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' );
     1812    }
     1813
     1814    return WP_Screen::get( $hook_name );
     1815}
Note: See TracChangeset for help on using the changeset viewer.