`.
*/
if (!function_exists('is_admin')) {
header('Status: 403 Forbidden');
header('HTTP/1.1 403 Forbidden');
exit();
}
if (!class_exists("HypeIt")) {
class HypeIt {
// constructor
function __construct()
{
add_action('admin_menu', array(&$this, 'showAdminMenuLink'));
register_deactivation_hook(__FILE__, array(&$this, 'deactivatePlugin'));
}
// delete all options on deactivation
function deactivatePlugin()
{
delete_option('hype_tags');
delete_option('hype_style');
}
// special urlencoding used by hype it
function hype_urlencode($str)
{
return str_replace('%', '%25', urlencode(htmlentities($str)));
}
// main method
function getButton($permlink, &$tags)
{
$defined_tags = explode(',', get_option('hype_tags'));
$url = $this->hype_urlencode($permlink);
$ret_val = '';
if (is_array($tags)) {
foreach($tags as $tag) {
if (in_array(strtolower($tag->name), $defined_tags)) {
$ret_val = "
";
break;
}
}
}
return $ret_val;
}
function showAdminMenuLink()
{
$hook = add_options_page('hypeIt',
(version_compare($GLOBALS['wp_version'], '2.6.999', '>') ? '
' : '') . 't3n SocialNews',
9,
plugin_basename(__FILE__),
array(&$this,
'showAdminOptions'
)
);
if (function_exists('add_contextual_help') === true) {
add_contextual_help($hook,
sprintf('%s%s',
__('Ticketsystem/Wiki', 'hype_it'),
__('Plugin-Homepage', 'hype_it')
)
);
}
}
// Prints out the admin page
function showAdminOptions()
{
$hidden_field_name = 'submit_hidden';
// Read in existing option value from database
$opt_tags = get_option('hype_tags');
$opt_style = get_option('hype_style');
// See if the user has posted us some information
// If they did, this hidden field will be set to 'Y'
if ($_POST[ $hidden_field_name ] == 'Y') {
// Read their posted value
$opt_tags = $_POST[ 'hype_tags' ];
$opt_style = $_POST[ 'hype_style' ];
// Save the posted value in the database
// first lets cleanup
$tags = explode(',', $opt_tags);
reset($tags);
while (list($key, $value) = each($tags)) {
$tags[$key] = strtolower(trim($value));
}
$opt_tags = implode(',', $tags);
update_option('hype_tags', $opt_tags);
update_option('hype_style', $opt_style);
// Put an options updated message on the screen
?>
" . __('t3n SocialNews', 'hype_it') . "";
// options form
?>
getButton($permlink, $tags);
}
}==== ORIGINAL VERSION trunk/hype.php 128071287065049