Making WordPress.org


Ignore:
Timestamp:
10/13/2020 11:55:05 PM (6 years ago)
Author:
coreymckrill
Message:

WordPress.org Learn: Sync with GitHub

https://github.com/WordPress/learn/compare/348e99fc763e9bd460a6446b2484312e6e5e68db...116a8706331ea044839d22347433f98af8ab8ccb

File:
1 edited

Legend:

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

    r10272 r10376  
    66use WP_Post;
    77use function WordPressdotorg\Locales\{ get_locales_with_english_names };
     8use function WPOrg_Learn\get_views_path;
     9use function WPOrg_Learn\Form\get_workshop_application_field_schema;
    810
    911defined( 'WPINC' ) || die();
     
    207209        'side'
    208210    );
     211
     212    add_meta_box(
     213        'workshop-application',
     214        __( 'Original Application', 'wporg_learn' ),
     215        __NAMESPACE__ . '\render_metabox_workshop_application',
     216        'wporg_workshop',
     217        'advanced'
     218    );
    209219}
    210220
     
    219229    $captions          = get_post_meta( $post->ID, 'video_caption_language' ) ?: array();
    220230
    221     require dirname( dirname( __FILE__ ) ) . '/views/metabox-workshop-details.php';
     231    require get_views_path() . 'metabox-workshop-details.php';
    222232}
    223233
     
    230240    $presenters = get_post_meta( $post->ID, 'presenter_wporg_username' ) ?: array();
    231241
    232     require dirname( dirname( __FILE__ ) ) . '/views/metabox-workshop-presenters.php';
     242    require get_views_path() . 'metabox-workshop-presenters.php';
     243}
     244
     245/**
     246 * Render the Original Application meta box.
     247 *
     248 * @param WP_Post $post
     249 */
     250function render_metabox_workshop_application( WP_Post $post ) {
     251    $schema = get_workshop_application_field_schema();
     252    $application = wp_parse_args(
     253        get_post_meta( $post->ID, 'original_application', true ) ?: array(),
     254        wp_list_pluck( $schema['properties'], 'default' )
     255    );
     256
     257    require get_views_path() . 'metabox-workshop-application.php';
    233258}
    234259
     
    241266function save_workshop_metabox_fields( $post_id, WP_Post $post ) {
    242267    if ( wp_is_post_revision( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) {
     268        return;
     269    }
     270
     271    // This nonce field is rendered in the Workshop Details metabox.
     272    $nonce = filter_input( INPUT_POST, 'workshop-metabox-nonce' );
     273    if ( ! wp_verify_nonce( $nonce, 'workshop-metaboxes' ) ) {
    243274        return;
    244275    }
     
    250281    }
    251282
     283    $video_language = filter_input( INPUT_POST, 'video-language' );
     284    update_post_meta( $post_id, 'video_language', $video_language );
     285
     286    $captions = filter_input( INPUT_POST, 'video-caption-language', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
     287    delete_post_meta( $post_id, 'video_caption_language' );
     288    if ( is_array( $captions ) ) {
     289        foreach ( $captions as $caption ) {
     290            add_post_meta( $post_id, 'video_caption_language', $caption );
     291        }
     292    }
     293
    252294    $presenter_wporg_username = filter_input( INPUT_POST, 'presenter-wporg-username' );
    253295    $usernames                = array_map( 'trim', explode( ',', $presenter_wporg_username ) );
    254296    delete_post_meta( $post_id, 'presenter_wporg_username' );
    255     foreach ( $usernames as $username ) {
    256         add_post_meta( $post_id, 'presenter_wporg_username', $username );
    257     }
    258 
    259     $video_language = filter_input( INPUT_POST, 'video-language' );
    260     update_post_meta( $post_id, 'video_language', $video_language );
    261 
    262     $captions = filter_input( INPUT_POST, 'video-caption-language', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
    263     if ( is_array( $captions ) ) {
    264         delete_post_meta( $post_id, 'video_caption_language' );
    265         foreach ( $captions as $caption ) {
    266             add_post_meta( $post_id, 'video_caption_language', $caption );
     297    if ( is_array( $usernames ) ) {
     298        foreach ( $usernames as $username ) {
     299            add_post_meta( $post_id, 'presenter_wporg_username', $username );
    267300        }
    268301    }
Note: See TracChangeset for help on using the changeset viewer.