Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/09/2014 12:54:33 AM (12 years ago)
Author:
tw2113
Message:

Add hook documentation for the Blogs component

Fixes #5939

File:
1 edited

Legend:

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

    r8999 r9218  
    2929         */
    3030        function bp_get_blogs_slug() {
     31
     32                /**
     33                 * Filters the blogs component slug.
     34                 *
     35                 * @since BuddyPress (1.5.0)
     36                 *
     37                 * @param string $slug Slug for the blogs component.
     38                 */
    3139                return apply_filters( 'bp_get_blogs_slug', buddypress()->blogs->slug );
    3240        }
    … …  
    5058         */
    5159        function bp_get_blogs_root_slug() {
     60
     61                /**
     62                 * Filters the blogs component root slug.
     63                 *
     64                 * @since BuddyPress (1.5.0)
     65                 *
     66                 * @param string $root_slug Root slug for the blogs component.
     67                 */
    5268                return apply_filters( 'bp_get_blogs_root_slug', buddypress()->blogs->root_slug );
    5369        }
    … …  
    7591         */
    7692        function bp_get_blogs_directory_permalink() {
     93
     94                /**
     95                 * Filters the blog directory permalink.
     96                 *
     97                 * @since BuddyPress (1.5.0)
     98                 *
     99                 * @param string $value Permalink URL for the blog directory.
     100                 */
    77101                return apply_filters( 'bp_get_blogs_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() ) );
    78102        }
    … …  
    278302                        return true;
    279303                } elseif ( ( $this->current_blog + 1 ) === $this->blog_count ) {
     304
     305                        /**
     306                         * Fires right before the rewinding of blogs listing after all are shown.
     307                         *
     308                         * @since BuddyPress (1.5.0)
     309                         */
    280310                        do_action( 'blog_loop_end' );
    281311                        // Do some cleaning up after the loop
    … …  
    303333                // loop has just started
    304334                if ( 0 === $this->current_blog ) {
     335
     336                        /**
     337                         * Fires if on the first blog in the loop.
     338                         *
     339                         * @since BuddyPress (1.5.0)
     340                         */
    305341                        do_action( 'blog_loop_start' );
    306342                }
    … …  
    384420        $blogs_template = new BP_Blogs_Template( $r['type'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['search_terms'], $r['page_arg'], $r['update_meta_cache'], $r['include_blog_ids'] );
    385421
    386         // Filter and return
     422        /**
     423         * Filters whether or not there are blogs to list.
     424         *
     425         * @since BuddyPress (1.1.0)
     426         *
     427         * @param bool              $value          Whether or not there are blogs to list.
     428         * @param BP_Blogs_Template $blogs_template Current blogs template object.
     429         * @param array             $r              Parsed arguments used in blogs template query.
     430         */
    387431        return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), $blogs_template, $r );
    388432}
    … …  
    446490                global $blogs_template;
    447491
     492                /**
     493                 * Filters the blogs pagination links.
     494                 *
     495                 * @since BuddyPress (1.0.0)
     496                 *
     497                 * @param string $pag_links HTML pagination links.
     498                 */
    448499                return apply_filters( 'bp_get_blogs_pagination_links', $blogs_template->pag_links );
    449500        }
    … …  
    527578                $avatar = apply_filters( 'bp_get_blog_avatar_' . $blogs_template->blog->blog_id, $avatar );
    528579
     580                /**
     581                 * Filters a blog's avatar.
     582                 *
     583                 * @since BuddyPress (1.5.0)
     584                 *
     585                 * @param string $avatar  Formatted HTML <img> element, or raw avatar
     586                 *                        URL based on $html arg.
     587                 * @param int    $blog_id ID of the blog whose avatar is being displayed.
     588                 * @param array  $r       Array of arguments used when fetching avatar.
     589                 */
    529590                return apply_filters( 'bp_get_blog_avatar', $avatar, $blogs_template->blog->blog_id, $r );
    530591        }
    … …  
    546607                }
    547608
     609                /**
     610                 * Filters the blog permalink.
     611                 *
     612                 * @since BuddyPress (1.0.0)
     613                 *
     614                 * @param string $permalink Permalink URL for the blog.
     615                 */
    548616                return apply_filters( 'bp_get_blog_permalink', $permalink );
    549617        }
    … …  
    563631                global $blogs_template;
    564632
     633                /**
     634                 * Filters the name of the current blog in the loop.
     635                 *
     636                 * @since BuddyPress (1.2.0)
     637                 *
     638                 * @param string $name Name of the current blog in the loop.
     639                 */
    565640                return apply_filters( 'bp_get_blog_name', $blogs_template->blog->name );
    566641        }
    … …  
    584659                global $blogs_template;
    585660
     661                /**
     662                 * Filters the ID of the current blog in the loop.
     663                 *
     664                 * @since BuddyPress (1.7.0)
     665                 *
     666                 * @param int $blog_id ID of the current blog in the loop.
     667                 */
    586668                return apply_filters( 'bp_get_blog_id', $blogs_template->blog->blog_id );
    587669        }
    … …  
    591673 */
    592674function bp_blog_description() {
     675
     676        /**
     677         * Filters the description of the current blog in the loop.
     678         *
     679         * @since BuddyPress (1.2.0)
     680         *
     681         * @param string $value Description of the current blog in the loop.
     682         */
    593683        echo apply_filters( 'bp_blog_description', bp_get_blog_description() );
    594684}
    … …  
    601691                global $blogs_template;
    602692
     693                /**
     694                 * Filters the description of the current blog in the loop.
     695                 *
     696                 * @since BuddyPress (1.0.0)
     697                 *
     698                 * @param string $value Description of the current blog in the loop.
     699                 */
    603700                return apply_filters( 'bp_get_blog_description', $blogs_template->blog->description );
    604701        }
    … …  
    633730                        $classes[] = 'bp-single-blog';
    634731
     732                /**
     733                 * Filters the row class of the current blog in the loop.
     734                 *
     735                 * @since BuddyPress (1.7.0)
     736                 *
     737                 * @param array $classes Array of classes to be applied to row.
     738                 */
    635739                $classes = apply_filters( 'bp_get_blog_class', $classes );
    636740                $classes = array_merge( $classes, array() );
    … …  
    684788                }
    685789
     790                /**
     791                 * Filters the last active date of the current blog in the loop.
     792                 *
     793                 * @since
     794                 *
     795                 * @param string $last_activity Last active date.
     796                 * @param array  $r             Array of parsed args used to determine formatting.
     797                 */
    686798                return apply_filters( 'bp_blog_last_active', $last_activity, $r );
    687799        }
    … …  
    717829                if ( ! empty( $retval ) ) {
    718830                        if ( ! empty( $r['latest_format'] ) ) {
     831
     832                                /**
     833                                 * Filters the title text of the latest post for the current blog in loop.
     834                                 *
     835                                 * @since BuddyPress (1.0.0)
     836                                 *
     837                                 * @param string $retval Title of the latest post.
     838                                 */
    719839                                $retval = sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>' );
    720840                        } else {
     841
     842                                /** This filter is documented in bp-blogs/bp-blogs-template.php */
    721843                                $retval = '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>';
    722844                        }
    723845                }
    724846
     847                /**
     848                 * Filters the HTML markup result for the latest blog post in loop.
     849                 *
     850                 * @since BuddyPress (1.2.0)
     851                 *
     852                 * @param string $retval HTML markup for the latest post.
     853                 */
    725854                return apply_filters( 'bp_get_blog_latest_post', $retval );
    726855        }
    … …  
    753882                        $retval = $blogs_template->blog->latest_post->post_title;
    754883
     884                /**
     885                 * Filters the title text of the latest post on the current blog in the loop.
     886                 *
     887                 * @since BuddyPress (1.7.0)
     888                 *
     889                 * @param string $retval Title text for the latest post.
     890                 */
    755891                return apply_filters( 'bp_get_blog_latest_post_title', $retval );
    756892        }
    … …  
    783919                        $retval = add_query_arg( 'p', $blogs_template->blog->latest_post->ID, bp_get_blog_permalink() );
    784920
     921                /**
     922                 * Filters the permalink of the latest post on the current blog in the loop.
     923                 *
     924                 * @since BuddyPress (1.7.0)
     925                 *
     926                 * @param string $retval Permalink URL of the latest post.
     927                 */
    785928                return apply_filters( 'bp_get_blog_latest_post_permalink', $retval );
    786929        }
    … …  
    813956                        $retval = $blogs_template->blog->latest_post->post_content;
    814957
     958                /**
     959                 * Filters the content of the latest post on the current blog in the loop.
     960                 *
     961                 * @since BuddyPress (1.7.0)
     962                 *
     963                 * @param string $retval Content of the latest post on the current blog in the loop.
     964                 */
    815965                return apply_filters( 'bp_get_blog_latest_post_content', $retval );
    816966        }
    … …  
    847997                        $retval = $blogs_template->blog->latest_post->images[$size];
    848998
     999                /**
     1000                 * Filters the featured image of the latest post on the current blog in the loop.
     1001                 *
     1002                 * @since BuddyPress (1.7.0)
     1003                 *
     1004                 * @param string $retval The featured image of the latest post on the current blog in the loop.
     1005                 */
    8491006                return apply_filters( 'bp_get_blog_latest_post_featured_image', $retval );
    8501007        }
    … …  
    8631020        $image  = bp_get_blog_latest_post_featured_image( $thumbnail );
    8641021
     1022        /**
     1023         * Filters whether or not the latest blog post has a featured image.
     1024         *
     1025         * @since BuddyPress (1.7.0)
     1026         *
     1027         * @param bool   $value     Whether or not the latest blog post has a featured image.
     1028         * @param string $thumbnail Image version to return.
     1029         * @param string $image     Returned value from bp_get_blog_latest_post_featured_image.
     1030         */
    8651031        return apply_filters( 'bp_blog_latest_post_has_featured_image', ! empty( $image ), $thumbnail, $image );
    8661032}
    … …  
    8961062         */
    8971063        function bp_get_total_blog_count() {
     1064
     1065                /**
     1066                 * Filters the total number of blogs on the site.
     1067                 *
     1068                 * @since BuddyPress (1.2.0)
     1069                 *
     1070                 * @param int $value Total number of blogs on the site.
     1071                 */
    8981072                return apply_filters( 'bp_get_total_blog_count', bp_blogs_total_blogs() );
    8991073        }
    … …  
    9151089         */
    9161090        function bp_get_total_blog_count_for_user( $user_id = 0 ) {
     1091
     1092                /**
     1093                 * Filters the total number of blogs for a given user.
     1094                 *
     1095                 * @since BuddyPress (1.2.0)
     1096                 *
     1097                 * @param int $value Total number of blogs for a given user.
     1098                 */
    9171099                return apply_filters( 'bp_get_total_blog_count_for_user', bp_blogs_total_blogs_for_user( $user_id ) );
    9181100        }
    … …  
    9351117        $active_signup = isset( $bp->site_options['registration'] ) ? $bp->site_options['registration'] : 'all';
    9361118
     1119        /**
     1120         * Filters whether or not blog creation is enabled.
     1121         *
     1122         * @since BuddyPress (1.0.0)
     1123         *
     1124         * @param string $active_signup Value of the registration site option creation status.
     1125         */
    9371126        $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
    9381127
    … …  
    9611150                }
    9621151
    963                 // allow definition of default variables
     1152                /**
     1153                 * Filters the default values for Blog name, title, and any current errors.
     1154                 *
     1155                 * @since BuddyPress (1.0.0)
     1156                 *
     1157                 * @param array $value {
     1158                 *      string   $blogname   Default blog name provided.
     1159                 *      string   $blog_title Default blog title provided.
     1160                 *      WP_Error $errors     WP_Error object.
     1161                 * }
     1162                 */
    9641163                $filtered_results = apply_filters('signup_another_blog_init', array('blogname' => $blogname, 'blog_title' => $blog_title, 'errors' => $errors ));
    9651164                $blogname = $filtered_results['blogname'];
    … …  
    9781177
    9791178                        <input type="hidden" name="stage" value="gimmeanotherblog" />
    980                         <?php do_action( 'signup_hidden_fields' ); ?>
     1179                        <?php
     1180
     1181                        /**
     1182                         * Fires after the default hidden fields in blog signup form markup.
     1183                         *
     1184                         * @since BuddyPress (1.0.0)
     1185                         */
     1186                        do_action( 'signup_hidden_fields' ); ?>
    9811187
    9821188                        <?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?>
    … …  
    10591265
    10601266        <?php
     1267
     1268        /**
     1269         * Fires at the end of all of the default input fields for blog creation form.
     1270         *
     1271         * @since BuddyPress (1.0.0)
     1272         *
     1273         * @param WP_Error $errors WP_Error object if any present.
     1274         */
    10611275        do_action('signup_blogform', $errors);
    10621276}
    … …  
    10921306
    10931307        $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated
     1308
     1309        /**
     1310         * Filters the default values for Blog meta.
     1311         *
     1312         * @since BuddyPress (1.0.0)
     1313         *
     1314         * @param array $meta {
     1315         *      string   $value   Default blog language ID.
     1316         *      string   $public  Default public status.
     1317         * }
     1318         */
    10941319        $meta = apply_filters( 'add_signup_meta', $meta );
    10951320
    … …  
    11381363
    11391364<?php
     1365
     1366        /**
     1367         * Fires after the default successful blog registration messsage markup.
     1368         *
     1369         * @since BuddyPress (1.0.0)
     1370         */
    11401371        do_action('signup_finished');
    11411372}
    … …  
    11461377function bp_create_blog_link() {
    11471378        if ( bp_is_my_profile() )
     1379
     1380                /**
     1381                 * Filters "Create a Site" links for users viewing their own profiles.
     1382                 *
     1383                 * @since BuddyPress (1.0.0)
     1384                 *
     1385                 * @param string $value HTML link for creating a site.
     1386                 */
    11481387                echo apply_filters( 'bp_create_blog_link', '<a href="' . bp_get_root_domain() . '/' . bp_get_blogs_root_slug() . '/create/">' . __( 'Create a Site', 'buddypress' ) . '</a>' );
    11491388}
    … …  
    11691408
    11701409<?php
     1410
     1411        /**
     1412         * Fires after the markup for the navigation tabs for a user Blogs page.
     1413         *
     1414         * @since BuddyPress (1.0.0)
     1415         */
    11711416        do_action( 'bp_blogs_blog_tabs' );
    11721417}
    … …  
    11841429        </form>';
    11851430
     1431        /**
     1432         * Filters the output for the blog directory search form.
     1433         *
     1434         * @since BuddyPress (1.9.0)
     1435         *
     1436         * @param string $search_form_html HTML markup for blog directory search form.
     1437         */
    11861438        echo apply_filters( 'bp_directory_blogs_search_form', $search_form_html );
    11871439}
    … …  
    12211473                );
    12221474
     1475                /**
     1476                 * Filters the Create a Site button.
     1477                 *
     1478                 * @since BuddyPress (2.0.0)
     1479                 *
     1480                 * @param array $button_args Array of arguments to be used for the Create a Site button.
     1481                 */
    12231482                return bp_get_button( apply_filters( 'bp_get_blog_create_button', $button_args ) );
    12241483        }
    … …  
    12701529                $button = wp_parse_args( $args, $defaults );
    12711530
    1272                 // Filter and return the HTML button
     1531                /**
     1532                 * Filters the button for visiting a blog in a loop.
     1533                 *
     1534                 * @since BuddyPress (1.2.10)
     1535                 *
     1536                 * @param array $button Array of arguments to be used for the button to visit a blog.
     1537                 */
    12731538                return bp_get_button( apply_filters( 'bp_get_blogs_visit_blog_button', $button ) );
    12741539        }
    … …  
    13241589        }
    13251590
    1326         // Filter and return
     1591        /**
     1592         * Filters the number of blogs in user's profile.
     1593         *
     1594         * @since BuddyPress (2.0.0)
     1595         *
     1596         * @param string $value Output determined for the profile stats.
     1597         * @param array  $r     Array of arguments used for default output if none provided.
     1598         */
    13271599        return apply_filters( 'bp_blogs_get_profile_stats', $r['output'], $r );
    13281600}
Note: See TracChangeset for help on using the changeset viewer.