Making WordPress.org

Changeset 13819


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

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

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

Legend:

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

    r13101 r13819  
    282282        $this->version_status = 'live';
    283283
     284        if ( 'themedropbox' !== $author && function_exists( 'bump_stats_extras' ) ) {
     285            bump_stats_extras( 'themes', 'upload_from_svn' );
     286        }
     287
    284288        return $this->import( array( // return true | WP_Error
    285289            // Since this version is already in SVN, we shouldn't try to import it again.
     
    448452            $this->theme_post = $this->get_theme_post();
    449453        }
     454        $is_new_upload = empty( $this->theme_post );
     455        $is_update     = ! $is_new_upload;
    450456
    451457        // Populate author.
     
    761767        // Initiate a GitHub actions run for the theme.
    762768        $this->trigger_e2e_run();
     769
     770        // Record stats.
     771        if ( function_exists( 'bump_stats_extras' ) ) {
     772            bump_stats_extras( 'themes', $is_new_upload ? 'new' : 'update' );
     773        }
    763774
    764775        // Success!
  • 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 );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/upload.php

    r13101 r13819  
    126126    $message = $upload->process_upload( $_FILES['zip_file'] );
    127127
     128    if ( ! is_wp_error( $message ) && function_exists( 'bump_stats_extras' ) ) {
     129        bump_stats_extras( 'themes', 'upload_by_zip' );
     130    }
     131
    128132    return $message;
    129133}
Note: See TracChangeset for help on using the changeset viewer.