dikiyforester (September 6th, 2013), dubya (September 19th, 2013)
<?php /** * @package Quality_Control * @subpackage Ticket Taxonomies * @since Quality Control 0.2 */ class QC_Ticket_Milestone extends QC_Taxonomy { protected $mandatory = false; function __construct() { parent::__construct( 'ticket_product', 'product', array( 'name' => __( 'Products', APP_TD ), 'singular_name' => __( 'Product', APP_TD ), 'search_items' => __( 'Search Products', APP_TD ), 'popular_items' => __( 'Popular Products', APP_TD ), 'all_items' => __( 'All Products', APP_TD ), 'update_item' => __( 'Update Product', APP_TD ), 'add_new_item' => __( 'Add New Product', APP_TD ), 'new_item_name' => __( 'New Product Name', APP_TD ), 'edit_item' => __( 'Edit Product', APP_TD ) ) ); } } $ticket_milestone = new QC_Ticket_Milestone;
<?php /** * @package Quality_Control * @subpackage Ticket Taxonomies * @since Quality Control 0.2 */ class QC_Ticket_Tags extends QC_Taxonomy { function __construct() { parent::__construct( 'post_tag', 'tag', array( 'name' => __( 'Version', APP_TD ), 'singular_name' => __( 'Version', APP_TD ), 'search_items' => __( 'Search Versions', APP_TD ), 'popular_items' => __( 'Popular Versions', APP_TD ), 'all_items' => __( 'All Versions', APP_TD ), 'update_item' => __( 'Update Version', APP_TD ), 'add_new_item' => __( 'Add New Version', APP_TD ), 'new_item_name' => __( 'New Version Name', APP_TD ), 'edit_item' => __( 'Edit Version', APP_TD ) ) ); } /** * We don't want to add all the actions/filters as the * other taxonomies */ function actions() { add_action( 'init', array( $this, 'register_taxonomy' ) ); add_action( 'qc_ticket_fields_between', array( $this, 'ticket_meta' ) ); add_action( 'qc_create_ticket', array( $this, 'save_taxonomy_frontend' ), 10, 2 ); add_action( 'pre_comment_on_post', array( $this, 'update_taxonomy_frontend' ), 9 ); add_filter( 'manage_edit-ticket_columns', array( $this, 'manage_column_titles' ) ); add_action( 'manage_posts_custom_column', array( $this, 'manage_columns' ) ); } function save_taxonomy_frontend( $ticket_id, $ticket ) { wp_set_post_terms( $ticket_id, $ticket['ticket_tags'], $this->taxonomy ); } /** * When a comment has been created, the tags have to be checked slightly * differently. */ function update_taxonomy_frontend() { $ticket_id = $GLOBALS['post']->ID; $old = wp_get_post_terms( $ticket_id, 'post_tag', array( 'fields' => 'names' ) ); wp_set_post_terms( $ticket_id, $_POST['ticket_tags'], 'post_tag', false ); $new = wp_get_post_terms( $ticket_id, 'post_tag', array( 'fields' => 'names' ) ); $added = array_diff( $new, $old ); $deleted = array_diff( $old, $new ); $msg = _qc_get_message_diff( $added, $deleted ); if ( empty( $msg ) ) return; $msg = '<strong>' . __( 'Version', APP_TD ) . '</strong> ' . implode( '; ', $msg ) . '.'; // Store message for when we have a comment id self::$attr_changes[] = apply_filters( "qc_ticket_update_{$this->taxonomy}", $msg, $old_term, $new_term ); add_filter( 'qc_did_change_ticket', '__return_true' ); } /** * Override to add the tags class */ function ticket_meta( $exclude ) { global $post; // Only display on single pages $tax_object = get_taxonomy( $this->taxonomy ); echo'<li class="tags"> <small>' . $tax_object->labels->singular_name. '</small>'; if ( get_the_term_list( $post->ID, $this->taxonomy, '', ', ', '' ) ) echo get_the_term_list( $post->ID, $this->taxonomy, '', ', ', '' ); else echo'—'; echo'</li>'; } } $qc_ticket_tags = new QC_Ticket_Tags;
dikiyforester (September 6th, 2013), dubya (September 19th, 2013)
There are currently 1 users browsing this thread. (0 members and 1 guests)