Skip to:
Content

bbPress.org

Changeset 3348


Ignore:
Timestamp:
06/24/2011 07:01:46 AM (11 years ago)
Author:
johnjamesjacoby
Message:

Topic tag audit. Split topic tag edit form into its own template file. Rename the topic_tag_id global to topic_tag_tax_id. Add missing topic tag template tags and functions.

Location:
branches/plugin
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-admin/bbp-metaboxes.php

    r3341 r3348  
    103103                    $text = _n( 'Topic Tag', 'Topic Tags', $topic_tag_count, 'bbpress' );
    104104                    if ( current_user_can( 'manage_topic_tags' ) ) {
    105                         $link = add_query_arg( array( 'taxonomy' => $bbp->topic_tag_id, 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) );
     105                        $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) );
    106106                        $num  = '<a href="' . $link . '">' . $num  . '</a>';
    107107                        $text = '<a href="' . $link . '">' . $text . '</a>';
     
    189189                        $num  = $empty_topic_tag_count;
    190190                        $text = _n( 'Empty Topic Tag', 'Empty Topic Tags', $empty_topic_tag_count, 'bbpress' );
    191                         $link = add_query_arg( array( 'taxonomy' => $bbp->topic_tag_id, 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) );
     191                        $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) );
    192192                        $num  = '<a href="' . $link . '">' . $num  . '</a>';
    193193                        $text = '<a class="waiting" href="' . $link . '">' . $text . '</a>';
  • branches/plugin/bbp-admin/bbp-topics.php

    r3343 r3348  
    212212        // Add help
    213213        global $bbp;
    214         add_contextual_help( 'edit-' . $bbp->topic_tag_id, $contextual_help );
     214        add_contextual_help( 'edit-' . bbp_get_topic_tag_tax_id(), $contextual_help );
    215215    }
    216216
  • branches/plugin/bbp-includes/bbp-common-functions.php

    r3336 r3348  
    480480
    481481        // Get the count
    482         $topic_tag_count = wp_count_terms( $bbp->topic_tag_id, array( 'hide_empty' => true ) );
     482        $topic_tag_count = wp_count_terms( bbp_get_topic_tag_tax_id(), array( 'hide_empty' => true ) );
    483483
    484484        // Empty tags
    485485        if ( !empty( $count_empty_tags ) && current_user_can( 'edit_topic_tags' ) ) {
    486             $empty_topic_tag_count = wp_count_terms( $bbp->topic_tag_id ) - $topic_tag_count;
     486            $empty_topic_tag_count = wp_count_terms( bbp_get_topic_tag_tax_id() ) - $topic_tag_count;
    487487        }
    488488    }
  • branches/plugin/bbp-includes/bbp-common-template.php

    r3344 r3348  
    234234 */
    235235function bbp_is_topic_tag() {
    236     global $bbp;
    237 
    238     if ( is_tax( $bbp->topic_tag_id ) )
     236
     237    if ( is_tax( bbp_get_topic_tag_tax_id() ) )
     238        return true;
     239
     240    return false;
     241}
     242
     243/**
     244 * Check if the current page is editing a topic tag
     245 *
     246 * @since bbPress (r3346)
     247 *
     248 * @uses WP_Query Checks if WP_Query::bbp_is_topic_tag_edit is true
     249 * @return bool True if editing a topic tag, false if not
     250 */
     251function bbp_is_topic_tag_edit() {
     252    global $wp_query;
     253
     254    if ( !empty( $wp_query->bbp_is_topic_tag_edit ) && ( true == $wp_query->bbp_is_topic_tag_edit ) )
    239255        return true;
    240256
     
    14501466            $pre_current_text = sprintf( __( 'Topic Tag: %s', 'bbpress' ), bbp_get_topic_tag_name() );
    14511467
     1468        // Edit Topic Tag
     1469        elseif ( bbp_is_topic_tag_edit() )
     1470            $pre_current_text = __( 'Edit', 'bbpress' );
     1471
    14521472        // Single
    14531473        else
     
    15381558                }
    15391559            }
     1560
     1561        // Edit topic tag
     1562        } elseif ( bbp_is_topic_tag_edit() ) {
     1563            $breadcrumbs[] = '<a href="' . get_term_link( bbp_get_topic_tag_id(), bbp_get_topic_tag_tax_id() ) . '">' . sprintf( __( 'Topic Tag: %s', 'bbpress' ), bbp_get_topic_tag_name() ) . '</a>';
    15401564        }
    15411565
  • branches/plugin/bbp-includes/bbp-core-akismet.php

    r3308 r3348  
    540540
    541541        // Get any pre-existing terms
    542         $existing_terms = wp_get_object_terms( $topic_id, $bbp->topic_tag_id, array( 'fields' => 'names' ) );
     542        $existing_terms = wp_get_object_terms( $topic_id, bbp_get_topic_tag_tax_id(), array( 'fields' => 'names' ) );
    543543
    544544        // Save the terms for later in case the reply gets hammed
  • branches/plugin/bbp-includes/bbp-core-compatibility.php

    r3344 r3348  
    601601    $templates = bbp_set_theme_compat_templates( $templates );
    602602   
     603    $template  = locate_template( $templates, false, false );
     604    $template  = bbp_set_theme_compat_template( $template );
     605
     606    return $template;
     607}
     608
     609/**
     610 * Get the topic edit template
     611 *
     612 * @since bbPress (r3311)
     613 *
     614 * @uses bbp_get_topic_post_type()
     615 * @uses apply_filters()
     616 *
     617 * @return array
     618 */
     619function bbp_get_topic_tag_edit_template() {
     620
     621    $tt_id = bbp_get_topic_tag_tax_id();
     622    $templates = array(
     623
     624        // Single Topic Tag Edit
     625        'taxonomy-'         . $tt_id . '-edit.php',
     626        'bbpress/taxonomy-' . $tt_id . '-edit.php',
     627        'forums/taxonomy-'  . $tt_id . '-edit.php',
     628
     629        // Single Topic Tag
     630        'taxonomy-'         . $tt_id . '.php',
     631        'forums/taxonomy-'  . $tt_id . '.php',
     632        'bbpress/taxonomy-' . $tt_id . '.php',
     633    );
     634
     635    $templates = apply_filters( 'bbp_get_topic_tag_edit_template', $templates );
     636    $templates = bbp_set_theme_compat_templates( $templates );
     637
    603638    $template  = locate_template( $templates, false, false );
    604639    $template  = bbp_set_theme_compat_template( $template );
     
    697732        // Editing a reply
    698733        elseif ( bbp_is_reply_edit()        && ( $new_template = bbp_get_reply_edit_template()        ) ) :
     734
     735        // Editing a topic tag
     736        elseif ( bbp_is_topic_tag_edit()    && ( $new_template = bbp_get_topic_tag_edit_template()    ) ) :
    699737        endif;
    700738
     
    818856
    819857        /** Topic Tags ********************************************************/
     858
     859        } elseif ( bbp_is_topic_tag_edit() ) {
     860
     861            // Stash the current term in a new var
     862            set_query_var( 'bbp_topic_tag', get_query_var( 'term' ) );
     863
     864            // Reset the post with our new title
     865            bbp_theme_compat_reset_post( array(
     866                'post_title' => sprintf( __( 'Edit Topic Tag: %s', 'bbpress' ), '<span>' . bbp_get_topic_tag_name() . '</span>' ),
     867            ) );
    820868
    821869        } elseif ( bbp_is_topic_tag() ) {
     
    10191067
    10201068        } elseif ( get_query_var( 'bbp_topic_tag' ) ) {
    1021             $new_content = $bbp->shortcodes->display_topics_of_tag( array( 'id' => bbp_get_topic_tag_id() ) );
     1069
     1070            // Edit topic tag
     1071            if ( bbp_is_topic_tag_edit() ) {
     1072                $new_content = $bbp->shortcodes->display_topic_tag_form();
     1073
     1074            // Show topics of tag
     1075            } else {
     1076                $new_content = $bbp->shortcodes->display_topics_of_tag ( array( 'id' => bbp_get_topic_tag_id() ) );
     1077            }
    10221078
    10231079        /** Forums/Topics/Replies *********************************************/
     
    14421498            $posts_query->bbp_is_reply_edit = true;
    14431499
     1500        // We are editing a topic tag
     1501        elseif ( bbp_is_topic_tag() )
     1502            $posts_query->bbp_is_topic_tag_edit = true;
     1503
    14441504        // We save post revisions on our own
    14451505        remove_action( 'pre_post_update', 'wp_save_post_revision' );
  • branches/plugin/bbp-includes/bbp-core-shortcodes.php

    r3344 r3348  
    577577     * @since bbPress (r3110)
    578578     *
    579      * @global bbPress $bbp
    580      *
    581579     * @return string
    582580     */
    583581    public function display_topic_tags() {
    584         global $bbp;
    585582
    586583        // Unset globals
     
    595592            'largest'  => 38,
    596593            'number'   => 80,
    597             'taxonomy' => $bbp->topic_tag_id
     594            'taxonomy' => bbp_get_topic_tag_tax_id()
    598595        ) );
    599596
     
    607604     *
    608605     * @since bbPress (r3110)
    609      *
    610      * @global bbPress $bbp
    611606     *
    612607     * @param array $attr
     
    617612     */
    618613    public function display_topics_of_tag( $attr, $content = '' ) {
    619         global $bbp;
    620614
    621615        // Sanity check required info
     
    628622        // Setup tax query
    629623        $args = array( 'tax_query' => array( array(
    630             'taxonomy' => $bbp->topic_tag_id,
     624            'taxonomy' => bbp_get_topic_tag_tax_id(),
    631625            'field'    => 'id',
    632626            'terms'    => $tag_id
     
    646640
    647641        // Before tag topics
    648         do_action( 'bbp_template_before_tag_topics' );
     642        do_action( 'bbp_template_before_topic_tag' );
    649643
    650644        // Load the topics
    651645        if ( bbp_has_topics( $args ) ) {
    652 
    653             // Template files
    654646            bbp_get_template_part( 'bbpress/pagination', 'topics'    );
    655647            bbp_get_template_part( 'bbpress/loop',       'topics'    );
    656648            bbp_get_template_part( 'bbpress/pagination', 'topics'    );
    657             bbp_get_template_part( 'bbpress/form',       'topic-tag' );
    658649
    659650        // No topics
     
    663654
    664655        // After tag topics
    665         do_action( 'bbp_template_after_tag_topics' );
     656        do_action( 'bbp_template_after_topic_tag' );
     657
     658        // Return contents of output buffer
     659        return $this->end();
     660    }
     661
     662    /**
     663     * Display the contents of a specific topic tag in an output buffer
     664     * and return to ensure that post/page contents are displayed first.
     665     *
     666     * @since bbPress (r3346)
     667     *
     668     * @param array $attr
     669     * @param string $content
     670     * @uses current_theme_supports()
     671     * @uses get_template_part()
     672     * @return string
     673     */
     674    public function display_topic_tag_form() {
     675
     676        // Unset globals
     677        $this->unset_globals();
     678
     679        // Start output buffer
     680        $this->start( 'bbp_topic_tag_edit' );
     681
     682        // Breadcrumb
     683        bbp_breadcrumb();
     684
     685        // Tag description
     686        bbp_topic_tag_description();
     687
     688        // Before tag topics
     689        do_action( 'bbp_template_before_topic_tag_edit' );
     690
     691        // Tag editing form
     692        bbp_get_template_part( 'bbpress/form', 'topic-tag' );
     693
     694        // After tag topics
     695        do_action( 'bbp_template_after_topic_tag_edit' );
    666696
    667697        // Return contents of output buffer
  • branches/plugin/bbp-includes/bbp-reply-functions.php

    r3344 r3348  
    274274
    275275                // Insert terms
    276                 $terms = wp_set_post_terms( $topic_id, $terms, $bbp->topic_tag_id, false );
     276                $terms = wp_set_post_terms( $topic_id, $terms, bbp_get_topic_tag_tax_id(), false );
    277277
    278278                // Term error
     
    501501
    502502            // Insert terms
    503             $terms = wp_set_post_terms( $topic_id, $terms, $bbp->topic_tag_id, false );
     503            $terms = wp_set_post_terms( $topic_id, $terms, bbp_get_topic_tag_tax_id(), false );
    504504
    505505            // Term error
  • branches/plugin/bbp-includes/bbp-topic-functions.php

    r3344 r3348  
    5858        $forum_id = $topic_author = $anonymous_data = 0;
    5959        $topic_title = $topic_content = '';
    60         $terms = array( $bbp->topic_tag_id => array() );
     60        $terms = array( bbp_get_topic_tag_tax_id() => array() );
    6161
    6262        /** Topic Author ******************************************************/
     
    168168
    169169            // Add topic tag ID as main key
    170             $terms = array( $bbp->topic_tag_id => $terms );
     170            $terms = array( bbp_get_topic_tag_tax_id() => $terms );
    171171        }
    172172
     
    329329        $topic_id = $forum_id = $anonymous_data = 0;
    330330        $topic_title = $topic_content = $topic_edit_reason = '';
    331         $terms = array( $bbp->topic_tag_id => array() );
     331        $terms = array( bbp_get_topic_tag_tax_id() => array() );
    332332
    333333        /** Topic *************************************************************/
     
    440440
    441441            // Add topic tag ID as main key
    442             $terms = array( $bbp->topic_tag_id => $terms );
     442            $terms = array( bbp_get_topic_tag_tax_id() => $terms );
    443443        }
    444444
     
    941941
    942942            // Get the source topic tags
    943             $source_topic_tags = wp_get_post_terms( $source_topic->ID, $bbp->topic_tag_id, array( 'fields' => 'names' ) );
     943            $source_topic_tags = wp_get_post_terms( $source_topic->ID, bbp_get_topic_tag_tax_id(), array( 'fields' => 'names' ) );
    944944
    945945            // Tags to possibly merge
     
    948948                // Shift the tags if told to
    949949                if ( !empty( $_POST['bbp_topic_tags'] ) && ( 1 == $_POST['bbp_topic_tags'] ) )
    950                     wp_set_post_terms( $destination_topic->ID, $source_topic_tags, $bbp->topic_tag_id, true );
     950                    wp_set_post_terms( $destination_topic->ID, $source_topic_tags, bbp_get_topic_tag_tax_id(), true );
    951951
    952952                // Delete the tags from the source topic
    953                 wp_delete_object_term_relationships( $source_topic->ID, $bbp->topic_tag_id );
     953                wp_delete_object_term_relationships( $source_topic->ID, bbp_get_topic_tag_tax_id() );
    954954            }
    955955
     
    12621262
    12631263                // Get the source topic tags
    1264                 if ( $source_topic_tags = wp_get_post_terms( $source_topic->ID, $bbp->topic_tag_id, array( 'fields' => 'names' ) ) ) {
    1265                     wp_set_post_terms( $destination_topic->ID, $source_topic_tags, $bbp->topic_tag_id, true );
     1264                if ( $source_topic_tags = wp_get_post_terms( $source_topic->ID, bbp_get_topic_tag_tax_id(), array( 'fields' => 'names' ) ) ) {
     1265                    wp_set_post_terms( $destination_topic->ID, $source_topic_tags, bbp_get_topic_tag_tax_id(), true );
    12661266                }
    12671267            }
     
    13951395        $action = $_POST['action'];
    13961396        $tag_id = (int) $_POST['tag-id'];
    1397         $tag    = get_term( $tag_id, $bbp->topic_tag_id );
     1397        $tag    = get_term( $tag_id, bbp_get_topic_tag_tax_id() );
    13981398
    13991399        // Tag does not exist
     
    14261426                // Attempt to update the tag
    14271427                $slug = !empty( $_POST['tag-slug'] ) ? $_POST['tag-slug'] : '';
    1428                 $tag  = wp_update_term( $tag_id, $bbp->topic_tag_id, array( 'name' => $name, 'slug' => $slug ) );
     1428                $tag  = wp_update_term( $tag_id, bbp_get_topic_tag_tax_id(), array( 'name' => $name, 'slug' => $slug ) );
    14291429
    14301430                // Cannot update tag
     
    14351435
    14361436                // Redirect
    1437                 $redirect = get_term_link( $tag_id, $bbp->topic_tag_id );
     1437                $redirect = get_term_link( $tag_id, bbp_get_topic_tag_tax_id() );
    14381438
    14391439                // Update counts, etc...
     
    14611461
    14621462                // If term does not exist, create it
    1463                 if ( !$tag = term_exists( $name, $bbp->topic_tag_id ) )
    1464                     $tag = wp_insert_term( $name, $bbp->topic_tag_id );
     1463                if ( !$tag = term_exists( $name, bbp_get_topic_tag_tax_id() ) )
     1464                    $tag = wp_insert_term( $name, bbp_get_topic_tag_tax_id() );
    14651465
    14661466                // Problem inserting the new term
     
    14801480
    14811481                // Delete the old term
    1482                 $tag = wp_delete_term( $tag_id, $bbp->topic_tag_id, array( 'default' => $to_tag, 'force_default' => true ) );
     1482                $tag = wp_delete_term( $tag_id, bbp_get_topic_tag_tax_id(), array( 'default' => $to_tag, 'force_default' => true ) );
    14831483
    14841484                // Error merging the terms
     
    14891489
    14901490                // Redirect
    1491                 $redirect = get_term_link( (int) $to_tag, $bbp->topic_tag_id );
     1491                $redirect = get_term_link( (int) $to_tag, bbp_get_topic_tag_tax_id() );
    14921492
    14931493                // Update counts, etc...
     
    15091509
    15101510                // Attempt to delete term
    1511                 $tag = wp_delete_term( $tag_id, $bbp->topic_tag_id );
     1511                $tag = wp_delete_term( $tag_id, bbp_get_topic_tag_tax_id() );
    15121512
    15131513                // Error deleting term
     
    15301530        // Redirect back
    15311531        $redirect = ( !empty( $redirect ) && !is_wp_error( $redirect ) ) ? $redirect : home_url();
    1532         wp_redirect( $redirect );
     1532        wp_safe_redirect( $redirect );
    15331533
    15341534        // For good measure
  • branches/plugin/bbp-includes/bbp-topic-template.php

    r3344 r3348  
    17921792     */
    17931793    function bbp_get_topic_tag_list( $topic_id = 0, $args = '' ) {
    1794         global $bbp;
    17951794
    17961795        $defaults = array(
     
    18051804        $topic_id = bbp_get_topic_id( $topic_id );
    18061805
    1807         return get_the_term_list( $topic_id, $bbp->topic_tag_id, $before, $sep, $after );
     1806        return get_the_term_list( $topic_id, bbp_get_topic_tag_tax_id(), $before, $sep, $after );
    18081807    }
    18091808
     
    26532652
    26542653/**
     2654 * Output the unique id of the topic tag taxonomy
     2655 *
     2656 * @since bbPress (r3348)
     2657 *
     2658 * @uses bbp_get_topic_post_type() To get the topic post type
     2659 */
     2660function bbp_topic_tag_tax_id() {
     2661    echo bbp_get_topic_tag_tax_id();
     2662}
     2663    /**
     2664     * Return the unique id of the topic tag taxonomy
     2665     *
     2666     * @since bbPress (r3348)
     2667     *
     2668     * @uses apply_filters() Calls 'bbp_get_topic_tag_tax_id' with the topic tax id
     2669     * @return string The unique topic tag taxonomy
     2670     */
     2671    function bbp_get_topic_tag_tax_id() {
     2672        global $bbp;
     2673
     2674        return apply_filters( 'bbp_get_topic_tag_tax_id', $bbp->topic_tag_tax_id );
     2675    }
     2676
     2677/**
    26552678 * Output the id of the current tag
    26562679 *
     
    26592682 * @uses bbp_get_topic_tag_id()
    26602683 */
    2661 function bbp_topic_tag_id() {
    2662     echo bbp_get_topic_tag_id();
     2684function bbp_topic_tag_id( $tag = '' ) {
     2685    echo bbp_get_topic_tag_id( $tag );
    26632686}
    26642687    /**
     
    26732696     * @return string Term Name
    26742697     */
    2675     function bbp_get_topic_tag_id() {
     2698    function bbp_get_topic_tag_id( $tag = '' ) {
    26762699
    26772700        // Get the term
    2678         $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
     2701        $tag  = !empty( $tag ) ? $tag : get_query_var( 'term' );
     2702        $term = get_term_by( 'slug', $tag, bbp_get_topic_tag_tax_id() );
    26792703
    26802704        // Add before and after if description exists
     
    26862710            $retval = '';
    26872711
    2688         return apply_filters( 'bbp_get_topic_tag_id', $retval );
     2712        return apply_filters( 'bbp_get_topic_tag_id', (int) $retval );
    26892713    }
    26902714
     
    26962720 * @uses bbp_get_topic_tag_name()
    26972721 */
    2698 function bbp_topic_tag_name() {
    2699     echo bbp_get_topic_tag_name();
     2722function bbp_topic_tag_name( $tag = '' ) {
     2723    echo bbp_get_topic_tag_name( $tag );
    27002724}
    27012725    /**
     
    27102734     * @return string Term Name
    27112735     */
    2712     function bbp_get_topic_tag_name() {
     2736    function bbp_get_topic_tag_name( $tag = '' ) {
    27132737
    27142738        // Get the term
    2715         $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
     2739        $tag  = !empty( $tag ) ? $tag : get_query_var( 'term' );
     2740        $term = get_term_by( 'slug', $tag, bbp_get_topic_tag_tax_id() );
    27162741
    27172742        // Add before and after if description exists
     
    27332758 * @uses bbp_get_topic_tag_slug()
    27342759 */
    2735 function bbp_topic_tag_slug() {
    2736     echo bbp_get_topic_tag_slug();
     2760function bbp_topic_tag_slug( $tag = '' ) {
     2761    echo bbp_get_topic_tag_slug( $tag );
    27372762}
    27382763    /**
     
    27472772     * @return string Term Name
    27482773     */
    2749     function bbp_get_topic_tag_slug() {
     2774    function bbp_get_topic_tag_slug( $tag = '' ) {
    27502775
    27512776        // Get the term
    2752         $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
     2777        $tag  = !empty( $tag ) ? $tag : get_query_var( 'term' );
     2778        $term = get_term_by( 'slug', $tag, bbp_get_topic_tag_tax_id() );
    27532779
    27542780        // Add before and after if description exists
     
    27642790
    27652791/**
    2766  * Output the description of the current tag
    2767  *
    2768  * @since bbPress (r3109)
    2769  *
    2770  * @uses bbp_get_topic_tag_description()
    2771  */
    2772 function bbp_topic_tag_description( $args = array() ) {
    2773     echo bbp_get_topic_tag_description( $args );
    2774 }
    2775     /**
    2776      * Return the description of the current tag
    2777      *
    2778      * @since bbPress (r3109)
     2792 * Output the link of the current tag
     2793 *
     2794 * @since bbPress (r3348)
     2795 *
     2796 * @uses bbp_get_topic_tag_link()
     2797 */
     2798function bbp_topic_tag_link( $tag = '' ) {
     2799    echo bbp_get_topic_tag_link( $tag );
     2800}
     2801    /**
     2802     * Return the link of the current tag
     2803     *
     2804     * @since bbPress (r3348)
    27792805     *
    27802806     * @uses get_term_by()
     
    27842810     * @return string Term Name
    27852811     */
     2812    function bbp_get_topic_tag_link( $tag = '' ) {
     2813
     2814        // Get the term
     2815        $tag  = !empty( $tag ) ? $tag : get_query_var( 'term' );
     2816        $term = get_term_by( 'slug', $tag, bbp_get_topic_tag_tax_id() );
     2817
     2818        // Add before and after if description exists
     2819        if ( !empty( $term->term_id ) )
     2820            $retval = get_term_link( $term->term_id, bbp_get_topic_tag_tax_id() );
     2821
     2822        // No link
     2823        else
     2824            $retval = '';
     2825
     2826        return apply_filters( 'bbp_get_topic_tag_link', $retval );
     2827    }
     2828
     2829/**
     2830 * Output the link of the current tag
     2831 *
     2832 * @since bbPress (r3348)
     2833 *
     2834 * @uses bbp_get_topic_tag_edit_link()
     2835 */
     2836function bbp_topic_tag_edit_link( $tag = '' ) {
     2837    echo bbp_get_topic_tag_edit_link( $tag );
     2838}
     2839    /**
     2840     * Return the link of the current tag
     2841     *
     2842     * @since bbPress (r3348)
     2843     *
     2844     * @uses get_term_by()
     2845     * @uses get_query_var()
     2846     * @uses apply_filters()
     2847     *
     2848     * @return string Term Name
     2849     */
     2850    function bbp_get_topic_tag_edit_link( $tag = '' ) {
     2851        global $wp_query;
     2852
     2853        // Get the term
     2854        $tag  = !empty( $tag ) ? $tag : get_query_var( 'term' );
     2855        $term = get_term_by( 'slug', $tag, bbp_get_topic_tag_tax_id() );
     2856
     2857        // Add before and after if description exists
     2858        if ( !empty( $term->term_id ) ) {
     2859
     2860            // Pretty
     2861            if ( $wp_rewrite->using_permalinks() ) {
     2862                $retval = user_trailingslashit( trailingslashit( bbp_get_topic_tag_link() ) . 'edit' );
     2863
     2864            // Ugly
     2865            } else {
     2866                $retval = add_query_arg( array( 'paged' => '%#%' ), bbp_get_topic_tag_link() );
     2867            }
     2868
     2869        // No link
     2870        } else {
     2871            $retval = '';
     2872        }
     2873
     2874        return apply_filters( 'bbp_get_topic_tag_edit_link', $retval );
     2875    }
     2876
     2877/**
     2878 * Output the description of the current tag
     2879 *
     2880 * @since bbPress (r3109)
     2881 *
     2882 * @uses bbp_get_topic_tag_description()
     2883 */
     2884function bbp_topic_tag_description( $args = array() ) {
     2885    echo bbp_get_topic_tag_description( $args );
     2886}
     2887    /**
     2888     * Return the description of the current tag
     2889     *
     2890     * @since bbPress (r3109)
     2891     *
     2892     * @uses get_term_by()
     2893     * @uses get_query_var()
     2894     * @uses apply_filters()
     2895     *
     2896     * @return string Term Name
     2897     */
    27862898    function bbp_get_topic_tag_description( $args = array() ) {
    27872899        global $bbp;
     
    27892901        $defaults = array(
    27902902            'before' => '<div class="bbp-topic-tag-description"><p>',
    2791             'after'  => '</p></div>'
     2903            'after'  => '</p></div>',
     2904            'tag'    => ''
    27922905        );
    27932906        $r = wp_parse_args( $args, $defaults );
     
    27952908
    27962909        // Get the term
    2797         $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
     2910        $tag  = !empty( $tag ) ? $tag : get_query_var( 'term' );
     2911        $term = get_term_by( 'slug', $tag, bbp_get_topic_tag_tax_id() );
    27982912
    27992913        // Add before and after if description exists
     
    29213035
    29223036            // Topic exists and has tags
    2923             if ( !empty( $topic_id ) && ( $terms = get_the_terms( $topic_id, $bbp->topic_tag_id ) ) ) {
     3037            if ( !empty( $topic_id ) && ( $terms = get_the_terms( $topic_id, bbp_get_topic_tag_tax_id() ) ) ) {
    29243038
    29253039                // Loop through them
  • branches/plugin/bbp-themes/bbp-twentyten/page-topic-tags.php

    r3241 r3348  
    2929                            <div id="bbp-topic-hot-tags">
    3030
    31                                 <?php wp_tag_cloud( array( 'smallest' => 9, 'largest' => 38, 'number' => 80, 'taxonomy' => $bbp->topic_tag_id ) ); ?>
     31                                <?php wp_tag_cloud( array( 'smallest' => 9, 'largest' => 38, 'number' => 80, 'taxonomy' => bbp_get_topic_tag_tax_id() ) ); ?>
    3232
    3333                            </div>
  • branches/plugin/bbp-themes/bbp-twentyten/taxonomy-topic-tag.php

    r3345 r3348  
    4242                        <?php endif; ?>
    4343
    44                         <?php bbp_get_template_part( 'bbpress/form', 'topic-tag' ); ?>
    45 
    4644                        <?php do_action( 'bbp_template_after_topic_tag' ); ?>
    4745
  • branches/plugin/bbpress.php

    r3341 r3348  
    6262     * @public string Topic tag id
    6363     */
    64     public $topic_tag_id = '';
     64    public $topic_tag_tax_id = '';
    6565
    6666    /** Permastructs **********************************************************/
     
    324324
    325325        // Post type identifiers
    326         $this->forum_post_type    = apply_filters( 'bbp_forum_post_type', 'forum'     );
    327         $this->topic_post_type    = apply_filters( 'bbp_topic_post_type', 'topic'     );
    328         $this->reply_post_type    = apply_filters( 'bbp_reply_post_type', 'reply'     );
    329         $this->topic_tag_id       = apply_filters( 'bbp_topic_tag_id',    'topic-tag' );
     326        $this->forum_post_type    = apply_filters( 'bbp_forum_post_type',  'forum'     );
     327        $this->topic_post_type    = apply_filters( 'bbp_topic_post_type',  'topic'     );
     328        $this->reply_post_type    = apply_filters( 'bbp_reply_post_type',  'reply'     );
     329        $this->topic_tag_tax_id   = apply_filters( 'bbp_topic_tag_tax_id', 'topic-tag' );
    330330
    331331        // Status identifiers
     
    844844        // Register the topic tag taxonomy
    845845        register_taxonomy(
    846             $this->topic_tag_id,    // The topic tag id
    847             $this->topic_post_type, // The topic post type
     846            $this->topic_tag_tax_id, // The topic tag id
     847            $this->topic_post_type,  // The topic post type
    848848            $bbp_tt
    849849        );
     
    928928
    929929            // Edit Topic/Reply
    930             $this->topic_slug . '/([^/]+)/edit/?$' => 'index.php?' . $this->topic_post_type . '=' . $wp_rewrite->preg_index( 1 ) . '&edit=1',
    931             $this->reply_slug . '/([^/]+)/edit/?$' => 'index.php?' . $this->reply_post_type . '=' . $wp_rewrite->preg_index( 1 ) . '&edit=1',
    932 
    933             // @todo Edit Topic Tag
    934             //$this->topic_tag_slug . '/([^/]+)/edit/?$' => 'index.php?' . $this->topic_tag_id . '=' . $wp_rewrite->preg_index( 1 ) . '&edit=1',
     930            $this->topic_slug     . '/([^/]+)/edit/?$' => 'index.php?' . $this->topic_post_type . '=' . $wp_rewrite->preg_index( 1 ) . '&edit=1',
     931            $this->reply_slug     . '/([^/]+)/edit/?$' => 'index.php?' . $this->reply_post_type . '=' . $wp_rewrite->preg_index( 1 ) . '&edit=1',
     932
     933            // Edit Topic Tag
     934            $this->topic_tag_slug . '/([^/]+)/edit/?$' => 'index.php?' . $this->topic_tag_tax_id . '=' . $wp_rewrite->preg_index( 1 ) . '&edit=1',
    935935
    936936            // Profile Page
    937             $this->user_slug . '/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?' . $this->user_id . '=' . $wp_rewrite->preg_index( 1 ) . '&paged=' . $wp_rewrite->preg_index( 2 ),
    938             $this->user_slug . '/([^/]+)/?$'                   => 'index.php?' . $this->user_id . '=' . $wp_rewrite->preg_index( 1 ),
    939             $this->user_slug . '/([^/]+)/edit/?$'              => 'index.php?' . $this->user_id . '=' . $wp_rewrite->preg_index( 1 ) . '&edit=1',
     937            $this->user_slug      . '/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?' . $this->user_id . '=' . $wp_rewrite->preg_index( 1 ) . '&paged=' . $wp_rewrite->preg_index( 2 ),
     938            $this->user_slug      . '/([^/]+)/?$'                   => 'index.php?' . $this->user_id . '=' . $wp_rewrite->preg_index( 1 ),
     939            $this->user_slug      . '/([^/]+)/edit/?$'              => 'index.php?' . $this->user_id . '=' . $wp_rewrite->preg_index( 1 ) . '&edit=1',
    940940
    941941            // @todo - favorites feeds
    942             //$this->user_slug . '/([^/]+)/(feed|rdf|rss|rss2|atom)/?$'      => 'index.php?' . $this->user_id . '=' . $wp_rewrite->preg_index( 1 ) . '&feed='  . $wp_rewrite->preg_index( 2 ),
    943             //$this->user_slug . '/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?' . $this->user_id . '=' . $wp_rewrite->preg_index( 1 ) . '&feed='  . $wp_rewrite->preg_index( 2 ),
     942            //$this->user_slug      . '/([^/]+)/(feed|rdf|rss|rss2|atom)/?$'      => 'index.php?' . $this->user_id . '=' . $wp_rewrite->preg_index( 1 ) . '&feed='  . $wp_rewrite->preg_index( 2 ),
     943            //$this->user_slug      . '/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?' . $this->user_id . '=' . $wp_rewrite->preg_index( 1 ) . '&feed='  . $wp_rewrite->preg_index( 2 ),
    944944
    945945            // @todo - view feeds
    946             //$this->view_slug . '/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?' . $this->view_id . '=' . $wp_rewrite->preg_index( 1 ) . '&feed='  . $wp_rewrite->preg_index( 2 ),
     946            //$this->view_slug      . '/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?' . $this->view_id . '=' . $wp_rewrite->preg_index( 1 ) . '&feed='  . $wp_rewrite->preg_index( 2 ),
    947947
    948948            // View Page
Note: See TracChangeset for help on using the changeset viewer.