| 1 |
<?php |
| 2 |
/** |
| 3 |
* Functions to help troubleshoot installations of Force Refresh. |
| 4 |
* |
| 5 |
* @package ForceRefresh |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace JordanLeven\Plugins\ForceRefresh; |
| 9 |
|
| 10 |
if ( ! function_exists( 'plugins_api' ) ) { |
| 11 |
require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
| 12 |
} |
| 13 |
|
| 14 |
/** |
| 15 |
* Function to get the latest version of Force Refresh from the WordPress repository. |
| 16 |
* |
| 17 |
* @return mixed Either null (if unable to get the version) or a string. |
| 18 |
*/ |
| 19 |
function get_latest_plugin_version() { |
| 20 |
$args = array( |
| 21 |
'slug' => WP_FORCE_REFRESH_REPOSITORY_SLUG, |
| 22 |
'fields' => array( 'version' => true ), |
| 23 |
); |
| 24 |
|
| 25 |
$call_api = plugins_api( 'plugin_information', $args ); |
| 26 |
|
| 27 |
if ( ! is_wp_error( $call_api ) && ! empty( $call_api->version ) ) { |
| 28 |
return $call_api->version; |
| 29 |
} |
| 30 |
|
| 31 |
return null; |
| 32 |
} |
| 33 |
|