Apps
6 days ago
CollaborationComment
6 days ago
Collection
6 days ago
CollectionItem
6 days ago
Media
6 days ago
Page
6 days ago
Post
6 days ago
CollaborationRequest.php
6 days ago
DataRequest.php
6 days ago
DownloadGoogleFontRequest.php
6 days ago
DownloadGoogleFontRequest.php
50 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Kirki\App\Http\Requests; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use Kirki\Framework\Http\Request; |
| 8 | use Kirki\Framework\Sanitizer; |
| 9 | |
| 10 | use function Kirki\App\ensure_array; |
| 11 | |
| 12 | class DownloadGoogleFontRequest extends Request |
| 13 | { |
| 14 | protected function prepare_for_validation() |
| 15 | { |
| 16 | $this->merge([ |
| 17 | 'font' => ensure_array($this->font), |
| 18 | ]); |
| 19 | } |
| 20 | |
| 21 | public function rules() |
| 22 | { |
| 23 | return [ |
| 24 | 'font' => 'required|array', |
| 25 | 'font.family' => 'required|string', |
| 26 | 'font.fontUrl' => [ |
| 27 | 'required', |
| 28 | 'url', |
| 29 | function ($value) { |
| 30 | if (stripos($value, 'fonts.googleapis.com') === false) { |
| 31 | return __('It\'s not a valid Google Font', 'kirki'); |
| 32 | } |
| 33 | |
| 34 | return true; |
| 35 | } |
| 36 | ], |
| 37 | 'font.files' => 'required|array', |
| 38 | ]; |
| 39 | } |
| 40 | |
| 41 | public function filters() |
| 42 | { |
| 43 | return [ |
| 44 | 'font' => Sanitizer::ARRAY, |
| 45 | 'font.family' => Sanitizer::TEXT, |
| 46 | 'font.fontUrl' => Sanitizer::URL, |
| 47 | 'font.files' => Sanitizer::ARRAY |
| 48 | ]; |
| 49 | } |
| 50 | } |