new-template.php 3.6 KB

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