Making WordPress.org

Changeset 12845


Ignore:
Timestamp:
08/17/2023 04:10:57 AM (10 months ago)
Author:
dd32
Message:

Theme Directory: When a theme is published, mark the GlotPress project and wp-themes.com as available.

See #7213.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/admin-edit.php

    r12601 r12845  
    193193    }
    194194    elseif ( current_user_can( 'reinstate_theme', $post->ID ) && 'suspend' == $post->post_status ) {
    195         $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' ) );
     195        $links[] = sprintf( '<a class="submit-reinstate_theme" title="%1$s" href="%2$s">%3$s</a>', esc_attr__( 'Reinstate this item', 'wporg-themes' ), esc_url( wporg_themes_get_reinstate_url( $post ) ), __( 'Reinstate', 'wporg-themes' ) );
    196196    }
    197197
     
    260260        'post_status' => 'suspend',
    261261    ) );
    262 
    263     wporg_themes_remove_wpthemescom( $post->post_name );
    264262
    265263    wp_redirect( add_query_arg( 'suspended', 1, remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids', 'reinstated', 'delisted', 'relisted' ), wp_get_referer() ) ) );
     
    404402}
    405403add_filter( 'admin_action_relist', 'wporg_themes_relist_theme' );
    406 
    407 /**
    408  * Remove themes from wp-themes.com upon theme status moving to draft.
    409  *
    410  * @param WP_Post $post
    411  */
    412 function wporg_themes_remove_draft_themes_from_wpthemescom( $post ) {
    413     if ( 'repopackage' === $post->post_type ) {
    414         wporg_themes_remove_wpthemescom( $post->post_name );
    415     }
    416 }
    417 add_action( 'publish_to_draft', 'wporg_themes_remove_draft_themes_from_wpthemescom' );
    418404
    419405/**
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r12600 r12845  
    11181118
    11191119/**
    1120  * Hooks into the Suspend process to mark a theme as inactive in GlotPress.
     1120 * Hooks into the Suspend/Draft process to mark a theme as inactive in GlotPress.
    11211121 *
    11221122 * @param int  $post_id The post ID being suspended
     
    11291129
    11301130    wporg_themes_glotpress_import( $post, 'inactive' );
     1131    wporg_themes_remove_wpthemescom( $post->post_name );
    11311132}
    11321133add_action( 'suspend_repopackage', 'wporg_themes_glotpress_mark_as_inactive_on_suspend' );
     1134add_action( 'publish_to_draft', 'wporg_themes_glotpress_mark_as_inactive_on_suspend' );
     1135
     1136/**
     1137 * Hooks into the publish process to mark a theme as active in GlotPress if it was deactivated.
     1138 *
     1139 * @param int  $post_id The post ID being published
     1140 */
     1141function wporg_themes_glotpress_mark_as_active_on_publish( $post_id ) {
     1142    $post           = get_post( $post_id );
     1143    $latest_version = array_search( 'live', $post->_status ?: [] );
     1144    if ( ! $latest_version ) {
     1145        return;
     1146    }
     1147
     1148    wporg_themes_glotpress_import( $post, $latest_version );
     1149    wporg_themes_update_wpthemescom( $post->post_name, $latest_version );
     1150}
     1151add_action( 'publish_repopackage', 'wporg_themes_glotpress_mark_as_active_on_publish' );
    11331152
    11341153/**
Note: See TracChangeset for help on using the changeset viewer.