This repository was 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
Expand file tree
/
Copy pathsmart-donations-progress-widget.php
More file actions
73 lines (61 loc) · 2.34 KB
/
Copy pathsmart-donations-progress-widget.php
File metadata and controls
73 lines (61 loc) · 2.34 KB
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
<?php
/**
* Created by JetBrains PhpStorm.
* User: edseventeen
* Date: 3/31/13
* Time: 8:06 AM
* To change this template use File | Settings | File Templates.
*/
require_once("smart-donations-helpers.php");
add_action( 'widgets_init', 'rednao_smart_donations_register_progress_widget' );
function rednao_smart_donations_register_progress_widget()
{
register_widget('rednao_smart_donations_progress_widget');
}
class rednao_smart_donations_progress_widget extends WP_Widget
{
function rednao_smart_donations_progress_widget()
{
$widget_ops = array(
'classname' => 'rednao_smart_donations_progress_widget', 'description' => 'Let you insert an progress indicator in any area'
);
parent::__construct('rednao_smart_donations_progress_widget', 'Smart Donations - Progress Indicator',$widget_ops );
}
function form($instance)
{
$defaults = array( 'progress_id' => '0','title'=>'' );
$instance = wp_parse_args( (array) $instance, $defaults );
$id = $instance['progress_id'];
$title = $instance['title'];
global $wpdb;
$results =$wpdb->get_results('select progress_id,progress_name from '.SMART_DONATIONS_PROGRESS_TABLE);
?>
<p class="description">
Select a progress indicator.
</p>
<p>Title
<input class="widefat" type="text" name="<?php echo $this->get_field_name("title");?>" value="<?php echo $title?>"/>
</p>
<?php
echo "<select class='widefat' name='".$this->get_field_name("progress_id")."'>";
foreach($results as $result)
{
echo "<option value='$result->progress_id'".($id==$result->progress_id?" selected='sel'":"" ).">";
echo $result->progress_name;
echo "</option>";
}
echo "</select>";
}
function update($new_instance, $old_instance)
{
$new_instance['title'] =strip_tags($new_instance['title']);
$new_instance['progress_id'] =strip_tags($new_instance['progress_id']);
delete_transient("rednao_smart_donations_progress_".$new_instance['progress_id']);
return $new_instance;
}
function widget($args, $instance) { // displays the widget
$id=$instance['progress_id'];
return rednao_smart_donations_load_progress($id,$instance['title'],false);
}
}
?>