Making WordPress.org

Changeset 3102


Ignore:
Timestamp:
05/09/2016 02:07:50 PM (10 years ago)
Author:
kovshenin
Message:

WordCamp.org: Display links to slides and WordPress.tv videos on session pages.

Fixes #1163
Props juanfra

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php

    r3042 r3102  
    5252        add_filter( 'the_content', array( $this, 'add_avatar_to_speaker_posts' ) );
    5353        add_filter( 'the_content', array( $this, 'add_speaker_info_to_session_posts' ) );
     54        add_filter( 'the_content', array( $this, 'add_slides_info_to_session_posts' ) );
     55        add_filter( 'the_content', array( $this, 'add_video_info_to_session_posts' ) );
    5456        add_filter( 'the_content', array( $this, 'add_session_info_to_speaker_posts' ) );
    5557
     
    12251227
    12261228        return $content . $speakers_html;
     1229    }
     1230
     1231    /**
     1232     * Add Slides link to Session posts
     1233     *
     1234     * We don't enable it for sites that were created before it was committed, because some will have already
     1235     * crafted the session to include this content, so duplicating it would look wrong, but we still allow older
     1236     * sites to opt-in.
     1237     *
     1238     * @param string $content
     1239     *
     1240     * @return string
     1241     */
     1242    function add_slides_info_to_session_posts( $content ) {
     1243        global $post;
     1244        $enabled_site_ids = apply_filters( 'wcpt_session_post_slides_info_enabled_site_ids', array( 206 ) ); // testing.wordcamp.org
     1245
     1246        if ( ! $this->is_single_cpt_post( 'wcb_session' ) ) {
     1247            return $content;
     1248        }
     1249
     1250        $site_id = get_current_blog_id();
     1251        if ( $site_id <= apply_filters( 'wcpt_session_post_slides_info_min_site_id', 699 ) && ! in_array( $site_id, $enabled_site_ids ) ) {
     1252            return $content;
     1253        }
     1254
     1255        $session_slides = get_post_meta( $post->ID, '_wcpt_session_slides', true );
     1256
     1257        if ( empty ( $session_slides ) ) {
     1258            return $content;
     1259        }
     1260
     1261        $session_slides_html  = '<div class="session-video">';
     1262        $session_slides_html .= sprintf( __( '<a href="%s" target="_blank">View Session Slides</a>', 'wordcamporg' ), esc_url( $session_slides ) );
     1263        $session_slides_html .= '</div>';
     1264
     1265        return $content . $session_slides_html;
     1266    }
     1267
     1268    /**
     1269     * Add Video link to Session posts
     1270     *
     1271     * We don't enable it for sites that were created before it was committed, because some will have already
     1272     * crafted the session to include this content, so duplicating it would look wrong, but we still allow older
     1273     * sites to opt-in.
     1274     *
     1275     * @param string $content
     1276     *
     1277     * @return string
     1278     */
     1279    function add_video_info_to_session_posts( $content ) {
     1280        global $post;
     1281        $enabled_site_ids = apply_filters( 'wcpt_session_post_video_info_enabled_site_ids', array( 206 ) ); // testing.wordcamp.org
     1282
     1283        if ( ! $this->is_single_cpt_post( 'wcb_session' ) ) {
     1284            return $content;
     1285        }
     1286
     1287        $site_id = get_current_blog_id();
     1288        if ( $site_id <= apply_filters( 'wcpt_session_post_video_info_min_site_id', 699 ) && ! in_array( $site_id, $enabled_site_ids ) ) {
     1289            return $content;
     1290        }
     1291
     1292        $session_video = get_post_meta( $post->ID, '_wcpt_session_video', true );
     1293
     1294        if ( empty ( $session_video ) ) {
     1295            return $content;
     1296        }
     1297
     1298        $session_video_html  = '<div class="session-video">';
     1299        $session_video_html .= sprintf( __( '<a href="%s" target="_blank">View Session Video</a>', 'wordcamporg' ), esc_url( $session_video ) );
     1300        $session_video_html .= '</div>';
     1301
     1302        return $content . $session_video_html;
    12271303    }
    12281304
Note: See TracChangeset for help on using the changeset viewer.