/** * Init method, called when accessing the page. Handles tab setup, boxes setup, contest object loading and processing of $_POST and $_GET requests. */ function init() { $this->tabs = array('description' => array('title' => __('Description', 'contesthopper')), 'design' => array('title' => __('Design', 'contesthopper')), 'settings' => array('title' => __('Settings', 'contesthopper')), 'publish' => array('title' => __('Publish', 'contesthopper'), 'custom' => true), 'preview' => array('title' => __('Live Preview', 'contesthopper'), 'custom' => true), 'dashboard' => array('title' => __('Dashboard', 'contesthopper'), 'custom' => true)); if (empty($_GET['ch_page'])) { $_GET['ch_page'] = 'description'; } $this->tabs = apply_filters('ch_contest_tabs', $this->tabs); $this->boxes = array(); if ($_GET['ch_page'] == 'description' || empty($_GET['ch_page'])) { $this->setup_description(); } else { if ($_GET['ch_page'] == 'design') { $this->setup_design(); } else { if ($_GET['ch_page'] == 'settings') { $this->setup_settings(); } } } $this->boxes = apply_filters('ch_contest_boxes', $this->boxes, $_GET['ch_page']); if (empty($_GET['contest'])) { $contest_id = CH_Contest::get_new_id(); $ch_page = ''; if (isset($_GET['ch_page'])) { $ch_page = '&ch_page=' . $_GET['ch_page']; } wp_safe_redirect(admin_url('admin.php?page=' . self::page_id . $ch_page . '&contest=' . $contest_id)); die; } $this->contest = new CH_Contest($_GET['contest']); if ($this->contest->_valid != true) { wp_safe_redirect(admin_url()); die; } if (isset($_POST['_ch_form_post'])) { $fname = 'process_' . $_GET['ch_page']; if (isset($this->tabs[$_GET['ch_page']]['custom']) && $this->tabs[$_GET['ch_page']]['custom'] == true && method_exists($this, $fname)) { $this->{$fname}(); } else { $this->process_default(); } } wp_enqueue_style('ch_css_base'); add_action('admin_footer', array(&$this, 'list_scripts')); add_action('admin_enqueue_scripts', array(&$this, 'enqueue_scripts')); }