model = new AmadeoThemeSettingsModel(); } function themeActivationInit(){ $this->model->createTable(); } function themeSettingsAddAdminPage(){ add_theme_page(esc_html__('Theme Settings', 'amadeo-free'), esc_html__('Theme Settings', 'amadeo-free'), $this->user_capability, static::$plugin_id, array($this, 'themeSettingsPage')); } function addAdminScripts(){ if(get_current_screen()->id == 'appearance_page_'.static::$plugin_id){ wp_enqueue_script('jquery'); wp_enqueue_media(); wp_register_style('amadeo_ts_custom_admin_css', $this->pluginDirUrl() . '/css/admin_style.css'); wp_enqueue_style('amadeo_ts_custom_admin_css'); wp_register_script('amadeo_ts_custom_admin_js', $this->pluginDirUrl() . '/js/admin_script.js'); wp_enqueue_script('amadeo_ts_custom_admin_js'); } } function themeSettingsPage(){ $request = AmadeoRequest::instance(); $theme_entry = new AmadeoThemeSettingsEntry(); $action = $request->getQuerySingleParam('action'); if($action == 'save' && $request->isMethod('POST') && isset($_POST['entry'])){ if(check_admin_referer($this->action_token)){ $theme_entry->setFields($_POST['entry']); $this->model->createTable(); $this->model->saveEntry($theme_entry); } } $this->renderView('form.php', array('entry' => $theme_entry)); } private function renderView($view = 'form.php', array $args = array()){ extract($args); require_once 'views/index.php'; } public function getAdminPageUrl(array $params = array()){ $admin_url = admin_url('admin.php?page='. static::$plugin_id); $admin_url = add_query_arg($params, $admin_url); return $admin_url; } function pluginDirUrl(){ return strstr(content_url(), 'wp-content', TRUE) . strstr( __DIR__ , 'wp-content'. DIRECTORY_SEPARATOR); } } $themeSettings = new AmadeoThemeSettings();