Completed
Push — develop ( 01a244...59c56b )
by Naveen
01:05
created
src/wordlift/vocabulary/jsonld/class-term-jsonld.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@
 block discarded – undo
8 8
 
9 9
 class Term_Jsonld {
10 10
 
11
-	public function init() {
12
-		add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
13
-	}
11
+    public function init() {
12
+        add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
13
+    }
14 14
 
15
-	public function wl_term_jsonld_array( $jsonld_array, $term_id ) {
15
+    public function wl_term_jsonld_array( $jsonld_array, $term_id ) {
16 16
 
17
-		$entities = Jsonld_Utils::get_matched_entities_for_term( $term_id );
17
+        $entities = Jsonld_Utils::get_matched_entities_for_term( $term_id );
18 18
 
19
-		if ( count( $entities ) > 0 ) {
20
-			$entity                     = array_shift( $entities );
21
-			$entity['@context']         = 'http://schema.org';
22
-			$entity['@id']              = get_term_link( $term_id ) . "/#id";
23
-			$entity['url']              = get_term_link( $term_id );
24
-			$entity['mainEntityOfPage'] = get_term_link( $term_id );
25
-			$jsonld_array['jsonld'][]   = $entity;
26
-		}
19
+        if ( count( $entities ) > 0 ) {
20
+            $entity                     = array_shift( $entities );
21
+            $entity['@context']         = 'http://schema.org';
22
+            $entity['@id']              = get_term_link( $term_id ) . "/#id";
23
+            $entity['url']              = get_term_link( $term_id );
24
+            $entity['mainEntityOfPage'] = get_term_link( $term_id );
25
+            $jsonld_array['jsonld'][]   = $entity;
26
+        }
27 27
 
28
-		return $jsonld_array;
29
-	}
28
+        return $jsonld_array;
29
+    }
30 30
 
31 31
 }
32 32
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,19 +9,19 @@
 block discarded – undo
