PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.15.2
GiveWP – Donation Plugin and Fundraising Platform v4.15.2
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 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / DonationForms / FormPage / TemplateHandler.php
TemplateHandler.php
55 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\DonationForms\FormPage;
4
5 use Give\Helpers\Form\Utils;
6 use WP_Post as Post;
7
8 /**
9 * @since 3.0.0
10 */
11 class TemplateHandler
12 {
13 /**
14 * @var Post|null
15 */
16 private $post;
17
18 /**
19 * @var string
20 */
21 private $formPageTemplatePath;
22
23 public function __construct( $post, string $formPageTemplatePath )
24 {
25 $this->post = $post;
26 $this->formPageTemplatePath = $formPageTemplatePath;
27 }
28
29 /**
30 * @since 3.20.0 Add earlier return for archive pages
31 * @since 3.0.0
32 */
33 public function handle($template)
34 {
35 if (is_archive()) {
36 return $template;
37 }
38
39 return $this->isNextGenForm()
40 ? $this->formPageTemplatePath
41 : $template;
42 }
43
44 /**
45 * @since 3.0.3 Use isV3Form() method instead of 'post_content' to check if the form is built with Visual Builder
46 * @since 3.0.0
47 */
48 protected function isNextGenForm(): bool
49 {
50 return $this->post
51 && Utils::isV3Form($this->post->ID)
52 && 'give_forms' === $this->post->post_type;
53 }
54 }
55