| 1 |
<?php |
| 2 |
namespace Elementor; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly. |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Elementor structure control. |
| 10 |
* |
| 11 |
* A base control for creating structure control. A private control for section |
| 12 |
* columns structure. |
| 13 |
* |
| 14 |
* @since 1.0.0 |
| 15 |
*/ |
| 16 |
class Control_Structure extends Base_Data_Control { |
| 17 |
|
| 18 |
/** |
| 19 |
* Get structure control type. |
| 20 |
* |
| 21 |
* Retrieve the control type, in this case `structure`. |
| 22 |
* |
| 23 |
* @since 1.0.0 |
| 24 |
* @access public |
| 25 |
* |
| 26 |
* @return string Control type. |
| 27 |
*/ |
| 28 |
public function get_type() { |
| 29 |
return 'structure'; |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Render structure control output in the editor. |
| 34 |
* |
| 35 |
* Used to generate the control HTML in the editor using Underscore JS |
| 36 |
* template. The variables for the class are available using `data` JS |
| 37 |
* object. |
| 38 |
* |
| 39 |
* @since 1.0.0 |
| 40 |
* @access public |
| 41 |
*/ |
| 42 |
public function content_template() { |
| 43 |
$preset_control_uid = $this->get_control_uid( '{{ preset.key }}' ); |
| 44 |
?> |
| 45 |
<div class="elementor-control-field"> |
| 46 |
<div class="elementor-control-input-wrapper"> |
| 47 |
<# |
| 48 |
var morePresets = getMorePresets(); |
| 49 |
|
| 50 |
if ( morePresets.length ) { #> |
| 51 |
<div class="elementor-control-structure-presets"> |
| 52 |
<# _.each( morePresets, function( preset ) { #> |
| 53 |
<div class="elementor-control-structure-preset-wrapper"> |
| 54 |
<input id="<?php echo $preset_control_uid; ?>" type="radio" name="elementor-control-structure-preset-{{ data._cid }}" data-setting="structure" value="{{ preset.key }}"> |
| 55 |
<label for="<?php echo $preset_control_uid; ?>" class="elementor-control-structure-preset"> |
| 56 |
{{{ elementor.presetsFactory.getPresetSVG( preset.preset, 102, 42 ).outerHTML }}} |
| 57 |
</label> |
| 58 |
<div class="elementor-control-structure-preset-title">{{{ preset.preset.join( ', ' ) }}}</div> |
| 59 |
</div> |
| 60 |
<# } ); #> |
| 61 |
</div> |
| 62 |
<# } #> |
| 63 |
</div> |
| 64 |
<div class="elementor-control-structure-reset"> |
| 65 |
<i class="eicon-undo" aria-hidden="true"></i> |
| 66 |
<?php echo __( 'Reset', 'elementor' ); ?> |
| 67 |
</div> |
| 68 |
</div> |
| 69 |
<# if ( data.description ) { #> |
| 70 |
<div class="elementor-control-field-description">{{{ data.description }}}</div> |
| 71 |
<# } #> |
| 72 |
<?php |
| 73 |
} |
| 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 |
'show_label' => false, |
| 91 |
]; |
| 92 |
} |
| 93 |
} |
| 94 |
|