Changeset 6259
- Timestamp:
- 12/11/2017 08:57:30 PM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
r6224 r6259 1402 1402 1403 1403 /** 1404 * Retrieve the post content from an explanation post. 1405 * 1406 * @param int|WP_Post $_post Post ID or object for the function, hook, class, or method post 1407 * to retrieve an explanation field for. 1408 * @return string The post content of the explanation. 1409 */ 1410 function get_explanation_content( $_post ) { 1411 global $post; 1412 1413 // Temporarily remove filter. 1414 remove_filter( 'the_content', array( 'DevHub_Formatting', 'fix_unintended_markdown' ), 1 ); 1415 1416 // Store original global post. 1417 $orig = $post; 1418 1419 // Set global post to the explanation post. 1420 $post = get_explanation( $_post ); 1421 1422 // Get explanation's raw post content. 1423 $content = get_explanation_field( 'post_content', $_post ); 1424 1425 // Pass the content through expected content filters. 1426 $content = apply_filters( 'the_content', apply_filters( 'get_the_content', $content ) ); 1427 1428 // Restore original global post. 1429 $post = $orig; 1430 1431 // Restore filter. 1432 add_filter( 'the_content', array( 'DevHub_Formatting', 'fix_unintended_markdown' ), 1 ); 1433 1434 return $content; 1435 } 1436 1437 /** 1404 1438 * Generates a private access message for a private element. 1405 1439 * -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/reference/template-explanation.php
r6258 r6259 9 9 namespace DevHub; 10 10 11 if ( $explanation = get_explanation_ field( 'post_content',get_the_ID() ) ) :11 if ( $explanation = get_explanation_content( get_the_ID() ) ) : 12 12 ?> 13 13 <hr /> … … 15 15 <h2><?php _e( 'More Information', 'wporg' ); ?></h2> 16 16 17 <?php 18 // Output the explanation. Passed through 'the_content' on retrieval, thus no escaping. 19 remove_filter( 'the_content', array( 'DevHub_Formatting', 'fix_unintended_markdown' ), 1 ); 20 global $post; 21 $orig = $post; 22 $post = get_explanation( get_the_ID() ); 23 echo apply_filters( 'the_content', apply_filters( 'get_the_content', $explanation ) ); 24 $post = $orig; 25 add_filter( 'the_content', array( 'DevHub_Formatting', 'fix_unintended_markdown' ), 1 ); 26 ?> 17 <?php echo $explanation; // Already escaped. ?> 27 18 </section> 28 19 <?php endif; ?>
Note: See TracChangeset
for help on using the changeset viewer.