/var/www/html/wp-content/plugins/elementor/includes/template-library/forms/new-template-form.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace Elementor\TemplateLibrary\Forms;

use 
Elementor\Controls_Manager;
use 
Elementor\Controls_Stack;

if ( ! 
defined'ABSPATH' ) ) {
    exit; 
// Exit if accessed directly
}

class 
New_Template_Form extends Controls_Stack {

    public function 
get_name() {
        return 
'add-template-form';
    }

    
/**
     * @throws \Exception
     */
    
public function render() {
        foreach ( 
$this->get_controls() as $control ) {
            switch ( 
$control['type'] ) {
                case 
Controls_Manager::SELECT:
                    
$this->render_select$control );
                    break;
                default:
                    throw new 
\Exception"'{$control['type']}' control type is not supported." );
            }
        }
    }

    private function 
render_select$control_settings ) {
        
$control_id "elementor-new-template__form__{$control_settings['name']}";
        
$wrapper_class = isset( $control_settings['wrapper_class'] ) ? $control_settings['wrapper_class'] : '';
        
?>
        <div id="<?php echo esc_attr$control_id ); ?>__wrapper" class="elementor-form-field <?php echo esc_attr$wrapper_class ); ?>">
            <label for="<?php echo esc_attr$control_id ); ?>" class="elementor-form-field__label">
                <?php echo esc_html$control_settings['label'] ); ?>
            </label>
            <div class="elementor-form-field__select__wrapper">
                <select id="<?php echo esc_attr$control_id ); ?>" class="elementor-form-field__select" name="meta[<?php echo esc_html$control_settings['name'] ); ?>]">
                    <?php
                    
foreach ( $control_settings['options'] as $key => $value ) {
                        echo 
sprintf'<option value="%1$s">%2$s</option>'esc_html$key ), esc_html$value ) );
                    }
                    
?>
                </select>
            </div>
        </div>
        <?php
    
}
}