Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Dein Benutzer-Profil um weitere Social Media Accounts erweitern

<?php
/**
 * Managing contact fields for author bio
 */
$evolution_pro_Contactfields = new evolution_pro_Contactfields(
// Fehlende Accounts kannst du leicht ergänzen
       array (
    'Feed',
    'Twitter',
        'Facebook',
        'GooglePlus',
        'Flickr',
        'Xing',
        'Github',
        'Instagram',
        'LinkedIn',
        'Pinterest',
        'Vimeo',
        'Youtube'
    )
);
class evolution_pro_Contactfields {
    public
        $new_fields
    ,   $active_fields
    ,   $replace
    ;
    /**
     * @param array $fields New fields: array ('Twitter', 'Facebook')
     * @param bool $replace Replace default fields?

     */
    public function __construct($fields, $replace = TRUE)
    {
        foreach ( $fields as $field )
        {
            $this->new_fields[ mb_strtolower($field, 'utf-8') ] = $field;
        }
        $this->replace = (bool) $replace;
        add_filter('user_contactmethods', array( $this, 'add_fields' ) );
    }
    /**
     * Changing contact fields
     * @param  $original_fields Original WP fields
     * @return array
     */
    public function add_fields($original_fields)
    {
        if ( $this->replace )
        {
            $this->active_fields = $this->new_fields;
            return $this->new_fields;
        }
        $this->active_fields = array_merge($original_fields, $this->new_fields);
        return $this->active_fields;
    }
    /**
     * Helper function
     * @return array The currently active fields.

     */
    public function get_active_fields()
    {
        return $this->active_fields;
    }
}
Source by www.drweb.de #
 
PREVIOUS NEXT
Tagged: #Dein #um #weitere #Social #Media #Accounts #erweitern
ADD COMMENT
Topic
Name
8+3 =