function on_load_manage_matches() { $id = isset($_GET['id']) ? $_GET['id'] : 0; $act = isset($_GET['act']) ? $_GET['act'] : ''; $media_options = array(); if ($act === 'add') { $this->set_page_title(__('Add match', WP_CLANWARS_TEXTDOMAIN)); } else { if ($act === 'edit') { $this->set_page_title(__('Edit match', WP_CLANWARS_TEXTDOMAIN)); // Check if match really exists $matchResult = \WP_Clanwars\Matches::get_match(array('id' => $id)); if (!$matchResult->count()) { wp_die(__('Cheatin’ uh?')); } if (!\WP_Clanwars\ACL::user_can('manage_game', $matchResult[0]->game_id)) { wp_die(__('Cheatin’ uh?')); } $media_options['post'] = $matchResult[0]->post_id; } else { // setup match table only when displaying all matches $this->match_table = new \WP_Clanwars\MatchTable(); $this->match_table->prepare_items(); } } wp_enqueue_media($media_options); wp_enqueue_script('wp-clanwars-matches'); wp_enqueue_script('wp-clanwars-gallery'); wp_localize_script('wp-clanwars-matches', 'wpCWL10n', array('plugin_url' => WP_CLANWARS_URL, 'addRound' => __('Add Round', WP_CLANWARS_TEXTDOMAIN), 'excludeMap' => __('Exclude map from match', WP_CLANWARS_TEXTDOMAIN), 'removeRound' => __('Remove round', WP_CLANWARS_TEXTDOMAIN), 'addGallery' => __('Add images', WP_CLANWARS_TEXTDOMAIN), 'confirmDeleteScreenshot' => __('Are you sure you want to delete this screenshot?', WP_CLANWARS_TEXTDOMAIN))); if (!Utils::is_post()) { return; } if (isset($_POST['game_id']) && !\WP_Clanwars\ACL::user_can('manage_game', $_POST['game_id'])) { wp_die(__('Cheatin’ uh?')); } if ($act === 'add') { $this->handle_add_match(); } else { if ($act === 'edit') { $this->handle_edit_match(); } else { $this->handle_matches_bulk_actions(); } } }