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