fs ) { return $this->fs; } global $wp_filesystem; if ( ! function_exists( 'WP_Filesystem' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } if ( ! WP_Filesystem() ) { return new \WP_Error( 'pagecore_filesystem', __( 'WordPress could not get direct access to the filesystem on this host.', 'pagecore' ) ); } $this->fs = $wp_filesystem; return $this->fs; } /** * Whether the uploads directory can be written to. * * @return bool */ public function uploads_writable() { $uploads = wp_upload_dir(); if ( ! empty( $uploads['error'] ) ) { return false; } return wp_is_writable( $uploads['basedir'] ); } /** * Free space on the uploads volume, in bytes. * * @return int|null Null when the host does not report it. */ public function free_space() { $uploads = wp_upload_dir(); if ( ! empty( $uploads['error'] ) || ! function_exists( 'disk_free_space' ) ) { return null; } // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged $free = @disk_free_space( $uploads['basedir'] ); return false === $free ? null : (int) $free; } }