| 1 |
<?php |
| 2 |
namespace ElementorWpStream\Widgets; |
| 3 |
|
| 4 |
use Elementor\Widget_Base; |
| 5 |
use Elementor\Controls_Manager; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 8 |
|
| 9 |
|
| 10 |
class Wpstream_Start_Streaming_Base extends Widget_Base { |
| 11 |
|
| 12 |
/** |
| 13 |
* Retrieve the widget name. |
| 14 |
* |
| 15 |
* @since 1.0.0 |
| 16 |
* |
| 17 |
* @access public |
| 18 |
* |
| 19 |
* @return string Widget name. |
| 20 |
*/ |
| 21 |
public function get_name() { |
| 22 |
return 'Wpstream_Start_Streaming'; |
| 23 |
} |
| 24 |
|
| 25 |
public function get_categories() { |
| 26 |
return [ 'wpstream' ]; |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
/** |
| 31 |
* Retrieve the widget title. |
| 32 |
* |
| 33 |
* @since 1.0.0 |
| 34 |
* |
| 35 |
* @access public |
| 36 |
* |
| 37 |
* @return string Widget title. |
| 38 |
*/ |
| 39 |
public function get_title() { |
| 40 |
return '<div class="wpestate_elementor_widget_title">'.__( 'WpStream - Start Streaming', 'wpstream' ).'</div>'; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Retrieve the widget icon. |
| 45 |
* |
| 46 |
* @since 1.0.0 |
| 47 |
* |
| 48 |
* @access public |
| 49 |
* |
| 50 |
* @return string Widget icon. |
| 51 |
*/ |
| 52 |
public function get_icon() { |
| 53 |
return 'eicon-play-o'; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
/** |
| 59 |
* Retrieve the list of scripts the widget depended on. |
| 60 |
* |
| 61 |
* Used to set scripts dependencies required to run the widget. |
| 62 |
* |
| 63 |
* @since 1.0.0 |
| 64 |
* |
| 65 |
* @access public |
| 66 |
* |
| 67 |
* @return array Widget scripts dependencies. |
| 68 |
*/ |
| 69 |
public function get_script_depends() { |
| 70 |
return [ '' ]; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Register the widget controls. |
| 75 |
* |
| 76 |
* Adds different input fields to allow the user to change and customize the widget settings. |
| 77 |
* |
| 78 |
* @since 1.0.0 |
| 79 |
* |
| 80 |
* @access protected |
| 81 |
*/ |
| 82 |
|
| 83 |
public function elementor_transform($input){ |
| 84 |
$output=array(); |
| 85 |
if( is_array($input) ){ |
| 86 |
foreach ($input as $key=>$tax){ |
| 87 |
$output[$tax['value']]=$tax['label']; |
| 88 |
} |
| 89 |
} |
| 90 |
return $output; |
| 91 |
} |
| 92 |
|
| 93 |
protected function _register_controls() { |
| 94 |
global $all_tax; |
| 95 |
|
| 96 |
$featured_places_array =array(1=>1,2=>2,3=>3); |
| 97 |
|
| 98 |
$this->start_controls_section( |
| 99 |
'section_content', |
| 100 |
[ |
| 101 |
'label' => __( 'Content', 'wpstream' ), |
| 102 |
] |
| 103 |
); |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
$this->add_control( |
| 109 |
'item_id', |
| 110 |
[ |
| 111 |
'label' => __( 'Product/Free Product id', 'wpstream' ), |
| 112 |
'label_block'=>true, |
| 113 |
'type' => Controls_Manager::TEXT, |
| 114 |
'description'=>__('If you leave this option blank we will stream on the first free/paid channel for this user','wpstream') |
| 115 |
] |
| 116 |
); |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
$this->end_controls_section(); |
| 122 |
|
| 123 |
|
| 124 |
} |
| 125 |
|
| 126 |
/** |
| 127 |
* Render the widget output on the frontend. |
| 128 |
* |
| 129 |
* Written in PHP and used to generate the final HTML. |
| 130 |
* |
| 131 |
* @since 1.0.0 |
| 132 |
* |
| 133 |
* @access protected |
| 134 |
*/ |
| 135 |
|
| 136 |
public function wpresidence_send_to_shortcode($input){ |
| 137 |
$output=''; |
| 138 |
if($input!==''){ |
| 139 |
$numItems = count($input); |
| 140 |
$i = 0; |
| 141 |
|
| 142 |
foreach ($input as $key=>$value){ |
| 143 |
$output.=$value; |
| 144 |
if(++$i !== $numItems) { |
| 145 |
$output.=', '; |
| 146 |
} |
| 147 |
} |
| 148 |
} |
| 149 |
return $output; |
| 150 |
} |
| 151 |
|
| 152 |
protected function render() { |
| 153 |
$settings = $this->get_settings_for_display(); |
| 154 |
|
| 155 |
$attributes['id'] = $settings['item_id'] ; |
| 156 |
|
| 157 |
global $wpstream_plugin; |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
// echo $wpstream_plugin->admin->wpstream_live_stream_unit( $attributes['id'],'front' ); |
| 162 |
echo $wpstream_plugin->wpstream_live_stream_unit_wrapper( $attributes['id'],'front' ); |
| 163 |
} |
| 164 |
|
| 165 |
/** |
| 166 |
* Render the widget output in the editor. |
| 167 |
* |
| 168 |
* Written as a Backbone JavaScript template and used to generate the live preview. |
| 169 |
* |
| 170 |
* @since 1.0.0 |
| 171 |
* |
| 172 |
* @access protected |
| 173 |
*/ |
| 174 |
protected function content_template() { |
| 175 |
?> |
| 176 |
<div class="title"> |
| 177 |
{{{ settings.title }}} |
| 178 |
</div> |
| 179 |
<?php |
| 180 |
} |
| 181 |
} |
| 182 |
|