Last active
December 15, 2015 01:19
-
-
Save brasofilo/5179139 to your computer and use it in GitHub Desktop.
Buscar informarción de plugins
This file contains hidden or 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 | |
/** | |
* Imprime información del plugin en el pié de página del sitio | |
* Ejemplo bruto de como se hace | |
* Mover la llamada a la función informacion_del_plugin() donde sea apropriado | |
* / | |
add_action( 'wp_footer', 'imprimir_info_de_plugin' ); | |
function imprimir_info_de_plugin() | |
{ | |
$plugin_info = informacion_del_plugin('woocommerce'); | |
echo '<pre>' . print_r( $plugin_info, true ) . '</pre>'; | |
} | |
function informacion_del_plugin( $slug ) | |
{ | |
$request = wp_remote_post( | |
'http://api.wordpress.org/plugins/info/1.0/', array( | |
'body' => array( | |
'action' => 'plugin_information', | |
'request' => serialize( | |
(object) array( | |
'slug' => $slug, | |
'fields' => array( 'last_updated' => true ) | |
) | |
) | |
) | |
) | |
); | |
if ( 200 != wp_remote_retrieve_response_code( $request ) ) | |
return 'error'; | |
$response = unserialize( wp_remote_retrieve_body( $request ) ); | |
// Return an empty but cachable response if the plugin isn't in the .org repo | |
if ( empty( $response ) ) | |
return 'sin respuesta'; | |
return $response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment