-
Run
git clone [email protected]:tombroucke/wordpress-functionality-plugin.git {{website-name}}
in your mu-plugins directory -
Remove .git directory
-
Rename
src/Providers/FunctionalityPluginServiceProvider.php
tosrc/Providers/WebsiteNameServiceProvider.php
-
Find and replace (Case-sensitive)
FunctionalityPlugin
> WebsiteNamefunctionality-plugin
> website-namefunctionality_plugin
> website_name
-
Add to root
composer.json
:Also replace
FunctionalityPlugin
with WebsiteNamefunctionality-plugin
with website-name
"extra": { "acorn": { "providers": [ "FunctionalityPlugin\\Providers\\AppServiceProvider", "FunctionalityPlugin\\Providers\\FunctionalityPluginServiceProvider" ], "aliases": { "FunctionalityPluginContactInformation": "FunctionalityPlugin\\Facades\\ContactInformation", "FunctionalityPluginSocialMedia": "FunctionalityPlugin\\Facades\\SocialMedia" } } }
"autoload": { "psr-4": { "FunctionalityPlugin\\": "web/app/mu-plugins/functionality-plugin/src/" } }
Run the script below from your site (Bedrock) root.
Important
Replace these strings first.
- {{website-name}}
- {{website_name}}
- {{WebsiteName}}
At the moment, there is no way to add a namespace to autoload.psr-4 in composer.json through CLI, so it should be manually added:
"autoload": {
"psr-4": {
"{{WebsiteName}}\\": "web/app/mu-plugins/{{website-name}}/src/"
}
}
Then run this script
git clone [email protected]:tombroucke/wordpress-functionality-plugin.git web/app/mu-plugins/{{website-name}}
rm -rf web/app/mu-plugins/{{website-name}}/.git
mv web/app/mu-plugins/{{website-name}}/src/Providers/FunctionalityPluginServiceProvider.php web/app/mu-plugins/{{website-name}}/src/Providers/{{WebsiteName}}ServiceProvider.php
composer config --json --merge extra.acorn.providers '["{{WebsiteName}}\\Providers\\AppServiceProvider", "{{WebsiteName}}\\Providers\\{{WebsiteName}}ServiceProvider"]'
composer config --json --merge extra.acorn.aliases '{"{{WebsiteName}}ContactInformation": "{{WebsiteName}}\\Facades\\ContactInformation", "{{WebsiteName}}SocialMedia": "{{WebsiteName}}\\Facades\\SocialMedia"}'
find web/app/mu-plugins/{{website-name}} -type f \( -name '*.php' -o -name '*.stub' \) -not -exec sed -i '' "s/FunctionalityPlugin/{{WebsiteName}}/g" {} \;
find web/app/mu-plugins/{{website-name}} -type f \( -name '*.php' -o -name '*.stub' \) -not -exec sed -i '' "s/functionality-plugin/{{website-name}}/g" {} \;
find web/app/mu-plugins/{{website-name}} -type f \( -name '*.php' -o -name '*.stub' \) -not -exec sed -i '' "s/functionality_plugin/{{website_name}}/g" {} \;
composer dump-autoload
wp acorn optimize:clear
By default, this plugin provides a "General" options page, with company info, social media links, opening hours and newsletter signup form.
It provides a shortcode + view for the opening hours [opening-hours]
and the newsletter signup form [newsletter-signup-form]
.
To fetch contact information, you can use the Facade {{WebsiteName}}ContactInformation
.
{!! {{WebsiteName}}ContactInformation::formattedAddress() !!}
{!! {{WebsiteName}}ContactInformation::formattedPhoneEmail() !!}
You could also use the [contact-information]
shortcode or @include('{{WebsiteName}}::shortcodes.contact-information')
[contact-information property="address"]
[contact-information property="phone"]
[contact-information property="email"]
[contact-information property="vat_number"]
[contact-information property="bank_account_number"]
To fetch social media, you can use the Facade {{WebsiteName}}SocialMedia
.
$channels = {{WebsiteName}}SocialMedia::channels()
- Str::phoneLink('+12 345 678 910')
- Str::emailLink('[email protected]')
The boot()
method of src/Providers/{{WebsiteName}}ServiceProvider.php
is an entrypoint for custom functionality.
wp acorn website-name:post-type Story
Where 'Story' is the name of your post type. Recipe should be PascalCase. The post type slug and labels will be generated automatically. A Recipe.php file will be created in src/PostTypes, and will be registered automatically.
wp acorn website-name:post-type Genre Story
Where 'Genre' is the name of your post type and 'Story' is your post type. Both should be PascalCase. The taxonomy slug and labels will be generated automatically. A Genre.php file will be created in src/Taxonomies/Recipe, and will be registered automatically.
wp acorn website-name:options-page CustomOptions
Where 'CustomOptions' is the name of your options page. CustomOptions should be PascalCase. A CustomOptions.php file will be created in src/OptionsPages, and will be registered automatically.
wp acorn website-name:shortcode CustomShortcode
Where 'CustomShortcode' is the PascalCase version of 'custom-shortcode'. A controller will be created in src/Shortcodes, and a view will be created in resources/views/shortcodes.