- Timestamp:
- 12/15/2014 09:32:58 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/functions.php
r1029 r1044 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_boxes' ) ); 31 add_action( 'save_post', array( $this, 'save_meta_box_fields' ), 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 ); … … 150 152 151 153 /** 154 * Register meta boxes 155 */ 156 function add_meta_boxes() { 157 add_meta_box( 'video-info', 'Video Info', array( $this, 'render_video_info_metabox' ), 'post', 'normal', 'high' ); 158 } 159 160 /** 161 * Render the Video Info box 162 */ 163 function render_video_info_metabox() { 164 global $post; 165 166 $slides_url = get_post_meta( $post->ID, '_wptv_slides_url', true ); 167 wp_nonce_field( 'edit-video-info', 'video_info_metabox_nonce' ); 168 169 ?> 170 171 <p> 172 <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 ); ?>" /> 174 </p> 175 176 <?php 177 } 178 179 /** 180 * Save the values of meta box fields 181 * 182 * @param int $post_id 183 * @param WP_Post $post 184 */ 185 function save_meta_box_fields( $post_id, $post ) { 186 if ( wp_is_post_revision( $post_id ) || defined( 'DOING_AUTOSAVE' ) || ! current_user_can( 'edit_post', $post_id ) ) { 187 return; 188 } 189 190 if ( ! isset( $_POST['video_info_metabox_nonce'] ) || ! wp_verify_nonce( $_POST['video_info_metabox_nonce'], 'edit-video-info' ) ) { 191 return; 192 } 193 194 $slides_url = esc_url_raw( $_POST['_wptv_slides_url'] ); 195 196 if ( $slides_url ) { 197 update_post_meta( $post_id, '_wptv_slides_url', $slides_url ); 198 } else { 199 delete_post_meta( $post_id, '_wptv_slides_url' ); 200 } 201 } 202 203 /** 152 204 * Activates the improved search, but not in admin. 153 205 */ … … 176 228 177 229 /** 178 * Improved Se rach: posts_search filter230 * Improved Search: posts_search filter 179 231 * 180 232 * Recreates the search SQL by including a taxonomy search. … … 751 803 } 752 804 add_filter( 'wp_title', 'wptv_wp_title', 10, 2 ); 805 806 /** 807 * Append the slide URL to the excerpt 808 * 809 * @param string $excerpt 810 * 811 * @return string 812 */ 813 function wptv_excerpt_slides( $excerpt ) { 814 $slides = get_post_meta( get_the_ID(), '_wptv_slides_url', true ); 815 816 if ( ! empty( $slides ) ) { 817 $excerpt .= '<p><a href="' . esc_url( $slides ) . '">Presentation Slides »</a></p>'; 818 } 819 820 return $excerpt; 821 } 822 add_filter( 'get_the_excerpt', 'wptv_excerpt_slides' );
Note: See TracChangeset
for help on using the changeset viewer.