| 1 |
<?php |
| 2 |
|
| 3 |
function get_ph_pro_features() |
| 4 |
{ |
| 5 |
$features = array(); |
| 6 |
|
| 7 |
if ( false === ( $features = get_transient( 'propertyhive_features' ) ) || isset($_GET['ph_force_get_features']) ) |
| 8 |
{ |
| 9 |
// It wasn't there, so regenerate the data and save the transient |
| 10 |
$response = wp_remote_get( |
| 11 |
'https://wp-property-hive.com/add-ons-json.php', |
| 12 |
array( |
| 13 |
'timeout' => 10 |
| 14 |
) |
| 15 |
); |
| 16 |
|
| 17 |
if ( !is_wp_error( $response ) && is_array( $response ) ) |
| 18 |
{ |
| 19 |
$body = $response['body']; // use the content |
| 20 |
|
| 21 |
$add_ons = json_decode($body, TRUE); |
| 22 |
|
| 23 |
if ( $add_ons !== FALSE && is_array($add_ons) && !empty($add_ons) ) |
| 24 |
{ |
| 25 |
$features = $add_ons; |
| 26 |
set_transient( 'propertyhive_features', $features, DAY_IN_SECONDS ); |
| 27 |
} |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
$features = apply_filters( 'propertyhive_pro_features', $features ); |
| 32 |
|
| 33 |
return $features; |
| 34 |
} |
| 35 |
|
| 36 |
function get_ph_pro_feature( $requested_feature ) |
| 37 |
{ |
| 38 |
$features = get_ph_pro_features(); |
| 39 |
|
| 40 |
foreach ( $features as $feature ) |
| 41 |
{ |
| 42 |
$slug = explode("/", $feature['wordpress_plugin_file']); |
| 43 |
$slug = $slug[0]; |
| 44 |
|
| 45 |
if ( $slug == $requested_feature ) |
| 46 |
{ |
| 47 |
return $feature; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
return false; |
| 52 |
} |