Set_Up_Automator::initialize_integration_helpers()

Initialize all trigger,action, and closure classes


Source Source

File: src/core/classes/class-set-up-automator.php

	public function initialize_integration_helpers() {

		if ( empty( $this->active_directories ) ) {
			return;
		}

		foreach ( $this->active_directories as $dir_name => $object ) {
			$files = isset( self::$all_integrations[ $dir_name ]['helpers'] ) && in_array( 'helpers', $this->directories_to_include[ $dir_name ], true ) ? self::$all_integrations[ $dir_name ]['helpers'] : array();

			if ( empty( $files ) ) {
				continue;
			}
			// Loop through all files in directory to create class names from file name
			foreach ( $files as $file ) {
				require_once $file;
				$class = apply_filters( 'automator_helpers_class_name', $this->get_class_name( $file ), $file );
				if ( class_exists( $class ) ) {
					$mod = str_replace( '-', '_', $dir_name );
					try {
						$reflection = new ReflectionClass( $class );
						if ( $reflection->hasMethod( 'setOptions' ) ) {
							// Todo: Do not initiate helpers class.
							Utilities::add_helper_instance( $mod, new $class() );
						}