Changeset 10468 for sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/plugins/wordpresstv-anon-upload/anon-upload.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/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.