定制 ralfhortt/wp-assets 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ralfhortt/wp-assets

最新稳定版本:3.0.0

Composer 安装命令:

composer require ralfhortt/wp-assets

包简介

A helper package for working with the WordPress assets

README 文档

README

Installation

composer require ralfhortt/wp-assets

Documentation

Scripts

<?php
use \RalfHortt\Assets\Script;
use \RalfHortt\Assets\AdminScript;
use \RalfHortt\Assets\EditorScript;
use \RalfHortt\Assets\LoginScript;

new Script(string $handle, string $source, array $dependencies = [], string $version = true, array|bool $args);
new AdminScript(string $handle, string $source, array $dependencies = [], string $version = true, array|bool $args);
new EditorScript(string $handle, string $source, array $dependencies = [], string $version = true, array|bool $args);
new LoginScript(string $handle, string $source, array $dependencies = [], string $version = true, array|bool $args);

InlineScripts

use \RalfHortt\Assets\InlineScript;

new InlineScript(string $handle, string $data, bool $after = true);

Styles

<?php
use \RalfHortt\Assets\Style;
use \RalfHortt\Assets\AdminStyle;
use \RalfHortt\Assets\EditorStyle;
use \RalfHortt\Assets\LoginStyle;

new Style(string $handle, string $source, array $dependencies = [], $version = true, string $media = 'all');
new AdminStyle(string $handle, string $source, array $dependencies = [], $version = true, string $media = 'all');
new EditorStyle(string $handle, string $source, array $dependencies = [], $version = true, string $media = 'all');
new LoginStyle(string $handle, string $source, array $dependencies = [], $version = true, string $media = 'all');
new PrintStyle(string $handle, string $source, array $dependencies = [], $version = true, string $media = 'all');

Usage

<?php
// Initialize the Style object
$myTheme = new Style(get_stylesheet_directory_uri() . '/my-theme', 'theme.css');

// Hook Style object into WordPress lifecycle
$myTheme->register();

// InlineScript
$inlineScript = new InlineScript('my-theme', 'const ThemeName = "Awesome"', true);
$inlineScript->register();

// or
(new Style('my-theme', 'theme.css', ['global.css']))->register();
<?php
// Shortversion
(new Style(get_stylesheet_directory_uri() . '/my-theme', 'theme.css'))->register();
<?php
// Reuse asset
(new Style('my-theme', 'theme.css')->register();
(new LoginStyle('my-theme'))->register();

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-03