| 1 |
<?php |
| 2 |
/** |
| 3 |
* Assist admin page. |
| 4 |
*/ |
| 5 |
|
| 6 |
namespace Extendify\Assist; |
| 7 |
|
| 8 |
use Extendify\Config; |
| 9 |
|
| 10 |
/** |
| 11 |
* This class handles the Assist admin page. |
| 12 |
*/ |
| 13 |
class AdminPage |
| 14 |
{ |
| 15 |
|
| 16 |
/** |
| 17 |
* The admin page slug |
| 18 |
* |
| 19 |
* @var $string |
| 20 |
*/ |
| 21 |
public $slug = 'extendify-assist'; |
| 22 |
|
| 23 |
/** |
| 24 |
* Adds various actions to set up the page |
| 25 |
* |
| 26 |
* @return void |
| 27 |
*/ |
| 28 |
public function __construct() |
| 29 |
{ |
| 30 |
\add_action( |
| 31 |
'in_admin_header', |
| 32 |
function () { |
| 33 |
// phpcs:ignore WordPress.Security.NonceVerification |
| 34 |
if (isset($_GET['page']) && $_GET['page'] === 'extendify-assist') { |
| 35 |
\remove_all_actions('admin_notices'); |
| 36 |
\remove_all_actions('all_admin_notices'); |
| 37 |
} |
| 38 |
}, |
| 39 |
1000 |
| 40 |
); |
| 41 |
|
| 42 |
\add_action( |
| 43 |
'admin_enqueue_scripts', |
| 44 |
function () { |
| 45 |
// phpcs:ignore WordPress.Security.NonceVerification |
| 46 |
if (isset($_GET['page']) && $_GET['page'] === 'extendify-assist') { |
| 47 |
// TODO: Remove this dependency. |
| 48 |
\wp_enqueue_style( |
| 49 |
'extendify-assist', |
| 50 |
EXTENDIFY_URL . 'public/admin-page/welcome.css', |
| 51 |
[], |
| 52 |
Config::$environment === 'PRODUCTION' ? Config::$version : uniqid() |
| 53 |
); |
| 54 |
} |
| 55 |
} |
| 56 |
); |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
/** |
| 62 |
* Settings page output |
| 63 |
* |
| 64 |
* @since 1.0.0 |
| 65 |
* |
| 66 |
* @return void |
| 67 |
*/ |
| 68 |
public function pageContent() |
| 69 |
{ |
| 70 |
?> |
| 71 |
<div class="extendify-outer-container"> |
| 72 |
<div class="wrap" style="max-width:1000px;margin:-16px auto 24px;"> |
| 73 |
<ul class="extendify-welcome-tabs"> |
| 74 |
<li class="active"><a href="<?php echo \esc_url(\admin_url('admin.php?page=extendify-assist')); ?>">Assist</a></li> |
| 75 |
<li><a href="<?php echo \esc_url(\admin_url('admin.php?page=extendify-welcome')); ?>">Library</a></li> |
| 76 |
<li class="cta-button"><a href="<?php echo \esc_url_raw(\get_home_url()); ?>" target="_blank"><?php echo \esc_html(__('View Site', 'extendify')); ?></a></li> |
| 77 |
</ul> |
| 78 |
<div id="extendify-assist-landing-page" class="extendify-assist"></div> |
| 79 |
</div> |
| 80 |
</div> |
| 81 |
<?php |
| 82 |
} |
| 83 |
} |
| 84 |
|