PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.1
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
give / src / DonorDashboards / Tabs / Contracts / Tab.php

Tab.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.1, at src/DonorDashboards/Tabs/Contracts/Tab.php

69 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\DonorDashboards\Tabs\Contracts;
4
5 use Give\DonorDashboards\Tabs\Contracts\Route as RouteAbstract;
6 use Give\Framework\Exceptions\Primitives\RuntimeException;
7
8 /**
9 * Class Tab
10 *
11 * Extend this class when creating Donor Profile tabs.
12 *
13 * @since 2.10.0
14 */
15 abstract class Tab
16 {
17 /**
18 * Return array of routes (must extend DonorDashboard Route class)
19 *
20 * @since 2.10.0
21 * @return array
22 */
23 abstract public function routes();
24
25 /**
26 * Return a unique identifier for the tab
27 *
28 * @since 2.10.0
29 * @return string
30 */
31 public static function id()
32 {
33 throw new RuntimeException('A unique ID must be provided for the tab');
34 }
35
36 /**
37 * Enqueue assets required for frontend rendering of tab
38 *
39 * @since 2.10.0
40 */
41 public function enqueueAssets()
42 {
43 return null;
44 }
45
46 /**
47 * Registers routes with WP REST api
48 *
49 * @since 2.10.0
50 */
51 public function registerRoutes()
52 {
53 $routeClasses = $this->routes();
54 foreach ($routeClasses as $routeClass) {
55 if ( ! is_subclass_of($routeClass, RouteAbstract::class)) {
56 throw new \InvalidArgumentException(
57 $routeClass . ' must extend the ' . RouteAbstract::class . ' class'
58 );
59 }
60 (new $routeClass)->registerRoute();
61 }
62 }
63
64 public function registerTab()
65 {
66 give()->donorDashboardTabs->addTab(get_called_class());
67 }
68 }
69