Changeset 10468 for sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/anon-upload-template.php
- Timestamp:
- 11/25/2020 07:28:26 AM (4 years ago)
- File:
-
- 1 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 ) {
Note: See TracChangeset
for help on using the changeset viewer.