Version Description
Download this release
Release Info
| Developer | Bueltge |
| Plugin | |
| Version | 1.6 |
| Comparing to | |
| See all releases | |
Version 1.6
- searchandreplace.php +193 -0
searchandreplace.php
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/*
|
| 3 |
+
Plugin Name: Search and Replace
|
| 4 |
+
Plugin URI: http://bueltge.de/wp-suchen-und-ersetzen-de-plugin/114
|
| 5 |
+
Description: A simple search for find strings in your database and replace the string. Use in <a href="admin.php?page=searchandreplace.php">Manage -> Search/Replace</a> by <a href='http://thedeadone.net/'>Mark Cunningham</a> and <a href="http://bueltge.de" >Frank Bueltge</a>
|
| 6 |
+
Version: 1.6
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
/*
|
| 10 |
+
Um dieses Plugin zu nutzen, musst du das File in den
|
| 11 |
+
Plugin-Ordner deines WP kopieren und aktivieren.
|
| 12 |
+
Es fuegt einen neuen Tab im Bereich "Verwalten" hinzu.
|
| 13 |
+
Dort koennen Strings dann gesucht und ersetzt werden.
|
| 14 |
+
*/
|
| 15 |
+
|
| 16 |
+
if(function_exists('load_plugin_textdomain'))
|
| 17 |
+
load_plugin_textdomain('suchenundersetzen','wp-content/plugins');
|
| 18 |
+
|
| 19 |
+
if (!is_plugin_page()) {
|
| 20 |
+
|
| 21 |
+
function tdo_searchandreplace_hook(){
|
| 22 |
+
if (function_exists('add_management_page')) {
|
| 23 |
+
add_management_page(__('Search/Replace', 'suchenundersetzen'),
|
| 24 |
+
__('Search/Replace', 'suchenundersetzen'),
|
| 25 |
+
10, /* only admins */
|
| 26 |
+
basename(__FILE__),
|
| 27 |
+
'tdo_searchandreplace_hook');
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
add_action('admin_head','tdo_searchandreplace_hook');
|
| 32 |
+
} else {
|
| 33 |
+
|
| 34 |
+
/* this does the important stuff! */
|
| 35 |
+
function tdo_do_searchandreplace($search_text,
|
| 36 |
+
$replace_text,
|
| 37 |
+
$content = TRUE,
|
| 38 |
+
$title = TRUE,
|
| 39 |
+
$excerpt = TRUE,
|
| 40 |
+
$comment_content = TRUE,
|
| 41 |
+
$comment_author = TRUE,
|
| 42 |
+
$comment_author_email = TRUE,
|
| 43 |
+
$comment_author_url = TRUE
|
| 44 |
+
){
|
| 45 |
+
global $wpdb;
|
| 46 |
+
|
| 47 |
+
if (!$content && !$title && !$excerpt && !$comment_content && !$comment_author && !$comment_author_email && !$comment_author_url){
|
| 48 |
+
return __('Keine Aktion (Checkbox) gewählt um zu ersetzen!', 'suchenundersetzen');
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
if ($content) {
|
| 52 |
+
echo "<p>» Suche nach Beiträgen ...</p>";
|
| 53 |
+
$query = "UPDATE $wpdb->posts ";
|
| 54 |
+
$query .= "SET post_content = ";
|
| 55 |
+
$query .= "REPLACE(post_content, \"$search_text\", \"$replace_text\") ";
|
| 56 |
+
$wpdb->get_results($query);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
if ($title) {
|
| 60 |
+
echo "<p>» Suche nach Titeln ...</p>";
|
| 61 |
+
$query = "UPDATE $wpdb->posts ";
|
| 62 |
+
$query .= "SET post_title = ";
|
| 63 |
+
$query .= "REPLACE(post_title, \"$search_text\", \"$replace_text\") ";
|
| 64 |
+
$wpdb->get_results($query);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
if ($excerpt) {
|
| 68 |
+
echo "<p>» Suche nach Auszügen ...</p>";
|
| 69 |
+
$query = "UPDATE $wpdb->posts ";
|
| 70 |
+
$query .= "SET post_excerpt = ";
|
| 71 |
+
$query .= "REPLACE(post_excerpt, \"$search_text\", \"$replace_text\") ";
|
| 72 |
+
$wpdb->get_results($query);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
if ($comment_content) {
|
| 76 |
+
echo "<p>» Suche nach Kommentarbeträgen ...</p>";
|
| 77 |
+
$query = "UPDATE $wpdb->comments ";
|
| 78 |
+
$query .= "SET comment_content = ";
|
| 79 |
+
$query .= "REPLACE(comment_content, \"$search_text\", \"$replace_text\") ";
|
| 80 |
+
$wpdb->get_results($query);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
if ($comment_author) {
|
| 84 |
+
echo "<p>» Suche nach Kommentarautor ...</p>";
|
| 85 |
+
$query = "UPDATE $wpdb->comments ";
|
| 86 |
+
$query .= "SET comment_author = ";
|
| 87 |
+
$query .= "REPLACE(comment_author, \"$search_text\", \"$replace_text\") ";
|
| 88 |
+
$wpdb->get_results($query);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
if ($comment_author_email) {
|
| 92 |
+
echo "<p>» Suche nach Kommentarautoren-E-Mails ...</p>";
|
| 93 |
+
$query = "UPDATE $wpdb->comments ";
|
| 94 |
+
$query .= "SET comment_author_email = ";
|
| 95 |
+
$query .= "REPLACE(comment_author_email, \"$search_text\", \"$replace_text\") ";
|
| 96 |
+
$wpdb->get_results($query);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
if ($comment_author_url) {
|
| 100 |
+
echo "<p>» Suche nach Kommentarautor-URLs ...</p>";
|
| 101 |
+
$query = "UPDATE $wpdb->comments ";
|
| 102 |
+
$query .= "SET comment_author_url = ";
|
| 103 |
+
$query .= "REPLACE(comment_author_url, \"$search_text\", \"$replace_text\") ";
|
| 104 |
+
$wpdb->get_results($query);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
return '';
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
?>
|
| 111 |
+
|
| 112 |
+
<div class="wrap">
|
| 113 |
+
<h2>Suchen und Ersetzen</h2>
|
| 114 |
+
|
| 115 |
+
<?php if (isset($_POST['submitted'])) {
|
| 116 |
+
if (empty($_POST['search_text'])) { ?>
|
| 117 |
+
<p><strong>» Du musst Text spezifizieren, um Text zu ersetzen!</strong></p>
|
| 118 |
+
<?php } else { ?>
|
| 119 |
+
<p><strong>» Versuche die Suche duchzuführen und zu ersetzen ...</strong></p>
|
| 120 |
+
<p>» Suche nach <code><?php echo $_POST['search_text']; ?></code>...</p>
|
| 121 |
+
|
| 122 |
+
<?php $error = tdo_do_searchandreplace(
|
| 123 |
+
$_POST['search_text'],
|
| 124 |
+
$_POST['replace_text'],
|
| 125 |
+
isset($_POST['content']),
|
| 126 |
+
isset($_POST['title']),
|
| 127 |
+
isset($_POST['excerpt']),
|
| 128 |
+
isset($_POST['comment_content']),
|
| 129 |
+
isset($_POST['comment_author']),
|
| 130 |
+
isset($_POST['comment_author_email']),
|
| 131 |
+
isset($_POST['comment_author_url'])
|
| 132 |
+
);
|
| 133 |
+
if ($error != '') { ?>
|
| 134 |
+
<div class="updated"><p><?php _e('Es gab eine Störung!', 'suchenundersetzen'); ?></p>
|
| 135 |
+
<p><code><?php echo $error; ?></code></p></div>
|
| 136 |
+
<?php } else { ?>
|
| 137 |
+
<div class="updated"><p><?php _e('Erfolgreich durchgeführt!', 'suchenundersetzen'); ?></p></div>
|
| 138 |
+
<?php }
|
| 139 |
+
}
|
| 140 |
+
} ?>
|
| 141 |
+
|
| 142 |
+
<p><?php _e('Dieses Plugin arbeitet mit einer Standard SQL Abfrage und verändert deine Datenbank direkt!<br /><strong>Achtung: </strong>Du <strong>kannst nichts</strong> rückgängig machen mit diesem Plugin. Wenn du dir nicht sicher bist, fertige eine Sicherung deiner Datenbank im Vorfeld an.', 'suchenundersetzen'); ?></p>
|
| 143 |
+
<p><?php _e('Die Textsuche ist sensitiv und besitzt keine passende Abstimmungsbefähigung.<br />Du kannst folgende Einträge bearbeiten: Beitrag (content), Titel (titles), Auszug (excerpt), Kommentarbeiträge (comment_content), Kommentarautor (comment_author) und Kommentar-URL (comment_author_url).<br />Die Funktion arbeitet stringbasierend und kann somit auch HTML-Tags ersetzen.', 'suchenundersetzen'); ?></p>
|
| 144 |
+
|
| 145 |
+
<form name="replace" action="" method="post">
|
| 146 |
+
<fieldset>
|
| 147 |
+
<legend><strong><?php _e('Suche in', 'suchenundersetzen'); ?></strong></legend>
|
| 148 |
+
<table>
|
| 149 |
+
<tr>
|
| 150 |
+
<td colspan=2><input type='checkbox' name='content' id='content_label' value='1' checked='checked' /><label for="content_label"> <?php _e('Beiträgen', 'suchenundersetzen'); ?></label></td>
|
| 151 |
+
</tr>
|
| 152 |
+
<tr>
|
| 153 |
+
<td colspan=2><input type='checkbox' name='title' id='title_label' value='1' checked='checked' /><label for="title_label"> <?php _e('Titeln', 'suchenundersetzen'); ?></label></td>
|
| 154 |
+
</tr>
|
| 155 |
+
<tr>
|
| 156 |
+
<td colspan=2><input type='checkbox' name='excerpt' id='excerpt_label' value='1' checked='checked' /><label for="excerpt_label"> <?php _e('Auszügen', 'suchenundersetzen'); ?></label></td>
|
| 157 |
+
</tr>
|
| 158 |
+
<tr>
|
| 159 |
+
<td colspan=2><input type='checkbox' name='comment_content' id='comment_content_label' value='1' checked='checked' /><label for="comment_content_label"> <?php _e('Kommentarbeiträgen', 'suchenundersetzen'); ?></label></td>
|
| 160 |
+
</tr>
|
| 161 |
+
<tr>
|
| 162 |
+
<td colspan=2><input type='checkbox' name='comment_author' id='comment_author_label' value='1' checked='checked' /><label for="comment_author_label"> <?php _e('Kommentarautoren', 'suchenundersetzen'); ?></label></td>
|
| 163 |
+
</tr>
|
| 164 |
+
<tr>
|
| 165 |
+
<td colspan=2><input type='checkbox' name='comment_author_email' id='comment_author_email_label' value='1' checked='checked' /><label for="comment_author_email_label"> <?php _e('Kommentarautoren-E-Mail', 'suchenundersetzen'); ?></label></td>
|
| 166 |
+
</tr>
|
| 167 |
+
<tr>
|
| 168 |
+
<td colspan=2><input type='checkbox' name='comment_author_url' id='comment_author_url_label' value='1' checked='checked' /><label for="comment_author_url_label"> <?php _e('Kommentarautoren-URLs', 'suchenundersetzen'); ?></label></td>
|
| 169 |
+
</tr>
|
| 170 |
+
</table>
|
| 171 |
+
</fieldset>
|
| 172 |
+
<br/>
|
| 173 |
+
<fieldset>
|
| 174 |
+
<table>
|
| 175 |
+
<tr>
|
| 176 |
+
<td><?php _e('Ersetze', 'suchenundersetzen'); ?></td>
|
| 177 |
+
<td><input class="code" type="text" name="search_text" value="" size="80" /></td>
|
| 178 |
+
</tr>
|
| 179 |
+
<tr>
|
| 180 |
+
<td>mit</td>
|
| 181 |
+
<td><input class="code" type="text" name="replace_text" value="" size="80" /></td>
|
| 182 |
+
</tr>
|
| 183 |
+
</table>
|
| 184 |
+
<p class="submit"><input class="submit" type="submit" value="<?php _e('Go', 'suchenundersetzen'); ?> »" /></p>
|
| 185 |
+
<input type="hidden" name="submitted" />
|
| 186 |
+
</fieldset>
|
| 187 |
+
</form>
|
| 188 |
+
<hr />
|
| 189 |
+
<p><small><?php _e('"Search and Replace" Originalplugin (en) ist von <a href=\'http://thedeadone.net/\'>Mark Cunningham</a> und wurde erweitert (Kommentarbeiträge, Kommentarautor) durch <a href=\'http://www.gonahkar.com\'>Gonahkar</a>.<br />"Suchen und Ersetzen" wurde erweitert (Kommentarautoren-E-Mail, Kommentarautoren-URLs) in\'s deutsche übersetzt durch <a href=\'http://www.bueltge.de\'>Frank Bueltge</a>', 'suchenundersetzen'); ?></small></p>
|
| 190 |
+
<p><small><?php _e('Further information: Visit the <a href=\'http://bueltge.de/wp-suchen-und-ersetzen-de-plugin/114\'>plugin homepage</a> for further information or to grab the latest version of this plugin.', 'suchenundersetzen'); ?><br />© Copyright 2007 <a href="http://bueltge.de">Frank Bültge</a> | <?php _e('You want to thank me? Visit my <a href=\'http://bueltge.de/wunschliste\'>wishlist</a>.', 'suchenundersetzen'); ?></small></p>
|
| 191 |
+
</div>
|
| 192 |
+
|
| 193 |
+
<?php } ?>
|
