Skip to content

Instantly share code, notes, and snippets.

Last active March 15, 2016 10:37
Show Gist options
  • Save kurozumi/8002f9a793e6d3aba5fb to your computer and use it in GitHub Desktop.
Save kurozumi/8002f9a793e6d3aba5fb to your computer and use it in GitHub Desktop.
require '../../../wp-admin/admin.php';
if (!is_admin())
$keyword = "wordpress";
$users = 3;
$url = sprintf("", urlencode($keyword), $users);
$options = array(
"http" => array(
"method" => "GET",
"header" => "User-Agent: wp"
$context = stream_context_create($options);
$feed = file_get_contents($url, false, $context);
$feed = simplexml_load_string($feed);
<link rel="stylesheet" href="">
<body id="hatebu">
<div class="container-fluid" style="padding:15px;">
<form class="form-inline" method="post" action="dialog.php">
<div class="form-group">
<input class="form-control" type="text" name="keyword" value="<?php echo $keyword; ?>" />
<div class="form-group">
<select class="form-control" name="users">
<?php foreach(array(1,3,50,100,500,1000) as $value):?>
<?php if($users == $value):?>
<option valeu="<?php echo $value;?>" selected><?php echo $value;?></option>
<?php else:?>
<option valeu="<?php echo $value;?>"><?php echo $value;?></option>
<?php endif;?>
<?php endforeach;?>
foreach ($feed->item as $item):
$dc = $item->children('');
$content = $item->children('');
$hatena = $item->children('');
<div class="well">
<h4><a href="<?php echo $item->link; ?>" target="_blank"><?php echo $item->title; ?></a></h4>
<p><?php echo strip_tags($item->description); ?></p>
<p><?php echo date("Y-m-d H:i:s", strtotime($dc->date));?></p>
<div class="clearfix">
<p class="pull-left"><button class="btn btn-primary" type="button">Hatena Bookmark <span class="badge"><?php echo $hatena->bookmarkcount;?></span></button></p>
<div class="pull-right"><button class="btn btn-success" data-url="<?php echo $item->link; ?>" onClick="insert(this)">挿入</button></div>
<?php endforeach; ?>
<script type="text/javascript">
function insert(button) {
var args = top.tinymce.activeEditor.windowManager.getParams();
var $ = args['jquery'];
var elem = $(button).parents(".well");
var text = $("h4", elem).text();
var url = $("button", elem).data("url");
top.tinymce.activeEditor.execCommand('mceInsertContent', false, '<a href="' + url + '">' + text + '</a>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment