WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Filesystem_Base::find_folder() public WP 2.7.0

Locates a folder on the remote filesystem.

Assumes that on Windows systems, Stripping off the Drive letter is OK Sanitizes \ to / in Windows filepaths.

Это метод класса: WP_Filesystem_Base{}

Хуков нет.

Возвращает

Строку/false. The location of the remote path, false on failure.

Использование

$WP_Filesystem_Base = new WP_Filesystem_Base();
$WP_Filesystem_Base->find_folder( $folder );
$folder(строка) (обязательный)
the folder to locate.

Список изменений

С версии 2.7.0 Введена.

Код WP_Filesystem_Base::find_folder() WP 5.5.1

wp-admin/includes/class-wp-filesystem-base.php
<?php
public function find_folder( $folder ) {
	if ( isset( $this->cache[ $folder ] ) ) {
		return $this->cache[ $folder ];
	}

	if ( stripos( $this->method, 'ftp' ) !== false ) {
		$constant_overrides = array(
			'FTP_BASE'        => ABSPATH,
			'FTP_CONTENT_DIR' => WP_CONTENT_DIR,
			'FTP_PLUGIN_DIR'  => WP_PLUGIN_DIR,
			'FTP_LANG_DIR'    => WP_LANG_DIR,
		);

		// Direct matches ( folder = CONSTANT/ ).
		foreach ( $constant_overrides as $constant => $dir ) {
			if ( ! defined( $constant ) ) {
				continue;
			}

			if ( $folder === $dir ) {
				return trailingslashit( constant( $constant ) );
			}
		}

		// Prefix matches ( folder = CONSTANT/subdir ),
		foreach ( $constant_overrides as $constant => $dir ) {
			if ( ! defined( $constant ) ) {
				continue;
			}

			if ( 0 === stripos( $folder, $dir ) ) { // $folder starts with $dir.
				$potential_folder = preg_replace( '#^' . preg_quote( $dir, '#' ) . '/#i', trailingslashit( constant( $constant ) ), $folder );
				$potential_folder = trailingslashit( $potential_folder );

				if ( $this->is_dir( $potential_folder ) ) {
					$this->cache[ $folder ] = $potential_folder;

					return $potential_folder;
				}
			}
		}
	} elseif ( 'direct' === $this->method ) {
		$folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation.

		return trailingslashit( $folder );
	}

	$folder = preg_replace( '|^([a-z]{1}):|i', '', $folder ); // Strip out Windows drive letter if it's there.
	$folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation.

	if ( isset( $this->cache[ $folder ] ) ) {
		return $this->cache[ $folder ];
	}

	if ( $this->exists( $folder ) ) { // Folder exists at that absolute path.
		$folder                 = trailingslashit( $folder );
		$this->cache[ $folder ] = $folder;

		return $folder;
	}

	$return = $this->search_for_folder( $folder );

	if ( $return ) {
		$this->cache[ $folder ] = $return;
	}

	return $return;
}