PluginProbe
Leadpages / trunk
Leadpages vtrunk
1.3.0 1.2.1 1.2.2 1.2.3 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0
leadpages / includes / serving / PageSource.php

PageSource.php in Leadpages trunk, at includes/serving/PageSource.php

76 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Leadpages\serving;
4
5 defined('ABSPATH') || die('No script kiddies please!'); // Avoid direct file request
6
7 /**
8 * A strategy describing how to serve a connected landing page from a particular Leadpages backend
9 * (Classic or Nova). The Proxy performs the shared reverse-proxy mechanics (fetch with retry,
10 * render, cache) and defers every backend-specific decision to a PageSource so one install can
11 * serve some slugs from Classic and others from Nova.
12 *
13 * @see \Leadpages\serving\ClassicPageSource
14 * @see \Leadpages\serving\NovaPageSource
15 */
16 interface PageSource {
17
18 /**
19 * The upstream URL to fetch for this page and the public WordPress URL being served.
20 *
21 * @param object $page the landing page row
22 * @param string $wp_url the public WordPress URL of the current request (scheme + host + path)
23 * @return string
24 */
25 public function build_url( $page, string $wp_url ): string;
26
27 /**
28 * The wp_remote_request options for the upstream fetch (forwarded cookies, X-Forwarded-For,
29 * timeout, etc.).
30 *
31 * @return array
32 */
33 public function build_request_options(): array;
34
35 /**
36 * Whether the upstream body should be served when the upstream returns 404. Classic serves the
37 * Leadpages 404 page; Nova declines so it never echoes an error/"under construction" page at the
38 * customer's URL.
39 *
40 * @return bool
41 */
42 public function serves_not_found(): bool;
43
44 /**
45 * The "leadpages-serving-tags" meta value identifying this backend's WordPress traffic.
46 *
47 * @return string
48 */
49 public function serving_tag(): string;
50
51 /**
52 * The cookies from the upstream response that should be mirrored back to the visitor.
53 *
54 * @param array $response the upstream wp_remote_request response
55 * @return \WP_Http_Cookie[]
56 */
57 public function cookies_to_mirror( $response ): array;
58
59 /**
60 * The cache key under which this page's response is stored.
61 *
62 * @param object $page the landing page row
63 * @return string
64 */
65 public function cache_key( $page ): string;
66
67 /**
68 * How long (in seconds) the upstream response may be cached, or null if it must not be cached.
69 *
70 * @param object $page the landing page row
71 * @param array $response the upstream wp_remote_request response
72 * @return int|null null to skip caching
73 */
74 public function cache_ttl( $page, $response ): ?int;
75 }
76