Making WordPress.org

Ticket #1163: 1163.patch

File 1163.patch, 3.5 KB (added by juanfra, 10 years ago)

New functions to filter the content and include links to slides and video. Markup can change. We need to define the site ID from which this feature will be enabled.

  • trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php

     
    5151
    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
    5658                add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ) );
     
    12421244        }
    12431245
    12441246        /**
     1247         * Add Slides link to Session posts
     1248         *
     1249         * We don't enable it for sites that were created before it was committed, because some will have already
     1250         * crafted the session to include this content, so duplicating it would look wrong, but we still allow older
     1251         * sites to opt-in.
     1252         *
     1253         * @param string $content
     1254         *
     1255         * @return string
     1256         */
     1257        function add_slides_info_to_session_posts( $content ) {
     1258                global $post;
     1259                $enabled_site_ids = apply_filters( 'wcpt_session_post_slides_info_enabled_site_ids', array( 364 ) );
     1260
     1261                if ( ! $this->is_single_cpt_post( 'wcb_session' ) ) {
     1262                        return $content;
     1263                }
     1264
     1265                $site_id = get_current_blog_id();
     1266                if ( $site_id <= apply_filters( 'wcpt_session_post_slides_info_min_site_id', 463 ) && ! in_array( $site_id, $enabled_site_ids ) ) {
     1267                        return $content;
     1268                }
     1269
     1270                $session_slides = get_post_meta( $post->ID, '_wcpt_session_slides', true );
     1271
     1272                if ( empty ( $session_slides ) ) {
     1273                        return $content;
     1274                }
     1275
     1276                $session_slides_html  = '<div class="session-video">';
     1277                $session_slides_html .= sprintf( __( '<a href="%s" target="_blank">View Session Slides</a>', 'wordcamporg' ), esc_url( $session_slides ) );
     1278                $session_slides_html .= '</div>';
     1279
     1280                return $content . $session_slides_html;
     1281        }
     1282
     1283        /**
     1284         * Add Video link to Session posts
     1285         *
     1286         * We don't enable it for sites that were created before it was committed, because some will have already
     1287         * crafted the session to include this content, so duplicating it would look wrong, but we still allow older
     1288         * sites to opt-in.
     1289         *
     1290         * @param string $content
     1291         *
     1292         * @return string
     1293         */
     1294        function add_video_info_to_session_posts( $content ) {
     1295                global $post;
     1296                $enabled_site_ids = apply_filters( 'wcpt_session_post_video_info_enabled_site_ids', array( 364 ) );
     1297
     1298                if ( ! $this->is_single_cpt_post( 'wcb_session' ) ) {
     1299                        return $content;
     1300                }
     1301
     1302                $site_id = get_current_blog_id();
     1303                if ( $site_id <= apply_filters( 'wcpt_session_post_video_info_min_site_id', 463 ) && ! in_array( $site_id, $enabled_site_ids ) ) {
     1304                        return $content;
     1305                }
     1306
     1307                $session_video = get_post_meta( $post->ID, '_wcpt_session_video', true );
     1308
     1309                if ( empty ( $session_video ) ) {
     1310                        return $content;
     1311                }
     1312
     1313                $session_video_html  = '<div class="session-video">';
     1314                $session_video_html .= sprintf( __( '<a href="%s" target="_blank">View Session Video</a>', 'wordcamporg' ), esc_url( $session_video ) );
     1315                $session_video_html .= '</div>';
     1316
     1317                return $content . $session_video_html;
     1318        }
     1319
     1320        /**
    12451321         * Add session information to Speaker posts
    12461322         *
    12471323         * We don't enable it for sites that were created before it was committed, because some will have already