Scaffold::check_target_directory( string $target_dir )

Checks that the $target_dir is a child directory of the WP themes or plugins directory, depending on $type.

Parameters Parameters


(string) (Required) "theme" or "plugin"


(string) (Required) The theme/plugin directory to check.

Top ↑

Return Return

(null|string) Returns null on success, error message on error.

Source Source

File: cli/src/scaffold.php

	public function check_target_directory( $target_dir ) {
		$parent_dir = dirname( self::canonicalize_path( str_replace( '\\', '/', $target_dir ) ) );

		if ( str_replace( '\\', '/', WP_PLUGIN_DIR ) !== $parent_dir ) {
			return sprintf( 'The target directory \'%1$s\' is not in \'%2$s\'.', $target_dir, WP_PLUGIN_DIR );

		// Success.
		return null;

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.