Making WordPress.org


Ignore:
Timestamp:
06/14/2024 03:24:50 AM (22 months ago)
Author:
dd32
Message:

Theme Directory: Add some internal stats of actions that occur.

File:
1 edited

Legend:

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

    r13563 r13819  
    15421542    return 200 === wp_remote_retrieve_response_code( $request );
    15431543}
     1544
     1545/**
     1546 * Record some stats on theme status changes.
     1547 *
     1548 * @param string $new_status
     1549 * @param string $old_status
     1550 * @param WP_Post $post
     1551 */
     1552function wporg_themes_status_change_stats( $new_status, $old_status, $post ) {
     1553    if (
     1554        'repopackage' !== $post->post_type ||
     1555        in_array( $new_status, [ 'draft', 'auto-draft' ] ) ||
     1556        ! function_exists( 'bump_stats_extras' )
     1557    ) {
     1558        return;
     1559    }
     1560
     1561    if ( 'suspended' == $old_status && 'publish' == $new_status ) {
     1562        $stat = 'reinstated';
     1563    } elseif( 'delist' == $old_status && 'publish' == $new_status ) {
     1564        $stat = 'relisted';
     1565    } else {
     1566        $stat = $new_status;
     1567    }
     1568 
     1569    bump_stats_extras( 'themes', 'status-' . $stat );
     1570}
     1571add_action( 'transition_post_status', 'wporg_themes_status_change_stats', 10, 3 );
Note: See TracChangeset for help on using the changeset viewer.