forked from EddieRingle/wicketpixie
-
Notifications
You must be signed in to change notification settings - Fork 1
/
wicketpixie-admin.php
166 lines (158 loc) · 6.84 KB
/
wicketpixie-admin.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
$settings = array(
array(
"name" => "Blog Feed URL",
"description" => "RSS feed URL of your blog.",
"id" => "blog_feed_url",
"std" => "http://feeds.pirillo.com/ChrisPirillo",
"type" => "text"),
array(
"name" => "Flickr ID",
"description" => "Flickr ID used to access Flickr photo stream.",
"id" => "flickrid",
"type" => "text"),
array(
"name" => "Podcast Feed URL",
"description" => "URL of your podcast's feed.",
"id" => "podcastfeed",
"std" => "http://feeds.pirillo.com/ChrisPirilloShow",
"type" => "text"),
array(
"name" => "Twitter Username",
"description" => "Twitter Username",
"id" => "twitterid",
"std" => "chrispirillo",
"type" => "text"),
array(
"name" => "Ustream Channel",
"description" => "Channel name of stream set for live video.",
"id" => "ustreamchannel",
"std" => "chris-pirillo-live",
"type" => "text"),
array(
"name" => "YouTube Username",
"description" => "Your username for YouTube.",
"id" => "youtubeid",
"std" => "lockergnome",
"type" => "text"),
array(
"name" => "Show author on posts",
"description" => "Whether or not to show who wrote a particular post.",
"id" => "auth_credit",
"std" => 1,
"status" => 'checked',
"type" => 'checkbox'),
array(
"name" => "Enable WicketPixie Notifications",
"description" => "Check this if you want WicketPixie to notify services like Ping.fm about your new blog posts, as configured on the WicketPixie Notifications page.",
"id" => "notify",
"std" => 1,
"status" => 'checked',
"type" => 'checkbox')
);
function save($data,$array) {
check_admin_referer('wicketpixie-settings');
foreach ( $array as $value ) {
if(!wp_add_option($value['id'],$_POST[$value['id']])) {
wp_update_option($value['id'],$_POST[$value['id']]);
}
}
foreach ( $array as $value ) {
if( $value['type'] == 'checkbox' ) {
if(isset($_POST[$value['id']])) {
if(!wp_add_option($value['id'],'1')) {
wp_update_option($value['id'],'1');
}
} else {
if(!wp_add_option($value['id'],'0')) {
wp_update_option($value['id'],'0');
}
}
} elseif( $value['type'] != 'checkbox' ) {
if(!wp_add_option($value['id'],$_POST[$value['id']])) {
wp_update_option($value['id'],$_POST[$value['id']]);
}
} else {
if(!wp_add_option($value['id'],$_POST[$value['id']])) {
wp_update_option($value['id'],$_POST[$value['id']]);
}
}
}
wp_redirect($_SERVER['PHP_SELF'] ."?page=".basename(__FILE__)."&saved=true");
die;
}
function wicketpixie_toplevel_admin() {
global $settings;
if($_POST['action'] == 'save_settings') {
save($_POST,$settings);
}
if ( 'ccode' == $_REQUEST['action'] ) {
if('global_announcement' == $_POST['file']) {
require_once(TEMPLATEPATH .'/app/customcode.php');
writeto($_POST['code'],"global_announcement.php");
}
}
add_menu_page('WicketPixie Admin', 'WicketPixie', 'edit_themes', 'wicketpixie-admin.php', 'wicketpixie_admin_index',get_template_directory_uri() .'/images/wicketsmall.png');
}
function wicketpixie_admin_index() {
global $settings;
?>
<div class="wrap">
<div id="admin-options">
<h2>WicketPixie Setup</h2>
<p>We will need a few things from you to enable some of WicketPixie's features.</p>
<h3>IDs and URLs</h3>
<p id="flickrid_tip">You can obtain your Flickr ID by using <a href="http://idgettr.com">idGettr</a>.</p>
<p id="ustreamchannel_tip">Your Ustream Channel is the name of the Ustream channel you'd like to stream from. For example, the channel 'Chris Pirillo Live' (url of which is http://ustream.tv/channel/chris-pirillo-live) would be entered as 'chris-pirillo-live'. (Like you'd see it in the Ustream URL.)</p>
<form method="post" style="padding:20px 0 40px;" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=wicketpixie-admin.php">
<?php wp_nonce_field('wicketpixie-settings'); ?>
<table class="form-table">
<?php foreach( $settings as $value ) { ?>
<tr valign="top">
<th scope="row" style="font-size:12px;text-align:left;padding-right:10px;">
<acronym title="<?php echo $value['description']; ?>"><?php echo $value['name']; ?></acronym>
</th>
<td style="padding-right:10px;">
<?php
if (wp_get_option($value['id']) != false) {
$optdata = wp_get_option($value['id']);
} else {
$optdata = $value['std'];
}
?>
<input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php echo $optdata; ?>" <?php if($optdata === '1') { echo "checked='checked'"; } ?> />
</td>
</tr>
<?php } ?>
</table>
<p class="submit">
<input name="save_settings" type="submit" value="Save changes" />
<input type="hidden" name="action" value="save_settings" />
</p>
</form>
<h3>Global Announcement</h3>
<?php
require_once(TEMPLATEPATH .'/app/customcode.php');
if(function_exists(fetchcustomcode)) {
$glob = fetchcustomcode('global_announcement.php',true);
if($glob == fetchcustomcode('idontexist.no')) {
$glob = "";
}
} else {
$glob = "";
}
?>
<p>The text you enter here will appear on the home page and all your posts as a global announcement. HTML is allowed.</p>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=wicketpixie-admin.php&ccode=true" class="form-table">
<p><textarea name="code" id="code" style="border: 1px solid #999999;" cols="80" rows="15" /><?php echo $glob; ?></textarea></p>
<p class="submit">
<input name="save" type="submit" value="Save Global Announcement" />
<input type="hidden" name="action" value="ccode" />
<input type="hidden" name="file" value="global_announcement" />
</p>
</form>
</div>
<?php include_once('app/advert.php'); ?>
<?php
}
?>