| 1 |
<?php |
| 2 |
|
| 3 |
namespace YayMailScoped\YayCommerce\AdminShell\Contracts; |
| 4 |
|
| 5 |
/** |
| 6 |
* Minimal per-plugin config for menu registration. |
| 7 |
* All plugins (lite + pro) implement this. |
| 8 |
* Pro plugins implement LicenseConfigAdapter which extends this. |
| 9 |
*/ |
| 10 |
interface PluginMenuAdapter |
| 11 |
{ |
| 12 |
/** |
| 13 |
* Short name for the admin sidebar submenu item, e.g. 'YayMail'. |
| 14 |
*/ |
| 15 |
public function get_menu_title(): string; |
| 16 |
/** |
| 17 |
* Browser tab title for the settings page, e.g. 'YayMail Pro - Settings'. |
| 18 |
*/ |
| 19 |
public function get_page_title(): string; |
| 20 |
/** |
| 21 |
* Menu slug under YayCommerce, e.g. 'yaymail-settings'. |
| 22 |
* Return empty string if plugin has no settings page. |
| 23 |
*/ |
| 24 |
public function get_menu_slug(): string; |
| 25 |
/** |
| 26 |
* Render callback for the settings page. |
| 27 |
* Return null to redirect to the Licenses page (pro) or show nothing (lite). |
| 28 |
*/ |
| 29 |
public function get_settings_page_callback(): ?callable; |
| 30 |
/** |
| 31 |
* Ordering rank of the plugin submenu under the YayCommerce menu. |
| 32 |
* Lower numbers appear first; ties keep registration order. Values may be |
| 33 |
* sparse (e.g. 10, 20, 21, 40). Return null to append after positioned items. |
| 34 |
*/ |
| 35 |
public function get_settings_page_position(): ?int; |
| 36 |
/** |
| 37 |
* WP capability required. Default: 'manage_options'. |
| 38 |
*/ |
| 39 |
public function get_capability(): string; |
| 40 |
/** |
| 41 |
* WP plugin basename, e.g. 'yaymail-pro/yaymail.php'. |
| 42 |
*/ |
| 43 |
public function get_plugin_basename(): string; |
| 44 |
/** |
| 45 |
* Label for the settings action link on the Plugins page. |
| 46 |
*/ |
| 47 |
public function get_settings_label(): string; |
| 48 |
/** |
| 49 |
* Documentation URL. Return empty string to hide the link. |
| 50 |
*/ |
| 51 |
public function get_docs_url(): string; |
| 52 |
/** |
| 53 |
* "Go Pro" upgrade URL (for lite plugins). Return empty string to hide. |
| 54 |
*/ |
| 55 |
public function get_pro_url(): string; |
| 56 |
/* |
| 57 |
* ── Optional capability methods (NOT part of the interface contract) ── |
| 58 |
* |
| 59 |
* These are detected at runtime via method_exists() (see AdminContext), |
| 60 |
* so adapters MAY implement them without breaking the append-only contract. |
| 61 |
* Declaring them here would force every shipped adapter to implement them. |
| 62 |
* |
| 63 |
* Multisite Network Admin placement (defaults preserve legacy behavior): |
| 64 |
* |
| 65 |
* // Submenu shows on each site's dashboard. Absent ⇒ true. |
| 66 |
* public function wants_site_menu(): bool; |
| 67 |
* |
| 68 |
* // Submenu shows in the Multisite Network Admin. Absent ⇒ false. |
| 69 |
* public function wants_network_menu(): bool; |
| 70 |
* |
| 71 |
* WooCommerce dependency gate (see PluginSubmenu + Pages\WooCommerceRequiredPage): |
| 72 |
* |
| 73 |
* // Render the shared "WooCommerce required" screen in place of the settings |
| 74 |
* // page. Absent ⇒ false. The adapter owns the runtime check (typically |
| 75 |
* // `! class_exists( 'WooCommerce' )`) so it evaluates un-prefixed under |
| 76 |
* // PHP-Scoper — the adapter class is excluded from scoping in each plugin. |
| 77 |
* // The license redirect takes precedence: unlicensed pro plugins still go |
| 78 |
* // to the Licenses page even when this returns true. |
| 79 |
* public function needs_woocommerce_screen(): bool; |
| 80 |
* |
| 81 |
* // Optional copy overrides for that screen: { icon, title, text, button, hint }. |
| 82 |
* // Absent ⇒ generic de-branded defaults are used. |
| 83 |
* public function get_woocommerce_screen_copy(): array; |
| 84 |
*/ |
| 85 |
} |
| 86 |
|