Plugin Directory

Changeset 194442


Ignore:
Timestamp:
01/16/2010 02:09:37 PM (16 years ago)
Author:
randomaniac
Message:

Submit v0.3.5 of Page Tagger plugin.

Location:
page-tagger/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • page-tagger/trunk/README.txt

    r185297 r194442  
    55Tags: tags, tagging, posts, pages
    66Requires at least: 2.8.4
    7 Tested up to: 2.9
    8 Stable tag: 0.3.4
     7Tested up to: 2.9.1
     8Stable tag: 0.3.5
    99
    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.
     10Page 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.
    1111
    1212== Description ==
    1313
    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.
     14Page 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.
    1515
    1616Detailed information including installation and usage is available at http://www.hiddentao.com/code/wordpress-page-tagger-plugin/
     
    2323
    2424== 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
    2529
    2630= 0.3.4 (Dec 20, 2009) =
  • page-tagger/trunk/page-tagger.js

    r185297 r194442  
     1/*
     2Page Tagger wordpress plugin
     3Copyright (C) 2009-2010 Ramesh Nair
     4
     5This program is free software: you can redistribute it and/or modify
     6it under the terms of the GNU General Public License as published by
     7the Free Software Foundation, either version 3 of the License, or
     8(at your option) any later version.
     9
     10This program is distributed in the hope that it will be useful,
     11but WITHOUT ANY WARRANTY; without even the implied warranty of
     12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13GNU General Public License for more details.
     14
     15You should have received a copy of the GNU General Public License
     16along with this program. If not, see <http://www.gnu.org/licenses/>.
     17*/
     18
    119/*
    220Plugin Name: Page Tagger
    321Plugin URI: http://www.hiddentao.com/code/wordpress-page-tagger-plugin/
    4 Description: Enables tagging for pages.
    5 Version: 0.3.4
     22Description: Enables tagging for pages. PHP 5 required.
     23Version: 0.3.5
    624Author: Ramesh Nair
    725Author URI: http://www.hiddentao.com/
     
    125143    });
    126144
    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 );
    130147
    131148    // catch the enter key
  • page-tagger/trunk/page-tagger.php

    r185297 r194442  
    22/*
    33Page Tagger wordpress plugin
    4 Copyright (C) 2009 Ramesh Nair
     4Copyright (C) 2009-2010 Ramesh Nair
    55
    66This program is free software: you can redistribute it and/or modify
     
    2121Plugin Name: Page Tagger
    2222Plugin URI: http://www.hiddentao.com/code/wordpress-page-tagger-plugin/
    23 Description: Enables tagging for pages.
    24 Version: 0.3.4
     23Description: Enables tagging for pages. PHP 5 required.
     24Version: 0.3.5
    2525Author: Ramesh Nair
    2626Author URI: http://www.hiddentao.com/
     
    2929
    3030// name of my parent folder
    31 define('PAGE_TAGS_PARENT_DIR', basename(dirname(__FILE__)) );
     31define('PAGE_TAGGER_PARENT_DIR', basename(dirname(__FILE__)) );
    3232
    3333
    3434/**
    35  * The class. Handles everything.
    36  */ 
    37 class PageTagger
     35 * Inform user of the minimum PHP version requird for Page Tagger.
     36 */
     37function _page_tagger_min_version_notice()
    3838{
    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}
    6041
    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 taxonomies
    79         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     }
    9042
    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
     44if (5 > intval(phpversion()))
     45{
     46    add_action('admin_notices', '_page_tagger_min_version_notice');
     47}
     48else
     49{
     50    require_once('page-tagger-class.php');
     51    add_action('plugins_loaded',array('PageTagger','init'));
    17752}
    17853
    17954
    18055
    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.