diff --git anon-upload-template.php anon-upload-template.php
old mode 100644
new mode 100755
index 68be0b8..af9ae0a
|
|
|
function anon_upload_css() { |
| 126 | 126 | border-color: #bbb; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | | .video-upload-left #wptv_honey_container { |
| 130 | | display: none; |
| 131 | | } |
| | 129 | .video-upload-left #wptv_honey_container { |
| | 130 | display: none; |
| | 131 | } |
| 132 | 132 | |
| 133 | 133 | #video-upload-form p.last { |
| 134 | 134 | margin: 5px 80px 25px; |
| … |
… |
function anon_upload_css() { |
| 169 | 169 | display: inline; |
| 170 | 170 | width: auto; |
| 171 | 171 | } |
| | 172 | |
| | 173 | #wptv_video_producer_username { |
| | 174 | margin: 22px 0; |
| | 175 | } |
| 172 | 176 | </style> |
| 173 | 177 | <?php |
| 174 | 178 | } |
| … |
… |
get_header(); |
| 179 | 183 | |
| 180 | 184 | $message = ''; |
| 181 | 185 | |
| 182 | | if ( !empty($_REQUEST['error']) ) { |
| | 186 | if ( !empty( $_REQUEST['error'] ) ) { |
| 183 | 187 | $message = (int) $_REQUEST['error']; |
| 184 | 188 | |
| 185 | 189 | switch ( $message ) { |
| … |
… |
if ( !empty($_REQUEST['error']) ) { |
| 214 | 218 | case 13: |
| 215 | 219 | $message = "Error: please leave the first field empty. (It helps us know you're not a spammer.)"; |
| 216 | 220 | break; |
| | 221 | case 14: |
| | 222 | $message = "Error: invalid WordPress.org username given for Producer."; |
| | 223 | break; |
| 217 | 224 | } |
| 218 | 225 | $message = '<div class="error"><p>' . $message . '</p></div>'; |
| 219 | 226 | } elseif ( !empty($_REQUEST['success']) ) { |
| … |
… |
if ( !empty($_REQUEST['error']) ) { |
| 312 | 319 | ?> |
| 313 | 320 | </ul> |
| 314 | 321 | </div> |
| 315 | | |
| 316 | 322 | <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="" /> |
| | 323 | <label for="wptv_video_producer_username"><?php esc_html_e( 'Producer WordPress.org Username' ); ?></label> |
| | 324 | <input type="text" id="wptv_video_producer_username" name="wptv_video_producer_username" value="" /> |
| 319 | 325 | </p> |
| 320 | 326 | <p> |
| 321 | 327 | <label for="wptv_speakers"><?php esc_html_e( 'Speakers' ); ?></label> |
diff --git functions.php functions.php
index 9f6d785..86abe50 100644
|
|
|
class WordPressTV_Theme { |
| 164 | 164 | global $post; |
| 165 | 165 | |
| 166 | 166 | $slides_url = get_post_meta( $post->ID, '_wptv_slides_url', true ); |
| | 167 | $producer_username = get_post_meta( $post->ID, '_wptv_producer_username', true ); |
| 167 | 168 | wp_nonce_field( 'edit-video-info', 'video_info_metabox_nonce' ); |
| 168 | 169 | |
| 169 | 170 | ?> |
| … |
… |
class WordPressTV_Theme { |
| 172 | 173 | <label for="wptv-slides-url">Slides URL</label> |
| 173 | 174 | <input type="text" class="widefat" id="wptv-slides-url" name="_wptv_slides_url" value="<?php echo esc_url( $slides_url ); ?>" /> |
| 174 | 175 | </p> |
| 175 | | |
| | 176 | <p> |
| | 177 | <label for="wptv-producer-username">Video Producer WordPress.org Username</label> |
| | 178 | <input type="text" class="widefat" id="wptv-producer-username" name="_wptv_producer_username" value="<?php echo sanitize_user( $producer_username, true ); ?>" /> |
| | 179 | </p> |
| 176 | 180 | <?php |
| 177 | 181 | } |
| 178 | 182 | |
| … |
… |
class WordPressTV_Theme { |
| 198 | 202 | } else { |
| 199 | 203 | delete_post_meta( $post_id, '_wptv_slides_url' ); |
| 200 | 204 | } |
| | 205 | |
| | 206 | $producer_username = sanitize_user( $_POST['_wptv_producer_username'], true ); |
| | 207 | |
| | 208 | if ( $producer_username ) { |
| | 209 | update_post_meta( $post_id, '_wptv_producer_username', $producer_username ); |
| | 210 | } else { |
| | 211 | delete_post_meta( $post_id, '_wptv_producer_username' ); |
| | 212 | } |
| 201 | 213 | } |
| 202 | 214 | |
| 203 | 215 | /** |
| … |
… |
function wptv_excerpt_slides( $excerpt ) { |
| 829 | 841 | return $excerpt; |
| 830 | 842 | } |
| 831 | 843 | add_filter( 'get_the_excerpt', 'wptv_excerpt_slides' ); |
| | 844 | |
| | 845 | /** |
| | 846 | * When given a string, returns boolean based on whether the string matches a valid w.org username |
| | 847 | * |
| | 848 | * @param $username |
| | 849 | * |
| | 850 | * @return bool |
| | 851 | */ |
| | 852 | function dotorg_username_exists( $username ) { |
| | 853 | $args = array( |
| | 854 | 'redirection' => 0, |
| | 855 | ); |
| | 856 | $url = 'https://wordpress.org/grav-redirect.php?user=' . $username; |
| | 857 | $response = wp_remote_get( $url, $args ); |
| | 858 | $response = wp_remote_retrieve_headers( $response ); |
| | 859 | |
| | 860 | if ( validate_username( $username ) && array_key_exists( 'location', $response ) ) { |
| | 861 | $result = ( ! strpos( $response['location'], 'd=mm' ) ) ? true : false; |
| | 862 | } else { |
| | 863 | $result = false; |
| | 864 | } |
| | 865 | return $result; |
| | 866 | } |
| | 867 | No newline at end of file |
diff --git plugins/wordpresstv-anon-upload/anon-upload.php plugins/wordpresstv-anon-upload/anon-upload.php
old mode 100644
new mode 100755
index 18bca59..c1df414
|
|
|
class WPTV_Anon_Upload { |
| 47 | 47 | function validate() { |
| 48 | 48 | $text_fields = array( |
| 49 | 49 | 'wptv_video_title', |
| 50 | | 'wptv_video_producer', |
| | 50 | 'wptv_video_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 ( isset ( $_POST['wptv_video_producer_username'] ) && dotorg_username_exists( $_POST['wptv_video_producer_username'] ) == false ) { |
| | 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 { |
| 186 | 190 | |
| 187 | 191 | if ( ! empty( $name_parts['extension'] ) ) { |
| 188 | 192 | if ( ! in_array( strtolower( $name_parts['extension'] ), array( |
| 189 | | 'avi', |
| 190 | | 'mov', |
| 191 | | 'qt', |
| 192 | | 'mpeg', |
| 193 | | 'mpg', |
| 194 | | 'mpe', |
| 195 | | 'mp4', |
| 196 | | 'm4v', |
| 197 | | 'asf', |
| 198 | | 'asx', |
| 199 | | 'wax', |
| 200 | | 'wmv', |
| 201 | | 'wmx', |
| 202 | | 'ogv', |
| 203 | | '3gp', |
| 204 | | '3g2', |
| 205 | | ), true ) |
| | 193 | 'avi', |
| | 194 | 'mov', |
| | 195 | 'qt', |
| | 196 | 'mpeg', |
| | 197 | 'mpg', |
| | 198 | 'mpe', |
| | 199 | 'mp4', |
| | 200 | 'm4v', |
| | 201 | 'asf', |
| | 202 | 'asx', |
| | 203 | 'wax', |
| | 204 | 'wmv', |
| | 205 | 'wmx', |
| | 206 | 'ogv', |
| | 207 | '3gp', |
| | 208 | '3g2', |
| | 209 | ), true ) |
| 206 | 210 | ) { |
| 207 | 211 | return $this->error( 2 ); |
| 208 | 212 | } |
| … |
… |
class WPTV_Anon_Upload { |
| 229 | 233 | // Add default cat according to the "This is a WC video" checkbox |
| 230 | 234 | if ( ! empty( $_posted['wptv_video_wordcamp'] ) ) { |
| 231 | 235 | $anon_post['post_category'] = array( '12784353' ); // add the "WordCampTV" category |
| 232 | | } |
| 233 | | else { |
| | 236 | } else { |
| 234 | 237 | $anon_post['post_category'] = array( '1' ); // Uncategorized |
| 235 | 238 | } |
| 236 | 239 | |
| … |
… |
class WPTV_Anon_Upload { |
| 269 | 272 | $anon_author_email = $this->sanitize_text( $_posted['wptv_email'] ); |
| 270 | 273 | } |
| 271 | 274 | |
| 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']; |
| | 275 | $video_title = $this->sanitize_text( $_posted['wptv_video_title'] ); |
| | 276 | $video_producer_username = $this->sanitize_text( $_posted['wptv_video_producer_username'] ); |
| | 277 | $speakers = $this->sanitize_text( $_posted['wptv_speakers'] ); |
| | 278 | $event = $this->sanitize_text( $_posted['wptv_event'] ); |
| | 279 | $description = $this->sanitize_text( $_posted['wptv_video_description'], false ); |
| | 280 | $language = $this->sanitize_text( $_posted['wptv_language'] ); |
| | 281 | $slides = $this->sanitize_text( $_posted['wptv_slides_url'] ); |
| | 282 | $ip = $_SERVER['REMOTE_ADDR']; |
| 280 | 283 | |
| 281 | 284 | $categories = ''; |
| 282 | 285 | if ( ! empty( $_posted['post_category'] ) && is_array( $_posted['post_category'] ) ) { |
| … |
… |
class WPTV_Anon_Upload { |
| 289 | 292 | } |
| 290 | 293 | |
| 291 | 294 | $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, |
| | 295 | 'attachment_id' => $attachment_id, |
| | 296 | 'submitted_by' => $anon_author, |
| | 297 | 'submitted_email' => $anon_author_email, |
| | 298 | 'title' => $video_title, |
| | 299 | 'producer_username' => $video_producer_username, |
| | 300 | 'speakers' => $speakers, |
| | 301 | 'event' => $event, |
| | 302 | 'language' => $language, |
| | 303 | 'categories' => $categories, |
| | 304 | 'description' => $description, |
| | 305 | 'slides' => $slides, |
| | 306 | 'ip' => $ip, |
| 304 | 307 | ); |
| 305 | 308 | |
| 306 | 309 | $post_meta['video_guid'] = $video_data->guid; |
| … |
… |
class WPTV_Anon_Upload { |
| 327 | 330 | |
| 328 | 331 | $attachment_post = get_post( $meta['attachment_id'] ); |
| 329 | 332 | |
| 330 | | $embed_args = array( |
| | 333 | $embed_args = array( |
| 331 | 334 | 'format' => 'fmt_std', |
| 332 | 335 | 'width' => 600, |
| 333 | 336 | 'context' => 'admin', |
| … |
… |
class WPTV_Anon_Upload { |
| 335 | 338 | $embed_args['blog_id'] = get_current_blog_id(); |
| 336 | 339 | $embed_args['post_id'] = $meta['attachment_id']; |
| 337 | 340 | |
| 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'] = ''; |
| | 341 | // Add missing indexes to meta (necessary for posts that were uploaded before the fields were added) |
| | 342 | $new_fields = array( |
| | 343 | 'slides', |
| | 344 | 'producer_username', |
| | 345 | ); |
| | 346 | foreach ( $new_fields as $field ) { |
| | 347 | if ( ! array_key_exists( $field, $meta ) ) { |
| | 348 | $meta[$field] = ''; |
| | 349 | } |
| 341 | 350 | } |
| 342 | 351 | |
| 343 | 352 | ?> |
| … |
… |
class WPTV_Anon_Upload { |
| 401 | 410 | <tr> |
| 402 | 411 | <td> |
| 403 | 412 | <?php |
| 404 | | if ( function_exists( 'video_embed' ) ) { |
| 405 | | echo video_embed( $embed_args ); |
| 406 | | } |
| | 413 | if ( function_exists( 'video_embed' ) ) { |
| | 414 | echo video_embed( $embed_args ); |
| | 415 | } |
| 407 | 416 | ?> |
| 408 | 417 | </td> |
| 409 | 418 | </tr> |
| … |
… |
class WPTV_Anon_Upload { |
| 412 | 421 | <div class="anon-data"> |
| 413 | 422 | <div class="row"> |
| 414 | 423 | <p class="label">Submitted by:<br></p> |
| | 424 | |
| 415 | 425 | <p class="data"> |
| 416 | | <input type="text" readonly="readonly" value="<?php echo esc_attr( $meta['submitted_by'] ); ?>"/> |
| | 426 | <input type="text" readonly="readonly" |
| | 427 | value="<?php echo esc_attr( $meta['submitted_by'] ); ?>"/> |
| 417 | 428 | </p> |
| 418 | 429 | </div> |
| 419 | 430 | |
| 420 | 431 | <div class="row"> |
| 421 | 432 | <p class="label">Email:</p> |
| | 433 | |
| 422 | 434 | <p class="data"> |
| 423 | 435 | <a href="mailto:<?php echo esc_attr( $meta['submitted_email'] ); ?>?Subject=Your%20WordPress.tv%20submission"><?php echo esc_html( $meta['submitted_email'] ); ?></a> |
| 424 | 436 | </p> |
| … |
… |
class WPTV_Anon_Upload { |
| 426 | 438 | |
| 427 | 439 | <div class="row"> |
| 428 | 440 | <p class="label">IP Address:</p> |
| | 441 | |
| 429 | 442 | <p class="data"> |
| 430 | | <a href="<?php echo esc_url( add_query_arg( array( 'query' => $meta['ip'] ), 'http://en.utrace.de' ) ); ?>" target="_blank"><?php echo esc_html( $meta['ip'] ); ?></a> (opens in new tab, shows location of the IP) |
| | 443 | <a href="<?php echo esc_url( add_query_arg( array( 'query' => $meta['ip'] ), 'http://en.utrace.de' ) ); ?>" |
| | 444 | target="_blank"><?php echo esc_html( $meta['ip'] ); ?></a> (opens in new tab, shows |
| | 445 | location of the IP) |
| 431 | 446 | </p> |
| 432 | 447 | </div> |
| 433 | 448 | |
| 434 | 449 | <div class="row"> |
| 435 | 450 | <p class="label">Title:</p> |
| | 451 | |
| 436 | 452 | <p class="data"> |
| 437 | 453 | <input type="text" value="<?php echo esc_attr( $meta['title'] ); ?>"/> |
| 438 | 454 | <a class="button-secondary anon-approve" href="#title">Approve</a> |
| … |
… |
class WPTV_Anon_Upload { |
| 441 | 457 | |
| 442 | 458 | <div class="row"> |
| 443 | 459 | <p class="label">Language:</p> |
| | 460 | |
| 444 | 461 | <p class="data"> |
| 445 | 462 | <input type="text" value="<?php echo esc_attr( $meta['language'] ); ?>"/> |
| 446 | 463 | <a class="button-secondary anon-approve" href="#new-tag-language">Approve</a> |
| … |
… |
class WPTV_Anon_Upload { |
| 449 | 466 | |
| 450 | 467 | <div class="row"> |
| 451 | 468 | <p class="label">Categories:</p> |
| | 469 | |
| 452 | 470 | <p class="data" id="anon-approve-cats"> |
| 453 | 471 | <?php |
| 454 | | $cats = preg_replace( '/[^0-9,]+/', '', trim( $meta['categories'], ' ,' ) ); |
| 455 | | $cats = explode( ',', $cats ); |
| 456 | | foreach ( $cats as $cat ) { |
| 457 | | if ( intval( $cat ) ) { |
| 458 | | echo '<a href="#in-category-' . $cat . '" class="anon-cat-link" title="Click to approve">Unknown?</a>, '; |
| 459 | | } |
| | 472 | $cats = preg_replace( '/[^0-9,]+/', '', trim( $meta['categories'], ' ,' ) ); |
| | 473 | $cats = explode( ',', $cats ); |
| | 474 | foreach ( $cats as $cat ) { |
| | 475 | if ( intval( $cat ) ) { |
| | 476 | echo '<a href="#in-category-' . $cat . '" class="anon-cat-link" title="Click to approve">Unknown?</a>, '; |
| 460 | 477 | } |
| | 478 | } |
| 461 | 479 | ?> |
| 462 | 480 | </p> |
| 463 | 481 | </div> |
| 464 | 482 | |
| 465 | 483 | <div class="row"> |
| 466 | 484 | <p class="label">Event:</p> |
| | 485 | |
| 467 | 486 | <p class="data"> |
| 468 | 487 | <input type="text" value="<?php echo esc_attr( $meta['event'] ); ?>"/> |
| 469 | 488 | <a class="button-secondary anon-approve" href="#new-tag-event">Approve</a> |
| … |
… |
class WPTV_Anon_Upload { |
| 471 | 490 | </div> |
| 472 | 491 | |
| 473 | 492 | <div class="row"> |
| 474 | | <p class="label">Producer:</p> |
| | 493 | <p class="label">Producer w.org Username:</p> |
| | 494 | |
| 475 | 495 | <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> |
| | 496 | <input type="text" value="<?php echo esc_attr( $meta['producer_username'] ); ?>"/> |
| | 497 | <a class="button-secondary anon-approve" href="#wptv-producer-username">Approve</a> |
| 478 | 498 | </p> |
| 479 | 499 | </div> |
| 480 | 500 | |
| 481 | 501 | <div class="row"> |
| 482 | 502 | <p class="label">Speakers:</p> |
| | 503 | |
| 483 | 504 | <p class="data"> |
| 484 | 505 | <input type="text" value="<?php echo esc_attr( $meta['speakers'] ); ?>"/> |
| 485 | 506 | <a class="button-secondary anon-approve" href="#new-tag-speakers">Approve</a> |
| … |
… |
class WPTV_Anon_Upload { |
| 488 | 509 | |
| 489 | 510 | <div class="row txtarea"> |
| 490 | 511 | <p class="label">Description:</p> |
| | 512 | |
| 491 | 513 | <p class="data"> |
| 492 | 514 | <textarea rows="10"><?php echo esc_html( $meta['description'] ); ?></textarea> |
| 493 | 515 | <a class="button-secondary anon-approve" href="#excerpt">Approve</a> |
| … |
… |
class WPTV_Anon_Upload { |
| 496 | 518 | |
| 497 | 519 | <div class="row"> |
| 498 | 520 | <p class="label">Slides:</p> |
| | 521 | |
| 499 | 522 | <p class="data"> |
| 500 | 523 | <input type="text" value="<?php echo esc_attr( $meta['slides'] ); ?>"/> |
| 501 | 524 | <a class="button-secondary anon-approve" href="#wptv-slides-url">Approve</a> |
| … |
… |
class WPTV_Anon_Upload { |
| 504 | 527 | |
| 505 | 528 | <div class="row"> |
| 506 | 529 | <p class="label">Edit attachment:</p> |
| | 530 | |
| 507 | 531 | <p class="data"> |
| 508 | | <a href="<?php echo esc_url( get_edit_post_link( $meta['attachment_id'] ) ); ?>" target="_blank"><?php echo esc_html( $attachment_post->post_title ); ?></a> |
| | 532 | <a href="<?php echo esc_url( get_edit_post_link( $meta['attachment_id'] ) ); ?>" |
| | 533 | target="_blank"><?php echo esc_html( $attachment_post->post_title ); ?></a> |
| 509 | 534 | </p> |
| 510 | 535 | </div> |
| 511 | 536 | </div> |
| … |
… |
class WPTV_Anon_Upload { |
| 539 | 564 | if (id.indexOf('#new-tag-') != -1) { |
| 540 | 565 | el.val(target.siblings('input[type="text"]').val()); |
| 541 | 566 | el.siblings('.tagadd').click(); |
| 542 | | } else if ('#title' == id || '#wptv-slides-url' == id) { |
| | 567 | } else if ('#title' == id || '#wptv-producer-username' == id) { |
| | 568 | el.val(target.siblings('input[type="text"]').val()); |
| | 569 | } else if ('#title' == id || '#wptv-slides-url' == id) { |
| 543 | 570 | el.val(target.siblings('input[type="text"]').val()); |
| 544 | 571 | } else if (id == '#excerpt') { |
| 545 | 572 | el.val(target.siblings('textarea').val()); |
diff --git sidebar-single.php sidebar-single.php
old mode 100644
new mode 100755
index 84a2fe6..14527a9
|
|
|
|
| 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 | | ?> |
| | 84 | |
| | 85 | // Credit video producer with link to their w.org profile |
| | 86 | $producer_username = get_post_meta( get_the_ID(), '_wptv_producer_username', true ); |
| | 87 | $producer_name = ( get_the_terms( get_the_ID(), 'producer' ) ) ? get_the_terms( get_the_ID(), 'producer' )[0]->name : $producer_username; |
| | 88 | |
| | 89 | if ( $producer_username ) { ?> |
| | 90 | <h5>Producer</h5> |
| | 91 | <div class="video-producer"> |
| | 92 | <a href="http://profiles.wordpress.org/<?php esc_attr_e( $producer_username ); ?>"><?php esc_attr_e( $producer_name ); ?></a> |
| | 93 | </div> |
| | 94 | <?php } ?> |
| | 95 | |
| 85 | 96 | </div><!-- .secondary-content --> |