Quantcast
Channel: Michael Fields » Topics » Dashboard
Viewing all articles
Browse latest Browse all 2

WordPress Plugin Support Aggregator

$
0
0

I make plugins for WordPress and I make it a point to host as many of them as possible in the Official WordPress Plugin Directory. I also like to support my plugins and prefer to do so at the WordPress Support Forums. Unfortunately, there is no easy way to see if someone has posted a new question except for clicking on all of the plugin pages and scrolling down to the “See what others are saying…” section on the right-hand sidebar. While I wish that these two sections of WordPress.org were better integrated this is currently not the case. For the time being, I came up with a solution that I would like to share with you.

Mad Props to the Following…

The following solution was created gluing together two tutorials that I have read. The first is an easy to follow article by Jeff Star on Perisable Press titled How to Import and Display RSS Feeds in WordPress. Jeff walks us through using the SimplePie class. The second tutorial was written by Devin Price and focuses on controlling what is displayed on the WordPress Dashboard and is titled Dashboard Support Widgets.

My goal was to combine these two tutorials into a custom solution where I would create a custom Dashboard Widget that displayed the 10 latest support questions for all of my plugins hosted on WordPress.org.

Create a Cache Directory

The first step is to create a cache directory on the server where WordPress is installed. In this example, I have created a directory named “wordpress-plugin-support-cache” directly under /wp-content/. You will want to set the new directory’s file permissions to 755.

Getting the Feeds

Fortunately, the Plugin Directory provides us with a public RSS feed for each plugin’s support section. The first step in finding the feed is to navigate to the plugins main page in the directory and click on the “Forum Posts” link.

You will want to click on the little orange RSS Feed icon to the right of “Forum Posts”. This will take you directly to the feed. Clicking on the text “Forum Posts” will bring you to a tag archive for support forums.

Save Some Time!

You do not need to follow the above process every single plugin that you have. Once you have one feed all you really need to do is modify the unique identifier in the url. Here’s the url for the support feed for my Taxonomy Images Plugin:

http://wordpress.org/support/rss/tags/taxonomy-images

The unique identifier here is “taxonomy-images” which is basically the title of the plugin in lowercase with spaces replaced by dashes. Here are all the links to my plugins hosted on Wordress.org:

http://wordpress.org/support/rss/tags/category-radio-buttons

http://wordpress.org/support/rss/tags/taxonomy-widget


http://wordpress.org/support/rss/tags/taxonomy-list-shortcode


http://wordpress.org/support/rss/tags/taxonomy-images


http://wordpress.org/support/rss/tags/taxonomy-terms-list


http://wordpress.org/support/rss/tags/bulk-image-resize-utility

Creating the Widget

if( !function_exists( 'mfields_dashboard_widget_plugin_support_aggregator' ) ) {
	function mfields_dashboard_widget_plugin_support_aggregator() {
		$feed_urls = array(
			'http://wordpress.org/support/rss/tags/category-radio-buttons',
			'http://wordpress.org/support/rss/tags/taxonomy-widget',
			'http://wordpress.org/support/rss/tags/taxonomy-list-shortcode',
			'http://wordpress.org/support/rss/tags/taxonomy-images',
			'http://wordpress.org/support/rss/tags/taxonomy-terms-list',
			'http://wordpress.org/support/rss/tags/bulk-image-resize-utility',
			);
		
		include_once ABSPATH . WPINC . '/class-simplepie.php';
		$feed = new SimplePie();
		$feed->set_feed_url( $feed_urls );
		$feed->set_cache_location( WP_CONTENT_DIR . '/wordpress-plugin-support-cache/' );
		$feed->set_cache_duration( 999 );
		$feed->handle_content_type();
		$check = $feed->init();
		
		if ( $check ) {
			print "\n\t" . '<ul>';
			foreach ( $feed->get_items( 0, 10 ) as $item ) {
				$blog = '';
				$href = $item->get_permalink();
				$title = $item->get_title();
				
				print "\n\t" . '<li><a href="' . $href . '">' . $title . '</a></li>';
			}
			print "\n\t" . '</ul>';
		}
		else {
			print "\n\t" . '<h2>Feeds currently not available</h2>';
			print "\n\t" . '<p>Please try again later</p>';
		}
	}
}

This function is based of the knowledge that I gained from the SimplePie article on Perisable Press. You will want to replace my feed urls with you own in the $feed_urls array.

Register the Dashboard Widget

if( !function_exists( 'mfields_dashboard_widget_plugin_support_aggregator_init' ) ) {
	add_action('wp_dashboard_setup', 'mfields_dashboard_widget_plugin_support_aggregator_init');
	function mfields_dashboard_widget_plugin_support_aggregator_init() {
		wp_add_dashboard_widget( 
			'mfields_dashboard_widget_plugin_support_aggregator', 
			'WordPress Plugin Support', 
			'mfields_dashboard_widget_plugin_support_aggregator'
			);
	}
}

This function was derived from the code that I found in Devin’s article. If you would like to change the title on the widget please modify the second argument passed to the wp_add_dashboard_widget() function.

That’s Really All There is to It!

You can copy and paste the following two functions into you theme’s functions.php or use them in a custom plugin.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles



Latest Images