Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 548 lines (503 sloc) 15.469 kb
a2cbe2d @msporny Added saving of PaySwarm configuration.
msporny authored
1 <?php
2
987cf90 @dlongley Use settings API.
dlongley authored
3 require_once('payswarm-wp-hooks.inc');
698e94e @dlongley Add use of license caching.
dlongley authored
4
7783a55 @msporny Added more database code, lots of documentation.
msporny authored
5 /**
987cf90 @dlongley Use settings API.
dlongley authored
6 * Called when a user accesses the admin area.
cdd0749 @dlongley Fixes to wordpress article asset and listing data.
dlongley authored
7 *
7783a55 @msporny Added more database code, lots of documentation.
msporny authored
8 * @package payswarm
9 * @since 1.0
10 */
987cf90 @dlongley Use settings API.
dlongley authored
11 function payswarm_admin_init() {
12 // set up pages
13 payswarm_setup_register_page();
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
14 payswarm_setup_options_page();
987cf90 @dlongley Use settings API.
dlongley authored
15 }
f721507 @msporny Added PaySwarm token database, re-arranged code, added basic JavaScri…
msporny authored
16
987cf90 @dlongley Use settings API.
dlongley authored
17 /**
18 * Add a PaySwarm configuration link to the admin panel.
19 *
20 * @package payswarm
21 * @since 1.0
22 */
23 function payswarm_admin_menu() {
24 if(!current_user_can('manage_options')) {
25 return;
26 }
27
28 // add registration page
29 add_submenu_page(
30 'plugins.php', 'PaySwarm', 'PaySwarm',
31 'administrator', 'payswarm', 'payswarm_render_register_page');
32
33 // add settings page
34 add_options_page(
35 'PaySwarm Settings', 'PaySwarm',
36 'manage_options', 'payswarm', 'payswarm_render_options_page');
37 }
1ba43f2 @msporny Added more code to support new client registration procedure.
msporny authored
38
987cf90 @dlongley Use settings API.
dlongley authored
39 /**
40 * Gets the PaySwarm options.
41 *
42 * @package payswarm
43 * @since 1.0
44 *
45 * @return the payswarm options.
46 */
47 function payswarm_get_options() {
48 // get default payswarm options
49 return get_option('payswarm_options', array(
50 'default_price' => '0.05',
51 'default_license_id' => 'http://purl.org/payswarm/licenses/blogging',
b8207a0 @dlongley Use payswarm_get_options().
dlongley authored
52 'default_license_hash' => '7ede2ee1c8e0f3125b7758df2b6b47115dd596ce',
987cf90 @dlongley Use settings API.
dlongley authored
53 'default_authority_rate' => '10.0'
54 ));
a2cbe2d @msporny Added saving of PaySwarm configuration.
msporny authored
55 }
56
7783a55 @msporny Added more database code, lots of documentation.
msporny authored
57 /**
987cf90 @dlongley Use settings API.
dlongley authored
58 * Sets up the PaySwarm options page.
cdd0749 @dlongley Fixes to wordpress article asset and listing data.
dlongley authored
59 *
7783a55 @msporny Added more database code, lots of documentation.
msporny authored
60 * @package payswarm
61 * @since 1.0
62 */
987cf90 @dlongley Use settings API.
dlongley authored
63 function payswarm_setup_options_page() {
64 // get payswarm options
65 $options = payswarm_get_options();
66
67 // add payswarm option section
68 add_settings_section(
69 'payswarm_options_section',
70 'PaySwarm Options',
71 'payswarm_render_options_section',
72 'payswarm');
73
74 // add payswarm option fields
75 add_settings_field(
76 'payswarm_default_price',
77 'Default Paid Content Price',
78 'payswarm_render_default_price',
79 'payswarm',
80 'payswarm_options_section',
81 $options);
82 add_settings_field(
83 'payswarm_default_license_id',
84 'Default Paid Content License',
85 'payswarm_render_default_license_id',
86 'payswarm',
87 'payswarm_options_section',
88 $options);
89 add_settings_field(
90 'payswarm_default_authority_rate',
91 'Default Authority Rate',
92 'payswarm_render_default_authority_rate',
93 'payswarm',
94 'payswarm_options_section',
95 $options);
96
97 // register payswarm options
98 register_setting(
99 'payswarm',
100 'payswarm_options',
101 'payswarm_validate_options');
a2cbe2d @msporny Added saving of PaySwarm configuration.
msporny authored
102 }
103
7783a55 @msporny Added more database code, lots of documentation.
msporny authored
104 /**
987cf90 @dlongley Use settings API.
dlongley authored
105 * Sets up the PaySwarm registration page.
106 */
107 function payswarm_setup_register_page() {
108 // add payswarm registration section
109 add_settings_section(
110 'payswarm_register_section',
111 'PaySwarm Registration',
112 'payswarm_render_register_section',
113 'payswarm_register');
114
115 // add payswarm register fields
116 add_settings_field(
117 'payswarm_authority_host',
118 'PaySwarm Authority',
119 'payswarm_render_authority_host',
120 'payswarm_register',
121 'payswarm_register_section');
122 add_settings_field(
123 'payswarm_overwrite_key_pair',
124 'Overwrite Existing Key Pair',
125 'payswarm_render_overwrite_key_pair',
126 'payswarm_register',
127 'payswarm_register_section');
128
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
129 // no need to register settings, options.php is not used for registration
987cf90 @dlongley Use settings API.
dlongley authored
130 }
131
132 /**
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
133 * Initiates vendor registration with a PaySwarm Authority.
cdd0749 @dlongley Fixes to wordpress article asset and listing data.
dlongley authored
134 *
1ba43f2 @msporny Added more code to support new client registration procedure.
msporny authored
135 * @package payswarm
136 * @since 1.0
137 */
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
138 function payswarm_init_registration() {
139 // do nonce security check (dies on failure)
1bb26c0 @dlongley Fix bugs with registration.
dlongley authored
140 $valid_nonce = wp_verify_nonce(
141 $_POST['_wpnonce'], 'payswarm_register-options');
142 if(!$valid_nonce) {
143 wp_die(__('Access denied.'));
144 }
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
145
146 try {
147 // validate authority host
148 if(!isset($_POST['payswarm_authority_host']) or
149 $_POST['payswarm_authority_host'] === '') {
150 throw new Exception('Invalid PaySwarm Authority host.');
151 }
152 $host = $_POST['payswarm_authority_host'];
1bb26c0 @dlongley Fix bugs with registration.
dlongley authored
153 update_option('payswarm_authority_host', $host);
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
154
155 // sanitize overwrite key pair
156 $overwrite = isset($_POST['payswarm_overwrite_key_pair']);
1bb26c0 @dlongley Fix bugs with registration.
dlongley authored
157 update_option('payswarm_overwrite_key_pair', $overwrite);
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
158
159 // get register vendor url
160 $callback = plugins_url() . '/payswarm/payswarm-register.php';
161 $url = payswarm_get_register_vendor_url($host, $callback, $overwrite);
162
163 // redirect to the PaySwarm Authority registration URL
164 header('HTTP/1.1 303 See Other');
165 header("Location: $url");
166 }
167 catch(Exception $e) {
168 // close the popup and report an error
169 $url = admin_url() . 'plugins.php?page=payswarm&error=config';
0d80d6a @dlongley Fix more registration bugs.
dlongley authored
170 payswarm_close_register_popup($url);
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
171 }
172 }
173
174 /**
175 * Completes vendor registration with a PaySwarm Authority.
176 *
177 * @package payswarm
178 * @since 1.0
179 *
180 * @param string $response the JSON encoded encrypted registration response.
181 */
182 function payswarm_complete_registration($response) {
183 try {
184 // get vendor preferences from response
185 $prefs = payswarm_register_vendor($response);
987cf90 @dlongley Use settings API.
dlongley authored
186
2d83d1a @dlongley More clean up and reorganization.
dlongley authored
187 // save vendor information, set registered
188 update_option('payswarm_vendor_id', $prefs->{'ps:owner'});
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
189 update_option('payswarm_financial_account', $prefs->{'com:destination'});
2d83d1a @dlongley More clean up and reorganization.
dlongley authored
190 update_option('payswarm_registered', 1);
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
191
192 // trigger resign of listings
193 payswarm_trigger_listing_resign();
987cf90 @dlongley Use settings API.
dlongley authored
194
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
195 // close popup and show admin page
196 $url = admin_url() . 'plugins.php?page=payswarm';
197 payswarm_close_register_popup($url);
198 }
199 catch(Exception $e) {
200 // close the popup and report an error
201 $url = admin_url() . 'plugins.php?page=payswarm&error=authority';
202 payswarm_close_register_popup($url);
203 }
204 exit(0);
205 }
d0eb25f @dlongley Show errors in parent registration window.
dlongley authored
206
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
207 /**
208 * A helper function that outputs JavaScript to close the registration
209 * popup.
210 *
211 * @package payswarm
212 * @since 1.0
213 *
214 * @param string $url the URL to load in the parent window.
215 */
216 function payswarm_close_register_popup($url) {
1bb26c0 @dlongley Fix bugs with registration.
dlongley authored
217 $script = PAYSWARM_PLUGIN_URL . 'payswarm.js';
218 ?>
ef29ba5 @dlongley Moved html output to allow cookies to be set.
dlongley authored
219 <html><body>
1bb26c0 @dlongley Fix bugs with registration.
dlongley authored
220 <script type="text/javascript" src="<?php echo $script; ?>"></script>
221 <script type="text/javascript">closePopup('<?php echo $url; ?>');</script>
ef29ba5 @dlongley Moved html output to allow cookies to be set.
dlongley authored
222 </body></html>
1bb26c0 @dlongley Fix bugs with registration.
dlongley authored
223 <?php
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
224 }
a2cbe2d @msporny Added saving of PaySwarm configuration.
msporny authored
225
7783a55 @msporny Added more database code, lots of documentation.
msporny authored
226 /**
227 * Adds a warning to the administration page.
228 *
229 * @package payswarm
230 * @since 1.0
231 *
232 * @param string $warning The warning to print to the administration page.
233 */
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
234 function payswarm_admin_warning($warning) {
235 ?>
236 <div id='payswarm-admin-warning' class='updated fade'>
1bb26c0 @dlongley Fix bugs with registration.
dlongley authored
237 <p>
238 <?php _e($warning); ?>
239 You still need to
240 <a href="plugins.php?page=payswarm">configure PaySwarm</a>.
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
241 </p>
242 </div>
243 <?php
244 }
a2cbe2d @msporny Added saving of PaySwarm configuration.
msporny authored
245
7783a55 @msporny Added more database code, lots of documentation.
msporny authored
246 /**
987cf90 @dlongley Use settings API.
dlongley authored
247 * Displays the PaySwarm registration page to the administrator.
cdd0749 @dlongley Fixes to wordpress article asset and listing data.
dlongley authored
248 *
7783a55 @msporny Added more database code, lots of documentation.
msporny authored
249 * @package payswarm
250 * @since 1.0
251 */
987cf90 @dlongley Use settings API.
dlongley authored
252 function payswarm_render_register_page() {
2d83d1a @dlongley More clean up and reorganization.
dlongley authored
253 $register_url = PAYSWARM_PLUGIN_URL . 'payswarm-register.php';
987cf90 @dlongley Use settings API.
dlongley authored
254 ?>
255 <div class="wrap">
256 <?php screen_icon('options-general'); ?>
df2a7e9 @dlongley Cookie fixes, add settings link to registration page.
dlongley authored
257 <h2>PaySwarm</h2>
258 <form action="<?php echo $register_url; ?>" method="post"
259 onsubmit="javascript:showAuthorityPopup(this);">
260 <?php settings_fields('payswarm_register'); ?>
261 <?php do_settings_sections('payswarm_register'); ?>
262 <p class="submit">
263 <input name="submit" type="submit" class="button-primary"
264 value="<?php _e('Register this site'); ?>" />
265 </p>
266 </form>
267 <p>To manage your PaySwarm options after registering go to the
268 <a href="options-general.php?page=payswarm">PaySwarm Options</a> page.
269 </p>
270 </div>
987cf90 @dlongley Use settings API.
dlongley authored
271 <?php
272
273 // output warnings
274 if(isset($_GET['error'])) {
275 $host = get_option('payswarm_authority_host');
276 $url = "https://$host/payswarm-v1-config";
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
277 if($_GET['error'] === 'config') {
987cf90 @dlongley Use settings API.
dlongley authored
278 payswarm_admin_warning(
279 'There was an error fetching the PaySwarm Authority ' .
280 'Configuration (' . htmlentities($url) . '). ' .
281 'This may have happened because the ' .
282 'PaySwarm Authority configuration URL specified was incorrect ' .
283 'or because the PaySwarm Authority you specified is not responding.');
284 }
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
285 else if($_GET['error'] === 'authority') {
987cf90 @dlongley Use settings API.
dlongley authored
286 payswarm_admin_warning(
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
287 'The PaySwarm Authority reported an error during registration. ' .
288 'Please try again.');
987cf90 @dlongley Use settings API.
dlongley authored
289 }
ef09804 @dlongley Update admin pages, register implementation, etc.
dlongley authored
290 }
a2cbe2d @msporny Added saving of PaySwarm configuration.
msporny authored
291 }
292
7783a55 @msporny Added more database code, lots of documentation.
msporny authored
293 /**
987cf90 @dlongley Use settings API.
dlongley authored
294 * Renders the description for the PaySwarm register section.
698e94e @dlongley Add use of license caching.
dlongley authored
295 *
987cf90 @dlongley Use settings API.
dlongley authored
296 * @package payswarm
297 * @since 1.0
298 */
299 function payswarm_render_register_section() {
300 ?>
301 <p>PaySwarm enables you to sell your articles, photos, and other content
302 directly to your website visitors without requiring them to create accounts
303 or fill in any of their credit card or banking details. You can charge as
304 little as a penny per article or up to hundreds of dollars for your content.
305 To use PaySwarm, you must first sign up with a
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
306 <a href="<?php echo PAYSWARM_AUTHORITY_URL; ?>">PaySwarm Authority</a>.
987cf90 @dlongley Use settings API.
dlongley authored
307 </p>
308 </p>After you have created an account on a
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
309 <a href="<?php echo PAYSWARM_AUTHORITY_URL; ?>">PaySwarm Authority</a>,
310 enter the website for the PaySwarm Authority below. For example:
311 <code><?php echo PAYSWARM_AUTHORITY_HOST; ?></code>.
987cf90 @dlongley Use settings API.
dlongley authored
312 </p>
313 <?php
314 }
315
316 /**
317 * Renders the PaySwarm Authority host field.
698e94e @dlongley Add use of license caching.
dlongley authored
318 *
987cf90 @dlongley Use settings API.
dlongley authored
319 * @package payswarm
320 * @since 1.0
698e94e @dlongley Add use of license caching.
dlongley authored
321 */
987cf90 @dlongley Use settings API.
dlongley authored
322 function payswarm_render_authority_host() {
323 $value = get_option('payswarm_authority_host', '');
324 ?>
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
325 <input id="payswarm_authority_host" type="text" size="32"
326 name="payswarm_authority_host"
987cf90 @dlongley Use settings API.
dlongley authored
327 value="<?php echo $value; ?>" />
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
328 <label for="payswarm_authority_host">eg: dev.payswarm.com</label>
987cf90 @dlongley Use settings API.
dlongley authored
329 <?php
330 }
698e94e @dlongley Add use of license caching.
dlongley authored
331
987cf90 @dlongley Use settings API.
dlongley authored
332 /**
333 * Renders the overwrite key pair field.
334 *
335 * @package payswarm
336 * @since 1.0
337 */
338 function payswarm_render_overwrite_key_pair() {
339 $value = get_option('payswarm_overwrite_key_pair', '');
340 ?>
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
341 <input id="payswarm_overwrite_key_pair" type="checkbox"
342 name="payswarm_overwrite_key_pair"
987cf90 @dlongley Use settings API.
dlongley authored
343 value="1" <?php checked($value); ?> />
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
344 <label for="payswarm_overwrite_key_pair">
345 Check to always create a new key pair before registering
346 (default: off)</label>
987cf90 @dlongley Use settings API.
dlongley authored
347 <?php
698e94e @dlongley Add use of license caching.
dlongley authored
348 }
349
350 /**
987cf90 @dlongley Use settings API.
dlongley authored
351 * Displays the PaySwarm options page to the administrator.
cdd0749 @dlongley Fixes to wordpress article asset and listing data.
dlongley authored
352 *
7783a55 @msporny Added more database code, lots of documentation.
msporny authored
353 * @package payswarm
354 * @since 1.0
355 */
987cf90 @dlongley Use settings API.
dlongley authored
356 function payswarm_render_options_page() {
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
357 // show registration page if not registered with an authority yet
358 if(!get_option('payswarm_registered', false)) {
359 payswarm_render_register_page();
360 }
361 else {
362 ?>
363 <div class="wrap">
364 <?php screen_icon('options-general'); ?>
365 <h2>PaySwarm</h2>
366 <form action="options.php" method="post">
367 <?php settings_fields('payswarm'); ?>
368 <?php do_settings_sections('payswarm'); ?>
369 <p class="submit">
370 <input name="submit" type="submit" class="button-primary"
371 value="<?php _e('Save Changes'); ?>" />
372 </p>
373 </form>
374 </div>
375 <?php
376 }
987cf90 @dlongley Use settings API.
dlongley authored
377 }
0655c62 @msporny Moved OAuth registration calls into a separate file.
msporny authored
378
987cf90 @dlongley Use settings API.
dlongley authored
379 /**
380 * Renders the description for the PaySwarm options section.
381 *
382 * @package payswarm
383 * @since 1.0
384 */
385 function payswarm_render_options_section() {
386 ?>
387 <p>This page allows you to configure the default settings used for content
388 your customers must pay for to access. The PaySwarm plugin allows you
389 specify entire posts or just parts of posts that require payment. Below
390 are default settings that only apply to content that you specify must be
391 paid for. You can use settings other than these defaults when editing
392 individual posts, but you may often want to reuse the same settings, so
393 these defaults save you time.</p>
394 <?php
395 }
0655c62 @msporny Moved OAuth registration calls into a separate file.
msporny authored
396
987cf90 @dlongley Use settings API.
dlongley authored
397 /**
398 * Renders the default price field.
399 *
400 * @package payswarm
401 * @since 1.0
402 *
403 * @param array $options the payswarm options.
404 */
405 function payswarm_render_default_price($options) {
406 ?>
407 <input type="text" size="8" name="payswarm_options[default_price]"
408 value="<?php echo $options['default_price']; ?>" /> USD
409 <p>This is the default price that will be used for any content
410 in a post that you specify must be paid for.</p>
411 <?php
412 }
a2cbe2d @msporny Added saving of PaySwarm configuration.
msporny authored
413
987cf90 @dlongley Use settings API.
dlongley authored
414 /**
415 * Renders the default license ID field.
416 *
417 * @package payswarm
418 * @since 1.0
419 *
420 * @param array $options the payswarm options.
421 */
422 function payswarm_render_default_license_id($options) {
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
423 $hash = $options['default_license_hash'];
424 if($hash === '') {
425 $hash = 'Save settings to compute';
426 }
987cf90 @dlongley Use settings API.
dlongley authored
427 ?>
428 <input type="text" size="64" name="payswarm_options[default_license_id]"
429 value="<?php echo $options['default_license_id']; ?>" />
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
430 <p>Hash: <?php echo $hash ?></p>
987cf90 @dlongley Use settings API.
dlongley authored
431 <p>This is the URL for the default license to use for any
432 content in a post that you specify must be paid for.</p>
433 <?php
434 }
0655c62 @msporny Moved OAuth registration calls into a separate file.
msporny authored
435
987cf90 @dlongley Use settings API.
dlongley authored
436 /**
437 * Renders the default authority rate field.
438 *
439 * @package payswarm
440 * @since 1.0
441 *
442 * @param array $options the payswarm options.
443 */
444 function payswarm_render_default_authority_rate($options) {
445 ?>
446 <input type="text" size="8" name="payswarm_options[default_authority_rate]"
447 value="<?php echo $options['default_authority_rate']; ?>" />
448 <p>This is the percentage of the price paid by your customers
449 for content that you permit a PaySwarm Authority to collect in
450 exchange for processing payments. If it is too low, a PaySwarm
451 Authority may elect to refuse your business.</p>
452 <?php
453 }
0655c62 @msporny Moved OAuth registration calls into a separate file.
msporny authored
454
987cf90 @dlongley Use settings API.
dlongley authored
455 /**
456 * Validates payswarm options input.
457 *
458 * @package payswarm
459 * @since 1.0
460 *
461 * @param array $input the submitted payswarm options.
462 *
463 * @return array the validated payswarm options.
464 */
465 function payswarm_validate_options($input) {
466 $options = payswarm_get_options();
467
468 // validate default price
469 if(payswarm_is_decimal($input['default_price']) and
470 floatval($input['default_price']) >= 0) {
471 $options['default_price'] = sprintf('%0.7f', $input['default_price']);
472 }
473 else {
474 add_settings_error(
475 'payswarm_options',
476 'payswarm_default_price_error',
477 __('The default price must be a number greater than or equal to 0 and
478 have the format: x.xx.'));
479 }
480
481 // validate default license
482 try {
483 $authority_host = get_option('payswarm_authority_host');
713eea4 @dlongley Bug fixes, hide meta fields, fix payswarm meta box.
dlongley authored
484 $license_id = $options['default_license_id'];
485 if(wp_kses_bad_protocol($license_id, array('http', 'https')) !==
486 $license_id) {
987cf90 @dlongley Use settings API.
dlongley authored
487 throw new Exception('Invalid license ID.');
488 }
489
490 // get license
713eea4 @dlongley Bug fixes, hide meta fields, fix payswarm meta box.
dlongley authored
491 $license = payswarm_authority_cache_license($authority_host, $license_id);
492 $options['default_license_id'] = $license_id;
987cf90 @dlongley Use settings API.
dlongley authored
493 $options['default_license_hash'] = payswarm_hash($license);
494 }
495 catch(Exception $e) {
496 add_settings_error(
497 'payswarm_options',
498 'payswarm_default_license_id_error',
499 __('The default license must be a valid URL that contains a ' .
500 'PaySwarm license.'));
501 }
502
503 // validate default authority rate
504 if(payswarm_is_decimal($input['default_authority_rate']) and
505 floatval($input['default_authority_rate']) >= 0 and
506 floatval($input['default_authority_rate']) <= 100) {
507 $options['default_authority_rate'] = sprintf(
508 '%0.7f', $input['default_authority_rate']);
509 }
510 else {
511 add_settings_error(
512 'payswarm_options',
513 'payswarm_default_authority_rate_error',
514 __('The default authority rate must be a number between 0 and 100.'));
515 }
516
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
517 // trigger listing resign
518 payswarm_trigger_listing_resign();
519
987cf90 @dlongley Use settings API.
dlongley authored
520 return $options;
521 }
a2cbe2d @msporny Added saving of PaySwarm configuration.
msporny authored
522
987cf90 @dlongley Use settings API.
dlongley authored
523 /**
524 * Returns true if the given input is of the given decimal format.
525 *
526 * @param string @input the input.
527 *
528 * @return true if the format is valid, false if not.
529 */
530 function payswarm_is_decimal($input, $format='%.0f') {
531 return sprintf($format, $input) === $input;
a2cbe2d @msporny Added saving of PaySwarm configuration.
msporny authored
532 }
987cf90 @dlongley Use settings API.
dlongley authored
533
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
534 /**
535 * Sets a flag that indicates that listings need to be resigned due to
536 * registration or options changes.
537 *
538 * @package payswarm
539 * @since 1.0
540 */
541 function payswarm_trigger_listing_resign() {
542 // set resign_if_before date
2d83d1a @dlongley More clean up and reorganization.
dlongley authored
543 $now = date_format(date_create(), DateTime::W3C);
1d5dee6 @dlongley Clean up, reorganization.
dlongley authored
544 update_option('payswarm_resign_if_before', $now);
545 }
546
987cf90 @dlongley Use settings API.
dlongley authored
547 /* end of file, omit ?> */
Something went wrong with that request. Please try again.