Making WordPress.org

Changeset 1133


Ignore:
Timestamp:
01/12/2015 05:14:29 PM (10 years ago)
Author:
ocean90
Message:

GlotPress WPorg plugin: Add natural sorting for WordPress and BuddyPress sub projects.

fixes #813.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-specifics.php

    r1046 r1133  
    1212        $this->add_filter( 'gp_url_profile', array( 'args' => 2 ) );
    1313        $this->add_filter( 'routes' );
     14        $this->add_filter( 'projects', array( 'args' => 2 ) );
    1415    }
    1516
     
    2627        return $routes;
    2728    }
     29
     30    function projects( $sub_projects, $parent_id ) {
     31        if ( 1 != $parent_id && 13 != $parent_id ) { // 1 = WordPress, 13 = BuddyPress
     32            return $sub_projects;
     33        }
     34
     35        /*
     36         * Natural sorting for sub projects.
     37         *
     38         * 3.0.x
     39         * 4.0.x
     40         * 3.1.x
     41         * 4.1.x
     42         *  =>
     43         * 4.1.x
     44         * 4.0.x
     45         * 3.1.x
     46         * 3.0.x
     47         */
     48        usort( $sub_projects, function( $a, $b ) {
     49            return - strcasecmp( $a->name, $b->name );
     50        });
     51
     52        return $sub_projects;
     53    }
    2854}
    2955GP::$plugins->wporg_specifics = new GP_WPorg_Specifics;
Note: See TracChangeset for help on using the changeset viewer.