cbnet Ping Optimizer - Version 3.0

Version Description

  • Major update
  • Plugin functionality not needed, and therefore removed and replaced with an explanation of why it is not needed.
Download this release

Release Info

Developer chipbennett
Plugin Icon wp plugin cbnet Ping Optimizer
Version 3.0
Comparing to
See all releases

Code changes from version 2.3.3 to 3.0

cbnet-ping-optimizer.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  * Plugin Name: cbnet Ping Optimizer
4
  * Plugin URI: http://www.chipbennett.net/wordpress/plugins/cbnet-ping-optimizer/
5
- * Description: Saves your wordpress blog from getting tagged as ping spammer. (Note: this plugin is a fork of the MaxBlogPress Ping Optimizer plugin, with registration/activiation functionality removed.)
6
- * Version: 2.3.3
7
  * Author: chipbennett
8
  * Author URI: http://www.chipbennett.net//
9
  *
@@ -20,599 +20,111 @@
20
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
  * GNU General Public License for more details.
22
  *
23
- * This program was modified from MaxBlogPress Favicon plugin, version 2.2.5,
 
 
 
24
  * Copyright (C) 2007 www.maxblogpress.com, released under the GNU General Public License.
25
  */
26
 
27
- define('cbnetpo_NAME', 'cbnet Ping Optimizer'); // Name of the Plugin
28
- define('cbnetpo_VERSION', '2.3.3'); // Current version of the Plugin
29
- define("cbnetpo_LOG", true); // Set to 'true' to keep log, else 'false'.
30
-
31
  /**
32
- * cbnetPingOptimizer - cbnet Ping Optimizer Class
33
- * Holds all the necessary functions and variables
 
 
 
 
 
 
 
34
  */
