| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Url Control |
| 5 |
* |
| 6 |
* Main options: |
| 7 |
* @see FactoryForms420_TextboxControl |
| 8 |
* |
| 9 |
* @author Alex Kovalev <alex.kovalevv@gmail.com> |
| 10 |
* @copyright (c) 2018, Webcraftic Ltd |
| 11 |
* |
| 12 |
* @package factory-forms |
| 13 |
* @since 1.0.0 |
| 14 |
*/ |
| 15 |
|
| 16 |
// Exit if accessed directly |
| 17 |
if( !defined('ABSPATH') ) { |
| 18 |
exit; |
| 19 |
} |
| 20 |
|
| 21 |
if( !class_exists('Wbcr_FactoryForms420_UrlControl') ) { |
| 22 |
|
| 23 |
class Wbcr_FactoryForms420_UrlControl extends Wbcr_FactoryForms420_TextboxControl { |
| 24 |
|
| 25 |
public $type = 'url'; |
| 26 |
|
| 27 |
/** |
| 28 |
* Adding 'http://' to the url if it was missed. |
| 29 |
* |
| 30 |
* @since 1.0.0 |
| 31 |
* @return string |
| 32 |
*/ |
| 33 |
public function getSubmitValue($name, $sub_name) |
| 34 |
{ |
| 35 |
$value = parent::getSubmitValue($name, $sub_name); |
| 36 |
if( !empty($value) && substr($value, 0, 4) != 'http' ) { |
| 37 |
$value = 'http://' . $value; |
| 38 |
} |
| 39 |
|
| 40 |
return $value; |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
|