PluginProbe
FeedWordPress / 2022.0204
FeedWordPress v2022.0204
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
← All changes | admin-ui.php +388 -200 2009.06122022.0204 View file →
@@ -1,46 +1,72 @@
1 1 <?php
2 -function fwp_linkedit_single_submit ($status = NULL) {
3 - if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) :
4 -?>
5 -<div class="submitbox" id="submitlink">
6 -<div id="previewview"></div>
7 -<div class="inside"></div>
2 +/**
3 + * admin-ui.php: This is kind of a junk pile of utility functions mostly created to smooth
4 + * out interactions to make things show up, or behave correctly, within the WordPress admin
5 + * settings interface. Major chunks of this code that deal with making it easy for FWP,
6 + * add-on modules, etc. to create new settings panels have since been hived off into class
7 + * FeedWordPressAdminPage. Many of the functions that remain here were created to handle
8 + * compatibility across multiple, sometimes very old, versions of WordPress, many of which
9 + * are no longer supported anymore. It's likely that some of these functions will be
10 + * re-evaluated, re-organized, deprecated, or clipped out in the next few versions.
11 + * -cj 2017-10-27
12 + */
8 13
9 -<p class="submit">
10 -<input type="submit" name="submit" value="<?php _e('Save') ?>" />
11 -</p>
12 -</div>
13 -<?php
14 +$dir = dirname(__FILE__);
15 +require_once("${dir}/feedwordpressadminpage.class.php");
16 +require_once("${dir}/feedwordpresssettingsui.class.php");
17 +
18 +function fwp_form_class_attr( $className ) {
19 +
20 + if ( is_string($className) ) :
21 + if (strlen($className) > 0 ) :
22 + $sClassName = sanitize_html_class( $className );
23 + print sprintf( 'class="%s"', esc_attr( $sClassName ) );
24 + endif;
14 25 endif;
15 -}
26 +} /* fwp_form_class_attr() */
16 27
17 -function fwp_linkedit_periodic_submit ($caption = NULL) {
18 - if (!fwp_test_wp_version(FWP_SCHEMA_25)) :
19 - if (is_null($caption)) : $caption = __('Save Changes &raquo;'); endif;
20 -?>
21 -<p class="submit">
22 -<input type="submit" name="submit" value="<?php print $caption; ?>" />
23 -</p>
24 -<?php
28 +function fwp_selected_flag( /* mixed */ $arg = null, $key = null, $flag = "selected" ) {
29 +
30 + $bIsOn = false;
31 +
32 + $theArg = $arg;
33 + if (is_array($arg) and !is_null($key)) :
34 + if (array_key_exists($key, $arg)) :
35 + $theArg = $arg[$key];
36 + else :
37 + $theArg = false;
38 + endif;
25 39 endif;
26 -}
40 +
41 + if (is_string($theArg)) :
42 + $bIsOn = (strlen($theArg) > 0);
43 + else :
44 + $bIsOn = !!($theArg);
45 + endif;
46 +
47 + if ( $bIsOn ) :
48 + print sprintf( '%s="%s"', esc_attr($flag), esc_attr($flag) );
49 + endif;
50 +} /* fwp_selected_flag() */
27 51
28 -function fwp_linkedit_single_submit_closer ($caption = NULL) {
29 - if (fwp_test_wp_version(FWP_SCHEMA_27)) :
30 - if (is_null($caption)) : $caption = __('Save Changes'); endif;
31 -?>
32 -<p class="submit">
33 -<input class="button-primary" type="submit" name="submit" value="<?php print $caption; ?>" />
34 -</p>
35 -<?php
52 +function fwp_checked_flag( /* mixed */ $arg = null, $key = null ) {
53 + fwp_selected_flag( $arg, $key, "checked" );
54 +} /* fwp_checked_flag() */
55 +
56 +function fwp_update_set_results_message ($delta, $joiner = ';') {
57 + $mesg = array();
58 + if (isset($delta['new'])) : $mesg[] = ' '.$delta['new'].' new posts were syndicated'; endif;
59 + if (isset($delta['updated']) and ($delta['updated'] != 0)) : $mesg[] = ' '.$delta['updated'].' existing posts were updated'; endif;
60 + if (isset($delta['stored']) and ($delta['stored'] != 0)) : $mesg[] = ' '.$delta['stored'].' alternate versions of existing posts were stored for reference'; endif;
61 +
62 + if (!is_null($joiner)) :
63 + $mesg = implode($joiner, $mesg);
36 64 endif;
37 -}
65 + return $mesg;
66 +} /* function fwp_update_set_results_message () */
38 67
39 68 function fwp_authors_single_submit ($link = NULL) {
40 - global $wp_db_version;
41 -
42 - if (fwp_test_wp_version(FWP_SCHEMA_25)) :
43 69 ?>
44 70 <div class="submitbox" id="submitlink">
45 71 <div id="previewview">
46 72 </div>
@@ -51,106 +77,163 @@
51 77 <input type="submit" name="save" value="<?php _e('Save') ?>" />
52 78 </p>
53 79 </div>
54 80 <?php
81 +}
82 +
83 +function fwp_tags_box ($tags, $object, $params = array()) {
84 + $params = wp_parse_args($params, array( // Default values
85 + 'taxonomy' => 'post_tag',
86 + 'textarea_name' => NULL,
87 + 'textarea_id' => NULL,
88 + 'input_id' => NULL,
89 + 'input_name' => NULL,
90 + 'id' => NULL,
91 + 'box_title' => __('Post Tags'),
92 + ));
93 +
94 + if (!is_array($tags)) : $tags = array(); endif;
95 +
96 + $tax_name = $params['taxonomy'];
97 +
98 + $oTax = get_taxonomy($params['taxonomy']);
99 + $oTaxLabels = get_taxonomy_labels($oTax);
100 +
101 + $disabled = (!current_user_can($oTax->cap->assign_terms) ? 'disabled="disabled"' : '');
102 +
103 + $desc = "<p style=\"font-size:smaller;font-style:bold;margin:0\">Tag $object as...</p>";
104 +
105 + if (is_null($params['textarea_name'])) :
106 + $params['textarea_name'] = "tax_input[$tax_name]";
55 107 endif;
108 + if (is_null($params['textarea_id'])) :
109 + $params['textarea_id'] = "tax-input-${tax_name}";
110 + endif;
111 + if (is_null($params['input_id'])) :
112 + $params['input_id'] = "new-tag-${tax_name}";
113 + endif;
114 + if (is_null($params['input_name'])) :
115 + $params['input_name'] = "newtag[$tax_name]";
116 + endif;
117 +
118 + if (is_null($params['id'])) :
119 + $params['id'] = $tax_name;
120 + endif;
121 +
122 + print $desc;
123 + $helps = __('Separate tags with commas.');
124 + $box['title'] = __('Tags');
125 + ?>
126 +<div class="tagsdiv" id="<?php echo esc_attr( $params['id'] ); ?>">
127 + <div class="jaxtag">
128 + <div class="nojs-tags hide-if-js">
129 + <p><?php echo esc_html( $oTaxLabels->add_or_remove_items ); ?></p>
130 + <textarea name="<?php echo esc_attr( $params['textarea_name'] ); ?>" class="the-tags" id="<?php echo esc_attr( $params['textarea_id'] ); ?>"><?php echo esc_attr(implode(",", $tags)); ?></textarea></div>
131 +
132 + <?php if ( current_user_can($oTax->cap->assign_terms) ) :?>
133 + <div class="ajaxtag hide-if-no-js">
134 + <label class="screen-reader-text" for="<?php echo esc_attr( $params['input_id'] ); ?>"><?php echo esc_html( $params['box_title'] ); ?></label>
135 + <div class="taghint"><?php echo esc_html( $oTaxLabels->add_new_item ); ?></div>
136 + <p><input type="text" id="<?php print esc_attr( $params['input_id'] ); ?>" name="<?php print esc_attr( $params['input_name'] ); ?>" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
137 + <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" /></p>
138 + </div>
139 + <p class="howto"><?php echo esc_attr( $oTaxLabels->separate_items_with_commas ); ?></p>
140 + <?php endif; ?>
141 + </div>
142 +
143 + <div class="tagchecklist"></div>
144 +</div>
145 +<?php if ( current_user_can($oTax->cap->assign_terms) ) : ?>
146 +<p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo esc_attr( $tax_name ); ?>"><?php echo esc_html( $oTaxLabels->choose_from_most_used ); ?></a></p>
147 +<?php endif;
148 +
56 149 }
57 150
58 -function fwp_option_box_opener ($legend, $id, $class = "stuffbox") {
151 +function fwp_category_box ($checked, $object, $tags = array(), $params = array()) {
59 152 global $wp_db_version;
60 - if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
61 -?>
62 -<div id="<?php print $id; ?>" class="<?php print $class; ?>">
63 -<h3><?php print htmlspecialchars($legend); ?></h3>
64 -<div class="inside">
65 -<?php
66 - else :
67 -?>
68 -<fieldset class="options"><legend><?php print htmlspecialchars($legend); ?></legend>
69 -<?php
153 +
154 + if (is_string($params)) :
155 + $prefix = $params;
156 + $taxonomy = 'category';
157 + elseif (is_array($params)) :
158 + $prefix = (isset($params['prefix']) ? $params['prefix'] : '');
159 + $taxonomy = (isset($params['taxonomy']) ? $params['taxonomy'] : 'category');
70 160 endif;
71 -}
161 +
162 + $oTax = get_taxonomy($taxonomy);
163 + $oTaxLabels = get_taxonomy_labels($oTax);
72 164
73 -function fwp_option_box_closer () {
74 - global $wp_db_version;
75 - if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
76 -?>
77 - </div> <!-- class="inside" -->
78 - </div> <!-- class="stuffbox" -->
79 -<?php
165 + if (strlen($prefix) > 0) :
166 + $idPrefix = $prefix.'-';
167 + $idSuffix = "-".$prefix;
168 + $namePrefix = $prefix . '_';
80 169 else :
81 -?>
82 -</fieldset>
83 -<?php
170 + $idPrefix = 'feedwordpress-';
171 + $idSuffix = "-feedwordpress";
172 + $namePrefix = 'feedwordpress_';
84 173 endif;
85 -}
86 174
87 -function fwp_tags_box ($tags) {
88 - if (!is_array($tags)) : $tags = array(); endif;
175 + $boxDivId = sanitize_html_class( $idPrefix . 'taxonomy-' . $taxonomy );
176 + $tabsUlId = sanitize_html_class( $idPrefix . $taxonomy . '-tabs' );
177 + $allTabId = sanitize_html_class( $idPrefix . $taxonomy . '-all' );
178 + $chkLstId = sanitize_html_class( $idPrefix . $taxonomy . 'checklist' );
179 + $addTaxId = sanitize_html_class( $idPrefix . $taxonomy . '-adder' );
180 + $addTogId = sanitize_html_class( $idPrefix . $taxonomy . '-add-toggle' );
181 + $addCatId = sanitize_html_class( $idPrefix . $taxonomy . '-add' );
182 + $newTaxId = sanitize_html_class( $idPrefix . 'new' . $taxonomy );
183 + $taxIdAddSubmit = sanitize_html_class( $idPrefix . $taxonomy . '-add-sumbit' );
89 184 ?>
90 -<div id="tagsdiv" class="postbox">
91 - <h3><?php _e('Tags') ?></h3>
92 - <p style="font-size:smaller;font-style:bold;margin:0">Place <?php print $object; ?> under...</p>
93 - <div class="inside">
94 - <p id="jaxtag"><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo implode(",", $tags); ?>" /></p>
95 - <div id="tagchecklist"></div>
96 - </div>
185 +<div id="<?php print esc_attr( $boxDivId ); ?>" class="feedwordpress-category-div">
186 + <ul id="<?php print esc_attr( $tabsUlId ); ?>" class="category-tabs">
187 + <li class="ui-tabs-selected tabs"><a href="#<?php print esc_attr( $allTabId ); ?>" tabindex="3"><?php _e( 'All posts' ); ?></a>
188 + <p style="font-size:smaller;font-style:bold;margin:0">Give <?php print esc_html( $object ); ?> these <?php print esc_html( $oTaxLabels->name ); ?></p>
189 + </li>
190 + </ul>
191 +
192 +<div id="<?php print esc_attr( $allTabId); ?>" class="tabs-panel">
193 + <input type="hidden" value="0" name="tax_input[<?php print esc_attr( $taxonomy ); ?>][]" />
194 + <ul id="<?php print esc_attr($chkLstId); ?>" class="list:<?php print esc_attr( $taxonomy ); ?> categorychecklist form-no-clear">
195 + <?php fwp_category_checklist(null, false, $checked, $params) ?>
196 + </ul>
97 197 </div>
198 +
199 +<div id="<?php print esc_attr( $addTaxId ); ?>" class="<?php print esc_attr( $taxonomy ); ?>-adder wp-hidden-children">
200 + <h4><a id="<?php print esc_attr( $addTogId ); ?>" class="category-add-toggle" href="#<?php print esc_attr( $addCatId ); ?>" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
201 + <p id="<?php print esc_attr($addCatId); ?>" class="category-add wp-hidden-child">
98 202 <?php
99 -}
100 -
101 -function fwp_category_box ($checked, $object, $tags = array()) {
102 - global $wp_db_version;
103 -
104 - if (fwp_test_wp_version(FWP_SCHEMA_25)) : // WordPress 2.5.x
203 + $newcat = 'new' . $taxonomy;
105 204 ?>
106 -<div id="category-adder" class="wp-hidden-children">
107 - <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
108 - <p id="category-add" class="wp-hidden-child">
109 - <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" />
110 - <?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
111 - <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
112 - <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
113 - <span id="category-ajax-response"></span>
205 + <label class="screen-reader-text" for="<?php print esc_attr($newTaxId); ?>"><?php _e('Add New Category'); ?></label>
206 + <input
207 + id="<?php print esc_attr($newTaxId); ?>"
208 + class="<?php print esc_attr( $newcat ); ?> form-required form-input-tip"
209 + aria-required="true"
210 + tabindex="3"
211 + type="text" name="<?php print esc_attr( $newcat ); ?>"
212 + value="<?php _e( 'New category name' ); ?>"
213 + />
214 + <label class="screen-reader-text" for="<?php print esc_attr( $newTaxId ); ?>-parent"><?php _e('Parent Category:'); ?></label>
215 + <?php wp_dropdown_categories( array(
216 + 'taxonomy' => $taxonomy,
217 + 'hide_empty' => 0,
218 + 'id' => $newTaxId . '-parent',
219 + 'class' => $newcat . '-parent',
220 + 'name' => $newcat . '_parent',
221 + 'orderby' => 'name',
222 + 'hierarchical' => 1,
223 + 'show_option_none' => __('Parent category'),
224 + 'tab_index' => 3,
225 + ) ); ?>
226 + <input type="button" id="<?php print esc_attr( $taxIdAddSubmit ); ?>" class="add:<?php print esc_attr( $idPrefix . $taxonomy ); ?>checklist:<?php print esc_attr( $idPrefix . $taxonomy ); ?>-add add-categorychecklist-category-add button category-add-submit" value="<?php _e( 'Add' ); ?>" tabindex="3" />
227 + <?php /* wp_nonce_field currently doesn't let us set an id different from name, but we need a non-unique name and a unique id */ ?>
228 + <input type="hidden" id="_ajax_nonce<?php print esc_html($idSuffix); ?>" name="_ajax_nonce" value="<?php print wp_create_nonce('add-'.$taxonomy); ?>" />
229 + <input type="hidden" id="_ajax_nonce-add-<?php print esc_attr( $taxonomy . $idSuffix ); ?>" name="_ajax_nonce-add-<?php print esc_attr( $taxonomy ); ?>" value="<?php print wp_create_nonce('add-'.$taxonomy); ?>" />
230 + <span id="<?php print esc_attr( $idPrefix . $taxonomy ); ?>-ajax-response" class="<?php print esc_attr( $taxonomy ); ?>-ajax-response"></span>
114 231 </p>
115 232 </div>
116 233
117 -<ul id="category-tabs">
118 - <li class="ui-tabs-selected"><a href="#categories-all" tabindex="3"><?php _e( 'All posts' ); ?></a>
119 - <p style="font-size:smaller;font-style:bold;margin:0">Give <?php print $object; ?> these categories</p>
120 -</li>
121 -</ul>
122 -
123 -<div id="categories-all" class="ui-tabs-panel">
124 - <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
125 - <?php fwp_category_checklist(NULL, false, $checked) ?>
126 - </ul>
127 234 </div>
128 235 <?php
129 - elseif (fwp_test_wp_version(FWP_SCHEMA_20)) : // WordPress 2.x
130 -?>
131 - <div id="moremeta">
132 - <div id="grabit" class="dbx-group">
133 - <fieldset id="categorydiv" class="dbx-box">
134 - <h3 class="dbx-handle"><?php _e('Categories') ?></h3>
135 - <div class="dbx-content">
136 - <p style="font-size:smaller;font-style:bold;margin:0">Place <?php print $object; ?> under...</p>
137 - <p id="jaxcat"></p>
138 - <div id="categorychecklist"><?php fwp_category_checklist(NULL, false, $checked); ?></div>
139 - </div>
140 - </fieldset>
141 - </div>
142 - </div>
143 -<?php
144 - else : // WordPress 1.5
145 -?>
146 - <fieldset style="width: 60%;">
147 - <legend><?php _e('Categories') ?></legend>
148 - <p style="font-size:smaller;font-style:bold;margin:0">Place <?php print $object; ?> under...</p>
149 - <div style="height: 10em; overflow: scroll;"><?php fwp_category_checklist(NULL, false, $checked); ?></div>
150 - </fieldset>
151 -<?php
152 - endif;
153 236 }
154 237
155 238 function update_feeds_mention ($feed) {
156 239 echo "<li>Updating <cite>".$feed['link/name']."</cite> from &lt;<a href=\""
@@ -157,9 +240,18 @@
157 240 .$feed['link/uri']."\">".$feed['link/uri']."</a>&gt; ...";
158 241 flush();
159 242 }
160 243 function update_feeds_finish ($feed, $added, $dt) {
161 - echo " completed in $dt second".(($dt==1)?'':'s')."</li>\n";
244 + if (is_wp_error($added)) :
245 + $mesgs = $added->get_error_messages();
246 + foreach ($mesgs as $mesg) :
247 + echo "<br/><strong>Feed error:</strong> <code>$mesg</code>";
248 + endforeach;
249 + echo "</li>\n";
250 + else :
251 + echo " completed in $dt second".(($dt==1)?'':'s')."</li>\n";
252 + endif;
253 + flush();
162 254 }
163 255
164 256 function fwp_author_list () {
165 257 global $wpdb;
@@ -164,20 +256,13 @@
164 256 function fwp_author_list () {
165 257 global $wpdb;
166 258 $ret = array();
167 259
168 - // display_name introduced in WP 2.0
169 - if (fwp_test_wp_version(FWP_SCHEMA_20)) :
170 - $name_column = 'display_name';
171 - else :
172 - $name_column = 'user_nickname';
173 - endif;
174 -
175 - $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY {$name_column}");
260 + $users = get_users();
176 261 if (is_array($users)) :
177 262 foreach ($users as $user) :
178 263 $id = (int) $user->ID;
179 - $ret[$id] = $user->{$name_column};
264 + $ret[$id] = $user->display_name;
180 265 if (strlen(trim($ret[$id])) == 0) :
181 266 $ret[$id] = $user->user_login;
182 267 endif;
183 268 endforeach;
@@ -184,72 +269,8 @@
184 269 endif;
185 270 return $ret;
186 271 }
187 272
188 -class FeedWordPressSettingsUI {
189 - function instead_of_posts_box ($link_id = null) {
190 - fwp_option_box_opener('Syndicated Posts, Comments & Pings', 'syndicatedpostsdiv', 'postbox');
191 - if (!is_null($link_id)) :
192 - $from_this_feed = 'from this feed';
193 - $by_default = '';
194 - $id_param = "&amp;link_id=".$link_id;
195 - else :
196 - $from_this_feed = 'from syndicated feeds';
197 - $by_default = " by default";
198 - $id_param = "";
199 - endif;
200 -?>
201 -<p>Use the <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php<?php print $id_param; ?>"><?php _e('Posts'); ?></a>
202 -settings page to set up how new posts <?php print $from_this_feed; ?> will be published<?php $by_default; ?>, whether they will accept
203 -comments and pings, any custom fields that should be set on each post, etc.</p>
204 -<?php
205 - fwp_option_box_closer();
206 - } /* FeedWordPressSettingsUI::instead_of_posts_box () */
207 -
208 - function instead_of_authors_box ($link_id = null) {
209 - if (!is_null($link_id)) :
210 - $from_this_feed = 'from this feed';
211 - $by_default = '';
212 - $id_param = "&amp;link_id=".$link_id;
213 - else :
214 - $from_this_feed = 'from syndicated feeds';
215 - $by_default = " by default";
216 - $id_param = "";
217 - endif;
218 -
219 - fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox')
220 -?>
221 -<p>Use the <a
222 -href="admin.php?page=<?php print $GLOBALS['fwp_path']
223 -?>/authors-page.php<?php print $id_param; ?>"><?php _e('Authors');
224 -?></a> settings page to set up how new posts
225 -<?php print $from_this_feed; ?> will be assigned to
226 -authors.</p>
227 -<?php
228 - fwp_option_box_closer();
229 - } /* FeedWordPressSettingsUI::instead_of_authors_box () */
230 -
231 - function instead_of_categories_box ($link_id = null) {
232 - if (!is_null($link_id)) :
233 - $from_this_feed = 'from this feed';
234 - $by_default = '';
235 - $id_param = "&amp;link_id=".$link_id;
236 - else :
237 - $from_this_feed = 'from syndicated feeds';
238 - $by_default = " by default";
239 - $id_param = "";
240 - endif;
241 -
242 - fwp_option_box_opener(__('Categories & Tags'), 'categorydiv', 'postbox');
243 -?>
244 -<p>Use the <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php<?php print $id_param; ?>"><?php _e('Categories & Tags'); ?></a>
245 -settings page to set up how new posts <?php print $from_this_feed; ?> are assigned categories or tags<?php print $by_default; ?>.</p>
246 -<?php
247 - fwp_option_box_closer();
248 - } /* FeedWordPressSettingsUI::instead_of_categories_box () */
249 -
250 -} /* class FeedWordPressSettingsUI */
251 -
252 273 function fwp_insert_new_user ($newuser_name) {
253 274 global $wpdb;
254 275
255 276 $ret = null;
@@ -255,25 +276,192 @@
255 276 $ret = null;
256 277 if (strlen($newuser_name) > 0) :
257 278 $userdata = array();
258 279 $userdata['ID'] = NULL;
259 -
260 - $userdata['user_login'] = sanitize_user($newuser_name);
261 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
262 -
263 - $userdata['user_nicename'] = sanitize_title($newuser_name);
264 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
265 -
266 - $userdata['display_name'] = $wpdb->escape($newuser_name);
280 + $userdata['user_login'] = apply_filters('pre_user_login', sanitize_user($newuser_name));
281 + $userdata['user_nicename'] = apply_filters('pre_user_nicename', sanitize_title($newuser_name));
282 + $userdata['display_name'] = $newuser_name;
283 + $userdata['user_pass'] = substr(md5(uniqid(microtime())), 0, 6); // just something random to lock it up
267 284
285 + $blahUrl = get_bloginfo('url'); $url = parse_url($blahUrl);
286 + $userdata['user_email'] = substr(md5(uniqid(microtime())), 0, 6).'@'.$url['host'];
287 +
268 288 $newuser_id = wp_insert_user($userdata);
269 - if (is_numeric($newuser_id)) :
270 - $ret = $newuser_id;
271 - else :
272 - // TODO: Add some error detection and reporting
273 - endif;
289 + $ret = $newuser_id; // Either a numeric ID or a WP_Error object
274 290 else :
275 291 // TODO: Add some error reporting
276 292 endif;
277 293 return $ret;
278 294 } /* fwp_insert_new_user () */
295 +
296 +function fwp_syndication_manage_page_links_table_rows ($links, $page, $visible = 'Y') {
297 +
298 + $fwp_syndicated_sources_columns = array(__('Name'), __('Feed'), __('Updated'));
299 +
300 + $subscribed = ('Y' == strtoupper($visible));
301 + if ($subscribed or (count($links) > 0)) :
302 + ?>
303 + <table class="widefat<?php if (!$subscribed) : ?> unsubscribed<?php endif; ?>">
304 + <thead>
305 + <tr>
306 + <th class="check-column" scope="col"><input type="checkbox" /></th>
307 +<?php
308 + foreach ($fwp_syndicated_sources_columns as $col) :
309 + print "\t<th scope='col'>${col}</th>\n";
310 + endforeach;
311 + print "</tr>\n";
312 + print "</thead>\n";
313 + print "\n";
314 + print "<tbody>\n";
315 +
316 + $alt_row = true;
317 + if (count($links) > 0):
318 + foreach ($links as $link):
319 + $trClass = array();
320 +
321 + // Prep: Get last updated timestamp
322 + $sLink = new SyndicatedLink($link->link_id);
323 + if (!is_null($sLink->setting('update/last'))) :
324 + $lastUpdated = 'Last checked '. fwp_time_elapsed($sLink->setting('update/last'));
325 + else :
326 + $lastUpdated = __('None yet');
327 + endif;
328 +
329 + // Prep: get last error timestamp, if any
330 + $fileSizeLines = array();
331 + $feed_type = $sLink->get_feed_type();
332 + if (is_null($sLink->setting('update/error'))) :
333 + $errorsSince = '';
334 + if (!is_null($sLink->setting('link/item count'))) :
335 + $N = $sLink->setting('link/item count');
336 + $fileSizeLines[] = sprintf((($N==1) ? __('%d item') : __('%d items')), $N) . ", " . $feed_type;
337 + endif;
338 +
339 + if (!is_null($sLink->setting('link/filesize'))) :
340 + $fileSizeLines[] = size_format($sLink->setting('link/filesize')). ' total';
341 + endif;
342 + else :
343 + $trClass[] = 'feed-error';
344 +
345 + $theError = unserialize($sLink->setting('update/error'));
346 +
347 + $errorsSince = "<div class=\"returning-errors\">"
348 + ."<p><strong>Returning errors</strong> since "
349 + .fwp_time_elapsed($theError['since'])
350 + ."</p>"
351 + ."<p>Most recent ("
352 + .fwp_time_elapsed($theError['ts'])
353 + ."):<br/><code>"
354 + .implode("</code><br/><code>", $theError['object']->get_error_messages())
355 + ."</code></p>"
356 + ."</div>\n";
357 + endif;
358 +
359 + $nextUpdate = "<div style='max-width: 30.0em; font-size: 0.9em;'><div style='font-style:italic;'>";
360 +
361 + $ttl = $sLink->setting('update/ttl');
362 + if (is_numeric($ttl)) :
363 + $next = $sLink->setting('update/last') + $sLink->setting('update/fudge') + ((int) $ttl * 60);
364 + if ('automatically'==$sLink->setting('update/timed')) :
365 + if ($next < time()) :
366 + $nextUpdate .= 'Ready and waiting to be updated since ';
367 + else :
368 + $nextUpdate .= 'Scheduled for next update ';
369 + endif;
370 + $nextUpdate .= fwp_time_elapsed($next);
371 + if (FEEDWORDPRESS_DEBUG) : $nextUpdate .= " [".(($next-time())/60)." minutes]"; endif;
372 + else :
373 + $lastUpdated .= " &middot; Next ";
374 + if ($next < time()) :
375 + $lastUpdated .= 'ASAP';
376 + elseif ($next - time() < 60) :
377 + $lastUpdated .= fwp_time_elapsed($next);
378 + elseif ($next - time() < 60*60*24) :
379 + $lastUpdated .= gmdate('g:ia', $next + (get_option('gmt_offset') * 3600));
380 + else :
381 + $lastUpdated .= gmdate('F j', $next + (get_option('gmt_offset') * 3600));
382 + endif;
383 +
384 + $nextUpdate .= "Scheduled to be checked for updates every ".$ttl." minute".(($ttl!=1)?"s":"")."</div><div style='size:0.9em; margin-top: 0.5em'> This update schedule was requested by the feed provider";
385 + if ($sLink->setting('update/xml')) :
386 + $nextUpdate .= " using a standard <code style=\"font-size: inherit; padding: 0; background: transparent\">&lt;".$sLink->setting('update/xml')."&gt;</code> element";
387 + endif;
388 + $nextUpdate .= ".";
389 + endif;
390 + else:
391 + $nextUpdate .= "Scheduled for update as soon as possible";
392 + endif;
393 + $nextUpdate .= "</div></div>";
394 +
395 + $fileSize = '';
396 + if (count($fileSizeLines) > 0) :
397 + $fileSize = '<div>'.implode(" / ", $fileSizeLines)."</div>";
398 + endif;
399 +
400 + unset($sLink);
401 +
402 + $alt_row = !$alt_row;
403 +
404 + if ($alt_row) :
405 + $trClass[] = 'alternate';
406 + endif;
407 + ?>
408 + <tr<?php echo ((count($trClass) > 0) ? ' class="'.implode(" ", $trClass).'"':''); ?>>
409 + <th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo esc_attr( $link->link_id ); ?>" /></th>
410 + <?php
411 + $caption = (
412 + (strlen($link->link_rss) > 0)
413 + ? __('Switch Feed')
414 + : $caption=__('Find Feed')
415 + );
416 + ?>
417 + <td>
418 + <strong><a href="<?php print esc_url( $page->admin_page_href('feeds-page.php', array(), $link) ); ?>"><?php print esc_html($link->link_name); ?></a></strong>
419 + <div class="row-actions"><?php if ($subscribed) :
420 + $page->display_feed_settings_page_links(array(
421 + 'before' => '<div><strong>Settings &gt;</strong> ',
422 + 'after' => '</div>',
423 + 'subscription' => $link,
424 + ));
425 + endif; ?>
426 +
427 + <div><strong>Actions &gt;</strong>
428 + <?php if ($subscribed) : ?>
429 + <a href="<?php print esc_url( $page->admin_page_href('syndication.php', array('action' => 'feedfinder'), $link) ); ?>"><?php echo esc_html( $caption ); ?></a>
430 + <?php else : ?>
431 + <a href="<?php print esc_url( $page->admin_page_href('syndication.php', array('action' => FWP_RESUB_CHECKED), $link) ); ?>"><?php _e('Re-subscribe'); ?></a>
432 + <?php endif; ?>
433 + | <a href="<?php print esc_url( $page->admin_page_href( 'syndication.php', array('action' => 'Unsubscribe'), $link ) ); ?>"><?php _e( ( $subscribed ? 'Unsubscribe' : 'Delete permanently' ) ); ?></a>
434 + | <a href="<?php print esc_url( $link->link_url ); ?>"><?php _e('View')?></a></div>
435 + </div>
436 + </td>
437 + <?php if (strlen($link->link_rss) > 0): ?>
438 + <td><div><a href="<?php echo esc_html($link->link_rss); ?>"><?php echo esc_html(feedwordpress_display_url($link->link_rss, 32)); ?></a></div></td>
439 + <?php else: ?>
440 + <td class="feed-missing"><p><strong>no feed assigned</strong></p></td>
441 + <?php endif; ?>
442 +
443 + <td><div style="float: right; padding-left: 10px">
444 + <input type="submit" class="button" name="update_uri[<?php print esc_html($link->link_rss); ?>]" value="<?php _e('Update Now'); ?>" />
445 + </div>
446 + <?php
447 + print $lastUpdated;
448 + print $fileSize;
449 + print $errorsSince;
450 + print $nextUpdate;
451 + ?>
452 + </td>
453 + </tr>
454 + <?php
455 + endforeach;
456 + else :
457 +?>
458 +<tr><td colspan="4"><p>There are no websites currently listed for syndication.</p></td></tr>
459 +<?php
460 + endif;
461 +?>
462 +</tbody>
463 +</table>
464 + <?php
465 + endif;
466 +} /* function fwp_syndication_manage_page_links_table_rows () */
279 467