PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.5.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.5.0
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Page_Cache / WP_Context.php

WP_Context.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution 1.5.0, at src/Performance/Page_Cache/WP_Context.php

75 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * A class for storing the current context for a request in WordPress.
4 *
5 * @since 0.1.0
6 *
7 * @package SolidWP\Performance
8 */
9
10 namespace SolidWP\Performance\Page_Cache;
11
12 use SolidWP\Performance\Http\Request;
13
14 /**
15 * A class for storing the current context for a request in WordPress.
16 *
17 * @since 0.1.0
18 *
19 * @package SolidWP\Performance
20 */
21 class WP_Context {
22 /**
23 * The current request.
24 *
25 * @since 0.1.0
26 *
27 * @var Request
28 */
29 private Request $request;
30
31 /**
32 * The current post.
33 *
34 * @since 0.1.0
35 *
36 * @var int
37 */
38 private int $post_id;
39
40 /**
41 * The class constructor.
42 *
43 * @since 0.1.0
44 *
45 * @param Request $request A request instance.
46 * @param int $post_id The ID of the current post.
47 */
48 public function __construct( Request $request, int $post_id = 0 ) {
49 $this->request = $request;
50 $this->post_id = $post_id;
51 }
52
53 /**
54 * Gets the current request URI.
55 *
56 * @since 0.1.0
57 *
58 * @return string
59 */
60 public function get_request(): Request {
61 return $this->request;
62 }
63
64 /**
65 * Gets the current post ID.
66 *
67 * @since 0.1.0
68 *
69 * @return int
70 */
71 public function get_post_id(): int {
72 return $this->post_id;
73 }
74 }
75