| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
|
| 8 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Legacy public global helper get_ph_pro_features; the established callable name is part of the plugin/extension API and must remain stable. |
| 9 |
function get_ph_pro_features() |
| 10 |
{ |
| 11 |
$features = array(); |
| 12 |
|
| 13 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only public feature metadata refresh; no installation, activation or licensing mutation is performed. |
| 14 |
if ( false === ( $features = get_transient( 'propertyhive_features' ) ) || isset($_GET['ph_force_get_features']) ) |
| 15 |
{ |
| 16 |
// It wasn't there, so regenerate the data and save the transient |
| 17 |
$response = wp_remote_get( |
| 18 |
'https://wp-property-hive.com/add-ons-json.php', |
| 19 |
array( |
| 20 |
'timeout' => 10 |
| 21 |
) |
| 22 |
); |
| 23 |
|
| 24 |
if ( !is_wp_error( $response ) && is_array( $response ) ) |
| 25 |
{ |
| 26 |
$body = $response['body']; // use the content |
| 27 |
|
| 28 |
$add_ons = json_decode($body, TRUE); |
| 29 |
|
| 30 |
if ( $add_ons !== FALSE && is_array($add_ons) && !empty($add_ons) ) |
| 31 |
{ |
| 32 |
$features = $add_ons; |
| 33 |
set_transient( 'propertyhive_features', $features, DAY_IN_SECONDS ); |
| 34 |
} |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
$features = apply_filters( 'propertyhive_pro_features', $features ); |
| 39 |
|
| 40 |
return $features; |
| 41 |
} |
| 42 |
|
| 43 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- Legacy public global helper get_ph_pro_feature; the established callable name is part of the plugin/extension API and must remain stable. |
| 44 |
function get_ph_pro_feature( $requested_feature ) |
| 45 |
{ |
| 46 |
$features = get_ph_pro_features(); |
| 47 |
|
| 48 |
foreach ( $features as $feature ) |
| 49 |
{ |
| 50 |
$slug = explode("/", $feature['wordpress_plugin_file']); |
| 51 |
$slug = $slug[0]; |
| 52 |
|
| 53 |
if ( $slug == $requested_feature ) |
| 54 |
{ |
| 55 |
return $feature; |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
return false; |
| 60 |
} |