35
- class cbnetPingOptimizer
36
- {
37
- var $cbnetpo_ping_option = 0; // cbnet Ping Optimizer option
38
- var $cbnetpo_ping_sites = ''; // cbnet Ping Optimizer pinging URLs
39
- var $cbnetpo_future_pings = array(); // List of future posts to be pinged
40
- var $cbnetpo_future_ping_time = ''; // Last updated time for future ping
41
- var $cbnetpo_current_date = ''; // Holds the current date and time
42
- var $cbnetpo_post_title = ""; // Title of the post
43
- var $cbnetpo_edited = ""; // Set if post is edited
44
- var $cbnetpo_pvt_to_pub = ""; // Set if post status changes from private to published
45
- var $cbnetpo_max_log = 1000; // Maximum lines of log data to be stored
46
- var $cbnetpo_rows_to_show = 35; // Number of log rows to be displayed in options page
47
- var $cbnetpo_pinglog_tbl = 'cbnetpo_ping_optimizer'; // Ping log table
48
- // Pinging action/type
49
- var $cbnetpo_type = array(1 => 'none', 2 => 'new', 3 => 'future', 4 => 'forced', 5 => 'edited', 6 => 'disabled', 7 => 'noservices', 8 => 'excessive');
50
-
51
- /**
52
- * Constructor. Add cbnet Ping Optimizer plugin actions/filters and gets the user defined options.
53
- * Also removes the default WordPress pinging services.
54
- */
55
- function cbnetPingOptimizer() {
56
- global $wp_version, $table_prefix;
57
- $this->cbnetpo_pinglog_tbl = $table_prefix.$this->cbnetpo_pinglog_tbl;
58
- $this->cbnetpo_siteurl = get_bloginfo('wpurl');
59
- $this->cbnetpo_siteurl = (strpos($this->cbnetpo_siteurl,'http://') === false) ? get_bloginfo('siteurl') : $this->cbnetpo_siteurl;
60
- $this->cbnetpo_path = preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', __FILE__);
61
- $this->cbnetpo_path = str_replace('\\','/',$this->cbnetpo_path);
62
- $this->cbnetpo_fullpath = $this->cbnetpo_siteurl.'/wp-content/plugins/'.substr($this->cbnetpo_path,0,strrpos($this->cbnetpo_path,'/')).'/';
63
- $this->cbnetpo_incpath = $this->cbnetpo_fullpath.'include/';
64
- $this->cbnetpo_abspath = str_replace("\\","/",ABSPATH);
65
- $this->img_how = '<img src="'.$this->cbnetpo_incpath.'images/how.gif" border="0" align="absmiddle">';
66
- $this->img_comment = '<img src="'.$this->cbnetpo_incpath.'images/comment.gif" border="0" align="absmiddle">';
67
- $this->cbnetpo_wp_version = $wp_version;
68
- add_action('activate_'.$this->cbnetpo_path, array(&$this, 'cbnetpoActivate'));
69
- add_action('deactivate_'.$this->cbnetpo_path, array(&$this, 'cbnetpoDeactivate'));
70
- add_action('admin_menu', array(&$this, 'cbnetpoAddMenu'));
71
- add_filter('plugin_action_links_'.plugin_basename(__FILE__), array($this, 'cbnetpo_actlinks'), 10, 1 );
72
- add_action('wp_head', array(&$this, 'cbnetpoFuturePing'));
73
- add_filter('title_save_pre', array(&$this, 'cbnetpoGetPostTitle'));
74
- add_action('edit_post', array(&$this, 'cbnetpoEditPost'));
75
- add_action('private_to_published', array(&$this, 'cbnetpoPrivateToPublished'));
76
- add_action('save_post', array(&$this, 'cbnetpoPing'));
77
- add_action("delete_post", array(&$this, 'cbnetpoFuturePingDelete'));
78
- do_action('cbnetpo_ping', $post_title, $post_type);
79
- add_action('cbnetpo_ping', array(&$this, 'cbnetpoPingServices'), 5, 2);
80
- remove_action('do_pings', 'do_all_pings');
81
- remove_action("publish_post", "generic_ping");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
- $this->cbnetpo_current_date = current_time('mysql');
84
- $this->cbnetpo_ping_sites = get_option("ping_sites");
85
- $this->cbnetpo_ping_option = get_option('cbnetpo_ping_optimizer');
86
- $this->cbnetpo_future_pings = get_option('cbnetpo_future_pings');
87
- $this->cbnetpo_options = get_option('cbnetpo_options');
88
- if ( $this->cbnetpo_wp_version < 2.1 ) {
89
- if( !is_array($this->cbnetpo_future_pings) ) {
90
- $this->cbnetpo_future_pings = array();
91
- }
92
- if( !$this->cbnetpo_future_ping_time = get_option('cbnetpo_future_ping_time') ) {
93
- $this->cbnetpo_future_ping_time = date('Y-m-d-H-i-s');
94
- }
95
- }
96
- // Check if ping limit reached
97
- if ( $this->cbnetpo_options['limit_ping'] == 1 ) {
98
- $last_ping_time = get_option('cbnetpo_last_ping_time');
99
- $curr_time = current_time('mysql');
100
- $limit_time = $this->cbnetpo_options['limit_time'] * 60;
101
- $limit_number = $this->cbnetpo_options['limit_number'];
102
- $_last_ping_time = intval(strtotime($last_ping_time));
103
- $_curr_time = intval(strtotime($curr_time));
104
- $cbnetpo_ping_num = get_option('cbnetpo_ping_num');
105
- if ( $_last_ping_time <= 0 ) $_last_ping_time = $_curr_time;
106
- if ( ($limit_time >= ($_curr_time - $_last_ping_time)) && ($cbnetpo_ping_num >= $limit_number) ) {
107
- $this->excessive_pinging = 1;
108
- } else {
109
- if ( $cbnetpo_ping_num >= $limit_number ) update_option('cbnetpo_ping_num',0);
110
- $this->excessive_pinging = 0;
111
- }
112
- } else {
113
- $this->excessive_pinging = 0;
114
- }
115
- }
116
-
117
- /**
118
- * Called when plugin is activated. Adds option_value to the options table.
119
- */
120
- function cbnetpoActivate() {
121
- $default_options = array('cbnetpo_version' => cbnetpo_VERSION, 'limit_ping' => 0, 'limit_number' => 1, 'limit_time' => 15);
122
- add_option('cbnetpo_options', $default_options);
123
- add_option('cbnetpo_ping_optimizer', 1, 'cbnet Ping Optimizer plugin options', 'no');
124
- if ( $this->cbnetpo_wp_version < 2.1 ) {
125
- add_option('cbnetpo_future_ping_time', date('Y-m-d-H-i-s'), 'cbnet Ping Optimizer plugin options', 'no');
126
- }
127
- $this->cbnetpoCreateLogTable();
128
- return true;
129
- }
130
-
131
- /**
132
- * Called when plugin is deactivated. Deletes cbnet Ping Optimizer option from the options table.
133
- */
134
- function cbnetpoDeactivate() {
135
- delete_option('cbnetpo_future_ping_time');
136
- delete_option('cbnetpo_future_pings');
137
- return true;
138
- }
139
-
140
- /**
141
- * Creates ping log table
142
- * @access public
143
- */
144
- function cbnetpoCreateLogTable() {
145
- global $wpdb;
146
- if ( $wpdb->get_var("show tables like '$this->cbnetpo_pinglog_tbl'") != $this->cbnetpo_pinglog_tbl ) {
147
- if ( file_exists(ABSPATH . 'wp-admin/includes/upgrade.php') ) {
148
- require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
149
- } else { // Wordpress <= 2.2
150
- require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
151
- }
152
- dbDelta("CREATE TABLE `{$this->cbnetpo_pinglog_tbl}` (
153
- `id` int(11) NOT NULL auto_increment,
154
- `date_time` datetime NOT NULL,
155
- `post_title` text,
156
- `log_data` text,
157
- `type` tinyint(4) DEFAULT 1,
158
- PRIMARY KEY (`id`)
159
- );
160
- ");
161
- }
162
- }
163
 
164
- /**
165
- * Adds "cbnet Ping Optimizer" link to admin Options menu
166
- */
167
- function cbnetpoAddMenu() {
168
- add_options_page(cbnetpo_NAME, 'cbnet Ping Optimizer', 'manage_options', $this->cbnetpo_path, array(&$this, 'cbnetpoOptionsPg'));
169
- }
170
 
171
- /**
172
- * Adds "Settings" link to Plugin Action links on Manage Plugins page
173
- */
174
- function cbnetpo_actlinks( $links ) {
175
- $cbnetpo_settings_link = '<a href="options-general.php?page=cbnet-ping-optimizer/cbnet-ping-optimizer.php">Settings</a>';
176
- $links[] = $cbnetpo_settings_link;
177
- return $links;
178
- }
179
-
180
- /**
181
- * Page Header
182
- */
183
- function cbnetpoHeader() {
184
- echo '<h2>'.cbnetpo_NAME.' '.cbnetpo_VERSION.'</h2>';
185
- }
186
-
187
- /**
188
- * Page Footer
189
- */
190
- function cbnetpoFooter() {
191
- echo '<p style="text-align:center;margin-top:3em;"><strong>'.cbnetpo_NAME.' '.cbnetpo_VERSION.' by <a href="http://www.chipbennett.net/" target="_blank" >Chip Bennett</a></strong></p>';
192
- }
193
-
194
- /**
195
- * Displays the options page
196
- * Carries out all the operations in options page
197
- */
198
- function cbnetpoOptionsPg() {
199
- global $wpdb;
200
- $this->cbnetpo_request = $_REQUEST['cbnetpo'];
201
- $msg ='';
202
-
203
- if ( $this->cbnetpo_request['pingnow'] ) {
204
- if ( $this->cbnetpo_wp_version >= 2.1 ) {
205
- if ( $this->cbnetpo_ping_sites == "" ) {
206
- $this->cbnetpoLog("NOT Pinging (no ping sites in services lists)", 7);
207
- } else if ( $this->cbnetpo_ping_option != 1 ) {
208
- $this->cbnetpoLog("NOT Pinging (disabled by administrator)", 6);
209
- } else {
210
- // schedule ping for now (forced ping)
211
- wp_schedule_single_event(time(), 'cbnetpo_ping', array('',4));
212
- }
213
- } else {
214
- $this->cbnetpoPingServices('',4);
215
- }
216
- } else if ( $this->cbnetpo_request['save'] ) {
217
- $this->cbnetpo_ping_sites = $this->cbnetpo_request['uris'];
218
- $this->cbnetpo_ping_option = 0;
219
- if ( $this->cbnetpo_request['ping'] == 1 ) {
220
- $this->cbnetpo_ping_option = 1;
221
- }
222
- update_option("cbnetpo_ping_optimizer", $this->cbnetpo_ping_option);
223
- update_option("ping_sites", $this->cbnetpo_ping_sites);
224
- $this->cbnetpo_options = array('limit_ping' => $this->cbnetpo_request['limit_ping'], 'limit_number' => $this->cbnetpo_request['limit_number'], 'limit_time' => $this->cbnetpo_request['limit_time']);
225
- update_option('cbnetpo_options', $this->cbnetpo_options);
226
- $msg = 'Options saved.';
227
- } else if ( $_GET['d'] == 'yes' ) {
228
- $wpdb->query("DELETE FROM $this->cbnetpo_pinglog_tbl");
229
- $msg = 'Ping Log Deleted.';
230
- }
231
-
232
- if ( $this->cbnetpo_options['limit_ping'] == 1 ) {
233
- $limit_ping_chk = 'checked';
234
- $limit_ping_display = 'block ';
235
- } else {
236
- $limit_ping_chk = '';
237
- $limit_ping_display = 'none ';
238
- }
239
- if ( $this->cbnetpo_ping_option == 1 ) $ping_enable_chk = 'checked';
240
- else $ping_enable_chk = '';
241
- if ( $wpdb->get_var("show tables like '$this->cbnetpo_pinglog_tbl'") != $this->cbnetpo_pinglog_tbl ) {
242
- if ( $msg != '' ) $msg .= "<br>";
243
- $msg .= "<font color='#ff0000'>Plugin NOT upgraded properly. Please reactivate the plugin.</font>";
244
- }
245
- if ( trim($msg) != '' ) {
246
- echo '<div id="message" class="updated fade"><p><strong>'.$msg.'</strong></p></div>';
247
- }
248
- require_once('include/options-pg.php');
249
- }
250
-
251
- /**
252
- * Sets flag if post is edited
253
- * @param integer $id The Post ID
254
- */
255
- function cbnetpoEditPost($id = 0) {
256
- if ( $id == 0 ) return;
257
- $this->cbnetpo_edited = 1;
258
- return $id;
259
- }
260
-
261
- /**
262
- * Sets flag if post status changes from private to published
263
- * @param integer $id The Post ID
264
- */
265
- function cbnetpoPrivateToPublished($id = 0) {
266
- if ( $id == 0 ) return;
267
- $this->cbnetpo_pvt_to_pub = 1;
268
- return $id;
269
- }
270
-
271
- /**
272
- * Gets the post title before publishing
273
- * @param string $title
274
- * @return string $title
275
- */
276
- function cbnetpoGetPostTitle($title) {
277
- $this->cbnetpo_post_title = $title;
278
- return $title;
279
- }
280
-
281
- /**
282
- * Formats the date to mm-dd-yyyy format
283
- * @param datetime $datetime
284
- * @return datetime $datetime. Formatted Date
285
- */
286
- function cbnetpoFormatDate($datetime) {
287
- if ( $datetime != '' ) {
288
- $datetime_parts = explode(' ',$datetime);
289
- $date_parts = explode('-',$datetime_parts[0]);
290
- $datetime = $date_parts[1].'-'.$date_parts[2].'-'.$date_parts[0].' '.$datetime_parts[1];
291
- }
292
- return $datetime;
293
- }
294
-
295
- /**
296
- * Copy of WP's "generic_ping".
297
- * Uses another function to send the actual XML-RPC messages.
298
- * @param string $post_title Title of the post
299
- * @param integer $post_type Future post or current post
300
- */
301
- function cbnetpoPingServices($post_title, $post_type) {
302
- global $wpdb;
303
-
304
- $this->already_pinged = array();
305
- $this->_post_type = $post_type;
306
- if ( strpos($post_title,'~#') !== false ) {
307
- $post_id_title = explode('~#',$post_title);
308
- $this->_post_title = $post_id_title[1];
309
- $this->_post_url = get_permalink($post_id_title[0]);
310
- } else {
311
- $this->_post_title = $post_title;
312
- $this->_post_url = '';
313
- }
314
 
315
- if ( $this->cbnetpo_wp_version >= 2.1 ) {
316
- // Do pingbacks
317
- while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
318
- $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';");
319
- pingback($ping->post_content, $ping->ID);
320
- }
321
- // Do Enclosures
322
- while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
323
- $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';");
324
- do_enclose($enclosure->post_content, $enclosure->ID);
325
- }
326
- // Do Trackbacks
327
- $trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'");
328
- if ( is_array($trackbacks) ) {
329
- foreach ( $trackbacks as $trackback )
330
- do_trackbacks($trackback->ID);
331
- }
332
- }
333
- $services = get_settings('ping_sites');
334
- $services = preg_replace("|(\s)+|", '$1', $services);
335
- $services = trim($services);
336
- if ( '' != $services ) {
337
- set_time_limit(300);
338
- $services = explode("\n", $services);
339
- foreach ($services as $service) {
340
- $this->cbnetpoSendXmlrpc($service);
341
- }
342
- }
343
- unset($this->already_pinged);
344
- set_time_limit(60);
345
- }
346
-
347
- /**
348
- * A modified version of WP's ping functionality "weblog_ping" in functions.php
349
- * Uses correct extended Ping format and logs response from service.
350
- * @param string $server
351
- * @param string $path
352
- */
353
- function cbnetpoSendXmlrpc($server = '', $path = '') {
354
- include_once (ABSPATH . WPINC . '/class-IXR.php');
355
-
356
- // using a timeout of 3 seconds should be enough to cover slow servers
357
- $client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));
358
- $client->timeout = 3;
359
- $client->useragent .= ' -- WordPress/'.$this->cbnetpo_wp_version;
360
-
361
- // when set to true, this outputs debug messages by itself
362
- $client->debug = false;
363
- $home = trailingslashit(get_option('home'));
364
- $check_url = ($this->_post_url != '') ? $this->_post_url : get_bloginfo('rss2_url');
365
-
366
- if ( !in_array($server,$this->already_pinged) ) {
367
- $this->already_pinged[] = $server;
368
- ///$this->_post_title = $this->_post_title.'###'.$check_url;///
369
- // the extendedPing format should be "blog name", "blog url", "check url" (post url), and "feed url",
370
- // but it would seem as if the standard has been mixed up. It's therefore good to repeat the feed url.
371
- // $this->_post_type = 2 if new post and 3 if future post
372
- if ( $client->query('weblogUpdates.extendedPing', get_settings('blogname'), $home, $check_url, get_bloginfo('rss2_url')) ) {
373
- $this->cbnetpoLog($server." was successfully pinged (extended format)", $this->_post_type, $this->_post_title);
374
- } else {
375
- if ( $client->query('weblogUpdates.ping', get_settings('blogname'), $home) ) {
376
- $this->cbnetpoLog($server." was successfully pinged", $this->_post_type, $this->_post_title);
377
- } else {
378
- $this->cbnetpoLog($server." could not be pinged. Error message: \"".$client->error->message."\"", $this->_post_type, $this->_post_title);
379
- }
380
- }
381
- }
382
- }
383
-
384
- /**
385
- * Pings if the post is published.
386
- * Doesn't ping if the post is edited or if future post
387
- * @param integer $id The Post ID
388
- */
389
- function cbnetpoPing($id) {
390
- global $wpdb;
391
-
392
- $row = $wpdb->get_row("SELECT ID,post_date,post_date_gmt,post_modified,post_status FROM $wpdb->posts WHERE id=$id", ARRAY_A);
393
-
394
- if ( $this->cbnetpo_ping_sites != "" ) {
395
- if ( $this->cbnetpo_ping_option == 1 ) {
396
- // if post is edited and not turned from private/draft to published
397
- if ( $this->cbnetpo_edited == 1 && $this->cbnetpo_pvt_to_pub == 0 && $row['post_status'] != 'draft' && $this->cbnetpo_post_title != '' && ($row['post_date'] <= current_time('mysql')) ) {
398
- $this->cbnetpoLog("NOT Pinging (%title% was edited)", 5, $this->cbnetpo_post_title);
399
- } else if ( $row['post_status'] != 'draft' ) {
400
- $post_id_title = $row['ID'].'~#'.$this->cbnetpo_post_title;
401
- // if post_date is greater than current time/date then its a future post (don't ping it)
402
- if ( ($row['post_date'] > current_time('mysql')) ) {
403
- if ( $this->excessive_pinging != 1 ) {
404
- if ( $this->cbnetpo_wp_version >= 2.1 ) {
405
- // schedule ping for future post
406
- wp_schedule_single_event(strtotime($row['post_date_gmt'].' GMT'), 'cbnetpo_ping', array($post_id_title,3));
407
- } else {
408
- $this->cbnetpo_future_pings[$id] = $id;
409
- update_option('cbnetpo_future_pings', $this->cbnetpo_future_pings);
410
- }
411
- $this->cbnetpoLog("NOT Pinging (future post: %title%). Will ping after ".$this->cbnetpoFormatDate($row['post_date']), 1, $this->cbnetpo_post_title);
412
- update_option('cbnetpo_last_ping_time',current_time('mysql'));
413
- update_option('cbnetpo_ping_num', get_option('cbnetpo_ping_num')+1);
414
- } else {
415
- $this->cbnetpoLog("NOT Pinging (Excessive Pinging Limit Reached)", 8);
416
- }
417
- } else if ( ($this->cbnetpo_pvt_to_pub == 1 || $row["post_status"] == 'publish') && $this->cbnetpo_post_title != '' ) {
418
- if ( $this->excessive_pinging != 1 ) {
419
- if ( $this->cbnetpo_wp_version >= 2.1 ) {
420
- // schedule ping for new post
421
- wp_schedule_single_event(time(), 'cbnetpo_ping', array($post_id_title,2));
422
- } else {
423
- $this->cbnetpoPingServices($post_id_title, 2);
424
- }
425
- update_option('cbnetpo_last_ping_time',current_time('mysql'));
426
- update_option('cbnetpo_ping_num', get_option('cbnetpo_ping_num')+1);
427
- } else {
428
- $this->cbnetpoLog("NOT Pinging (Excessive Pinging Limit Reached)", 8);
429
- }
430
- }
431
- }
432
- } else {
433
- if ( $row['post_status'] != 'draft' ) {
434
- if ( $this->cbnetpo_edited == 1 && $this->cbnetpo_pvt_to_pub == 0 && $row['post_status'] != 'draft' && $this->cbnetpo_post_title != '' && ($row['post_date'] <= current_time('mysql')) ) {
435
- $extra_msg = "It would NOT have pinged even if the ping was enabled.<br><br>Reason: %title% was edited";
436
- } else if ( ($row['post_date'] > current_time('mysql')) ) {
437
- $extra_msg = "It would have been scheduled for future ping if the ping was enabled.<br><br>Reason: future post %title%";
438
- } else if ( ($this->cbnetpo_pvt_to_pub == 1 || $row["post_status"] == 'publish') && $this->cbnetpo_post_title != '' ) {
439
- $extra_msg = "It would have pinged if the ping was enabled.<br><br>Reason: new post %title%";
440
- }
441
- $this->cbnetpoLog("NOT Pinging (disabled by administrator)~^$extra_msg", 6, $this->cbnetpo_post_title);
442
- }
443
- }
444
- } else {
445
- if ( $row['post_status'] != 'draft' ) {
446
- if ( $this->cbnetpo_edited == 1 && $this->cbnetpo_pvt_to_pub == 0 && $row['post_status'] != 'draft' && $this->cbnetpo_post_title != '' && ($row['post_date'] <= current_time('mysql')) ) {
447
- $extra_msg = "It would NOT have pinged even if ping sites were available.<br><br>Reason: %title% was edited";
448
- } else if ( ($row['post_date'] > current_time('mysql')) ) {
449
- $extra_msg = "It would have been scheduled for future ping if ping sites were available.<br><br>Reason: future post %title%";
450
- } else if ( ($this->cbnetpo_pvt_to_pub == 1 || $row["post_status"] == 'publish') && $this->cbnetpo_post_title != '' ) {
451
- $extra_msg = "It would have pinged if ping sites were available.<br><br>Reason: new post %title%";
452
- }
453
- $this->cbnetpoLog("NOT Pinging (no ping sites in services lists)~^$extra_msg", 7, $this->cbnetpo_post_title);
454
- }
455
- }
456
- }
457
-
458
- /**
459
- * Checks if time elasped for future post, and if so, removes post form the ping list and pings
460
- * For wordpress versions below 2.1
461
- */
462
- function cbnetpoFuturePing() {
463
- global $wpdb;
464
-
465
- // future ping list is empty
466
- if ( count($this->cbnetpo_future_pings) <= 0 || $this->cbnetpo_wp_version >= 2.1) {
467
- return true;
468
- }
469
- $maxbpddc_data_recent = $this->cbnetpo_future_ping_time;
470
-
471
- // Check last updated date and update it if more than 15 min, and ping if any future post's time elasped
472
- $prev_time = $this->cbnetpo_future_ping_time;
473
- $prev_time_parts = explode('-',$prev_time);
474
- $_prev_time = mktime((int)$prev_time_parts[3], (int)$prev_time_parts[4], (int)$prev_time_parts[5], (int)$prev_time_parts[1], (int)$prev_time_parts[2], (int)$prev_time_parts[0]);
475
- $_now_time = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
476
- $elapsed_min = ($_now_time-$_prev_time)/(60);
477
- $do_ping = 0;
478
-
479
- /// if last update/ping time more than 5 minutes
480
- if ( $elapsed_min > 5 ) {
481
- if ( is_array($this->cbnetpo_future_pings) ) {
482
- foreach ( $this->cbnetpo_future_pings as $id ) {
483
- $sql = "SELECT ID,post_date,post_status,post_title FROM $wpdb->posts WHERE id=$id";
484
- $row = $wpdb->get_row($sql, ARRAY_A);
485
-
486
- // if future published post later has been changed to draft or other status
487
- // then delete it from the ping list (It will be automatically be pinged when its status changes to publish)
488
- if ( $row['post_status'] != 'publish' && $row['post_status'] != 'future' ) {
489
- unset($this->cbnetpo_future_pings[$id]);
490
- }
491
- if ( $row["post_date"] <= current_time('mysql') && ($row['post_status'] == 'publish' || $row['post_status'] == 'future') ) {
492
- unset($this->cbnetpo_future_pings[$id]);
493
- $do_ping = 1;
494
- $post_title = $row['post_title'];
495
- }
496
- }
497
- }
498
- update_option("cbnetpo_future_pings", $this->cbnetpo_future_pings);
499
- update_option('cbnetpo_future_ping_time', date('Y-m-d-H-i-s'));
500
- if ( $do_ping == 1 ) {
501
- $post_id_title = $row['ID'].'~#'.$post_title;
502
- $this->cbnetpoPingServices($post_id_title,3);
503
- }
504
- }
505
- }
506
-
507
- /**
508
- * Deletes post from future ping list if deleted
509
- * @param integer $id The Post ID
510
- * @return integer $id
511
- */
512
- function cbnetpoFuturePingDelete($id) {
513
- global $wpdb;
514
- if ( $this->cbnetpo_wp_version >= 2.1 ) {
515
- $row = $wpdb->get_row("SELECT ID,post_date_gmt,post_title FROM $wpdb->posts WHERE id=$id", ARRAY_A);
516
- $post_id_title = $row['ID'].'~#'.$row['post_title'];
517
- wp_unschedule_event(strtotime($row['post_date_gmt'].' GMT'), 'cbnetpo_ping', array($post_id_title,2));
518
- return $id;
519
- }
520
- if ( count($this->cbnetpo_future_pings) <= 0 ) {
521
- return $id;
522
- }
523
- unset($this->cbnetpo_future_pings[$id]);
524
- update_option('cbnetpo_future_pings', $this->cbnetpo_future_pings);
525
- return $id;
526
- }
527
-
528
- /**
529
- * Saves the current plugin action
530
- */
531
- function cbnetpoLog($log_data,$type,$post_title='') {
532
- global $wpdb;
533
- $date_time = $this->cbnetpo_current_date;
534
- if ( cbnetpo_LOG == true ) {
535
- $query = "INSERT INTO $this->cbnetpo_pinglog_tbl (date_time, post_title, log_data, type)
536
- VALUES ('$date_time', '$post_title', '$log_data', '$type')";
537
- $wpdb->query($query);
538
- }
539
- return true;
540
- }
541
-
542
- /**
543
- * Gets log data and displays it
544
- * @param integer $total_logs Total lines of log data to be shown
545
- * @return string
546
- */
547
- function cbnetpoGetLogData() {
548
- global $wpdb;
549
- $query = "SELECT * FROM $this->cbnetpo_pinglog_tbl ORDER BY date_time DESC";
550
- $results = $wpdb->get_results($query,'ARRAY_A');
551
- $noof_records = count($results);
552
-
553
- // Delete old records form log table if max limit exceeds
554
- if ( $noof_records > $this->cbnetpo_max_log ) {
555
- $sql = "SELECT date_time FROM $this->cbnetpo_pinglog_tbl ORDER BY date_time DESC, id DESC LIMIT {$this->cbnetpo_max_log},1";
556
- $date_time = $wpdb->get_var($sql);
557
- $sql = "DELETE FROM $this->cbnetpo_pinglog_tbl WHERE date_time <= '$date_time'";
558
- $wpdb->query($sql);
559
- }
560
-
561
- if ( $noof_records <= 0 ) {
562
- $exists = 0;
563
- $msg = '<br>No ping log recorded yet.';
564
- } else {
565
- $exists = 1;
566
- $ping_data = array();
567
- foreach ( (array) $results as $key => $details ) {
568
- $ping_data[$details[date_time]][] = array($details['post_title'],$details['log_data'],$details['type']);
569
- }
570
- $count = 0;
571
- foreach ( (array) $ping_data as $ping_date => $_ping_data_arr ) {
572
- $ping_date = $this->cbnetpoFormatDate($ping_date);
573
- $count++; $cnt = 0;
574
- $bgcol = ($count%2 == 0) ? '#f8f8f8' : '#ffffff';
575
- foreach ( $_ping_data_arr as $key => $ping_data_arr ) {
576
- $ping_data = str_replace('%title%', '"'.$ping_data_arr[0].'"', $ping_data_arr[1]);
577
- if ( $ping_data_arr[2] == 2 || $ping_data_arr[2] == 3 || $ping_data_arr[2] == 4 ) {
578
- if ( $ping_data_arr[2] == 2 ) { // new post ping
579
- $_data = "Pinging (new post: \"$ping_data_arr[0]\")";
580
- } else if ( $ping_data_arr[2] == 3 ) { // future post ping
581
- $_data = "Pinging (future post appeared in your blog: \"$ping_data_arr[0]\")";
582
- } else if ( $ping_data_arr[2] == 4 ) { // forced ping
583
- $_data = "Pinging (forced ping)";
584
- }
585
- if ( strpos($ping_data,'(extended format)') !== false ) {
586
- $_ping_data = '<font color="#009207">'.$ping_data.'</font>';
587
- } else if ( strpos($ping_data,'Error message:') !== false ) {
588
- $_ping_data = '<font color="#FF0000">'.$ping_data.'</font>';
589
- } else {
590
- $_ping_data = '<font color="#0273A8">'.$ping_data.'</font>';
591
- }
592
- if ( $cnt == 0 ) $msg .= '<div style="padding:4px;background-color:'.$bgcol.'" id="parent'.$count.'"><b><a style="cursor:hand;cursor:pointer;border-bottom:0px" onclick="cbnetpoShowHide(\'child'.$count.'\',\'img'.$count.'\');"><img src="'.$this->cbnetpo_incpath.'images/arr_green1.gif" id="img'.$count.'" align="absmiddle"> <u>'.$ping_date.'</u></a></b> - '.$_data.'</div><div id="child'.$count.'" style="display:none;">';
593
- $msg .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &raquo; '.$_ping_data.'<br />';
594
- $cnt++;
595
- if ( count($_ping_data_arr) == $cnt ) $msg .= '<br></div>';
596
- } else {
597
- if ( strpos($ping_data,'~^') !== false ) {
598
- $msg_parts = explode('~^', $ping_data);
599
- $msg_part1 = $msg_parts[0];
600
- $msg_part2 = htmlspecialchars($msg_parts[1]);
601
- $msg .= '<div style="padding:4px;background-color:'.$bgcol.'"><img src="'.$this->cbnetpo_incpath.'images/arr_blue1.gif" align="absmiddle"> <b>'.$ping_date.'</b> - '.$msg_part1;
602
- $msg .= ' <a href="#" onMouseover="tooltip(\''.$msg_part2.'\',200)" onMouseout="hidetooltip()" style="border-bottom:none;"><img src="'.$this->cbnetpo_incpath.'images/help.gif" border="0" align="absmiddle" /></a></div>';
603
- } else {
604
- $msg .= '<div style="padding:4px;background-color:'.$bgcol.'"><img src="'.$this->cbnetpo_incpath.'images/arr_blue1.gif" align="absmiddle"> <b>'.$ping_date.'</b> - '.$ping_data.'</div>';
605
- }
606
- }
607
- }
608
- if ( $count >= $this->cbnetpo_rows_to_show ) return array($msg,$exists,$noof_records);
609
- }
610
- }
611
- return array($msg,$exists,$noof_records);
612
- }
613
-
614
-
615
- } // Eof Class
616
 
