Changeset 5156
- Timestamp:
- 11/20/2013 07:50:55 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/common/functions.php
r5134 r5156 983 983 984 984 /** 985 * Sends notification emails for new posts985 * Sends notification emails for new replies to subscribed topics 986 986 * 987 987 * Gets new post's ID and check if there are subscribed users to that topic, and … … 993 993 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 994 994 * @uses bbp_get_reply_id() To validate the reply ID 995 * @uses bbp_get_topic_id() To validate the topic ID 996 * @uses bbp_get_forum_id() To validate the forum ID 995 997 * @uses bbp_get_reply() To get the reply 996 * @uses bbp_get_reply_topic_id() To get the topic ID of the reply997 998 * @uses bbp_is_reply_published() To make sure the reply is published 998 999 * @uses bbp_get_topic_id() To validate the topic ID 999 1000 * @uses bbp_get_topic() To get the reply's topic 1000 1001 * @uses bbp_is_topic_published() To make sure the topic is published 1001 * @uses get_the_author_meta() To get theauthor's display name1002 * @uses do_action() Calls 'bbp_pre_notify_subscribers' with the reply id and1003 * topic id 1002 * @uses bbp_get_reply_author_display_name() To get the reply author's display name 1003 * @uses do_action() Calls 'bbp_pre_notify_subscribers' with the reply id, 1004 * topic id and user id 1004 1005 * @uses bbp_get_topic_subscribers() To get the topic subscribers 1005 1006 * @uses apply_filters() Calls 'bbp_subscription_mail_message' with the 1006 * message, reply id, topic id and user id 1007 * message, reply id, topic id and user id 1008 * @uses apply_filters() Calls 'bbp_subscription_mail_title' with the 1009 * topic title, reply id, topic id and user id 1010 * @uses apply_filters() Calls 'bbp_subscription_mail_headers' 1007 1011 * @uses get_userdata() To get the user data 1008 1012 * @uses wp_mail() To send the mail 1009 * @uses do_action() Calls 'bbp_post_notify_subscribers' with the reply id 1010 * and topicid1013 * @uses do_action() Calls 'bbp_post_notify_subscribers' with the reply id, 1014 * topic id and user id 1011 1015 * @return bool True on success, false on failure 1012 1016 */ … … 1037 1041 /** User ******************************************************************/ 1038 1042 1039 // Get subscribers and bail if empty1043 // Get topic subscribers and bail if empty 1040 1044 $user_ids = bbp_get_topic_subscribers( $topic_id, true ); 1041 1045 if ( empty( $user_ids ) ) … … 1105 1109 1106 1110 do_action( 'bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids ); 1111 1112 return true; 1113 } 1114 1115 /** 1116 * Sends notification emails for new topics to subscribed forums 1117 * 1118 * Gets new post's ID and check if there are subscribed users to that topic, and 1119 * if there are, send notifications 1120 * 1121 * @since bbPress (rxxxx) 1122 * 1123 * @param int $topic_id ID of the newly made reply 1124 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 1125 * @uses bbp_get_topic_id() To validate the topic ID 1126 * @uses bbp_get_forum_id() To validate the forum ID 1127 * @uses bbp_is_topic_published() To make sure the topic is published 1128 * @uses bbp_get_forum_subscribers() To get the forum subscribers 1129 * @uses bbp_get_topic_author_display_name() To get the topic author's display name 1130 * @uses do_action() Calls 'bbp_pre_notify_forum_subscribers' with the topic id, 1131 * forum id and user id 1132 * @uses apply_filters() Calls 'bbp_forum_subscription_mail_message' with the 1133 * message, topic id, forum id and user id 1134 * @uses apply_filters() Calls 'bbp_forum_subscription_mail_title' with the 1135 * topic title, topic id, forum id and user id 1136 * @uses apply_filters() Calls 'bbp_forum_subscription_mail_headers' 1137 * @uses get_userdata() To get the user data 1138 * @uses wp_mail() To send the mail 1139 * @uses do_action() Calls 'bbp_post_notify_forum_subscribers' with the topic, 1140 * id, forum id and user id 1141 * @return bool True on success, false on failure 1142 */ 1143 function bbp_notify_forum_subscribers( $topic_id = 0, $forum_id = 0, $anonymous_data = false, $topic_author = 0 ) { 1144 1145 // Bail if subscriptions are turned off 1146 if ( !bbp_is_subscriptions_active() ) 1147 return false; 1148 1149 /** Validation ************************************************************/ 1150 1151 $topic_id = bbp_get_topic_id( $topic_id ); 1152 $forum_id = bbp_get_forum_id( $forum_id ); 1153 1154 /** Topic *****************************************************************/ 1155 1156 // Bail if topic is not published 1157 if ( ! bbp_is_topic_published( $topic_id ) ) 1158 return false; 1159 1160 /** User ******************************************************************/ 1161 1162 // Get forum subscribers and bail if empty 1163 $user_ids = bbp_get_forum_subscribers( $forum_id, true ); 1164 if ( empty( $user_ids ) ) 1165 return false; 1166 1167 // Poster name 1168 $topic_author_name = bbp_get_topic_author_display_name( $topic_id ); 1169 1170 /** Mail ******************************************************************/ 1171 1172 do_action( 'bbp_pre_notify_forum_subscribers', $topic_id, $forum_id, $user_ids ); 1173 1174 // Remove filters from reply content and topic title to prevent content 1175 // from being encoded with HTML entities, wrapped in paragraph tags, etc... 1176 remove_all_filters( 'bbp_get_topic_content' ); 1177 remove_all_filters( 'bbp_get_topic_title' ); 1178 1179 // Strip tags from text 1180 $topic_title = strip_tags( bbp_get_topic_title( $topic_id ) ); 1181 $topic_content = strip_tags( bbp_get_topic_content( $topic_id ) ); 1182 $topic_url = get_permalink( $topic_id ); 1183 $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 1184 1185 // Loop through users 1186 foreach ( (array) $user_ids as $user_id ) { 1187 1188 // Don't send notifications to the person who made the post 1189 if ( !empty( $topic_author ) && (int) $user_id === (int) $topic_author ) 1190 continue; 1191 1192 // For plugins to filter messages per reply/topic/user 1193 $message = sprintf( __( '%1$s wrote: 1194 1195 %2$s 1196 1197 Topic Link: %3$s 1198 1199 ----------- 1200 1201 You are receiving this email because you subscribed to a forum. 1202 1203 Login and visit the topic to unsubscribe from these emails.', 'bbpress' ), 1204 1205 $topic_author_name, 1206 $topic_content, 1207 $topic_url 1208 ); 1209 $message = apply_filters( 'bbp_forum_subscription_mail_message', $message, $topic_id, $forum_id, $user_id ); 1210 if ( empty( $message ) ) 1211 continue; 1212 1213 // For plugins to filter titles per reply/topic/user 1214 $subject = apply_filters( 'bbp_forum_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $topic_id, $forum_id, $user_id ); 1215 if ( empty( $subject ) ) 1216 continue; 1217 1218 // Custom headers 1219 $headers = apply_filters( 'bbp_forum_subscription_mail_headers', array() ); 1220 1221 // Get user data of this user 1222 $user = get_userdata( $user_id ); 1223 1224 // Send notification email 1225 wp_mail( $user->user_email, $subject, $message, $headers ); 1226 } 1227 1228 do_action( 'bbp_post_notify_forum_subscribers', $topic_id, $forum_id, $user_ids ); 1107 1229 1108 1230 return true; -
trunk/includes/core/actions.php
r4999 r5156 38 38 * v--WordPress Actions v--bbPress Sub-actions 39 39 */ 40 add_action( 'plugins_loaded', 'bbp_loaded', 41 add_action( 'init', 'bbp_init', 42 add_action( 'parse_query', 'bbp_parse_query', 43 add_action( 'widgets_init', 'bbp_widgets_init', 44 add_action( 'generate_rewrite_rules', 'bbp_generate_rewrite_rules', 45 add_action( 'wp_enqueue_scripts', 'bbp_enqueue_scripts', 46 add_action( 'wp_head', 'bbp_head', 47 add_action( 'wp_footer', 'bbp_footer', 48 add_action( 'set_current_user', 'bbp_setup_current_user', 49 add_action( 'setup_theme', 'bbp_setup_theme', 50 add_action( 'after_setup_theme', 'bbp_after_setup_theme', 51 add_action( 'template_redirect', 'bbp_template_redirect', 52 add_action( 'login_form_login', 'bbp_login_form_login', 53 add_action( 'profile_update', 'bbp_profile_update', 54 add_action( 'user_register', 'bbp_user_register', 40 add_action( 'plugins_loaded', 'bbp_loaded', 10 ); 41 add_action( 'init', 'bbp_init', 0 ); // Early for bbp_register 42 add_action( 'parse_query', 'bbp_parse_query', 2 ); // Early for overrides 43 add_action( 'widgets_init', 'bbp_widgets_init', 10 ); 44 add_action( 'generate_rewrite_rules', 'bbp_generate_rewrite_rules', 10 ); 45 add_action( 'wp_enqueue_scripts', 'bbp_enqueue_scripts', 10 ); 46 add_action( 'wp_head', 'bbp_head', 10 ); 47 add_action( 'wp_footer', 'bbp_footer', 10 ); 48 add_action( 'set_current_user', 'bbp_setup_current_user', 10 ); 49 add_action( 'setup_theme', 'bbp_setup_theme', 10 ); 50 add_action( 'after_setup_theme', 'bbp_after_setup_theme', 10 ); 51 add_action( 'template_redirect', 'bbp_template_redirect', 8 ); // Before BuddyPress's 10 [BB2225] 52 add_action( 'login_form_login', 'bbp_login_form_login', 10 ); 53 add_action( 'profile_update', 'bbp_profile_update', 10, 2 ); // user_id and old_user_data 54 add_action( 'user_register', 'bbp_user_register', 10 ); 55 55 56 56 /** … … 119 119 120 120 // Autoembeds 121 add_action( 'bbp_init', 'bbp_reply_content_autoembed', 8 122 add_action( 'bbp_init', 'bbp_topic_content_autoembed', 8 121 add_action( 'bbp_init', 'bbp_reply_content_autoembed', 8 ); 122 add_action( 'bbp_init', 'bbp_topic_content_autoembed', 8 ); 123 123 124 124 /** … … 225 225 add_action( 'bbp_trash_topic', 'bbp_remove_topic_from_all_subscriptions' ); 226 226 add_action( 'bbp_delete_topic', 'bbp_remove_topic_from_all_subscriptions' ); 227 add_action( 'bbp_trash_forum', 'bbp_remove_forum_from_all_subscriptions' ); 228 add_action( 'bbp_delete_forum', 'bbp_remove_forum_from_all_subscriptions' ); 227 229 add_action( 'bbp_new_reply', 'bbp_notify_subscribers', 11, 5 ); 230 add_action( 'bbp_new_topic', 'bbp_notify_forum_subscribers', 11, 4 ); 228 231 229 232 // Sticky … … 298 301 299 302 // Theme-side GET requests 300 add_action( 'bbp_get_request', 'bbp_toggle_topic_handler', 1 ); 301 add_action( 'bbp_get_request', 'bbp_toggle_reply_handler', 1 ); 302 add_action( 'bbp_get_request', 'bbp_favorites_handler', 1 ); 303 add_action( 'bbp_get_request', 'bbp_subscriptions_handler', 1 ); 304 add_action( 'bbp_get_request', 'bbp_search_results_redirect', 10 ); 303 add_action( 'bbp_get_request', 'bbp_toggle_topic_handler', 1 ); 304 add_action( 'bbp_get_request', 'bbp_toggle_reply_handler', 1 ); 305 add_action( 'bbp_get_request', 'bbp_favorites_handler', 1 ); 306 add_action( 'bbp_get_request', 'bbp_subscriptions_handler', 1 ); 307 add_action( 'bbp_get_request', 'bbp_forum_subscriptions_handler', 1 ); 308 add_action( 'bbp_get_request', 'bbp_search_results_redirect', 10 ); 305 309 306 310 // Maybe convert the users password -
trunk/includes/forums/functions.php
r5114 r5156 962 962 } 963 963 964 /** Subscriptions *************************************************************/ 965 966 /** 967 * Remove a deleted forum from all users' subscriptions 968 * 969 * @since bbPress (rxxxx) 970 * 971 * @param int $forum_id Get the forum ID to remove 972 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 973 * @uses bbp_get_forum_id To get the forum id 974 * @uses bbp_get_forum_subscribers() To get the forum subscribers 975 * @uses bbp_remove_user_subscription() To remove the user subscription 976 */ 977 function bbp_remove_forum_from_all_subscriptions( $forum_id = 0 ) { 978 979 // Subscriptions are not active 980 if ( ! bbp_is_subscriptions_active() ) { 981 return; 982 } 983 984 $forum_id = bbp_get_forum_id( $forum_id ); 985 986 // Bail if no forum 987 if ( empty( $forum_id ) ) { 988 return; 989 } 990 991 // Get users 992 $users = (array) bbp_get_forum_subscribers( $forum_id ); 993 994 // Users exist 995 if ( !empty( $users ) ) { 996 997 // Loop through users 998 foreach ( $users as $user ) { 999 1000 // Remove each user 1001 bbp_remove_user_subscription( $user, $forum_id ); 1002 } 1003 } 1004 } 1005 964 1006 /** Count Bumpers *************************************************************/ 965 1007 -
trunk/includes/forums/template.php
r5130 r5156 790 790 } 791 791 792 /** Forum Subscriptions *******************************************************/ 793 794 /** 795 * Output the forum subscription link 796 * 797 * @since bbPress (rxxxx) 798 * 799 * @uses bbp_get_forum_subscription_link() 800 */ 801 function bbp_forum_subscription_link( $args = array() ) { 802 echo bbp_get_forum_subscription_link( $args ); 803 } 804 805 /** 806 * Get the forum subscription link 807 * 808 * A custom wrapper for bbp_get_user_subscribe_link() 809 * 810 * @since bbPress (rxxxx) 811 * 812 * @uses bbp_parse_args() 813 * @uses bbp_get_user_subscribe_link() 814 * @uses apply_filters() Calls 'bbp_get_forum_subscribe_link' 815 */ 816 function bbp_get_forum_subscription_link( $args = array() ) { 817 818 // No link 819 $retval = false; 820 821 // Parse the arguments 822 $r = bbp_parse_args( $args, array( 823 'forum_id' => 0, 824 'user_id' => 0, 825 'before' => '', 826 'after' => '', 827 'subscribe' => __( 'Subscribe', 'bbpress' ), 828 'unsubscribe' => __( 'Unsubscribe', 'bbpress' ) 829 ), 'get_forum_subscribe_link' ); 830 831 // Get the link 832 $retval = bbp_get_user_subscribe_link( $r ); 833 834 return apply_filters( 'bbp_get_forum_subscribe_link', $retval, $r ); 835 } 836 792 837 /** Forum Last Topic **********************************************************/ 793 838 … … 2166 2211 return apply_filters( 'bbp_get_form_forum_visibility', esc_attr( $forum_visibility ) ); 2167 2212 } 2213 2214 /** 2215 * Output checked value of forum subscription 2216 * 2217 * @since bbPress (rxxxx) 2218 * 2219 * @uses bbp_get_form_forum_subscribed() To get the subscribed checkbox value 2220 */ 2221 function bbp_form_forum_subscribed() { 2222 echo bbp_get_form_forum_subscribed(); 2223 } 2224 /** 2225 * Return checked value of forum subscription 2226 * 2227 * @since bbPress (rxxxx) 2228 * 2229 * @uses bbp_is_forum_edit() To check if it's the forum edit page 2230 * @uses bbp_get_global_post_field() To get current post author 2231 * @uses bbp_get_current_user_id() To get the current user id 2232 * @uses bbp_is_user_subscribed() To check if the user is subscribed to 2233 * the forum 2234 * @uses apply_filters() Calls 'bbp_get_form_forum_subscribed' with the 2235 * option 2236 * @return string Checked value of forum subscription 2237 */ 2238 function bbp_get_form_forum_subscribed() { 2239 2240 // Get _POST data 2241 if ( bbp_is_post_request() && isset( $_POST['bbp_forum_subscription'] ) ) { 2242 $forum_subscribed = (bool) $_POST['bbp_forum_subscription']; 2243 2244 // Get edit data 2245 } elseif ( bbp_is_forum_edit() || bbp_is_reply_edit() ) { 2246 2247 // Get current posts author 2248 $post_author = bbp_get_global_post_field( 'post_author', 'raw' ); 2249 2250 // Post author is not the current user 2251 if ( bbp_get_current_user_id() !== $post_author ) { 2252 $forum_subscribed = bbp_is_user_subscribed( $post_author ); 2253 2254 // Post author is the current user 2255 } else { 2256 $forum_subscribed = bbp_is_user_subscribed( bbp_get_current_user_id() ); 2257 } 2258 2259 // Get current status 2260 } elseif ( bbp_is_single_forum() ) { 2261 $forum_subscribed = bbp_is_user_subscribed( bbp_get_current_user_id() ); 2262 2263 // No data 2264 } else { 2265 $forum_subscribed = false; 2266 } 2267 2268 // Get checked output 2269 $checked = checked( $forum_subscribed, true, false ); 2270 2271 return apply_filters( 'bbp_get_form_forum_subscribed', $checked, $forum_subscribed ); 2272 } 2168 2273 2169 2274 /** Form Dropdowns ************************************************************/ -
trunk/includes/topics/functions.php
r5078 r5156 2201 2201 * @since bbPress (r2652) 2202 2202 * 2203 * @param int $topic_id Topic ID to remove 2203 * @param int $topic_id Get the topic id to remove 2204 * @uses bbp_get_topic_id To get the topic id 2204 2205 * @uses bbp_get_topic_favoriters() To get the topic's favoriters 2205 2206 * @uses bbp_remove_user_favorite() To remove the topic from user's favorites … … 2232 2233 * @since bbPress (r2652) 2233 2234 * 2234 * @param int $topic_id Topic IDto remove2235 * @param int $topic_id Get the topic id to remove 2235 2236 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 2237 * @uses bbp_get_topic_id To get the topic id 2236 2238 * @uses bbp_get_topic_subscribers() To get the topic subscribers 2237 2239 * @uses bbp_remove_user_subscription() To remove the user subscription -
trunk/includes/topics/template.php
r5130 r5156 1808 1808 } 1809 1809 1810 /** Topic Subscriptions *******************************************************/ 1811 1812 /** 1813 * Output the topic subscription link 1814 * 1815 * @since bbPress (rxxxx) 1816 * 1817 * @uses bbp_get_topic_subscription_link() 1818 */ 1819 function bbp_topic_subscription_link( $args = array() ) { 1820 echo bbp_get_topic_subscription_link( $args ); 1821 } 1822 1823 /** 1824 * Get the forum subscription link 1825 * 1826 * A custom wrapper for bbp_get_user_subscribe_link() 1827 * 1828 * @since bbPress (rxxxx) 1829 * 1830 * @uses bbp_parse_args() 1831 * @uses bbp_get_user_subscribe_link() 1832 * @uses apply_filters() Calls 'bbp_get_topic_subscribe_link' 1833 */ 1834 function bbp_get_topic_subscription_link( $args = array() ) { 1835 1836 // No link 1837 $retval = false; 1838 1839 // Parse the arguments 1840 $r = bbp_parse_args( $args, array( 1841 'user_id' => 0, 1842 'topic_id' => 0, 1843 'before' => ' | ', 1844 'after' => '', 1845 'subscribe' => __( 'Subscribe', 'bbpress' ), 1846 'unsubscribe' => __( 'Unsubscribe', 'bbpress' ) 1847 ), 'get_forum_subscribe_link' ); 1848 1849 // Get the link 1850 $retval = bbp_get_user_subscribe_link( $r ); 1851 1852 return apply_filters( 'bbp_get_topic_subscribe_link', $retval, $r ); 1853 } 1854 1855 /** Topic Favorites ***********************************************************/ 1856 1857 /** 1858 * Output the topic favorite link 1859 * 1860 * @since bbPress (rxxxx) 1861 * 1862 * @uses bbp_get_topic_favorite_link() 1863 */ 1864 function bbp_topic_favorite_link( $args = array() ) { 1865 echo bbp_get_topic_favorite_link( $args ); 1866 } 1867 1868 /** 1869 * Get the forum favorite link 1870 * 1871 * A custom wrapper for bbp_get_user_favorite_link() 1872 * 1873 * @since bbPress (rxxxx) 1874 * 1875 * @uses bbp_parse_args() 1876 * @uses bbp_get_user_favorites_link() 1877 * @uses apply_filters() Calls 'bbp_get_topic_favorite_link' 1878 */ 1879 function bbp_get_topic_favorite_link( $args = array() ) { 1880 1881 // No link 1882 $retval = false; 1883 1884 // Parse the arguments 1885 $r = bbp_parse_args( $args, array( 1886 'user_id' => 0, 1887 'topic_id' => 0, 1888 'before' => '', 1889 'after' => '', 1890 'favorite' => __( 'Favorite', 'bbpress' ), 1891 'favorited' => __( 'Unfavorite', 'bbpress' ) 1892 ), 'get_forum_favorite_link' ); 1893 1894 // Get the link 1895 $retval = bbp_get_user_favorites_link( $r ); 1896 1897 return apply_filters( 'bbp_get_topic_favorite_link', $retval, $r ); 1898 } 1899 1810 1900 /** Topic Last Reply **********************************************************/ 1811 1901 -
trunk/includes/users/functions.php
r5121 r5156 314 314 315 315 if ( !empty( $favorites ) ) { 316 316 317 317 // Checking a specific topic id 318 318 if ( !empty( $topic_id ) ) { … … 513 513 514 514 /** 515 * Get the users who have subscribed to the forum 516 * 517 * @since bbPress (rxxxx) 518 * 519 * @param int $forum_id Optional. forum id 520 * @uses wpdb::get_col() To execute our query and get the column back 521 * @uses apply_filters() Calls 'bbp_get_forum_subscribers' with the subscribers 522 * @return array|bool Results if the forum has any subscribers, otherwise false 523 */ 524 function bbp_get_forum_subscribers( $forum_id = 0 ) { 525 $forum_id = bbp_get_forum_id( $forum_id ); 526 if ( empty( $forum_id ) ) 527 return; 528 529 global $wpdb; 530 531 $key = $wpdb->prefix . '_bbp_forum_subscriptions'; 532 $users = wp_cache_get( 'bbp_get_forum_subscribers_' . $forum_id, 'bbpress_users' ); 533 if ( false === $users ) { 534 $users = $wpdb->get_col( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = '{$key}' and FIND_IN_SET('{$forum_id}', meta_value) > 0" ); 535 wp_cache_set( 'bbp_get_forum_subscribers_' . $forum_id, $users, 'bbpress_users' ); 536 } 537 538 return apply_filters( 'bbp_get_forum_subscribers', $users ); 539 } 540 541 /** 515 542 * Get the users who have subscribed to the topic 516 543 * … … 544 571 * @since bbPress (r2668) 545 572 * 573 * @deprecated since bbPress (rxxxx) 574 * 575 * @param int $user_id Optional. User id 576 * @uses bbp_get_user_topic_subscriptions() To get the user's subscriptions 577 * @return array|bool Results if user has subscriptions, otherwise false 578 */ 579 function bbp_get_user_subscriptions( $user_id = 0 ) { 580 _deprecated_function( __FUNCTION__, 2.5, 'bbp_get_user_topic_subscriptions()' ); 581 $query = bbp_get_user_topic_subscriptions( $user_id ); 582 return apply_filters( 'bbp_get_user_subscriptions', $query, $user_id ); 583 } 584 585 /** 586 * Get a user's subscribed topics 587 * 588 * @since bbPress (r2668) 589 * 546 590 * @param int $user_id Optional. User id 547 591 * @uses bbp_get_user_subscribed_topic_ids() To get the user's subscriptions … … 551 595 * @return array|bool Results if user has subscriptions, otherwise false 552 596 */ 553 function bbp_get_user_ subscriptions( $user_id = 0 ) {597 function bbp_get_user_topic_subscriptions( $user_id = 0 ) { 554 598 555 599 // Default to the displayed user 556 600 $user_id = bbp_get_user_id( $user_id ); 557 if ( empty( $user_id ) ) 558 return false; 601 if ( empty( $user_id ) ) { 602 return false; 603 } 559 604 560 605 // If user has subscriptions, load them … … 566 611 } 567 612 568 return apply_filters( 'bbp_get_user_subscriptions', $query, $user_id ); 613 return apply_filters( 'bbp_get_user_topic_subscriptions', $query, $user_id ); 614 } 615 616 /** 617 * Get a user's subscribed forums 618 * 619 * @since bbPress (rxxxx) 620 * 621 * @param int $user_id Optional. User id 622 * @uses bbp_get_user_subscribed_forum_ids() To get the user's subscriptions 623 * @uses bbp_has_forums() To get the forums 624 * @uses apply_filters() Calls 'bbp_get_user_forum_subscriptions' with the forum 625 * query and user id 626 * @return array|bool Results if user has subscriptions, otherwise false 627 */ 628 function bbp_get_user_forum_subscriptions( $user_id = 0 ) { 629 630 // Default to the displayed user 631 $user_id = bbp_get_user_id( $user_id ); 632 if ( empty( $user_id ) ) { 633 return false; 634 } 635 636 // If user has subscriptions, load them 637 $subscriptions = bbp_get_user_subscribed_forum_ids( $user_id ); 638 if ( !empty( $subscriptions ) ) { 639 $query = bbp_has_forums( array( 'post__in' => $subscriptions ) ); 640 } else { 641 $query = false; 642 } 643 644 return apply_filters( 'bbp_get_user_forum_subscriptions', $query, $user_id ); 645 } 646 647 /** 648 * Get a user's subscribed forum ids 649 * 650 * @since bbPress (rxxxx) 651 * 652 * @param int $user_id Optional. User id 653 * @uses bbp_get_user_id() To get the user id 654 * @uses get_user_option() To get the user's subscriptions 655 * @uses apply_filters() Calls 'bbp_get_user_subscribed_forum_ids' with 656 * the subscriptions and user id 657 * @return array|bool Results if user has subscriptions, otherwise false 658 */ 659 function bbp_get_user_subscribed_forum_ids( $user_id = 0 ) { 660 $user_id = bbp_get_user_id( $user_id ); 661 if ( empty( $user_id ) ) 662 return false; 663 664 $subscriptions = get_user_option( '_bbp_forum_subscriptions', $user_id ); 665 $subscriptions = array_filter( wp_parse_id_list( $subscriptions ) ); 666 667 return (array) apply_filters( 'bbp_get_user_subscribed_forum_ids', $subscriptions, $user_id ); 569 668 } 570 669 … … 593 692 594 693 /** 694 * Check if a topic or forum is in user's subscription list or not 695 * 696 * @since bbPress (rxxxx) 697 * 698 * @param int $user_id Optional. User id 699 * @param int $forum_id Optional. Topic id 700 * @uses get_post() To get the post object 701 * @uses bbp_get_user_subscribed_forum_ids() To get the user's forum subscriptions 702 * @uses bbp_get_user_subscribed_topic_ids() To get the user's topic subscriptions 703 * @uses bbp_get_forum_post_type() To get the forum post type 704 * @uses bbp_get_topic_post_type() To get the topic post type 705 * @uses apply_filters() Calls 'bbp_is_user_subscribed' with the bool, user id, 706 * forum/topic id and subsriptions 707 * @return bool True if the forum or topic is in user's subscriptions, otherwise false 708 */ 709 function bbp_is_user_subscribed( $user_id = 0, $object_id = 0 ) { 710 711 // Assume user is not subscribed 712 $retval = false; 713 714 // Setup ID's array 715 $subscribed_ids = array(); 716 717 // User and object ID's are passed 718 if ( ! empty( $user_id ) && ! empty( $object_id ) ) { 719 720 // Get the post type 721 $post_type = get_post_type( $object_id ); 722 723 // Post exists, so check the types 724 if ( ! empty( $post_type ) ) { 725 726 switch( $post_type ) { 727 728 // Forum 729 case bbp_get_forum_post_type() : 730 $subscribed_ids = bbp_get_user_subscribed_forum_ids( $user_id ); 731 $retval = bbp_is_user_subscribed_to_forum( $user_id, $object_id, $subscribed_ids ); 732 break; 733 734 // Topic (default) 735 case bbp_get_topic_post_type() : 736 default : 737 $subscribed_ids = bbp_get_user_subscribed_topic_ids( $user_id ); 738 $retval = bbp_is_user_subscribed_to_topic( $user_id, $object_id, $subscribed_ids ); 739 break; 740 } 741 } 742 } 743 744 return (bool) apply_filters( 'bbp_is_user_subscribed', $retval, $user_id, $object_id, $subscribed_ids ); 745 } 746 747 /** 748 * Check if a forum is in user's subscription list or not 749 * 750 * @since bbPress (rxxxx) 751 * 752 * @param int $user_id Optional. User id 753 * @param int $forum_id Optional. Topic id 754 * @param array $subscribed_ids Optional. Array of forum ID's to check 755 * @uses bbp_get_user_id() To get the user id 756 * @uses bbp_get_user_subscribed_forum_ids() To get the user's subscriptions 757 * @uses bbp_get_forum() To get the forum 758 * @uses bbp_get_forum_id() To get the forum id 759 * @uses apply_filters() Calls 'bbp_is_user_subscribed' with the bool, user id, 760 * forum id and subsriptions 761 * @return bool True if the forum is in user's subscriptions, otherwise false 762 */ 763 function bbp_is_user_subscribed_to_forum( $user_id = 0, $forum_id = 0, $subscribed_ids = array() ) { 764 765 // Assume user is not subscribed 766 $retval = false; 767 768 // Validate user 769 $user_id = bbp_get_user_id( $user_id, true, true ); 770 if ( ! empty( $user_id ) ) { 771 772 // Get subscription ID's if none passed 773 if ( empty( $subscribed_ids ) ) { 774 $subscribed_ids = bbp_get_user_subscribed_forum_ids( $user_id ); 775 } 776 777 // User has forum subscriptions 778 if ( ! empty( $subscribed_ids ) ) { 779 780 // Checking a specific forum id 781 if ( ! empty( $forum_id ) ) { 782 $forum = bbp_get_forum( $forum_id ); 783 $forum_id = ! empty( $forum ) ? $forum->ID : 0; 784 785 // Using the global forum id 786 } elseif ( bbp_get_forum_id() ) { 787 $forum_id = bbp_get_forum_id(); 788 789 // Use the current post id 790 } elseif ( ! bbp_get_forum_id() ) { 791 $forum_id = get_the_ID(); 792 } 793 794 // Is forum_id in the user's favorites 795 if ( ! empty( $forum_id ) ) { 796 $retval = in_array( $forum_id, $subscribed_ids ); 797 } 798 } 799 } 800 801 return (bool) apply_filters( 'bbp_is_user_subscribed_to_forum', (bool) $retval, $user_id, $forum_id, $subscribed_ids ); 802 } 803 804 /** 595 805 * Check if a topic is in user's subscription list or not 596 806 * 597 * @since bbPress (r 2668)807 * @since bbPress (rxxxx) 598 808 * 599 809 * @param int $user_id Optional. User id 600 810 * @param int $topic_id Optional. Topic id 811 * @param array $subscribed_ids Optional. Array of topic ID's to check 601 812 * @uses bbp_get_user_id() To get the user id 602 813 * @uses bbp_get_user_subscribed_topic_ids() To get the user's subscriptions … … 607 818 * @return bool True if the topic is in user's subscriptions, otherwise false 608 819 */ 609 function bbp_is_user_subscribed( $user_id = 0, $topic_id = 0 ) { 820 function bbp_is_user_subscribed_to_topic( $user_id = 0, $topic_id = 0, $subscribed_ids = array() ) { 821 822 // Assume user is not subscribed 823 $retval = false; 610 824 611 825 // Validate user 612 826 $user_id = bbp_get_user_id( $user_id, true, true ); 613 if ( empty( $user_id ) ) 614 return false; 615 616 $retval = false; 617 $subscriptions = bbp_get_user_subscribed_topic_ids( $user_id ); 618 619 if ( !empty( $subscriptions ) ) { 620 621 // Checking a specific topic id 622 if ( !empty( $topic_id ) ) { 623 $topic = bbp_get_topic( $topic_id ); 624 $topic_id = !empty( $topic ) ? $topic->ID : 0; 625 626 // Using the global topic id 627 } elseif ( bbp_get_topic_id() ) { 628 $topic_id = bbp_get_topic_id(); 629 630 // Use the current post id 631 } elseif ( !bbp_get_topic_id() ) { 632 $topic_id = get_the_ID(); 827 if ( !empty( $user_id ) ) { 828 829 // Get subscription ID's if none passed 830 if ( empty( $subscribed_ids ) ) { 831 $subscribed_ids = bbp_get_user_subscribed_topic_ids( $user_id ); 633 832 } 634 833 635 // Is topic_id in the user's favorites 636 if ( !empty( $topic_id ) ) { 637 $retval = in_array( $topic_id, $subscriptions ); 834 // User has topic subscriptions 835 if ( ! empty( $subscribed_ids ) ) { 836 837 // Checking a specific topic id 838 if ( ! empty( $topic_id ) ) { 839 $topic = bbp_get_topic( $topic_id ); 840 $topic_id = ! empty( $topic ) ? $topic->ID : 0; 841 842 // Using the global topic id 843 } elseif ( bbp_get_topic_id() ) { 844 $topic_id = bbp_get_topic_id(); 845 846 // Use the current post id 847 } elseif ( !bbp_get_topic_id() ) { 848 $topic_id = get_the_ID(); 849 } 850 851 // Is topic_id in the user's favorites 852 if ( ! empty( $topic_id ) ) { 853 $retval = in_array( $topic_id, $subscribed_ids ); 854 } 638 855 } 639 856 } 640 857 641 return (bool) apply_filters( 'bbp_is_user_subscribed', (bool) $retval, $user_id, $topic_id, $subscriptions ); 858 return (bool) apply_filters( 'bbp_is_user_subscribed_to_topic', (bool) $retval, $user_id, $topic_id, $subscribed_ids ); 859 } 860 861 /** 862 * Add a topic to user's subscriptions 863 * 864 * @since bbPress (rxxxx) 865 * 866 * @param int $user_id Optional. User id 867 * @param int $topic_id Optional. Topic id 868 * @uses get_post() To get the post object 869 * @uses bbp_get_user_subscribed_forum_ids() To get the user's forum subscriptions 870 * @uses bbp_get_user_subscribed_topic_ids() To get the user's topic subscriptions 871 * @uses bbp_get_forum_post_type() To get the forum post type 872 * @uses bbp_get_topic_post_type() To get the topic post type 873 * @uses update_user_option() To update the user's subscriptions 874 * @uses do_action() Calls 'bbp_add_user_subscription' with the user & topic id 875 * @return bool Always true 876 */ 877 function bbp_add_user_subscription( $user_id = 0, $object_id = 0 ) { 878 if ( empty( $user_id ) || empty( $object_id ) ) { 879 return false; 880 } 881 882 // Get the post type 883 $post_type = get_post_type( $object_id ); 884 if ( empty( $post_type ) ) { 885 return false; 886 } 887 888 switch( $post_type ) { 889 890 // Forum 891 case bbp_get_forum_post_type() : 892 bbp_add_user_forum_subscription( $user_id, $object_id ); 893 break; 894 895 // Topic 896 case bbp_get_topic_post_type() : 897 default : 898 bbp_add_user_topic_subscription( $user_id, $object_id ); 899 break; 900 } 901 902 do_action( 'bbp_add_user_subscription', $user_id, $object_id, $post_type ); 903 904 return true; 905 } 906 907 /** 908 * Add a forum to user's subscriptions 909 * 910 * @since bbPress (rxxxx) 911 * 912 * @param int $user_id Optional. User id 913 * @param int $forum_id Optional. forum id 914 * @uses bbp_get_user_subscribed_forum_ids() To get the user's subscriptions 915 * @uses bbp_get_forum() To get the forum 916 * @uses update_user_option() To update the user's subscriptions 917 * @uses do_action() Calls 'bbp_add_user_subscription' with the user & forum id 918 * @return bool Always true 919 */ 920 function bbp_add_user_forum_subscription( $user_id = 0, $forum_id = 0 ) { 921 if ( empty( $user_id ) || empty( $forum_id ) ) { 922 return false; 923 } 924 925 $forum = bbp_get_forum( $forum_id ); 926 if ( empty( $forum ) ) { 927 return false; 928 } 929 930 $subscriptions = (array) bbp_get_user_subscribed_forum_ids( $user_id ); 931 if ( !in_array( $forum_id, $subscriptions ) ) { 932 $subscriptions[] = $forum_id; 933 $subscriptions = implode( ',', wp_parse_id_list( array_filter( $subscriptions ) ) ); 934 update_user_option( $user_id, '_bbp_forum_subscriptions', $subscriptions ); 935 936 wp_cache_delete( 'bbp_get_forum_subscribers_' . $forum_id, 'bbpress_users' ); 937 } 938 939 do_action( 'bbp_add_user_forum_subscription', $user_id, $forum_id ); 940 941 return true; 642 942 } 643 943 … … 655 955 * @return bool Always true 656 956 */ 657 function bbp_add_user_subscription( $user_id = 0, $topic_id = 0 ) { 658 if ( empty( $user_id ) || empty( $topic_id ) ) 659 return false; 957 function bbp_add_user_topic_subscription( $user_id = 0, $topic_id = 0 ) { 958 if ( empty( $user_id ) || empty( $topic_id ) ) { 959 return false; 960 } 660 961 661 962 $topic = bbp_get_topic( $topic_id ); 662 if ( empty( $topic ) ) 663 return false; 963 if ( empty( $topic ) ) { 964 return false; 965 } 664 966 665 967 $subscriptions = (array) bbp_get_user_subscribed_topic_ids( $user_id ); … … 672 974 } 673 975 674 do_action( 'bbp_add_user_ subscription', $user_id, $topic_id );976 do_action( 'bbp_add_user_topic_subscription', $user_id, $topic_id ); 675 977 676 978 return true; … … 681 983 * 682 984 * @since bbPress (r2668) 985 * 986 * @param int $user_id Optional. User id 987 * @param int $topic_id Optional. Topic id 988 * @uses get_post() To get the post object 989 * @uses bbp_get_forum_post_type() To get the forum post type 990 * @uses bbp_get_topic_post_type() To get the topic post type 991 * @uses bbp_remove_user_forum_subscription() To remove the user's subscription 992 * @uses bbp_remove_user_topic_subscription() To remove the user's subscription 993 * @uses do_action() Calls 'bbp_remove_user_subscription' with the user id and 994 * topic id 995 * @return bool True if the topic was removed from user's subscriptions, 996 * otherwise false 997 */ 998 function bbp_remove_user_subscription( $user_id = 0, $object_id = 0 ) { 999 if ( empty( $user_id ) || empty( $object_id ) ) { 1000 return false; 1001 } 1002 1003 $post_type = get_post_type( $object_id ); 1004 if ( empty( $post_type ) ) { 1005 return false; 1006 } 1007 1008 switch( $post_type ) { 1009 1010 // Forum 1011 case bbp_get_forum_post_type() : 1012 bbp_remove_user_forum_subscription( $user_id, $object_id ); 1013 break; 1014 1015 // Topic 1016 case bbp_get_topic_post_type() : 1017 default : 1018 bbp_remove_user_topic_subscription( $user_id, $object_id ); 1019 break; 1020 } 1021 1022 do_action( 'bbp_remove_user_subscription', $user_id, $object_id, $post_type ); 1023 1024 return true; 1025 } 1026 1027 /** 1028 * Remove a forum from user's subscriptions 1029 * 1030 * @since bbPress (rxxxx) 1031 * 1032 * @param int $user_id Optional. User id 1033 * @param int $forum_id Optional. forum id 1034 * @uses bbp_get_user_subscribed_forum_ids() To get the user's subscriptions 1035 * @uses update_user_option() To update the user's subscriptions 1036 * @uses delete_user_option() To delete the user's subscriptions meta 1037 * @uses do_action() Calls 'bbp_remove_user_subscription' with the user id and 1038 * forum id 1039 * @return bool True if the forum was removed from user's subscriptions, 1040 * otherwise false 1041 */ 1042 function bbp_remove_user_forum_subscription( $user_id, $forum_id ) { 1043 if ( empty( $user_id ) || empty( $forum_id ) ) { 1044 return false; 1045 } 1046 1047 $subscriptions = (array) bbp_get_user_subscribed_forum_ids( $user_id ); 1048 if ( empty( $subscriptions ) ) { 1049 return false; 1050 } 1051 1052 $pos = array_search( $forum_id, $subscriptions ); 1053 if ( false === $pos ) { 1054 return false; 1055 } 1056 1057 array_splice( $subscriptions, $pos, 1 ); 1058 $subscriptions = array_filter( $subscriptions ); 1059 1060 if ( !empty( $subscriptions ) ) { 1061 $subscriptions = implode( ',', wp_parse_id_list( $subscriptions ) ); 1062 update_user_option( $user_id, '_bbp_forum_subscriptions', $subscriptions ); 1063 } else { 1064 delete_user_option( $user_id, '_bbp_forum_subscriptions' ); 1065 } 1066 1067 wp_cache_delete( 'bbp_get_forum_subscribers_' . $forum_id, 'bbpress_users' ); 1068 1069 do_action( 'bbp_remove_user_forum_subscription', $user_id, $forum_id ); 1070 1071 return true; 1072 } 1073 1074 /** 1075 * Remove a topic from user's subscriptions 1076 * 1077 * @since bbPress (rxxxx) 683 1078 * 684 1079 * @param int $user_id Optional. User id … … 687 1082 * @uses update_user_option() To update the user's subscriptions 688 1083 * @uses delete_user_option() To delete the user's subscriptions meta 689 * @uses do_action() Calls 'bbp_remove_user_ subscription' with the user id and1084 * @uses do_action() Calls 'bbp_remove_user_topic_subscription' with the user id and 690 1085 * topic id 691 1086 * @return bool True if the topic was removed from user's subscriptions, 692 1087 * otherwise false 693 1088 */ 694 function bbp_remove_user_subscription( $user_id, $topic_id ) { 695 if ( empty( $user_id ) || empty( $topic_id ) ) 696 return false; 1089 function bbp_remove_user_topic_subscription( $user_id, $topic_id ) { 1090 if ( empty( $user_id ) || empty( $topic_id ) ) { 1091 return false; 1092 } 697 1093 698 1094 $subscriptions = (array) bbp_get_user_subscribed_topic_ids( $user_id ); 699 700 if ( empty( $subscriptions ) )701 return false;1095 if ( empty( $subscriptions ) ) { 1096 return false; 1097 } 702 1098 703 1099 $pos = array_search( $topic_id, $subscriptions ); 704 if ( is_numeric( $pos ) ) { 705 array_splice( $subscriptions, $pos, 1 ); 706 $subscriptions = array_filter( $subscriptions ); 707 708 if ( !empty( $subscriptions ) ) { 709 $subscriptions = implode( ',', wp_parse_id_list( $subscriptions ) ); 710 update_user_option( $user_id, '_bbp_subscriptions', $subscriptions ); 1100 if ( false === $pos ) { 1101 return false; 1102 } 1103 1104 array_splice( $subscriptions, $pos, 1 ); 1105 $subscriptions = array_filter( $subscriptions ); 1106 1107 if ( !empty( $subscriptions ) ) { 1108 $subscriptions = implode( ',', wp_parse_id_list( $subscriptions ) ); 1109 update_user_option( $user_id, '_bbp_subscriptions', $subscriptions ); 1110 } else { 1111 delete_user_option( $user_id, '_bbp_subscriptions' ); 1112 } 1113 1114 wp_cache_delete( 'bbp_get_topic_subscribers_' . $topic_id, 'bbpress_users' ); 1115 1116 do_action( 'bbp_remove_user_topic_subscription', $user_id, $topic_id ); 1117 1118 return true; 1119 } 1120 1121 /** 1122 * Handles the front end subscribing and unsubscribing forums 1123 * 1124 * @since bbPress (rxxxx) 1125 * 1126 * @param string $action The requested action to compare this function to 1127 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 1128 * @uses bbp_get_user_id() To get the user id 1129 * @uses bbp_verify_nonce_request() To verify the nonce and check the request 1130 * @uses current_user_can() To check if the current user can edit the user 1131 * @uses bbPress:errors:add() To log the error messages 1132 * @uses bbp_is_user_subscribed() To check if the forum is in user's 1133 * subscriptions 1134 * @uses bbp_remove_user_subscription() To remove the user subscription 1135 * @uses bbp_add_user_subscription() To add the user subscription 1136 * @uses do_action() Calls 'bbp_subscriptions_handler' with success, user id, 1137 * forum id and action 1138 * @uses bbp_is_subscription() To check if it's the subscription page 1139 * @uses bbp_get_forum_permalink() To get the forum permalink 1140 * @uses wp_safe_redirect() To redirect to the url 1141 */ 1142 function bbp_forum_subscriptions_handler( $action = '' ) { 1143 1144 if ( ! bbp_is_subscriptions_active() ) { 1145 return false; 1146 } 1147 1148 // Bail if no forum ID is passed 1149 if ( empty( $_GET['forum_id'] ) ) { 1150 return; 1151 } 1152 1153 // Setup possible get actions 1154 $possible_actions = array( 1155 'bbp_subscribe', 1156 'bbp_unsubscribe', 1157 ); 1158 1159 // Bail if actions aren't meant for this function 1160 if ( ! in_array( $action, $possible_actions ) ) { 1161 return; 1162 } 1163 1164 // Get required data 1165 $user_id = bbp_get_user_id( 0, true, true ); 1166 $forum_id = intval( $_GET['forum_id'] ); 1167 1168 // Check for empty forum 1169 if ( empty( $forum_id ) ) { 1170 bbp_add_error( 'bbp_subscription_forum_id', __( '<strong>ERROR</strong>: No forum was found! Which forum are you subscribing/unsubscribing to?', 'bbpress' ) ); 1171 1172 // Check nonce 1173 } elseif ( ! bbp_verify_nonce_request( 'toggle-subscription_' . $forum_id ) ) { 1174 bbp_add_error( 'bbp_subscription_forum_id', __( '<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress' ) ); 1175 1176 // Check current user's ability to edit the user 1177 } elseif ( !current_user_can( 'edit_user', $user_id ) ) { 1178 bbp_add_error( 'bbp_subscription_permissions', __( '<strong>ERROR</strong>: You don\'t have the permission to edit favorites of that user!', 'bbpress' ) ); 1179 } 1180 1181 // Bail if we have errors 1182 if ( bbp_has_errors() ) { 1183 return; 1184 } 1185 1186 /** No errors *************************************************************/ 1187 1188 $is_subscription = bbp_is_user_subscribed( $user_id, $forum_id ); 1189 $success = false; 1190 1191 if ( true === $is_subscription && 'bbp_unsubscribe' === $action ) { 1192 $success = bbp_remove_user_subscription( $user_id, $forum_id ); 1193 } elseif ( false === $is_subscription && 'bbp_subscribe' === $action ) { 1194 $success = bbp_add_user_subscription( $user_id, $forum_id ); 1195 } 1196 1197 // Do additional subscriptions actions 1198 do_action( 'bbp_subscriptions_handler', $success, $user_id, $forum_id, $action ); 1199 1200 // Success! 1201 if ( true === $success ) { 1202 1203 // Redirect back from whence we came 1204 if ( bbp_is_subscriptions() ) { 1205 $redirect = bbp_get_subscriptions_permalink( $user_id ); 1206 } elseif ( bbp_is_single_user() ) { 1207 $redirect = bbp_get_user_profile_url(); 1208 } elseif ( is_singular( bbp_get_forum_post_type() ) ) { 1209 $redirect = bbp_get_forum_permalink( $forum_id ); 1210 } elseif ( is_single() || is_page() ) { 1211 $redirect = get_permalink(); 711 1212 } else { 712 delete_user_option( $user_id, '_bbp_subscriptions');1213 $redirect = get_permalink( $forum_id ); 713 1214 } 714 1215 715 wp_cache_delete( 'bbp_get_topic_subscribers_' . $topic_id, 'bbpress_users' ); 716 } 717 718 do_action( 'bbp_remove_user_subscription', $user_id, $topic_id ); 719 720 return true; 1216 wp_safe_redirect( $redirect ); 1217 1218 // For good measure 1219 exit(); 1220 1221 // Fail! Handle errors 1222 } elseif ( true === $is_subscription && 'bbp_unsubscribe' === $action ) { 1223 bbp_add_error( 'bbp_unsubscribe', __( '<strong>ERROR</strong>: There was a problem unsubscribing from that forum!', 'bbpress' ) ); 1224 } elseif ( false === $is_subscription && 'bbp_subscribe' === $action ) { 1225 bbp_add_error( 'bbp_subscribe', __( '<strong>ERROR</strong>: There was a problem subscribing to that forum!', 'bbpress' ) ); 1226 } 721 1227 } 722 1228 … … 737 1243 * topic id and action 738 1244 * @uses bbp_is_subscription() To check if it's the subscription page 739 * @uses bbp_get_subscription_link() To get the subscription page link740 1245 * @uses bbp_get_topic_permalink() To get the topic permalink 741 1246 * @uses wp_safe_redirect() To redirect to the url … … 743 1248 function bbp_subscriptions_handler( $action = '' ) { 744 1249 745 if ( !bbp_is_subscriptions_active() ) 746 return false; 1250 if ( !bbp_is_subscriptions_active() ) { 1251 return false; 1252 } 747 1253 748 1254 // Bail if no topic ID is passed 749 if ( empty( $_GET['topic_id'] ) ) 750 return; 1255 if ( empty( $_GET['topic_id'] ) ) { 1256 return; 1257 } 751 1258 752 1259 // Setup possible get actions … … 757 1264 758 1265 // Bail if actions aren't meant for this function 759 if ( !in_array( $action, $possible_actions ) ) 760 return; 1266 if ( !in_array( $action, $possible_actions ) ) { 1267 return; 1268 } 761 1269 762 1270 // Get required data … … 778 1286 779 1287 // Bail if we have errors 780 if ( bbp_has_errors() ) 781 return; 1288 if ( bbp_has_errors() ) { 1289 return; 1290 } 782 1291 783 1292 /** No errors *************************************************************/ … … 786 1295 $success = false; 787 1296 788 if ( true === $is_subscription && 'bbp_unsubscribe' === $action ) 1297 if ( true === $is_subscription && 'bbp_unsubscribe' === $action ) { 789 1298 $success = bbp_remove_user_subscription( $user_id, $topic_id ); 790 elseif ( false === $is_subscription && 'bbp_subscribe' === $action )1299 } elseif ( false === $is_subscription && 'bbp_subscribe' === $action ) { 791 1300 $success = bbp_add_user_subscription( $user_id, $topic_id ); 1301 } 792 1302 793 1303 // Do additional subscriptions actions … … 969 1479 */ 970 1480 function bbp_get_user_topics_started( $user_id = 0 ) { 971 1481 972 1482 // Validate user 973 1483 $user_id = bbp_get_user_id( $user_id ); … … 994 1504 */ 995 1505 function bbp_get_user_replies_created( $user_id = 0 ) { 996 1506 997 1507 // Validate user 998 1508 $user_id = bbp_get_user_id( $user_id ); … … 1032 1542 * met. We assume a user cannot perform this task, and look for ways they can 1033 1543 * earn the ability to access this template. 1034 * 1544 * 1035 1545 * @since bbPress (r3605) 1036 1546 * -
trunk/includes/users/template.php
r5126 r5156 613 613 614 614 /** Anonymous Fields **********************************************************/ 615 615 616 616 /** 617 617 * Output the author disylay-name of a topic or reply. … … 886 886 */ 887 887 function bbp_get_user_favorites_link( $args = '', $user_id = 0, $wrap = true ) { 888 if ( ! bbp_is_favorites_active() )888 if ( ! bbp_is_favorites_active() ) { 889 889 return false; 890 } 890 891 891 892 // Parse arguments against default values … … 907 908 908 909 // No link if you can't edit yourself 909 if ( ! current_user_can( 'edit_user', (int) $user_id ) ) {910 if ( ! current_user_can( 'edit_user', (int) $user_id ) ) { 910 911 return false; 911 912 } … … 913 914 // Decide which link to show 914 915 $is_fav = bbp_is_user_favorite( $user_id, $topic_id ); 915 if ( ! empty( $is_fav ) ) {916 if ( ! empty( $is_fav ) ) { 916 917 $text = $r['favorited']; 917 918 $query_args = array( 'action' => 'bbp_favorite_remove', 'topic_id' => $topic_id ); … … 936 937 937 938 // Initial output is wrapped in a span, ajax output is hooked to this 938 if ( ! empty( $wrap ) ) {939 if ( ! empty( $wrap ) ) { 939 940 $html = '<span id="favorite-toggle">' . $html . '</span>'; 940 941 } … … 1019 1020 } 1020 1021 /** 1021 * Return the link to subscribe/unsubscribe from a topic1022 * Return the link to subscribe/unsubscribe from a forum or topic 1022 1023 * 1023 1024 * @since bbPress (r2668) … … 1028 1029 * - user_id: User id 1029 1030 * - topic_id: Topic id 1031 * - forum_id: Forum id 1030 1032 * - before: Before the link 1031 1033 * - after: After the link 1032 1034 * @param int $user_id Optional. User id 1033 1035 * @param bool $wrap Optional. If you want to wrap the link in <span id="subscription-toggle">. 1036 * @uses bbp_is_subscriptions_active() to check if subscriptions are active 1034 1037 * @uses bbp_get_user_id() To get the user id 1038 * @uses bbp_get_user_id() To get the user id 1039 * @uses bbp_get_topic_id() To get the topic id 1040 * @uses bbp_get_forum_id() To get the forum id 1035 1041 * @uses current_user_can() To check if the current user can edit user 1036 * @uses bbp_ get_topic_id() To get the topic id1037 * @uses bbp_is_user_subscribed () To check if the user is subscribed1042 * @uses bbp_is_user_subscribed_to_forum() To check if the user is subscribed to the forum 1043 * @uses bbp_is_user_subscribed_to_topic() To check if the user is subscribed to the topic 1038 1044 * @uses bbp_is_subscriptions() To check if it's the subscriptions page 1039 1045 * @uses bbp_get_subscriptions_permalink() To get subscriptions link … … 1044 1050 */ 1045 1051 function bbp_get_user_subscribe_link( $args = '', $user_id = 0, $wrap = true ) { 1046 if ( ! bbp_is_subscriptions_active() )1052 if ( ! bbp_is_subscriptions_active() ) { 1047 1053 return; 1054 } 1048 1055 1049 1056 // Parse arguments against default values … … 1053 1060 'user_id' => 0, 1054 1061 'topic_id' => 0, 1062 'forum_id' => 0, 1055 1063 'before' => ' | ', 1056 1064 'after' => '' 1057 1065 ), 'get_user_subscribe_link' ); 1058 1066 1059 // Validate user and topicID's1067 // Validate user and object ID's 1060 1068 $user_id = bbp_get_user_id( $r['user_id'], true, true ); 1061 1069 $topic_id = bbp_get_topic_id( $r['topic_id'] ); 1062 if ( empty( $user_id ) || empty( $topic_id ) ) { 1070 $forum_id = bbp_get_forum_id( $r['forum_id'] ); 1071 if ( empty( $user_id ) || ( empty( $topic_id ) && empty( $forum_id ) ) ) { 1063 1072 return false; 1064 1073 } 1065 1074 1066 1075 // No link if you can't edit yourself 1067 if ( ! current_user_can( 'edit_user', (int) $user_id ) ) {1076 if ( ! current_user_can( 'edit_user', (int) $user_id ) ) { 1068 1077 return false; 1069 1078 } 1070 1079 1071 // Decide which link to show 1072 $is_subscribed = bbp_is_user_subscribed( $user_id, $topic_id ); 1073 if ( !empty( $is_subscribed ) ) { 1074 $text = $r['unsubscribe']; 1075 $query_args = array( 'action' => 'bbp_unsubscribe', 'topic_id' => $topic_id ); 1080 // Check if viewing a single forum 1081 if ( empty( $topic_id ) && ! empty( $forum_id ) ) { 1082 1083 // Decide which link to show 1084 $is_subscribed = bbp_is_user_subscribed_to_forum( $user_id, $forum_id ); 1085 if ( ! empty( $is_subscribed ) ) { 1086 $text = $r['unsubscribe']; 1087 $query_args = array( 'action' => 'bbp_unsubscribe', 'forum_id' => $forum_id ); 1088 } else { 1089 $text = $r['subscribe']; 1090 $query_args = array( 'action' => 'bbp_subscribe', 'forum_id' => $forum_id ); 1091 } 1092 1093 // Create the link based where the user is and if the user is 1094 // subscribed already 1095 if ( bbp_is_subscriptions() ) { 1096 $permalink = bbp_get_subscriptions_permalink( $user_id ); 1097 } elseif ( bbp_is_single_forum() || bbp_is_single_reply() ) { 1098 $permalink = bbp_get_forum_permalink( $forum_id ); 1099 } else { 1100 $permalink = get_permalink(); 1101 } 1102 1103 $url = esc_url( wp_nonce_url( add_query_arg( $query_args, $permalink ), 'toggle-subscription_' . $forum_id ) ); 1104 $sub = $is_subscribed ? ' class="is-subscribed"' : ''; 1105 $html = sprintf( '%s<span id="subscribe-%d" %s><a href="%s" class="subscription-toggle" data-forum="%d">%s</a></span>%s', $r['before'], $forum_id, $sub, $url, $forum_id, $text, $r['after'] ); 1106 1107 // Initial output is wrapped in a span, ajax output is hooked to this 1108 if ( !empty( $wrap ) ) { 1109 $html = '<span id="subscription-toggle">' . $html . '</span>'; 1110 } 1111 1076 1112 } else { 1077 $text = $r['subscribe']; 1078 $query_args = array( 'action' => 'bbp_subscribe', 'topic_id' => $topic_id ); 1079 } 1080 1081 // Create the link based where the user is and if the user is 1082 // subscribed already 1083 if ( bbp_is_subscriptions() ) { 1084 $permalink = bbp_get_subscriptions_permalink( $user_id ); 1085 } elseif ( bbp_is_single_topic() || bbp_is_single_reply() ) { 1086 $permalink = bbp_get_topic_permalink( $topic_id ); 1087 } else { 1088 $permalink = get_permalink(); 1089 } 1090 1091 $url = esc_url( wp_nonce_url( add_query_arg( $query_args, $permalink ), 'toggle-subscription_' . $topic_id ) ); 1092 $sub = $is_subscribed ? ' class="is-subscribed"' : ''; 1093 $html = sprintf( '%s<span id="subscribe-%d" %s><a href="%s" class="subscription-toggle" data-topic="%d">%s</a></span>%s', $r['before'], $topic_id, $sub, $url, $topic_id, $text, $r['after'] ); 1094 1095 // Initial output is wrapped in a span, ajax output is hooked to this 1096 if ( !empty( $wrap ) ) { 1097 $html = '<span id="subscription-toggle">' . $html . '</span>'; 1113 1114 // Decide which link to show 1115 $is_subscribed = bbp_is_user_subscribed_to_topic( $user_id, $topic_id ); 1116 if ( ! empty( $is_subscribed ) ) { 1117 $text = $r['unsubscribe']; 1118 $query_args = array( 'action' => 'bbp_unsubscribe', 'topic_id' => $topic_id ); 1119 } else { 1120 $text = $r['subscribe']; 1121 $query_args = array( 'action' => 'bbp_subscribe', 'topic_id' => $topic_id ); 1122 } 1123 1124 // Create the link based where the user is and if the user is 1125 // subscribed already 1126 if ( bbp_is_subscriptions() ) { 1127 $permalink = bbp_get_subscriptions_permalink( $user_id ); 1128 } elseif ( bbp_is_single_topic() || bbp_is_single_reply() ) { 1129 $permalink = bbp_get_topic_permalink( $topic_id ); 1130 } else { 1131 $permalink = get_permalink(); 1132 } 1133 1134 $url = esc_url( wp_nonce_url( add_query_arg( $query_args, $permalink ), 'toggle-subscription_' . $topic_id ) ); 1135 $sub = $is_subscribed ? ' class="is-subscribed"' : ''; 1136 $html = sprintf( '%s<span id="subscribe-%d" %s><a href="%s" class="subscription-toggle" data-topic="%d">%s</a></span>%s', $r['before'], $topic_id, $sub, $url, $topic_id, $text, $r['after'] ); 1137 1138 // Initial output is wrapped in a span, ajax output is hooked to this 1139 if ( !empty( $wrap ) ) { 1140 $html = '<span id="subscription-toggle">' . $html . '</span>'; 1141 } 1098 1142 } 1099 1143 -
trunk/templates/default/bbpress-functions.php
r4944 r5156 85 85 /** Scripts ***********************************************************/ 86 86 87 add_action( 'bbp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS 88 add_action( 'bbp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS 89 add_filter( 'bbp_enqueue_scripts', array( $this, 'localize_topic_script' ) ); // Enqueue theme script localization 90 add_action( 'bbp_head', array( $this, 'head_scripts' ) ); // Output some extra JS in the <head> 91 add_action( 'bbp_ajax_favorite', array( $this, 'ajax_favorite' ) ); // Handles the ajax favorite/unfavorite 92 add_action( 'bbp_ajax_subscription', array( $this, 'ajax_subscription' ) ); // Handles the ajax subscribe/unsubscribe 87 add_action( 'bbp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); // Enqueue theme CSS 88 add_action( 'bbp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); // Enqueue theme JS 89 add_filter( 'bbp_enqueue_scripts', array( $this, 'localize_topic_script' ) ); // Enqueue theme script localization 90 add_action( 'bbp_head', array( $this, 'head_scripts' ) ); // Output some extra JS in the <head> 91 add_action( 'bbp_ajax_favorite', array( $this, 'ajax_favorite' ) ); // Handles the topic ajax favorite/unfavorite 92 add_action( 'bbp_ajax_subscription', array( $this, 'ajax_subscription' ) ); // Handles the topic ajax subscribe/unsubscribe 93 add_action( 'bbp_ajax_forum_subscription', array( $this, 'ajax_forum_subscription' ) ); // Handles the forum ajax subscribe/unsubscribe 93 94 94 95 /** Template Wrappers *************************************************/ … … 169 170 * @since bbPress (r3732) 170 171 * 172 * @uses bbp_is_single_forum() To check if it's the forum page 171 173 * @uses bbp_is_single_topic() To check if it's the topic page 174 * @uses bbp_thread_replies() To check if threaded replies are enabled 172 175 * @uses bbp_is_single_user_edit() To check if it's the profile edit page 173 176 * @uses wp_enqueue_script() To enqueue the scripts … … 178 181 if ( bbp_use_wp_editor() ) { 179 182 wp_enqueue_script( 'jquery' ); 183 } 184 185 // Forum-specific scripts 186 if ( bbp_is_single_forum() ) { 187 188 // Forum subscribe/unsubscribe 189 wp_enqueue_script( 'bbpress-forum', $this->url . 'js/forum.js', array( 'jquery' ), $this->version ); 180 190 } 181 191 … … 286 296 * @since bbPress (r3732) 287 297 * 298 * @uses bbp_is_single_forum() To check if it's the forum page 288 299 * @uses bbp_is_single_topic() To check if it's the topic page 289 300 * @uses is_user_logged_in() To check if user is logged in 290 301 * @uses bbp_get_current_user_id() To get the current user id 302 * @uses bbp_get_forum_id() To get the forum id 291 303 * @uses bbp_get_topic_id() To get the topic id 292 304 * @uses bbp_get_favorites_permalink() To get the favorites permalink … … 299 311 public function localize_topic_script() { 300 312 301 // Bail if not viewing a single topic 302 if ( !bbp_is_single_topic() ) 303 return; 304 305 wp_localize_script( 'bbpress-topic', 'bbpTopicJS', array( 306 'bbp_ajaxurl' => bbp_get_ajax_url(), 307 'generic_ajax_error' => __( 'Something went wrong. Refresh your browser and try again.', 'bbpress' ), 308 'is_user_logged_in' => is_user_logged_in(), 309 'fav_nonce' => wp_create_nonce( 'toggle-favorite_' . get_the_ID() ), 310 'subs_nonce' => wp_create_nonce( 'toggle-subscription_' . get_the_ID() ) 311 ) ); 313 // Single forum 314 if ( bbp_is_single_forum() ) { 315 wp_localize_script( 'bbpress-forum', 'bbpForumJS', array( 316 'bbp_ajaxurl' => bbp_get_ajax_url(), 317 'generic_ajax_error' => __( 'Something went wrong. Refresh your browser and try again.', 'bbpress' ), 318 'is_user_logged_in' => is_user_logged_in(), 319 'subs_nonce' => wp_create_nonce( 'toggle-subscription_' . get_the_ID() ) 320 ) ); 321 322 // Single topic 323 } elseif ( bbp_is_single_topic() ) { 324 wp_localize_script( 'bbpress-topic', 'bbpTopicJS', array( 325 'bbp_ajaxurl' => bbp_get_ajax_url(), 326 'generic_ajax_error' => __( 'Something went wrong. Refresh your browser and try again.', 'bbpress' ), 327 'is_user_logged_in' => is_user_logged_in(), 328 'fav_nonce' => wp_create_nonce( 'toggle-favorite_' . get_the_ID() ), 329 'subs_nonce' => wp_create_nonce( 'toggle-subscription_' . get_the_ID() ) 330 ) ); 331 } 332 } 333 334 /** 335 * AJAX handler to Subscribe/Unsubscribe a user from a forum 336 * 337 * @since bbPress (r5155) 338 * 339 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 340 * @uses bbp_is_user_logged_in() To check if user is logged in 341 * @uses bbp_get_current_user_id() To get the current user id 342 * @uses current_user_can() To check if the current user can edit the user 343 * @uses bbp_get_forum() To get the forum 344 * @uses wp_verify_nonce() To verify the nonce 345 * @uses bbp_is_user_subscribed() To check if the forum is in user's subscriptions 346 * @uses bbp_remove_user_subscriptions() To remove the forum from user's subscriptions 347 * @uses bbp_add_user_subscriptions() To add the forum from user's subscriptions 348 * @uses bbp_ajax_response() To return JSON 349 */ 350 public function ajax_forum_subscription() { 351 352 // Bail if subscriptions are not active 353 if ( ! bbp_is_subscriptions_active() ) { 354 bbp_ajax_response( false, __( 'Subscriptions are no longer active.', 'bbpress' ), 300 ); 355 } 356 357 // Bail if user is not logged in 358 if ( ! is_user_logged_in() ) { 359 bbp_ajax_response( false, __( 'Please login to subscribe to this forum.', 'bbpress' ), 301 ); 360 } 361 362 // Get user and forum data 363 $user_id = bbp_get_current_user_id(); 364 $id = intval( $_POST['id'] ); 365 366 // Bail if user cannot add favorites for this user 367 if ( ! current_user_can( 'edit_user', $user_id ) ) { 368 bbp_ajax_response( false, __( 'You do not have permission to do this.', 'bbpress' ), 302 ); 369 } 370 371 // Get the forum 372 $forum = bbp_get_forum( $id ); 373 374 // Bail if forum cannot be found 375 if ( empty( $forum ) ) { 376 bbp_ajax_response( false, __( 'The forum could not be found.', 'bbpress' ), 303 ); 377 } 378 379 // Bail if user did not take this action 380 if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'toggle-subscription_' . $forum->ID ) ) { 381 bbp_ajax_response( false, __( 'Are you sure you meant to do that?', 'bbpress' ), 304 ); 382 } 383 384 // Take action 385 $status = bbp_is_user_subscribed( $user_id, $forum->ID ) ? bbp_remove_user_subscription( $user_id, $forum->ID ) : bbp_add_user_subscription( $user_id, $forum->ID ); 386 387 // Bail if action failed 388 if ( empty( $status ) ) { 389 bbp_ajax_response( false, __( 'The request was unsuccessful. Please try again.', 'bbpress' ), 305 ); 390 } 391 392 // Put subscription attributes in convenient array 393 $attrs = array( 394 'forum_id' => $forum->ID, 395 'user_id' => $user_id 396 ); 397 398 // Action succeeded 399 bbp_ajax_response( true, bbp_get_forum_subscription_link( $attrs, $user_id, false ), 200 ); 312 400 } 313 401 … … 317 405 * @since bbPress (r3732) 318 406 * 407 * @uses bbp_is_favorites_active() To check if favorites are active 408 * @uses bbp_is_user_logged_in() To check if user is logged in 319 409 * @uses bbp_get_current_user_id() To get the current user id 320 410 * @uses current_user_can() To check if the current user can edit the user … … 334 424 335 425 // Bail if user is not logged in 336 if ( ! is_user_logged_in() ) {426 if ( ! is_user_logged_in() ) { 337 427 bbp_ajax_response( false, __( 'Please login to make this topic a favorite.', 'bbpress' ), 301 ); 338 428 } … … 343 433 344 434 // Bail if user cannot add favorites for this user 345 if ( ! current_user_can( 'edit_user', $user_id ) ) {435 if ( ! current_user_can( 'edit_user', $user_id ) ) { 346 436 bbp_ajax_response( false, __( 'You do not have permission to do this.', 'bbpress' ), 302 ); 347 437 } … … 356 446 357 447 // Bail if user did not take this action 358 if ( ! isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'toggle-favorite_' . $topic->ID ) ) {448 if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'toggle-favorite_' . $topic->ID ) ) { 359 449 bbp_ajax_response( false, __( 'Are you sure you meant to do that?', 'bbpress' ), 304 ); 360 450 } … … 384 474 * 385 475 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 476 * @uses bbp_is_user_logged_in() To check if user is logged in 386 477 * @uses bbp_get_current_user_id() To get the current user id 387 478 * @uses current_user_can() To check if the current user can edit the user … … 396 487 397 488 // Bail if subscriptions are not active 398 if ( ! bbp_is_subscriptions_active() ) {489 if ( ! bbp_is_subscriptions_active() ) { 399 490 bbp_ajax_response( false, __( 'Subscriptions are no longer active.', 'bbpress' ), 300 ); 400 491 } 401 492 402 493 // Bail if user is not logged in 403 if ( ! is_user_logged_in() ) {494 if ( ! is_user_logged_in() ) { 404 495 bbp_ajax_response( false, __( 'Please login to subscribe to this topic.', 'bbpress' ), 301 ); 405 496 } … … 410 501 411 502 // Bail if user cannot add favorites for this user 412 if ( ! current_user_can( 'edit_user', $user_id ) ) {503 if ( ! current_user_can( 'edit_user', $user_id ) ) { 413 504 bbp_ajax_response( false, __( 'You do not have permission to do this.', 'bbpress' ), 302 ); 414 505 } … … 423 514 424 515 // Bail if user did not take this action 425 if ( ! isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'toggle-subscription_' . $topic->ID ) ) {516 if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'toggle-subscription_' . $topic->ID ) ) { 426 517 bbp_ajax_response( false, __( 'Are you sure you meant to do that?', 'bbpress' ), 304 ); 427 518 } -
trunk/templates/default/bbpress/content-archive-forum.php
r4971 r5156 24 24 <?php bbp_breadcrumb(); ?> 25 25 26 <?php bbp_forum_subscription_link(); ?> 27 26 28 <?php do_action( 'bbp_template_before_forums_index' ); ?> 27 29 -
trunk/templates/default/bbpress/content-single-forum.php
r4836 r5156 13 13 14 14 <?php bbp_breadcrumb(); ?> 15 16 <?php bbp_forum_subscription_link(); ?> 15 17 16 18 <?php do_action( 'bbp_template_before_single_forum' ); ?> -
trunk/templates/default/bbpress/content-single-topic-lead.php
r5031 r5156 22 22 <?php _e( 'Topic', 'bbpress' ); ?> 23 23 24 <?php bbp_ user_subscribe_link(); ?>24 <?php bbp_topic_subscription_link(); ?> 25 25 26 <?php bbp_ user_favorites_link(); ?>26 <?php bbp_topic_favorite_link(); ?> 27 27 28 28 </div><!-- .bbp-topic-content --> -
trunk/templates/default/bbpress/loop-replies.php
r4944 r5156 24 24 <?php _e( 'Posts', 'bbpress' ); ?> 25 25 26 <?php bbp_ user_subscribe_link(); ?>26 <?php bbp_topic_subscription_link(); ?> 27 27 28 28 <?php bbp_user_favorites_link(); ?> -
trunk/templates/default/bbpress/loop-single-forum.php
r4974 r5156 13 13 14 14 <li class="bbp-forum-info"> 15 16 <?php if ( bbp_is_user_home() && bbp_is_subscriptions() ) : ?> 17 18 <span class="bbp-row-actions"> 19 20 <?php do_action( 'bbp_theme_before_forum_subscription_action' ); ?> 21 22 <?php bbp_forum_subscription_link( array( 'before' => '', 'subscribe' => '+', 'unsubscribe' => '×' ) ); ?> 23 24 <?php do_action( 'bbp_theme_after_forum_subscription_action' ); ?> 25 26 </span> 27 28 <?php endif; ?> 15 29 16 30 <?php do_action( 'bbp_theme_before_forum_title' ); ?> -
trunk/templates/default/bbpress/loop-single-topic.php
r4995 r5156 18 18 <?php if ( bbp_is_favorites() ) : ?> 19 19 20 <span class="bbp- topic-action">20 <span class="bbp-row-actions"> 21 21 22 22 <?php do_action( 'bbp_theme_before_topic_favorites_action' ); ?> 23 23 24 <?php bbp_ user_favorites_link( array( 'before' => '', 'favorite' => '+', 'favorited' => '×' ) ); ?>24 <?php bbp_topic_favorite_link( array( 'before' => '', 'favorite' => '+', 'favorited' => '×' ) ); ?> 25 25 26 26 <?php do_action( 'bbp_theme_after_topic_favorites_action' ); ?> … … 30 30 <?php elseif ( bbp_is_subscriptions() ) : ?> 31 31 32 <span class="bbp- topic-action">32 <span class="bbp-row-actions"> 33 33 34 34 <?php do_action( 'bbp_theme_before_topic_subscription_action' ); ?> 35 35 36 <?php bbp_ user_subscribe_link( array( 'before' => '', 'subscribe' => '+', 'unsubscribe' => '×' ) ); ?>36 <?php bbp_topic_subscription_link( array( 'before' => '', 'subscribe' => '+', 'unsubscribe' => '×' ) ); ?> 37 37 38 38 <?php do_action( 'bbp_theme_after_topic_subscription_action' ); ?> -
trunk/templates/default/bbpress/user-subscriptions.php
r4733 r5156 17 17 18 18 <div id="bbp-user-subscriptions" class="bbp-user-subscriptions"> 19 <h2 class="entry-title"><?php _e( 'Subscribed Forum Topics', 'bbpress' ); ?></h2>19 <h2 class="entry-title"><?php _e( 'Subscribed Forums', 'bbpress' ); ?></h2> 20 20 <div class="bbp-user-section"> 21 21 22 <?php if ( bbp_get_user_subscriptions() ) : ?> 22 <?php if ( bbp_get_user_forum_subscriptions() ) : ?> 23 24 <?php bbp_get_template_part( 'loop', 'forums' ); ?> 25 26 <?php else : ?> 27 28 <p><?php bbp_is_user_home() ? _e( 'You are not currently subscribed to any forums.', 'bbpress' ) : _e( 'This user is not currently subscribed to any topics.', 'bbpress' ); ?></p> 29 30 <?php endif; ?> 31 32 </div> 33 34 <h2 class="entry-title"><?php _e( 'Subscribed Topics', 'bbpress' ); ?></h2> 35 <div class="bbp-user-section"> 36 37 <?php if ( bbp_get_user_topic_subscriptions() ) : ?> 23 38 24 39 <?php bbp_get_template_part( 'pagination', 'topics' ); ?> -
trunk/templates/default/css/bbpress-rtl.css
r5085 r5156 174 174 padding: 0; 175 175 text-transform: none; 176 } 177 178 #bbpress-forums div.bbp-forum-author, 176 } 177 178 #bbpress-forums div.bbp-forum-author, 179 179 #bbpress-forums div.bbp-topic-author, 180 180 #bbpress-forums div.bbp-reply-author { … … 184 184 } 185 185 186 #bbpress-forums div.bbp-forum-author img.avatar, 186 #bbpress-forums div.bbp-forum-author img.avatar, 187 187 #bbpress-forums div.bbp-topic-author img.avatar, 188 188 #bbpress-forums div.bbp-reply-author img.avatar { … … 251 251 } 252 252 253 div.bbp-forum-header, 253 div.bbp-forum-header, 254 254 div.bbp-topic-header, 255 255 div.bbp-reply-header { … … 474 474 } 475 475 476 .bbp-forum-header a.bbp-forum-permalink, 476 .bbp-forum-header a.bbp-forum-permalink, 477 477 .bbp-topic-header a.bbp-topic-permalink, 478 478 .bbp-reply-header a.bbp-reply-permalink { … … 485 485 -------------------------------------------------------------- */ 486 486 487 .bbp- topic-action#favorite-toggle a {487 .bbp-row-actions #favorite-toggle a { 488 488 text-decoration: none; 489 489 padding: 0 3px 1px; … … 494 494 font-size: 13px; 495 495 } 496 .bbp- topic-action#favorite-toggle a:hover {496 .bbp-row-actions #favorite-toggle a:hover { 497 497 color: #5a5; 498 498 border-color: #7c7; 499 499 background-color: #beb; 500 500 } 501 .bbp- topic-action#favorite-toggle span.is-favorite a {501 .bbp-row-actions #favorite-toggle span.is-favorite a { 502 502 color: #faa; 503 503 border: 1px solid #faa; 504 504 background-color: #fee; 505 505 } 506 .bbp- topic-action#favorite-toggle span.is-favorite a:hover {506 .bbp-row-actions #favorite-toggle span.is-favorite a:hover { 507 507 color: #c88; 508 508 border-color: #c88; … … 510 510 } 511 511 512 .bbp- topic-action#subscription-toggle a {512 .bbp-row-actions #subscription-toggle a { 513 513 text-decoration: none; 514 514 padding: 0 3px 1px; … … 519 519 font-size: 13px; 520 520 } 521 .bbp- topic-action#subscription-toggle a:hover {521 .bbp-row-actions #subscription-toggle a:hover { 522 522 color: #5a5; 523 523 border-color: #7c7; 524 524 background-color: #beb; 525 525 } 526 .bbp- topic-action#subscription-toggle span.is-subscribed a {526 .bbp-row-actions #subscription-toggle span.is-subscribed a { 527 527 color: #faa; 528 528 border: 1px solid #faa; 529 529 background-color: #fee; 530 530 } 531 .bbp- topic-action#subscription-toggle span.is-subscribed a:hover {531 .bbp-row-actions #subscription-toggle span.is-subscribed a:hover { 532 532 color: #c88; 533 533 border-color: #c88; … … 1182 1182 margin-right: 0; 1183 1183 word-wrap: break-word; 1184 } 1184 } 1185 1185 #bbpress-forums div.bbp-reply-author img.avatar { 1186 1186 position: absolute; … … 1205 1205 float: right; 1206 1206 } 1207 #bbpress-forums fieldset.bbp-form { 1207 #bbpress-forums fieldset.bbp-form { 1208 1208 padding: 0 10px 10px; 1209 1209 } … … 1300 1300 #bbpress-forums li.bbp-body li.bbp-topic-voice-count, 1301 1301 #bbpress-forums li.bbp-body li.bbp-topic-reply-count, 1302 #bbpress-forums li.bbp-footer div.bbp-reply-author, 1302 #bbpress-forums li.bbp-footer div.bbp-reply-author, 1303 1303 #bbpress-forums li.bbp-footer div.bbp-reply-content { 1304 1304 width: 45%; … … 1314 1314 } 1315 1315 #bbpress-forums li.bbp-header li.bbp-forum-freshness, 1316 #bbpress-forums li.bbp-header li.bbp-topic-freshness { 1316 #bbpress-forums li.bbp-header li.bbp-topic-freshness { 1317 1317 text-align: center; 1318 1318 } … … 1339 1339 width: 40px; 1340 1340 height: auto; 1341 } 1342 } 1341 } 1342 } -
trunk/templates/default/css/bbpress.css
r5085 r5156 485 485 -------------------------------------------------------------- */ 486 486 487 .bbp- topic-action#favorite-toggle a {487 .bbp-row-actions #favorite-toggle a { 488 488 text-decoration: none; 489 489 padding: 0 3px 1px; … … 494 494 font-size: 13px; 495 495 } 496 .bbp- topic-action#favorite-toggle a:hover {496 .bbp-row-actions #favorite-toggle a:hover { 497 497 color: #5a5; 498 498 border-color: #7c7; 499 499 background-color: #beb; 500 500 } 501 .bbp- topic-action#favorite-toggle span.is-favorite a {501 .bbp-row-actions #favorite-toggle span.is-favorite a { 502 502 color: #faa; 503 503 border: 1px solid #faa; 504 504 background-color: #fee; 505 505 } 506 .bbp- topic-action#favorite-toggle span.is-favorite a:hover {506 .bbp-row-actions #favorite-toggle span.is-favorite a:hover { 507 507 color: #c88; 508 508 border-color: #c88; … … 510 510 } 511 511 512 .bbp- topic-action#subscription-toggle a {512 .bbp-row-actions #subscription-toggle a { 513 513 text-decoration: none; 514 514 padding: 0 3px 1px; … … 519 519 font-size: 13px; 520 520 } 521 .bbp- topic-action#subscription-toggle a:hover {521 .bbp-row-actions #subscription-toggle a:hover { 522 522 color: #5a5; 523 523 border-color: #7c7; 524 524 background-color: #beb; 525 525 } 526 .bbp- topic-action#subscription-toggle span.is-subscribed a {526 .bbp-row-actions #subscription-toggle span.is-subscribed a { 527 527 color: #faa; 528 528 border: 1px solid #faa; 529 529 background-color: #fee; 530 530 } 531 .bbp- topic-action#subscription-toggle span.is-subscribed a:hover {531 .bbp-row-actions #subscription-toggle span.is-subscribed a:hover { 532 532 color: #c88; 533 533 border-color: #c88;
Note: See TracChangeset
for help on using the changeset viewer.