Ticket #2933: ping-2.patch
| File ping-2.patch, 3.2 KB (added by c960657, 7 years ago) |
|---|
-
wp-includes/comment.php
635 635 } 636 636 637 637 function generic_ping($post_id = 0) { 638 $errors = get_option('ping_errors'); 639 if ( !is_array($errors) ) 640 $errors = array(); 638 641 $services = get_settings('ping_sites'); 639 642 $services = preg_replace("|(\s)+|", '$1', $services); // Kill dupe lines 640 643 $services = trim($services); 641 644 if ( '' != $services ) { 645 $update_ping_sites = false; 642 646 $services = explode("\n", $services); 643 foreach ($services as $service) { 644 weblog_ping($service); 647 foreach ($services as $i => $service) { 648 $error = weblog_ping($service); 649 if ( $error ) { 650 if ( !isset($errors[$service]) ) 651 $errors[$service] = array('count' => 0); 652 $errors[$service]['count']++; 653 $errors[$service]['last_message'] = $error; 654 if ( $errors[$service]['count'] > 25 || 655 $error == "DO NOT PING THIS SERVICE AGAIN!" ) { 656 unset($services[$i]); 657 $update_ping_sites = true; 658 } 659 } else { 660 unset($errors[$service]); 661 } 645 662 } 663 if ($update_ping_sites) 664 update_option('ping_sites', implode("\n", $services)); 646 665 } 666 update_option('ping_errors', $errors); 647 667 648 668 return $post_id; 649 669 } … … 791 811 $home = trailingslashit( get_option('home') ); 792 812 if ( !$client->query('weblogUpdates.extendedPing', get_settings('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping 793 813 $client->query('weblogUpdates.ping', get_settings('blogname'), $home); 814 815 $error = false; 816 if ( $client->isError() ) { 817 $error = $client->getErrorMessage(); 818 } else { 819 $response = $client->getResponse(); 820 if ( !isset($response['flerror']) || $response['flerror'] ) { 821 $error = isset($response['message']) && $response['message'] 822 ? $response['message'] : 'Invalid response'; 823 } 824 } 825 return $error; 794 826 } 795 827 796 828 ?> -
wp-admin/options-writing.php
99 99 <p><?php _e('When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see <a href="http://codex.wordpress.org/Update_Services">Update Services</a> on the Codex. Separate multiple service URIs with line breaks.') ?></p> 100 100 101 101 <textarea name="ping_sites" id="ping_sites" style="width: 98%;" rows="3" cols="50"><?php form_option('ping_sites'); ?></textarea> 102 103 <?php 104 $min_ping_error_count = 3; 105 ?> 106 <p><?php _e('These update services has failed the last ' . $min_ping_error_count . ' times or more. You should consider removing these services from the list above.') ?></p> 107 <dl> 108 <?php 109 $has_errors = false; 110 $services = get_option('ping_sites'); 111 foreach (get_option('ping_errors') as $service => $error) : 112 if ($error['count'] >= $min_ping_error_count && strpos($services, $service) !== false) : 113 echo "<dt>" . htmlspecialchars($service) . "<dt>"; 114 echo "<dd>" . htmlspecialchars($error['last_message']) . "<dd>"; 115 $has_errors = true; 116 endif; 117 endforeach; 118 119 if (!$has_errors) : 120 echo "<dd><em>" . __('No errors') . "</em></dd>"; 121 endif; 122 ?> 123 </dl> 102 124 </fieldset> 103 125 104 126 <p class="submit">
