Modify tags dropdown
This commit is contained in:
parent
cb9f900588
commit
731b4487de
1 changed files with 33 additions and 7 deletions
|
@ -36,9 +36,14 @@ class WP_OpenPhoto {
|
||||||
|
|
||||||
function media_render_openphoto_tab() {
|
function media_render_openphoto_tab() {
|
||||||
media_upload_header();
|
media_upload_header();
|
||||||
|
|
||||||
|
$post_id = intval($_GET['post_id']);
|
||||||
|
$m = $_POST['m'];
|
||||||
|
|
||||||
$openphoto = get_option('openphoto_wordpress_settings');
|
$openphoto = get_option('openphoto_wordpress_settings');
|
||||||
|
|
||||||
|
|
||||||
|
// get photos
|
||||||
$curl_get = '?';
|
$curl_get = '?';
|
||||||
$curl_get .= 'oauth_consumer_key=' . $openphoto["oauth_consumer_key"];
|
$curl_get .= 'oauth_consumer_key=' . $openphoto["oauth_consumer_key"];
|
||||||
$curl_get .= '&oauth_consumer_secret=' . $openphoto["oauth_consumer_secret"];
|
$curl_get .= '&oauth_consumer_secret=' . $openphoto["oauth_consumer_secret"];
|
||||||
|
@ -54,10 +59,29 @@ class WP_OpenPhoto {
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt_array($ch, $curl_options);
|
curl_setopt_array($ch, $curl_options);
|
||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
$response = json_decode($response);
|
$response = json_decode($response);
|
||||||
$photos = $response->result;
|
$photos = $response->result;
|
||||||
|
|
||||||
|
// get tags
|
||||||
|
$curl_get = '?';
|
||||||
|
$curl_get .= 'oauth_consumer_key=' . $openphoto["oauth_consumer_key"];
|
||||||
|
$curl_get .= '&oauth_consumer_secret=' . $openphoto["oauth_consumer_secret"];
|
||||||
|
$curl_get .= '&oauth_token=' . $openphoto["oauth_token"];
|
||||||
|
$curl_get .= '&oauth_token_secret=' . $openphoto["oauth_token_secret"];
|
||||||
|
$curl_options = array(
|
||||||
|
CURLOPT_HEADER => 0,
|
||||||
|
CURLOPT_URL => trailingslashit($openphoto['host']) . 'tags/list.json' . $curl_get,
|
||||||
|
CURLOPT_FRESH_CONNECT => 1,
|
||||||
|
CURLOPT_RETURNTRANSFER => 1,
|
||||||
|
);
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt_array($ch, $curl_options);
|
||||||
|
$response = curl_exec($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
$response = json_decode($response);
|
||||||
|
$tags = $response->result;
|
||||||
|
|
||||||
$post_id = $_GET["post_id"];
|
$post_id = $_GET["post_id"];
|
||||||
|
|
||||||
if ($photos)
|
if ($photos)
|
||||||
|
@ -114,24 +138,26 @@ class WP_OpenPhoto {
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form id="op-filter" action="" method="get">
|
<?php if ($tags) { ?>
|
||||||
|
<form id="op-filter" action="?post_id=<?php echo $post_id ?>&type=image&tab=openphoto" method="post">
|
||||||
<div class="tablenav">
|
<div class="tablenav">
|
||||||
<div class="alignleft actions">
|
<div class="alignleft actions">
|
||||||
<select name="m">
|
<select name="m">
|
||||||
<option value="0">Show all tags</option>
|
<option value="0">Show all tags</option>
|
||||||
<?php
|
<?php
|
||||||
foreach($photos as $photo) {
|
|
||||||
$tags = $photo->tags;
|
|
||||||
foreach($tags as $tag) {
|
foreach($tags as $tag) {
|
||||||
echo '<option value="'.$tag.'">' . $tag . '</option>';
|
$selected = "";
|
||||||
|
if ($tag->id==$m) $selected = ' selected="selected"';
|
||||||
|
if ($tag->count > 0) echo '<option value="'.$tag->id .'"' . $selected . '>' . $tag->id . ' (' . $tag->count . ')</option>';
|
||||||
}
|
}
|
||||||
} ?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" name="post-query-submit" id="op-post-query-submit" class="button-secondary" value="Filter »">
|
<input type="submit" name="post-query-submit" id="op-post-query-submit" class="button-secondary" value="Filter »">
|
||||||
</div>
|
</div>
|
||||||
<br class="clear">
|
<br class="clear">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
<?php echo '<form enctype="multipart/form-data" method="post" action="'.home_url().'/wp-admin/media-upload.php?type=image&tab=library&post_id='.$post_id.'" class="media-upload-form validate" id="library-form">';
|
<?php echo '<form enctype="multipart/form-data" method="post" action="'.home_url().'/wp-admin/media-upload.php?type=image&tab=library&post_id='.$post_id.'" class="media-upload-form validate" id="library-form">';
|
||||||
echo '<input type="hidden" id="_wpnonce" name="_wpnonce" value="5acb57476d" /><input type="hidden" name="_wp_http_referer" value="/wp-admin/media-upload.php?post_id='.$post_id.'&type=image&tab=library" />';
|
echo '<input type="hidden" id="_wpnonce" name="_wpnonce" value="5acb57476d" /><input type="hidden" name="_wp_http_referer" value="/wp-admin/media-upload.php?post_id='.$post_id.'&type=image&tab=library" />';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue