Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/15/2013 12:17:45 AM (9 years ago)
Author:
boonebgorges
Message:

Adds link_title support to Recent Networkwide Posts widget

This allows admins to decide whether they'd like the title of this widget to
link to the Sites directory.

Fixes #4982

Props lenasterg

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs/bp-blogs-widgets.php

    r7065 r7066  
    2828    function widget($args, $instance) {
    2929
    30         extract( $args );
     30        $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : __( 'Recent Networkwide Posts', 'buddypress' );
    3131
    32         $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Recent Networkwide Posts', 'buddypress' );
     32        if ( ! empty( $instance['link_title'] ) ) {
     33            $title = '<a href="' . trailingslashit( bp_get_root_domain() ) . trailingslashit( bp_get_blogs_root_slug() ) . '">' . esc_html( $title ) . '</a>';
     34        }
    3335
    3436        echo $args['before_widget'];
    35         echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
     37        echo $args['before_title'] . $title . $args['after_title'];
    3638
    3739        if ( empty( $instance['max_posts'] ) || !$instance['max_posts'] )
     
    7981        $instance['title'] = strip_tags( $new_instance['title'] );
    8082        $instance['max_posts'] = strip_tags( $new_instance['max_posts'] );
     83        $instance['link_title'] = (bool) $new_instance['link_title'];
    8184
    8285        return $instance;
     
    8588    function form( $instance ) {
    8689        $instance = wp_parse_args( (array) $instance, array(
    87             'title'     => __( 'Recent Networkwide Posts', 'buddypress' ),
    88             'max_posts' => 10,
     90            'title'      => __( 'Recent Networkwide Posts', 'buddypress' ),
     91            'max_posts'  => 10,
     92            'link_title' => false,
    8993        ) );
    9094
    9195        $title = strip_tags( $instance['title'] );
    9296        $max_posts = strip_tags( $instance['max_posts'] );
     97        $link_title = (bool) $instance['link_title'];
    9398
    9499        ?>
    95100
    96101        <p><label for="<?php echo $this->get_field_id( 'title' ) ?>"><?php _ex( 'Title:', 'Label for the Title field of the Recent Networkwide Posts widget', 'buddypress' ) ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ) ?>" name="<?php echo $this->get_field_name( 'title' ) ?>" type="text" value="<?php echo esc_attr( $title ) ?>" style="width: 100%;" /></label></p>
     102        <p><label for="<?php echo $this->get_field_id( 'link_title' ) ?>"><input type="checkbox" name="<?php echo $this->get_field_name( 'link_title' ) ?>" value="1" <?php checked( $link_title ) ?> /> <?php _e( 'Link widget title to Blogs directory', 'buddypress' ) ?></label></p>
    97103        <p><label for="bp-blogs-widget-posts-max"><?php _e('Max posts to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="text" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p>
    98104    <?php
Note: See TracChangeset for help on using the changeset viewer.