function jwplayer_proxy() { global $JWPLAYER_PROXY_METHODS; $nonce = ''; if (!empty($_GET['token'])) { $nonce = sanitize_text_field($_GET['token']); // input var okay } if (!wp_verify_nonce($nonce, 'jwplayer-widget-nonce')) { return; } if (!current_user_can('edit_posts')) { jwplayer_json_error('Access denied'); return; } if (!empty($_GET['method'])) { $method = sanitize_text_field($_GET['method']); // input var okay } if (null === $method) { jwplayer_json_error('Method was not specified'); return; } if (!in_array($method, $JWPLAYER_PROXY_METHODS)) { jwplayer_json_error('Access denied'); return; } $jwplayer_api = jwplayer_get_api_instance(); if (null === $jwplayer_api) { jwplayer_json_error('Enter your API key and secret first'); return; } $params = array(); foreach ($_GET as $name => $value) { if ('method' != $name) { $params[$name] = sanitize_text_field($value); // input var okay } } $params['api_format'] = 'php'; $response = $jwplayer_api->call($method, $params); header('Content-Type: application/json'); echo json_encode($response); }
function jwplayer_player_setting() { $login = get_option('jwplayer_login'); $loggedin = !empty($login); if ($loggedin) { $jwplayer_api = jwplayer_get_api_instance(); $response = $jwplayer_api->call('/players/list'); $player = get_option('jwplayer_player'); echo '<select name="jwplayer_player" id="jwplayer_player" />'; foreach ($response['players'] as $i => $p) { $key = $p['key']; if ($p['responsive']) { $description = htmlentities($p['name']) . ' (Responsive, ' . $p['aspectratio'] . ')'; } else { $description = htmlentities($p['name']) . ' (Fixed size, ' . $p['width'] . 'x' . $p['height'] . ')'; } echo '<option value="' . esc_attr($key) . '"' . esc_attr(selected($key == $player, true, false)) . '>' . esc_html($description) . '</option>'; } echo '</select>'; echo '<br />The <a href="' . esc_url('http://dashboard.jwplatform.com/players/') . '">player</a> to use for embedding the videos.'; echo 'If you want to override the default player for a given video, simply append a dash and the corresponding player key to video key in the quicktag. For example: <code>[jwplatform MdkflPz7-35rdi1pO]</code>.'; } else { echo '<input type="hidden" name="jwplayer_player" value="' . esc_attr(JWPLAYER_PLAYER) . '" />'; echo 'You have to save log in before you can set this option.'; } }