Changeset 153397
- Timestamp:
- 09/09/2009 11:57:28 PM (17 years ago)
- Location:
- similarity
- Files:
-
- 17 added
- 2 edited
-
tags/2.13.1 (added)
-
tags/2.13.1/readme.txt (added)
-
tags/2.13.1/screenshot-1.png (added)
-
tags/2.13.1/similarity-de_DE.mo (added)
-
tags/2.13.1/similarity-de_DE.po (added)
-
tags/2.13.1/similarity-en_US.mo (added)
-
tags/2.13.1/similarity-en_US.po (added)
-
tags/2.13.1/similarity-es_ES.mo (added)
-
tags/2.13.1/similarity-es_ES.po (added)
-
tags/2.13.1/similarity-fr_FR.mo (added)
-
tags/2.13.1/similarity-fr_FR.po (added)
-
tags/2.13.1/similarity-it_IT.mo (added)
-
tags/2.13.1/similarity-it_IT.po (added)
-
tags/2.13.1/similarity-pl_PL.mo (added)
-
tags/2.13.1/similarity-pl_PL.po (added)
-
tags/2.13.1/similarity.php (added)
-
tags/2.13.1/similarity.pot (added)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/similarity.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
similarity/trunk/readme.txt
r153287 r153397 48 48 == Changelog == 49 49 50 = 2.13.1 = 51 * New options make it possible to layout and style the php function generated lists (for sidebars) independent of the auto-generated list. 52 50 53 = 2.13 = 51 * New options make it possible to layout and style the php function generated lists (for sidebars) independent of the auto-generated list.54 * Mistaken release - corrected in 2.13.1. 52 55 53 56 = 2.12 = -
similarity/trunk/similarity.php
r153286 r153397 3 3 Plugin Name: Similarity 4 4 Plugin URI: http://www.davidjmiller.org/2008/similarity/ 5 Description: Returns links to similar posts. Similarity is determined by the way posts are tagged or by their categories. Compatible with Wordpress 2.3 and above. (Tested on 2.3, 2.5, 2.6, 2.7 )6 Version: 2.13 5 Description: Returns links to similar posts. Similarity is determined by the way posts are tagged or by their categories. Compatible with Wordpress 2.3 and above. (Tested on 2.3, 2.5, 2.6, 2.7, 2.8) 6 Version: 2.13.1 7 7 Author: David Miller 8 8 Author URI: http://www.davidjmiller.org/ … … 16 16 e.g.: <?php sim_by_tag_multi(); ?> determines similarity based on the tags applied to the first post on milti-post pages 17 17 e.g.: <?php sim_by_cat_multi(); ?> determines similarity based on the categories assigned to the first post on milti-post pages 18 e.g.: <?php sim_by_mix _multi(); ?> determines similarity based on the categories and tags assigned to the first post on milti-post pages weighting each according to the ratio you assign18 e.g.: <?php sim_by_mix(multi); ?> determines similarity based on the categories and tags assigned to the first post on milti-post pages weighting each according to the ratio you assign 19 19 Shortcodes: 20 20 e.g.: [SIM-BY-TAG] … … 31 31 function sim_by_tag() { 32 32 $list = get_list("tag"); 33 echo '<div class="similarity">';34 33 echo print_similarity($list); 35 echo '< /div><!-- Similarity - Sim_by_Tag -->';34 echo '<!-- Similarity - Sim_by_Tag -->'; 36 35 } 37 36 function sim_by_cat() { 38 37 $list = get_list("cat"); 39 echo '<div class="similarity">';40 38 echo print_similarity($list); 41 echo '</div><!-- Similarity - Sim_by_Cat -->'; 39 echo '<!-- Similarity - Sim_by_Cat -->'; 40 } 41 function sim_by_mix_multi() { 42 $taglist = get_list("firstt"); 43 $catlist = get_list("firstc"); 44 $list = mix_lists($taglist, $catlist); 45 echo print_similarity($list); 46 echo '<!-- Similarity - Sim_by_Mix -->'; 47 } 48 function sim_by_tag_multi() { 49 $list = get_list("firstt"); 50 echo print_similarity($list); 51 echo '<!-- Similarity - Sim_by_Tag -->'; 52 } 53 function sim_by_cat_multi() { 54 $list = get_list("firstc"); 55 echo print_similarity($list); 56 echo '<!-- Similarity - Sim_by_Cat -->'; 42 57 } 43 58 function sim_by_mix() { … … 45 60 $catlist = get_list("cat"); 46 61 $list = mix_lists($taglist, $catlist); 47 echo '<div class="similarity">';48 62 echo print_similarity($list); 49 echo '</div><!-- Similarity - Sim_by_Mix -->'; 50 } 51 function sim_by_tag_multi() { 52 $list = get_list("firstt"); 53 echo '<div class="similarity_sb">'; 54 echo print_similarity($list); 55 echo '</div><!-- Similarity - Sim_by_Tag -->'; 56 } 57 function sim_by_cat_multi() { 58 $list = get_list("firstc"); 59 echo '<div class="similarity_sb">'; 60 echo print_similarity($list); 61 echo '</div><!-- Similarity - Sim_by_Cat -->'; 62 } 63 function sim_by_mix_multi() { 64 $taglist = get_list("firstt"); 65 $catlist = get_list("firstc"); 66 $list = mix_lists($taglist, $catlist); 67 echo '<div class="similarity_sb">'; 68 echo print_similarity($list); 69 echo '</div><!-- Similarity - Sim_by_Mix -->'; 63 echo '<!-- Similarity - Sim_by_Mix -->'; 70 64 } 71 65 … … 92 86 $catlist = get_list("cat"); 93 87 $list = mix_lists($taglist, $catlist); 94 return $content.'<div class="similarity">'.print_similarity($list ).'</div><!-- Mix -->';88 return $content.'<div class="similarity">'.print_similarity($list, 'auto').'</div><!-- Mix -->'; 95 89 break; 96 90 default: … … 114 108 } 115 109 116 function print_similarity($list ) {110 function print_similarity($list, $template = 'default') { 117 111 global $current_user; 118 112 $options = get_option(basename(__FILE__, ".php")); 119 113 $limit = stripslashes($options['limit']); 120 114 $none_text = stripslashes($options['none_text']); 121 $prefix = stripslashes($options['prefix']); 122 $suffix = stripslashes($options['suffix']); 123 $format = stripslashes($options['format']); 115 if ($template == 'auto') { 116 $prefix = stripslashes($options['auto_prefix']); 117 $suffix = stripslashes($options['auto_suffix']); 118 $format = stripslashes($options['auto_format']); 119 $output_template = stripslashes($options['auto_output_template']); 120 } else { 121 $prefix = stripslashes($options['prefix']); 122 $suffix = stripslashes($options['suffix']); 123 $format = stripslashes($options['format']); 124 $output_template = stripslashes($options['output_template']); 125 } 124 126 $minimum_strength = stripslashes($options['minimum_strength']); 125 127 $random_min = stripslashes($options['random_min']); 126 $output_template = stripslashes($options['output_template']);127 128 // an empty output_template makes no sense so we fall back to the default 128 129 if ($output_template == '') $output_template = '<li>{link} ({strength})</li>'; … … 428 429 $default_options['format'] = 'value'; 429 430 $default_options['output_template'] = '<li>{link} ({strength})</li>'; 431 $default_options['auto_prefix'] = '<ul>'; 432 $default_options['auto_suffix'] = '</ul>'; 433 $default_options['auto_format'] = 'value'; 434 $default_options['auto_output_template'] = '<li>{link} ({strength})</li>'; 430 435 $default_options['tag_weight'] = 1; 431 436 $default_options['cat_weight'] = 1; … … 450 455 $options['format'] = $_POST['format']; 451 456 $options['output_template'] = $_POST['output_template']; 457 $options['auto_prefix'] = $_POST['auto_prefix']; 458 $options['auto_suffix'] = $_POST['auto_suffix']; 459 $options['auto_format'] = $_POST['auto_format']; 460 $options['auto_output_template'] = $_POST['auto_output_template']; 452 461 $options['tag_weight'] = $_POST['tag_weight']; 453 462 $options['cat_weight'] = $_POST['cat_weight']; … … 482 491 $options['format'] = 'value'; 483 492 $options['output_template'] = '<li>{link} ({strength})</li>'; 493 $options['auto_prefix'] = '<ul>'; 494 $options['auto_suffix'] = '</ul>'; 495 $options['auto_format'] = 'value'; 496 $options['auto_output_template'] = '<li>{link} ({strength})</li>'; 484 497 $options['tag_weight'] = 1; 485 498 $options['cat_weight'] = 1; … … 511 524 <tr valign="top"> 512 525 <th scope="row" align="right"><?php _e('Number of posts to show', 'similarity') ?>:</th> 513 <td ><input name="limit" type="text" id="limit" value="<?php echo $options['limit']; ?>" size="2" /></td>526 <td colspan="2"><input name="limit" type="text" id="limit" value="<?php echo $options['limit']; ?>" size="2" /></td> 514 527 </tr> 515 528 <tr valign="top"> 516 529 <th scope="row" align="right"><?php _e('Minimum match strength', 'similarity') ?>:</th> 517 <td ><input name="minimum_strength" type="text" id="minimum_strength" value="<?php echo $options['minimum_strength']; ?>" size="5" /> <?php _e('(Any number between .00 and 1 with 1 being a perfect match.)', 'similarity') ?></td>530 <td colspan="2"><input name="minimum_strength" type="text" id="minimum_strength" value="<?php echo $options['minimum_strength']; ?>" size="5" /> <?php _e('(Any number between .00 and 1 with 1 being a perfect match.)', 'similarity') ?></td> 518 531 </tr> 519 532 <tr valign="top"> 520 533 521 534 <th scope="row" align="right"><?php _e('Default display if no matches', 'similarity') ?>:</th> 522 <td><input name="none_text" type="text" id="none_text" value="<?php echo htmlspecialchars(stripslashes($options['none_text'])); ?>" size="40" /></td> 535 <td colspan="2"><input name="none_text" type="text" id="none_text" value="<?php echo htmlspecialchars(stripslashes($options['none_text'])); ?>" size="40" /></td> 536 </tr> 537 <tr valign="top"> 538 <th scope="row" align="right"></th> 539 <td align="center"><strong><?php _e('Template functions', 'similarity') ?></strong></td> 540 <td align="center"><strong><?php _e('Auto display functions', 'similarity') ?></strong></td> 523 541 </tr> 524 542 <tr valign="top"> 525 543 <th scope="row" align="right"><?php _e('Text and codes before the list', 'similarity') ?>:</th> 526 544 <td><input name="prefix" type="text" id="prefix" value="<?php echo htmlspecialchars(stripslashes($options['prefix'])); ?>" size="40" /></td> 545 <td><input name="auto_prefix" type="text" id="auto_prefix" value="<?php echo htmlspecialchars(stripslashes($options['auto_prefix'])); ?>" size="40" /></td> 527 546 </tr> 528 547 <tr valign="top"> 529 548 <th scope="row" align="right"><?php _e('Text and codes after the list', 'similarity') ?>:</th> 530 549 <td><input name="suffix" type="text" id="suffix" value="<?php echo htmlspecialchars(stripslashes($options['suffix'])); ?>" size="40" /></td> 550 <td><input name="auto_suffix" type="text" id="auto_suffix" value="<?php echo htmlspecialchars(stripslashes($options['auto_suffix'])); ?>" size="40" /></td> 551 </tr> 552 <tr valign="top"> 553 <th scope="row" align="right"><?php _e('Output template', 'similarity') ?>:</th> 554 <td><textarea name="output_template" id="output_template" rows="4" cols="32"><?php echo htmlspecialchars(stripslashes($options['output_template'])); ?></textarea></td> 555 <td><textarea name="auto_output_template" id="auto_output_template" rows="4" cols="32"><?php echo htmlspecialchars(stripslashes($options['auto_output_template'])); ?></textarea></td> 556 </tr> 557 <tr valign="top"> 558 <th scope="row" align="right"></th> 559 <td colspan="2" align="center"><?php _e('Valid template tags', 'similarity') ?>:{link}, {strength}, {url}, {title}</td> 531 560 </tr> 532 561 <tr valign="top"> 533 562 <th scope="row" align="right"><?php _e('Display format for similarity strength', 'similarity') ?>:</th> 534 <td >563 <td colspan="2"> 535 564 <input type="radio" name="format" id="format" value="color"<?php if ($options['format'] == 'color') echo ' checked'; ?>><?php _e('Visual', 'similarity') ?></input> 536 565 <input type="radio" name="format" id="format" value="percent"<?php if ($options['format'] == 'percent') echo ' checked'; ?>><?php _e('Percent', 'similarity') ?></input> … … 541 570 <tr valign="top"> 542 571 <th scope="row" align="right"><?php _e('Custom text for strength', 'similarity') ?>:</th> 543 <td ><input name="text_strong" type="text" id="text_strong" value="<?php echo htmlspecialchars(stripslashes($options['text_strong'])); ?>" size="40" /> >75%</td>572 <td colspan="2"><input name="text_strong" type="text" id="text_strong" value="<?php echo htmlspecialchars(stripslashes($options['text_strong'])); ?>" size="40" /> >75%</td> 544 573 </tr> 545 574 <tr valign="top"> 546 575 <th scope="row" align="right"> </th> 547 <td ><input name="text_mild" type="text" id="text_mild" value="<?php echo htmlspecialchars(stripslashes($options['text_mild'])); ?>" size="40" /> 75% > 50%</td>576 <td colspan="2"><input name="text_mild" type="text" id="text_mild" value="<?php echo htmlspecialchars(stripslashes($options['text_mild'])); ?>" size="40" /> 75% > 50%</td> 548 577 </tr> 549 578 <tr valign="top"> 550 579 <th scope="row" align="right"> </th> 551 <td ><input name="text_weak" type="text" id="text_weak" value="<?php echo htmlspecialchars(stripslashes($options['text_weak'])); ?>" size="40" /> 50% > 25%</td>580 <td colspan="2"><input name="text_weak" type="text" id="text_weak" value="<?php echo htmlspecialchars(stripslashes($options['text_weak'])); ?>" size="40" /> 50% > 25%</td> 552 581 </tr> 553 582 <tr valign="top"> 554 583 <th scope="row" align="right"> </th> 555 <td ><input name="text_tenuous" type="text" id="text_tenuous" value="<?php echo htmlspecialchars(stripslashes($options['text_tenuous'])); ?>" size="40" /> < 25%</td>584 <td colspan="2"><input name="text_tenuous" type="text" id="text_tenuous" value="<?php echo htmlspecialchars(stripslashes($options['text_tenuous'])); ?>" size="40" /> < 25%</td> 556 585 </tr> 557 586 <tr valign="top"> 558 587 <th scope="row" align="right"><?php _e('Relative mixing weights', 'similarity') ?>:</th> 559 <td ><input name="tag_weight" type="text" id="tag_weight" value="<?php echo htmlspecialchars(stripslashes($options['tag_weight'])); ?>" size="40" /> <?php _e('Tags', 'similarity') ?></td>588 <td colspan="2"><input name="tag_weight" type="text" id="tag_weight" value="<?php echo htmlspecialchars(stripslashes($options['tag_weight'])); ?>" size="40" /> <?php _e('Tags', 'similarity') ?></td> 560 589 </tr> 561 590 <tr valign="top"> 562 591 <th scope="row" align="right"> </th> 563 <td><input name="cat_weight" type="text" id="cat_weight" value="<?php echo htmlspecialchars(stripslashes($options['cat_weight'])); ?>" size="40" /> <?php _e('Categories', 'similarity') ?></td> 564 </tr> 565 <tr valign="top"> 566 <th scope="row" align="right"><?php _e('Output template', 'similarity') ?>:</th> 567 <td><textarea name="output_template" id="output_template" rows="4" cols="60"><?php echo htmlspecialchars(stripslashes($options['output_template'])); ?></textarea><br/><?php _e('Valid template tags', 'similarity') ?>:{link}, {strength}, {url}, {title}</td> 592 <td colspan="2"><input name="cat_weight" type="text" id="cat_weight" value="<?php echo htmlspecialchars(stripslashes($options['cat_weight'])); ?>" size="40" /> <?php _e('Categories', 'similarity') ?></td> 568 593 </tr> 569 594 <tr valign="top"> 570 595 <th scope="row" align="right"><?php _e('Show one more random related post', 'similarity') ?>:</th> 571 <td >596 <td colspan="2"> 572 597 <input type="radio" name="one_extra" id="one_extra" value="true"<?php if ($options['one_extra'] == 'true') echo ' checked'; ?>><?php _e('Yes', 'similarity') ?></input> 573 598 <input type="radio" name="one_extra" id="one_extra" value="false"<?php if ($options['one_extra'] == 'false') echo ' checked'; ?>><?php _e('No', 'similarity') ?></input> … … 577 602 <tr valign="top"> 578 603 <th scope="row" align="right"><?php _e('Auto-display list from function', 'similarity') ?>:</th> 579 <td >604 <td colspan="2"> 580 605 <input type="radio" name="adf" id="adf" value="none"<?php if ($options['adf'] == 'none') echo ' checked'; ?>><?php _e('None', 'similarity') ?></input> 581 606 <input type="radio" name="adf" id="adf" value="tag"<?php if ($options['adf'] == 'tag') echo ' checked'; ?>>sim_by_tag</input> … … 586 611 <tr valign="top"> 587 612 <th scope="row" align="right"><?php _e('Display Similarity on pages', 'similarity') ?>:</th> 588 <td >613 <td colspan="2"> 589 614 <input type="radio" name="sim_pages" id="sim_pages" value="yes"<?php if ($options['sim_pages'] == 'yes') echo ' checked'; ?>><?php _e('Yes', 'similarity') ?></input> 590 615 <input type="radio" name="sim_pages" id="sim_pages" value="no"<?php if ($options['sim_pages'] == 'no') echo ' checked'; ?>><?php _e('No', 'similarity') ?></input>
Note: See TracChangeset
for help on using the changeset viewer.