Ejemplo n.º 1
0
function tern_wp_youtube_list()
{
    global $getWP, $wpdb, $post, $tern_wp_youtube_options;
    $o = $getWP->getOption('tern_wp_youtube', $tern_wp_youtube_options);
    //
    $page = empty($_GET['page']) ? (tern_wp_youtube_page() - 1) * $o['limit'] : (intval($_GET['page']) - 1) * $o['limit'];
    $p = $wpdb->get_results("select ID from {$wpdb->posts} as p, {$wpdb->postmeta} as m where p.ID = m.post_id and m.meta_key = '_tern_wp_youtube_video' order by p.post_date desc limit " . $page . ',' . $o['limit']);
    $t = $wpdb->get_var("select COUNT(*) from {$wpdb->posts} as p, {$wpdb->postmeta} as m where p.ID = m.post_id and m.meta_key = '_tern_wp_youtube_video'");
    //
    if (!empty($p)) {
        $n = new pagination(array('total' => $t, 'limit' => $o['limit'], 'url' => get_permalink(), 'seo' => $o['pages']));
        ?>
	
	<ul class="tern_wp_post_list category-<?php 
        echo $o['category'];
        ?>
">
<?php 
        foreach ($p as $post) {
            $post = get_post($post->ID);
            setup_postdata($post);
            $i = get_post_meta($post->ID, '_tern_wp_youtube_video', true);
            ?>
			<li class="tern_wp_post post<?php 
            echo $c;
            ?>
">
				<div class="tern_wp_post_head">
					<h3 id="post-<?php 
            the_ID();
            ?>
">
						<a href="<?php 
            the_permalink();
            ?>
" rel="bookmark" title="Permanent Link to <?php 
            the_title_attribute();
            ?>
"><?php 
            the_title();
            ?>
</a>
					</h3>
					<small><?php 
            the_time('F ');
            ?>
<span><?php 
            the_time('j');
            ?>
</span><?php 
            the_time(' Y');
            ?>
</small>
				</div>
				<div class="tern_wp_post_entry">
					<div class="tern_wp_post_image">
						<a href="<?php 
            the_permalink();
            ?>
"><?php 
            tern_wp_youtube_thumb();
            ?>
</a>
					</div>
					<?php 
            the_content('read more...');
            ?>
				</div>
				<div class="tern_wp_post_footer">
					Filed in <?php 
            the_category(', ', 'single');
            ?>
   |   Comments (<?php 
            echo comments_number('0', '1', '%');
            ?>
)
				</div>
			</li>
<?php 
            $c++;
        }
        ?>
	</ul>
<?php 
        $n = new pagination(array('total' => $t, 'limit' => $o['limit'], 'url' => get_category_link($o['category']), 'seo' => $o['pages']));
    } else {
        echo '<h3>Sorry, there is nothing here to see yet.</h3>';
    }
}
Ejemplo n.º 2
0
function WP_ayvpp_video_posts()
{
    global $getWP, $tern_wp_youtube_options, $wpdb;
    $o = $getWP->getOption('tern_wp_youtube', $tern_wp_youtube_options);
    //$videos = get_option('tern_wp_youtube_videos');
    //$videos = is_array($videos) ? $videos : array();
    $videos = $wpdb->get_col("select post_id from {$wpdb->postmeta} where meta_key='_tern_wp_youtube_video'");
    ?>
<div class="wrap">
	<div id="icon-options-general" class="icon32"><br /></div>
	<h2>Video Posts</h2>
	<p>Below you can delete, publish or draft your video posts.</p>
	
	<p>Let's talk about this video list a little. This list displays all the videos that have been found in your YouTube channels and playlists. For each of these videos a WordPress post has been created. From this list you can manipulate the WordPress post by publishing, drafting or deleting it. When deleting a post you are simply moving it to the trash. Any of these actions taken does not affect the list of videos below PROVIDED THAT YOU NEVER PERMANENTLY DELETE THE POST CREATED. You cannot delete a video from the list below unless you reset the list below or manually delete a post from the trash. Publishing, deleting or drafting only affects the post associated with the YouTube video. Remember this list is simply a reference to the videos that this plugin has found in your YouTube channels and playlists. However, upon the permanent deletion of a post the import may republish the deleted video post automatically. If you wish to hide a video post from your blog, set the post to draft or move it to the trash.</p>
	
	<form method="post" action="">
		<p>The following button will delete all videos from the list below and all WordPress posts associated with the videos below. THIS MAY TAKE SOME TIME.</p>
		<input type="submit" value="Completely Refresh Videos" name="refresh" class="button-primary action" />
		<input type="hidden" name="action" value="refresh" />
		<input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php 
    echo wp_create_nonce('tern_wp_youtube_nonce');
    ?>
" />
	</form>
	<br /><br />
	<form id="tern_wp_youtube_list_fm" method="post" action="">
		<div class="tablenav">
			<?php 
    $paged = $_GET['paged'] ? $_GET['paged'] : 1;
    $num = 10;
    $paging_text = paginate_links(array('total' => ceil(count($videos) / $num), 'current' => $paged, 'base' => 'admin.php?page=ayvpp-video-posts&%_%', 'format' => 'paged=%#%'));
    if ($paging_text) {
        $paging_text = sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>%s', number_format_i18n(($paged - 1) * $num + 1), number_format_i18n(min($paged * $num, count($videos))), number_format_i18n(count($videos)), $paging_text);
    }
    ?>
			<div class="tablenav-pages"><?php 
    echo $paging_text;
    ?>
</div>
			<div class="alignleft actions">
				<select name="action">
					<option value="" selected="selected">Bulk Actions</option>
					<option value="delete">Delete</option>
					<option value="publish">Publish</option>
					<option value="draft">Draft</option>
				</select>
				<input type="submit" value="Apply" name="doaction" class="button-secondary action" />
			</div>
			<br class="clear" />
		</div>
		<table class="widefat fixed" cellspacing="0">
			<thead>
			<tr class="thead">
				<th scope="col" id="cb" class="manage-column column-cb check-column"><input type="checkbox" /></th>
				<th scope="col" id="image" class="manage-column column-img" style="width:150px;">Preview</th>
				<th scope="col" id="video-id" class="manage-column column-id" style="width:20%;">Video I.D.</th>
				<th scope="col" id="title" class="manage-column column-title" style="width:20%;">Video Title</th>
				<th scope="col" id="url" class="manage-column column-url">URL</th>
				<th scope="col" id="post-id" class="manage-column column-post-id">Post ID</th>
			</tr>
			</thead>
			<tfoot>
			<tr class="thead">
				<th scope="col" class="manage-column column-cb check-column"><input type="checkbox" /></th>
				<th scope="col" class="manage-column column-img">Preview</th>
				<th scope="col" class="manage-column column-id">Video I.D.</th>
				<th scope="col" class="manage-column column-title">Video Title</th>
				<th scope="col" class="manage-column column-url">URL</th>
				<th scope="col" class="manage-column column-post-id">Post ID</th>
			</tr>
			</tfoot>
			<tbody id="fields" class="list:fields field-list">
				<?php 
    $videos = array_slice($videos, ($paged - 1) * $num, $num);
    foreach ($videos as $v) {
        $p = get_post($v);
        $k = get_post_meta($v, '_tern_wp_youtube_video', true);
        $d = empty($d) ? ' class="alternate"' : '';
        ?>
						<tr id='field-<?php 
        echo $k;
        ?>
'<?php 
        echo $d;
        ?>
>
							<th scope='row' class='check-column'><input type='checkbox' name='videos[]' id='field_<?php 
        echo $k;
        ?>
' value='<?php 
        echo $v;
        ?>
' /></th>
							<td class="image column-image">
								<?php 
        tern_wp_youtube_thumb($k);
        ?>
							</td>
							<td class="id column-id">
								<strong><?php 
        echo $k;
        ?>
</strong>
								<div class="row-actions">
									<?php 
        $s = '';
        if ($p->ID and $p->post_status != 'trash') {
            $s = '<span class="edit"><a href="admin.php?page=ayvpp-video-posts&videos%5B%5D=' . $v . '&action=delete&_wpnonce=' . wp_create_nonce('tern_wp_youtube_nonce') . '">Delete</a></span>';
        }
        if ($p->ID and $p->post_status != 'publish') {
            $s .= empty($s) ? '' : ' | ';
            $s .= '<span class="edit"><a href="admin.php?page=ayvpp-video-posts&videos%5B%5D=' . $v . '&action=publish&_wpnonce=' . wp_create_nonce('tern_wp_youtube_nonce') . '">Publish</a></span>';
        }
        if ($p->ID and $p->post_status != 'draft') {
            $s .= empty($s) ? '' : ' | ';
            $s .= '<span class="edit"><a href="admin.php?page=ayvpp-video-posts&videos%5B%5D=' . $v . '&action=draft&_wpnonce=' . wp_create_nonce('tern_wp_youtube_nonce') . '">Draft</a></span>';
        }
        echo $s;
        ?>
								</div>
							</td>
							<td class="title column-title">
								<span class="field_titles"><?php 
        echo $p->post_title;
        ?>
</span>
							</td>
							<td class="url column-url">
								<a href="<?php 
        tern_wp_youtube_video_watch_link($k);
        ?>
" target="_blank"><?php 
        tern_wp_youtube_video_watch_link($k);
        ?>
</a>
							</td>
							<td class="post-id column-post-id">
								<?php 
        echo $v;
        ?>
							</td>
						</tr>
				<?php 
    }
    ?>
			</tbody>
		</table>
		<div class="tablenav">
			<div class="alignleft actions">
				<select name="action2">
					<option value="" selected="selected">Bulk Actions</option>
					<option value="delete">Delete</option>
					<option value="publish">Publish</option>
					<option value="draft">Draft</option>
				</select>
				<input type="submit" value="Apply" name="doaction2" class="button-secondary action" />
			</div>
			<br class="clear" />
		</div>
		<input type="hidden" id="page" name="page" value="ayvpp-video-posts" />
		<input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php 
    echo wp_create_nonce('tern_wp_youtube_nonce');
    ?>
" />
	</form>
</div>
<?php 
}