This repository has been archived by the owner on Sep 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpagebar_options.php
254 lines (210 loc) · 9.53 KB
/
pagebar_options.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
if (!class_exists('PagebarOptions')) {
class PagebarOptions {
function PagebarOptions() {
$page = add_action('admin_menu', array(&$this, 'adminmenu'));
if (!empty($_POST ['pagebar2update'])) {
$all_opts = array ("left", "center", "right", "pbText", "remove", "standard",
"current", "first", "last", "connect", "prev", "next",
"tooltipText", "tooltips", "pdisplay", "ndisplay",
"stylesheet", "cssFilename", "inherit");
$additionalPostbarOpts = array("auto", "bef_loop", "aft_loop", "footer");
$additionalCommentbarOpts = array("all", "where_all", "label_all");
$additionalMultipagebarOpts = array("all", "label_all");
$postbaroptions = (array_merge($all_opts, $additionalPostbarOpts));
$commentbaroptions = (array_merge($all_opts, $additionalCommentbarOpts));
$multipagebaroptions = (array_merge($all_opts, $additionalMultipagebarOpts));
$pbOptionsPostbar = array();
foreach ($postbaroptions as $param)
$pbOptionsPostbar[$param] = (empty ($_POST ["post_" . $param])) ?
"" : addslashes ( $_POST ["post_" . $param] );
$pbOptionsCommentbar = array();
foreach ($commentbaroptions as $param)
$pbOptionsCommentbar[$param] = (empty ($_POST ["comment_" . $param])) ?
"" : addslashes ( $_POST ["comment_" . $param] );
$pbOptionsMultipagebar = array();
foreach ($multipagebaroptions as $param)
$pbOptionsMultipagebar[$param] = (empty ($_POST ["multipage_" . $param])) ?
"" : addslashes ( $_POST ["multipage_" . $param] );
$text1 = update_option('postbar', $pbOptionsPostbar);
$text2 = update_option('multipagebar', $pbOptionsMultipagebar);
$text3 = update_option('commentbar', $pbOptionsCommentbar);
$text = ($text1 || $text2 || $text3) ? __( 'Options', 'pagebar') : __( 'No options', 'pagebar');
echo '<div id="message" class="updated fade"><p>' . $text . ' ' . __( 'updated', 'pagebar') . '</p></div>';
} //if
} //PagebarOptions()
/* -------------------------------------------------------------------------- */
function textinput($text, $var, $pbOptions, $prefix) {
echo '<tr><th scope="row" valign="top"><label for ="' . $var . '">' . __($text, 'pagebar') . '</label></th>';
echo '<td><input type="text" name="' . $prefix.'_'.$var . '" value="' . $pbOptions[$var] . '"></td></tr>';
}
/* -------------------------------------------------------------------------- */
function checkbox($text,$var,$pbOptions, $prefix, $onClick = '') {
return '<label id="lbl_' . $var . '"><input type="checkbox" id="cb_' . $var . '" name="' . $prefix.'_'.$var . '"' .
($onClick != '' ? ' onClick="' . $onClick .'" ' : '') .
($pbOptions [$var] ? "checked" : '') . '> ' . __($text, 'pagebar') . "</label><br/>\n";
}
/* -------------------------------------------------------------------------- */
function radiobutton($name, $value, $text, $pbOptions, $prefix, $onClick = '') {
return '<label><input type="radio" name="'. $prefix .'_'.$name.'" value="' . $value . '"' .
($onClick != '' ? ' onClick="' . $onClick .'" ' : '') .
($pbOptions[$name] == $value ? " checked " : '') . '> ' . __($text, 'pagebar') . "</label>\n";
}
/* -------------------------------------------------------------------------- */
function pb_basicOptions($pbOptions, $prefix) {
?>
<tr>
<?php
$this->textinput ( 'Left', 'left', $pbOptions, $prefix);
$this->textinput ( 'Center', 'center', $pbOptions, $prefix );
$this->textinput ( 'Right', 'right', $pbOptions, $prefix );
$this->textinput ( 'Leading text', 'pbText', $pbOptions, $prefix );
$this->textinput ( 'Standard page', 'standard', $pbOptions, $prefix );
$this->textinput ( 'Current Page', 'current', $pbOptions, $prefix );
$this->textinput ( 'First page', 'first', $pbOptions, $prefix );
$this->textinput ( 'Last page', 'last', $pbOptions, $prefix );
$this->textinput ( 'Connector', 'connect', $pbOptions, $prefix );
?>
</tr>
<tr>
<th scope="row" valign="top"><?php echo __( 'Previous', 'pagebar' )?></th>
<td>
<input type="text" id="previous" name="<?php echo $prefix ?>_prev" value="<?php echo $pbOptions ["prev"]?>">
<?php echo $this->radiobutton('pdisplay', 'auto', 'auto', $pbOptions, $prefix); ?>
<?php echo $this->radiobutton('pdisplay', 'always', 'always', $pbOptions, $prefix); ?>
<?php echo $this->radiobutton('pdisplay', 'never', 'never', $pbOptions, $prefix); ?>
</td>
</tr>
<tr>
<th scope="row" valign="top">
<?php echo __( 'Next', 'pagebar' )?>:
</th>
<td>
<input type="text" id="next" name="<?php echo $prefix ?>_next" value="<?php echo $pbOptions ["next"]?>">
<?php echo $this->radiobutton('ndisplay', 'auto', 'auto', $pbOptions, $prefix); ?>
<?php echo $this->radiobutton('ndisplay', 'always', 'always', $pbOptions, $prefix); ?>
<?php echo $this->radiobutton('ndisplay', 'never', 'never', $pbOptions, $prefix); ?>
</td>
</tr>
<tr>
<th scope="row"><?php echo __( 'Tooltip text', 'pagebar' )?>:</th>
<td>
<input type="text" name="<?php echo $prefix ?>_tooltipText" value="<?php echo $pbOptions ["tooltipText"]?>">
<?php echo $this->checkbox('Display', 'tooltips', $pbOptions, $prefix) ?>
</td>
</tr>
<?php } //pb_BasicOptions
/* -------------------------------------------------------------------------- */
function pb_stylesheetOptions($pbOptions, $prefix) {
?>
<tr>
<th scope="row" valign="top"><?php echo __( 'Stylesheet', 'pagebar')?>:</th>
<td>
<label>
<input onClick="cssSwitch();" type="radio" id="rdo_style"
name="<?php echo $prefix.'_'; ?>stylesheet" value="styleCss"
<?php
if ($pbOptions ["stylesheet"] == "styleCss")
echo " checked " ?>>
<?php echo __ ( 'style.css', 'pagebar')?>
</label>
<br />
<input onClick="cssSwitch();" type="radio" id="rdo_own"
name="<?php echo $prefix.'_'; ?>stylesheet" value="own"
<?php
if ($pbOptions ["stylesheet"] == "own")
echo " checked "
?>>
<input type="text" id="edt_cssFile" name="<?php echo $prefix.'_'; ?>cssFilename" value="<?php echo $pbOptions ["cssFilename"]?>">
</td>
</tr>
<?php }//stylesheetOptions()
/* -------------------------------------------------------------------------- */
function pb_submitButton($prefix) {
?>
<p class="submit"><input type="submit" name="pagebar2update" class="button-primary"
value="<?php echo __( 'Update Options', 'pagebar' );?>" /> <input
type="button" name="cancel" value="<?php echo __( 'Cancel', 'pagebar' );?>"
class="button" onclick="javascript:history.go(-1)" /></p>
<?php } //pb_submitButton
/* -------------------------------------------------------------------------- */
function adminmenu() {
global $pbOptions;
if (function_exists('add_options_page'))
$this->hook = add_options_page('Pagebar', 'Pagebar', 'manage_options', basename(__FILE__), array(&$this, 'pboptions'));
//add contextual help
if ( $this->hook )
add_action( 'load-' . $this->hook, array(&$this, 'load_help' ));
} //admin_menu()
/* -------------------------------------------------------------------------- */
function load_help() {
if (method_exists(get_current_screen(),'add_help_tab')) { // WP >= v3.3
get_current_screen()->add_help_tab(array('id'=>'pagebar_info', 'title'=>'Manual',
'content'=>'<p>If you\'re having problems you can consult the <a href="http://www.elektroelch.de/hacks/wp/pagebar/" target="_blank">Manual</a></p>'));
} else {
if (function_exists('add_contextual_help')) {
add_contextual_help(
$this->hook,
'<a href="http://www.elektroelch.de/hacks/wp/pagebar/" target="_blank">Manual</a>'
);
}
}
}
/* -------------------------------------------------------------------------- */
function pb_load_jquery() {
global $wp_scripts;
// tell WordPress to load jQuery UI tabs
wp_enqueue_script('jquery-ui-tabs');
// get registered script object for jquery-ui
$ui = $wp_scripts->query('jquery-ui-core');
// tell WordPress to load the Smoothness theme from Google CDN
$protocol = is_ssl() ? 'https' : 'http';
$url = "$protocol://ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/smoothness/jquery-ui.css";
wp_enqueue_style('jquery-ui-smoothness', $url, false, null);
}
/* -------------------------------------------------------------------------- */
function pboptions() {
global $pbOptions;
?>
<div class="wrap" id="top">
<h2>
<?php echo __( 'Pagebar' )?>
</h2>
<script>
$j=jQuery.noConflict();
$j(document).ready(function(){
$j("#optiontabs").tabs();
js_comment();
js_multipage();
});
</script>
<form method="post" id="pagebar" action="<?php echo $_SERVER ['REQUEST_URI']; ?>">
<?php settings_fields( 'pagebar-options' ); ?>
<div id="optiontabs">
<ul>
<li><a href="#postbar"><span>Postbar</span></a></li>
<li><a href="#multipagebar"><span>Multipagebar</span></a></li>
<li><a href="#commentbar"><span>Commentbar</span></a></li>
</ul>
<div id="postbar"><br/>
<p>
<?php require ('pagebar_options_postbar.php'); ?>
</p>
</div>
<div id="multipagebar" class="ui-tabs-hide"><br/>
<p>
<?php require ('pagebar_options_multipagebar.php'); ?>
</p>
</div>
<div id="commentbar" class="ui-tabs-hide"><br/>
<p>
<?php require ('pagebar_options_commentbar.php'); ?>
</p>
</div>
</div>
</form>
</div>
<?php } //pboptions()
} //if classexists
} //class
$pagebaroptions = new PagebarOptions;