{"id":19450872,"url":"https://github.com/morning-train/wp-view","last_synced_at":"2025-10-06T23:21:03.686Z","repository":{"id":62551359,"uuid":"509376153","full_name":"Morning-Train/wp-view","owner":"Morning-Train","description":"Laravel blade and view for WordPress with custom directives.","archived":false,"fork":false,"pushed_at":"2023-03-30T15:00:08.000Z","size":87,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-01T13:54:29.160Z","etag":null,"topics":["blade","php","wordpress","wp"],"latest_commit_sha":null,"homepage":null,"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/Morning-Train.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":"2022-07-01T08:22:00.000Z","updated_at":"2023-01-19T21:22:50.000Z","dependencies_parsed_at":"2024-11-10T16:40:48.886Z","dependency_job_id":null,"html_url":"https://github.com/Morning-Train/wp-view","commit_stats":{"total_commits":68,"total_committers":4,"mean_commits":17.0,"dds":"0.16176470588235292","last_synced_commit":"12884095ef16e3bdc374e7fdbfa254f9c55fce14"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/Morning-Train/wp-view","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Morning-Train","download_url":"https://codeload.github.com/Morning-Train/wp-view/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-view/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278693681,"owners_count":26029569,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["blade","php","wordpress","wp"],"created_at":"2024-11-10T16:39:20.037Z","updated_at":"2025-10-06T23:21:03.654Z","avatar_url":"https://github.com/Morning-Train.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Views\n\nLaravel blade and view for WordPress with custom directives.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Getting Started](#getting-started)\n    - [Installation](#installation)\n- [Dependencies](#dependencies)\n    - [illuminate/view](https://github.com/illuminate/view)\n    - [morningtrain/php-loader](#morningtrainphp-loader)\n- [Usage](#usage)\n    - [View directory](#view-directory)\n    - [Render a view](#render-a-view)\n    - [Working with namespaces](#working-with-namespaces)\n        - [Registering a namespace](#registering-a-namespace)\n        - [Using a namespace](#using-a-namespace)\n    - [Custom @directives](#custom-directives)\n        - [@wpauth()](#wpauth)\n        - [@header()](#header)\n        - [@footer()](#footer)\n        - [@script()](#script)\n        - [@style()](#style)\n        - [@username()](#username)\n        - [@cache()](#cache)\n        - [@react()](#react)\n- [Credits](#credits)\n- [License](#license)\n\n# Introduction\n\n## Getting Started\n\nTo get started install the package as described below in [Installation](#installation).\n\nTo use the tool have a look at [Usage](#usage)\n\n### Installation\n\nInstall with composer\n\n```bash\ncomposer require morningtrain/wp-view\n```\n\n## Dependencies\n\n### illuminate/view\n\n[illuminate/view](https://github.com/illuminate/view)\n\n### morningtrain/php-loader\n\n[PHP Loader](https://github.com/Morning-Train/php-loader) is used to load and initialize all Hooks\n\n## Usage\n\nFor an overview see the [official Laravel documentation](https://laravel.com/docs/views)\n\n### View directory\n\nTo set the main directory for views\n\n```php\n\\Morningtrain\\WP\\View\\View::setup(__DIR__ . \"/resources/views\");\n```\n\n### Render a view\n\n```php\necho \\Morningtrain\\WP\\View\\View::render('person',['name' =\u003e 'John','email' =\u003e 'john@doe.com']);\n```\n\n### Working with namespaces\n\nYou may register a namespaced for a set of views. This is especially useful when writing plugins as you may group all\nyour plugin views and not worry about duplicate naming. Views in a namespace may be overwritten in the main namespace as\nlong as you use `first()` instead of `render()`.\n\nEg. `View::first(['vendor/myPlugin/myview','myPlugin::myview])` will render from the vendor dir first if the view\nexists, thereby allowing theme authors to overwrite this view when necessary.\n\n#### Registering a namespace\n\n```php\necho \\Morningtrain\\WP\\View\\View::addNamespace('myPlugin', __DIR__ . \"/resources/views\");\n```\n\n#### Using a namespace\n\n```php\necho \\Morningtrain\\WP\\View\\View::render('myPlugin::person',['name' =\u003e 'John','email' =\u003e 'john@doe.com']);\n```\n\n### Custom @directives\n\nThis package contains some custom [blade directives](https://laravel.com/docs/blade#blade-directives) that you may use:\n\n#### @wpauth()\n\n```php\n\n\u003cdiv\u003e\n  @wpauth()\n    Hello @username!\n  @else\n    \u003ca\u003eLogin\u003c/a\u003e\n  @endwpauth\n\u003c/div\u003e\n```\n\n#### @header()\n\nActs the same as : https://developer.wordpress.org/reference/functions/get_header/\n\nThe following will render the `header.blade.php` view or `header-small.blade.php`\n\n```php\n@header()\n@header('small')\n```\n\n#### @footer()\n\nActs the same as : https://developer.wordpress.org/reference/functions/get_footer/\n\nThe following will render the `footer.blade.php` view or `footer-dark.blade.php`\n\n```php\n@footer()\n@footer('dark')\n```\n\n#### @script()\n\nAn easy way to enqueue an already registered script.\n\nUsing this directive is the same as calling `wp_enqueue_script()` with only the handle.\n\n```php\n@script('swiper')\n\u003csection id=\"my-cool-slider\"\u003e\n  ...\n\u003c/section\u003e\n```\n\n#### @style()\n\nAn easy way to enqueue an already registered stylesheet.\n\nUsing this directive is the same as calling `wp_enqueue_style()` with only the handle.\n\n```php\n@style('employees')\n\u003csection id=\"employees\" class=\"employees list\"\u003e\n  ...\n\u003c/section\u003e\n```\n\n#### @username()\n\nPrints the username of the currently logged in user or an empty string if no one is logged in.\n\n#### @cache()\n\nCaches content in a transient and uses the cached data if it exists\n\n```php\n\u003cdiv\u003e\n    \u003ch3\u003eCache test for post: {!! $postId !!}\u003c/h3\u003e\n    @if(!empty($postId))\n        @cache(\"post_card_{$postId}\")\n        \u003caside @class(['post-card', \"post-card__\".get_post_type($postId)])\u003e\n            \u003ch3\u003e{!! get_the_title($postId) !!}\u003c/h3\u003e\n            \u003cp\u003e{{ get_the_excerpt($postId) }}\u003c/p\u003e\n            \u003cspan\u003eYes\u003c/span\u003e\n            \u003ca href=\"{!! get_permalink($postId) !!}\"\u003e{{__('Read more','domain')}}\u003c/a\u003e\n        \u003c/aside\u003e\n        @endcache\n    @else\n        \u003cp\u003e{{__('This is not a post','domain')}}\u003c/p\u003e\n    @endif\n\u003c/div\u003e\n\n```\n\n#### @react()\n\nPrints a Morningtrain ReactRenderer compatible element with optional props. This makes it easy to prepare components for\nreact to handle in the client.\n\n```php\n@react('myComponent', [\n'someData' =\u003e 'someValue'\n])\n```\n\nThe @react directive also supports a child view that will be rendered inside the component-wrapper until the react\ncomponent is rendered. This is especially useful for skeletons and to avoid popping ins.\n\n```php\n@react('myComponent', [\n'someData' =\u003e 'someValue'\n],\n'my-skeleton-view'),\n['skeletonProp' =\u003e 'skeletonValue']\n```\n\n## Credits\n\n- [Mathias Munk](https://github.com/mrmoeg)\n- [Martin Schadegg Brønniche](https://github.com/mschadegg)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorning-train%2Fwp-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorning-train%2Fwp-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorning-train%2Fwp-view/lists"}