├── changelog.txt
├── sql.txt
├── lib
└── dash-notices
│ └── wpmudev-dash-notification.php
├── README.md
└── comment-indexer.php
/changelog.txt:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------------------------
2 | Comment Indexer
3 | Authors: Paul Menard (Incsub)
4 | ----------------------------------------------------------------------
5 |
6 | = 1.0.9.1 =
7 | 2013:04/25:
8 | - XSS prevention patches
9 |
10 | = 1.0.9 =
11 | 2012/08/12: Added support for Trash/Untrash comments.
12 |
13 | = 1.0.8 =
14 | 2012/08/07: Compatibility update for WordPress 3.1
15 | Update Notifications script added
16 | Bug fixes
17 |
18 | = 1.0.6 =
19 | * Compatibility update for WordPress 3.1
20 | * Bug fixes.
21 |
22 | = 1.0.5 =
23 | * Minor bug fixes.
24 |
25 | = 1.0.4 =
26 | * Minor bug fixes.
27 |
28 | = 1.0.3 =
29 | * Adding Update Notifications Support
30 |
31 | = 1.0.2 =
32 | * Fixed comment_auther type.
33 |
34 | = 1.0.1 =
35 | * Fixed duplicate comments issue.
36 |
37 | = 1.0.0 =
38 | * Initial Release.
39 |
40 |
--------------------------------------------------------------------------------
/sql.txt:
--------------------------------------------------------------------------------
1 | CREATE TABLE IF NOT EXISTS `wp_site_comments` (
2 | `site_comment_id` bigint(20) unsigned NOT NULL auto_increment,
3 | `blog_id` bigint(20),
4 | `site_id` bigint(20),
5 | `sort_terms` TEXT,
6 | `blog_public` int(2),
7 | `comment_approved` VARCHAR(255),
8 | `comment_id` bigint(20),
9 | `comment_post_id` bigint(20),
10 | `comment_post_permalink` TEXT,
11 | `comment_author` VARCHAR(60),
12 | `comment_author_email` VARCHAR(255),
13 | `comment_author_IP` VARCHAR(255),
14 | `comment_author_url` VARCHAR(50),
15 | `comment_author_user_id` bigint(20),
16 | `comment_content` TEXT,
17 | `comment_content_stripped` TEXT,
18 | `comment_karma` VARCHAR(255),
19 | `comment_agent` VARCHAR(255),
20 | `comment_type` VARCHAR(255),
21 | `comment_parent` VARCHAR(255),
22 | `comment_date_gmt` datetime NOT NULL default '0000-00-00 00:00:00',
23 | `comment_date_stamp` VARCHAR(255),
24 | PRIMARY KEY (`site_comment_id`)
25 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--------------------------------------------------------------------------------
/lib/dash-notices/wpmudev-dash-notification.php:
--------------------------------------------------------------------------------
1 | slug, 'install_wpmudev_dash') !== false ) {
31 | $res = new stdClass;
32 | $res->name = 'WPMU DEV Dashboard';
33 | $res->slug = 'wpmu-dev-dashboard';
34 | $res->version = '';
35 | $res->rating = 100;
36 | $res->homepage = 'http://premium.wpmudev.org/project/wpmu-dev-dashboard/';
37 | $res->download_link = "http://premium.wpmudev.org/wdp-un.php?action=install_wpmudev_dash";
38 | $res->tested = $cur_wp_version;
39 |
40 | return $res;
41 | }
42 |
43 | return false;
44 | }
45 |
46 | function auto_install_url() {
47 | $function = is_multisite() ? 'network_admin_url' : 'admin_url';
48 | return wp_nonce_url($function("update.php?action=install-plugin&plugin=install_wpmudev_dash"), "install-plugin_install_wpmudev_dash");
49 | }
50 |
51 | function activate_url() {
52 | $function = is_multisite() ? 'network_admin_url' : 'admin_url';
53 | return wp_nonce_url($function('plugins.php?action=activate&plugin=wpmudev-updates%2Fupdate-notifications.php'), 'activate-plugin_wpmudev-updates/update-notifications.php');
54 | }
55 |
56 | function install_notice() {
57 | echo '
';
58 | }
59 |
60 | function activate_notice() {
61 | echo '';
62 | }
63 |
64 | }
65 | new WPMUDEV_Dashboard_Notice();
66 | }
67 | ?>
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Comment Indexer
2 |
3 | **INACTIVE NOTICE: This plugin is unsupported by WPMUDEV, we've published it here for those technical types who might want to fork and maintain it for their needs.**
4 |
5 |
6 | Supercharge how comments are shared and managed across your network and build a powerful foundation for Multisite interaction.
7 |
8 | * Power global comment sharing for Multisite
9 | * Manage network comments in new ways
10 | * Catalog comments across a network
11 | * Expand network comment plugins
12 | * Great tool for developers
13 | * Pairs with Post Indexer
14 |
15 | ## Comment Indexer is the engine that makes global comment sharing on Multisite possible.
16 |
17 | It works behind the scenes to catalog your comments, providing a foundation for other plugins to display your content in new and exciting ways.
18 |
19 | ### Manage Multisite Comments in New Ways
20 |
21 | We built Comment Indexer to work together with other plugins to harness its power.
22 |
23 | While Multisite is a powerful tool, one of its biggest limitations is the lack of control you have for displaying comments and content from different sites on your network in one place.
24 |
25 | We've built a huge collection of plugins that can help you do that, but those plugins need an index of all the different comments and posts on your network to pull from. This is where Comment Indexer comes in.
26 |
27 | ### Expand Global Comments
28 |
29 | We've developed a robust collection of plugins that work around Comment Indexer to extend Multisite's capabilities.
30 |
31 | * **Recent Global Author Comments Feed** – Display a global feed of comments from a single author made across multiple sites on the network
32 | * **Recent Global Comments Widget** – Display the latest comments from across your entire network
33 | * **Recent Global Comments Feed** – Provide a RSS feed of the latest comments on your network
34 | * **Post Index Summary** – Provide an overview of indexed post types and most indexed sites
35 | * **Post Indexer Stats and Graphs** – Post Indexer helps you keep track of exactly what is being stored on your global index with rich statistics and graphs
36 | * **Indexed Post Types** – A simple graph that visually illustrates indexed post types by usage percent
37 | * **Recently Indexed Posts** – View and access recently indexed content with linked post titles and site names
38 | * **Most Indexed Posts** – View a clear, bold bar graph to see what posts have been indexed most
39 |
40 | ## Reimagine What Multisite Can Do
41 |
42 | Pair Comment Indexer with our Post Indexer plugin and expand your global index to include comments from across your network.
43 |
44 | * **Reader** – Turn your Multisite into a community, complete with Tumblr, WordPress.com and Edublogs-style "Follow" features
45 | * **Anti-splog** – Stop splogs in their tracks
46 | * **Blogs Directory** – A fully searchable, avatar inclusive, automatic and rather good-looking directory of all the sites in your network
47 | * **Global Site Search** – Activate global search across all of the sites on your network with ease
48 | * **Global Site Tags** – Display global site tags for your entire network
49 | * **Tag feed** – Display a list of posts that have been tagged with a specific tag or category
50 | * **Recent Global Posts** – Display a list of recent posts anywhere on your site using a simple shortcode or template function
51 | * **Recent Global Posts Widget** – Display the latest posts from across your entire network
52 | * **Recent Global Posts Feed** – Create an RSS feed of all the latest posts on your network
53 | * **Live Stream** – Display your own slick animated Live Stream Widget
54 | * **User Reports** – Track user posts and comments across your network
55 |
56 | ### To Use:
57 |
58 | This plugin by itself does not provide any features to your users. It’s simply a backend plugin that can be used to build other features.
59 |
60 | 1\. Install the Comment Indexer.
61 |
62 | 2\. Visit **Plugins** in your network admin dashboard and **Network Activate** the Comment Indexer plugin there.
63 | * The Comment Indexer is designed to index comments from the time it is installed on your site.
64 | * The Comment Indexer can’t index comments that were published prior to being installed. e,g. _ comments published prior to it being installed won’t display in your Recent Global comments widget_
65 |
66 | 3\. Once installed check it is working by publishing a new comment and see if the comments shows when used with a plugin like Recent Global Comments Widget
67 |
68 | * Make sure the comment is published on a site with privacy set to ‘Allow search engines to index this site.’
69 | * Check Global tables installed correctly if have any issues.
70 |
71 |
72 |
--------------------------------------------------------------------------------
/comment-indexer.php:
--------------------------------------------------------------------------------
1 | base_prefix . "site_comments` (
69 | `site_comment_id` bigint(20) unsigned NOT NULL auto_increment,
70 | `blog_id` bigint(20),
71 | `site_id` bigint(20),
72 | `sort_terms` TEXT,
73 | `blog_public` int(2),
74 | `comment_approved` VARCHAR(255),
75 | `comment_id` bigint(20),
76 | `comment_post_id` bigint(20),
77 | `comment_post_permalink` TEXT,
78 | `comment_author` VARCHAR(60),
79 | `comment_author_email` VARCHAR(255),
80 | `comment_author_IP` VARCHAR(255),
81 | `comment_author_url` VARCHAR(50),
82 | `comment_author_user_id` bigint(20),
83 | `comment_content` TEXT,
84 | `comment_content_stripped` TEXT,
85 | `comment_karma` VARCHAR(255),
86 | `comment_agent` VARCHAR(255),
87 | `comment_type` VARCHAR(255),
88 | `comment_parent` VARCHAR(255),
89 | `comment_date_gmt` datetime NOT NULL default '0000-00-00 00:00:00',
90 | `comment_date_stamp` VARCHAR(255),
91 | PRIMARY KEY (`site_comment_id`)
92 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
93 |
94 | $wpdb->query( $comment_indexer_table1 );
95 | }
96 |
97 | function comment_indexer_update_comment_status($tmp_comment_ID, $tmp_comment_status){
98 | global $wpdb;
99 |
100 | if (!$tmp_comment_status)
101 | $tmp_comment_status = '0';
102 |
103 | $new_comment_status = '';
104 | switch ( $tmp_comment_status ) {
105 | case '1':
106 | case 'approve':
107 | //$query = "UPDATE " . $wpdb->base_prefix . "site_comments SET comment_approved='1' WHERE comment_id ='" . $tmp_comment_ID . "' and blog_id = '" . $wpdb->blogid . "' LIMIT 1";
108 | $new_comment_status = '1';
109 | break;
110 |
111 | case 'spam':
112 | //$query = "UPDATE " . $wpdb->base_prefix . "site_comments SET comment_approved='spam' WHERE comment_id ='" . $tmp_comment_ID . "' and blog_id = '" . $wpdb->blogid . "' LIMIT 1";
113 | $new_comment_status = 'spam';
114 | break;
115 |
116 | case 'trash':
117 | //$query = "UPDATE " . $wpdb->base_prefix . "site_comments SET comment_approved='trash' WHERE comment_id ='" . $tmp_comment_ID . "' and blog_id = '" . $wpdb->blogid . "' LIMIT 1";
118 | $new_comment_status = 'trash';
119 |
120 | break;
121 |
122 | case 'delete':
123 | comment_indexer_delete($tmp_comment_ID);
124 | //return true;
125 | break;
126 |
127 | case '0':
128 | case 'hold':
129 | default:
130 | //$query = "UPDATE " . $wpdb->base_prefix . "site_comments SET comment_approved='0' WHERE comment_id ='" . $tmp_comment_ID . "' and blog_id = '" . $wpdb->blogid . "' LIMIT 1";
131 | $new_comment_status = '0';
132 | break;
133 |
134 | }
135 |
136 | if ($new_comment_status != '') {
137 | $wpdb->update($wpdb->base_prefix . "site_comments",
138 | array(
139 | 'comment_approved' => $new_comment_status
140 | ),
141 | array(
142 | 'comment_id' => $tmp_comment_ID,
143 | 'blog_id' => $wpdb->blogid
144 | ), array('%s'), array('%d', '%d')
145 | );
146 | }
147 | return false;
148 | }
149 |
150 | function comment_indexer_get_sort_terms($tmp_blog_ID){
151 | $comment_indexer_blog_lang = get_blog_option($tmp_blog_ID,"WPLANG");
152 | if ($comment_indexer_blog_lang == ''){
153 | $comment_indexer_blog_lang = 'en_EN';
154 | }
155 | $comment_indexer_blog_types = get_blog_option($tmp_blog_ID,"blog_types");
156 | if ($comment_indexer_blog_types == ''){
157 | $comment_indexer_blog_types = '||';
158 | }
159 | $comment_indexer_class = get_blog_option($tmp_blog_ID,"blog_class");
160 |
161 | $tmp_sort_terms = array();
162 |
163 | $comment_indexer_blog_types = explode("|", $comment_indexer_blog_types);
164 | foreach ( $comment_indexer_blog_types as $comment_indexer_blog_type ) {
165 | if ( $comment_indexer_blog_type != '' ) {
166 | $tmp_sort_terms[] = 'blog_type_' . $comment_indexer_blog_type;
167 | }
168 | }
169 | if ( $comment_indexer_class != '' ) {
170 | $tmp_sort_terms[] = 'class_' . $comment_indexer_class;
171 | }
172 |
173 | $tmp_sort_terms[] = 'blog_lang_' . strtolower( $comment_indexer_blog_lang );
174 |
175 | return '|' . implode("|", $tmp_sort_terms) . '|all|';
176 |
177 | }
178 |
179 | function comment_indexer_comment_insert_update($tmp_comment_ID){
180 | global $wpdb, $current_site;
181 |
182 | $tmp_blog_public = get_blog_status( $wpdb->blogid, 'public');
183 | $tmp_blog_archived = get_blog_status( $wpdb->blogid, 'archived');
184 | $tmp_blog_mature = get_blog_status( $wpdb->blogid, 'mature');
185 | $tmp_blog_spam = get_blog_status( $wpdb->blogid, 'spam');
186 | $tmp_blog_deleted = get_blog_status( $wpdb->blogid, 'deleted');
187 |
188 | $tmp_comment = get_comment($tmp_comment_ID);
189 | if ($tmp_blog_archived == '1'){
190 | comment_indexer_delete($tmp_comment_ID);
191 | } else if ($tmp_blog_mature == '1'){
192 | comment_indexer_delete($tmp_comment_ID);
193 | } else if ($tmp_blog_spam == '1'){
194 | comment_indexer_delete($tmp_comment_ID);
195 | } else if ($tmp_blog_deleted == '1'){
196 | comment_indexer_delete($tmp_comment_ID);
197 | } else if ($tmp_comment->comment_content == ''){
198 | comment_indexer_delete($tmp_comment_ID);
199 | } else {
200 | //delete comment
201 | comment_indexer_delete($tmp_comment_ID);
202 |
203 | //get sort terms
204 | $tmp_sort_terms = comment_indexer_get_sort_terms($wpdb->blogid);
205 |
206 | //comment does not exist - insert site comment
207 | $wpdb->insert( $wpdb->base_prefix . "site_comments",
208 | array(
209 | 'blog_id' => $wpdb->blogid,
210 | 'site_id' => $wpdb->siteid,
211 | 'sort_terms' => $tmp_sort_terms,
212 | 'blog_public' => $tmp_blog_public,
213 | 'comment_approved' => $tmp_comment->comment_approved,
214 | 'comment_id' => $tmp_comment_ID,
215 | 'comment_post_id' => $tmp_comment->comment_post_ID,
216 | 'comment_post_permalink' => get_permalink($tmp_comment->comment_post_ID),
217 | 'comment_author' => $tmp_comment->comment_author,
218 | 'comment_author_email' => $tmp_comment->comment_author_email,
219 | 'comment_author_IP' => $tmp_comment->comment_author_IP,
220 | 'comment_author_url' => $tmp_comment->comment_author_url,
221 | 'comment_author_user_id' => $tmp_comment->user_id,
222 | 'comment_content' => $tmp_comment->comment_content,
223 | 'comment_content_stripped' => comment_indexer_strip_content($tmp_comment->comment_content),
224 | 'comment_karma' => $tmp_comment->comment_karma,
225 | 'comment_agent' => $tmp_comment->comment_agent,
226 | 'comment_type' => $tmp_comment->comment_type,
227 | 'comment_parent' => $tmp_comment->comment_parent,
228 | 'comment_date_gmt' => $tmp_comment->comment_date_gmt,
229 | 'comment_date_stamp' => time()
230 | ), array(
231 | '%d', // blog_id
232 | '%d', // site_id
233 | '%s', // sort_terms
234 | '%d', // blog_public
235 | '%s', // comment_approved
236 | '%d', // comment_id
237 | '%d', // comment_post_id
238 | '%s', // comment_post_permalink
239 | '%s', // comment_author
240 | '%s', // comment_author_email
241 | '%s', // comment_author_IP
242 | '%s', // comment_author_url
243 | '%d', // comment_author_user_id
244 | '%s', // comment_content
245 | '%s', // comment_content_stripped
246 | '%s', // comment_karma
247 | '%s', // comment_agent
248 | '%s', // comment_type
249 | '%s', // comment_parent
250 | '%s', // comment_date_gmt
251 | '%s' // comment_date_stamp
252 | )
253 | );
254 | }
255 | }
256 |
257 | function comment_indexer_delete($tmp_comment_ID){
258 | global $wpdb;
259 | //delete site comment
260 | $wpdb->query( $wpdb->prepare("DELETE FROM " . $wpdb->base_prefix . "site_comments WHERE comment_id = %d AND blog_id = %d", $tmp_comment_ID, $wpdb->blogid ));
261 | }
262 |
263 | function comment_indexer_delete_by_site_comment_id($tmp_site_comment_ID, $tmp_blog_ID) {
264 | global $wpdb;
265 | //delete site comment
266 | $wpdb->query( $wpdb->prepare("DELETE FROM " . $wpdb->base_prefix . "site_comments WHERE site_comment_id = %d", $tmp_site_comment_ID));
267 | }
268 |
269 | function comment_indexer_public_update(){
270 | global $wpdb;
271 | if ( $_GET['updated'] == 'true' ) {
272 | //$wpdb->query("UPDATE " . $wpdb->base_prefix . "site_comments SET blog_public = '" . get_blog_status( $wpdb->blogid, 'public') . "' WHERE blog_id = '" . $wpdb->blogid . "' AND site_id = '" . $wpdb->siteid . "'");
273 | $wpdb->update($wpdb->base_prefix . "site_comments",
274 | array(
275 | 'blog_public' => get_blog_status( $wpdb->blogid, 'public')
276 | ),
277 | array(
278 | 'blog_id' => $wpdb->blogid,
279 | 'site_id' => $wpdb->siteid
280 | ), array('%s'), array('%d', '%d')
281 | );
282 | }
283 | }
284 | function comment_indexer_sort_terms_update(){
285 | global $wpdb;
286 | //$wpdb->query("UPDATE " . $wpdb->base_prefix . "site_comments SET sort_terms = '" . comment_indexer_get_sort_terms($wpdb->blogid) . "' WHERE blog_id = '" . $wpdb->blogid . "' AND site_id = '" . $wpdb->siteid . "'");
287 |
288 | $wpdb->update($wpdb->base_prefix . "site_comments",
289 | array(
290 | 'sort_terms' => comment_indexer_get_sort_terms($wpdb->blogid)
291 | ),
292 | array(
293 | 'blog_id' => $wpdb->blogid,
294 | 'site_id' => $wpdb->siteid
295 | ), array('%s'), array('%d', '%d')
296 | );
297 | }
298 |
299 | function comment_indexer_change_remove($tmp_blog_ID){
300 | global $wpdb, $current_user, $current_site;
301 | //delete site posts
302 | $blog_site_comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . "site_comments WHERE blog_id = %d AND site_id = %d", $tmp_blog_ID, $wpdb->siteid), ARRAY_A );
303 | if (count($blog_site_comments) > 0){
304 | foreach ($blog_site_comments as $blog_site_comment){
305 | comment_indexer_delete_by_site_comment_id($blog_site_comment['site_comment_id'], $tmp_blog_ID);
306 | }
307 | }
308 | }
309 |
310 | //------------------------------------------------------------------------//
311 | //---Output Functions-----------------------------------------------------//
312 | //------------------------------------------------------------------------//
313 |
314 | //------------------------------------------------------------------------//
315 | //---Page Output Functions------------------------------------------------//
316 | //------------------------------------------------------------------------//
317 |
318 | //------------------------------------------------------------------------//
319 | //---Support Functions----------------------------------------------------//
320 | //------------------------------------------------------------------------//
321 |
322 | function comment_indexer_strip_content($tmp_content){
323 | $tmp_content = strip_tags($tmp_content);
324 | return $tmp_content;
325 | }
326 |
--------------------------------------------------------------------------------