Browse files

Merge pull request #1 from mheadd/master

Bug fix and formatting change to WP plugin
  • Loading branch information...
2 parents 9723fd6 + 69ca50d commit be6815f64b6dceb8b473ba99f8bd2d4681b5b900 @abhinemani abhinemani committed Apr 20, 2012
Showing with 48 additions and 42 deletions.
  1. +26 −22 cc-mkplc.php
  2. +22 −0 readme.md
  3. +0 −20 readme.txt
View
48 cc-mkplc.php
@@ -1,37 +1,41 @@
<?php
-/*
-Plugin Name: Civic Commons Marketplace
-Plugin URI: http://www.walkscore.com/professional/word-press.php
-Description:Provides simple shortcodes to embed Civic Commons Marketplace information on your wordpress blog
-Version: 0.1
-Author: Abhi Nemani
-Author URI: http://www.civiccommons.org
-License: GPL2
-*/
+/*
+ Plugin Name: Civic Commons Marketplace
+ Plugin URI: http://www.civiccommons.org
+ Description:Provides simple shortcodes to embed Civic Commons Marketplace information on your wordpress blog.
+ Version: 0.2
+ Author: Abhi Nemani
+ Author URI: http://www.civiccommons.org
+ License: GPL2
+ */
/* USAGE
- Shortcodes: [cc-mkplc]
-*/
+ Shortcodes: [cc-mkplc]
+ */
// [walk-score-map id="ws-id" address="" size="" orientation=""]
add_shortcode( 'cc-mkplc', 'cc_mkplc_sc' );
function cc_mkplc_sc( $atts, $content = null ) {
-
+
$default_atts = array(
'app' => null,
'height' => "300px",
);
-
- //get shortcode attributes
+
+ //get shortcode attributes
extract( shortcode_atts( $default_atts, $atts ) );
-
- //convert application name to ID
- $url = "http://marketplace.civiccommons.org/api/v1/views/application_api.xml?filters[keywords]=".$app;
- $xml = simplexml_load_file($url);
- $id = $xml->item->nid;
-
- return "<iframe src='http://50.19.214.65/cc-mkplc-widget/widget.html#" . $id . "' width='610px;' height='" . $height . "' frameborder='0' scrolling='no'></iframe>"; }
- ?>
+
+ // Convert application name to ID.
+ $url = "http://marketplace.civiccommons.org/api/v1/views/application_api.xml?filters[keywords]=".$app;
+ $xml = simplexml_load_file($url);
+ // If search terms return numtiple apps, randomize display.
+ $key = (count($xml->item) > 1) ? rand(0, (count($xml->item)-1)) : 0;
+ $id = $xml->item[$key]->nid;
+
+ return "<iframe src='http://codeforamerica.github.com/cc-mkplc-widget/widget.html#" . $id . "' width='610px;' height='" . $height . "' frameborder='0' scrolling='no'></iframe>";
+}
+
+?>
View
22 readme.md
@@ -0,0 +1,22 @@
+The Civic Commons Marketplace Wordpress Plugin
+==============================================
+
+This plugin enables you to embed links and information about Civic Technology from the Civic Commons Marketplace.
+
+Walk Score Plugin
+=================
+
+Contributors: mahalie, walkscore
+License: GPLv2
+
+**Shortcode Usage**
+
+The plugin makes the following shortcode available.
+
+ [cc-mkplc app="ANY-APP-NAME-OR-SEARCH-TERM-GOES-HERE" height="HEIGHTpx"]
+
+**Shortcode Examples**
+
+Display projects with a mapping component:
+
+ [cc-mkplc app="Drupal"]
View
20 readme.txt
@@ -1,20 +0,0 @@
-=== The Civic Commons Marketplace Wordpress Plugin ===
-
-This plugin enables you to embed links and information about Civic Technology from the Civic Commons Marketplace.
-
-=== Walk Score Plugin ===
-Contributors: mahalie, walkscore
-License: GPLv2
-
-**Shortcode Usage**
-
-The plugin makes the following shortcode available.
-
-`[cc-mkplc app="ANY-APP-NAME-GOES-HERE" height="HEIGHTpx"]`
-
-
-**Shortcode Examples**
-
-Display a map of the White House, USA:
-
-`[cc-mkplc app="Drupal" height"500px"]

0 comments on commit be6815f

Please sign in to comment.