| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
|
| 5 |
Plugin Name: Zotpress |
| 6 |
Plugin URI: http://katieseaborn.com/plugins |
| 7 |
Description: Display your Zotero citations on your Wordpress blog. |
| 8 |
Author: Katie Seaborn |
| 9 |
Version: 2.2 |
| 10 |
Author URI: http://katieseaborn.com |
| 11 |
|
| 12 |
*/ |
| 13 |
|
| 14 |
define('ZOTPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ )); |
| 15 |
|
| 16 |
$shortcode_displayed = false; |
| 17 |
global $shortcode_displayed; |
| 18 |
|
| 19 |
|
| 20 |
// INSTALL ----------------------------------------------------------------------------------------- |
| 21 |
|
| 22 |
function Zotpress_activate() |
| 23 |
{ |
| 24 |
global $wpdb; |
| 25 |
|
| 26 |
$table_name = $wpdb->prefix . "zotpress"; |
| 27 |
if($wpdb->get_var("show tables like '$table_name'") != $table_name) |
| 28 |
{ |
| 29 |
$structure = "CREATE TABLE " . $wpdb->prefix . "zotpress ( |
| 30 |
id INT(9) NOT NULL AUTO_INCREMENT, |
| 31 |
account_type VARCHAR(10) NOT NULL, |
| 32 |
api_user_id VARCHAR(10) NOT NULL, |
| 33 |
public_key VARCHAR(28) default NULL, |
| 34 |
nickname VARCHAR(200) default NULL, |
| 35 |
UNIQUE KEY id (id) |
| 36 |
);"; |
| 37 |
|
| 38 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
| 39 |
dbDelta($structure); |
| 40 |
} |
| 41 |
//$wpdb->query($structure); |
| 42 |
|
| 43 |
$table_name = $wpdb->prefix . "zotpress_images"; |
| 44 |
if($wpdb->get_var("show tables like '$table_name'") != $table_name) |
| 45 |
{ |
| 46 |
$structure = "CREATE TABLE " . $wpdb->prefix . "zotpress_images ( |
| 47 |
id INT(9) NOT NULL AUTO_INCREMENT, |
| 48 |
citation_id VARCHAR(10) NOT NULL, |
| 49 |
image VARCHAR(300) NOT NULL, |
| 50 |
account_type VARCHAR(10) NOT NULL, |
| 51 |
api_user_id VARCHAR(10) NOT NULL, |
| 52 |
UNIQUE KEY id (id) |
| 53 |
);"; |
| 54 |
|
| 55 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
| 56 |
dbDelta($structure); |
| 57 |
} |
| 58 |
//$wpdb->query($structure); |
| 59 |
|
| 60 |
$table_name = $wpdb->prefix . "zotpress_cache"; |
| 61 |
if($wpdb->get_var("show tables like '$table_name'") != $table_name) |
| 62 |
{ |
| 63 |
$structure = "CREATE TABLE " . $wpdb->prefix . "zotpress_cache ( |
| 64 |
id INT(9) NOT NULL AUTO_INCREMENT, |
| 65 |
cache_key VARCHAR(100) NOT NULL, |
| 66 |
xml_data LONGTEXT NOT NULL, |
| 67 |
cache_time VARCHAR(100), |
| 68 |
UNIQUE KEY id (id) |
| 69 |
);"; |
| 70 |
|
| 71 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
| 72 |
dbDelta($structure); |
| 73 |
} |
| 74 |
//$wpdb->query($structure); |
| 75 |
} |
| 76 |
|
| 77 |
register_activation_hook(__FILE__, 'Zotpress_activate'); |
| 78 |
|
| 79 |
// INSTALL ----------------------------------------------------------------------------------------- |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
// ADMIN ----------------------------------------------------------------------------------------- |
| 84 |
|
| 85 |
function Zotpress_admin_footer() |
| 86 |
{ |
| 87 |
// Connect to database |
| 88 |
global $wpdb; |
| 89 |
|
| 90 |
$zp_accounts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."zotpress ORDER BY account_type DESC"); |
| 91 |
|
| 92 |
$zp_accounts_total = $wpdb->num_rows; |
| 93 |
|
| 94 |
// INCLUDE FILTER SCRIPT |
| 95 |
|
| 96 |
if ($zp_accounts_total > 0) |
| 97 |
{ |
| 98 |
if (!isset($_GET['accounts']) || !isset($_GET['help'])) { |
| 99 |
?> |
| 100 |
<script type="text/javascript"> |
| 101 |
|
| 102 |
jQuery(document).ready(function() |
| 103 |
{ |
| 104 |
<?php include('zotpress.display.filter.php'); ?> |
| 105 |
|
| 106 |
/* |
| 107 |
|
| 108 |
CITATION IMAGE HOVER |
| 109 |
|
| 110 |
*/ |
| 111 |
|
| 112 |
jQuery('div#zp-List').delegate("div.zp-Entry-Image", "hover", function () { |
| 113 |
jQuery(this).toggleClass("hover"); |
| 114 |
}); |
| 115 |
|
| 116 |
}); |
| 117 |
|
| 118 |
</script> |
| 119 |
<?php |
| 120 |
} |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
function Zotpress_admin_scripts() |
| 125 |
{ |
| 126 |
wp_enqueue_script( 'jquery' ); // For Wordpress 3.1 - TEST! |
| 127 |
wp_enqueue_script('media-upload'); |
| 128 |
wp_enqueue_script('thickbox'); |
| 129 |
|
| 130 |
if (isset($_GET['image'])) { |
| 131 |
wp_register_script('zotpress.image.js', ZOTPRESS_PLUGIN_URL . 'zotpress.image.js', array('jquery','media-upload','thickbox')); |
| 132 |
wp_enqueue_script('zotpress.image.js'); |
| 133 |
} |
| 134 |
|
| 135 |
if (isset($_GET['accounts'])) { |
| 136 |
wp_register_script('zotpress.accounts.js', ZOTPRESS_PLUGIN_URL . 'zotpress.accounts.js', array('jquery','media-upload','thickbox')); |
| 137 |
wp_enqueue_script('zotpress.accounts.js'); |
| 138 |
} |
| 139 |
|
| 140 |
wp_register_script('jquery.dotimeout.min.js', ZOTPRESS_PLUGIN_URL . 'jquery.dotimeout.min.js', array('jquery')); |
| 141 |
wp_enqueue_script('jquery.dotimeout.min.js'); |
| 142 |
|
| 143 |
wp_register_script('jquery.qtip-1.0.0-rc3.js', ZOTPRESS_PLUGIN_URL . 'jquery.qtip-1.0.0-rc3.js', array('jquery')); |
| 144 |
wp_enqueue_script('jquery.qtip-1.0.0-rc3.js'); |
| 145 |
|
| 146 |
wp_register_script('jquery.livequery.js', ZOTPRESS_PLUGIN_URL . 'jquery.livequery.js', array('jquery')); |
| 147 |
wp_enqueue_script('jquery.livequery.js'); |
| 148 |
} |
| 149 |
|
| 150 |
function Zotpress_admin_styles() |
| 151 |
{ |
| 152 |
wp_enqueue_style('thickbox'); |
| 153 |
|
| 154 |
wp_register_style('zotpress.css', ZOTPRESS_PLUGIN_URL . 'zotpress.css'); |
| 155 |
wp_enqueue_style('zotpress.css'); |
| 156 |
} |
| 157 |
|
| 158 |
function Zotpress_admin_menu() |
| 159 |
{ |
| 160 |
add_menu_page("Zotpress", "Zotpress", 3, "Zotpress", "Zotpress_options", ZOTPRESS_PLUGIN_URL."icon.png"); |
| 161 |
} |
| 162 |
|
| 163 |
function Zotpress_options() |
| 164 |
{ |
| 165 |
// Keep out those without access! |
| 166 |
if (!current_user_can('manage_options')) { |
| 167 |
wp_die( __('You do not have sufficient permissions to access this page.') ); |
| 168 |
} |
| 169 |
|
| 170 |
// cURL FUNCTION |
| 171 |
|
| 172 |
function Zotpress_curl($url) |
| 173 |
{ |
| 174 |
$ch = curl_init(); |
| 175 |
curl_setopt($ch, CURLOPT_URL, $url); |
| 176 |
curl_setopt($ch, CURLOPT_TIMEOUT, 30); |
| 177 |
curl_setopt ($ch, CURLOPT_HEADER, 0); |
| 178 |
curl_setopt ($ch, CURLOPT_USERAGENT, sprintf("Mozilla/%d.0",rand(4,5))); |
| 179 |
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
| 180 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 181 |
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); |
| 182 |
|
| 183 |
$data = curl_exec($ch); |
| 184 |
curl_close($ch); |
| 185 |
|
| 186 |
return $data; |
| 187 |
} |
| 188 |
|
| 189 |
|
| 190 |
// ADD ZOTERO ACCOUNT |
| 191 |
|
| 192 |
if (isset($_GET['accounts'])) |
| 193 |
{ |
| 194 |
include('zotpress.accounts.php'); |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
// ADD ZOTERO ACCOUNT |
| 200 |
|
| 201 |
else if (isset($_GET['image'])) |
| 202 |
{ |
| 203 |
global $wpdb; |
| 204 |
|
| 205 |
$zp_image = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."zotpress_images WHERE citation_id='".trim($_GET['citation_id'])."'"); |
| 206 |
|
| 207 |
include('zotpress.image.php'); |
| 208 |
} |
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
// HELP PAGE |
| 213 |
|
| 214 |
else if (isset($_GET['help'])) |
| 215 |
{ |
| 216 |
include('zotpress.help.php'); |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
// ADMIN VIEW CITATIONS |
| 222 |
|
| 223 |
else |
| 224 |
{ |
| 225 |
global $wpdb; |
| 226 |
|
| 227 |
$zp_accounts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."zotpress ORDER BY account_type DESC"); |
| 228 |
|
| 229 |
$zp_accounts_total = $wpdb->num_rows; |
| 230 |
|
| 231 |
|
| 232 |
// FILTER PARAMETERS |
| 233 |
|
| 234 |
// Account ID |
| 235 |
|
| 236 |
global $account_id; |
| 237 |
|
| 238 |
if (isset($_GET['account_id'])) |
| 239 |
if (trim($_GET['account_id']) != "") |
| 240 |
$account_id = trim($_GET['account_id']); |
| 241 |
else |
| 242 |
$account_id = false; |
| 243 |
else |
| 244 |
$account_id = false; |
| 245 |
|
| 246 |
// Collection ID |
| 247 |
|
| 248 |
global $collection_id; |
| 249 |
|
| 250 |
if (isset($_GET['collection_id'])) |
| 251 |
if (trim($_GET['collection_id']) != "") |
| 252 |
$collection_id = trim($_GET['collection_id']); |
| 253 |
else |
| 254 |
$collection_id = false; |
| 255 |
else |
| 256 |
$collection_id = false; |
| 257 |
|
| 258 |
// Tag Name |
| 259 |
|
| 260 |
global $tag_name; |
| 261 |
|
| 262 |
if (isset($_GET['tag_name'])) |
| 263 |
if (trim($_GET['tag_name']) != "") |
| 264 |
$tag_name = trim($_GET['tag_name']); |
| 265 |
else |
| 266 |
$tag_name = false; |
| 267 |
else |
| 268 |
$tag_name = false; |
| 269 |
|
| 270 |
// Limit |
| 271 |
|
| 272 |
global $limit; |
| 273 |
|
| 274 |
if (isset($_GET['limit'])) |
| 275 |
if (trim($_GET['limit']) != "") |
| 276 |
$limit = trim($_GET['limit']); |
| 277 |
else |
| 278 |
$limit = "5"; |
| 279 |
else |
| 280 |
$limit = "5"; |
| 281 |
|
| 282 |
|
| 283 |
// DISPLAY ADMIN CITATIONS |
| 284 |
|
| 285 |
include('zotpress.default.php'); |
| 286 |
} |
| 287 |
|
| 288 |
|
| 289 |
} |
| 290 |
|
| 291 |
// ADMIN ----------------------------------------------------------------------------------------- |
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
// SHORTCODE ----------------------------------------------------------------------------------------- |
| 296 |
|
| 297 |
function Zotpress_func($atts) { |
| 298 |
extract(shortcode_atts(array( |
| 299 |
|
| 300 |
'api_user_id' => false, |
| 301 |
'nickname' => false, |
| 302 |
'author' => false, |
| 303 |
|
| 304 |
'data_type' => "items", |
| 305 |
|
| 306 |
'collection_id' => false, |
| 307 |
'item_key' => false, |
| 308 |
'tag_name' => false, |
| 309 |
|
| 310 |
'content' => "bib", |
| 311 |
'style' => "apa", |
| 312 |
'order' => false, |
| 313 |
'sort' => false, |
| 314 |
'limit' => "50", |
| 315 |
|
| 316 |
'image' => "no" |
| 317 |
|
| 318 |
), $atts)); |
| 319 |
|
| 320 |
// Format attritbutes |
| 321 |
$api_user_id = str_replace('"','',html_entity_decode($api_user_id)); |
| 322 |
$nickname = str_replace('"','',html_entity_decode($nickname)); |
| 323 |
$author = str_replace('"','',html_entity_decode($author)); |
| 324 |
|
| 325 |
$data_type = str_replace('"','',html_entity_decode($data_type)); |
| 326 |
|
| 327 |
$collection_id = str_replace('"','',html_entity_decode($collection_id)); |
| 328 |
$item_key = str_replace('"','',html_entity_decode($item_key)); |
| 329 |
$tag_name = str_replace('"','',html_entity_decode($tag_name)); |
| 330 |
|
| 331 |
$content = str_replace('"','',html_entity_decode($content)); |
| 332 |
$style = str_replace('"','',html_entity_decode($style)); |
| 333 |
$order = str_replace('"','',html_entity_decode($order)); |
| 334 |
$sort = str_replace('"','',html_entity_decode($sort)); |
| 335 |
$limit = str_replace('"','',html_entity_decode($limit)); |
| 336 |
|
| 337 |
$image = str_replace('"','',html_entity_decode($image)); |
| 338 |
|
| 339 |
// Connect to database |
| 340 |
global $wpdb; |
| 341 |
|
| 342 |
if ($api_user_id != false) |
| 343 |
$zp_accounts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."zotpress WHERE api_user_id='".$api_user_id."'"); |
| 344 |
else if ($nickname != false) |
| 345 |
$zp_accounts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."zotpress WHERE nickname='".$nickname."'"); |
| 346 |
else |
| 347 |
$zp_accounts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."zotpress ORDER BY account_type DESC"); |
| 348 |
|
| 349 |
$zp_accounts_total = $wpdb->num_rows; |
| 350 |
$zp_instance_id = "zotpress-".rand(100,999); |
| 351 |
|
| 352 |
if ($zp_accounts_total > 0) |
| 353 |
{ |
| 354 |
include('zotpress.shortcode.php'); |
| 355 |
return "<div id='".$zp_instance_id."' class='zp-Zotpress'><span class='zp-Loading'><span>loading</span></span><div class='zp-ZotpressInner'></div></div>\n"; |
| 356 |
} |
| 357 |
|
| 358 |
$shortcode_displayed = true; |
| 359 |
} |
| 360 |
|
| 361 |
// SHORTCODE ----------------------------------------------------------------------------------------- |
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
// WIDGET ---------------------------------------------------------------------------------------------- |
| 366 |
|
| 367 |
class ZotpressWidget extends WP_Widget { |
| 368 |
|
| 369 |
function ZotpressWidget() |
| 370 |
{ |
| 371 |
$widget_ops = array('description' => __('Display your citations on your sidebar', 'zp-ZotpressWidget')); |
| 372 |
parent::WP_Widget(false, __('Zotpress Widget'), $widget_ops); |
| 373 |
} |
| 374 |
|
| 375 |
function widget( $args, $instance ) |
| 376 |
{ |
| 377 |
extract( $args ); |
| 378 |
|
| 379 |
// ARGUMENTS |
| 380 |
$title = apply_filters('widget_title', $instance['title'] ); |
| 381 |
|
| 382 |
$api_user_id = $instance['api_user_id']; |
| 383 |
$nickname = isset( $instance['nickname'] ) ? $instance['nickname'] : false; |
| 384 |
$author = isset( $instance['author'] ) ? $instance['author'] : false; |
| 385 |
|
| 386 |
$data_type = isset( $instance['data_type'] ) ? $instance['data_type'] : "items"; |
| 387 |
$collection_id = isset( $instance['collection_id'] ) ? $instance['collection_id'] : false; |
| 388 |
$item_key = isset( $instance['item_key'] ) ? $instance['item_key'] : false; |
| 389 |
$tag_name = isset( $instance['tag_name'] ) ? $instance['tag_name'] : false; |
| 390 |
|
| 391 |
$content = isset( $instance['content'] ) ? $instance['content'] : "bib"; |
| 392 |
$style = isset( $instance['style'] ) ? $instance['style'] : "apa"; |
| 393 |
$order = isset( $instance['order'] ) ? $instance['order'] : false; |
| 394 |
$sort = isset( $instance['sort'] ) ? $instance['sort'] : false; |
| 395 |
$limit = isset( $instance['limit'] ) ? $instance['limit'] : "5"; |
| 396 |
|
| 397 |
$image = isset( $instance['image'] ) ? $instance['image'] : "no"; |
| 398 |
|
| 399 |
// Required for theme |
| 400 |
echo $before_widget; |
| 401 |
|
| 402 |
if ($title) |
| 403 |
echo $before_title . $title . $after_title; |
| 404 |
|
| 405 |
// DISPLAY |
| 406 |
|
| 407 |
if (!$shortcode_displayed) |
| 408 |
{ |
| 409 |
// Connect to database |
| 410 |
global $wpdb; |
| 411 |
|
| 412 |
if ($api_user_id != false) |
| 413 |
$zp_accounts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."zotpress WHERE api_user_id='".$api_user_id."'"); |
| 414 |
else if ($nickname != false) |
| 415 |
$zp_accounts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."zotpress WHERE nickname='".$nickname."'"); |
| 416 |
else |
| 417 |
$zp_accounts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."zotpress ORDER BY account_type DESC"); |
| 418 |
} |
| 419 |
|
| 420 |
$zp_accounts_total = $wpdb->num_rows; |
| 421 |
$zp_instance_id = "zotpress-".rand(100,999); |
| 422 |
|
| 423 |
if ($zp_accounts_total > 0) |
| 424 |
{ |
| 425 |
include('zotpress.shortcode.php'); |
| 426 |
echo "<div id='".$zp_instance_id."' class='zp-Zotpress zp-ZotpressWidget'><span class='zp-Loading'><span>loading</span></span><div class='zp-ZotpressInner'></div></div>\n"; |
| 427 |
} |
| 428 |
else |
| 429 |
{ |
| 430 |
echo "<div id='".$zp_instance_id."' class='zp-Zotpress zp-ZotpressWidget'>Sorry, no citations found.</div>\n"; |
| 431 |
} |
| 432 |
|
| 433 |
// Required for theme |
| 434 |
echo $after_widget; |
| 435 |
} |
| 436 |
|
| 437 |
function update( $new_instance, $old_instance ) |
| 438 |
{ |
| 439 |
$instance = $old_instance; |
| 440 |
|
| 441 |
$instance['title'] = strip_tags( $new_instance['title'] ); |
| 442 |
|
| 443 |
$instance['api_user_id'] = strip_tags( $new_instance['api_user_id'] ); |
| 444 |
$instance['nickname'] = strip_tags($new_instance['nickname']); |
| 445 |
$instance['author'] = str_replace(" ", "+", strip_tags($new_instance['author'])); |
| 446 |
|
| 447 |
$instance['data_type'] = strip_tags( $new_instance['data_type'] ); |
| 448 |
$instance['collection_id'] = strip_tags($new_instance['collection_id']); |
| 449 |
$instance['item_key'] = strip_tags($new_instance['item_key']); |
| 450 |
$instance['tag_name'] = str_replace(" ", "+", strip_tags($new_instance['tag_name'])); |
| 451 |
|
| 452 |
$instance['content'] = strip_tags( $new_instance['content'] ); |
| 453 |
$instance['style'] = strip_tags($new_instance['style']); |
| 454 |
$instance['order'] = strip_tags($new_instance['order']); |
| 455 |
$instance['sort'] = strip_tags($new_instance['sort']); |
| 456 |
$instance['limit'] = strip_tags($new_instance['limit']); |
| 457 |
if (intval($instance['limit']) > 99) |
| 458 |
$instance['limit'] = "99"; |
| 459 |
if (trim($instance['limit']) == "") |
| 460 |
$instance['limit'] = "5"; |
| 461 |
|
| 462 |
$instance['image'] = strip_tags($new_instance['image']); |
| 463 |
|
| 464 |
return $instance; |
| 465 |
} |
| 466 |
|
| 467 |
function form( $instance ) |
| 468 |
{ |
| 469 |
$title = esc_attr( $instance['title'] ); |
| 470 |
?> |
| 471 |
|
| 472 |
<style type="text/css"> |
| 473 |
<!-- |
| 474 |
span.req { |
| 475 |
color: #CC0066; |
| 476 |
font-weight: bold; |
| 477 |
font-size: 1.4em; |
| 478 |
vertical-align: -20%; |
| 479 |
} |
| 480 |
|
| 481 |
div.zp-ZotpressWidget-Required { |
| 482 |
border-radius: 10px; |
| 483 |
-moz-border-radius: 10px; |
| 484 |
background-color: #fafafa; |
| 485 |
margin: 0 0 10px 0; |
| 486 |
padding: 10px 10px 1px 10px; |
| 487 |
} |
| 488 |
|
| 489 |
div.zp-ZotpressWidget-Required .widefat { |
| 490 |
width: 98%; |
| 491 |
} |
| 492 |
--> |
| 493 |
</style> |
| 494 |
|
| 495 |
<p> |
| 496 |
<label for="<?php echo $this->get_field_id( 'title' ); ?>">Widget Title:</label> |
| 497 |
<input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" class="widefat" /> |
| 498 |
</p> |
| 499 |
|
| 500 |
<div class="zp-ZotpressWidget-Required"> |
| 501 |
|
| 502 |
<p> |
| 503 |
Fill in <strong>one</strong> of the below. Req'd. |
| 504 |
</p> |
| 505 |
|
| 506 |
<p> |
| 507 |
<label for="<?php echo $this->get_field_id( 'api_user_id' ); ?>">API User/Group ID: <span class="req">*</span></label> |
| 508 |
<input id="<?php echo $this->get_field_id( 'api_user_id' ); ?>" name="<?php echo $this->get_field_name( 'api_user_id' ); ?>" value="<?php echo $instance['api_user_id']; ?>" class="widefat" /> |
| 509 |
</p> |
| 510 |
|
| 511 |
<p> |
| 512 |
<label for="<?php echo $this->get_field_id( 'nickname' ); ?>">Nickname: <span class="req">*</span></label> |
| 513 |
<input id="<?php echo $this->get_field_id( 'nickname' ); ?>" name="<?php echo $this->get_field_name( 'nickname' ); ?>" value="<?php echo $instance['nickname']; ?>" class="widefat" /> |
| 514 |
</p> |
| 515 |
|
| 516 |
</div> |
| 517 |
|
| 518 |
<p> |
| 519 |
<label for="<?php echo $this->get_field_id( 'data_type' ); ?>">Data Type:</label> |
| 520 |
<select id="<?php echo $this->get_field_id( 'data_type' ); ?>" name="<?php echo $this->get_field_name( 'data_type' ); ?>" class="widefat"> |
| 521 |
<option <?php if ( 'items' == $instance['data_type'] ) echo 'selected="selected"'; ?>>items</option> |
| 522 |
<option <?php if ( 'tags' == $instance['data_type'] ) echo 'selected="selected"'; ?>>tags</option> |
| 523 |
<option <?php if ( 'collections' == $instance['data_type'] ) echo 'selected="selected"'; ?>>collections</option> |
| 524 |
</select> |
| 525 |
</p> |
| 526 |
|
| 527 |
<p> |
| 528 |
<label for="<?php echo $this->get_field_id( 'author' ); ?>">Enter Author to List by Author:</label> |
| 529 |
<input id="<?php echo $this->get_field_id( 'author' ); ?>" name="<?php echo $this->get_field_name( 'author' ); ?>" value="<?php echo $instance['author']; ?>" class="widefat" /> |
| 530 |
</p> |
| 531 |
|
| 532 |
<p> |
| 533 |
<label for="<?php echo $this->get_field_id( 'collection_id' ); ?>">Enter Collection ID to List by Collection:</label> |
| 534 |
<input id="<?php echo $this->get_field_id( 'collection_id' ); ?>" name="<?php echo $this->get_field_name( 'collection_id' ); ?>" value="<?php echo $instance['collection_id']; ?>" class="widefat" /> |
| 535 |
</p> |
| 536 |
|
| 537 |
<p> |
| 538 |
<label for="<?php echo $this->get_field_id( 'item_key' ); ?>">Enter Item Key to List by Citation:</label> |
| 539 |
<input id="<?php echo $this->get_field_id( 'item_key' ); ?>" name="<?php echo $this->get_field_name( 'item_key' ); ?>" value="<?php echo $instance['item_key']; ?>" class="widefat" /> |
| 540 |
</p> |
| 541 |
|
| 542 |
<p> |
| 543 |
<label for="<?php echo $this->get_field_id( 'tag_name' ); ?>">Enter Tag Name to List by Tag:</label> |
| 544 |
<input id="<?php echo $this->get_field_id( 'tag_name' ); ?>" name="<?php echo $this->get_field_name( 'tag_name' ); ?>" value="<?php echo $instance['tag_name']; ?>" class="widefat" /> |
| 545 |
</p> |
| 546 |
|
| 547 |
<p> |
| 548 |
<label for="<?php echo $this->get_field_id( 'content' ); ?>">Content:</label> |
| 549 |
<select id="<?php echo $this->get_field_id( 'content' ); ?>" name="<?php echo $this->get_field_name( 'content' ); ?>" class="widefat"> |
| 550 |
<option <?php if ( 'bib' == $instance['content'] ) echo 'selected="selected"'; ?>>bib</option> |
| 551 |
<option <?php if ( 'html' == $instance['content'] ) echo 'selected="selected"'; ?>>html</option> |
| 552 |
</select> |
| 553 |
</p> |
| 554 |
|
| 555 |
<p> |
| 556 |
<label for="<?php echo $this->get_field_id( 'style' ); ?>">Style:</label> |
| 557 |
<input id="<?php echo $this->get_field_id( 'style' ); ?>" name="<?php echo $this->get_field_name( 'style' ); ?>" value="<?php echo $instance['style']; ?>" class="widefat" /> |
| 558 |
</p> |
| 559 |
|
| 560 |
<p> |
| 561 |
<label for="<?php echo $this->get_field_id( 'order' ); ?>">Order By:</label> |
| 562 |
<input id="<?php echo $this->get_field_id( 'order' ); ?>" name="<?php echo $this->get_field_name( 'order' ); ?>" value="<?php echo $instance['order']; ?>" class="widefat" /> |
| 563 |
</p> |
| 564 |
|
| 565 |
<p> |
| 566 |
<label for="<?php echo $this->get_field_id( 'sort' ); ?>">Sort Order:</label> |
| 567 |
<select id="<?php echo $this->get_field_id( 'sort' ); ?>" name="<?php echo $this->get_field_name( 'sort' ); ?>" class="widefat"> |
| 568 |
<option <?php if ( 'desc' == $instance['sort'] ) echo 'selected="selected"'; ?>>desc</option> |
| 569 |
<option <?php if ( 'asc' == $instance['sort'] ) echo 'selected="selected"'; ?>>asc</option> |
| 570 |
</select> |
| 571 |
</p> |
| 572 |
|
| 573 |
<p> |
| 574 |
<label for="<?php echo $this->get_field_id( 'limit' ); ?>">Limit:</label> |
| 575 |
<input id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" value="<?php echo $instance['limit']; ?>" class="widefat" /> |
| 576 |
</p> |
| 577 |
|
| 578 |
<p> |
| 579 |
<label for="<?php echo $this->get_field_id( 'image' ); ?>">Show Image?:</label> |
| 580 |
<select id="<?php echo $this->get_field_id( 'image' ); ?>" name="<?php echo $this->get_field_name( 'image' ); ?>" class="widefat"> |
| 581 |
<option <?php if ( 'no' == $instance['image'] ) echo 'selected="selected"'; ?>>no</option> |
| 582 |
<option <?php if ( 'yes' == $instance['image'] ) echo 'selected="selected"'; ?>>yes</option> |
| 583 |
</select> |
| 584 |
</p> |
| 585 |
|
| 586 |
<?php |
| 587 |
} |
| 588 |
} |
| 589 |
|
| 590 |
function ZotpressWidgetInit() { |
| 591 |
register_widget( 'ZotpressWidget' ); |
| 592 |
} |
| 593 |
|
| 594 |
// WIDGET ---------------------------------------------------------------------------------------------- |
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
// REGISTER ACTIONS --------------------------------------------------------------------------------- |
| 599 |
|
| 600 |
if (isset($_GET['page']) && $_GET['page'] == 'Zotpress') { |
| 601 |
add_action('admin_print_scripts', 'Zotpress_admin_scripts'); |
| 602 |
add_action('admin_print_styles', 'Zotpress_admin_styles'); |
| 603 |
add_action('admin_footer', 'Zotpress_admin_footer'); |
| 604 |
} |
| 605 |
|
| 606 |
add_action('admin_menu', 'Zotpress_admin_menu'); |
| 607 |
|
| 608 |
add_shortcode('zotpress', 'Zotpress_func'); |
| 609 |
add_action( 'widgets_init', 'ZotpressWidgetInit' ); |
| 610 |
|
| 611 |
// REGISTER ACTIONS --------------------------------------------------------------------------------- |
| 612 |
|
| 613 |
|
| 614 |
?> |