PluginProbe
ReviewX – Multi-Criteria Reviews for WooCommerce with Google Reviews & Schema / trunk
ReviewX – Multi-Criteria Reviews for WooCommerce with Google Reviews & Schema vtrunk
2.5.1 2.5.0 2.4.1 2.4.0 2.3.11 2.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 All 143 releases
reviewx / app / Form / ReviewForm.php

ReviewForm.php in ReviewX – Multi-Criteria Reviews for WooCommerce with Google Reviews & Schema trunk, at app/Form/ReviewForm.php

54 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ReviewX\Form;
4
5 use ReviewX\CPT\CptHelper;
6 use ReviewX\Utilities\Auth\Client;
7 class ReviewForm
8 {
9 protected $cptHelper;
10 public function __construct()
11 {
12 $this->cptHelper = new CptHelper();
13 }
14 public static function post_type_support()
15 {
16 if (Client::getSync()) {
17 // Retrieve settings
18 $enabled_post_types = (new self())->cptHelper->enabledCPT();
19 // Dynamically add comment support for enabled post types
20 foreach ($enabled_post_types as $post_type) {
21 if (post_type_exists($post_type)) {
22 add_post_type_support($post_type, 'comments');
23 }
24 }
25 }
26 }
27 public static function comments_template_init($default)
28 {
29 if (Client::getSync()) {
30 // Retrieve settings
31 $enabled_post_types = (new self())->cptHelper->enabledCPT();
32 // Check if the current post type is enabled
33 if (is_singular($enabled_post_types)) {
34 // Exclude WooCommerce account page
35 if (\class_exists('WooCommerce') && is_account_page()) {
36 // Do nothing on WooCommerce front-end user dashboard
37 } else {
38 // Invoke custom handler
39 if (\class_exists('ReviewX\\Handlers\\CommentBoxHandle')) {
40 (new \ReviewX\Handlers\CommentBoxHandle())->__invoke();
41 }
42 // Load custom template if it exists
43 $custom_template = \dirname(__FILE__) . '/widget.php';
44 if (\file_exists($custom_template)) {
45 return $custom_template;
46 }
47 }
48 }
49 // Fallback to default template
50 return $default;
51 }
52 }
53 }
54