PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.8.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.8.2
4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.5.2 All 199 releases
betterdocs / includes / Admin / Builder / Rule.php

Rule.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.8.2, at includes/Admin/Builder/Rule.php

48 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPDeveloper\BetterDocs\Admin\Builder;
4
5 use JsonSerializable;
6
7 class Rule implements JsonSerializable {
8 public $condition;
9 public $name;
10 public $value;
11 public function __construct( $condition, $name, $value ) {
12 $this->condition = $condition;
13 $this->name = $name;
14 $this->value = $value;
15 }
16
17 public function add_value( $value ) {
18 if ( ! is_array( $this->value ) ) {
19 $this->value = [ $this->value ];
20 }
21 if ( is_a( $value, 'NotificationX\Core\Rule' ) ) {
22 $value = $value->value;
23 }
24 if ( is_array( $value ) ) {
25 $this->value = array_merge( $this->value, $value );
26 } else {
27 $this->value[] = $value;
28 }
29 $this->value = array_values( array_unique( $this->value ) );
30 }
31
32 public function can_add( $rule ) {
33 if ( $this->condition == 'includes' && $this->condition == $rule->condition && $this->name == $rule->name ) {
34 return true;
35 }
36 return false;
37 }
38
39 #[\ReturnTypeWillChange]
40 public function jsonSerialize() {
41 return [
42 $this->condition,
43 $this->name,
44 $this->value
45 ];
46 }
47 }
48