Skip to content
Permalink
Browse files

added Autoloading section to readme file

  • Loading branch information...
aristath committed Sep 8, 2019
1 parent 868a664 commit 4bdac54ac93aa67c662469ad8fdbf84619544de5
Showing with 26 additions and 0 deletions.
  1. +1 −0 .gitattributes
  2. +25 −0 readme.md
@@ -5,6 +5,7 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/CHANGELOG.md export-ignore
/composer.json export-ignore
/composer.lock export-ignore
/contributing.md export-ignore

@@ -56,3 +56,28 @@ new Notice( $notice_id, $notice_content, $notice_args );
```

The above example will create a new notice that will only show in the "Themes" screen in the dasboard. When the notice gets dismissed, a new user-meta will be saved and the key for the stored user-meta will be `notice_dismissed_my_theme_notice`. The key gets created by appending the `$notice_id` to our defined `option_key_prefix`, separated by an underscore.


## Autoloading

You'll need to use an autoloader with this. Ideally, this would be [Composer](https://getcomposer.org). However, we have a [basic autoloader](https://github.com/WPTRT/autoload) available to include with themes if needed.

### Composer

From the command line:

```sh
composer require wptrt/admin-notices
```

### WPTRT Autoloader

If using the WPTRT autoloader, use the following code:

```php
include get_theme_file_path( 'path/to/autoload/src/Loader.php' );
$loader = new \WPTRT\Autoload\Loader();
$loader->add( 'WPTRT\\Dashboard\\Notice', get_theme_file_path( 'path/to/admin-notices/src' ) );
$loader->register();
```

0 comments on commit 4bdac54

Please sign in to comment.
You can’t perform that action at this time.