Ticket #5362: 5362-delist-actions.3.diff
File 5362-delist-actions.3.diff, 8.5 KB (added by , 4 years ago) |
---|
-
admin-edit.php
43 43 'exclude_from_search' => true, 44 44 'label_count' => _n_noop( 'Suspended <span class="count">(%s)</span>', 'Suspended <span class="count">(%s)</span>', 'wporg-themes' ), 45 45 ) ); 46 47 // Themes can be "delisted" to hide them from search, but allow them to be uploaded. 48 register_post_status( 'delist', array( 49 'label' => __( 'Delisted', 'wporg-themes' ), 50 'protected' => false, 51 'public' => true, 52 'exclude_from_search' => true, 53 'label_count' => _n_noop( 'Delisted <span class="count">(%s)</span>', 'Delisted <span class="count">(%s)</span>', 'wporg-themes' ), 54 ) ); 46 55 } 47 56 add_action( 'init', 'wporg_themes_post_status' ); 48 57 … … 124 133 $links[] = sprintf( '<a class="submit-reinstate_theme" title="%1$s" href="%2$s">%3$s</a>', esc_attr__( 'Suspend this item', 'wporg-themes' ), esc_url( wporg_themes_get_reinstate_url( $post ) ), __( 'Reinstate', 'wporg-themes' ) ); 125 134 } 126 135 136 if ( current_user_can( 'suspend_theme', $post->ID ) && 'publish' == $post->post_status ) { 137 $links[] = sprintf( '<a class="submit-delist_theme submitdelete" title="%1$s" href="%2$s">%3$s</a>', esc_attr__( 'Delist this item', 'wporg-themes' ), esc_url( wporg_themes_get_delist_url( $post ) ), __( 'Delist', 'wporg-themes' ) ); 138 } 139 elseif ( current_user_can( 'reinstate_theme', $post->ID ) && 'delist' == $post->post_status ) { 140 $links[] = sprintf( '<a class="submit-relist_theme" title="%1$s" href="%2$s">%3$s</a>', esc_attr__( 'Relist this item', 'wporg-themes' ), esc_url( wporg_themes_get_relist_url( $post ) ), __( 'Relist', 'wporg-themes' ) ); 141 } 142 127 143 if ( ! empty( $links ) ) { 128 144 echo '<div class="misc-pub-section">' . implode( ' | ', $links ) . '</div>'; 129 145 } … … 184 200 185 201 wporg_themes_remove_wpthemescom( $post->post_name ); 186 202 187 wp_redirect( add_query_arg( 'suspended', 1, remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids', 'reinstated' ), wp_get_referer() ) ) );203 wp_redirect( add_query_arg( 'suspended', 1, remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids', 'reinstated', 'delisted', 'relisted' ), wp_get_referer() ) ) ); 188 204 exit(); 189 205 } 190 206 add_filter( 'admin_action_suspend', 'wporg_themes_suspend_theme' ); … … 227 243 */ 228 244 add_post_meta( $post_id, '_wporg_themes_reinstated', true ); 229 245 230 wp_redirect( add_query_arg( 'reinstated', 1, remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids', 'suspended' ), wp_get_referer() ) ) );246 wp_redirect( add_query_arg( 'reinstated', 1, remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids', 'suspended', 'delisted', 'relisted' ), wp_get_referer() ) ) ); 231 247 exit(); 232 248 } 233 249 add_filter( 'admin_action_reinstate', 'wporg_themes_reinstate_theme' ); 234 250 235 251 /** 252 * Action link to delist a theme. 253 * 254 * @param WP_Post $post 255 * @return string URL 256 */ 257 function wporg_themes_get_delist_url( $post ) { 258 return wp_nonce_url( add_query_arg( 'action', 'delist', admin_url( sprintf( get_post_type_object( $post->post_type )->_edit_link, $post->ID ) ) ), "delist-post_{$post->ID}" ); 259 } 260 261 /** 262 * Action link to relist a theme. 263 * 264 * @param WP_Post $post 265 * @return string URL 266 */ 267 function wporg_themes_get_relist_url( $post ) { 268 return wp_nonce_url( add_query_arg( 'action', 'relist', admin_url( sprintf( get_post_type_object( $post->post_type )->_edit_link, $post->ID ) ) ), "relist-post_{$post->ID}" ); 269 } 270 271 /** 272 * Delist a theme. 273 */ 274 function wporg_themes_delist_theme() { 275 $post_id = isset( $_GET['post'] ) ? (int) $_GET['post'] : 0; 276 277 if ( ! $post_id ) { 278 wp_redirect( admin_url( 'edit.php' ) ); 279 exit(); 280 } 281 282 check_admin_referer( 'delist-post_' . $post_id ); 283 284 $post = get_post( $post_id ); 285 286 if ( 'delist' == $post->post_status ) { 287 wp_die( __( 'This item has already been delisted.', 'wporg-themes' ) ); 288 } 289 290 if ( ! get_post_type_object( $post->post_type ) ) { 291 wp_die( __( 'Unknown post type.', 'wporg-themes' ) ); 292 } 293 294 if ( ! current_user_can( 'suspend_theme', $post_id ) || 'repopackage' != $post->post_type ) { 295 wp_die( __( 'You are not allowed to delist this item.', 'wporg-themes' ) ); 296 } 297 298 wp_update_post( array( 299 'ID' => $post_id, 300 'post_status' => 'delist', 301 ) ); 302 303 wp_redirect( add_query_arg( 'delisted', 1, remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids', 'reinstated', 'delisted', 'relisted' ), wp_get_referer() ) ) ); 304 exit(); 305 } 306 add_filter( 'admin_action_delist', 'wporg_themes_delist_theme' ); 307 308 /** 309 * Reinstate a theme. 310 */ 311 function wporg_themes_relist_theme() { 312 $post_id = isset( $_GET['post'] ) ? (int) $_GET['post'] : 0; 313 314 if ( ! $post_id ) { 315 wp_redirect( admin_url( 'edit.php' ) ); 316 exit(); 317 } 318 319 check_admin_referer( 'relist-post_' . $post_id ); 320 321 $post = get_post( $post_id ); 322 323 if ( 'delist' != $post->post_status ) { 324 wp_die( __( 'This item has already been relisted.', 'wporg-themes' ) ); 325 } 326 327 if ( ! get_post_type_object( $post->post_type ) ) { 328 wp_die( __( 'Unknown post type.', 'wporg-themes' ) ); 329 } 330 331 if ( ! current_user_can( 'reinstate_theme', $post_id ) || 'repopackage' != $post->post_type ) { 332 wp_die( __( 'You are not allowed to relist this item.', 'wporg-themes' ) ); 333 } 334 335 wp_update_post( array( 336 'ID' => $post_id, 337 'post_status' => 'publish', 338 ) ); 339 340 wp_redirect( add_query_arg( 'relisted', 1, remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids', 'suspended', 'delisted', 'relisted' ), wp_get_referer() ) ) ); 341 exit(); 342 } 343 add_filter( 'admin_action_relist', 'wporg_themes_relist_theme' ); 344 345 /** 236 346 * Remove themes from wp-themes.com upon theme status moving to draft. 237 347 * 238 348 * @param WP_Post $post … … 262 372 add_settings_error( 'wporg_themes', 'reinstated', sprintf( $message, $reinstated ), 'updated' ); 263 373 } 264 374 375 elseif ( ! empty( $_GET['delisted'] ) ) { 376 $delisted = absint( $_GET['delisted'] ); 377 $message = _n( '%s theme delisted.', '%s themes delisted.', $delisted, 'wporg-themes' ); 378 379 add_settings_error( 'wporg_themes', 'delisted', sprintf( $message, $delisted ) ); 380 } 381 elseif ( ! empty( $_GET['relisted'] ) ) { 382 $relisted = absint( $_GET['relisted'] ); 383 $message = _n( '%s theme relisted.', '%s themes relisted.', $relisted, 'wporg-themes' ); 384 385 add_settings_error( 'wporg_themes', 'relisted', sprintf( $message, $relisted ), 'updated' ); 386 } 387 265 388 // Display admin notices, if any. 266 389 settings_errors( 'wporg_themes' ); 267 390 } -
class-themes-api.php
446 446 $themes = get_posts( array( 447 447 'name' => $this->request->slug, 448 448 'post_type' => 'repopackage', 449 'post_status' => 'publish,delist', 449 450 ) ); 450 451 451 452 if ( $themes ) { -
class-wporg-themes-upload.php
487 487 * Specify post stati so this query returns a result for draft themes, even 488 488 * if the uploading user doesn't have have the permission to view drafts. 489 489 */ 490 'post_status' => array( 'publish', 'pending', 'draft', 'future', 'trash', 'suspend' ),490 'post_status' => array( 'publish', 'pending', 'draft', 'future', 'trash', 'suspend', 'delist' ), 491 491 'suppress_filters' => false, 492 492 ) ); 493 493 $theme = current( $themes ); -
query-modifications.php
38 38 $query->query_vars['post_status'] = 'publish'; 39 39 } 40 40 41 if ( !empty( $query->query_vars['name'] ) ) { 42 $query->query_vars['post_status'] = 'publish,delist'; 43 } 44 41 45 switch ( $query->query_vars['browse'] ) { 42 46 case 'new': 43 47 $query->query_vars['orderby'] = 'post_date'; -
theme-directory.php
1144 1144 $noindex = true; 1145 1145 } 1146 1146 } 1147 1148 if ( !$noindex && 'delist' === $post->post_status ) { 1149 $noindex = 'nosnippet'; 1150 } 1147 1151 } 1148 1152 1149 1153 if ( is_tag() ) { … … 1333 1337 add_filter( 'wporg_canonical_url', 'wporg_themes_canonical_url' ); 1334 1338 1335 1339 // Theme Directory doesn't support pagination. 1336 add_filter( 'wporg_rel_next_pages', '__return_zero' ); 1337 No newline at end of file 1340 add_filter( 'wporg_rel_next_pages', '__return_zero' );