Changeset 46710 for branches/5.3/src/wp-admin/includes/credits.php
- Timestamp:
- 11/11/2019 08:46:56 PM (5 years ago)
- Location:
- branches/5.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.3
- Property svn:mergeinfo changed
/trunk merged: 46705,46709
- Property svn:mergeinfo changed
-
branches/5.3/src/wp-admin/includes/credits.php
r42343 r46710 77 77 $data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>'; 78 78 } 79 80 /** 81 * Display a the title for a given group of contributors. 82 * 83 * @since 5.3.0 84 * 85 * @param array $group_data The current contributor group. 86 */ 87 function wp_credits_section_title( $group_data = array() ) { 88 if ( ! count( $group_data ) ) { 89 return; 90 } 91 92 if ( $group_data['name'] ) { 93 if ( 'Translators' === $group_data['name'] ) { 94 // Considered a special slug in the API response. (Also, will never be returned for en_US.) 95 $title = _x( 'Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section' ); 96 } elseif ( isset( $group_data['placeholders'] ) ) { 97 // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText 98 $title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] ); 99 } else { 100 // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText 101 $title = translate( $group_data['name'] ); 102 } 103 104 echo '<h2 class="wp-people-group-title">' . esc_html( $title ) . "</h2>\n"; 105 } 106 } 107 108 /** 109 * Display a list of contributors for a given group. 110 * 111 * @since 5.3.0 112 * 113 * @param array $credits The credits groups returned from the API. 114 * @param string $slug The current group to display. 115 */ 116 function wp_credits_section_list( $credits = array(), $slug = '' ) { 117 $group_data = isset( $credits['groups'][ $slug ] ) ? $credits['groups'][ $slug ] : array(); 118 $credits_data = $credits['data']; 119 if ( ! count( $group_data ) ) { 120 return; 121 } 122 123 if ( ! empty( $group_data['shuffle'] ) ) { 124 shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt. 125 } 126 127 switch ( $group_data['type'] ) { 128 case 'list': 129 array_walk( $group_data['data'], '_wp_credits_add_profile_link', $credits_data['profiles'] ); 130 echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n"; 131 break; 132 case 'libraries': 133 array_walk( $group_data['data'], '_wp_credits_build_object_link' ); 134 echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n"; 135 break; 136 default: 137 $compact = 'compact' === $group_data['type']; 138 $classes = 'wp-people-group ' . ( $compact ? 'compact' : '' ); 139 echo '<ul class="' . $classes . '" id="wp-people-group-' . $slug . '">' . "\n"; 140 foreach ( $group_data['data'] as $person_data ) { 141 echo '<li class="wp-person" id="wp-person-' . esc_attr( $person_data[2] ) . '">' . "\n\t"; 142 echo '<a href="' . esc_url( sprintf( $credits_data['profiles'], $person_data[2] ) ) . '" class="web">'; 143 $size = $compact ? 40 : 80; 144 $data = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) ); 145 $data2x = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size * 2 ) ); 146 echo '<img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" />' . "\n"; 147 echo esc_html( $person_data[0] ) . "</a>\n\t"; 148 if ( ! $compact ) { 149 // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText 150 echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n"; 151 } 152 echo "</li>\n"; 153 } 154 echo "</ul>\n"; 155 break; 156 } 157 }
Note: See TracChangeset
for help on using the changeset viewer.