current = $this->currentItemMenu(); if ( array_key_exists( $this->current, $this->listMenu() ) ) { $this->catch_request(); } } /** * create template for admin page */ function createTpl( $content ) { $this->header(); echo $content; $this->footer(); } /** * show current template * @return bool or show template */ function getTemplate() { $current = $this->current; $args = $this->listMenu(); if ( !isset( $args[ $current ][ 'tmp' ] ) ) { return false; } $cancel = false; foreach ( $args as $key => $val ) { if ( $cancel ) { continue; } if ( $key == $current ) { $this->title = $val[ 'title' ]; $this->description = $val[ 'description' ]; $this->icon = $val[ 'icon' ]; $cancel = true; } if ( isset( $val[ 'submenu' ] ) ) { foreach ( $val[ 'submenu' ] as $skey => $sval ) { if ( $skey == $current ) { $this->title = $sval[ 'title' ]; $this->description = $sval[ 'description' ]; $this->icon = $val[ 'icon' ]; $cancel = true; } } } } $method = $args[ $current ][ 'tmp' ]; if ( method_exists( $this, $method ) or function_exists( $method ) ) { ob_start(); $this->renderTmpl( $method ); $content = ob_get_contents(); ob_end_clean(); $this->createTpl( $content ); return true; } return false; } /** * List Menu * @return mixed|string */ public function currentItemMenu() { $page = isset( $_GET[ 'czpage' ] ) ? $_GET[ 'czpage' ] : ''; if ( !$page ) { $list = $this->listMenu(); $page = key( $list ); } return $page; } /** * Admin form before */ private function header() { ?>
' . $args[ 'description' ] . '
'; $result .= '' . $args[ 'description' ] . '
'; $result .= '' . $args[ 'description' ] . '
'; $result .= $wp_editor; $result .= '' . $args[ 'description' ] . '
'; $result .= '' . $args[ 'description' ] . '
' . $args[ 'description' ] . '
'; $result .= '' . $args[ 'description' ] . '
'; $result .= '' . $args[ 'description' ] . '
'; $result .= '' . $args[ 'description' ] . '
| '; $result .= $field; $result .= ' | '; } $result .= '
| ';
foreach ( $fields as $field ) {
$result .= ' ';
$result .= $field;
$result .= ' ';
}
$result .= ' |
| '; foreach ( $rows as $row ) { $result .= $row; } $result .= ' |
| '; foreach ( $tabs as $tab ) { $result .= $tab; } $result .= ' |