WordPress plugin to import taxonomy terms (tags)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

settings.php 1.1 KiB

9 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <div class="wrap">
  2. <h2>Tag Importer</h2>
  3. <?php
  4. if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
  5. $tax = $_POST['taxonomy'];
  6. $terms = split("\n", $_POST['terms']);
  7. $success = 0;
  8. foreach ( $terms as $term ) {
  9. if ( trim( $term ) > '' && wp_insert_term( $term, $tax) ) {
  10. $success++;
  11. }
  12. }
  13. echo "<h3>Saved $success terms.</h3>";
  14. }
  15. ?>
  16. </div>
  17. <form method="POST" action="">
  18. <p>Choose a taxonomy to import into:</p>
  19. <select name="taxonomy">
  20. <option></option>
  21. <?php
  22. $args = array(
  23. 'public' => true,
  24. );
  25. $output = 'names'; // or objects
  26. $operator = 'and'; // 'and' or 'or'
  27. $taxonomies = get_taxonomies( $args, $output, $operator );
  28. if ( $taxonomies ) {
  29. sort( $taxonomies );
  30. foreach ( $taxonomies as $taxonomy ) {
  31. echo "<option value=\"$taxonomy\">" . $taxonomy . "</option>\n";
  32. }
  33. }
  34. ?>
  35. </select>
  36. <p>
  37. Paste in your tag names (terms), one tag on each row. Duplicate tags will only be added once.
  38. </p>
  39. <textarea name="terms" rows="15" cols="60">
  40. Apples
  41. Oranges
  42. Pears
  43. </textarea>
  44. <input class="button-primary" type="submit" value="Import Tags" />
  45. </form>