private static function check_for_auth_error($response, $url)
 {
     // Sign in if the token is invalid/expired
     $responseBody = wp_remote_retrieve_body($response);
     //If the response is longer than 500 characters, then it's definitely not an auth exception, don't process very long strings.
     if (strlen($responseBody) < 500 && strpos($responseBody, 'Invalid security token.') !== false) {
         $tp_api = new ThePlatform_API();
         $oldToken = get_option(TP_TOKEN_OPTIONS_KEY);
         $token = $tp_api->mpx_signin(true);
         $newUrl = str_replace($oldToken, $token, $url);
         return $newUrl;
     } else {
         return false;
     }
 }
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
if (!defined('ABSPATH')) {
    exit;
}
//TODO: Would just be better to not include the upload media link in the sidebar?
preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);
if (count($matches) > 1) {
    //Then we're using IE
    $version = $matches[1];
    if ($version <= 9) {
        echo "<h2>Internet Explorer " . $version . ' is not supported</h2>';
        exit;
    }
}
if (!isset($tp_api)) {
    $tp_api = new ThePlatform_API();
}
$metadata = $tp_api->get_metadata_fields();
$preferences = get_option(TP_PREFERENCES_OPTIONS_KEY);
$account = get_option(TP_ACCOUNT_OPTIONS_KEY);
$upload_options = get_option(TP_UPLOAD_OPTIONS_KEY);
$metadata_options = get_option(TP_METADATA_OPTIONS_KEY);
$dataTypeDesc = array('Integer' => 'Integer', 'Decimal' => 'Decimal', 'String' => 'String', 'DateTime' => 'MM/DD/YYYY HH:MM:SS', 'Date' => 'YYYY-MM-DD', 'Time' => '24 hr time (20:00)', 'Link' => 'title: Link Title, href: http://www.wordpress.com', 'Duration' => 'HH:MM:SS', 'Boolean' => 'true, false, or empty', 'URI' => 'http://www.wordpress.com');
$structureDesc = array('Map' => 'Map (field1: value1, field2: value2)', 'List' => 'List (value1, value2)');
if (!defined('TP_MEDIA_BROWSER')) {
    wp_enqueue_style('tp_bootstrap_css');
    wp_enqueue_script('tp_theplatform_js');
    $tp_uploader_cap = apply_filters(TP_UPLOADER_CAP, TP_UPLOADER_DEFAULT_CAP);
    if (!current_user_can($tp_uploader_cap)) {
        wp_die('<p>You do not have sufficient permissions to upload MPX Media</p>');
    }
 /**
  * Validate mpx Settings for invalid input
  *
  * @param array $input Passed by Wordpress, an Array of mpx options
  *
  * @return array A cleaned up copy of the array, invalid values will be cleared.
  */
 function theplatform_preferences_options_validate($input)
 {
     require_once dirname(__FILE__) . '/thePlatform-API.php';
     $tp_api = new ThePlatform_API();
     $account_is_verified = $tp_api->verify_account_settings();
     if ($account_is_verified) {
         $region_is_verified = $tp_api->verify_account_region();
         if (isset($input['default_player_name']) && strpos($input['default_player_name'], '|') !== false) {
             $ids = explode('|', $input['default_player_name']);
             $input['default_player_name'] = $ids[0];
             $input['default_player_pid'] = $ids[1];
         }
         // If the account is selected, but no player has been set, use the first
         // returned as the default.
         if (!isset($input['default_player_name']) || empty($input['default_player_name'])) {
             if ($region_is_verified) {
                 $players = $tp_api->get_players();
                 $player = $players[0];
                 $input['default_player_name'] = $player['title'];
                 $input['default_player_pid'] = $player['pid'];
             } else {
                 $input['default_player_name'] = '';
                 $input['default_player_pid'] = '';
             }
         }
         // If the account is selected, but no upload server has been set, use the first
         // returned as the default.
         if (!isset($input['mpx_server_id']) || empty($input['mpx_server_id'])) {
             $input['mpx_server_id'] = 'DEFAULT_SERVER';
         }
         foreach ($input as $key => $value) {
             if ($key == 'videos_per_page' || $key === 'default_width' || $key === 'default_height') {
                 $input[$key] = intval($value);
             } else {
                 $input[$key] = sanitize_text_field($value);
             }
         }
     }
     return $input;
 }
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta name="tp:PreferredRuntimes" content="Flash, HTML5" />
		<meta name="tp:initialize" content="false" />

		<?php 
if (!defined('ABSPATH')) {
    exit;
}
$tp_viewer_cap = apply_filters(TP_VIEWER_CAP, TP_VIEWER_DEFAULT_CAP);
if (!current_user_can($tp_viewer_cap)) {
    wp_die('<p>You do not have sufficient permissions to browse MPX Media</p>');
}
if (!class_exists('ThePlatform_API')) {
    require_once dirname(__FILE__) . '/thePlatform-API.php';
}
$tp_api = new ThePlatform_API();
$metadata = $tp_api->get_metadata_fields();
define('TP_MEDIA_BROWSER', true);
$metadata_options = get_option(TP_METADATA_OPTIONS_KEY, array());
$upload_options = get_option(TP_UPLOAD_OPTIONS_KEY, TP_UPLOAD_FIELDS_DEFAULTS());
$preferences = get_option(TP_PREFERENCES_OPTIONS_KEY);
$account = get_option(TP_ACCOUNT_OPTIONS_KEY);
if (strcmp($account['mpx_account_id'], "") == 0) {
    wp_die('MPX Account ID is not set, please configure the plugin before attempting to manage media');
}
//Embed only stuff
$players = $tp_api->get_players();
$IS_EMBED = isset($_GET['embed']) ? true : false;
function writePlayers($players, $preferences)
{
    $html = '<p class="navbar-text sort-bar-text">Player:</p><form class="navbar-form navbar-left sort-bar-nav" role="sort"><select id="selectpick-player" class="form-control">';