';
}
return $content;
}
}
function adrcdp_check_publisher_auth($pub) {
$body = array(
'publisher' => $pub
);
$args = array(
'body' => $body
);
$result = wp_remote_post('https://www.compariola.com/ContentDrivenPromotion/WpRegisterAuth', $args);
if (!empty($result)) {
$result = json_decode($result['body'], true);
$auth = $result['Auth'] == "YES" ? 1 : 0;
update_option( 'adrcdp_publisher_auth', $auth );
return $auth;
}
return false;
}
class AdrCdp_Widget extends WP_Widget {
function __construct() {
parent::__construct(
'adrcdp_widget',
__( 'AdrCdp Widget' , 'adrcdp'),
array( 'description' => __( 'Display recommendations' , 'adrcdp') )
);
}
function widget( $args, $instance ) {
$pub = get_option( 'adrcdp_publisher' );
$auth = get_option( 'adrcdp_publisher_auth' );
if (!$auth || $auth == 0) {
$auth = adrcdp_check_publisher_auth($pub);
}
if ($auth && $auth == 1) {
?>
You are not authorized to display recommendations. Please register at https://www.adrelevantis.com/plugin-register.php.