PATH:
home
/
ediuae
/
petalwellnessspa.com
/
wp-content
/
plugins
/
simply-schedule-appointments
/
includes
<?php /** * Simply Schedule Appointments Action Model. * * @since 1.9.4 * @package Simply_Schedule_Appointments */ /** * Simply Schedule Appointments Action Model. * * @since 1.9.4 */ class SSA_Async_Action_Model extends TD_Async_Action_Model { protected $hook_namespace = 'ssa'; protected $db_namespace = 'ssa'; protected $api_namespace = 'ssa'; protected $api_version = '1'; /** * Parent plugin class. * * @since 1.9.4 * * @var Simply_Schedule_Appointments */ protected $plugin = null; /** * Constructor. * * @since 1.9.4 * * @param Simply_Schedule_Appointments $plugin Main plugin object. */ public function __construct( $plugin ) { parent::__construct( $plugin ); $this->hooks(); } /** * Initiate our hooks. * * @since 1.9.4 */ public function hooks() { add_filter( 'cron_schedules', array( $this, 'filter_cron_schedules' ) ); if ( ! wp_next_scheduled( 'ssa_cron_process_async_actions' ) ) { add_action( 'init', array( $this, 'schedule_cron' ) ); } add_action( 'ssa_cron_process_async_actions', array( $this, 'execute_cron_process_async_actions' ) ); add_action( 'init', array( $this, 'schedule_async_action_cleanup' ) ); add_action( 'ssa/async_actions/cleanup', array( $this, 'cleanup_async_actions' ) ); } /** * Filter the where conditions for the query * * @param string $where * @param array $args * @return string */ public function filter_where_conditions( $where, $args ) { global $wpdb; if ( ! empty( $args['object_id'] ) ) { $where .= $wpdb->prepare( ' AND object_id=%d', sanitize_text_field( $args['object_id'] ) ); } if ( ! empty( $args['object_type'] ) ) { $where .= $wpdb->prepare( ' AND object_type=%s', sanitize_text_field( $args['object_type'] ) ); } return $where; } /** * Scheduling the cleanup of completed async actions * * @return void */ public function schedule_async_action_cleanup() { if( ssa_should_skip_async_logic() ) { return; } if ( false === ssa_has_scheduled_action( 'ssa/async_actions/cleanup' ) ) { ssa_schedule_recurring_action( strtotime( 'now' ), DAY_IN_SECONDS, 'ssa/async_actions/cleanup' ); } } /** * completed async actions cleanup * * @return void */ public function cleanup_async_actions() { $all_async_actions = $this->query( array( 'date_completed_max' => gmdate( 'Y-m-d H:i:s', strtotime( '-90 days' ) ), 'date_completed_min' => SSA_Constants::EPOCH_START_DATE, 'number' => 10000, ) ); if ( empty( $all_async_actions ) ) { return; } // get ids of async actions as an array $all_async_actions_ids = wp_list_pluck( $all_async_actions, 'id' ); if ( ! empty( $all_async_actions_ids ) ) { // delete async actions rows $this->bulk_delete( array( 'id' => $all_async_actions_ids, ) ); } } public function filter_cron_schedules( $schedules ) { if ( ! isset( $schedules['ssa_async_interval'] ) ) { $interval_in_seconds = 60; if ( defined( 'SSA_ASYNC_CRON_INTERVAL' ) ) { $interval_in_seconds = SSA_ASYNC_CRON_INTERVAL; } $schedules['ssa_async_interval'] = array( 'interval' => $interval_in_seconds, 'display' => __( 'Once every minute', 'simply-schedule-appointments' ), ); } return $schedules; } public function schedule_cron() { wp_schedule_event( time(), 'ssa_async_interval', 'ssa_cron_process_async_actions' ); } public function execute_cron_process_async_actions() { $this->process(); } public function register_routes() { $version = '1'; $namespace = 'ssa/v' . $version; $base = 'async'; register_rest_route( $namespace, '/' . $base, array( array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => array( $this, 'process_endpoint' ), 'permission_callback' => '__return_true', ), array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'process_endpoint' ), 'permission_callback' => '__return_true', ), ) ); } public function process_endpoint( $request ) { define( 'SSA_DOING_ASYNC', true ); $params = $request->get_params(); if ( ! empty( $params[ 'delay' ] ) ) { $delay = (int) sanitize_text_field( $params['delay'] ); sleep( $delay ); } $params = shortcode_atts( array( 'object_type' => '', 'object_id' => '', ), $params ); // TODO: narrow scope to only appointment type $this->process(); // Call the runner() on wp_actionscheduler_actions ssa_run_action_scheduler_queue(); return true; } } function ssa_doing_async() { return defined( 'SSA_DOING_ASYNC' ) && SSA_DOING_ASYNC; } function ssa_queue_action( $hook, $action = null, $priority = 10, $payload = array(), $object_type = null, $object_id = null, $action_group = null, $meta = array() ) { if ( empty( $action ) ) { $action = 'ssa_async_' . $hook; } ssa()->async_action_model->queue_action( $hook, $action, $priority, $payload, $object_type, $object_id, $action_group, $meta ); } function ssa_complete_action( $action_id, $response = array() ) { ssa()->async_action_model->complete_action( $action_id, $response ); }
[-] class-settings.php
[edit]
[-] class-hooks.php
[edit]
[-] class-availability-query.php
[edit]
[-] class-appointment-model.php
[edit]
[-] class-beaver-builder.php
[edit]
[-] class-web-meetings.php
[edit]
[-] class-availability-model.php
[edit]
[-] class-recipient-admin.php
[edit]
[-] class-recipient-customer.php
[edit]
[-] class-constants.php
[edit]
[-] class-async-action-model.php
[edit]
[-] class-support.php
[edit]
[-] class-google-calendar-client.php
[edit]
[+]
..
[-] class-capabilities.php
[edit]
[-] class-encryption.php
[edit]
[-] class-availability-cache-invalidation.php
[edit]
[-] class-calendar-events-settings.php
[edit]
[-] class-settings-global.php
[edit]
[-] class-translation.php
[edit]
[-] class-cli.php
[edit]
[-] class-missing.php
[edit]
[-] class-action-scheduler.php
[edit]
[-] class-templates-api.php
[edit]
[-] class-blackout-dates.php
[edit]
[-] class-calendar-events-object.php
[edit]
[-] class-divi.php
[edit]
[-] class-templates.php
[edit]
[-] class-wp-admin.php
[edit]
[-] class-appointment-factory.php
[edit]
[-] class-scheduling-max-per-day.php
[edit]
[-] class-notifications-api.php
[edit]
[-] class-shortcodes.php
[edit]
[-] class-validation.php
[edit]
[-] class-resource-group-object-factory.php
[edit]
[-] class-payment-object.php
[edit]
[-] class-locale.php
[edit]
[-] class-ics-exporter.php
[edit]
[-] class-filesystem.php
[edit]
[-] class-recipient-shared.php
[edit]
[-] class-availability-schedule.php
[edit]
[-] class-block-upcoming-appointments.php
[edit]
[-] class-elementor.php
[edit]
[-] class-appointment-meta-model.php
[edit]
[-] class-revision-meta-model.php
[edit]
[+]
divi
[-] class-notifications.php
[edit]
[-] class-upgrade.php
[edit]
[-] class-utils.php
[edit]
[-] class-availability-functions.php
[edit]
[-] class-external-calendar-api.php
[edit]
[-] class-csv-exporter.php
[edit]
[-] class-external-google-calendar-api.php
[edit]
[-] class-twig-extension.php
[edit]
[-] class-bootstrap.php
[edit]
[-] class-notices.php
[edit]
[-] class-availability-schedule-factory.php
[edit]
[-] class-blackout-dates-settings.php
[edit]
[-] class-support-status.php
[edit]
[-] class-block-booking.php
[edit]
[-] class-advanced-scheduling-availability.php
[edit]
[-] class-exception.php
[edit]
[-] class-styles-settings.php
[edit]
[-] class-forms.php
[edit]
[-] class-recipient-staff.php
[edit]
[+]
beaver-builder
[-] class-users.php
[edit]
[-] class-sequence-factory.php
[edit]
[+]
third-party
[-] class-locales.php
[edit]
[-] class-db-model.php
[edit]
[-] class-db.php
[edit]
[-] class-availability-default.php
[edit]
[-] class-staff-settings.php
[edit]
[-] class-notification-model.php
[edit]
[-] class-settings-installed.php
[edit]
[-] class-appointment-object.php
[edit]
[-] class-notices-api.php
[edit]
[-] class-translation-settings.php
[edit]
[-] class-support-status-api.php
[edit]
[-] class-notices-data.php
[edit]
[-] class-appointment-type-object.php
[edit]
[-] class-appointment-type-object-factory.php
[edit]
[-] class-availability-block-factory.php
[edit]
[-] class-recipient.php
[edit]
[-] class-revision-model.php
[edit]
[-] class-customers.php
[edit]
[-] class-settings-api.php
[edit]
[-] class-cache.php
[edit]
[-] class-availability-detective-case.php
[edit]
[-] class-styles.php
[edit]
[-] class-capacity-settings.php
[edit]
[-] class-gcal-exporter.php
[edit]
[-] class-advanced-scheduling-settings.php
[edit]
[-] class-appointment-type-model.php
[edit]
[-] class-notifications-settings.php
[edit]
[-] class-period.php
[edit]
[-] class-external-api.php
[edit]
[-] class-error-notices.php
[edit]
[-] class-availability-cache.php
[edit]
[-] class-developer-settings.php
[edit]
[-] class-dashboard-upcoming-appointments-widget.php
[edit]
[-] class-availability-external-model.php
[edit]
[-] class-availability-block.php
[edit]
[-] class-customer-information.php
[edit]
[+]
elementor
[-] class-appointment-type-label-model.php
[edit]
[-] class-embed-booking-app-api.php
[edit]
[+]
lib
[-] class-sequence.php
[edit]
[-] class-debug.php
[edit]
[-] class-appointment-types-db.php
[edit]