/** * load admin area * * @param none * @return void */ public function __construct() { require_once ABSPATH . 'wp-admin/includes/template.php'; add_action('leaguemanager_edit_match_5280pool', array($this, 'editMatch'), 10, 7); add_action('team_edit_form_5280pool', array($this, 'editTeam')); add_action('admin_enqueue_scripts', function ($hook) { if (isset($_GET['page']) && $_GET['page'] == 'leaguemanager' && isset($_GET['subpage']) && $_GET['subpage'] == 'match') { wp_register_script('storageapi', WP_PLUGIN_URL . '/my5280/jquery.storageapi.min.js', array('jquery'), '1.7.2'); wp_register_script('my5280', WP_PLUGIN_URL . '/my5280/my5280.js', array('storageapi'), '0.1'); wp_enqueue_script('my5280'); } }); add_filter('league_menu_5280pool', array($this, 'appendToLeagueMenu')); add_filter('leaguemanager_matches_file_5280pool', function ($league, $season) { global $wpdb, $leaguemanager; // Check for team update information if (isset($_POST['updateLeague']) && $_POST['updateLeague'] === 'team' && isset($_POST['my5280_players']) && is_array($_POST['my5280_players'])) { if ($_POST['team_id'] == '') { $teamID = $wpdb->insert_id; } else { $teamID = $_POST['team_id']; } // Get the team include_once __DIR__ . '/../lib/team.php'; $team = new my5280_Team($leaguemanager->getTeam($teamID)); $team->clearPlayers(); foreach ($_POST['my5280_players'] as $playerID) { if ($playerID !== 'NONE') { $player = my5280::$instance->getPlayer($playerID); if ($player) { $team->addPlayer($player); } } } $team->save(); } // Display the matches return __DIR__ . '/matches.php'; }, 10, 2); }
/** * Add a new team to the session. * * @param string Name of the team. * @param string Home location for the team. * @param object The new team object. */ public function addTeam($Name, $Location) { $this->listTeams(); include_once dirname(__FILE__) . '/team.php'; $team = new my5280_Team(); $team->setName($Name); $team->setLocation($Location); $team->setSession($this); $this->teams[] = $team; return $team; }