617
- $cbnetPingOptimizer = new cbnetPingOptimizer();
618
  ?>
2
  /*
3
  * Plugin Name: cbnet Ping Optimizer
4
  * Plugin URI: http://www.chipbennett.net/wordpress/plugins/cbnet-ping-optimizer/
5
+ * Description: Doesn't do anything. Isn't needed. Core WordPress handling of Pings is oh-so-fine!
6
+ * Version: 3.0
7
  * Author: chipbennett
8
  * Author URI: http://www.chipbennett.net//
9
  *
20
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
  * GNU General Public License for more details.
22
  *
23
+ * Version 3.0 and later of this Plugin: Copyright (C) 2012 Chip Bennett,
24
+ * Released under the GNU General Public License, version 2.0 (or newer)
25
+ *
26
+ * Previous versions of this Plugin were derived from MaxBlogPress Ping Optimizer plugin, version 2.2.5,
27
  * Copyright (C) 2007 www.maxblogpress.com, released under the GNU General Public License.
28
  */
29
 
 
 
 
 
30
  /**
31
+ * Add Plugin Settings Page
32
+ */
33
+ function cbnetpo_add_settings_page() {
34
+ add_options_page( 'cbnet Ping Optimier', 'cbnet Ping Optimizer', 'manage_options', 'cbnetpo-settings', 'cbnetpo_settings_page' );
35
+ }
36
+ add_action( 'admin_menu', 'cbnetpo_add_settings_page' );
37
+
38
+ /**
39
+ * Define Plugin Settings Page
40
  */
