/**
 * Filter the post content & append activity action to it
 *
 * @since 0.1.0
 *
 * @param   string  $content
 *
 * @return  string
 */
function wp_user_activity_append_action_to_the_content($content = '')
{
    // Get the current post
    $post = get_post();
    // Bail if not an activity post
    if ('activity' !== $post->post_type) {
        return $content;
    }
    // Setup empty array
    $retval = array();
    // Maybe append action, if not empty
    $action = wp_get_user_activity_action($post);
    if (!empty($action)) {
        $retval[] = $action;
    }
    // Maybe append content, if not empty
    if (!empty($content)) {
        $retval[] = $content;
    }
    // Prepend the action
    $_retval = implode('<br>', $retval);
    // Return content with action prepended
    return $_retval;
}
Exemple #2
0
/**
 * Output content for each activity item
 *
 * @since 0.1.0
 *
 * @param  string  $column
 * @param  int     $post_id
 */
function wp_user_activity_manage_custom_column_data($column = '', $post_id = 0)
{
    // Get post & metadata
    $post = get_post($post_id);
    $meta = wp_user_activity_get_meta($post_id);
    // Custom column IDs
    switch ($column) {
        // Attempt to output human-readable action
        case 'activity_type':
            echo wp_get_user_activity_type_icon($post, $meta);
            break;
            // User who performed this activity
        // User who performed this activity
        case 'activity_username':
            echo wp_get_user_activity_action($post, $meta);
            break;
            // Session of the user who performed this activity
        // Session of the user who performed this activity
        case 'activity_session':
            echo '<abbr title="' . wp_get_user_activity_ua($post, $meta) . '">' . wp_get_user_activity_ip($post, $meta) . '</abbr>';
            break;
            // Attempt to output helpful connection to object
        // Attempt to output helpful connection to object
        case 'activity_when':
            $when = strtotime($post->post_date);
            $date = get_option('date_format');
            $time = get_option('time_format');
            echo date_i18n($date, $when, true);
            echo '<br>';
            echo date_i18n($time, $when, true);
            break;
    }
}