Changeset 10468
- Timestamp:
- 11/25/2020 07:28:26 AM (4 years ago)
- Location:
- sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/anon-upload-template.php
r10467 r10468 110 110 height: 150px; 111 111 overflow: auto; 112 margin-top: 4px; 112 113 } 113 114 … … 211 212 $message = "Error: please enter a valid WordPress.org username for the producer, or leave the field empty."; 212 213 break; 214 case 15: 215 $message = 'Error: form nonce was missing or invalid.'; 216 break; 213 217 } 214 218 $message = '<div class="error"><p>' . $message . '</p></div>'; 215 219 } elseif ( !empty($_REQUEST['success']) ) { 216 220 $message = '<div class="success"> <p>Thank you for submitting a video; it was uploaded successfully.</p> <p>Submit another?</p> </div>'; 221 } 222 223 $selected_cats = []; 224 if ( isset( $_GET['post_category'] ) ) { 225 // [ selected Id => 0.. ] 226 $selected_cats = array_flip( array_map( 'intval', $_GET['post_category'] ) ); 217 227 } 218 228 … … 304 314 </p> 305 315 316 <div class="location"> 317 <label for="wptv_location"><?php esc_html_e( 'Location' ); ?></label> 318 <ul class="cats-checkboxes"> 319 <?php 320 321 foreach ( get_categories( [ 322 'parent' => get_term_by( 'slug', 'location', 'category' )->term_id, 323 'hide_empty' => false, 324 ] ) as $term ) { 325 printf( 326 '<li id="category-%1$d"><label class="selectit"><input value="%1$d" type="checkbox" name="post_category[]" id="in-category-%1$d" %2$s> %3$s</label></li>', 327 $term->term_id, 328 isset( $selected_cats[ $term->term_id ] ) ? 'checked="checked" ' : '', 329 $term->name, 330 ); 331 } 332 ?> 333 </ul> 334 </div> 335 306 336 <div class="cats"> 307 337 <label for="post_category"><?php esc_html_e( 'Category' ); ?></label> 308 338 <ul class="cats-checkboxes"> 309 339 <?php 310 include_once( ABSPATH . '/wp-admin/includes/template.php' ); 311 $selected_cats = false; 312 if ( isset( $_GET['post_category'] ) ) { 313 $selected_cats = array_map( 'intval', $_GET['post_category'] ); 340 foreach ( get_categories( [ 341 'exclude_tree' => [ 342 get_term_by( 'slug', 'location', 'category' )->term_id, 343 get_term_by( 'slug', 'year', 'category' )->term_id, 344 ], 345 'parent' => 0, 346 'hide_empty' => false, 347 ] ) as $term ) { 348 printf( 349 '<li id="category-%1$d"><label class="selectit"><input value="%1$d" type="checkbox" name="post_category[]" id="in-category-%1$d" %2$s> %3$s</label></li>', 350 $term->term_id, 351 isset( $selected_cats[ $term->term_id ] ) ? 'checked="checked" ' : '', 352 $term->name, 353 ); 314 354 } 315 wp_category_checklist( 0, 0, $selected_cats, false, null, false );316 355 ?> 317 356 </ul> … … 373 412 $( 'ul.cats-checkboxes input' ).prop( 'disabled', false ); 374 413 375 $( '#wptv_video_wordcamp, ul.cats-checkboxes input' ).on( 'change', function() { 414 // Float selected items to the start. 415 $( '.location ul.cats-checkboxes, .cats ul.cats-checkboxes' ).each( function() { 416 var list = $(this), 417 selected = list.find( 'input:checked, #in-category-2648' ); // checked & World-Wide-Web 418 419 selected.each( function() { 420 var li = $(this).parents( 'li' ); 421 li.remove(); 422 list.prepend( li ); 423 } ); 424 } ); 425 426 // Generate the Event Name 427 $( '#wptv_video_wordcamp, .location ul.cats-checkboxes input, .cats ul.cats-checkboxes input, #wptv_date' ).on( 'change', function() { 376 428 if ( $( '#wptv_event' ).data('user-altered') ) { 377 429 return; … … 380 432 var title = ''; 381 433 // Get the Location 382 title += $( ' #category-6418 ul.children input:checked' ).parent().text().trim() + " ";434 title += $( '.location input:checked' ).parent().text().trim() + " "; 383 435 384 436 // .. and the Year 385 title += $( '# category-91093 ul.children input:checked' ).parent().text().trim();437 title += $( '#wptv_date' ).value.substring( 0, 4 ); 386 438 387 439 // If a location or year has been selected, build the Event Name. … … 410 462 }); 411 463 412 // Pre-select the date category. 413 $( '#wptv_date' ).on( 'change', function() { 414 var year = parseInt( this.value.substring( 0, 4 ) ); 415 416 // Blank the year selections. 417 $( '#category-91093 ul.children input' ).prop( 'checked', false ); 418 419 // Check the year 420 $( '#category-91093 ul.children input' ).filter( function() { 421 return parseInt( $(this).parent().text() ) === year; 422 } ).prop( 'checked', true ) 423 } ); 464 $( '#wptv_video_wordcamp' ).on( 'change', function() { 465 // WordCampTV cat 466 $( '#in-category-12784353' ).prop( 'checked', $( this ).prop( 'checked' ) ); 467 }); 424 468 425 469 $( '#video-upload-form' ).submit( function( e ) { -
sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/plugins/wordpresstv-anon-upload/anon-upload.php
r10467 r10468 11 11 $this->drafts_author = apply_filters( 'wptv_drafts_author_id', $this->drafts_author ); // this is filterable in order to support local development 12 12 13 add_action( 'admin_post_wptv_video_upload', array( &$this, 'init' ) );14 add_action( 'admin_post_nopriv_wptv_video_upload', array( &$this, 'init' ) );15 add_action( 'dbx_post_sidebar', array( &$this, 'display' ) );13 add_action( 'admin_post_wptv_video_upload', array( $this, 'init' ) ); 14 add_action( 'admin_post_nopriv_wptv_video_upload', array( $this, 'init' ) ); 15 add_action( 'dbx_post_sidebar', array( $this, 'display' ) ); 16 16 } 17 17 18 18 function init() { 19 if ( ! empty( $_POST['wptvvideon'] ) && wp_verify_nonce( $_POST['wptvvideon'], 'wptv-upload-video' ) ) { 19 $redir = home_url( '/submit-video/' ); 20 21 if ( 22 empty( $_POST['wptvvideon'] ) || 23 ( 24 empty( $_POST['wptv_uploaded_by'] ) && 25 ! wp_verify_nonce( $_POST['wptvvideon'], 'wptv-upload-video' ) 26 ) 27 ) { 28 $this->errors = 15; /* no-nonce / invalid nonce */ 29 } else { 20 30 $this->validate(); 21 31 … … 23 33 $this->success = $this->save(); 24 34 } 25 26 $redir = home_url( '/submit-video/' ); 27 28 // Fields to prefill 29 $keep_fields = array( 30 'wptv_video_wordcamp', 31 'wptv_uploaded_by', 32 'wptv_email', 33 'wptv_language', 34 'wptv_date', 35 'post_category', // 'wptv_categories', 36 'wptv_producer_username', 37 'wptv_event', 35 } 36 37 // Fields to prefill 38 $keep_fields = array( 39 'wptv_video_wordcamp', 40 'wptv_uploaded_by', 41 'wptv_email', 42 'wptv_language', 43 'wptv_date', 44 'post_category', // 'wptv_categories', 45 'wptv_producer_username', 46 'wptv_event', 47 ); 48 49 if ( $this->success ) { 50 $redir = add_query_arg( array( 'success' => 1 ), $redir ); 51 } elseif ( $this->errors ) { 52 $redir = add_query_arg( array( 'error' => $this->errors ), $redir ); 53 54 // Video upload failed, include the video-specific fields in pre-fill. 55 $keep_fields[] = 'wptv_video_title'; 56 $keep_fields[] = 'wptv_speakers'; 57 $keep_fields[] = 'wptv_video_description'; 58 $keep_fields[] = 'wptv_slides_url'; 59 60 } else { 61 $keep_fields = array(); 62 $redir = add_query_arg( array( 'error' => 5 ), $redir ); 63 } 64 65 // Keep some fields. 66 if ( $keep_fields ) { 67 $redir = add_query_arg( 68 urlencode_deep( 69 array_intersect_key( 70 $_POST, 71 array_flip( $keep_fields ) 72 ) 73 ), 74 $redir 38 75 ); 39 40 if ( $this->success ) { 41 $redir = add_query_arg( array( 'success' => 1 ), $redir ); 42 } elseif ( $this->errors ) { 43 $redir = add_query_arg( array( 'error' => $this->errors ), $redir ); 44 45 // Video upload failed, include the video-specific fields in pre-fill. 46 $keep_fields[] = 'wptv_video_title'; 47 $keep_fields[] = 'wptv_speakers'; 48 $keep_fields[] = 'wptv_video_description'; 49 $keep_fields[] = 'wptv_slides_url'; 50 51 } else { 52 $keep_fields = array(); 53 $redir = add_query_arg( array( 'error' => 5 ), $redir ); 54 } 55 56 // Keep some fields. 57 if ( $keep_fields ) { 58 $redir = add_query_arg( 59 urlencode_deep( 60 array_intersect_key( 61 $_POST, 62 array_flip( $keep_fields ) 63 ) 64 ), 65 $redir 66 ); 67 } 68 69 wp_redirect( $redir ); 70 } else { 71 // no nonce, send them "home"? 72 wp_redirect( home_url() ); 73 } 74 76 } 77 78 wp_redirect( $redir ); 75 79 exit; 76 80 } … … 305 309 $language = $this->sanitize_text( $_posted['wptv_language'] ); 306 310 $slides = $this->sanitize_text( $_posted['wptv_slides_url'] ); 307 $recorded = $this->sanitize_te tt( $_posted['wptv_date'] );311 $recorded = $this->sanitize_text( $_posted['wptv_date'] ); // yyyy-mm-dd 308 312 $ip = $_SERVER['REMOTE_ADDR']; 309 313 … … 315 319 $categories .= "$cat,"; 316 320 } 321 } 322 } 323 324 // Add the year category. 325 if ( $recorded ) { 326 $year = substr( $recorded, 0, 4 ); 327 if ( $term = get_term_by( 'name', $year, 'category' ) ) { 328 $categories .= $term->term_id; 317 329 } 318 330 } … … 481 493 <p class="data"> 482 494 <input type="text" value="<?php echo esc_attr( $meta['recorded'] ); ?>"/> 495 <?php 496 // Find the year cat 497 $cat = get_term_by( 'name', substr( $meta['recorded'], 0, 4 ), 'category' ); 498 if ( $cat ) { 499 echo '<a href="#in-category-' . $cat->term_id . '" class="button-secondary anon-approve anon-cat-link" title="Click to approve">Approve</a>'; 500 } 501 ?> 502 483 503 </p> 484 504 </div>
Note: See TracChangeset
for help on using the changeset viewer.