| 1 |
<?php |
| 2 |
|
| 3 |
namespace WordProof\SDK\Controllers; |
| 4 |
|
| 5 |
use WordProof\SDK\Support\Settings; |
| 6 |
|
| 7 |
class SettingsController |
| 8 |
{ |
| 9 |
/** |
| 10 |
* Redirects user to the settings page. Returns false if not authenticated. |
| 11 |
* |
| 12 |
* @param null|string $redirectUrl |
| 13 |
* @return false |
| 14 |
*/ |
| 15 |
public function redirect($redirectUrl = null) |
| 16 |
{ |
| 17 |
return Settings::redirect($redirectUrl); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Adds admin page that will redirect the user to a predefined url. |
| 22 |
* |
| 23 |
* @action admin_menu |
| 24 |
*/ |
| 25 |
public function addRedirectPage() |
| 26 |
{ |
| 27 |
add_submenu_page( |
| 28 |
null, |
| 29 |
'WordProof Settings', |
| 30 |
'WordProof Settings', |
| 31 |
'publish_pages', |
| 32 |
'wordproof-redirect-settings', |
| 33 |
[$this, 'redirectPageContent'] |
| 34 |
); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* The content for the redirect page. Triggered by addRedirectPage(). |
| 39 |
*/ |
| 40 |
public function redirectPageContent() |
| 41 |
{ |
| 42 |
return; |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Redirects user on admin page load to the settings page on the WordProof My. |
| 47 |
* |
| 48 |
* @action load-admin_page_settings |
| 49 |
*/ |
| 50 |
public function redirectOnLoad() |
| 51 |
{ |
| 52 |
$closeWindowUrl = admin_url('admin.php?page=wordproof-close-after-redirect'); |
| 53 |
|
| 54 |
if ($this->redirect($closeWindowUrl) === false) { |
| 55 |
do_action('wordproof_authenticate', $closeWindowUrl); |
| 56 |
} |
| 57 |
} |
| 58 |
} |
| 59 |
|