9 9
 class Term_Jsonld {
10 10
 
11 11
 	public function init() {
12
-		add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
12
+		add_filter('wl_term_jsonld_array', array($this, 'wl_term_jsonld_array'), 10, 2);
13 13
 	}
14 14
 
15
-	public function wl_term_jsonld_array( $jsonld_array, $term_id ) {
15
+	public function wl_term_jsonld_array($jsonld_array, $term_id) {
16 16
 
17
-		$entities = Jsonld_Utils::get_matched_entities_for_term( $term_id );
17
+		$entities = Jsonld_Utils::get_matched_entities_for_term($term_id);
18 18
 
19
-		if ( count( $entities ) > 0 ) {
20
-			$entity                     = array_shift( $entities );
19
+		if (count($entities) > 0) {
20
+			$entity                     = array_shift($entities);
21 21
 			$entity['@context']         = 'http://schema.org';
22
-			$entity['@id']              = get_term_link( $term_id ) . "/#id";
23
-			$entity['url']              = get_term_link( $term_id );
24
-			$entity['mainEntityOfPage'] = get_term_link( $term_id );
22
+			$entity['@id']              = get_term_link($term_id)."/#id";
23
+			$entity['url']              = get_term_link($term_id);
24
+			$entity['mainEntityOfPage'] = get_term_link($term_id);
25 25
 			$jsonld_array['jsonld'][]   = $entity;
26 26
 		}
27 27
 
Please login to merge, or discard this patch.
src/wordlift/vocabulary-terms/jsonld/class-jsonld-generator.php 2 patches
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -12,142 +12,142 @@
 block discarded – undo
12 12
 
13 13
 class Jsonld_Generator {
14 14
 
15
-	/**
16
-	 * @var \Wordlift_Entity_Type_Service
17
-	 */
18
-	private $entity_type_service;
19
-	/**
20
-	 * @var \Wordlift_Property_Getter
21
-	 */
22
-	private $property_getter;
23
-	/**
24
-	 * @var Type_Service
25
-	 */
26
-	private $term_entity_type_service;
27
-	/**
28
-	 * @var \Wordlift_Entity_Service
29
-	 */
30
-	private $entity_service;
31
-
32
-	public function __construct( $entity_type_service, $property_getter ) {
33
-		$this->entity_type_service      = $entity_type_service;
34
-		$this->property_getter          = $property_getter;
35
-		$this->term_entity_type_service = Type_Service::get_instance();
36
-		$this->entity_service           = \Wordlift_Entity_Service::get_instance();
37
-	}
38
-
39
-	public function init() {
40
-		add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
41
-	}
42
-
43
-	public function wl_term_jsonld_array( $data, $term_id ) {
44
-		$jsonld     = $data['jsonld'];
45
-		$references = $data['references'];
46
-
47
-		$term_jsonld_data = $this->get_jsonld_data_for_term( $term_id );
48
-
49
-		// Return early if we dont have the entity data
50
-		// for the term.
51
-		if ( ! $term_jsonld_data ) {
52
-			return $data;
53
-		}
54
-
55
-		$term_jsonld = $term_jsonld_data['jsonld'];
56
-
57
-		$references = array_merge( $references, $term_jsonld_data['references'] );
58
-
59
-
60
-		array_unshift( $jsonld, $term_jsonld );
61
-
62
-		return array(
63
-			'jsonld'     => $jsonld,
64
-			'references' => $references
65
-		);
66
-	}
67
-
68
-	private function get_jsonld_data_for_term( $term_id ) {
69
-
70
-		$id = $this->entity_service->get_uri( $term_id, Object_Type_Enum::TERM );
71
-
72
-		// If we don't have a dataset  URI, then don't publish the term data
73
-		// on this page.
74
-		if ( ! $id ) {
75
-			return false;
76
-		}
77
-
78
-		$references = array();
79
-		$term       = get_term( $term_id );
80
-		$permalink  = get_term_link( $term );
81
-
82
-		$custom_fields = $this->entity_type_service->get_custom_fields_for_term( $term_id );
83
-		$term          = get_term( $term_id );
84
-		$jsonld        = array(
85
-			'@context'    => 'http://schema.org',
86
-			'name'        => $term->name,
87
-			'@type'       => $this->term_entity_type_service->get_entity_types_labels( $term_id ),
88
-			'@id'         => $id,
89
-			'description' => $term->description,
90
-		);
91
-
92
-		if ( ! $custom_fields || ! is_array( $custom_fields ) ) {
93
-			return $jsonld;
94
-		}
95
-
96
-		foreach ( $custom_fields as $key => $value ) {
97
-			$name  = $this->relative_to_schema_context( $value['predicate'] );
98
-			$value = $this->property_getter->get( $term_id, $key, Object_Type_Enum::TERM );
99
-			$value = $this->process_value( $value, $references );
100
-			if ( ! isset( $value ) ||
101
-			     is_array( $value ) && empty( $value ) ||
102
-			     is_string( $value ) && empty( $value ) ) {
103
-				continue;
104
-			}
105
-			$jsonld[ $name ] = $value;
106
-
107
-		}
108
-
109
-		if ( $permalink ) {
110
-			$jsonld['mainEntityOfPage'] = $permalink;
111
-		}
112
-
113
-		return apply_filters( 'wl_no_vocabulary_term_jsonld_array', array(
114
-			'jsonld'     => $jsonld,
115
-			'references' => $references
116
-		), $term_id );
117
-
118
-	}
119
-
120
-	private function relative_to_schema_context( $predicate ) {
121
-		return str_replace( 'http://schema.org/', '', $predicate );
122
-	}
123
-
124
-	private function process_value( $value, &$references ) {
125
-
126
-		if ( is_array( $value )
127
-		     && count( $value ) > 0
128
-		     && $value[0] instanceof \Wordlift_Property_Entity_Reference ) {
15
+    /**
16
+     * @var \Wordlift_Entity_Type_Service
17
+     */
18
+    private $entity_type_service;
19
+    /**
20
+     * @var \Wordlift_Property_Getter
21
+     */
22
+    private $property_getter;
23
+    /**
24
+     * @var Type_Service
25
+     */
26
+    private $term_entity_type_service;
27
+    /**
28
+     * @var \Wordlift_Entity_Service
29
+     */
30
+    private $entity_service;
31
+
32
+    public function __construct( $entity_type_service, $property_getter ) {
33
+        $this->entity_type_service      = $entity_type_service;
34
+        $this->property_getter          = $property_getter;
35
+        $this->term_entity_type_service = Type_Service::get_instance();
36
+        $this->entity_service           = \Wordlift_Entity_Service::get_instance();
37
+    }
38
+
39
+    public function init() {
40
+        add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
41
+    }
42
+
43
+    public function wl_term_jsonld_array( $data, $term_id ) {
44
+        $jsonld     = $data['jsonld'];
45
+        $references = $data['references'];
46
+
47
+        $term_jsonld_data = $this->get_jsonld_data_for_term( $term_id );
48
+
49
+        // Return early if we dont have the entity data
50
+        // for the term.
51
+        if ( ! $term_jsonld_data ) {
52
+            return $data;
53
+        }
54
+
55
+        $term_jsonld = $term_jsonld_data['jsonld'];
56
+
57
+        $references = array_merge( $references, $term_jsonld_data['references'] );
58
+
59
+
60
+        array_unshift( $jsonld, $term_jsonld );
61
+
62
+        return array(
63
+            'jsonld'     => $jsonld,
64
+            'references' => $references
65
+        );
66
+    }
67
+
68
+    private function get_jsonld_data_for_term( $term_id ) {
69
+
70
+        $id = $this->entity_service->get_uri( $term_id, Object_Type_Enum::TERM );
71
+
72
+        // If we don't have a dataset  URI, then don't publish the term data
73
+        // on this page.
74
+        if ( ! $id ) {
75
+            return false;
76
+        }
77
+
78
+        $references = array();
79
+        $term       = get_term( $term_id );
80
+        $permalink  = get_term_link( $term );
81
+
82
+        $custom_fields = $this->entity_type_service->get_custom_fields_for_term( $term_id );
83
+        $term          = get_term( $term_id );
84
+        $jsonld        = array(
85
+            '@context'    => 'http://schema.org',
86
+            'name'        => $term->name,
87
+            '@type'       => $this->term_entity_type_service->get_entity_types_labels( $term_id ),
88
+            '@id'         => $id,
89
+            'description' => $term->description,
90
+        );
91
+
92
+        if ( ! $custom_fields || ! is_array( $custom_fields ) ) {
93
+            return $jsonld;
94
+        }
95
+
96
+        foreach ( $custom_fields as $key => $value ) {
97
+            $name  = $this->relative_to_schema_context( $value['predicate'] );
98
+            $value = $this->property_getter->get( $term_id, $key, Object_Type_Enum::TERM );
99
+            $value = $this->process_value( $value, $references );
100
+            if ( ! isset( $value ) ||
101
+                 is_array( $value ) && empty( $value ) ||
102
+                 is_string( $value ) && empty( $value ) ) {
103
+                continue;
104
+            }
105
+            $jsonld[ $name ] = $value;
106
+
107
+        }
108
+
109
+        if ( $permalink ) {
110
+            $jsonld['mainEntityOfPage'] = $permalink;
111
+        }
112
+
113
+        return apply_filters( 'wl_no_vocabulary_term_jsonld_array', array(
114
+            'jsonld'     => $jsonld,
115
+            'references' => $references
116
+        ), $term_id );
117
+
118
+    }
119
+
120
+    private function relative_to_schema_context( $predicate ) {
121
+        return str_replace( 'http://schema.org/', '', $predicate );
122
+    }
123
+
124
+    private function process_value( $value, &$references ) {
125
+
126
+        if ( is_array( $value )
127
+             && count( $value ) > 0
128
+             && $value[0] instanceof \Wordlift_Property_Entity_Reference ) {
129 129
 
130
-			// All of the references from the custom fields are post references.
131
-			$references = array_merge( $references, array_map( function ( $property_entity_reference ) {
132
-				/**
133
-				 * @var $property_entity_reference \Wordlift_Property_Entity_Reference
134
-				 */
135
-				return new Post_Reference( $property_entity_reference->get_id() );
136
-			}, $value ) );
130
+            // All of the references from the custom fields are post references.
131
+            $references = array_merge( $references, array_map( function ( $property_entity_reference ) {
132
+                /**
133
+                 * @var $property_entity_reference \Wordlift_Property_Entity_Reference
134
+                 */
135
+                return new Post_Reference( $property_entity_reference->get_id() );
136
+            }, $value ) );
137 137
 
138 138
 
139
-			$that = $this;
139
+            $that = $this;
140 140
 
141
-			return array_map( function ( $reference ) use ( $that ) {
142
-				/**
143
-				 * @var $reference \Wordlift_Property_Entity_Reference
144
-				 */
145
-				return array( '@id' => $that->entity_service->get_uri( $reference->get_id() ) );
146
-			}, $value );
141
+            return array_map( function ( $reference ) use ( $that ) {
142
+                /**
143
+                 * @var $reference \Wordlift_Property_Entity_Reference
144
+                 */
145
+                return array( '@id' => $that->entity_service->get_uri( $reference->get_id() ) );
146
+            }, $value );
147 147
 
148
-		}
148
+        }
149 149
 
150
-		return $value;
151
-	}
150
+        return $value;
151
+    }
152 152
 
153 153
 }
154 154
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	private $entity_service;
31 31
 
32
-	public function __construct( $entity_type_service, $property_getter ) {
32
+	public function __construct($entity_type_service, $property_getter) {
33 33
 		$this->entity_type_service      = $entity_type_service;
34 34
 		$this->property_getter          = $property_getter;
35 35
 		$this->term_entity_type_service = Type_Service::get_instance();
@@ -37,27 +37,27 @@  discard block
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	public function init() {
40
-		add_filter( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
40
+		add_filter('wl_term_jsonld_array', array($this, 'wl_term_jsonld_array'), 10, 2);
41 41
 	}
42 42
 
43
-	public function wl_term_jsonld_array( $data, $term_id ) {
43
+	public function wl_term_jsonld_array($data, $term_id) {
44 44
 		$jsonld     = $data['jsonld'];
45 45
 		$references = $data['references'];
46 46
 
47
-		$term_jsonld_data = $this->get_jsonld_data_for_term( $term_id );
47
+		$term_jsonld_data = $this->get_jsonld_data_for_term($term_id);
48 48
 
49 49
 		// Return early if we dont have the entity data
50 50
 		// for the term.
51
-		if ( ! $term_jsonld_data ) {
51
+		if ( ! $term_jsonld_data) {
52 52
 			return $data;
53 53
 		}
54 54
 
55 55
 		$term_jsonld = $term_jsonld_data['jsonld'];
56 56
 
57
-		$references = array_merge( $references, $term_jsonld_data['references'] );
57
+		$references = array_merge($references, $term_jsonld_data['references']);
58 58
 
59 59
 
60
-		array_unshift( $jsonld, $term_jsonld );
60
+		array_unshift($jsonld, $term_jsonld);
61 61
 
62 62
 		return array(
63 63
 			'jsonld'     => $jsonld,
@@ -65,85 +65,85 @@  discard block
 block discarded – undo
65 65
 		);
66 66
 	}
67 67
 
68
-	private function get_jsonld_data_for_term( $term_id ) {
68
+	private function get_jsonld_data_for_term($term_id) {
69 69
 
70
-		$id = $this->entity_service->get_uri( $term_id, Object_Type_Enum::TERM );
70
+		$id = $this->entity_service->get_uri($term_id, Object_Type_Enum::TERM);
71 71
 
72 72
 		// If we don't have a dataset  URI, then don't publish the term data
73 73
 		// on this page.
74
-		if ( ! $id ) {
74
+		if ( ! $id) {
75 75
 			return false;
76 76
 		}
77 77
 
78 78
 		$references = array();
79
-		$term       = get_term( $term_id );
80
-		$permalink  = get_term_link( $term );
79
+		$term       = get_term($term_id);
80
+		$permalink  = get_term_link($term);
81 81
 
82
-		$custom_fields = $this->entity_type_service->get_custom_fields_for_term( $term_id );
83
-		$term          = get_term( $term_id );
82
+		$custom_fields = $this->entity_type_service->get_custom_fields_for_term($term_id);
83
+		$term          = get_term($term_id);
84 84
 		$jsonld        = array(
85 85
 			'@context'    => 'http://schema.org',
86 86
 			'name'        => $term->name,
87
-			'@type'       => $this->term_entity_type_service->get_entity_types_labels( $term_id ),
87
+			'@type'       => $this->term_entity_type_service->get_entity_types_labels($term_id),
88 88
 			'@id'         => $id,
89 89
 			'description' => $term->description,
90 90
 		);
91 91
 
92
-		if ( ! $custom_fields || ! is_array( $custom_fields ) ) {
92
+		if ( ! $custom_fields || ! is_array($custom_fields)) {
93 93
 			return $jsonld;
94 94
 		}
95 95
 
96
-		foreach ( $custom_fields as $key => $value ) {
97
-			$name  = $this->relative_to_schema_context( $value['predicate'] );
98
-			$value = $this->property_getter->get( $term_id, $key, Object_Type_Enum::TERM );
99
-			$value = $this->process_value( $value, $references );
100
-			if ( ! isset( $value ) ||
101
-			     is_array( $value ) && empty( $value ) ||
102
-			     is_string( $value ) && empty( $value ) ) {
96
+		foreach ($custom_fields as $key => $value) {
97
+			$name  = $this->relative_to_schema_context($value['predicate']);
98
+			$value = $this->property_getter->get($term_id, $key, Object_Type_Enum::TERM);
99
+			$value = $this->process_value($value, $references);
100
+			if ( ! isset($value) ||
101
+			     is_array($value) && empty($value) ||
102
+			     is_string($value) && empty($value)) {
103 103
 				continue;
104 104
 			}
105
-			$jsonld[ $name ] = $value;
105
+			$jsonld[$name] = $value;
106 106
 
107 107
 		}
108 108
 
109
-		if ( $permalink ) {
109
+		if ($permalink) {
110 110
 			$jsonld['mainEntityOfPage'] = $permalink;
111 111
 		}
112 112
 
113
-		return apply_filters( 'wl_no_vocabulary_term_jsonld_array', array(
113
+		return apply_filters('wl_no_vocabulary_term_jsonld_array', array(
114 114
 			'jsonld'     => $jsonld,
115 115
 			'references' => $references
116
-		), $term_id );
116
+		), $term_id);
117 117
 
118 118
 	}
119 119
 
120
-	private function relative_to_schema_context( $predicate ) {
121
-		return str_replace( 'http://schema.org/', '', $predicate );
120
+	private function relative_to_schema_context($predicate) {
121
+		return str_replace('http://schema.org/', '', $predicate);
122 122
 	}
123 123
 
124
-	private function process_value( $value, &$references ) {
124
+	private function process_value($value, &$references) {
125 125
 
126
-		if ( is_array( $value )
127
-		     && count( $value ) > 0
128
-		     && $value[0] instanceof \Wordlift_Property_Entity_Reference ) {
126
+		if (is_array($value)
127
+		     && count($value) > 0
128
+		     && $value[0] instanceof \Wordlift_Property_Entity_Reference) {
129 129
 
130 130
 			// All of the references from the custom fields are post references.
131
-			$references = array_merge( $references, array_map( function ( $property_entity_reference ) {
131
+			$references = array_merge($references, array_map(function($property_entity_reference) {
132 132
 				/**
133 133
 				 * @var $property_entity_reference \Wordlift_Property_Entity_Reference
134 134
 				 */
135
-				return new Post_Reference( $property_entity_reference->get_id() );
136
-			}, $value ) );
135
+				return new Post_Reference($property_entity_reference->get_id());
136
+			}, $value));
137 137
 
138 138
 
139 139
 			$that = $this;
140 140
 
141
-			return array_map( function ( $reference ) use ( $that ) {
141
+			return array_map(function($reference) use ($that) {
142 142
 				/**
143 143
 				 * @var $reference \Wordlift_Property_Entity_Reference
144 144
 				 */
145
-				return array( '@id' => $that->entity_service->get_uri( $reference->get_id() ) );
146
-			}, $value );
145
+				return array('@id' => $that->entity_service->get_uri($reference->get_id()));
146
+			}, $value);
147 147
 
148 148
 		}
149 149
 
Please login to merge, or discard this patch.
src/wordlift/metabox/field/class-wl-metabox-field-sameas.php 2 patches
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -22,142 +22,142 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class Wl_Metabox_Field_sameas extends Wl_Metabox_Field {
24 24
 
25
-	/**
26
-	 * @inheritdoc
27
-	 */
28
-	public function __construct( $args, $id, $type ) {
29
-		parent::__construct( $args['sameas'], $id, $type );
30
-	}
31
-
32
-	/**
33
-	 * @inheritdoc
34
-	 */
35
-	public function save_data( $values ) {
36
-		// The autocomplete select may send JSON arrays in input values.
37
-
38
-		// Only use mb_* functions when mbstring is available.
39
-		//
40
-		// See https://github.com/insideout10/wordlift-plugin/issues/693.
41
-		if ( extension_loaded( 'mbstring' ) ) {
42
-			mb_regex_encoding( 'UTF-8' );
43
-
44
-			$merged = array_reduce( (array) $values, function ( $carry, $item ) {
45
-				return array_merge( $carry, mb_split( "\x{2063}", wp_unslash( $item ) ) );
46
-			}, array() );
47
-		} else {
48
-			$merged = array_reduce( (array) $values, function ( $carry, $item ) {
49
-				return array_merge( $carry, preg_split( "/\x{2063}/u", wp_unslash( $item ) ) );
50
-			}, array() );
51
-		}
52
-
53
-		// Convert all escaped special characters to their original.
54
-		$merged = array_map( 'urldecode', $merged );
55
-
56
-		$merged = $this->filter_urls( $merged );
57
-
58
-		parent::save_data( $merged );
59
-	}
60
-
61
-	/**
62
-	 * @inheritdoc
63
-	 */
64
-	public function sanitize_data_filter( $value ) {
65
-
66
-		// Call our sanitizer helper.
67
-		return Wordlift_Sanitizer::sanitize_url( $value );
68
-	}
69
-
70
-	/**
71
-	 * @inheritdoc
72
-	 */
73
-	protected function get_heading_html() {
74
-
75
-		// Add the select html fragment after the heading.
76
-		return parent::get_heading_html()
77
-		       . $this->get_select_html();
78
-	}
79
-
80
-	/**
81
-	 * Get the select html fragment.
82
-	 *
83
-	 * @return string The html fragment.
84
-	 * @since 3.15.0
85
-	 */
86
-	private function get_select_html() {
87
-		// Return an element where the new Autocomplete Select will attach to.
88
-		return '<p>'
89
-		       . esc_html__( 'Use the search below to link this entity with equivalent entities in the linked data cloud.', 'wordlift' )
90
-		       . '<div id="wl-metabox-field-sameas"></div></p>';
91
-	}
92
-
93
-	/**
94
-	 * @inheritdoc
95
-	 */
96
-	protected function get_add_button_html( $count ) {
97
-
98
-		$placeholder = esc_attr_x( 'Type here the URL of an equivalent entity from another dataset.', 'sameAs metabox input', 'wordlift' );
99
-
100
-		return
101
-			'<button type="button" class="wl-add-input wl-add-input--link">' . esc_html__( 'Click here to manually add URLs', 'wordlift' ) . '</button>'
102
-			. '<div style="display: none;"><div class="wl-input-wrapper">'
103
-			. "<input type='text' id='$this->meta_name' name='wl_metaboxes[$this->meta_name][]' placeholder='$placeholder' />"
104
-			. '<button type="button" class="wl-remove-input wl-remove-input--sameas"></button>'
105
-			. '</div></div>'
106
-			. '<fieldset id="wl-input-container">' . $this->get_stored_values_html( $count ) . '</fieldset>'
107
-			. parent::get_add_custom_button_html( $count, 'Add Another URL', 'hide' );
108
-	}
109
-
110
-	/**
111
-	 * @inheritdoc
112
-	 */
113
-	protected function get_stored_values_html( &$count ) {
114
-
115
-		return parent::get_stored_values_html( $count );
116
-	}
117
-
118
-	/**
119
-	 * @inheritdoc
120
-	 */
121
-	public function html() {
122
-
123
-		/**
124
-		 * Filter: wl_feature__enable__metabox-sameas.
125
-		 *
126
-		 * @param bool whether the sameAs metabox should be shown, defaults to true.
127
-		 *
128
-		 * @return bool
129
-		 * @since 3.29.1
130
-		 */
131
-		if ( apply_filters( 'wl_feature__enable__metabox-sameas', true ) ) {
132
-
133
-			// Open main <div> for the Field.
134
-			$html = $this->html_wrapper_open();
135
-
136
-			// Label.
137
-			$html .= $this->get_heading_html();
138
-
139
-			// print nonce.
140
-			$html .= $this->html_nonce();
141
-
142
-			// print data loaded from DB.
143
-			$count = 0;
144
-
145
-			// If cardinality allows it, print button to add new values.
146
-			$html .= $this->get_add_button_html( $count );
147
-
148
-			// Close the HTML wrapper.
149
-			$html .= $this->html_wrapper_close();
150
-
151
-			return $html;
152
-		}
153
-	}
154
-
155
-	/**
156
-	 * @inheritdoc
157
-	 */
158
-	public function html_input( $value ) {
159
-		@ob_start();
160
-		?>
25
+    /**
26
+     * @inheritdoc
27
+     */
28
+    public function __construct( $args, $id, $type ) {
29
+        parent::__construct( $args['sameas'], $id, $type );
30
+    }
31
+
32
+    /**
33
+     * @inheritdoc
34
+     */
35
+    public function save_data( $values ) {
36
+        // The autocomplete select may send JSON arrays in input values.
37
+
38
+        // Only use mb_* functions when mbstring is available.
39
+        //
40
+        // See https://github.com/insideout10/wordlift-plugin/issues/693.
41
+        if ( extension_loaded( 'mbstring' ) ) {
42
+            mb_regex_encoding( 'UTF-8' );
43
+
44
+            $merged = array_reduce( (array) $values, function ( $carry, $item ) {
45
+                return array_merge( $carry, mb_split( "\x{2063}", wp_unslash( $item ) ) );
46
+            }, array() );
47
+        } else {
48
+            $merged = array_reduce( (array) $values, function ( $carry, $item ) {
49
+                return array_merge( $carry, preg_split( "/\x{2063}/u", wp_unslash( $item ) ) );
50
+            }, array() );
51
+        }
52
+
53
+        // Convert all escaped special characters to their original.
54
+        $merged = array_map( 'urldecode', $merged );
55
+
56
+        $merged = $this->filter_urls( $merged );
57
+
58
+        parent::save_data( $merged );
59
+    }
60
+
61
+    /**
62
+     * @inheritdoc
63
+     */
64
+    public function sanitize_data_filter( $value ) {
65
+
66
+        // Call our sanitizer helper.
67
+        return Wordlift_Sanitizer::sanitize_url( $value );
68
+    }
69
+
70
+    /**
71
+     * @inheritdoc
72
+     */
73
+    protected function get_heading_html() {
74
+
75
+        // Add the select html fragment after the heading.
76
+        return parent::get_heading_html()
77
+                . $this->get_select_html();
78
+    }
79
+
80
+    /**
81
+     * Get the select html fragment.
82
+     *
83
+     * @return string The html fragment.
84
+     * @since 3.15.0
85
+     */
86
+    private function get_select_html() {
87
+        // Return an element where the new Autocomplete Select will attach to.
88
+        return '<p>'
89
+                . esc_html__( 'Use the search below to link this entity with equivalent entities in the linked data cloud.', 'wordlift' )
90
+                . '<div id="wl-metabox-field-sameas"></div></p>';
91
+    }
92
+
93
+    /**
94
+     * @inheritdoc
95
+     */
96
+    protected function get_add_button_html( $count ) {
97
+
98
+        $placeholder = esc_attr_x( 'Type here the URL of an equivalent entity from another dataset.', 'sameAs metabox input', 'wordlift' );
99
+
100
+        return
101
+            '<button type="button" class="wl-add-input wl-add-input--link">' . esc_html__( 'Click here to manually add URLs', 'wordlift' ) . '</button>'
102
+            . '<div style="display: none;"><div class="wl-input-wrapper">'
103
+            . "<input type='text' id='$this->meta_name' name='wl_metaboxes[$this->meta_name][]' placeholder='$placeholder' />"
104
+            . '<button type="button" class="wl-remove-input wl-remove-input--sameas"></button>'
105
+            . '</div></div>'
106
+            . '<fieldset id="wl-input-container">' . $this->get_stored_values_html( $count ) . '</fieldset>'
107
+            . parent::get_add_custom_button_html( $count, 'Add Another URL', 'hide' );
108
+    }
109
+
110
+    /**
111
+     * @inheritdoc
112
+     */
113
+    protected function get_stored_values_html( &$count ) {
114
+
115
+        return parent::get_stored_values_html( $count );
116
+    }
117
+
118
+    /**
119
+     * @inheritdoc
120
+     */
121
+    public function html() {
122
+
123
+        /**
124
+         * Filter: wl_feature__enable__metabox-sameas.
125
+         *
126
+         * @param bool whether the sameAs metabox should be shown, defaults to true.
127
+         *
128
+         * @return bool
129
+         * @since 3.29.1
130
+         */
131
+        if ( apply_filters( 'wl_feature__enable__metabox-sameas', true ) ) {
132
+
133
+            // Open main <div> for the Field.
134
+            $html = $this->html_wrapper_open();
135
+
136
+            // Label.
137
+            $html .= $this->get_heading_html();
138
+
139
+            // print nonce.
140
+            $html .= $this->html_nonce();
141
+
142
+            // print data loaded from DB.
143
+            $count = 0;
144
+
145
+            // If cardinality allows it, print button to add new values.
146
+            $html .= $this->get_add_button_html( $count );
147
+
148
+            // Close the HTML wrapper.
149
+            $html .= $this->html_wrapper_close();
150
+
151
+            return $html;
152
+        }
153
+    }
154
+
155
+    /**
156
+     * @inheritdoc
157
+     */
158
+    public function html_input( $value ) {
159
+        @ob_start();
160
+        ?>
161 161
         <div class="wl-input-wrapper wl-input-wrapper-readonly">
162 162
             <input
163 163
                     type="text"
@@ -171,29 +171,29 @@  discard block
 block discarded – undo
171 171
         </div>
172 172
 		<?php
173 173
 
174
-		$html = ob_get_clean();
175
-
176
-		return $html;
177
-	}
178
-
179
-	/**
180
-	 * @param array $urls
181
-	 *
182
-	 * @return array
183
-	 */
184
-	private function filter_urls( $urls ) {
185
-		$configuration_service = Wordlift_Configuration_Service::get_instance();
186
-		$dataset_uri           = $configuration_service->get_dataset_uri();
187
-
188
-		return array_filter( $urls, function ( $url ) use ( $dataset_uri ) {
189
-			$url_validation = filter_var( $url, FILTER_VALIDATE_URL );
190
-			if ( null === $dataset_uri ) {
191
-				return $url_validation;
192
-			}
193
-
194
-			// URLs should not start with local dataset uri.
195
-			return $url_validation && ( empty( $dataset_uri ) || 0 !== strpos( $url, $dataset_uri ) );
196
-		} );
197
-	}
174
+        $html = ob_get_clean();
175
+
176
+        return $html;
177
+    }
178
+
179
+    /**
180
+     * @param array $urls
181
+     *
182
+     * @return array
183
+     */
184
+    private function filter_urls( $urls ) {
185
+        $configuration_service = Wordlift_Configuration_Service::get_instance();
186
+        $dataset_uri           = $configuration_service->get_dataset_uri();
187
+
188
+        return array_filter( $urls, function ( $url ) use ( $dataset_uri ) {
189
+            $url_validation = filter_var( $url, FILTER_VALIDATE_URL );
190
+            if ( null === $dataset_uri ) {
191
+                return $url_validation;
192
+            }
193
+
194
+            // URLs should not start with local dataset uri.
195
+            return $url_validation && ( empty( $dataset_uri ) || 0 !== strpos( $url, $dataset_uri ) );
196
+        } );
197
+    }
198 198
 
199 199
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * @inheritdoc
27 27
 	 */
28
-	public function __construct( $args, $id, $type ) {
29
-		parent::__construct( $args['sameas'], $id, $type );
28
+	public function __construct($args, $id, $type) {
29
+		parent::__construct($args['sameas'], $id, $type);
30 30
 	}
31 31
 
32 32
 	/**
33 33
 	 * @inheritdoc
34 34
 	 */
35
-	public function save_data( $values ) {
35
+	public function save_data($values) {
36 36
 		// The autocomplete select may send JSON arrays in input values.
37 37
 
38 38
 		// Only use mb_* functions when mbstring is available.
39 39
 		//
40 40
 		// See https://github.com/insideout10/wordlift-plugin/issues/693.
41
-		if ( extension_loaded( 'mbstring' ) ) {
42
-			mb_regex_encoding( 'UTF-8' );
41
+		if (extension_loaded('mbstring')) {
42
+			mb_regex_encoding('UTF-8');
43 43
 
44
-			$merged = array_reduce( (array) $values, function ( $carry, $item ) {
45
-				return array_merge( $carry, mb_split( "\x{2063}", wp_unslash( $item ) ) );
46
-			}, array() );
44
+			$merged = array_reduce((array) $values, function($carry, $item) {
45
+				return array_merge($carry, mb_split("\x{2063}", wp_unslash($item)));
46
+			}, array());
47 47
 		} else {
48
-			$merged = array_reduce( (array) $values, function ( $carry, $item ) {
49
-				return array_merge( $carry, preg_split( "/\x{2063}/u", wp_unslash( $item ) ) );
50
-			}, array() );
48
+			$merged = array_reduce((array) $values, function($carry, $item) {
49
+				return array_merge($carry, preg_split("/\x{2063}/u", wp_unslash($item)));
50
+			}, array());
51 51
 		}
52 52
 
53 53
 		// Convert all escaped special characters to their original.
54
-		$merged = array_map( 'urldecode', $merged );
54
+		$merged = array_map('urldecode', $merged);
55 55
 
56
-		$merged = $this->filter_urls( $merged );
56
+		$merged = $this->filter_urls($merged);
57 57
 
58
-		parent::save_data( $merged );
58
+		parent::save_data($merged);
59 59
 	}
60 60
 
61 61
 	/**
62 62
 	 * @inheritdoc
63 63
 	 */
64
-	public function sanitize_data_filter( $value ) {
64
+	public function sanitize_data_filter($value) {
65 65
 
66 66
 		// Call our sanitizer helper.
67
-		return Wordlift_Sanitizer::sanitize_url( $value );
67
+		return Wordlift_Sanitizer::sanitize_url($value);
68 68
 	}
69 69
 
70 70
 	/**
@@ -86,33 +86,33 @@  discard block
 block discarded – undo
86 86
 	private function get_select_html() {
87 87
 		// Return an element where the new Autocomplete Select will attach to.
88 88
 		return '<p>'
89
-		       . esc_html__( 'Use the search below to link this entity with equivalent entities in the linked data cloud.', 'wordlift' )
89
+		       . esc_html__('Use the search below to link this entity with equivalent entities in the linked data cloud.', 'wordlift')
90 90
 		       . '<div id="wl-metabox-field-sameas"></div></p>';
91 91
 	}
92 92
 
93 93
 	/**
94 94
 	 * @inheritdoc
95 95
 	 */
96
-	protected function get_add_button_html( $count ) {
96
+	protected function get_add_button_html($count) {
97 97
 
98
-		$placeholder = esc_attr_x( 'Type here the URL of an equivalent entity from another dataset.', 'sameAs metabox input', 'wordlift' );
98
+		$placeholder = esc_attr_x('Type here the URL of an equivalent entity from another dataset.', 'sameAs metabox input', 'wordlift');
99 99
 
100 100
 		return
101
-			'<button type="button" class="wl-add-input wl-add-input--link">' . esc_html__( 'Click here to manually add URLs', 'wordlift' ) . '</button>'
101
+			'<button type="button" class="wl-add-input wl-add-input--link">'.esc_html__('Click here to manually add URLs', 'wordlift').'</button>'
102 102
 			. '<div style="display: none;"><div class="wl-input-wrapper">'
103 103
 			. "<input type='text' id='$this->meta_name' name='wl_metaboxes[$this->meta_name][]' placeholder='$placeholder' />"
104 104
 			. '<button type="button" class="wl-remove-input wl-remove-input--sameas"></button>'
105 105
 			. '</div></div>'
106
-			. '<fieldset id="wl-input-container">' . $this->get_stored_values_html( $count ) . '</fieldset>'
107
-			. parent::get_add_custom_button_html( $count, 'Add Another URL', 'hide' );
106
+			. '<fieldset id="wl-input-container">'.$this->get_stored_values_html($count).'</fieldset>'
107
+			. parent::get_add_custom_button_html($count, 'Add Another URL', 'hide');
108 108
 	}
109 109
 
110 110
 	/**
111 111
 	 * @inheritdoc
112 112
 	 */
113
-	protected function get_stored_values_html( &$count ) {
113
+	protected function get_stored_values_html(&$count) {
114 114
 
115
-		return parent::get_stored_values_html( $count );
115
+		return parent::get_stored_values_html($count);
116 116
 	}
117 117
 
118 118
 	/**
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		 * @return bool
129 129
 		 * @since 3.29.1
130 130
 		 */
131
-		if ( apply_filters( 'wl_feature__enable__metabox-sameas', true ) ) {
131
+		if (apply_filters('wl_feature__enable__metabox-sameas', true)) {
132 132
 
133 133
 			// Open main <div> for the Field.
134 134
 			$html = $this->html_wrapper_open();
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 			$count = 0;
144 144
 
145 145
 			// If cardinality allows it, print button to add new values.
146
-			$html .= $this->get_add_button_html( $count );
146
+			$html .= $this->get_add_button_html($count);
147 147
 
148 148
 			// Close the HTML wrapper.
149 149
 			$html .= $this->html_wrapper_close();
@@ -155,16 +155,16 @@  discard block
 block discarded – undo
155 155
 	/**
156 156
 	 * @inheritdoc
157 157
 	 */
158
-	public function html_input( $value ) {
158
+	public function html_input($value) {
159 159
 		@ob_start();
160 160
 		?>
161 161
         <div class="wl-input-wrapper wl-input-wrapper-readonly">
162 162
             <input
163 163
                     type="text"
164 164
                     readonly="readonly"
165
-                    id="<?php echo esc_attr( $this->meta_name ); ?>"
166
-                    name="wl_metaboxes[<?php echo esc_attr( $this->meta_name ); ?>][]"
167
-                    value="<?php echo esc_attr( $value ); ?>"
165
+                    id="<?php echo esc_attr($this->meta_name); ?>"
166
+                    name="wl_metaboxes[<?php echo esc_attr($this->meta_name); ?>][]"
167
+                    value="<?php echo esc_attr($value); ?>"
168 168
             />
169 169
 
170 170
             <button class="wl-remove-input wl-remove-input--sameas"></button>
@@ -181,18 +181,18 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return array
183 183
 	 */
184
-	private function filter_urls( $urls ) {
184
+	private function filter_urls($urls) {
185 185
 		$configuration_service = Wordlift_Configuration_Service::get_instance();
186 186
 		$dataset_uri           = $configuration_service->get_dataset_uri();
187 187
 
188
-		return array_filter( $urls, function ( $url ) use ( $dataset_uri ) {
189
-			$url_validation = filter_var( $url, FILTER_VALIDATE_URL );
190
-			if ( null === $dataset_uri ) {
188
+		return array_filter($urls, function($url) use ($dataset_uri) {
189
+			$url_validation = filter_var($url, FILTER_VALIDATE_URL);
190
+			if (null === $dataset_uri) {
191 191
 				return $url_validation;
192 192
 			}
193 193
 
194 194
 			// URLs should not start with local dataset uri.
195
-			return $url_validation && ( empty( $dataset_uri ) || 0 !== strpos( $url, $dataset_uri ) );
195
+			return $url_validation && (empty($dataset_uri) || 0 !== strpos($url, $dataset_uri));
196 196
 		} );
197 197
 	}
198 198
 
Please login to merge, or discard this patch.
src/includes/class-wordlift-entity-service.php 2 patches
Indentation   +579 added lines, -579 removed lines patch added patch discarded remove patch
@@ -21,499 +21,499 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class Wordlift_Entity_Service {
23 23
 
24
-	/**
25
-	 * The Log service.
26
-	 *
27
-	 * @since  3.2.0
28
-	 * @access private
29
-	 * @var \Wordlift_Log_Service $log The Log service.
30
-	 */
31
-	private $log;
32
-
33
-	/**
34
-	 * The {@link Wordlift_Relation_Service} instance.
35
-	 *
36
-	 * @since  3.15.0
37
-	 * @access private
38
-	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
39
-	 */
40
-	private $relation_service;
41
-
42
-	/**
43
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
44
-	 *
45
-	 * @since  3.16.3
46
-	 * @access private
47
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
48
-	 */
49
-	private $entity_uri_service;
50
-
51
-	/**
52
-	 * The entity post type name.
53
-	 *
54
-	 * @since 3.1.0
55
-	 */
56
-	const TYPE_NAME = 'entity';
57
-
58
-	/**
59
-	 * The alternative label meta key.
60
-	 *
61
-	 * @since 3.2.0
62
-	 */
63
-	const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
64
-
65
-	/**
66
-	 * The alternative label input template.
67
-	 *
68
-	 * @since 3.2.0
69
-	 */
70
-	// TODO: this should be moved to a class that deals with HTML code.
71
-	const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
24
+    /**
25
+     * The Log service.
26
+     *
27
+     * @since  3.2.0
28
+     * @access private
29
+     * @var \Wordlift_Log_Service $log The Log service.
30
+     */
31
+    private $log;
32
+
33
+    /**
34
+     * The {@link Wordlift_Relation_Service} instance.
35
+     *
36
+     * @since  3.15.0
37
+     * @access private
38
+     * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
39
+     */
40
+    private $relation_service;
41
+
42
+    /**
43
+     * The {@link Wordlift_Entity_Uri_Service} instance.
44
+     *
45
+     * @since  3.16.3
46
+     * @access private
47
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
48
+     */
49
+    private $entity_uri_service;
50
+
51
+    /**
52
+     * The entity post type name.
53
+     *
54
+     * @since 3.1.0
55
+     */
56
+    const TYPE_NAME = 'entity';
57
+
58
+    /**
59
+     * The alternative label meta key.
60
+     *
61
+     * @since 3.2.0
62
+     */
63
+    const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
64
+
65
+    /**
66
+     * The alternative label input template.
67
+     *
68
+     * @since 3.2.0
69
+     */
70
+    // TODO: this should be moved to a class that deals with HTML code.
71
+    const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
72 72
                 <label class="screen-reader-text" id="wl-alternative-label-prompt-text" for="wl-alternative-label">Enter alternative label here</label>
73 73
                 <input name="wl_alternative_label[]" size="30" value="%s" id="wl-alternative-label" type="text">
74 74
                 <button class="button wl-delete-button">%s</button>
75 75
                 </div>';
76 76
 
77
-	/**
78
-	 * Create a Wordlift_Entity_Service instance.
79
-	 *
80
-	 * @throws Exception if the `$content_service` is not of the `Content_Service` type.
81
-	 * @since 3.2.0
82
-	 */
83
-	protected function __construct() {
84
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
85
-
86
-		$this->entity_uri_service = Wordlift_Entity_Uri_Service::get_instance();
87
-		$this->relation_service   = Wordlift_Relation_Service::get_instance();
88
-
89
-	}
90
-
91
-	/**
92
-	 * A singleton instance of the Entity service.
93
-	 *
94
-	 * @since  3.2.0
95
-	 * @access private
96
-	 * @var Wordlift_Entity_Service $instance A singleton instance of the Entity service.
97
-	 */
98
-	private static $instance = null;
99
-
100
-	/**
101
-	 * Get the singleton instance of the Entity service.
102
-	 *
103
-	 * @return Wordlift_Entity_Service The singleton instance of the Entity service.
104
-	 * @since 3.2.0
105
-	 */
106
-	public static function get_instance() {
107
-
108
-		if ( ! isset( self::$instance ) ) {
109
-			self::$instance = new self();
110
-		}
111
-
112
-		return self::$instance;
113
-	}
114
-
115
-	/**
116
-	 * Determines whether a post is an entity or not. Entity is in this context
117
-	 * something which is not an article.
118
-	 *
119
-	 * @param int $post_id A post id.
120
-	 *
121
-	 * @return bool Return true if the post is an entity otherwise false.
122
-	 * @since 3.1.0
123
-	 *
124
-	 */
125
-	public function is_entity( $post_id ) {
126
-
127
-		// Improve performance by giving for granted that a product is an entity.
128
-		if ( 'product' === get_post_type( $post_id ) ) {
129
-			return true;
130
-		}
131
-
132
-		$terms = wp_get_object_terms( $post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
133
-
134
-		if ( is_wp_error( $terms ) ) {
135
-			$this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
136
-
137
-			return false;
138
-		}
139
-
140
-		if ( empty( $terms ) ) {
141
-			return false;
142
-		}
143
-
144
-		/*
77
+    /**
78
+     * Create a Wordlift_Entity_Service instance.
79
+     *
80
+     * @throws Exception if the `$content_service` is not of the `Content_Service` type.
81
+     * @since 3.2.0
82
+     */
83
+    protected function __construct() {
84
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
85
+
86
+        $this->entity_uri_service = Wordlift_Entity_Uri_Service::get_instance();
87
+        $this->relation_service   = Wordlift_Relation_Service::get_instance();
88
+
89
+    }
90
+
91
+    /**
92
+     * A singleton instance of the Entity service.
93
+     *
94
+     * @since  3.2.0
95
+     * @access private
96
+     * @var Wordlift_Entity_Service $instance A singleton instance of the Entity service.
97
+     */
98
+    private static $instance = null;
99
+
100
+    /**
101
+     * Get the singleton instance of the Entity service.
102
+     *
103
+     * @return Wordlift_Entity_Service The singleton instance of the Entity service.
104
+     * @since 3.2.0
105
+     */
106
+    public static function get_instance() {
107
+
108
+        if ( ! isset( self::$instance ) ) {
109
+            self::$instance = new self();
110
+        }
111
+
112
+        return self::$instance;
113
+    }
114
+
115
+    /**
116
+     * Determines whether a post is an entity or not. Entity is in this context
117
+     * something which is not an article.
118
+     *
119
+     * @param int $post_id A post id.
120
+     *
121
+     * @return bool Return true if the post is an entity otherwise false.
122
+     * @since 3.1.0
123
+     *
124
+     */
125
+    public function is_entity( $post_id ) {
126
+
127
+        // Improve performance by giving for granted that a product is an entity.
128
+        if ( 'product' === get_post_type( $post_id ) ) {
129
+            return true;
130
+        }
131
+
132
+        $terms = wp_get_object_terms( $post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
133
+
134
+        if ( is_wp_error( $terms ) ) {
135
+            $this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
136
+
137
+            return false;
138
+        }
139
+
140
+        if ( empty( $terms ) ) {
141
+            return false;
142
+        }
143
+
144
+        /*
145 145
 		 * We don't consider an `article` to be an entity.
146 146
 		 *
147 147
 		 * @since 3.20.0 At least one associated mustn't be an `article`.
148 148
 		 *
149 149
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
150 150
 		 */
151
-		foreach ( $terms as $term ) {
152
-			if ( 1 !== preg_match( '~(^|-)article$~', $term->slug ) ) {
153
-				return true;
154
-			}
155
-		}
156
-
157
-		return false;
158
-	}
159
-
160
-	/**
161
-	 * Get the proper classification scope for a given entity post
162
-	 *
163
-	 * @param integer $post_id An entity post id.
164
-	 *
165
-	 * @param string $default The default classification scope, `what` if not
166
-	 *                         provided.
167
-	 *
168
-	 * @return string Returns a classification scope (e.g. 'what').
169
-	 * @since 3.5.0
170
-	 *
171
-	 */
172
-	public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
173
-
174
-		if ( false === $this->is_entity( $post_id ) ) {
175
-			return $default;
176
-		}
177
-
178
-		// Retrieve the entity type
179
-		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
180
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
181
-		// Retrieve classification boxes configuration
182
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
183
-		foreach ( $classification_boxes as $cb ) {
184
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
185
-				return $cb['id'];
186
-			}
187
-		}
188
-
189
-		return $default;
190
-	}
191
-
192
-	/**
193
-	 * Check whether a {@link WP_Post} is used.
194
-	 *
195
-	 * @param int $post_id The {@link WP_Post}'s id.
196
-	 *
197
-	 * @return bool|null Null if it's not an entity, otherwise true if it's used.
198
-	 */
199
-	public function is_used( $post_id ) {
200
-
201
-		if ( false === $this->is_entity( $post_id ) ) {
202
-			return null;
203
-		}
204
-		// Retrieve the post
205
-		$entity = get_post( $post_id );
206
-
207
-		global $wpdb;
208
-		// Retrieve Wordlift relation instances table name
209
-		$table_name = wl_core_get_relation_instances_table_name();
210
-
211
-		// Check is it's referenced / related to another post / entity
212
-		$stmt = $wpdb->prepare(
213
-			"SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
214
-			$entity->ID
215
-		);
216
-
217
-		// Perform the query
218
-		$relation_instances = (int) $wpdb->get_var( $stmt );
219
-		// If there is at least one relation instance for the current entity, then it's used
220
-		if ( 0 < $relation_instances ) {
221
-			return true;
222
-		}
223
-
224
-		// Check if the entity uri is used as meta_value
225
-		$stmt = $wpdb->prepare(
226
-			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
227
-			$entity->ID,
228
-			wl_get_entity_uri( $entity->ID )
229
-		);
230
-		// Perform the query
231
-		$meta_instances = (int) $wpdb->get_var( $stmt );
232
-
233
-		// If there is at least one meta that refers the current entity uri, then current entity is used
234
-		if ( 0 < $meta_instances ) {
235
-			return true;
236
-		}
237
-
238
-		// If we are here, it means the current entity is not used at the moment
239
-		return false;
240
-	}
241
-
242
-	/**
243
-	 * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
244
-	 *
245
-	 * @param string $uri The entity URI.
246
-	 *
247
-	 * @return WP_Post|null A WP_Post instance or null if not found.
248
-	 * @deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
249
-	 *
250
-	 * @since      3.16.3 deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
251
-	 * @since      3.2.0
252
-	 *
253
-	 */
254
-	public function get_entity_post_by_uri( $uri ) {
255
-
256
-		return $this->entity_uri_service->get_entity( $uri );
257
-	}
258
-
259
-	/**
260
-	 * Fires once a post has been saved. This function uses the $_REQUEST, therefore
261
-	 * we check that the post we're saving is the current post.
262
-	 *
263
-	 * @see   https://github.com/insideout10/wordlift-plugin/issues/363
264
-	 *
265
-	 * @since 3.2.0
266
-	 *
267
-	 * @param int $post_id Post ID.
268
-	 * @param WP_Post $post Post object.
269
-	 * @param bool $update Whether this is an existing post being updated or not.
270
-	 */
271
-	public function save_post( $post_id, $post, $update ) {
272
-
273
-		// Avoid doing anything if post is autosave or a revision.
274
-		if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
275
-			return;
276
-		}
277
-
278
-		// We're setting the alternative label that have been provided via the UI
279
-		// (in fact we're using $_REQUEST), while save_post may be also called
280
-		// programmatically by some other function: we need to check therefore if
281
-		// the $post_id in the save_post call matches the post id set in the request.
282
-		//
283
-		// If this is not the current post being saved or if it's not an entity, return.
284
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
285
-			return;
286
-		}
287
-
288
-		// Get the alt labels from the request (or empty array).
289
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? (array) $_REQUEST['wl_alternative_label'] : array();
290
-
291
-		if ( ( ! empty( $_POST['content'] ) && ! empty( $_POST['post_content'] ) ) || isset( $_REQUEST['wl_alternative_label'] ) ) {
292
-			// This is via classic editor, so set the alternative labels.
293
-			$this->set_alternative_labels( $post_id, $alt_labels );
294
-		}
295
-
296
-
297
-	}
298
-
299
-	/**
300
-	 * Set the alternative labels.
301
-	 *
302
-	 * @param int $post_id The post id.
303
-	 * @param array $alt_labels An array of labels.
304
-	 *
305
-	 * @since 3.2.0
306
-	 *
307
-	 */
308
-	public function set_alternative_labels( $post_id, $alt_labels ) {
309
-
310
-		// Bail out if post id is not numeric. We add this check as we found a WP install that was sending a WP_Error
311
-		// instead of post id.
312
-		if ( ! is_numeric( $post_id ) ) {
313
-			return;
314
-		}
315
-
316
-		// Force $alt_labels to be an array
317
-		if ( ! is_array( $alt_labels ) ) {
318
-			$alt_labels = array( $alt_labels );
319
-		}
320
-
321
-		$this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
322
-
323
-		// Delete all the existing alternate labels.
324
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
325
-
326
-		// Save only unique synonymns.
327
-		$alt_labels = array_unique( $alt_labels );
328
-
329
-		// Set the alternative labels.
330
-		foreach ( $alt_labels as $alt_label ) {
331
-
332
-			// Strip html code from synonym.
333
-			$alt_label = wp_strip_all_tags( $alt_label );
334
-
335
-			if ( ! empty( $alt_label ) ) {
336
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, (string) $alt_label );
337
-			}
338
-		}
339
-
340
-	}
341
-
342
-	public function append_alternative_labels( $post_id, $labels_to_append ) {
343
-
344
-		$merged_labels = $this->get_alternative_labels( $post_id );
345
-
346
-		// Append new synonyms to the end.
347
-		$merged_labels = array_merge( $merged_labels, $labels_to_append );
348
-
349
-		$this->set_alternative_labels( $post_id, $merged_labels );
350
-
351
-	}
352
-
353
-	/**
354
-	 * Retrieve the alternate labels.
355
-	 *
356
-	 * @param int $post_id Post id.
357
-	 *
358
-	 * @return mixed An array  of alternative labels.
359
-	 * @since 3.2.0
360
-	 *
361
-	 */
362
-	public function get_alternative_labels( $post_id ) {
363
-
364
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
365
-	}
366
-
367
-	/**
368
-	 * Retrieve the labels for an entity, i.e. the title + the synonyms.
369
-	 *
370
-	 * @param int $post_id The entity {@link WP_Post} id.
371
-	 * @param int $object_type The object type {@link Object_Type_Enum}
372
-	 *
373
-	 * @return array An array with the entity title and labels.
374
-	 * @since 3.12.0
375
-	 */
376
-	public function get_labels( $post_id, $object_type = Object_Type_Enum::POST ) {
377
-		if ( $object_type === Object_Type_Enum::POST ) {
378
-			return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
379
-		}
380
-
381
-		// Term Reference dont have synonyms yet.
382
-		return array();
383
-	}
384
-
385
-	/**
386
-	 * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0).
387
-	 *
388
-	 * @param WP_Post $post Post object.
389
-	 *
390
-	 * @since 3.2.0
391
-	 *
392
-	 */
393
-	public function edit_form_before_permalink( $post ) {
394
-
395
-		// If it's not an entity, return.
396
-		if ( ! $this->is_entity( $post->ID ) ) {
397
-			return;
398
-		}
399
-
400
-		// If disabled by filter, return.
401
-		if ( ! apply_filters( 'wl_feature__enable__add-synonyms', true ) ) {
402
-			return;
403
-		}
404
-
405
-		// Print the input template.
406
-		Wordlift_UI_Service::print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
407
-
408
-		// Print all the currently set alternative labels.
409
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
410
-
411
-			echo $this->get_alternative_label_input( $alt_label );
412
-
413
-		};
414
-
415
-		// Print the button.
416
-		Wordlift_UI_Service::print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
417
-
418
-	}
419
-
420
-	public function get_uri( $object_id, $type = Object_Type_Enum::POST ) {
421
-		$content_service = Wordpress_Content_Service::get_instance();
422
-		$entity_id       = $content_service->get_entity_id( new Wordpress_Content_Id( $object_id, $type ) );
423
-		$dataset_uri     = Wordlift_Configuration_Service::get_instance()->get_dataset_uri();
424
-
425
-		if ( ! isset( $entity_id ) ||
426
-		     ( ! empty( $dataset_uri ) && 0 !== strpos( $entity_id, $dataset_uri ) ) ) {
427
-			$rel_uri = Entity_Uri_Generator::create_uri( $type, $object_id );
428
-			try {
429
-				$content_service->set_entity_id( new Wordpress_Content_Id( $object_id, $type ), $rel_uri );
430
-				$entity_id = $content_service->get_entity_id( new Wordpress_Content_Id( $object_id, $type ) );
431
-			} catch ( Exception $e ) {
432
-				return null;
433
-			}
434
-		}
435
-
436
-		return $entity_id;
437
-	}
438
-
439
-	/**
440
-	 * Get the alternative label input HTML code.
441
-	 *
442
-	 * @param string $value The input value.
443
-	 *
444
-	 * @return string The input HTML code.
445
-	 * @since 3.2.0
446
-	 *
447
-	 */
448
-	private function get_alternative_label_input( $value = '' ) {
449
-
450
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
451
-	}
452
-
453
-	/**
454
-	 * Get the number of entity posts published in this blog.
455
-	 *
456
-	 * @return int The number of published entity posts.
457
-	 * @since 3.6.0
458
-	 *
459
-	 */
460
-	public function count() {
461
-		global $wpdb;
462
-
463
-		// Try to get the count from the transient.
464
-		$count = get_transient( '_wl_entity_service__count' );
465
-		if ( false !== $count ) {
466
-			return $count;
467
-		}
468
-
469
-		// Query the count.
470
-		$count = $wpdb->get_var( $wpdb->prepare(
471
-			"SELECT COUNT( DISTINCT( tr.object_id ) )"
472
-			. " FROM {$wpdb->term_relationships} tr"
473
-			. " INNER JOIN {$wpdb->term_taxonomy} tt"
474
-			. "  ON tt.taxonomy = %s AND tt.term_taxonomy_id = tr.term_taxonomy_id"
475
-			. " INNER JOIN {$wpdb->terms} t"
476
-			. "  ON t.term_id = tt.term_id AND t.name != %s",
477
-			Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
478
-			'article'
479
-		) );
480
-
481
-		// Store the count in cache.
482
-		set_transient( '_wl_entity_service__count', $count, 900 );
483
-
484
-		return $count;
485
-	}
486
-
487
-	/**
488
-	 * Add the entity filtering criterias to the arguments for a `get_posts`
489
-	 * call.
490
-	 *
491
-	 * @param array $args The arguments for a `get_posts` call.
492
-	 *
493
-	 * @return array The arguments for a `get_posts` call.
494
-	 * @since 3.15.0
495
-	 *
496
-	 */
497
-	public static function add_criterias( $args ) {
498
-
499
-		// Build an optimal tax-query.
500
-		$tax_query = array(
501
-			'relation' => 'AND',
502
-			array(
503
-				'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
504
-				'operator' => 'EXISTS',
505
-			),
506
-			array(
507
-				'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
508
-				'field'    => 'slug',
509
-				'terms'    => 'article',
510
-				'operator' => 'NOT IN',
511
-			),
512
-		);
513
-
514
-		return $args + array(
515
-				'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
516
-				/*
151
+        foreach ( $terms as $term ) {
152
+            if ( 1 !== preg_match( '~(^|-)article$~', $term->slug ) ) {
153
+                return true;
154
+            }
155
+        }
156
+
157
+        return false;
158
+    }
159
+
160
+    /**
161
+     * Get the proper classification scope for a given entity post
162
+     *
163
+     * @param integer $post_id An entity post id.
164
+     *
165
+     * @param string $default The default classification scope, `what` if not
166
+     *                         provided.
167
+     *
168
+     * @return string Returns a classification scope (e.g. 'what').
169
+     * @since 3.5.0
170
+     *
171
+     */
172
+    public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
173
+
174
+        if ( false === $this->is_entity( $post_id ) ) {
175
+            return $default;
176
+        }
177
+
178
+        // Retrieve the entity type
179
+        $entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
180
+        $entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
181
+        // Retrieve classification boxes configuration
182
+        $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
183
+        foreach ( $classification_boxes as $cb ) {
184
+            if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
185
+                return $cb['id'];
186
+            }
187
+        }
188
+
189
+        return $default;
190
+    }
191
+
192
+    /**
193
+     * Check whether a {@link WP_Post} is used.
194
+     *
195
+     * @param int $post_id The {@link WP_Post}'s id.
196
+     *
197
+     * @return bool|null Null if it's not an entity, otherwise true if it's used.
198
+     */
199
+    public function is_used( $post_id ) {
200
+
201
+        if ( false === $this->is_entity( $post_id ) ) {
202
+            return null;
203
+        }
204
+        // Retrieve the post
205
+        $entity = get_post( $post_id );
206
+
207
+        global $wpdb;
208
+        // Retrieve Wordlift relation instances table name
209
+        $table_name = wl_core_get_relation_instances_table_name();
210
+
211
+        // Check is it's referenced / related to another post / entity
212
+        $stmt = $wpdb->prepare(
213
+            "SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
214
+            $entity->ID
215
+        );
216
+
217
+        // Perform the query
218
+        $relation_instances = (int) $wpdb->get_var( $stmt );
219
+        // If there is at least one relation instance for the current entity, then it's used
220
+        if ( 0 < $relation_instances ) {
221
+            return true;
222
+        }
223
+
224
+        // Check if the entity uri is used as meta_value
225
+        $stmt = $wpdb->prepare(
226
+            "SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
227
+            $entity->ID,
228
+            wl_get_entity_uri( $entity->ID )
229
+        );
230
+        // Perform the query
231
+        $meta_instances = (int) $wpdb->get_var( $stmt );
232
+
233
+        // If there is at least one meta that refers the current entity uri, then current entity is used
234
+        if ( 0 < $meta_instances ) {
235
+            return true;
236
+        }
237
+
238
+        // If we are here, it means the current entity is not used at the moment
239
+        return false;
240
+    }
241
+
242
+    /**
243
+     * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
244
+     *
245
+     * @param string $uri The entity URI.
246
+     *
247
+     * @return WP_Post|null A WP_Post instance or null if not found.
248
+     * @deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
249
+     *
250
+     * @since      3.16.3 deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
251
+     * @since      3.2.0
252
+     *
253
+     */
254
+    public function get_entity_post_by_uri( $uri ) {
255
+
256
+        return $this->entity_uri_service->get_entity( $uri );
257
+    }
258
+
259
+    /**
260
+     * Fires once a post has been saved. This function uses the $_REQUEST, therefore
261
+     * we check that the post we're saving is the current post.
262
+     *
263
+     * @see   https://github.com/insideout10/wordlift-plugin/issues/363
264
+     *
265
+     * @since 3.2.0
266
+     *
267
+     * @param int $post_id Post ID.
268
+     * @param WP_Post $post Post object.
269
+     * @param bool $update Whether this is an existing post being updated or not.
270
+     */
271
+    public function save_post( $post_id, $post, $update ) {
272
+
273
+        // Avoid doing anything if post is autosave or a revision.
274
+        if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
275
+            return;
276
+        }
277
+
278
+        // We're setting the alternative label that have been provided via the UI
279
+        // (in fact we're using $_REQUEST), while save_post may be also called
280
+        // programmatically by some other function: we need to check therefore if
281
+        // the $post_id in the save_post call matches the post id set in the request.
282
+        //
283
+        // If this is not the current post being saved or if it's not an entity, return.
284
+        if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
285
+            return;
286
+        }
287
+
288
+        // Get the alt labels from the request (or empty array).
289
+        $alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? (array) $_REQUEST['wl_alternative_label'] : array();
290
+
291
+        if ( ( ! empty( $_POST['content'] ) && ! empty( $_POST['post_content'] ) ) || isset( $_REQUEST['wl_alternative_label'] ) ) {
292
+            // This is via classic editor, so set the alternative labels.
293
+            $this->set_alternative_labels( $post_id, $alt_labels );
294
+        }
295
+
296
+
297
+    }
298
+
299
+    /**
300
+     * Set the alternative labels.
301
+     *
302
+     * @param int $post_id The post id.
303
+     * @param array $alt_labels An array of labels.
304
+     *
305
+     * @since 3.2.0
306
+     *
307
+     */
308
+    public function set_alternative_labels( $post_id, $alt_labels ) {
309
+
310
+        // Bail out if post id is not numeric. We add this check as we found a WP install that was sending a WP_Error
311
+        // instead of post id.
312
+        if ( ! is_numeric( $post_id ) ) {
313
+            return;
314
+        }
315
+
316
+        // Force $alt_labels to be an array
317
+        if ( ! is_array( $alt_labels ) ) {
318
+            $alt_labels = array( $alt_labels );
319
+        }
320
+
321
+        $this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
322
+
323
+        // Delete all the existing alternate labels.
324
+        delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
325
+
326
+        // Save only unique synonymns.
327
+        $alt_labels = array_unique( $alt_labels );
328
+
329
+        // Set the alternative labels.
330
+        foreach ( $alt_labels as $alt_label ) {
331
+
332
+            // Strip html code from synonym.
333
+            $alt_label = wp_strip_all_tags( $alt_label );
334
+
335
+            if ( ! empty( $alt_label ) ) {
336
+                add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, (string) $alt_label );
337
+            }
338
+        }
339
+
340
+    }
341
+
342
+    public function append_alternative_labels( $post_id, $labels_to_append ) {
343
+
344
+        $merged_labels = $this->get_alternative_labels( $post_id );
345
+
346
+        // Append new synonyms to the end.
347
+        $merged_labels = array_merge( $merged_labels, $labels_to_append );
348
+
349
+        $this->set_alternative_labels( $post_id, $merged_labels );
350
+
351
+    }
352
+
353
+    /**
354
+     * Retrieve the alternate labels.
355
+     *
356
+     * @param int $post_id Post id.
357
+     *
358
+     * @return mixed An array  of alternative labels.
359
+     * @since 3.2.0
360
+     *
361
+     */
362
+    public function get_alternative_labels( $post_id ) {
363
+
364
+        return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
365
+    }
366
+
367
+    /**
368
+     * Retrieve the labels for an entity, i.e. the title + the synonyms.
369
+     *
370
+     * @param int $post_id The entity {@link WP_Post} id.
371
+     * @param int $object_type The object type {@link Object_Type_Enum}
372
+     *
373
+     * @return array An array with the entity title and labels.
374
+     * @since 3.12.0
375
+     */
376
+    public function get_labels( $post_id, $object_type = Object_Type_Enum::POST ) {
377
+        if ( $object_type === Object_Type_Enum::POST ) {
378
+            return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
379
+        }
380
+
381
+        // Term Reference dont have synonyms yet.
382
+        return array();
383
+    }
384
+
385
+    /**
386
+     * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0).
387
+     *
388
+     * @param WP_Post $post Post object.
389
+     *
390
+     * @since 3.2.0
391
+     *
392
+     */
393
+    public function edit_form_before_permalink( $post ) {
394
+
395
+        // If it's not an entity, return.
396
+        if ( ! $this->is_entity( $post->ID ) ) {
397
+            return;
398
+        }
399
+
400
+        // If disabled by filter, return.
401
+        if ( ! apply_filters( 'wl_feature__enable__add-synonyms', true ) ) {
402
+            return;
403
+        }
404
+
405
+        // Print the input template.
406
+        Wordlift_UI_Service::print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
407
+
408
+        // Print all the currently set alternative labels.
409
+        foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
410
+
411
+            echo $this->get_alternative_label_input( $alt_label );
412
+
413
+        };
414
+
415
+        // Print the button.
416
+        Wordlift_UI_Service::print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
417
+
418
+    }
419
+
420
+    public function get_uri( $object_id, $type = Object_Type_Enum::POST ) {
421
+        $content_service = Wordpress_Content_Service::get_instance();
422
+        $entity_id       = $content_service->get_entity_id( new Wordpress_Content_Id( $object_id, $type ) );
423
+        $dataset_uri     = Wordlift_Configuration_Service::get_instance()->get_dataset_uri();
424
+
425
+        if ( ! isset( $entity_id ) ||
426
+             ( ! empty( $dataset_uri ) && 0 !== strpos( $entity_id, $dataset_uri ) ) ) {
427
+            $rel_uri = Entity_Uri_Generator::create_uri( $type, $object_id );
428
+            try {
429
+                $content_service->set_entity_id( new Wordpress_Content_Id( $object_id, $type ), $rel_uri );
430
+                $entity_id = $content_service->get_entity_id( new Wordpress_Content_Id( $object_id, $type ) );
431
+            } catch ( Exception $e ) {
432
+                return null;
433
+            }
434
+        }
435
+
436
+        return $entity_id;
437
+    }
438
+
439
+    /**
440
+     * Get the alternative label input HTML code.
441
+     *
442
+     * @param string $value The input value.
443
+     *
444
+     * @return string The input HTML code.
445
+     * @since 3.2.0
446
+     *
447
+     */
448
+    private function get_alternative_label_input( $value = '' ) {
449
+
450
+        return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
451
+    }
452
+
453
+    /**
454
+     * Get the number of entity posts published in this blog.
455
+     *
456
+     * @return int The number of published entity posts.
457
+     * @since 3.6.0
458
+     *
459
+     */
460
+    public function count() {
461
+        global $wpdb;
462
+
463
+        // Try to get the count from the transient.
464
+        $count = get_transient( '_wl_entity_service__count' );
465
+        if ( false !== $count ) {
466
+            return $count;
467
+        }
468
+
469
+        // Query the count.
470
+        $count = $wpdb->get_var( $wpdb->prepare(
471
+            "SELECT COUNT( DISTINCT( tr.object_id ) )"
472
+            . " FROM {$wpdb->term_relationships} tr"
473
+            . " INNER JOIN {$wpdb->term_taxonomy} tt"
474
+            . "  ON tt.taxonomy = %s AND tt.term_taxonomy_id = tr.term_taxonomy_id"
475
+            . " INNER JOIN {$wpdb->terms} t"
476
+            . "  ON t.term_id = tt.term_id AND t.name != %s",
477
+            Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
478
+            'article'
479
+        ) );
480
+
481
+        // Store the count in cache.
482
+        set_transient( '_wl_entity_service__count', $count, 900 );
483
+
484
+        return $count;
485
+    }
486
+
487
+    /**
488
+     * Add the entity filtering criterias to the arguments for a `get_posts`
489
+     * call.
490
+     *
491
+     * @param array $args The arguments for a `get_posts` call.
492
+     *
493
+     * @return array The arguments for a `get_posts` call.
494
+     * @since 3.15.0
495
+     *
496
+     */
497
+    public static function add_criterias( $args ) {
498
+
499
+        // Build an optimal tax-query.
500
+        $tax_query = array(
501
+            'relation' => 'AND',
502
+            array(
503
+                'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
504
+                'operator' => 'EXISTS',
505
+            ),
506
+            array(
507
+                'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
508
+                'field'    => 'slug',
509
+                'terms'    => 'article',
510
+                'operator' => 'NOT IN',
511
+            ),
512
+        );
513
+
514
+        return $args + array(
515
+                'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
516
+                /*
517 517
 				 * Ensure compatibility with Polylang.
518 518
 				 *
519 519
 				 * @see https://github.com/insideout10/wordlift-plugin/issues/855.
@@ -521,102 +521,102 @@  discard block
 block discarded – undo
521 521
 				 *
522 522
 				 * @since 3.19.5
523 523
 				 */
524
-				'lang'      => '',
525
-				'tax_query' => $tax_query,
526
-			);
527
-	}
528
-
529
-	/**
530
-	 * Create a new entity.
531
-	 *
532
-	 * @param string $name The entity name.
533
-	 * @param string $type_uri The entity's type URI.
534
-	 * @param null $logo The entity logo id (or NULL if none).
535
-	 * @param string $status The post status, by default 'publish'.
536
-	 *
537
-	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
538
-	 * @since 3.9.0
539
-	 *
540
-	 */
541
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
542
-
543
-		// Create an entity for the publisher.
544
-		$post_id = @wp_insert_post( array(
545
-			'post_type'    => self::TYPE_NAME,
546
-			'post_title'   => $name,
547
-			'post_status'  => $status,
548
-			'post_content' => '',
549
-		) );
550
-
551
-		// Return the error if any.
552
-		if ( is_wp_error( $post_id ) ) {
553
-			return $post_id;
554
-		}
555
-
556
-		// Set the entity logo.
557
-		if ( $logo && is_numeric( $logo ) ) {
558
-			set_post_thumbnail( $post_id, $logo );
559
-		}
560
-
561
-		// Set the entity type.
562
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
563
-
564
-		return $post_id;
565
-	}
566
-
567
-	/**
568
-	 * Get the entities related to the one with the specified id. By default only
569
-	 * published entities will be returned.
570
-	 *
571
-	 * @param int $id The post id.
572
-	 * @param string $post_status The target post status (default = publish).
573
-	 *
574
-	 * @return array An array of post ids.
575
-	 * @since 3.10.0
576
-	 *
577
-	 */
578
-	public function get_related_entities( $id, $post_status = 'publish' ) {
579
-
580
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
581
-	}
582
-
583
-	/**
584
-	 * Get the list of entities.
585
-	 *
586
-	 * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
587
-	 *
588
-	 * @return array An array of entity posts.
589
-	 * @since 3.12.2
590
-	 *
591
-	 */
592
-	public function get( $params = array() ) {
593
-
594
-		// Set the defaults.
595
-		$defaults = array( 'post_type' => 'entity' );
596
-
597
-		// Merge the defaults with the provided parameters.
598
-		$args = wp_parse_args( $params, $defaults );
599
-
600
-		// Call the `get_posts` function.
601
-		return get_posts( $args );
602
-	}
603
-
604
-	/**
605
-	 * The list of post type names which can be used for entities
606
-	 *
607
-	 * Criteria is that the post type is public. The list of valid post types
608
-	 * can be overridden with a filter.
609
-	 *
610
-	 * @return array Array containing the names of the valid post types.
611
-	 * @since 3.15.0
612
-	 *
613
-	 */
614
-	static function valid_entity_post_types() {
615
-
616
-		// Ignore builtins in the call to avoid getting attachments.
617
-		$post_types = array( 'post', 'page', self::TYPE_NAME, 'product' );
618
-
619
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
620
-	}
524
+                'lang'      => '',
525
+                'tax_query' => $tax_query,
526
+            );
527
+    }
528
+
529
+    /**
530
+     * Create a new entity.
531
+     *
532
+     * @param string $name The entity name.
533
+     * @param string $type_uri The entity's type URI.
534
+     * @param null $logo The entity logo id (or NULL if none).
535
+     * @param string $status The post status, by default 'publish'.
536
+     *
537
+     * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
538
+     * @since 3.9.0
539
+     *
540
+     */
541
+    public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
542
+
543
+        // Create an entity for the publisher.
544
+        $post_id = @wp_insert_post( array(
545
+            'post_type'    => self::TYPE_NAME,
546
+            'post_title'   => $name,
547
+            'post_status'  => $status,
548
+            'post_content' => '',
549
+        ) );
550
+
551
+        // Return the error if any.
552
+        if ( is_wp_error( $post_id ) ) {
553
+            return $post_id;
554
+        }
555
+
556
+        // Set the entity logo.
557
+        if ( $logo && is_numeric( $logo ) ) {
558
+            set_post_thumbnail( $post_id, $logo );
559
+        }
560
+
561
+        // Set the entity type.
562
+        Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
563
+
564
+        return $post_id;
565
+    }
566
+
567
+    /**
568
+     * Get the entities related to the one with the specified id. By default only
569
+     * published entities will be returned.
570
+     *
571
+     * @param int $id The post id.
572
+     * @param string $post_status The target post status (default = publish).
573
+     *
574
+     * @return array An array of post ids.
575
+     * @since 3.10.0
576
+     *
577
+     */
578
+    public function get_related_entities( $id, $post_status = 'publish' ) {
579
+
580
+        return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
581
+    }
582
+
583
+    /**
584
+     * Get the list of entities.
585
+     *
586
+     * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
587
+     *
588
+     * @return array An array of entity posts.
589
+     * @since 3.12.2
590
+     *
591
+     */
592
+    public function get( $params = array() ) {
593
+
594
+        // Set the defaults.
595
+        $defaults = array( 'post_type' => 'entity' );
596
+
597
+        // Merge the defaults with the provided parameters.
598
+        $args = wp_parse_args( $params, $defaults );
599
+
600
+        // Call the `get_posts` function.
601
+        return get_posts( $args );
602
+    }
603
+
604
+    /**
605
+     * The list of post type names which can be used for entities
606
+     *
607
+     * Criteria is that the post type is public. The list of valid post types
608
+     * can be overridden with a filter.
609
+     *
610
+     * @return array Array containing the names of the valid post types.
611
+     * @since 3.15.0
612
+     *
613
+     */
614
+    static function valid_entity_post_types() {
615
+
616
+        // Ignore builtins in the call to avoid getting attachments.
617
+        $post_types = array( 'post', 'page', self::TYPE_NAME, 'product' );
618
+
619
+        return apply_filters( 'wl_valid_entity_post_types', $post_types );
620
+    }
621 621
 
622 622
 }
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * @since 3.2.0
82 82
 	 */
83 83
 	protected function __construct() {
84
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
84
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Entity_Service');
85 85
 
86 86
 		$this->entity_uri_service = Wordlift_Entity_Uri_Service::get_instance();
87 87
 		$this->relation_service   = Wordlift_Relation_Service::get_instance();
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public static function get_instance() {
107 107
 
108
-		if ( ! isset( self::$instance ) ) {
108
+		if ( ! isset(self::$instance)) {
109 109
 			self::$instance = new self();
110 110
 		}
111 111
 
@@ -122,22 +122,22 @@  discard block
 block discarded – undo
122 122
 	 * @since 3.1.0
123 123
 	 *
124 124
 	 */
125
-	public function is_entity( $post_id ) {
125
+	public function is_entity($post_id) {
126 126
 
127 127
 		// Improve performance by giving for granted that a product is an entity.
128
-		if ( 'product' === get_post_type( $post_id ) ) {
128
+		if ('product' === get_post_type($post_id)) {
129 129
 			return true;
130 130
 		}
131 131
 
132
-		$terms = wp_get_object_terms( $post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
132
+		$terms = wp_get_object_terms($post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
133 133
 
134
-		if ( is_wp_error( $terms ) ) {
135
-			$this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
134
+		if (is_wp_error($terms)) {
135
+			$this->log->error("Cannot get the terms for post $post_id: ".$terms->get_error_message());
136 136
 
137 137
 			return false;
138 138
 		}
139 139
 
140
-		if ( empty( $terms ) ) {
140
+		if (empty($terms)) {
141 141
 			return false;
142 142
 		}
143 143
 
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 		 *
149 149
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
150 150
 		 */
151
-		foreach ( $terms as $term ) {
152
-			if ( 1 !== preg_match( '~(^|-)article$~', $term->slug ) ) {
151
+		foreach ($terms as $term) {
152
+			if (1 !== preg_match('~(^|-)article$~', $term->slug)) {
153 153
 				return true;
154 154
 			}
155 155
 		}
@@ -169,19 +169,19 @@  discard block
 block discarded – undo
169 169
 	 * @since 3.5.0
170 170
 	 *
171 171
 	 */
172
-	public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
172
+	public function get_classification_scope_for($post_id, $default = WL_WHAT_RELATION) {
173 173
 
174
-		if ( false === $this->is_entity( $post_id ) ) {
174
+		if (false === $this->is_entity($post_id)) {
175 175
 			return $default;
176 176
 		}
177 177
 
178 178
 		// Retrieve the entity type
179
-		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
180
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
179
+		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get($post_id);
180
+		$entity_type     = str_replace('wl-', '', $entity_type_arr['css_class']);
181 181
 		// Retrieve classification boxes configuration
182
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
183
-		foreach ( $classification_boxes as $cb ) {
184
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
182
+		$classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES);
183
+		foreach ($classification_boxes as $cb) {
184
+			if (in_array($entity_type, $cb['registeredTypes'])) {
185 185
 				return $cb['id'];
186 186
 			}
187 187
 		}
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return bool|null Null if it's not an entity, otherwise true if it's used.
198 198
 	 */
199
-	public function is_used( $post_id ) {
199
+	public function is_used($post_id) {
200 200
 
201
-		if ( false === $this->is_entity( $post_id ) ) {
201
+		if (false === $this->is_entity($post_id)) {
202 202
 			return null;
203 203
 		}
204 204
 		// Retrieve the post
205
-		$entity = get_post( $post_id );
205
+		$entity = get_post($post_id);
206 206
 
207 207
 		global $wpdb;
208 208
 		// Retrieve Wordlift relation instances table name
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
 		);
216 216
 
217 217
 		// Perform the query
218
-		$relation_instances = (int) $wpdb->get_var( $stmt );
218
+		$relation_instances = (int) $wpdb->get_var($stmt);
219 219
 		// If there is at least one relation instance for the current entity, then it's used
220
-		if ( 0 < $relation_instances ) {
220
+		if (0 < $relation_instances) {
221 221
 			return true;
222 222
 		}
223 223
 
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
 		$stmt = $wpdb->prepare(
226 226
 			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
227 227
 			$entity->ID,
228
-			wl_get_entity_uri( $entity->ID )
228
+			wl_get_entity_uri($entity->ID)
229 229
 		);
230 230
 		// Perform the query
231
-		$meta_instances = (int) $wpdb->get_var( $stmt );
231
+		$meta_instances = (int) $wpdb->get_var($stmt);
232 232
 
233 233
 		// If there is at least one meta that refers the current entity uri, then current entity is used
234
-		if ( 0 < $meta_instances ) {
234
+		if (0 < $meta_instances) {
235 235
 			return true;
236 236
 		}
237 237
 
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 	 * @since      3.2.0
252 252
 	 *
253 253
 	 */
254
-	public function get_entity_post_by_uri( $uri ) {
254
+	public function get_entity_post_by_uri($uri) {
255 255
 
256
-		return $this->entity_uri_service->get_entity( $uri );
256
+		return $this->entity_uri_service->get_entity($uri);
257 257
 	}
258 258
 
259 259
 	/**
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
 	 * @param WP_Post $post Post object.
269 269
 	 * @param bool $update Whether this is an existing post being updated or not.
270 270
 	 */
271
-	public function save_post( $post_id, $post, $update ) {
271
+	public function save_post($post_id, $post, $update) {
272 272
 
273 273
 		// Avoid doing anything if post is autosave or a revision.
274
-		if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
274
+		if (wp_is_post_autosave($post) || wp_is_post_revision($post)) {
275 275
 			return;
276 276
 		}
277 277
 
@@ -281,16 +281,16 @@  discard block
 block discarded – undo
281 281
 		// the $post_id in the save_post call matches the post id set in the request.
282 282
 		//
283 283
 		// If this is not the current post being saved or if it's not an entity, return.
284
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
284
+		if ( ! isset($_REQUEST['post_ID']) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity($post_id)) {
285 285
 			return;
286 286
 		}
287 287
 
288 288
 		// Get the alt labels from the request (or empty array).
289
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? (array) $_REQUEST['wl_alternative_label'] : array();
289
+		$alt_labels = isset($_REQUEST['wl_alternative_label']) ? (array) $_REQUEST['wl_alternative_label'] : array();
290 290
 
291
-		if ( ( ! empty( $_POST['content'] ) && ! empty( $_POST['post_content'] ) ) || isset( $_REQUEST['wl_alternative_label'] ) ) {
291
+		if (( ! empty($_POST['content']) && ! empty($_POST['post_content'])) || isset($_REQUEST['wl_alternative_label'])) {
292 292
 			// This is via classic editor, so set the alternative labels.
293
-			$this->set_alternative_labels( $post_id, $alt_labels );
293
+			$this->set_alternative_labels($post_id, $alt_labels);
294 294
 		}
295 295
 
296 296
 
@@ -305,48 +305,48 @@  discard block
 block discarded – undo
305 305
 	 * @since 3.2.0
306 306
 	 *
307 307
 	 */
308
-	public function set_alternative_labels( $post_id, $alt_labels ) {
308
+	public function set_alternative_labels($post_id, $alt_labels) {
309 309
 
310 310
 		// Bail out if post id is not numeric. We add this check as we found a WP install that was sending a WP_Error
311 311
 		// instead of post id.
312
-		if ( ! is_numeric( $post_id ) ) {
312
+		if ( ! is_numeric($post_id)) {
313 313
 			return;
314 314
 		}
315 315
 
316 316
 		// Force $alt_labels to be an array
317
-		if ( ! is_array( $alt_labels ) ) {
318
-			$alt_labels = array( $alt_labels );
317
+		if ( ! is_array($alt_labels)) {
318
+			$alt_labels = array($alt_labels);
319 319
 		}
320 320
 
321
-		$this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
321
+		$this->log->debug("Setting alternative labels [ post id :: $post_id ][ alt labels :: ".implode(',', $alt_labels)." ]");
322 322
 
323 323
 		// Delete all the existing alternate labels.
324
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
324
+		delete_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
325 325
 
326 326
 		// Save only unique synonymns.
327
-		$alt_labels = array_unique( $alt_labels );
327
+		$alt_labels = array_unique($alt_labels);
328 328
 
329 329
 		// Set the alternative labels.
330
-		foreach ( $alt_labels as $alt_label ) {
330
+		foreach ($alt_labels as $alt_label) {
331 331
 
332 332
 			// Strip html code from synonym.
333
-			$alt_label = wp_strip_all_tags( $alt_label );
333
+			$alt_label = wp_strip_all_tags($alt_label);
334 334
 
335
-			if ( ! empty( $alt_label ) ) {
336
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, (string) $alt_label );
335
+			if ( ! empty($alt_label)) {
336
+				add_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY, (string) $alt_label);
337 337
 			}
338 338
 		}
339 339
 
340 340
 	}
341 341
 
342
-	public function append_alternative_labels( $post_id, $labels_to_append ) {
342
+	public function append_alternative_labels($post_id, $labels_to_append) {
343 343
 
344
-		$merged_labels = $this->get_alternative_labels( $post_id );
344
+		$merged_labels = $this->get_alternative_labels($post_id);
345 345
 
346 346
 		// Append new synonyms to the end.
347
-		$merged_labels = array_merge( $merged_labels, $labels_to_append );
347
+		$merged_labels = array_merge($merged_labels, $labels_to_append);
348 348
 
349
-		$this->set_alternative_labels( $post_id, $merged_labels );
349
+		$this->set_alternative_labels($post_id, $merged_labels);
350 350
 
351 351
 	}
352 352
 
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
 	 * @since 3.2.0
360 360
 	 *
361 361
 	 */
362
-	public function get_alternative_labels( $post_id ) {
362
+	public function get_alternative_labels($post_id) {
363 363
 
364
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
364
+		return get_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
365 365
 	}
366 366
 
367 367
 	/**
@@ -373,9 +373,9 @@  discard block
 block discarded – undo
373 373
 	 * @return array An array with the entity title and labels.
374 374
 	 * @since 3.12.0
375 375
 	 */
376
-	public function get_labels( $post_id, $object_type = Object_Type_Enum::POST ) {
377
-		if ( $object_type === Object_Type_Enum::POST ) {
378
-			return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
376
+	public function get_labels($post_id, $object_type = Object_Type_Enum::POST) {
377
+		if ($object_type === Object_Type_Enum::POST) {
378
+			return array_merge((array) get_the_title($post_id), $this->get_alternative_labels($post_id));
379 379
 		}
380 380
 
381 381
 		// Term Reference dont have synonyms yet.
@@ -390,45 +390,45 @@  discard block
 block discarded – undo
390 390
 	 * @since 3.2.0
391 391
 	 *
392 392
 	 */
393
-	public function edit_form_before_permalink( $post ) {
393
+	public function edit_form_before_permalink($post) {
394 394
 
395 395
 		// If it's not an entity, return.
396
-		if ( ! $this->is_entity( $post->ID ) ) {
396
+		if ( ! $this->is_entity($post->ID)) {
397 397
 			return;
398 398
 		}
399 399
 
400 400
 		// If disabled by filter, return.
401
-		if ( ! apply_filters( 'wl_feature__enable__add-synonyms', true ) ) {
401
+		if ( ! apply_filters('wl_feature__enable__add-synonyms', true)) {
402 402
 			return;
403 403
 		}
404 404
 
405 405
 		// Print the input template.
406
-		Wordlift_UI_Service::print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
406
+		Wordlift_UI_Service::print_template('wl-tmpl-alternative-label-input', $this->get_alternative_label_input());
407 407
 
408 408
 		// Print all the currently set alternative labels.
409
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
409
+		foreach ($this->get_alternative_labels($post->ID) as $alt_label) {
410 410
 
411
-			echo $this->get_alternative_label_input( $alt_label );
411
+			echo $this->get_alternative_label_input($alt_label);
412 412
 
413 413
 		};
414 414
 
415 415
 		// Print the button.
416
-		Wordlift_UI_Service::print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
416
+		Wordlift_UI_Service::print_button('wl-add-alternative-labels-button', __('Add more titles', 'wordlift'));
417 417
 
418 418
 	}
419 419
 
420
-	public function get_uri( $object_id, $type = Object_Type_Enum::POST ) {
420
+	public function get_uri($object_id, $type = Object_Type_Enum::POST) {
421 421
 		$content_service = Wordpress_Content_Service::get_instance();
422
-		$entity_id       = $content_service->get_entity_id( new Wordpress_Content_Id( $object_id, $type ) );
422
+		$entity_id       = $content_service->get_entity_id(new Wordpress_Content_Id($object_id, $type));
423 423
 		$dataset_uri     = Wordlift_Configuration_Service::get_instance()->get_dataset_uri();
424 424
 
425
-		if ( ! isset( $entity_id ) ||
426
-		     ( ! empty( $dataset_uri ) && 0 !== strpos( $entity_id, $dataset_uri ) ) ) {
427
-			$rel_uri = Entity_Uri_Generator::create_uri( $type, $object_id );
425
+		if ( ! isset($entity_id) ||
426
+		     ( ! empty($dataset_uri) && 0 !== strpos($entity_id, $dataset_uri))) {
427
+			$rel_uri = Entity_Uri_Generator::create_uri($type, $object_id);
428 428
 			try {
429
-				$content_service->set_entity_id( new Wordpress_Content_Id( $object_id, $type ), $rel_uri );
430
-				$entity_id = $content_service->get_entity_id( new Wordpress_Content_Id( $object_id, $type ) );
431
-			} catch ( Exception $e ) {
429
+				$content_service->set_entity_id(new Wordpress_Content_Id($object_id, $type), $rel_uri);
430
+				$entity_id = $content_service->get_entity_id(new Wordpress_Content_Id($object_id, $type));
431
+			} catch (Exception $e) {
432 432
 				return null;
433 433
 			}
434 434
 		}
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
 	 * @since 3.2.0
446 446
 	 *
447 447
 	 */
448
-	private function get_alternative_label_input( $value = '' ) {
448
+	private function get_alternative_label_input($value = '') {
449 449
 
450
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
450
+		return sprintf(self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr($value), __('Delete', 'wordlift'));
451 451
 	}
452 452
 
453 453
 	/**
@@ -461,13 +461,13 @@  discard block
 block discarded – undo
461 461
 		global $wpdb;
462 462
 
463 463
 		// Try to get the count from the transient.
464
-		$count = get_transient( '_wl_entity_service__count' );
465
-		if ( false !== $count ) {
464
+		$count = get_transient('_wl_entity_service__count');
465
+		if (false !== $count) {
466 466
 			return $count;
467 467
 		}
468 468
 
469 469
 		// Query the count.
470
-		$count = $wpdb->get_var( $wpdb->prepare(
470
+		$count = $wpdb->get_var($wpdb->prepare(
471 471
 			"SELECT COUNT( DISTINCT( tr.object_id ) )"
472 472
 			. " FROM {$wpdb->term_relationships} tr"
473 473
 			. " INNER JOIN {$wpdb->term_taxonomy} tt"
@@ -476,10 +476,10 @@  discard block
 block discarded – undo
476 476
 			. "  ON t.term_id = tt.term_id AND t.name != %s",
477 477
 			Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
478 478
 			'article'
479
-		) );
479
+		));
480 480
 
481 481
 		// Store the count in cache.
482
-		set_transient( '_wl_entity_service__count', $count, 900 );
482
+		set_transient('_wl_entity_service__count', $count, 900);
483 483
 
484 484
 		return $count;
485 485
 	}
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 	 * @since 3.15.0
495 495
 	 *
496 496
 	 */
497
-	public static function add_criterias( $args ) {
497
+	public static function add_criterias($args) {
498 498
 
499 499
 		// Build an optimal tax-query.
500 500
 		$tax_query = array(
@@ -538,28 +538,28 @@  discard block
 block discarded – undo
538 538
 	 * @since 3.9.0
539 539
 	 *
540 540
 	 */
541
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
541
+	public function create($name, $type_uri, $logo = null, $status = 'publish') {
542 542
 
543 543
 		// Create an entity for the publisher.
544
-		$post_id = @wp_insert_post( array(
544
+		$post_id = @wp_insert_post(array(
545 545
 			'post_type'    => self::TYPE_NAME,
546 546
 			'post_title'   => $name,
547 547
 			'post_status'  => $status,
548 548
 			'post_content' => '',
549
-		) );
549
+		));
550 550
 
551 551
 		// Return the error if any.
552
-		if ( is_wp_error( $post_id ) ) {
552
+		if (is_wp_error($post_id)) {
553 553
 			return $post_id;
554 554
 		}
555 555
 
556 556
 		// Set the entity logo.
557
-		if ( $logo && is_numeric( $logo ) ) {
558
-			set_post_thumbnail( $post_id, $logo );
557
+		if ($logo && is_numeric($logo)) {
558
+			set_post_thumbnail($post_id, $logo);
559 559
 		}
560 560
 
561 561
 		// Set the entity type.
562
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
562
+		Wordlift_Entity_Type_Service::get_instance()->set($post_id, $type_uri);
563 563
 
564 564
 		return $post_id;
565 565
 	}
@@ -575,9 +575,9 @@  discard block
 block discarded – undo
575 575
 	 * @since 3.10.0
576 576
 	 *
577 577
 	 */
578
-	public function get_related_entities( $id, $post_status = 'publish' ) {
578
+	public function get_related_entities($id, $post_status = 'publish') {
579 579
 
580
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
580
+		return $this->relation_service->get_objects($id, 'ids', null, $post_status);
581 581
 	}
582 582
 
583 583
 	/**
@@ -589,16 +589,16 @@  discard block
 block discarded – undo
589 589
 	 * @since 3.12.2
590 590
 	 *
591 591
 	 */
592
-	public function get( $params = array() ) {
592
+	public function get($params = array()) {
593 593
 
594 594
 		// Set the defaults.
595
-		$defaults = array( 'post_type' => 'entity' );
595
+		$defaults = array('post_type' => 'entity');
596 596
 
597 597
 		// Merge the defaults with the provided parameters.
598
-		$args = wp_parse_args( $params, $defaults );
598
+		$args = wp_parse_args($params, $defaults);
599 599
 
600 600
 		// Call the `get_posts` function.
601
-		return get_posts( $args );
601
+		return get_posts($args);
602 602
 	}
603 603
 
604 604
 	/**
@@ -614,9 +614,9 @@  discard block
 block discarded – undo
614 614
 	static function valid_entity_post_types() {
615 615
 
616 616
 		// Ignore builtins in the call to avoid getting attachments.
617
-		$post_types = array( 'post', 'page', self::TYPE_NAME, 'product' );
617
+		$post_types = array('post', 'page', self::TYPE_NAME, 'product');
618 618
 
619
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
619
+		return apply_filters('wl_valid_entity_post_types', $post_types);
620 620
 	}
621 621
 
622 622
 }
Please login to merge, or discard this patch.
src/includes/properties/class-wordlift-url-property-service.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -16,35 +16,35 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class Wordlift_Url_Property_Service extends Wordlift_Simple_Property_Service {
18 18
 
19
-	/**
20
-	 * The meta key for the schema:url property.
21
-	 */
22
-	const META_KEY = 'wl_schema_url';
19
+    /**
20
+     * The meta key for the schema:url property.
21
+     */
22
+    const META_KEY = 'wl_schema_url';
23 23
 
24
-	/**
25
-	 * Get the URLs associated with the post.
26
-	 *
27
-	 * @param int $id The post id.
28
-	 * @param string $meta_key The meta key.
29
-	 *
30
-	 * @return array An array of URLs.
31
-	 */
32
-	public function get( $id, $meta_key, $type ) {
24
+    /**
25
+     * Get the URLs associated with the post.
26
+     *
27
+     * @param int $id The post id.
28
+     * @param string $meta_key The meta key.
29
+     *
30
+     * @return array An array of URLs.
31
+     */
32
+    public function get( $id, $meta_key, $type ) {
33 33
 
34
-		// Get the meta values and push the <permalink> to
35
-		// ensure that default url will be added to the schema:url's.
36
-		/*
34
+        // Get the meta values and push the <permalink> to
35
+        // ensure that default url will be added to the schema:url's.
36
+        /*
37 37
 		 * Do not add `<permalink>` if one or more URLs have been provided by the editor.
38 38
 		 *
39 39
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/913
40 40
 		 *
41 41
 		 * @since 3.21.1
42 42
 		 */
43
-		$urls = array_filter( parent::get( $id, $meta_key, $type ) ?: array( '<permalink>' ) );
43
+        $urls = array_filter( parent::get( $id, $meta_key, $type ) ?: array( '<permalink>' ) );
44 44
 
45
-		// Convert <permalink> in actual permalink values.
46
-		return array_map( function ( $item ) use ( $id, $type ) {
47
-			/*
45
+        // Convert <permalink> in actual permalink values.
46
+        return array_map( function ( $item ) use ( $id, $type ) {
47
+            /*
48 48
 			 * If `<permalink>` get the production permalink.
49 49
 			 *
50 50
 			 * @since 3.20.0
@@ -52,20 +52,20 @@  discard block
 block discarded – undo
52 52
 			 * @see https://github.com/insideout10/wordlift-plugin/issues/850.
53 53
 			 */
54 54
 
55
-			if ( '<permalink>' !== $item ) {
56
-				return $item;
57
-			}
55
+            if ( '<permalink>' !== $item ) {
56
+                return $item;
57
+            }
58 58
 
59
-			// Permalinks.
60
-			switch ( $type ) {
61
-				case Object_Type_Enum::POST:
62
-					return Wordlift_Post_Adapter::get_production_permalink( $id );
63
-				case Object_Type_Enum::TERM:
64
-					return get_term_link( $id );
65
-				default:
66
-					return $item;
67
-			}
68
-		}, array_unique( $urls ) );
69
-	}
59
+            // Permalinks.
60
+            switch ( $type ) {
61
+                case Object_Type_Enum::POST:
62
+                    return Wordlift_Post_Adapter::get_production_permalink( $id );
63
+                case Object_Type_Enum::TERM:
64
+                    return get_term_link( $id );
65
+                default:
66
+                    return $item;
67
+            }
68
+        }, array_unique( $urls ) );
69
+    }
70 70
 
71 71
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @return array An array of URLs.
31 31
 	 */
32
-	public function get( $id, $meta_key, $type ) {
32
+	public function get($id, $meta_key, $type) {
33 33
 
34 34
 		// Get the meta values and push the <permalink> to
35 35
 		// ensure that default url will be added to the schema:url's.
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 		 *
41 41
 		 * @since 3.21.1
42 42
 		 */
43
-		$urls = array_filter( parent::get( $id, $meta_key, $type ) ?: array( '<permalink>' ) );
43
+		$urls = array_filter(parent::get($id, $meta_key, $type) ?: array('<permalink>'));
44 44
 
45 45
 		// Convert <permalink> in actual permalink values.
46
-		return array_map( function ( $item ) use ( $id, $type ) {
46
+		return array_map(function($item) use ($id, $type) {
47 47
 			/*
48 48
 			 * If `<permalink>` get the production permalink.
49 49
 			 *
@@ -52,20 +52,20 @@  discard block
 block discarded – undo
52 52
 			 * @see https://github.com/insideout10/wordlift-plugin/issues/850.
53 53
 			 */
54 54
 
55
-			if ( '<permalink>' !== $item ) {
55
+			if ('<permalink>' !== $item) {
56 56
 				return $item;
57 57
 			}
58 58
 
59 59
 			// Permalinks.
60
-			switch ( $type ) {
60
+			switch ($type) {
61 61
 				case Object_Type_Enum::POST:
62
-					return Wordlift_Post_Adapter::get_production_permalink( $id );
62
+					return Wordlift_Post_Adapter::get_production_permalink($id);
63 63
 				case Object_Type_Enum::TERM:
64
-					return get_term_link( $id );
64
+					return get_term_link($id);
65 65
 				default:
66 66
 					return $item;
67 67
 			}
68
-		}, array_unique( $urls ) );
68
+		}, array_unique($urls));
69 69
 	}
70 70
 
71 71
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift.php 1 patch
Indentation   +1681 added lines, -1681 removed lines patch added patch discarded remove patch
@@ -82,1762 +82,1762 @@
 block discarded – undo
82 82
  */
83 83
 class Wordlift {
84 84
 
85
-	//<editor-fold desc="## FIELDS">
86
-
87
-	/**
88
-	 * The loader that's responsible for maintaining and registering all hooks that power
89
-	 * the plugin.
90
-	 *
91
-	 * @since    1.0.0
92
-	 * @access   protected
93
-	 * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
94
-	 */
95
-	protected $loader;
96
-
97
-	/**
98
-	 * The unique identifier of this plugin.
99
-	 *
100
-	 * @since    1.0.0
101
-	 * @access   protected
102
-	 * @var      string $plugin_name The string used to uniquely identify this plugin.
103
-	 */
104
-	protected $plugin_name;
105
-
106
-	/**
107
-	 * The current version of the plugin.
108
-	 *
109
-	 * @since    1.0.0
110
-	 * @access   protected
111
-	 * @var      string $version The current version of the plugin.
112
-	 */
113
-	protected $version;
114
-
115
-	/**
116
-	 * The {@link Wordlift_Tinymce_Adapter} instance.
117
-	 *
118
-	 * @since  3.12.0
119
-	 * @access protected
120
-	 * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
121
-	 */
122
-	protected $tinymce_adapter;
123
-
124
-	/**
125
-	 * The Schema service.
126
-	 *
127
-	 * @since  3.3.0
128
-	 * @access protected
129
-	 * @var \Wordlift_Schema_Service $schema_service The Schema service.
130
-	 */
131
-	protected $schema_service;
132
-
133
-	/**
134
-	 * The Topic Taxonomy service.
135
-	 *
136
-	 * @since  3.5.0
137
-	 * @access private
138
-	 * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
139
-	 */
140
-	private $topic_taxonomy_service;
141
-
142
-	/**
143
-	 * The Entity Types Taxonomy service.
144
-	 *
145
-	 * @since  3.18.0
146
-	 * @access private
147
-	 * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service.
148
-	 */
149
-	private $entity_types_taxonomy_service;
150
-
151
-	/**
152
-	 * The User service.
153
-	 *
154
-	 * @since  3.1.7
155
-	 * @access protected
156
-	 * @var \Wordlift_User_Service $user_service The User service.
157
-	 */
158
-	protected $user_service;
159
-
160
-	/**
161
-	 * The Timeline service.
162
-	 *
163
-	 * @since  3.1.0
164
-	 * @access private
165
-	 * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
166
-	 */
167
-	private $timeline_service;
168
-
169
-	/**
170
-	 * The Redirect service.
171
-	 *
172
-	 * @since  3.2.0
173
-	 * @access private
174
-	 * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
175
-	 */
176
-	private $redirect_service;
177
-
178
-	/**
179
-	 * The Notice service.
180
-	 *
181
-	 * @since  3.3.0
182
-	 * @access private
183
-	 * @var \Wordlift_Notice_Service $notice_service The Notice service.
184
-	 */
185
-	private $notice_service;
186
-
187
-	/**
188
-	 * The Entity list customization.
189
-	 *
190
-	 * @since  3.3.0
191
-	 * @access protected
192
-	 * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
193
-	 */
194
-	protected $entity_list_service;
195
-
196
-	/**
197
-	 * The Entity Types Taxonomy Walker.
198
-	 *
199
-	 * @since  3.1.0
200
-	 * @access private
201
-	 * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
202
-	 */
203
-	private $entity_types_taxonomy_walker;
204
-
205
-	/**
206
-	 * The ShareThis service.
207
-	 *
208
-	 * @since  3.2.0
209
-	 * @access private
210
-	 * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
211
-	 */
212
-	private $sharethis_service;
213
-
214
-	/**
215
-	 * The PrimaShop adapter.
216
-	 *
217
-	 * @since  3.2.3
218
-	 * @access private
219
-	 * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
220
-	 */
221
-	private $primashop_adapter;
222
-
223
-	/**
224
-	 * The entity type service.
225
-	 *
226
-	 * @since  3.6.0
227
-	 * @access private
228
-	 * @var \Wordlift_Entity_Post_Type_Service
229
-	 */
230
-	private $entity_post_type_service;
231
-
232
-	/**
233
-	 * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
234
-	 *
235
-	 * @since  3.6.0
236
-	 * @access private
237
-	 * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance.
238
-	 */
239
-	private $entity_link_service;
240
-
241
-	/**
242
-	 * A {@link Wordlift_Jsonld_Service} instance.
243
-	 *
244
-	 * @since  3.7.0
245
-	 * @access protected
246
-	 * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
247
-	 */
248
-	protected $jsonld_service;
249
-
250
-	/**
251
-	 * A {@link Wordlift_Website_Jsonld_Converter} instance.
252
-	 *
253
-	 * @since  3.14.0
254
-	 * @access protected
255
-	 * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
256
-	 */
257
-	protected $jsonld_website_converter;
258
-
259
-	/**
260
-	 * A {@link Wordlift_Property_Factory} instance.
261
-	 *
262
-	 * @since  3.7.0
263
-	 * @access private
264
-	 * @var \Wordlift_Property_Factory $property_factory
265
-	 */
266
-	private $property_factory;
267
-
268
-	/**
269
-	 * The 'Download Your Data' page.
270
-	 *
271
-	 * @since  3.6.0
272
-	 * @access private
273
-	 * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
274
-	 */
275
-	private $download_your_data_page;
276
-
277
-	/**
278
-	 * The 'WordLift Settings' page.
279
-	 *
280
-	 * @since  3.11.0
281
-	 * @access protected
282
-	 * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
283
-	 */
284
-	protected $settings_page;
285
-
286
-	/**
287
-	 * The install wizard page.
288
-	 *
289
-	 * @since  3.9.0
290
-	 * @access private
291
-	 * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
292
-	 */
293
-	public $admin_setup;
294
-
295
-	/**
296
-	 * The Content Filter Service hooks up to the 'the_content' filter and provides
297
-	 * linking of entities to their pages.
298
-	 *
299
-	 * @since  3.8.0
300
-	 * @access private
301
-	 * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
302
-	 */
303
-	private $content_filter_service;
304
-
305
-	/**
306
-	 * The Faq Content filter service
307
-	 * @since  3.26.0
308
-	 * @access private
309
-	 * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance.
310
-	 */
311
-	private $faq_content_filter_service;
312
-
313
-	/**
314
-	 * A {@link Wordlift_Key_Validation_Service} instance.
315
-	 *
316
-	 * @since  3.9.0
317
-	 * @access private
318
-	 * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
319
-	 */
320
-	private $key_validation_service;
321
-
322
-	/**
323
-	 * A {@link Wordlift_Rating_Service} instance.
324
-	 *
325
-	 * @since  3.10.0
326
-	 * @access private
327
-	 * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
328
-	 */
329
-	private $rating_service;
330
-
331
-	/**
332
-	 * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
333
-	 *
334
-	 * @since  3.10.0
335
-	 * @access protected
336
-	 * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
337
-	 */
338
-	protected $post_to_jsonld_converter;
339
-
340
-	/**
341
-	 * A {@link Wordlift_Install_Service} instance.
342
-	 *
343
-	 * @since  3.18.0
344
-	 * @access protected
345
-	 * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance.
346
-	 */
347
-	protected $install_service;
348
-
349
-	/**
350
-	 * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
351
-	 *
352
-	 * @since  3.10.0
353
-	 * @access protected
354
-	 * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
355
-	 */
356
-	protected $entity_post_to_jsonld_converter;
357
-
358
-	/**
359
-	 * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
360
-	 *
361
-	 * @since  3.10.0
362
-	 * @access protected
363
-	 * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
364
-	 */
365
-	protected $postid_to_jsonld_converter;
366
-
367
-	/**
368
-	 * The {@link Wordlift_Category_Taxonomy_Service} instance.
369
-	 *
370
-	 * @since  3.11.0
371
-	 * @access protected
372
-	 * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
373
-	 */
374
-	protected $category_taxonomy_service;
375
-
376
-	/**
377
-	 * The {@link Wordlift_Entity_Page_Service} instance.
378
-	 *
379
-	 * @since  3.11.0
380
-	 * @access protected
381
-	 * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
382
-	 */
383
-	protected $entity_page_service;
384
-
385
-	/**
386
-	 * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
387
-	 *
388
-	 * @since  3.11.0
389
-	 * @access protected
390
-	 * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
391
-	 */
392
-	protected $settings_page_action_link;
393
-
394
-	/**
395
-	 * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
396
-	 *
397
-	 * @since  3.11.0
398
-	 * @access protected
399
-	 * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
400
-	 */
401
-	protected $analytics_settings_page_action_link;
402
-
403
-	/**
404
-	 * The {@link Wordlift_Analytics_Connect} class.
405
-	 *
406
-	 * @since  3.11.0
407
-	 * @access protected
408
-	 * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class.
409
-	 */
410
-	protected $analytics_connect;
411
-
412
-	/**
413
-	 * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
414
-	 *
415
-	 * @since  3.11.0
416
-	 * @access protected
417
-	 * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
418
-	 */
419
-	protected $publisher_ajax_adapter;
420
-
421
-	/**
422
-	 * The {@link Wordlift_Admin_Input_Element} element renderer.
423
-	 *
424
-	 * @since  3.11.0
425
-	 * @access protected
426
-	 * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
427
-	 */
428
-	protected $input_element;
429
-
430
-	/**
431
-	 * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
432
-	 *
433
-	 * @since  3.13.0
434
-	 * @access protected
435
-	 * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
436
-	 */
437
-	protected $radio_input_element;
438
-
439
-	/**
440
-	 * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
441
-	 *
442
-	 * @since  3.11.0
443
-	 * @access protected
444
-	 * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
445
-	 */
446
-	protected $language_select_element;
447
-
448
-	/**
449
-	 * The {@link Wordlift_Admin_Country_Select_Element} element renderer.
450
-	 *
451
-	 * @since  3.18.0
452
-	 * @access protected
453
-	 * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer.
454
-	 */
455
-	protected $country_select_element;
456
-
457
-	/**
458
-	 * The {@link Wordlift_Admin_Publisher_Element} element renderer.
459
-	 *
460
-	 * @since  3.11.0
461
-	 * @access protected
462
-	 * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
463
-	 */
464
-	protected $publisher_element;
465
-
466
-	/**
467
-	 * The {@link Wordlift_Admin_Select2_Element} element renderer.
468
-	 *
469
-	 * @since  3.11.0
470
-	 * @access protected
471
-	 * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
472
-	 */
473
-	protected $select2_element;
474
-
475
-	/**
476
-	 * The controller for the entity type list admin page
477
-	 *
478
-	 * @since  3.11.0
479
-	 * @access private
480
-	 * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
481
-	 */
482
-	private $entity_type_admin_page;
483
-
484
-	/**
485
-	 * The controller for the entity type settings admin page
486
-	 *
487
-	 * @since  3.11.0
488
-	 * @access private
489
-	 * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
490
-	 */
491
-	private $entity_type_settings_admin_page;
492
-
493
-	/**
494
-	 * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
495
-	 *
496
-	 * @since  3.11.0
497
-	 * @access protected
498
-	 * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
499
-	 */
500
-	protected $related_entities_cloud_widget;
501
-
502
-	/**
503
-	 * The {@link Wordlift_Admin_Author_Element} instance.
504
-	 *
505
-	 * @since  3.14.0
506
-	 * @access protected
507
-	 * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
508
-	 */
509
-	protected $author_element;
510
-
511
-	/**
512
-	 * The {@link Wordlift_Sample_Data_Service} instance.
513
-	 *
514
-	 * @since  3.12.0
515
-	 * @access protected
516
-	 * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
517
-	 */
518
-	protected $sample_data_service;
519
-
520
-	/**
521
-	 * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
522
-	 *
523
-	 * @since  3.12.0
524
-	 * @access protected
525
-	 * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
526
-	 */
527
-	protected $sample_data_ajax_adapter;
528
-
529
-	/**
530
-	 * The {@link Wordlift_Google_Analytics_Export_Service} instance.
531
-	 *
532
-	 * @since  3.16.0
533
-	 * @access protected
534
-	 * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance.
535
-	 */
536
-	protected $google_analytics_export_service;
537
-
538
-	/**
539
-	 * {@link Wordlift}'s singleton instance.
540
-	 *
541
-	 * @since  3.15.0
542
-	 * @access protected
543
-	 * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
544
-	 */
545
-	protected $entity_type_adapter;
546
-
547
-	/**
548
-	 * The {@link Wordlift_Storage_Factory} instance.
549
-	 *
550
-	 * @since  3.15.0
551
-	 * @access protected
552
-	 * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
553
-	 */
554
-	protected $storage_factory;
555
-
556
-	/**
557
-	 * The {@link Wordlift_Autocomplete_Adapter} instance.
558
-	 *
559
-	 * @since  3.15.0
560
-	 * @access private
561
-	 * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
562
-	 */
563
-	private $autocomplete_adapter;
564
-
565
-	/**
566
-	 * The {@link Wordlift_Cached_Post_Converter} instance.
567
-	 *
568
-	 * @since  3.16.0
569
-	 * @access protected
570
-	 * @var  \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance.
571
-	 *
572
-	 */
573
-	protected $cached_postid_to_jsonld_converter;
574
-
575
-	/**
576
-	 * The {@link Wordlift_Entity_Uri_Service} instance.
577
-	 *
578
-	 * @since  3.16.3
579
-	 * @access protected
580
-	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
581
-	 */
582
-	protected $entity_uri_service;
583
-
584
-	/**
585
-	 * The {@link Wordlift_Publisher_Service} instance.
586
-	 *
587
-	 * @since  3.19.0
588
-	 * @access protected
589
-	 * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance.
590
-	 */
591
-	protected $publisher_service;
592
-
593
-	/**
594
-	 * The {@link Wordlift_Context_Cards_Service} instance.
595
-	 *
596
-	 * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance.
597
-	 */
598
-	protected $context_cards_service;
599
-
600
-	/**
601
-	 * {@link Wordlift}'s singleton instance.
602
-	 *
603
-	 * @since  3.11.2
604
-	 * @access private
605
-	 * @var Wordlift $instance {@link Wordlift}'s singleton instance.
606
-	 */
607
-	private static $instance;
608
-
609
-	/**
610
-	 * A singleton instance of features registry.
611
-	 * @since 3.30.0
612
-	 * @var Features_Registry
613
-	 */
614
-	private $features_registry;
615
-
616
-	private $analytics_settings_page;
617
-	//</editor-fold>
618
-
619
-	// Experimental code added by Nishit for feature request 1496
620
-	private $webhook_loader;
621
-	// Experimental code ents here
622
-
623
-	/**
624
-	 * Define the core functionality of the plugin.
625
-	 *
626
-	 * Set the plugin name and the plugin version that can be used throughout the plugin.
627
-	 * Load the dependencies, define the locale, and set the hooks for the admin area and
628
-	 * the public-facing side of the site.
629
-	 *
630
-	 * @since    1.0.0
631
-	 */
632
-	public function __construct() {
633
-
634
-		self::$instance = $this;
635
-
636
-		$this->plugin_name = 'wordlift';
637
-		$this->version     = '3.35.2';
638
-		$this->load_dependencies();
639
-		$this->set_locale();
640
-
641
-		$that = $this;
642
-		add_action( 'plugins_loaded', function () use ( $that ) {
643
-			$that->define_admin_hooks( $that );
644
-			$that->define_public_hooks( $that );
645
-		}, 4 );
646
-
647
-		// If we're in `WP_CLI` load the related files.
648
-		if ( class_exists( 'WP_CLI' ) ) {
649
-			$this->load_cli_dependencies();
650
-		}
651
-
652
-	}
653
-
654
-	/**
655
-	 * Get the singleton instance.
656
-	 *
657
-	 * @return Wordlift The {@link Wordlift} singleton instance.
658
-	 * @since 3.11.2
659
-	 *
660
-	 */
661
-	public static function get_instance() {
662
-
663
-		return self::$instance;
664
-	}
665
-
666
-	/**
667
-	 * Load the required dependencies for this plugin.
668
-	 *
669
-	 * Include the following files that make up the plugin:
670
-	 *
671
-	 * - Wordlift_Loader. Orchestrates the hooks of the plugin.
672
-	 * - Wordlift_i18n. Defines internationalization functionality.
673
-	 * - Wordlift_Admin. Defines all hooks for the admin area.
674
-	 * - Wordlift_Public. Defines all hooks for the public side of the site.
675
-	 *
676
-	 * Create an instance of the loader which will be used to register the hooks
677
-	 * with WordPress.
678
-	 *
679
-	 * @throws Exception
680
-	 * @since    1.0.0
681
-	 * @access   private
682
-	 */
683
-	private function load_dependencies() {
684
-
685
-		/**
686
-		 * The class responsible for orchestrating the actions and filters of the
687
-		 * core plugin.
688
-		 */
689
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
690
-
691
-		// The class responsible for plugin uninstall.
692
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php';
693
-
694
-		/**
695
-		 * The class responsible for defining internationalization functionality
696
-		 * of the plugin.
697
-		 */
698
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
699
-
700
-		/**
701
-		 * WordLift's supported languages.
702
-		 */
703
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
704
-
705
-		/**
706
-		 * WordLift's supported countries.
707
-		 */
708
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php';
709
-
710
-		/**
711
-		 * Provide support functions to sanitize data.
712
-		 */
713
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
714
-
715
-		/** Services. */
716
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
717
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
718
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
719
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
720
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
721
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
722
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
723
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
724
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php';
725
-
726
-		/**
727
-		 * The Schema service.
728
-		 */
729
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
730
-
731
-		/**
732
-		 * The schema:url property service.
733
-		 */
734
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
735
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
736
-
737
-		/**
738
-		 * The UI service.
739
-		 */
740
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
741
-
742
-		/**
743
-		 * The Entity Types Taxonomy service.
744
-		 */
745
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php';
746
-
747
-		/**
748
-		 * The Entity service.
749
-		 */
750
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
751
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
752
-
753
-		// Add the entity rating service.
754
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
755
-
756
-		/**
757
-		 * The User service.
758
-		 */
759
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
760
-
761
-		/**
762
-		 * The Timeline service.
763
-		 */
764
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
765
-
766
-		/**
767
-		 * The Topic Taxonomy service.
768
-		 */
769
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
770
-
771
-		/**
772
-		 * The WordLift URI service.
773
-		 */
774
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
775
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
776
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
777
-
778
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
779
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
780
-
781
-		/**
782
-		 * Load the converters.
783
-		 */
784
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
785
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
786
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
787
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
788
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
789
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
790
-
791
-		/**
792
-		 * Load cache-related files.
793
-		 */
794
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
795
-
796
-		/**
797
-		 * Load the content filter.
798
-		 */
799
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
800
-
801
-		/*
85
+    //<editor-fold desc="## FIELDS">
86
+
87
+    /**
88
+     * The loader that's responsible for maintaining and registering all hooks that power
89
+     * the plugin.
90
+     *
91
+     * @since    1.0.0
92
+     * @access   protected
93
+     * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
94
+     */
95
+    protected $loader;
96
+
97
+    /**
98
+     * The unique identifier of this plugin.
99
+     *
100
+     * @since    1.0.0
101
+     * @access   protected
102
+     * @var      string $plugin_name The string used to uniquely identify this plugin.
103
+     */
104
+    protected $plugin_name;
105
+
106
+    /**
107
+     * The current version of the plugin.
108
+     *
109
+     * @since    1.0.0
110
+     * @access   protected
111
+     * @var      string $version The current version of the plugin.
112
+     */
113
+    protected $version;
114
+
115
+    /**
116
+     * The {@link Wordlift_Tinymce_Adapter} instance.
117
+     *
118
+     * @since  3.12.0
119
+     * @access protected
120
+     * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
121
+     */
122
+    protected $tinymce_adapter;
123
+
124
+    /**
125
+     * The Schema service.
126
+     *
127
+     * @since  3.3.0
128
+     * @access protected
129
+     * @var \Wordlift_Schema_Service $schema_service The Schema service.
130
+     */
131
+    protected $schema_service;
132
+
133
+    /**
134
+     * The Topic Taxonomy service.
135
+     *
136
+     * @since  3.5.0
137
+     * @access private
138
+     * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
139
+     */
140
+    private $topic_taxonomy_service;
141
+
142
+    /**
143
+     * The Entity Types Taxonomy service.
144
+     *
145
+     * @since  3.18.0
146
+     * @access private
147
+     * @var \Wordlift_Entity_Type_Taxonomy_Service The Entity Types Taxonomy service.
148
+     */
149
+    private $entity_types_taxonomy_service;
150
+
151
+    /**
152
+     * The User service.
153
+     *
154
+     * @since  3.1.7
155
+     * @access protected
156
+     * @var \Wordlift_User_Service $user_service The User service.
157
+     */
158
+    protected $user_service;
159
+
160
+    /**
161
+     * The Timeline service.
162
+     *
163
+     * @since  3.1.0
164
+     * @access private
165
+     * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
166
+     */
167
+    private $timeline_service;
168
+
169
+    /**
170
+     * The Redirect service.
171
+     *
172
+     * @since  3.2.0
173
+     * @access private
174
+     * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
175
+     */
176
+    private $redirect_service;
177
+
178
+    /**
179
+     * The Notice service.
180
+     *
181
+     * @since  3.3.0
182
+     * @access private
183
+     * @var \Wordlift_Notice_Service $notice_service The Notice service.
184
+     */
185
+    private $notice_service;
186
+
187
+    /**
188
+     * The Entity list customization.
189
+     *
190
+     * @since  3.3.0
191
+     * @access protected
192
+     * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
193
+     */
194
+    protected $entity_list_service;
195
+
196
+    /**
197
+     * The Entity Types Taxonomy Walker.
198
+     *
199
+     * @since  3.1.0
200
+     * @access private
201
+     * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
202
+     */
203
+    private $entity_types_taxonomy_walker;
204
+
205
+    /**
206
+     * The ShareThis service.
207
+     *
208
+     * @since  3.2.0
209
+     * @access private
210
+     * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
211
+     */
212
+    private $sharethis_service;
213
+
214
+    /**
215
+     * The PrimaShop adapter.
216
+     *
217
+     * @since  3.2.3
218
+     * @access private
219
+     * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
220
+     */
221
+    private $primashop_adapter;
222
+
223
+    /**
224
+     * The entity type service.
225
+     *
226
+     * @since  3.6.0
227
+     * @access private
228
+     * @var \Wordlift_Entity_Post_Type_Service
229
+     */
230
+    private $entity_post_type_service;
231
+
232
+    /**
233
+     * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
234
+     *
235
+     * @since  3.6.0
236
+     * @access private
237
+     * @var \Wordlift_Entity_Link_Service $entity_link_service The {@link Wordlift_Entity_Link_Service} instance.
238
+     */
239
+    private $entity_link_service;
240
+
241
+    /**
242
+     * A {@link Wordlift_Jsonld_Service} instance.
243
+     *
244
+     * @since  3.7.0
245
+     * @access protected
246
+     * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
247
+     */
248
+    protected $jsonld_service;
249
+
250
+    /**
251
+     * A {@link Wordlift_Website_Jsonld_Converter} instance.
252
+     *
253
+     * @since  3.14.0
254
+     * @access protected
255
+     * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
256
+     */
257
+    protected $jsonld_website_converter;
258
+
259
+    /**
260
+     * A {@link Wordlift_Property_Factory} instance.
261
+     *
262
+     * @since  3.7.0
263
+     * @access private
264
+     * @var \Wordlift_Property_Factory $property_factory
265
+     */
266
+    private $property_factory;
267
+
268
+    /**
269
+     * The 'Download Your Data' page.
270
+     *
271
+     * @since  3.6.0
272
+     * @access private
273
+     * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
274
+     */
275
+    private $download_your_data_page;
276
+
277
+    /**
278
+     * The 'WordLift Settings' page.
279
+     *
280
+     * @since  3.11.0
281
+     * @access protected
282
+     * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
283
+     */
284
+    protected $settings_page;
285
+
286
+    /**
287
+     * The install wizard page.
288
+     *
289
+     * @since  3.9.0
290
+     * @access private
291
+     * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
292
+     */
293
+    public $admin_setup;
294
+
295
+    /**
296
+     * The Content Filter Service hooks up to the 'the_content' filter and provides
297
+     * linking of entities to their pages.
298
+     *
299
+     * @since  3.8.0
300
+     * @access private
301
+     * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
302
+     */
303
+    private $content_filter_service;
304
+
305
+    /**
306
+     * The Faq Content filter service
307
+     * @since  3.26.0
308
+     * @access private
309
+     * @var Faq_Content_Filter $faq_content_filter_service A {@link Faq_Content_Filter} instance.
310
+     */
311
+    private $faq_content_filter_service;
312
+
313
+    /**
314
+     * A {@link Wordlift_Key_Validation_Service} instance.
315
+     *
316
+     * @since  3.9.0
317
+     * @access private
318
+     * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
319
+     */
320
+    private $key_validation_service;
321
+
322
+    /**
323
+     * A {@link Wordlift_Rating_Service} instance.
324
+     *
325
+     * @since  3.10.0
326
+     * @access private
327
+     * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
328
+     */
329
+    private $rating_service;
330
+
331
+    /**
332
+     * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
333
+     *
334
+     * @since  3.10.0
335
+     * @access protected
336
+     * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
337
+     */
338
+    protected $post_to_jsonld_converter;
339
+
340
+    /**
341
+     * A {@link Wordlift_Install_Service} instance.
342
+     *
343
+     * @since  3.18.0
344
+     * @access protected
345
+     * @var \Wordlift_Install_Service $install_service A {@link Wordlift_Install_Service} instance.
346
+     */
347
+    protected $install_service;
348
+
349
+    /**
350
+     * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
351
+     *
352
+     * @since  3.10.0
353
+     * @access protected
354
+     * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
355
+     */
356
+    protected $entity_post_to_jsonld_converter;
357
+
358
+    /**
359
+     * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
360
+     *
361
+     * @since  3.10.0
362
+     * @access protected
363
+     * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
364
+     */
365
+    protected $postid_to_jsonld_converter;
366
+
367
+    /**
368
+     * The {@link Wordlift_Category_Taxonomy_Service} instance.
369
+     *
370
+     * @since  3.11.0
371
+     * @access protected
372
+     * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
373
+     */
374
+    protected $category_taxonomy_service;
375
+
376
+    /**
377
+     * The {@link Wordlift_Entity_Page_Service} instance.
378
+     *
379
+     * @since  3.11.0
380
+     * @access protected
381
+     * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
382
+     */
383
+    protected $entity_page_service;
384
+
385
+    /**
386
+     * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
387
+     *
388
+     * @since  3.11.0
389
+     * @access protected
390
+     * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
391
+     */
392
+    protected $settings_page_action_link;
393
+
394
+    /**
395
+     * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
396
+     *
397
+     * @since  3.11.0
398
+     * @access protected
399
+     * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
400
+     */
401
+    protected $analytics_settings_page_action_link;
402
+
403
+    /**
404
+     * The {@link Wordlift_Analytics_Connect} class.
405
+     *
406
+     * @since  3.11.0
407
+     * @access protected
408
+     * @var \Wordlift_Analytics_Connect $analytics_connect The {@link Wordlift_Analytics_Connect} class.
409
+     */
410
+    protected $analytics_connect;
411
+
412
+    /**
413
+     * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
414
+     *
415
+     * @since  3.11.0
416
+     * @access protected
417
+     * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
418
+     */
419
+    protected $publisher_ajax_adapter;
420
+
421
+    /**
422
+     * The {@link Wordlift_Admin_Input_Element} element renderer.
423
+     *
424
+     * @since  3.11.0
425
+     * @access protected
426
+     * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
427
+     */
428
+    protected $input_element;
429
+
430
+    /**
431
+     * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
432
+     *
433
+     * @since  3.13.0
434
+     * @access protected
435
+     * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
436
+     */
437
+    protected $radio_input_element;
438
+
439
+    /**
440
+     * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
441
+     *
442
+     * @since  3.11.0
443
+     * @access protected
444
+     * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
445
+     */
446
+    protected $language_select_element;
447
+
448
+    /**
449
+     * The {@link Wordlift_Admin_Country_Select_Element} element renderer.
450
+     *
451
+     * @since  3.18.0
452
+     * @access protected
453
+     * @var \Wordlift_Admin_Country_Select_Element $country_select_element The {@link Wordlift_Admin_Country_Select_Element} element renderer.
454
+     */
455
+    protected $country_select_element;
456
+
457
+    /**
458
+     * The {@link Wordlift_Admin_Publisher_Element} element renderer.
459
+     *
460
+     * @since  3.11.0
461
+     * @access protected
462
+     * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
463
+     */
464
+    protected $publisher_element;
465
+
466
+    /**
467
+     * The {@link Wordlift_Admin_Select2_Element} element renderer.
468
+     *
469
+     * @since  3.11.0
470
+     * @access protected
471
+     * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
472
+     */
473
+    protected $select2_element;
474
+
475
+    /**
476
+     * The controller for the entity type list admin page
477
+     *
478
+     * @since  3.11.0
479
+     * @access private
480
+     * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
481
+     */
482
+    private $entity_type_admin_page;
483
+
484
+    /**
485
+     * The controller for the entity type settings admin page
486
+     *
487
+     * @since  3.11.0
488
+     * @access private
489
+     * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
490
+     */
491
+    private $entity_type_settings_admin_page;
492
+
493
+    /**
494
+     * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
495
+     *
496
+     * @since  3.11.0
497
+     * @access protected
498
+     * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
499
+     */
500
+    protected $related_entities_cloud_widget;
501
+
502
+    /**
503
+     * The {@link Wordlift_Admin_Author_Element} instance.
504
+     *
505
+     * @since  3.14.0
506
+     * @access protected
507
+     * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
508
+     */
509
+    protected $author_element;
510
+
511
+    /**
512
+     * The {@link Wordlift_Sample_Data_Service} instance.
513
+     *
514
+     * @since  3.12.0
515
+     * @access protected
516
+     * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
517
+     */
518
+    protected $sample_data_service;
519
+
520
+    /**
521
+     * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
522
+     *
523
+     * @since  3.12.0
524
+     * @access protected
525
+     * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
526
+     */
527
+    protected $sample_data_ajax_adapter;
528
+
529
+    /**
530
+     * The {@link Wordlift_Google_Analytics_Export_Service} instance.
531
+     *
532
+     * @since  3.16.0
533
+     * @access protected
534
+     * @var \Wordlift_Google_Analytics_Export_Service $google_analytics_export_service The {@link Wordlift_Google_Analytics_Export_Service} instance.
535
+     */
536
+    protected $google_analytics_export_service;
537
+
538
+    /**
539
+     * {@link Wordlift}'s singleton instance.
540
+     *
541
+     * @since  3.15.0
542
+     * @access protected
543
+     * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
544
+     */
545
+    protected $entity_type_adapter;
546
+
547
+    /**
548
+     * The {@link Wordlift_Storage_Factory} instance.
549
+     *
550
+     * @since  3.15.0
551
+     * @access protected
552
+     * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
553
+     */
554
+    protected $storage_factory;
555
+
556
+    /**
557
+     * The {@link Wordlift_Autocomplete_Adapter} instance.
558
+     *
559
+     * @since  3.15.0
560
+     * @access private
561
+     * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
562
+     */
563
+    private $autocomplete_adapter;
564
+
565
+    /**
566
+     * The {@link Wordlift_Cached_Post_Converter} instance.
567
+     *
568
+     * @since  3.16.0
569
+     * @access protected
570
+     * @var  \Wordlift_Cached_Post_Converter $cached_postid_to_jsonld_converter The {@link Wordlift_Cached_Post_Converter} instance.
571
+     *
572
+     */
573
+    protected $cached_postid_to_jsonld_converter;
574
+
575
+    /**
576
+     * The {@link Wordlift_Entity_Uri_Service} instance.
577
+     *
578
+     * @since  3.16.3
579
+     * @access protected
580
+     * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
581
+     */
582
+    protected $entity_uri_service;
583
+
584
+    /**
585
+     * The {@link Wordlift_Publisher_Service} instance.
586
+     *
587
+     * @since  3.19.0
588
+     * @access protected
589
+     * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance.
590
+     */
591
+    protected $publisher_service;
592
+
593
+    /**
594
+     * The {@link Wordlift_Context_Cards_Service} instance.
595
+     *
596
+     * @var \Wordlift_Context_Cards_Service The {@link Wordlift_Context_Cards_Service} instance.
597
+     */
598
+    protected $context_cards_service;
599
+
600
+    /**
601
+     * {@link Wordlift}'s singleton instance.
602
+     *
603
+     * @since  3.11.2
604
+     * @access private
605
+     * @var Wordlift $instance {@link Wordlift}'s singleton instance.
606
+     */
607
+    private static $instance;
608
+
609
+    /**
610
+     * A singleton instance of features registry.
611
+     * @since 3.30.0
612
+     * @var Features_Registry
613
+     */
614
+    private $features_registry;
615
+
616
+    private $analytics_settings_page;
617
+    //</editor-fold>
618
+
619
+    // Experimental code added by Nishit for feature request 1496
620
+    private $webhook_loader;
621
+    // Experimental code ents here
622
+
623
+    /**
624
+     * Define the core functionality of the plugin.
625
+     *
626
+     * Set the plugin name and the plugin version that can be used throughout the plugin.
627
+     * Load the dependencies, define the locale, and set the hooks for the admin area and
628
+     * the public-facing side of the site.
629
+     *
630
+     * @since    1.0.0
631
+     */
632
+    public function __construct() {
633
+
634
+        self::$instance = $this;
635
+
636
+        $this->plugin_name = 'wordlift';
637
+        $this->version     = '3.35.2';
638
+        $this->load_dependencies();
639
+        $this->set_locale();
640
+
641
+        $that = $this;
642
+        add_action( 'plugins_loaded', function () use ( $that ) {
643
+            $that->define_admin_hooks( $that );
644
+            $that->define_public_hooks( $that );
645
+        }, 4 );
646
+
647
+        // If we're in `WP_CLI` load the related files.
648
+        if ( class_exists( 'WP_CLI' ) ) {
649
+            $this->load_cli_dependencies();
650
+        }
651
+
652
+    }
653
+
654
+    /**
655
+     * Get the singleton instance.
656
+     *
657
+     * @return Wordlift The {@link Wordlift} singleton instance.
658
+     * @since 3.11.2
659
+     *
660
+     */
661
+    public static function get_instance() {
662
+
663
+        return self::$instance;
664
+    }
665
+
666
+    /**
667
+     * Load the required dependencies for this plugin.
668
+     *
669
+     * Include the following files that make up the plugin:
670
+     *
671
+     * - Wordlift_Loader. Orchestrates the hooks of the plugin.
672
+     * - Wordlift_i18n. Defines internationalization functionality.
673
+     * - Wordlift_Admin. Defines all hooks for the admin area.
674
+     * - Wordlift_Public. Defines all hooks for the public side of the site.
675
+     *
676
+     * Create an instance of the loader which will be used to register the hooks
677
+     * with WordPress.
678
+     *
679
+     * @throws Exception
680
+     * @since    1.0.0
681
+     * @access   private
682
+     */
683
+    private function load_dependencies() {
684
+
685
+        /**
686
+         * The class responsible for orchestrating the actions and filters of the
687
+         * core plugin.
688
+         */
689
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
690
+
691
+        // The class responsible for plugin uninstall.
692
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-deactivator-feedback.php';
693
+
694
+        /**
695
+         * The class responsible for defining internationalization functionality
696
+         * of the plugin.
697
+         */
698
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
699
+
700
+        /**
701
+         * WordLift's supported languages.
702
+         */
703
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
704
+
705
+        /**
706
+         * WordLift's supported countries.
707
+         */
708
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-countries.php';
709
+
710
+        /**
711
+         * Provide support functions to sanitize data.
712
+         */
713
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
714
+
715
+        /** Services. */
716
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
717
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-http-api.php';
718
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
719
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
720
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
721
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
722
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
723
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
724
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-image-service.php';
725
+
726
+        /**
727
+         * The Schema service.
728
+         */
729
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
730
+
731
+        /**
732
+         * The schema:url property service.
733
+         */
734
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
735
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
736
+
737
+        /**
738
+         * The UI service.
739
+         */
740
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
741
+
742
+        /**
743
+         * The Entity Types Taxonomy service.
744
+         */
745
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-taxonomy-service.php';
746
+
747
+        /**
748
+         * The Entity service.
749
+         */
750
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-uri-service.php';
751
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
752
+
753
+        // Add the entity rating service.
754
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
755
+
756
+        /**
757
+         * The User service.
758
+         */
759
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
760
+
761
+        /**
762
+         * The Timeline service.
763
+         */
764
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
765
+
766
+        /**
767
+         * The Topic Taxonomy service.
768
+         */
769
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
770
+
771
+        /**
772
+         * The WordLift URI service.
773
+         */
774
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
775
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
776
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
777
+
778
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
779
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
780
+
781
+        /**
782
+         * Load the converters.
783
+         */
784
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
785
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
786
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
787
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
788
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
789
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
790
+
791
+        /**
792
+         * Load cache-related files.
793
+         */
794
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/cache/require.php';
795
+
796
+        /**
797
+         * Load the content filter.
798
+         */
799
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
800
+
801
+        /*
802 802
 		 * Load the excerpt helper.
803 803
 		 */
804
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
805
-
806
-		/**
807
-		 * Load the JSON-LD service to publish entities using JSON-LD.s
808
-		 *
809
-		 * @since 3.8.0
810
-		 */
811
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
812
-
813
-		// The Publisher Service and the AJAX adapter.
814
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
815
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
816
-
817
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
818
-
819
-		/**
820
-		 * Load the WordLift key validation service.
821
-		 */
822
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
823
-
824
-		// Load the `Wordlift_Category_Taxonomy_Service` class definition.
825
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
826
-
827
-		// Load the `Wordlift_Entity_Page_Service` class definition.
828
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
829
-
830
-		/** Linked Data. */
831
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
832
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
833
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
834
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
835
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
836
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
837
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
838
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
839
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
840
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
841
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
842
-
843
-		/** Services. */
844
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
845
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php';
846
-
847
-		/** Adapters. */
848
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
849
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
850
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
851
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
852
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php';
853
-
854
-		/** Autocomplete. */
855
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
856
-
857
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php';
858
-
859
-		/** Analytics */
860
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php';
861
-
862
-		/**
863
-		 * The class responsible for defining all actions that occur in the admin area.
864
-		 */
865
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
866
-
867
-		/**
868
-		 * The class to customize the entity list admin page.
869
-		 */
870
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
871
-
872
-		/**
873
-		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
874
-		 */
875
-		global $wp_version;
876
-		if ( version_compare( $wp_version, '5.3', '<' ) ) {
877
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
878
-		} else {
879
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php';
880
-		}
881
-
882
-		/**
883
-		 * The Notice service.
884
-		 */
885
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
886
-
887
-		/**
888
-		 * The PrimaShop adapter.
889
-		 */
890
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
891
-
892
-		/**
893
-		 * The WordLift Dashboard service.
894
-		 */
895
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
896
-
897
-		/**
898
-		 * The admin 'Install wizard' page.
899
-		 */
900
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
901
-
902
-		/**
903
-		 * The WordLift entity type list admin page controller.
904
-		 */
905
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
906
-
907
-		/**
908
-		 * The WordLift entity type settings admin page controller.
909
-		 */
910
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
911
-
912
-		/**
913
-		 * The admin 'Download Your Data' page.
914
-		 */
915
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
916
-
917
-		/**
918
-		 * The admin 'WordLift Settings' page.
919
-		 */
920
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php';
921
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php';
922
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php';
923
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php';
924
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php';
925
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php';
926
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php';
927
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php';
928
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php';
929
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php';
930
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
931
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
932
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php';
933
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
934
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php';
935
-
936
-		/** Admin Pages */
937
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
938
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
939
-
940
-		/**
941
-		 * The class responsible for defining all actions that occur in the public-facing
942
-		 * side of the site.
943
-		 */
944
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
945
-
946
-		/**
947
-		 * The shortcode abstract class.
948
-		 */
949
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
950
-
951
-		/**
952
-		 * The Timeline shortcode.
953
-		 */
954
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
955
-
956
-		/**
957
-		 * The Navigator shortcode.
958
-		 */
959
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
960
-
961
-		/**
962
-		 * The Products Navigator shortcode.
963
-		 */
964
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php';
965
-
966
-		/**
967
-		 * The chord shortcode.
968
-		 */
969
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
970
-
971
-		/**
972
-		 * The geomap shortcode.
973
-		 */
974
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
975
-
976
-		/**
977
-		 * The entity cloud shortcode.
978
-		 */
979
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
980
-
981
-		/**
982
-		 * The entity glossary shortcode.
983
-		 */
984
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
985
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
986
-
987
-		/**
988
-		 * Faceted Search shortcode.
989
-		 */
990
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php';
991
-
992
-		/**
993
-		 * The ShareThis service.
994
-		 */
995
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
996
-
997
-		/**
998
-		 * The SEO service.
999
-		 */
1000
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1001
-
1002
-		/**
1003
-		 * The AMP service.
1004
-		 */
1005
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1006
-
1007
-		/** Widgets */
1008
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1009
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1010
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php';
1011
-
1012
-		/*
804
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
805
+
806
+        /**
807
+         * Load the JSON-LD service to publish entities using JSON-LD.s
808
+         *
809
+         * @since 3.8.0
810
+         */
811
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
812
+
813
+        // The Publisher Service and the AJAX adapter.
814
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
815
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
816
+
817
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
818
+
819
+        /**
820
+         * Load the WordLift key validation service.
821
+         */
822
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
823
+
824
+        // Load the `Wordlift_Category_Taxonomy_Service` class definition.
825
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
826
+
827
+        // Load the `Wordlift_Entity_Page_Service` class definition.
828
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
829
+
830
+        /** Linked Data. */
831
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
832
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
833
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
834
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
835
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
836
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
837
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
838
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
839
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
840
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
841
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
842
+
843
+        /** Services. */
844
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-google-analytics-export-service.php';
845
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-api-service.php';
846
+
847
+        /** Adapters. */
848
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
849
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
850
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
851
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
852
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-wprocket-adapter.php';
853
+
854
+        /** Autocomplete. */
855
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
856
+
857
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-remote-image-service.php';
858
+
859
+        /** Analytics */
860
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/analytics/class-wordlift-analytics-connect.php';
861
+
862
+        /**
863
+         * The class responsible for defining all actions that occur in the admin area.
864
+         */
865
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
866
+
867
+        /**
868
+         * The class to customize the entity list admin page.
869
+         */
870
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
871
+
872
+        /**
873
+         * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
874
+         */
875
+        global $wp_version;
876
+        if ( version_compare( $wp_version, '5.3', '<' ) ) {
877
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
878
+        } else {
879
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker-5-3.php';
880
+        }
881
+
882
+        /**
883
+         * The Notice service.
884
+         */
885
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
886
+
887
+        /**
888
+         * The PrimaShop adapter.
889
+         */
890
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
891
+
892
+        /**
893
+         * The WordLift Dashboard service.
894
+         */
895
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
896
+
897
+        /**
898
+         * The admin 'Install wizard' page.
899
+         */
900
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
901
+
902
+        /**
903
+         * The WordLift entity type list admin page controller.
904
+         */
905
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
906
+
907
+        /**
908
+         * The WordLift entity type settings admin page controller.
909
+         */
910
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
911
+
912
+        /**
913
+         * The admin 'Download Your Data' page.
914
+         */
915
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
916
+
917
+        /**
918
+         * The admin 'WordLift Settings' page.
919
+         */
920
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/intf-wordlift-admin-element.php';
921
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-element.php';
922
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-input-radio-element.php';
923
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select-element.php';
924
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-select2-element.php';
925
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-language-select-element.php';
926
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-country-select-element.php';
927
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-tabs-element.php';
928
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-author-element.php';
929
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/elements/class-wordlift-admin-publisher-element.php';
930
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
931
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
932
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page.php';
933
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
934
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-analytics-page-action-link.php';
935
+
936
+        /** Admin Pages */
937
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
938
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
939
+
940
+        /**
941
+         * The class responsible for defining all actions that occur in the public-facing
942
+         * side of the site.
943
+         */
944
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
945
+
946
+        /**
947
+         * The shortcode abstract class.
948
+         */
949
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
950
+
951
+        /**
952
+         * The Timeline shortcode.
953
+         */
954
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
955
+
956
+        /**
957
+         * The Navigator shortcode.
958
+         */
959
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
960
+
961
+        /**
962
+         * The Products Navigator shortcode.
963
+         */
964
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-products-navigator-shortcode.php';
965
+
966
+        /**
967
+         * The chord shortcode.
968
+         */
969
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
970
+
971
+        /**
972
+         * The geomap shortcode.
973
+         */
974
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
975
+
976
+        /**
977
+         * The entity cloud shortcode.
978
+         */
979
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
980
+
981
+        /**
982
+         * The entity glossary shortcode.
983
+         */
984
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-alphabet-service.php';
985
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-vocabulary-shortcode.php';
986
+
987
+        /**
988
+         * Faceted Search shortcode.
989
+         */
990
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-faceted-search-shortcode.php';
991
+
992
+        /**
993
+         * The ShareThis service.
994
+         */
995
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
996
+
997
+        /**
998
+         * The SEO service.
999
+         */
1000
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
1001
+
1002
+        /**
1003
+         * The AMP service.
1004
+         */
1005
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1006
+
1007
+        /** Widgets */
1008
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1009
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1010
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-context-cards.php';
1011
+
1012
+        /*
1013 1013
 		 * Batch Operations. They're similar to Batch Actions but do not require working on post types.
1014 1014
 		 *
1015 1015
 		 * Eventually Batch Actions will become Batch Operations.
1016 1016
 		 *
1017 1017
 		 * @since 3.20.0
1018 1018
 		 */
1019
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php';
1020
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php';
1019
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/intf-wordlift-batch-operation.php';
1020
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/batch/class-wordlift-batch-operation-ajax-adapter.php';
1021 1021
 
1022
-		/*
1022
+        /*
1023 1023
 		 * Schema.org Services.
1024 1024
 		 *
1025 1025
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
1026 1026
 		 */
1027
-		if ( WL_ALL_ENTITY_TYPES ) {
1028
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php';
1029
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php';
1030
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php';
1031
-			new Wordlift_Schemaorg_Sync_Service();
1032
-			$schemaorg_property_service = Wordlift_Schemaorg_Property_Service::get_instance();
1033
-			new Wordlift_Schemaorg_Class_Service();
1034
-		} else {
1035
-			$schemaorg_property_service = null;
1036
-		}
1037
-
1038
-		$this->loader = new Wordlift_Loader();
1039
-		/**
1040
-		 * @since 3.30.0
1041
-		 */
1042
-		$this->features_registry = Features_Registry::get_instance();
1043
-
1044
-		// Instantiate a global logger.
1045
-		global $wl_logger;
1046
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1047
-
1048
-		// Load the `wl-api` end-point.
1049
-		new Wordlift_Http_Api();
1050
-
1051
-		// Load the Install Service.
1052
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php';
1053
-		$this->install_service = new Wordlift_Install_Service();
1054
-		$this->notice_service  = new Wordlift_Notice_Service();
1055
-		$this->user_service    = Wordlift_User_Service::get_instance();
1056
-		// create an instance of the entity type list admin page controller.
1057
-		$this->entity_type_admin_page        = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1058
-		$this->topic_taxonomy_service        = new Wordlift_Topic_Taxonomy_Service();
1059
-		$this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service();
1060
-		// Create an entity type service instance. It'll be later bound to the init action.
1061
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service(
1062
-			Wordlift_Entity_Service::TYPE_NAME, Wordlift_Configuration_Service::get_instance()->get_entity_base_path() );
1063
-		/* WordPress Admin. */
1064
-		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page();
1065
-		// create an instance of the entity type setting admin page controller.
1066
-		$this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1067
-
1068
-
1069
-		$that = $this;
1070
-		add_action( 'plugins_loaded', function () use ( &$that, $schemaorg_property_service ) {
1071
-
1072
-			/** Services. */
1073
-			// Create the configuration service.
1074
-			$api_service = new Wordlift_Api_Service();
1075
-
1076
-			// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1077
-			$that->entity_link_service = new Wordlift_Entity_Link_Service( $that->entity_post_type_service, Wordlift_Configuration_Service::get_instance()->get_entity_base_path() );
1078
-
1079
-			$schema_url_property_service = new Wordlift_Schema_Url_Property_Service();
1080
-
1081
-			$that->entity_uri_service = Wordlift_Entity_Uri_Service::get_instance();
1082
-
1083
-			// Create a new instance of the Redirect service.
1084
-			$that->redirect_service = new Wordlift_Redirect_Service( $that->entity_uri_service );
1085
-
1086
-			// Create a new instance of the Timeline service and Timeline shortcode.
1087
-			$that->timeline_service = new Wordlift_Timeline_Service();
1088
-
1089
-			$that->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1090
-
1091
-			// Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1092
-			$that->sharethis_service = new Wordlift_ShareThis_Service();
1093
-
1094
-			// Create an instance of the PrimaShop adapter.
1095
-			$that->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1096
-
1097
-			$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1098
-
1099
-			// Create the entity rating service.
1100
-			$that->rating_service = Wordlift_Rating_Service::get_instance();
1101
-
1102
-			// Create entity list customization (wp-admin/edit.php).
1103
-			$that->entity_list_service = new Wordlift_Entity_List_Service( $that->rating_service );
1104
-
1105
-			// Create an instance of the Publisher Service and the AJAX Adapter.
1106
-			$that->publisher_service = Wordlift_Publisher_Service::get_instance();
1107
-			$that->property_factory  = new Wordlift_Property_Factory( $schema_url_property_service );
1108
-			$that->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1109
-
1110
-			$attachment_service = Wordlift_Attachment_Service::get_instance();
1111
-
1112
-			// Instantiate the JSON-LD service.
1113
-			$property_getter                       = Wordlift_Property_Getter_Factory::create();
1114
-			$that->post_to_jsonld_converter        = new Wordlift_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service );
1115
-			$that->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $that->post_to_jsonld_converter );
1116
-			$that->postid_to_jsonld_converter      = new Wordlift_Postid_To_Jsonld_Converter( $that->entity_post_to_jsonld_converter, $that->post_to_jsonld_converter );
1117
-			$that->jsonld_website_converter        = new Wordlift_Website_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service );
1118
-
1119
-			$jsonld_cache                            = new Ttl_Cache( 'jsonld', 86400 );
1120
-			$that->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $that->postid_to_jsonld_converter, $jsonld_cache );
1121
-			/*
1027
+        if ( WL_ALL_ENTITY_TYPES ) {
1028
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-service.php';
1029
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-property-service.php';
1030
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-class-service.php';
1031
+            new Wordlift_Schemaorg_Sync_Service();
1032
+            $schemaorg_property_service = Wordlift_Schemaorg_Property_Service::get_instance();
1033
+            new Wordlift_Schemaorg_Class_Service();
1034
+        } else {
1035
+            $schemaorg_property_service = null;
1036
+        }
1037
+
1038
+        $this->loader = new Wordlift_Loader();
1039
+        /**
1040
+         * @since 3.30.0
1041
+         */
1042
+        $this->features_registry = Features_Registry::get_instance();
1043
+
1044
+        // Instantiate a global logger.
1045
+        global $wl_logger;
1046
+        $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1047
+
1048
+        // Load the `wl-api` end-point.
1049
+        new Wordlift_Http_Api();
1050
+
1051
+        // Load the Install Service.
1052
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'install/class-wordlift-install-service.php';
1053
+        $this->install_service = new Wordlift_Install_Service();
1054
+        $this->notice_service  = new Wordlift_Notice_Service();
1055
+        $this->user_service    = Wordlift_User_Service::get_instance();
1056
+        // create an instance of the entity type list admin page controller.
1057
+        $this->entity_type_admin_page        = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1058
+        $this->topic_taxonomy_service        = new Wordlift_Topic_Taxonomy_Service();
1059
+        $this->entity_types_taxonomy_service = new Wordlift_Entity_Type_Taxonomy_Service();
1060
+        // Create an entity type service instance. It'll be later bound to the init action.
1061
+        $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service(
1062
+            Wordlift_Entity_Service::TYPE_NAME, Wordlift_Configuration_Service::get_instance()->get_entity_base_path() );
1063
+        /* WordPress Admin. */
1064
+        $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page();
1065
+        // create an instance of the entity type setting admin page controller.
1066
+        $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1067
+
1068
+
1069
+        $that = $this;
1070
+        add_action( 'plugins_loaded', function () use ( &$that, $schemaorg_property_service ) {
1071
+
1072
+            /** Services. */
1073
+            // Create the configuration service.
1074
+            $api_service = new Wordlift_Api_Service();
1075
+
1076
+            // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1077
+            $that->entity_link_service = new Wordlift_Entity_Link_Service( $that->entity_post_type_service, Wordlift_Configuration_Service::get_instance()->get_entity_base_path() );
1078
+
1079
+            $schema_url_property_service = new Wordlift_Schema_Url_Property_Service();
1080
+
1081
+            $that->entity_uri_service = Wordlift_Entity_Uri_Service::get_instance();
1082
+
1083
+            // Create a new instance of the Redirect service.
1084
+            $that->redirect_service = new Wordlift_Redirect_Service( $that->entity_uri_service );
1085
+
1086
+            // Create a new instance of the Timeline service and Timeline shortcode.
1087
+            $that->timeline_service = new Wordlift_Timeline_Service();
1088
+
1089
+            $that->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1090
+
1091
+            // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1092
+            $that->sharethis_service = new Wordlift_ShareThis_Service();
1093
+
1094
+            // Create an instance of the PrimaShop adapter.
1095
+            $that->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1096
+
1097
+            $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1098
+
1099
+            // Create the entity rating service.
1100
+            $that->rating_service = Wordlift_Rating_Service::get_instance();
1101
+
1102
+            // Create entity list customization (wp-admin/edit.php).
1103
+            $that->entity_list_service = new Wordlift_Entity_List_Service( $that->rating_service );
1104
+
1105
+            // Create an instance of the Publisher Service and the AJAX Adapter.
1106
+            $that->publisher_service = Wordlift_Publisher_Service::get_instance();
1107
+            $that->property_factory  = new Wordlift_Property_Factory( $schema_url_property_service );
1108
+            $that->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1109
+
1110
+            $attachment_service = Wordlift_Attachment_Service::get_instance();
1111
+
1112
+            // Instantiate the JSON-LD service.
1113
+            $property_getter                       = Wordlift_Property_Getter_Factory::create();
1114
+            $that->post_to_jsonld_converter        = new Wordlift_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service );
1115
+            $that->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service, $property_getter, $schemaorg_property_service, $that->post_to_jsonld_converter );
1116
+            $that->postid_to_jsonld_converter      = new Wordlift_Postid_To_Jsonld_Converter( $that->entity_post_to_jsonld_converter, $that->post_to_jsonld_converter );
1117
+            $that->jsonld_website_converter        = new Wordlift_Website_Jsonld_Converter( Wordlift_Entity_Type_Service::get_instance(), $that->user_service, $attachment_service );
1118
+
1119
+            $jsonld_cache                            = new Ttl_Cache( 'jsonld', 86400 );
1120
+            $that->cached_postid_to_jsonld_converter = new Wordlift_Cached_Post_Converter( $that->postid_to_jsonld_converter, $jsonld_cache );
1121
+            /*
1122 1122
 			 * Load the `Wordlift_Term_JsonLd_Adapter`.
1123 1123
 			 *
1124 1124
 			 * @see https://github.com/insideout10/wordlift-plugin/issues/892
1125 1125
 			 *
1126 1126
 			 * @since 3.20.0
1127 1127
 			 */
1128
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php';
1129
-
1130
-			$term_jsonld_adapter  = new Wordlift_Term_JsonLd_Adapter( $that->entity_uri_service, $that->cached_postid_to_jsonld_converter );
1131
-			$that->jsonld_service = new Wordlift_Jsonld_Service( Wordlift_Entity_Service::get_instance(), $that->cached_postid_to_jsonld_converter, $that->jsonld_website_converter, $term_jsonld_adapter );
1132
-
1133
-			$jsonld_service = new Jsonld_Service(
1134
-				$that->jsonld_service,
1135
-				$term_jsonld_adapter,
1136
-				new Jsonld_User_Service( $that->user_service ) );
1137
-			new Jsonld_Endpoint( $jsonld_service, $that->entity_uri_service );
1138
-
1139
-			// Prints the JSON-LD in the head.
1140
-			new Jsonld_Adapter( $that->jsonld_service );
1141
-
1142
-			new Jsonld_By_Id_Endpoint( $that->jsonld_service, $that->entity_uri_service );
1143
-
1144
-			$that->key_validation_service = new Wordlift_Key_Validation_Service();
1145
-			$that->content_filter_service = Wordlift_Content_Filter_Service::get_instance();
1146
-			// Creating Faq Content filter service.
1147
-			$that->faq_content_filter_service = new Faq_Content_Filter();
1148
-			$that->sample_data_service        = Wordlift_Sample_Data_Service::get_instance();
1149
-			$that->sample_data_ajax_adapter   = new Wordlift_Sample_Data_Ajax_Adapter( $that->sample_data_service );
1150
-
1151
-			$that->loader->add_action( 'enqueue_block_editor_assets', $that, 'add_wl_enabled_blocks' );
1152
-			$that->loader->add_action( 'admin_enqueue_scripts', $that, 'add_wl_enabled_blocks' );
1153
-
1154
-			/**
1155
-			 * Filter: wl_feature__enable__blocks.
1156
-			 *
1157
-			 * @param bool whether the blocks needed to be registered, defaults to true.
1158
-			 *
1159
-			 * @return bool
1160
-			 * @since 3.27.6
1161
-			 */
1162
-			if ( apply_filters( 'wl_feature__enable__blocks', true ) ) {
1163
-				// Initialize the short-codes.
1164
-				new Async_Template_Decorator( new Wordlift_Navigator_Shortcode() );
1165
-				new Wordlift_Chord_Shortcode();
1166
-				new Wordlift_Geomap_Shortcode();
1167
-				new Wordlift_Timeline_Shortcode();
1168
-				new Wordlift_Related_Entities_Cloud_Shortcode( Wordlift_Relation_Service::get_instance(), Wordlift_Entity_Service::get_instance() );
1169
-				new Wordlift_Vocabulary_Shortcode();
1170
-				new Async_Template_Decorator( new Wordlift_Faceted_Search_Shortcode() );
1171
-			}
1172
-
1173
-			new Wordlift_Products_Navigator_Shortcode();
1174
-
1175
-
1176
-			// Initialize the Context Cards Service
1177
-			$that->context_cards_service = new Wordlift_Context_Cards_Service();
1178
-
1179
-			// Initialize the SEO service.
1180
-			new Wordlift_Seo_Service();
1181
-
1182
-			// Initialize the AMP service.
1183
-			new Wordlift_AMP_Service( $that->jsonld_service );
1184
-
1185
-			/** Services. */
1186
-			$that->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1187
-			new Wordlift_Image_Service();
1188
-
1189
-			/** Adapters. */
1190
-			$that->entity_type_adapter    = new Wordlift_Entity_Type_Adapter( Wordlift_Entity_Type_Service::get_instance() );
1191
-			$that->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $that->publisher_service );
1192
-			$that->tinymce_adapter        = new Wordlift_Tinymce_Adapter( $that );
1193
-
1194
-			/*
1128
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-term-jsonld-adapter.php';
1129
+
1130
+            $term_jsonld_adapter  = new Wordlift_Term_JsonLd_Adapter( $that->entity_uri_service, $that->cached_postid_to_jsonld_converter );
1131
+            $that->jsonld_service = new Wordlift_Jsonld_Service( Wordlift_Entity_Service::get_instance(), $that->cached_postid_to_jsonld_converter, $that->jsonld_website_converter, $term_jsonld_adapter );
1132
+
1133
+            $jsonld_service = new Jsonld_Service(
1134
+                $that->jsonld_service,
1135
+                $term_jsonld_adapter,
1136
+                new Jsonld_User_Service( $that->user_service ) );
1137
+            new Jsonld_Endpoint( $jsonld_service, $that->entity_uri_service );
1138
+
1139
+            // Prints the JSON-LD in the head.
1140
+            new Jsonld_Adapter( $that->jsonld_service );
1141
+
1142
+            new Jsonld_By_Id_Endpoint( $that->jsonld_service, $that->entity_uri_service );
1143
+
1144
+            $that->key_validation_service = new Wordlift_Key_Validation_Service();
1145
+            $that->content_filter_service = Wordlift_Content_Filter_Service::get_instance();
1146
+            // Creating Faq Content filter service.
1147
+            $that->faq_content_filter_service = new Faq_Content_Filter();
1148
+            $that->sample_data_service        = Wordlift_Sample_Data_Service::get_instance();
1149
+            $that->sample_data_ajax_adapter   = new Wordlift_Sample_Data_Ajax_Adapter( $that->sample_data_service );
1150
+
1151
+            $that->loader->add_action( 'enqueue_block_editor_assets', $that, 'add_wl_enabled_blocks' );
1152
+            $that->loader->add_action( 'admin_enqueue_scripts', $that, 'add_wl_enabled_blocks' );
1153
+
1154
+            /**
1155
+             * Filter: wl_feature__enable__blocks.
1156
+             *
1157
+             * @param bool whether the blocks needed to be registered, defaults to true.
1158
+             *
1159
+             * @return bool
1160
+             * @since 3.27.6
1161
+             */
1162
+            if ( apply_filters( 'wl_feature__enable__blocks', true ) ) {
1163
+                // Initialize the short-codes.
1164
+                new Async_Template_Decorator( new Wordlift_Navigator_Shortcode() );
1165
+                new Wordlift_Chord_Shortcode();
1166
+                new Wordlift_Geomap_Shortcode();
1167
+                new Wordlift_Timeline_Shortcode();
1168
+                new Wordlift_Related_Entities_Cloud_Shortcode( Wordlift_Relation_Service::get_instance(), Wordlift_Entity_Service::get_instance() );
1169
+                new Wordlift_Vocabulary_Shortcode();
1170
+                new Async_Template_Decorator( new Wordlift_Faceted_Search_Shortcode() );
1171
+            }
1172
+
1173
+            new Wordlift_Products_Navigator_Shortcode();
1174
+
1175
+
1176
+            // Initialize the Context Cards Service
1177
+            $that->context_cards_service = new Wordlift_Context_Cards_Service();
1178
+
1179
+            // Initialize the SEO service.
1180
+            new Wordlift_Seo_Service();
1181
+
1182
+            // Initialize the AMP service.
1183
+            new Wordlift_AMP_Service( $that->jsonld_service );
1184
+
1185
+            /** Services. */
1186
+            $that->google_analytics_export_service = new Wordlift_Google_Analytics_Export_Service();
1187
+            new Wordlift_Image_Service();
1188
+
1189
+            /** Adapters. */
1190
+            $that->entity_type_adapter    = new Wordlift_Entity_Type_Adapter( Wordlift_Entity_Type_Service::get_instance() );
1191
+            $that->publisher_ajax_adapter = new Wordlift_Publisher_Ajax_Adapter( $that->publisher_service );
1192
+            $that->tinymce_adapter        = new Wordlift_Tinymce_Adapter( $that );
1193
+
1194
+            /*
1195 1195
 			 * Exclude our public js from WP-Rocket.
1196 1196
 			 *
1197 1197
 			 * @since 3.19.4
1198 1198
 			 *
1199 1199
 			 * @see https://github.com/insideout10/wordlift-plugin/issues/842.
1200 1200
 			 */
1201
-			new Wordlift_WpRocket_Adapter();
1201
+            new Wordlift_WpRocket_Adapter();
1202 1202
 
1203
-			/** WordPress Admin UI. */
1203
+            /** WordPress Admin UI. */
1204 1204
 
1205
-			// UI elements.
1206
-			$that->input_element           = new Wordlift_Admin_Input_Element();
1207
-			$that->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1208
-			$that->select2_element         = new Wordlift_Admin_Select2_Element();
1209
-			$that->language_select_element = new Wordlift_Admin_Language_Select_Element();
1210
-			$that->country_select_element  = new Wordlift_Admin_Country_Select_Element();
1211
-			$tabs_element                  = new Wordlift_Admin_Tabs_Element();
1212
-			$that->publisher_element       = new Wordlift_Admin_Publisher_Element( $that->publisher_service, $tabs_element, $that->select2_element );
1213
-			$that->author_element          = new Wordlift_Admin_Author_Element( $that->publisher_service, $that->select2_element );
1205
+            // UI elements.
1206
+            $that->input_element           = new Wordlift_Admin_Input_Element();
1207
+            $that->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1208
+            $that->select2_element         = new Wordlift_Admin_Select2_Element();
1209
+            $that->language_select_element = new Wordlift_Admin_Language_Select_Element();
1210
+            $that->country_select_element  = new Wordlift_Admin_Country_Select_Element();
1211
+            $tabs_element                  = new Wordlift_Admin_Tabs_Element();
1212
+            $that->publisher_element       = new Wordlift_Admin_Publisher_Element( $that->publisher_service, $tabs_element, $that->select2_element );
1213
+            $that->author_element          = new Wordlift_Admin_Author_Element( $that->publisher_service, $that->select2_element );
1214 1214
 
1215
-			$that->settings_page             = Wordlift_Admin_Settings_Page::get_instance();
1216
-			$that->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $that->settings_page );
1215
+            $that->settings_page             = Wordlift_Admin_Settings_Page::get_instance();
1216
+            $that->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $that->settings_page );
1217 1217
 
1218
-			$that->analytics_settings_page             = new Wordlift_Admin_Settings_Analytics_Page( $that->input_element, $that->radio_input_element );
1219
-			$that->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $that->analytics_settings_page );
1220
-			$that->analytics_connect                   = new Wordlift_Analytics_Connect();
1218
+            $that->analytics_settings_page             = new Wordlift_Admin_Settings_Analytics_Page( $that->input_element, $that->radio_input_element );
1219
+            $that->analytics_settings_page_action_link = new Wordlift_Admin_Settings_Analytics_Page_Action_Link( $that->analytics_settings_page );
1220
+            $that->analytics_connect                   = new Wordlift_Analytics_Connect();
1221 1221
 
1222
-			// Pages.
1223
-			/*
1222
+            // Pages.
1223
+            /*
1224 1224
 			 * Call the `wl_can_see_classification_box` filter to determine whether we can display the classification box.
1225 1225
 			 *
1226 1226
 			 * @since 3.20.3
1227 1227
 			 *
1228 1228
 			 * @see https://github.com/insideout10/wordlift-plugin/issues/914
1229 1229
 			 */
1230
-			if ( apply_filters( 'wl_can_see_classification_box', true ) ) {
1231
-				require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
1232
-				new Wordlift_Admin_Post_Edit_Page( $that );
1233
-			}
1234
-			new Wordlift_Entity_Type_Admin_Service();
1230
+            if ( apply_filters( 'wl_can_see_classification_box', true ) ) {
1231
+                require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
1232
+                new Wordlift_Admin_Post_Edit_Page( $that );
1233
+            }
1234
+            new Wordlift_Entity_Type_Admin_Service();
1235 1235
 
1236
-			/** Widgets */
1237
-			$that->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1236
+            /** Widgets */
1237
+            $that->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1238 1238
 
1239
-			// Create an instance of the install wizard.
1240
-			$that->admin_setup = new Wordlift_Admin_Setup( $that->key_validation_service, Wordlift_Entity_Service::get_instance(), $that->language_select_element, $that->country_select_element );
1239
+            // Create an instance of the install wizard.
1240
+            $that->admin_setup = new Wordlift_Admin_Setup( $that->key_validation_service, Wordlift_Entity_Service::get_instance(), $that->language_select_element, $that->country_select_element );
1241 1241
 
1242
-			$that->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $that->entity_post_type_service );
1242
+            $that->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $that->entity_post_type_service );
1243 1243
 
1244
-			// User Profile.
1245
-			new Wordlift_Admin_User_Profile_Page( $that->author_element, $that->user_service );
1244
+            // User Profile.
1245
+            new Wordlift_Admin_User_Profile_Page( $that->author_element, $that->user_service );
1246 1246
 
1247
-			$that->entity_page_service = new Wordlift_Entity_Page_Service();
1247
+            $that->entity_page_service = new Wordlift_Entity_Page_Service();
1248 1248
 
1249
-			// Load the debug service if WP is in debug mode.
1250
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1251
-				require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1252
-				new Wordlift_Debug_Service( Wordlift_Entity_Service::get_instance(), $uri_service );
1253
-			}
1249
+            // Load the debug service if WP is in debug mode.
1250
+            if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1251
+                require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1252
+                new Wordlift_Debug_Service( Wordlift_Entity_Service::get_instance(), $uri_service );
1253
+            }
1254 1254
 
1255
-			// Remote Image Service.
1256
-			new Wordlift_Remote_Image_Service();
1255
+            // Remote Image Service.
1256
+            new Wordlift_Remote_Image_Service();
1257 1257
 
1258
-			/*
1258
+            /*
1259 1259
 			 * Provides mappings between post types and entity types.
1260 1260
 			 *
1261 1261
 			 * @since 3.20.0
1262 1262
 			 *
1263 1263
 			 * @see https://github.com/insideout10/wordlift-plugin/issues/852.
1264 1264
 			 */
1265
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php';
1266
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php';
1267
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php';
1265
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-action.php';
1266
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-service.php';
1267
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/mapping/class-wordlift-mapping-ajax-adapter.php';
1268 1268
 
1269
-			// Create an instance of the Mapping Service and assign it to the Ajax Adapter.
1270
-			new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) );
1269
+            // Create an instance of the Mapping Service and assign it to the Ajax Adapter.
1270
+            new Wordlift_Mapping_Ajax_Adapter( new Wordlift_Mapping_Service( Wordlift_Entity_Type_Service::get_instance() ) );
1271 1271
 
1272
-			/*
1272
+            /*
1273 1273
 			 * Load the Mappings JSON-LD post processing.
1274 1274
 			 *
1275 1275
 			 * @since 3.25.0
1276 1276
 			 */
1277 1277
 
1278
-			$mappings_dbo           = new Mappings_DBO();
1279
-			$default_rule_validator = new Taxonomy_Rule_Validator();
1280
-			new Post_Type_Rule_Validator();
1281
-			// Taxonomy term rule validator for validating rules for term pages.
1282
-			new Taxonomy_Term_Rule_Validator();
1283
-			new Post_Taxonomy_Term_Rule_Validator();
1284
-			$rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator );
1285
-			$rule_groups_validator    = new Rule_Groups_Validator( $rule_validators_registry );
1286
-			$mappings_validator       = new Mappings_Validator( $mappings_dbo, $rule_groups_validator );
1287
-
1288
-			new Url_To_Entity_Transform_Function( $that->entity_uri_service );
1289
-			new Taxonomy_To_Terms_Transform_Function();
1290
-			new Post_Id_To_Entity_Transform_Function();
1291
-			$mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry();
1292
-
1293
-			/**
1294
-			 * @since 3.27.1
1295
-			 * Intiailize the acf group data formatter.
1296
-			 */
1297
-			new Acf_Group_Formatter();
1298
-			new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry );
1299
-
1300
-			/**
1301
-			 * @since 3.26.0
1302
-			 * Initialize the Faq JSON LD converter here - disabled.
1303
-			 */
1304
-			// new Faq_To_Jsonld_Converter();
1305
-			/*
1278
+            $mappings_dbo           = new Mappings_DBO();
1279
+            $default_rule_validator = new Taxonomy_Rule_Validator();
1280
+            new Post_Type_Rule_Validator();
1281
+            // Taxonomy term rule validator for validating rules for term pages.
1282
+            new Taxonomy_Term_Rule_Validator();
1283
+            new Post_Taxonomy_Term_Rule_Validator();
1284
+            $rule_validators_registry = new Rule_Validators_Registry( $default_rule_validator );
1285
+            $rule_groups_validator    = new Rule_Groups_Validator( $rule_validators_registry );
1286
+            $mappings_validator       = new Mappings_Validator( $mappings_dbo, $rule_groups_validator );
1287
+
1288
+            new Url_To_Entity_Transform_Function( $that->entity_uri_service );
1289
+            new Taxonomy_To_Terms_Transform_Function();
1290
+            new Post_Id_To_Entity_Transform_Function();
1291
+            $mappings_transform_functions_registry = new Mappings_Transform_Functions_Registry();
1292
+
1293
+            /**
1294
+             * @since 3.27.1
1295
+             * Intiailize the acf group data formatter.
1296
+             */
1297
+            new Acf_Group_Formatter();
1298
+            new Jsonld_Converter( $mappings_validator, $mappings_transform_functions_registry );
1299
+
1300
+            /**
1301
+             * @since 3.26.0
1302
+             * Initialize the Faq JSON LD converter here - disabled.
1303
+             */
1304
+            // new Faq_To_Jsonld_Converter();
1305
+            /*
1306 1306
 			 * Use the Templates Ajax Endpoint to load HTML templates for the legacy Angular app via admin-ajax.php
1307 1307
 			 * end-point.
1308 1308
 			 *
1309 1309
 			 * @see https://github.com/insideout10/wordlift-plugin/issues/834
1310 1310
 			 * @since 3.24.4
1311 1311
 			 */
1312
-			new Templates_Ajax_Endpoint();
1313
-			// Call this static method to register FAQ routes to rest api - disabled
1314
-			//Faq_Rest_Controller::register_routes();
1315
-
1316
-			$that->storage_factory = new Wordlift_Storage_Factory( Wordlift_Entity_Service::get_instance(), $that->user_service, $property_getter );
1317
-
1318
-			/** WL Autocomplete. */
1319
-			$autocomplete_service       = new All_Autocomplete_Service( array(
1320
-				new Local_Autocomplete_Service(),
1321
-				new Linked_Data_Autocomplete_Service( Entity_Helper::get_instance(), $that->entity_uri_service, Wordlift_Entity_Service::get_instance() ),
1322
-			) );
1323
-			$that->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service );
1324
-
1325
-			/**
1326
-			 * @since 3.27.2
1327
-			 * Integrate the recipe maker jsonld & set recipe
1328
-			 * as default entity type to the wprm_recipe CPT.
1329
-			 */
1330
-			new Recipe_Maker_Post_Type_Hook();
1331
-			$recipe_maker_validation_service = new Recipe_Maker_Validation_Service();
1332
-			new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service );
1333
-			new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service );
1334
-			new Recipe_Maker_Warning( $recipe_maker_validation_service );
1335
-			new Yoast_Jsonld( $recipe_maker_validation_service );
1336
-
1337
-			/**
1338
-			 * @since 3.27.4
1339
-			 * Add the faq duplicate markup hook.
1340
-			 */
1341
-			new Faq_Duplicate_Markup_Remover();
1342
-			/**
1343
-			 * @since 3.33.1
1344
-			 * Remove the duplicate HowTo Markup.
1345
-			 */
1346
-			new How_To_Duplicate_Markup_Remover();
1347
-
1348
-			/**
1349
-			 * @since 3.27.8
1350
-			 * @see https://github.com/insideout10/wordlift-plugin/issues/1248
1351
-			 */
1352
-			new Key_Validation_Notice( $that->key_validation_service, Wordlift_Configuration_Service::get_instance() );
1353
-			/**
1354
-			 * @since 3.28.0
1355
-			 * @see https://github.com/insideout10/wordlift-plugin/issues?q=assignee%3Anaveen17797+is%3Aopen
1356
-			 */
1357
-			new Entity_No_Index_Flag();
1358
-
1359
-			/**
1360
-			 * @since 3.29.0
1361
-			 * @see https://github.com/insideout10/wordlift-plugin/issues/1304
1362
-			 */
1363
-			new Entity_Rest_Service( Wordlift_Entity_Type_Service::get_instance() );
1364
-
1365
-			/**
1366
-			 * Expand author in to references.
1367
-			 * @since 3.30.0
1368
-			 * @see https://github.com/insideout10/wordlift-plugin/issues/1318
1369
-			 */
1370
-
1371
-
1372
-			if ( apply_filters( 'wl_feature__enable__article-wrapper', false ) ) {
1373
-				new Jsonld_Article_Wrapper( Wordlift_Post_To_Jsonld_Converter::get_instance(), $that->cached_postid_to_jsonld_converter );
1374
-			}
1375
-
1376
-
1377
-			if ( apply_filters( 'wl_feature__enable__match-terms', false ) ) {
1378
-				$vocabulary_loader = new Vocabulary_Loader();
1379
-				$vocabulary_loader->init_vocabulary();
1380
-			}
1381
-
1382
-			/**
1383
-			 *Added for feature request 1496 (Webhooks)
1384
-			 */
1385
-			if ( apply_filters( 'wl_feature__enable__webhooks', false ) ) {
1386
-				$that->webhook_loader = new Webhooks_Loader();
1387
-				$that->webhook_loader->init();
1388
-			}
1389
-
1390
-			/**
1391
-			 * @since 3.30.0
1392
-			 * Add a checkbox to user option screen for wordlift admin.
1393
-			 */
1394
-			$wordlift_admin_checkbox = new Admin_User_Option();
1395
-			$wordlift_admin_checkbox->connect_hook();
1396
-
1397
-			/**
1398
-			 * @since 3.31.0
1399
-			 * Init loader class for videoobject.
1400
-			 */
1401
-			$videoobject_loader = new Loader();
1402
-			$videoobject_loader->init_feature();
1403
-
1404
-			/**
1405
-			 * @since 3.35.0
1406
-			 */
1407
-			$google_addon_integration_loader = new \Wordlift\Google_Addon_Integration\Loader();
1408
-			$google_addon_integration_loader->init_feature();
1409
-
1410
-			/**
1411
-			 * @since 3.31.5
1412
-			 * Create configuration endpoint for webapp to configure.
1413
-			 */
1414
-			new Config( $that->admin_setup, $that->key_validation_service );
1415
-			/**
1416
-			 * @since 3.31.7
1417
-			 * Remove duplicate videoobject.
1418
-			 */
1419
-			new Videoobject_Duplicate_Remover();
1420
-			$synonym_loader = new \Wordlift\Synonym\Loader();
1421
-			$synonym_loader->init_feature();
1422
-			/**
1423
-			 * @since 3.32.0
1424
-			 * Create loader for vocabulary terms.
1425
-			 */
1426
-			$vocabulary_terms_loader = new Vocabulary_Terms_Loader( Wordlift_Entity_Type_Service::get_instance(), $property_getter );
1427
-			$vocabulary_terms_loader->init_feature();
1428
-
1429
-			new Entity_Type_Change_Handler(
1430
-				Wordlift_Entity_Service::get_instance(),
1431
-				Wordlift_Entity_Type_Service::get_instance()
1432
-			);
1433
-
1434
-		}, 3 );
1435
-
1436
-
1437
-		new Entity_Type_Setter();
1438
-		$no_editor_analysis_loader = new \Wordlift\No_Editor_Analysis\Loader();
1439
-		$no_editor_analysis_loader->init_feature();
1440
-	}
1441
-
1442
-	/**
1443
-	 * Define the locale for this plugin for internationalization.
1444
-	 *
1445
-	 * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1446
-	 * with WordPress.
1447
-	 *
1448
-	 * @since    1.0.0
1449
-	 * @access   private
1450
-	 */
1451
-	private function set_locale() {
1452
-
1453
-		$plugin_i18n = new Wordlift_i18n();
1454
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
1455
-
1456
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1457
-
1458
-	}
1459
-
1460
-	/**
1461
-	 * Register all of the hooks related to the admin area functionality
1462
-	 * of the plugin.
1463
-	 *
1464
-	 * @since    1.0.0
1465
-	 * @access   private
1466
-	 */
1467
-	private function define_admin_hooks( $that ) {
1468
-		$plugin_admin = new
1469
-		Wordlift_Admin(
1470
-			$that->get_plugin_name(),
1471
-			$that->get_version(),
1472
-			$that->notice_service,
1473
-			$that->user_service
1474
-		);
1475
-
1476
-		$that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1477
-		$that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 );
1478
-
1479
-		// Hook the `admin_init` function to the Admin Setup.
1480
-		Assertions::is_set( $that->admin_setup, '`admin_setup` must be set' );
1481
-		$that->loader->add_action( 'admin_init', $that->admin_setup, 'admin_init' );
1482
-
1483
-		// Hook the admin_init to the settings page.
1484
-		Assertions::is_set( $that->settings_page, '`setting_page` must be set' );
1485
-		$that->loader->add_action( 'admin_init', $that->settings_page, 'admin_init' );
1486
-
1487
-		// Hook the init action to taxonomy services.
1488
-		$that->loader->add_action( 'init', $that->topic_taxonomy_service, 'init', 0 );
1489
-		$that->loader->add_action( 'init', $that->entity_types_taxonomy_service, 'init', 0 );
1490
-
1491
-		// Hook the AJAX wl_timeline action to the Timeline service.
1492
-		$that->loader->add_action( 'wp_ajax_wl_timeline', $that->timeline_service, 'ajax_timeline' );
1493
-
1494
-		// Register custom allowed redirect hosts.
1495
-		$that->loader->add_filter( 'allowed_redirect_hosts', $that->redirect_service, 'allowed_redirect_hosts' );
1496
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1497
-		$that->loader->add_action( 'wp_ajax_wordlift_redirect', $that->redirect_service, 'ajax_redirect' );
1498
-
1499
-		// Hook save_post to the entity service to update custom fields (such as alternate labels).
1500
-		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
1501
-		$that->loader->add_action( 'save_post', Wordlift_Entity_Service::get_instance(), 'save_post', 9, 3 );
1502
-		$that->loader->add_action( 'save_post', $that->rating_service, 'set_rating_for', 20, 1 );
1503
-
1504
-		$that->loader->add_action( 'edit_form_before_permalink', Wordlift_Entity_Service::get_instance(), 'edit_form_before_permalink', 10, 1 );
1505
-		$that->loader->add_action( 'in_admin_header', $that->rating_service, 'in_admin_header' );
1506
-
1507
-		// Entity listing customization (wp-admin/edit.php)
1508
-		// Add custom columns.
1509
-		$that->loader->add_filter( 'manage_entity_posts_columns', $that->entity_list_service, 'register_custom_columns' );
1510
-		// no explicit entity as it prevents handling of other post types.
1511
-		$that->loader->add_filter( 'manage_posts_custom_column', $that->entity_list_service, 'render_custom_columns', 10, 2 );
1512
-		// Add 4W selection.
1513
-		$that->loader->add_action( 'restrict_manage_posts', $that->entity_list_service, 'restrict_manage_posts_classification_scope' );
1514
-		$that->loader->add_filter( 'posts_clauses', $that->entity_list_service, 'posts_clauses_classification_scope' );
1515
-		$that->loader->add_action( 'pre_get_posts', $that->entity_list_service, 'pre_get_posts' );
1516
-		$that->loader->add_action( 'load-edit.php', $that->entity_list_service, 'load_edit' );
1517
-
1518
-		/*
1312
+            new Templates_Ajax_Endpoint();
1313
+            // Call this static method to register FAQ routes to rest api - disabled
1314
+            //Faq_Rest_Controller::register_routes();
1315
+
1316
+            $that->storage_factory = new Wordlift_Storage_Factory( Wordlift_Entity_Service::get_instance(), $that->user_service, $property_getter );
1317
+
1318
+            /** WL Autocomplete. */
1319
+            $autocomplete_service       = new All_Autocomplete_Service( array(
1320
+                new Local_Autocomplete_Service(),
1321
+                new Linked_Data_Autocomplete_Service( Entity_Helper::get_instance(), $that->entity_uri_service, Wordlift_Entity_Service::get_instance() ),
1322
+            ) );
1323
+            $that->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $autocomplete_service );
1324
+
1325
+            /**
1326
+             * @since 3.27.2
1327
+             * Integrate the recipe maker jsonld & set recipe
1328
+             * as default entity type to the wprm_recipe CPT.
1329
+             */
1330
+            new Recipe_Maker_Post_Type_Hook();
1331
+            $recipe_maker_validation_service = new Recipe_Maker_Validation_Service();
1332
+            new Recipe_Maker_Jsonld_Hook( $attachment_service, $recipe_maker_validation_service );
1333
+            new Recipe_Maker_After_Get_Jsonld_Hook( $recipe_maker_validation_service );
1334
+            new Recipe_Maker_Warning( $recipe_maker_validation_service );
1335
+            new Yoast_Jsonld( $recipe_maker_validation_service );
1336
+
1337
+            /**
1338
+             * @since 3.27.4
1339
+             * Add the faq duplicate markup hook.
1340
+             */
1341
+            new Faq_Duplicate_Markup_Remover();
1342
+            /**
1343
+             * @since 3.33.1
1344
+             * Remove the duplicate HowTo Markup.
1345
+             */
1346
+            new How_To_Duplicate_Markup_Remover();
1347
+
1348
+            /**
1349
+             * @since 3.27.8
1350
+             * @see https://github.com/insideout10/wordlift-plugin/issues/1248
1351
+             */
1352
+            new Key_Validation_Notice( $that->key_validation_service, Wordlift_Configuration_Service::get_instance() );
1353
+            /**
1354
+             * @since 3.28.0
1355
+             * @see https://github.com/insideout10/wordlift-plugin/issues?q=assignee%3Anaveen17797+is%3Aopen
1356
+             */
1357
+            new Entity_No_Index_Flag();
1358
+
1359
+            /**
1360
+             * @since 3.29.0
1361
+             * @see https://github.com/insideout10/wordlift-plugin/issues/1304
1362
+             */
1363
+            new Entity_Rest_Service( Wordlift_Entity_Type_Service::get_instance() );
1364
+
1365
+            /**
1366
+             * Expand author in to references.
1367
+             * @since 3.30.0
1368
+             * @see https://github.com/insideout10/wordlift-plugin/issues/1318
1369
+             */
1370
+
1371
+
1372
+            if ( apply_filters( 'wl_feature__enable__article-wrapper', false ) ) {
1373
+                new Jsonld_Article_Wrapper( Wordlift_Post_To_Jsonld_Converter::get_instance(), $that->cached_postid_to_jsonld_converter );
1374
+            }
1375
+
1376
+
1377
+            if ( apply_filters( 'wl_feature__enable__match-terms', false ) ) {
1378
+                $vocabulary_loader = new Vocabulary_Loader();
1379
+                $vocabulary_loader->init_vocabulary();
1380
+            }
1381
+
1382
+            /**
1383
+             *Added for feature request 1496 (Webhooks)
1384
+             */
1385
+            if ( apply_filters( 'wl_feature__enable__webhooks', false ) ) {
1386
+                $that->webhook_loader = new Webhooks_Loader();
1387
+                $that->webhook_loader->init();
1388
+            }
1389
+
1390
+            /**
1391
+             * @since 3.30.0
1392
+             * Add a checkbox to user option screen for wordlift admin.
1393
+             */
1394
+            $wordlift_admin_checkbox = new Admin_User_Option();
1395
+            $wordlift_admin_checkbox->connect_hook();
1396
+
1397
+            /**
1398
+             * @since 3.31.0
1399
+             * Init loader class for videoobject.
1400
+             */
1401
+            $videoobject_loader = new Loader();
1402
+            $videoobject_loader->init_feature();
1403
+
1404
+            /**
1405
+             * @since 3.35.0
1406
+             */
1407
+            $google_addon_integration_loader = new \Wordlift\Google_Addon_Integration\Loader();
1408
+            $google_addon_integration_loader->init_feature();
1409
+
1410
+            /**
1411
+             * @since 3.31.5
1412
+             * Create configuration endpoint for webapp to configure.
1413
+             */
1414
+            new Config( $that->admin_setup, $that->key_validation_service );
1415
+            /**
1416
+             * @since 3.31.7
1417
+             * Remove duplicate videoobject.
1418
+             */
1419
+            new Videoobject_Duplicate_Remover();
1420
+            $synonym_loader = new \Wordlift\Synonym\Loader();
1421
+            $synonym_loader->init_feature();
1422
+            /**
1423
+             * @since 3.32.0
1424
+             * Create loader for vocabulary terms.
1425
+             */
1426
+            $vocabulary_terms_loader = new Vocabulary_Terms_Loader( Wordlift_Entity_Type_Service::get_instance(), $property_getter );
1427
+            $vocabulary_terms_loader->init_feature();
1428
+
1429
+            new Entity_Type_Change_Handler(
1430
+                Wordlift_Entity_Service::get_instance(),
1431
+                Wordlift_Entity_Type_Service::get_instance()
1432
+            );
1433
+
1434
+        }, 3 );
1435
+
1436
+
1437
+        new Entity_Type_Setter();
1438
+        $no_editor_analysis_loader = new \Wordlift\No_Editor_Analysis\Loader();
1439
+        $no_editor_analysis_loader->init_feature();
1440
+    }
1441
+
1442
+    /**
1443
+     * Define the locale for this plugin for internationalization.
1444
+     *
1445
+     * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1446
+     * with WordPress.
1447
+     *
1448
+     * @since    1.0.0
1449
+     * @access   private
1450
+     */
1451
+    private function set_locale() {
1452
+
1453
+        $plugin_i18n = new Wordlift_i18n();
1454
+        $plugin_i18n->set_domain( $this->get_plugin_name() );
1455
+
1456
+        $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1457
+
1458
+    }
1459
+
1460
+    /**
1461
+     * Register all of the hooks related to the admin area functionality
1462
+     * of the plugin.
1463
+     *
1464
+     * @since    1.0.0
1465
+     * @access   private
1466
+     */
1467
+    private function define_admin_hooks( $that ) {
1468
+        $plugin_admin = new
1469
+        Wordlift_Admin(
1470
+            $that->get_plugin_name(),
1471
+            $that->get_version(),
1472
+            $that->notice_service,
1473
+            $that->user_service
1474
+        );
1475
+
1476
+        $that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1477
+        $that->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts', 11 );
1478
+
1479
+        // Hook the `admin_init` function to the Admin Setup.
1480
+        Assertions::is_set( $that->admin_setup, '`admin_setup` must be set' );
1481
+        $that->loader->add_action( 'admin_init', $that->admin_setup, 'admin_init' );
1482
+
1483
+        // Hook the admin_init to the settings page.
1484
+        Assertions::is_set( $that->settings_page, '`setting_page` must be set' );
1485
+        $that->loader->add_action( 'admin_init', $that->settings_page, 'admin_init' );
1486
+
1487
+        // Hook the init action to taxonomy services.
1488
+        $that->loader->add_action( 'init', $that->topic_taxonomy_service, 'init', 0 );
1489
+        $that->loader->add_action( 'init', $that->entity_types_taxonomy_service, 'init', 0 );
1490
+
1491
+        // Hook the AJAX wl_timeline action to the Timeline service.
1492
+        $that->loader->add_action( 'wp_ajax_wl_timeline', $that->timeline_service, 'ajax_timeline' );
1493
+
1494
+        // Register custom allowed redirect hosts.
1495
+        $that->loader->add_filter( 'allowed_redirect_hosts', $that->redirect_service, 'allowed_redirect_hosts' );
1496
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1497
+        $that->loader->add_action( 'wp_ajax_wordlift_redirect', $that->redirect_service, 'ajax_redirect' );
1498
+
1499
+        // Hook save_post to the entity service to update custom fields (such as alternate labels).
1500
+        // We have a priority of 9 because we want to be executed before data is sent to Redlink.
1501
+        $that->loader->add_action( 'save_post', Wordlift_Entity_Service::get_instance(), 'save_post', 9, 3 );
1502
+        $that->loader->add_action( 'save_post', $that->rating_service, 'set_rating_for', 20, 1 );
1503
+
1504
+        $that->loader->add_action( 'edit_form_before_permalink', Wordlift_Entity_Service::get_instance(), 'edit_form_before_permalink', 10, 1 );
1505
+        $that->loader->add_action( 'in_admin_header', $that->rating_service, 'in_admin_header' );
1506
+
1507
+        // Entity listing customization (wp-admin/edit.php)
1508
+        // Add custom columns.
1509
+        $that->loader->add_filter( 'manage_entity_posts_columns', $that->entity_list_service, 'register_custom_columns' );
1510
+        // no explicit entity as it prevents handling of other post types.
1511
+        $that->loader->add_filter( 'manage_posts_custom_column', $that->entity_list_service, 'render_custom_columns', 10, 2 );
1512
+        // Add 4W selection.
1513
+        $that->loader->add_action( 'restrict_manage_posts', $that->entity_list_service, 'restrict_manage_posts_classification_scope' );
1514
+        $that->loader->add_filter( 'posts_clauses', $that->entity_list_service, 'posts_clauses_classification_scope' );
1515
+        $that->loader->add_action( 'pre_get_posts', $that->entity_list_service, 'pre_get_posts' );
1516
+        $that->loader->add_action( 'load-edit.php', $that->entity_list_service, 'load_edit' );
1517
+
1518
+        /*
1519 1519
 		 * If `All Entity Types` is disable, use the radio button Walker.
1520 1520
 		 *
1521 1521
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
1522 1522
 		 */
1523
-		if ( ! WL_ALL_ENTITY_TYPES ) {
1524
-			$that->loader->add_filter( 'wp_terms_checklist_args', $that->entity_types_taxonomy_walker, 'terms_checklist_args' );
1525
-		}
1526
-
1527
-		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1528
-		// entities.
1529
-		$that->loader->add_filter( 'prima_metabox_entity_header_args', $that->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1530
-
1531
-		/**
1532
-		 * Filter: wl_feature__enable__settings-download.
1533
-		 *
1534
-		 * @param bool whether the screens needed to be registered, defaults to true.
1535
-		 *
1536
-		 * @return bool
1537
-		 * @since 3.27.6
1538
-		 */
1539
-		$that->features_registry->register_feature_from_slug( 'settings-download', true, array(
1540
-			$that,
1541
-			'register_screens'
1542
-		) );
1543
-
1544
-
1545
-		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1546
-		$that->loader->add_action( 'wp_ajax_wl_download_your_data', $that->download_your_data_page, 'download_your_data', 10 );
1547
-
1548
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1549
-		$that->loader->add_action( 'wp_ajax_wl_jsonld', $that->jsonld_service, 'get' );
1550
-		$that->loader->add_action( 'admin_post_wl_jsonld', $that->jsonld_service, 'get' );
1551
-		$that->loader->add_action( 'admin_post_nopriv_wl_jsonld', $that->jsonld_service, 'get' );
1552
-
1553
-		// Hook the AJAX wl_validate_key action to the Key Validation service.
1554
-		$that->loader->add_action( 'wp_ajax_wl_validate_key', $that->key_validation_service, 'validate_key' );
1555
-
1556
-		// Hook the AJAX wl_update_country_options action to the countries.
1557
-		$that->loader->add_action( 'wp_ajax_wl_update_country_options', $that->country_select_element, 'get_options_html' );
1558
-
1559
-		$that->loader->add_filter( 'admin_post_thumbnail_html', $that->publisher_service, 'add_featured_image_instruction' );
1560
-
1561
-		// Hook the menu creation on the general wordlift menu creation.
1562
-		/**
1563
-		 * Filter: wl_feature__enable__screens.
1564
-		 *
1565
-		 * @param bool whether the screens needed to be registered, defaults to true.
1566
-		 *
1567
-		 * @return bool
1568
-		 * @since 3.27.6
1569
-		 *
1570
-		 * Since 3.30.0 this feature is registered using registry.
1571
-		 */
1572
-		if ( apply_filters( 'wl_feature__enable__settings-screen', true ) || Admin_User_Option::is_wordlift_admin() ) {
1573
-			add_action( 'wl_admin_menu', array( $that->settings_page, 'admin_menu' ), 10, 2 );
1574
-		}
1575
-
1576
-		// Hook key update.
1577
-		$that->loader->add_action( 'pre_update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'maybe_update_dataset_uri', 10, 2 );
1578
-		$that->loader->add_action( 'update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'update_key', 10, 2 );
1579
-
1580
-		// Add additional action links to the WordLift plugin in the plugins page.
1581
-		$that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->settings_page_action_link, 'action_links', 10, 1 );
1582
-
1583
-		/*
1523
+        if ( ! WL_ALL_ENTITY_TYPES ) {
1524
+            $that->loader->add_filter( 'wp_terms_checklist_args', $that->entity_types_taxonomy_walker, 'terms_checklist_args' );
1525
+        }
1526
+
1527
+        // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1528
+        // entities.
1529
+        $that->loader->add_filter( 'prima_metabox_entity_header_args', $that->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1530
+
1531
+        /**
1532
+         * Filter: wl_feature__enable__settings-download.
1533
+         *
1534
+         * @param bool whether the screens needed to be registered, defaults to true.
1535
+         *
1536
+         * @return bool
1537
+         * @since 3.27.6
1538
+         */
1539
+        $that->features_registry->register_feature_from_slug( 'settings-download', true, array(
1540
+            $that,
1541
+            'register_screens'
1542
+        ) );
1543
+
1544
+
1545
+        // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1546
+        $that->loader->add_action( 'wp_ajax_wl_download_your_data', $that->download_your_data_page, 'download_your_data', 10 );
1547
+
1548
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1549
+        $that->loader->add_action( 'wp_ajax_wl_jsonld', $that->jsonld_service, 'get' );
1550
+        $that->loader->add_action( 'admin_post_wl_jsonld', $that->jsonld_service, 'get' );
1551
+        $that->loader->add_action( 'admin_post_nopriv_wl_jsonld', $that->jsonld_service, 'get' );
1552
+
1553
+        // Hook the AJAX wl_validate_key action to the Key Validation service.
1554
+        $that->loader->add_action( 'wp_ajax_wl_validate_key', $that->key_validation_service, 'validate_key' );
1555
+
1556
+        // Hook the AJAX wl_update_country_options action to the countries.
1557
+        $that->loader->add_action( 'wp_ajax_wl_update_country_options', $that->country_select_element, 'get_options_html' );
1558
+
1559
+        $that->loader->add_filter( 'admin_post_thumbnail_html', $that->publisher_service, 'add_featured_image_instruction' );
1560
+
1561
+        // Hook the menu creation on the general wordlift menu creation.
1562
+        /**
1563
+         * Filter: wl_feature__enable__screens.
1564
+         *
1565
+         * @param bool whether the screens needed to be registered, defaults to true.
1566
+         *
1567
+         * @return bool
1568
+         * @since 3.27.6
1569
+         *
1570
+         * Since 3.30.0 this feature is registered using registry.
1571
+         */
1572
+        if ( apply_filters( 'wl_feature__enable__settings-screen', true ) || Admin_User_Option::is_wordlift_admin() ) {
1573
+            add_action( 'wl_admin_menu', array( $that->settings_page, 'admin_menu' ), 10, 2 );
1574
+        }
1575
+
1576
+        // Hook key update.
1577
+        $that->loader->add_action( 'pre_update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'maybe_update_dataset_uri', 10, 2 );
1578
+        $that->loader->add_action( 'update_option_wl_general_settings', Wordlift_Configuration_Service::get_instance(), 'update_key', 10, 2 );
1579
+
1580
+        // Add additional action links to the WordLift plugin in the plugins page.
1581
+        $that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->settings_page_action_link, 'action_links', 10, 1 );
1582
+
1583
+        /*
1584 1584
 		 * Remove the Analytics Settings link from the plugin page.
1585 1585
 		 *
1586 1586
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/932
1587 1587
 		 * @since 3.21.1
1588 1588
 		 */
1589
-		// $that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->analytics_settings_page_action_link, 'action_links', 10, 1 );
1590
-
1591
-		// Hook the AJAX `wl_publisher` action name.
1592
-		$that->loader->add_action( 'wp_ajax_wl_publisher', $that->publisher_ajax_adapter, 'publisher' );
1593
-
1594
-		// Hook row actions for the entity type list admin.
1595
-		$that->loader->add_filter( 'wl_entity_type_row_actions', $that->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1596
-
1597
-		/** Ajax actions. */
1598
-		$that->loader->add_action( 'wp_ajax_wl_google_analytics_export', $that->google_analytics_export_service, 'export' );
1599
-
1600
-		// Hook capabilities manipulation to allow access to entity type admin
1601
-		// page  on WordPress versions before 4.7.
1602
-		global $wp_version;
1603
-		if ( version_compare( $wp_version, '4.7', '<' ) ) {
1604
-			$that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1605
-		}
1606
-
1607
-		/** Adapters. */
1608
-		$that->loader->add_filter( 'mce_external_plugins', $that->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1609
-		/**
1610
-		 * Disabling Faq temporarily.
1611
-		 * Load the tinymce editor button on the tool bar.
1612
-		 * @since 3.26.0
1613
-		 */
1614
-		//$that->loader->add_filter( 'tiny_mce_before_init', $that->faq_tinymce_adapter, 'register_custom_tags' );
1615
-		//$that->loader->add_filter( 'mce_buttons', $that->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 );
1616
-		//$that->loader->add_filter( 'mce_external_plugins', $that->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 );
1617
-
1618
-
1619
-		$that->loader->add_action( 'wp_ajax_wl_sample_data_create', $that->sample_data_ajax_adapter, 'create' );
1620
-		$that->loader->add_action( 'wp_ajax_wl_sample_data_delete', $that->sample_data_ajax_adapter, 'delete' );
1621
-
1622
-		/**
1623
-		 * @since 3.26.0
1624
-		 */
1625
-		$excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter();
1626
-		$that->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' );
1627
-		// Adding Rest route for the post excerpt
1628
-		Post_Excerpt_Rest_Controller::register_routes();
1629
-
1630
-		// Handle the autocomplete request.
1631
-		add_action( 'wp_ajax_wl_autocomplete', array(
1632
-			$that->autocomplete_adapter,
1633
-			'wl_autocomplete',
1634
-		) );
1635
-		add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1636
-			$that->autocomplete_adapter,
1637
-			'wl_autocomplete',
1638
-		) );
1639
-
1640
-		// Hooks to restrict multisite super admin from manipulating entity types.
1641
-		if ( is_multisite() ) {
1642
-			$that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1643
-		}
1644
-
1645
-		$deactivator_feedback = new Wordlift_Deactivator_Feedback();
1646
-
1647
-		add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) );
1648
-		add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) );
1649
-		add_action( 'wp_ajax_wl_deactivation_feedback', array(
1650
-			$deactivator_feedback,
1651
-			'wl_deactivation_feedback'
1652
-		) );
1653
-
1654
-		/**
1655
-		 * Always allow the `wordlift/classification` block.
1656
-		 *
1657
-		 * @since 3.23.0
1658
-		 */
1659
-		add_filter( 'allowed_block_types', function ( $value ) {
1660
-
1661
-			if ( true === $value ) {
1662
-				return $value;
1663
-			}
1664
-
1665
-			return array_merge( (array) $value, array( 'wordlift/classification' ) );
1666
-		}, PHP_INT_MAX );
1667
-
1668
-		/**
1669
-		 * @since 3.27.7
1670
-		 * @see https://github.com/insideout10/wordlift-plugin/issues/1214
1671
-		 */
1672
-		new Top_Entities();
1673
-
1674
-	}
1675
-
1676
-	/**
1677
-	 * Register all of the hooks related to the public-facing functionality
1678
-	 * of the plugin.
1679
-	 *
1680
-	 * @since    1.0.0
1681
-	 * @access   private
1682
-	 */
1683
-	private function define_public_hooks( $that ) {
1684
-
1685
-		$plugin_public = new Wordlift_Public( $that->get_plugin_name(), $that->get_version() );
1686
-
1687
-		// Register the entity post type.
1688
-		$that->loader->add_action( 'init', $that->entity_post_type_service, 'register' );
1689
-
1690
-		// Bind the link generation and handling hooks to the entity link service.
1691
-		$that->loader->add_filter( 'post_type_link', $that->entity_link_service, 'post_type_link', 10, 4 );
1692
-		$that->loader->add_action( 'pre_get_posts', $that->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1693
-		// $that->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $that->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 );
1694
-		// $that->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $that->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 );
1695
-
1696
-		$that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1697
-		$that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1698
-		$that->loader->add_action( 'wp_enqueue_scripts', $that->context_cards_service, 'enqueue_scripts' );
1699
-
1700
-		// Registering Faq_Content_Filter service used for removing faq question and answer tags from the html.
1701
-		$that->loader->add_filter( 'the_content', $that->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' );
1702
-		// Hook the content filter service to add entity links.
1703
-		if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1704
-			$that->loader->add_filter( 'the_content', $that->content_filter_service, 'the_content' );
1705
-		}
1706
-
1707
-		// Hook the AJAX wl_timeline action to the Timeline service.
1708
-		$that->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $that->timeline_service, 'ajax_timeline' );
1709
-
1710
-		// Hook the ShareThis service.
1711
-		$that->loader->add_filter( 'the_content', $that->sharethis_service, 'the_content', 99 );
1712
-		$that->loader->add_filter( 'the_excerpt', $that->sharethis_service, 'the_excerpt', 99 );
1713
-
1714
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1715
-		$that->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $that->jsonld_service, 'get' );
1716
-
1717
-		// Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1718
-		// in order to tweak WP's `WP_Query` to include entities in queries related
1719
-		// to categories.
1720
-		$that->loader->add_action( 'pre_get_posts', $that->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1721
-
1722
-		/*
1589
+        // $that->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $that->analytics_settings_page_action_link, 'action_links', 10, 1 );
1590
+
1591
+        // Hook the AJAX `wl_publisher` action name.
1592
+        $that->loader->add_action( 'wp_ajax_wl_publisher', $that->publisher_ajax_adapter, 'publisher' );
1593
+
1594
+        // Hook row actions for the entity type list admin.
1595
+        $that->loader->add_filter( 'wl_entity_type_row_actions', $that->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1596
+
1597
+        /** Ajax actions. */
1598
+        $that->loader->add_action( 'wp_ajax_wl_google_analytics_export', $that->google_analytics_export_service, 'export' );
1599
+
1600
+        // Hook capabilities manipulation to allow access to entity type admin
1601
+        // page  on WordPress versions before 4.7.
1602
+        global $wp_version;
1603
+        if ( version_compare( $wp_version, '4.7', '<' ) ) {
1604
+            $that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1605
+        }
1606
+
1607
+        /** Adapters. */
1608
+        $that->loader->add_filter( 'mce_external_plugins', $that->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1609
+        /**
1610
+         * Disabling Faq temporarily.
1611
+         * Load the tinymce editor button on the tool bar.
1612
+         * @since 3.26.0
1613
+         */
1614
+        //$that->loader->add_filter( 'tiny_mce_before_init', $that->faq_tinymce_adapter, 'register_custom_tags' );
1615
+        //$that->loader->add_filter( 'mce_buttons', $that->faq_tinymce_adapter, 'register_faq_toolbar_button', 10, 1 );
1616
+        //$that->loader->add_filter( 'mce_external_plugins', $that->faq_tinymce_adapter, 'register_faq_tinymce_plugin', 10, 1 );
1617
+
1618
+
1619
+        $that->loader->add_action( 'wp_ajax_wl_sample_data_create', $that->sample_data_ajax_adapter, 'create' );
1620
+        $that->loader->add_action( 'wp_ajax_wl_sample_data_delete', $that->sample_data_ajax_adapter, 'delete' );
1621
+
1622
+        /**
1623
+         * @since 3.26.0
1624
+         */
1625
+        $excerpt_adapter = new Post_Excerpt_Meta_Box_Adapter();
1626
+        $that->loader->add_action( 'do_meta_boxes', $excerpt_adapter, 'replace_post_excerpt_meta_box' );
1627
+        // Adding Rest route for the post excerpt
1628
+        Post_Excerpt_Rest_Controller::register_routes();
1629
+
1630
+        // Handle the autocomplete request.
1631
+        add_action( 'wp_ajax_wl_autocomplete', array(
1632
+            $that->autocomplete_adapter,
1633
+            'wl_autocomplete',
1634
+        ) );
1635
+        add_action( 'wp_ajax_nopriv_wl_autocomplete', array(
1636
+            $that->autocomplete_adapter,
1637
+            'wl_autocomplete',
1638
+        ) );
1639
+
1640
+        // Hooks to restrict multisite super admin from manipulating entity types.
1641
+        if ( is_multisite() ) {
1642
+            $that->loader->add_filter( 'map_meta_cap', $that->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1643
+        }
1644
+
1645
+        $deactivator_feedback = new Wordlift_Deactivator_Feedback();
1646
+
1647
+        add_action( 'admin_footer', array( $deactivator_feedback, 'render_feedback_popup' ) );
1648
+        add_action( 'admin_enqueue_scripts', array( $deactivator_feedback, 'enqueue_popup_scripts' ) );
1649
+        add_action( 'wp_ajax_wl_deactivation_feedback', array(
1650
+            $deactivator_feedback,
1651
+            'wl_deactivation_feedback'
1652
+        ) );
1653
+
1654
+        /**
1655
+         * Always allow the `wordlift/classification` block.
1656
+         *
1657
+         * @since 3.23.0
1658
+         */
1659
+        add_filter( 'allowed_block_types', function ( $value ) {
1660
+
1661
+            if ( true === $value ) {
1662
+                return $value;
1663
+            }
1664
+
1665
+            return array_merge( (array) $value, array( 'wordlift/classification' ) );
1666
+        }, PHP_INT_MAX );
1667
+
1668
+        /**
1669
+         * @since 3.27.7
1670
+         * @see https://github.com/insideout10/wordlift-plugin/issues/1214
1671
+         */
1672
+        new Top_Entities();
1673
+
1674
+    }
1675
+
1676
+    /**
1677
+     * Register all of the hooks related to the public-facing functionality
1678
+     * of the plugin.
1679
+     *
1680
+     * @since    1.0.0
1681
+     * @access   private
1682
+     */
1683
+    private function define_public_hooks( $that ) {
1684
+
1685
+        $plugin_public = new Wordlift_Public( $that->get_plugin_name(), $that->get_version() );
1686
+
1687
+        // Register the entity post type.
1688
+        $that->loader->add_action( 'init', $that->entity_post_type_service, 'register' );
1689
+
1690
+        // Bind the link generation and handling hooks to the entity link service.
1691
+        $that->loader->add_filter( 'post_type_link', $that->entity_link_service, 'post_type_link', 10, 4 );
1692
+        $that->loader->add_action( 'pre_get_posts', $that->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1693
+        // $that->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $that->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 );
1694
+        // $that->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $that->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 );
1695
+
1696
+        $that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1697
+        $that->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1698
+        $that->loader->add_action( 'wp_enqueue_scripts', $that->context_cards_service, 'enqueue_scripts' );
1699
+
1700
+        // Registering Faq_Content_Filter service used for removing faq question and answer tags from the html.
1701
+        $that->loader->add_filter( 'the_content', $that->faq_content_filter_service, 'remove_all_faq_question_and_answer_tags' );
1702
+        // Hook the content filter service to add entity links.
1703
+        if ( ! defined( 'WL_DISABLE_CONTENT_FILTER' ) || ! WL_DISABLE_CONTENT_FILTER ) {
1704
+            $that->loader->add_filter( 'the_content', $that->content_filter_service, 'the_content' );
1705
+        }
1706
+
1707
+        // Hook the AJAX wl_timeline action to the Timeline service.
1708
+        $that->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $that->timeline_service, 'ajax_timeline' );
1709
+
1710
+        // Hook the ShareThis service.
1711
+        $that->loader->add_filter( 'the_content', $that->sharethis_service, 'the_content', 99 );
1712
+        $that->loader->add_filter( 'the_excerpt', $that->sharethis_service, 'the_excerpt', 99 );
1713
+
1714
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1715
+        $that->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $that->jsonld_service, 'get' );
1716
+
1717
+        // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1718
+        // in order to tweak WP's `WP_Query` to include entities in queries related
1719
+        // to categories.
1720
+        $that->loader->add_action( 'pre_get_posts', $that->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1721
+
1722
+        /*
1723 1723
 		 * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service`
1724 1724
 		 * in order to tweak WP's `WP_Query` to show event related entities in reverse
1725 1725
 		 * order of start time.
1726 1726
 		 */
1727
-		$that->loader->add_action( 'pre_get_posts', $that->entity_page_service, 'pre_get_posts', 10, 1 );
1728
-
1729
-		// This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1730
-		$that->loader->add_action( 'save_post', $that->entity_type_adapter, 'save_post', 9, 3 );
1731
-
1732
-		// Analytics Script Frontend.
1733
-		if ( apply_filters( 'wl_feature__enable__analytics', true ) && Wordlift_Configuration_Service::get_instance()->is_analytics_enable() ) {
1734
-			$that->loader->add_action( 'wp_enqueue_scripts', $that->analytics_connect, 'enqueue_scripts', 10 );
1735
-		}
1736
-
1737
-	}
1738
-
1739
-	/**
1740
-	 * Run the loader to execute all of the hooks with WordPress.
1741
-	 *
1742
-	 * @since    1.0.0
1743
-	 */
1744
-	public function run() {
1745
-		$this->loader->run();
1746
-	}
1747
-
1748
-	/**
1749
-	 * The name of the plugin used to uniquely identify it within the context of
1750
-	 * WordPress and to define internationalization functionality.
1751
-	 *
1752
-	 * @return    string    The name of the plugin.
1753
-	 * @since     1.0.0
1754
-	 */
1755
-	public function get_plugin_name() {
1756
-		return $this->plugin_name;
1757
-	}
1758
-
1759
-	/**
1760
-	 * The reference to the class that orchestrates the hooks with the plugin.
1761
-	 *
1762
-	 * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1763
-	 * @since     1.0.0
1764
-	 */
1765
-	public function get_loader() {
1766
-		return $this->loader;
1767
-	}
1768
-
1769
-	/**
1770
-	 * Retrieve the version number of the plugin.
1771
-	 *
1772
-	 * @return    string    The version number of the plugin.
1773
-	 * @since     1.0.0
1774
-	 */
1775
-	public function get_version() {
1776
-		return $this->version;
1777
-	}
1778
-
1779
-	/**
1780
-	 * Load dependencies for WP-CLI.
1781
-	 *
1782
-	 * @throws Exception
1783
-	 * @since 3.18.0
1784
-	 */
1785
-	private function load_cli_dependencies() {
1786
-
1787
-	}
1788
-
1789
-	public function add_wl_enabled_blocks() {
1790
-		/**
1791
-		 * Filter: wl_feature__enable__blocks.
1792
-		 *
1793
-		 * @param bool whether the blocks needed to be registered, defaults to true.
1794
-		 *
1795
-		 * @return bool
1796
-		 * @since 3.27.6
1797
-		 */
1798
-
1799
-		wp_register_script( 'wl_enabled_blocks', false );
1800
-
1801
-		$enabled_blocks = array();
1802
-
1803
-		/**
1804
-		 * Filter name: wl_feature__enable__product-navigator
1805
-		 * @since 3.32.3
1806
-		 */
1807
-		if ( apply_filters( 'wl_feature__enable__product-navigator', true ) ) {
1808
-			$enabled_blocks[] = 'wordlift/products-navigator';
1809
-		}
1810
-
1811
-		if ( apply_filters( 'wl_feature__enable__blocks', true ) ) {
1812
-			// To intimate JS
1813
-			$enabled_blocks = array_merge( $enabled_blocks, array(
1814
-				'wordlift/navigator',
1815
-				'wordlift/chord',
1816
-				'wordlift/geomap',
1817
-				'wordlift/timeline',
1818
-				'wordlift/cloud',
1819
-				'wordlift/vocabulary',
1820
-				'wordlift/faceted-search'
1821
-			) );
1822
-		}
1823
-
1824
-		wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks );
1825
-		wp_enqueue_script( 'wl_enabled_blocks' );
1826
-	}
1827
-
1828
-	/**
1829
-	 * Register screens based on the filter.
1830
-	 */
1831
-	public function register_screens() {
1832
-		// Hook the menu to the Download Your Data page.
1833
-		if ( apply_filters( 'wl_feature__enable__settings-download', true ) ) {
1834
-			Assertions::is_set( $this->download_your_data_page, "`download_your_data_page` can't be null" );
1835
-			add_action( 'admin_menu', array( $this->download_your_data_page, 'admin_menu' ), 100, 0 );
1836
-		}
1837
-
1838
-		Assertions::is_set( $this->entity_type_settings_admin_page, "`entity_type_settings_admin_page` can't be null" );
1839
-		add_action( 'admin_menu', array( $this->entity_type_settings_admin_page, 'admin_menu' ), 100, 0 );
1840
-
1841
-	}
1727
+        $that->loader->add_action( 'pre_get_posts', $that->entity_page_service, 'pre_get_posts', 10, 1 );
1728
+
1729
+        // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1730
+        $that->loader->add_action( 'save_post', $that->entity_type_adapter, 'save_post', 9, 3 );
1731
+
1732
+        // Analytics Script Frontend.
1733
+        if ( apply_filters( 'wl_feature__enable__analytics', true ) && Wordlift_Configuration_Service::get_instance()->is_analytics_enable() ) {
1734
+            $that->loader->add_action( 'wp_enqueue_scripts', $that->analytics_connect, 'enqueue_scripts', 10 );
1735
+        }
1736
+
1737
+    }
1738
+
1739
+    /**
1740
+     * Run the loader to execute all of the hooks with WordPress.
1741
+     *
1742
+     * @since    1.0.0
1743
+     */
1744
+    public function run() {
1745
+        $this->loader->run();
1746
+    }
1747
+
1748
+    /**
1749
+     * The name of the plugin used to uniquely identify it within the context of
1750
+     * WordPress and to define internationalization functionality.
1751
+     *
1752
+     * @return    string    The name of the plugin.
1753
+     * @since     1.0.0
1754
+     */
1755
+    public function get_plugin_name() {
1756
+        return $this->plugin_name;
1757
+    }
1758
+
1759
+    /**
1760
+     * The reference to the class that orchestrates the hooks with the plugin.
1761
+     *
1762
+     * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1763
+     * @since     1.0.0
1764
+     */
1765
+    public function get_loader() {
1766
+        return $this->loader;
1767
+    }
1768
+
1769
+    /**
1770
+     * Retrieve the version number of the plugin.
1771
+     *
1772
+     * @return    string    The version number of the plugin.
1773
+     * @since     1.0.0
1774
+     */
1775
+    public function get_version() {
1776
+        return $this->version;
1777
+    }
1778
+
1779
+    /**
1780
+     * Load dependencies for WP-CLI.
1781
+     *
1782
+     * @throws Exception
1783
+     * @since 3.18.0
1784
+     */
1785
+    private function load_cli_dependencies() {
1786
+
1787
+    }
1788
+
1789
+    public function add_wl_enabled_blocks() {
1790
+        /**
1791
+         * Filter: wl_feature__enable__blocks.
1792
+         *
1793
+         * @param bool whether the blocks needed to be registered, defaults to true.
1794
+         *
1795
+         * @return bool
1796
+         * @since 3.27.6
1797
+         */
1798
+
1799
+        wp_register_script( 'wl_enabled_blocks', false );
1800
+
1801
+        $enabled_blocks = array();
1802
+
1803
+        /**
1804
+         * Filter name: wl_feature__enable__product-navigator
1805
+         * @since 3.32.3
1806
+         */
1807
+        if ( apply_filters( 'wl_feature__enable__product-navigator', true ) ) {
1808
+            $enabled_blocks[] = 'wordlift/products-navigator';
1809
+        }
1810
+
1811
+        if ( apply_filters( 'wl_feature__enable__blocks', true ) ) {
1812
+            // To intimate JS
1813
+            $enabled_blocks = array_merge( $enabled_blocks, array(
1814
+                'wordlift/navigator',
1815
+                'wordlift/chord',
1816
+                'wordlift/geomap',
1817
+                'wordlift/timeline',
1818
+                'wordlift/cloud',
1819
+                'wordlift/vocabulary',
1820
+                'wordlift/faceted-search'
1821
+            ) );
1822
+        }
1823
+
1824
+        wp_localize_script( 'wl_enabled_blocks', 'wlEnabledBlocks', $enabled_blocks );
1825
+        wp_enqueue_script( 'wl_enabled_blocks' );
1826
+    }
1827
+
1828
+    /**
1829
+     * Register screens based on the filter.
1830
+     */
1831
+    public function register_screens() {
1832
+        // Hook the menu to the Download Your Data page.
1833
+        if ( apply_filters( 'wl_feature__enable__settings-download', true ) ) {
1834
+            Assertions::is_set( $this->download_your_data_page, "`download_your_data_page` can't be null" );
1835
+            add_action( 'admin_menu', array( $this->download_your_data_page, 'admin_menu' ), 100, 0 );
1836
+        }
1837
+
1838
+        Assertions::is_set( $this->entity_type_settings_admin_page, "`entity_type_settings_admin_page` can't be null" );
1839
+        add_action( 'admin_menu', array( $this->entity_type_settings_admin_page, 'admin_menu' ), 100, 0 );
1840
+
1841
+    }
1842 1842
 
1843 1843
 }
Please login to merge, or discard this patch.
src/modules/linked_data/wordlift_linked_data.php 2 patches
Indentation   +425 added lines, -425 removed lines patch added patch discarded remove patch
@@ -22,62 +22,62 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function wl_linked_data_save_post( $post_id ) {
24 24
 
25
-	$log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post' );
26
-
27
-	$log->trace( "Saving post $post_id to Linked Data..." );
28
-
29
-	// If it's not numeric exit from here.
30
-	if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) {
31
-		$log->debug( "Skipping $post_id, because id is not numeric or is a post revision." );
32
-
33
-		return;
34
-	}
35
-
36
-	// Get the post type and check whether it supports the editor.
37
-	//
38
-	// @see https://github.com/insideout10/wordlift-plugin/issues/659.
39
-	$post_type = get_post_type( $post_id );
40
-	/**
41
-	 * Use `wl_post_type_supports_editor` which calls a filter to allow 3rd parties to change the setting.
42
-	 *
43
-	 * @since 3.19.4
44
-	 *
45
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/847.
46
-	 */
47
-	$is_editor_supported = wl_post_type_supports_editor( $post_type );
48
-
49
-	$is_no_editor_analysis_enabled = Wordlift\No_Editor_Analysis\No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( $post_id );
50
-	// Bail out if it's not an entity.
51
-	if ( ! $is_editor_supported
52
-	     && ! $is_no_editor_analysis_enabled ) {
53
-		$log->debug( "Skipping $post_id, because $post_type doesn't support the editor (content)." );
54
-
55
-		return;
56
-	}
57
-
58
-	/**
59
-	 * Only process valid post types
60
-	 *
61
-	 * @since 3.25.6
62
-	 *
63
-	 */
64
-	$supported_types = Wordlift_Entity_Service::valid_entity_post_types();
65
-
66
-	// Bail out if it's not a valid entity.
67
-	if ( ! in_array( $post_type, $supported_types ) && ! $is_no_editor_analysis_enabled ) {
68
-		$log->debug( "Skipping $post_id, because $post_type is not a valid entity." );
69
-
70
-		return;
71
-	}
72
-
73
-	// Unhook this function so it doesn't loop infinitely.
74
-	remove_action( 'save_post', 'wl_linked_data_save_post' );
75
-
76
-	// raise the *wl_linked_data_save_post* event.
77
-	do_action( 'wl_linked_data_save_post', $post_id );
78
-
79
-	// Re-hook this function.
80
-	add_action( 'save_post', 'wl_linked_data_save_post' );
25
+    $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post' );
26
+
27
+    $log->trace( "Saving post $post_id to Linked Data..." );
28
+
29
+    // If it's not numeric exit from here.
30
+    if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) {
31
+        $log->debug( "Skipping $post_id, because id is not numeric or is a post revision." );
32
+
33
+        return;
34
+    }
35
+
36
+    // Get the post type and check whether it supports the editor.
37
+    //
38
+    // @see https://github.com/insideout10/wordlift-plugin/issues/659.
39
+    $post_type = get_post_type( $post_id );
40
+    /**
41
+     * Use `wl_post_type_supports_editor` which calls a filter to allow 3rd parties to change the setting.
42
+     *
43
+     * @since 3.19.4
44
+     *
45
+     * @see https://github.com/insideout10/wordlift-plugin/issues/847.
46
+     */
47
+    $is_editor_supported = wl_post_type_supports_editor( $post_type );
48
+
49
+    $is_no_editor_analysis_enabled = Wordlift\No_Editor_Analysis\No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( $post_id );
50
+    // Bail out if it's not an entity.
51
+    if ( ! $is_editor_supported
52
+         && ! $is_no_editor_analysis_enabled ) {
53
+        $log->debug( "Skipping $post_id, because $post_type doesn't support the editor (content)." );
54
+
55
+        return;
56
+    }
57
+
58
+    /**
59
+     * Only process valid post types
60
+     *
61
+     * @since 3.25.6
62
+     *
63
+     */
64
+    $supported_types = Wordlift_Entity_Service::valid_entity_post_types();
65
+
66
+    // Bail out if it's not a valid entity.
67
+    if ( ! in_array( $post_type, $supported_types ) && ! $is_no_editor_analysis_enabled ) {
68
+        $log->debug( "Skipping $post_id, because $post_type is not a valid entity." );
69
+
70
+        return;
71
+    }
72
+
73
+    // Unhook this function so it doesn't loop infinitely.
74
+    remove_action( 'save_post', 'wl_linked_data_save_post' );
75
+
76
+    // raise the *wl_linked_data_save_post* event.
77
+    do_action( 'wl_linked_data_save_post', $post_id );
78
+
79
+    // Re-hook this function.
80
+    add_action( 'save_post', 'wl_linked_data_save_post' );
81 81
 }
82 82
 
83 83
 add_action( 'save_post', 'wl_linked_data_save_post' );
@@ -92,184 +92,184 @@  discard block
 block discarded – undo
92 92
  */
93 93
 function wl_linked_data_save_post_and_related_entities( $post_id ) {
94 94
 
95
-	$log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post_and_related_entities' );
95
+    $log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post_and_related_entities' );
96 96
 
97
-	$log->trace( "Saving $post_id to Linked Data along with related entities..." );
97
+    $log->trace( "Saving $post_id to Linked Data along with related entities..." );
98 98
 
99
-	// Ignore auto-saves
100
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
101
-		$log->trace( 'Doing autosave, skipping...' );
102
-
103
-		return;
104
-	}
105
-
106
-	// get the current post.
107
-	$post = get_post( $post_id );
108
-
109
-	remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
110
-
111
-	// wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" );
112
-
113
-	// Get the entity service instance.
114
-	$entity_service  = Wordlift_Entity_Service::get_instance();
115
-	$uri_service     = Wordlift_Entity_Uri_Service::get_instance();
116
-	$content_service = Wordpress_Content_Service::get_instance();
117
-
118
-	// Store mapping between tmp new entities uris and real new entities uri
119
-	$entities_uri_mapping = array();
120
-
121
-	// Save all the selected internal entity uris to this variable.
122
-	$internal_entity_uris = array();
123
-
124
-	// Save the entities coming with POST data.
125
-	if ( isset( $_POST['wl_entities'] ) ) {
126
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " );
127
-		wl_write_log( json_encode( $_POST['wl_entities'] ) );
128
-		wl_write_log( "]" );
129
-
130
-		$entities_via_post = $_POST['wl_entities'];
131
-
132
-		foreach ( $entities_via_post as $entity_uri => $entity ) {
133
-
134
-			if ( preg_match( '/^local-entity-.+/', $entity_uri ) ) {
135
-				$existing_entity = get_page_by_title( $entity['label'], OBJECT, Wordlift_Entity_Service::valid_entity_post_types() );
136
-				if ( isset( $existing_entity ) ) {
137
-					$existing_entity_type = Wordlift_Entity_Type_Service::get_instance()->get( $existing_entity->ID );
138
-					// Type doesn't match, continue to create a new entity.
139
-					if ( ! isset( $existing_entity_type ) || $existing_entity_type['css_class'] !== $entity['main_type'] ) {
140
-						$existing_entity = null;
141
-					}
142
-				}
143
-			} else {
144
-				// Look if current entity uri matches an internal existing entity, meaning:
145
-				// 1. when $entity_uri is an internal uri
146
-				// 2. when $entity_uri is an external uri used as sameAs of an internal entity
147
-				$existing_entity = $entity_service->get_entity_post_by_uri( $entity_uri );
148
-			}
149
-
150
-			// Don't save the entities which are not found, but also local.
151
-			if ( ! isset( $existing_entity ) && $uri_service->is_internal( $entity_uri ) ) {
152
-				$internal_entity_uris[] = $entity_uri;
153
-				continue;
154
-			}
155
-
156
-			if ( ! isset( $existing_entity ) ) {
157
-				// New entity, save it.
158
-				$existing_entity = wl_save_entity( $entity );
159
-			} else {
160
-				// Existing entity, update post status.
161
-				if ( $existing_entity instanceof WP_Post && $existing_entity->post_status !== 'publish' ) {
162
-					$post_status = apply_filters( 'wl_feature__enable__entity-auto-publish', true )
163
-						? $post->post_status : 'draft';
164
-					wl_update_post_status( $existing_entity->ID, $post_status );
165
-				}
166
-			}
167
-
168
-			$uri = $content_service->get_entity_id( Wordpress_Content_Id::create_post( $existing_entity->ID ) );
169
-
170
-
171
-			// Update entity data with related post
172
-			$entity['related_post_id'] = $post_id;
173
-
174
-			$internal_entity_uris[] = $uri;
175
-			wl_write_log( "Map $entity_uri on $uri" );
176
-			$entities_uri_mapping[ $entity_uri ] = $uri;
177
-
178
-		}
179
-
180
-	}
181
-
182
-	// Replace tmp uris in content post if needed
183
-	$updated_post_content = $post->post_content;
184
-
185
-	// Update the post content if we found mappings of new entities.
186
-	if ( ! empty( $entities_uri_mapping ) ) {
187
-		// Save each entity and store the post id.
188
-		foreach ( $entities_uri_mapping as $tmp_uri => $uri ) {
189
-			if ( 1 !== preg_match( '@^(https?://|local-entity-)@', $tmp_uri ) ) {
190
-				continue;
191
-			}
192
-
193
-			$updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content );
194
-		}
195
-
196
-		// Update the post content.
197
-		/**
198
-		 * Note: wp_update_post do stripslashes before saving the
199
-		 * content, so add the slashes to prevent back slash getting
200
-		 * removed.
201
-		 */
202
-		wp_update_post( array(
203
-			'ID'           => $post->ID,
204
-			'post_content' => addslashes( $updated_post_content ),
205
-		) );
206
-	}
207
-
208
-	// Reset previously saved instances.
209
-	wl_core_delete_relation_instances( $post_id );
210
-
211
-	$relations = Object_Relation_Factory::get_instance( $post_id )
212
-	                                    ->get_relations_from_content(
213
-		                                    $updated_post_content,
214
-		                                    Object_Type_Enum::POST,
215
-		                                    $internal_entity_uris
216
-	                                    );
217
-
218
-	// Save relation instances
219
-	foreach ( $relations as $relation ) {
220
-
221
-		wl_core_add_relation_instance(
222
-		// subject id.
223
-			$post_id,
224
-			// what, where, when, who
225
-			$relation->get_relation_type(),
226
-			// object id.
227
-			$relation->get_object_id(),
228
-			// Subject type.
229
-			$relation->get_subject_type(),
230
-			// Object type.
231
-			$relation->get_object_type()
232
-		);
233
-
234
-	}
235
-
236
-	if ( isset( $_POST['wl_entities'] ) ) {
237
-		// Save post metadata if available
238
-		$metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ?
239
-			$_POST['wl_metadata'] : array();
240
-
241
-		$fields = array(
242
-			Wordlift_Schema_Service::FIELD_LOCATION_CREATED,
243
-			Wordlift_Schema_Service::FIELD_TOPIC,
244
-		);
245
-
246
-		// Unlink topic taxonomy terms
247
-		Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID );
248
-
249
-		foreach ( $fields as $field ) {
250
-
251
-			// Delete current values
252
-			delete_post_meta( $post->ID, $field );
253
-			// Retrieve the entity uri
254
-			$uri = ( isset( $metadata_via_post[ $field ] ) ) ?
255
-				stripslashes( $metadata_via_post[ $field ] ) : '';
256
-
257
-			if ( empty( $uri ) ) {
258
-				continue;
259
-			}
260
-			$entity = $entity_service->get_entity_post_by_uri( $uri );
261
-
262
-			if ( $entity ) {
263
-				add_post_meta( $post->ID, $field, $entity->ID, true );
264
-				// Set also the topic taxonomy
265
-				if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) {
266
-					Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity );
267
-				}
268
-			}
269
-		}
270
-	}
271
-
272
-	add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
99
+    // Ignore auto-saves
100
+    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
101
+        $log->trace( 'Doing autosave, skipping...' );
102
+
103
+        return;
104
+    }
105
+
106
+    // get the current post.
107
+    $post = get_post( $post_id );
108
+
109
+    remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
110
+
111
+    // wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" );
112
+
113
+    // Get the entity service instance.
114
+    $entity_service  = Wordlift_Entity_Service::get_instance();
115
+    $uri_service     = Wordlift_Entity_Uri_Service::get_instance();
116
+    $content_service = Wordpress_Content_Service::get_instance();
117
+
118
+    // Store mapping between tmp new entities uris and real new entities uri
119
+    $entities_uri_mapping = array();
120
+
121
+    // Save all the selected internal entity uris to this variable.
122
+    $internal_entity_uris = array();
123
+
124
+    // Save the entities coming with POST data.
125
+    if ( isset( $_POST['wl_entities'] ) ) {
126
+        wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " );
127
+        wl_write_log( json_encode( $_POST['wl_entities'] ) );
128
+        wl_write_log( "]" );
129
+
130
+        $entities_via_post = $_POST['wl_entities'];
131
+
132
+        foreach ( $entities_via_post as $entity_uri => $entity ) {
133
+
134
+            if ( preg_match( '/^local-entity-.+/', $entity_uri ) ) {
135
+                $existing_entity = get_page_by_title( $entity['label'], OBJECT, Wordlift_Entity_Service::valid_entity_post_types() );
136
+                if ( isset( $existing_entity ) ) {
137
+                    $existing_entity_type = Wordlift_Entity_Type_Service::get_instance()->get( $existing_entity->ID );
138
+                    // Type doesn't match, continue to create a new entity.
139
+                    if ( ! isset( $existing_entity_type ) || $existing_entity_type['css_class'] !== $entity['main_type'] ) {
140
+                        $existing_entity = null;
141
+                    }
142
+                }
143
+            } else {
144
+                // Look if current entity uri matches an internal existing entity, meaning:
145
+                // 1. when $entity_uri is an internal uri
146
+                // 2. when $entity_uri is an external uri used as sameAs of an internal entity
147
+                $existing_entity = $entity_service->get_entity_post_by_uri( $entity_uri );
148
+            }
149
+
150
+            // Don't save the entities which are not found, but also local.
151
+            if ( ! isset( $existing_entity ) && $uri_service->is_internal( $entity_uri ) ) {
152
+                $internal_entity_uris[] = $entity_uri;
153
+                continue;
154
+            }
155
+
156
+            if ( ! isset( $existing_entity ) ) {
157
+                // New entity, save it.
158
+                $existing_entity = wl_save_entity( $entity );
159
+            } else {
160
+                // Existing entity, update post status.
161
+                if ( $existing_entity instanceof WP_Post && $existing_entity->post_status !== 'publish' ) {
162
+                    $post_status = apply_filters( 'wl_feature__enable__entity-auto-publish', true )
163
+                        ? $post->post_status : 'draft';
164
+                    wl_update_post_status( $existing_entity->ID, $post_status );
165
+                }
166
+            }
167
+
168
+            $uri = $content_service->get_entity_id( Wordpress_Content_Id::create_post( $existing_entity->ID ) );
169
+
170
+
171
+            // Update entity data with related post
172
+            $entity['related_post_id'] = $post_id;
173
+
174
+            $internal_entity_uris[] = $uri;
175
+            wl_write_log( "Map $entity_uri on $uri" );
176
+            $entities_uri_mapping[ $entity_uri ] = $uri;
177
+
178
+        }
179
+
180
+    }
181
+
182
+    // Replace tmp uris in content post if needed
183
+    $updated_post_content = $post->post_content;
184
+
185
+    // Update the post content if we found mappings of new entities.
186
+    if ( ! empty( $entities_uri_mapping ) ) {
187
+        // Save each entity and store the post id.
188
+        foreach ( $entities_uri_mapping as $tmp_uri => $uri ) {
189
+            if ( 1 !== preg_match( '@^(https?://|local-entity-)@', $tmp_uri ) ) {
190
+                continue;
191
+            }
192
+
193
+            $updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content );
194
+        }
195
+
196
+        // Update the post content.
197
+        /**
198
+         * Note: wp_update_post do stripslashes before saving the
199
+         * content, so add the slashes to prevent back slash getting
200
+         * removed.
201
+         */
202
+        wp_update_post( array(
203
+            'ID'           => $post->ID,
204
+            'post_content' => addslashes( $updated_post_content ),
205
+        ) );
206
+    }
207
+
208
+    // Reset previously saved instances.
209
+    wl_core_delete_relation_instances( $post_id );
210
+
211
+    $relations = Object_Relation_Factory::get_instance( $post_id )
212
+                                        ->get_relations_from_content(
213
+                                            $updated_post_content,
214
+                                            Object_Type_Enum::POST,
215
+                                            $internal_entity_uris
216
+                                        );
217
+
218
+    // Save relation instances
219
+    foreach ( $relations as $relation ) {
220
+
221
+        wl_core_add_relation_instance(
222
+        // subject id.
223
+            $post_id,
224
+            // what, where, when, who
225
+            $relation->get_relation_type(),
226
+            // object id.
227
+            $relation->get_object_id(),
228
+            // Subject type.
229
+            $relation->get_subject_type(),
230
+            // Object type.
231
+            $relation->get_object_type()
232
+        );
233
+
234
+    }
235
+
236
+    if ( isset( $_POST['wl_entities'] ) ) {
237
+        // Save post metadata if available
238
+        $metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ?
239
+            $_POST['wl_metadata'] : array();
240
+
241
+        $fields = array(
242
+            Wordlift_Schema_Service::FIELD_LOCATION_CREATED,
243
+            Wordlift_Schema_Service::FIELD_TOPIC,
244
+        );
245
+
246
+        // Unlink topic taxonomy terms
247
+        Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID );
248
+
249
+        foreach ( $fields as $field ) {
250
+
251
+            // Delete current values
252
+            delete_post_meta( $post->ID, $field );
253
+            // Retrieve the entity uri
254
+            $uri = ( isset( $metadata_via_post[ $field ] ) ) ?
255
+                stripslashes( $metadata_via_post[ $field ] ) : '';
256
+
257
+            if ( empty( $uri ) ) {
258
+                continue;
259
+            }
260
+            $entity = $entity_service->get_entity_post_by_uri( $uri );
261
+
262
+            if ( $entity ) {
263
+                add_post_meta( $post->ID, $field, $entity->ID, true );
264
+                // Set also the topic taxonomy
265
+                if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) {
266
+                    Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity );
267
+                }
268
+            }
269
+        }
270
+    }
271
+
272
+    add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
273 273
 }
274 274
 
275 275
 add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
@@ -292,205 +292,205 @@  discard block
 block discarded – undo
292 292
  */
293 293
 function wl_save_entity( $entity_data ) {
294 294
 
295
-	// Required for REST API calls
296
-	if ( ! function_exists( 'wp_crop_image' ) ) {
297
-		require_once( ABSPATH . 'wp-admin/includes/image.php' );
298
-	}
295
+    // Required for REST API calls
296
+    if ( ! function_exists( 'wp_crop_image' ) ) {
297
+        require_once( ABSPATH . 'wp-admin/includes/image.php' );
298
+    }
299 299
 
300
-	$log = Wordlift_Log_Service::get_logger( 'wl_save_entity' );
300
+    $log = Wordlift_Log_Service::get_logger( 'wl_save_entity' );
301 301
 
302
-	/*
302
+    /*
303 303
 	 * Data is coming from a $_POST, sanitize it.
304 304
 	 *
305 305
 	 * @since 3.19.4
306 306
 	 *
307 307
 	 * @see https://github.com/insideout10/wordlift-plugin/issues/841
308 308
 	 */
309
-	$label            = preg_replace( '/\xEF\xBB\xBF/', '', sanitize_text_field( $entity_data['label'] ) );
310
-	$type_uri         = $entity_data['main_type'];
311
-	$entity_types     = isset( $entity_data['type'] ) ? $entity_data['type'] : array();
312
-	$description      = $entity_data['description'];
313
-	$images           = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array();
314
-	$same_as          = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array();
315
-	$related_post_id  = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null;
316
-	$other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array();
317
-
318
-	// Get the synonyms.
319
-	$synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array();
320
-
321
-	// Check whether an entity already exists with the provided URI.
322
-	$uri = $entity_data['uri'];
323
-	if ( isset ( $uri ) && null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) {
324
-		$log->debug( "Post already exists for URI $uri." );
325
-
326
-		return $post;
327
-	}
328
-
329
-	// Prepare properties of the new entity.
330
-	$post_status = apply_filters( 'wl_feature__enable__entity-auto-publish', true ) && is_numeric( $related_post_id )
331
-		? get_post_status( $related_post_id ) : 'draft';
332
-
333
-	$params = array(
334
-		// @@todo: we don't want an entity to be automatically published.
335
-		'post_status'  => $post_status,
336
-		'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
337
-		'post_title'   => $label,
338
-		'post_content' => $description,
339
-		'post_excerpt' => '',
340
-		// Ensure we're using a valid slug. We're not overwriting an existing
341
-		// entity with a post_name already set, since this call is made only for
342
-		// new entities.
343
-		//
344
-		// See https://github.com/insideout10/wordlift-plugin/issues/282
345
-		'post_name'    => sanitize_title( $label ),
346
-	);
347
-
348
-	// If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over"
349
-	// the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156)
350
-	// Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148)
351
-	// This does NOT affect saving an entity from the entity admin page since this function is called when an entity
352
-	// is created when saving a post.
353
-	global $wpseo_metabox, $seo_ultimate;
354
-	if ( isset( $wpseo_metabox ) ) {
355
-		remove_action( 'wp_insert_post', array(
356
-			$wpseo_metabox,
357
-			'save_postdata',
358
-		) );
359
-	}
360
-
361
-	if ( isset( $seo_ultimate ) ) {
362
-		remove_action( 'save_post', array(
363
-			$seo_ultimate,
364
-			'save_postmeta_box',
365
-		) );
366
-	}
367
-
368
-	// The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to
369
-	// save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks
370
-	// to the save_post and restore them after we saved the entity.
371
-	// see https://github.com/insideout10/wordlift-plugin/issues/203
372
-	// see https://github.com/insideout10/wordlift-plugin/issues/156
373
-	// see https://github.com/insideout10/wordlift-plugin/issues/148
374
-	global $wp_filter;
375
-	$save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks;
376
-	is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters();
377
-
378
-
379
-	$log->trace( 'Going to insert new post...' );
380
-
381
-	// create or update the post.
382
-	$post_id = wp_insert_post( $params, true );
383
-
384
-	// Setting the alternative labels for this entity.
385
-	Wordlift_Entity_Service::get_instance()
386
-	                       ->set_alternative_labels( $post_id, $synonyms );
387
-
388
-	// Restore all the existing filters.
389
-	is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters;
390
-
391
-	// If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156)
392
-	if ( isset( $wpseo_metabox ) ) {
393
-		add_action( 'wp_insert_post', array(
394
-			$wpseo_metabox,
395
-			'save_postdata',
396
-		) );
397
-	}
398
-
399
-	// If SEO Ultimate is installed, add back the hook we removed a few lines above.
400
-	if ( isset( $seo_ultimate ) ) {
401
-		add_action( 'save_post', array(
402
-			$seo_ultimate,
403
-			'save_postmeta_box',
404
-		), 10, 2 );
405
-	}
406
-
407
-	// TODO: handle errors.
408
-	if ( is_wp_error( $post_id ) ) {
409
-		$log->error( 'An error occurred: ' . $post_id->get_error_message() );
410
-
411
-		// inform an error occurred.
412
-		return null;
413
-	}
414
-
415
-	wl_set_entity_main_type( $post_id, $type_uri );
416
-
417
-	// Save the entity types.
418
-	wl_set_entity_rdf_types( $post_id, $entity_types );
419
-
420
-	// Get a dataset URI for the entity.
421
-	$wl_uri = Wordlift_Entity_Service::get_instance()->get_uri( $post_id );
422
-
423
-	// Add the uri to the sameAs data if it's not a local URI.
424
-	if ( isset( $uri ) && preg_match( '@https?://.*@', $uri ) &&
425
-	     $wl_uri !== $uri &&
426
-	     // Only remote entities
427
-	     0 !== strpos( $uri, Wordlift_Configuration_Service::get_instance()->get_dataset_uri() )
428
-	) {
429
-		array_push( $same_as, $uri );
430
-	}
431
-
432
-	// Save the sameAs data for the entity.
433
-	wl_schema_set_value( $post_id, 'sameAs', $same_as );
434
-
435
-	// Save the other properties (latitude, langitude, startDate, endDate, etc.)
436
-	foreach ( $other_properties as $property_name => $property_value ) {
437
-		wl_schema_set_value( $post_id, $property_name, $property_value );
438
-	}
439
-
440
-	// Call hooks.
441
-	do_action( 'wl_save_entity', $post_id );
442
-
443
-	foreach ( $images as $image_remote_url ) {
444
-
445
-		// Check if image is already present in local DB
446
-		if ( strpos( $image_remote_url, site_url() ) !== false ) {
447
-			// Do nothing.
448
-			continue;
449
-		}
450
-
451
-		// Check if there is an existing attachment for this post ID and source URL.
452
-		$existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url );
453
-
454
-		// Skip if an existing image is found.
455
-		if ( null !== $existing_image ) {
456
-			continue;
457
-		}
458
-
459
-		// Save the image and get the local path.
460
-		$image = Wordlift_Remote_Image_Service::save_from_url( $image_remote_url );
461
-
462
-		if ( false === $image || is_wp_error( $image ) ) {
463
-			continue;
464
-		}
465
-
466
-		// Get the local URL.
467
-		$filename     = $image['path'];
468
-		$url          = $image['url'];
469
-		$content_type = $image['content_type'];
470
-
471
-		$attachment = array(
472
-			'guid'           => $url,
473
-			// post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type
474
-			'post_title'     => $label,
475
-			// Set the title to the post title.
476
-			'post_content'   => '',
477
-			'post_status'    => 'inherit',
478
-			'post_mime_type' => $content_type,
479
-		);
480
-
481
-		// Create the attachment in WordPress and generate the related metadata.
482
-		$attachment_id = wp_insert_attachment( $attachment, $filename, $post_id );
483
-
484
-		// Set the source URL for the image.
485
-		wl_set_source_url( $attachment_id, $image_remote_url );
486
-
487
-		$attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
488
-		wp_update_attachment_metadata( $attachment_id, $attachment_data );
489
-
490
-		// Set it as the featured image.
491
-		set_post_thumbnail( $post_id, $attachment_id );
492
-	}
493
-
494
-	// finally return the entity post.
495
-	return get_post( $post_id );
309
+    $label            = preg_replace( '/\xEF\xBB\xBF/', '', sanitize_text_field( $entity_data['label'] ) );
310
+    $type_uri         = $entity_data['main_type'];
311
+    $entity_types     = isset( $entity_data['type'] ) ? $entity_data['type'] : array();
312
+    $description      = $entity_data['description'];
313
+    $images           = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array();
314
+    $same_as          = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array();
315
+    $related_post_id  = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null;
316
+    $other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array();
317
+
318
+    // Get the synonyms.
319
+    $synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array();
320
+
321
+    // Check whether an entity already exists with the provided URI.
322
+    $uri = $entity_data['uri'];
323
+    if ( isset ( $uri ) && null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) {
324
+        $log->debug( "Post already exists for URI $uri." );
325
+
326
+        return $post;
327
+    }
328
+
329
+    // Prepare properties of the new entity.
330
+    $post_status = apply_filters( 'wl_feature__enable__entity-auto-publish', true ) && is_numeric( $related_post_id )
331
+        ? get_post_status( $related_post_id ) : 'draft';
332
+
333
+    $params = array(
334
+        // @@todo: we don't want an entity to be automatically published.
335
+        'post_status'  => $post_status,
336
+        'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
337
+        'post_title'   => $label,
338
+        'post_content' => $description,
339
+        'post_excerpt' => '',
340
+        // Ensure we're using a valid slug. We're not overwriting an existing
341
+        // entity with a post_name already set, since this call is made only for
342
+        // new entities.
343
+        //
344
+        // See https://github.com/insideout10/wordlift-plugin/issues/282
345
+        'post_name'    => sanitize_title( $label ),
346
+    );
347
+
348
+    // If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over"
349
+    // the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156)
350
+    // Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148)
351
+    // This does NOT affect saving an entity from the entity admin page since this function is called when an entity
352
+    // is created when saving a post.
353
+    global $wpseo_metabox, $seo_ultimate;
354
+    if ( isset( $wpseo_metabox ) ) {
355
+        remove_action( 'wp_insert_post', array(
356
+            $wpseo_metabox,
357
+            'save_postdata',
358
+        ) );
359
+    }
360
+
361
+    if ( isset( $seo_ultimate ) ) {
362
+        remove_action( 'save_post', array(
363
+            $seo_ultimate,
364
+            'save_postmeta_box',
365
+        ) );
366
+    }
367
+
368
+    // The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to
369
+    // save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks
370
+    // to the save_post and restore them after we saved the entity.
371
+    // see https://github.com/insideout10/wordlift-plugin/issues/203
372
+    // see https://github.com/insideout10/wordlift-plugin/issues/156
373
+    // see https://github.com/insideout10/wordlift-plugin/issues/148
374
+    global $wp_filter;
375
+    $save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks;
376
+    is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters();
377
+
378
+
379
+    $log->trace( 'Going to insert new post...' );
380
+
381
+    // create or update the post.
382
+    $post_id = wp_insert_post( $params, true );
383
+
384
+    // Setting the alternative labels for this entity.
385
+    Wordlift_Entity_Service::get_instance()
386
+                            ->set_alternative_labels( $post_id, $synonyms );
387
+
388
+    // Restore all the existing filters.
389
+    is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters;
390
+
391
+    // If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156)
392
+    if ( isset( $wpseo_metabox ) ) {
393
+        add_action( 'wp_insert_post', array(
394
+            $wpseo_metabox,
395
+            'save_postdata',
396
+        ) );
397
+    }
398
+
399
+    // If SEO Ultimate is installed, add back the hook we removed a few lines above.
400
+    if ( isset( $seo_ultimate ) ) {
401
+        add_action( 'save_post', array(
402
+            $seo_ultimate,
403
+            'save_postmeta_box',
404
+        ), 10, 2 );
405
+    }
406
+
407
+    // TODO: handle errors.
408
+    if ( is_wp_error( $post_id ) ) {
409
+        $log->error( 'An error occurred: ' . $post_id->get_error_message() );
410
+
411
+        // inform an error occurred.
412
+        return null;
413
+    }
414
+
415
+    wl_set_entity_main_type( $post_id, $type_uri );
416
+
417
+    // Save the entity types.
418
+    wl_set_entity_rdf_types( $post_id, $entity_types );
419
+
420
+    // Get a dataset URI for the entity.
421
+    $wl_uri = Wordlift_Entity_Service::get_instance()->get_uri( $post_id );
422
+
423
+    // Add the uri to the sameAs data if it's not a local URI.
424
+    if ( isset( $uri ) && preg_match( '@https?://.*@', $uri ) &&
425
+         $wl_uri !== $uri &&
426
+         // Only remote entities
427
+         0 !== strpos( $uri, Wordlift_Configuration_Service::get_instance()->get_dataset_uri() )
428
+    ) {
429
+        array_push( $same_as, $uri );
430
+    }
431
+
432
+    // Save the sameAs data for the entity.
433
+    wl_schema_set_value( $post_id, 'sameAs', $same_as );
434
+
435
+    // Save the other properties (latitude, langitude, startDate, endDate, etc.)
436
+    foreach ( $other_properties as $property_name => $property_value ) {
437
+        wl_schema_set_value( $post_id, $property_name, $property_value );
438
+    }
439
+
440
+    // Call hooks.
441
+    do_action( 'wl_save_entity', $post_id );
442
+
443
+    foreach ( $images as $image_remote_url ) {
444
+
445
+        // Check if image is already present in local DB
446
+        if ( strpos( $image_remote_url, site_url() ) !== false ) {
447
+            // Do nothing.
448
+            continue;
449
+        }
450
+
451
+        // Check if there is an existing attachment for this post ID and source URL.
452
+        $existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url );
453
+
454
+        // Skip if an existing image is found.
455
+        if ( null !== $existing_image ) {
456
+            continue;
457
+        }
458
+
459
+        // Save the image and get the local path.
460
+        $image = Wordlift_Remote_Image_Service::save_from_url( $image_remote_url );
461
+
462
+        if ( false === $image || is_wp_error( $image ) ) {
463
+            continue;
464
+        }
465
+
466
+        // Get the local URL.
467
+        $filename     = $image['path'];
468
+        $url          = $image['url'];
469
+        $content_type = $image['content_type'];
470
+
471
+        $attachment = array(
472
+            'guid'           => $url,
473
+            // post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type
474
+            'post_title'     => $label,
475
+            // Set the title to the post title.
476
+            'post_content'   => '',
477
+            'post_status'    => 'inherit',
478
+            'post_mime_type' => $content_type,
479
+        );
480
+
481
+        // Create the attachment in WordPress and generate the related metadata.
482
+        $attachment_id = wp_insert_attachment( $attachment, $filename, $post_id );
483
+
484
+        // Set the source URL for the image.
485
+        wl_set_source_url( $attachment_id, $image_remote_url );
486
+
487
+        $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
488
+        wp_update_attachment_metadata( $attachment_id, $attachment_data );
489
+
490
+        // Set it as the featured image.
491
+        set_post_thumbnail( $post_id, $attachment_id );
492
+    }
493
+
494
+    // finally return the entity post.
495
+    return get_post( $post_id );
496 496
 }
Please login to merge, or discard this patch.
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
  * @since 3.0.0
21 21
  *
22 22
  */
23
-function wl_linked_data_save_post( $post_id ) {
23
+function wl_linked_data_save_post($post_id) {
24 24
 
25
-	$log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post' );
25
+	$log = Wordlift_Log_Service::get_logger('wl_linked_data_save_post');
26 26
 
27
-	$log->trace( "Saving post $post_id to Linked Data..." );
27
+	$log->trace("Saving post $post_id to Linked Data...");
28 28
 
29 29
 	// If it's not numeric exit from here.
30
-	if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) {
31
-		$log->debug( "Skipping $post_id, because id is not numeric or is a post revision." );
30
+	if ( ! is_numeric($post_id) || is_numeric(wp_is_post_revision($post_id))) {
31
+		$log->debug("Skipping $post_id, because id is not numeric or is a post revision.");
32 32
 
33 33
 		return;
34 34
 	}
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	// Get the post type and check whether it supports the editor.
37 37
 	//
38 38
 	// @see https://github.com/insideout10/wordlift-plugin/issues/659.
39
-	$post_type = get_post_type( $post_id );
39
+	$post_type = get_post_type($post_id);
40 40
 	/**
41 41
 	 * Use `wl_post_type_supports_editor` which calls a filter to allow 3rd parties to change the setting.
42 42
 	 *
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	 *
45 45
 	 * @see https://github.com/insideout10/wordlift-plugin/issues/847.
46 46
 	 */
47
-	$is_editor_supported = wl_post_type_supports_editor( $post_type );
47
+	$is_editor_supported = wl_post_type_supports_editor($post_type);
48 48
 
49
-	$is_no_editor_analysis_enabled = Wordlift\No_Editor_Analysis\No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( $post_id );
49
+	$is_no_editor_analysis_enabled = Wordlift\No_Editor_Analysis\No_Editor_Analysis_Feature::can_no_editor_analysis_be_used($post_id);
50 50
 	// Bail out if it's not an entity.
51 51
 	if ( ! $is_editor_supported
52
-	     && ! $is_no_editor_analysis_enabled ) {
53
-		$log->debug( "Skipping $post_id, because $post_type doesn't support the editor (content)." );
52
+	     && ! $is_no_editor_analysis_enabled) {
53
+		$log->debug("Skipping $post_id, because $post_type doesn't support the editor (content).");
54 54
 
55 55
 		return;
56 56
 	}
@@ -64,23 +64,23 @@  discard block
 block discarded – undo
64 64
 	$supported_types = Wordlift_Entity_Service::valid_entity_post_types();
65 65
 
66 66
 	// Bail out if it's not a valid entity.
67
-	if ( ! in_array( $post_type, $supported_types ) && ! $is_no_editor_analysis_enabled ) {
68
-		$log->debug( "Skipping $post_id, because $post_type is not a valid entity." );
67
+	if ( ! in_array($post_type, $supported_types) && ! $is_no_editor_analysis_enabled) {
68
+		$log->debug("Skipping $post_id, because $post_type is not a valid entity.");
69 69
 
70 70
 		return;
71 71
 	}
72 72
 
73 73
 	// Unhook this function so it doesn't loop infinitely.
74
-	remove_action( 'save_post', 'wl_linked_data_save_post' );
74
+	remove_action('save_post', 'wl_linked_data_save_post');
75 75
 
76 76
 	// raise the *wl_linked_data_save_post* event.
77
-	do_action( 'wl_linked_data_save_post', $post_id );
77
+	do_action('wl_linked_data_save_post', $post_id);
78 78
 
79 79
 	// Re-hook this function.
80
-	add_action( 'save_post', 'wl_linked_data_save_post' );
80
+	add_action('save_post', 'wl_linked_data_save_post');
81 81
 }
82 82
 
83
-add_action( 'save_post', 'wl_linked_data_save_post' );
83
+add_action('save_post', 'wl_linked_data_save_post');
84 84
 
85 85
 /**
86 86
  * Save the post to the triple store. Also saves the entities locally and on the triple store.
@@ -90,23 +90,23 @@  discard block
 block discarded – undo
90 90
  * @since 3.0.0
91 91
  *
92 92
  */
93
-function wl_linked_data_save_post_and_related_entities( $post_id ) {
93
+function wl_linked_data_save_post_and_related_entities($post_id) {
94 94
 
95
-	$log = Wordlift_Log_Service::get_logger( 'wl_linked_data_save_post_and_related_entities' );
95
+	$log = Wordlift_Log_Service::get_logger('wl_linked_data_save_post_and_related_entities');
96 96
 
97
-	$log->trace( "Saving $post_id to Linked Data along with related entities..." );
97
+	$log->trace("Saving $post_id to Linked Data along with related entities...");
98 98
 
99 99
 	// Ignore auto-saves
100
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
101
-		$log->trace( 'Doing autosave, skipping...' );
100
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
101
+		$log->trace('Doing autosave, skipping...');
102 102
 
103 103
 		return;
104 104
 	}
105 105
 
106 106
 	// get the current post.
107
-	$post = get_post( $post_id );
107
+	$post = get_post($post_id);
108 108
 
109
-	remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
109
+	remove_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities');
110 110
 
111 111
 	// wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" );
112 112
 
@@ -122,21 +122,21 @@  discard block
 block discarded – undo
122 122
 	$internal_entity_uris = array();
123 123
 
124 124
 	// Save the entities coming with POST data.
125
-	if ( isset( $_POST['wl_entities'] ) ) {
126
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " );
127
-		wl_write_log( json_encode( $_POST['wl_entities'] ) );
128
-		wl_write_log( "]" );
125
+	if (isset($_POST['wl_entities'])) {
126
+		wl_write_log("[ post id :: $post_id ][ POST(wl_entities) :: ");
127
+		wl_write_log(json_encode($_POST['wl_entities']));
128
+		wl_write_log("]");
129 129
 
130 130
 		$entities_via_post = $_POST['wl_entities'];
131 131
 
132
-		foreach ( $entities_via_post as $entity_uri => $entity ) {
132
+		foreach ($entities_via_post as $entity_uri => $entity) {
133 133
 
134
-			if ( preg_match( '/^local-entity-.+/', $entity_uri ) ) {
135
-				$existing_entity = get_page_by_title( $entity['label'], OBJECT, Wordlift_Entity_Service::valid_entity_post_types() );
136
-				if ( isset( $existing_entity ) ) {
137
-					$existing_entity_type = Wordlift_Entity_Type_Service::get_instance()->get( $existing_entity->ID );
134
+			if (preg_match('/^local-entity-.+/', $entity_uri)) {
135
+				$existing_entity = get_page_by_title($entity['label'], OBJECT, Wordlift_Entity_Service::valid_entity_post_types());
136
+				if (isset($existing_entity)) {
137
+					$existing_entity_type = Wordlift_Entity_Type_Service::get_instance()->get($existing_entity->ID);
138 138
 					// Type doesn't match, continue to create a new entity.
139
-					if ( ! isset( $existing_entity_type ) || $existing_entity_type['css_class'] !== $entity['main_type'] ) {
139
+					if ( ! isset($existing_entity_type) || $existing_entity_type['css_class'] !== $entity['main_type']) {
140 140
 						$existing_entity = null;
141 141
 					}
142 142
 				}
@@ -144,36 +144,36 @@  discard block
 block discarded – undo
144 144
 				// Look if current entity uri matches an internal existing entity, meaning:
145 145
 				// 1. when $entity_uri is an internal uri
146 146
 				// 2. when $entity_uri is an external uri used as sameAs of an internal entity
147
-				$existing_entity = $entity_service->get_entity_post_by_uri( $entity_uri );
147
+				$existing_entity = $entity_service->get_entity_post_by_uri($entity_uri);
148 148
 			}
149 149
 
150 150
 			// Don't save the entities which are not found, but also local.
151
-			if ( ! isset( $existing_entity ) && $uri_service->is_internal( $entity_uri ) ) {
151
+			if ( ! isset($existing_entity) && $uri_service->is_internal($entity_uri)) {
152 152
 				$internal_entity_uris[] = $entity_uri;
153 153
 				continue;
154 154
 			}
155 155
 
156
-			if ( ! isset( $existing_entity ) ) {
156
+			if ( ! isset($existing_entity)) {
157 157
 				// New entity, save it.
158
-				$existing_entity = wl_save_entity( $entity );
158
+				$existing_entity = wl_save_entity($entity);
159 159
 			} else {
160 160
 				// Existing entity, update post status.
161
-				if ( $existing_entity instanceof WP_Post && $existing_entity->post_status !== 'publish' ) {
162
-					$post_status = apply_filters( 'wl_feature__enable__entity-auto-publish', true )
161
+				if ($existing_entity instanceof WP_Post && $existing_entity->post_status !== 'publish') {
162
+					$post_status = apply_filters('wl_feature__enable__entity-auto-publish', true)
163 163
 						? $post->post_status : 'draft';
164
-					wl_update_post_status( $existing_entity->ID, $post_status );
164
+					wl_update_post_status($existing_entity->ID, $post_status);
165 165
 				}
166 166
 			}
167 167
 
168
-			$uri = $content_service->get_entity_id( Wordpress_Content_Id::create_post( $existing_entity->ID ) );
168
+			$uri = $content_service->get_entity_id(Wordpress_Content_Id::create_post($existing_entity->ID));
169 169
 
170 170
 
171 171
 			// Update entity data with related post
172 172
 			$entity['related_post_id'] = $post_id;
173 173
 
174 174
 			$internal_entity_uris[] = $uri;
175
-			wl_write_log( "Map $entity_uri on $uri" );
176
-			$entities_uri_mapping[ $entity_uri ] = $uri;
175
+			wl_write_log("Map $entity_uri on $uri");
176
+			$entities_uri_mapping[$entity_uri] = $uri;
177 177
 
178 178
 		}
179 179
 
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 	$updated_post_content = $post->post_content;
184 184
 
185 185
 	// Update the post content if we found mappings of new entities.
186
-	if ( ! empty( $entities_uri_mapping ) ) {
186
+	if ( ! empty($entities_uri_mapping)) {
187 187
 		// Save each entity and store the post id.
188
-		foreach ( $entities_uri_mapping as $tmp_uri => $uri ) {
189
-			if ( 1 !== preg_match( '@^(https?://|local-entity-)@', $tmp_uri ) ) {
188
+		foreach ($entities_uri_mapping as $tmp_uri => $uri) {
189
+			if (1 !== preg_match('@^(https?://|local-entity-)@', $tmp_uri)) {
190 190
 				continue;
191 191
 			}
192 192
 
193
-			$updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content );
193
+			$updated_post_content = str_replace($tmp_uri, $uri, $updated_post_content);
194 194
 		}
195 195
 
196 196
 		// Update the post content.
@@ -199,16 +199,16 @@  discard block
 block discarded – undo
199 199
 		 * content, so add the slashes to prevent back slash getting
200 200
 		 * removed.
201 201
 		 */
202
-		wp_update_post( array(
202
+		wp_update_post(array(
203 203
 			'ID'           => $post->ID,
204
-			'post_content' => addslashes( $updated_post_content ),
205
-		) );
204
+			'post_content' => addslashes($updated_post_content),
205
+		));
206 206
 	}
207 207
 
208 208
 	// Reset previously saved instances.
209
-	wl_core_delete_relation_instances( $post_id );
209
+	wl_core_delete_relation_instances($post_id);
210 210
 
211
-	$relations = Object_Relation_Factory::get_instance( $post_id )
211
+	$relations = Object_Relation_Factory::get_instance($post_id)
212 212
 	                                    ->get_relations_from_content(
213 213
 		                                    $updated_post_content,
214 214
 		                                    Object_Type_Enum::POST,
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	                                    );
217 217
 
218 218
 	// Save relation instances
219
-	foreach ( $relations as $relation ) {
219
+	foreach ($relations as $relation) {
220 220
 
221 221
 		wl_core_add_relation_instance(
222 222
 		// subject id.
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
 
234 234
 	}
235 235
 
236
-	if ( isset( $_POST['wl_entities'] ) ) {
236
+	if (isset($_POST['wl_entities'])) {
237 237
 		// Save post metadata if available
238
-		$metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ?
238
+		$metadata_via_post = (isset($_POST['wl_metadata'])) ?
239 239
 			$_POST['wl_metadata'] : array();
240 240
 
241 241
 		$fields = array(
@@ -244,35 +244,35 @@  discard block
 block discarded – undo
244 244
 		);
245 245
 
246 246
 		// Unlink topic taxonomy terms
247
-		Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID );
247
+		Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for($post->ID);
248 248
 
249
-		foreach ( $fields as $field ) {
249
+		foreach ($fields as $field) {
250 250
 
251 251
 			// Delete current values
252
-			delete_post_meta( $post->ID, $field );
252
+			delete_post_meta($post->ID, $field);
253 253
 			// Retrieve the entity uri
254
-			$uri = ( isset( $metadata_via_post[ $field ] ) ) ?
255
-				stripslashes( $metadata_via_post[ $field ] ) : '';
254
+			$uri = (isset($metadata_via_post[$field])) ?
255
+				stripslashes($metadata_via_post[$field]) : '';
256 256
 
257
-			if ( empty( $uri ) ) {
257
+			if (empty($uri)) {
258 258
 				continue;
259 259
 			}
260
-			$entity = $entity_service->get_entity_post_by_uri( $uri );
260
+			$entity = $entity_service->get_entity_post_by_uri($uri);
261 261
 
262
-			if ( $entity ) {
263
-				add_post_meta( $post->ID, $field, $entity->ID, true );
262
+			if ($entity) {
263
+				add_post_meta($post->ID, $field, $entity->ID, true);
264 264
 				// Set also the topic taxonomy
265
-				if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) {
266
-					Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity );
265
+				if ($field === Wordlift_Schema_Service::FIELD_TOPIC) {
266
+					Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for($post->ID, $entity);
267 267
 				}
268 268
 			}
269 269
 		}
270 270
 	}
271 271
 
272
-	add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
272
+	add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities');
273 273
 }
274 274
 
275
-add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
275
+add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities');
276 276
 
277 277
 /**
278 278
  * Save the specified data as an entity in WordPress. This method only create new entities. When an existing entity is
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
  *
291 291
  * @return null|WP_Post A post instance or null in case of failure.
292 292
  */
293
-function wl_save_entity( $entity_data ) {
293
+function wl_save_entity($entity_data) {
294 294
 
295 295
 	// Required for REST API calls
296
-	if ( ! function_exists( 'wp_crop_image' ) ) {
297
-		require_once( ABSPATH . 'wp-admin/includes/image.php' );
296
+	if ( ! function_exists('wp_crop_image')) {
297
+		require_once(ABSPATH.'wp-admin/includes/image.php');
298 298
 	}
299 299
 
300
-	$log = Wordlift_Log_Service::get_logger( 'wl_save_entity' );
300
+	$log = Wordlift_Log_Service::get_logger('wl_save_entity');
301 301
 
302 302
 	/*
303 303
 	 * Data is coming from a $_POST, sanitize it.
@@ -306,29 +306,29 @@  discard block
 block discarded – undo
306 306
 	 *
307 307
 	 * @see https://github.com/insideout10/wordlift-plugin/issues/841
308 308
 	 */
309
-	$label            = preg_replace( '/\xEF\xBB\xBF/', '', sanitize_text_field( $entity_data['label'] ) );
309
+	$label            = preg_replace('/\xEF\xBB\xBF/', '', sanitize_text_field($entity_data['label']));
310 310
 	$type_uri         = $entity_data['main_type'];
311
-	$entity_types     = isset( $entity_data['type'] ) ? $entity_data['type'] : array();
311
+	$entity_types     = isset($entity_data['type']) ? $entity_data['type'] : array();
312 312
 	$description      = $entity_data['description'];
313
-	$images           = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array();
314
-	$same_as          = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array();
315
-	$related_post_id  = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null;
316
-	$other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array();
313
+	$images           = isset($entity_data['image']) ? (array) $entity_data['image'] : array();
314
+	$same_as          = isset($entity_data['sameas']) ? (array) $entity_data['sameas'] : array();
315
+	$related_post_id  = isset($entity_data['related_post_id']) ? $entity_data['related_post_id'] : null;
316
+	$other_properties = isset($entity_data['properties']) ? $entity_data['properties'] : array();
317 317
 
318 318
 	// Get the synonyms.
319
-	$synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array();
319
+	$synonyms = isset($entity_data['synonym']) ? $entity_data['synonym'] : array();
320 320
 
321 321
 	// Check whether an entity already exists with the provided URI.
322 322
 	$uri = $entity_data['uri'];
323
-	if ( isset ( $uri ) && null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) {
324
-		$log->debug( "Post already exists for URI $uri." );
323
+	if (isset ($uri) && null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri)) {
324
+		$log->debug("Post already exists for URI $uri.");
325 325
 
326 326
 		return $post;
327 327
 	}
328 328
 
329 329
 	// Prepare properties of the new entity.
330
-	$post_status = apply_filters( 'wl_feature__enable__entity-auto-publish', true ) && is_numeric( $related_post_id )
331
-		? get_post_status( $related_post_id ) : 'draft';
330
+	$post_status = apply_filters('wl_feature__enable__entity-auto-publish', true) && is_numeric($related_post_id)
331
+		? get_post_status($related_post_id) : 'draft';
332 332
 
333 333
 	$params = array(
334 334
 		// @@todo: we don't want an entity to be automatically published.
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 		// new entities.
343 343
 		//
344 344
 		// See https://github.com/insideout10/wordlift-plugin/issues/282
345
-		'post_name'    => sanitize_title( $label ),
345
+		'post_name'    => sanitize_title($label),
346 346
 	);
347 347
 
348 348
 	// If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over"
@@ -351,18 +351,18 @@  discard block
 block discarded – undo
351 351
 	// This does NOT affect saving an entity from the entity admin page since this function is called when an entity
352 352
 	// is created when saving a post.
353 353
 	global $wpseo_metabox, $seo_ultimate;
354
-	if ( isset( $wpseo_metabox ) ) {
355
-		remove_action( 'wp_insert_post', array(
354
+	if (isset($wpseo_metabox)) {
355
+		remove_action('wp_insert_post', array(
356 356
 			$wpseo_metabox,
357 357
 			'save_postdata',
358
-		) );
358
+		));
359 359
 	}
360 360
 
361
-	if ( isset( $seo_ultimate ) ) {
362
-		remove_action( 'save_post', array(
361
+	if (isset($seo_ultimate)) {
362
+		remove_action('save_post', array(
363 363
 			$seo_ultimate,
364 364
 			'save_postmeta_box',
365
-		) );
365
+		));
366 366
 	}
367 367
 
368 368
 	// The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to
@@ -372,94 +372,94 @@  discard block
 block discarded – undo
372 372
 	// see https://github.com/insideout10/wordlift-plugin/issues/156
373 373
 	// see https://github.com/insideout10/wordlift-plugin/issues/148
374 374
 	global $wp_filter;
375
-	$save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks;
376
-	is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters();
375
+	$save_post_filters = is_array($wp_filter['save_post']) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks;
376
+	is_array($wp_filter['save_post']) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters();
377 377
 
378 378
 
379
-	$log->trace( 'Going to insert new post...' );
379
+	$log->trace('Going to insert new post...');
380 380
 
381 381
 	// create or update the post.
382
-	$post_id = wp_insert_post( $params, true );
382
+	$post_id = wp_insert_post($params, true);
383 383
 
384 384
 	// Setting the alternative labels for this entity.
385 385
 	Wordlift_Entity_Service::get_instance()
386
-	                       ->set_alternative_labels( $post_id, $synonyms );
386
+	                       ->set_alternative_labels($post_id, $synonyms);
387 387
 
388 388
 	// Restore all the existing filters.
389
-	is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters;
389
+	is_array($wp_filter['save_post']) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters;
390 390
 
391 391
 	// If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156)
392
-	if ( isset( $wpseo_metabox ) ) {
393
-		add_action( 'wp_insert_post', array(
392
+	if (isset($wpseo_metabox)) {
393
+		add_action('wp_insert_post', array(
394 394
 			$wpseo_metabox,
395 395
 			'save_postdata',
396
-		) );
396
+		));
397 397
 	}
398 398
 
399 399
 	// If SEO Ultimate is installed, add back the hook we removed a few lines above.
400
-	if ( isset( $seo_ultimate ) ) {
401
-		add_action( 'save_post', array(
400
+	if (isset($seo_ultimate)) {
401
+		add_action('save_post', array(
402 402
 			$seo_ultimate,
403 403
 			'save_postmeta_box',
404
-		), 10, 2 );
404
+		), 10, 2);
405 405
 	}
406 406
 
407 407
 	// TODO: handle errors.
408
-	if ( is_wp_error( $post_id ) ) {
409
-		$log->error( 'An error occurred: ' . $post_id->get_error_message() );
408
+	if (is_wp_error($post_id)) {
409
+		$log->error('An error occurred: '.$post_id->get_error_message());
410 410
 
411 411
 		// inform an error occurred.
412 412
 		return null;
413 413
 	}
414 414
 
415
-	wl_set_entity_main_type( $post_id, $type_uri );
415
+	wl_set_entity_main_type($post_id, $type_uri);
416 416
 
417 417
 	// Save the entity types.
418
-	wl_set_entity_rdf_types( $post_id, $entity_types );
418
+	wl_set_entity_rdf_types($post_id, $entity_types);
419 419
 
420 420
 	// Get a dataset URI for the entity.
421
-	$wl_uri = Wordlift_Entity_Service::get_instance()->get_uri( $post_id );
421
+	$wl_uri = Wordlift_Entity_Service::get_instance()->get_uri($post_id);
422 422
 
423 423
 	// Add the uri to the sameAs data if it's not a local URI.
424
-	if ( isset( $uri ) && preg_match( '@https?://.*@', $uri ) &&
424
+	if (isset($uri) && preg_match('@https?://.*@', $uri) &&
425 425
 	     $wl_uri !== $uri &&
426 426
 	     // Only remote entities
427
-	     0 !== strpos( $uri, Wordlift_Configuration_Service::get_instance()->get_dataset_uri() )
427
+	     0 !== strpos($uri, Wordlift_Configuration_Service::get_instance()->get_dataset_uri())
428 428
 	) {
429
-		array_push( $same_as, $uri );
429
+		array_push($same_as, $uri);
430 430
 	}
431 431
 
432 432
 	// Save the sameAs data for the entity.
433
-	wl_schema_set_value( $post_id, 'sameAs', $same_as );
433
+	wl_schema_set_value($post_id, 'sameAs', $same_as);
434 434
 
435 435
 	// Save the other properties (latitude, langitude, startDate, endDate, etc.)
436
-	foreach ( $other_properties as $property_name => $property_value ) {
437
-		wl_schema_set_value( $post_id, $property_name, $property_value );
436
+	foreach ($other_properties as $property_name => $property_value) {
437
+		wl_schema_set_value($post_id, $property_name, $property_value);
438 438
 	}
439 439
 
440 440
 	// Call hooks.
441
-	do_action( 'wl_save_entity', $post_id );
441
+	do_action('wl_save_entity', $post_id);
442 442
 
443
-	foreach ( $images as $image_remote_url ) {
443
+	foreach ($images as $image_remote_url) {
444 444
 
445 445
 		// Check if image is already present in local DB
446
-		if ( strpos( $image_remote_url, site_url() ) !== false ) {
446
+		if (strpos($image_remote_url, site_url()) !== false) {
447 447
 			// Do nothing.
448 448
 			continue;
449 449
 		}
450 450
 
451 451
 		// Check if there is an existing attachment for this post ID and source URL.
452
-		$existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url );
452
+		$existing_image = wl_get_attachment_for_source_url($post_id, $image_remote_url);
453 453
 
454 454
 		// Skip if an existing image is found.
455
-		if ( null !== $existing_image ) {
455
+		if (null !== $existing_image) {
456 456
 			continue;
457 457
 		}
458 458
 
459 459
 		// Save the image and get the local path.
460
-		$image = Wordlift_Remote_Image_Service::save_from_url( $image_remote_url );
460
+		$image = Wordlift_Remote_Image_Service::save_from_url($image_remote_url);
461 461
 
462
-		if ( false === $image || is_wp_error( $image ) ) {
462
+		if (false === $image || is_wp_error($image)) {
463 463
 			continue;
464 464
 		}
465 465
 
@@ -479,18 +479,18 @@  discard block
 block discarded – undo
479 479
 		);
480 480
 
481 481
 		// Create the attachment in WordPress and generate the related metadata.
482
-		$attachment_id = wp_insert_attachment( $attachment, $filename, $post_id );
482
+		$attachment_id = wp_insert_attachment($attachment, $filename, $post_id);
483 483
 
484 484
 		// Set the source URL for the image.
485
-		wl_set_source_url( $attachment_id, $image_remote_url );
485
+		wl_set_source_url($attachment_id, $image_remote_url);
486 486
 
487
-		$attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
488
-		wp_update_attachment_metadata( $attachment_id, $attachment_data );
487
+		$attachment_data = wp_generate_attachment_metadata($attachment_id, $filename);
488
+		wp_update_attachment_metadata($attachment_id, $attachment_data);
489 489
 
490 490
 		// Set it as the featured image.
491
-		set_post_thumbnail( $post_id, $attachment_id );
491
+		set_post_thumbnail($post_id, $attachment_id);
492 492
 	}
493 493
 
494 494
 	// finally return the entity post.
495
-	return get_post( $post_id );
495
+	return get_post($post_id);
496 496
 }
Please login to merge, or discard this patch.