diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/explanations.php wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/explanations.php
index 12b53083b..427dcbf9d 100644
|
|
|
class WPORG_Explanations { |
| 60 | 60 | // Output checkmark in explanations column if post has an explanation. |
| 61 | 61 | add_action( 'manage_posts_custom_column', array( $this, 'handle_column_data' ), 10, 2 ); |
| 62 | 62 | |
| | 63 | add_filter( 'preview_post_link', array ( $this, 'preview_post_link' ), 10, 2 ); |
| | 64 | |
| 63 | 65 | // Permissions. |
| 64 | 66 | add_action( 'after_switch_theme', array( $this, 'add_roles' ) ); |
| 65 | 67 | add_filter( 'user_has_cap', array( $this, 'grant_caps' ) ); |
| … |
… |
class WPORG_Explanations { |
| 92 | 94 | 'not_found_in_trash' => __( 'No Explanations found in trash', 'wporg' ), |
| 93 | 95 | ), |
| 94 | 96 | 'public' => false, |
| | 97 | 'publicly_queryable'=> true, |
| 95 | 98 | 'hierarchical' => false, |
| 96 | 99 | 'show_ui' => true, |
| 97 | 100 | 'show_in_menu' => true, |
| … |
… |
class WPORG_Explanations { |
| 117 | 120 | } |
| 118 | 121 | } |
| 119 | 122 | |
| | 123 | /** |
| | 124 | * Catch and complement preview post links from 'explanation' post types, |
| | 125 | * divert them to their parent Function/Hook/etc. post preview with extra |
| | 126 | * query parameters to override the respective section with the user's edits. |
| | 127 | * |
| | 128 | * @param string $preview_link The preview URL as generated by a previous internal call to get_preview_post_link |
| | 129 | * @param WP_Post $post Current post object. |
| | 130 | * |
| | 131 | * @see 'preview_post_link' filter |
| | 132 | * @access public |
| | 133 | * @return string |
| | 134 | **/ |
| | 135 | public function preview_post_link( $preview_link, $post ) { |
| | 136 | if ( $this->exp_post_type != $post->post_type ) { |
| | 137 | return $preview_link; |
| | 138 | } |
| | 139 | |
| | 140 | if ( false !== strpos( $preview_link, 'preview_nonce=' ) ) { |
| | 141 | $url = parse_url( $preview_link ); |
| | 142 | $url_query = array(); |
| | 143 | parse_str ( $url['query'], $url_query ); |
| | 144 | |
| | 145 | return get_preview_post_link( |
| | 146 | $post->post_parent, |
| | 147 | array( |
| | 148 | 'wporg_explanations_preview_id' => $url_query['preview_id'], |
| | 149 | 'wporg_explanations_preview_nonce' => $url_query['preview_nonce'], |
| | 150 | ) |
| | 151 | ); |
| | 152 | } |
| | 153 | |
| | 154 | return $preview_link; |
| | 155 | } |
| | 156 | |
| 120 | 157 | /** |
| 121 | 158 | * Customizes admin menu. |
| 122 | 159 | * |
diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php
index 559308ae2..c7b05c6e5 100644
|
|
|
namespace DevHub { |
| 1681 | 1681 | $post = get_explanation( $_post ); |
| 1682 | 1682 | |
| 1683 | 1683 | // Get explanation's raw post content. |
| 1684 | | $content = get_explanation_field( 'post_content', $_post ); |
| | 1684 | if ( !empty( $_GET['wporg_explanations_preview_nonce'] ) |
| | 1685 | && false !== wp_verify_nonce( $_GET['wporg_explanations_preview_nonce'], 'post_preview_' . $post->ID ) |
| | 1686 | ) { |
| | 1687 | $preview = wp_get_post_autosave( $post->ID ); |
| | 1688 | |
| | 1689 | if ( is_object( $preview ) ) { |
| | 1690 | $post = $preview; |
| | 1691 | $content = get_post_field( 'post_content', $preview, 'display' ); |
| | 1692 | } |
| | 1693 | } else { |
| | 1694 | $content = get_explanation_field( 'post_content', $_post ); |
| | 1695 | } |
| 1685 | 1696 | |
| 1686 | 1697 | // Pass the content through expected content filters. |
| 1687 | 1698 | $content = apply_filters( 'the_content', apply_filters( 'get_the_content', $content ) ); |