From de19b1c5a4324e86bc749bfd76f46233799a8faf Mon Sep 17 00:00:00 2001
From: Kyle Maurer <kyle@realbigmarketing.com>
Date: Thu, 11 Dec 2014 15:59:50 -0500
Subject: [PATCH] Added .gitignore. Also added working slides url field in a
Video Info meta box.
---
.gitignore | 3 +++
functions.php | 36 +++++++++++++++++++++++++++++++++++-
2 files changed, 38 insertions(+), 1 deletion(-)
create mode 100644 .gitignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..194e312
|
-
|
+
|
|
| | 1 | .idea/ |
| | 2 | .DS_Store |
| | 3 | i/ |
| | 4 | No newline at end of file |
diff --git a/functions.php b/functions.php
index 87cb803..38789d7 100755
|
a
|
b
|
class WordPressTV_Theme { |
| 27 | 27 | add_action( 'pre_get_posts', array( $this, 'posts_per_page' ) ); |
| 28 | 28 | add_action( 'init', array( $this, 'improve_search' ) ); |
| 29 | 29 | add_action( 'publish_post', array( $this, 'publish_post' ), 10, 1 ); |
| | 30 | add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) ); |
| | 31 | add_action( 'save_post', array( $this, 'save_slides' ), 10, 2); |
| 30 | 32 | add_action( 'wp_footer', array( $this, 'videopress_flash_params' ) ); |
| 31 | 33 | add_action( 'transition_post_status', array( $this, 'transition_post_status' ), 10, 2 ); |
| 32 | 34 | |
| … |
… |
class WordPressTV_Theme { |
| 149 | 151 | } |
| 150 | 152 | |
| 151 | 153 | /** |
| | 154 | * Adds meta box for additional video information to posts |
| | 155 | */ |
| | 156 | function add_meta_box() { |
| | 157 | add_meta_box( 'video-info', 'Video Info', array( $this, 'metabox_video_info' ), 'post', 'normal', 'high' ); |
| | 158 | } |
| | 159 | |
| | 160 | function metabox_video_info() { |
| | 161 | global $post; |
| | 162 | |
| | 163 | $slides_url = get_post_meta( $post->ID, '_wptv_slides_url', true ); |
| | 164 | wp_nonce_field( 'edit-video-info', 'wptv_slides_url' ); ?> |
| | 165 | <p> |
| | 166 | <label for="wptv-slides-url">Slides URL</label> |
| | 167 | <input type="text" class="widefat" id="wptv-slides-url" name="_wptv_slides_url" value="<?php echo esc_url( $slides_url ); ?>" /> |
| | 168 | </p> |
| | 169 | <?php |
| | 170 | } |
| | 171 | |
| | 172 | function save_slides( $post_id, $post ) { |
| | 173 | if ( wp_is_post_revision( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) |
| | 174 | return; |
| | 175 | |
| | 176 | if ( isset( $_POST['_wptv_slides_url'] ) && wp_verify_nonce( $_POST['wptv_slides_url'], 'edit-video-info' ) ) { |
| | 177 | $slides = sanitize_text_field( $_POST['_wptv_slides_url'] ); |
| | 178 | |
| | 179 | if ( ! $slides ) |
| | 180 | delete_post_meta( $post_id, '_wptv_slides_url' ); |
| | 181 | else |
| | 182 | update_post_meta( $post_id, '_wptv_slides_url', $slides ); |
| | 183 | } |
| | 184 | } |
| | 185 | /** |
| 152 | 186 | * Activates the improved search, but not in admin. |
| 153 | 187 | */ |
| 154 | 188 | function improve_search() { |
| … |
… |
class WordPressTV_Theme { |
| 175 | 209 | } |
| 176 | 210 | |
| 177 | 211 | /** |
| 178 | | * Improved Serach: posts_search filter |
| | 212 | * Improved Search: posts_search filter |
| 179 | 213 | * |
| 180 | 214 | * Recreates the search SQL by including a taxonomy search. |
| 181 | 215 | * Relies on various other filters used once. |
--
1.8.4.2
From 69c4b860f20f11c1d8ca64401d761e10569971aa Mon Sep 17 00:00:00 2001
From: Kyle Maurer <kyle@realbigmarketing.com>
Date: Thu, 11 Dec 2014 16:43:53 -0500
Subject: [PATCH] Added Link to Slides field on submit video form.
---
anon-upload-template.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/anon-upload-template.php b/anon-upload-template.php
index c1118ed..6ce125f 100755
|
a
|
b
|
if ( !empty($_REQUEST['error']) ) { |
| 330 | 330 | <textarea name="wptv_video_description" id="wptv_video_description" rows="8" cols="40"></textarea> |
| 331 | 331 | </p> |
| 332 | 332 | <p> |
| | 333 | <label for="wptv_slides_url"><?php esc_html_e( 'Link to slides' ); ?></label> |
| | 334 | <input type="text" name="wptv_slides_url" id="wptv_slides_url" value=""/> |
| | 335 | </p> |
| | 336 | <p> |
| 333 | 337 | <label for="wptv_file"><?php esc_html_e( 'Video file' ); ?><span class="required"> * </span></label> |
| 334 | 338 | <input type="file" name="wptv_file" id="wptv_file" /> |
| 335 | 339 | </p> |
--
1.8.4.2
From f393ee19015ec8ce05359f494107dbb08207b9b7 Mon Sep 17 00:00:00 2001
From: Kyle Maurer <kyle@realbigmarketing.com>
Date: Fri, 12 Dec 2014 13:06:30 -0500
Subject: [PATCH] Added slides to post.php upload form. Also had to add the
'slides' key to $meta for posts that were uploaded before the slides field
existed.
---
plugins/wordpresstv-anon-upload/anon-upload.php | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/plugins/wordpresstv-anon-upload/anon-upload.php b/plugins/wordpresstv-anon-upload/anon-upload.php
index 5c1930b..e80d776 100755
|
a
|
b
|
class WPTV_Anon_Upload { |
| 50 | 50 | 'wptv_video_producer', |
| 51 | 51 | 'wptv_speakers', |
| 52 | 52 | 'wptv_event', |
| | 53 | 'wptv_slides_url' |
| 53 | 54 | ); |
| 54 | 55 | |
| 55 | 56 | // Normal users won't see the honeypot field, so if there's a value in it, then we can assume the submission is spam from a bot |
| … |
… |
class WPTV_Anon_Upload { |
| 274 | 275 | $event = $this->sanitize_text( $_posted['wptv_event'] ); |
| 275 | 276 | $description = $this->sanitize_text( $_posted['wptv_video_description'], false ); |
| 276 | 277 | $language = $this->sanitize_text( $_posted['wptv_language'] ); |
| | 278 | $slides = $this->sanitize_text( $_posted['wptv_slides_url'] ); |
| 277 | 279 | $ip = $_SERVER['REMOTE_ADDR']; |
| 278 | 280 | |
| 279 | 281 | $categories = ''; |
| … |
… |
class WPTV_Anon_Upload { |
| 297 | 299 | 'language' => $language, |
| 298 | 300 | 'categories' => $categories, |
| 299 | 301 | 'description' => $description, |
| | 302 | 'slides' => $slides, |
| 300 | 303 | 'ip' => $ip, |
| 301 | 304 | ); |
| 302 | 305 | |
| … |
… |
class WPTV_Anon_Upload { |
| 332 | 335 | $embed_args['blog_id'] = get_current_blog_id(); |
| 333 | 336 | $embed_args['post_id'] = $meta['attachment_id']; |
| 334 | 337 | |
| | 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 | } |
| 335 | 342 | ?> |
| 336 | 343 | <div class="stuffbox" id="review-video"> |
| 337 | 344 | <style type="text/css" scoped="scoped"> |
| … |
… |
class WPTV_Anon_Upload { |
| 385 | 392 | } |
| 386 | 393 | </style> |
| 387 | 394 | <h3 class="hndle"><span>Submitted video</span></h3> |
| 388 | | |
| 389 | 395 | <div id="anon-data-wrap" class="inside"> |
| 390 | 396 | |
| 391 | 397 | <p>To change the default thumbnail image, play the video and click "Capture Thumbnail" button.</p> |
| … |
… |
class WPTV_Anon_Upload { |
| 487 | 493 | </div> |
| 488 | 494 | |
| 489 | 495 | <div class="row"> |
| | 496 | <p class="label">Slides:</p> |
| | 497 | <p class="data"> |
| | 498 | <input type="text" value="<?php echo esc_attr( $meta['slides'] ); ?>"/> |
| | 499 | <a class="button-secondary anon-approve" href="#wptv-slides-url">Approve</a> |
| | 500 | </p> |
| | 501 | </div> |
| | 502 | |
| | 503 | <div class="row"> |
| 490 | 504 | <p class="label">Edit attachment:</p> |
| 491 | 505 | <p class="data"> |
| 492 | 506 | <a href="<?php echo esc_url( get_edit_post_link( $meta['attachment_id'] ) ); ?>" target="_blank"><?php echo esc_html( $attachment_post->post_title ); ?></a> |
| … |
… |
class WPTV_Anon_Upload { |
| 525 | 539 | el.siblings('.tagadd').click(); |
| 526 | 540 | } else if (id == '#title') { |
| 527 | 541 | el.val(target.siblings('input[type="text"]').val()); |
| | 542 | } else if (id == '#wptv-slides-url') { |
| | 543 | el.val(target.siblings('input[type="text"]').val()); |
| 528 | 544 | } else if (id == '#excerpt') { |
| 529 | 545 | el.val(target.siblings('textarea').val()); |
| 530 | 546 | } else if (target.is('a.anon-cat-link')) { |
--
1.8.4.2
From 32b01a877b3b1d033cfc7fbfbd75cd8639eafc44 Mon Sep 17 00:00:00 2001
From: Kyle Maurer <kyle@realbigmarketing.com>
Date: Fri, 12 Dec 2014 13:26:01 -0500
Subject: [PATCH] Adjusted the URL escaping for the field. Appended the slides
link to the_excerpt() if it isn't empty.
---
functions.php | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/functions.php b/functions.php
index 38789d7..f24b92f 100755
|
a
|
b
|
class WordPressTV_Theme { |
| 164 | 164 | wp_nonce_field( 'edit-video-info', 'wptv_slides_url' ); ?> |
| 165 | 165 | <p> |
| 166 | 166 | <label for="wptv-slides-url">Slides URL</label> |
| 167 | | <input type="text" class="widefat" id="wptv-slides-url" name="_wptv_slides_url" value="<?php echo esc_url( $slides_url ); ?>" /> |
| | 167 | <input type="text" class="widefat" id="wptv-slides-url" name="_wptv_slides_url" value="<?php echo $slides_url; ?>" /> |
| 168 | 168 | </p> |
| 169 | 169 | <?php |
| 170 | 170 | } |
| … |
… |
class WordPressTV_Theme { |
| 174 | 174 | return; |
| 175 | 175 | |
| 176 | 176 | if ( isset( $_POST['_wptv_slides_url'] ) && wp_verify_nonce( $_POST['wptv_slides_url'], 'edit-video-info' ) ) { |
| 177 | | $slides = sanitize_text_field( $_POST['_wptv_slides_url'] ); |
| | 177 | $slides = esc_url( $_POST['_wptv_slides_url'] ); |
| 178 | 178 | |
| 179 | 179 | if ( ! $slides ) |
| 180 | 180 | delete_post_meta( $post_id, '_wptv_slides_url' ); |
| … |
… |
function wptv_wp_title( $title, $sep ) { |
| 784 | 784 | return $title; |
| 785 | 785 | } |
| 786 | 786 | add_filter( 'wp_title', 'wptv_wp_title', 10, 2 ); |
| | 787 | |
| | 788 | /** |
| | 789 | * If a slides URL has been entered, use it |
| | 790 | * |
| | 791 | * @param $excerpt |
| | 792 | * |
| | 793 | * @return string |
| | 794 | */ |
| | 795 | function wptv_excerpt_slides( $excerpt ) { |
| | 796 | $slides = get_post_meta( get_the_ID(), '_wptv_slides_url', true ); |
| | 797 | if ( ! empty( $slides ) ) { |
| | 798 | return $excerpt . '<a href="' . $slides . '" target="_blank">Presentation Slides »</a>'; |
| | 799 | } else { |
| | 800 | return $excerpt; |
| | 801 | } |
| | 802 | } |
| | 803 | add_filter( 'the_excerpt', 'wptv_excerpt_slides' ); |
| | 804 | No newline at end of file |