PluginProbe
FeedWordPress / 2022.0222
FeedWordPress v2022.0222
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
feedwordpress / feedwordpressadminpage.class.php

feedwordpressadminpage.class.php in FeedWordPress 2022.0222, at feedwordpressadminpage.class.php

774 lines 22.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * class FeedWordPressAdminPage
4 *
5 * Handles a lot of the interface-code related jots and tittles for putting together
6 * admin / settings pages within FeedWordPress, like Syndication > Posts & Links,
7 * Syndication > Feeds & Updates, etc., whether for setting global defaults, or for
8 * settings on particular feeds.
9 *
10 */
11
12 define( 'FWP_BOLD_PREFIX_REGEX', '/^[*][*] ([^*]+) [*][*] \s+ (\S.*)$/x');
13
14 class FeedWordPressAdminPage {
15 protected $context;
16 protected $updated = false;
17 protected $mesg = NULL;
18
19 var $link = NULL;
20 var $dispatch = NULL;
21 var $filename = NULL;
22 var $pagenames = array();
23
24 /**
25 * Construct the admin page object.
26 *
27 * @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings
28 */
29 public function __construct( $page = 'feedwordpressadmin', $link = NULL ) {
30 $this->link = $link;
31
32 // Set meta-box context name
33 $this->context = $page;
34 if ($this->for_feed_settings()) :
35 $this->context .= 'forfeed';
36 endif;
37 } /* FeedWordPressAdminPage constructor */
38
39 public function pageslug () {
40 $slug = preg_replace('/FeedWordPress(.*)Page/', '$1', get_class($this));
41 return strtolower($slug);
42 }
43
44 public function pagename ($context = NULL) {
45 if (is_null($context)) :
46 $context = 'default';
47 endif;
48
49 if (isset($this->pagenames[$context])) :
50 $name = $this->pagenames[$context];
51 elseif (isset($tis->pagenames['default'])) :
52 $name = $this->pagenames['default'];
53 else :
54 $name = $this->pageslug();
55 endif;
56 return __($name);
57 } /* FeedWordPressAdminPage::pagename () */
58
59 public function accept_POST () {
60 if ( $this->for_feed_settings() and $this->update_requested() ) :
61 $this->update_feed();
62 elseif ($this->save_requested()) : // User mashed Save Changes
63 $this->save_settings();
64 endif;
65 do_action($this->dispatch.'_post', null, $this);
66 }
67
68 public function update_feed () {
69 global $feedwordpress;
70
71 add_action('feedwordpress_check_feed', 'update_feeds_mention');
72 add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
73
74 $link = $this->link;
75
76 print '<div class="updated">';
77 print "<ul>";
78 $uri = $this->link->uri();
79 $displayUrl = $uri;
80
81 // check for effects of an effective-url filter
82 $effectiveUrl = $link->uri(array('fetch' => true));
83 if ($uri != $effectiveUrl) : $displayUrl .= ' | ' . $effectiveUrl; endif;
84
85 $delta = $feedwordpress->update($uri);
86 print "</ul>";
87
88 if (!is_null($delta)) :
89 echo "<p><strong>Update complete.</strong>".fwp_update_set_results_message($delta)."</p>";
90 echo "\n"; flush();
91 else :
92 $effectiveUrl = esc_html($effectiveUrl);
93 echo "<p><strong>Error:</strong> There was a problem updating <a href=\"$effectiveUrl\">$displayUrl</a></p>\n";
94 endif;
95 print "</div>\n";
96 remove_action('feedwordpress_check_feed', 'update_feeds_mention');
97 remove_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
98 }
99
100 public function save_settings () {
101 do_action($this->dispatch.'_save', null, $this);
102
103 if ($this->for_feed_settings()) :
104 // Save settings
105 $this->link->save_settings(/*reload=*/ true);
106 $this->updated = true;
107
108 // Reset, reload
109 $link_id = $this->link->id;
110 unset($this->link);
111 $this->link = new SyndicatedLink($link_id);
112 else :
113 $this->updated = true;
114 endif;
115 } /* FeedWordPressAdminPage::save_settings () */
116
117 public function for_feed_settings () { return (is_object($this->link) and method_exists($this->link, 'found') and $this->link->found()); }
118 public function for_default_settings () { return !$this->for_feed_settings(); }
119
120 public function setting ($names, $fallback_value = NULL, $params = array()) {
121 if (!is_array($params)) :
122 $params = array('default' => $params);
123 endif;
124 $params = shortcode_atts(array(
125 'default' => 'default',
126 'fallback' => true,
127 ), $params);
128
129 if (is_string($names)) :
130 $feed_name = $names;
131 $global_name = 'feedwordpress_'.preg_replace('![\s/]+!', '_', $names);
132 else :
133 $feed_name = $names['feed'];
134 $global_name = 'feedwordpress_'.$names['global'];
135 endif;
136
137 if ($this->for_feed_settings()) : // Check feed-specific setting first; fall back to global
138 if (!$params['fallback']) : $global_name = NULL; endif;
139 $ret = $this->link->setting($feed_name, $global_name, $fallback_value, $params['default']);
140 else : // Check global setting
141 $ret = get_option($global_name, $fallback_value);
142 endif;
143 return $ret;
144 }
145
146 public function update_setting ($names, $value, $default = 'default') {
147 if (is_string($names)) :
148 $feed_name = $names;
149 $global_name = 'feedwordpress_'.preg_replace('![\s/]+!', '_', $names);
150 else :
151 $feed_name = $names['feed'];
152 $global_name = 'feedwordpress_'.$names['global'];
153 endif;
154
155 if ($this->for_feed_settings()) : // Update feed-specific setting
156 $this->link->update_setting($feed_name, $value, $default);
157 else : // Update global setting
158 update_option($global_name, $value);
159 endif;
160 } /* FeedWordPressAdminPage::update_setting () */
161
162 public function save_requested () {
163 return ! ( is_null( MyPHP::post('save') ) && is_null( MyPHP::post('submit') ) );
164 }
165 public function update_requested () {
166 return ( strlen( MyPHP::post('update', '') ) > 0 );
167 }
168
169 public function submitted_link_id () {
170
171 // Presume global unless we get a specific link ID
172 $link_id = NULL;
173
174 $submit_buttons = array(
175 'save',
176 'submit',
177 'fix_mismatch',
178 'feedfinder',
179 );
180 foreach ($submit_buttons as $field) :
181 if ( ! is_null( MyPHP::request($field) ) ) :
182 $link_id = sanitize_text_field( MyPHP::request('save_link_id') );
183 endif;
184 endforeach;
185
186 if ( is_null($link_id) ) :
187 $link_id = sanitize_text_field( MyPHP::request( 'link_id' ) );
188 endif;
189
190 return $link_id;
191 } /* FeedWordPressAdminPage::submitted_link_id() */
192
193 public function submitted_link () {
194 $link_id = $this->submitted_link_id();
195 if (is_numeric($link_id) and $link_id) :
196 $link = new SyndicatedLink($link_id);
197 else :
198 $link = NULL;
199 endif;
200 return $link;
201 } /* FeedWordPressAdminPage::submitted_link () */
202
203 public function stamp_link_id ($field = null) {
204 if (is_null($field)) : $field = 'save_link_id'; endif;
205 ?>
206 <input type="hidden" name="<?php print esc_attr($field); ?>" value="<?php print ($this->for_feed_settings() ? $this->link->id : '*'); ?>" />
207 <?php
208 } /* FeedWordPressAdminPage::stamp_link_id () */
209
210 public function these_posts_phrase () {
211 if ($this->for_feed_settings()) :
212 $phrase = __('posts from this feed');
213 else :
214 $phrase = __('syndicated posts');
215 endif;
216 return $phrase;
217 } /* FeedWordPressAdminPage::these_posts_phrase() */
218
219 /**
220 * Provides a uniquely identifying name for the interface context for
221 * use with add_meta_box() and do_meta_boxes(),
222 *
223 * @return string the context name
224 *
225 * @see add_meta_box()
226 * @see do_meta_boxes()
227 */
228 public function meta_box_context () {
229 return $this->context;
230 } /* FeedWordPressAdminPage::meta_box_context () */
231
232 /**
233 * Outputs JavaScript to fix AJAX toggles settings.
234 *
235 * @uses FeedWordPressAdminPage::meta_box_context()
236 */
237 public function fix_toggles () {
238 FeedWordPressSettingsUI::fix_toggles_js($this->meta_box_context());
239 } /* FeedWordPressAdminPage::fix_toggles() */
240
241 public function ajax_interface_js () {
242 ?>
243 function contextual_appearance (item, appear, disappear, value, visibleStyle, checkbox) {
244 if (typeof(visibleStyle)=='undefined') visibleStyle = 'block';
245
246 var rollup=document.getElementById(item);
247 if (rollup) {
248 if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) {
249 jQuery('#'+disappear).hide();
250 jQuery('#'+appear).show(600);
251 } else {
252 jQuery('#'+appear).hide();
253 jQuery('#'+disappear).show(600);
254 }
255 }
256 }
257 <?php
258 } /* FeedWordPressAdminPage::ajax_interface_js () */
259
260 public function admin_page_href ($page, $params = array(), $link = NULL) {
261 global $fwp_path;
262
263 // Merge in the page's filename
264 $params = array_merge($params, array('page' => $fwp_path.'/'.$page));
265
266 // If there is a link ID provided, then merge that in too.
267 if (!is_null($link)) :
268 $link_id = NULL;
269 if (is_object($link)) :
270 if (method_exists($link, 'found')) :
271 // Is this a SyndicatedLink object?
272 if ($link->found()) :
273 $link_id = $link->link->link_id;
274 endif;
275 else :
276 // Is this a wp_links table record?
277 $link_id = $link->link_id;
278 endif;
279 else :
280 // Is this just a numeric ID?
281 $link_id = $link;
282 endif;
283
284 if (!is_null($link_id)) :
285 $params = array_merge($params, array('link_id' => $link_id));
286 endif;
287 endif;
288
289 return MyPHP::url(admin_url('admin.php'), $params);
290 } /* FeedWordPressAdminPage::admin_page_href () */
291
292 public function display_feed_settings_page_links ($params = array()) {
293 global $fwp_path;
294
295 $params = wp_parse_args($params, array(
296 'before' => '',
297 'between' => ' | ',
298 'after' => '',
299 'long' => false,
300 'subscription' => $this->link,
301 ));
302 $sub = $params['subscription'];
303
304 $links = array(
305 "Feed" => array('page' => 'feeds-page.php', 'long' => 'Feeds & Updates'),
306 "Posts" => array('page' => 'posts-page.php', 'long' => 'Posts & Links'),
307 "Authors" => array('page' => 'authors-page.php', 'long' => 'Authors'),
308 'Categories' => array('page' => 'categories-page.php', 'long' => 'Categories & Tags'),
309 );
310
311 $link_id = NULL;
312 if (is_object($sub)) :
313 if (method_exists($sub, 'found')) :
314 if ($sub->found()) :
315 $link_id = $sub->link->link_id;
316 endif;
317 else :
318 $link_id = $sub->link_id;
319 endif;
320 endif;
321
322 print $params['before']; $first = true;
323 foreach ($links as $label => $link) :
324 if (!$first) : print $params['between']; endif;
325
326 if (isset($link['url'])) : MyPHP::url($link['url'], array("link_id" => $link_id));
327 else : $url = $this->admin_page_href($link['page'], array(), $sub);
328 endif;
329 $url = esc_html($url);
330
331 if ($link['page']==basename($this->filename)) :
332 print "<strong>";
333 else :
334 print "<a href=\"${url}\">";
335 endif;
336
337 if ($params['long']) : print esc_html(__($link['long']));
338 else : print esc_html(__($label));
339 endif;
340
341 if ($link['page']==basename($this->filename)) :
342 print "</strong>";
343 else :
344 print "</a>";
345 endif;
346
347 $first = false;
348 endforeach;
349 print $params['after'];
350 } /* FeedWordPressAdminPage::display_feed_settings_page_links */
351
352 public function display_feed_select_dropdown() {
353 $links = FeedWordPress::syndicated_links();
354
355 ?>
356 <div id="fwpfs-container"><ul class="subsubsub">
357 <li><select name="link_id" class="fwpfs" style="max-width: 20.0em;">
358 <option value="*"<?php if ($this->for_default_settings()) : ?> selected="selected"<?php endif; ?>>- defaults for all feeds -</option>
359 <?php if ($links) : foreach ($links as $ddlink) : ?>
360 <option value="<?php print (int) $ddlink->link_id; ?>"<?php if (!is_null($this->link) and ($this->link->id==$ddlink->link_id)) : ?> selected="selected"<?php endif; ?>><?php print esc_html($ddlink->link_name); ?></option>
361 <?php endforeach; endif; ?>
362 </select>
363 <input id="fwpfs-button" class="button" type="submit" name="go" value="<?php _e('Go') ?> &raquo;" /></li>
364
365 <?php
366 $this->display_feed_settings_page_links(array(
367 'before' => '<li>',
368 'between' => "</li>\n<li>",
369 'after' => '</li>',
370 'subscription' => $this->link,
371 ));
372
373 if ($this->for_feed_settings()) :
374 ?>
375 <li><input class="button" type="submit" name="update" value="Update Now" /></li>
376 <?php
377 endif;
378 ?>
379 </ul>
380 </div>
381 <?php
382 } /* FeedWordPressAdminPage::display_feed_select_dropdown() */
383
384 public function display_sheet_header ($pagename = 'Syndication', $all = false) {
385 ?>
386 <div class="icon32"><img src="<?php print esc_attr( plugins_url( 'feedwordpress.png', __FILE__ ) ); ?>" alt="" /></div>
387 <h2><?php print esc_html(__($pagename.($all ? '' : ' Settings'))); ?><?php if ($this->for_feed_settings()) : ?>: <?php echo esc_html($this->link->name(/*from feed=*/ false)); ?><?php endif; ?></h2>
388 <?php
389 }
390
391 public function display_update_notice_if_updated ($pagename = 'Syndication', $mesg = NULL) {
392 if (!is_null($mesg)) :
393 $this->mesg = $mesg;
394 endif;
395
396 if ($this->updated) :
397 if ($this->updated === true) :
398 $this->mesg = $pagename . ' settings updated.';
399 else :
400 $this->mesg = $this->updated;
401 endif;
402 endif;
403
404 if (!is_null($this->mesg)) :
405 ?>
406 <div class="updated">
407 <p><?php print esc_html($this->mesg); ?></p>
408 </div>
409 <?php
410 endif;
411 } /* FeedWordPressAdminPage::display_update_notice_if_updated() */
412
413 public function display_settings_scope_message () {
414 if ($this->for_feed_settings()) :
415 ?>
416 <p>These settings only affect posts syndicated from
417 <strong><?php echo esc_html($this->link->link->link_name); ?></strong>.</p>
418 <?php
419 else :
420 ?>
421 <p>These settings affect posts syndicated from any feed unless they are overridden
422 by settings for that specific feed.</p>
423 <?php
424 endif;
425 } /* FeedWordPressAdminPage::display_settings_scope_message () */
426
427 /*static*/ function has_link () { return true; }
428
429 public function form_action ($filename = NULL) {
430 if (is_null($filename)) :
431 $filename = basename($this->filename);
432 endif;
433 return $this->admin_page_href($filename);
434 } /* FeedWordPressAdminPage::form_action () */
435
436 public function update_message () {
437 return $this->mesg;
438 }
439
440 public function display () {
441
442 if (FeedWordPress::needs_upgrade()) :
443 fwp_upgrade_page();
444 return;
445 endif;
446
447 FeedWordPressCompatibility::validate_http_request(/*action=*/ $this->dispatch, /*capability=*/ 'manage_links');
448
449 ////////////////////////////////////////////////
450 // Process POST request, if any ////////////////
451 ////////////////////////////////////////////////
452 if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
453 $this->accept_POST();
454 else :
455 $this->updated = false;
456 endif;
457
458 ////////////////////////////////////////////////
459 // Prepare settings page ///////////////////////
460 ////////////////////////////////////////////////
461
462 $this->display_update_notice_if_updated(
463 $this->pagename('settings-update'),
464 $this->update_message()
465 );
466
467 $this->open_sheet($this->pagename('open-sheet'));
468 ?>
469 <div id="post-body">
470 <?php
471 foreach ($this->boxes_by_methods as $method => $row) :
472 if (is_array($row)) :
473 $id = $row['id'];
474 $title = $row['title'];
475 else :
476 $id = 'feedwordpress_'.$method;
477 $title = $row;
478 endif;
479
480 add_meta_box(
481 /*id=*/ $id,
482 /*title=*/ $title,
483 /*callback=*/ array($this, $method),
484 /*page=*/ $this->meta_box_context(),
485 /*context=*/ $this->meta_box_context()
486 );
487 endforeach;
488 do_action($this->dispatch.'_meta_boxes', $this);
489 ?>
490 <div class="metabox-holder">
491 <?php
492 do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
493 ?>
494 </div> <!-- class="metabox-holder" -->
495 </div> <!-- id="post-body" -->
496 <?php $this->close_sheet(); ?>
497 <?php
498 }
499
500 public function open_sheet ($header) {
501 // Set up prepatory AJAX stuff
502 ?>
503 <script type="text/javascript">
504 <?php
505 $this->ajax_interface_js();
506 ?>
507 </script>
508
509 <?php
510 add_action(
511 FeedWordPressCompatibility::bottom_script_hook($this->filename),
512 /*callback=*/ array($this, 'fix_toggles'),
513 /*priority=*/ 10000
514 );
515 FeedWordPressSettingsUI::ajax_nonce_fields();
516
517 ?>
518 <div class="wrap feedwordpress-admin" id="feedwordpress-admin-<?php print esc_attr( $this->pageslug() ); ?>">
519 <?php
520 if (!is_null($header)) :
521 $this->display_sheet_header($header);
522 endif;
523
524 if ( !is_null( $this->dispatch ) ) :
525 ?>
526 <form action="<?php print esc_url( $this->form_action() ); ?>" method="post">
527 <div><?php
528 FeedWordPressCompatibility::stamp_nonce($this->dispatch);
529 $this->stamp_link_id();
530 ?></div>
531 <?php
532 endif;
533
534 if ($this->has_link()) :
535 $this->display_settings_scope_message();
536 endif;
537
538 ?><div class="tablenav"><?php
539 if (!is_null($this->dispatch)) :
540 ?><div class="alignright"><?php
541 $this->save_button();
542 ?></div><?php
543 endif;
544
545 if ($this->has_link()) :
546 $this->display_feed_select_dropdown();
547 endif;
548 ?>
549 </div>
550
551 <div id="poststuff">
552 <?php
553 } /* FeedWordPressAdminPage::open_sheet () */
554
555 public function close_sheet () {
556 ?>
557
558 </div> <!-- id="poststuff" -->
559 <?php
560 if (!is_null($this->dispatch)) :
561 $this->save_button();
562 print "</form>\n";
563 endif;
564 ?>
565 </div> <!-- class="wrap" -->
566
567 <?php
568 } /* FeedWordPressAdminPage::close_sheet () */
569
570 public function setting_radio_control ($localName, $globalName, $options, $params = array()) {
571 global $fwp_path;
572
573 $params = wp_parse_args(
574 $params,
575 array(
576 'filename' => basename($this->filename),
577 'site-wide-url' => null,
578 'setting-default' => null,
579 'global-setting-default' => null,
580 'offer-site-wide' => null,
581 )
582 );
583
584 $filename = $params['filename'];
585 $href = $params['site-wide-url'];
586 if ( is_null( $href ) ) :
587 $href = $this->admin_page_href( $filename );
588 endif;
589
590 $settingDefault = $params['setting-default'];
591 $globalSettingDefault = $params['global-setting-default'];
592 if ( is_null( $globalSettingDefault ) ) :
593 $globalSettingDefault = $settingDefault;
594 endif;
595
596 $globalSetting = get_option('feedwordpress_'.$globalName, $globalSettingDefault);
597 if ( $this->for_feed_settings() ) :
598 $setting = $this->link->setting($localName, NULL, $settingDefault);
599 else :
600 $setting = $globalSetting;
601 endif;
602
603 $offerSiteWide = $params['offer-site-wide'];
604 if ( is_null( $offerSiteWide ) ) :
605 $offerSiteWide = $this->for_feed_settings();
606 endif;
607
608 // This allows us to provide an alternative set of human-readable
609 // labels for each potential value. For use in Currently: line.
610 if (isset($params['labels'])) : $labels = $params['labels'];
611 elseif (is_callable($options)) : $labels = NULL;
612 else : $labels = $options;
613 endif;
614
615 if (isset($params['input-name'])) : $inputName = $params['input-name'];
616 else : $inputName = $globalName;
617 endif;
618
619 if (isset($params['default-input-id'])) : $defaultInputId = $params['default-input-id'];
620 else : $defaultInputId = NULL;
621 endif;
622
623 if (isset($params['default-input-id-no'])) : $defaultInputIdNo = $params['default-input-id-no'];
624 elseif (!is_null($defaultInputId)) : $defaultInputIdNo = $defaultInputId.'-no';
625 else : $defaultInputIdNo = NULL;
626 endif;
627
628 // This allows us to either include the site-default setting as
629 // one of the options within the radio box, or else as a simple
630 // yes/no toggle that controls whether or not to check another
631 // set of inputs.
632 if (isset($params['default-input-name'])) : $defaultInputName = $params['default-input-name'];
633 else : $defaultInputName = $inputName;
634 endif;
635
636 if ($defaultInputName != $inputName) :
637 $defaultInputValue = 'yes';
638 else :
639 $defaultInputValue = (
640 isset($params['default-input-value'])
641 ? $params['default-input-value']
642 : 'site-default'
643 );
644 endif;
645
646 $settingDefaulted = (is_null($setting) or ($settingDefault === $setting));
647
648 if (!is_callable($options)) :
649 $checked = array();
650 if ($settingDefaulted) :
651 $checked[$defaultInputValue] = ' checked="checked"';
652 endif;
653
654 foreach ($options as $value => $label) :
655 if ($setting == $value) :
656 $checked[$value] = ' checked="checked"';
657 else :
658 $checked[$value] = '';
659 endif;
660 endforeach;
661 endif;
662
663 $defaulted = array();
664 if ($defaultInputName != $inputName) :
665 $defaulted['yes'] = ($settingDefaulted ? ' checked="checked"' : '');
666 $defaulted['no'] = ($settingDefaulted ? '' : ' checked="checked"');
667 else :
668 $defaulted['yes'] = (isset($checked[$defaultInputValue]) ? $checked[$defaultInputValue] : '');
669 endif;
670
671 if (isset($params['defaulted'])) :
672 $defaulted['yes'] = ($params['defaulted'] ? ' checked="checked"' : '');
673 $defaulted['no'] = ($params['defaulted'] ? '' : ' checked="checked"');
674 endif;
675
676 if ($offerSiteWide) :
677 ?>
678 <table class="twofer">
679 <tbody>
680 <tr><td class="equals first inactive">
681 <ul class="options">
682 <li><label><input type="radio"
683 name="<?php print esc_attr( $defaultInputName ); ?>"
684 value="<?php print esc_attr( $defaultInputValue ); ?>"
685 <?php if (!is_null($defaultInputId)) : ?>id="<?php print esc_attr( $defaultInputId ); ?>" <?php endif; ?>
686 <?php fwp_checked_flag($defaulted, 'yes'); ?> />
687 Use the site-wide setting</label>
688 <span class="current-setting">Currently:
689 <strong><?php if (is_callable($labels)) :
690 print call_user_func($labels, $globalSetting, $defaulted, $params);
691 elseif (is_null($labels)) :
692 print $globalSetting;
693 else :
694 $label = $labels[ $globalSetting ];
695 if ( preg_match( FWP_BOLD_PREFIX_REGEX, $label, $ref ) ) :
696 $label = $ref[1] . ' ' . $ref[2];
697 endif;
698
699 print esc_html( $label );
700 endif; ?></strong> (<a href="<?php print esc_url( $href ); ?>">change</a>)</span></li>
701 </ul></td>
702
703 <td class="equals second inactive">
704 <?php if ($defaultInputName != $inputName) : ?>
705 <ul class="options">
706 <li><label><input type="radio"
707 name="<?php print esc_attr( $defaultInputName ); ?>"
708 value="no"
709 <?php if (!is_null($defaultInputIdNo)) : ?>id="<?php print esc_attr( $defaultInputIdNo ); ?>" <?php endif; ?>
710 <?php fwp_checked_flag($defaulted, 'no'); ?> />
711 <?php _e('Do something different with this feed.'); ?></label>
712 <?php endif;
713 endif;
714
715 // Let's spit out the controls here.
716 if (is_callable($options)) :
717 // Method call to print out options list
718 call_user_func($options, $setting, $defaulted, $params);
719 else :
720 ?>
721 <ul class="options">
722 <?php
723 foreach ($options as $value => $label) :
724 if ( preg_match( FWP_BOLD_PREFIX_REGEX, $label, $ref ) ) :
725 $prefix = $ref[1];
726 $label = $ref[2];
727 else :
728 $prefix = null;
729 endif;
730 ?>
731 <li><label><input type="radio" name="<?php print esc_attr( $inputName ); ?>"
732 value="<?php print esc_attr( $value ); ?>"
733 <?php print fwp_checked_flag($checked, $value); ?> />
734 <?php
735 if ( !is_null($prefix) ) :
736 printf( '<strong>%s</strong> ', esc_html( $prefix ) );
737 endif;
738 printf( '%s', esc_html( $label ) );
739 ?>
740 </label></li>
741 <?php endforeach; ?>
742 </ul> <!-- class="options" -->
743 <?php
744 endif;
745
746 if ($offerSiteWide) :
747 if ($defaultInputName != $inputName) :
748 // Close the <li> and <ul class="options"> we opened above
749 ?>
750 </li>
751 </ul> <!-- class="options" -->
752 <?php
753 endif;
754
755 // Close off the twofer table that we opened up above.
756 ?>
757 </td></tr>
758 </tbody>
759 </table>
760 <?php
761 endif;
762 } /* FeedWordPressAdminPage::setting_radio_control () */
763
764 public function save_button ($caption = NULL) {
765 if (is_null($caption)) : $caption = __('Save Changes'); endif;
766 ?>
767 <p class="submit">
768 <input class="button-primary" type="submit" name="save" value="<?php print esc_attr( $caption ); ?>" />
769 </p>
770 <?php
771 }
772 } /* class FeedWordPressAdminPage */
773
774