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;
     }
 }
$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">';
    foreach ($players as $player) {
        $html .= '<option value="' . esc_attr($player['pid']) . '"' . selected($player['pid'], $preferences['default_player_pid'], false) . '>' . esc_html($player['title']) . '</option>';
    }
    $html .= '</select></form>';
    echo $html;
}
?>

		<script type="text/javascript">
			tpHelper = { };
			tpHelper.token = "<?php 
echo esc_js($tp_api->mpx_signin());
?>
";
			tpHelper.account = "<?php 
echo esc_js($account['mpx_account_id']);
?>
";
			tpHelper.accountPid = "<?php 
echo esc_js($account['mpx_account_pid']);
?>
";
			tpHelper.isEmbed = "<?php 
echo esc_js($IS_EMBED);
?>
";
			tpHelper.mediaEmbedType = "<?php