• Stars
    star
    129
  • Rank 279,262 (Top 6 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 3 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Injects assets from a Vite manifest to the Wordpress head, supports themes and plugins

Vite Assets for WordPress

Adds assets from a Vite manifest to the WordPress head

License Version PHP Version Build

Table of contents

Installation

composer require idleberg/wordpress-vite-assets

Usage

To get you going, first instantiate the class exposed by this library

new Assets(string $manifestPath, string $baseUri, string $algorithm = "sha256");

Example

// functions.php

use Idleberg\WordPress\ViteAssets\Assets;

$baseUrl = get_stylesheet_directory_uri();
$manifest = "path/to/manifest.json";
$entryPoint = "index.ts";

$viteAssets = new Assets($manifest, $baseUrl);
$viteAssets->inject($entryPoint);

Methods

inject()

Usage: inject(array|string $entrypoints, array $options = [])

Injects tags for entries specified in the manifest to the page header

  • script entrypoint
  • preloads for imported scripts
  • style tags

getScriptTag()

Usage: getScriptTag(string $entrypoint, array $options = [])

Returns the script tag for an entry in the manifest

getStyleTags()

Usage: getStyleTags(string $entrypoint, array $options = [])

Returns the style tags for an entry in the manifest

getPreloadTags()

Usage: getPreloadTags(string $entrypoint)

Returns the preload tags for an entry in the manifest

Options

option.action

Type: null | string

Allows overriding the default action for the inject() method.

Example

// plugin.php

$viteAssets->inject("index.ts", [
	"action" => "admin_head"
]);

⚠️ It's unlikely that you want to change the default action, so don't override unless you know what you're doing!

option.crossorigin

Type: boolean | "anonymous" | "use-credentials"

Toggles crossorigin attribute on script and style tags, or assigns a value

option.integrity

Type: boolean

Toggles integrity attribute on script and style tags

option.priority

Type: int | array

Allows overriding the priority for the inject() method. It allows granular control when provided as an array:

Example

// functions.php

$viteAssets->inject("index.ts", [
	"priority" => [
		"scripts"  => 10,
		"preloads" => 0,
		"styles"   => 20
	]
]);

License

This work is licensed under The MIT License

More Repositories

1

Creative-Commons-Markdown

Markdown-formatted Creative Commons licenses
511
star
2

Bootstrap-Listr

Beautiful, responsive directory listings built upon Bootstrap
PHP
225
star
3

playdate-arcade-fonts

A collection of classic arcade game fonts for the Playdate
Svelte
158
star
4

Hopscotch

Color schemes inspired by the Hopscotch learning platform for kids
Emacs Lisp
117
star
5

sublime-icon-fonts

Completions for popular icon fonts such as Font Awesome, Glyphicons and many more!
JavaScript
72
star
6

vscode-nsis

Language syntax, IntelliSense and build system for Nullsoft Scriptable Install System (NSIS)
TypeScript
64
star
7

vscode-applescript

Language syntax and snippets for AppleScript
TypeScript
59
star
8

sublime-applescript

AppleScript command completions, build system and useful snippets. Supports editing binary scripts
Python
52
star
9

base16-notepad-plus-plus

Notepad++ styles based on Chris Kempson's Base16 colour scheme
HTML
42
star
10

base16-chrome-devtools

Chrome Developer Tools style sheets based on Chris Kempson's Base16 colour scheme
CSS
38
star
11

vscode-icon-fonts

Snippets for popular icon fonts such as Font Awesome, Ionicons, Glyphicons, Octicons, Material Design Icons and many more!
JavaScript
36
star
12

atomizr.rb

A script to convert Sublime Text (and TextMate) snippets and completions into Atom snippets
Ruby
32
star
13

vscode-badges

Snippets to quickly insert Shield.io badges into HTML, Markdown, reStructuredText or Textile documents
JavaScript
32
star
14

vscode-svg-icons

Snippets for a variety of SVG icons
JavaScript
31
star
15

sublime-semantic-ui

Snippets for the Semantic UI framework
31
star
16

Paraiso.tmTheme

Color scheme inspired by the art of Rubens LP
JavaScript
28
star
17

vscode-emoji-code

Snippets to insert escaped Emoji code into HTML, CSS, JavaScript, Python and Ruby
JavaScript
25
star
18

sveltekit-adapter-html-like

SvelteKit adapter for template engines such as PHP, Blade, Handlebars, etc.
JavaScript
24
star
19

vscode-hopscotch

Color scheme inspired by the Hopscotch learning platform for kids
23
star
20

node-makensis

A Node wrapper for makensis, the NSIS compiler
JavaScript
22
star
21

m8tro-bootstrap

Modern UI-inspired Bootstrap theme
HTML
20
star
22

3024.tmTheme

3024 theme for TextMate & Sublime Text
20
star
23

atom-icon-fonts

Atom snippets for a variety of icon fonts
JavaScript
19
star
24

atomizr

Convert snippets for Atom, Sublime Text, TextMate, and Visual Studio Code
JavaScript
19
star
25

Readme-Helper

Snippets to help you create Readme files
JavaScript
18
star
26

Zissou.tmTheme

The Life Aquatic inspired themes for TextMate & Sublime Text
HTML
18
star
27

vscode-innosetup

Language syntax and snippets for Inno Setup
TypeScript
17
star
28

atom-paraiso-dark

Color scheme inspired by the art of Rubens LP
Less
16
star
29

Kimbie.tmTheme

Color scheme inspired by Mount Kimbie's second album
JavaScript
15
star
30

RetroComputers.tmTheme

Color schemes for Textmate and Sublime Text, based on palettes of vintage computers
JavaScript
14
star
31

Paraiso-IntelliJ-IDEA

Color scheme inspired by the art of Rubens LP
14
star
32

Paraiso-iTerm2

Color scheme inspired by the art of Rubens LP
13
star
33

playdate-arcade-fonts-viewer

A simple viewer for my collection of arcade fonts for the Playdate
Lua
13
star
34

sublime-atomizr

Convert Sublime Text completions into Atom (or Visual Studio Code) snippets, and vice versa.
Python
13
star
35

Hopscotch.tmTheme

Color scheme inspired by the Hopscotch learning platform for kids
JavaScript
11
star
36

base16-highlight.js

Style sheets for highlight.js, based on Chris Kempson's Base16 colour scheme
CSS
11
star
37

Paraiso-Pygments

Color scheme inspired by the art of Rubens LP
Python
11
star
38

php-vite-manifest

A parser for Vite manifest files
PHP
10
star
39

atom-hopscotch

Color scheme inspired by the Hopscotch learning platform for kids
CSS
10
star
40

ASCII-Cowpletions

ASCII cow snippets for Sublime Text. Moo.
JavaScript
10
star
41

vscode-subway

A collection of color schemes based on subway maps from around the world
JavaScript
9
star
42

setup-playdate-sdk

A GitHub action that installs the Playdate SDK
9
star
43

atom-badges

Snippets to quickly insert Shield.io badges into HTML, Markdown, reStructuredText or Textile documents
JavaScript
8
star
44

applescript-svg-icon

Alternative icon for AppleScript
JavaScript
8
star
45

atom-semantic-ui

Atom snippets for Semantic UI
JavaScript
8
star
46

Paraiso-Terminal

Color scheme inspired by the art of Rubens LP
8
star
47

atom-edit-in-new-tab

Opens the current selection in a new tab, optionally writes back the changes to the origin
CoffeeScript
8
star
48

sublime-innosetup

Inno Setup syntax definition, completions and build system for SublimeText
Shell
7
star
49

wp-ratchet

Mobile-only WordPress theme built upon the Ratchet framework
CSS
7
star
50

vscode-openvpn

Language support and snippets for OpenVPN configuration files
JavaScript
7
star
51

sublime-badges

Snippets to quickly insert Shield.io badges into HTML, Markdown, reStructuredText or Textile documents
7
star
52

atom-svg-icons

Snippets for a variety of SVG icons
JavaScript
6
star
53

Paraiso-Windows-Command-Prompt

Color scheme inspired by the art of Rubens LP
6
star
54

homebrew-dbxcli

Homebrew tap for Dropbox CLI
Ruby
6
star
55

web-porridge

Feature-enhanced wrappers for the Storage and IndexedDB APIs
TypeScript
6
star
56

vscode-badgen

Snippets to quickly insert Badgen badges into Markdown documents
JavaScript
6
star
57

atom-build-python

Atom Build provider for python/python3/py, runs Python
JavaScript
6
star
58

atom-build-osa

Atom Build provider for Apple's Open Scripting Architecture, runs or compiles AppleScript and JavaScript for Automation (JXA)
JavaScript
6
star
59

create-playdate-release

A GitHub action that compiles and attaches a Playdate game to a release
6
star
60

Subway.tmTheme

A collection of color schemes based on subway maps from around the world
JavaScript
6
star
61

Zissou-iTerm2

The Life Aquatic inspired themes for iTerm2
5
star
62

vscode-electron-builder

Build system for Electron Builder
TypeScript
5
star
63

Paraiso-Gedit

Color scheme inspired by the art of Rubens LP
5
star
64

scoop-playdate-sdk

A Scoop bucket to install the Playdate SDK
JavaScript
5
star
65

webvsc-ui

Web frontend for webvsc, a converter for Winamp AVS presets
JavaScript
5
star
66

Paraiso-Eclipse

Color scheme inspired by the art of Rubens LP
5
star
67

sublime-drunken-php

Sublime Text completions for PHP, right kinda wrong
5
star
68

atom-browse

Adds commands that let you quickly browse Atom-related folders or reveal files you're working on
TypeScript
5
star
69

sublime-icon-fonts-legacy

Sublime Text snippets for legacy icon fonts that were removed from the main package
5
star
70

Paraiso-Xcode

Color scheme inspired by the art of Rubens LP
4
star
71

atom-language-nsis

Atom language support for NSIS, including grammar, snippets and build system
TypeScript
4
star
72

OGraphr

A Wordpress plugin that automatically retrieves images from embedded media-players and includes them as Open Graph compatible thumbnails
PHP
4
star
73

atom-emoji-code

Atom snippets to insert escaped Emoji codes into HTML, CSS, JavaScript and Ruby
JavaScript
4
star
74

Kimbie-IntelliJ-IDEA

Color scheme inspired by Mount Kimbie's second album
4
star
75

Kimbie-Xcode

Color scheme inspired by Mount Kimbie's second album
4
star
76

sublime-emoji-code

Sublime Text completions to insert escaped Emoji codes into HTML, CSS, JavaScript and Ruby
Python
4
star
77

atom-build-cmd

Atom Build provider for the Windows Command Prompt, runs Batch script
JavaScript
4
star
78

sublime-svg-icons

Sublime Text completions for a variety of popular SVG icons
4
star
79

vscode-textile

Syntax highlighting and snippets for the Textile markup language
JavaScript
4
star
80

atom-sublime

A meta package to bring some of Sublime Text's features to Atom
JavaScript
4
star
81

atom-package-control

Manage Atom packages from the command palette
TypeScript
4
star
82

sublime-nsis

Sublime Text completions and snippets for Nullsoft Scriptable Install System (NSIS)
4
star
83

atom-do-not-track

Blocks tracking scripts used in Atom packages
TypeScript
4
star
84

mediathek-youtubedl-bookmarklet

Bookmarklet to create a list of youtube-dl commands for search results on MediathekViewWeb
EJS
4
star
85

sublime-drunken-nsis

Sublime Text completions for NSIS, right kinda wrong
4
star
86

Creative-Commons-4.0-reStructuredText

RST-formatted Creative Commons 4.0 license texts
4
star
87

WebDAV-Connect.scpt

AppleScript that connects to a WebDAV server with credentials hard-coded in the source
AppleScript
4
star
88

vscode-nsis-plugins

Snippets for third-party plug-ins for Nullsoft Scriptable Install System (NSIS)
JavaScript
4
star
89

brackets-hopscotch

Color schemes inspired by the Hopscotch learning platform for kids
CSS
3
star
90

atom-build-sass

Atom Build provider for sass, compiles SCSS (and Sass)
JavaScript
3
star
91

NSIS.docset

Offline NSIS documentation set for Dash, Zeal, and Velocity
HTML
3
star
92

Kimbie-CodeMirror

Color scheme inspired by Mount Kimbie's second album
CSS
3
star
93

gulp-xml-validator

Gulp plugin to validate XML
JavaScript
3
star
94

Paraiso-Chrome-Developer-Tools

Color scheme inspired by the art of Rubens LP
CSS
3
star
95

log-smith

Creates a Markdown changelog from your GitHub releases
JavaScript
3
star
96

generator-nsis

Yeoman generator for NSIS scripts
JavaScript
3
star
97

generator-atom-package-webpack

[DEPRECATED] Generator for Atom packages written in JavaScript and compiled using Webpack
JavaScript
3
star
98

atom-nsis-plugins

Atom snippets for NSIS plug-ins
JavaScript
3
star
99

Paraiso-Color-Palettes

Color scheme inspired by the art of Rubens LP
3
star
100

Paraiso-CodeMirror

Color scheme inspired by the art of Rubens LP
CSS
3
star