Ticket #1243: tags.2.diff
| File tags.2.diff, 25.6 KB (added by GautamGupta, 2 years ago) |
|---|
-
bb-admin/includes/functions.bb-admin.php
68 68 $bb_submenu['topics.php'][5] = array( __( 'Topics' ), 'moderate', 'topics.php' ); 69 69 $bb_menu[160] = array( __( 'Posts' ), 'moderate', 'posts.php', '', 'bb-menu-posts' ); 70 70 $bb_submenu['posts.php'][5] = array( __( 'Posts' ), 'moderate', 'posts.php' ); 71 $bb_menu[165] = array( __( 'Tags' ), 'manage_tags', 'tags.php', '', 'bb-menu-tags' ); 72 $bb_submenu['tags.php'][5] = array( __( 'Tags' ), 'manage_tags', 'tags.php' ); 71 73 72 74 // 200 < Plugin added menu items < 250 73 75 … … 710 712 711 713 } 712 714 715 /* Tags */ 716 717 function bb_tag_row( $tag ) { 718 719 $actions = "<a href='" . esc_attr( bb_get_tag_link( (int) $tag['tag_id'] ) ) . "'>" . __( 'View' ) . "</a>"; 720 $actions .= " | <a href='" . bb_get_tag_link( (int) $tag['tag_id'] ) . "#manage-tags'>" . __( 'Edit' ) . "</a>"; 721 $actions .= " | <a href='" . esc_attr( bb_nonce_url( bb_get_uri( 'bb-admin/tags.php', array( 'action' => 'destroy', 'id' => $tag['tag_id'], 'tagsearch' => @$_GET['tagsearch'], 'page' => @$_GET['page'], 'orderby' => @$_GET['orderby'], 'order' => @$_GET['order'], 'per_page' => @$_GET['per_page'] ), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN ), 'destroy-tag_' . $tag['tag_id'] ) ) . "' onclick=\"return confirm('" . esc_js( sprintf(__( 'Are you sure you want to destroy the "%s" tag? This is permanent and cannot be undone.' ), $tag['name'] ) ) . "');\">" . __( 'Delete' ) . "</a>"; 722 723 $r = "\t<tr id='tag-" . $tag['tag_id'] . "'" . get_alt_class( 'tag' ) . ">\n"; 724 $r .= "\t<td class='check-column'><input type='checkbox' name='tag[]' value='" . $tag['tag_id'] . "' /></td>"; 725 $r .= "\t\t<td class=\"tag\"><span class=\"row-title\">" . $tag['tag_id'] . "</td>\n"; 726 $r .= "\t\t<td class=\"tag\"><span class=\"row-title\"><a href='" . bb_get_tag_link( (int) $tag['tag_id'] ) . "'>" . $tag['name'] . "</a></span><div><span class=\"row-actions\">$actions</span> </div></td>\n"; 727 $r .= "\t\t<td>" . $tag['count'] . "</td>\n"; 728 $r .= "\t</tr>\n"; 729 730 return $r; 731 } 732 733 // BB_Tag_Search class 734 // Derived from BB_User_Search 735 736 class BB_Tag_Search { 737 var $results; 738 var $search_term; 739 var $page; 740 var $raw_page; 741 var $tags_per_page = 25; 742 var $first_tag; 743 var $last_tag; 744 var $query_limit; 745 var $total_tags_for_query = 0; 746 var $search_errors; 747 var $paging_text; 748 var $paging_text_bottom; 749 var $order_by = 'name'; 750 var $order = 'ASC'; 751 752 function BB_Tag_Search ( $search_term = false, $page = 1, $getorder_by = 'name', $getorder = 'ASC', $get_per_page = 25 ) { // constructor 753 $this->search_term = $search_term ? stripslashes( $search_term ) : false; 754 $this->raw_page = ( '' == $page ) ? false : (int) $page; 755 $page = (int) $page; 756 $this->page = $page < 2 ? 1 : $page; 757 758 $this->order_by = in_array( $getorder_by, array( 'id', 'name', 'count' ) ) ? $getorder_by : 'name'; 759 $this->order = in_array( $getorder, array( 'ASC', 'DESC' ) ) ? $getorder : 'ASC'; 760 $this->tags_per_page = in_array( $get_per_page, array( 25, 50, 100 ) ) ? (int)$get_per_page : 25; 761 762 $this->prepare_query(); 763 $this->query(); 764 $this->prepare_vars_for_template_usage(); 765 $this->do_paging(); 766 } 767 768 function prepare_query() { 769 $this->first_tag = ( $this->page - 1 ) * $this->tags_per_page; 770 } 771 772 function query() { 773 global $wp_taxonomy_object; 774 775 $terms = $wp_taxonomy_object->get_terms( 776 'bb_topic_tag', 777 array( 778 'search' => $this->search_term, 779 'offset' => $this->first_tag, 780 'number' => $this->tags_per_page, 781 'orderby' => $this->order_by, 782 'order' => $this->order, 783 'get' => 'all' 784 ) 785 ); 786 if ( is_wp_error( $terms ) ) 787 $this->search_errors = $terms; 788 789 $tags = array(); 790 791 for ( $i = 0; isset( $terms[$i] ); $i++ ) { 792 $tags[$i]['tag_id'] = $terms[$i]->term_id; 793 $tags[$i]['name'] = $terms[$i]->name; 794 $tags[$i]['count'] = $terms[$i]->count; 795 } 796 797 $this->results = $tags; 798 799 if ( $this->results ) 800 $this->total_tags_for_query = bb_count_last_query(); 801 elseif ( !is_wp_error( $this->search_errors ) ) 802 $this->search_errors = new WP_Error( 'no_matching_users_found', '<strong>' . __( 'No matching tags were found!' ) . '</strong>' ); 803 804 if ( is_wp_error( $this->search_errors ) ) 805 bb_admin_notice( $this->search_errors ); 806 } 807 808 function prepare_vars_for_template_usage() { 809 $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone 810 } 811 812 function do_paging() { 813 global $bb_current_submenu; 814 $displaying_num = sprintf( 815 __( '%1$s to %2$s of %3$s' ), 816 bb_number_format_i18n( ( $this->page - 1 ) * $this->tags_per_page + 1 ), 817 $this->page * $this->tags_per_page < $this->total_tags_for_query ? bb_number_format_i18n( $this->page * $this->tags_per_page ) : '<span class="total-type-count">' . bb_number_format_i18n( $this->total_tags_for_query ) . '</span>', 818 '<span class="total-type-count">' . bb_number_format_i18n( $this->total_tags_for_query ) . '</span>' 819 ); 820 $page_number_links = $this->total_tags_for_query > $this->tags_per_page ? get_page_number_links( $this->page, $this->total_tags_for_query, $this->tags_per_page, false ) : ''; 821 $this->paging_text = "<div class='tablenav-pages'><span class='displaying-num'>$displaying_num</span><span class=\"displaying-pages\">$page_number_links</span><div class=\"clear\"></div></div>\n"; 822 $this->paging_text_bottom = "<div class='tablenav-pages'><span class=\"displaying-pages\">$page_number_links</span><div class=\"clear\"></div></div>\n"; 823 } 824 825 function get_results() { 826 return (array) $this->results; 827 } 828 829 function page_links() { 830 echo $this->paging_text; 831 } 832 833 function results_are_paged() { 834 if ( isset($this->paging_text) && $this->paging_text ) 835 return true; 836 return false; 837 } 838 839 function is_search() { 840 if ( $this->search_term ) 841 return true; 842 return false; 843 } 844 845 function display( $show_extra = true ) { 846 $r = ''; 847 848 $h2_search = $this->search_term ? ' ' . sprintf( __( 'matching “%s”' ), esc_html( $this->search_term ) ) : ''; 849 850 $h2_span = '<span class="subtitle">'; 851 $h2_span .= apply_filters( 'bb_tag_search_description', $h2_search, $this ); 852 $h2_span .= '</span>'; 853 854 echo "<h2 class=\"first\">" . apply_filters( 'bb_tag_search_title', __( 'Tags' ) ) . $h2_span . "</h2>\n"; 855 do_action( 'bb_admin_notices' ); 856 857 if ( $show_extra ) { 858 859 $order_by = array( 'id' => __( 'Tag ID' ), 'name' => __( 'Tag Name' ), 'count' => __( 'Topic Count' ) ); 860 $orders = array( 'ASC' => __( 'Ascending' ), 'DESC' => __( 'Descending' ) ); 861 $per_pages = array( '25' => bb_number_format_i18n( '25' ), '50' => bb_number_format_i18n( '50' ), '100' => bb_number_format_i18n( '100' ) ); 862 863 $r .= "<form action='' method='get' id='search' class='search-form'>\n"; 864 $r .= "<fieldset>\n"; 865 866 /* Search */ 867 $r .= "<div>\n"; 868 $r .= "\t\t<label for='tagsearch'>" . __( 'Search Term' ) . "</label>"; 869 $r .= "\t\t<div><input type='text' name='tagsearch' id='tagsearch' class='text-input' value='" . esc_html( $this->search_term, 1 ) . "' /></div>\n"; 870 $r .= "</div>\n"; 871 872 /* Order by */ 873 $r .= "<div>\n"; 874 $r .= "\t\t<label for='orderby'>" . __( 'Order By' ) . "</label>"; 875 $r .= "\t\t<div><select name='orderby' id='orderby'>\n"; 876 877 foreach ( $order_by as $orderby => $display ) { 878 $selected = ''; 879 if ( $this->order_by == $orderby ) 880 $selected = ' selected="selected"'; 881 $value = esc_attr( $orderby ); 882 $display = esc_html( $display ); 883 $r .= "\t\t\t<option value='$value'$selected>$display</option>\n"; 884 } 885 886 $r .= "\t\t</select></div>\n"; 887 $r .= "</div>\n"; 888 889 /* Order */ 890 $r .= "<div>\n"; 891 $r .= "\t\t<label for='order'>" . __( 'Order' ) . "</label>"; 892 $r .= "\t\t<div><select name='order' id='order'>\n"; 893 894 foreach ( $orders as $order => $display ) { 895 $selected = ''; 896 if ( $this->order == $order ) 897 $selected = ' selected="selected"'; 898 $value = esc_attr( $order ); 899 $display = esc_html( $display ); 900 $r .= "\t\t\t<option value='$value'$selected>$display</option>\n"; 901 } 902 903 $r .= "\t\t</select></div>\n"; 904 $r .= "</div>\n"; 905 906 /* Per Page */ 907 $r .= "<div>\n"; 908 $r .= "\t\t<label for='per_page'>" . __( 'Per Page' ) . "</label>"; 909 $r .= "\t\t<div><select name='per_page' id='per_page'>\n"; 910 911 foreach ( $per_pages as $per_page => $display ) { 912 $selected = ''; 913 if ( $this->tags_per_page == $per_page ) 914 $selected = ' selected="selected"'; 915 $value = esc_attr( $per_page ); 916 $display = esc_html( $display ); 917 $r .= "\t\t\t<option value='$value'$selected>$display</option>\n"; 918 } 919 920 $r .= "\t\t</select></div>\n"; 921 $r .= "</div>\n"; 922 923 $r = apply_filters( 'bb_tag_search_form_inputs', $r, $this ); 924 925 $r .= "<div class=\"submit\">\n"; 926 $r .= "\t\t<label class='hidden' for='submit'>" . __( 'Search' ) . "</label>"; 927 $r .= "\t\t<div><input type='submit' id='submit' class='button submit-input' value='" . __( 'Filter' ) . "' /></div>\n"; 928 $r .= "</div>\n"; 929 $r .= "</fieldset>\n"; 930 $r .= "</form>\n\n"; 931 932 /* Bulk Actions */ 933 934 $bulk_actions = array( 935 'destroy' => __( 'Destroy' ), 936 'merge' => __( 'Merge' ) 937 ); 938 939 do_action_ref_array( 'bulk_tag_actions', array( &$bulk_actions ) ); 940 941 $r .= "<form class='table-form bulk-form' method='post'>\n"; 942 $r .= "\t<fieldset>\n"; 943 $r .= "\t\t<select name='action' onchange=\"if(this.value=='merge'){jQuery('#new-tag').css('display','inline');}else{jQuery('#new-tag').css('display','none');}\">\n"; 944 $r .= "\t\t\t<option>" . __( 'Bulk Actions' ) . "</option>\n"; 945 foreach ( $bulk_actions as $value => $label ) { 946 $r .= "\t\t\t<option value='" . esc_attr( $value ) . "'>" . esc_html( $label ) . "</option>\n"; 947 } 948 $r .= "\t\t</select>\n"; 949 $r .= "\t\t<input type='text' name='merge_new_tag' id='new-tag' class='text-input' value='" . __( 'New Tag Name' ) . "' style='display:none;' onblur='if(this.value==\"" . __( 'New Tag Name' ) . "\")this.value=\"\"';' onblur='if(this.value==\"\")this.value=\"" . __( 'New Tag Name' ) . "\"';' />\n"; 950 $r .= "\t\t<input type='submit' value='" . __( 'Apply' ) . "' class='button submit-input' onclick=\"return confirm('" . esc_js( __( 'Are you sure you want to do this? This is permanent and cannot be undone.' ) ) . "');\" />\n"; 951 $r .= bb_nonce_field( 'tags-bulk', '_wpnonce', true, false ); 952 $r .= "\t</fieldset>\n"; 953 } 954 955 if ( $this->get_results() ) { 956 if ( $this->results_are_paged() ) 957 $r .= "<div class='tablenav'>\n" . $this->paging_text . "</div><div class=\"clear\"></div>\n\n"; 958 959 $r .= "<table class='widefat'>\n"; 960 $r .= "<thead>\n"; 961 $r .= "\t<tr>\n"; 962 963 $r .= "\t\t<th scope='col' class='check-column'><input type='checkbox' /></th>\n"; 964 $r .= "\t\t<th style='width:20%;'>" . __( 'Tag ID' ) . "</th>\n"; 965 $r .= "\t\t<th style='width:50%;'>" . __( 'Tag Name' ) . "</th>\n"; 966 $r .= "\t\t<th style='width:30%;'>" . __( 'Topics' ) . "</th>\n"; 967 968 $r .= "\t</tr>\n"; 969 $r .= "</thead>\n\n"; 970 971 $r .= "<tfoot>\n"; 972 $r .= "\t<tr>\n"; 973 974 $r .= "\t\t<th scope='col' class='check-column'><input type='checkbox' /></th>\n"; 975 $r .= "\t\t<th style='width:20%;'>" . __( 'Tag ID' ) . "</th>\n"; 976 $r .= "\t\t<th style='width:50%;'>" . __( 'Tag Name' ) . "</th>\n"; 977 $r .= "\t\t<th style='width:30%;'>" . __( 'Topics' ) . "</th>\n"; 978 979 $r .= "\t</tr>\n"; 980 $r .= "</tfoot>\n\n"; 981 982 $r .= "<tbody id='role-$role'>\n"; 983 foreach ( (array) $this->get_results() as $tag ) 984 $r .= bb_tag_row( $tag ); 985 $r .= "</tbody>\n"; 986 $r .= "</table>\n\n"; 987 988 $r .= "</form>\n"; 989 990 if ( $this->results_are_paged() ) 991 $r .= "<div class='tablenav bottom'>\n" . $this->paging_text_bottom . "</div><div class=\"clear\"></div>\n\n"; 992 } 993 echo $r; 994 } 995 996 } 997 713 998 /* Forums */ 714 999 715 1000 // Expects forum_name, forum_desc to be pre-escaped -
bb-admin/style.css
451 451 background-position: -186px -7px; 452 452 } 453 453 454 ul#bbAdminMenu li#bb-menu-tags a div.bb-menu-icon { 455 background-position: -278px -39px; 456 } 457 458 ul#bbAdminMenu li#bb-menu-tags.bb-menu-current a div.bb-menu-icon, 459 ul#bbAdminMenu li#bb-menu-tags a:hover div.bb-menu-icon { 460 background-position: -278px -7px; 461 } 462 454 463 ul#bbAdminMenu li#bb-menu-users a div.bb-menu-icon { 455 464 background-position: -308px -39px; 456 465 } … … 847 856 color: rgb(70, 70, 70); 848 857 } 849 858 850 form.search-form fieldset div div input.text-input { 859 form.search-form fieldset div div input.text-input, 860 #new-tag { 851 861 width: 100px; 852 862 padding: 3px; 853 863 -moz-border-radius: 4px; -
bb-admin/tag-destroy.php
1 <?php2 require('admin.php');3 4 if ( !bb_current_user_can('manage_tags') )5 bb_die(__('You are not allowed to manage tags.'));6 7 $tag_id = (int) $_POST['id' ];8 9 bb_check_admin_referer( 'destroy-tag_' . $tag_id );10 11 $old_tag = bb_get_tag( $tag_id );12 if ( !$old_tag )13 bb_die(__('Tag not found.'));14 15 if ( $destroyed = bb_destroy_tag( $tag_id ) ) {16 printf(__("Rows deleted from tags table: %d <br />\n"), $destroyed['tags']);17 printf(__("Rows deleted from tagged table: %d <br />\n"), $destroyed['tagged']);18 printf(__('<a href="%s">Home</a>'), bb_get_uri());19 } else {20 die(printf(__("Something odd happened when attempting to destroy that tag.<br />\n<a href=\"%s\">Try Again?</a>"), wp_get_referer()));21 }22 ?> -
bb-admin/tag-merge.php
1 <?php2 require('admin.php');3 4 if ( !bb_current_user_can('manage_tags') )5 bb_die(__('You are not allowed to manage tags.'));6 7 $old_id = (int) $_POST['id' ];8 $tag = $_POST['tag'];9 10 bb_check_admin_referer( 'merge-tag_' . $old_id );11 12 if ( ! $tag = bb_get_tag( $tag ) )13 bb_die(__('Tag specified not found.'));14 15 if ( ! bb_get_tag( $old_id ) )16 bb_die(__('Tag to be merged not found.'));17 18 if ( $merged = bb_merge_tags( $old_id, $tag->tag_id ) ) {19 printf(__("Number of topics from which the old tag was removed: %d <br />\n"), $merged['old_count']);20 printf(__("Number of topics to which the new tag was added: %d <br />\n"),$merged['diff_count']);21 printf(__("Number of rows deleted from tags table:%d <br />\n"),$merged['destroyed']['tags']);22 printf(__('<a href="%s">New Tag</a>'), bb_get_tag_link());23 } else {24 die(printf(__("Something odd happened when attempting to merge those tags.<br />\n<a href=\"%s\">Try Again?</a>"), wp_get_referer()));25 }26 ?> -
bb-admin/tag-rename.php
1 <?php2 require('admin.php');3 4 if ( !bb_current_user_can('manage_tags') )5 bb_die(__('You are not allowed to manage tags.'));6 7 $tag_id = (int) $_POST['id' ];8 $tag = $_POST['tag'];9 10 bb_check_admin_referer( 'rename-tag_' . $tag_id );11 12 $old_tag = bb_get_tag( $tag_id );13 if ( !$old_tag )14 bb_die(__('Tag not found.'));15 16 $tag = stripslashes( $tag );17 if ( $tag = bb_rename_tag( $tag_id, $tag ) )18 wp_redirect( bb_get_tag_link() );19 else20 die(printf(__('There already exists a tag by that name or the name is invalid. <a href="%s">Try Again</a>'), wp_get_referer()));21 exit;22 ?> -
bb-admin/tags.php
1 <?php 2 require_once( 'admin.php' ); 3 4 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) ) { /* Accepts multiple tags in array */ 5 bb_check_admin_referer( 'tags-bulk' ); 6 7 $tag_ids = array_map( 'absint', (array) $_POST['tag'] ); 8 $count = 0; 9 $action = trim( $_POST['action'] ); 10 11 switch ( $action ) { 12 case 'destroy' : 13 foreach ( $tag_ids as $tag_id ) 14 $count += (int) (bool) bb_destroy_tag( $tag_id ); 15 16 $query_vars = array( 'message' => 'destroyed', 'count' => $count ); 17 break; 18 case 'merge' : 19 if ( !$new_tag = (string) trim( $_POST['merge_new_tag'] ) ) 20 break; 21 if ( !$new_tag_id = bb_create_tag( $new_tag ) ) /* The tag ID would be returned if tag is already there, else it would be created */ 22 if ( !$new_tag_id = bb_get_tag_id( $new_tag ) ) /* Due to some problem, bb_create_tag doesn't return the term id so we need to try to get the id again */ 23 break; 24 25 foreach ( $tag_ids as $tag_id ) { 26 if ( $tag_id == $new_tag_id ) 27 continue; 28 $count += (int) (bool) bb_merge_tags( $tag_id, $new_tag_id ); 29 } 30 31 $query_vars = array( 'message' => 'merged', 'count' => $count, 'new_id' => $new_tag_id ); 32 break; 33 default : 34 if ( $action ) 35 $query_vars = apply_filters( "bulk_tag__$action", array(), $tag_ids, $action ); 36 break; 37 } 38 39 bb_safe_redirect( add_query_arg( $query_vars ) ); 40 exit; 41 } 42 43 if ( !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'rename', 'merge', 'destroy' ) ) && $old_tag = bb_get_tag( (int) $_GET['id'] ) ) { /* Accepts only one tag */ 44 $action = $_GET['action']; 45 $old_id = (int) $_GET['id']; 46 47 bb_check_admin_referer( $action . '-tag_' . $old_id ); 48 49 switch ( $action ) { 50 case 'destroy': 51 $query_vars = ( (bool) bb_destroy_tag( $old_id ) ) ? array( 'message' => 'destroyed' ) : $query_vars = array( 'message' => 'error' ); 52 break; 53 case 'merge': 54 if ( !$new_tag = bb_get_tag( $_GET['tag'] ) ) { 55 $query_vars = array( 'message' => 'error' ); 56 break; 57 } 58 $query_vars = ( (bool) bb_merge_tags( $old_id, $new_tag->tag_id ) ) ? array( 'message' => 'merged', 'new_id' => $new_tag->tag_id ) : array( 'message' => 'error' ); 59 break; 60 case 'rename': 61 $new_tag = stripslashes( $_GET['tag'] ); 62 $query_vars = ( (bool) bb_rename_tag( $old_id, $new_tag ) ) ? array( 'message' => 'renamed', 'new_id' => $old_id ) : array( 'message' => 'error' ); 63 break; 64 } 65 66 bb_safe_redirect( remove_query_arg( array( 'action', 'tag', 'Submit', 'id', '_wpnonce' ), add_query_arg( $query_vars ) ) ); /* Just keep _wp_http_referer for messages (below) */ 67 exit; 68 } 69 70 if ( !empty( $_GET['message'] ) ) { 71 $message_count = isset( $_GET['count'] ) ? (int) $_GET['count'] : 1; 72 73 switch ( (string) $_GET['message'] ) { 74 case 'destroyed': 75 $back = isset( $_GET['_wp_http_referer'] ) ? ' <a href="' . bb_get_uri() . '">' . __( 'Back to forums.' ) . '</a>' : ''; 76 bb_admin_notice( '<strong>' . sprintf( _n( 'Tag destroyed.', '%s tags destroyed.', $message_count ), bb_number_format_i18n( $message_count ) ) . '</strong>' . $back ); 77 break; 78 case 'merged': 79 bb_admin_notice( '<strong>' . sprintf( _n( 'Tag merged into %2$s.', '%1$s tags merged into %2$s.', $message_count ), bb_number_format_i18n( $message_count ), '<a href="' . bb_get_tag_link( (int) $_GET['new_id'] ) . '">' . bb_get_tag_name( (int) $_GET['new_id'] ) . '</a>' ) . '</strong>' ); 80 break; 81 case 'renamed': 82 bb_admin_notice( '<strong>' . sprintf( 'Tag renamed to %s.', '<a href="' . bb_get_tag_link( (int) $_GET['new_id'] ) . '">' . bb_get_tag_name( (int) $_GET['new_id'] ) . '</a>' ) . '</strong>' ); 83 break; 84 case 'error': 85 $back = isset( $_GET['_wp_http_referer'] ) ? ' <a href="' . bb_get_uri() . '">' . __( 'Back to forums.' ) . '</a>' : ''; 86 bb_admin_notice( '<strong>' . __( 'There was an error with your request! Please try again.' ) . '</strong>' . $back ); 87 break; 88 } 89 } 90 91 $tag_query = new BB_Tag_Search( @$_GET['tagsearch'], @$_GET['page'], @$_GET['orderby'], @$_GET['order'], @$_GET['per_page'] ); 92 93 $bb_admin_body_class = ' bb-admin-tags'; 94 95 bb_get_admin_header(); 96 97 if ( !bb_current_user_can( 'manage_tags' ) ) 98 die( __( "Now how'd you get here? And what did you think you'd being doing?" ) ); //This should never happen. 99 ?> 100 101 <div class="wrap"> 102 103 <?php $tag_query->display(); ?> 104 105 </div> 106 107 <?php bb_get_admin_footer(); ?> -
bb-includes/functions.bb-template.php
3137 3137 <?php 3138 3138 } 3139 3139 3140 function manage_tags_forms() 3141 { 3140 function manage_tags_forms() { 3141 if ( !bb_current_user_can( 'manage_tags' ) ) 3142 return false; 3143 3142 3144 global $tag; 3143 if ( !bb_current_user_can( 'manage_tags' ) ) {3144 return false;3145 }3146 3145 3147 3146 $form = '<ul id="manage-tags">' . "\n"; 3148 $form .= '<li id="tag-rename">' . __( 'Rename tag:') . "\n\t";3149 $form .= '<form method=" post" action="' . bb_get_uri( 'bb-admin/tag-rename.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ) . '"><div>' . "\n\t";3147 $form .= '<li id="tag-rename">' . __( 'Rename tag:' ) . "\n\t"; 3148 $form .= '<form method="get" action="' . bb_get_uri( 'bb-admin/tags.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ) . '"><div>' . "\n\t"; 3150 3149 $form .= '<input type="text" name="tag" size="10" maxlength="30" />' . "\n\t"; 3151 3150 $form .= '<input type="hidden" name="id" value="' . $tag->tag_id . '" />' . "\n\t"; 3152 $form .= "<input type='submit' name='Submit' value='" . __('Rename') . "' />\n\t"; 3151 $form .= '<input type="hidden" name="action" value="rename" />' . "\n\t"; 3152 $form .= "<input type='submit' name='Submit' value='" . __( 'Rename' ) . "' />\n\t"; 3153 3153 echo $form; 3154 3154 bb_nonce_field( 'rename-tag_' . $tag->tag_id ); 3155 3155 echo "\n\t</div></form>\n </li>\n "; 3156 $form = "<li id='tag-merge'>" . __('Merge this tag into:') . "\n\t"; 3157 $form .= "<form method='post' action='" . bb_get_uri('bb-admin/tag-merge.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN) . "'><div>\n\t"; 3156 3157 $form = "<li id='tag-merge'>" . __( 'Merge this tag into:' ) . "\n\t"; 3158 $form .= "<form method='get' action='" . bb_get_uri( 'bb-admin/tags.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ) . "'><div>\n\t"; 3158 3159 $form .= "<input type='text' name='tag' size='10' maxlength='30' />\n\t"; 3159 3160 $form .= "<input type='hidden' name='id' value='$tag->tag_id' />\n\t"; 3160 $form .= "<input type='submit' name='Submit' value='" . __('Merge') . "' "; 3161 $form .= 'onclick="return confirm(\'' . esc_js( sprintf(__('Are you sure you want to merge the "%s" tag into the tag you specified? This is permanent and cannot be undone.'), $tag->raw_tag) ) . "');\" />\n\t"; 3161 $form .= '<input type="hidden" name="action" value="merge" />' . "\n\t"; 3162 $form .= "<input type='submit' name='Submit' value='" . __( 'Merge' ) . "' "; 3163 $form .= 'onclick="return confirm(\'' . esc_js( sprintf(__( 'Are you sure you want to merge the "%s" tag into the tag you specified? This is permanent and cannot be undone.' ), $tag->raw_tag ) ) . "');\" />\n\t"; 3162 3164 echo $form; 3163 3165 bb_nonce_field( 'merge-tag_' . $tag->tag_id ); 3164 3166 echo "\n\t</div></form>\n </li>\n "; 3165 $form = "<li id='tag-destroy'>" . __('Destroy tag:') . "\n\t"; 3166 $form .= "<form method='post' action='" . bb_get_uri('bb-admin/tag-destroy.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN) . "'><div>\n\t"; 3167 3168 $form = "<li id='tag-destroy'>" . __( 'Destroy tag:' ) . "\n\t"; 3169 $form .= "<form method='get' action='" . bb_get_uri( 'bb-admin/tags.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ) . "'><div>\n\t"; 3167 3170 $form .= "<input type='hidden' name='id' value='$tag->tag_id' />\n\t"; 3168 $form .= "<input type='submit' name='Submit' value='" . __('Destroy') . "' "; 3169 $form .= 'onclick="return confirm(\'' . esc_js( sprintf(__('Are you sure you want to destroy the "%s" tag? This is permanent and cannot be undone.'), $tag->raw_tag) ) . "');\" />\n\t"; 3171 $form .= '<input type="hidden" name="action" value="destroy" />' . "\n\t"; 3172 $form .= "<input type='submit' name='Submit' value='" . __( 'Destroy' ) . "' "; 3173 $form .= 'onclick="return confirm(\'' . esc_js( sprintf(__( 'Are you sure you want to destroy the "%s" tag? This is permanent and cannot be undone.' ), $tag->raw_tag ) ) . "');\" />\n\t"; 3170 3174 echo $form; 3171 3175 bb_nonce_field( 'destroy-tag_' . $tag->tag_id ); 3172 3176 echo "\n\t</div></form>\n </li>\n</ul>"; 3177 3173 3178 } 3174 3179 3175 3180 function bb_tag_remove_link( $args = null ) { -
bb-includes/functions.bb-topic-tags.php
422 422 423 423 $tag_id = (int) $tag_id; 424 424 $raw_tag = bb_trim_for_db( $tag_name, 50 ); 425 $tag_name = tag_sanitize( $tag_name );425 $tag_name = bb_pre_term_slug( $tag_name ); 426 426 427 427 if ( empty( $tag_name ) ) { 428 428 return false; … … 464 464 do_action( 'bb_pre_merge_tags', $old_id, $new_id ); 465 465 466 466 // Get all topics tagged with old tag 467 $old_topics = bb_get_tagged_topic_ids( $old_id );467 $old_topics = (array) bb_get_tagged_topic_ids( $old_id ); 468 468 469 469 // Get all toics tagged with new tag 470 $new_topics = bb_get_tagged_topic_ids( $new_id );470 $new_topics = (array) bb_get_tagged_topic_ids( $new_id ); 471 471 472 472 // Get intersection of those topics 473 $both_topics = array_intersect( $old_topics, $new_topics );473 $both_topics = (array) array_intersect( $old_topics, $new_topics ); 474 474 475 475 // Discard the intersection from the old tags topics 476 $old_topics = array_diff( $old_topics, $both_topics );476 $old_topics = (array) array_diff( $old_topics, $both_topics ); 477 477 478 478 // Add the remainder of the old tag topics to the new tag 479 479 if ( count( $old_topics ) ) {