PageRenderTime 27ms CodeModel.GetById 37ms RepoModel.GetById 1ms app.codeStats 0ms

/wordpress/plugins/post-plugin-library/admin_common_functions.php

https://github.com/prabhu/desistartups
PHP | 724 lines | 695 code | 12 blank | 17 comment | 21 complexity | b69fe54d1b0317a415af5228277858f1 MD5 | raw file
  1. <?php
  2. /*
  3. Library for the Recent Posts, Random Posts, Recent Comments, and Similar Posts plugins
  4. -- provides the admin routines which the plugins share
  5. */
  6. define('ACF_LIBRARY', true);
  7. function ppl_options_from_post($options, $args) {
  8. foreach ($args as $arg) {
  9. switch ($arg) {
  10. case 'limit':
  11. case 'skip':
  12. $options[$arg] = ppl_check_cardinal($_POST[$arg]);
  13. break;
  14. case 'excluded_cats':
  15. case 'included_cats':
  16. if (isset($_POST[$arg])) {
  17. // get the subcategories too
  18. if (function_exists('get_term_children')) {
  19. $catarray = $_POST[$arg];
  20. foreach ($catarray as $cat) {
  21. $catarray = array_merge($catarray, get_term_children($cat, 'category'));
  22. }
  23. $_POST[$arg] = array_unique($catarray);
  24. }
  25. $options[$arg] = implode(',', $_POST[$arg]);
  26. } else {
  27. $options[$arg] = '';
  28. }
  29. break;
  30. case 'excluded_authors':
  31. case 'included_authors':
  32. if (isset($_POST[$arg])) {
  33. $options[$arg] = implode(',', $_POST[$arg]);
  34. } else {
  35. $options[$arg] = '';
  36. }
  37. break;
  38. case 'excluded_posts':
  39. case 'included_posts':
  40. $check = explode(',', rtrim($_POST[$arg]));
  41. $ids = array();
  42. foreach ($check as $id) {
  43. $id = ppl_check_cardinal($id);
  44. if ($id !== 0) $ids[] = $id;
  45. }
  46. $options[$arg] = implode(',', array_unique($ids));
  47. break;
  48. case 'stripcodes':
  49. $st = explode("\n", trim($_POST['starttags']));
  50. $se = explode("\n", trim($_POST['endtags']));
  51. if (count($st) != count($se)) {
  52. $options['stripcodes'] = array(array());
  53. } else {
  54. $num = count($st);
  55. for ($i = 0; $i < $num; $i++) {
  56. $options['stripcodes'][$i]['start'] = $st[$i];
  57. $options['stripcodes'][$i]['end'] = $se[$i];
  58. }
  59. }
  60. break;
  61. case 'age':
  62. $options['age']['direction'] = $_POST['age-direction'];
  63. $options['age']['length'] = ppl_check_cardinal($_POST['age-length']);
  64. $options['age']['duration'] = $_POST['age-duration'];
  65. break;
  66. case 'custom':
  67. $options['custom']['key'] = $_POST['custom-key'];
  68. $options['custom']['op'] = $_POST['custom-op'];
  69. $options['custom']['value'] = $_POST['custom-value'];
  70. break;
  71. case 'num_terms':
  72. $options['num_terms'] = $_POST['num_terms'];
  73. if ($options['num_terms'] < 1) $options['num_terms'] = 20;
  74. break;
  75. default:
  76. $options[$arg] = $_POST[$arg];
  77. }
  78. }
  79. return $options;
  80. }
  81. function ppl_check_cardinal($string) {
  82. $value = intval($string);
  83. return ($value > 0) ? $value : 0;
  84. }
  85. function ppl_display_available_tags($plugin_name) {
  86. ?>
  87. <h3><?php _e('Available Tags', 'post_plugins'); ?></h3>
  88. <ul style="list-style-type: none;">
  89. <li title="">{author}</li>
  90. <li title="">{categoryid}</li>
  91. <li title="">{categorylinks}</li>
  92. <li title="">{categorynames}</li>
  93. <li title="">{commentcount}</li>
  94. <li title="">{custom}</li>
  95. <li title="">{date}</li>
  96. <li title="">{dateedited}</li>
  97. <li title="">{excerpt}</li>
  98. <li title="">{fullpost}</li>
  99. <li title="">{gravatar}</li>
  100. <li title="">{if}</li>
  101. <li title="">{image}</li>
  102. <li title="">{link}</li>
  103. <li title="">{php}</li>
  104. <li title="">{postid}</li>
  105. <li title="">{postviews}</li>
  106. <?php if ($plugin_name === 'similar-posts') { ?>
  107. <li title="">{score}</li>
  108. <?php } ?>
  109. <li title="">{snippet}</li>
  110. <li title="">{tags}</li>
  111. <li title="">{taglinks}</li>
  112. <li title="">{title}</li>
  113. <li title="">{time}</li>
  114. <li title="">{timeedited}</li>
  115. <li title="">{totalpages}</li>
  116. <li title="">{totalposts}</li>
  117. <li title="">{url}</li>
  118. </ul>
  119. <?php
  120. }
  121. function ppl_display_available_comment_tags() {
  122. ?>
  123. <ul style="list-style-type: none;">
  124. <li title="">{commentexcerpt}</li>
  125. <li title="">{commentsnippet}</li>
  126. <li title="">{commentsnippetword}</li>
  127. <li title="">{commentdate}</li>
  128. <li title="">{commenttime}</li>
  129. <li title="">{commentdategmt}</li>
  130. <li title="">{commenttimegmt}</li>
  131. <li title="">{commenter}</li>
  132. <li title="">{commenterip}</li>
  133. <li title="">{commenterurl}</li>
  134. <li title="">{commenterlink}</li>
  135. <li title="">{commenturl}</li>
  136. <li title="">{commentlink}</li>
  137. <li title="">{commentlink2}</li>
  138. </ul>
  139. <?php
  140. }
  141. /*
  142. inserts a form button to submit a bug report to my web site
  143. */
  144. function get_plugin_version($prefix) {
  145. $plugin_version = str_replace('-', '_', $prefix) . '_version';
  146. global $$plugin_version;
  147. return ${$plugin_version};
  148. }
  149. function ppl_bug_form($options_key) {
  150. global $wp_version;
  151. $template_name = basename(get_bloginfo('template_url'));
  152. $options = get_option($options_key);
  153. $options['mbstring'] = intval(function_exists('mb_internal_encoding'));
  154. $woptions = get_option('widget_rrm_'.str_replace('-', '_', $options_key));
  155. ?>
  156. <div class="wrap">
  157. <h2>Report a Bug</h2>
  158. <form method="post" action="http://rmarsh.com/report-a-bug/">
  159. <p><?php _e('This option takes you to my site where you can inform me of any issues
  160. you are having with this plugin. It also passes along useful debugging information such as
  161. which versions of WordPress, PHP, and MySQL you are using, as well as the current
  162. plugin settings.', 'post_plugins'); ?></p>
  163. <div class="submit"><input type="submit" name="report_bug" value="<?php _e('File Report', 'post_plugins') ?>" /></div>
  164. <input type="hidden" name="plugin" value="<?php echo $options_key; ?>" />
  165. <input type="hidden" name="plugin_version" value="<?php echo get_plugin_version($options_key); ?>" />
  166. <input type="hidden" name="wp_version" value="<?php echo $wp_version; ?>" />
  167. <input type="hidden" name="php_version" value="<?php echo PHP_VERSION; ?>" />
  168. <input type="hidden" name="mysql_version" value="<?php echo mysql_get_client_info(); ?>" />
  169. <input type="hidden" name="wp_language" value='<?php echo WPLANG; ?>' />
  170. <input type="hidden" name="template" value='<?php echo $template_name; ?>' />
  171. <input type="hidden" name="options_set" value='<?php echo serialize($options); ?>' />
  172. <input type="hidden" name="widget_options_set" value='<?php echo serialize($woptions); ?>' />
  173. </form>
  174. </div>
  175. <?php
  176. }
  177. /*
  178. inserts a form button to completely remove the plugin and all its options etc.
  179. */
  180. function ppl_plugin_eradicate_form($eradicate_action, $plugin_file) {
  181. if (isset($_POST['eradicate-plugin'])) {
  182. check_admin_referer('eradicate-plugin');
  183. if (ppl_confirm_eradicate()) {
  184. if (defined('POC_CACHE_4')) poc_cache_flush();
  185. $eradicate_action();
  186. ppl_deactivate_plugin($plugin_file);
  187. echo '<div class="updated fade"><p>' . __('The plugin and all its settings have been completely removed', 'post_plugins') . '</p></div>';
  188. exit;
  189. }
  190. }
  191. ?>
  192. <div class="wrap">
  193. <h2>Remove this Plugin</h2>
  194. <form method="post" action="">
  195. <p><?php _e('Deactivating a plugin from the Plugins page usually leaves all the plugin\'s
  196. settings intact. Often this is the desired behaviour as you can then choose to reactivate the plugin
  197. and all your settings will still be in place. If, however, you want to remove this plugin
  198. completely, along with all its settings and tables, you can do so by pressing the button below.', 'post_plugins'); ?></p>
  199. <div class="submit">
  200. <p><label for="eradicate-check"><input type="checkbox" name="eradicate-check" value="yes" /> check this box to confirm your intention</label></p>
  201. <input type="submit" name="eradicate-plugin" id="eradicate-plugin" value="<?php _e('Remove Plugin', 'post_plugins') ?>" />
  202. </div>
  203. <?php if (function_exists('wp_nonce_field')) wp_nonce_field('eradicate-plugin'); ?>
  204. </form>
  205. </div>
  206. <?php
  207. }
  208. function ppl_confirm_eradicate() {
  209. return (isset($_POST['eradicate-check']) && 'yes'===$_POST['eradicate-check']);
  210. }
  211. function ppl_deactivate_plugin($plugin_file) {
  212. $current = get_option('active_plugins');
  213. $plugin_file = substr($plugin_file, strlen(ABSPATH.PLUGINDIR)+1);
  214. $plugin_file = str_replace('\\', '/', $plugin_file);
  215. if (in_array($plugin_file, $current)) {
  216. array_splice($current, array_search($plugin_file, $current), 1);
  217. update_option('active_plugins', $current);
  218. }
  219. }
  220. /*
  221. For the display of the option pages
  222. */
  223. function ppl_display_limit($limit) {
  224. ?>
  225. <tr valign="top">
  226. <th scope="row"><?php _e('Number of posts to show:', 'post_plugins') ?></th>
  227. <td><input name="limit" type="text" id="limit" value="<?php echo $limit; ?>" size="2" /></td>
  228. </tr>
  229. <?php
  230. }
  231. function ppl_display_skip($skip) {
  232. ?>
  233. <tr valign="top">
  234. <th scope="row"><?php _e('Number of posts to skip:', 'post_plugins') ?></th>
  235. <td><input name="skip" type="text" id="skip" value="<?php echo $skip; ?>" size="2" /></td>
  236. </tr>
  237. <?php
  238. }
  239. function ppl_display_omit_current_post($omit_current_post) {
  240. ?>
  241. <tr valign="top">
  242. <th scope="row"><?php _e('Omit the current post?', 'post_plugins') ?></th>
  243. <td>
  244. <select name="omit_current_post" id="omit_current_post" >
  245. <option <?php if($omit_current_post == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
  246. <option <?php if($omit_current_post == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
  247. </select>
  248. </td>
  249. </tr>
  250. <?php
  251. }
  252. function ppl_display_show_private($show_private) {
  253. ?>
  254. <tr valign="top">
  255. <th scope="row"><?php _e('Show password-protected posts?', 'post_plugins') ?></th>
  256. <td>
  257. <select name="show_private" id="show_private">
  258. <option <?php if($show_private == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
  259. <option <?php if($show_private == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
  260. </select>
  261. </td>
  262. </tr>
  263. <?php
  264. }
  265. function ppl_display_show_pages($show_pages) {
  266. ?>
  267. <tr valign="top">
  268. <th scope="row"><?php _e('Show static pages?', 'post_plugins') ?></th>
  269. <td>
  270. <select name="show_pages" id="show_pages">
  271. <option <?php if($show_pages == 'false') { echo 'selected="selected"'; } ?> value="false">No pages, just posts</option>
  272. <option <?php if($show_pages == 'true') { echo 'selected="selected"'; } ?> value="true">Both pages and posts</option>
  273. <option <?php if($show_pages == 'but') { echo 'selected="selected"'; } ?> value="but">Pages but no posts</option>
  274. </select>
  275. </td>
  276. </tr>
  277. <?php
  278. }
  279. function ppl_display_match_cat($match_cat) {
  280. ?>
  281. <tr valign="top">
  282. <th scope="row"><?php _e('Match the current post\'s category?', 'post_plugins') ?></th>
  283. <td>
  284. <select name="match_cat" id="match_cat">
  285. <option <?php if($match_cat == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
  286. <option <?php if($match_cat == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
  287. </select>
  288. </td>
  289. </tr>
  290. <?php
  291. }
  292. function ppl_display_match_tags($match_tags) {
  293. global $wp_version;
  294. ?>
  295. <tr valign="top">
  296. <th scope="row"><?php _e('Match the current post\'s tags?', 'post_plugins') ?></th>
  297. <td>
  298. <select name="match_tags" id="match_tags" <?php if ($wp_version < 2.3) echo 'disabled="true"'; ?> >
  299. <option <?php if($match_tags == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
  300. <option <?php if($match_tags == 'any') { echo 'selected="selected"'; } ?> value="any">Any tag</option>
  301. <option <?php if($match_tags == 'all') { echo 'selected="selected"'; } ?> value="all">Every tag</option>
  302. </select>
  303. </td>
  304. </tr>
  305. <?php
  306. }
  307. function ppl_display_none_text($none_text) {
  308. ?>
  309. <tr valign="top">
  310. <th scope="row"><?php _e('Default display if no matches:', 'post_plugins') ?></th>
  311. <td><input name="none_text" type="text" id="none_text" value="<?php echo htmlspecialchars(stripslashes($none_text)); ?>" size="40" /></td>
  312. </tr>
  313. <?php
  314. }
  315. function ppl_display_no_text($no_text) {
  316. ?>
  317. <tr valign="top">
  318. <th scope="row"><?php _e('Show nothing if no matches?', 'post_plugins') ?></th>
  319. <td>
  320. <select name="no_text" id="no_text">
  321. <option <?php if($no_text == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
  322. <option <?php if($no_text == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
  323. </select>
  324. </td>
  325. </tr>
  326. <?php
  327. }
  328. function ppl_display_prefix($prefix) {
  329. ?>
  330. <tr valign="top">
  331. <th scope="row"><?php _e('Text and codes before the list:', 'post_plugins') ?></th>
  332. <td><input name="prefix" type="text" id="prefix" value="<?php echo htmlspecialchars(stripslashes($prefix)); ?>" size="40" /></td>
  333. </tr>
  334. <?php
  335. }
  336. function ppl_display_suffix($suffix) {
  337. ?>
  338. <tr valign="top">
  339. <th scope="row"><?php _e('Text and codes after the list:', 'post_plugins') ?></th>
  340. <td><input name="suffix" type="text" id="suffix" value="<?php echo htmlspecialchars(stripslashes($suffix)); ?>" size="40" /></td>
  341. </tr>
  342. <?php
  343. }
  344. function ppl_display_output_template($output_template) {
  345. ?>
  346. <tr valign="top">
  347. <th scope="row"><?php _e('Output template:', 'post_plugins') ?></th>
  348. <td><textarea name="output_template" id="output_template" rows="4" cols="38"><?php echo htmlspecialchars(stripslashes($output_template)); ?></textarea></td>
  349. </tr>
  350. <?php
  351. }
  352. function ppl_display_trim_before($trim_before) {
  353. ?>
  354. <tr valign="top">
  355. <th scope="row"><?php _e('Text to trim at start:', 'post_plugins') ?></th>
  356. <td><input name="trim_before" type="text" id="trim_before" value="<?php echo $trim_before; ?>" size="40" /></td>
  357. </tr>
  358. <?php
  359. }
  360. function ppl_display_tag_str($tag_str) {
  361. global $wp_version;
  362. ?>
  363. <tr valign="top">
  364. <th scope="row"><?php _e('Match posts with tags:<br />(a,b matches posts with either tag, a+b only matches posts with both tags)', 'post_plugins') ?></th>
  365. <td><input name="tag_str" type="text" id="tag_str" value="<?php echo $tag_str; ?>" <?php if ($wp_version < 2.3) echo 'disabled="true"'; ?> size="40" /></td>
  366. </tr>
  367. <?php
  368. }
  369. function ppl_display_excluded_posts($excluded_posts) {
  370. ?>
  371. <tr valign="top">
  372. <th scope="row"><?php _e('Posts to exclude:', 'post_plugins') ?></th>
  373. <td><input name="excluded_posts" type="text" id="excluded_posts" value="<?php echo $excluded_posts; ?>" size="40" /> <?php _e('comma-separated IDs', 'post_plugins'); ?></td>
  374. </tr>
  375. <?php
  376. }
  377. function ppl_display_included_posts($included_posts) {
  378. ?>
  379. <tr valign="top">
  380. <th scope="row"><?php _e('Posts to include:', 'post_plugins') ?></th>
  381. <td><input name="included_posts" type="text" id="included_posts" value="<?php echo $included_posts; ?>" size="40" /> <?php _e('comma-separated IDs', 'post_plugins'); ?></td>
  382. </tr>
  383. <?php
  384. }
  385. function ppl_display_authors($excluded_authors, $included_authors) {
  386. global $wpdb;
  387. ?>
  388. <tr valign="top">
  389. <th scope="row"><?php _e('Authors to exclude/include:', 'post_plugins') ?></th>
  390. <td>
  391. <table border="1">
  392. <?php
  393. $users = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login");
  394. if ($users) {
  395. $excluded = explode(',', $excluded_authors);
  396. $included = explode(',', $included_authors);
  397. echo "\n\t<tr valign=\"top\"><td style=\"border-bottom-width: 0px;\" ><strong>Author</strong></td><td style=\"border-bottom-width: 0px;\">Exclude</td><td style=\"border-bottom-width: 0px;\">Include</td></tr>";
  398. foreach ($users as $user) {
  399. if (false === in_array($user->ID, $excluded)) {
  400. $ex_ischecked = '';
  401. } else {
  402. $ex_ischecked = 'checked';
  403. }
  404. if (false === in_array($user->ID, $included)) {
  405. $in_ischecked = '';
  406. } else {
  407. $in_ischecked = 'checked';
  408. }
  409. echo "\n\t<tr valign=\"top\"><td style=\"border-bottom-width: 0px;\">$user->user_login</td><td style=\"border-bottom-width: 0px;\"><input type=\"checkbox\" name=\"excluded_authors[]\" value=\"$user->ID\" $ex_ischecked /></td><td style=\"border-bottom-width: 0px;\"><input type=\"checkbox\" name=\"included_authors[]\" value=\"$user->ID\" $in_ischecked /></td></tr>";
  410. }
  411. }
  412. ?>
  413. </table>
  414. </td>
  415. </tr>
  416. <?php
  417. }
  418. function ppl_display_cats($excluded_cats, $included_cats) {
  419. global $wpdb;
  420. ?>
  421. <tr valign="top">
  422. <th scope="row"><?php _e('Categories to exclude/include:', 'post_plugins') ?></th>
  423. <td>
  424. <table border="1">
  425. <?php
  426. if (function_exists("get_categories")) {
  427. $categories = get_categories('&hide_empty=1');
  428. } else {
  429. $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE category_count <> 0 ORDER BY cat_name");
  430. }
  431. if ($categories) {
  432. echo "\n\t<tr valign=\"top\"><td style=\"border-bottom-width: 0px;\"><strong>Category</strong></td><td style=\"border-bottom-width: 0px;\">Exclude</td><td style=\"border-bottom-width: 0px;\">Include</td></tr>";
  433. $excluded = explode(',', $excluded_cats);
  434. $included = explode(',', $included_cats);
  435. $level = 0;
  436. $cats_added = array();
  437. $last_parent = 0;
  438. $cat_parent = 0;
  439. foreach ($categories as $category) {
  440. $category->cat_name = wp_specialchars($category->cat_name);
  441. if (false === in_array($category->cat_ID, $excluded)) {
  442. $ex_ischecked = '';
  443. } else {
  444. $ex_ischecked = 'checked';
  445. }
  446. if (false === in_array($category->cat_ID, $included)) {
  447. $in_ischecked = '';
  448. } else {
  449. $in_ischecked = 'checked';
  450. }
  451. $last_parent = $cat_parent;
  452. $cat_parent = $category->category_parent;
  453. if ($cat_parent == 0) {
  454. $level = 0;
  455. } elseif ($last_parent != $cat_parent) {
  456. if (in_array($cat_parent, $cats_added)) {
  457. $level = $level - 1;
  458. } else {
  459. $level = $level + 1;
  460. }
  461. $cats_added[] = $cat_parent;
  462. }
  463. $pad = str_repeat('&nbsp;', 3*$level);
  464. echo "\n\t<tr valign=\"top\"><td style=\"border-bottom-width: 0px;\">$pad$category->cat_name</td><td style=\"border-bottom-width: 0px;\"><input type=\"checkbox\" name=\"excluded_cats[]\" value=\"$category->cat_ID\" $ex_ischecked /></td><td style=\"border-bottom-width: 0px;\"><input type=\"checkbox\" name=\"included_cats[]\" value=\"$category->cat_ID\" $in_ischecked /></td></tr>";
  465. }
  466. }
  467. ?>
  468. </table>
  469. </td>
  470. </tr>
  471. <?php
  472. }
  473. function ppl_display_stripcodes($stripcodes) {
  474. ?>
  475. <tr valign="top">
  476. <th scope="row"><?php _e('Other plugins\' tags to remove from snippet:', 'post_plugins') ?></th>
  477. <td>
  478. <table>
  479. <tr><td style="border-bottom-width: 0"><?php _e('opening', 'post_plugins') ?></td><td style="border-bottom-width: 0"><?php _e('closing', 'post_plugins') ?></td></tr>
  480. <tr valign="top"><td style="border-bottom-width: 0"><textarea name="starttags" id="starttags" rows="4" cols="10"><?php foreach ($stripcodes as $tag) echo htmlspecialchars(stripslashes($tag['start']))."\n"; ?></textarea></td><td style="border-bottom-width: 0"><textarea name="endtags" id="endtags" rows="4" cols="10"><?php foreach ($stripcodes as $tag) echo htmlspecialchars(stripslashes($tag['end']))."\n"; ?></textarea></td></tr>
  481. </table>
  482. </td>
  483. </tr>
  484. <?php
  485. }
  486. function ppl_display_age($age) {
  487. ?>
  488. <tr valign="top">
  489. <th scope="row"><?php _e('Ignore posts :', 'post_plugins') ?></th>
  490. <td>
  491. <table><tr>
  492. <td style="border-bottom-width: 0">
  493. <select name="age-direction" id="age-direction">
  494. <option <?php if($age['direction'] == 'before') { echo 'selected="selected"'; } ?> value="before">less than</option>
  495. <option <?php if($age['direction'] == 'after') { echo 'selected="selected"'; } ?> value="after">more than</option>
  496. <option <?php if($age['direction'] == 'none') { echo 'selected="selected"'; } ?> value="none">-----</option>
  497. </select>
  498. </td>
  499. <td style="border-bottom-width: 0"><input name="age-length" type="text" id="age-length" value="<?php echo $age['length']; ?>" size="4" /></td>
  500. <td style="border-bottom-width: 0">
  501. <select name="age-duration" id="age-duration">
  502. <option <?php if($age['duration'] == 'day') { echo 'selected="selected"'; } ?> value="day">day(s)</option>
  503. <option <?php if($age['duration'] == 'month') { echo 'selected="selected"'; } ?> value="month">month(s)</option>
  504. <option <?php if($age['duration'] == 'year') { echo 'selected="selected"'; } ?> value="year">year(s)</option>
  505. </select>
  506. old
  507. </td>
  508. </tr></table>
  509. </td>
  510. </tr>
  511. <?php
  512. }
  513. function ppl_display_custom($custom) {
  514. ?>
  515. <tr valign="top">
  516. <th scope="row"><?php _e('Match posts by custom field:', 'post_plugins') ?></th>
  517. <td>
  518. <table>
  519. <tr><td style="border-bottom-width: 0">Field Name</td><td style="border-bottom-width: 0"></td><td style="border-bottom-width: 0">Field Value</td></tr>
  520. <tr>
  521. <td style="border-bottom-width: 0"><input name="custom-key" type="text" id="custom-key" value="<?php echo $custom['key']; ?>" size="20" /></td>
  522. <td style="border-bottom-width: 0">
  523. <select name="custom-op" id="custom-op">
  524. <option <?php if($custom['op'] == '=') { echo 'selected="selected"'; } ?> value="=">=</option>
  525. <option <?php if($custom['op'] == '!=') { echo 'selected="selected"'; } ?> value="!=">!=</option>
  526. <option <?php if($custom['op'] == '>') { echo 'selected="selected"'; } ?> value=">">></option>
  527. <option <?php if($custom['op'] == '>=') { echo 'selected="selected"'; } ?> value=">=">>=</option>
  528. <option <?php if($custom['op'] == '<') { echo 'selected="selected"'; } ?> value="<"><</option>
  529. <option <?php if($custom['op'] == '<=') { echo 'selected="selected"'; } ?> value="<="><=</option>
  530. <option <?php if($custom['op'] == 'LIKE') { echo 'selected="selected"'; } ?> value="LIKE">LIKE</option>
  531. <option <?php if($custom['op'] == 'NOT LIKE') { echo 'selected="selected"'; } ?> value="NOT LIKE">NOT LIKE</option>
  532. <option <?php if($custom['op'] == 'REGEXP') { echo 'selected="selected"'; } ?> value="REGEXP">REGEXP</option>
  533. <option <?php if($custom['op'] == 'EXISTS') { echo 'selected="selected"'; } ?> value="EXISTS">EXISTS</option>
  534. </select>
  535. </td>
  536. <td style="border-bottom-width: 0"><input name="custom-value" type="text" id="custom-value" value="<?php echo $custom['value']; ?>" size="20" /></td>
  537. </tr>
  538. </table>
  539. </td>
  540. </tr>
  541. <?php
  542. }
  543. function ppl_display_content_filter($content_filter) {
  544. ?>
  545. <tr valign="top">
  546. <th scope="row"><?php _e('Replace special tags in content?', 'post_plugins') ?></th>
  547. <td>
  548. <select name="content_filter" id="content_filter">
  549. <option <?php if($content_filter == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
  550. <option <?php if($content_filter == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
  551. </select>
  552. </td>
  553. </tr>
  554. <?php
  555. }
  556. // now for similar_posts
  557. function ppl_display_num_terms($num_terms) {
  558. ?>
  559. <tr valign="top">
  560. <th scope="row"><?php _e('Maximum number of words to use for match:', 'post_plugins') ?></th>
  561. <td><input name="num_terms" type="text" id="num_terms" value="<?php echo $num_terms; ?>" size="3" /></td>
  562. </tr>
  563. <?php
  564. }
  565. function ppl_display_crossmatch($crossmatch) {
  566. ?>
  567. <tr valign="top">
  568. <th scope="row" title=""><?php _e('Crossmatch terms?', 'post_plugins') ?></th>
  569. <td>
  570. <select name="crossmatch" id="crossmatch">
  571. <option <?php if($crossmatch == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
  572. <option <?php if($crossmatch == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
  573. </select>
  574. </td>
  575. </tr>
  576. <?php
  577. }
  578. function ppl_display_weights($options) {
  579. ?>
  580. <tr valign="top">
  581. <th scope="row"><?php _e('Relative importance of:', 'post_plugins') ?></th>
  582. <td>
  583. <table><tr>
  584. <td style="border-bottom-width: 0"><label for="weight_content" style="float:left;">content: </label><input name="weight_content" type="text" id="weight_content" value="<?php echo round(100 * $options['weight_content']); ?>" size="3" /> % </td>
  585. <td style="border-bottom-width: 0"><label for="weight_title" style="float:left;">title: </label><input name="weight_title" type="text" id="weight_title" value="<?php echo round(100 * $options['weight_title']); ?>" size="3" /> % </td>
  586. <td style="border-bottom-width: 0"><label for="weight_tags" style="float:left;">tags: </label><input name="weight_tags" type="text" id="weight_tags" value="<?php echo round(100 * $options['weight_tags']); ?>" size="3" /> % ( adds up to 100% )</td>
  587. </tr></table>
  588. </td>
  589. </tr>
  590. <?php
  591. }
  592. function ppl_display_feed_active($feed_active) {
  593. ?>
  594. <tr valign="top">
  595. <th scope="row"><?php _e('Add Similar Posts to feeds? (configured from own options page)', 'post_plugins') ?></th>
  596. <td>
  597. <select name="feed_active" id="feed_active">
  598. <option <?php if($feed_active == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
  599. <option <?php if($feed_active == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
  600. </select>
  601. </td>
  602. </tr>
  603. <?php
  604. }
  605. // now for recent_comments
  606. function ppl_display_show_type($show_type) {
  607. ?>
  608. <tr valign="top">
  609. <th scope="row" title=""><?php _e('Type of comment to show:', 'post_plugins') ?></th>
  610. <td>
  611. <select name="show_type" id="show_type">
  612. <option <?php if($show_type == 'all') { echo 'selected="selected"'; } ?> value="all">All kinds of comment</option>
  613. <option <?php if($show_type == 'comments') { echo 'selected="selected"'; } ?> value="comments">Just plain comments</option>
  614. <option <?php if($show_type == 'trackbacks') { echo 'selected="selected"'; } ?> value="trackbacks">Just trackbacks and pingbacks</option>
  615. </select>
  616. </td>
  617. </tr>
  618. <?php
  619. }
  620. function ppl_display_group_by($group_by) {
  621. ?>
  622. <tr valign="top">
  623. <th scope="row" title=""><?php _e('Type of grouping:', 'post_plugins') ?></th>
  624. <td>
  625. <select name="group_by" id="group_by">
  626. <option <?php if($group_by == 'post') { echo 'selected="selected"'; } ?> value="post">By Post</option>
  627. <option <?php if($group_by == 'none') { echo 'selected="selected"'; } ?> value="none">Ungrouped</option>
  628. <option <?php if($group_by == 'author') { echo 'selected="selected"'; } ?> value="author">By Commenter</option>
  629. </select>
  630. </td>
  631. </tr>
  632. <?php
  633. }
  634. function ppl_display_group_template($group_template) {
  635. ?>
  636. <tr valign="top">
  637. <th scope="row"><?php _e('Group title template:', 'post_plugins') ?></th>
  638. <td><textarea name="group_template" id="group_template" rows="4" cols="38"><?php echo htmlspecialchars(stripslashes($group_template)); ?></textarea></td>
  639. </tr>
  640. <?php
  641. }
  642. function ppl_display_no_author_comments($no_author_comments) {
  643. ?>
  644. <tr valign="top">
  645. <th scope="row"><?php _e('Omit comments by the post author?', 'post_plugins') ?></th>
  646. <td>
  647. <select name="no_author_comments" id="no_author_comments">
  648. <option <?php if($no_author_comments == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
  649. <option <?php if($no_author_comments == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
  650. </select>
  651. </td>
  652. </tr>
  653. <?php
  654. }
  655. function ppl_display_no_user_comments($no_user_comments) {
  656. ?>
  657. <tr valign="top">
  658. <th scope="row"><?php _e('Omit comments by registered users?', 'post_plugins') ?></th>
  659. <td>
  660. <select name="no_user_comments" id="no_user_comments">
  661. <option <?php if($no_user_comments == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
  662. <option <?php if($no_user_comments == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
  663. </select>
  664. </td>
  665. </tr>
  666. <?php
  667. }
  668. ?>