moderntribe / tribe-alerts
Tribe Alerts WordPress Plugin
Installs: 262
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 12
Forks: 0
Open Issues: 0
Type:wordpress-plugin
Requires
- php: >=7.4
- ext-json: *
- ext-readline: *
- johnbillion/extended-cpts: ^5.0
- league/plates: ^3.4
- moderntribe/tribe-libs: ^3.4.13
- spatie/data-transfer-object: ^2.8
Requires (Dev)
- advanced-custom-fields/advanced-custom-fields-pro: *
- codeception/module-asserts: ^1.3
- codeception/module-cli: ^1.1
- codeception/module-db: ^1.1
- codeception/module-filesystem: ^1.0
- codeception/module-phpbrowser: ^1.0
- codeception/module-webdriver: ^1.4
- codeception/util-universalframework: ^1.0
- composer/installers: ^2.0
- johnpbloch/wordpress-core: 5.9.4
- johnpbloch/wordpress-core-installer: 2.0.*
- larapack/dd: ^1.1
- lucatume/function-mocker: ^1.3
- lucatume/wp-browser: ^3.0
- moderntribe/coding-standards: ^2.0
- nickford/acf-swatch: ^1.0
README
Displays a customizable banner on that screen and remembers when users have dismissed it.
Display custom banner alerts on your website.
Requirements
- php7.4+
- Advanced Custom Fields Pro
- nvm or fnm
- node 16+
- yarn 1.22+
- npm 8.3+
Quick Start First Run
- Install SquareOne Docker (so)
- Run:
so bootstrap
- Run:
nvm use
- Run:
yarn install
- Run:
yarn mix
- Activate your plugins in the WordPress dashboard and start developing!
Pull Requests / Building
Ensure you run yarn prod
before submitting a PR to ensure the resources/dist
folder is updated with the latest build.
Front end
Front end building is powered by Laravel Mix.
Building
nvm use
yarn install
Usage
Build for development:
yarn dev
Watch for file changes:
yarn watch
Poll for file changes:
yarn watch-poll
Watch with hot module replacement:
yarn hot
Build for production:
yarn production
See more options: yarn mix --help
Installing this plugin
Every published release automatically creates a tribe-alerts.zip
which is a fully built and vendor scoped WordPress plugin, about a minute after the release is published. To manually install, visit a release and download and extract the zip in your WordPress plugins folder.
Composer
The best way to include the release zip is by using the fantastic ffraenz/private-composer-installer plugin.
Add a custom repository to your project's repository
key in composer.json
:
"repositories": [ { "type": "package", "package": { "name": "moderntribe/tribe-alerts", "version": "1.1.0", "type": "wordpress-plugin", "dist": { "type": "zip", "url": "https://github.com/moderntribe/tribe-alerts/releases/download/{%VERSION}/tribe-alerts.zip" }, "require": { "ffraenz/private-composer-installer": "^5.0" } } }, ],
NOTE: Simply update the version above and run
composer update
to upgrade the plugin in the future.
Then, add the plugin definition to the require section:
"require": { "moderntribe/tribe-alerts": "*", }
Tell composer where to put your WordPress plugins/themes via the extra
section.
NOTE: Adjust the paths based on your project.
"extra": { "wordpress-install-dir": "wp", "installer-paths": { "wp-content/mu-plugins/{$name}": [ "type:wordpress-muplugin" ], "wp-content/plugins/{$name}": [ "type:wordpress-plugin" ], "wp-content/themes/{$name}": [ "type:wordpress-theme" ] } },
You may have to allow this plugin in your config as well:
"allow-plugins": { "composer/installers": true, "ffraenz/private-composer-installer": true, }
Finally, install the plugin:
composer update
Displaying an Alert
The banner is set to automatically display using the wp_footer
hook. If you need to manually add it to a theme or a plugin, add the following code to render the alert view:
<?php if ( function_exists( '\Tribe\Alert\tribe_alert' ) && function_exists( '\Tribe\Alert\render_alert' ) ) { \Tribe\Alert\render_alert(); } ?>
You can hide the automatic wp_footer
output by defining the following in your wp-config.php:
define( 'TRIBE_ALERTS_AUTOMATIC_OUTPUT', false );
Customize The Alert View Markup
You can filter the directory where we look for view files, e.g.
add_filter( 'tribe/alerts/view_directory', static fn ( string $directory ) => get_stylesheet_directory() . '/components/alerts', 10, 1 );
And then copy the resources/views/alert.php to your specified folder and customize as needed.
ACF Swatch Field Options
Color options are disabled by default. You can enable it by defining the following in your wp-config.php:
define( 'TRIBE_ALERTS_COLOR_OPTIONS', true );
Filter the color options provided to the ACF swatch field:
add_filter( 'tribe/alerts/color_options', static fn ( array $options ) => [ '#880ED4' => [ 'name' => esc_html__( 'Purple', 'tribe-alerts' ), 'class' => 'purple-mono', ], '#8155BA' => [ 'name' => esc_html__( 'Violet', 'tribe-alerts' ), 'class' => 'violet', ], '#323E42' => [ 'name' => esc_html__( 'Charcoal', 'tribe-alerts' ), 'class' => 'charcoal', ], ], 10, 1 );
The default CSS class prefix for the color theme is tribe-alerts__theme
, which ends up being tribe-alerts__theme-$name
once a color is selected.
Filter the CSS class prefix:
add_filter( 'tribe/alerts/color_options/css_class_prefix', static fn ( string $prefix ) => 'new-prefix', 10, 1 );
Credits
- Based on Spatie Skeleton
License
GNU General Public License GPLv2 (or later). Please see License File for more information.