Skip to:
Content

BuddyPress.org

Changeset 10724


Ignore:
Timestamp:
04/27/2016 05:05:42 PM (9 years ago)
Author:
r-a-y
Message:

Emails Admin: Introduce 'Situations' column.

This will allow site admins to easily identify the email situations in the
WordPress post list table.

Fixes #7031.

Location:
trunk/src/bp-core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/admin/css/common-rtl.css

    r10617 r10724  
    368368    height: auto;
    369369}
     370
     371body.post-type-bp-email th#situation {
     372    width: 20%;
     373}
     374
     375body.post-type-bp-email td.column-situation ul {
     376    margin: 0;
     377}
  • trunk/src/bp-core/admin/css/common.css

    r10617 r10724  
    368368    height: auto;
    369369}
     370
     371body.post-type-bp-email th#situation {
     372    width: 20%;
     373}
     374
     375body.post-type-bp-email td.column-situation ul {
     376    margin: 0;
     377}
  • trunk/src/bp-core/classes/class-bp-admin.php

    r10652 r10724  
    174174        // On non-multisite, catch.
    175175        add_action( 'load-users.php', 'bp_core_admin_user_manage_spammers' );
     176
     177        // Emails.
     178        add_filter( 'manage_' . bp_get_email_post_type() . '_posts_columns',       array( $this, 'emails_register_situation_column' ) );
     179        add_action( 'manage_' . bp_get_email_post_type() . '_posts_custom_column', array( $this, 'emails_display_situation_column_data' ), 10, 2 );
    176180
    177181        /* Filters ***********************************************************/
     
    895899    }
    896900
     901    /** Emails ****************************************************************/
     902
     903    /**
     904     * Registers 'Situations' column on Emails dashboard page.
     905     *
     906     * @since 2.6.0
     907     *
     908     * @param  array $columns Current column data.
     909     * @return array
     910     */
     911    public function emails_register_situation_column( $columns = array() ) {
     912        $situation = array(
     913            'situation' => _x( 'Situations', 'Email post type', 'buddypress' )
     914        );
     915
     916        // Inject our 'Situations' column just before the last 'Date' column.
     917        return array_slice( $columns, 0, -1, true ) + $situation + array_slice( $columns, -1, null, true );
     918    }
     919
     920    /**
     921     * Output column data for our custom 'Situations' column.
     922     *
     923     * @since 2.6.0
     924     *
     925     * @param string $column  Current column name.
     926     * @param int    $post_id Current post ID.
     927     */
     928    public function emails_display_situation_column_data( $column = '', $post_id = 0 ) {
     929        if ( 'situation' !== $column ) {
     930            return;
     931        }
     932
     933        // Grab email situations for the current post.
     934        $situations = wp_list_pluck( get_the_terms( $post_id, bp_get_email_tax_type() ), 'description' );
     935
     936        // Output each situation as a list item.
     937        echo '<ul><li>';
     938        echo implode( '</li><li>', $situations );
     939        echo '</li></ul>';
     940    }
     941
    897942    /** Helpers ***************************************************************/
    898943
Note: See TracChangeset for help on using the changeset viewer.