{"id":14954887,"url":"https://github.com/travelopia/wordpress-blade","last_synced_at":"2026-05-25T00:11:51.996Z","repository":{"id":253190552,"uuid":"838641849","full_name":"Travelopia/wordpress-blade","owner":"Travelopia","description":"Use Laravel Blade components in WordPress","archived":false,"fork":false,"pushed_at":"2024-11-13T14:35:33.000Z","size":62,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-01-29T08:11:28.866Z","etag":null,"topics":["laravel-blade","wordpress","wordpress-plugin"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/travelopia/wordpress-blade","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/Travelopia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2024-08-06T04:18:54.000Z","updated_at":"2024-12-18T11:00:34.000Z","dependencies_parsed_at":"2024-09-29T06:17:36.873Z","dependency_job_id":null,"html_url":"https://github.com/Travelopia/wordpress-blade","commit_stats":{"total_commits":18,"total_committers":3,"mean_commits":6.0,"dds":0.5,"last_synced_commit":"da22241102c6fc57e2a15df79b54a12dcea28435"},"previous_names":["travelopia/wordpress-blade"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Travelopia%2Fwordpress-blade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Travelopia%2Fwordpress-blade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Travelopia%2Fwordpress-blade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Travelopia%2Fwordpress-blade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Travelopia","download_url":"https://codeload.github.com/Travelopia/wordpress-blade/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237932060,"owners_count":19389560,"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":["laravel-blade","wordpress","wordpress-plugin"],"created_at":"2024-09-24T13:10:06.772Z","updated_at":"2026-05-25T00:11:51.989Z","avatar_url":"https://github.com/Travelopia.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WordPress Blade Plugin\n\n![maintenance-status](https://img.shields.io/badge/maintenance-actively--developed-brightgreen.svg)\n\nUse Laravel Blade components in WordPress.\n\n🚨 Note: Only Anonymous Components are currently supported: https://laravel.com/docs/10.x/blade#anonymous-components\n\n\u003ctable width=\"100%\"\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd align=\"left\" width=\"70%\"\u003e\n            \u003cp\u003eBuilt by the super talented team at \u003cstrong\u003e\u003ca href=\"https://www.travelopia.com/work-with-us/\"\u003eTravelopia\u003c/a\u003e\u003c/strong\u003e.\u003c/p\u003e\n\t\t\u003c/td\u003e\n\t\t\u003ctd align=\"center\" width=\"30%\"\u003e\n\t\t\t\u003cimg src=\"https://www.travelopia.com/wp-content/themes/travelopia/src/assets/svg/logo-travelopia-circle.svg\" width=\"50\" /\u003e\n\t\t\u003c/td\u003e\n\t\u003c/tr\u003e\n\u003c/table\u003e\n\n## Video Tutorial\n▶ ️[tutorial](https://www.youtube.com/watch?v=M7aCzMkL7Lo)\n\n## Installation\n\n### Install via Composer (recommended):\n\n```\n$ composer require travelopia/wordpress-blade\n```\n\n* Your composer file should include this\n```json\n{\n\t\"name\": \"your/packagename\",\n\t\"description\": \"Description\",\n\t\"extra\": {\n\t\t\"installer-paths\": {\n\t\t\t\"wp-content/mu-plugins/{$name}/\": [\"type:wordpress-muplugin\"]\n\t\t}\n\t},\n\t\"require\": {\n\t\t\"travelopia/wordpress-blade\": \"^1.0.0\",\n\t\t\"composer/installers\": \"^2.3\"\n\t},\n\t\"config\": {\n\t\t\"allow-plugins\": {\n\t\t\t\"composer/installers\": true\n\t\t}\n\t},\n\t\"scripts\": {\n\t\t\"wordpress-blade\": \"wordpress-blade\"\n\t}\n}\n```\n\n* This installs it as an MU Plugin.\n* Then load this plugin in your mu plugins loader file e.g. mu-plugins/loader.php\n```php\nrequire_once WPMU_PLUGIN_DIR . '/wordpress-blade/plugin.php';\n```\n* Then require the autoload file from vendor directory by adding the following code in your wp-config.php file.\n```php\nrequire_once 'vendor/autoload.php';\n```\n\n### Manual Installation (if you know what you are doing):\n\n1. Download this repository as a ZIP file.\n2. Run `composer install --no-dev --optimize-autoloader`\n3. Use it either as an MU plugin or a normal plugin!\n\n## Building for Production\n\nCompile your Blade components for production as a best practice. Some production environments are read-only, in which case this step is necessary.\n\nRun the following command:\n\n`composer exec wordpress-blade -- --config-file=blade.config.php` - Ensure the path to the Blade config is correct.\n\n## Usage\n\nFirst, create a `blade.config.php` file at the root of your project, and add the following code in there:\n\n```php\n\u003c?php\n/**\n * Blade Config.\n *\n * @package wordpress-blade\n */\n\ndefine(\n\t'WORDPRESS_BLADE',\n\t[\n\t\t'paths_to_views'         =\u003e [\n\t\t\t__DIR__ . '/wp-content/themes/\u003cyour-theme\u003e/\u003cpath-to-your-components\u003e',\n\t\t\t'parts' =\u003e __DIR__ . '/wp-content/themes/\u003cyour-theme\u003e/\u003cpath-to-your-components\u003e', // With namespace.\n\t\t\t// Any other paths where Blade needs to look for components.\n\t\t],\n\t\t'path_to_compiled_views' =\u003e __DIR__ . '/wp-content/themes/\u003cyour-theme\u003e/dist/blade', // Where you want Blade to save compiled files.\n\t\t'never_expire_cache'     =\u003e false, // Use `true` on production environments.\n\t\t'base_path'              =\u003e __DIR__, // The base path that is common to the front-end and admin.\n\t\t'encode_echo'            =\u003e true, // Double-encode entities in `{{ }}` output. See \"Echo encoding\" below.\n\t\t'register_wp_directives' =\u003e true, // Register `@escHtml`, `@escUrl`, `@escAttr`, `@wpKsesPost`, `@stripTags`, `@safeEscape` directives. See \"WordPress-aware escape directives\" below.\n\t]\n);\n```\n\n#### Echo encoding\n\nBy default Blade's `{{ $value }}` calls `e( $value, true )`, which **double-encodes** HTML entities. This is the Laravel default and is preserved by setting `encode_echo =\u003e true`.\n\nIf your templates receive values that have already been escaped upstream (for example, the output of WordPress's `esc_html()`, `esc_attr()`, or `wptexturize()`), double-encoding turns `\u0026amp;` into the literal text `\u0026amp;amp;`. Set `encode_echo =\u003e false` to switch to single-encoding (`e( $value, false )`) so upstream encoding is preserved.\n\n#### WordPress-aware escape directives\n\nThe package registers six Blade directives that wrap WordPress's escape helpers, letting templates express intent rather than the function call:\n\n| Directive | Compiles to | Use for |\n|---|---|---|\n| `@escHtml( $v )` | `echo esc_html( $v );` | Plain text in HTML bodies |\n| `@escUrl( $v )` | `echo esc_url( $v );` | `href` / `src` attribute values |\n| `@escAttr( $v )` | `echo esc_attr( $v );` | Other HTML attribute values |\n| `@wpKsesPost( $v )` | `echo wp_kses_post( $v );` | Rich text from editors (block content, ACF WYSIWYG, etc.) |\n| `@stripTags( $v )` | `echo wp_strip_all_tags( $v );` | Atomic strip-only — for values that need tag removal but will be escaped or used somewhere else (JSON, plain text response, an upstream-escaped pipeline). |\n| `@safeEscape( $v )` | `echo esc_html( wp_strip_all_tags( $v ) );` | The combined \"strip then escape\" path — the safe default for plain-text fields that may receive `wpautop`-wrapped or otherwise tag-laden content (post titles via filters, ACF text fields rendered alongside WYSIWYG siblings). |\n\nDirective names are prefixed / cased to correlate with the underlying WordPress helper (`@esc*` → `esc_*()`, `@wp*` → `wp_*()`, `@stripTags` → `wp_strip_all_tags()`, `@safeEscape` → the combined safe-default) and stay out of Laravel's reserved-directive namespace.\n\nThe expression — including its surrounding parentheses — is forwarded verbatim to the underlying WordPress helper. To skip registration (for example, if your project registers its own escape directives), set `'register_wp_directives' =\u003e false` in the bootstrap config or filter `wordpress_blade_register_wp_directives`.\n\n### Bootstrap a layout.\n\nAs a best practice, and if applicable, bootstrap an entire layout like so:\n\n```bladehtml\n# bootstrap.blade.php\n\u003cx-layout\u003e\n    \u003cx-hello name=\"Jane\"\u003eHi there!\u003c/x-hello\u003e\n\u003c/x-layout\u003e\n```\n\n```bladehtml\n# layout.blade.php\n@php\n    get_header();\n@endphp\n\n    \u003cmain\u003e\n        {{ $slot }}\n    \u003c/main\u003e\n\n@php\n    get_footer();\n@endphp\n```\n\n```bladehtml\n# hello.blade.php\n@props( [\n    'name' =\u003e '',\n] )\n\n\u003cdiv\u003e\n    \u003ch1\u003e{{ $slot }}\u003c/h1\u003e\n    \u003cp\u003eHello, {{ $name }}\u003c/p\u003e\n\u003c/div\u003e\n```\n\nAnd then load the view in your template:\n\n```php\nTravelopia\\Blade\\load_view( 'bootstrap' );\n```\n\nYou can also load an individual component like so:\n\n```php\n$name       = 'hello';              // The name of the component.\n$attributes = [ 'name' =\u003e 'Jane' ]; // Properties / attributes to pass into the component.\n$echo       = true;                 // Whether to echo the component. `false` returns the component as a string.\n\nTravelopia\\Blade\\load_view( $name, $attributes, $echo );\n```\n\nThis is especially useful when you want to load components from Blocks and Full Site Editing.\n\nIf you've used namespaces, you can use them like so:\n\n```bladehtml\n\u003cx-parts::my-part\u003e\u003c/x-parts::my-part\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravelopia%2Fwordpress-blade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftravelopia%2Fwordpress-blade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravelopia%2Fwordpress-blade/lists"}