/**
     * WP Page - Mass edit tags
     *
     */
    public static function pageMassEditTags()
    {
        global $wpdb, $wp_locale, $wp_query;
        list($post_stati, $avail_post_stati) = self::edit_data_query();
        if (!isset($_GET['paged'])) {
            $_GET['paged'] = 1;
        }
        // Display message
        settings_errors(__CLASS__);
        ?>
		<div class="wrap">
			<?php 
        SimpleTags_Admin::boxSelectorTaxonomy('st_mass_terms');
        ?>
			
			<form id="posts-filter" action="" method="get">
				<input type="hidden" name="page" value="st_mass_terms" />
				<input type="hidden" name="taxo" value="<?php 
        echo esc_attr(SimpleTags_Admin::$taxonomy);
        ?>
" />
				<input type="hidden" name="cpt" value="<?php 
        echo esc_attr(SimpleTags_Admin::$post_type);
        ?>
" />
				
				<h2><?php 
        _e('Mass edit terms', 'simpletags');
        ?>
</h2>
				
				<ul class="subsubsub">
					<?php 
        $status_links = array();
        $num_posts = wp_count_posts(SimpleTags_Admin::$post_type, 'readable');
        $class = empty($_GET['post_status']) && empty($_GET['post_type']) ? ' class="current"' : '';
        $status_links[] = '<li><a href="' . admin_url('tools.php') . '?page=st_mass_terms&amp;cpt=' . SimpleTags_Admin::$post_type . '&amp;taxo=' . SimpleTags_Admin::$taxonomy . '"' . $class . '>' . __('All', 'simpletags') . '</a>';
        foreach ($post_stati as $status => $label) {
            $class = '';
            if (!in_array($status, $avail_post_stati)) {
                continue;
            }
            if (empty($num_posts->{$status})) {
                continue;
            }
            if (isset($_GET['post_status']) && $status == $_GET['post_status']) {
                $class = ' class="current"';
            }
            $status_links[] = '<li><a href="' . admin_url('tools.php') . '?page=st_mass_terms&amp;cpt=' . SimpleTags_Admin::$post_type . '&amp;taxo=' . SimpleTags_Admin::$taxonomy . '&amp;post_status=' . $status . '"' . $class . '>' . sprintf(_n($label[2][0], $label[2][1], (int) $num_posts->{$status}), number_format_i18n($num_posts->{$status})) . '</a>';
        }
        echo implode(' |</li>', $status_links) . '</li>';
        unset($status_links);
        $class = !empty($_GET['post_type']) ? ' class="current"' : '';
        ?>
				</ul>
				
				<?php 
        if (isset($_GET['post_status'])) {
            ?>
					<input type="hidden" name="post_status" value="<?php 
            echo esc_attr($_GET['post_status']);
            ?>
" />
				<?php 
        }
        ?>
				
				<p class="search-box">
					<input type="text" id="post-search-input" name="s" value="<?php 
        the_search_query();
        ?>
" />
					<input type="submit" value="<?php 
        _e('Search', 'simpletags');
        ?>
" class="button" />
				</p>
				
				<div class="tablenav">
					<?php 
        $posts_per_page = isset($_GET['posts_per_page']) ? (int) $_GET['posts_per_page'] : 0;
        if ((int) $posts_per_page == 0) {
            $posts_per_page = 15;
        }
        $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'total' => ceil($wp_query->found_posts / $posts_per_page), 'current' => (int) $_GET['paged']));
        if ($page_links) {
            echo "<div class='tablenav-pages'>{$page_links}</div>";
        }
        ?>
					
					<div style="float: left">
						<?php 
        if (!is_singular()) {
            $arc_result = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM {$wpdb->posts} WHERE post_type = %s ORDER BY post_date DESC", SimpleTags_Admin::$post_type));
            $month_count = count($arc_result);
            if (!isset($_GET['m'])) {
                $_GET['m'] = '';
            }
            if ($month_count && !(1 == $month_count && 0 == $arc_result[0]->mmonth)) {
                ?>
								<select name='m'>
								<option<?php 
                selected(@$_GET['m'], 0);
                ?>
 value='0'><?php 
                _e('Show all dates', 'simpletags');
                ?>
</option>
								<?php 
                foreach ($arc_result as $arc_row) {
                    if ($arc_row->yyear == 0) {
                        continue;
                    }
                    $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
                    if ($arc_row->yyear . $arc_row->mmonth == $_GET['m']) {
                        $default = ' selected="selected"';
                    } else {
                        $default = '';
                    }
                    echo "<option{$default} value='{$arc_row->yyear}{$arc_row->mmonth}'>";
                    echo $wp_locale->get_month($arc_row->mmonth) . " {$arc_row->yyear}";
                    echo "</option>\n";
                }
                ?>
								</select>
							<?php 
            }
            ?>
						
						<select name="posts_per_page" id="posts_per_page">
							<option <?php 
            if (!isset($_GET['posts_per_page'])) {
                echo 'selected="selected"';
            }
            ?>
 value=""><?php 
            _e('Quantity&hellip;', 'simpletags');
            ?>
</option>
							<option <?php 
            selected($posts_per_page, 10);
            ?>
 value="10">10</option>
							<option <?php 
            selected($posts_per_page, 20);
            ?>
 value="20">20</option>
							<option <?php 
            selected($posts_per_page, 30);
            ?>
 value="30">30</option>
							<option <?php 
            selected($posts_per_page, 40);
            ?>
 value="40">40</option>
							<option <?php 
            selected($posts_per_page, 50);
            ?>
 value="50">50</option>
							<option <?php 
            selected($posts_per_page, 100);
            ?>
 value="100">100</option>
							<option <?php 
            selected($posts_per_page, 200);
            ?>
 value="200">200</option>
						</select>
						
						<input type="submit" id="post-query-submit" value="<?php 
            _e('Filter', 'simpletags');
            ?>
" class="button-secondary" />
						<?php 
        }
        ?>
					</div>
					
					<br style="clear:both;" />
				</div>
			</form>
			
			<br style="clear:both;" />
			
			<?php 
        if (have_posts()) {
            add_filter('the_title', 'esc_html');
            ?>
				<form name="post" id="post" method="post">
					<table class="widefat post fixed">
						<thead>
							<tr>
								<th class="manage-column"><?php 
            _e('Post title', 'simpletags');
            ?>
</th>
								<th class="manage-column"><?php 
            printf(__('Terms : %s', 'simpletags'), esc_html(SimpleTags_Admin::$taxo_name));
            ?>
</th>
							</tr>
						</thead>
						<tbody>
							<?php 
            $class = 'alternate';
            while (have_posts()) {
                the_post();
                $class = $class == 'alternate' ? '' : 'alternate';
                ?>
								<tr valign="top" class="<?php 
                echo $class;
                ?>
">
									<th scope="row"><a href="<?php 
                echo admin_url('post.php?action=edit&amp;post=' . get_the_ID());
                ?>
" title="<?php 
                _e('Edit', 'simpletags');
                ?>
"><?php 
                echo get_the_title() == '' ? the_ID() : the_title();
                ?>
</a></th>
									<td><input id="tags-input<?php 
                the_ID();
                ?>
" class="autocomplete-input tags_input" type="text" size="100" name="tags[<?php 
                the_ID();
                ?>
]" value="<?php 
                echo SimpleTags_Admin::getTermsToEdit(SimpleTags_Admin::$taxonomy, get_the_ID());
                ?>
" /></td>
								</tr>
								<?php 
            }
            ?>
						</tbody>
					</table>
					
					<p class="submit">
						<input type="hidden" name="secure_mass" value="<?php 
            echo wp_create_nonce('st_mass_terms');
            ?>
" />
						<input class="button-primary" type="submit" name="update_mass" value="<?php 
            _e('Update all &raquo;', 'simpletags');
            ?>
" />
					</p>
				</form>
			
			<?php 
        } else {
            ?>
				
				<p><?php 
            _e('No content to edit.', 'simpletags');
            ?>
			
			<?php 
        }
        ?>
			<p><?php 
        _e('Visit the <a href="https://github.com/herewithme/simple-tags">plugin\'s homepage</a> for further details. If you find a bug, or have a fantastic idea for this plugin, <a href="mailto:amaury@wordpress-fr.net">ask me</a> !', 'simpletags');
        ?>
