/** * display global settings page (e.g. color scheme options) * * @param none * @return void */ function displayOptionsPage() { $options = get_option('leaguemanager'); if (isset($_POST['updateLeagueManager'])) { check_admin_referer('leaguemanager_manage-global-league-options'); $options['colors']['headers'] = $_POST['color_headers']; $options['colors']['rows'] = array('alternate' => $_POST['color_rows_alt'], 'main' => $_POST['color_rows'], 'ascend' => $_POST['color_rows_ascend'], 'descend' => $_POST['color_rows_descend'], 'relegation' => $_POST['color_rows_relegation']); update_option('leaguemanager', $options); parent::setMessage(__('Settings saved', 'leaguemanager')); parent::printMessage(); } require_once dirname(__FILE__) . '/settings-global.php'; }
/** * save match statistics * * The first parameter is simply the match ID. The second is a multidimensional array holding all statistics. * * @param int $match_id * @param array $stats * @return string */ function save($match_id, $stats) { global $wpdb, $leaguemanager; $match = $leaguemanager->getMatch($match_id); $custom = $match->custom; foreach ((array) $stats as $stat => $data) { $custom[$stat] = array_values($data); } $custom['hasStats'] = true; $wpdb->query($wpdb->prepare("UPDATE {$wpdb->leaguemanager_matches} SET `custom` = '%s' WHERE `id` = '%s'", maybe_serialize($custom), $match_id)); parent::setMessage(__('Saved Statstics', 'leaguemanager')); parent::printMessage(); }
/** * Load template for user display. First the current theme directory is checked for a template * before defaulting to the plugin * * @param string $template Name of the template file (without extension) * @param array $vars Array of variables name=>value available to display code (optional) * @return the content */ function loadTemplate($template, $vars = array()) { global $leaguemanager, $lmStats, $championship; extract($vars); ob_start(); if (file_exists(get_template_directory() . "/leaguemanager/{$template}.php")) { include get_template_directory() . "/leaguemanager/{$template}.php"; } elseif (file_exists(LEAGUEMANAGER_PATH . "/templates/" . $template . ".php")) { include LEAGUEMANAGER_PATH . "/templates/" . $template . ".php"; } else { parent::setMessage(sprintf(__('Could not load template %s.php', 'leaguemanager'), $template), true); parent::printMessage(); } $output = ob_get_contents(); ob_end_clean(); return $output; }