Changeset 10376 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/post-meta.php
- Timestamp:
- 10/13/2020 11:55:05 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-learn/inc/post-meta.php
r10272 r10376 6 6 use WP_Post; 7 7 use function WordPressdotorg\Locales\{ get_locales_with_english_names }; 8 use function WPOrg_Learn\get_views_path; 9 use function WPOrg_Learn\Form\get_workshop_application_field_schema; 8 10 9 11 defined( 'WPINC' ) || die(); … … 207 209 'side' 208 210 ); 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 ); 209 219 } 210 220 … … 219 229 $captions = get_post_meta( $post->ID, 'video_caption_language' ) ?: array(); 220 230 221 require dirname( dirname( __FILE__ ) ) . '/views/metabox-workshop-details.php';231 require get_views_path() . 'metabox-workshop-details.php'; 222 232 } 223 233 … … 230 240 $presenters = get_post_meta( $post->ID, 'presenter_wporg_username' ) ?: array(); 231 241 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 */ 250 function 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'; 233 258 } 234 259 … … 241 266 function save_workshop_metabox_fields( $post_id, WP_Post $post ) { 242 267 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' ) ) { 243 274 return; 244 275 } … … 250 281 } 251 282 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 252 294 $presenter_wporg_username = filter_input( INPUT_POST, 'presenter-wporg-username' ); 253 295 $usernames = array_map( 'trim', explode( ',', $presenter_wporg_username ) ); 254 296 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 ); 267 300 } 268 301 }
Note: See TracChangeset
for help on using the changeset viewer.