-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds "url" input type for View settings
This takes advantage of browser validation (related to #2159), while making a very small change. I considered updating the `GravityView_FieldType` abstract class to add an `input_type` and just use the existing `GravityView_FieldType_text` class, but I determined that this was cleaner.
- Loading branch information
Showing
2 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* url input type | ||
*/ | ||
class GravityView_FieldType_url extends GravityView_FieldType_text { | ||
|
||
function render_input( $override_input = null ) { | ||
|
||
if ( isset( $override_input ) ) { | ||
echo $override_input; | ||
return; | ||
} | ||
|
||
$class = ''; | ||
|
||
$show_mt = $this->show_merge_tags(); | ||
|
||
if ( $show_mt && false !== $this->field['merge_tags'] || 'force' === $this->field['merge_tags'] ) { | ||
$class = 'gv-merge-tag-support mt-position-right mt-hide_all_fields '; | ||
} | ||
$class .= \GV\Utils::get( $this->field, 'class', 'widefat' ); | ||
$placeholder = \GV\Utils::get( $this->field, 'placeholder' ); | ||
?> | ||
<input name="<?php echo esc_attr( $this->name ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>" id="<?php echo $this->get_field_id(); ?>" type="url" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>"> | ||
<?php | ||
} | ||
} | ||
|
||
|
||
|