Changeset 3290
- Timestamp:
- 06/02/2016 07:24:24 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r3289 r3290 27 27 add_filter( 'pre_insert_term', array( $this, 'pre_insert_term_prevent' ) ); 28 28 add_action( 'pre_get_posts', array( $this, 'use_plugins_in_query' ) ); 29 add_filter( 'the_content', array( $this, 'filter_post_content_to_correct_page' ), 1 );30 29 add_filter( 'rest_api_allowed_post_types', array( $this, 'filter_allowed_post_types' ) ); 31 30 add_filter( 'pre_update_option_jetpack_options', array( $this, 'filter_jetpack_options' ) ); … … 207 206 add_permastruct( 'browse', 'browse/%browse%' ); 208 207 209 add_rewrite_endpoint( 'installation', EP_PERMALINK );210 add_rewrite_endpoint( 'faq', EP_PERMALINK );211 add_rewrite_endpoint( 'screenshots', EP_PERMALINK );212 add_rewrite_endpoint( 'changelog', EP_PERMALINK );213 add_rewrite_endpoint( 'stats', EP_PERMALINK );214 add_rewrite_endpoint( 'developers', EP_PERMALINK );215 add_rewrite_endpoint( 'other_notes', EP_PERMALINK );216 217 208 // If changing capabilities around, uncomment this. 218 209 //Capabilities::add_roles(); … … 448 439 } 449 440 450 // Re-route the Endpoints to the `content_page` query var.451 if ( ! empty( $wp_query->query['name'] ) ) {452 $plugin_fields = array(453 'installation',454 'faq',455 'screenshots',456 'changelog',457 'stats',458 'developers',459 'other_notes'460 );461 462 foreach ( $plugin_fields as $plugin_field ) {463 if ( isset( $wp_query->query[ $plugin_field ] ) ) {464 $wp_query->query['content_page'] = $wp_query->query_vars['content_page'] = $plugin_field;465 unset( $wp_query->query[ $plugin_field ], $wp_query->query_vars[ $plugin_field ] );466 }467 }468 }469 }470 471 /**472 * Returns the requested page's content.473 *474 * @param string $content475 * @return string476 */477 public function filter_post_content_to_correct_page( $content ) {478 if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {479 return $content;480 }481 if ( 'plugin' === get_post()->post_type ) {482 $page = get_query_var( 'content_page' );483 484 $content_pages = $this->split_post_content_into_pages( $content );485 if ( ! isset( $content_pages[ $page ] ) ) {486 $page = 'description';487 }488 489 $content = $content_pages[ $page ];490 }491 492 return $content;493 441 } 494 442
Note: See TracChangeset
for help on using the changeset viewer.