Changeset 13108 for trunk/src/bp-activity/bp-activity-functions.php
- Timestamp:
- 09/12/2021 08:43:39 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/bp-activity-functions.php
r12987 r13108 494 494 495 495 if ( ! empty( $post_type_object->bp_activity ) ) { 496 $post_type_activity = bp_parse_args( (array) $post_type_object->bp_activity, $post_type_activity, $post_type . '_tracking_args' ); 496 $post_type_activity = bp_parse_args( 497 (array) $post_type_object->bp_activity, 498 $post_type_activity, 499 $post_type . '_tracking_args' 500 ); 497 501 } 498 502 … … 1771 1775 function bp_activity_get( $args = '' ) { 1772 1776 1773 $r = bp_parse_args( $args, array( 1774 'max' => false, // Maximum number of results to return. 1775 'fields' => 'all', 1776 'page' => 1, // Page 1 without a per_page will result in no pagination. 1777 'per_page' => false, // results per page. 1778 'sort' => 'DESC', // sort ASC or DESC. 1779 'display_comments' => false, // False for no comments. 'stream' for within stream display, 'threaded' for below each activity item. 1780 1781 'search_terms' => false, // Pass search terms as a string. 1782 'meta_query' => false, // Filter by activity meta. See WP_Meta_Query for format. 1783 'date_query' => false, // Filter by date. See first parameter of WP_Date_Query for format. 1784 'filter_query' => false, 1785 'show_hidden' => false, // Show activity items that are hidden site-wide? 1786 'exclude' => false, // Comma-separated list of activity IDs to exclude. 1787 'in' => false, // Comma-separated list or array of activity IDs to which you. 1788 // want to limit the query. 1789 'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'. 1790 'update_meta_cache' => true, 1791 'count_total' => false, 1792 'scope' => false, 1793 1794 /** 1795 * Pass filters as an array -- all filter items can be multiple values comma separated: 1796 * array( 1797 * 'user_id' => false, // User ID to filter on. 1798 * 'object' => false, // Object to filter on e.g. groups, profile, status, friends. 1799 * 'action' => false, // Action to filter on e.g. activity_update, profile_updated. 1800 * 'primary_id' => false, // Object ID to filter on e.g. a group_id or blog_id etc. 1801 * 'secondary_id' => false, // Secondary object ID to filter on e.g. a post_id. 1802 * ); 1803 */ 1804 'filter' => array() 1805 ), 'activity_get' ); 1777 $r = bp_parse_args( 1778 $args, 1779 array( 1780 'max' => false, // Maximum number of results to return. 1781 'fields' => 'all', 1782 'page' => 1, // Page 1 without a per_page will result in no pagination. 1783 'per_page' => false, // results per page. 1784 'sort' => 'DESC', // sort ASC or DESC. 1785 'display_comments' => false, // False for no comments. 'stream' for within stream display, 'threaded' for below each activity item. 1786 1787 'search_terms' => false, // Pass search terms as a string. 1788 'meta_query' => false, // Filter by activity meta. See WP_Meta_Query for format. 1789 'date_query' => false, // Filter by date. See first parameter of WP_Date_Query for format. 1790 'filter_query' => false, 1791 'show_hidden' => false, // Show activity items that are hidden site-wide? 1792 'exclude' => false, // Comma-separated list of activity IDs to exclude. 1793 'in' => false, // Comma-separated list or array of activity IDs to which you. 1794 // want to limit the query. 1795 'spam' => 'ham_only', // 'ham_only' (default), 'spam_only' or 'all'. 1796 'update_meta_cache' => true, 1797 'count_total' => false, 1798 'scope' => false, 1799 1800 /** 1801 * Pass filters as an array -- all filter items can be multiple values comma separated: 1802 * array( 1803 * 'user_id' => false, // User ID to filter on. 1804 * 'object' => false, // Object to filter on e.g. groups, profile, status, friends. 1805 * 'action' => false, // Action to filter on e.g. activity_update, profile_updated. 1806 * 'primary_id' => false, // Object ID to filter on e.g. a group_id or blog_id etc. 1807 * 'secondary_id' => false, // Secondary object ID to filter on e.g. a post_id. 1808 * ); 1809 */ 1810 'filter' => array() 1811 ), 1812 'activity_get' 1813 ); 1806 1814 1807 1815 $activity = BP_Activity_Activity::get( array( … … 1845 1853 * 1846 1854 * @param array|string $args { 1855 * An array of arguments. 1847 1856 * All arguments and defaults are shared with BP_Activity_Activity::get(), 1848 1857 * except for the following: … … 1850 1859 * or array of IDs. 1851 1860 * } 1852 * @return array $activitySee BP_Activity_Activity::get() for description.1861 * @return array See BP_Activity_Activity::get() for description. 1853 1862 */ 1854 1863 function bp_activity_get_specific( $args = '' ) { 1855 1864 1856 $r = bp_parse_args( $args, array( 1857 'activity_ids' => false, // A single activity_id or array of IDs. 1858 'display_comments' => false, // True or false to display threaded comments for these specific activity items. 1859 'max' => false, // Maximum number of results to return. 1860 'page' => 1, // Page 1 without a per_page will result in no pagination. 1861 'per_page' => false, // Results per page. 1862 'show_hidden' => true, // When fetching specific items, show all. 1863 'sort' => 'DESC', // Sort ASC or DESC. 1864 'spam' => 'ham_only', // Retrieve items marked as spam. 1865 'update_meta_cache' => true, 1866 ), 'activity_get_specific' ); 1865 $r = bp_parse_args( 1866 $args, 1867 array( 1868 'activity_ids' => false, // A single activity_id or array of IDs. 1869 'display_comments' => false, // True or false to display threaded comments for these specific activity items. 1870 'max' => false, // Maximum number of results to return. 1871 'page' => 1, // Page 1 without a per_page will result in no pagination. 1872 'per_page' => false, // Results per page. 1873 'show_hidden' => true, // When fetching specific items, show all. 1874 'sort' => 'DESC', // Sort ASC or DESC. 1875 'spam' => 'ham_only', // Retrieve items marked as spam. 1876 'update_meta_cache' => true, 1877 ), 1878 'activity_get_specific' 1879 ); 1867 1880 1868 1881 $get_args = array( … … 1878 1891 ); 1879 1892 1893 $activity = BP_Activity_Activity::get( $get_args ); 1894 1880 1895 /** 1881 1896 * Filters the requested specific activity item. … … 1883 1898 * @since 1.2.0 1884 1899 * 1885 * @param BP_Activity_Activity $activity Requested activity object.1886 * @param array 1887 * @param array 1888 */ 1889 return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $get_args ), $args, $get_args );1900 * @param array $activity The array returned has two keys: total and activity. 1901 * @param array $args Original passed in arguments. 1902 * @param array $get_args Constructed arguments used with request. 1903 */ 1904 return apply_filters( 'bp_activity_get_specific', $activity, $args, $get_args ); 1890 1905 } 1891 1906 … … 1932 1947 function bp_activity_add( $args = '' ) { 1933 1948 1934 $r = bp_parse_args( $args, array( 1935 'id' => false, // Pass an existing activity ID to update an existing entry. 1936 'action' => '', // The activity action - e.g. "Jon Doe posted an update". 1937 'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!". 1938 'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent. 1939 'type' => false, // The activity type e.g. activity_update, profile_updated. 1940 'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink). 1941 'user_id' => bp_loggedin_user_id(), // Optional: The user to record the activity for, can be false if this activity is not for a user. 1942 'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id. 1943 'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id. 1944 'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded. 1945 'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream? 1946 'is_spam' => false, // Is this activity item to be marked as spam? 1947 'error_type' => 'bool' 1948 ), 'activity_add' ); 1949 $r = bp_parse_args( 1950 $args, 1951 array( 1952 'id' => false, // Pass an existing activity ID to update an existing entry. 1953 'action' => '', // The activity action - e.g. "Jon Doe posted an update". 1954 'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!". 1955 'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent. 1956 'type' => false, // The activity type e.g. activity_update, profile_updated. 1957 'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink). 1958 'user_id' => bp_loggedin_user_id(), // Optional: The user to record the activity for, can be false if this activity is not for a user. 1959 'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id. 1960 'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id. 1961 'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded. 1962 'hide_sitewide' => false, // Should this be hidden on the sitewide activity stream? 1963 'is_spam' => false, // Is this activity item to be marked as spam? 1964 'error_type' => 'bool', 1965 ), 1966 'activity_add' 1967 ); 1949 1968 1950 1969 // Make sure we are backwards compatible. 1951 if ( empty( $r['component'] ) && ! empty( $r['component_name'] ) ) {1970 if ( empty( $r['component'] ) && ! empty( $r['component_name'] ) ) { 1952 1971 $r['component'] = $r['component_name']; 1953 1972 } 1954 1973 1955 if ( empty( $r['type'] ) && ! empty( $r['component_action'] ) ) {1974 if ( empty( $r['type'] ) && ! empty( $r['component_action'] ) ) { 1956 1975 $r['type'] = $r['component_action']; 1957 1976 } … … 1978 1997 if ( 'wp_error' === $r['error_type'] && is_wp_error( $save ) ) { 1979 1998 return $save; 1980 } elseif ( 'bool' === $r['error_type'] && false === $save ) {1999 } elseif ( 'bool' === $r['error_type'] && false === $save ) { 1981 2000 return false; 1982 2001 } … … 2012 2031 * 2013 2032 * @param array|string $args { 2033 * An array of arguments. 2014 2034 * @type string $content The content of the activity update. 2015 2035 * @type int $user_id Optional. Defaults to the logged-in user. … … 2022 2042 function bp_activity_post_update( $args = '' ) { 2023 2043 2024 $r = wp_parse_args( $args, array( 2025 'content' => false, 2026 'user_id' => bp_loggedin_user_id(), 2027 'error_type' => 'bool', 2028 ) ); 2029 2030 if ( empty( $r['content'] ) || !strlen( trim( $r['content'] ) ) ) { 2044 $r = bp_parse_args( 2045 $args, 2046 array( 2047 'content' => false, 2048 'user_id' => bp_loggedin_user_id(), 2049 'error_type' => 'bool', 2050 ) 2051 ); 2052 2053 if ( empty( $r['content'] ) || ! strlen( trim( $r['content'] ) ) ) { 2031 2054 return false; 2032 2055 } … … 2646 2669 function bp_activity_new_comment( $args = '' ) { 2647 2670 $bp = buddypress(); 2648 2649 $r = wp_parse_args( $args, array( 2650 'id' => false, 2651 'content' => false, 2652 'user_id' => bp_loggedin_user_id(), 2653 'activity_id' => false, // ID of the root activity item. 2654 'parent_id' => false, // ID of a parent comment (optional). 2655 'primary_link' => '', 2656 'skip_notification' => false, 2657 'error_type' => 'bool' 2658 ) ); 2671 $r = bp_parse_args( 2672 $args, 2673 array( 2674 'id' => false, 2675 'content' => false, 2676 'user_id' => bp_loggedin_user_id(), 2677 'activity_id' => false, // ID of the root activity item. 2678 'parent_id' => false, // ID of a parent comment (optional). 2679 'primary_link' => '', 2680 'skip_notification' => false, 2681 'error_type' => 'bool', 2682 ) 2683 ); 2659 2684 2660 2685 // Error type is boolean; need to initialize some variables for backpat. … … 2725 2750 'id' => $r['id'], 2726 2751 'content' => $comment_content, 2727 'component' => buddypress()->activity->id,2752 'component' => $bp->activity->id, 2728 2753 'type' => 'activity_comment', 2729 2754 'primary_link' => $r['primary_link'], … … 2805 2830 function bp_activity_get_activity_id( $args = '' ) { 2806 2831 2807 $r = bp_parse_args( $args, array( 2808 'user_id' => false, 2809 'component' => false, 2810 'type' => false, 2811 'item_id' => false, 2812 'secondary_item_id' => false, 2813 'action' => false, 2814 'content' => false, 2815 'date_recorded' => false, 2816 ) ); 2832 $r = bp_parse_args( 2833 $args, 2834 array( 2835 'user_id' => false, 2836 'component' => false, 2837 'type' => false, 2838 'item_id' => false, 2839 'secondary_item_id' => false, 2840 'action' => false, 2841 'content' => false, 2842 'date_recorded' => false, 2843 ) 2844 ); 2817 2845 2818 2846 /** … … 2865 2893 2866 2894 // Pass one or more the of following variables to delete by those variables. 2867 $args = bp_parse_args( $args, array( 2868 'id' => false, 2869 'action' => false, 2870 'content' => false, 2871 'component' => false, 2872 'type' => false, 2873 'primary_link' => false, 2874 'user_id' => false, 2875 'item_id' => false, 2876 'secondary_item_id' => false, 2877 'date_recorded' => false, 2878 'hide_sitewide' => false 2879 ) ); 2895 $args = bp_parse_args( 2896 $args, 2897 array( 2898 'id' => false, 2899 'action' => false, 2900 'content' => false, 2901 'component' => false, 2902 'type' => false, 2903 'primary_link' => false, 2904 'user_id' => false, 2905 'item_id' => false, 2906 'secondary_item_id' => false, 2907 'date_recorded' => false, 2908 'hide_sitewide' => false, 2909 ) 2910 ); 2880 2911 2881 2912 /** … … 2939 2970 * @deprecated 1.2.0 2940 2971 * 2941 *2942 2972 * @param array|string $args See BP_Activity_Activity::get for a 2943 2973 * description of accepted arguments. … … 2946 2976 function bp_activity_delete_by_item_id( $args = '' ) { 2947 2977 2948 $r = bp_parse_args( $args, array( 2949 'item_id' => false, 2950 'component' => false, 2951 'type' => false, 2952 'user_id' => false, 2953 'secondary_item_id' => false 2954 ) ); 2978 $r = bp_parse_args( 2979 $args, 2980 array( 2981 'item_id' => false, 2982 'component' => false, 2983 'type' => false, 2984 'user_id' => false, 2985 'secondary_item_id' => false, 2986 ) 2987 ); 2955 2988 2956 2989 return bp_activity_delete( $r );
Note: See TracChangeset
for help on using the changeset viewer.