function team_editor($page_title, $page_action, $page_submit, $team_id = 0) { $defaults = array('title' => '', 'logo' => 0, 'country' => '', 'home_team' => 0, 'action' => ''); $team = new stdClass(); if ($team_id > 0) { $teams = \WP_Clanwars\Teams::get_team(array('id' => $team_id)); if (!empty($teams)) { $team = reset($teams); } } extract(Utils::extract_args(stripslashes_deep($_POST), Utils::extract_args($team, $defaults))); $country_select = Utils::html_country_select_helper('name=country&id=country&show_popular=1&class=select2&select=' . $country, false); $view = new View('edit_team'); $context = compact('page_title', 'page_action', 'page_submit', 'team_id', 'title', 'logo', 'country', 'home_team', 'action', 'country_select'); $context['attach'] = isset($team->logo) ? wp_get_attachment_image($team->logo, 'thumbnail') : ''; $view->render($context); }