|
8 | 8 |
|
9 | 9 | use XWP\Helper\Functions as f;
|
10 | 10 |
|
| 11 | +if ( ! function_exists( 'xwp_wpfs' ) ) : |
| 12 | + /** |
| 13 | + * Loads the WordPress filesystem |
| 14 | + * |
| 15 | + * @template TFS of \WP_Filesystem_Base |
| 16 | + * |
| 17 | + * @param class-string<TFS> $method Optional. Filesystem method classname. Default null. |
| 18 | + * @param array|false $args Optional. Connection args, These are passed directly to the WP_Filesystem_*() classes. Default false. |
| 19 | + * @param string|false $context Optional. Context for get_filesystem_method(). Default false. |
| 20 | + * @return TFS|false|null |
| 21 | + */ |
| 22 | + function xwp_wpfs( |
| 23 | + string $method = null, |
| 24 | + array|bool $args = false, |
| 25 | + string|bool $context = false, |
| 26 | + ): WP_Filesystem_Base|bool|null { |
| 27 | + //phpcs:ignore Universal.Operators.DisallowShortTernary.Found |
| 28 | + $args = array_filter( $args ?: array( 'method' => $method ) ); |
| 29 | + |
| 30 | + return f\WPFS::load( $args, $context ); |
| 31 | + } |
| 32 | +endif; |
| 33 | + |
11 | 34 | if ( ! function_exists( 'wp_load_filesystem' ) ) :
|
12 | 35 | /**
|
13 | 36 | * Loads the WordPress filesystem
|
14 | 37 | *
|
15 |
| - * @param array|false $args Optional. Connection args, These are passed directly to the WP_Filesystem_*() classes. Default false. |
16 |
| - * @param string|false $context Optional. Context for get_filesystem_method(). Default false. |
17 |
| - * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false. |
| 38 | + * @template TFS of \WP_Filesystem_Base |
| 39 | + * |
| 40 | + * @param array{method?: class-string<TFS>}|array<string,mixed>|false $args Optional. Connection args, These are passed directly to the WP_Filesystem_*() classes. Default false. |
| 41 | + * @param string|false $context Optional. Context for get_filesystem_method(). Default false. |
18 | 42 | *
|
19 | 43 | * @return \WP_Filesystem_Base|false|null
|
| 44 | + * |
| 45 | + * @deprecated 1.10.0 Use xwp_wpfs instead. |
20 | 46 | */
|
21 | 47 | function wp_load_filesystem(
|
22 |
| - array|false $args = false, |
23 |
| - string|false $context = false, |
24 |
| - bool $allow_relaxed_file_ownership = false, |
25 |
| - ): \WP_Filesystem_Base|false|null { |
26 |
| - return f\WPFS::load( $args, $context, $allow_relaxed_file_ownership ); |
| 48 | + array|bool $args = false, |
| 49 | + string|bool $context = false, |
| 50 | + ): WP_Filesystem_Base|bool|null { |
| 51 | + return xwp_wpfs( null, $args, $context ); |
27 | 52 | }
|
28 | 53 | endif;
|
29 | 54 |
|
@@ -147,9 +172,9 @@ function xwp_deregister_blocks(): array {
|
147 | 172 | */
|
148 | 173 | function xwp_remove_hook_callbacks(
|
149 | 174 | string $classname,
|
150 |
| - string|false $target_hook = false, |
151 |
| - string|false $method = false, |
152 |
| - int|false $priority = false, |
| 175 | + string|bool $target_hook = false, |
| 176 | + string|bool $method = false, |
| 177 | + int|bool $priority = false, |
153 | 178 | ): array {
|
154 | 179 | return f\Hook_Remover::remove_callbacks( $classname, $target_hook, $method, $priority );
|
155 | 180 | }
|
|
0 commit comments