Making WordPress.org

Changeset 13563


Ignore:
Timestamp:
04/18/2024 07:02:13 AM (2 months ago)
Author:
dd32
Message:

Theme Directory: Auto-subscribe the theme author to the support threads for their theme upon approval.

Fixes #7566.

File:
1 edited

Legend:

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

    r13442 r13563  
    608608
    609609        wp_update_post( $post_args );
     610
     611        // Subscribe the author to the theme.
     612        woprg_themes_subscribe_author_to_theme_forum( get_post( $post_id ) );
    610613    }
    611614
     
    15121515}
    15131516add_filter( 'jetpack_active_modules', 'wporg_themes_jetpack_seo_enable' );
     1517
     1518/**
     1519 * Subscribe a theme author to their theme support threads upon approval.
     1520 *
     1521 * @param WP_Post $post
     1522 */
     1523function woprg_themes_subscribe_author_to_theme_forum( $post ) {
     1524    if ( ! $post || ! defined( 'PLUGIN_API_INTERNAL_BEARER_TOKEN' ) ) {
     1525        return false;
     1526    }
     1527
     1528    $request = wp_remote_post(
     1529        'https://wordpress.org/support/wp-json/wporg-support/v1/subscribe-user-to-term',
     1530        [
     1531            'body'    => [
     1532                'type'    => 'theme',
     1533                'slug'    => $post->post_name,
     1534                'user_id' => $post->post_author,
     1535            ],
     1536            'headers' => [
     1537                'Authorization' => 'Bearer ' . PLUGIN_API_INTERNAL_BEARER_TOKEN,
     1538            ],
     1539        ]
     1540    );
     1541
     1542    return 200 === wp_remote_retrieve_response_code( $request );
     1543}
Note: See TracChangeset for help on using the changeset viewer.