Changeset 1786 for sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/class-translation-editors-list-table.php
- Timestamp:
- 07/26/2015 04:42:45 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/class-translation-editors-list-table.php
r1437 r1786 34 34 */ 35 35 public $projects; 36 37 /** 38 * Holds the list of a project tree. 39 * 40 * @var array 41 */ 42 public $project_tree; 36 43 37 44 /** … … 52 59 $this->project_access_meta_key = $args['project_access_meta_key']; 53 60 $this->projects = $args['projects']; 61 $this->project_tree = $args['project_tree']; 54 62 $this->user_can_promote = current_user_can( 'promote_users' ); 55 63 } … … 226 234 foreach ( $project_access_list as $project_id ) { 227 235 if ( $this->projects[ $project_id ] ) { 228 $projects[] = esc_html( $this->projects[ $project_id ]->name ); 236 $parent = $this->get_parent_project( $this->project_tree, $project_id ); 237 if ( $parent->id != $project_id ) { 238 $name = sprintf( 239 '%s → %s', 240 esc_html( $parent->name ), 241 esc_html( $this->projects[ $project_id ]->name ) 242 ); 243 } else { 244 $name = esc_html( $this->projects[ $project_id ]->name ); 245 } 246 $projects[] = $name; 229 247 } 230 248 } … … 232 250 echo implode( '<br>', $projects ); 233 251 } 252 253 /** 254 * Returns the parent project for a sub project. 255 * 256 * @param array $tree The project tree. 257 * @param int $child_id The project tree. 258 * @return object The parent project. 259 */ 260 private function get_parent_project( $tree, $child_id ) { 261 $parent = null; 262 foreach ( $tree as $project ) { 263 if ( $project->id == $child_id ) { 264 $parent = $project; 265 break; 266 } 267 268 if ( isset( $project->sub_projects ) ) { 269 $parent = $this->get_parent_project( $project->sub_projects, $child_id ); 270 if ( $parent ) { 271 $parent = $project; 272 break; 273 } 274 } 275 } 276 277 return $parent; 278 } 234 279 }
Note: See TracChangeset
for help on using the changeset viewer.