PluginProbe
Property Hive / 2.3.0
Property Hive v2.3.0
2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 1.4.62 All 260 releases
propertyhive / includes / ph-pro-feature-functions.php

ph-pro-feature-functions.php in Property Hive 2.3.0, at includes/ph-pro-feature-functions.php

60 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }