{"id":13417512,"url":"https://github.com/idleberg/php-wordpress-vite-assets","last_synced_at":"2025-05-16T05:00:22.204Z","repository":{"id":49755755,"uuid":"461930073","full_name":"idleberg/php-wordpress-vite-assets","owner":"idleberg","description":"Injects assets from a Vite manifest to the Wordpress head, supports themes and plugins","archived":false,"fork":false,"pushed_at":"2025-05-04T22:37:08.000Z","size":242,"stargazers_count":142,"open_issues_count":0,"forks_count":14,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-10T20:35:26.320Z","etag":null,"topics":["manifest-json","vite","vitejs","wordpress"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/idleberg/wordpress-vite-assets","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idleberg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"buy_me_a_coffee":"idleberg"}},"created_at":"2022-02-21T15:53:11.000Z","updated_at":"2025-05-04T22:37:11.000Z","dependencies_parsed_at":"2024-06-19T02:50:44.728Z","dependency_job_id":"5314b168-02b3-4e1a-8dab-223421e0942d","html_url":"https://github.com/idleberg/php-wordpress-vite-assets","commit_stats":{"total_commits":162,"total_committers":7,"mean_commits":"23.142857142857142","dds":0.05555555555555558,"last_synced_commit":"93b8618beb5c9f67f3417c2266f0d198dd89e281"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idleberg%2Fphp-wordpress-vite-assets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idleberg%2Fphp-wordpress-vite-assets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idleberg%2Fphp-wordpress-vite-assets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idleberg%2Fphp-wordpress-vite-assets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idleberg","download_url":"https://codeload.github.com/idleberg/php-wordpress-vite-assets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471028,"owners_count":22076582,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["manifest-json","vite","vitejs","wordpress"],"created_at":"2024-07-30T22:00:38.880Z","updated_at":"2025-05-16T05:00:22.153Z","avatar_url":"https://github.com/idleberg.png","language":"PHP","readme":"# Vite Assets for WordPress\n\n\u003e Adds assets from a [Vite](https://vitejs.dev/) manifest to the WordPress head, supports themes and plugins.\n\n[![License](https://img.shields.io/packagist/l/idleberg/wordpress-vite-assets?style=for-the-badge\u0026color=blue)](https://github.com/idleberg/php-wordpress-vite-assets/blob/main/LICENSE)\n[![Version](https://img.shields.io/packagist/v/idleberg/wordpress-vite-assets?style=for-the-badge)](https://github.com/idleberg/php-wordpress-vite-assets/releases)\n![PHP Version](https://img.shields.io/packagist/dependency-v/idleberg/wordpress-vite-assets/php?style=for-the-badge)\n[![Build](https://img.shields.io/github/actions/workflow/status/idleberg/php-wordpress-vite-assets/default.yml?style=for-the-badge)](https://github.com/idleberg/php-wordpress-vite-assets/actions)\n\n\n**Table of contents**\n\n- [Installation](#installation)\n- [Usage](#usage)\n\t- [Methods](#methods)\n\t\t- [`inject()`](#inject)\n\t\t- [`getScriptTag()`](#getscripttag)\n\t\t- [`getStyleTags()`](#getstyletags)\n\t\t- [`getPreloadTags()`](#getpreloadtags)\n\t- [Options](#options)\n\t\t- [`option.action`](#optionaction)\n\t\t- [`option.crossorigin`](#optioncrossorigin)\n\t\t- [`option.integrity`](#optionintegrity)\n\t\t- [`option.priority`](#optionpriority)\n- [License](#license)\n\t\n## Installation\n\n`composer require idleberg/wordpress-vite-assets`\n\n## Usage\n\nTo get you going, first instantiate the class exposed by this library\n\n```php\nnew Assets(string $manifestPath, string $baseUri, string $algorithm = \"sha256\");\n```\n\n### Parameters\n\n#### `$manifestPath`\n\nType: `string`\n\nSpecifies the path to the manifest.\n\n#### `$baseUri`\n\nType: `string`\n\nSpecifies the base URI for the assets in the manifest.\n\n#### `$algorithm`\n\nType: `\"sha256\"` |`\"sha384\"` |`\"sha512\"` | `\":manifest:\"`  \nDefault: `\"sha256\"`  \n\nSpecifies the algorithm used for hashing the assets. This will be used for [subsource integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) when printing script or style tags.\n\n\u003e [!TIP]\n\u003e You can use `\":manifest:\"` in conjunction with [vite-plugin-manifest-sri](https://github.com/ElMassimo/vite-plugin-manifest-sri), a plug-in that calculates the hashes at build-time and adds them to the manifest.\n\n**Example**\n\n```php\n// functions.php\n\nuse Idleberg\\WordPress\\ViteAssets\\Assets;\n\n$baseUrl = get_stylesheet_directory_uri();\n$manifest = \"path/to/manifest.json\";\n$entryPoint = \"index.ts\";\n\n$viteAssets = new Assets($manifest, $baseUrl);\n$viteAssets-\u003einject($entryPoint);\n```\n\n### Methods\n\n#### `inject()`\n\nUsage: `inject(array|string $entrypoints, array $options = [])`\n\nInjects tags for entries specified in the manifest to the page header\n\n- script entrypoint\n- preloads for imported scripts\n- style tags\n\n#### `getScriptTag()`\n\nUsage: `getScriptTag(string $entrypoint, array $options = [])`\n\nReturns the script tag for an entry in the manifest\n\n#### `getStyleTags()`\n\nUsage: `getStyleTags(string $entrypoint, array $options = [])`\n\nReturns the style tags for an entry in the manifest\n\n#### `getPreloadTags()`\n\nUsage: `getPreloadTags(string $entrypoint)`\n\nReturns the preload tags for an entry in the manifest\n\n### Options\n\n#### `option.action`\n\nType: `null | string`\n\nAllows overriding the default action for the [`inject()`](#inject) method.\n\n\u003e [!WARNING]\n\u003e It's unlikely that you want to change the default action, so don't override unless you know what you're doing!\n\n**Example**\n\n```php\n// plugin.php\n\n$viteAssets-\u003einject(\"index.ts\", [\n\t\"action\" =\u003e \"admin_head\"\n]);\n```\n\n#### `option.crossorigin`\n\nType: `boolean | \"anonymous\" | \"use-credentials\"`\n\nToggles `crossorigin` attribute on script and style tags, or assigns a value\n\n#### `option.integrity`\n\nType: `boolean`\n\nToggles `integrity` attribute on script and style tags\n\n#### `option.priority`\n\nType: `int | array`\n\nAllows overriding the priority for the [`inject()`](#inject) method. It allows granular control when provided as an array:\n\n**Example**\n\n```php\n// functions.php\n\n$viteAssets-\u003einject(\"index.ts\", [\n\t\"priority\" =\u003e [\n\t\t\"scripts\"  =\u003e 10,\n\t\t\"preloads\" =\u003e 0,\n\t\t\"styles\"   =\u003e 20\n\t]\n]);\n```\n\n## License\n\nThis work is licensed under [The MIT License](LICENSE).\n","funding_links":["https://buymeacoffee.com/idleberg"],"categories":["Integrations with Backends","PHP"],"sub_categories":["WordPress"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidleberg%2Fphp-wordpress-vite-assets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidleberg%2Fphp-wordpress-vite-assets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidleberg%2Fphp-wordpress-vite-assets/lists"}