{"id":23690023,"url":"https://github.com/murdercode/laravel-shortcode-plus","last_synced_at":"2025-06-26T23:44:40.177Z","repository":{"id":62305768,"uuid":"558796044","full_name":"murdercode/laravel-shortcode-plus","owner":"murdercode","description":"Extend your Laravel Application with Shortcode+","archived":false,"fork":false,"pushed_at":"2024-12-16T10:17:12.000Z","size":731,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-12-21T16:57:53.689Z","etag":null,"topics":["laravel","php","shortcodes"],"latest_commit_sha":null,"homepage":"","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/murdercode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-10-28T10:11:30.000Z","updated_at":"2024-12-16T10:17:16.000Z","dependencies_parsed_at":"2023-10-10T18:17:21.548Z","dependency_job_id":"368db4f9-15f9-46e9-90cf-5f7f89863ad4","html_url":"https://github.com/murdercode/laravel-shortcode-plus","commit_stats":{"total_commits":122,"total_committers":6,"mean_commits":"20.333333333333332","dds":0.3770491803278688,"last_synced_commit":"40338c9cfb46433c00fdea0b1908b3e9616c423a"},"previous_names":[],"tags_count":93,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murdercode%2Flaravel-shortcode-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murdercode%2Flaravel-shortcode-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murdercode%2Flaravel-shortcode-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murdercode%2Flaravel-shortcode-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/murdercode","download_url":"https://codeload.github.com/murdercode/laravel-shortcode-plus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231804128,"owners_count":18429033,"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","php","shortcodes"],"created_at":"2024-12-30T01:58:24.306Z","updated_at":"2025-06-26T23:44:40.140Z","avatar_url":"https://github.com/murdercode.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/murdercode/laravel-shortcode-plus/raw/HEAD/art/laravel-shortcode-logo.svg\" alt=\"Logo Laravel Shortcode Plus\"\u003e\u003c/p\u003e\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/murdercode/laravel-shortcode-plus.svg?style=flat-square)](https://packagist.org/packages/murdercode/laravel-shortcode-plus)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/murdercode/laravel-shortcode-plus/run-tests.yml?branch=main\u0026label=pest)](https://github.com/murdercode/laravel-shortcode-plus/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub PHPStan](https://img.shields.io/github/actions/workflow/status/murdercode/laravel-shortcode-plus/phpstan.yml?branch=main\u0026label=phpstan)](https://github.com/murdercode/laravel-shortcode-plus/actions?query=workflow%3Aphpstan+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/murdercode/laravel-shortcode-plus/fix-php-code-style-issues.yml?branch=main\u0026label=pint)](https://github.com/murdercode/laravel-shortcode-plus/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Maintainability](https://api.codeclimate.com/v1/badges/ebf1003822baede56567/maintainability)](https://codeclimate.com/github/murdercode/laravel-shortcode-plus/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/ebf1003822baede56567/test_coverage)](https://codeclimate.com/github/murdercode/laravel-shortcode-plus/test_coverage)\n![License Mit](https://img.shields.io/github/license/murdercode/laravel-shortcode-plus)\n[![Total Downloads](https://img.shields.io/packagist/dt/murdercode/laravel-shortcode-plus.svg?style=flat-square)](https://packagist.org/packages/murdercode/laravel-shortcode-plus)\n\n---\n\n## Why Shortcode+?\n\nThis package allows you to use shortcodes in your application, like a Wordpress / BBS style\nwebsites.\n\nIn our days, shortcodes are a great way to preserve the integrity of the data within the content\npublished on our site (such as a blog or forum) without risking having to rewrite the format each\ntime.\n\nWith Laravel Shortcode+ we have the ability to turn a standard shortcode into a dynamic asset that\ncan update over time (new HTML standards, cookie consent, AMP versions, and more)!\n\n**Warning: this is a very opinionated package and it's not intended to be multi-purpose.**\n\n## How it Works\n\nFor example, you can use the following shortcode to embed a Youtube video:\n\n```markdown\n[youtube url=\"https://www.youtube.com/watch?v=dQw4w9WgXcQ\"]\n```\n\nThis will be rendered as:\n\n```html\n\n\u003ciframe\n    src=\"https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ\u0026autoplay=1\"\n    srcdoc=\"\u003cstyle\u003e*{padding:0;margin:0;overflow:hidden}html,body{height:100%}img,span{position:absolute;width:100%;top:0;bottom:0;margin:auto}span{height:1.5em;text-align:center;font:48px/1.5 sans-serif;color:white;text-shadow:0 0 0.5em black}\u003c/style\u003e\u003ca href=https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ?autoplay=1\u003e\u003cimg style='object-fit:cover;height:100%;' loading='lazy' src=https://img.youtube.com/vi/123456789/hqdefault.jpg alt='dQw4w9WgXcQ'\n        loading=lazy\u003e\u003cspan\u003e▶\u003c/span\u003e\u003c/a\u003e\"\n    frameborder=\"0\"\n    allow=\"accelerometer; autoplay; encrypted-media; gyroscope;\n        picture-in-picture\"\n    allowfullscreen\n    title=\"dQw4w9WgXcQ\"\n\u003e\u003c/iframe\u003e\n```\n\nAs you can see, we don't just generate an iframe but make it accessible, performant and in line with\nthe best SEO practices around.\n\n---\n\n## Requirements\n\n| Package Version     | Requirement | Version      |\n|---------------------|-------------|--------------|\n| 5.x.x               | Laravel     | 10.x or 11.x |\n| 5.x.x               | Nova        | 4.x          |\n| dev-beta-laravel-12 | Laravel     | 12.x         |\n| dev-beta-laravel-12 | Nova        | 5.x          |\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require murdercode/laravel-shortcode-plus\n```\n\nYou can use shortcodes CSS publishing the assets:\n\n```bash\nphp artisan vendor:publish --tag=\"shortcode-plus-assets\"\n```\n\nYou can publish and run the migrations with:\n\n```bash\nphp artisan vendor:publish --tag=\"shortcode-plus-migrations\"\nphp artisan migrate\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"shortcode-plus-config\"\n```\n\n\u003c!--\nThis is the contents of the published config file:\n\n```php\nreturn [\n];\n```\n--\u003e\n\nIf you want to upgrade every time your assets, add in your composer.json:\n\n```json\n    \"scripts\": {\n\"post-update-cmd\": [\n\"@php artisan vendor:publish --tag=shortcode-plus-assets --ansi --force\",\n```\n\nOptionally, you can publish the views using\n\n```bash\nphp artisan vendor:publish --tag=\"shortcode-plus-views\"\n```\n\n## Usage\n\nLaravel Shortcode Plus is shipped with a default CSS and JS for a better user experience.\nYou can add on **resources/css/app.css** the CSS files:\n\n```css\n@import url(\"/public/vendor/shortcode-plus/app.css\");\n```\n\nand in **resources/js/app.js** the JS files:\n\n```js\nimport '/public/vendor/shortcode-plus/app2.js';\n```\n\nNow you can parse your source as follows:\n\n```php\nuse Murdercode\\LaravelShortcodePlus\\Facades\\LaravelShortcodePlus;\n\n$html = \"I want to parse this twitter tag: [twitter url=\\\"https://twitter.com/elonmusk/status/1585841080431321088\\\"]\";\nreturn LaravelShortcodePlus::source($html)-\u003eparseAll();\n```\n\n### Use Iubenda Cookie\n\nAdd in your iubenda cookie script the following code:\n(/organisms/cookie-solution.blade.php)\n\n```blade\nif (purposeId === \"3\") {\n    var elements = document.getElementsByClassName('shortcode_nocookie');\n    for (var i = 0; i \u003c elements.length; i++) {\n        elements[i].style.display = 'none';\n    }\n}\n```\n\n#### Use Paywall with Iubenda Cookie\n\nIn config, set `cookiePaywall` to `true`\n\nIn your iubenda cookie script, add the following code:\n(/organisms/cookie-solution.blade.php)\n\n```blade\n\u003cscript\u003e\n    function manageShortcodePaywall() {\n        const shortcodesWithPaywall = document.querySelectorAll('.shortcode_with_paywall');\n        const paywalls = document.querySelectorAll('.shortcode_paywall');\n\n        shortcodesWithPaywall.forEach(shortcode =\u003e {\n            if (_iub.cs.api.isConsentGiven()) {\n                shortcode.style.display = 'block';\n                paywalls.forEach(paywall =\u003e paywall.style.display = 'none');\n            } else {\n                shortcode.style.display = 'none';\n                paywalls.forEach(paywall =\u003e paywall.style.display = 'block');\n            }\n        });\n    }\n    \n    var _iub = _iub || [];\n```\n\n```blade\n_iub.csConfiguration.callback.onPreferenceExpressed = manageShortcodePaywall;\n_iub.csConfiguration.callback.onReady = manageShortcodePaywall;\n```   \n\n```blade    \n\u003cscript\u003e\n    var paywallPrefBtn = document.querySelector('.shortcode_paywall button');\n    paywallPrefBtn.addEventListener('click', function(ev) {\n        ev.preventDefault();\n        _iub.cs.api.acceptAll();\n    });\n\u003c/script\u003e\n```\n\n### Indexing feature\n\nIf you want to use the `[index]` shortcode, you can add the `withAutoHeadingIds()` method to your source **before**\nparsing it. It will add an automatic ID to every headline (h2, h3, h4 etc...) in your source:\n\n```php\nreturn LaravelShortcodePlus::source($html)-\u003ewithAutoHeadingIds()-\u003eparseAll();\n```\n\nThis will add an ID to every heading (h2, h3, h4 etc...) in your source.\n\n## Parsers\n\nHere is the list of the available parsers:\n\n| Shortcode      | Description                                                                                     | Parameters                                                                     | Example                                                                                                                                                                                |\n|----------------|-------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `[twitter]  `  | Get a Twitter card                                                                              | `url`                                                                          | `[twitter url=\"https://twitter.com/elonmusk/status/1585841080431321088\"]`                                                                                                              |\n| `[bluesky]  `  | Get a BlueSky card                                                                              | `url`                                                                          | `[bluesky url=\"https://bsky.app/profile/adamparkhomenko.bsky.social/post/3liz5p73u6k2f\"]`                                                                                              |\n| `[youtube]`    | Get a Youtube (light) player                                                                    | `url`                                                                          | `[youtube url=\"https://www.youtube.com/watch?v=9bZkp7q19f0\"]`                                                                                                                          |\n| `[spotify]`    | Get a Spotify player                                                                            | `url` or `uri`                                                                 | `[spotify url=\"https://open.spotify.com/track/2TpxZ7JUBn3uw46aR7qd6V\"]`                                                                                                                |\n| `[faq]`        | Create a `\u003cdetails\u003e` tag with embedded content                                                  | `title`                                                                        | `[faq title=\"What is the answer to the ultimate question?\"]42[/faq]`                                                                                                                   |\n| `[spoiler]`    | Create a `\u003cdetails\u003e` tag with embedded content                                                  | `title`                                                                        | `[spoiler title=\"Spoiler\"]This is hidden content[/spoiler]`                                                                                                                            |\n| `[facebook]`   | Get a Facebook card                                                                             | `url`                                                                          | `[facebook url=\"https://www.facebook.com/elonmusk/posts/10157744420210129\"]`                                                                                                           |\n| `[instagram]`  | Get a Instagram card                                                                            | `url`                                                                          | `[instagram url=\"https://www.instagram.com/p/CApQfIjBGxC/\"]`                                                                                                                           |\n| `[image]`      | Create an image with `Image::class` model                                                       | `id`, `caption` (optional)                                                     | `[image id=\"123\"]`                                                                                                                                                                     |\n| `[gallery]`    | Create a gallery image with `Image::class` model                                                | `title`, `images`                                                              | Single or multiple images: `[gallery title=\"Gallery title here\" images=\"1\"]` or `[gallery title=\"Gallery title here\" images=\"1,2,3\"]`                                                  |\n| `[photo]`      | Create a gallery image with `[Nova Media Hub](https://github.com/outl1ne/nova-media-hub)` model | `didascalia` `effect`(optional) `link`(optional) `shape`(optional)             | Single or multiple images: `[photo didascalia=\"Gallery title here\" id=\"1,2,3\"] Effect [photo id=\"1,2,3\" effect=\"carousel - juxtapose - gallery-flex\" link=\"https://...\" shape=\"default |rounded\"]`             |\n| `[leggianche]` | Create a Read more div, based on `Article` or `Post` model                                      | `id`                                                                           | `[leggianche id=\"1\"]`                                                                                                                                                                  |\n| `[distico]`    | Create a side text block, based on `Article` or `Post` model                                    | `id`                                                                           | `[distico id=\"1\"]`                                                                                                                                                                     |\n| `[button]`     | Create a button that links to an URL                                                            | `link`, `label`, `level (optional)`                                            | `[button link=\"https://www.google.com\" label=\"Google\" level=\"primary/secondary\"]`                                                                                                      |\n| `[tmdb]`       | Create a TMDB card                                                                              | `type`, `id`                                                                   | `[tmdb type=\"movie/tv\" id=\"123\"]`                                                                                                                                                      |\n| `[widgetbay]`  | Create a Widgetbay iframe                                                                       | `id (optional)`, `link (optional)`, `forceLink (optional)`, `title (optional)` | `[widgetbay id=\"1\"]` `[widgetbay title=\"Product Title\" link=\"https://www.amazon.it/product?tag=\"41515\u0026subtag=\"5151\"...\"]`                                                              |\n| `[index]`      | Create an automatic index based on Heading (h2, h3, h4 etc...)                                  | none                                                                           | `[index]`                                                                                                                                                                              |\n| `[trivia]`     | Create a trivia                                                                                 | `id`                                                                           | `[trivia id=\"1\"]`                                                                                                                                                                      |\n\n### Note for Facebook\n\nPlease remember to call the SDK before `\u003c/body\u003e`:\n\n```html\n\n\u003cdiv id=\"fb-root\"\u003e\u003c/div\u003e\n\u003cscript\n    async\n    defer\n    crossorigin=\"anonymous\"\n    src=\"https://connect.facebook.net/en_US/sdk.js#xfbml=1\u0026version=v15.0\"\n    nonce=\"UcAjseAO\"\n\u003e\u003c/script\u003e\n```\n\n### Note for Twitter\n\nPlease remember to call the SDK before `\u003c/body\u003e`:\n\n```html\n\n\u003cscript type=\"text/javascript\"\u003e\n    window.twttr = (function (d, s, id) {\n        var js, fjs = d.getElementsByTagName(s)[0],\n            t = window.twttr || {};\n        if (d.getElementById(id)) return t;\n        js = d.createElement(s);\n        js.id = id;\n        js.src = \"https://platform.twitter.com/widgets.js\";\n        fjs.parentNode.insertBefore(js, fjs);\n\n        t._e = [];\n        t.ready = function (f) {\n            t._e.push(f);\n        };\n\n        return t;\n    }(document, \"script\", \"twitter-wjs\"));\n\u003c/script\u003e\n```\n\n### Note for Reddit\n\nPlease remember to call the SDK before `\u003c/body\u003e`:\n\n```html\n\n\u003cscript async src=\"https://embed.reddit.com/widgets.js\" charset=\"UTF-8\"\u003e\u003c/script\u003e\n```\n\n### Note for Justwatch\n\nPlease remember to call the SDK before `\u003c/body\u003e`:\n\n```html\n\n\u003cscript async src=\"https://widget.justwatch.com/justwatch_widget.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n```\n\n### Note for Parse links\n\nPlease remember to add in config file the links to parse:\n\n```php\n    'linksToParse' =\u003e [\n        'sponsored' =\u003e [\n            '#https://www\\\\.amazon\\\\.[A-Za-z]+#i',\n            '#https://www\\\\.ebay\\\\.[A-Za-z]+#i',\n            'https://www.instant-gaming.com',\n        ],\n        'dofollow' =\u003e [\n            'https://forum.tomshw.it/',\n        ],\n        'nofollow' =\u003e [\n            'https://www.youtube.com',\n            'https://multiplayer.it',\n            'https://www.everyeye.it',\n        ],\n    ],\n```\n\nYou can use a regex or a string to parse the links.\n\nAnd, when parse your content, you can use forceRel():\n\n```php\n    $content = LaravelShortcodePlus::source($content)\n        -\u003eforceRel()\n        -\u003eparseAll();\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security\nvulnerabilities.\n\n## Credits\n\n- [Stefano Novelli](https://github.com/murdercode)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurdercode%2Flaravel-shortcode-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmurdercode%2Flaravel-shortcode-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurdercode%2Flaravel-shortcode-plus/lists"}