Changeset 372705
- Timestamp:
- 04/13/2011 10:44:52 PM (15 years ago)
- Location:
- docs-auto-tags/trunk
- Files:
-
- 4 edited
-
docs-auto-tags.php (modified) (4 diffs)
-
lang/en_US.mo (modified) (previous)
-
lang/en_US.po (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
docs-auto-tags/trunk/docs-auto-tags.php
r372436 r372705 4 4 Plugin URI: http://wordpress.org/extend/plugins/docs-auto-tags/ 5 5 Description: Assigns tags to posts containing specific text strings, handy for filtering within the loop. A gift to @docrock from @johnleblanc to help keep Instagr.am image posts out of the mrdocrock.com homepage loop April, 2011. 6 Version: 0. 16 Version: 0.2 7 7 Author: John LeBlanc 8 8 Author URI: http://johnleblanc.com … … 51 51 52 52 // main auto-tagging functionality 53 add_action( 'save_post', 'jpl_docs_autotag' ); 53 54 function jpl_docs_autotag($post_id) { 54 $instagram_pattern = 'httpimagesinsta';55 55 $post = get_post($post_id); 56 if ( intval($post->ID) > 0 && strpos( $post->post_content, $instagram_pattern ) ) { 57 wp_set_post_tags( $post->ID, $tags, TRUE ); // TRUE means append 56 if ( intval($post->ID) > 0 ) { 57 $options = get_option( 'docs_autotags' ); 58 foreach ( $options as $pattern => $tags ) { 59 if ( strpos($post->post_content, $pattern) ) 60 wp_set_post_tags( $post->ID, $tags, TRUE ); // TRUE means append 61 } 58 62 } 59 63 } … … 63 67 function jpl_docs_autotags_options_page() { 64 68 if ( !current_user_can( 'manage_options' ) ) { 65 // Doc might wouldinclude profanity, but he can manage his own language file69 // Doc might include profanity, but he can manage his own language file 66 70 wp_die( __('You do not have sufficient permissions to access this page.') ); 67 71 } … … 70 74 <div class="wrap"> 71 75 <h2><?php _e("Doc's Autotags") ?></h2> 72 <form method="post" action="tools.php"> 76 <p><?php _e('Posts that include the (case-sensitive) string patterns defined below will be assigned the specified tag(s) when saved.') ?></p> 77 <form method="post" action=""> 73 78 <?php settings_fields( 'docs_autotags_options' ); ?> 74 <?php do_settings( 'docs_autotags_options' ); ?> 79 80 <?php 81 // receive post data 82 if ( isset($_POST['pattern']) ) { 83 $i = 0; 84 while ( $i <= count($_POST['pattern']) ) { 85 if ( strlen(trim($_POST['pattern'][$i])) > 0 && strlen(trim($_POST['tags'][$i])) > 0 ) 86 $options[$_POST['pattern'][$i]] = $_POST['tags'][$i]; 87 $i++; 88 } 89 update_option( 'docs_autotags', $options ); 90 } 91 ?> 92 75 93 <?php $options = get_option( 'docs_autotags' ); ?> 76 94 95 <?php $i=0; ?> 96 <?php foreach ( $options as $pattern => $tags ) :?> 97 <div id="rule-<?php echo $i ?>"> 98 <p> 99 <label for="pattern[<?php echo $i ?>]"><?php _e('Pattern') ?></label> <input name="pattern[<?php echo $i ?>]" value="<?php echo $pattern ?>" /> 100 <label for="tags[<?php echo $i ?>]"><?php _e('Tags') ?></label> <input class="suggest" name="tags[<?php echo $i ?>]" value="<?php echo $tags ?>" /> 101 <a href="#" class="delete" onclick="jQuery('#rule-<?php echo $i ?>').remove();return false">delete</a> 102 </p> 103 </div> 104 <?php $i++; ?> 105 <?php endforeach; ?> 106 107 <div id="rule-new"> 108 <p> 109 <label for="pattern[<?php echo $i ?>]"><?php _e('Pattern') ?></label> <input name="pattern[<?php echo $i ?>]" value="" /> 110 <label for="tags[<?php echo $i ?>]"><?php _e('Tags') ?></label> <input class="suggest" name="tags[<?php echo $i ?>]" value="" /> 111 </p> 112 </div> 113 114 <p class="submit"> 115 <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> 116 </p> 77 117 </form> 78 <p class="submit">79 <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />80 </p>81 118 </div> 82 119 83 120 <?php 121 } 122 123 124 // use "suggest" for tag input 125 add_action('admin_print_scripts', 'jpl_docs_autotag_scripts'); 126 function jpl_docs_autotag_scripts() { 127 wp_enqueue_script( 'suggest' ); 128 } 129 130 add_action('admin_head', 'jpl_docs_autotag_admin_head'); 131 function jpl_docs_autotag_admin_head() { 132 ?> 133 <script type="text/javascript"> 134 jQuery(function() { 135 jQuery('.suggest').suggest("<?php echo get_bloginfo('wpurl'); ?>/wp-admin/admin-ajax.php?action=ajax-tag-search&tax=post_tag", {multiple:true, multipleSep: ","}); 136 }); 137 </script> 138 <?php 84 139 } 85 140 -
docs-auto-tags/trunk/lang/en_US.po
r372418 r372705 3 3 "Project-Id-Version: Doc's Auto Tag WordPress Plugin\n" 4 4 "Report-Msgid-Bugs-To: \n" 5 "POT-Creation-Date: 2011-04-1 2 23:57-1000\n"6 "PO-Revision-Date: 2011-04-1 2 23:58-1000\n"5 "POT-Creation-Date: 2011-04-13 12:43-1000\n" 6 "PO-Revision-Date: 2011-04-13 12:43-1000\n" 7 7 "Last-Translator: John <poedit@johnleblanc.com>\n" 8 8 "Language-Team: johnleblanc <wordpress@johnleblanc.com>\n" … … 16 16 "X-Poedit-SearchPath-1: .\n" 17 17 18 #: docs-auto-tags.php:71 18 #: ../trunk/docs-auto-tags.php:75 19 #: docs-auto-tags.php:75 19 20 msgid "Doc's Autotags" 20 21 msgstr "" 21 22 22 #: docs-auto-tags.php:77 23 #: ../trunk/docs-auto-tags.php:76 24 #: docs-auto-tags.php:76 25 msgid "Posts that include the (case-sensitive) string patterns defined below will be assigned the specified tag(s) when saved." 26 msgstr "" 27 28 #: ../trunk/docs-auto-tags.php:99 29 #: ../trunk/docs-auto-tags.php:109 30 #: docs-auto-tags.php:99 31 #: docs-auto-tags.php:109 32 msgid "Pattern" 33 msgstr "" 34 35 #: ../trunk/docs-auto-tags.php:100 36 #: ../trunk/docs-auto-tags.php:110 37 #: docs-auto-tags.php:100 38 #: docs-auto-tags.php:110 39 msgid "Tags" 40 msgstr "" 41 42 #: ../trunk/docs-auto-tags.php:115 43 #: docs-auto-tags.php:115 23 44 msgid "Save Changes" 24 45 msgstr "" -
docs-auto-tags/trunk/readme.txt
r372418 r372705 21 21 == Changelog == 22 22 23 = 0.2 = 24 Added management page 25 23 26 = 0.1 = 24 27 Initial Release
Note: See TracChangeset
for help on using the changeset viewer.