Changeset 5431 for trunk/src/includes/replies/functions.php
- Timestamp:
- 07/09/2014 10:21:52 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/replies/functions.php (modified) (34 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/replies/functions.php
r5399 r5431 109 109 110 110 // Bail if action is not bbp-new-reply 111 if ( 'bbp-new-reply' !== $action ) 111 if ( 'bbp-new-reply' !== $action ) { 112 112 return; 113 } 113 114 114 115 // Nonce check … … 261 262 /** Reply Title ***********************************************************/ 262 263 263 if ( !empty( $_POST['bbp_reply_title'] ) ) 264 if ( !empty( $_POST['bbp_reply_title'] ) ) { 264 265 $reply_title = esc_attr( strip_tags( $_POST['bbp_reply_title'] ) ); 266 } 265 267 266 268 // Filter and sanitize … … 269 271 /** Reply Content *********************************************************/ 270 272 271 if ( !empty( $_POST['bbp_reply_content'] ) ) 273 if ( !empty( $_POST['bbp_reply_content'] ) ) { 272 274 $reply_content = $_POST['bbp_reply_content']; 275 } 273 276 274 277 // Filter and sanitize … … 276 279 277 280 // No reply content 278 if ( empty( $reply_content ) ) 281 if ( empty( $reply_content ) ) { 279 282 bbp_add_error( 'bbp_reply_content', __( '<strong>ERROR</strong>: Your reply cannot be empty.', 'bbpress' ) ); 283 } 280 284 281 285 /** Reply Flooding ********************************************************/ 282 286 283 if ( !bbp_check_for_flood( $anonymous_data, $reply_author ) ) 287 if ( !bbp_check_for_flood( $anonymous_data, $reply_author ) ) { 284 288 bbp_add_error( 'bbp_reply_flood', __( '<strong>ERROR</strong>: Slow down; you move too fast.', 'bbpress' ) ); 289 } 285 290 286 291 /** Reply Duplicate *******************************************************/ 287 292 288 if ( !bbp_check_for_duplicate( array( 'post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_author, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'anonymous_data' => $anonymous_data ) ) ) 293 if ( !bbp_check_for_duplicate( array( 'post_type' => bbp_get_reply_post_type(), 'post_author' => $reply_author, 'post_content' => $reply_content, 'post_parent' => $topic_id, 'anonymous_data' => $anonymous_data ) ) ) { 289 294 bbp_add_error( 'bbp_reply_duplicate', __( '<strong>ERROR</strong>: Duplicate reply detected; it looks as though you’ve already said that!', 'bbpress' ) ); 295 } 290 296 291 297 /** Reply Blacklist *******************************************************/ 292 298 293 if ( !bbp_check_for_blacklist( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) 299 if ( !bbp_check_for_blacklist( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) { 294 300 bbp_add_error( 'bbp_reply_blacklist', __( '<strong>ERROR</strong>: Your reply cannot be created at this time.', 'bbpress' ) ); 301 } 295 302 296 303 /** Reply Status **********************************************************/ … … 339 346 340 347 // Bail if errors 341 if ( bbp_has_errors() ) 348 if ( bbp_has_errors() ) { 342 349 return; 350 } 343 351 344 352 /** No Errors *************************************************************/ … … 491 499 492 500 // Bail if action is not bbp-edit-reply 493 if ( 'bbp-edit-reply' !== $action ) 501 if ( 'bbp-edit-reply' !== $action ) { 494 502 return; 503 } 495 504 496 505 // Define local variable(s) … … 593 602 /** Reply Title ***********************************************************/ 594 603 595 if ( !empty( $_POST['bbp_reply_title'] ) ) 604 if ( !empty( $_POST['bbp_reply_title'] ) ) { 596 605 $reply_title = esc_attr( strip_tags( $_POST['bbp_reply_title'] ) ); 606 } 597 607 598 608 // Filter and sanitize … … 601 611 /** Reply Content *********************************************************/ 602 612 603 if ( !empty( $_POST['bbp_reply_content'] ) ) 613 if ( !empty( $_POST['bbp_reply_content'] ) ) { 604 614 $reply_content = $_POST['bbp_reply_content']; 615 } 605 616 606 617 // Filter and sanitize … … 608 619 609 620 // No reply content 610 if ( empty( $reply_content ) ) 621 if ( empty( $reply_content ) ) { 611 622 bbp_add_error( 'bbp_edit_reply_content', __( '<strong>ERROR</strong>: Your reply cannot be empty.', 'bbpress' ) ); 623 } 612 624 613 625 /** Reply Blacklist *******************************************************/ 614 626 615 if ( !bbp_check_for_blacklist( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) 627 if ( !bbp_check_for_blacklist( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) { 616 628 bbp_add_error( 'bbp_reply_blacklist', __( '<strong>ERROR</strong>: Your reply cannot be edited at this time.', 'bbpress' ) ); 629 } 617 630 618 631 /** Reply Status **********************************************************/ … … 658 671 659 672 // Bail if errors 660 if ( bbp_has_errors() ) 673 if ( bbp_has_errors() ) { 661 674 return; 675 } 662 676 663 677 /** No Errors *************************************************************/ … … 706 720 707 721 // Revision Reason 708 if ( !empty( $_POST['bbp_reply_edit_reason'] ) ) 722 if ( !empty( $_POST['bbp_reply_edit_reason'] ) ) { 709 723 $reply_edit_reason = esc_attr( strip_tags( $_POST['bbp_reply_edit_reason'] ) ); 724 } 710 725 711 726 // Update revision log … … 798 813 799 814 // Bail if there is no reply 800 if ( empty( $reply_id ) ) 815 if ( empty( $reply_id ) ) { 801 816 return; 817 } 802 818 803 819 // Check author_id 804 if ( empty( $author_id ) ) 820 if ( empty( $author_id ) ) { 805 821 $author_id = bbp_get_current_user_id(); 822 } 806 823 807 824 // Check topic_id 808 if ( empty( $topic_id ) ) 825 if ( empty( $topic_id ) ) { 809 826 $topic_id = bbp_get_reply_topic_id( $reply_id ); 827 } 810 828 811 829 // Check forum_id 812 if ( !empty( $topic_id ) && empty( $forum_id ) ) 830 if ( !empty( $topic_id ) && empty( $forum_id ) ) { 813 831 $forum_id = bbp_get_topic_forum_id( $topic_id ); 832 } 814 833 815 834 // If anonymous post, store name, email, website and ip in post_meta. … … 935 954 936 955 // If we want a full refresh, unset any of the possibly passed variables 937 if ( true === $refresh ) 956 if ( true === $refresh ) { 938 957 $forum_id = $topic_id = $reply_id = $active_id = $last_active_time = 0; 958 } 939 959 940 960 // Walk up ancestors … … 1259 1279 1260 1280 // Bail if action is not 'bbp-move-reply' 1261 if ( 'bbp-move-reply' !== $action ) 1281 if ( 'bbp-move-reply' !== $action ) { 1262 1282 return; 1283 } 1263 1284 1264 1285 // Prevent debug notices … … 1278 1299 1279 1300 // Reply exists 1280 if ( empty( $move_reply ) ) 1301 if ( empty( $move_reply ) ) { 1281 1302 bbp_add_error( 'bbp_mover_reply_r_not_found', __( '<strong>ERROR</strong>: The reply you want to move was not found.', 'bbpress' ) ); 1303 } 1282 1304 1283 1305 /** Topic to Move From ***************************************************/ … … 1443 1465 'meta_value' => $move_reply->ID, 1444 1466 ) ); 1445 foreach ( $children as $child ) 1467 foreach ( $children as $child ) { 1446 1468 bbp_update_reply_to( $child->ID, $parent ); 1469 } 1447 1470 1448 1471 // Remove reply_to from moved reply … … 1553 1576 1554 1577 // Bail if required GET actions aren't passed 1555 if ( empty( $_GET['reply_id'] ) ) 1578 if ( empty( $_GET['reply_id'] ) ) { 1556 1579 return; 1580 } 1557 1581 1558 1582 // Setup possible get actions … … 1563 1587 1564 1588 // Bail if actions aren't meant for this function 1565 if ( !in_array( $action, $possible_actions ) ) 1589 if ( !in_array( $action, $possible_actions ) ) { 1566 1590 return; 1591 } 1567 1592 1568 1593 $failure = ''; // Empty failure string … … 1574 1599 // Make sure reply exists 1575 1600 $reply = bbp_get_reply( $reply_id ); 1576 if ( empty( $reply ) ) 1601 if ( empty( $reply ) ) { 1577 1602 return; 1603 } 1578 1604 1579 1605 // What is the user doing here? … … 1602 1628 $sub_action = in_array( $_GET['sub_action'], array( 'trash', 'untrash', 'delete' ) ) ? $_GET['sub_action'] : false; 1603 1629 1604 if ( empty( $sub_action ) ) 1630 if ( empty( $sub_action ) ) { 1605 1631 break; 1632 } 1606 1633 1607 1634 switch ( $sub_action ) { … … 1650 1677 1651 1678 // Add view all if needed 1652 if ( !empty( $view_all ) ) 1679 if ( !empty( $view_all ) ) { 1653 1680 $reply_url = bbp_add_view_all( $reply_url, true ); 1681 } 1654 1682 1655 1683 // Redirect back to reply … … 1702 1730 // Get reply 1703 1731 $reply = bbp_get_reply( $reply_id ); 1704 if ( empty( $reply ) ) 1732 if ( empty( $reply ) ) { 1705 1733 return $reply; 1734 } 1706 1735 1707 1736 // Bail if already spam 1708 if ( bbp_get_spam_status_id() === $reply->post_status ) 1737 if ( bbp_get_spam_status_id() === $reply->post_status ) { 1709 1738 return false; 1739 } 1710 1740 1711 1741 // Execute pre spam code … … 1749 1779 // Get reply 1750 1780 $reply = bbp_get_reply( $reply_id ); 1751 if ( empty( $reply ) ) 1781 if ( empty( $reply ) ) { 1752 1782 return $reply; 1783 } 1753 1784 1754 1785 // Bail if already not spam 1755 if ( bbp_get_spam_status_id() !== $reply->post_status ) 1786 if ( bbp_get_spam_status_id() !== $reply->post_status ) { 1756 1787 return false; 1788 } 1757 1789 1758 1790 // Execute pre unspam code … … 1795 1827 $reply_id = bbp_get_reply_id( $reply_id ); 1796 1828 1797 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) 1829 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) { 1798 1830 return false; 1831 } 1799 1832 1800 1833 do_action( 'bbp_delete_reply', $reply_id ); … … 1811 1844 $reply_id = bbp_get_reply_id( $reply_id ); 1812 1845 1813 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) 1846 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) { 1814 1847 return false; 1848 } 1815 1849 1816 1850 do_action( 'bbp_trash_reply', $reply_id ); … … 1827 1861 $reply_id = bbp_get_reply_id( $reply_id ); 1828 1862 1829 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) 1863 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) { 1830 1864 return false; 1865 } 1831 1866 1832 1867 do_action( 'bbp_untrash_reply', $reply_id ); … … 1845 1880 $reply_id = bbp_get_reply_id( $reply_id ); 1846 1881 1847 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) 1882 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) { 1848 1883 return false; 1884 } 1849 1885 1850 1886 do_action( 'bbp_deleted_reply', $reply_id ); … … 1861 1897 $reply_id = bbp_get_reply_id( $reply_id ); 1862 1898 1863 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) 1899 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) { 1864 1900 return false; 1901 } 1865 1902 1866 1903 do_action( 'bbp_trashed_reply', $reply_id ); … … 1877 1914 $reply_id = bbp_get_reply_id( $reply_id ); 1878 1915 1879 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) 1916 if ( empty( $reply_id ) || !bbp_is_reply( $reply_id ) ) { 1880 1917 return false; 1918 } 1881 1919 1882 1920 do_action( 'bbp_untrashed_reply', $reply_id ); … … 1901 1939 1902 1940 // If return val is empty, set it to default 1903 if ( empty( $retval ) ) 1941 if ( empty( $retval ) ) { 1904 1942 $retval = $default; 1943 } 1905 1944 1906 1945 // Filter and return … … 1924 1963 1925 1964 // If return val is empty, set it to default 1926 if ( empty( $retval ) ) 1965 if ( empty( $retval ) ) { 1927 1966 $retval = $default; 1967 } 1928 1968 1929 1969 // Filter and return … … 2052 2092 2053 2093 // User cannot access forum this topic is in 2054 if ( bbp_is_single_topic() && !bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) ) 2094 if ( bbp_is_single_topic() && !bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) ) { 2055 2095 return; 2096 } 2056 2097 2057 2098 // Adjust the title based on context 2058 if ( bbp_is_single_topic() && bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) ) 2099 if ( bbp_is_single_topic() && bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) ) { 2059 2100 $title = apply_filters( 'wp_title_rss', get_wp_title_rss( ' » ' ) ); 2060 elseif ( !bbp_show_lead_topic() )2101 } elseif ( !bbp_show_lead_topic() ) { 2061 2102 $title = ' » ' . __( 'All Posts', 'bbpress' ); 2062 else2103 } else { 2063 2104 $title = ' » ' . __( 'All Replies', 'bbpress' ); 2105 } 2064 2106 2065 2107 // Display the feed … … 2168 2210 2169 2211 // Bail if not editing a topic 2170 if ( !bbp_is_reply_edit() ) 2212 if ( !bbp_is_reply_edit() ) { 2171 2213 return; 2214 } 2172 2215 2173 2216 // User cannot edit topic, so redirect back to reply … … 2199 2242 // Bail if reply_id is empty 2200 2243 $reply_id = bbp_get_reply_id( $reply_id ); 2201 if ( empty( $reply_id ) ) 2244 if ( empty( $reply_id ) ) { 2202 2245 return false; 2246 } 2203 2247 2204 2248 // If no position was passed, get it from the db and update the menu_order
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)