Changeset 13011
- Timestamp:
- 12/05/2023 06:24:43 AM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/plugins-themes.php
r12844 r13011 140 140 echo '<ul>'; 141 141 foreach ( $post_ids as $post_id ) { 142 $post = get_post( $post_id ); 143 $post_status = ''; 144 $style = 'color: green;'; 145 $reviewer = false; 146 if ( 'plugin' === $post->post_type && $post->assigned_reviewer ) { 147 $reviewer_user = get_user_by( 'id', $post->assigned_reviewer ); 148 $reviewer = $reviewer_user->display_name ?: $reviewer_user->user_login; 149 } 142 $post = get_post( $post_id ); 143 $type = 'theme'; // plugin set below. 144 $post_status = ''; 145 $style = 'color: green;'; 146 $reviewer = false; 147 $last_modidied = $post->post_modified_gmt; 148 $download_link = "https://downloads.wordpress.org/{$type}/{$post->post_name}.latest-stable.zip"; 149 150 if ( 'plugin' === $post->post_type ) { 151 $type = 'plugin'; 152 153 if ( $post->assigned_reviewer ) { 154 $reviewer_user = get_user_by( 'id', $post->assigned_reviewer ); 155 $reviewer = $reviewer_user->display_name ?: $reviewer_user->user_login; 156 } 157 158 // Prefer the last_modified post meta. 159 $last_modified = $post->last_updated ?: $last_modified; 160 161 // Get the ZIPs attached, link to the latest for pending/new. 162 if ( in_array( $post->post_status, [ 'new', 'pending' ] ) ) { 163 $attachments = get_posts( [ 164 'post_parent' => $post_id, 165 'post_type' => 'attachment', 166 'orderby' => 'post_date', 167 'order' => 'DESC', 168 'posts_per_page' => 1, 169 ] ); 170 $download_link = $attachments ? wp_get_attachment_url( $attachments[0]->ID ) : '#'; 171 } 172 } 173 174 $last_updated = human_time_diff( strtotime( $last_modified ), time() ); 175 $short_last_updated = str_ireplace( 176 [ ' seconds', ' second', ' hours', ' hour', ' days', ' day', ' weeks', ' week', ' months', ' month', ' years', ' year' ], 177 [ 's', 's', 'h', 'h', 'd', 'd', 'w', 'w', 'm', 'm', 'y', 'y' ], 178 $last_updated 179 ); 150 180 151 181 switch ( $post->post_status ) { 152 182 // Plugins 153 183 case 'rejected': 154 $post_status = '(Rejected)'; 155 $style = 'color: red;'; 184 $post_status = '(Rejected)'; 185 $style = 'color: red;'; 186 $download_link = '#'; // No zips exist for rejected plugins. 156 187 break; 157 188 case 'closed': … … 177 208 // Themes 178 209 case 'draft': 179 $post_status = '(In Review or Rejected)'; 180 $style = ''; 210 $post_status = '(In Review or Rejected)'; 211 $style = ''; 212 $download_link = '#'; // No zips exist for drafts. 181 213 break; 182 214 case 'suspend': … … 196 228 197 229 printf( 198 '<li><a href="%1$s" style="%2$s">%3$s</a> <a href="%4$s" style="%2$s">#</a> %5$s</li>', 199 /* 1 get_edit_post_link( $post ), // Won't work as post type not registered */ 200 /* 1 */ esc_url( add_query_arg( [ 'action' => 'edit', 'post' => $post_id ], admin_url( 'post.php' ) ) ), 201 /* 2 */ esc_attr( $style ), 202 /* 3 */ esc_html( $post->post_title ), 203 /* 4 get_permalink( $post ), */ 204 /* 4 */ esc_url( home_url( "/{$post->post_name}/" ) ), 205 /* 5 */ esc_html( $post_status ) 230 '<li> 231 <a href="%1$s" style="%2$s">%3$s</a> 232 <a href="%4$s" style="%2$s">#</a> 233 <a href="%5$s" style="%2$s">ↆ</a> %6$s 234 <br><span style="%2$s">%7$s</span> 235 %8$s 236 </li>', 237 /* 1: get_edit_post_link( $post ), // Won't work as post type not registered. */ 238 /* 1: Edit link */ esc_url( add_query_arg( [ 'action' => 'edit', 'post' => $post_id ], admin_url( 'post.php' ) ) ), 239 /* 2: The HTML style for the links */ esc_attr( $style ), 240 /* 3: The title */ esc_html( $post->post_title ), 241 /* 4: get_permalink( $post ), // Won't work as post type is not properly registered. */ 242 /* 4: Permalink */ esc_url( home_url( "/{$post->post_name}/" ) ), 243 /* 5: Download link */ esc_attr( $download_link ), 244 /* 6: Last Updated diff */ esc_html( $short_last_updated ), 245 /* 7: slug */ esc_html( $post->post_name ), 246 /* 8: The actual text */ esc_html( $post_status ) 206 247 ); 207 248 }
Note: See TracChangeset
for help on using the changeset viewer.