Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/07/2012 07:48:58 PM (13 years ago)
Author:
djpaul
Message:

Add 'history' meta box to admin edit activity screen. See #3660.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-akismet.php

    r5622 r5623  
    5656        // Hook into the Activity wp-admin screen
    5757        add_action( 'bp_activity_admin_comment_row_actions', array( $this, 'comment_row_action' ), 10, 2 );
     58        add_action( 'bp_activity_admin_load',                array( $this, 'add_history_metabox' ) );
    5859    }
    5960
     
    9798                $b[ $k ] = $item;
    9899                if ( $k == 'edit' )
    99                     $b['history'] = '<a href="' . network_admin_url( 'admin.php?page=bp-activity&amp;action=edit&aid=' . $activity['id'] ) . '#history"> '. __( 'History', 'buddypress' ) . '</a>';
     100                    $b['history'] = '<a href="' . network_admin_url( 'admin.php?page=bp-activity&amp;action=edit&aid=' . $activity['id'] ) . '#bp_activity_history"> '. __( 'History', 'buddypress' ) . '</a>';
    100101            }
    101102
     
    104105
    105106        if ( $desc )
    106             echo '<span class="akismet-status"><a href="' . network_admin_url( 'admin.php?page=bp-activity&amp;action=edit&aid=' . $activity['id'] ) . '#history">' . htmlspecialchars( $desc ) . '</a></span>';
     107            echo '<span class="akismet-status"><a href="' . network_admin_url( 'admin.php?page=bp-activity&amp;action=edit&aid=' . $activity['id'] ) . '#bp_activity_history">' . htmlspecialchars( $desc ) . '</a></span>';
    107108
    108109        return apply_filters( 'bp_akismet_comment_row_action', $actions );
    109110    }
    110 
    111111
    112112    /**
     
    485485
    486486    /**
     487     * Adds a "History" meta box to the activity edit screen.
     488     *
     489     * @param string $screen_action The type of screen that has been requested
     490     * @since 1.6
     491     */
     492    function add_history_metabox( $screen_action ) {
     493        // Only proceed if we're on the edit screen
     494        if ( 'edit' != $screen_action )
     495            return;
     496
     497        // Display meta box with a low priority (low position on screen by default)
     498        add_meta_box( 'bp_activity_history',  __( 'Activity History', 'buddypress' ), array( $this, 'history_metabox' ), 'toplevel_page_bp-activity', 'advanced', 'low' );
     499    }
     500
     501    /**
     502     * History meta box for the Activity admin edit screen
     503     *
     504     * @param object $item Activity item
     505     * @since 1.6
     506     * @todo Update activity meta to allow >1 record with the same key (iterate through $history).
     507     * @see http://buddypress.trac.wordpress.org/ticket/3907
     508     */
     509    function history_metabox( $item ) {
     510        $history = BP_Akismet::get_activity_history( $item->id );
     511
     512        if ( empty( $history ) )
     513            return;
     514
     515        echo '<div class="akismet-history"><div>';
     516        printf( '<span>%1$s</span> &mdash; %2$s', bp_core_time_since( $history[2] ), esc_html( $history[1] ) );
     517        echo '</div></div>';
     518    }
     519
     520    /**
    487521     * Update an activity item's Akismet history
    488522     *
Note: See TracChangeset for help on using the changeset viewer.