WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/31/16 18:10:45 (18 months ago)
Author:
ocean90
Message:

Plugins: Use install_plugins_upload action to print the upload form.

Since [37221] the upload form is added to every plugin install screen via install_plugins_upload(). Previously the form was added through the install_plugins_upload (alias of install_plugins_$tab) action which allowed plugin authors to replace the form. This restores the previous behaviour.

  • Add the form only to non-upload plugin install screens.
  • Replace install_plugins_upload() with the install_plugins_upload and install_plugins_pre_upload actions.
  • Remove $upload_tab_class and add a CSS class for the current tab to .wrap
  • Adjust CSS selectors and toggle the whole container to support upload without an upload-plugin class.

Props DavidAnderson, ocean90.
Fixes #37495.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/plugin-install.php

    r38119 r38172  
    6767do_action( "install_plugins_pre_$tab" ); 
    6868 
     69/* 
     70 * Call the pre upload action on every non-upload plugin install screen 
     71 * because the form is always displayed on these screens. 
     72 */ 
     73if ( 'upload' !== $tab ) { 
     74    /** This action is documented in wp-admin/plugin-install.php */ 
     75    do_action( 'install_plugins_pre_upload' ); 
     76} 
     77 
    6978get_current_screen()->add_help_tab( array( 
    7079'id'        => 'overview', 
     
    102111include(ABSPATH . 'wp-admin/admin-header.php'); 
    103112?> 
    104 <div class="wrap"> 
     113<div class="wrap <?php echo esc_attr( "plugin-install-tab-$tab" ); ?>"> 
    105114<h1> 
    106115    <?php 
    107116    echo esc_html( $title ); 
    108117    if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_plugins' ) ) { 
    109         if ( $tab === 'upload' ) { 
    110             $href = self_admin_url( 'plugin-install.php' ); 
    111             $upload_tab_class = ' upload-tab'; 
    112         } else { 
    113             $href = self_admin_url( 'plugin-install.php?tab=upload' ); 
    114             $upload_tab_class = ''; 
    115         } 
    116  
    117         printf( ' <a href="%s" class="upload-view-toggle page-title-action%s"><span class="upload">%s</span><span class="browse">%s</span></a>', 
    118             $href, 
    119             $upload_tab_class, 
     118        printf( ' <a href="%s" class="upload-view-toggle page-title-action"><span class="upload">%s</span><span class="browse">%s</span></a>', 
     119            ( 'upload' === $tab ) ? self_admin_url( 'plugin-install.php' ) : self_admin_url( 'plugin-install.php?tab=upload' ), 
    120120            __( 'Upload Plugin' ), 
    121121            __( 'Browse Plugins' ) 
     
    125125</h1> 
    126126 
    127 <div class="upload-plugin-wrap<?php echo $upload_tab_class; ?>"> 
    128127<?php 
    129128/* 
    130  * Output the upload plugin form on every plugin install screen, so it can be 
     129 * Output the upload plugin form on every non-upload plugin install screen, so it can be 
    131130 * displayed via JavaScript rather then opening up the devoted upload plugin page. 
    132131 */ 
    133 install_plugins_upload(); ?> 
    134 </div> 
     132if ( $tab !== 'upload' ) { 
     133    ?> 
     134    <div class="upload-plugin-wrap"> 
     135        <?php 
     136        /** This action is documented in wp-admin/plugin-install.php */ 
     137        do_action( 'install_plugins_upload' ); 
     138        ?> 
     139    </div> 
     140    <?php 
     141} 
    135142 
    136 <?php 
    137143if ( $tab !== 'upload' ) { 
    138144    $wp_list_table->views(); 
Note: See TracChangeset for help on using the changeset viewer.