Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pm_fix_jreviews_query( $query, $old_query, $uri_parts, $pm_query, $content_type ) {
- $endpoints = array(
- 'filter' => 'filter',
- 'videos' => 'videos',
- 'photos' => 'photos',
- 'uploads' => 'upload',
- 'reviews' => 'reviews',
- 'discussions' => 'discussions',
- 'new' => 'new',
- 'edit' => 'listing-edit'
- );
- if ( ! empty( $pm_query['id'] ) && is_numeric( $pm_query['id'] ) ) {
- foreach ( $endpoints as $endpoint => $endpoint_value ) {
- if ( isset( $query[ $endpoint ] ) ) {
- $query['url'] = $endpoint_value;
- unset( $query[ $endpoint ] );
- break; // Stop the loop once a match is found
- }
- }
- }
- return $query;
- }
- add_filter('permalink_manager_filter_query', 'pm_fix_jreviews_query', 3, 5);
- function pm_exclude_jreviews_pages( $excluded_ids ) {
- if ( class_exists( 'JReviews\JReviews' ) ) {
- $args = array(
- 'post_type' => 'page',
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- 'fields' => 'ids',
- 'meta_query' => array(
- array(
- 'key' => '_jr_menu_type',
- 'compare' => 'EXISTS',
- ),
- ),
- );
- $jr_menu_page_ids = get_posts($args);
- if( ! empty( $jr_menu_page_ids ) && count( $jr_menu_page_ids ) ) {
- $excluded_ids = array_merge( $excluded_ids, $jr_menu_page_ids );
- }
- }
- return $excluded_ids;
- }
- add_filter( 'permalink_manager_excluded_post_ids', 'pm_exclude_jreviews_pages' );
Advertisement
Add Comment
Please, Sign In to add comment