41
+ function cbnetpo_settings_page() {
42
+ ?>
43
+ <div class="wrap">
44
+ <h2>Ping Optimizer</h2>
45
+ <p>
46
+ Hello there! You may be wondering why you're reading this, instead of looking at Plugin settings. Well, the reason that you're
47
+ not looking at Plugin settings is because <em>there aren't any Plugin settings anymore</em>. In fact, this Plugin doesn't have
48
+ any functionality anymore.
49
+ </p>
50
+ <p>
51
+ Why? Because <em>this Plugin's functionality is no longer needed</em>. In fact, this Plugin's functionality may never have been needed in the first place. But regardless of that, it certainly isn't needed <em>now</em>.</p>
52
+
53
+ <h3>How Pings Work in WordPress</h3>
54
+
55
+ <p>
56
+ Let me explain why, starting with a walkthrough of how pings work in WordPress, courtesy of @Otto42:
57
+ </p>
58
+ <ol>
59
+ <li>When a post gets created, updated, inserted, modified, etc., eventually, it always goes through <code>wp_insert_post()</code>.</li>
60
+ <li><code>wp_insert_post()</code> calls <code>wp_transition_post_status()</code>.</li>
61
+ <li><code>wp_transition_post_status()</code> does various actions, but importantly it does this:<br />
62
+ <code>do_action("{$new_status}_{$post->post_type}", $post->ID, $post);</code><br />
63
+ So the action of <code>new-status</code> and <code>new-post-type</code> is called. In this case,
64
+ we're interested in the <em>publish</em> status on the <em>post</em> post-type, so <code>publish_post</code> is the action hook.</li>
65
+ <li>In <code>wp-includes/default-filters.php</code>, we have this:<br />
66
+ <code>add_action( 'publish_post', '_publish_post_hook', 5, 1 );</code><br />
67
+ So that causes <code>publish_post</code> to call <code>_publish_post_hook()</code>.</li>
68
+ <li><code>_publish_post_hook()</code>, among other things, adds the <code>'_pingme'</code> post meta to the post, and schedules the <code>do_pings</code> action for a one-time cron call, which will happen on the next page load (because it's hooked to <code>time()</code> for the schedule).</li>
69
+ <li>Again in <code>wp-includes/default-filters.php</code>, we have this:<br />
70
+ <code>add_action( 'do_pings', 'do_all_pings' );</code><br />
71
+ The <code>do_all_pings()</code> function does all the pings for all the posts that are marked as needing them done at the moment.</li>
72
+ </ol>
73
+ <p>Regarding draft, scheduled (future), and edited posts:</p>
74
+ <ol>
75
+ <li>Draft posts have a post_status of <code>draft</code>, meaning that <code>wp_transition_post_status()</code> calls <code>do_action()</code> on <code>draft_post</code> rather than on <code>publish_post</code>. Scheduled posts have a post_status of <code>future</code>, meaning that <code>wp_transition_post_status()</code> calls <code>do_action()</code> on <code>future_post</code> rather than on <code>publish_post</code>. Thus, neither draft nor scheduled posts get pings sent for them until
76
+ they actually transistion to <code>publish</code>, since that is when the <code>publish_post</code> action will get fired.</li>
77
+ <li>Editing posts: editing an existing post <em>will</em> send pings for the post, but <code>do_all_pings()</code> is smart. It calls the <code>pingback()</code> function to send pingbacks to blogs, and that in turn calls the <code>get_pung()</code> function to get the URLs in the post that have already been successfully pinged once before. This is very old code - so old, in fact, that the list of pinged blogs is actually a primary column (<code>pinged</code>) in the <code>wp_posts</code> table.</li>
78
+ </ol>
79
+
80
+ <h3>Why the Ping Optimizer Plugin Isn't Needed</h3>
81
+
82
+ <p>
83
+ So consider again the Plugin description:
84
+ </p>
85
+ <blockquote><em>
86
+ <p>Do you know your WordPress blog pings unnecessarily every time you edit a post? Think how many times you click on "Save and Continue Editing" or "Save" button. Your blog will ping unnecessarily that many times you click on those buttons.</p>
87
+
88
+ <p>Save your blog from getting tagged as ping spammer by installing this plugin.</p>
89
+
90
+ <p>After you install cbnet Ping Optimizer:</p>
91
+
92
+ <ol>
93
+ <li>When you create a new post, your blog will ping and notify all the ping services that it has been updated. This encourages search engines and different blog directories/services to index your updated blog properly.</li>
94
+
95
+ <li>When you edit an existing post, it won't send any unnecessary ping to ping services and saves your blog from getting banned by such services.</li>
96
+
97
+ <li>When you post a future post by editing the time stamp, it will ping only when your post appears in future. It won't unnecessarily ping many times when you schedule posts as WordPress does by default.</li>
98
+ </ol>
99
+ </em></blockquote>
100
+
101
+ <p>It should be obvious that most of that just isn't true anymore.</p>
102
+ <ol>
103
+ <li>
104
+ <blockquote><em>Think how many times you click on "Save and Continue Editing" or "Save" button. Your blog will ping unnecessarily that many times you click on those buttons.</em></blockquote>
105
+
106
+ <p>As you see above, this isn't true. Saving a draft post does not fire the <code>publish_post</code> action; therefore, no pings are triggered.</p>
107
+ </li>
108
+ <li>
109
+ <blockquote><em>When you create a new post, your blog will ping and notify all the ping services that it has been updated.</em></blockquote>
110
 
111
+ <p>WordPress core functionality does this already.</p>
112
+ </li>
113
+ <li>
114
+ <blockquote><em>When you edit an existing post, it won't send any unnecessary ping to ping services and saves your blog from getting banned by such services.</em></blockquote>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
 
116
+ <p>As you see above, WordPress intelligently fires pings when a post is edited, by keeping track of previous successful pings and not re-pinging them.</p>
117
+ </li>
118
+ <li>
119
+ <blockquote><em>When you post a future post by editing the time stamp, it will ping only when your post appears in future. It won't unnecessarily ping many times when you schedule posts as WordPress does by default.</em></blockquote>
 
 
120
 
121
+ <p>As you see above, scheduling a post fires the <code>future_post</code> action, and <em>not</em> the <code>publish_post</code> action. Thus, until a scheduled post actually transitions to <code>publish</code>, thereby firing the <code>publish_post</code> action, no pings are triggered.</p>
122
+ </li>
123
+ </ol>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
 
125
+ <p>So, none of this Plugin's functionality is needed. You can safely deactivate and uninstall it, with the understanding of why the core WordPress handling of pings works just fine.</p>
126
+ </div>
127
+ <?php
128
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
 
 
130
  ?>
include/options-pg.php DELETED
@@ -1,48 +0,0 @@
1
- <script type="text/javascript" src="<?php echo $this->cbnetpo_incpath;?>tooltip.js"></script>
2
- <link href="<?php echo $this->cbnetpo_incpath;?>tooltip.css" rel="stylesheet" type="text/css">
3
- <script><!--//
4
- function cbnetpoShowHide(Div,Img) {
5
- var divCtrl = document.getElementById(Div);
6
- if ( Img != '' ) var theImg = document.getElementById(Img);
7
- if ( divCtrl.style == "" || divCtrl.style.display == "none" ) {
8
- divCtrl.style.display = "block";
9
- if ( Img != '' ) theImg.src = '<?php echo $this->cbnetpo_incpath;?>images/arr_green2.gif';
10
- } else if ( divCtrl.style != "" || divCtrl.style.display == "block" ) {
11
- divCtrl.style.display = "none";
12
- if ( Img != '' ) theImg.src = '<?php echo $this->cbnetpo_incpath;?>images/arr_green1.gif';
13
- }
14
- }//--></script>
15
- <div class="wrap">
16
- <?php $this->cbnetpoHeader(); ?>
17
- <h3><?php _e('URIs to Ping', 'cbnetpo'); ?></h3>
18
- <p>The following services will automatically be pinged when you publish new posts or drafts.
19
- <strong>Not</strong> when you publish future posts or edit previously published posts, as WordPress does by default.</p>
20
- <p><strong>NB:</strong> This list is synchronized with the <a href="options-writing.php" target="_blank">original update services list</a>.</p>
21
- <form method="post">
22
- <p><?php _e('Separate multiple service URIs with line breaks:', 'cbnetpo'); ?><br />
23
- <textarea name="cbnetpo[uris]" cols="60" rows="10"><?php echo $this->cbnetpo_ping_sites;?></textarea></p>
24
- <p><input type="checkbox" name="cbnetpo[ping]" id="ping_checkbox" value="1" <?php echo $ping_enable_chk;?> /> Enable pinging</p>
25
- <p>
26
- <input type="checkbox" name="cbnetpo[limit_ping]" id="limit_ping" value="1" <?php echo $limit_ping_chk;?> onclick="cbnetpoShowHide('limit_ping_dv','')" /> Limit excessive pinging in short time
27
- <span id="limit_ping_dv" style="display:<?php echo $limit_ping_display;?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ping at most <input type="text" name="cbnetpo[limit_number]" value="<?php echo $this->cbnetpo_options['limit_number'];?>" style="width:25px" maxlength="5" /> time(s) within
28
- <input type="text" name="cbnetpo[limit_time]" value="<?php echo $this->cbnetpo_options['limit_time'];?>" style="width:25px" maxlength="5" /> minute(s)</span>
29
- </p>
30
- <p>
31
- <input type="submit" name="cbnetpo[save]" value="<?php _e('Save Settings', 'cbnetpo'); ?>" class="button" />
32
- <input type="submit" name="cbnetpo[pingnow]" value="<?php _e('Ping Now', 'cbnetpo'); ?>" class="button" onclick="return confirm('Are you sure you want to ping these services now? Pinging too often could get you banned for spamming.');" />
33
- </p>
34
- </form>
35
- <?php if ( cbnetpo_LOG == true ) { ?>
36
- <h3><?php _e('Ping Log', 'cbnetpo'); ?></h3>
37
- <?php
38
- list($pinglog,$exists,$pinglogrecords) = $this->cbnetpoGetLogData();
39
-
40
- if($exists){?><p><a href="?page=<?php echo $this->cbnetpo_path;?>&d=yes" onclick="return confirm('All ping log data will be deleted. Are you sure?')" style="color:#FF0000;font-weight:bold"><img src="<?php echo $this->cbnetpo_incpath;?>images/delete.gif" border="0" align="absmiddle"> Clear Log (<?php echo $pinglogrecords; ?> Records)</a></p><?php }?>
41
- <?php } ?>
42
- <p><strong><?php _e('Following are the lastest actions performed by the plugin:', 'cbnetpo'); ?></strong>
43
- <?php
44
- echo $pinglog;
45
- ?>
46
- </p>
47
- <?php $this->cbnetpoFooter(); ?>
48
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
include/tooltip.css DELETED
@@ -1,16 +0,0 @@
1
- #ddctooltip{
2
- position: absolute;
3
- left: -300px;
4
- width: 150px;
5
- border: 1px solid black;
6
- padding: 2px;
7
- background-color: lightyellow;
8
- visibility: hidden;
9
- z-index: 100;
10
- }
11
- #ddcpointer{
12
- position:absolute;
13
- left: -300px;
14
- z-index: 101;
15
- visibility: hidden;
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
include/tooltip.js DELETED
@@ -1,74 +0,0 @@
1
- var offsetfromcursorX=10
2
- var offsetfromcursorY=7
3
- var offsetdivfrompointerX=10
4
- var offsetdivfrompointerY=14
5
- document.write('<div id="ddctooltip"></div>')
6
- document.write('<div id="ddcpointer"></div>')
7
- var ie=document.all
8
- var ns6=document.getElementById && !document.all
9
- var enabletip=false
10
- if (ie||ns6)
11
- var tipobj=document.all? document.all["ddctooltip"] : document.getElementById? document.getElementById("ddctooltip") : ""
12
- var pointerobj=document.all? document.all["ddcpointer"] : document.getElementById? document.getElementById("ddcpointer") : ""
13
-
14
- function ietruebody(){
15
- return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
16
- }
17
-
18
- function tooltip(thetext, thewidth, thecolor){
19
- if (ns6||ie){
20
- if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
21
- if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
22
- tipobj.innerHTML=thetext
23
- enabletip=true
24
- return false
25
- }
26
- }
27
-
28
- function positiontip(e){
29
- if (enabletip){
30
- var nondefaultpos=false
31
- var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
32
- var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
33
- var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
34
- var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20
35
- var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
36
- var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY
37
- var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000
38
- if (rightedge<tipobj.offsetWidth){
39
- tipobj.style.left=curX-tipobj.offsetWidth+"px"
40
- nondefaultpos=true
41
- }
42
- else if (curX<leftedge)
43
- tipobj.style.left="5px"
44
- else{
45
- tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
46
- pointerobj.style.left=curX+offsetfromcursorX+"px"
47
- }
48
- if (bottomedge<tipobj.offsetHeight){
49
- tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
50
- nondefaultpos=true
51
- }
52
- else{
53
- tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
54
- pointerobj.style.top=curY+offsetfromcursorY+"px"
55
- }
56
- tipobj.style.visibility="visible"
57
- if (!nondefaultpos)
58
- pointerobj.style.visibility="visible"
59
- else
60
- pointerobj.style.visibility="hidden"
61
- }
62
- }
63
-
64
- function hidetooltip(){
65
- if (ns6||ie){
66
- enabletip=false
67
- tipobj.style.visibility="hidden"
68
- pointerobj.style.visibility="hidden"
69
- tipobj.style.left="-1000px"
70
- tipobj.style.backgroundColor=''
71
- tipobj.style.width=''
72
- }
73
- }
74
- document.onmousemove=positiontip
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,61 +1,93 @@
1
  === cbnet Ping Optimizer ===
2
  Contributors: chipbennett
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QP3N9HUSYJPK6
4
- Tags: cbnet, Ping Optimizer, images, plugin, generator, picture, icon, admin, maxblogpress
5
  Requires at least: 2.9
6
- Tested up to: 2.9.2
7
- Stable tag: 2.3.3
8
 
9
- Save your wordpress blog from getting tagged as ping spammer. Activation/subscription-free fork of MaxBlogPress Ping Optimizer plugin
10
 
11
  == Description ==
12
 
13
- Even the latest version of WordPress has this problem.
14
 
15
- Do you know your WordPress blog pings unnecessarily every time you edit a post? Think how many times you click on "Save and Continue Editing" or "Save" button. Your blog will ping unnecessarily that many times you click on those buttons.
16
 
17
- Save your blog from getting tagged as ping spammer by installing this plugin.
18
 
19
- **After you install cbnet Ping Optimizer:**
20
 
21
- * When you create a new post, your blog will ping and notify all the ping services that it has been updated. This encourages search engines and different blog directories/services to index your updated blog properly.
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- * When you edit an existing post, it won't send any unnecessary ping to ping services and saves your blog from getting banned by such services.
24
 
25
- * When you post a future post by editing the time stamp, it will ping only when your post appears in future. It won't unnecessarily ping many times when you schedule posts as WordPress does by default.
 
26
 
27
- == Installation ==
28
 
29
- Manual installation:
30
 
31
- 1. Upload the `cbnet-Ping Optimizer` folder to the `/wp-content/plugins/` directory
 
 
 
 
 
 
 
 
32
 
33
- Installation using "Add New Plugin"
34
 
35
- 1. From your Admin UI (Dashboard), use the menu to select Plugins -> Add New
36
- 2. Search for 'cbnet Ping Optimizer'
37
- 3. Click the 'Install' button to open the plugin's repository listing
38
- 4. Click the 'Install' button
39
 
40
- Activiation and Use
41
 
42
- 1. Activate the plugin through the 'Plugins' menu in WordPress
43
- 2. From your Admin UI (Dashboard), use the menu to select Options -> cbnet Ping Optimizer
44
- 3. Configure settings, and save
45
 
46
- == Frequently Asked Questions ==
 
 
 
 
 
 
 
 
47
 
48
- = Coming Soon =
 
 
 
 
 
 
49
 
50
- Let me know what questions you have!
51
 
52
- == Screenshots ==
53
 
54
- Screenshots coming soon.
55
 
56
 
57
  == Changelog ==
58
 
 
 
 
59
  = 2.3.3 =
60
  * Bugfix update.
61
  * Fixed the Settings page link in the plugin description, and moved to Plugin Actions list (next to Deactivate|Edit links).
@@ -72,6 +104,8 @@ Screenshots coming soon.
72
 
73
  == Upgrade Notice ==
74
 
 
 
75
  = 2.3.3 =
76
  Bugfix update. Fixed/moved Settings page link. Moved Clear Log link to top of ping log, and added record count.
77
  = 2.3.2 =
1
  === cbnet Ping Optimizer ===
2
  Contributors: chipbennett
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QP3N9HUSYJPK6
4
+ Tags: cbnet, Ping Optimizer
5
  Requires at least: 2.9
6
+ Tested up to: 3.5
7
+ Stable tag: 3.0
8
 
9
+ Doesn't do anything. Isn't needed. Core WordPress handling of Pings is oh-so-fine!
10
 
11
  == Description ==
12
 
13
+ Hello there! You may be wondering why you're reading this, instead of looking at Plugin settings. Well, the reason that you're not looking at Plugin settings is because there aren't any Plugin settings anymore. In fact, this Plugin doesn't have any functionality anymore.
14
 
15
+ Why? Because this Plugin's functionality is no longer needed. In fact, this Plugin's functionality may never have been needed in the first place. But regardless of that, it certainly isn't needed now.
16
 
17
+ = How Pings Work in WordPress =
18
 
19
+ Let me explain why, starting with a walkthrough of how pings work in WordPress, courtesy of @Otto42:
20
 
21
+ * When a post gets created, updated, inserted, modified, etc., eventually, it always goes through wp_insert_post().
22
+ * wp_insert_post() calls wp_transition_post_status().
23
+ * wp_transition_post_status() does various actions, but importantly it does this:
24
+ * do_action("{$new_status}_{$post->post_type}", $post->ID, $post);
25
+ * So the action of new-status and new-post-type is called. In this case, we're interested in the publish status on the post post-type, so publish_post is the action hook.
26
+ * In wp-includes/default-filters.php, we have this:
27
+ ** add_action( 'publish_post', '_publish_post_hook', 5, 1 );
28
+ ** So that causes publish_post to call _publish_post_hook().
29
+ * _publish_post_hook(), among other things, adds the '_pingme' post meta to the post, and schedules the do_pings action for a one-time cron call, which will happen on the next page load (because it's hooked to time() for the schedule).
30
+ * Again in wp-includes/default-filters.php, we have this:
31
+ ** add_action( 'do_pings', 'do_all_pings' );
32
+ * The do_all_pings() function does all the pings for all the posts that are marked as needing them done at the moment.
33
 
34
+ Regarding draft, scheduled (future), and edited posts:
35
 
36
+ * Draft posts have a post_status of draft, meaning that wp_transition_post_status() calls do_action() on draft_post rather than on publish_post. Scheduled posts have a post_status of future, meaning that wp_transition_post_status() calls do_action() on future_post rather than on publish_post. Thus, neither draft nor scheduled posts get pings sent for them until they actually transistion to publish, since that is when the publish_post action will get fired.
37
+ * Editing posts: editing an existing post will send pings for the post, but do_all_pings() is smart. It calls the pingback() function to send pingbacks to blogs, and that in turn calls the get_pung() function to get the URLs in the post that have already been successfully pinged once before. This is very old code - so old, in fact, that the list of pinged blogs is actually a primary column (pinged) in the wp_posts table.
38
 
39
+ = Why the Ping Optimizer Plugin Isn't Needed =
40
 
41
+ So consider again the Plugin description:
42
 
43
+ > Do you know your WordPress blog pings unnecessarily every time you edit a post? Think how many times you click on "Save and Continue Editing" or "Save" button. Your blog will ping unnecessarily that many times you click on those buttons.
44
+ >
45
+ > Save your blog from getting tagged as ping spammer by installing this plugin.
46
+ >
47
+ > After you install cbnet Ping Optimizer:
48
+ >
49
+ > * When you create a new post, your blog will ping and notify all the ping services that it has been updated. This encourages search engines and different blog directories/services to index your updated blog properly.
50
+ > * When you edit an existing post, it won't send any unnecessary ping to ping services and saves your blog from getting banned by such services.
51
+ > * When you post a future post by editing the time stamp, it will ping only when your post appears in future. It won't unnecessarily ping many times when you schedule posts as WordPress does by default.
52
 
53
+ It should be obvious that most of that just isn't true anymore.
54
 
55
+ > Think how many times you click on "Save and Continue Editing" or "Save" button. Your blog will ping unnecessarily that many times you click on those buttons.
 
 
 
56
 
57
+ As you see above, this isn't true. Saving a draft post does not fire the publish_post action; therefore, no pings are triggered.
58
 
59
+ > When you create a new post, your blog will ping and notify all the ping services that it has been updated.
 
 
60
 
61
+ WordPress core functionality does this already.
62
+
63
+ > When you edit an existing post, it won't send any unnecessary ping to ping services and saves your blog from getting banned by such services.
64
+
65
+ As you see above, WordPress intelligently fires pings when a post is edited, by keeping track of previous successful pings and not re-pinging them.
66
+
67
+ > When you post a future post by editing the time stamp, it will ping only when your post appears in future. It won't unnecessarily ping many times when you schedule posts as WordPress does by default.
68
+
69
+ As you see above, scheduling a post fires the future_post action, and not the publish_post action. Thus, until a scheduled post actually transitions to publish, thereby firing the publish_post action, no pings are triggered.
70
 
71
+ So, none of this Plugin's functionality is needed. You can safely deactivate and uninstall it, with the understanding of why the core WordPress handling of pings works just fine.
72
+
73
+ == Installation ==
74
+
75
+ Don't install this Plugin. You don't need it
76
+
77
+ == Frequently Asked Questions ==
78
 
79
+ = Why publish a Plugin that isn't needed? =
80
 
81
+ Originally, I forked this Plugin from another Plugin. That other Plugin, while released under GPL, required users to register and sign up for an email newsletter just to be able to use the Plugin. So, I forked it and removed all of the registration/email subscription code. Essentially, I forked the Plugin to prove a point, rather than to improve the code.
82
 
83
+ I did the same thing for a few other Plugins, for the same reason. When I originally released them, I just ripped out the registration/email subscription code, and re-released them. Recently, I have completely re-written all of those Plugins, except for this one. I was able to improve upon the code and functionality for the other Plugins, but not for this one. So, I'm simply updating this Plugin, and releasing it without functionality, and an explanation for why it is not needed.
84
 
85
 
86
  == Changelog ==
87
 
88
+ = 3.0 =
89
+ * Major update
90
+ * Plugin functionality not needed, and therefore removed and replaced with an explanation of why it is not needed.
91
  = 2.3.3 =
92
  * Bugfix update.
93
  * Fixed the Settings page link in the plugin description, and moved to Plugin Actions list (next to Deactivate|Edit links).
104
 
105
  == Upgrade Notice ==
106
 
107
+ = 3.0 =
108
+ Major update. Please visit the Plugin Settings page after updating.
109
  = 2.3.3 =
110
  Bugfix update. Fixed/moved Settings page link. Moved Clear Log link to top of ping log, and added record count.
111
  = 2.3.2 =