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/includes/Tools/ToolsService.php
<?php

namespace AutomateWoo\Tools;

use AutomateWoo\Guest_Eraser;
use AutomateWoo\Options;
use AutomateWoo\OptionsStore;
use AutomateWoo\Tool_Abstract;
use AutomateWoo\Tool_Optin_Importer;
use AutomateWoo\Tool_Optout_Importer;
use AutomateWoo\Tool_Reset_Workflow_Records;

/**
 * Tools service class.
 *
 * @since 5.2.0
 */
class ToolsService {

	/**
	 * @var Tool_Abstract[] $tools
	 */
	protected $tools;

	/**
	 * @var OptionsStore
	 */
	protected $options_store;

	/**
	 * @param OptionsStore $options_store
	 */
	public function __construct( OptionsStore $options_store ) {
		$this->options_store = $options_store;
	}

	/**
	 * Get all tools.
	 *
	 * @return Tool_Abstract[]
	 */
	public function get_tools() {
		if ( isset( $this->tools ) ) {
			return $this->tools;
		}

		$class_names = [];

		$class_names[] = $this->options_store->get_optin_enabled() ? Tool_Optin_Importer::class : Tool_Optout_Importer::class;
		$class_names[] = Guest_Eraser::class;
		$class_names[] = Tool_Reset_Workflow_Records::class;

		$class_names = apply_filters( 'automatewoo/tools', $class_names );

		foreach ( $class_names as $tool_class ) {
			/** @var Tool_Abstract $class */
			$class                           = new $tool_class();
			$this->tools[ $class->get_id() ] = $class;
		}

		return $this->tools;
	}

	/**
	 * Get a single tool.
	 *
	 * @param string $id
	 *
	 * @return Tool_Abstract|false
	 */
	public function get_tool( string $id ) {
		$tools = $this->get_tools();

		if ( isset( $tools[ $id ] ) ) {
			return $tools[ $id ];
		}

		return false;
	}

}