Making WordPress.org

Changeset 1044


Ignore:
Timestamp:
12/15/2014 09:32:58 PM (12 years ago)
Author:
iandunn
Message:

WordPress.tv: Add meta field for presentation slides.

Fixes #774
props BrashRebel

Location:
sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/anon-upload-template.php

    r1024 r1044  
    331331        </p>
    332332        <p>
     333                <label for="wptv_slides_url"><?php esc_html_e( 'Slides URL' ); ?></label>
     334                <input type="text" name="wptv_slides_url" id="wptv_slides_url" value="" />
     335        </p>
     336        <p>
    333337                <label for="wptv_file"><?php esc_html_e( 'Video file' ); ?><span class="required"> * </span></label>
    334338                <input type="file" name="wptv_file" id="wptv_file" />
  • sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/functions.php

    r1029 r1044  
    2828                add_action( 'init', array( $this, 'improve_search' ) );
    2929                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);
    3032                add_action( 'wp_footer', array( $this, 'videopress_flash_params' ) );
    3133                add_action( 'transition_post_status', array( $this, 'transition_post_status' ), 10, 2 );
    … …  
    150152
    151153        /**
     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        /**
    152204         * Activates the improved search, but not in admin.
    153205         */
    … …  
    176228
    177229        /**
    178          * Improved Serach: posts_search filter
     230         * Improved Search: posts_search filter
    179231         *
    180232         * Recreates the search SQL by including a taxonomy search.
    … …  
    751803}
    752804add_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 */
     813function 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 &raquo;</a></p>';
     818        }
     819
     820        return $excerpt;
     821}
     822add_filter( 'get_the_excerpt', 'wptv_excerpt_slides' );
  • sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/plugins/wordpresstv-anon-upload/anon-upload.php

    r1030 r1044  
    5151                        'wptv_speakers',
    5252                        'wptv_event',
     53                        'wptv_slides_url'
    5354                );
    5455
    … …  
    275276                $description    = $this->sanitize_text( $_posted['wptv_video_description'], false );
    276277                $language       = $this->sanitize_text( $_posted['wptv_language'] );
     278                $slides         = $this->sanitize_text( $_posted['wptv_slides_url'] );
    277279                $ip             = $_SERVER['REMOTE_ADDR'];
    278280
    … …  
    298300                        'categories'      => $categories,
    299301                        'description'     => $description,
     302                        'slides'          => $slides,
    300303                        'ip'              => $ip,
    301304                );
    … …  
    332335                $embed_args['blog_id'] = get_current_blog_id();
    333336                $embed_args['post_id'] = $meta['attachment_id'];
     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                }
    334342
    335343                ?>
    … …  
    488496
    489497                                        <div class="row">
     498                                                <p class="label">Slides:</p>
     499                                                <p class="data">
     500                                                        <input type="text" value="<?php echo esc_attr( $meta['slides'] ); ?>"/>
     501                                                        <a class="button-secondary anon-approve" href="#wptv-slides-url">Approve</a>
     502                                                </p>
     503                                        </div>
     504
     505                                        <div class="row">
    490506                                                <p class="label">Edit attachment:</p>
    491507                                                <p class="data">
    … …  
    524540                                                        el.val(target.siblings('input[type="text"]').val());
    525541                                                        el.siblings('.tagadd').click();
    526                                                 } else if (id == '#title') {
     542                                                } else if ('#title' == id  || '#wptv-slides-url' == id) {
    527543                                                        el.val(target.siblings('input[type="text"]').val());
    528544                                                } else if (id == '#excerpt') {
  • sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/sidebar-single.php

    r1024 r1044  
    55                        <p class="video-date"><?php echo get_the_date(); ?></p>
    66
    7                         <?php if ( $post->post_excerpt ) : ?>
     7                        <?php if ( get_the_excerpt() ) : ?>
    88                                <div class="video-description"><?php the_excerpt(); ?></div>
    99                        <?php
Note: See TracChangeset for help on using the changeset viewer.