| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
#[AllowDynamicProperties] |
| 3 |
class SH4_Api_Html_Admin |
| 4 |
{ |
| 5 |
public function __construct( |
| 6 |
HC3_Hooks $hooks, |
| 7 |
|
| 8 |
HC3_Ui $ui, |
| 9 |
HC3_Ui_Layout1 $layout |
| 10 |
) |
| 11 |
{ |
| 12 |
$this->ui = $ui; |
| 13 |
$this->layout = $layout; |
| 14 |
|
| 15 |
$this->self = $hooks->wrap($this); |
| 16 |
} |
| 17 |
|
| 18 |
public function post() |
| 19 |
{ |
| 20 |
$app = 'sh4-rest'; |
| 21 |
|
| 22 |
if( isset($_POST[$app . '_submit']) ){ |
| 23 |
if( isset($_POST[$app]) ){ |
| 24 |
foreach( (array)$_POST[$app] as $key => $value ){ |
| 25 |
$option_name = $app . '_' . $key; |
| 26 |
$value = sanitize_text_field( $value ); |
| 27 |
update_option( $option_name, $value ); |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
if( ! isset($_POST[$app]['enabled']) ){ |
| 32 |
$k = $app . '_enabled'; |
| 33 |
$value = 0; |
| 34 |
update_option( $k, $value ); |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
$ret = array( 'admin/api', '__Settings Updated__' ); |
| 39 |
return $ret; |
| 40 |
} |
| 41 |
|
| 42 |
public function render() |
| 43 |
{ |
| 44 |
ob_start(); |
| 45 |
require( dirname(__FILE__) . '/view.html.php' ); |
| 46 |
$out = ob_get_contents(); |
| 47 |
ob_end_clean(); |
| 48 |
|
| 49 |
$this->layout |
| 50 |
->setContent( $out ) |
| 51 |
->setBreadcrumb( $this->self->breadcrumb() ) |
| 52 |
->setHeader( $this->self->header() ) |
| 53 |
// ->setMenu( $this->self->menu() ) |
| 54 |
; |
| 55 |
|
| 56 |
$out = $this->layout->render(); |
| 57 |
return $out; |
| 58 |
} |
| 59 |
|
| 60 |
public function menu() |
| 61 |
{ |
| 62 |
$return = array(); |
| 63 |
return $return; |
| 64 |
} |
| 65 |
|
| 66 |
public function header() |
| 67 |
{ |
| 68 |
$out = '__REST API__'; |
| 69 |
return $out; |
| 70 |
} |
| 71 |
|
| 72 |
public function breadcrumb() |
| 73 |
{ |
| 74 |
$return = array(); |
| 75 |
$return['admin'] = array( 'admin', '__Administration__' ); |
| 76 |
return $return; |
| 77 |
} |
| 78 |
} |