groups
1 year ago
alert.php
2 years ago
animation.php
1 year ago
base-data.php
3 years ago
base-icon-font.php
3 years ago
base-multiple.php
3 years ago
base-ui.php
3 years ago
base-units.php
2 years ago
base.php
3 years ago
box-shadow.php
3 years ago
button.php
3 years ago
choose.php
3 years ago
code.php
3 years ago
color.php
3 years ago
date-time.php
3 years ago
deprecated-notice.php
3 years ago
dimensions.php
3 years ago
divider.php
2 years ago
exit-animation.php
1 year ago
font.php
3 years ago
gallery.php
1 year ago
gaps.php
2 years ago
heading.php
3 years ago
hidden.php
3 years ago
hover-animation.php
1 year ago
icon.php
2 years ago
icons.php
2 years ago
image-dimensions.php
3 years ago
media.php
1 year ago
notice.php
1 year ago
number.php
3 years ago
popover-toggle.php
3 years ago
raw-html.php
3 years ago
repeater.php
1 year ago
section.php
2 years ago
select.php
3 years ago
select2.php
2 years ago
slider.php
3 years ago
structure.php
2 years ago
switcher.php
3 years ago
tab.php
2 years ago
tabs.php
2 years ago
text-shadow.php
3 years ago
text.php
3 years ago
textarea.php
3 years ago
url.php
1 year ago
wp-widget.php
3 years ago
wysiwyg.php
3 years ago
url.php
134 lines
| 1 | <?php |
| 2 | namespace Elementor; |
| 3 | |
| 4 | use Elementor\Modules\DynamicTags\Module as TagsModule; |
| 5 | |
| 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | exit; // Exit if accessed directly. |
| 8 | } |
| 9 | |
| 10 | /** |
| 11 | * Elementor URL control. |
| 12 | * |
| 13 | * A base control for creating url control. Displays a URL input with the |
| 14 | * ability to set the target of the link to `_blank` to open in a new tab. |
| 15 | * |
| 16 | * @since 1.0.0 |
| 17 | */ |
| 18 | class Control_URL extends Control_Base_Multiple { |
| 19 | |
| 20 | /** |
| 21 | * Get url control type. |
| 22 | * |
| 23 | * Retrieve the control type, in this case `url`. |
| 24 | * |
| 25 | * @since 1.0.0 |
| 26 | * @access public |
| 27 | * |
| 28 | * @return string Control type. |
| 29 | */ |
| 30 | public function get_type() { |
| 31 | return 'url'; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Get url control default values. |
| 36 | * |
| 37 | * Retrieve the default value of the url control. Used to return the default |
| 38 | * values while initializing the url control. |
| 39 | * |
| 40 | * @since 1.0.0 |
| 41 | * @access public |
| 42 | * |
| 43 | * @return array Control default value. |
| 44 | */ |
| 45 | public function get_default_value() { |
| 46 | return [ |
| 47 | 'url' => '', |
| 48 | 'is_external' => '', |
| 49 | 'nofollow' => '', |
| 50 | 'custom_attributes' => '', |
| 51 | ]; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Get url control default settings. |
| 56 | * |
| 57 | * Retrieve the default settings of the url control. Used to return the default |
| 58 | * settings while initializing the url control. |
| 59 | * |
| 60 | * @since 1.0.0 |
| 61 | * @access protected |
| 62 | * |
| 63 | * @return array Control default settings. |
| 64 | */ |
| 65 | protected function get_default_settings() { |
| 66 | return [ |
| 67 | 'label_block' => true, |
| 68 | 'placeholder' => esc_html__( 'Paste URL or type', 'elementor' ), |
| 69 | 'autocomplete' => true, |
| 70 | 'options' => [ 'is_external', 'nofollow', 'custom_attributes' ], |
| 71 | 'dynamic' => [ |
| 72 | 'categories' => [ TagsModule::URL_CATEGORY ], |
| 73 | 'property' => 'url', |
| 74 | ], |
| 75 | 'custom_attributes_description' => sprintf( |
| 76 | '%1$s <a target="_blank" href="https://go.elementor.com/panel-link-custom-attributes/">%2$s</a>', |
| 77 | esc_html__( 'Set custom attributes for the link element. Separate attribute keys from values using the | (pipe) character. Separate key-value pairs with a comma.', 'elementor' ), |
| 78 | esc_html__( 'Learn more', 'elementor' ) |
| 79 | ), |
| 80 | ]; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Render url control output in the editor. |
| 85 | * |
| 86 | * Used to generate the control HTML in the editor using Underscore JS |
| 87 | * template. The variables for the class are available using `data` JS |
| 88 | * object. |
| 89 | * |
| 90 | * @since 1.0.0 |
| 91 | * @access public |
| 92 | */ |
| 93 | public function content_template() { |
| 94 | ?> |
| 95 | <div class="elementor-control-field elementor-control-url-external-{{{ ( data.options.length || data.show_external ) ? 'show' : 'hide' }}}"> |
| 96 | <label for="<?php $this->print_control_uid(); ?>" class="elementor-control-title">{{{ data.label }}}</label> |
| 97 | <div class="elementor-control-input-wrapper elementor-control-dynamic-switcher-wrapper"> |
| 98 | <i class="elementor-control-url-autocomplete-spinner eicon-loading eicon-animation-spin" aria-hidden="true"></i> |
| 99 | <input id="<?php $this->print_control_uid(); ?>" class="elementor-control-tag-area elementor-input" data-setting="url" placeholder="{{ view.getControlPlaceholder() }}" /> |
| 100 | <?php // PHPCS - Nonces don't require escaping. ?> |
| 101 | <input id="_ajax_linking_nonce" type="hidden" value="<?php echo wp_create_nonce( 'internal-linking' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>" /> |
| 102 | <# if ( !! data.options ) { #> |
| 103 | <button class="elementor-control-url-more tooltip-target elementor-control-unit-1" data-tooltip="<?php echo esc_attr__( 'Link Options', 'elementor' ); ?>" aria-label="<?php echo esc_attr__( 'Link Options', 'elementor' ); ?>"> |
| 104 | <i class="eicon-cog" aria-hidden="true"></i> |
| 105 | </button> |
| 106 | <# } #> |
| 107 | </div> |
| 108 | <# if ( !! data.options ) { #> |
| 109 | <div class="elementor-control-url-more-options"> |
| 110 | <div class="elementor-control-url-option"> |
| 111 | <input id="<?php $this->print_control_uid( 'is_external' ); ?>" type="checkbox" class="elementor-control-url-option-input" data-setting="is_external"> |
| 112 | <label for="<?php $this->print_control_uid( 'is_external' ); ?>"><?php echo esc_html__( 'Open in new window', 'elementor' ); ?></label> |
| 113 | </div> |
| 114 | <div class="elementor-control-url-option"> |
| 115 | <input id="<?php $this->print_control_uid( 'nofollow' ); ?>" type="checkbox" class="elementor-control-url-option-input" data-setting="nofollow"> |
| 116 | <label for="<?php $this->print_control_uid( 'nofollow' ); ?>"><?php echo esc_html__( 'Add nofollow', 'elementor' ); ?></label> |
| 117 | </div> |
| 118 | <div class="elementor-control-url__custom-attributes"> |
| 119 | <label for="<?php $this->print_control_uid( 'custom_attributes' ); ?>" class="elementor-control-url__custom-attributes-label"><?php echo esc_html__( 'Custom Attributes', 'elementor' ); ?></label> |
| 120 | <input type="text" id="<?php $this->print_control_uid( 'custom_attributes' ); ?>" class="elementor-control-unit-5" placeholder="key|value" data-setting="custom_attributes"> |
| 121 | </div> |
| 122 | <# if ( ( data.options && -1 !== data.options.indexOf( 'custom_attributes' ) ) && data.custom_attributes_description ) { #> |
| 123 | <div class="elementor-control-field-description">{{{ data.custom_attributes_description }}}</div> |
| 124 | <# } #> |
| 125 | </div> |
| 126 | <# } #> |
| 127 | </div> |
| 128 | <# if ( data.description ) { #> |
| 129 | <div class="elementor-control-field-description">{{{ data.description }}}</div> |
| 130 | <# } #> |
| 131 | <?php |
| 132 | } |
| 133 | } |
| 134 |