1
<?php
2
namespace YougitAI\SecureShowcase\Elementor;
3
4
use Elementor\Controls_Manager;
5
use Elementor\Widget_Base;
6
use YougitAI\SecureShowcase\Frontend\Renderer;
7
use YougitAI\SecureShowcase\Repository\RepositoryService;
8
9
final class RepositoryGridWidget extends Widget_Base {
10
public function __construct( private RepositoryService $repositories, $data = [], $args = null ) { parent::__construct( $data, $args ); }
11
public function get_name(): string { return 'yougitai_secure_showcase_grid'; }
12
public function get_title(): string { return __( 'Secure Repository Grid', 'yougitai-secure-showcase' ); }
13
public function get_icon(): string { return 'eicon-gallery-grid'; }
14
public function get_categories(): array { return [ 'yougitai' ]; }
15
public function get_keywords(): array { return [ 'github', 'repository', 'portfolio', 'grid', 'projects' ]; }
16
public function get_style_depends(): array { return [ 'yougitai-ss-frontend' ]; }
17
public function get_script_depends(): array { return [ 'yougitai-ss-frontend' ]; }
18
protected function register_controls(): void {
19
$this->start_controls_section( 'content', [ 'label' => __( 'Content', 'yougitai-secure-showcase' ) ] );
20
$this->add_control( 'columns', [ 'label' => __( 'Columns', 'yougitai-secure-showcase' ), 'type' => Controls_Manager::SELECT, 'options' => [ '1'=>'1','2'=>'2','3'=>'3','4'=>'4' ], 'default' => '3' ] );
21
$this->add_control( 'theme', [ 'label' => __( 'Theme', 'yougitai-secure-showcase' ), 'type' => Controls_Manager::SELECT, 'options' => [ 'auto'=>__( 'Automatic','yougitai-secure-showcase'),'light'=>__( 'Light','yougitai-secure-showcase'),'dark'=>__( 'Dark','yougitai-secure-showcase') ], 'default'=>'dark' ] );
22
$this->end_controls_section();
23
}
24
protected function render(): void {
25
$settings = $this->get_settings_for_display();
26
echo ( new Renderer( $this->repositories ) )->render_grid( sanitize_key( (string) ( $settings['theme'] ?? 'auto' ) ), absint( $settings['columns'] ?? 3 ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
27
}
28
}
29