Changeset 6006 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-consistency.php
- Timestamp:
- 10/07/2017 01:23:36 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-consistency.php
r3013 r6006 3 3 namespace WordPressdotorg\GlotPress\Routes\Routes; 4 4 5 use GP; 5 6 use GP_Locales; 6 7 use GP_Route; … … 15 16 private $cache_group = 'wporg-translate'; 16 17 18 const PROJECTS = [ 19 1 => 'WordPress', 20 523 => 'Themes', 21 17 => 'Plugins', 22 487 => 'Meta', 23 281 => 'Apps', 24 ]; 25 17 26 /** 18 27 * Prints a search form and the search results for a consistency view. … … 21 30 $sets = $this->get_translation_sets(); 22 31 23 $search = $set = '';24 $search_case_sensitive = true;32 $search = $set = $project = ''; 33 $search_case_sensitive = false; 25 34 26 35 if ( ! empty( $_REQUEST['search'] ) ) { … … 35 44 } 36 45 37 if ( ! empty( $_REQUEST ) && empty( $_REQUEST['search_case_sensitive'] ) ) { 38 $search_case_sensitive = false; 46 if ( ! empty( $_REQUEST['search_case_sensitive'] ) ) { 47 $search_case_sensitive = true; 48 } 49 50 if ( ! empty( $_REQUEST['project'] ) && isset( self::PROJECTS[ $_REQUEST['project'] ] ) ) { 51 $project = $_REQUEST['project']; 39 52 } 40 53 … … 53 66 'set' => $set, 54 67 'case_sensitive' => $search_case_sensitive, 68 'project' => $project, 55 69 ] ); 56 70 … … 58 72 $translations_unique = array_unique( $translations ); 59 73 } 74 75 $projects = self::PROJECTS; 60 76 61 77 $this->tmpl( 'consistency', get_defined_vars() ); … … 109 125 $slug = $wpdb->prepare( '%s', $slug ); 110 126 127 $project_where = ''; 128 if ( $args['project'] ) { 129 $project = GP::$project->get( $args['project'] ); 130 $project_where = $wpdb->prepare( 'AND p.path LIKE %s', $wpdb->esc_like( $project->path ) . '/%' ); 131 } 132 111 133 $results = $wpdb->get_results( " 112 134 SELECT … … 134 156 AND o.status = '+active' AND o.singular {$search} 135 157 AND ts.locale = {$locale} AND ts.slug = {$slug} 158 {$project_where} 136 159 LIMIT 0, 500 137 160 " ); … … 148 171 149 172 public function _sort_callback( $a, $b ) { 150 return strnatc mp( $a->translation, $b->translation );173 return strnatcasecmp( $a->translation, $b->translation ); 151 174 } 152 175 }
Note: See TracChangeset
for help on using the changeset viewer.