Make WordPress Core


Ignore:
Timestamp:
03/16/2014 06:27:38 PM (11 years ago)
Author:
azaozz
Message:

Restyle the plugin install details modal to match the rest of the admin. Props avryl and paulwilde for initial mockup, see #26952

File:
1 edited

Legend:

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

    r27369 r27559  
    313313    $api = plugins_api( 'plugin_information', array( 'slug' => wp_unslash( $_REQUEST['plugin'] ), 'is_ssl' => is_ssl() ) );
    314314
    315     if ( is_wp_error($api) )
    316         wp_die($api);
     315    if ( is_wp_error( $api ) )
     316        wp_die( $api );
    317317
    318318    $plugins_allowedtags = array(
     
    335335
    336336    //Sanitize HTML
    337     foreach ( (array)$api->sections as $section_name => $content )
     337    foreach ( (array)$api->sections as $section_name => $content ) {
    338338        $api->sections[$section_name] = wp_kses($content, $plugins_allowedtags);
     339    }
     340
    339341    foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) {
    340342        if ( isset( $api->$key ) )
    341343            $api->$key = wp_kses( $api->$key, $plugins_allowedtags );
    342344    }
     345
     346    $_tab = esc_attr( $tab );
    343347
    344348    $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; //Default to the Description tab, Do not translate, API returns English.
     
    349353
    350354    iframe_header( __('Plugin Install') );
    351     echo "<div id='$tab-header'>\n";
    352     echo "<ul id='sidemenu'>\n";
     355
     356    echo "<div id='{$_tab}-title'>{$api->name}</div>";
     357    echo "<div id='{$_tab}-tabs'>\n";
     358
    353359    foreach ( (array)$api->sections as $section_name => $content ) {
    354360
     
    360366        $class = ( $section_name == $section ) ? ' class="current"' : '';
    361367        $href = add_query_arg( array('tab' => $tab, 'section' => $section_name) );
    362         $href = esc_url($href);
     368        $href = esc_url( $href );
    363369        $san_section = esc_attr( $section_name );
    364         echo "\t<li><a name='$san_section' href='$href' $class>$title</a></li>\n";
    365     }
    366     echo "</ul>\n";
     370        echo "\t<a name='$san_section' href='$href' $class>$title</a>\n";
     371    }
     372
    367373    echo "</div>\n";
     374
    368375    ?>
    369     <div class="alignright fyi">
    370         <?php if ( ! empty($api->download_link) && ( current_user_can('install_plugins') || current_user_can('update_plugins') ) ) : ?>
    371         <p class="action-button">
    372         <?php
     376    <div id="<?php echo $_tab; ?>-content">
     377    <div class="fyi">
     378        <ul>
     379<?php if ( ! empty( $api->version ) ) : ?>
     380            <li><strong><?php _e('Version:') ?></strong> <?php echo $api->version ?></li>
     381<?php endif; if ( ! empty( $api->author ) ) : ?>
     382            <li><strong><?php _e('Author:') ?></strong> <?php echo links_add_target($api->author, '_blank') ?></li>
     383<?php endif; if ( ! empty( $api->last_updated ) ) : ?>
     384            <li><strong><?php _e('Last Updated:') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php
     385                            printf( __('%s ago'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li>
     386<?php endif; if ( ! empty( $api->requires ) ) : ?>
     387            <li><strong><?php _e('Requires WordPress Version:') ?></strong> <?php printf(__('%s or higher'), $api->requires) ?></li>
     388<?php endif; if ( ! empty( $api->tested ) ) : ?>
     389            <li><strong><?php _e('Compatible up to:') ?></strong> <?php echo $api->tested ?></li>
     390<?php endif; if ( ! empty( $api->downloaded ) ) : ?>
     391            <li><strong><?php _e('Downloaded:') ?></strong> <?php printf(_n('%s time', '%s times', $api->downloaded), number_format_i18n($api->downloaded)) ?></li>
     392<?php endif; if ( ! empty( $api->slug ) && empty( $api->external ) ) : ?>
     393            <li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug ?>/"><?php _e('WordPress.org Plugin Page &#187;') ?></a></li>
     394<?php endif; if ( ! empty( $api->homepage ) ) : ?>
     395            <li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage &#187;') ?></a></li>
     396<?php endif; ?>
     397        </ul>
     398        <?php if ( ! empty( $api->rating ) ) : ?>
     399        <h3><?php _e('Average Rating') ?></h3>
     400        <?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?>
     401        <small><?php printf( _n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings) ); ?></small>
     402        <?php endif; ?>
     403    </div>
     404    <div id="section-holder" class="wrap">
     405    <?php
     406        if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) )
     407            echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>';
     408
     409        else if ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) )
     410            echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.') . '</p></div>';
     411
     412        foreach ( (array)$api->sections as $section_name => $content ) {
     413
     414            if ( isset( $plugins_section_titles[ $section_name ] ) )
     415                $title = $plugins_section_titles[ $section_name ];
     416            else
     417                $title = ucwords( str_replace( '_', ' ', $section_name ) );
     418
     419            $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' );
     420            $content = links_add_target( $content, '_blank' );
     421
     422            $san_section = esc_attr( $section_name );
     423
     424            $display = ( $section_name == $section ) ? 'block' : 'none';
     425
     426            echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
     427            echo $content;
     428            echo "\t</div>\n";
     429        }
     430    echo "</div>\n";
     431    echo "</div>\n";
     432    echo "<div id='$tab-footer'>\n";
     433    if ( ! empty( $api->download_link ) && ( current_user_can('install_plugins') || current_user_can('update_plugins') ) ) {
    373434        $status = install_plugin_install_status($api);
    374435        switch ( $status['status'] ) {
    375436            case 'install':
    376437                if ( $status['url'] )
    377                     echo '<a href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>';
     438                    echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>';
    378439                break;
    379440            case 'update_available':
    380441                if ( $status['url'] )
    381                     echo '<a href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') .'</a>';
     442                    echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') .'</a>';
    382443                break;
    383444            case 'newer_installed':
    384                 echo '<a>' . sprintf(__('Newer Version (%s) Installed'), $status['version']) . '</a>';
     445                echo '<a class="button button-primary right">' . sprintf(__('Newer Version (%s) Installed'), $status['version']) . '</a>';
    385446                break;
    386447            case 'latest_installed':
    387                 echo '<a>' . __('Latest Version Installed') . '</a>';
     448                echo '<a class="button button-primary right">' . __('Latest Version Installed') . '</a>';
    388449                break;
    389450        }
    390         ?>
    391         </p>
    392         <?php endif; ?>
    393         <h2 class="mainheader"><?php /* translators: For Your Information */ _e('FYI') ?></h2>
    394         <ul>
    395 <?php if ( ! empty($api->version) ) : ?>
    396             <li><strong><?php _e('Version:') ?></strong> <?php echo $api->version ?></li>
    397 <?php endif; if ( ! empty($api->author) ) : ?>
    398             <li><strong><?php _e('Author:') ?></strong> <?php echo links_add_target($api->author, '_blank') ?></li>
    399 <?php endif; if ( ! empty($api->last_updated) ) : ?>
    400             <li><strong><?php _e('Last Updated:') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php
    401                             printf( __('%s ago'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li>
    402 <?php endif; if ( ! empty($api->requires) ) : ?>
    403             <li><strong><?php _e('Requires WordPress Version:') ?></strong> <?php printf(__('%s or higher'), $api->requires) ?></li>
    404 <?php endif; if ( ! empty($api->tested) ) : ?>
    405             <li><strong><?php _e('Compatible up to:') ?></strong> <?php echo $api->tested ?></li>
    406 <?php endif; if ( ! empty($api->downloaded) ) : ?>
    407             <li><strong><?php _e('Downloaded:') ?></strong> <?php printf(_n('%s time', '%s times', $api->downloaded), number_format_i18n($api->downloaded)) ?></li>
    408 <?php endif; if ( ! empty($api->slug) && empty($api->external) ) : ?>
    409             <li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug ?>/"><?php _e('WordPress.org Plugin Page &#187;') ?></a></li>
    410 <?php endif; if ( ! empty($api->homepage) ) : ?>
    411             <li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage &#187;') ?></a></li>
    412 <?php endif; ?>
    413         </ul>
    414         <?php if ( ! empty($api->rating) ) : ?>
    415         <h2><?php _e('Average Rating') ?></h2>
    416         <?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?>
    417         <small><?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?></small>
    418         <?php endif; ?>
    419     </div>
    420     <div id="section-holder" class="wrap">
    421     <?php
    422         if ( !empty($api->tested) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>') )
    423             echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>';
    424 
    425         else if ( !empty($api->requires) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->requires)), $api->requires, '<') )
    426             echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.') . '</p></div>';
    427 
    428         foreach ( (array)$api->sections as $section_name => $content ) {
    429 
    430             if ( isset( $plugins_section_titles[ $section_name ] ) )
    431                 $title = $plugins_section_titles[ $section_name ];
    432             else
    433                 $title = ucwords( str_replace( '_', ' ', $section_name ) );
    434 
    435             $content = links_add_base_url($content, 'https://wordpress.org/plugins/' . $api->slug . '/');
    436             $content = links_add_target($content, '_blank');
    437 
    438             $san_section = esc_attr( $section_name );
    439 
    440             $display = ( $section_name == $section ) ? 'block' : 'none';
    441 
    442             echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
    443             echo "\t\t<h2 class='long-header'>$title</h2>";
    444             echo $content;
    445             echo "\t</div>\n";
    446         }
     451    }
    447452    echo "</div>\n";
    448453
Note: See TracChangeset for help on using the changeset viewer.