| 1 |
<?php |
| 2 |
require_once(dirname(__FILE__) . '/admin-ui.php'); |
| 3 |
|
| 4 |
function fwp_syndication_options_page () { |
| 5 |
global $wpdb, $wp_db_version, $fwp_path; |
| 6 |
|
| 7 |
if (FeedWordPress::needs_upgrade()) : |
| 8 |
fwp_upgrade_page(); |
| 9 |
return; |
| 10 |
endif; |
| 11 |
|
| 12 |
// If this is a POST, validate source and user credentials |
| 13 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_options', /*capability=*/ 'manage_options'); |
| 14 |
|
| 15 |
if (isset($_POST['create_index'])) : |
| 16 |
FeedWordPress::create_guid_index(); |
| 17 |
?> |
| 18 |
<div class="updated"> |
| 19 |
<p><?php _e('Index created on database table.')?></p> |
| 20 |
</div> |
| 21 |
<?php |
| 22 |
endif; |
| 23 |
|
| 24 |
if (isset($_POST['submit']) or isset($_POST['create_index'])) : |
| 25 |
update_option('feedwordpress_cat_id', $_REQUEST['syndication_category']); |
| 26 |
update_option('feedwordpress_update_logging', $_REQUEST['update_logging']); |
| 27 |
update_option('feedwordpress_debug', $_POST['feedwordpress_debug']); |
| 28 |
update_option('feedwordpress_automatic_updates', ($_POST['automatic_updates']=='yes')); |
| 29 |
update_option('feedwordpress_update_time_limit', ($_POST['update_time_limit']=='yes')?(int) $_POST['time_limit_seconds']:0); |
| 30 |
|
| 31 |
$freshness_interval = (isset($_POST['freshness_interval']) ? (int) $_POST['freshness_interval'] : 10); |
| 32 |
update_option('feedworidpress_freshness', $freshness_interval*60); |
| 33 |
|
| 34 |
if (isset($_REQUEST['hardcode_name']) and ($_REQUEST['hardcode_name'] == 'no')) : |
| 35 |
update_option('feedwordpress_hardcode_name', 'no'); |
| 36 |
else : |
| 37 |
update_option('feedwordpress_hardcode_name', 'yes'); |
| 38 |
endif; |
| 39 |
|
| 40 |
if (isset($_REQUEST['hardcode_description']) and ($_REQUEST['hardcode_description'] == 'no')) : |
| 41 |
update_option('feedwordpress_hardcode_description', 'no'); |
| 42 |
else : |
| 43 |
update_option('feedwordpress_hardcode_description', 'yes'); |
| 44 |
endif; |
| 45 |
|
| 46 |
if (isset($_REQUEST['hardcode_url']) and ($_REQUEST['hardcode_url'] == 'no')) : |
| 47 |
update_option('feedwordpress_hardcode_url', 'no'); |
| 48 |
else : |
| 49 |
update_option('feedwordpress_hardcode_url', 'yes'); |
| 50 |
endif; |
| 51 |
?> |
| 52 |
<div class="updated"> |
| 53 |
<p><?php _e('Options saved.')?></p> |
| 54 |
</div> |
| 55 |
<?php |
| 56 |
endif; |
| 57 |
|
| 58 |
$cat_id = FeedWordPress::link_category_id(); |
| 59 |
$update_logging = get_option('feedwordpress_update_logging'); |
| 60 |
$feedwordpress_debug = (get_option('feedwordpress_debug')=='yes'); |
| 61 |
|
| 62 |
$update_time_limit = (int) get_option('feedwordpress_update_time_limit'); |
| 63 |
$automatic_updates = get_option('feedwordpress_automatic_updates'); |
| 64 |
|
| 65 |
$freshness_interval = get_option('feedwordpress_freshness'); |
| 66 |
if (false === $freshness_interval) : |
| 67 |
$freshness_interval = FEEDWORDPRESS_FRESHNESS_INTERVAL; |
| 68 |
endif; |
| 69 |
$freshness_interval = $freshness_interval / 60; // convert to minutes |
| 70 |
|
| 71 |
$hardcode_name = get_option('feedwordpress_hardcode_name'); |
| 72 |
$hardcode_description = get_option('feedwordpress_hardcode_description'); |
| 73 |
$hardcode_url = get_option('feedwordpress_hardcode_url'); |
| 74 |
|
| 75 |
if (isset($wp_db_version) and $wp_db_version >= 4772) : |
| 76 |
$results = get_categories(array( |
| 77 |
"type" => 'link', |
| 78 |
"hide_empty" => false, |
| 79 |
)); |
| 80 |
|
| 81 |
// Guarantee that the Contributors category will be in the drop-down chooser, even if it is empty. |
| 82 |
$found_link_category_id = false; |
| 83 |
foreach ($results as $row) : |
| 84 |
if ($row->cat_id == $cat_id) : $found_link_category_id = true; endif; |
| 85 |
endforeach; |
| 86 |
|
| 87 |
if (!$found_link_category_id) : $results[] = get_category($cat_id); endif; |
| 88 |
else : |
| 89 |
$results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id"); |
| 90 |
endif; |
| 91 |
|
| 92 |
$cats = array_map('trim', |
| 93 |
preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_cats')) |
| 94 |
); |
| 95 |
$dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL); |
| 96 |
|
| 97 |
$tags = array_map('trim', |
| 98 |
preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_tags')) |
| 99 |
); |
| 100 |
|
| 101 |
if (fwp_test_wp_version(FWP_SCHEMA_27)) : |
| 102 |
$icon = '<div class="icon32"><img src="'.htmlspecialchars(WP_PLUGIN_URL.'/'.$fwp_path.'/feedwordpress.png').'" alt="" /></div>'; |
| 103 |
else : |
| 104 |
$icon = ''; |
| 105 |
endif; |
| 106 |
|
| 107 |
if (fwp_test_wp_version(FWP_SCHEMA_26)) : |
| 108 |
$options = __('Settings'); |
| 109 |
else : |
| 110 |
$options = __('Options'); |
| 111 |
endif; |
| 112 |
?> |
| 113 |
<script type="text/javascript"> |
| 114 |
function contextual_appearance (item, appear, disappear, value, checkbox) { |
| 115 |
var rollup=document.getElementById(item); |
| 116 |
var newuser=document.getElementById(appear); |
| 117 |
var sitewide=document.getElementById(disappear); |
| 118 |
if (rollup) { |
| 119 |
if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) { |
| 120 |
if (newuser) newuser.style.display='block'; |
| 121 |
if (sitewide) sitewide.style.display='none'; |
| 122 |
} else { |
| 123 |
if (newuser) newuser.style.display='none'; |
| 124 |
if (sitewide) sitewide.style.display='block'; |
| 125 |
} |
| 126 |
} |
| 127 |
} |
| 128 |
</script> |
| 129 |
|
| 130 |
<div class="wrap"> |
| 131 |
<?php print $icon; ?> |
| 132 |
<h2>Syndication <?php print $options; ?></h2> |
| 133 |
<div id="poststuff"> |
| 134 |
<form action="" method="post"> |
| 135 |
<?php |
| 136 |
FeedWordPressCompatibility::stamp_nonce('feedwordpress_options'); |
| 137 |
fwp_linkedit_single_submit(); |
| 138 |
?> |
| 139 |
<div id="post-body"> |
| 140 |
<?php fwp_option_box_opener('Syndicated Feeds', 'syndicatedfeedsdiv'); ?> |
| 141 |
<table class="editform" width="100%" cellspacing="2" cellpadding="5"> |
| 142 |
<tr> |
| 143 |
<th width="33%" scope="row">Syndicated Link category:</th> |
| 144 |
<td width="67%"><?php |
| 145 |
echo "\n<select name=\"syndication_category\" size=\"1\">"; |
| 146 |
foreach ($results as $row) : |
| 147 |
if (!isset($row->cat_id)) : $row->cat_id = $row->cat_ID; endif; |
| 148 |
|
| 149 |
echo "\n\t<option value=\"$row->cat_id\""; |
| 150 |
if ($row->cat_id == $cat_id) : |
| 151 |
echo " selected='selected'"; |
| 152 |
endif; |
| 153 |
echo ">$row->cat_id: ".wp_specialchars($row->cat_name); |
| 154 |
if ('Y' == $row->auto_toggle) : |
| 155 |
echo ' (auto toggle)'; |
| 156 |
endif; |
| 157 |
echo "</option>\n"; |
| 158 |
endforeach; |
| 159 |
echo "\n</select>\n"; |
| 160 |
?></td> |
| 161 |
</tr> |
| 162 |
|
| 163 |
<tr style="vertical-align: top"> |
| 164 |
<th width="33%" scope="row">Check for updates:</th> |
| 165 |
<td width="67%"><select name="automatic_updates" size="1"> |
| 166 |
<option value="yes"<?php echo ($automatic_updates)?' selected="selected"':''; ?>>automatically</option> |
| 167 |
<option value="no"<?php echo (!$automatic_updates)?' selected="selected"':''; ?>>only when I request</option> |
| 168 |
</select> |
| 169 |
</td> |
| 170 |
</tr> |
| 171 |
|
| 172 |
<tr style="vertical-align: top"> |
| 173 |
<th width="33%" scope="row"><?php print __('Time limit on updates'); ?>:</th> |
| 174 |
<td width="67%"><select id="time-limit" name="update_time_limit" size="1" onchange="contextual_appearance('time-limit', 'time-limit-box', null, 'yes');"> |
| 175 |
<option value="no"<?php echo ($update_time_limit>0)?'':' selected="selected"'; ?>>no time limit on updates</option> |
| 176 |
<option value="yes"<?php echo ($update_time_limit>0)?' selected="selected"':''; ?>>limit updates to no more than...</option> |
| 177 |
</select> |
| 178 |
<span id="time-limit-box"><label><input type="text" name="time_limit_seconds" value="<?php print $update_time_limit; ?>" size="5" /> seconds</label></span> |
| 179 |
</tr> |
| 180 |
|
| 181 |
<script type="text/javascript"> |
| 182 |
contextual_appearance('time-limit', 'time-limit-box', null, 'yes'); |
| 183 |
</script> |
| 184 |
|
| 185 |
<tr><th width="33%" scope="row" style="vertical-align:top">Feed information:</th> |
| 186 |
<td width="67%"><ul style="margin:0;padding:0;list-style:none"> |
| 187 |
<li><input type="checkbox" name="hardcode_name" value="no"<?php echo (($hardcode_name=='yes')?'':' checked="checked"');?>/> Update the contributor title when the feed title changes</li> |
| 188 |
<li><input type="checkbox" name="hardcode_description" value="no"<?php echo (($hardcode_description=='yes')?'':' checked="checked"');?>/> Update when contributor description if the feed tagline changes</li> |
| 189 |
<li><input type="checkbox" name="hardcode_url" value="no"<?php echo (($hardcode_url=='yes')?'':' checked="checked"');?>/> Update the contributor homepage when the feed link changes</li> |
| 190 |
</ul></td></tr> |
| 191 |
</table> |
| 192 |
<?php fwp_linkedit_periodic_submit(); ?> |
| 193 |
<?php fwp_option_box_closer(); ?> |
| 194 |
|
| 195 |
<?php |
| 196 |
FeedWordPressSettingsUI::instead_of_posts_box(); |
| 197 |
FeedWordPressSettingsUI::instead_of_authors_box(); |
| 198 |
FeedWordPressSettingsUI::instead_of_categories_box(); |
| 199 |
|
| 200 |
fwp_option_box_opener('Back End', 'backenddiv', 'postbox'); |
| 201 |
?> |
| 202 |
<table class="editform" width="100%" cellspacing="2" cellpadding="5"> |
| 203 |
<tr style="vertical-align: top"> |
| 204 |
<th width="33%" scope="row">Update notices:</th> |
| 205 |
<td width="67%"><select name="update_logging" size="1"> |
| 206 |
<option value="yes"<?php echo (($update_logging=='yes')?' selected="selected"':''); ?>>write to PHP logs</option> |
| 207 |
<option value="no"<?php echo (($update_logging!='yes')?' selected="selected"':''); ?>>don't write to PHP logs</option> |
| 208 |
</select></td> |
| 209 |
</tr> |
| 210 |
<tr style="vertical-align: top"> |
| 211 |
<th width="33%" scope="row">Debugging mode:</th> |
| 212 |
<td width="67%"><select name="feedwordpress_debug" size="1"> |
| 213 |
<option value="yes"<?php echo ($feedwordpress_debug ? ' selected="selected"' : ''); ?>>on</option> |
| 214 |
<option value="no"<?php echo ($feedwordpress_debug ? '' : ' selected="selected"'); ?>>off</option> |
| 215 |
</select> |
| 216 |
<p>When debugging mode is <strong>ON</strong>, FeedWordPress displays many diagnostic error messages, |
| 217 |
warnings, and notices that are ordinarily suppressed, and turns off all caching of feeds. Use with |
| 218 |
caution: this setting is absolutely inappropriate for a production server.</p> |
| 219 |
</td> |
| 220 |
</tr> |
| 221 |
|
| 222 |
<tr style="vertical-align: top"> |
| 223 |
<th width="33%" scope="row">Guid index:</th> |
| 224 |
<td width="67%"><input class="button" type="submit" name="create_index" value="Create index on guid column in posts database table" /> |
| 225 |
<p>Creating this index may significantly improve performance on some large |
| 226 |
FeedWordPress installations.</p></td> |
| 227 |
</tr> |
| 228 |
</table> |
| 229 |
<?php |
| 230 |
fwp_option_box_closer(); |
| 231 |
fwp_linkedit_periodic_submit(); |
| 232 |
fwp_linkedit_single_submit_closer(); |
| 233 |
?> |
| 234 |
</div> |
| 235 |
</form> |
| 236 |
|
| 237 |
</div> <!-- id="poststuff" --> |
| 238 |
</div> <!-- class="wrap" --> |
| 239 |
<?php |
| 240 |
} |
| 241 |
|
| 242 |
fwp_syndication_options_page(); |
| 243 |
|
| 244 |
|