</p>
			<?php 
        SimpleTags_Admin::printAdminFooter();
        ?>
		</div>
		<?php 
        do_action('simpletags-mass_terms', SimpleTags_Admin::$taxonomy);
    }
    /**
     * Method for build the page HTML manage tags
     *
     * @return void
     * @author Amaury Balmer
     */
    public static function page_manage_tags()
    {
        // Control Post data
        if (isset($_POST['term_action'])) {
            if (!wp_verify_nonce($_POST['term_nonce'], 'simpletags_admin')) {
                // Origination and intention
                add_settings_error(__CLASS__, __CLASS__, __('Security problem. Try again. If this problem persist, contact <a href="mailto:amaury@wordpress-fr.net">plugin author</a>.', 'simpletags'), 'error');
            } elseif (!isset(SimpleTags_Admin::$taxonomy) || !taxonomy_exists(SimpleTags_Admin::$taxonomy)) {
                // Valid taxo ?
                add_settings_error(__CLASS__, __CLASS__, __('Missing valid taxonomy for work... Try again. If this problem persist, contact <a href="mailto:amaury@wordpress-fr.net">plugin author</a>.', 'simpletags'), 'error');
            } elseif ($_POST['term_action'] == 'renameterm') {
                $oldtag = isset($_POST['renameterm_old']) ? $_POST['renameterm_old'] : '';
                $newtag = isset($_POST['renameterm_new']) ? $_POST['renameterm_new'] : '';
                self::renameTerms(SimpleTags_Admin::$taxonomy, $oldtag, $newtag);
            } elseif ($_POST['term_action'] == 'deleteterm') {
                $todelete = isset($_POST['deleteterm_name']) ? $_POST['deleteterm_name'] : '';
                self::deleteTermsByTermList(SimpleTags_Admin::$taxonomy, $todelete);
            } elseif ($_POST['term_action'] == 'addterm') {
                $matchtag = isset($_POST['addterm_match']) ? $_POST['addterm_match'] : '';
                $newtag = isset($_POST['addterm_new']) ? $_POST['addterm_new'] : '';
                self::addMatchTerms(SimpleTags_Admin::$taxonomy, $matchtag, $newtag);
            } elseif ($_POST['term_action'] == 'remove-rarelyterms') {
                self::removeRarelyUsed(SimpleTags_Admin::$taxonomy, (int) $_POST['number-rarely']);
            }
            /* elseif ( $_POST['term_action'] == 'editslug'  ) {
            				
            				$matchtag = (isset($_POST['tagname_match'])) ? $_POST['tagname_match'] : '';
            				$newslug  = (isset($_POST['tagslug_new'])) ? $_POST['tagslug_new'] : '';
            				self::editTermSlug( SimpleTags_Admin::$taxonomy, $matchtag, $newslug );
            			
            			}*/
        }
        // Default order
        if (!isset($_GET['order'])) {
            $_GET['order'] = 'name-asc';
        }
        settings_errors(__CLASS__);
        ?>

		<div class="wrap st_wrap">
			<?php 
        SimpleTags_Admin::boxSelectorTaxonomy('st_manage');
        ?>


			<h2><?php 
        _e('Simple Tags: Manage Terms', 'simpletags');
        ?>
</h2>

			<p><?php 
        _e('Visit the <a href="https://github.com/herewithme/simple-tags">plugin\'s homepage</a> for further details. If you find a bug, or have a fantastic idea for this plugin, <a href="mailto:amaury@wordpress-fr.net">ask me</a> !', 'simpletags');
        ?>
</p>

			<div class="clear"></div>
			<div id="term-list">
				<h3><?php 
        _e('Click terms list:', 'simpletags');
        ?>
</h3>

				<form action="" method="get">
					<div>
						<input type="hidden" name="page" value="st_manage"/>
						<input type="hidden" name="taxo"
						       value="<?php 
        echo esc_attr(SimpleTags_Admin::$taxonomy);
        ?>
"/>
						<input type="hidden" name="cpt"
						       value="<?php 
        echo esc_attr(SimpleTags_Admin::$post_type);
        ?>
"/>

						<select name="order">
							<option <?php 
        selected($_GET['order'], 'count-asc');
        ?>

								value="count-asc"><?php 
        _e('Least used', 'simpletags');
        ?>
</option>
							<option <?php 
        selected($_GET['order'], 'count-desc');
        ?>

								value="count-desc"><?php 
        _e('Most popular', 'simpletags');
        ?>
</option>
							<option <?php 
        selected($_GET['order'], 'name-asc');
        ?>

								value="name-asc"><?php 
        _e('Alphabetical (default)', 'simpletags');
        ?>
</option>
							<option <?php 
        selected($_GET['order'], 'name-desc');
        ?>

								value="name-desc"><?php 
        _e('Inverse Alphabetical', 'simpletags');
        ?>
</option>
							<option <?php 
        selected($_GET['order'], 'random');
        ?>

								value="random"><?php 
        _e('Random', 'simpletags');
        ?>
</option>
						</select>
						<input class="button" type="submit" value="<?php 
        _e('Sort', 'simpletags');
        ?>
"/>
					</div>
				</form>

				<div id="term-list-inner">
					<?php 
        if (isset($_GET['order'])) {
            $order = explode('-', stripslashes($_GET['order']));
            if (!isset($order[1])) {
                $order[1] = '';
            }
            // for skip notice on random...
            $order = '&selectionby=' . $order[0] . '&selection=' . $order[1] . '&orderby=' . $order[0] . '&order=' . $order[1];
        } else {
            $order = '&selectionby=name&selection=asc&orderby=name&order=asc';
        }
        st_tag_cloud('hide_empty=false&number=&color=false&get=all&title=' . $order . '&taxonomy=' . SimpleTags_Admin::$taxonomy);
        ?>

				</div>
			</div>

			<table id="manage-table-terms" class="form-table">
				<tr valign="top">
					<th scope="row"><strong><?php 
        _e('Rename/Merge Terms', 'simpletags');
        ?>
</strong></th>
					<td>
						<p><?php 
        _e('Enter the term to rename and its new value. You can use this feature to merge terms too. Click "Rename" and all posts which use this term will be updated.', 'simpletags');
        ?>
</p>

						<p><?php 
        _e('You can specify multiple terms to rename by separating them with commas.', 'simpletags');
        ?>
</p>

						<fieldset>
							<form action="" method="post">
								<input type="hidden" name="taxo"
								       value="<?php 
        echo esc_attr(SimpleTags_Admin::$taxonomy);
        ?>
"/>
								<input type="hidden" name="cpt"
								       value="<?php 
        echo esc_attr(SimpleTags_Admin::$post_type);
        ?>
"/>

								<input type="hidden" name="term_action" value="renameterm"/>
								<input type="hidden" name="term_nonce"
								       value="<?php 
        echo wp_create_nonce('simpletags_admin');
        ?>
"/>

								<p>
									<label
										for="renameterm_old"><?php 
        _e('Term(s) to rename:', 'simpletags');
        ?>
</label>
									<br/>
									<input type="text" class="autocomplete-input" id="renameterm_old"
									       name="renameterm_old"
									       value="" size="40"/>
								</p>

								<p>
									<label for="renameterm_new"><?php 
        _e('New term name(s):', 'simpletags');
        ?>

										<br/>
										<input type="text" class="autocomplete-input" id="renameterm_new"
										       name="renameterm_new" value="" size="40"/>
								</p>

								<input class="button-primary" type="submit" name="rename"
								       value="<?php 
        _e('Rename', 'simpletags');
        ?>
"/>
							</form>
						</fieldset>
					</td>
				</tr>

				<tr valign="top">
					<th scope="row"><strong><?php 
        _e('Delete Terms', 'simpletags');
        ?>
</strong></th>
					<td>
						<p><?php 
        _e('Enter the name of terms to delete. Terms will be removed from all posts.', 'simpletags');
        ?>
</p>

						<p><?php 
        _e('You can specify multiple terms to delete by separating them with commas', 'simpletags');
        ?>

							.</p>

						<fieldset>
							<form action="" method="post">
								<input type="hidden" name="taxo"
								       value="<?php 
        echo esc_attr(SimpleTags_Admin::$taxonomy);
        ?>
"/>
								<input type="hidden" name="cpt"
								       value="<?php 
        echo esc_attr(SimpleTags_Admin::$post_type);
        ?>
"/>

								<input type="hidden" name="term_action" value="deleteterm"/>
								<input type="hidden" name="term_nonce"
								       value="<?php 
        echo wp_create_nonce('simpletags_admin');
        ?>
"/>

								<p>
									<label
										for="deleteterm_name"><?php 
        _e('Term(s) to delete:', 'simpletags');
        ?>
</label>
									<br/>
									<input type="text" class="autocomplete-input" id="deleteterm_name"
									       name="deleteterm_name" value="" size="40"/>
								</p>

								<input class="button-primary" type="submit" name="delete"
								       value="<?php 
        _e('Delete', 'simpletags');
        ?>
"/>
							</form>
						</fieldset>
					</td>
				</tr>

				<tr valign="top">
					<th scope="row"><strong><?php 
        _e('Add Terms', 'simpletags');
        ?>
</strong></th>
					<td>
						<p><?php 
        _e('This feature lets you add one or more new terms to all posts which match any of the terms given.', 'simpletags');
        ?>
</p>

						<p><?php 
        _e('You can specify multiple terms to add by separating them with commas.  If you want the term(s) to be added to all posts, then don\'t specify any terms to match.', 'simpletags');
        ?>
</p>

						<fieldset>
							<form action="" method="post">
								<input type="hidden" name="taxo"
								       value="<?php 
        echo esc_attr(SimpleTags_Admin::$taxonomy);
        ?>
"/>
								<input type="hidden" name="cpt"
								       value="<?php 
        echo esc_attr(SimpleTags_Admin::$post_type);
        ?>
"/>

								<input type="hidden" name="term_action" value="addterm"/>
								<input type="hidden" name="term_nonce"
								       value="<?php 
        echo wp_create_nonce('simpletags_admin');
        ?>
"/>

								<p>
									<label for="addterm_match"><?php 
        _e('Term(s) to match:', 'simpletags');
        ?>
</label>
									<br/>
									<input type="text" class="autocomplete-input" id="addterm_match"
									       name="addterm_match"
									       value="" size="40"/>
								</p>

								<p>
									<label for="addterm_new"><?php 
        _e('Term(s) to add:', 'simpletags');
        ?>
</label>
									<br/>
									<input type="text" class="autocomplete-input" id="addterm_new" name="addterm_new"
									       value="" size="40"/>
								</p>

								<input class="button-primary" type="submit" name="Add"
								       value="<?php 
        _e('Add', 'simpletags');
        ?>
"/>
							</form>
						</fieldset>
					</td>
				</tr>

				<tr valign="top">
					<th scope="row"><strong><?php 
        _e('Remove rarely used terms', 'simpletags');
        ?>
</strong></th>
					<td>
						<p><?php 
        _e('This feature allows you to remove rarely used terms.', 'simpletags');
        ?>
</p>

						<p><?php 
        _e('You can specify the number below which will be removed terms. If you put 5, all terms with a counter inferior to 5 will be deleted. The terms with a counter equal to 5 is keep.', 'simpletags');
        ?>
</p>

						<fieldset>
							<form action="" method="post">
								<input type="hidden" name="taxo"
								       value="<?php 
        echo esc_attr(SimpleTags_Admin::$taxonomy);
        ?>
"/>
								<input type="hidden" name="cpt"
								       value="<?php 
        echo esc_attr(SimpleTags_Admin::$post_type);
        ?>
"/>

								<input type="hidden" name="term_action" value="remove-rarelyterms"/>
								<input type="hidden" name="term_nonce"
								       value="<?php 
        echo wp_create_nonce('simpletags_admin');
        ?>
"/>

								<p>
									<label for="number-delete"><?php 
        _e('Numbers minimum:', 'simpletags');
        ?>
</label>
									<br/>
									<select name="number-rarely" id="number-delete">
										<?php 
        for ($i = 1; $i <= 100; $i++) {
            ?>

											<option value="<?php 
            echo $i;
            ?>
"><?php 
            echo $i;
            ?>
</option>
										<?php 
        }
        ?>

									</select>
								</p>

								<input class="button-primary" type="submit" name="Delete"
								       value="<?php 
        _e('Delete rarely used', 'simpletags');
        ?>
"/>
							</form>
						</fieldset>
					</td>
				</tr>

				<?php 
        /*
        <tr valign="top">
        	<th scope="row"><strong><?php _e('Edit Term Slug', 'simpletags'); ?></strong></th>
        	<td>
        		<p><?php _e('Enter the term name to edit and its new slug. <a href="http://codex.wordpress.org/Glossary#Slug">Slug definition</a>', 'simpletags'); ?></p>
        		<p><?php _e('You can specify multiple terms to rename by separating them with commas.', 'simpletags'); ?></p>
        		
        		<fieldset>
        			<form action="" method="post">
        				<input type="hidden" name="taxo" value="<?php echo esc_attr(SimpleTags_Admin::$taxonomy); ?>" />
        				<input type="hidden" name="cpt" value="<?php echo esc_attr(SimpleTags_Admin::$post_type); ?>" />
        				
        				<input type="hidden" name="term_action" value="editslug" />
        				<input type="hidden" name="term_nonce" value="<?php echo wp_create_nonce('simpletags_admin'); ?>" />
        				
        				<p>
        					<label for="tagname_match"><?php _e('Term(s) to match:', 'simpletags'); ?></label>
        					<br />
        					<input type="text" class="autocomplete-input" id="tagname_match" name="tagname_match" value="" size="40" />
        				</p>
        				
        				<p>
        					<label for="tagslug_new"><?php _e('Slug(s) to set:', 'simpletags'); ?></label>
        					<br />
        					<input type="text" class="autocomplete-input" id="tagslug_new" name="tagslug_new" value="" size="40" />
        				</p>
        				
        				<input class="button-primary" type="submit" name="edit" value="<?php _e('Edit', 'simpletags'); ?>" />
        			</form>
        		</fieldset>
        	</td>
        </tr>
        */
        ?>


				<tr>
					<th scope="row"><strong><?php 
        _e('Technical informations', 'simpletags');
        ?>
</strong></th>
					<td>
						<p><strong><?php 
        _e('Renaming', 'simpletags');
        ?>
</strong></p>

						<p>
							<em><?php 
        _e('Simple Tags don\'t use the same method as WordPress for rename a term. For example, in WordPress you have 2 terms : "Blogging" and "Bloging". When you want edit the term "Bloging" for rename it on "Blogging", WordPress will keep the two terms with the same name but with a different slug. <br />With Simple Tags, when you edit "Bloging" for "Blogging", Simple Tags merge posts filled with "Bloging" to "Blogging" and it delete the term "Bloging". Another logic ;)', 'simpletags');
        ?>

								<em></p>
					</td>
				</tr>
			</table>

			<div class="clear"></div>
			<?php 
        SimpleTags_Admin::printAdminFooter();
        ?>

		</div>
		<?php 
        do_action('simpletags-manage_terms', SimpleTags_Admin::$taxonomy);
    }