| Server IP : 186.64.123.29 / Your IP : 216.73.217.94 Web Server : LiteSpeed System : Linux house.hostinglat.cl 5.15.0-185-generic #195-Ubuntu SMP Fri Jun 19 17:11:50 UTC 2026 x86_64 User : tuemp9827 ( 1016) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/tuempresavirtual.cl/public_html/wp-content/plugins/cartflows/admin-core/ajax/ |
Upload File : |
<?php
/**
* CartFlows Flows Stats 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 FlowsStats 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.
*
* @since 1.0.0
* @return void
*/
public function register_ajax_events() {
$ajax_events = array(
'get_all_flows_stats',
);
$this->init_ajax_events( $ajax_events );
}
/**
* Get all Flows Stats.
*/
public function get_all_flows_stats() {
$response_data = array( 'messsage' => $this->get_error_msg( 'permission' ) );
if ( ! current_user_can( 'cartflows_manage_flows_steps' ) ) {
wp_send_json_error( $response_data );
}
/**
* Nonce verification
*/
if ( ! check_ajax_referer( 'cartflows_get_all_flows_stats', 'security', false ) ) {
$response_data = array( 'messsage' => $this->get_error_msg( 'nonce' ) );
wp_send_json_error( $response_data );
}
$start_date = isset( $_POST['date_from'] ) ? sanitize_text_field( wp_unslash( $_POST['date_from'] ) ) : '';
$end_date = isset( $_POST['date_to'] ) ? sanitize_text_field( wp_unslash( $_POST['date_to'] ) ) : '';
$total_flow_revenue = AdminHelper::get_earnings( $start_date, $end_date );
$response = array(
'flow_stats' => $total_flow_revenue,
);
wp_send_json_success( $response );
}
}