| 1 |
<?php |
| 2 |
if (! defined('ABSPATH')) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
class iHomefinderAdminShortcodes extends iHomefinderAdminAbstractPage |
| 7 |
{ |
| 8 |
|
| 9 |
private static $instance; |
| 10 |
private $shortcodeSelector; |
| 11 |
|
| 12 |
public static function getInstance() |
| 13 |
{ |
| 14 |
if (!isset(self::$instance)) { |
| 15 |
self::$instance = new self(); |
| 16 |
} |
| 17 |
return self::$instance; |
| 18 |
} |
| 19 |
|
| 20 |
public function __construct() |
| 21 |
{ |
| 22 |
parent::__construct(); |
| 23 |
$this->shortcodeSelector = new iHomefinderShortcodeSelector(); |
| 24 |
$this->shortcodeSelector->setButtonText("Copy to Clipboard"); |
| 25 |
$this->shortcodeSelector->setNotification("SearchByAddress"); |
| 26 |
} |
| 27 |
|
| 28 |
protected function getHeadContent() |
| 29 |
{ |
| 30 |
echo esc_html($this->shortcodeSelector->getHeadContent()); |
| 31 |
?> |
| 32 |
<style type="text/css"> |
| 33 |
body { |
| 34 |
background-color: inherit; |
| 35 |
} |
| 36 |
</style> |
| 37 |
<script type="text/javascript"> |
| 38 |
iHomefinderShortcodeSelector.onBuildShortcode = function(shortcode, theForm) { |
| 39 |
var $form = jQuery(theForm); |
| 40 |
var $submitButton = $form.find("button"); |
| 41 |
var $submitButtonContainer = $submitButton.parent(); |
| 42 |
var $notification = jQuery(".ihf-clipboard-notification"); |
| 43 |
var $copySelector = jQuery('input.ihf-select-shortcode'); |
| 44 |
if($notification.length == 0){ |
| 45 |
$notification = jQuery("<span>", { |
| 46 |
"class": "ihf-clipboard-notification", |
| 47 |
"style": "display: none;" |
| 48 |
}); |
| 49 |
$submitButtonContainer.append($notification); |
| 50 |
} |
| 51 |
$copySelector.val(shortcode).select(); |
| 52 |
if(document.execCommand("copy")){ |
| 53 |
$notification.html("Copied!"); |
| 54 |
$notification.slideDown("fast").delay(500).fadeOut(3000, function() { |
| 55 |
$notification.remove(); |
| 56 |
}); |
| 57 |
} else { |
| 58 |
$submitButtonContainer.append('<div class="panel panel-default" style="margin-top:25px"> <div class="panel-heading">Select and copy the following shortcode</div><div class="panel-body">' + shortcode + '</div></div>'); |
| 59 |
} |
| 60 |
} |
| 61 |
</script> |
| 62 |
<?php |
| 63 |
} |
| 64 |
|
| 65 |
protected function getContent() |
| 66 |
{ |
| 67 |
?> |
| 68 |
|
| 69 |
<h1>Optima Express Shortcodes</h1> |
| 70 |
<br /> |
| 71 |
|
| 72 |
<?php |
| 73 |
echo esc_html($this->shortcodeSelector->getShortcodeSelectorContent()); |
| 74 |
?> |
| 75 |
<input class="ihf-select-shortcode" type="text" value="" style="cursor: default !important; opacity:0;"> |
| 76 |
<?php |
| 77 |
} |
| 78 |
} |
| 79 |
|