Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/07/2015 05:06:57 AM (11 years ago)
Author:
tw2113
Message:

Adds hooks documentation for bp-core-template.php and class-bp-attachment-avatar.php.

See: #5940.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-template.php

    r9707 r9715  
    7272                $list_type = bp_is_group() ? 'groups' : 'personal';
    7373
    74                 // echo out the final list item
     74                /**
     75                 * Filters the "options nav", the secondary-level single item navigation menu.
     76                 *
     77                 * This is a dynamic filter that is dependent on the provided css_id value.
     78                 *
     79                 * @since BuddyPress (1.1.0)
     80                 *
     81                 * @param string $value         HTML list item for the submenu item.
     82                 * @param array  $subnav_item   Submenu array item being displayed.
     83                 * @param string $selected_item Current action.
     84                 */
    7585                echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="' . esc_attr( $subnav_item['css_id'] . '-' . $list_type . '-li' ) . '" ' . $selected . '><a id="' . esc_attr( $subnav_item['css_id'] ) . '" href="' . esc_url( $subnav_item['link'] ) . '">' . $subnav_item['name'] . '</a></li>', $subnav_item, $selected_item );
    7686        }
     
    115125        }
    116126
     127        /**
     128         * Filters the directory title for a component.
     129         *
     130         * @since BuddyPress (2.0.0)
     131         *
     132         * @param string $title     Text to be used in <title> tag.
     133         * @param string $component Current componet being displayed.
     134         */
    117135        return apply_filters( 'bp_get_directory_title', $title, $component );
    118136}
     
    201219                        : 'upload-image';
    202220
     221                /**
     222                 * Filters the current avatar upload step.
     223                 *
     224                 * @since BuddyPress (1.1.0)
     225                 *
     226                 * @param string $step The current avatar upload step.
     227                 */
    203228                return apply_filters( 'bp_get_avatar_admin_step', $step );
    204229        }
     
    221246                        : '';
    222247
     248                /**
     249                 * Filters the URL of the avatar to crop.
     250                 *
     251                 * @since BuddyPress (1.1.0)
     252                 *
     253                 * @param string $url URL for the avatar.
     254                 */
    223255                return apply_filters( 'bp_get_avatar_to_crop', $url );
    224256        }
     
    241273                        : '';
    242274
     275                /**
     276                 * Filters the relative file path to the avatar to crop.
     277                 *
     278                 * @since BuddyPress (1.1.0)
     279                 *
     280                 * @param string $src Relative file path for the avatar.
     281                 */
    243282                return apply_filters( 'bp_get_avatar_to_crop_src', $src );
    244283        }
     
    269308         */
    270309        function bp_get_site_name() {
     310
     311                /**
     312                 * Filters the name of the BP site. Used in RSS headers.
     313                 *
     314                 * @since BuddyPress (1.0.0)
     315                 *
     316                 * @param string $value Current BP site name.
     317                 */
    271318                return apply_filters( 'bp_site_name', get_bloginfo( 'name', 'display' ) );
    272319        }
     
    343390        }
    344391
     392        /**
     393         * Filters the date based on a UNIX timestamp.
     394         *
     395         * @since BuddyPress (1.0.0)
     396         *
     397         * @param string $formatted_date Formatted date from the timestamp.
     398         */
    345399        return apply_filters( 'bp_format_time', $formatted_date );
    346400}
     
    372426        if ( bp_displayed_user_id() == bp_loggedin_user_id() ) {
    373427                if ( true == $echo ) {
     428
     429                        /**
     430                         * Filters the text used based on context of own profile or someone else's profile.
     431                         *
     432                         * @since BuddyPress (1.0.0)
     433                         *
     434                         * @param string $youtext Context-determined string to display.
     435                         */
    374436                        echo apply_filters( 'bp_word_or_name', $youtext );
    375437                } else {
     438
     439                        /** This filter is documented in bp-core/bp-core-template.php */
    376440                        return apply_filters( 'bp_word_or_name', $youtext );
    377441                }
     
    381445                $nametext = sprintf( $nametext, $fullname[0] );
    382446                if ( true == $echo ) {
     447
     448                        /** This filter is documented in bp-core/bp-core-template.php */
    383449                        echo apply_filters( 'bp_word_or_name', $nametext );
    384450                } else {
     451
     452                        /** This filter is documented in bp-core/bp-core-template.php */
    385453                        return apply_filters( 'bp_word_or_name', $nametext );
    386454                }
     
    408476 */
    409477function bp_search_form_action() {
     478
     479        /**
     480         * Filters the "action" attribute for search forms.
     481         *
     482         * @since BuddyPress (1.0.0)
     483         *
     484         * @param string $value Search form action url.
     485         */
    410486        return apply_filters( 'bp_search_form_action', trailingslashit( bp_get_root_domain() . '/' . bp_get_search_slug() ) );
    411487}
     
    444520        $selection_box .= '<select name="search-which" id="search-which" style="width: auto">';
    445521
     522        /**
     523         * Filters all of the component options available for search scope.
     524         *
     525         * @since BuddyPress (1.5.0)
     526         *
     527         * @param array $options Array of options to add to select field.
     528         */
    446529        $options = apply_filters( 'bp_search_form_type_select_options', $options );
    447530        foreach( (array) $options as $option_value => $option_title ) {
     
    451534        $selection_box .= '</select>';
    452535
     536        /**
     537         * Filters the complete <select> input used for search scope.
     538         *
     539         * @since BuddyPress (1.0.0)
     540         *
     541         * @param string $selection_box <select> input for selecting search scope.
     542         */
    453543        return apply_filters( 'bp_search_form_type_select', $selection_box );
    454544}
     
    500590                }
    501591
     592                /**
     593                 * Filters the default text for the search box for a given component.
     594                 *
     595                 * @since BuddyPress (1.5.0)
     596                 *
     597                 * @param string $default_text Default text for search box.
     598                 * @param string $component    Current component displayed.
     599                 */
    502600                return apply_filters( 'bp_get_search_default_text', $default_text, $component );
    503601        }
     
    619717        function bp_get_button( $args = '' ) {
    620718                $button = new BP_Button( $args );
     719
     720                /**
     721                 * Filters the requested button output.
     722                 *
     723                 * @since BuddyPress (1.2.6)
     724                 *
     725                 * @param string    $contents  Button context to be used.
     726                 * @param array     $args      Array of args for the button.
     727                 * @param BP_Button $button    BP_Button object.
     728                 */
    621729                return apply_filters( 'bp_get_button', $button->contents, $args, $button );
    622730        }
     
    669777        $original_text = $text;
    670778
    671         // Allow plugins to modify these values globally
     779        /**
     780         * Filters the excerpt length to trim text to.
     781         *
     782         * @since BuddyPress (1.5.0)
     783         *
     784         * @param int $length Length of returned string, including ellipsis.
     785         */
    672786        $length = apply_filters( 'bp_excerpt_length',      $length      );
     787
     788        /**
     789         * Filters the excerpt appended text value.
     790         *
     791         * @since BuddyPress (1.5.0)
     792         *
     793         * @param string $value Text to append to the end of the excerpt.
     794         */
    673795        $ending = apply_filters( 'bp_excerpt_append_text', $r['ending'] );
    674796
     
    768890        }
    769891
     892        /**
     893         * Filters the final generated excerpt.
     894         *
     895         * @since BuddyPress (1.1.0)
     896         *
     897         * @param string $truncate      Generated excerpt.
     898         * @param string $original_text Original text provided.
     899         * @param int    $length        Length of returned string, including ellipsis.
     900         * @param array  $options       Array of HTML attributes and options.
     901         */
    770902        return apply_filters( 'bp_create_excerpt', $truncate, $original_text, $length, $options );
    771903}
     
    794926         */
    795927        function bp_get_total_member_count() {
     928
     929                /**
     930                 * Filters the total member count in your BP instance.
     931                 *
     932                 * @since BuddyPress (1.2.0)
     933                 *
     934                 * @param int $value Member count.
     935                 */
    796936                return apply_filters( 'bp_get_total_member_count', bp_core_get_active_member_count() );
    797937        }
     
    853993 */
    854994function bp_registration_needs_activation() {
     995
     996        /**
     997         * Filters whether registrations require activation on this installation.
     998         *
     999         * @since BuddyPress (1.2.0)
     1000         *
     1001         * @param bool $value Whether registrations require activation. Default true.
     1002         */
    8551003        return apply_filters( 'bp_registration_needs_activation', true );
    8561004}
     
    8901038        $subject = $r['before'] . wp_specialchars_decode( bp_get_option( 'blogname', $r['default'] ), ENT_QUOTES ) . $r['after'] . ' ' . $r['text'];
    8911039
     1040        /**
     1041         * Filters a client friendly version of the root blog name.
     1042         *
     1043         * @since BuddyPress (1.7.0)
     1044         *
     1045         * @param string $subject Client friendy version of the root blog name.
     1046         * @param array  $r       Array of arguments for the email subject.
     1047         */
    8921048        return apply_filters( 'bp_get_email_subject', $subject, $r );
    8931049}
     
    9131069        }
    9141070
     1071        /**
     1072         * Filters the template paramenters to be used in the query string.
     1073         *
     1074         * Allows templates to pass parameters into the template loops via AJAX.
     1075         *
     1076         * @since BuddyPress (1.2.0)
     1077         *
     1078         * @param string $ajax_querystring Current query string.
     1079         * @param string $object           Current template component.
     1080         */
    9151081        return apply_filters( 'bp_ajax_querystring', $bp->ajax_querystring, $object );
    9161082}
     
    9291095                : false;
    9301096
     1097        /**
     1098         * Filters the name of the current component.
     1099         *
     1100         * @since BuddyPress (1.0.0)
     1101         *
     1102         * @param string|bool $current_component Current component if available or false.
     1103         */
    9311104        return apply_filters( 'bp_current_component', $current_component );
    9321105}
     
    9431116                : '';
    9441117
     1118        /**
     1119         * Filters the name of the current action.
     1120         *
     1121         * @since BuddyPress (1.0.0)
     1122         *
     1123         * @param string $current_action Current action.
     1124         */
    9451125        return apply_filters( 'bp_current_action', $current_action );
    9461126}
     
    9571137                : false;
    9581138
     1139        /**
     1140         * Filters the name of the current item.
     1141         *
     1142         * @since BuddyPress (1.1.0)
     1143         *
     1144         * @param string|bool $current_item Current item if available or false.
     1145         */
    9591146        return apply_filters( 'bp_current_item', $current_item );
    9601147}
     
    9721159                : false;
    9731160
     1161        /**
     1162         * Filters the value of $bp->action_variables.
     1163         *
     1164         * @since BuddyPress (1.0.0)
     1165         *
     1166         * @param array|bool $action_variables Available action variables.
     1167         */
    9741168        return apply_filters( 'bp_action_variables', $action_variables );
    9751169}
     
    9901184                : false;
    9911185
     1186        /**
     1187         * Filters the value of a given action variable.
     1188         *
     1189         * @since BuddyPress (1.5.0)
     1190         *
     1191         * @param string|bool $action_variable Requested action variable based on position.
     1192         * @param int         $position        The key of the action variable requested.
     1193         */
    9921194        return apply_filters( 'bp_action_variable', $action_variable, $position );
    9931195}
     
    10141216                }
    10151217
     1218                /**
     1219                 * Filters the "root domain", the URL of the BP root blog.
     1220                 *
     1221                 * @since BuddyPress (1.2.4)
     1222                 *
     1223                 * @param string $domain URL of the BP root blog.
     1224                 */
    10161225                return apply_filters( 'bp_get_root_domain', $domain );
    10171226        }
     
    10861295                }
    10871296
     1297                /**
     1298                 * Filters the root slug for given component.
     1299                 *
     1300                 * @since BuddyPress (1.5.0)
     1301                 *
     1302                 * @param string $root_slug Root slug for given component.
     1303                 * @param string $component Current component.
     1304                 */
    10881305                return apply_filters( 'bp_get_root_slug', $root_slug, $component );
    10891306        }
     
    11251342                : false;
    11261343
     1344        /**
     1345         * Filters whether or not a user has access.
     1346         *
     1347         * @since BuddyPress (1.2.4)
     1348         *
     1349         * @param bool $has_access Whether or not user has access.
     1350         */
    11271351        return (bool) apply_filters( 'bp_user_has_access', $has_access );
    11281352}
     
    11461370         */
    11471371        function bp_get_search_slug() {
     1372
     1373                /**
     1374                 * Filters the search slug.
     1375                 *
     1376                 * @since BuddyPress (1.5.0)
     1377                 *
     1378                 * @param string BP_SEARCH_SLUG The search slug. Default "search".
     1379                 */
    11481380                return apply_filters( 'bp_get_search_slug', BP_SEARCH_SLUG );
    11491381        }
     
    11621394                : 0;
    11631395
     1396        /**
     1397         * Filters the ID of the currently displayed user.
     1398         *
     1399         * @since BuddyPress (1.0.0)
     1400         *
     1401         * @param int $id ID of the currently displayed user.
     1402         */
    11641403        return (int) apply_filters( 'bp_displayed_user_id', $id );
    11651404}
     
    11781417                : 0;
    11791418
     1419        /**
     1420         * Filters the ID of the currently logged-in user.
     1421         *
     1422         * @since BuddyPress (1.0.0)
     1423         *
     1424         * @param int $id ID of the currently logged-in user.
     1425         */
    11801426        return (int) apply_filters( 'bp_loggedin_user_id', $id );
    11811427}
     
    12571503        }
    12581504
     1505        /**
     1506         * Filters whether the current page belongs to the specified component.
     1507         *
     1508         * @since BuddyPress (1.5.0)
     1509         *
     1510         * @param bool   $is_current_component Whether or not the current page belongs to specified component.
     1511         * @param string $component            Name of the component being checked.
     1512         */
    12591513        return apply_filters( 'bp_is_current_component', $is_current_component, $component );
    12601514}
     
    13181572        }
    13191573
     1574        /**
     1575         * Filters whether the current page matches a given action_variable.
     1576         *
     1577         * @since BuddyPress (1.5.0)
     1578         *
     1579         * @param bool   $is_action_variable Whether the current page matches a given action_variable.
     1580         * @param string $action_variable    The action_variable being tested against.
     1581         * @param int    $position           The array key tested against.
     1582         */
    13201583        return apply_filters( 'bp_is_action_variable', $is_action_variable, $action_variable, $position );
    13211584}
     
    13301593        $retval = ( $item === bp_current_item() );
    13311594
     1595        /**
     1596         * Filters whether or not an item is the current item.
     1597         *
     1598         * @since BuddyPress (2.1.0)
     1599         *
     1600         * @param bool   $retval Whether or not an item is the current item.
     1601         * @param string $item   The item being checked.
     1602         */
    13321603        return (bool) apply_filters( 'bp_is_current_item', $retval, $item );
    13331604}
     
    13461617        }
    13471618
     1619        /**
     1620         * Filters whether or not an item is the a single item. (group, user, etc)
     1621         *
     1622         * @since BuddyPress (2.1.0)
     1623         *
     1624         * @param bool $retval Whether or not an item is a single item.
     1625         */
    13481626        return (bool) apply_filters( 'bp_is_single_item', $retval );
    13491627}
     
    13631641        }
    13641642
     1643        /**
     1644         * Filters whether or not the logged-in user is an admin for the current item.
     1645         *
     1646         * @since BuddyPress (2.1.0)
     1647         *
     1648         * @param bool $retval Whether or not the logged-in user is an admin.
     1649         */
    13651650        return (bool) apply_filters( 'bp_is_item_admin', $retval );
    13661651}
     
    13801665        }
    13811666
     1667        /**
     1668         * Filters whether or not the logged-in user is a mod for the current item.
     1669         *
     1670         * @since BuddyPress (2.1.0)
     1671         *
     1672         * @param bool $retval Whether or not the logged-in user is a mod.
     1673         */
    13821674        return (bool) apply_filters( 'bp_is_item_mod', $retval );
    13831675}
     
    13971689        }
    13981690
     1691        /**
     1692         * Filters whether or not user is on a component directory page.
     1693         *
     1694         * @since BuddyPress (2.1.0)
     1695         *
     1696         * @param bool $retval Whether or not user is on a component directory page.
     1697         */
    13991698        return (bool) apply_filters( 'bp_is_directory', $retval );
    14001699}
     
    14301729        }
    14311730
     1731        /**
     1732         * Filters whether or not a component's URL should be in the root, not under a member page.
     1733         *
     1734         * @since BuddyPress (2.1.0)
     1735         *
     1736         * @param bool $retval Whether or not URL should be in the root.
     1737         */
    14321738        return (bool) apply_filters( 'bp_is_root_component', $retval );
    14331739}
     
    14701776        }
    14711777
     1778        /**
     1779         * Filters whether or not the specified BuddyPress component directory is set to be the front page.
     1780         *
     1781         * @since BuddyPress (1.5.0)
     1782         *
     1783         * @param bool   $value     Whether or not the specified component directory is set as front page.
     1784         * @param string $component Current component being checked.
     1785         */
    14721786        return (bool) apply_filters( 'bp_is_component_front_page', ( $bp->pages->{$component}->id == $page_on_front ), $component );
    14731787}
     
    14921806        }
    14931807
     1808        /**
     1809         * Filters whether or not current page is a blog page or not.
     1810         *
     1811         * @since BuddyPress (1.5.0)
     1812         *
     1813         * @param bool $is_blog_page Whether or not current page is a blog page.
     1814         */
    14941815        return (bool) apply_filters( 'bp_is_blog_page', $is_blog_page );
    14951816}
     
    15121833        $retval = (bool) ( bp_current_component() || bp_is_user() );
    15131834
     1835        /**
     1836         * Filters whether or not this is a BuddyPress component.
     1837         *
     1838         * @since BuddyPress (1.7.0)
     1839         *
     1840         * @param bool $retval Whether or not this is a BuddyPress component.
     1841         */
    15141842        return apply_filters( 'is_buddypress', $retval );
    15151843}
     
    15361864        }
    15371865
     1866        /**
     1867         * Filters whether or not a given component has been activated by the admin.
     1868         *
     1869         * @since BuddyPress (2.1.0)
     1870         *
     1871         * @param bool   $retval    Whether or not a given component has been activated by the admin.
     1872         * @param string $component Current component being checked.
     1873         */
    15381874        return apply_filters( 'bp_is_active', $retval, $component );
    15391875}
     
    17142050        }
    17152051
     2052        /**
     2053         * Filters whether or not current page is part of the profile for the logged-in user.
     2054         *
     2055         * @since BuddyPress (1.2.4)
     2056         *
     2057         * @param bool $my_profile Whether or not current page is part of the profile for the logged-in user.
     2058         */
    17162059        return apply_filters( 'bp_is_my_profile', $my_profile );
    17172060}
     
    25352878                $classes = array_unique( array_merge( (array) $bp_classes, (array) $wp_classes ) );
    25362879
     2880                /**
     2881                 * Filters the BuddyPress classes to be added to body_class()
     2882                 *
     2883                 * @since BuddyPress (1.1.0)
     2884                 *
     2885                 * @param array $classes        Array of body classes to add.
     2886                 * @param array $bp_classes     Array of BuddyPress-based classes.
     2887                 * @param array $wp_classes     Array of WordPress-based classes.
     2888                 * @param array $custom_classes Array of classes that were passed to get_body_class().
     2889                 */
    25372890                return apply_filters( 'bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes );
    25382891        }
     
    27033056        }
    27043057
     3058        /**
     3059         * Filters the items registered in the primary and secondary BuddyPress navigation menus.
     3060         *
     3061         * @since BuddyPress (1.7.0)
     3062         *
     3063         * @param array $menus Array of items registered in the primary and secondary BuddyPress navigation.
     3064         */
    27053065        return apply_filters( 'bp_get_nav_menu_items', $menus );
    27063066}
     
    27623122        );
    27633123        $args = wp_parse_args( $args, $defaults );
     3124
     3125        /**
     3126         * Filters the parsed bp_nav_menu arguments.
     3127         *
     3128         * @since BuddyPress (1.7.0)
     3129         *
     3130         * @param array $args Array of parsed arguments.
     3131         */
    27643132        $args = apply_filters( 'bp_nav_menu_args', $args );
    27653133        $args = (object) $args;
     
    27793147        // Whether to wrap the ul, and what to wrap it with
    27803148        if ( $args->container ) {
     3149
     3150                /**
     3151                 * Filters the allowed tags for the wp_nav_menu_container.
     3152                 *
     3153                 * @since BuddyPress (1.7.0)
     3154                 *
     3155                 * @param array $value Array of allowed tags. Default 'div' and 'nav'.
     3156                 */
    27813157                $allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav', ) );
    27823158
     
    27903166        }
    27913167
    2792         // Get the BuddyPress menu items
     3168        /**
     3169         * Filters the BuddyPress menu objects.
     3170         *
     3171         * @since BuddyPress (1.7.0)
     3172         *
     3173         * @param array $value Array of nav menu objects.
     3174         * @param array $args  Array of arguments for the menu.
     3175         */
    27933176        $menu_items = apply_filters( 'bp_nav_menu_objects', bp_get_nav_menu_items(), $args );
    27943177        $items      = walk_nav_menu_tree( $menu_items, $args->depth, $args );
     
    28133196        $menu_id_slugs[] = $wrap_id;
    28143197
    2815         // Allow plugins to hook into the menu to add their own <li>'s
     3198        /**
     3199         * Filters the BuddyPress menu items.
     3200         *
     3201         * Allow plugins to hook into the menu to add their own <li>'s
     3202         *
     3203         * @since BuddyPress (1.7.0)
     3204         *
     3205         * @param array $items Array of nav menu items.
     3206         * @param array $args  Array of arguments for the menu.
     3207         */
    28163208        $items = apply_filters( 'bp_nav_menu_items', $items, $args );
    28173209
     
    28263218        }
    28273219
    2828         // Final chance to modify output
     3220        /**
     3221         * Filters the final BuddyPress menu output.
     3222         *
     3223         * @since BuddyPress (1.7.0)
     3224         *
     3225         * @param string $nav_menu Final nav menu output.
     3226         * @param array  $args     Array of arguments for the menu.
     3227         */
    28293228        $nav_menu = apply_filters( 'bp_nav_menu', $nav_menu, $args );
    28303229
Note: See TracChangeset for help on using the changeset viewer.