forked from wp-plugins/lyrics-search-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lyricstatus.php
executable file
·58 lines (52 loc) · 2.29 KB
/
lyricstatus.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/*
Plugin Name: Lyrics Search Plugin
Plugin URI: http://www.lyricstatus.com
Description: Adds a sidebar widget to search for song lyrics on <a href="http://lyricstatus.com/">LyricStatus.com</a>
Author: LyricStatus
Version: 1.0.0
Author URI: http://www.lyricstatus.com
*/
// Shortcode for putting it into pages or posts directly
// profile id is required. Won't work without it.
class LyricStatus_Widget extends WP_Widget {
function LyricStatus_Widget() {
$widget_ops = array('classname' => 'widget_'.strtolower("LyricStatus"), 'description' => __('Lyrics Search Plugin', ''));
$this->WP_Widget(strtolower("LyricStatus"), __('LyricStatus', strtolower("LyricStatus")), $widget_ops);
}
function lyricstatus_shortcode() {
$text = "<form action=\"http://www.lyricstatus.com/search\" id=\"searchform\" target=\"_blank\" onsubmit='document.getElementById(\"q\").value = document.getElementById(\"searchInput\").value + \" \";'>
<input id=\"searchInput\" type=\"text\" accesskey=\"f\" value=\"\" /><input type=\"submit\" id=\"fulltext\" class=\"searchButton\" value=\"Search\" />
<input type='hidden' name='q' id='q' value=''/>
</form>
";
return $text;
}
function widget($args, $instance) {
$options = get_option(strtolower("LyricStatus").'_options');
extract( $args );
$title = apply_filters('widget_title', $instance['title']);
?>
<?php echo $before_widget; ?>
<?php if ( $title ) echo $before_title . $title . $after_title; ?>
<?php echo $this->lyricstatus_shortcode(); ?>
<?php echo $after_widget; ?>
<?php
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '') );
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
function form($instance) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '') );
$title = strip_tags($instance['title']);
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
</label></p>
<?php
}
}
add_action('widgets_init', create_function('', 'return register_widget("LyricStatus_Widget");'));