Making WordPress.org

Changeset 3331


Ignore:
Timestamp:
06/11/2016 08:21:45 PM (9 years ago)
Author:
obenland
Message:

Plugin Directory: Give Reviewers the ability to filter plugins by author IP.

See #1570.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
5 edited

Legend:

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

    r3327 r3331  
    173173        if ( empty( $query->query['post_status'] ) ) {
    174174            $query->query_vars['post_status'] = array( 'publish', 'future', 'draft', 'pending', 'disabled', 'closed', 'rejected', 'approved' );
     175        }
     176
     177        // Make it possible to search for plugins that were submitted from a specific IP.
     178        if ( current_user_can( 'plugin_review' ) && ! empty( $query->query['s'] ) && filter_var( $query->query['s'], FILTER_VALIDATE_IP ) ) {
     179            $query->query_vars['meta_key']   = '_author_ip';
     180            $query->query_vars['meta_value'] = $query->query_vars['s'];
     181            unset( $query->query_vars['s'] );
     182
     183            add_filter( 'get_search_query', function() use ( $query ) {
     184                return esc_html( $query->query_vars['meta_value'] );
     185            } );
    175186        }
    176187
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-author-card.php

    r3174 r3331  
    7979        }
    8080
    81         $user_ips = array();// $wpdb->get_col( $wpdb->prepare( 'SELECT DISTINCT poster_ip FROM plugin_2_posts WHERE poster_id = %s', $author->ID ) );
    82         $user_ips = array_filter( $user_ips, 'strlen' );
     81        $post_ids = get_posts( array(
     82            'fields'         => 'ids',
     83            'post_type'      => 'plugin',
     84            'author'         => $author->ID,
     85            'meta_key'       => '_author_ip',
     86            'posts_per_page' => -1,
     87        ) );
     88
     89        $user_ips = array_unique( array_map( function( $post_id ) {
     90            return get_post_meta( $post_id, '_author_ip', true );
     91        }, $post_ids ) );
     92
    8393        if ( $user_ips ) :
    8494            sort( $user_ips, SORT_NUMERIC );
    8595
    86             $user_ips = array_map( array( 'Author_Card', 'link_ip' ), $user_ips );
    87 
    88             echo '<p>IPs : ' . implode( ', ', $user_ips ) . '</p>';
     96            printf( '<p>IPs : %s</p>', implode( ', ', array_map( array( __NAMESPACE__ . '\Author_Card', 'link_ip' ), $user_ips ) ) );
    8997        endif;
    9098
     
    191199        do_action( 'wporg_plugins_author_card', $post, $author, $all_plugins );
    192200    }
     201
     202    /**
     203     * Builds a link to a list of plugins submitted from a given IP.
     204     *
     205     * @param string $ip IP address of the plugin author.
     206     * @return string
     207     */
     208    protected static function link_ip( $ip ) {
     209        return sprintf( '<a href="%1$s">%2$s</a>', esc_url( add_query_arg( array(
     210            'post_type' => 'plugin',
     211            's'         => $ip,
     212        ), admin_url( 'edit.php' ) ) ), $ip );
     213    }
    193214}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r3326 r3331  
    661661     *     @type string $content     The long description of the plugin.
    662662     *     @type array  $tags        The tags associated with the plugin.
    663      *     @type array  $tags        The meta information of the plugin.
     663     *     @type array  $meta        The meta information of the plugin.
    664664     * }
    665665     * @return \WP_Post|\WP_Error
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php

    r3328 r3331  
    8080
    8181        if ( ! $plugin ) {
     82            $author_ip = $wpdb->get_var( $wpdb->prepare( 'SELECT poster_ip FROM ' . PLUGINS_TABLE_PREFIX . 'posts WHERE topic_id = %s', $topic->topic_id ) );
     83
    8284            $plugin = Plugin_Directory::create_plugin_post( array(
    8385                'slug' => $plugin_slug,
     
    8991                'post_modified' => $topic->topic_time,
    9092                'post_modified_gmt' => $topic->topic_time,
     93                'meta' => array(
     94                    '_author_ip' => $author_ip,
     95                ),
    9196            ) );
    9297        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php

    r3250 r3331  
    204204                    'support_threads'          => 0,
    205205                    'support_threads_resolved' => 0,
     206                    '_author_ip'               => preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] ),
    206207                ),
    207208            ) );
Note: See TracChangeset for help on using the changeset viewer.