This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mp3j_sc-widget.php
91 lines (78 loc) · 4.4 KB
/
mp3j_sc-widget.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/*
* SHORTCODES WIDGET
* add players via shortcodes.
*/
if ( class_exists("WP_Widget") ) {
if ( !class_exists("MP3j_single") ) {
class MP3j_single extends WP_Widget {
/* Constructor (required by api) */
function MP3j_single() {
$widget_ops = array(
'classname' => 'mp3jplayerwidget2',
'description' => __('Add mp3 players by writing shortcodes.',
'mp3jplayerwidget2')
);
$control_ops = array(
'id_base' => 'mp3mi-widget',
'width' => 800
);
$this->WP_Widget( 'mp3mi-widget', __('MP3j-sh', 'mp3jplayerwidget2'), $widget_ops, $control_ops );
}
/* Runs the shortcodes and writes the players (required by api) */
function widget( $args, $instance ) {
if ( !is_home() && !is_archive() && !is_singular() && !is_search() ) { return; }
global $mp3_fox;
if ( $mp3_fox->page_filter( $instance['restrict_list'], $instance['restrict_mode'] ) ) {
return;
}
$mp3_fox->Caller = "widget";
$arb_text = MP3j_Main::strip_scripts( $instance['arb_text'] );
$shortcodes_return = do_shortcode( $arb_text );
$mp3_fox->Caller = false;
extract( $args ); // supplied WP theme vars
echo $before_widget;
if ( $instance['title'] ) {
echo $before_title . MP3j_Main::strip_scripts( $instance['title'] ) . $after_title;
}
echo $shortcodes_return;
echo $after_widget;
return;
}
/* Updates the widget settings (required by api) */
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = MP3j_Main::strip_scripts( $new_instance['title'] );
$instance['restrict_list'] = MP3j_Main::strip_scripts( $new_instance['restrict_list'] );
$instance['restrict_mode'] = MP3j_Main::strip_scripts( $new_instance['restrict_mode'] );
$instance['arb_text'] = MP3j_Main::strip_scripts( $new_instance['arb_text'] );
return $instance;
}
/* Creates defaults and writes widget panel (required by api) */
function form( $instance ) {
$defaultvalues = array(
'title' => '',
'restrict_list' => '',
'restrict_mode' => 'exclude',
'arb_text' => ''
);
$instance = wp_parse_args( (array) $instance, $defaultvalues );
?>
<h3 style="text-align:right; font-size: 11px; margin-bottom:0px;"><a href="options-general.php?page=mp3jplayer.php">Plugin Options and Help</a></h3>
<p style="margin-top:-18px; margin-bottom:4px;">Shortcodes:</p>
<!-- Arbitrary text/shortcodes -->
<p style="margin:8px 0 10px 0; font-size: 11px;"><textarea class="widefat" style="font-size:11px;" rows="8" cols="85" id="<?php echo $this->get_field_id( 'arb_text' ); ?>" name="<?php echo $this->get_field_name( 'arb_text' ); ?>"><?php echo MP3j_Main::strip_scripts( $instance['arb_text'] ); ?></textarea></p>
<!-- Page Filter -->
<p style="font-size: 11px; margin:10px 0px 4px 0px;">
Include <input type="radio" id="<?php echo $this->get_field_id( 'restrict_mode' ); ?>" name="<?php echo $this->get_field_name( 'restrict_mode' ); ?>" value="include" <?php if ($instance['restrict_mode'] == "include") { _e('checked="checked"', "mp3jplayerwidget2"); }?> />
or <input type="radio" id="<?php echo $this->get_field_id( 'restrict_mode' ); ?>" name="<?php echo $this->get_field_name( 'restrict_mode' ); ?>" value="exclude" <?php if ($instance['restrict_mode'] == "exclude") { _e('checked="checked"', "mp3jplayerwidget2"); }?> />
Exclude pages <input type="text" class="widefat" style="font-size:11px; width:200px;" id="<?php echo $this->get_field_id( 'restrict_list' ); ?>" name="<?php echo $this->get_field_name( 'restrict_list' ); ?>" value="<?php echo MP3j_Main::strip_scripts( $instance['restrict_list'] ); ?>" /></p>
<p class="description" style="font-size:11px; color:#999999; margin-top:4px; margin-bottom:1px;">A comma separated list, can use post ID's, <code>index</code>, <code>archive</code>, <code>post</code>, and <code>search</code>.</p>
<!-- Widget Heading -->
<p style="margin: 0px 0px 35px 0px; font-size:11px;">Widget Heading: <input style="width:260px;"class="widefat" type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo MP3j_Main::strip_scripts( $instance['title'] ); ?>" /></p>
<?php
}
} //close class
}
}
?>