Changeset 2977
- Timestamp:
- 04/01/2011 07:57:09 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-general-functions.php
r2971 r2977 846 846 * @uses remove_action() To remove the auto save post revision action 847 847 */ 848 function bbp_pre_get_posts( $ wp_query ) {848 function bbp_pre_get_posts( $posts_query ) { 849 849 global $bbp; 850 850 851 // Bail if $ wp_query is emptyor of incorrect class852 if ( empty( $wp_query ) || ( 'WP_Query' != get_class( $wp_query ) ) )853 return $ wp_query;851 // Bail if $posts_query is not an object or of incorrect class 852 if ( !is_object( $posts_query ) || ( 'WP_Query' != get_class( $posts_query ) ) ) 853 return $posts_query; 854 854 855 855 // Get query variables 856 $bbp_user = get_query_var( 'bbp_user' );857 $bbp_view = get_query_var( 'bbp_view' );858 $is_edit = get_query_var( 'edit' );856 $bbp_user = $posts_query->get( 'bbp_user' ); 857 $bbp_view = $posts_query->get( 'bbp_view' ); 858 $is_edit = $posts_query->get( 'edit' ); 859 859 860 860 // It is a user page - We'll also check if it is user edit … … 881 881 // Stop if no user 882 882 if ( !isset( $user ) || empty( $user ) || empty( $user->ID ) ) { 883 $ wp_query->set_404();883 $posts_query->set_404(); 884 884 return; 885 885 } … … 895 895 896 896 // We are editing a profile 897 $ wp_query->bbp_is_user_profile_edit = true;897 $posts_query->bbp_is_user_profile_edit = true; 898 898 899 899 // Load the core WordPress contact methods … … 907 907 // We are viewing a profile 908 908 } else { 909 $ wp_query->bbp_is_user_profile_page = true;909 $posts_query->bbp_is_user_profile_page = true; 910 910 } 911 911 912 912 // Make sure 404 is not set 913 $ wp_query->is_404 = false;913 $posts_query->is_404 = false; 914 914 915 915 // Correct is_home variable 916 $ wp_query->is_home = false;916 $posts_query->is_home = false; 917 917 918 918 // Set bbp_user_id for future reference 919 $ wp_query->query_vars['bbp_user_id'] = $user->ID;919 $posts_query->query_vars['bbp_user_id'] = $user->ID; 920 920 921 921 // Set author_name as current user's nicename to get correct posts 922 922 if ( 'bbp_widget' != bbp_get_query_name() ) 923 $ wp_query->query_vars['author_name'] = $user->user_nicename;923 $posts_query->query_vars['author_name'] = $user->user_nicename; 924 924 925 925 // Set the displayed user global to this user … … 934 934 // Stop if view args is false - means the view isn't registered 935 935 if ( false === $view_args ) { 936 $ wp_query->set_404();936 $posts_query->set_404(); 937 937 return; 938 938 } 939 939 940 940 // We are in a custom topic view 941 $ wp_query->bbp_is_view = true;941 $posts_query->bbp_is_view = true; 942 942 943 943 // Topic/Reply Edit Page … … 945 945 946 946 // We are editing a topic 947 if ( get_query_var( 'post_type' ) == bbp_get_topic_post_type() )948 $ wp_query->bbp_is_topic_edit = true;947 if ( $posts_query->get( 'post_type' ) == bbp_get_topic_post_type() ) 948 $posts_query->bbp_is_topic_edit = true; 949 949 950 950 // We are editing a reply 951 elseif ( get_query_var( 'post_type' ) == bbp_get_reply_post_type() )952 $ wp_query->bbp_is_reply_edit = true;951 elseif ( $posts_query->get( 'post_type' ) == bbp_get_reply_post_type() ) 952 $posts_query->bbp_is_reply_edit = true; 953 953 954 954 // We save post revisions on our own 955 955 remove_action( 'pre_post_update', 'wp_save_post_revision' ); 956 956 } 957 958 return $posts_query; 957 959 } 958 960
Note: See TracChangeset
for help on using the changeset viewer.