Making WordPress.org


Ignore:
Timestamp:
05/02/2016 02:39:42 PM (10 years ago)
Author:
ocean90
Message:

Theme Directory: When updating a theme trigger an import to translate.w.org via the jobs endpoint.

Callback for the wporg_translate_import_or_update_theme hook was added in [3057].

Fixes #1685.

File:
1 edited

Legend:

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

    r3030 r3058  
    955955 */
    956956function wporg_themes_glotpress_import( $theme_post, $version ) {
     957        if ( ! defined( 'TRANSLATE_API_INTERNAL_BEARER_TOKEN' ) ) {
     958                return;
     959        }
     960
    957961        $theme_post = get_post( $theme_post );
    958962
     
    961965        }
    962966
    963         $cmd = WPORGTRANSLATE_WPCLI . ' wporg-translate set-theme-project ' . escapeshellarg( $theme_post->post_name ) . ' ' . escapeshellarg( $version );
    964 
    965         shell_exec( $cmd );
     967        wp_remote_post( 'https://translate.wordpress.org/wp-json/translate/v1/jobs', array(
     968                'body'       => json_encode(
     969                        array(
     970                                'timestamp'  => time() + 2 * 60,
     971                                'recurrence' => 'once',
     972                                'hook'       => 'wporg_translate_import_or_update_theme',
     973                                'args'       => array(
     974                                        array(
     975                                                'theme'   => $theme_post->post_name,
     976                                                'version' => $version,
     977                                        ),
     978                                ),
     979                        )
     980                ),
     981                'headers'    => array(
     982                        'Content-Type'  => 'application/json',
     983                        'Authorization' => 'Bearer ' . TRANSLATE_API_INTERNAL_BEARER_TOKEN,
     984                ),
     985                'blocking'   => false,
     986                'user-agent' => 'WordPress.org Themes Import',
     987        ) );
    966988}
    967989add_action( 'wporg_themes_update_version_live', 'wporg_themes_glotpress_import', 100, 2 );
Note: See TracChangeset for help on using the changeset viewer.