Skip to:
Content

BuddyPress.org


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

Make the title of the Recent Networkwide Posts widget editable by the admin

See #4982

Props lenasterg

File:
1 edited

Legend:

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

    r7064 r7065  
    3030        extract( $args );
    3131
    32         $widget_name = apply_filters( 'widget_title', $widget_name );
     32        $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Recent Networkwide Posts', 'buddypress' );
    3333
    3434        echo $args['before_widget'];
    35         echo $args['before_title'] . $widget_name . $args['after_title'];
     35        echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
    3636
    3737        if ( empty( $instance['max_posts'] ) || !$instance['max_posts'] )
     
    7777    function update( $new_instance, $old_instance ) {
    7878        $instance = $old_instance;
     79        $instance['title'] = strip_tags( $new_instance['title'] );
    7980        $instance['max_posts'] = strip_tags( $new_instance['max_posts'] );
    8081
     
    8384
    8485    function form( $instance ) {
    85         $instance = wp_parse_args( (array) $instance, array( 'max_posts' => 10 ) );
     86        $instance = wp_parse_args( (array) $instance, array(
     87            'title'     => __( 'Recent Networkwide Posts', 'buddypress' ),
     88            'max_posts' => 10,
     89        ) );
     90
     91        $title = strip_tags( $instance['title'] );
    8692        $max_posts = strip_tags( $instance['max_posts'] );
     93
    8794        ?>
    8895
     96        <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>
    8997        <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>
    9098    <?php
Note: See TracChangeset for help on using the changeset viewer.