WordPress.org

Making WordPress.org

Changeset 4224


Ignore:
Timestamp:
10/12/2016 01:03:26 PM (5 years ago)
Author:
dd32
Message:

Plugin Directory: Add the first foundations for the front-end admin/plugin-edit screen.

See #2111

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r4214 r4224  
    4646        add_filter( 'pre_update_option_jetpack_options', array( $this, 'filter_jetpack_options' ) );
    4747        add_action( 'template_redirect', array( $this, 'prevent_canonical_for_plugins' ), 9 );
    48         add_action( 'template_redirect', array( $this, 'redirect_old_plugin_urls' ) );
     48        add_action( 'template_redirect', array( $this, 'custom_redirects' ) );
    4949        add_filter( 'query_vars', array( $this, 'filter_query_vars' ) );
    5050        add_filter( 'single_term_title', array( $this, 'filter_single_term_title' ) );
     
    293293        add_rewrite_rule( '^browse/favorites/([^/]+)$', 'index.php?browse=favorites&favorites_user=$matches[1]', 'top' );
    294294
     295        // Handle plugin admin requests
     296        add_rewrite_rule( '^([^/]+)/admin/?$', 'index.php?name=$matches[1]&plugin_admin=1', 'top' );
     297
    295298        // Add duplicate search rule which will be hit before the following old-plugin tab rules
    296299        add_rewrite_rule( '^search/([^/]+)/?$', 'index.php?s=$matches[1]', 'top' );
     
    588591                }
    589592
     593                // TODO: Switch this to the capabilities systems
    590594                $restricted_access_statii = array_diff( $wp_query->query_vars['post_status'], array( 'publish' ) );
    591595                foreach ( $posts as $i => $post ) {
     
    777781        $vars[] = 'favorites_user';
    778782        $vars[] = 'redirect_plugin_tab';
     783        $vars[] = 'plugin_admin';
    779784
    780785        return $vars;
     
    828833
    829834    /**
    830      * Handles a redirect for the old /$plugin/$tab_name/ URLs and search.php
    831      */
    832     function redirect_old_plugin_urls() {
     835     * Handles all the custom redirects needed in the Plugin Directory.
     836     */
     837    function custom_redirects() {
    833838
    834839        // Handle a redirect for /$plugin/$tab_name/ to /$plugin/#$tab_name.
     
    880885            wp_safe_redirect( site_url( '/search/' . urlencode( get_query_var( 's' ) ) . '/' ) );
    881886            die();
     887        }
     888
     889        // TODO: Switch this to the capabilities systems, check if post_author should access
     890        // Filter access to the plugin administration area. Only certain users are allowed access.
     891        if ( get_query_var( 'plugin_admin' ) && ! current_user_can( 'plugin_review' ) ) {
     892            $post = Plugin_Directory::get_plugin_post( get_query_var( 'name' ) );
     893            if (
     894                // Logged out users can't access plugin admin
     895                ! is_user_logged_in() ||
     896                // Allow access to Committers OR Contributors.
     897                ! (
     898                    // Committers can access plugin admin
     899                    in_array( wp_get_current_user()->user_login, (array) Tools::get_plugin_committers( $post->post_name ), true ) ||
     900                    // Contributors can access plugin admin (but will have a more limited access)
     901                    in_array( wp_get_current_user()->user_nicename, (array) wp_list_pluck( get_the_terms( $post, 'plugin_contributors' ), 'slug' ), true )
     902                )
     903            ) {
     904                wp_safe_redirect( get_permalink( $post ) );
     905                die();
     906            }
    882907        }
    883908    }
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/plugin/favorite-button/style.scss

    r4223 r4224  
    3838
    3939.plugin-favorite {
    40     display: inline-block;
    4140    height: 36px;
    4241    text-align: center;
     42    vertical-align: top;
    4343    width: 36px;
    4444
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/plugin/style.scss

    r4223 r4224  
    1313        .plugin-actions {
    1414            float: right;
     15
     16            div {
     17                display: inline-block;
     18                text-align: center;
     19            }
    1520        }
    1621
     
    2025            font-weight: 400;
    2126            margin: 0;
     27
     28            a {
     29                color: inherit;
     30                text-decoration: none;
     31            }
    2232        }
    2333
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/css/style-rtl.css

    r4223 r4224  
    20332033
    20342034.plugin-favorite {
    2035   display: inline-block;
    20362035  height: 36px;
    20372036  text-align: center;
     2037  vertical-align: top;
    20382038  width: 36px;
    20392039}
     
    25542554}
    25552555
     2556.type-plugin .plugin-header .plugin-actions div {
     2557  display: inline-block;
     2558  text-align: center;
     2559}
     2560
    25562561.type-plugin .plugin-header .plugin-title {
    25572562  clear: none;
     
    25602565  font-weight: 400;
    25612566  margin: 0;
     2567}
     2568
     2569.type-plugin .plugin-header .plugin-title a {
     2570  color: inherit;
     2571  text-decoration: none;
    25622572}
    25632573
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/css/style.css

    r4223 r4224  
    20332033
    20342034.plugin-favorite {
    2035   display: inline-block;
    20362035  height: 36px;
    20372036  text-align: center;
     2037  vertical-align: top;
    20382038  width: 36px;
    20392039}
     
    25542554}
    25552555
     2556.type-plugin .plugin-header .plugin-actions div {
     2557  display: inline-block;
     2558  text-align: center;
     2559}
     2560
    25562561.type-plugin .plugin-header .plugin-title {
    25572562  clear: none;
     
    25602565  font-weight: 400;
    25612566  margin: 0;
     2567}
     2568
     2569.type-plugin .plugin-header .plugin-title a {
     2570  color: inherit;
     2571  text-decoration: none;
    25622572}
    25632573
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php

    r4223 r4224  
    8787                </div>
    8888            <?php endif; ?>
     89            <div>
     90                <a class="plugin-download button download-button button-large" href="<?php echo esc_url( Template::download_link() ); ?>" itemprop="downloadUrl"><?php _e( 'Download', 'wporg-plugins' ); ?></a>
     91                <?php if ( true /* TODO: Logic on when to show the edit link */ ) : ?>
     92                    <br>
     93                    <a class="plugin-edit" href="<?php echo esc_url( get_permalink() . 'admin/' ); ?>"><?php _e( 'Edit Plugin', 'wporg-plugins' ); ?></a>   
     94                <?php endif; ?>
     95            </div>
    8996
    90             <a class="plugin-download button download-button button-large" href="<?php echo esc_url( Template::download_link() ); ?>" itemprop="downloadUrl"><?php _e( 'Download', 'wporg-plugins' ); ?></a>
    9197            <meta itemprop="softwareVersion" content="<?php echo esc_attr( get_post_meta( get_the_ID(), 'version', true ) ); ?>">
    9298            <meta itemprop="fileFormat" content="application/zip">
    9399        </div>
    94100
    95         <?php the_title( '<h1 class="plugin-title">', '</h1>' ); ?>
     101        <?php the_title( '<h1 class="plugin-title"><a href="' . esc_url( get_permalink() ) . '">', '</a></h1>' ); ?>
    96102
    97103        <span class="byline"><?php
     
    102108                _x( 'By %s', 'post author', 'wporg-plugins' ),
    103109                '<span class="author vcard">' .
    104                 ( $url ? '<a class="url fn n" href="' . esc_url( $url ) . '">' : '' ) .
     110                ( $url ? '<a class="url fn n" rel="nofollow" href="' . esc_url( $url ) . '">' : '' ) .
    105111                esc_html( Template::encode( $author ) ) .
    106112                ( $url ? '</a>' : '' ) .
     
    112118    <div class="entry-content">
    113119        <?php
     120        if ( get_query_var( 'plugin_admin' ) ) :
     121            get_template_part( 'template-parts/section', 'admin' );
     122        else:
    114123            $plugin_sections = Template::get_plugin_sections();
    115124
     
    129138                get_template_part( 'template-parts/section', $section_slug );
    130139            endforeach;
     140        endif; // plugin_admin
    131141        ?>
    132142    </div><!-- .entry-content -->
Note: See TracChangeset for help on using the changeset viewer.