Twitter\WordPress\Shortcodes\Share::addPostData PHP Method

addPostData() protected static method

Add explicit Tweet button data related to the post and its author
Since: 1.0.0
protected static addPostData ( array $options, WP_Post $post ) : array
$options array Tweet button options { @type string option name @type string|bool option value }
$post WP_Post post of interest
return array Tweet button options with possible additions based on post data { @type string option name @type string|bool option value }
    protected static function addPostData($options, $post)
    {
        if (!is_array($options)) {
            $options = array();
        }
        // explicitly define post URL
        // maintains Tweet button context on a page listing multiple posts
        if (!(isset($options['url']) && $options['url'])) {
            /**
             * Filter the URL shared in Tweet text
             *
             * All URLs are wrapped in Twitter's t.co link wrapper
             *
             * @since 1.0.0
             *
             * @param string $url The URL returned by get_permalink() when in the loop
             */
            $url = apply_filters('twitter_url', get_permalink($post));
            if ($url) {
                $options['url'] = $url;
            }
            unset($url);
        }
        $author_id = get_the_author_meta('ID');
        if ($author_id) {
            $author_twitter_username = \Twitter\WordPress\User\Meta::getTwitterUsername($author_id);
            if ($author_twitter_username) {
                $author_display_name = trim(get_the_author_meta('display_name', $author_id));
                if (!isset($options['related']) || !is_array($options['related'])) {
                    $options['related'] = array();
                }
                if (!isset($options['related'][$author_twitter_username])) {
                    $options['related'][$author_twitter_username] = $author_display_name;
                }
                unset($author_display_name);
            }
            unset($author_twitter_username);
        }
        unset($author_id);
        return $options;
    }