| 1 |
<?php |
| 2 |
|
| 3 |
namespace FL\Assistant\Hooks\Actions; |
| 4 |
|
| 5 |
use FL\Assistant\Services\CustomizerService; |
| 6 |
|
| 7 |
/** |
| 8 |
* Class OnCustomizeRegister |
| 9 |
* @package FL\Assistant\Hooks\Actions |
| 10 |
*/ |
| 11 |
class OnCustomizeRegister { |
| 12 |
|
| 13 |
public function __invoke() { |
| 14 |
$this->init_customizer_requests(); |
| 15 |
} |
| 16 |
|
| 17 |
protected function init_customizer_requests() { |
| 18 |
if ( current_user_can( 'edit_theme_options' ) ) { |
| 19 |
|
| 20 |
if ( isset( $_POST['fl_assistant_export'] ) && is_numeric( $_POST['fl_assistant_export'] ) ) { |
| 21 |
|
| 22 |
$id = absint( $_POST['fl_assistant_export'] ); |
| 23 |
$service = new CustomizerService(); |
| 24 |
$response = $service->export_to_cloud( $id ); |
| 25 |
|
| 26 |
wp_send_json( $response ); |
| 27 |
|
| 28 |
} else if ( isset( $_POST['fl_assistant_import'] ) && is_numeric( $_POST['fl_assistant_import'] ) ) { |
| 29 |
|
| 30 |
$id = absint( $_POST['fl_assistant_import'] ); |
| 31 |
$service = new CustomizerService(); |
| 32 |
$response = $service->import_from_cloud( $id ); |
| 33 |
|
| 34 |
wp_send_json( $response ); |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
|