micropackage/filesystem 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

micropackage/filesystem

最新稳定版本:1.1.5

Composer 安装命令:

composer require micropackage/filesystem

包简介

Wrapper for WordPress' Filesystem for easier file manipulations.

README 文档

README

BracketSpace Micropackage Latest Stable Version PHP from Packagist Total Downloads License

Micropackage logo

🧬 About Filesystem

This micropackage is a wrapper for WordPress filesystem intended to be used within the wp-content directory.

Supports:

  • plugins
  • must-use plugins
  • themes
  • custom upload directories
  • custom wp-content directories

This package will prefix all the relative paths to full paths giving a convinient way to manipulate files.

💾 Installation

composer require micropackage/filesystem

🕹 Usage

Initializing the Filesystem class from the main plugin/theme file. It just needs a base directory.

use Micropackage\Filesystem\Filesystem;

$filesystem = new Filesystem( __DIR__ );

Using the micropackage to obtain full paths (plugin example).

echo $filesystem->path();
// /var/www/html/wp-content/plugins/my-plugin/

echo $filesystem->path( 'src/templates/full-width.php' );
// /var/www/html/wp-content/plugins/my-plugin/src/templates/full-width.php

Using the micropackage to obtain full URL (plugin example).

echo $filesystem->url();
// https://my.plugin/wp-content/plugins/my-plugin/

echo $filesystem->url( 'assets/images/logo.svg' );
// https://my.plugin/wp-content/plugins/my-plugin/assets/images/logo.svg

Convert image file to base64 URL.

printf( '<img src="%s">', $filesystem->image_to_base64( 'assets/images/logo.svg' ) );
// <img src="data:image/svg+xml;base64,m8q76v7wy4guiev...">

On top of that, you can use any method provided by WP_Filesystem class, which includes:

  • get_contents()
  • exists()
  • is_file(), is_dir()
  • mkdir()
  • delete()
  • ...

See all available methods

📦 About the Micropackage project

Micropackages - as the name suggests - are micro packages with a tiny bit of reusable code, helpful particularly in WordPress development.

The aim is to have multiple packages which can be put together to create something bigger by defining only the structure.

Micropackages are maintained by BracketSpace.

📖 Changelog

See the changelog file.

📃 License

This software is released under MIT license. See the LICENSE file for more information.

统计信息

  • 总下载量: 60.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 19
  • 点击次数: 2
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 19
  • Watchers: 3
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2020-01-28