<?php

namespace Simple_Giveaways;

if ( ! defined( 'ABSPATH' ) ) {
	return;
}

/**
 * Twitter Sharer
 */
class GA_Sharer_Twitter extends GA_Sharer {

	/**
	 * Link used for sharing
	 *
	 * @var string
	 */
	public $sharer_link = 'https://twitter.com/intent/tweet?';

	/**
	 * Icons class
	 *
	 * @var string
	 */
	public $sharer_icon = 'twitter';

	/**
	 * If true, the share link should be opened in a popup window.
	 *
	 * @var bool
	 */
	public $use_popup = true;

	/**
	 * GA_Sharer_Twitter constructor.
	 */
	public function __construct( $settings = array() ) {
		parent::__construct( $settings );
		$this->method_title = __( 'Twitter', 'giveasap' );
	}

	/**
	 * Setting the sharing attributes
	 *
	 * @param  string $url
	 * @param  string $text
	 * @param  array  $display Display options
	 * @return string
	 */
	public function sharing_attributes( $url, $text, $display ) {
		return 'url=' . $url . '&text=' . $text;
	}

	/**
	 * Returning the text for the button
	 *
	 * @return string
	 */
	public function get_sharer_text() {
		return __( 'Tweet it', 'giveasap' );
	}

	/**
	 * Returning the sharer icon
	 *
	 * @return [type] [description]
	 */
	public function get_sharer_icon() {

		ob_start();
		echo '<span class="sg-sharing-icon">';
		include untrailingslashit( GASAP_ROOT ) . '/includes/integrations/assets/twitter.svg';
		echo '</span>';

		return ob_get_clean();
	}
}
