| 1 |
<?php |
| 2 |
|
| 3 |
namespace forge12\contactform7\CF7DoubleOptIn { |
| 4 |
if (!defined('ABSPATH')) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
abstract class UIPage |
| 9 |
{ |
| 10 |
/** |
| 11 |
* @var string |
| 12 |
*/ |
| 13 |
protected $domain; |
| 14 |
/** |
| 15 |
* @var string |
| 16 |
*/ |
| 17 |
protected $slug; |
| 18 |
/** |
| 19 |
* @var string |
| 20 |
*/ |
| 21 |
protected $title; |
| 22 |
/** |
| 23 |
* @var string |
| 24 |
*/ |
| 25 |
protected $class; |
| 26 |
/** |
| 27 |
* @var int |
| 28 |
*/ |
| 29 |
protected $position = 0; |
| 30 |
|
| 31 |
/** |
| 32 |
* Constructor |
| 33 |
* @param UI $UI |
| 34 |
* @param string $domain |
| 35 |
*/ |
| 36 |
public function __construct($domain, $slug, $title, $position = 10, $class = '') |
| 37 |
{ |
| 38 |
$this->domain = $domain; |
| 39 |
$this->slug = $slug; |
| 40 |
$this->title = $title; |
| 41 |
$this->class = $class; |
| 42 |
$this->position = $position; |
| 43 |
|
| 44 |
add_filter('f12_cf7_doubleoptin_settings', array($this, 'getSettings')); |
| 45 |
} |
| 46 |
|
| 47 |
public function hideInMenu() |
| 48 |
{ |
| 49 |
return false; |
| 50 |
} |
| 51 |
|
| 52 |
public function getPosition() |
| 53 |
{ |
| 54 |
return $this->position; |
| 55 |
} |
| 56 |
|
| 57 |
public function isDashboard() |
| 58 |
{ |
| 59 |
return $this->getPosition() == 0; |
| 60 |
} |
| 61 |
|
| 62 |
public function getDomain() |
| 63 |
{ |
| 64 |
return $this->domain; |
| 65 |
} |
| 66 |
|
| 67 |
public function getSlug() |
| 68 |
{ |
| 69 |
return $this->slug; |
| 70 |
} |
| 71 |
|
| 72 |
public function getTitle() |
| 73 |
{ |
| 74 |
return __($this->title, 'double-opt-in'); |
| 75 |
} |
| 76 |
|
| 77 |
public function getClass() |
| 78 |
{ |
| 79 |
return $this->class; |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* @param $settings |
| 84 |
* @return mixed |
| 85 |
*/ |
| 86 |
public abstract function getSettings($settings); |
| 87 |
|
| 88 |
/** |
| 89 |
* @param string $slug - The WordPress Slug |
| 90 |
* @param string $page - The Name of the current Page e.g.: license |
| 91 |
* @return void |
| 92 |
*/ |
| 93 |
protected abstract function theSidebar($slug, $page); |
| 94 |
|
| 95 |
/** |
| 96 |
* @param string $slug - The WordPress Slug |
| 97 |
* @param string $page - The Name of the current Page e.g.: license |
| 98 |
* @return void |
| 99 |
*/ |
| 100 |
protected abstract function theContent($slug, $page, $settings); |
| 101 |
|
| 102 |
/** |
| 103 |
* @return void |
| 104 |
* @private WordPress HOOK |
| 105 |
*/ |
| 106 |
public function renderContent($slug, $page) |
| 107 |
{ |
| 108 |
if ($this->slug != $page) { |
| 109 |
return; |
| 110 |
} |
| 111 |
|
| 112 |
$settings = CF7DoubleOptIn::getInstance()->getSettings(); |
| 113 |
|
| 114 |
echo esc_html(Messages::getInstance()->getAll()); |
| 115 |
|
| 116 |
do_action('f12_cf7_doubleoptin_ui_'.$page.'_before_box'); |
| 117 |
?> |
| 118 |
<div class="box"> |
| 119 |
<?php |
| 120 |
do_action('f12_cf7_doubleoptin_ui_' . $page . '_before_content', $settings); |
| 121 |
$this->theContent($slug, $page, $settings); |
| 122 |
do_action('f12_cf7_doubleoptin_ui_' . $page . '_after_content', $settings); |
| 123 |
?> |
| 124 |
</div> |
| 125 |
<?php |
| 126 |
do_action('f12_cf7_doubleoptin_ui_'.$page.'_after_box'); |
| 127 |
} |
| 128 |
|
| 129 |
/** |
| 130 |
* @param string $slug |
| 131 |
* @param string $page |
| 132 |
* @return void |
| 133 |
* @private WordPress Hook |
| 134 |
*/ |
| 135 |
public function renderSidebar($slug, $page) |
| 136 |
{ |
| 137 |
if ($this->slug != $page) { |
| 138 |
return; |
| 139 |
} |
| 140 |
$this->theSidebar($slug, $page); |
| 141 |
} |
| 142 |
} |
| 143 |
} |