Making WordPress.org


Ignore:
Timestamp:
10/12/2021 10:22:24 PM (4 years ago)
Author:
coreymckrill
Message:

WordPress.org Learn: Sync with GitHub

Props psrpinto, ashfame

https://github.com/WordPress/learn/compare/c77e29cfdefc2b3ed6da22d1d363816073ba0afd...bf713ca73b711629febd561298510997ffc2cece

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/post-meta.php

    r11225 r11275  
    9898        array(
    9999            'description'       => __( 'The WordPress.org user name of a presenter for this workshop.', 'wporg_learn' ),
     100            'type'              => 'string',
     101            'single'            => false,
     102            'sanitize_callback' => 'sanitize_user',
     103            'show_in_rest'      => true,
     104        )
     105    );
     106
     107    register_post_meta(
     108        $post_type,
     109        'other_contributor_wporg_username',
     110        array(
     111            'description'       => __( 'The WordPress.org user name of "other contributor" for this workshop.', 'wporg_learn' ),
    100112            'type'              => 'string',
    101113            'single'            => false,
     
    356368
    357369    add_meta_box(
     370        'workshop-other-contributors',
     371        __( 'Other Contributors', 'wporg_learn' ),
     372        __NAMESPACE__ . '\render_metabox_workshop_other_contributors',
     373        'wporg_workshop',
     374        'side'
     375    );
     376
     377    add_meta_box(
    358378        'workshop-application',
    359379        __( 'Original Application', 'wporg_learn' ),
     
    396416
    397417/**
     418 * Render the Other Contributors meta box.
     419 *
     420 * @param WP_Post $post
     421 */
     422function render_metabox_workshop_other_contributors( WP_Post $post ) {
     423    $other_contributors = get_post_meta( $post->ID, 'other_contributor_wporg_username' ) ?: array();
     424
     425    require get_views_path() . 'metabox-workshop-other-contributors.php';
     426}
     427
     428/**
    398429 * Render the Original Application meta box.
    399430 *
     
    450481
    451482    $presenter_wporg_username = filter_input( INPUT_POST, 'presenter-wporg-username' );
    452     $usernames                = array_map( 'trim', explode( ',', $presenter_wporg_username ) );
     483    $presenter_usernames      = array_map( 'trim', explode( ',', $presenter_wporg_username ) );
    453484    delete_post_meta( $post_id, 'presenter_wporg_username' );
    454     if ( is_array( $usernames ) ) {
    455         foreach ( $usernames as $username ) {
     485    if ( is_array( $presenter_usernames ) ) {
     486        foreach ( $presenter_usernames as $username ) {
    456487            add_post_meta( $post_id, 'presenter_wporg_username', $username );
     488        }
     489    }
     490
     491    $other_contributor_wporg_username = filter_input( INPUT_POST, 'other-contributor-wporg-username' );
     492    $other_contributor_usernames      = array_map( 'trim', explode( ',', $other_contributor_wporg_username ) );
     493    delete_post_meta( $post_id, 'other_contributor_wporg_username' );
     494    if ( is_array( $other_contributor_usernames ) ) {
     495        foreach ( $other_contributor_usernames as $username ) {
     496            add_post_meta( $post_id, 'other_contributor_wporg_username', $username );
    457497        }
    458498    }
Note: See TracChangeset for help on using the changeset viewer.