Changeset 1724
- Timestamp:
- 07/10/2015 08:32:01 PM (11 years ago)
- Location:
- sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2
- Files:
-
- 4 edited
-
anon-upload-template.php (modified) (4 diffs)
-
functions.php (modified) (2 diffs)
-
plugins/wordpresstv-anon-upload/anon-upload.php (modified) (8 diffs)
-
sidebar-single.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/anon-upload-template.php
r1723 r1724 62 62 .video-upload p { 63 63 margin: 16px 0; 64 overflow: auto; 64 65 } 65 66 … … 174 175 case 1: 175 176 $message = 'Error: pleas select a video file.'; 177 // todo fix all the 'pleas' typos 176 178 break; 177 179 case 2: … … 202 204 case 13: 203 205 $message = "Error: please leave the first field empty. (It helps us know you're not a spammer.)"; 206 break; 207 case 14: 208 $message = "Error: please enter a valid WordPress.org username for the producer, or leave the field empty."; 204 209 break; 205 210 } … … 303 308 304 309 <p> 305 <label for="wptv_ video_producer"><?php esc_html_e( 'Video producer' ); ?></label>306 <input type="text" id="wptv_ video_producer" name="wptv_video_producer" value="" />310 <label for="wptv_producer_username"><?php esc_html_e( 'Producer WordPress.org Username' ); ?></label> 311 <input type="text" id="wptv_producer_username" name="wptv_producer_username" value="" /> 307 312 </p> 308 313 <p> -
sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/functions.php
r1712 r1724 77 77 'args' => array( 'orderby' => 'term_order' ), 78 78 'rewrite' => array( 'slug' => 'producer' ), 79 ) ); 80 81 register_taxonomy( 'producer-username', array( 'post' ), array( 82 'label' => __( 'Producer Username', 'wptv' ), 83 'template' => __( 'Producer: %l.', 'wptv' ), 84 'helps' => __( 'Separate producer usernames with commas.', 'wptv' ), 85 'sort' => true, 86 'args' => array( 'orderby' => 'term_order' ), 87 'rewrite' => array( 'slug' => 'producer-username' ), 79 88 ) ); 80 89 … … 819 828 } 820 829 add_filter( 'get_the_excerpt', 'wptv_excerpt_slides' ); 830 831 /** 832 * Checks if the given username exists on WordPress.org 833 * 834 * grav-redirect.php will redirect to a Gravatar image URL. If the WordPress.org username exists, the `d` parameter 835 * will be 'retro', and if it doesn't it'll be 'mm'. 836 * 837 * @param string $username 838 * 839 * @return bool 840 */ 841 function wporg_username_exists( $username ) { 842 $username_exists = false; 843 $validator_url = add_query_arg( 'user', $username, 'https://wordpress.org/grav-redirect.php' ); 844 $response = wp_remote_retrieve_headers( wp_remote_get( $validator_url, array( 'redirection' => 0 ) ) ); 845 846 if ( array_key_exists( 'location', $response ) ) { 847 if ( false === strpos( $response['location'], 'd=mm' ) ) { 848 $username_exists = true; 849 } 850 } 851 852 return $username_exists; 853 } -
sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/plugins/wordpresstv-anon-upload/anon-upload.php
r1650 r1724 48 48 $text_fields = array( 49 49 'wptv_video_title', 50 'wptv_ video_producer',50 'wptv_producer_username', 51 51 'wptv_speakers', 52 52 'wptv_event', … … 61 61 62 62 return $this->error( 13 ); 63 } 64 65 if ( ! empty( $_POST['wptv_producer_username'] ) && ! wporg_username_exists( $_POST['wptv_producer_username'] ) ) { 66 return $this->error( 14 ); 63 67 } 64 68 … … 260 264 261 265 $video_title = $this->sanitize_text( $_posted['wptv_video_title'] ); 262 $ video_producer = $this->sanitize_text( $_posted['wptv_video_producer'] );266 $producer_username = $this->sanitize_text( $_posted['wptv_producer_username'] ); 263 267 $speakers = $this->sanitize_text( $_posted['wptv_speakers'] ); 264 268 $event = $this->sanitize_text( $_posted['wptv_event'] ); … … 267 271 $slides = $this->sanitize_text( $_posted['wptv_slides_url'] ); 268 272 $ip = $_SERVER['REMOTE_ADDR']; 273 // todo realign in separate commit 269 274 270 275 $categories = ''; … … 283 288 'submitted_email' => $anon_author_email, 284 289 'title' => $video_title, 285 'producer ' => $video_producer,290 'producer_username' => $producer_username, 286 291 'speakers' => $speakers, 287 292 'event' => $event, … … 291 296 'slides' => $slides, 292 297 'ip' => $ip, 298 // todo realign in separate commit 293 299 ); 294 300 … … 325 331 $embed_args['post_id'] = $meta['attachment_id']; 326 332 327 // Add slides index to meta (necessary for posts that were uploaded before the field was added) 328 if ( ! array_key_exists( 'slides', $meta ) ) { 329 $meta['slides'] = ''; 333 // Add missing indexes to $meta (necessary for posts that were uploaded before the fields were added) 334 $new_fields = array( 'slides', 'producer_username' ); 335 foreach ( $new_fields as $field ) { 336 if ( ! array_key_exists( $field, $meta ) ) { 337 $meta[ $field ] = ''; 338 } 330 339 } 331 340 … … 461 470 462 471 <div class="row"> 463 <p class="label">Producer:</p> 464 <p class="data"> 465 <input type="text" value="<?php echo esc_attr( $meta['producer'] ); ?>"/> 466 <a class="button-secondary anon-approve" href="#new-tag-producer">Approve</a> 472 <p class="label">Producer WordPress.org Username:</p> 473 474 <p class="data"> 475 <input type="text" value="<?php echo esc_attr( $meta['producer_username'] ); ?>"/> 476 <a class="button-secondary anon-approve" href="#new-tag-producer-username">Approve</a> 467 477 </p> 468 478 </div> -
sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/sidebar-single.php
r1044 r1724 82 82 } 83 83 } 84 85 /* 86 * Credit video producer with link to their WordPress.org profile 87 * 88 * In most cases we'll either have the producer name, or the username, but not both. 89 */ 90 $producer_name = get_the_terms( get_the_ID(), 'producer' ); 91 $producer_username = get_the_terms( get_the_ID(), 'producer-username' ); 84 92 ?> 93 94 <?php if ( $producer_name || $producer_username ) : ?> 95 <h5>Producer</h5> 96 97 <div class="video-producer"> 98 <?php if ( $producer_username ) : ?> 99 100 <a href="<?php echo esc_url( 'https://profiles.wordpress.org/' . rawurlencode( $producer_username[0]->name ) ); ?>"> 101 <?php if ( $producer_name ) : ?> 102 <?php echo esc_html( $producer_name[0]->name ); ?> 103 <?php else : ?> 104 <?php echo esc_html( $producer_username[0]->name ); ?> 105 <?php endif; ?> 106 </a> 107 108 <?php else : ?> 109 110 <a href="<?php echo esc_url( get_term_link( $producer_name[0] ) ); ?>"> 111 <?php echo esc_html( $producer_name[0]->name ); ?> 112 </a> 113 114 <?php endif; ?> 115 </div> 116 <?php endif; ?> 117 85 118 </div><!-- .secondary-content -->
Note: See TracChangeset
for help on using the changeset viewer.