Changeset 194442
- Timestamp:
- 01/16/2010 02:09:37 PM (16 years ago)
- Location:
- page-tagger/trunk
- Files:
-
- 1 added
- 3 edited
-
README.txt (modified) (2 diffs)
-
page-tagger-class.php (added)
-
page-tagger.js (modified) (2 diffs)
-
page-tagger.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
page-tagger/trunk/README.txt
r185297 r194442 5 5 Tags: tags, tagging, posts, pages 6 6 Requires at least: 2.8.4 7 Tested up to: 2.9 8 Stable tag: 0.3. 47 Tested up to: 2.9.1 8 Stable tag: 0.3.5 9 9 10 Page Tagger is a Wordpress plugin which lets you tag your pages just like you do with your posts. It adds a tagging widget in the page-editing view in the admin interface. 10 Page Tagger is a Wordpress plugin which lets you tag your pages just like you do with your posts. It adds a tagging widget in the page-editing view in the admin interface. Page Tagger requires PHP 5. 11 11 12 12 == Description == 13 13 14 Page Tagger is a Wordpress plugin which lets you tag your pages just like you do with your posts. It adds a tagging widget in the page-editing view in the admin interface. 14 Page Tagger is a Wordpress plugin which lets you tag your pages just like you do with your posts. It adds a tagging widget in the page-editing view in the admin interface. Page Tagger requires PHP 5. 15 15 16 16 Detailed information including installation and usage is available at http://www.hiddentao.com/code/wordpress-page-tagger-plugin/ … … 23 23 24 24 == Changelog == 25 26 = 0.3.5 (Jan 16, 2010) = 27 * When clicking 'Preview' button 'Add new tag' no longer gets added as a tag 28 * Updated documentation 25 29 26 30 = 0.3.4 (Dec 20, 2009) = -
page-tagger/trunk/page-tagger.js
r185297 r194442 1 /* 2 Page Tagger wordpress plugin 3 Copyright (C) 2009-2010 Ramesh Nair 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 1 19 /* 2 20 Plugin Name: Page Tagger 3 21 Plugin URI: http://www.hiddentao.com/code/wordpress-page-tagger-plugin/ 4 Description: Enables tagging for pages. 5 Version: 0.3. 422 Description: Enables tagging for pages. PHP 5 required. 23 Version: 0.3.5 6 24 Author: Ramesh Nair 7 25 Author URI: http://www.hiddentao.com/ … … 125 143 }); 126 144 127 // auto-save tags on post save/publish 128 jQuery('#publish').click( tag_save_on_publish ); 129 jQuery('#save-post').click( tag_save_on_publish ); 145 // auto-save tags on post preview/save/publish 146 jQuery('#post-preview, #save-post, #publish').click( tag_save_on_publish ); 130 147 131 148 // catch the enter key -
page-tagger/trunk/page-tagger.php
r185297 r194442 2 2 /* 3 3 Page Tagger wordpress plugin 4 Copyright (C) 2009 Ramesh Nair4 Copyright (C) 2009-2010 Ramesh Nair 5 5 6 6 This program is free software: you can redistribute it and/or modify … … 21 21 Plugin Name: Page Tagger 22 22 Plugin URI: http://www.hiddentao.com/code/wordpress-page-tagger-plugin/ 23 Description: Enables tagging for pages. 24 Version: 0.3. 423 Description: Enables tagging for pages. PHP 5 required. 24 Version: 0.3.5 25 25 Author: Ramesh Nair 26 26 Author URI: http://www.hiddentao.com/ … … 29 29 30 30 // name of my parent folder 31 define('PAGE_TAG S_PARENT_DIR', basename(dirname(__FILE__)) );31 define('PAGE_TAGGER_PARENT_DIR', basename(dirname(__FILE__)) ); 32 32 33 33 34 34 /** 35 * The class. Handles everything.36 */ 37 class PageTagger 35 * Inform user of the minimum PHP version requird for Page Tagger. 36 */ 37 function _page_tagger_min_version_notice() 38 38 { 39 static $instance = NULL; 40 41 static function init() 42 { 43 if (NULL == self::$instance) 44 self::$instance = new PageTagger(); 45 } 46 47 function PageTagger() 48 { 49 // if we're editing or adding a page 50 global $pagenow; 51 if ( isset($pagenow) && in_array( $pagenow, array('page.php', 'page-new.php') ) ) 52 { 53 add_action('admin_head',array(&$this, 'admin_head_hook') ); 54 } 55 56 add_action('pre_get_posts', array(&$this, 'setup_query_vars_for_posts'), 100); 57 add_action('init',array(&$this,'setup_tag_post_count_callback'),100); 58 } 59 39 echo "<div class='updated' style='background-color:#f99;'><p><strong>WARNING:</strong> Page Tagger plugin requires PHP 5 or above to work.</p></div>"; 40 } 60 41 61 62 63 /**64 * Stuff to do for the 'admin_head' hook.65 */66 function admin_head_hook()67 {68 wp_register_script('page-tagger', WP_PLUGIN_URL.'/'.PAGE_TAGS_PARENT_DIR.'/page-tagger.js', array('jquery','suggest'), false);69 wp_localize_script('page-tagger','pageTaggerL10n',70 array(71 'tagsUsed' => __('Tags used on this page:'),72 'addTag' => esc_attr(__('Add new tag')),73 )74 );75 wp_print_scripts('page-tagger');76 77 78 // all tag-style post taxonomies79 foreach ( get_object_taxonomies('post') as $tax_name )80 {81 if ( !is_taxonomy_hierarchical($tax_name) )82 {83 $taxonomy = get_taxonomy($tax_name);84 $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name;85 86 add_meta_box('tagsdiv-'.$tax_name, $label, array(&$this, 'add_tags_meta_box'), 'page', 'side', 'default');87 }88 }89 }90 42 91 92 93 /** 94 * Setup the callback that will get used for counting the no. of posts 95 * associated with a tag. 96 * @return unknown_type 97 */ 98 function setup_tag_post_count_callback() 99 { 100 // override default tag count update callback 101 $tag = get_taxonomy('post_tag'); 102 if (!empty($tag)) 103 { 104 $tag->update_count_callback = array(&$this, '_update_post_term_count'); 105 } 106 } 107 108 109 /** 110 * Set the Wordpress query variables (this determines what gets loaded 111 * from the db). 112 */ 113 function setup_query_vars_for_posts(&$query) 114 { 115 // if we're viewing tag archives 116 if ($query->is_archive && $query->is_tag) 117 { 118 $q = &$query->query_vars; 119 120 // set the post-type to 'any' so that pages are also included 121 $q['post_type'] = 'any'; 122 } 123 } 124 125 126 127 128 /** 129 * Display page tags form fields. 130 * 131 * This is coped from wp-admin/edit-form-advanced.php. 132 * 133 * @param object $post 134 */ 135 function add_tags_meta_box($post, $box) 136 { 137 $tax_name = esc_attr(substr($box['id'], 8)); 138 $taxonomy = get_taxonomy($tax_name); 139 $helps = isset($taxonomy->helps) ? esc_attr($taxonomy->helps) : __('Separate tags with commas.'); 140 ?> 141 <div class="tagsdiv" id="<?php echo $tax_name ?>"> 142 <div class="jaxtag"> 143 <div class="nojs-tags hide-if-js"> 144 <p><?php _e('Add or remove tags'); ?></p> 145 <textarea name="<?php echo "tax_input[$tax_name]"; ?>" class="the-tags" id="tax-input[<?php echo $tax_name; ?>]"><?php echo esc_attr(get_terms_to_edit( $post->ID, $tax_name )); ?></textarea></div> 146 147 <span class="ajaxtag hide-if-no-js"> 148 <label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label> 149 <input type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" value="<?php esc_attr_e('Add new tag'); ?>" /> 150 <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" /> 151 </span></div> 152 <p class="howto"><?php echo $helps; ?></p> 153 <div class="tagchecklist"></div> 154 </div> 155 <p class="tagcloud-link hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php printf( __('Choose from the most used tags in %s'), $box['title'] ); ?></a></p> 156 <?php 157 } 158 159 160 161 162 /** 163 * Custom version of the Wordpress taxonomy 'update term count' callback method. 164 * 165 * This will update term count pased on posts AS WELL AS pages. 166 * @param array $terms List of Term taxonomy IDs 167 */ 168 function _update_post_term_count( $terms ) 169 { 170 global $wpdb; 171 foreach ( (array) $terms as $term ) { 172 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND (post_type = 'post' OR post_type = 'page') AND term_taxonomy_id = %d", $term ) ); 173 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); 174 } 175 } 176 43 // need atleast PHP 5 44 if (5 > intval(phpversion())) 45 { 46 add_action('admin_notices', '_page_tagger_min_version_notice'); 47 } 48 else 49 { 50 require_once('page-tagger-class.php'); 51 add_action('plugins_loaded',array('PageTagger','init')); 177 52 } 178 53 179 54 180 55 181 182 183 /**184 * Initialise PageTags object.185 */186 add_action('plugins_loaded',array('PageTagger','init'));187
Note: See TracChangeset
for help on using the changeset viewer.