PluginProbe
Extendify / 3.2.2
Extendify v3.2.2
3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 All 128 releases
extendify / app / QuickEdit / Schemas / NavigationLink.php

NavigationLink.php in Extendify 3.2.2, at app/QuickEdit/Schemas/NavigationLink.php

49 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Extendify\QuickEdit\Schemas;
4
5 defined('ABSPATH') || die('No direct access.');
6
7 // A ref nav's links live in a wp_navigation post, saved by WPNavigationController.
8 class NavigationLink implements Schema
9 {
10 public function fields(): array
11 {
12 return [
13 [
14 'key' => 'label',
15 'control' => 'text',
16 'label' => __('Label', 'extendify-local'),
17 ],
18 [
19 'key' => 'url',
20 'control' => 'link',
21 'label' => __('Destination', 'extendify-local'),
22 ],
23 ];
24 }
25
26 public function apply(array $block, string $fieldKey, $value): array
27 {
28 $attrs = $block['attrs'] ?? [];
29 switch ($fieldKey) {
30 case 'label':
31 $label = is_string($value) ? wp_strip_all_tags($value) : '';
32 $attrs['label'] = $label;
33 break;
34 case 'url':
35 $url = is_string($value) ? esc_url_raw($value) : '';
36 if ($url === '') {
37 unset($attrs['url']);
38 } else {
39 $attrs['url'] = $url;
40 }
41 break;
42 default:
43 return $block;
44 }
45 $block['attrs'] = $attrs;
46 return $block;
47 }
48 }
49