<?php
class AWSMTeamElementorWidget extends \Elementor\Widget_Base
{
	public function get_name() {
		return 'awsm-team';
	}

	public function get_title() {
		return __('AWSM Team', 'awsm-team-pro');
	}

	public function get_icon() {
		return 'eicon-gallery-grid';
	}

	public function get_categories() {
		return ['general'];
	}


	protected function _register_controls() {
		$this->start_controls_section(
			'setting_section',
			[
				'label' => __('Settings', 'awsm-team-pro'),
				'tab'   => \Elementor\Controls_Manager::TAB_CONTENT,
			]
		);
		$this->add_control(
			'awsm_team_id',
			array(
				'type'    => \Elementor\Controls_Manager::SELECT,
				'id'      => 'awsm_elem_team_id',
				'label'   => __('Team', 'awsm-team-pro'),
				'options' => array('0'=>'Select team')+Awsm_Team::get_teams(),
				'default' => __('0', 'awsm-team-pro'),
				'event'	  => 'awsm_elem_team_id',
			)
		);
		
		

		$this->end_controls_section();

	}

	protected function render() {
		$settings = $this->get_settings_for_display();
		if (isset($settings['awsm_team_id']) && !empty($settings['awsm_team_id'])) {
			$shortcode = '[awsmteam';
			$shortcode .= ' id="' . $settings['awsm_team_id'] . '"';
			$shortcode .= ']';
			$url = get_edit_post_link($settings['awsm_team_id'], '');

			echo do_shortcode($shortcode);
		} else{
			echo __('Select a team', 'awsm-team-pro');
		}
	}

}