structure.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace Elementor;
  3. if ( ! defined( 'ABSPATH' ) ) {
  4. exit; // Exit if accessed directly.
  5. }
  6. /**
  7. * Elementor structure control.
  8. *
  9. * A base control for creating structure control. A private control for section
  10. * columns structure.
  11. *
  12. * @since 1.0.0
  13. */
  14. class Control_Structure extends Base_Data_Control {
  15. /**
  16. * Get structure control type.
  17. *
  18. * Retrieve the control type, in this case `structure`.
  19. *
  20. * @since 1.0.0
  21. * @access public
  22. *
  23. * @return string Control type.
  24. */
  25. public function get_type() {
  26. return 'structure';
  27. }
  28. /**
  29. * Render structure control output in the editor.
  30. *
  31. * Used to generate the control HTML in the editor using Underscore JS
  32. * template. The variables for the class are available using `data` JS
  33. * object.
  34. *
  35. * @since 1.0.0
  36. * @access public
  37. */
  38. public function content_template() {
  39. $preset_control_uid = $this->get_control_uid( '{{ preset.key }}' );
  40. ?>
  41. <div class="elementor-control-field">
  42. <div class="elementor-control-input-wrapper">
  43. <div class="elementor-control-structure-title"><?php echo __( 'Structure', 'elementor' ); ?></div>
  44. <# var currentPreset = elementor.presetsFactory.getPresetByStructure( data.controlValue ); #>
  45. <div class="elementor-control-structure-preset elementor-control-structure-current-preset">
  46. {{{ elementor.presetsFactory.getPresetSVG( currentPreset.preset, 233, 72, 5 ).outerHTML }}}
  47. </div>
  48. <div class="elementor-control-structure-reset">
  49. <i class="fa fa-undo" aria-hidden="true"></i>
  50. <?php echo __( 'Reset Structure', 'elementor' ); ?>
  51. </div>
  52. <#
  53. var morePresets = getMorePresets();
  54. if ( morePresets.length > 1 ) { #>
  55. <div class="elementor-control-structure-more-presets-title"><?php echo __( 'More Structures', 'elementor' ); ?></div>
  56. <div class="elementor-control-structure-more-presets">
  57. <# _.each( morePresets, function( preset ) { #>
  58. <div class="elementor-control-structure-preset-wrapper">
  59. <input id="<?php echo $preset_control_uid; ?>" type="radio" name="elementor-control-structure-preset-{{ data._cid }}" data-setting="structure" value="{{ preset.key }}">
  60. <label for="<?php echo $preset_control_uid; ?>" class="elementor-control-structure-preset">
  61. {{{ elementor.presetsFactory.getPresetSVG( preset.preset, 102, 42 ).outerHTML }}}
  62. </label>
  63. <div class="elementor-control-structure-preset-title">{{{ preset.preset.join( ', ' ) }}}</div>
  64. </div>
  65. <# } ); #>
  66. </div>
  67. <# } #>
  68. </div>
  69. </div>
  70. <# if ( data.description ) { #>
  71. <div class="elementor-control-field-description">{{{ data.description }}}</div>
  72. <# } #>
  73. <?php
  74. }
  75. /**
  76. * Get structure control default settings.
  77. *
  78. * Retrieve the default settings of the structure control. Used to return the
  79. * default settings while initializing the structure control.
  80. *
  81. * @since 1.0.0
  82. * @access protected
  83. *
  84. * @return array Control default settings.
  85. */
  86. protected function get_default_settings() {
  87. return [
  88. 'separator' => 'none',
  89. 'label_block' => true,
  90. ];
  91. }
  92. }