Version Description
- Fix error thrown by regex options, props to leoxavier
- Fix pagination problem
Download this release
Release Info
Developer | johnny5 |
Plugin | Search Regex |
Version | 1.4.16 |
Comparing to | |
See all releases |
Code changes from version 1.4.15 to 1.4.16
- locale/search-regex.pot +192 -0
- messages.po +0 -168
- models/search.php +13 -18
- plugin.php +0 -345
- readme.txt +6 -7
- search-regex.php +79 -42
- searches/comment_author.php +11 -13
- searches/comment_author_email.php +10 -11
- searches/comment_author_url.php +11 -12
- searches/comment_content.php +12 -12
- searches/post_content.php +12 -16
- searches/post_excerpt.php +12 -12
- searches/post_meta.php +11 -13
- searches/post_title.php +17 -13
- searches/post_url.php +12 -12
- view/{admin/results.php → results.php} +0 -0
- view/{admin/search.php → search.php} +34 -14
locale/search-regex.pot
ADDED
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2016 Search Regex
|
2 |
+
# This file is distributed under the same license as the Search Regex package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: Search Regex\n"
|
6 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/plugins/search-regex/\n"
|
7 |
+
"MIME-Version: 1.0\n"
|
8 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
9 |
+
"Content-Transfer-Encoding: 8bit\n"
|
10 |
+
"PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n"
|
11 |
+
"X-Poedit-Basepath: ..\n"
|
12 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
13 |
+
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
14 |
+
"X-Poedit-SearchPath-0: .\n"
|
15 |
+
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
16 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n\n"
|
17 |
+
|
18 |
+
#: models/search.php:31
|
19 |
+
msgid "Invalid regular expression"
|
20 |
+
msgstr ""
|
21 |
+
|
22 |
+
#: models/search.php:73
|
23 |
+
msgid "No search pattern"
|
24 |
+
msgstr ""
|
25 |
+
|
26 |
+
#: search-regex.php:40, search-regex.php:40, search-regex.php:43, search-regex.php:43, view/search.php:3
|
27 |
+
msgid "Search Regex"
|
28 |
+
msgstr ""
|
29 |
+
|
30 |
+
#: searches/comment_author_email.php:39, searches/comment_author_url.php:39, searches/comment_author.php:39, searches/comment_content.php:35, searches/post_meta.php:36
|
31 |
+
msgid "view post"
|
32 |
+
msgstr ""
|
33 |
+
|
34 |
+
#: searches/comment_author_email.php:42, searches/comment_author_url.php:42, searches/comment_author.php:42, searches/comment_content.php:38, searches/post_content.php:35, searches/post_excerpt.php:35, searches/post_meta.php:39, searches/post_title.php:37, searches/post_url.php:35
|
35 |
+
msgid "edit"
|
36 |
+
msgstr ""
|
37 |
+
|
38 |
+
#: searches/comment_author_email.php:48, searches/comment_author_url.php:48, searches/comment_author.php:48, searches/comment_content.php:44
|
39 |
+
msgid "Comment #%d: %s"
|
40 |
+
msgstr ""
|
41 |
+
|
42 |
+
#: searches/comment_author_email.php:51
|
43 |
+
msgid "Comment author email"
|
44 |
+
msgstr ""
|
45 |
+
|
46 |
+
#: searches/comment_author_url.php:51
|
47 |
+
msgid "Comment author URL"
|
48 |
+
msgstr ""
|
49 |
+
|
50 |
+
#: searches/comment_author.php:51
|
51 |
+
msgid "Comment author"
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
+
#: searches/comment_content.php:47
|
55 |
+
msgid "Comment content"
|
56 |
+
msgstr ""
|
57 |
+
|
58 |
+
#: searches/post_content.php:32, searches/post_excerpt.php:32, searches/post_title.php:34, searches/post_url.php:32
|
59 |
+
msgid "view"
|
60 |
+
msgstr ""
|
61 |
+
|
62 |
+
#: searches/post_content.php:41, searches/post_excerpt.php:41, searches/post_title.php:45, searches/post_url.php:41
|
63 |
+
msgid "Post #%d: %s"
|
64 |
+
msgstr ""
|
65 |
+
|
66 |
+
#: searches/post_content.php:44
|
67 |
+
msgid "Post content"
|
68 |
+
msgstr ""
|
69 |
+
|
70 |
+
#: searches/post_excerpt.php:44
|
71 |
+
msgid "Post excerpt"
|
72 |
+
msgstr ""
|
73 |
+
|
74 |
+
#: searches/post_meta.php:45
|
75 |
+
msgid "Meta data for post #%d: %s"
|
76 |
+
msgstr ""
|
77 |
+
|
78 |
+
#: searches/post_meta.php:48
|
79 |
+
msgid "Post meta value"
|
80 |
+
msgstr ""
|
81 |
+
|
82 |
+
#: searches/post_title.php:48
|
83 |
+
msgid "Post title"
|
84 |
+
msgstr ""
|
85 |
+
|
86 |
+
#: searches/post_url.php:44
|
87 |
+
msgid "Post URL"
|
88 |
+
msgstr ""
|
89 |
+
|
90 |
+
#: view/results.php:3
|
91 |
+
msgid "Results"
|
92 |
+
msgstr ""
|
93 |
+
|
94 |
+
#: view/results.php:6
|
95 |
+
msgid "%1$s result(s) found."
|
96 |
+
msgstr ""
|
97 |
+
|
98 |
+
#: view/results.php:19
|
99 |
+
msgid "replaced with:"
|
100 |
+
msgstr ""
|
101 |
+
|
102 |
+
#: view/results.php:59
|
103 |
+
msgid "There are no results."
|
104 |
+
msgstr ""
|
105 |
+
|
106 |
+
#: view/search.php:4
|
107 |
+
msgid "Replacements will only be saved to the database if you click '<strong>Replace & Save</strong>', otherwise you will get a preview of the results."
|
108 |
+
msgstr ""
|
109 |
+
|
110 |
+
#: view/search.php:5
|
111 |
+
msgid "NOTE: <strong>No liability</strong> is accepted for any damage caused. You are strongly advised to backup your database before making any changes."
|
112 |
+
msgstr ""
|
113 |
+
|
114 |
+
#: view/search.php:11
|
115 |
+
msgid "Source"
|
116 |
+
msgstr ""
|
117 |
+
|
118 |
+
#: view/search.php:22
|
119 |
+
msgid "Limit to"
|
120 |
+
msgstr ""
|
121 |
+
|
122 |
+
#: view/search.php:25
|
123 |
+
msgid "No limit"
|
124 |
+
msgstr ""
|
125 |
+
|
126 |
+
#: view/search.php:26
|
127 |
+
msgid "10"
|
128 |
+
msgstr ""
|
129 |
+
|
130 |
+
#: view/search.php:27
|
131 |
+
msgid "25"
|
132 |
+
msgstr ""
|
133 |
+
|
134 |
+
#: view/search.php:28
|
135 |
+
msgid "50"
|
136 |
+
msgstr ""
|
137 |
+
|
138 |
+
#: view/search.php:29
|
139 |
+
msgid "100"
|
140 |
+
msgstr ""
|
141 |
+
|
142 |
+
#: view/search.php:32
|
143 |
+
msgid "Order By"
|
144 |
+
msgstr ""
|
145 |
+
|
146 |
+
#: view/search.php:35
|
147 |
+
msgid "Ascending"
|
148 |
+
msgstr ""
|
149 |
+
|
150 |
+
#: view/search.php:36
|
151 |
+
msgid "Descending"
|
152 |
+
msgstr ""
|
153 |
+
|
154 |
+
#: view/search.php:41
|
155 |
+
msgid "Search pattern"
|
156 |
+
msgstr ""
|
157 |
+
|
158 |
+
#: view/search.php:47
|
159 |
+
msgid "Replace pattern"
|
160 |
+
msgstr ""
|
161 |
+
|
162 |
+
#: view/search.php:53
|
163 |
+
msgid "Regex"
|
164 |
+
msgstr ""
|
165 |
+
|
166 |
+
#: view/search.php:59
|
167 |
+
msgid "case-insensitive:"
|
168 |
+
msgstr ""
|
169 |
+
|
170 |
+
#: view/search.php:63
|
171 |
+
msgid "multi-line:"
|
172 |
+
msgstr ""
|
173 |
+
|
174 |
+
#: view/search.php:67
|
175 |
+
msgid "dot-all:"
|
176 |
+
msgstr ""
|
177 |
+
|
178 |
+
#: view/search.php:71
|
179 |
+
msgid "remember to surround your regex with a delimiter!"
|
180 |
+
msgstr ""
|
181 |
+
|
182 |
+
#: view/search.php:78
|
183 |
+
msgid "Search"
|
184 |
+
msgstr ""
|
185 |
+
|
186 |
+
#: view/search.php:81
|
187 |
+
msgid "Replace"
|
188 |
+
msgstr ""
|
189 |
+
|
190 |
+
#: view/search.php:82
|
191 |
+
msgid "Replace & Save »"
|
192 |
+
msgstr ""
|
messages.po
DELETED
@@ -1,168 +0,0 @@
|
|
1 |
-
# Adds search & replace functionality across posts, pages, comments, and meta-data, with full regular expression support
|
2 |
-
# Copyright (C) 2007 John Godley
|
3 |
-
# This file is distributed under the same license as the Search Regex package.
|
4 |
-
# John Godley, http://urbangiraffe.com/, 2007.
|
5 |
-
#
|
6 |
-
msgid ""
|
7 |
-
msgstr "Project-Id-Version: Search Regex 1.4\n"
|
8 |
-
"Report-Msgid-Bugs-To: \n"
|
9 |
-
"POT-Creation-Date: 2007-03-26 17:31+0800\n"
|
10 |
-
"PO-Revision-Date: 2007-MO-DA HO:MI+ZONE\n"
|
11 |
-
"Last-Translator: John Godley http://urbangiraffe.com/\n"
|
12 |
-
"Language-Team: LANGUAGE <LL@li.org>\n"
|
13 |
-
"MIME-Version: 1.0\n"
|
14 |
-
"Content-Type: text/plain; charset=UTF8\n"
|
15 |
-
"Content-Transfer-Encoding: 8bit\n"
|
16 |
-
|
17 |
-
#: view/admin/results.php:5
|
18 |
-
#, php-format
|
19 |
-
msgid "%1$s result(s) found."
|
20 |
-
msgstr ""
|
21 |
-
|
22 |
-
#: searches/comment_author.php:44 searches/comment_author_email.php:44
|
23 |
-
#: searches/comment_author_url.php:44 searches/comment_content.php:44
|
24 |
-
#, php-format
|
25 |
-
msgid "Comment #%d: %s"
|
26 |
-
msgstr ""
|
27 |
-
|
28 |
-
#: searches/comment_author.php:47
|
29 |
-
msgid "Comment author"
|
30 |
-
msgstr ""
|
31 |
-
|
32 |
-
#: searches/comment_author_url.php:47
|
33 |
-
msgid "Comment author URL"
|
34 |
-
msgstr ""
|
35 |
-
|
36 |
-
#: searches/comment_author_email.php:47
|
37 |
-
msgid "Comment author email"
|
38 |
-
msgstr ""
|
39 |
-
|
40 |
-
#: searches/comment_content.php:47
|
41 |
-
msgid "Comment content"
|
42 |
-
msgstr ""
|
43 |
-
|
44 |
-
#: models/search.php:31
|
45 |
-
msgid "Invalid regular expression"
|
46 |
-
msgstr ""
|
47 |
-
|
48 |
-
#: searches/post_meta.php:45
|
49 |
-
#, php-format
|
50 |
-
msgid "Meta data for post #%d: %s"
|
51 |
-
msgstr ""
|
52 |
-
|
53 |
-
#: view/admin/search.php:4
|
54 |
-
msgid "NOTE: <strong>No liability</strong> is accepted for any damage "
|
55 |
-
"caused. You are strongly advised to backup your database before "
|
56 |
-
"making any changes."
|
57 |
-
msgstr ""
|
58 |
-
|
59 |
-
#: models/search.php:68
|
60 |
-
msgid "No search pattern"
|
61 |
-
msgstr ""
|
62 |
-
|
63 |
-
#: searches/post_content.php:41 searches/post_excerpt.php:41
|
64 |
-
#: searches/post_title.php:41 searches/post_url.php:41
|
65 |
-
#, php-format
|
66 |
-
msgid "Post #%d: %s"
|
67 |
-
msgstr ""
|
68 |
-
|
69 |
-
#: searches/post_url.php:44
|
70 |
-
msgid "Post URL"
|
71 |
-
msgstr ""
|
72 |
-
|
73 |
-
#: searches/post_content.php:44
|
74 |
-
msgid "Post content"
|
75 |
-
msgstr ""
|
76 |
-
|
77 |
-
#: searches/post_excerpt.php:44
|
78 |
-
msgid "Post excerpt"
|
79 |
-
msgstr ""
|
80 |
-
|
81 |
-
#: searches/post_meta.php:48
|
82 |
-
msgid "Post meta value"
|
83 |
-
msgstr ""
|
84 |
-
|
85 |
-
#: searches/post_title.php:44
|
86 |
-
msgid "Post title"
|
87 |
-
msgstr ""
|
88 |
-
|
89 |
-
#: view/admin/search.php:45
|
90 |
-
msgid "Replace"
|
91 |
-
msgstr ""
|
92 |
-
|
93 |
-
#: view/admin/search.php:46
|
94 |
-
msgid "Replace & Save »"
|
95 |
-
msgstr ""
|
96 |
-
|
97 |
-
#: view/admin/search.php:25
|
98 |
-
msgid "Replace pattern"
|
99 |
-
msgstr ""
|
100 |
-
|
101 |
-
#: view/admin/search.php:3
|
102 |
-
msgid "Replacements will only be saved to the database if you click "
|
103 |
-
"'<strong>Replace & Save</strong>', otherwise you will get a "
|
104 |
-
"preview of the results."
|
105 |
-
msgstr ""
|
106 |
-
|
107 |
-
#: view/admin/results.php:2
|
108 |
-
msgid "Results"
|
109 |
-
msgstr ""
|
110 |
-
|
111 |
-
#: view/admin/search.php:44
|
112 |
-
msgid "Search"
|
113 |
-
msgstr ""
|
114 |
-
|
115 |
-
#: search-regex.php:75 view/admin/search.php:2
|
116 |
-
msgid "Search Regex"
|
117 |
-
msgstr ""
|
118 |
-
|
119 |
-
#: view/admin/search.php:19
|
120 |
-
msgid "Search pattern"
|
121 |
-
msgstr ""
|
122 |
-
|
123 |
-
#: view/admin/search.php:9
|
124 |
-
msgid "Source"
|
125 |
-
msgstr ""
|
126 |
-
|
127 |
-
#: view/admin/results.php:58
|
128 |
-
msgid "There are no results."
|
129 |
-
msgstr ""
|
130 |
-
|
131 |
-
#: view/admin/search.php:35
|
132 |
-
msgid "case-insensitive:"
|
133 |
-
msgstr ""
|
134 |
-
|
135 |
-
#: models/search.php:171
|
136 |
-
msgid "deleted"
|
137 |
-
msgstr ""
|
138 |
-
|
139 |
-
#: view/admin/search.php:37
|
140 |
-
msgid "dot-all:"
|
141 |
-
msgstr ""
|
142 |
-
|
143 |
-
#: models/search.php:146 models/search.php:167 searches/comment_author.php:38
|
144 |
-
#: searches/comment_author_email.php:38 searches/comment_author_url.php:38
|
145 |
-
#: searches/comment_content.php:38 searches/post_content.php:35
|
146 |
-
#: searches/post_excerpt.php:35 searches/post_meta.php:39
|
147 |
-
#: searches/post_title.php:35 searches/post_url.php:35
|
148 |
-
msgid "edit"
|
149 |
-
msgstr ""
|
150 |
-
|
151 |
-
#: view/admin/search.php:36
|
152 |
-
msgid "multi-line:"
|
153 |
-
msgstr ""
|
154 |
-
|
155 |
-
#: view/admin/results.php:18
|
156 |
-
msgid "replaced with:"
|
157 |
-
msgstr ""
|
158 |
-
|
159 |
-
#: searches/post_content.php:30 searches/post_excerpt.php:30
|
160 |
-
#: searches/post_title.php:30 searches/post_url.php:30
|
161 |
-
msgid "view"
|
162 |
-
msgstr ""
|
163 |
-
|
164 |
-
#: searches/comment_author.php:33 searches/comment_author_email.php:33
|
165 |
-
#: searches/comment_author_url.php:33 searches/comment_content.php:33
|
166 |
-
#: searches/post_meta.php:34
|
167 |
-
msgid "view post"
|
168 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
models/search.php
CHANGED
@@ -103,7 +103,7 @@ class Search
|
|
103 |
static function valid_search( $class ) {
|
104 |
$classes = Search::get_searches();
|
105 |
foreach ( $classes AS $item ) {
|
106 |
-
if ( strcasecmp( get_class( $item ), $class )
|
107 |
return true;
|
108 |
}
|
109 |
|
@@ -146,14 +146,13 @@ class Search
|
|
146 |
if( $start != 0)
|
147 |
$result->search = '… ';
|
148 |
|
149 |
-
$result->search .=
|
150 |
-
$result->search .= '<
|
151 |
-
$result->search .=
|
152 |
-
$result->search .= htmlspecialchars( $right, HTML_ENTITIES, 'UTF-8');
|
153 |
|
154 |
-
$result->search_plain =
|
155 |
-
$result->search_plain .=
|
156 |
-
$result->search_plain .=
|
157 |
|
158 |
if( $start + $end < strlen( $content))
|
159 |
$result->search .= ' …';
|
@@ -167,19 +166,15 @@ class Search
|
|
167 |
if( $start != 0)
|
168 |
$result->replace = '… ';
|
169 |
|
170 |
-
$result->replace .=
|
171 |
-
$result->replace .= '<
|
172 |
-
|
173 |
-
$result->replace .= '<strong>'.htmlspecialchars( $rep, HTML_ENTITIES, 'UTF-8').'</strong></a>';
|
174 |
-
else
|
175 |
-
$result->replace .= '<strong>['.__( 'deleted','search-regex').']</strong></a>';
|
176 |
-
$result->replace .= htmlspecialchars( $right, HTML_ENTITIES, 'UTF-8');
|
177 |
|
178 |
$result->left_length_replace = strlen( $left) + strlen( $rep) + strlen( $right) + 1;
|
179 |
|
180 |
-
$result->replace_plain =
|
181 |
-
$result->replace_plain .=
|
182 |
-
$result->replace_plain .=
|
183 |
|
184 |
if( $start + $end < strlen( $content))
|
185 |
$result->replace .= ' …';
|
103 |
static function valid_search( $class ) {
|
104 |
$classes = Search::get_searches();
|
105 |
foreach ( $classes AS $item ) {
|
106 |
+
if ( strcasecmp( get_class( $item ), $class ) === 0 )
|
107 |
return true;
|
108 |
}
|
109 |
|
146 |
if( $start != 0)
|
147 |
$result->search = '… ';
|
148 |
|
149 |
+
$result->search .= esc_html( $left );
|
150 |
+
$result->search .= '<strong>'.esc_html( $found[0] ).'</strong>';
|
151 |
+
$result->search .= esc_html( $right );
|
|
|
152 |
|
153 |
+
$result->search_plain = esc_html( $left );
|
154 |
+
$result->search_plain .= esc_html( $found[0] );
|
155 |
+
$result->search_plain .= esc_html( $right );
|
156 |
|
157 |
if( $start + $end < strlen( $content))
|
158 |
$result->search .= ' …';
|
166 |
if( $start != 0)
|
167 |
$result->replace = '… ';
|
168 |
|
169 |
+
$result->replace .= esc_html( $left );
|
170 |
+
$result->replace .= '<strong>'.esc_html( $rep ).'</strong></a>';
|
171 |
+
$result->replace .= esc_html( $right );
|
|
|
|
|
|
|
|
|
172 |
|
173 |
$result->left_length_replace = strlen( $left) + strlen( $rep) + strlen( $right) + 1;
|
174 |
|
175 |
+
$result->replace_plain = esc_html( $left );
|
176 |
+
$result->replace_plain .= esc_html( $rep );
|
177 |
+
$result->replace_plain .= esc_html( $right );
|
178 |
|
179 |
if( $start + $end < strlen( $content))
|
180 |
$result->replace .= ' …';
|
plugin.php
DELETED
@@ -1,345 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// ======================================================================================
|
4 |
-
// This library is free software; you can redistribute it and/or
|
5 |
-
// modify it under the terms of the GNU Lesser General Public
|
6 |
-
// License as published by the Free Software Foundation; either
|
7 |
-
// version 2.1 of the License, or (at your option) any later version.
|
8 |
-
//
|
9 |
-
// This library is distributed in the hope that it will be useful,
|
10 |
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12 |
-
// Lesser General Public License for more details.
|
13 |
-
// ======================================================================================
|
14 |
-
// @author John Godley (http://urbangiraffe.com)
|
15 |
-
// @version 0.1.26
|
16 |
-
// @copyright Copyright © 2007 John Godley, All Rights Reserved
|
17 |
-
// ======================================================================================
|
18 |
-
// 0.1.6 - Corrected WP locale functions
|
19 |
-
// 0.1.7 - Add phpdoc comments
|
20 |
-
// 0.1.8 - Support for Admin SSL
|
21 |
-
// 0.1.9 - URL encoding, defer localization until init
|
22 |
-
// 0.1.10 - Better URL encoding
|
23 |
-
// 0.1.11 - Make work in WP 2.0, fix HTTPS issue on IIS
|
24 |
-
// 0.1.12 - Activation/deactivation actions that take into account the directory
|
25 |
-
// 0.1.13 - Add realpath function
|
26 |
-
// 0.1.14 - Add select/checked functions, fix locale loader
|
27 |
-
// 0.1.15 - Remove dependency on prototype
|
28 |
-
// 0.1.16 - Add support for homedir in realpath
|
29 |
-
// 0.1.17 - Added widget class
|
30 |
-
// 0.1.18 - Expand checked function
|
31 |
-
// 0.1.19 - Make url() cope with sites with no trailing slash
|
32 |
-
// 0.1.20 - Change init function to prevent overloading
|
33 |
-
// 0.1.21 - Make widget work for WP 2.1
|
34 |
-
// 0.1.22 - Make select work with option groups, RSS compatability fix
|
35 |
-
// 0.1.23 - Make widget count work better, fix widgets in K2
|
36 |
-
// 0.1.24 - Make realpath better
|
37 |
-
// 0.1.25 - Support for new WP2.6 config location
|
38 |
-
// 0.1.26 - Add description to widget class
|
39 |
-
// ======================================================================================
|
40 |
-
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Wraps up several useful functions for WordPress plugins and provides a method to separate
|
44 |
-
* display HTML from PHP code.
|
45 |
-
*
|
46 |
-
* <h4>Display Rendering</h4>
|
47 |
-
* The class uses a similar technique to Ruby On Rails views, whereby the display HTML is kept
|
48 |
-
* in a separate directory and file from the main code. A display is 'rendered' (sent to the browser)
|
49 |
-
* or 'captured' (returned to the calling function).
|
50 |
-
*
|
51 |
-
* Template files are separated into two areas: admin and user. Admin templates are only for display in
|
52 |
-
* the WordPress admin interface, while user templates are typically for display on the site (although neither
|
53 |
-
* of these are enforced). All templates are PHP code, but are referred to without .php extension.
|
54 |
-
*
|
55 |
-
* The reason for this separation is that one golden rule of plugin creation is that someone will always want to change
|
56 |
-
* the formatting and style of your output. Rather than forcing them to modify the plugin (bad), or modify files within
|
57 |
-
* the plugin (equally bad), the class allows user templates to be overridden with files contained within the theme.
|
58 |
-
*
|
59 |
-
* An additional benefit is that it leads to code re-use, especially with regards to Ajax (i.e. your display code can be called from
|
60 |
-
* many locations)
|
61 |
-
*
|
62 |
-
* Template files are located within the 'view' subdirectory of the plugins base (specified when registering the plugin):
|
63 |
-
*
|
64 |
-
* <pre>myplugin/view/admin
|
65 |
-
* myplugin/view/myplugin</pre>
|
66 |
-
*
|
67 |
-
* Admin templates are contained within 'admin', and user templates are contained within a directory of the same name as the plugin.
|
68 |
-
*
|
69 |
-
* User files can be overridden within the theme by creating a similar directory structure:
|
70 |
-
*
|
71 |
-
* <pre>/themes/mytheme/view/myplugin</pre>
|
72 |
-
*
|
73 |
-
* The class will first look in the theme and then defaults to the plugin. A plugin should always provide default templates.
|
74 |
-
*
|
75 |
-
* <h4>Display Parameters</h4>
|
76 |
-
* Also similar to Ruby On Rails, when you display a template you must supply the parameters that the template has access to. This tries
|
77 |
-
* to ensure a very clean separation between code and display. Parameters are supplied as an associative array mapping variable name to variable value.
|
78 |
-
*
|
79 |
-
* For example,
|
80 |
-
*
|
81 |
-
* array ('message' => 'Your data was processed', 'items' => 103);
|
82 |
-
*
|
83 |
-
* <h4>How it works in practice</h4>
|
84 |
-
* You create a template file to display how many items have been processed. You store this in 'view/admin/processed.php':
|
85 |
-
*
|
86 |
-
* <pre><p>You processed <?php echo $items ?> items</p></pre>
|
87 |
-
*
|
88 |
-
* When you want to display this in your plugin you use:
|
89 |
-
*
|
90 |
-
* <pre> $this->render_admin ('processed', array ('items' => 100));
|
91 |
-
*
|
92 |
-
* @package WordPress base library
|
93 |
-
* @author John Godley
|
94 |
-
* @copyright Copyright (C) John Godley
|
95 |
-
**/
|
96 |
-
|
97 |
-
class SearchRegex_Plugin
|
98 |
-
{
|
99 |
-
/**
|
100 |
-
* Plugin name
|
101 |
-
* @var string
|
102 |
-
**/
|
103 |
-
var $plugin_name;
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Plugin 'view' directory
|
107 |
-
* @var string Directory
|
108 |
-
**/
|
109 |
-
var $plugin_base;
|
110 |
-
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Register your plugin with a name and base directory. This <strong>must</strong> be called once.
|
114 |
-
*
|
115 |
-
* @param string $name Name of your plugin. Is used to determine the plugin locale domain
|
116 |
-
* @param string $base Directory containing the plugin's 'view' files.
|
117 |
-
* @return void
|
118 |
-
**/
|
119 |
-
|
120 |
-
function register_plugin ($name, $base)
|
121 |
-
{
|
122 |
-
$this->plugin_base = rtrim (dirname ($base), '/');
|
123 |
-
$this->plugin_name = $name;
|
124 |
-
|
125 |
-
$this->add_action ('init', 'load_locale');
|
126 |
-
}
|
127 |
-
|
128 |
-
function load_locale ()
|
129 |
-
{
|
130 |
-
// Here we manually fudge the plugin locale as WP doesnt allow many options
|
131 |
-
$locale = get_locale ();
|
132 |
-
if ( empty($locale) )
|
133 |
-
$locale = 'en_US';
|
134 |
-
|
135 |
-
$mofile = dirname (__FILE__)."/locale/$locale.mo";
|
136 |
-
load_textdomain ($this->plugin_name, $mofile);
|
137 |
-
}
|
138 |
-
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Register a WordPress action and map it back to the calling object
|
142 |
-
*
|
143 |
-
* @param string $action Name of the action
|
144 |
-
* @param string $function Function name (optional)
|
145 |
-
* @param int $priority WordPress priority (optional)
|
146 |
-
* @param int $accepted_args Number of arguments the function accepts (optional)
|
147 |
-
* @return void
|
148 |
-
**/
|
149 |
-
|
150 |
-
function add_action ($action, $function = '', $priority = 10, $accepted_args = 1)
|
151 |
-
{
|
152 |
-
add_action ($action, array (&$this, $function == '' ? $action : $function), $priority, $accepted_args);
|
153 |
-
}
|
154 |
-
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Register a WordPress filter and map it back to the calling object
|
158 |
-
*
|
159 |
-
* @param string $action Name of the action
|
160 |
-
* @param string $function Function name (optional)
|
161 |
-
* @param int $priority WordPress priority (optional)
|
162 |
-
* @param int $accepted_args Number of arguments the function accepts (optional)
|
163 |
-
* @return void
|
164 |
-
**/
|
165 |
-
|
166 |
-
function add_filter ($filter, $function = '', $priority = 10, $accepted_args = 1)
|
167 |
-
{
|
168 |
-
add_filter ($filter, array (&$this, $function == '' ? $filter : $function), $priority, $accepted_args);
|
169 |
-
}
|
170 |
-
|
171 |
-
|
172 |
-
/**
|
173 |
-
* Special activation function that takes into account the plugin directory
|
174 |
-
*
|
175 |
-
* @param string $pluginfile The plugin file location (i.e. __FILE__)
|
176 |
-
* @param string $function Optional function name, or default to 'activate'
|
177 |
-
* @return void
|
178 |
-
**/
|
179 |
-
|
180 |
-
function register_activation ($pluginfile, $function = '')
|
181 |
-
{
|
182 |
-
add_action ('activate_'.basename (dirname ($pluginfile)).'/'.basename ($pluginfile), array (&$this, $function == '' ? 'activate' : $function));
|
183 |
-
}
|
184 |
-
|
185 |
-
|
186 |
-
/**
|
187 |
-
* Special deactivation function that takes into account the plugin directory
|
188 |
-
*
|
189 |
-
* @param string $pluginfile The plugin file location (i.e. __FILE__)
|
190 |
-
* @param string $function Optional function name, or default to 'deactivate'
|
191 |
-
* @return void
|
192 |
-
**/
|
193 |
-
|
194 |
-
function register_deactivation ($pluginfile, $function = '')
|
195 |
-
{
|
196 |
-
add_action ('deactivate_'.basename (dirname ($pluginfile)).'/'.basename ($pluginfile), array (&$this, $function == '' ? 'deactivate' : $function));
|
197 |
-
}
|
198 |
-
|
199 |
-
|
200 |
-
/**
|
201 |
-
* Renders an admin section of display code
|
202 |
-
*
|
203 |
-
* @param string $ug_name Name of the admin file (without extension)
|
204 |
-
* @param string $array Array of variable name=>value that is available to the display code (optional)
|
205 |
-
* @return void
|
206 |
-
**/
|
207 |
-
|
208 |
-
function render_admin ($ug_name, $ug_vars = array ())
|
209 |
-
{
|
210 |
-
global $plugin_base;
|
211 |
-
foreach ($ug_vars AS $key => $val)
|
212 |
-
$$key = $val;
|
213 |
-
|
214 |
-
if (file_exists ("{$this->plugin_base}/view/admin/$ug_name.php"))
|
215 |
-
include ("{$this->plugin_base}/view/admin/$ug_name.php");
|
216 |
-
else
|
217 |
-
echo "<p>Rendering of admin template {$this->plugin_base}/view/admin/$ug_name.php failed</p>";
|
218 |
-
}
|
219 |
-
|
220 |
-
|
221 |
-
/**
|
222 |
-
* Renders a section of user display code. The code is first checked for in the current theme display directory
|
223 |
-
* before defaulting to the plugin
|
224 |
-
*
|
225 |
-
* @param string $ug_name Name of the admin file (without extension)
|
226 |
-
* @param string $array Array of variable name=>value that is available to the display code (optional)
|
227 |
-
* @return void
|
228 |
-
**/
|
229 |
-
|
230 |
-
function render ($ug_name, $ug_vars = array ())
|
231 |
-
{
|
232 |
-
foreach ($ug_vars AS $key => $val)
|
233 |
-
$$key = $val;
|
234 |
-
|
235 |
-
if (file_exists (TEMPLATEPATH."/view/{$this->plugin_name}/$ug_name.php"))
|
236 |
-
include (TEMPLATEPATH."/view/{$this->plugin_name}/$ug_name.php");
|
237 |
-
else if (file_exists ("{$this->plugin_base}/view/{$this->plugin_name}/$ug_name.php"))
|
238 |
-
include ("{$this->plugin_base}/view/{$this->plugin_name}/$ug_name.php");
|
239 |
-
else
|
240 |
-
echo "<p>Rendering of template $ug_name.php failed</p>";
|
241 |
-
}
|
242 |
-
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Renders a section of user display code. The code is first checked for in the current theme display directory
|
246 |
-
* before defaulting to the plugin
|
247 |
-
*
|
248 |
-
* @param string $ug_name Name of the admin file (without extension)
|
249 |
-
* @param string $array Array of variable name=>value that is available to the display code (optional)
|
250 |
-
* @return void
|
251 |
-
**/
|
252 |
-
|
253 |
-
function capture ($ug_name, $ug_vars = array ())
|
254 |
-
{
|
255 |
-
ob_start ();
|
256 |
-
$this->render ($ug_name, $ug_vars);
|
257 |
-
$output = ob_get_contents ();
|
258 |
-
ob_end_clean ();
|
259 |
-
return $output;
|
260 |
-
}
|
261 |
-
|
262 |
-
|
263 |
-
/**
|
264 |
-
* Captures an admin section of display code
|
265 |
-
*
|
266 |
-
* @param string $ug_name Name of the admin file (without extension)
|
267 |
-
* @param string $array Array of variable name=>value that is available to the display code (optional)
|
268 |
-
* @return string Captured code
|
269 |
-
**/
|
270 |
-
|
271 |
-
function capture_admin ($ug_name, $ug_vars = array ())
|
272 |
-
{
|
273 |
-
ob_start ();
|
274 |
-
$this->render_admin ($ug_name, $ug_vars);
|
275 |
-
$output = ob_get_contents ();
|
276 |
-
ob_end_clean ();
|
277 |
-
return $output;
|
278 |
-
}
|
279 |
-
|
280 |
-
function select ($items, $default = '')
|
281 |
-
{
|
282 |
-
if (count ($items) > 0)
|
283 |
-
{
|
284 |
-
foreach ($items AS $key => $value)
|
285 |
-
{
|
286 |
-
if (is_array ($value))
|
287 |
-
{
|
288 |
-
echo '<optgroup label="'.$key.'">';
|
289 |
-
foreach ($value AS $sub => $subvalue)
|
290 |
-
echo '<option value="'.esc_attr( $sub ).'"'.($sub == $default ? ' selected="selected"' : '').'>'.esc_html( $subvalue ).'</option>';
|
291 |
-
echo '</optgroup>';
|
292 |
-
}
|
293 |
-
else
|
294 |
-
echo '<option value="'.esc_attr( $key ).'"'.($key == $default ? ' selected="selected"' : '').'>'.esc_html( $value ).'</option>';
|
295 |
-
}
|
296 |
-
}
|
297 |
-
}
|
298 |
-
|
299 |
-
/**
|
300 |
-
* Display a standard error message (using CSS ID 'message' and classes 'fade' and 'error)
|
301 |
-
*
|
302 |
-
* @param string $message Message to display
|
303 |
-
* @return void
|
304 |
-
**/
|
305 |
-
|
306 |
-
function render_error ($message)
|
307 |
-
{
|
308 |
-
?>
|
309 |
-
<div class="fade error" id="message">
|
310 |
-
<p><?php echo $message ?></p>
|
311 |
-
</div>
|
312 |
-
<?php
|
313 |
-
}
|
314 |
-
|
315 |
-
|
316 |
-
/**
|
317 |
-
* Display a standard notice (using CSS ID 'message' and class 'updated').
|
318 |
-
* Note that the notice can be made to automatically disappear, and can be removed
|
319 |
-
* by clicking on it.
|
320 |
-
*
|
321 |
-
* @param string $message Message to display
|
322 |
-
* @param int $timeout Number of seconds to automatically remove the message (optional)
|
323 |
-
* @return void
|
324 |
-
**/
|
325 |
-
|
326 |
-
function render_message ($message, $timeout = 0)
|
327 |
-
{
|
328 |
-
?>
|
329 |
-
<div class="updated" id="message" onclick="this.parentNode.removeChild (this)">
|
330 |
-
<p><?php echo $message ?></p>
|
331 |
-
</div>
|
332 |
-
<?php
|
333 |
-
}
|
334 |
-
|
335 |
-
}
|
336 |
-
|
337 |
-
if (!function_exists ('pr'))
|
338 |
-
{
|
339 |
-
function pr ($thing)
|
340 |
-
{
|
341 |
-
echo '<pre>';
|
342 |
-
print_r ($thing);
|
343 |
-
echo '</pre>';
|
344 |
-
}
|
345 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: johnny5
|
3 |
Donate link: http://urbangiraffe.com/about/support/
|
4 |
Tags: search, regex, regular expression, admin, post, page
|
5 |
-
Requires at least:
|
6 |
-
Tested up to: 4.
|
7 |
Stable tag: trunk
|
8 |
|
9 |
Search Regex adds a powerful set of search and replace functions to WordPress that go beyond the standard searching capabilities, with full regex support.
|
@@ -45,6 +45,10 @@ Full documentation can be found on the [Search Regex Page](http://urbangiraffe.c
|
|
45 |
|
46 |
== Changelog ==
|
47 |
|
|
|
|
|
|
|
|
|
48 |
= 1.4.15 =
|
49 |
* Minor refresh
|
50 |
|
@@ -100,8 +104,3 @@ Full documentation can be found on the [Search Regex Page](http://urbangiraffe.c
|
|
100 |
= 1.1 =
|
101 |
* Minor cosmetic changes
|
102 |
* Set a timeout limit
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
2 |
Contributors: johnny5
|
3 |
Donate link: http://urbangiraffe.com/about/support/
|
4 |
Tags: search, regex, regular expression, admin, post, page
|
5 |
+
Requires at least: 4.1
|
6 |
+
Tested up to: 4.5
|
7 |
Stable tag: trunk
|
8 |
|
9 |
Search Regex adds a powerful set of search and replace functions to WordPress that go beyond the standard searching capabilities, with full regex support.
|
45 |
|
46 |
== Changelog ==
|
47 |
|
48 |
+
= 1.4.16 =
|
49 |
+
* Fix error thrown by regex options, props to leoxavier
|
50 |
+
* Fix pagination problem
|
51 |
+
|
52 |
= 1.4.15 =
|
53 |
* Minor refresh
|
54 |
|
104 |
= 1.1 =
|
105 |
* Minor cosmetic changes
|
106 |
* Set a timeout limit
|
|
|
|
|
|
|
|
|
|
search-regex.php
CHANGED
@@ -4,44 +4,69 @@ Plugin Name: Search Regex
|
|
4 |
Plugin URI: http://urbangiraffe.com/plugins/search-regex
|
5 |
Description: Adds search & replace functionality across posts, pages, comments, and meta-data, with full regular expression support
|
6 |
Author: John Godley
|
7 |
-
Version: 1.4.
|
8 |
Author URI: http://urbangiraffe.com/
|
9 |
*/
|
10 |
|
11 |
-
|
|
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
19 |
}
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
function search_head() {
|
23 |
include dirname( __FILE__ ).'/models/search.php';
|
24 |
include dirname( __FILE__ ).'/models/result.php';
|
25 |
|
26 |
-
wp_enqueue_style( 'search-regex', plugin_dir_url( __FILE__ ).'admin.css'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
-
function admin_screen()
|
30 |
$searches = Search::get_searches();
|
31 |
|
|
|
|
|
|
|
|
|
32 |
$search_pattern = $replace_pattern = '';
|
33 |
-
if ( isset( $_POST['search_pattern'] ) )
|
34 |
$search_pattern = stripslashes( $_POST['search_pattern'] );
|
|
|
35 |
|
36 |
-
if ( isset( $_POST['replace_pattern'] ) )
|
37 |
$replace_pattern = stripslashes( $_POST['replace_pattern'] );
|
|
|
38 |
|
39 |
$search_pattern = str_replace( "\'", "'", $search_pattern );
|
40 |
$replace_pattern = str_replace( "\'", "'", $replace_pattern );
|
41 |
$orderby = 'asc';
|
42 |
|
43 |
-
if ( isset( $_POST['orderby'] ) && $_POST['orderby']
|
44 |
$orderby = 'desc';
|
|
|
45 |
|
46 |
$limit = isset( $_POST['limit'] ) ? intval( $_POST['limit'] ) : 10;
|
47 |
$offset = 0;
|
@@ -51,11 +76,12 @@ class SearchRegex extends SearchRegex_Plugin {
|
|
51 |
$klass = stripslashes( $source );
|
52 |
$searcher = new $klass;
|
53 |
|
54 |
-
if ( isset( $_POST['regex'] ) )
|
55 |
-
$searcher->set_regex_options( $_POST['
|
|
|
56 |
|
57 |
// Make sure no one sneaks in with a replace
|
58 |
-
if ( !current_user_can( 'administrator' ) && !current_user_can( 'search_regex_write' ) ) {
|
59 |
unset( $_POST['replace'] );
|
60 |
unset( $_POST['replace_and_save'] );
|
61 |
$_POST['search'] = 'search';
|
@@ -63,45 +89,56 @@ class SearchRegex extends SearchRegex_Plugin {
|
|
63 |
|
64 |
$results = array();
|
65 |
|
66 |
-
if ( isset( $_POST['search'] ) )
|
67 |
$results = $searcher->search_for_pattern( $search_pattern, $limit, $offset, $orderby );
|
68 |
-
|
|
|
69 |
$results = $searcher->search_and_replace( $search_pattern, $replace_pattern, $limit, $offset, $orderby );
|
70 |
-
|
|
|
71 |
$results = $searcher->search_and_replace( $search_pattern, $replace_pattern, $limit, $offset, $orderby, true );
|
|
|
72 |
|
73 |
-
if ( !is_array( $results ) )
|
74 |
$this->render_error( $results );
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
-
$this->
|
79 |
|
80 |
-
if ( is_array( $results ) && !isset( $_POST['replace_and_save'] ) )
|
81 |
-
$this->
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
-
else
|
84 |
-
$this->render_admin( 'search', array( 'search' => $search_pattern, 'replace' => $replace_pattern, 'searches' => $searches, 'source' => $source ) );
|
85 |
}
|
86 |
|
87 |
-
function
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
add_management_page( __( "Search Regex", 'search-regex' ), __( "Search Regex", 'search-regex' ), 'search_regex_read', basename(__FILE__), array( &$this, 'admin_screen' ) );
|
92 |
-
}
|
93 |
|
94 |
-
|
95 |
-
|
96 |
}
|
97 |
|
98 |
-
function
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
}
|
105 |
}
|
106 |
|
107 |
-
|
|
|
|
4 |
Plugin URI: http://urbangiraffe.com/plugins/search-regex
|
5 |
Description: Adds search & replace functionality across posts, pages, comments, and meta-data, with full regular expression support
|
6 |
Author: John Godley
|
7 |
+
Version: 1.4.16
|
8 |
Author URI: http://urbangiraffe.com/
|
9 |
*/
|
10 |
|
11 |
+
class SearchRegex {
|
12 |
+
private static $instance = null;
|
13 |
|
14 |
+
static function init() {
|
15 |
+
if ( is_admin() ) {
|
16 |
+
if ( is_null( self::$instance ) ) {
|
17 |
+
self::$instance = new SearchRegex();
|
18 |
+
|
19 |
+
load_plugin_textdomain( 'search-regex', false, dirname( plugin_basename( __FILE__ ) ).'/locale/' );
|
20 |
+
}
|
21 |
+
|
22 |
+
return self::$instance;
|
23 |
}
|
24 |
}
|
25 |
|
26 |
+
function __construct() {
|
27 |
+
add_filter( 'admin_menu', array( &$this, 'admin_menu' ) );
|
28 |
+
add_action( 'load-tools_page_search-regex', array( &$this, 'search_head' ) );
|
29 |
+
}
|
30 |
+
|
31 |
function search_head() {
|
32 |
include dirname( __FILE__ ).'/models/search.php';
|
33 |
include dirname( __FILE__ ).'/models/result.php';
|
34 |
|
35 |
+
wp_enqueue_style( 'search-regex', plugin_dir_url( __FILE__ ).'admin.css' );
|
36 |
+
}
|
37 |
+
|
38 |
+
function admin_menu() {
|
39 |
+
if ( current_user_can( 'administrator' ) ) {
|
40 |
+
add_management_page( __( 'Search Regex', 'search-regex' ), __( 'Search Regex', 'search-regex' ), 'administrator', basename( __FILE__ ), array( &$this, 'admin_screen' ) );
|
41 |
+
}
|
42 |
+
elseif ( current_user_can( 'search_regex_read' ) ) {
|
43 |
+
add_management_page( __( 'Search Regex', 'search-regex' ), __( 'Search Regex', 'search-regex' ), 'search_regex_read', basename( __FILE__ ), array( &$this, 'admin_screen' ) );
|
44 |
+
}
|
45 |
}
|
46 |
|
47 |
+
function admin_screen() {
|
48 |
$searches = Search::get_searches();
|
49 |
|
50 |
+
if ( isset( $_POST['search_pattern'] ) && ! wp_verify_nonce( $_POST['search-regex-nonce'], 'search' ) ) {
|
51 |
+
return;
|
52 |
+
}
|
53 |
+
|
54 |
$search_pattern = $replace_pattern = '';
|
55 |
+
if ( isset( $_POST['search_pattern'] ) ) {
|
56 |
$search_pattern = stripslashes( $_POST['search_pattern'] );
|
57 |
+
}
|
58 |
|
59 |
+
if ( isset( $_POST['replace_pattern'] ) ) {
|
60 |
$replace_pattern = stripslashes( $_POST['replace_pattern'] );
|
61 |
+
}
|
62 |
|
63 |
$search_pattern = str_replace( "\'", "'", $search_pattern );
|
64 |
$replace_pattern = str_replace( "\'", "'", $replace_pattern );
|
65 |
$orderby = 'asc';
|
66 |
|
67 |
+
if ( isset( $_POST['orderby'] ) && $_POST['orderby'] === 'desc' ) {
|
68 |
$orderby = 'desc';
|
69 |
+
}
|
70 |
|
71 |
$limit = isset( $_POST['limit'] ) ? intval( $_POST['limit'] ) : 10;
|
72 |
$offset = 0;
|
76 |
$klass = stripslashes( $source );
|
77 |
$searcher = new $klass;
|
78 |
|
79 |
+
if ( isset( $_POST['regex'] ) ) {
|
80 |
+
$searcher->set_regex_options( isset( $_POST['regex_dot'] ) ? $_POST['regex_dot'] : false, isset( $_POST['regex_case'] ) ? $_POST['regex_case'] : false, isset( $_POST['regex_multi'] ) ? $_POST['regex_multi'] : false );
|
81 |
+
}
|
82 |
|
83 |
// Make sure no one sneaks in with a replace
|
84 |
+
if ( ! current_user_can( 'administrator' ) && ! current_user_can( 'search_regex_write' ) ) {
|
85 |
unset( $_POST['replace'] );
|
86 |
unset( $_POST['replace_and_save'] );
|
87 |
$_POST['search'] = 'search';
|
89 |
|
90 |
$results = array();
|
91 |
|
92 |
+
if ( isset( $_POST['search'] ) ) {
|
93 |
$results = $searcher->search_for_pattern( $search_pattern, $limit, $offset, $orderby );
|
94 |
+
}
|
95 |
+
elseif ( isset( $_POST['replace'] ) ) {
|
96 |
$results = $searcher->search_and_replace( $search_pattern, $replace_pattern, $limit, $offset, $orderby );
|
97 |
+
}
|
98 |
+
elseif ( isset( $_POST['replace_and_save'] ) ) {
|
99 |
$results = $searcher->search_and_replace( $search_pattern, $replace_pattern, $limit, $offset, $orderby, true );
|
100 |
+
}
|
101 |
|
102 |
+
if ( ! is_array( $results ) ) {
|
103 |
$this->render_error( $results );
|
104 |
+
}
|
105 |
+
elseif ( isset( $_POST['replace_and_save'] ) ) {
|
106 |
+
?>
|
107 |
+
<div class="updated" id="message" onclick="this.parentNode.removeChild (this)">
|
108 |
+
<p><?php printf( _n( '%d occurrence replaced', '%d occurrences replaced', count( $results ) ), count( $results ) ) ?></p>
|
109 |
+
</div>
|
110 |
+
<?php
|
111 |
+
}
|
112 |
|
113 |
+
$this->render( 'search', array( 'search' => $search_pattern, 'replace' => $replace_pattern, 'searches' => $searches, 'source' => $source ) );
|
114 |
|
115 |
+
if ( is_array( $results ) && ! isset( $_POST['replace_and_save'] ) ) {
|
116 |
+
$this->render( 'results', array( 'search' => $searcher, 'results' => $results ) );
|
117 |
+
}
|
118 |
+
}
|
119 |
+
else {
|
120 |
+
$this->render( 'search', array( 'search' => $search_pattern, 'replace' => $replace_pattern, 'searches' => $searches, 'source' => $source ) );
|
121 |
}
|
|
|
|
|
122 |
}
|
123 |
|
124 |
+
private function render( $template, $template_vars = array() ) {
|
125 |
+
foreach ( $template_vars as $key => $val ) {
|
126 |
+
$$key = $val;
|
127 |
+
}
|
|
|
|
|
128 |
|
129 |
+
if ( file_exists( dirname( __FILE__ )."/view/$template.php" ) )
|
130 |
+
include dirname( __FILE__ )."/view/$template.php";
|
131 |
}
|
132 |
|
133 |
+
function render_error( $message ) {
|
134 |
+
?>
|
135 |
+
<div class="fade error" id="message">
|
136 |
+
<p><?php echo $message ?></p>
|
137 |
+
</div>
|
138 |
+
<?php
|
139 |
}
|
140 |
}
|
141 |
|
142 |
+
if ( is_admin() ) {
|
143 |
+
add_action( 'init', array( 'SearchRegex', 'init' ) );
|
144 |
+
}
|
searches/comment_author.php
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class SearchCommentAuthor extends Search
|
4 |
-
{
|
5 |
-
function find ($pattern, $limit, $offset, $orderby)
|
6 |
-
{
|
7 |
global $wpdb;
|
8 |
|
9 |
if ($orderby == 'id')
|
@@ -11,12 +9,15 @@ class SearchCommentAuthor extends Search
|
|
11 |
else
|
12 |
$order = 'comment_date DESC';
|
13 |
|
14 |
-
$results = array
|
15 |
-
$
|
16 |
-
if (
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
20 |
if (($matches = $this->matches ($pattern, $comment->comment_author, $comment->comment_ID)))
|
21 |
{
|
22 |
foreach ($matches AS $match)
|
@@ -36,8 +37,6 @@ class SearchCommentAuthor extends Search
|
|
36 |
function get_options ($result)
|
37 |
{
|
38 |
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
39 |
-
if ($result->replace)
|
40 |
-
$options[] = '<a href="#" onclick="regex_replace (\'SearchCommentAuthor\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
41 |
|
42 |
if (current_user_can ('edit_post', $result->id))
|
43 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/comment.php?action=editcomment&c='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
@@ -65,4 +64,3 @@ class SearchCommentAuthor extends Search
|
|
65 |
$wpdb->query ($wpdb->prepare( "UPDATE {$wpdb->comments} SET comment_author=%s WHERE comment_ID=%d", $content, $id ) );
|
66 |
}
|
67 |
}
|
68 |
-
|
1 |
<?php
|
2 |
|
3 |
+
class SearchCommentAuthor extends Search {
|
4 |
+
function find( $pattern, $limit, $offset, $orderby ) {
|
|
|
|
|
5 |
global $wpdb;
|
6 |
|
7 |
if ($orderby == 'id')
|
9 |
else
|
10 |
$order = 'comment_date DESC';
|
11 |
|
12 |
+
$results = array();
|
13 |
+
$sql = "SELECT {$wpdb->comments}.comment_ID AS comment_ID, {$wpdb->comments}.comment_post_ID AS comment_post_ID, {$wpdb->comments}.comment_author AS comment_author, {$wpdb->posts}.post_title AS post_title FROM {$wpdb->comments},{$wpdb->posts} WHERE {$wpdb->comments}.comment_approved='1' AND {$wpdb->posts}.ID={$wpdb->comments}.comment_post_ID ORDER BY {$wpdb->comments}.comment_ID $orderby";
|
14 |
+
if ( $limit > 0 ) {
|
15 |
+
$sql .= $wpdb->prepare( "LIMIT %d,%d", $offset, $limit );
|
16 |
+
}
|
17 |
+
|
18 |
+
$comments = $wpdb->get_results( $sql );
|
19 |
+
if ( count( $comments ) > 0 ) {
|
20 |
+
foreach ( $comments as $comment ) {
|
21 |
if (($matches = $this->matches ($pattern, $comment->comment_author, $comment->comment_ID)))
|
22 |
{
|
23 |
foreach ($matches AS $match)
|
37 |
function get_options ($result)
|
38 |
{
|
39 |
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
|
|
|
|
40 |
|
41 |
if (current_user_can ('edit_post', $result->id))
|
42 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/comment.php?action=editcomment&c='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
64 |
$wpdb->query ($wpdb->prepare( "UPDATE {$wpdb->comments} SET comment_author=%s WHERE comment_ID=%d", $content, $id ) );
|
65 |
}
|
66 |
}
|
|
searches/comment_author_email.php
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class SearchCommentAuthorEmail extends Search
|
4 |
-
{
|
5 |
-
function find ($pattern, $limit, $offset, $orderby)
|
6 |
-
{
|
7 |
global $wpdb;
|
8 |
|
9 |
if ($orderby == 'id')
|
@@ -12,11 +10,14 @@ class SearchCommentAuthorEmail extends Search
|
|
12 |
$order = 'comment_date DESC';
|
13 |
|
14 |
$results = array ();
|
15 |
-
$
|
16 |
-
if (
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
20 |
if (($matches = $this->matches ($pattern, $comment->comment_author_email, $comment->comment_ID)))
|
21 |
{
|
22 |
foreach ($matches AS $match)
|
@@ -36,8 +37,6 @@ class SearchCommentAuthorEmail extends Search
|
|
36 |
function get_options ($result)
|
37 |
{
|
38 |
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
39 |
-
if ($result->replace)
|
40 |
-
$options[] = '<a href="#" onclick="regex_replace (\'SearchCommentAuthorEmail\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
41 |
|
42 |
if (current_user_can ('edit_post', $result->id))
|
43 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/comment.php?action=editcomment&c='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
1 |
<?php
|
2 |
|
3 |
+
class SearchCommentAuthorEmail extends Search {
|
4 |
+
function find( $pattern, $limit, $offset, $orderby ) {
|
|
|
|
|
5 |
global $wpdb;
|
6 |
|
7 |
if ($orderby == 'id')
|
10 |
$order = 'comment_date DESC';
|
11 |
|
12 |
$results = array ();
|
13 |
+
$sql = "SELECT {$wpdb->comments}.comment_ID AS comment_ID, {$wpdb->comments}.comment_post_ID AS comment_post_ID, {$wpdb->comments}.comment_author_email AS comment_author_email, {$wpdb->posts}.post_title AS post_title FROM {$wpdb->comments},{$wpdb->posts} WHERE {$wpdb->comments}.comment_approved='1' AND {$wpdb->posts}.ID={$wpdb->comments}.comment_post_ID ORDER BY {$wpdb->comments}.comment_ID $orderby";
|
14 |
+
if ( $limit > 0 ) {
|
15 |
+
$sql .= $wpdb->prepare( "LIMIT %d,%d", $offset, $limit );
|
16 |
+
}
|
17 |
+
|
18 |
+
$comments = $wpdb->get_results( $sql );
|
19 |
+
if ( count( $comments ) > 0 ) {
|
20 |
+
foreach ( $comments as $comment ) {
|
21 |
if (($matches = $this->matches ($pattern, $comment->comment_author_email, $comment->comment_ID)))
|
22 |
{
|
23 |
foreach ($matches AS $match)
|
37 |
function get_options ($result)
|
38 |
{
|
39 |
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
|
|
|
|
40 |
|
41 |
if (current_user_can ('edit_post', $result->id))
|
42 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/comment.php?action=editcomment&c='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
searches/comment_author_url.php
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class SearchCommentAuthorURL extends Search
|
4 |
-
{
|
5 |
-
function find ($pattern, $limit, $offset, $orderby)
|
6 |
-
{
|
7 |
global $wpdb;
|
8 |
|
9 |
if ($orderby == 'id')
|
@@ -11,12 +9,15 @@ class SearchCommentAuthorURL extends Search
|
|
11 |
else
|
12 |
$order = 'comment_date DESC';
|
13 |
|
14 |
-
$results = array
|
15 |
-
$
|
16 |
-
if (
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
20 |
if (($matches = $this->matches ($pattern, $comment->comment_author_url, $comment->comment_ID)))
|
21 |
{
|
22 |
foreach ($matches AS $match)
|
@@ -36,8 +37,6 @@ class SearchCommentAuthorURL extends Search
|
|
36 |
function get_options ($result)
|
37 |
{
|
38 |
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
39 |
-
if ($result->replace)
|
40 |
-
$options[] = '<a href="#" onclick="regex_replace (\'SearchCommentAuthorURL\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
41 |
|
42 |
if (current_user_can ('edit_post', $result->id))
|
43 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/comment.php?action=editcomment&c='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
1 |
<?php
|
2 |
|
3 |
+
class SearchCommentAuthorURL extends Search {
|
4 |
+
function find( $pattern, $limit, $offset, $orderby ) {
|
|
|
|
|
5 |
global $wpdb;
|
6 |
|
7 |
if ($orderby == 'id')
|
9 |
else
|
10 |
$order = 'comment_date DESC';
|
11 |
|
12 |
+
$results = array();
|
13 |
+
$sql = "SELECT {$wpdb->comments}.comment_ID AS comment_ID, {$wpdb->comments}.comment_post_ID AS comment_post_ID, {$wpdb->comments}.comment_author_url AS comment_author_url, {$wpdb->posts}.post_title AS post_title FROM {$wpdb->comments},{$wpdb->posts} WHERE {$wpdb->comments}.comment_approved='1' AND {$wpdb->posts}.ID={$wpdb->comments}.comment_post_ID ORDER BY {$wpdb->comments}.comment_ID $orderby";
|
14 |
+
if ( $limit > 0 ) {
|
15 |
+
$sql .= $wpdb->prepare( "LIMIT %d,%d", $offset, $limit );
|
16 |
+
}
|
17 |
+
|
18 |
+
$comments = $wpdb->get_results( $sql );
|
19 |
+
if ( count( $comments ) > 0 ) {
|
20 |
+
foreach ( $comments as $comment ) {
|
21 |
if (($matches = $this->matches ($pattern, $comment->comment_author_url, $comment->comment_ID)))
|
22 |
{
|
23 |
foreach ($matches AS $match)
|
37 |
function get_options ($result)
|
38 |
{
|
39 |
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
|
|
|
|
40 |
|
41 |
if (current_user_can ('edit_post', $result->id))
|
42 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/comment.php?action=editcomment&c='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
searches/comment_content.php
CHANGED
@@ -1,17 +1,19 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class SearchCommentContent extends Search
|
4 |
-
{
|
5 |
-
function find ($pattern, $limit, $offset, $orderby)
|
6 |
-
{
|
7 |
global $wpdb;
|
8 |
|
9 |
-
$results = array
|
10 |
-
$
|
11 |
-
|
12 |
-
{
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
if (($matches = $this->matches ($pattern, $comment->comment_content, $comment->comment_ID)))
|
16 |
{
|
17 |
foreach ($matches AS $match)
|
@@ -31,8 +33,6 @@ class SearchCommentContent extends Search
|
|
31 |
function get_options ($result)
|
32 |
{
|
33 |
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
34 |
-
if ($result->replace)
|
35 |
-
$options[] = '<a href="#" onclick="regex_replace (\'SearchCommentContent\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
36 |
|
37 |
if (current_user_can ('edit_post', $result->id))
|
38 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/comment.php?action=editcomment&c='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
1 |
<?php
|
2 |
|
3 |
+
class SearchCommentContent extends Search {
|
4 |
+
function find( $pattern, $limit, $offset, $orderby ) {
|
|
|
|
|
5 |
global $wpdb;
|
6 |
|
7 |
+
$results = array();
|
8 |
+
$sql = "SELECT {$wpdb->comments}.comment_ID AS comment_ID, {$wpdb->comments}.comment_post_ID AS comment_post_ID, {$wpdb->comments}.comment_content AS comment_content, {$wpdb->posts}.post_title AS post_title FROM {$wpdb->comments},{$wpdb->posts} WHERE {$wpdb->comments}.comment_approved='1' AND {$wpdb->posts}.ID={$wpdb->comments}.comment_post_ID ORDER BY {$wpdb->comments}.comment_ID $orderby";
|
9 |
+
|
10 |
+
if ( $limit > 0 ) {
|
11 |
+
$sql .= $wpdb->prepare( "LIMIT %d,%d", $offset, $limit );
|
12 |
+
}
|
13 |
+
|
14 |
+
$comments = $wpdb->get_results( $sql );
|
15 |
+
if ( count( $comments ) > 0 ) {
|
16 |
+
foreach ( $comments as $comment ) {
|
17 |
if (($matches = $this->matches ($pattern, $comment->comment_content, $comment->comment_ID)))
|
18 |
{
|
19 |
foreach ($matches AS $match)
|
33 |
function get_options ($result)
|
34 |
{
|
35 |
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
|
|
|
|
36 |
|
37 |
if (current_user_can ('edit_post', $result->id))
|
38 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/comment.php?action=editcomment&c='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
searches/post_content.php
CHANGED
@@ -1,27 +1,25 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class SearchPostContent extends Search
|
4 |
-
{
|
5 |
-
function find ($pattern, $limit, $offset, $orderby)
|
6 |
-
{
|
7 |
global $wpdb;
|
8 |
|
9 |
-
$
|
10 |
-
$posts = $wpdb->get_results ( "SELECT ID, post_content, post_title FROM {$wpdb->posts} WHERE post_status != 'inherit' AND post_type IN ('post','page') ORDER BY ID $orderby" );
|
11 |
|
12 |
if ( $limit > 0 )
|
13 |
$sql .= $wpdb->prepare( " LIMIT %d,%d", $offset, $limit );
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
{
|
21 |
-
foreach ($matches AS $match)
|
22 |
$match->title = $post->post_title;
|
|
|
23 |
|
24 |
-
$results = array_merge
|
25 |
}
|
26 |
}
|
27 |
}
|
@@ -32,8 +30,6 @@ class SearchPostContent extends Search
|
|
32 |
function get_options ($result)
|
33 |
{
|
34 |
$options[] = '<a href="'.get_permalink ($result->id).'">'.__ ('view', 'search-regex').'</a>';
|
35 |
-
if ($result->replace)
|
36 |
-
$options[] = '<a href="#" onclick="regex_replace (\'SearchPostContent\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
37 |
|
38 |
if (current_user_can ('edit_post', $result->id))
|
39 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
1 |
<?php
|
2 |
|
3 |
+
class SearchPostContent extends Search {
|
4 |
+
function find( $pattern, $limit, $offset, $orderby ) {
|
|
|
|
|
5 |
global $wpdb;
|
6 |
|
7 |
+
$sql = "SELECT ID, post_content, post_title FROM {$wpdb->posts} WHERE post_status != 'inherit' AND post_type IN ('post','page') ORDER BY ID ".$orderby;
|
|
|
8 |
|
9 |
if ( $limit > 0 )
|
10 |
$sql .= $wpdb->prepare( " LIMIT %d,%d", $offset, $limit );
|
11 |
|
12 |
+
$results = array();
|
13 |
+
$posts = $wpdb->get_results( $sql );
|
14 |
+
|
15 |
+
if ( count( $posts ) > 0 ) {
|
16 |
+
foreach ( $posts as $post ) {
|
17 |
+
if ( ( $matches = $this->matches( $pattern, $post->post_content, $post->ID ) ) ) {
|
18 |
+
foreach ( $matches AS $match ) {
|
19 |
$match->title = $post->post_title;
|
20 |
+
}
|
21 |
|
22 |
+
$results = array_merge( $results, $matches );
|
23 |
}
|
24 |
}
|
25 |
}
|
30 |
function get_options ($result)
|
31 |
{
|
32 |
$options[] = '<a href="'.get_permalink ($result->id).'">'.__ ('view', 'search-regex').'</a>';
|
|
|
|
|
33 |
|
34 |
if (current_user_can ('edit_post', $result->id))
|
35 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
searches/post_excerpt.php
CHANGED
@@ -1,17 +1,19 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class SearchPostExcerpt extends Search
|
4 |
-
{
|
5 |
-
function find ($pattern, $limit, $offset, $orderby)
|
6 |
-
{
|
7 |
global $wpdb;
|
8 |
|
9 |
-
$results = array
|
10 |
-
$
|
11 |
-
|
12 |
-
{
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
if (($matches = $this->matches ($pattern, $post->post_excerpt, $post->ID)))
|
16 |
{
|
17 |
foreach ($matches AS $match)
|
@@ -28,8 +30,6 @@ class SearchPostExcerpt extends Search
|
|
28 |
function get_options ($result)
|
29 |
{
|
30 |
$options[] = '<a href="'.get_permalink ($result->id).'">'.__ ('view', 'search-regex').'</a>';
|
31 |
-
if ($result->replace)
|
32 |
-
$options[] = '<a href="#" onclick="regex_replace (\'SearchPostExcerpt\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
33 |
|
34 |
if (current_user_can ('edit_post', $result->id))
|
35 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
1 |
<?php
|
2 |
|
3 |
+
class SearchPostExcerpt extends Search {
|
4 |
+
function find( $pattern, $limit, $offset, $orderby ) {
|
|
|
|
|
5 |
global $wpdb;
|
6 |
|
7 |
+
$results = array();
|
8 |
+
$sql = "SELECT ID, post_title, post_excerpt FROM {$wpdb->posts} WHERE post_status != 'inherit' ORDER BY ID $orderby";
|
9 |
+
|
10 |
+
if ( $limit > 0 ) {
|
11 |
+
$sql .= $wpdb->prepare( "LIMIT %d,%d", $offset, $limit );
|
12 |
+
}
|
13 |
+
|
14 |
+
$posts = $wpdb->get_results( $sql );
|
15 |
+
if ( count( $posts ) > 0 ) {
|
16 |
+
foreach ( $posts as $post ) {
|
17 |
if (($matches = $this->matches ($pattern, $post->post_excerpt, $post->ID)))
|
18 |
{
|
19 |
foreach ($matches AS $match)
|
30 |
function get_options ($result)
|
31 |
{
|
32 |
$options[] = '<a href="'.get_permalink ($result->id).'">'.__ ('view', 'search-regex').'</a>';
|
|
|
|
|
33 |
|
34 |
if (current_user_can ('edit_post', $result->id))
|
35 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
searches/post_meta.php
CHANGED
@@ -1,19 +1,20 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class SearchPostMetaValue extends Search
|
4 |
-
{
|
5 |
-
function find ($pattern, $limit, $offset, $orderby)
|
6 |
-
{
|
7 |
global $wpdb;
|
8 |
|
9 |
-
$results = array
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
$metas = $wpdb->get_results
|
12 |
|
13 |
-
if (count
|
14 |
-
|
15 |
-
foreach ($metas AS $meta)
|
16 |
-
{
|
17 |
// Perform a regex
|
18 |
if (($result = $this->matches ($pattern, $meta->meta_value, $meta->meta_id)) !== false)
|
19 |
{
|
@@ -33,8 +34,6 @@ class SearchPostMetaValue extends Search
|
|
33 |
function get_options ($result)
|
34 |
{
|
35 |
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
36 |
-
if ($result->replace)
|
37 |
-
$options[] = '<a href="#" onclick="regex_replace (\'SearchPostMetaValue\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
38 |
|
39 |
if (current_user_can ('edit_post', $result->sub_id))
|
40 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->sub_id.'">'.__ ('edit','search-regex').'</a>';
|
@@ -62,4 +61,3 @@ class SearchPostMetaValue extends Search
|
|
62 |
$wpdb->query ($wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value=%s WHERE meta_id=%d", $content, $id ) );
|
63 |
}
|
64 |
}
|
65 |
-
|
1 |
<?php
|
2 |
|
3 |
+
class SearchPostMetaValue extends Search {
|
4 |
+
function find( $pattern, $limit, $offset, $orderby ) {
|
|
|
|
|
5 |
global $wpdb;
|
6 |
|
7 |
+
$results = array();
|
8 |
+
$sql = "SELECT {$wpdb->postmeta}.meta_id AS meta_id, {$wpdb->postmeta}.meta_value AS meta_value, {$wpdb->postmeta}.post_id AS post_id, {$wpdb->posts}.post_title AS title FROM {$wpdb->postmeta} LEFT JOIN {$wpdb->posts} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID ORDER BY meta_value $orderby";
|
9 |
+
|
10 |
+
if ( $limit > 0 ) {
|
11 |
+
$sql .= $wpdb->prepare( "LIMIT %d,%d", $offset, $limit );
|
12 |
+
}
|
13 |
|
14 |
+
$metas = $wpdb->get_results( $sql );
|
15 |
|
16 |
+
if ( count( $metas ) > 0 ) {
|
17 |
+
foreach ( $metas as $meta ) {
|
|
|
|
|
18 |
// Perform a regex
|
19 |
if (($result = $this->matches ($pattern, $meta->meta_value, $meta->meta_id)) !== false)
|
20 |
{
|
34 |
function get_options ($result)
|
35 |
{
|
36 |
$options[] = '<a href="'.get_permalink ($result->sub_id).'">'.__ ('view post', 'search-regex').'</a>';
|
|
|
|
|
37 |
|
38 |
if (current_user_can ('edit_post', $result->sub_id))
|
39 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->sub_id.'">'.__ ('edit','search-regex').'</a>';
|
61 |
$wpdb->query ($wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value=%s WHERE meta_id=%d", $content, $id ) );
|
62 |
}
|
63 |
}
|
|
searches/post_title.php
CHANGED
@@ -1,13 +1,18 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class SearchPostTitle extends Search
|
4 |
-
{
|
5 |
-
function find ($pattern, $limit, $offset, $orderby)
|
6 |
-
{
|
7 |
global $wpdb;
|
8 |
|
9 |
-
$results = array
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
if (count ($posts) > 0)
|
12 |
{
|
13 |
foreach ($posts AS $post)
|
@@ -25,14 +30,13 @@ class SearchPostTitle extends Search
|
|
25 |
return $results;
|
26 |
}
|
27 |
|
28 |
-
function get_options
|
29 |
-
|
30 |
-
|
31 |
-
if ($result->
|
32 |
-
$options[] = '<a href="
|
|
|
33 |
|
34 |
-
if (current_user_can ('edit_post', $result->id))
|
35 |
-
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
36 |
return $options;
|
37 |
}
|
38 |
|
1 |
<?php
|
2 |
|
3 |
+
class SearchPostTitle extends Search {
|
4 |
+
function find ($pattern, $limit, $offset, $orderby) {
|
|
|
|
|
5 |
global $wpdb;
|
6 |
|
7 |
+
$results = array();
|
8 |
+
|
9 |
+
$sql = "SELECT ID, post_title FROM {$wpdb->posts} WHERE post_status != 'inherit' ORDER BY ID $orderby";
|
10 |
+
if ( $limit > 0 ) {
|
11 |
+
$sql .= $wpdb->prepare( " LIMIT %d,%d", $offset, $limit );
|
12 |
+
}
|
13 |
+
|
14 |
+
$posts = $wpdb->get_results( $sql );
|
15 |
+
|
16 |
if (count ($posts) > 0)
|
17 |
{
|
18 |
foreach ($posts AS $post)
|
30 |
return $results;
|
31 |
}
|
32 |
|
33 |
+
function get_options( $result ) {
|
34 |
+
$options[] = '<a href="'.get_permalink( $result->id ).'">'.__( 'view', 'search-regex' ).'</a>';
|
35 |
+
|
36 |
+
if ( current_user_can( 'edit_post', $result->id ) ) {
|
37 |
+
$options[] = '<a href="'.get_bloginfo( 'wpurl' ).'/wp-admin/post.php?action=edit&post='.$result->id.'">'.__( 'edit','search-regex' ).'</a>';
|
38 |
+
}
|
39 |
|
|
|
|
|
40 |
return $options;
|
41 |
}
|
42 |
|
searches/post_url.php
CHANGED
@@ -1,17 +1,19 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class SearchPostURL extends Search
|
4 |
-
{
|
5 |
-
function find ($pattern, $limit, $offset, $orderby)
|
6 |
-
{
|
7 |
global $wpdb;
|
8 |
|
9 |
-
$results = array
|
10 |
-
$
|
11 |
-
|
12 |
-
{
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
if (($matches = $this->matches ($pattern, $post->post_name, $post->ID)))
|
16 |
{
|
17 |
foreach ($matches AS $match)
|
@@ -28,8 +30,6 @@ class SearchPostURL extends Search
|
|
28 |
function get_options ($result)
|
29 |
{
|
30 |
$options[] = '<a href="'.get_permalink ($result->id).'">'.__ ('view', 'search-regex').'</a>';
|
31 |
-
if ($result->replace)
|
32 |
-
$options[] = '<a href="#" onclick="regex_replace (\'SearchPostURL\','.$result->id.','.$result->offset.','.$result->length.',\''.str_replace ("'", "\'", $result->replace_string).'\'); return false">replace</a>';
|
33 |
|
34 |
if (current_user_can ('edit_post', $result->id))
|
35 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
1 |
<?php
|
2 |
|
3 |
+
class SearchPostURL extends Search {
|
4 |
+
function find ($pattern, $limit, $offset, $orderby) {
|
|
|
|
|
5 |
global $wpdb;
|
6 |
|
7 |
+
$results = array();
|
8 |
+
$sql = "SELECT ID, post_name, post_title FROM {$wpdb->posts} WHERE post_status != 'inherit' ORDER BY ID $orderby";
|
9 |
+
|
10 |
+
if ( $limit > 0 ) {
|
11 |
+
$sql .= $wpdb->prepare( "LIMIT %d,%d", $offset, $limit );
|
12 |
+
}
|
13 |
+
|
14 |
+
$posts = $wpdb->get_results( $sql );
|
15 |
+
if ( count( $posts ) > 0 ) {
|
16 |
+
foreach ( $posts as $post ) {
|
17 |
if (($matches = $this->matches ($pattern, $post->post_name, $post->ID)))
|
18 |
{
|
19 |
foreach ($matches AS $match)
|
30 |
function get_options ($result)
|
31 |
{
|
32 |
$options[] = '<a href="'.get_permalink ($result->id).'">'.__ ('view', 'search-regex').'</a>';
|
|
|
|
|
33 |
|
34 |
if (current_user_can ('edit_post', $result->id))
|
35 |
$options[] = '<a href="'.get_bloginfo ('wpurl').'/wp-admin/post.php?action=edit&post='.$result->id.'">'.__ ('edit','search-regex').'</a>';
|
view/{admin/results.php → results.php}
RENAMED
File without changes
|
view/{admin/search.php → search.php}
RENAMED
@@ -6,13 +6,15 @@
|
|
6 |
|
7 |
<form method="post" action="">
|
8 |
<table class="searchargs">
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
12 |
<select name="source">
|
13 |
<?php foreach ( $searches AS $searcher ) : ?>
|
14 |
<option value="<?php echo get_class( $searcher ) ?>" <?php if ( strcasecmp( $source, get_class( $searcher ) ) == 0 || ( $source == '' && strcasecmp( get_class( $searcher ), 'SearchPostContent' ) == 0 ) ) echo ' selected="selected"' ?>>
|
15 |
-
<?php echo $searcher->name() ?>
|
16 |
</option>
|
17 |
<?php endforeach; ?>
|
18 |
</select>
|
@@ -20,13 +22,18 @@
|
|
20 |
<strong><?php _e( 'Limit to', 'search-regex' ); ?>:</strong>
|
21 |
<?php $limit = isset( $_POST['limit'] ) ? intval( $_POST['limit'] ) : 0 ?>
|
22 |
<select name="limit">
|
23 |
-
<?php
|
|
|
|
|
|
|
|
|
24 |
</select>
|
25 |
|
26 |
<strong><?php _e( 'Order By', 'search-regex' ); ?>:</strong>
|
27 |
<?php $orderby = isset( $_POST['orderby'] ) ? $_POST['orderby'] : ''; ?>
|
28 |
<select name="orderby">
|
29 |
-
<?php
|
|
|
30 |
</select>
|
31 |
</td>
|
32 |
</tr>
|
@@ -46,10 +53,21 @@
|
|
46 |
<th><label for="regex"><?php _e( 'Regex', 'search-regex' ); ?></label>:</th>
|
47 |
<td>
|
48 |
<input id="regex" type="checkbox" value="regex" name="regex"<?php if (isset ($_POST['regex'])) echo 'checked="checked"' ?>/>
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
— <?php _e( 'remember to surround your regex with a delimiter!', 'search-regex' ); ?>
|
54 |
</span>
|
55 |
</td>
|
@@ -57,19 +75,21 @@
|
|
57 |
<tr>
|
58 |
<th width="150"></th>
|
59 |
<td><p class="submit">
|
60 |
-
|
61 |
|
62 |
<?php if (current_user_can( 'administrator' ) || current_user_can( 'search_regex_write' )) : ?>
|
63 |
-
|
64 |
-
|
65 |
<?php endif; ?>
|
66 |
</p>
|
67 |
</td>
|
68 |
</tr>
|
|
|
|
|
69 |
</table>
|
70 |
</form>
|
71 |
</div>
|
72 |
|
73 |
<script type="text/javascript" charset="utf-8">
|
74 |
-
var wp_loading = '<?php echo plugins_url( '/images/small.gif',
|
75 |
</script>
|
6 |
|
7 |
<form method="post" action="">
|
8 |
<table class="searchargs">
|
9 |
+
<tr>
|
10 |
+
<th width="150">
|
11 |
+
<?php _e( "Source", 'search-regex' ) ?>
|
12 |
+
</th>
|
13 |
+
<td>
|
14 |
<select name="source">
|
15 |
<?php foreach ( $searches AS $searcher ) : ?>
|
16 |
<option value="<?php echo get_class( $searcher ) ?>" <?php if ( strcasecmp( $source, get_class( $searcher ) ) == 0 || ( $source == '' && strcasecmp( get_class( $searcher ), 'SearchPostContent' ) == 0 ) ) echo ' selected="selected"' ?>>
|
17 |
+
<?php echo esc_attr( $searcher->name() ) ?>
|
18 |
</option>
|
19 |
<?php endforeach; ?>
|
20 |
</select>
|
22 |
<strong><?php _e( 'Limit to', 'search-regex' ); ?>:</strong>
|
23 |
<?php $limit = isset( $_POST['limit'] ) ? intval( $_POST['limit'] ) : 0 ?>
|
24 |
<select name="limit">
|
25 |
+
<option <?php selected( $limit, 0 ); ?> value="0"><?php _e( 'No limit', 'search-regex' ); ?></option>
|
26 |
+
<option <?php selected( $limit, 10 ); ?> value="10"><?php _e( '10', 'search-regex' ); ?></option>
|
27 |
+
<option <?php selected( $limit, 25 ); ?> value="25"><?php _e( '25', 'search-regex' ); ?></option>
|
28 |
+
<option <?php selected( $limit, 50 ); ?> value="50"><?php _e( '50', 'search-regex' ); ?></option>
|
29 |
+
<option <?php selected( $limit, 100 ); ?> value="100"><?php _e( '100', 'search-regex' ); ?></option>
|
30 |
</select>
|
31 |
|
32 |
<strong><?php _e( 'Order By', 'search-regex' ); ?>:</strong>
|
33 |
<?php $orderby = isset( $_POST['orderby'] ) ? $_POST['orderby'] : ''; ?>
|
34 |
<select name="orderby">
|
35 |
+
<option <?php selected( $orderby, 'asc' ); ?>value="asc"><?php _e( 'Ascending', 'search-regex' ); ?></option>
|
36 |
+
<option <?php selected( $orderby, 'desc' ); ?>value="desc"><?php _e( 'Descending', 'search-regex' ); ?></option>
|
37 |
</select>
|
38 |
</td>
|
39 |
</tr>
|
53 |
<th><label for="regex"><?php _e( 'Regex', 'search-regex' ); ?></label>:</th>
|
54 |
<td>
|
55 |
<input id="regex" type="checkbox" value="regex" name="regex"<?php if (isset ($_POST['regex'])) echo 'checked="checked"' ?>/>
|
56 |
+
|
57 |
+
<span id="regex-options" class="sub">
|
58 |
+
<label>
|
59 |
+
<?php _e( 'case-insensitive:', 'search-regex' ) ?>
|
60 |
+
<input type="checkbox" name="regex_case" <?php checked( !empty( $_POST['regex_case'] ) ); ?>/>
|
61 |
+
</label>
|
62 |
+
<label>
|
63 |
+
<?php _e( 'multi-line:', 'search-regex' ) ?>
|
64 |
+
<input type="checkbox" name="regex_multi" <?php checked( !empty( $_POST['regex_multi'] ) ); ?>/>
|
65 |
+
</label>
|
66 |
+
<label>
|
67 |
+
<?php _e( 'dot-all:', 'search-regex' ) ?>
|
68 |
+
<input type="checkbox" name="regex_dot" <?php checked( !empty( $_POST['regex_dot'] ) ); ?>/>
|
69 |
+
</label>
|
70 |
+
|
71 |
— <?php _e( 'remember to surround your regex with a delimiter!', 'search-regex' ); ?>
|
72 |
</span>
|
73 |
</td>
|
75 |
<tr>
|
76 |
<th width="150"></th>
|
77 |
<td><p class="submit">
|
78 |
+
<input type="submit" class="button-primary" name="search" value="<?php esc_attr_e( 'Search', 'search-regex' )?> »" />
|
79 |
|
80 |
<?php if (current_user_can( 'administrator' ) || current_user_can( 'search_regex_write' )) : ?>
|
81 |
+
<input type="submit" class="button" name="replace" value="<?php esc_attr_e( 'Replace', 'search-regex' )?> »" />
|
82 |
+
<input type="submit" class="button" name="replace_and_save" value="<?php esc_attr_e( 'Replace & Save »', 'search-regex' ) ?>"/>
|
83 |
<?php endif; ?>
|
84 |
</p>
|
85 |
</td>
|
86 |
</tr>
|
87 |
+
|
88 |
+
<?php wp_nonce_field( 'search', 'search-regex-nonce' ); ?>
|
89 |
</table>
|
90 |
</form>
|
91 |
</div>
|
92 |
|
93 |
<script type="text/javascript" charset="utf-8">
|
94 |
+
var wp_loading = '<?php echo plugins_url( '/images/small.gif', dirname( __FILE__ ) ); ?>';
|
95 |
</script>
|