| 1 |
<?php |
| 2 |
/** |
| 3 |
* Telemetry functions. |
| 4 |
* |
| 5 |
* @package FaustWP |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WPE\FaustWP\Telemetry; |
| 9 |
|
| 10 |
use function WPE\FaustWP\Settings\{ |
| 11 |
is_redirects_enabled, |
| 12 |
is_rewrites_enabled, |
| 13 |
is_themes_disabled, |
| 14 |
is_image_source_replacement_enabled, |
| 15 |
faustwp_get_setting, |
| 16 |
}; |
| 17 |
|
| 18 |
if ( ! defined( 'ABSPATH' ) ) { |
| 19 |
exit; |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Returns the current WordPress version. |
| 24 |
* |
| 25 |
* @return string |
| 26 |
*/ |
| 27 |
function get_wp_version() { |
| 28 |
return get_bloginfo( 'version' ); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Checks if the current hosting environment is WP Engine. |
| 33 |
* |
| 34 |
* @return boolean |
| 35 |
*/ |
| 36 |
function is_wpe() { |
| 37 |
return defined( 'WPE_APIKEY' ); |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Returns the current FaustWP settings while keeping identifiable information private. |
| 42 |
* |
| 43 |
* @return array |
| 44 |
*/ |
| 45 |
function get_anonymous_faustwp_data() { |
| 46 |
$anonymous_data = array( |
| 47 |
'version' => get_plugin_version(), |
| 48 |
'has_frontend_uri' => has_frontend_uri(), |
| 49 |
'redirects_enabled' => is_redirects_enabled(), |
| 50 |
'rewrites_enabled' => is_rewrites_enabled(), |
| 51 |
'themes_disabled' => is_themes_disabled(), |
| 52 |
'image_source_replacement_enabled' => is_image_source_replacement_enabled(), |
| 53 |
); |
| 54 |
|
| 55 |
return $anonymous_data; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Returns the current WPGraphQL Content Blocks settings while keeping identifiable information private. |
| 60 |
* |
| 61 |
* @return array |
| 62 |
*/ |
| 63 |
function get_anonymous_wpgraphql_content_blocks_data() { |
| 64 |
$anonymous_data = array( |
| 65 |
'version' => get_wpgraphql_content_blocks_plugin_version(), |
| 66 |
); |
| 67 |
|
| 68 |
return $anonymous_data; |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* Checks if the frontend_uri FaustWP setting has been set. |
| 73 |
* |
| 74 |
* @return boolean |
| 75 |
*/ |
| 76 |
function has_frontend_uri() { |
| 77 |
$frontend_uri = faustwp_get_setting( 'frontend_uri' ); |
| 78 |
|
| 79 |
if ( empty( $frontend_uri ) ) { |
| 80 |
return false; |
| 81 |
} |
| 82 |
|
| 83 |
return true; |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Returns the FaustWP plugin version. |
| 88 |
* |
| 89 |
* @return string |
| 90 |
*/ |
| 91 |
function get_plugin_version() { |
| 92 |
$file_data = get_file_data( FAUSTWP_FILE, array( 'Version' ) ); |
| 93 |
$version = $file_data[0]; |
| 94 |
|
| 95 |
return $version; |
| 96 |
} |
| 97 |
|
| 98 |
/** |
| 99 |
* Returns the WPGraphql Content Blocks plugin version. |
| 100 |
* |
| 101 |
* @return null|string |
| 102 |
*/ |
| 103 |
function get_wpgraphql_content_blocks_plugin_version() { |
| 104 |
return defined( 'WPGRAPHQL_CONTENT_BLOCKS_VERSION' ) ? WPGRAPHQL_CONTENT_BLOCKS_VERSION : null; |
| 105 |
} |
| 106 |
|