function sort_api_response($players) { if (!is_array($players) || !is_array($players['items'])) { return false; } $players = $players['items']; foreach ($players as $key => $player) { $id = BC_Utility::sanitize_player_id($player['id']); $players[$id] = $player; unset($players[$key]); } ksort($players); return $players; }
public static function remove_all_media_objects_for_account_id($account_id) { // Delete account players $player_ids = get_option('_bc_player_ids_' . BC_Utility::sanitize_id($account_id), array()); delete_option('_bc_player_playlist_ids_' . BC_Utility::sanitize_id($account_id)); delete_option('_bc_player_ids_' . BC_Utility::sanitize_id($account_id)); foreach ($player_ids as $player_id) { delete_option('_bc_player_' . BC_Utility::sanitize_player_id($player_id) . '_' . BC_Utility::sanitize_id($account_id)); } delete_option('_bc_player_default_' . BC_Utility::sanitize_id($account_id)); wp_reset_postdata(); }
/** * Render Player * * Renders the player from Brightcove based on passed parameters * * @since 1.0 * * @param string $type "playlist" or "video". * @param string $id The brightcove player or video ID. * @param string $account_id The Brightcove account ID. * @param string $player_id The brightcove player ID. * @param int $width The Width to display. * @param int $height The height to display. * * @return string The HTML code for the player */ public static function player($type, $id, $account_id, $player_id = 'default', $width = 0, $height = 0) { // Sanitize and Verify. $account_id = BC_Utility::sanitize_id($account_id); $player_id = BC_Utility::sanitize_player_id($player_id); $id = BC_Utility::sanitize_id($id); $height = (int) $height; $width = (int) $width; $type = 'playlist' === $type ? 'playlist' : 'video'; if ('playlist' === $type && 'default' === $player_id) { $player_api = new BC_Player_Management_API(); $players = $player_api->player_list_playlist_enabled(); if (is_wp_error($players) || !is_array($players) || $players['item_count'] < 1) { return '<div class="brightcove-player-warning">' . __('A specified Source does not have a playlist capable player <a href="https://studio.brightcove.com/products/videocloud/players/">configured</a>. Make sure there is at least one player with "Display Playlist" enabled.', 'brightcove') . '</div>'; } $player_id = esc_attr($players['items'][0]['id']); } $html = '<!-- Start of Brightcove Player -->'; if (0 === $width && 0 === $height) { $html .= '<div style="display: block; position: relative; max-width: 100%;"><div style="padding-top: 56.25%;">'; } $html .= sprintf('<iframe src="//players.brightcove.net/%s/%s_default/index.html?%sId=%s" allowfullscreen="" webkitallowfullscreen="" mozallowfullscreen="" style="width: %s; height: %s;%s"></iframe>', $account_id, $player_id, $type, $id, 0 === $width ? '100%' : $width . 'px', 0 === $height ? '100%' : $height . 'px', 0 === $width && 0 === $height ? 'position: absolute; top: 0px; bottom: 0px; right: 0px; left: 0px;' : ''); if (0 === $width && 0 === $height) { $html .= '</div></div>'; } $html .= '<!-- End of Brightcove Player -->'; /** * Filter the Brightcove Player HTML. * * @param string $html HTML markup of the Brightcove Player. * @param string $type "playlist" or "video". * @param string $id The brightcove player or video ID. * @param string $account_id The Brightcove account ID. * @param string $player_id The brightcove player ID. * @param int $width The Width to display. * @param int $height The height to display. */ $html = apply_filters('brightcove_video_html', $html, $type, $id, $account_id, $player_id, $width, $height); return $html; }