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
/
smart-donations-progress-indicators.php
133 lines (105 loc) · 4.89 KB
/
smart-donations-progress-indicators.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
if(!defined('ABSPATH'))
die('Forbidden');
wp_enqueue_style('smart-donations-bootstrap-theme',SMART_DONATIONS_PLUGIN_URL.'css/bootstrap/bootstrap-theme.css');
wp_enqueue_style('smart-donations-bootstrap',SMART_DONATIONS_PLUGIN_URL.'css/bootstrap/bootstrap-scopped.css');
wp_enqueue_style('smart-donations-ladda',SMART_DONATIONS_PLUGIN_URL.'css/bootstrap/ladda-themeless.min.css');
wp_enqueue_script('smart-donations-bootstrap-theme',SMART_DONATIONS_PLUGIN_URL.'js/bootstrap/bootstrapUtils.js',array('isolated-slider'));
wp_enqueue_script('smart-donations-bootstrap-js',SMART_DONATIONS_PLUGIN_URL.'js/bootstrap/bootstrap.min.js',array('isolated-slider'));
wp_enqueue_script('smart-donations-spin-js',SMART_DONATIONS_PLUGIN_URL.'js/bootstrap/spin.min.js');
wp_enqueue_script('smart-donations-ladda-js',SMART_DONATIONS_PLUGIN_URL.'js/bootstrap/ladda.min.js',array('smart-donations-spin-js'));
if (isset($_GET['action'])) {
$action=$_GET['action'];
}else
$action='';
if($action==="add")
{
require_once('smart-donations-progress-add.php');
return;
}
wp_enqueue_script('jquery');
wp_enqueue_script('isolated-slider',plugin_dir_url(__FILE__).'js/rednao-isolated-jq.js',array('jquery'));
wp_enqueue_script('campaigns',plugin_dir_url(__FILE__).'js/smart-donations-progress-indicators.js',array('isolated-slider'));
wp_enqueue_style('smart-donations-main-style',plugin_dir_url(__FILE__).'css/mainStyle.css');
wp_enqueue_style('smart-donations-Slider',plugin_dir_url(__FILE__).'css/smartDonationsSlider/jquery-ui-1.10.2.custom.min.css');
if (isset($_GET['$progress_id'])) {
$progress_id=$_GET['$progress_id'];
}else
$progress_id='';
if($action!=null)
{
global $wpdb;
if($progress_id!=null)
{
if($action==="delete")
$wpdb->query($wpdb->prepare("delete from ".SMART_DONATIONS_PROGRESS_TABLE." WHERE progress_id=%d",$progress_id));
if($action==="edit")
{
$result=$wpdb->get_results($wpdb->prepare("SELECT * FROM ".SMART_DONATIONS_PROGRESS_TABLE." WHERE progress_id=%d",$progress_id));
if(count($result)>0)
{
$result=$result[0];
$options=rednao_smart_donations_json_object($result->options,$result->styles,null,null,null,null);
$script=<<<EOF
<script type="text/javascript" language="javascript">
var smartDonationsSavedProgress_Id="%s";
var smartDonationsSavedCampaign_Id="%s";
var smartDonationsSavedName="%s";
var smartDonationsSavedProgressType="%s";
var smartDonationsSavedOptions=jQuery.parseJSON('%s');
</script>
EOF;
echo sprintf($script,$result->progress_id,$result->campaign_id,$result->progress_name,$result->progress_type,$options);
include(SMART_DONATIONS_DIR.'/smart-donations-progress-add.php');
return;
}
}
}
}
require_once('smart-donations-messages.php');
if($action!="edit")
{
echo "<div class='bootstrap-wrapper'>";
echo "<h1>Progress Indicators</h1>";
echo sprintf(' <a href="?page=%s&action=%s" id="sDonationsAddNew" class="btn btn-default btn-success" ><span class="glyphicon glyphicon-plus" ></span>Add New</a>',$_REQUEST['page'],'add');
echo "</div>";
}
class Donations extends WP_List_Table
{
function get_columns()
{
return array(
'progress_name'=>'Name',
'campaign_name'=>'Campaign',
'progress_type'=>'Type',
'progress_id'=>'Progress Id'
);
}
function prepare_items()
{
$this->_column_headers=array($this->get_columns(),array('progress_id'),$this->get_sortable_columns());
global $wpdb;
$this->items=$result=$wpdb->get_results("select progress_name,coalesce(campaign.name,'Default') campaign_name,progress_type,progress_id
from ".SMART_DONATIONS_PROGRESS_TABLE." progress
left join ".SMART_DONATIONS_CAMPAIGN_TABLE." campaign
on campaign.campaign_id=progress.campaign_id ");
}
function get_sortable_columns()
{
}
function column_default($item, $column_name)
{
return $item->$column_name;
}
function column_progress_name($item) {
$actions = array(
'edit' => sprintf('<a href="?page=%s&$progress_id=%s&action=%s">Edit</a>',$_REQUEST['page'],$item->progress_id,'edit'),
'delete' => sprintf('<a href="?page=%s&$progress_id=%s&action=%s">Delete</a>',$_REQUEST['page'],$item->progress_id,'delete'),
);
return sprintf('%1$s %2$s', $item->progress_name, $this->row_actions($actions) );
}
}
$donationList=new Donations();
$donationList->prepare_items();
$donationList->display();
?>