Make WordPress Core

Changeset 19063


Ignore:
Timestamp:
10/25/2011 06:54:23 AM (14 years ago)
Author:
nacin
Message:

Make convert_to_screen() more resilient. see #18785.

File:
1 edited

Legend:

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

    r19054 r19063  
    402402        $action = $post_type = $taxonomy = '';
    403403
     404        if ( $hook_name )
     405            $id = $hook_name;
     406        else
     407            $id = $GLOBALS['hook_suffix'];
     408
     409        $id = str_replace( '.php', '', $id );
     410        if ( in_array( substr( $id, -4 ), array( '-add', '-new' ) ) )
     411            $action = 'add';
     412        $id = str_replace( array( '-new', '-add' ), '', $id );
     413
    404414        if ( $hook_name ) {
    405             if ( '-network' == substr( $hook_name, -8 ) )
    406                 $hook_name = str_replace( '-network', '', $hook_name );
    407             elseif ( '-user' == substr( $hook_name, -5 ) )
    408                 $hook_name = str_replace( '-user', '', $hook_name );
    409             $id = sanitize_key( $hook_name );
     415            if ( '-network' == substr( $id, -8 ) )
     416                $id = str_replace( '-network', '', $id );
     417            elseif ( '-user' == substr( $id, -5 ) )
     418                $id = str_replace( '-user', '', $id );
     419
     420            $id = sanitize_key( $id );
    410421            if ( false !== strpos( $id, '-' ) ) {
    411422                list( $id, $second ) = explode( '-', $id, 2 );
     
    419430                }
    420431            }
    421         } else {
    422             $id = $GLOBALS['hook_suffix'];
    423             $id = str_replace( '.php', '', $id );
    424             if ( in_array( substr( $id, -4 ), array( '-add', '-new' ) ) )
    425                 $action = 'add';
    426             $id = str_replace( array( '-new', '-add' ), '', $id );
    427         }
     432        }
    428433
    429434        if ( 'index' == $id )
Note: See TracChangeset for help on using the changeset viewer.