Changeset 9503 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/explanations.php
- Timestamp:
- 02/13/2020 11:40:22 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/explanations.php
r8662 r9503 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 63 add_filter( 'preview_post_link', array ( $this, 'preview_post_link' ), 10, 2 ); 62 64 63 65 // Permissions. … … 93 95 ), 94 96 'public' => false, 97 'publicly_queryable'=> true, 95 98 'hierarchical' => false, 96 99 'show_ui' => true, … … 116 119 remove_post_type_support( $type, 'editor' ); 117 120 } 121 } 122 123 /** 124 * Override preview post links for explanations to preview the explanation 125 * within the context of its associated function/hook/method/class. 126 * 127 * The associated post's preview link is amended with query parameters used 128 * by `get_explanation_content()` to use the explanation being previewed 129 * instead of the published explanation currently associated with the post. 130 * 131 * @access public 132 * @see 'preview_post_link' filter 133 * 134 * @param string $preview_link URL used for the post preview. 135 * @param WP_Post $post Post object. 136 * @return string 137 **/ 138 public function preview_post_link( $preview_link, $post ) { 139 if ( $this->exp_post_type !== $post->post_type ) { 140 return $preview_link; 141 } 142 143 if ( false !== strpos( $preview_link, 'preview_nonce=' ) ) { 144 $url = parse_url( $preview_link ); 145 $url_query = array(); 146 parse_str ( $url['query'], $url_query ); 147 148 $preview_link = get_preview_post_link( 149 $post->post_parent, 150 array( 151 'wporg_explanations_preview_id' => $url_query['preview_id'], 152 'wporg_explanations_preview_nonce' => $url_query['preview_nonce'], 153 ) 154 ); 155 } 156 157 return $preview_link; 118 158 } 119 159
Note: See TracChangeset
for help on using the changeset viewer.