thoughtis / cata-co-authors-plus

Common functions, configuration and compatibility fixes for Co-Authors Plus when used in Cata child themes. Not a fork or replacement for CAP.
GNU General Public License v3.0
0 stars 0 forks source link

Remove older social networks from Guest Author profiles #2

Closed douglas-johnson closed 3 years ago

douglas-johnson commented 3 years ago

CAP includes meta fields in Guest Author profiles for AIM, YahooIM and Jabber which we don't use. On Shop Catalog we removed them like this...

add_filter( 'coauthors_guest_author_fields', array( __CLASS__, 'remove_unused_meta_fields' ), 10, 2 );

/**
 * Remove Unused Meta Fields
 * 
 * @param  array $fields_to_return Provided array of fields CAP is looking for.
 * @return array Updated array of fields CAP should return.
 */
public static function remove_unused_meta_fields( array $fields_to_return ) : array {
    $remove_these_fields = array(
        'aim',
        'yahooim',
        'jabber',
    );

    return array_values(
        array_filter(
            $fields_to_return,
            function( $field ) use ( $remove_these_fields ) {
                return ! in_array( $field['key'], $remove_these_fields, true );
            }
        )
    );
}