HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/html/ielts-store/wp-content/plugins/automatewoo/admin/controllers/logs.php
<?php
// phpcs:ignoreFile

namespace AutomateWoo\Admin\Controllers;

use AutomateWoo\Clean;
use AutomateWoo\Log_Factory;
use AutomateWoo\Report_Logs;

if ( ! defined( 'ABSPATH' ) ) exit;

/**
 * @class Logs
 */
class Logs extends Base {


	function handle() {

		$action = $this->get_current_action();

		switch ( $action ) {
			case 'rerun':
				$this->action_rerun();
				break;

			case 'bulk_delete':
				$this->action_bulk_edit( str_replace( 'bulk_', '', $action ) );
				$this->output_list_table();
				break;

			default:
				if ( aw_request( 'did-action' ) ) {
					$this->load_stored_responses();
				}
				$this->output_list_table();
				break;
		}
	}


	private function output_list_table() {
		$table = new Report_Logs();
		$table->prepare_items();
		$table->nonce_action = $this->get_nonce_action();

		$sidebar_content = '<p>' . __( 'Every time a workflow runs a log entry is created. Logs are used by some triggers to determine when they should and should not fire. For this reason deleting logs should generally be avoided.', 'automatewoo' ) . '</p>';

		$this->output_view( 'page-table-with-sidebar', [
			'table' => $table,
			'sidebar_content' => $sidebar_content
		]);
	}


	private function action_rerun() {

		$this->verify_nonce_action( 'rerun_log' );

		$log = Log_Factory::get( Clean::id( aw_request( 'log_id' ) ) );

		if ( $log ) {
			$new_log = $log->rerun();

			if ( $new_log ) {
				$this->add_message(
					__( 'Workflow was successfully re-run.', 'automatewoo' ),
					sprintf( __( 'Created log #%d.', 'automatewoo' ), $new_log->get_id() )
				);
			}
			else {
				$this->add_error( __( 'Workflow could not be re-run.', 'automatewoo' ) );
			}
		}
		else {
			$this->add_error( __( 'Log not found.', 'automatewoo' ) );
		}

		$this->redirect_after_action();
	}


	/**
	 * @param $action
	 */
	private function action_bulk_edit( $action ) {

		$this->verify_nonce_action();

		$ids = Clean::ids( aw_request( 'log_ids' ) );

		if ( empty( $ids ) ) {
			$this->add_error( __('Please select some logs to bulk edit.', 'automatewoo') );
			return;
		}

		foreach ( $ids as $id ) {

			if ( ! $log = Log_Factory::get( $id ) ) {
				continue;
			}

			switch ( $action ) {
				case 'delete':
					$log->delete();
					break;
			}
		}

		$this->add_message( __('Bulk edit completed.', 'automatewoo' ) );
	}
}

return new Logs();