diff --git anon-upload-template.php anon-upload-template.php
index 68be0b8..949d4b9 100644
|
|
|
function anon_upload_css() { |
| 61 | 61 | |
| 62 | 62 | .video-upload p { |
| 63 | 63 | margin: 16px 0; |
| | 64 | overflow: auto; |
| 64 | 65 | } |
| 65 | 66 | |
| 66 | 67 | .video-upload h3 { |
| … |
… |
if ( !empty($_REQUEST['error']) ) { |
| 214 | 215 | case 13: |
| 215 | 216 | $message = "Error: please leave the first field empty. (It helps us know you're not a spammer.)"; |
| 216 | 217 | break; |
| | 218 | case 14: |
| | 219 | $message = "Error: please enter a valid WordPress.org username for the producer, or leave the field empty."; |
| | 220 | break; |
| 217 | 221 | } |
| 218 | 222 | $message = '<div class="error"><p>' . $message . '</p></div>'; |
| 219 | 223 | } elseif ( !empty($_REQUEST['success']) ) { |
| … |
… |
if ( !empty($_REQUEST['error']) ) { |
| 314 | 318 | </div> |
| 315 | 319 | |
| 316 | 320 | <p> |
| 317 | | <label for="wptv_video_producer"><?php esc_html_e( 'Video producer' ); ?></label> |
| 318 | | <input type="text" id="wptv_video_producer" name="wptv_video_producer" value="" /> |
| | 321 | <label for="wptv_producer_username"><?php esc_html_e( 'Producer WordPress.org Username' ); ?></label> |
| | 322 | <input type="text" id="wptv_producer_username" name="wptv_producer_username" value="" /> |
| 319 | 323 | </p> |
| 320 | 324 | <p> |
| 321 | 325 | <label for="wptv_speakers"><?php esc_html_e( 'Speakers' ); ?></label> |
diff --git functions.php functions.php
index 9f6d785..7007f48 100644
|
|
|
class WordPressTV_Theme { |
| 28 | 28 | add_action( 'init', array( $this, 'improve_search' ) ); |
| 29 | 29 | add_action( 'publish_post', array( $this, 'publish_post' ), 10, 1 ); |
| 30 | 30 | add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); |
| 31 | | add_action( 'save_post', array( $this, 'save_meta_box_fields' ), 10, 2); |
| | 31 | add_action( 'save_post', array( $this, 'save_meta_box_fields' ), 10, 2 ); |
| 32 | 32 | add_action( 'wp_footer', array( $this, 'videopress_flash_params' ) ); |
| 33 | 33 | add_action( 'transition_post_status', array( $this, 'transition_post_status' ), 10, 2 ); |
| 34 | 34 | |
| … |
… |
class WordPressTV_Theme { |
| 78 | 78 | 'rewrite' => array( 'slug' => 'producer' ), |
| 79 | 79 | ) ); |
| 80 | 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' ), |
| | 88 | ) ); |
| | 89 | |
| 81 | 90 | register_taxonomy( 'speakers', array( 'post' ), array( |
| 82 | 91 | 'label' => __( 'Speakers', 'wptv' ), |
| 83 | 92 | 'template' => __( 'Speakers: %l.', 'wptv' ), |
| … |
… |
class WordPressTV_Theme { |
| 154 | 163 | * Register meta boxes |
| 155 | 164 | */ |
| 156 | 165 | function add_meta_boxes() { |
| 157 | | add_meta_box( 'video-info', 'Video Info', array( $this, 'render_video_info_metabox' ), 'post', 'normal', 'high' ); |
| | 166 | add_meta_box( 'video-info', 'Video Info', array( |
| | 167 | $this, |
| | 168 | 'render_video_info_metabox' |
| | 169 | ), 'post', 'normal', 'high' ); |
| 158 | 170 | } |
| 159 | 171 | |
| 160 | 172 | /** |
| … |
… |
class WordPressTV_Theme { |
| 170 | 182 | |
| 171 | 183 | <p> |
| 172 | 184 | <label for="wptv-slides-url">Slides URL</label> |
| 173 | | <input type="text" class="widefat" id="wptv-slides-url" name="_wptv_slides_url" value="<?php echo esc_url( $slides_url ); ?>" /> |
| | 185 | <input type="text" class="widefat" id="wptv-slides-url" name="_wptv_slides_url" |
| | 186 | value="<?php echo esc_url( $slides_url ); ?>"/> |
| 174 | 187 | </p> |
| 175 | | |
| 176 | | <?php |
| | 188 | <?php |
| 177 | 189 | } |
| 178 | 190 | |
| 179 | 191 | /** |
| … |
… |
class WordPressTV_Theme { |
| 226 | 238 | * |
| 227 | 239 | * Maybe look at ways to do the sorting in PHP, or just use Elasticsearch instead. |
| 228 | 240 | */ |
| | 241 | |
| 229 | 242 | return; |
| 230 | 243 | |
| 231 | 244 | if ( ! $query->is_main_query() || ! $query->is_search ) { |
| … |
… |
class WordPressTV_Theme { |
| 405 | 418 | <?php if ( $comment->comment_type != 'pingback' ) : ?> |
| 406 | 419 | |
| 407 | 420 | <small class="commentmetadata"> |
| 408 | | <a href="#comment-<?php comment_ID() ?>" title=""><?php printf( __( '%1$s at %2$s', 'wptv' ), get_comment_date(), get_comment_time() ); ?></a> |
| | 421 | <a href="#comment-<?php comment_ID() ?>" |
| | 422 | title=""><?php printf( __( '%1$s at %2$s', 'wptv' ), get_comment_date(), get_comment_time() ); ?></a> |
| 409 | 423 | <?php |
| 410 | | edit_comment_link( __( 'edit', 'wptv' ), ' ', '' ); |
| 411 | | echo comment_reply_link( array( |
| 412 | | 'depth' => $depth, |
| 413 | | 'max_depth' => $args['max_depth'], |
| 414 | | 'before' => ' | ', |
| 415 | | ) ); |
| | 424 | edit_comment_link( __( 'edit', 'wptv' ), ' ', '' ); |
| | 425 | echo comment_reply_link( array( |
| | 426 | 'depth' => $depth, |
| | 427 | 'max_depth' => $args['max_depth'], |
| | 428 | 'before' => ' | ', |
| | 429 | ) ); |
| 416 | 430 | ?> |
| 417 | 431 | </small> |
| 418 | 432 | |
| … |
… |
class WordPressTV_Theme { |
| 514 | 528 | foreach ( $matches[1] as $key => $code ) { |
| 515 | 529 | $code = '[vodpod ' . $code . ']'; |
| 516 | 530 | $vodpod = apply_filters( 'the_content', $code ); |
| 517 | | $id = trim( str_replace( '</div>','', preg_replace( '/.*key\=([^&]+)&.*/', '$1', $vodpod ) ) ); |
| | 531 | $id = trim( str_replace( '</div>', '', preg_replace( '/.*key\=([^&]+)&.*/', '$1', $vodpod ) ) ); |
| 518 | 532 | |
| 519 | 533 | $image = $this->get_vodpod_thumbnails( $code ); |
| 520 | 534 | $video = $vodpod; |
| … |
… |
class WordPressTV_Theme { |
| 548 | 562 | foreach ( $matches[1] as $key => $code ) { |
| 549 | 563 | preg_match( '/([0-9A-Za-z]+)/i', $code, $m ); |
| 550 | 564 | $guid = $m[1]; |
| 551 | | $ret = video_image_url_by_guid( $guid, 'fmt_dvd' ); |
| | 565 | $ret = video_image_url_by_guid( $guid, 'fmt_dvd' ); |
| 552 | 566 | } |
| 553 | 567 | |
| 554 | 568 | preg_match_all( '|\[wporg-screencast (.+?)]|ie', $post->post_content, $matches ); |
| … |
… |
class WordCampTV_Walker_Nav_Menu extends Walker { |
| 745 | 759 | <div> |
| 746 | 760 | <h3> |
| 747 | 761 | <?php echo apply_filters( 'the_title', $item->title ); ?> |
| 748 | | <a href="<?php echo esc_url( $item->url ); ?>" class="view-more"><?php esc_html_e( 'More →' ); ?></a> |
| | 762 | <a href="<?php echo esc_url( $item->url ); ?>" |
| | 763 | class="view-more"><?php esc_html_e( 'More →' ); ?></a> |
| 749 | 764 | </h3> |
| 750 | 765 | <ul class="video-list four-col"> |
| 751 | 766 | <?php while ( $query->have_posts() ) : $query->the_post(); ?> |
| 752 | | <li> |
| 753 | | <a href="<?php the_permalink(); ?>"> |
| 754 | | <span class="video-thumbnail"><?php $wptv->the_video_image( 50, null, false ); ?></span> |
| 755 | | <span class="video-title"><?php the_title(); ?></span> |
| 756 | | </a> |
| 757 | | </li> |
| | 767 | <li> |
| | 768 | <a href="<?php the_permalink(); ?>"> |
| | 769 | <span class="video-thumbnail"><?php $wptv->the_video_image( 50, null, false ); ?></span> |
| | 770 | <span class="video-title"><?php the_title(); ?></span> |
| | 771 | </a> |
| | 772 | </li> |
| 758 | 773 | <?php endwhile; ?> |
| 759 | 774 | </ul> |
| 760 | 775 | </div> |
| … |
… |
function wptv_enqueue_scripts() { |
| 776 | 791 | wp_enqueue_script( 'comment-reply' ); |
| 777 | 792 | } |
| 778 | 793 | } |
| | 794 | |
| 779 | 795 | add_action( 'wp_enqueue_scripts', 'wptv_enqueue_scripts' ); |
| 780 | 796 | |
| 781 | 797 | /** |
| … |
… |
function wptv_wp_title( $title, $sep ) { |
| 810 | 826 | |
| 811 | 827 | return $title; |
| 812 | 828 | } |
| | 829 | |
| 813 | 830 | add_filter( 'wp_title', 'wptv_wp_title', 10, 2 ); |
| 814 | 831 | |
| 815 | 832 | /** |
| … |
… |
function wptv_excerpt_slides( $excerpt ) { |
| 828 | 845 | |
| 829 | 846 | return $excerpt; |
| 830 | 847 | } |
| | 848 | |
| 831 | 849 | add_filter( 'get_the_excerpt', 'wptv_excerpt_slides' ); |
| | 850 | |
| | 851 | /** |
| | 852 | * Checks if the given username exists on WordPress.org |
| | 853 | * |
| | 854 | * grav-redirect.php will redirect to a Gravatar image URL. If the WordPress.org username exists, the `d` parameter |
| | 855 | * will be 'retro', and if it doesn't it'll be 'mm'. |
| | 856 | * |
| | 857 | * @param string $username |
| | 858 | * |
| | 859 | * @return bool |
| | 860 | */ |
| | 861 | function wporg_username_exists( $username ) { |
| | 862 | $username_exists = false; |
| | 863 | $validator_url = add_query_arg( 'user', $username, 'https://wordpress.org/grav-redirect.php' ); |
| | 864 | $response = wp_remote_retrieve_headers( wp_remote_get( $validator_url, array( 'redirection' => 0 ) ) ); |
| | 865 | |
| | 866 | if ( array_key_exists( 'location', $response ) ) { |
| | 867 | if ( false === strpos( $response['location'], 'd=mm' ) ) { |
| | 868 | $username_exists = true; |
| | 869 | } |
| | 870 | } |
| | 871 | |
| | 872 | return $username_exists; |
| | 873 | } |
diff --git plugins/wordpresstv-anon-upload/anon-upload.php plugins/wordpresstv-anon-upload/anon-upload.php
index 18bca59..92390e0 100644
|
|
|
class WPTV_Anon_Upload { |
| 47 | 47 | function validate() { |
| 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', |
| 53 | 53 | 'wptv_slides_url' |
| … |
… |
class WPTV_Anon_Upload { |
| 62 | 62 | return $this->error( 13 ); |
| 63 | 63 | } |
| 64 | 64 | |
| | 65 | if ( empty( $_POST['wptv_producer_username'] ) || ! wporg_username_exists( $_POST['wptv_producer_username'] ) ) { |
| | 66 | return $this->error( 14 ); |
| | 67 | } |
| | 68 | |
| 65 | 69 | if ( ! is_user_logged_in() ) { |
| 66 | 70 | if ( empty( $_POST['wptv_uploaded_by'] ) ) { |
| 67 | 71 | return $this->error( 10 ); |
| … |
… |
class WPTV_Anon_Upload { |
| 269 | 273 | $anon_author_email = $this->sanitize_text( $_posted['wptv_email'] ); |
| 270 | 274 | } |
| 271 | 275 | |
| 272 | | $video_title = $this->sanitize_text( $_posted['wptv_video_title'] ); |
| 273 | | $video_producer = $this->sanitize_text( $_posted['wptv_video_producer'] ); |
| 274 | | $speakers = $this->sanitize_text( $_posted['wptv_speakers'] ); |
| 275 | | $event = $this->sanitize_text( $_posted['wptv_event'] ); |
| 276 | | $description = $this->sanitize_text( $_posted['wptv_video_description'], false ); |
| 277 | | $language = $this->sanitize_text( $_posted['wptv_language'] ); |
| 278 | | $slides = $this->sanitize_text( $_posted['wptv_slides_url'] ); |
| 279 | | $ip = $_SERVER['REMOTE_ADDR']; |
| | 276 | $video_title = $this->sanitize_text( $_posted['wptv_video_title'] ); |
| | 277 | $producer_username = $this->sanitize_text( $_posted['wptv_producer_username'] ); |
| | 278 | $speakers = $this->sanitize_text( $_posted['wptv_speakers'] ); |
| | 279 | $event = $this->sanitize_text( $_posted['wptv_event'] ); |
| | 280 | $description = $this->sanitize_text( $_posted['wptv_video_description'], false ); |
| | 281 | $language = $this->sanitize_text( $_posted['wptv_language'] ); |
| | 282 | $slides = $this->sanitize_text( $_posted['wptv_slides_url'] ); |
| | 283 | $ip = $_SERVER['REMOTE_ADDR']; |
| 280 | 284 | |
| 281 | 285 | $categories = ''; |
| 282 | 286 | if ( ! empty( $_posted['post_category'] ) && is_array( $_posted['post_category'] ) ) { |
| … |
… |
class WPTV_Anon_Upload { |
| 289 | 293 | } |
| 290 | 294 | |
| 291 | 295 | $post_meta = array( |
| 292 | | 'attachment_id' => $attachment_id, |
| 293 | | 'submitted_by' => $anon_author, |
| 294 | | 'submitted_email' => $anon_author_email, |
| 295 | | 'title' => $video_title, |
| 296 | | 'producer' => $video_producer, |
| 297 | | 'speakers' => $speakers, |
| 298 | | 'event' => $event, |
| 299 | | 'language' => $language, |
| 300 | | 'categories' => $categories, |
| 301 | | 'description' => $description, |
| 302 | | 'slides' => $slides, |
| 303 | | 'ip' => $ip, |
| | 296 | 'attachment_id' => $attachment_id, |
| | 297 | 'submitted_by' => $anon_author, |
| | 298 | 'submitted_email' => $anon_author_email, |
| | 299 | 'title' => $video_title, |
| | 300 | 'producer_username' => $producer_username, |
| | 301 | 'speakers' => $speakers, |
| | 302 | 'event' => $event, |
| | 303 | 'language' => $language, |
| | 304 | 'categories' => $categories, |
| | 305 | 'description' => $description, |
| | 306 | 'slides' => $slides, |
| | 307 | 'ip' => $ip, |
| 304 | 308 | ); |
| 305 | 309 | |
| 306 | 310 | $post_meta['video_guid'] = $video_data->guid; |
| … |
… |
class WPTV_Anon_Upload { |
| 335 | 339 | $embed_args['blog_id'] = get_current_blog_id(); |
| 336 | 340 | $embed_args['post_id'] = $meta['attachment_id']; |
| 337 | 341 | |
| 338 | | // Add slides index to meta (necessary for posts that were uploaded before the field was added) |
| 339 | | if ( ! array_key_exists( 'slides', $meta ) ) { |
| 340 | | $meta['slides'] = ''; |
| | 342 | // Add missing indexes to $meta (necessary for posts that were uploaded before the fields were added) |
| | 343 | $new_fields = array( 'slides', 'producer_username' ); |
| | 344 | foreach ( $new_fields as $field ) { |
| | 345 | if ( ! array_key_exists( $field, $meta ) ) { |
| | 346 | $meta[ $field ] = ''; |
| | 347 | } |
| 341 | 348 | } |
| 342 | 349 | |
| 343 | 350 | ?> |
| … |
… |
class WPTV_Anon_Upload { |
| 471 | 478 | </div> |
| 472 | 479 | |
| 473 | 480 | <div class="row"> |
| 474 | | <p class="label">Producer:</p> |
| | 481 | <p class="label">Producer WordPress.org Username:</p> |
| | 482 | |
| 475 | 483 | <p class="data"> |
| 476 | | <input type="text" value="<?php echo esc_attr( $meta['producer'] ); ?>"/> |
| 477 | | <a class="button-secondary anon-approve" href="#new-tag-producer">Approve</a> |
| | 484 | <input type="text" value="<?php echo esc_attr( $meta['producer_username'] ); ?>"/> |
| | 485 | <a class="button-secondary anon-approve" href="#new-tag-producer-username">Approve</a> |
| 478 | 486 | </p> |
| 479 | 487 | </div> |
| 480 | 488 | |
diff --git sidebar-single.php sidebar-single.php
index 84a2fe6..deb288d 100644
|
|
|
|
| 81 | 81 | printf( '<a href="%s">Subtitle this video →</a>', esc_url( add_query_arg( 'video', $video->post_id, home_url( 'subtitle/' ) ) ) ); |
| 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_username = get_the_terms( get_the_ID(), 'producer-username' ); |
| | 91 | $producer_name = get_the_terms( get_the_ID(), 'producer' ); |
| 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 && $producer_name ) : ?> |
| | 99 | <?php $producer_username = $producer_username[0]->name; ?> |
| | 100 | <a href="<?php echo esc_url( 'https://profiles.wordpress.org/' . rawurlencode( $producer_username ) ); ?>"> |
| | 101 | <?php echo esc_html( $producer_name[0]->name ); ?> |
| | 102 | </a> |
| | 103 | |
| | 104 | <?php elseif ( $producer_username ) : ?> |
| | 105 | |
| | 106 | <?php $producer_username = $producer_username[0]->name; ?> |
| | 107 | <a href="<?php echo esc_url( 'https://profiles.wordpress.org/' . rawurlencode( $producer_username ) ); ?>"> |
| | 108 | <?php echo esc_html( $producer_username ); ?> |
| | 109 | </a> |
| | 110 | |
| | 111 | <?php else : ?> |
| | 112 | |
| | 113 | <a href="<?php echo esc_url( get_term_link( $producer_name[0] ) ); ?>"> |
| | 114 | <?php echo esc_html( $producer_name[0]->name ); ?> |
| | 115 | </a> |
| | 116 | |
| | 117 | <?php endif; ?> |
| | 118 | </div> |
| | 119 | <?php endif; ?> |
| | 120 | |
| 85 | 121 | </div><!-- .secondary-content --> |