Advertisement
kitchin

Fix dashboard_incoming_links_feed

Apr 6th, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.05 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Fix dashboard_incoming_links_feed
  4. Plugin URI: http://core.trac.wordpress.org/ticket/20379
  5. Description: Fixes an issue updating the home URL's in Dashboard/Settings/General, in WP 3.3.1 and other versions. Note changes do not take effect until you return to Dashboard. To verify, look at the the db table 'wp_options' row with option_name='dashboard_widget_options'.
  6. Version: 1.0
  7. Author: kitchin
  8. License: FreeBSD
  9. */
  10.  
  11. if ( ! function_exists('fix_dashboard_incoming_links_feed') ) {
  12.  
  13.     // This filter is called when the adminr changes 'home' in the Dashboard, and on initial WP setup.
  14.  
  15.     add_filter( 'dashboard_incoming_links_feed', 'fix_dashboard_incoming_links_feed' );
  16.  
  17.     function fix_dashboard_incoming_links_feed( $url ) {
  18.  
  19.         // Copy code from wp-admin/includes/dashboard.php :
  20.  
  21.         $widget_options = get_option( 'dashboard_widget_options' );
  22.         if ( !$widget_options || !is_array($widget_options) )
  23.             $widget_options = array();
  24.  
  25.         $num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10;
  26.  
  27.         // New code :
  28.  
  29.         // This value is hard-coded in wp-admin/includes/dashboard.php :
  30.         $url_prefix = 'http://blogsearch.google.com/blogsearch_feeds?scoring=d&ie=utf-8&num=' . $num_items . '&output=rss&partner=wordpress&q=link:';
  31.  
  32.         // This is the default new url, as WP uses on initial setup :
  33.         $url = $url_prefix . trailingslashit( get_option('home') );
  34.  
  35.         // Heuristic to override the default url if it has been modded in the db.
  36.         // Maybe not a good idea, but here to maintain current WP behavior in that case.
  37.         // Not tested.
  38.  
  39.         if ( isset( $widget_options['dashboard_incoming_links']['url'] ) ) {
  40.             if (0 !== strpos($widget_options['dashboard_incoming_links']['url'], $url_prefix)) {
  41.                 $url = $widget_options['dashboard_incoming_links']['url'];
  42.             }
  43.         }
  44.  
  45.         // Note changes do not take effect until you return to Dashboard.
  46.         // To verify, look at the the db table 'wp_options' row with option_name='dashboard_widget_options'.
  47.  
  48.         return $url;
  49.     }
  50. }
  51.  
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement