91 lines
1.6 KiB
PHP
91 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* CartFlows Flows ajax actions.
|
|
*
|
|
* @package CartFlows
|
|
*/
|
|
|
|
namespace CartflowsAdmin\AdminCore\Ajax;
|
|
|
|
// Exit if accessed directly.
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
use CartflowsAdmin\AdminCore\Ajax\AjaxBase;
|
|
use CartflowsAdmin\AdminCore\Inc\AdminHelper;
|
|
|
|
/**
|
|
* Class Flows.
|
|
*/
|
|
class SetupPage extends AjaxBase {
|
|
|
|
/**
|
|
* Instance
|
|
*
|
|
* @access private
|
|
* @var object Class object.
|
|
* @since 1.0.0
|
|
*/
|
|
private static $instance;
|
|
|
|
/**
|
|
* Initiator
|
|
*
|
|
* @since 1.0.0
|
|
* @return object initialized object of class.
|
|
*/
|
|
public static function get_instance() {
|
|
if ( ! isset( self::$instance ) ) {
|
|
self::$instance = new self();
|
|
}
|
|
return self::$instance;
|
|
}
|
|
|
|
/**
|
|
* Register_ajax_events.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register_ajax_events() {
|
|
|
|
$ajax_events = array(
|
|
'dismiss_setup_page',
|
|
);
|
|
|
|
$this->init_ajax_events( $ajax_events );
|
|
}
|
|
|
|
/**
|
|
* Save settings.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function dismiss_setup_page() {
|
|
|
|
$response_data = array( 'messsage' => $this->get_error_msg( 'permission' ) );
|
|
|
|
if ( ! current_user_can( 'cartflows_manage_settings' ) ) {
|
|
wp_send_json_error( $response_data );
|
|
}
|
|
|
|
/**
|
|
* Nonce verification
|
|
*/
|
|
if ( ! check_ajax_referer( 'cartflows_dismiss_setup_page', 'security', false ) ) {
|
|
$response_data = array( 'messsage' => $this->get_error_msg( 'nonce' ) );
|
|
wp_send_json_error( $response_data );
|
|
}
|
|
|
|
update_option( 'wcf_setup_page_skipped', true );
|
|
|
|
$response_data = array(
|
|
'success' => true,
|
|
'message' => __( 'Setup page dismissed successfully.', 'cartflows' ),
|
|
);
|
|
|
|
wp_send_json_success( $response_data );
|
|
}
|
|
|
|
|
|
}
|