<?php

if( !class_exists( 'PS_AEDL_Advance_Delivery' ) ):
class PS_AEDL_Advance_Delivery {

    private static $instance = null;
    private $enabled_advance_delivery = false;

    /**
     * Get the instance of the class
     * 
     * @since 1.0.0
     * @version 1.0.0
     */
    public static function get_instance() {

        if( null == self::$instance ) {

            self::$instance = new self;

        }

        return self::$instance;

    }

    /**
     * constructor of the class
     * 
     * @since 1.0.0
     * @version 1.0.0
     */
    public function __construct() {
        
        $settings = get_option( PS_AEDL_Settings::OPTION );
        $this->enabled_advance_delivery = psaedl_extract_value_from_option( $settings, 'enable_advance_delivery' );

        //Prevent emails from being sent, and keep them in queue
        if( $this->enabled_advance_delivery ) {

            add_filter( 'post_smtp_send_email', '__return_false', 12 );
            add_filter( 'post_smtp_do_send_email', '__return_false', 12 );
            add_filter( 'post_smtp_log_status', array( $this, 'set_log_status' ) );

        }

    }


    public function set_log_status() {

        return 'In Queue';

    }


}

PS_AEDL_Advance_Delivery::get_instance();    

endif;