Skip to Content
Menu

twitter_url()

Returns a full Twitter URL for a user.

PHP June 5, 2017

Usage

PHP
nebula()->twitter_url($username)

Parameters

$username
(Optional) (String) The username to use for the URL
Default: nebula_option('twitter_username')

Parameter Notes

Username can include the @ or not.

Request or provide clarification »

Examples

PHP
<?php echo nebula()->twitter_url(); ?>
PHP
<?php echo nebula()->twitter_url('Great_Blakes'); ?>

Twitter URL using an author's metadata.

PHP
nebula()->twitter_url(get_the_author_meta('twitter', $user->ID))
Was this page helpful? Yes No


    A feedback message is required to submit this form.


    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

    Located in /libs/Options/Options.php on line 133.

    No Hooks

    This function does not have any filters or actions available. Request one?

    Note: This function contains 1 to-do comment.

    PHP
            public function twitter_url($username=false){
                //@todo "Nebula" 0: Use null coalescing operator here if possible
                if ( empty($username) ){
                    $username = $this->get_option('twitter_username');
                }
    
                if ( !empty($username) ){
                    return esc_url('https://twitter.com/' . str_replace('@', '', $username));
                }
    
                return false;
            }
    

    Override

    This function can not be short-circuited with an override filter. Request one?