| 1 |
<?php |
| 2 |
namespace Elementor; |
| 3 |
|
| 4 |
use Elementor\Core\Base\Document; |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; // Exit if accessed directly |
| 8 |
} |
| 9 |
|
| 10 |
$document_types = Plugin::$instance->documents->get_document_types(); |
| 11 |
|
| 12 |
$types = []; |
| 13 |
|
| 14 |
$selected = get_query_var( 'elementor_library_type' ); |
| 15 |
|
| 16 |
foreach ( $document_types as $document_type ) { |
| 17 |
if ( $document_type::get_property( 'show_in_library' ) ) { |
| 18 |
/** |
| 19 |
* @var Document $instance |
| 20 |
*/ |
| 21 |
$instance = new $document_type(); |
| 22 |
|
| 23 |
$types[ $instance->get_name() ] = $document_type::get_title(); |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Create new template library dialog types. |
| 29 |
* |
| 30 |
* Filters the dialog types when printing new template dialog. |
| 31 |
* |
| 32 |
* @since 2.0.0 |
| 33 |
* |
| 34 |
* @param array $types Types data. |
| 35 |
* @param Document $document_types Document types. |
| 36 |
*/ |
| 37 |
$types = apply_filters( 'elementor/template-library/create_new_dialog_types', $types, $document_types ); |
| 38 |
?> |
| 39 |
<script type="text/template" id="tmpl-elementor-new-template"> |
| 40 |
<div id="elementor-new-template__description"> |
| 41 |
<div id="elementor-new-template__description__title"><?php echo __( 'Templates Help You <span>Work Efficiently</span>', 'elementor' ); ?></div> |
| 42 |
<div id="elementor-new-template__description__content"><?php echo __( 'Use templates to create the different pieces of your site, and reuse them with one click whenever needed.', 'elementor' ); ?></div> |
| 43 |
<?php |
| 44 |
/* |
| 45 |
<div id="elementor-new-template__take_a_tour"> |
| 46 |
<i class="eicon-play-o"></i> |
| 47 |
<a href="#"><?php echo __( 'Take The Video Tour', 'elementor' ); ?></a> |
| 48 |
</div> |
| 49 |
*/ |
| 50 |
?> |
| 51 |
</div> |
| 52 |
<form id="elementor-new-template__form" action="<?php esc_url( admin_url( '/edit.php' ) ); ?>"> |
| 53 |
<input type="hidden" name="post_type" value="elementor_library"> |
| 54 |
<input type="hidden" name="action" value="elementor_new_post"> |
| 55 |
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'elementor_action_new_post' ); ?>"> |
| 56 |
<div id="elementor-new-template__form__title"><?php echo __( 'Choose Template Type', 'elementor' ); ?></div> |
| 57 |
<div id="elementor-new-template__form__template-type__wrapper" class="elementor-form-field"> |
| 58 |
<label for="elementor-new-template__form__template-type" class="elementor-form-field__label"><?php echo __( 'Select the type of template you want to work on', 'elementor' ); ?></label> |
| 59 |
<div class="elementor-form-field__select__wrapper"> |
| 60 |
<select id="elementor-new-template__form__template-type" class="elementor-form-field__select" name="template_type" required> |
| 61 |
<option value=""><?php echo __( 'Select', 'elementor' ); ?>...</option> |
| 62 |
<?php |
| 63 |
foreach ( $types as $value => $type_title ) { |
| 64 |
printf( '<option value="%1$s" %2$s>%3$s</option>', $value, selected( $selected, $value, false ), $type_title ); |
| 65 |
} |
| 66 |
?> |
| 67 |
</select> |
| 68 |
</div> |
| 69 |
</div> |
| 70 |
<?php |
| 71 |
/** |
| 72 |
* Template library dialog fields. |
| 73 |
* |
| 74 |
* Fires after Elementor template library dialog fields are displayed. |
| 75 |
* |
| 76 |
* @since 2.0.0 |
| 77 |
*/ |
| 78 |
do_action( 'elementor/template-library/create_new_dialog_fields' ); |
| 79 |
?> |
| 80 |
|
| 81 |
<div id="elementor-new-template__form__post-title__wrapper" class="elementor-form-field"> |
| 82 |
<label for="elementor-new-template__form__post-title" class="elementor-form-field__label"> |
| 83 |
<?php echo __( 'Name your template', 'elementor' ); ?> |
| 84 |
</label> |
| 85 |
<div class="elementor-form-field__text__wrapper"> |
| 86 |
<input type="text" placeholder="<?php echo esc_attr__( 'Enter template name (optional)', 'elementor' ); ?>" id="elementor-new-template__form__post-title" class="elementor-form-field__text" name="post_data[post_title]"> |
| 87 |
</div> |
| 88 |
</div> |
| 89 |
<button id="elementor-new-template__form__submit" class="elementor-button elementor-button-success"><?php echo __( 'Create Template', 'elementor' ); ?></button> |
| 90 |
</form> |
| 91 |
</script> |
| 92 |
|