Created
August 14, 2014 19:34
-
-
Save toolness/b5416a7eb2d27dd4d263 to your computer and use it in GitHub Desktop.
Wordpress plugin to list Hive member organizations from a Hive Directory server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package Hive_Directory_Listing | |
* @version 1.0 | |
*/ | |
/* | |
Plugin Name: Hive Directory Listing | |
Plugin URI: http://github.com/toolness/hive-django | |
Description: This is a plugin that integrates your WordPress site with the Hive\ | |
directory. | |
Author: Atul Varma | |
Version: 1.0 | |
Author URI: http://toolness.com/ | |
*/ | |
function hive_directory_listing_func($atts) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $atts['url']); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
$members = json_decode(curl_exec($ch), TRUE); | |
curl_close($ch); | |
$html = ''; | |
for ($i = 0; $i < count($members); $i++) { | |
$m = $members[$i]; | |
$html = $html . '<a href="' . $m['website'] . '">' . | |
$m['name'] . '</a><br>'; | |
} | |
return $html; | |
} | |
add_shortcode( 'hive_directory_listing', 'hive_directory_listing_func' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently this just registers a shortcode that can be used like so in a Wordpress page/post:
This will just insert a list of links into the page/post similar to the one on the current members page of the Hive NYC site.
This is just a super early initial version. Things left to do:
htmlspecialchars
(for text) andfilter_var
(for urls), just to be extra safe.<br>
at the end of the output that should be removed.<ul>
if they wanted, or something else. I originally wanted to use the Shortcode Exec PHP plugin instead of rolling my own plugin, but it doesn't seem to be maintained anymore.Note that this plugin is meant to integrate, eventually, with toolness/hive-django#34.