PHP code example of justinholtweb / craft-redpen

1. Go to this page and download the library: Download justinholtweb/craft-redpen library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

justinholtweb / craft-redpen example snippets


use justinholtweb\redpen\events\RegisterRulesEvent;
use justinholtweb\redpen\services\Rules;
use yii\base\Event;

Event::on(Rules::class, Rules::EVENT_REGISTER_RULES, function(RegisterRulesEvent $event) {
    $event->rules[] = new MyHouseRule();
});

class NoFirstPersonRule extends PhraseRule
{
    public function id(): string { return 'style.no-first-person'; }
    public function label(): string { return 'No first person'; }
    public function category(): string { return Issue::CATEGORY_STYLE; }

    protected function phrases(): array
    {
        return ['I think' => null, 'in my opinion' => null];
    }
}

php craft redpen/check                                  # everything, summary only
php craft redpen/check --sections=news,blog --verbose    # list every finding
php craft redpen/check --profile=houseStyle --limit=50   # pin a profile, sample the site
php craft redpen/check --fail-on=error                   # exit non-zero if anything is broken
php craft redpen/check --store                           # keep the run as an audit in the CP