Making WordPress.org

Changeset 14465


Ignore:
Timestamp:
06/11/2025 06:39:42 AM (4 months ago)
Author:
dd32
Message:

Theme Directory: Keep track of the date an item entered it's current status.
This will help query/track how long an item has been delisted/suspended.

See #8001.

File:
1 edited

Legend:

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

    r14463 r14465  
    393393    exit;
    394394}
    395 add_action('wp_ajax_author-lookup', 'wporg_themes_author_lookup');
     395add_action( 'wp_ajax_author-lookup', 'wporg_themes_author_lookup' );
    396396
    397397
     
    15801580
    15811581/**
     1582 * Record the date a theme was put into it's current status.
     1583 *
     1584 * @param string $new_status
     1585 * @param string $old_status
     1586 * @param WP_Post $post
     1587 */
     1588function wporg_themes_status_change_metadata( $new_status, $old_status, $post ) {
     1589    $tracked_statii = [
     1590        'publish',
     1591        'suspend',
     1592        'delist',
     1593    ];
     1594
     1595    if (
     1596        'repopackage' !== $post->post_type ||
     1597        $new_status === $old_status ||
     1598        (
     1599            ! in_array( $new_status, $tracked_statii ) &&
     1600            ! in_array( $old_status, $tracked_statii )
     1601        )
     1602    ) {
     1603        return;
     1604    }
     1605
     1606    foreach ( $tracked_statii as $status ) {
     1607        delete_post_meta( $post->ID, "_{$status}_date" );
     1608    }
     1609
     1610    if ( in_array( $new_status, $tracked_statii ) ) {
     1611        update_post_meta( $post->ID, "_{$new_status}_date", current_time( 'mysql' ) );
     1612    }
     1613
     1614}
     1615add_action( 'transition_post_status', 'wporg_themes_status_change_metadata', 10, 3 );
     1616
     1617/**
    15821618 * Check if a user has any themes.
    15831619 *
     
    16121648 */
    16131649function wporg_themes_log_metadata_changes( $meta_keys ) {
     1650    // Don't keep track of the page template, we don't use that.
     1651    $meta_keys = array_diff(
     1652        $meta_keys,
     1653        array(
     1654            '_wp_page_template'
     1655        )
     1656    );
     1657
    16141658    $meta_keys[] = '_live_version';
    16151659    $meta_keys[] = 'external_support_url';
Note: See TracChangeset for help on using the changeset viewer.