plugin updates
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Leadin\admin\api;
|
||||
|
||||
use Leadin\api\Base_Api_Controller;
|
||||
use Leadin\data\Portal_Options;
|
||||
|
||||
/**
|
||||
* Hublet Api. Used to fetch portal's hublet and update in case of region migration
|
||||
*/
|
||||
class Hublet_Api_Controller extends Base_Api_Controller {
|
||||
|
||||
/**
|
||||
* Class constructor, register route.
|
||||
*/
|
||||
public function __construct() {
|
||||
self::register_leadin_admin_route(
|
||||
'/hublet',
|
||||
\WP_REST_Server::EDITABLE,
|
||||
array( $this, 'update_hublet' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get's correct hublet and updates it in Options
|
||||
*
|
||||
* @param array $request Request body.
|
||||
*/
|
||||
public function update_hublet( $request ) {
|
||||
$data = json_decode( $request->get_body(), true );
|
||||
$hublet = $data['hublet'];
|
||||
|
||||
if ( ! $hublet ) {
|
||||
return new \WP_REST_Response( 'Hublet is required', 400 );
|
||||
}
|
||||
Portal_Options::set_hublet( $hublet );
|
||||
return new \WP_REST_Response( $hublet, 200 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Leadin\admin\api;
|
||||
|
||||
use Leadin\api\Base_Api_Controller;
|
||||
use Leadin\data\Portal_Options;
|
||||
|
||||
/**
|
||||
* Disable Internal Tracking Api. Used to exclude internal users to appear in HS analytics
|
||||
*/
|
||||
class Internal_Tracking_Api_Controller extends Base_Api_Controller {
|
||||
|
||||
/**
|
||||
* Class constructor, register route.
|
||||
*/
|
||||
public function __construct() {
|
||||
self::register_leadin_admin_route(
|
||||
'/internal-tracking',
|
||||
\WP_REST_Server::READABLE,
|
||||
array( $this, 'get_internal_tracking_option' )
|
||||
);
|
||||
self::register_leadin_admin_route(
|
||||
'/internal-tracking',
|
||||
\WP_REST_Server::EDITABLE,
|
||||
array( $this, 'set_internal_tracking_option' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the disable internal tracking option.
|
||||
*
|
||||
* @return bool Internal tracking option value.
|
||||
*/
|
||||
public function get_internal_tracking_option() {
|
||||
return new \WP_REST_Response( Portal_Options::get_disable_internal_tracking(), 200 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the disable internal tracking option.
|
||||
*
|
||||
* @param array $request Request body.
|
||||
*
|
||||
* @return string OK response message.
|
||||
*/
|
||||
public function set_internal_tracking_option( $request ) {
|
||||
Portal_Options::set_disable_internal_tracking( json_decode( $request->get_body(), true ) );
|
||||
return new \WP_REST_Response( 'OK', 200 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Leadin\admin\api;
|
||||
|
||||
use Leadin\api\Base_Api_Controller;
|
||||
use Leadin\admin\Connection;
|
||||
use Leadin\data\Portal_Options;
|
||||
|
||||
/**
|
||||
* Portal Api, used to clean portal id and domain from the WordPress options.
|
||||
*/
|
||||
class Portal_Api_Controller extends Base_Api_Controller {
|
||||
|
||||
/**
|
||||
* Class constructor, register route.
|
||||
*/
|
||||
public function __construct() {
|
||||
self::register_leadin_admin_route(
|
||||
'/business-unit',
|
||||
\WP_REST_Server::READABLE,
|
||||
array( $this, 'get_business_unit_option' )
|
||||
);
|
||||
self::register_leadin_admin_route(
|
||||
'/business-unit',
|
||||
\WP_REST_Server::EDITABLE,
|
||||
array( $this, 'set_business_unit_option' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get business unit id option.
|
||||
*
|
||||
* @return string Business Unit Id
|
||||
*/
|
||||
public function get_business_unit_option() {
|
||||
return new \WP_REST_Response( Portal_Options::get_business_unit_id(), 200 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set business unit id option.
|
||||
*
|
||||
* @param number $request Request body.
|
||||
*
|
||||
* @return string OK response message.
|
||||
*/
|
||||
public function set_business_unit_option( $request ) {
|
||||
$data = json_decode( $request->get_body(), true );
|
||||
$business_unit_id = $data['businessUnitId'];
|
||||
Portal_Options::set_business_unit_id( $business_unit_id );
|
||||
return new \WP_REST_Response( 'OK', 200 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Leadin\admin\api;
|
||||
|
||||
use Leadin\api\Base_Api_Controller;
|
||||
use Leadin\data\User_Metadata;
|
||||
|
||||
/**
|
||||
* User meta review Api, used to set the user metadata.
|
||||
*/
|
||||
class User_Meta_Api_Controller extends Base_Api_Controller {
|
||||
|
||||
/**
|
||||
* Class constructor, register route.
|
||||
*/
|
||||
public function __construct() {
|
||||
self::register_leadin_route(
|
||||
'/skip-review',
|
||||
\WP_REST_Server::CREATABLE,
|
||||
array( $this, 'skip_review' )
|
||||
);
|
||||
self::register_leadin_route(
|
||||
'/track-consent',
|
||||
\WP_REST_Server::CREATABLE,
|
||||
array( $this, 'track_consent' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip Review. Sets SKIP_REVIEW meta data for a user with current datetime.
|
||||
*/
|
||||
public function skip_review() {
|
||||
User_Metadata::set_skip_review( time() );
|
||||
return new \WP_REST_Response( 'OK', 200 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to set user consent on HubSpot anonymous tracking.
|
||||
*
|
||||
* @param array $request Request body.
|
||||
*/
|
||||
public function track_consent( $request ) {
|
||||
$data = json_decode( $request->get_body(), true );
|
||||
if ( array_key_exists( 'canTrack', $data ) ) {
|
||||
$consent = $data['canTrack'];
|
||||
User_Metadata::set_track_consent( $consent ? 'true' : 'false' );
|
||||
}
|
||||
return new \WP_REST_Response(
|
||||
json_encode( User_Metadata::get_track_consent(), true ),
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user