WP_Ooyala_Backlot::render_popup PHP Method

render_popup() private method

private render_popup ( $response )
    private function render_popup($response)
    {
        $videos = json_decode($response);
        if (empty($videos->items)) {
            esc_html_e('No videos found.', 'ooyalavideo');
            return;
        }
        $output = $page_token = $next = '';
        if (!empty($videos->next_page)) {
            parse_str(urldecode($videos->next_page));
            $next = '<a href="' . esc_url('#' . $page_token) . '" class="next page-numbers ooyala-paging">Next &raquo;</a>';
        }
        $ids = isset($_REQUEST['ooyala_ids']) ? $_REQUEST['ooyala_ids'] : '';
        $ids = explode(',', $ids);
        $prev_token = -1;
        if ($page_token) {
            if (in_array($page_token, $ids)) {
                $key = array_keys($ids, $page_token);
                $key = $key[0];
                $prev_token = $key > 1 ? $ids[$key - 2] : '-1';
            } else {
                $c = count($ids);
                $prev_token = $c > 1 ? $ids[count($ids) - 2] : '-1';
                $ids[] = $page_token;
            }
        } elseif (count($ids) > 1) {
            $prev_token = $ids[count($ids) - 2];
        }
        if ($next || $prev_token != -1) {
            $output .= '<div class="tablenav"><div class="tablenav-pages">';
            if ($prev_token != -1) {
                $output .= '<a href="#' . esc_url('#' . $prev_token) . '" class="prev page-numbers ooyala-paging">&laquo; Prev</a>';
            }
            if ($next) {
                $output .= $next;
            }
            $output .= '</div></div>';
        }
        $ids = implode(',', $ids);
        $output .= '<input type="hidden" id="ooyala-ids" value="' . esc_attr($ids) . '" />';
        $output .= '<div id="ooyala-items">';
        foreach ($videos->items as $video) {
            $output .= '
			<div id="ooyala-item-' . esc_attr($video->embed_code) . '" class="ooyala-item">
				<div class="item-title"><a href="#" title="' . esc_attr($video->embed_code) . '" class="use-shortcode">' . esc_attr($video->name) . '</a></div>
				<div class="photo">
					<a href="#" title="' . esc_attr($video->embed_code) . '" class="use-shortcode"><img src="' . esc_url($video->preview_image_url) . '"></a>';
            if (current_theme_supports('post-thumbnails')) {
                $output .= '	<p><a href="#" class="use-featured">Use as featured image</a></p>';
            }
            $output .= '
				</div>
			</div>';
        }
        $output .= '</div><div style="clear:both;"></div>';
        echo $output;
    }