Changeset 9683 for trunk/src/bp-core/bp-core-functions.php
- Timestamp:
- 04/03/2015 03:05:18 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-functions.php
r9665 r9683 90 90 global $wpdb; 91 91 92 /** 93 * Filters the $wpdb base prefix. 94 * 95 * Intended primarily for use in multinetwork installations. 96 * 97 * @since BuddyPress (1.2.6) 98 * 99 * @param string $base_prefix Base prefix to use. 100 */ 92 101 return apply_filters( 'bp_core_get_table_prefix', $wpdb->base_prefix ); 93 102 } … … 172 181 } 173 182 183 /** 184 * Filters the BuddyPress formatted number. 185 * 186 * @since BuddyPress (1.2.4) 187 * 188 * @param string $value BuddyPress formatted value. 189 * @param int $number The number to be formatted. 190 * @param bool $decimals Whether or not to use decimals. 191 */ 174 192 return apply_filters( 'bp_core_number_format', number_format_i18n( $number, $decimals ), $number, $decimals ); 175 193 } … … 251 269 // Passively filter the args before the parse 252 270 if ( !empty( $filter_key ) ) { 271 272 /** 273 * Filters the arguments key before parsing if filter key provided. 274 * 275 * This is a dynamic filter dependent on the specified key. 276 * 277 * @since BuddyPress (2.0.0) 278 * 279 * @param array $r Array of arguments to use. 280 */ 253 281 $r = apply_filters( 'bp_before_' . $filter_key . '_parse_args', $r ); 254 282 } … … 261 289 // Aggressively filter the args after the parse 262 290 if ( !empty( $filter_key ) ) { 291 292 /** 293 * Filters the arguments key after parsing if filter key provided. 294 * 295 * This is a dynamic filter dependent on the specified key. 296 * 297 * @since BuddyPress (2.0.0) 298 * 299 * @param array $r Array of parsed arguments. 300 */ 263 301 $r = apply_filters( 'bp_after_' . $filter_key . '_parse_args', $r ); 264 302 } … … 351 389 */ 352 390 function bp_is_username_compatibility_mode() { 391 392 /** 393 * Filters whether or not to use username compatibility mode. 394 * 395 * @since BuddyPress (1.5.0) 396 * 397 * @param bool $value Whether or not username compatibility mode should be used. 398 */ 353 399 return apply_filters( 'bp_is_username_compatibility_mode', defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) && BP_ENABLE_USERNAME_COMPATIBILITY_MODE ); 354 400 } … … 380 426 } 381 427 428 /** 429 * Filters whether or not to use the admin bar. 430 * 431 * @since BuddyPress (1.5.0) 432 * 433 * @param bool $use_admin_bar Whether or not to use the admin bar. 434 */ 382 435 return (bool) apply_filters( 'bp_use_wp_admin_bar', $use_admin_bar ); 383 436 } … … 453 506 } 454 507 508 /** 509 * Filters the list of BP directory pages from the appropriate meta table. 510 * 511 * @since BuddyPress (1.5.0) 512 * 513 * @param array $page_ids Array of directory pages. 514 */ 455 515 return apply_filters( 'bp_core_get_directory_page_ids', $page_ids ); 456 516 } … … 530 590 } 531 591 592 /** 593 * Filters the names and slugs for BuddyPress component directory pages. 594 * 595 * @since BuddyPress (1.5.0) 596 * 597 * @param object $pages Object holding page names and slugs. 598 */ 532 599 return apply_filters( 'bp_core_get_directory_pages', $pages ); 533 600 } … … 688 755 $slug = array_pop( $slug_chunks ); 689 756 757 /** 758 * Filters the default component slug from a WP page root_slug. 759 * 760 * @since BuddyPress (1.5.0) 761 * 762 * @param string $slug Short slug for use in the middle of URLs. 763 * @param string $root_slug The root slug which comes from $bp->pages-[component]->slug. 764 */ 690 765 return apply_filters( 'bp_core_component_slug_from_root_slug', $slug, $root_slug ); 691 766 } … … 798 873 } 799 874 875 /** 876 * Filters whether BuddyPress should register the bp-themes directory. 877 * 878 * @since BuddyPress (1.9.0) 879 * 880 * @param bool $register If bp-themes should be registered. 881 */ 800 882 return apply_filters( 'bp_do_register_theme_directory', $register ); 801 883 } … … 816 898 $domain = get_home_url( bp_get_root_blog_id() ); 817 899 900 /** 901 * Filters the domain for the root blog. 902 * 903 * @since BuddyPress (1.0.1) 904 * 905 * @param string $domain The domain URL for the blog. 906 */ 818 907 return apply_filters( 'bp_core_get_root_domain', $domain ); 819 908 } … … 870 959 871 960 /** 872 * Get the path of ofthe current site.961 * Get the path of the current site. 873 962 * 874 963 * @global object $current_site … … 900 989 } 901 990 991 /** 992 * Filters the path of the current site. 993 * 994 * @since BuddyPress (1.2.0) 995 * 996 * @param string $site_path URL to the current site. 997 */ 902 998 return apply_filters( 'bp_core_get_site_path', $site_path ); 903 999 } … … 916 1012 */ 917 1013 function bp_core_current_time( $gmt = true, $type = 'mysql' ) { 1014 1015 /** 1016 * Filters the current GMT time to save into the DB. 1017 * 1018 * @since BuddyPress (1.2.6) 1019 * 1020 * @param string $value Current GMT time. 1021 */ 918 1022 return apply_filters( 'bp_core_current_time', current_time( $type, $gmt ) ); 919 1023 } … … 947 1051 function bp_core_time_since( $older_date, $newer_date = false ) { 948 1052 949 // Use this filter to bypass BuddyPress's time_since calculations 1053 /** 1054 * Filters whether or not to bypass BuddyPress' time_since calculations. 1055 * 1056 * @since BuddyPress (1.7.0) 1057 * 1058 * @param bool $value Whether or not to bypass. 1059 * @param string $older_date Earlier time from which we're calculating time elapsed. 1060 * @param string $newer_date Unix timestamp of date to compare older time to. 1061 */ 950 1062 $pre_value = apply_filters( 'bp_core_time_since_pre', false, $older_date, $newer_date ); 951 1063 if ( false !== $pre_value ) { … … 953 1065 } 954 1066 955 // Setup the strings 1067 /** 1068 * Filters the value to use if the time since is unknown. 1069 * 1070 * @since BuddyPress (1.5.0) 1071 * 1072 * @param string $value String representing the time since the older date. 1073 */ 956 1074 $unknown_text = apply_filters( 'bp_core_time_since_unknown_text', __( 'sometime', 'buddypress' ) ); 1075 1076 /** 1077 * Filters the value to use if the time since is right now. 1078 * 1079 * @since BuddyPress (1.5.0) 1080 * 1081 * @param string $value String representing the time since the older date. 1082 */ 957 1083 $right_now_text = apply_filters( 'bp_core_time_since_right_now_text', __( 'right now', 'buddypress' ) ); 1084 1085 /** 1086 * Filters the value to use if the time since is some time ago. 1087 * 1088 * @since BuddyPress (1.5.0) 1089 * 1090 * @param string $value String representing the time since the older date. 1091 */ 958 1092 $ago_text = apply_filters( 'bp_core_time_since_ago_text', __( '%s ago', 'buddypress' ) ); 959 1093 … … 1086 1220 } 1087 1221 1222 /** 1223 * Filters the English-language representation of the time elapsed since a given date. 1224 * 1225 * @since BuddyPress (1.7.0) 1226 * 1227 * @param string $output Final 'time since' string. 1228 * @param string $older_date Earlier time from which we're calculating time elapsed. 1229 * @param string $newer_date Unix timestamp of date to compare older time to. 1230 */ 1088 1231 return apply_filters( 'bp_core_time_since', $output, $older_date, $newer_date ); 1089 1232 } … … 1170 1313 if ( !empty( $bp->template_message ) ) : 1171 1314 $type = ( 'success' === $bp->template_message_type ) ? 'updated' : 'error'; 1315 1316 /** 1317 * Filters the 'template_notices' feedback message content. 1318 * 1319 * @since BuddyPress (1.5.5) 1320 * 1321 * @param string $template_message Feedback message content. 1322 * @param string $type The type of message being displayed. 1323 * Either 'updated' or 'error'. 1324 */ 1172 1325 $content = apply_filters( 'bp_core_render_message_content', $bp->template_message, $type ); ?> 1173 1326 … … 1180 1333 <?php 1181 1334 1335 /** 1336 * Fires after the display of any template_notices feedback messages. 1337 * 1338 * @since BuddyPress (1.1.0) 1339 */ 1182 1340 do_action( 'bp_core_render_message' ); 1183 1341 … … 1228 1386 // Use this action to detect the very first activity for a given member 1229 1387 if ( empty( $activity ) ) { 1388 1389 /** 1390 * Fires inside the recording of an activity item. 1391 * 1392 * Use this action to detect the very first activity for a given member. 1393 * 1394 * @since BuddyPress (1.6.0) 1395 * 1396 * @param int $user_id ID of the user whose activity is recorded. 1397 */ 1230 1398 do_action( 'bp_first_activity_for_member', $user_id ); 1231 1399 } … … 1260 1428 : sprintf( $string, bp_core_time_since( $last_activity_date ) ); 1261 1429 1262 // Filter and return 1430 /** 1431 * Filters last activity string based on time since date given. 1432 * 1433 * @since BuddyPress (1.2.0) 1434 * 1435 * @param string $last_active Last activity string based on time since date given. 1436 * @param string $last_activity_date The date of last activity. 1437 * @param string $string A sprintf()-able statement of the form 'active %s'. 1438 */ 1263 1439 return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string ); 1264 1440 } … … 1290 1466 */ 1291 1467 function bp_get_user_meta_key( $key = false ) { 1468 1469 /** 1470 * Filters the meta_key for a given piece of user metadata. 1471 * 1472 * @since BuddyPress (1.5.0) 1473 * 1474 * @param string $key The usermeta meta key. 1475 */ 1292 1476 return apply_filters( 'bp_get_user_meta_key', $key ); 1293 1477 } … … 1385 1569 */ 1386 1570 function bp_use_embed_in_activity() { 1571 1572 /** 1573 * Filters whether or not oEmbeds are allowed in activity items. 1574 * 1575 * @since BuddyPress (1.5.0) 1576 * 1577 * @param bool $value Whether or not oEmbeds are allowed. 1578 */ 1387 1579 return apply_filters( 'bp_use_oembed_in_activity', !defined( 'BP_EMBED_DISABLE_ACTIVITY' ) || !BP_EMBED_DISABLE_ACTIVITY ); 1388 1580 } … … 1397 1589 */ 1398 1590 function bp_use_embed_in_activity_replies() { 1591 1592 /** 1593 * Filters whether or not oEmbeds are allowed in activity replies. 1594 * 1595 * @since BuddyPress (1.5.0) 1596 * 1597 * @param bool $value Whether or not oEmbeds are allowed. 1598 */ 1399 1599 return apply_filters( 'bp_use_embed_in_activity_replies', !defined( 'BP_EMBED_DISABLE_ACTIVITY_REPLIES' ) || !BP_EMBED_DISABLE_ACTIVITY_REPLIES ); 1400 1600 } … … 1409 1609 */ 1410 1610 function bp_use_embed_in_forum_posts() { 1611 1612 /** 1613 * Filters whether or not oEmbeds are allowed in forum posts. 1614 * 1615 * @since BuddyPress (1.5.0) 1616 * 1617 * @param bool $value Whether or not oEmbeds are allowed. 1618 */ 1411 1619 return apply_filters( 'bp_use_embed_in_forum_posts', !defined( 'BP_EMBED_DISABLE_FORUM_POSTS' ) || !BP_EMBED_DISABLE_FORUM_POSTS ); 1412 1620 } … … 1421 1629 */ 1422 1630 function bp_use_embed_in_private_messages() { 1631 1632 /** 1633 * Filters whether or not oEmbeds are allowed in private messages. 1634 * 1635 * @since BuddyPress (1.5.0) 1636 * 1637 * @param bool $value Whether or not oEmbeds are allowed. 1638 */ 1423 1639 return apply_filters( 'bp_use_embed_in_private_messages', !defined( 'BP_EMBED_DISABLE_PRIVATE_MESSAGES' ) || !BP_EMBED_DISABLE_PRIVATE_MESSAGES ); 1424 1640 } … … 1493 1709 } 1494 1710 1711 /** 1712 * Filters whether or not BuddyPress should appear in network admin. 1713 * 1714 * @since BuddyPress (1.5.0) 1715 * 1716 * @param bool $retval Whether or not BuddyPress should be in the network admin. 1717 */ 1495 1718 return (bool) apply_filters( 'bp_core_do_network_admin', $retval ); 1496 1719 } … … 1511 1734 $hook = bp_core_do_network_admin() ? 'network_admin_menu' : 'admin_menu'; 1512 1735 1736 /** 1737 * Filters the action name that BuddyPress nav setup callbacks should be hooked to. 1738 * 1739 * @since BuddyPress (1.5.0) 1740 * 1741 * @param string $hook Action name to be attached to. 1742 */ 1513 1743 return apply_filters( 'bp_core_admin_hook', $hook ); 1514 1744 } … … 1539 1769 } 1540 1770 1771 /** 1772 * Filters whether or not we're on the root blog. 1773 * 1774 * @since BuddyPress (1.5.0) 1775 * 1776 * @param bool $is_root_blog Whether or not we're on the root blog. 1777 */ 1541 1778 return (bool) apply_filters( 'bp_is_root_blog', (bool) $is_root_blog ); 1542 1779 } … … 1554 1791 */ 1555 1792 function bp_get_root_blog_id() { 1793 1794 /** 1795 * Filters the ID for the root blog. 1796 * 1797 * @since BuddyPress (1.5.0) 1798 * 1799 * @param int $root_blog_id ID for the root blog. 1800 */ 1556 1801 return (int) apply_filters( 'bp_get_root_blog_id', (int) buddypress()->root_blog_id ); 1557 1802 } … … 1604 1849 } 1605 1850 1851 /** 1852 * Filters whether or not we're running in multiblog mode. 1853 * 1854 * @since BuddyPress (1.5.0) 1855 * 1856 * @param bool $retval Whether or not we're running multiblog mode. 1857 */ 1606 1858 return apply_filters( 'bp_is_multiblog_mode', $retval ); 1607 1859 } … … 1633 1885 } 1634 1886 1887 /** 1888 * Filters whether or not we're active at the network level. 1889 * 1890 * @since BuddyPress (1.7.0) 1891 * 1892 * @param bool $retval Whether or not we're network activated. 1893 */ 1635 1894 return (bool) apply_filters( 'bp_is_network_activated', $retval ); 1636 1895 } … … 1651 1910 } 1652 1911 1912 /** 1913 * Filters the "is_directory" global value. 1914 * 1915 * @since BuddyPress (1.5.0) 1916 * 1917 * @param bool $is_directory Whether or not we're "is_directory". 1918 * @param string $component Component name. Default: the current component. 1919 */ 1653 1920 buddypress()->is_directory = apply_filters( 'bp_update_is_directory', $is_directory, $component ); 1654 1921 } … … 1667 1934 } 1668 1935 1936 /** 1937 * Filters the "is_item_admin" global value. 1938 * 1939 * @since BuddyPress (1.5.0) 1940 * 1941 * @param bool $is_item_admin Whether or not we're "is_item_admin". 1942 * @param string $component Component name. Default: the current component. 1943 */ 1669 1944 buddypress()->is_item_admin = apply_filters( 'bp_update_is_item_admin', $is_item_admin, $component ); 1670 1945 } … … 1683 1958 } 1684 1959 1960 /** 1961 * Filters the "is_item_mod" global value. 1962 * 1963 * @since BuddyPress (1.5.0) 1964 * 1965 * @param bool $is_item_mod Whether or not we're "is_item_mod". 1966 * @param string $component Component name. Default: the current component. 1967 */ 1685 1968 buddypress()->is_item_mod = apply_filters( 'bp_update_is_item_mod', $is_item_mod, $component ); 1686 1969 } … … 1699 1982 global $wp_query; 1700 1983 1984 /** 1985 * Fires inside the triggering of a 404. 1986 * 1987 * @since BuddyPress (1.5.0) 1988 * 1989 * @param string $redirect Redirect type used to determine if redirect_canonical 1990 * function should be be removed. 1991 */ 1701 1992 do_action( 'bp_do_404', $redirect ); 1702 1993 … … 1758 2049 /** Look for match ********************************************************/ 1759 2050 1760 // Filter the requested URL, for configurations like reverse proxying 2051 /** 2052 * Filters the requested URL being nonce-verified. 2053 * 2054 * Useful for configurations like reverse proxying. 2055 * 2056 * @since BuddyPress (1.9.0) 2057 * 2058 * @param string $requested_url The requested URL. 2059 */ 1761 2060 $matched_url = apply_filters( 'bp_verify_nonce_request_url', $requested_url ); 1762 2061 … … 1769 2068 } 1770 2069 1771 // Do extra things 2070 /** 2071 * Fires at the end of the nonce verification check. 2072 * 2073 * @since BuddyPress (1.6.0) 2074 * 2075 * @param string $action Action nonce. 2076 * @param bool $result Boolean result of nonce verification. 2077 */ 1772 2078 do_action( 'bp_verify_nonce_request', $action, $result ); 1773 2079 … … 1809 2115 function bp_core_load_buddypress_textdomain() { 1810 2116 $domain = 'buddypress'; 2117 2118 /** 2119 * Filters the locale to be loaded for the language files. 2120 * 2121 * @since BuddyPress (1.0.2) 2122 * 2123 * @param string $value Current locale for the install. 2124 */ 1811 2125 $mofile_custom = sprintf( '%s-%s.mo', $domain, apply_filters( 'buddypress_locale', get_locale() ) ); 1812 2126 2127 /** 2128 * Filters the locations to load language files from. 2129 * 2130 * @since BuddyPress (2.2.0) 2131 * 2132 * @param array $value Array of directories to check for language files in. 2133 */ 1813 2134 $locations = apply_filters( 'buddypress_locale_locations', array( 1814 2135 trailingslashit( WP_LANG_DIR . '/' . $domain ), … … 1890 2211 } 1891 2212 2213 /** 2214 * Filters the constructed url for use with site searching. 2215 * 2216 * @since BuddyPress (1.0.0) 2217 * 2218 * @param string $value URL for use with site searching. 2219 * @param array $search_terms Array of search terms. 2220 */ 1892 2221 bp_core_redirect( apply_filters( 'bp_core_search_site', home_url( $slug . $query_string . urlencode( $search_terms ) ), $search_terms ) ); 1893 2222 } … … 2128 2457 2129 2458 } else { 2130 // If you've built a custom suggestions service, use this to tell BP the name of your class. 2459 2460 /** 2461 * Filters the default suggestions service to use. 2462 * 2463 * Use this hook to tell BP the name of your class 2464 * if you've built a custom suggestions service. 2465 * 2466 * @since BuddyPress (2.1.0) 2467 * 2468 * @param string $value Custom class to use. Default: none. 2469 * @param array $args Array of arguments for sugggestions. 2470 */ 2131 2471 $class = apply_filters( 'bp_suggestions_services', '', $args ); 2132 2472 } … … 2146 2486 } 2147 2487 2488 /** 2489 * Filters the available type of at-mentions. 2490 * 2491 * @since BuddyPress (2.1.0) 2492 * 2493 * @param array|WP_Error $retval Array of results or WP_Error object. 2494 * @param array $args Array of arguments for suggestions. 2495 */ 2148 2496 return apply_filters( 'bp_core_get_suggestions', $retval, $args ); 2149 2497 }
Note: See TracChangeset
for help on using the changeset viewer.