array(
'href' => array(),
),
'strong' => array(),
)
);
?>
=' );
}
/**
* Gets the message for display when the environment is incompatible with this plugin.
*
* @since 1.10.0
*
* @return string
*/
private function get_environment_message() {
return sprintf( 'The minimum PHP version required for this plugin is %1$s. You are running %2$s.', self::MINIMUM_PHP_VERSION, PHP_VERSION );
}
private static function is_wp_com() {
$api_url = 'https://public-api.wordpress.com/rest/v1.1/sites/' . wp_parse_url( get_site_url() )['host'];
$response = wp_remote_get( $api_url );
$response_body = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! is_wp_error( $response ) && isset( $response_body['ID'] ) ) {
return true;
}
return false;
}
private static function is_site_connected_compat() {
if ( ! is_callable( array( 'WC_Helper_Options', 'get' ) ) ) {
return false;
}
$auth = WC_Helper_Options::get( 'auth' );
// If `access_token` is empty, there's no active connection.
return ! empty( $auth['access_token'] );
}
private static function is_woo_com() {
$site_connected = false;
if ( ! is_callable( array( 'WC_Helper', 'is_site_connected' ) ) ) {
$site_connected = self::is_site_connected_compat();
} else {
$site_connected = WC_Helper::is_site_connected();
}
return $site_connected;
}
private static function has_woo_um_active() {
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
return is_plugin_active( 'woo-update-manager/woo-update-manager.php' );
}
private static function set_wc_facebook_svr_flags() {
if ( ! function_exists( 'update_option' ) ||
! function_exists( 'get_transient' ) ||
! function_exists( 'set_transient' ) ) {
return;
}
if ( false !== get_transient( 'wc_facebook_svr_flags_ds' ) ) {
return;
}
set_transient( 'wc_facebook_svr_flags_ds', 1, HOUR_IN_SECONDS );
$wp_woo_flags = 0;
$is_wp_com = self::is_wp_com();
if ( $is_wp_com ) {
$wp_woo_flags |= 1;
}
$is_woo_com = self::is_woo_com();
if ( $is_woo_com ) {
$wp_woo_flags |= 2;
}
$has_plugin_mgr = self::has_woo_um_active();
if ( $has_plugin_mgr ) {
$wp_woo_flags |= 4;
}
update_option( 'wc_facebook_svr_flags', $wp_woo_flags );
set_transient( 'wc_facebook_svr_flags_ds', 1, WEEK_IN_SECONDS );
}
/**
* Gets the main \WC_Facebook_Loader instance.
*
* Ensures only one instance can be loaded.
*
* @since 1.10.0
*
* @return \WC_Facebook_Loader
*/
public static function instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
}
// fire it up!
WC_Facebook_Loader::instance();