Last active
September 7, 2017 09:35
-
-
Save kristarella/5b45ec8f05f8ea805eb1a38677898bce to your computer and use it in GitHub Desktop.
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 | |
function plugins( $search ) { | |
$num = 10; | |
$order = 'ASC'; | |
$orderby = 'name'; | |
$fields = 'URL,title'; | |
$url = 'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[search]='.urlencode( $search ); | |
$ch = curl_init(); | |
curl_setopt( $ch, CURLOPT_FAILONERROR, false ); | |
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ); | |
curl_setopt( $ch, CURLOPT_URL, $url ); | |
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); | |
curl_setopt($ch, CURLOPT_VERBOSE, true); | |
$body = curl_exec( $ch ); | |
$err = curl_errno( $ch ); | |
$data = json_decode( $body, true ); | |
if( $data ) { | |
echo '<?xml version="1.0"?><items>'; | |
while (list($key, $plugin) = each( $data['plugins'] ) ) { | |
echo '<item uid="'.$key.'" arg="https://wordpress.com/plugins/'.$plugin['slug'].'"><title>'.$plugin['name'].'</title> | |
<subtitle>ENTER to paste URL. SHIFT for Markdown link. CMD to open.</subtitle> | |
<mod key="shift" subtitle="Create Markdown Link" arg="['.$plugin['name'].' Plugin](https://wordpress.com/plugins/'.$plugin['slug'].'/)" /> | |
<mod key="option" subtitle="WordPress.org version" arg="https://wordpress.org/plugins/'.$plugin['slug'].'/" /> | |
</item>'; | |
} | |
echo "</items>"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment