Completed
Push — master ( 6f958b...ce5918 )
by David
02:40
created
src/admin/wordlift_admin_meta_box_entities.php 2 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
  */
11 11
 function wl_register_metaboxes() {
12 12
 
13
-	// Load metabox classes.
14
-	require_once( 'WL_Metabox/class-wl-metabox.php' );
13
+    // Load metabox classes.
14
+    require_once( 'WL_Metabox/class-wl-metabox.php' );
15 15
 
16
-	$wl_metabox = new WL_Metabox();     // Everything is done inside here with the correct timing.
16
+    $wl_metabox = new WL_Metabox();     // Everything is done inside here with the correct timing.
17 17
 }
18 18
 
19 19
 if ( is_admin() ) {
20
-	add_action( 'load-post.php', 'wl_register_metaboxes' );
21
-	add_action( 'load-post-new.php', 'wl_register_metaboxes' );
20
+    add_action( 'load-post.php', 'wl_register_metaboxes' );
21
+    add_action( 'load-post-new.php', 'wl_register_metaboxes' );
22 22
 }
23 23
 
24 24
 
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
  */
30 30
 function wl_admin_add_entities_meta_box( $post_type ) {
31 31
 
32
-	// Bail out if the post type doesn't support a TinyMCE editor.
33
-	if ( ! post_type_supports( $post_type, 'editor' ) ) {
34
-		return;
35
-	}
32
+    // Bail out if the post type doesn't support a TinyMCE editor.
33
+    if ( ! post_type_supports( $post_type, 'editor' ) ) {
34
+        return;
35
+    }
36 36
 
37
-	// Add main meta box for related entities and 4W.
38
-	add_meta_box(
39
-		'wordlift_entities_box', __( 'WordLift', 'wordlift' ), 'wl_entities_box_content', $post_type, 'side', 'high'
40
-	);
37
+    // Add main meta box for related entities and 4W.
38
+    add_meta_box(
39
+        'wordlift_entities_box', __( 'WordLift', 'wordlift' ), 'wl_entities_box_content', $post_type, 'side', 'high'
40
+    );
41 41
 }
42 42
 
43 43
 add_action( 'add_meta_boxes', 'wl_admin_add_entities_meta_box' );
@@ -49,92 +49,92 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function wl_entities_box_content( $post ) {
51 51
 
52
-	// Angularjs edit-post widget wrapper.
53
-	echo '<div id="wordlift-edit-post-outer-wrapper"></div>';
54
-
55
-	// Angularjs edit-post widget classification boxes configuration.
56
-	$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
57
-
58
-	// Array to store all related entities ids.
59
-	$all_referenced_entities_ids = array();
60
-
61
-	// Add selected entities to classification_boxes.
62
-	foreach ( $classification_boxes as $i => $box ) {
63
-		// Build the proper relation name.
64
-		$relation_name = $box['id'];
65
-
66
-		// Get the entity referenced from the post content.
67
-		$entity_uris = Wordlift_Content_Filter_Service::get_instance()->get_entity_uris( $post->post_content );
68
-
69
-		// Enhance current box selected entities.
70
-		$classification_boxes[ $i ]['selectedEntities'] = $entity_uris;
71
-
72
-		// Maps the URIs to entity posts.
73
-		$entity_service = Wordlift_Entity_Service::get_instance();
74
-
75
-		// Replace all entity URI's with post ID's if found or null if there is no related post.
76
-		$entity_ids = array_map( function ( $item ) use ( $entity_service ) {
77
-			// Return entity post by the entity URI or null.
78
-			$post = $entity_service->get_entity_post_by_uri( $item );
79
-
80
-			// Check that the post object is not null.
81
-			if ( ! empty( $post ) ) {
82
-				return $post->ID;
83
-			}
84
-		}, $entity_uris );
85
-		// Store the entity ids for all the 4W.
86
-		$all_referenced_entities_ids = array_merge( $all_referenced_entities_ids, $entity_ids );
87
-
88
-	}
89
-	// Json encoding for classification boxes structure.
90
-	$classification_boxes = wp_json_encode( $classification_boxes );
91
-
92
-	// Ensure there are no repetitions of the referenced entities.
93
-	$all_referenced_entities_ids = array_unique( $all_referenced_entities_ids );
94
-
95
-	// Remove all null, false and empty strings.
96
-	// NULL is being returned in some cases, when there is not related post, so we need to remove it.
97
-	$all_referenced_entities_ids = array_filter( $all_referenced_entities_ids );
98
-
99
-	// Build the entity storage object.
100
-	$referenced_entities_obj = array();
101
-	foreach ( $all_referenced_entities_ids as $referenced_entity ) {
102
-		$entity                                   = wl_serialize_entity( $referenced_entity );
103
-		$referenced_entities_obj[ $entity['id'] ] = $entity;
104
-	}
105
-
106
-	$referenced_entities_obj = empty( $referenced_entities_obj ) ?
107
-		'{}' : wp_json_encode( $referenced_entities_obj );
108
-
109
-	$published_place_id  = get_post_meta(
110
-		$post->ID, Wordlift_Schema_Service::FIELD_LOCATION_CREATED, true
111
-	);
112
-	$published_place_obj = ( $published_place_id ) ?
113
-		wp_json_encode( wl_serialize_entity( $published_place_id ) ) :
114
-		'undefined';
115
-
116
-	$topic_id  = get_post_meta(
117
-		$post->ID, Wordlift_Schema_Service::FIELD_TOPIC, true
118
-	);
119
-	$topic_obj = ( $topic_id ) ?
120
-		wp_json_encode( wl_serialize_entity( $topic_id ) ) :
121
-		'undefined';
122
-
123
-	$configuration_service = Wordlift_Configuration_Service::get_instance();
124
-
125
-	$default_thumbnail_path = WL_DEFAULT_THUMBNAIL_PATH;
126
-	$default_path           = WL_DEFAULT_PATH;
127
-	$dataset_uri            = $configuration_service->get_dataset_uri();
128
-	$current_post_uri       = wl_get_entity_uri( $post->ID );
129
-
130
-	// Retrieve the current post author.
131
-	$post_author = get_userdata( $post->post_author )->display_name;
132
-	// Retrive the published date.
133
-	$published_date = get_the_time( 'Y-m-d', $post->ID );
134
-	// Current language.
135
-	$current_language = $configuration_service->get_language_code();
136
-
137
-	echo <<<EOF
52
+    // Angularjs edit-post widget wrapper.
53
+    echo '<div id="wordlift-edit-post-outer-wrapper"></div>';
54
+
55
+    // Angularjs edit-post widget classification boxes configuration.
56
+    $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
57
+
58
+    // Array to store all related entities ids.
59
+    $all_referenced_entities_ids = array();
60
+
61
+    // Add selected entities to classification_boxes.
62
+    foreach ( $classification_boxes as $i => $box ) {
63
+        // Build the proper relation name.
64
+        $relation_name = $box['id'];
65
+
66
+        // Get the entity referenced from the post content.
67
+        $entity_uris = Wordlift_Content_Filter_Service::get_instance()->get_entity_uris( $post->post_content );
68
+
69
+        // Enhance current box selected entities.
70
+        $classification_boxes[ $i ]['selectedEntities'] = $entity_uris;
71
+
72
+        // Maps the URIs to entity posts.
73
+        $entity_service = Wordlift_Entity_Service::get_instance();
74
+
75
+        // Replace all entity URI's with post ID's if found or null if there is no related post.
76
+        $entity_ids = array_map( function ( $item ) use ( $entity_service ) {
77
+            // Return entity post by the entity URI or null.
78
+            $post = $entity_service->get_entity_post_by_uri( $item );
79
+
80
+            // Check that the post object is not null.
81
+            if ( ! empty( $post ) ) {
82
+                return $post->ID;
83
+            }
84
+        }, $entity_uris );
85
+        // Store the entity ids for all the 4W.
86
+        $all_referenced_entities_ids = array_merge( $all_referenced_entities_ids, $entity_ids );
87
+
88
+    }
89
+    // Json encoding for classification boxes structure.
90
+    $classification_boxes = wp_json_encode( $classification_boxes );
91
+
92
+    // Ensure there are no repetitions of the referenced entities.
93
+    $all_referenced_entities_ids = array_unique( $all_referenced_entities_ids );
94
+
95
+    // Remove all null, false and empty strings.
96
+    // NULL is being returned in some cases, when there is not related post, so we need to remove it.
97
+    $all_referenced_entities_ids = array_filter( $all_referenced_entities_ids );
98
+
99
+    // Build the entity storage object.
100
+    $referenced_entities_obj = array();
101
+    foreach ( $all_referenced_entities_ids as $referenced_entity ) {
102
+        $entity                                   = wl_serialize_entity( $referenced_entity );
103
+        $referenced_entities_obj[ $entity['id'] ] = $entity;
104
+    }
105
+
106
+    $referenced_entities_obj = empty( $referenced_entities_obj ) ?
107
+        '{}' : wp_json_encode( $referenced_entities_obj );
108
+
109
+    $published_place_id  = get_post_meta(
110
+        $post->ID, Wordlift_Schema_Service::FIELD_LOCATION_CREATED, true
111
+    );
112
+    $published_place_obj = ( $published_place_id ) ?
113
+        wp_json_encode( wl_serialize_entity( $published_place_id ) ) :
114
+        'undefined';
115
+
116
+    $topic_id  = get_post_meta(
117
+        $post->ID, Wordlift_Schema_Service::FIELD_TOPIC, true
118
+    );
119
+    $topic_obj = ( $topic_id ) ?
120
+        wp_json_encode( wl_serialize_entity( $topic_id ) ) :
121
+        'undefined';
122
+
123
+    $configuration_service = Wordlift_Configuration_Service::get_instance();
124
+
125
+    $default_thumbnail_path = WL_DEFAULT_THUMBNAIL_PATH;
126
+    $default_path           = WL_DEFAULT_PATH;
127
+    $dataset_uri            = $configuration_service->get_dataset_uri();
128
+    $current_post_uri       = wl_get_entity_uri( $post->ID );
129
+
130
+    // Retrieve the current post author.
131
+    $post_author = get_userdata( $post->post_author )->display_name;
132
+    // Retrive the published date.
133
+    $published_date = get_the_time( 'Y-m-d', $post->ID );
134
+    // Current language.
135
+    $current_language = $configuration_service->get_language_code();
136
+
137
+    echo <<<EOF
138 138
 	<script type="text/javascript">
139 139
 		jQuery( function() {
140 140
 
Please login to merge, or discard this patch.
Spacing   +34 added lines, -36 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 function wl_register_metaboxes() {
12 12
 
13 13
 	// Load metabox classes.
14
-	require_once( 'WL_Metabox/class-wl-metabox.php' );
14
+	require_once('WL_Metabox/class-wl-metabox.php');
15 15
 
16
-	$wl_metabox = new WL_Metabox();     // Everything is done inside here with the correct timing.
16
+	$wl_metabox = new WL_Metabox(); // Everything is done inside here with the correct timing.
17 17
 }
18 18
 
19
-if ( is_admin() ) {
20
-	add_action( 'load-post.php', 'wl_register_metaboxes' );
21
-	add_action( 'load-post-new.php', 'wl_register_metaboxes' );
19
+if (is_admin()) {
20
+	add_action('load-post.php', 'wl_register_metaboxes');
21
+	add_action('load-post-new.php', 'wl_register_metaboxes');
22 22
 }
23 23
 
24 24
 
@@ -27,110 +27,108 @@  discard block
 block discarded – undo
27 27
  *
28 28
  * @param string $post_type The type of the current open post.
29 29
  */
30
-function wl_admin_add_entities_meta_box( $post_type ) {
30
+function wl_admin_add_entities_meta_box($post_type) {
31 31
 
32 32
 	// Bail out if the post type doesn't support a TinyMCE editor.
33
-	if ( ! post_type_supports( $post_type, 'editor' ) ) {
33
+	if ( ! post_type_supports($post_type, 'editor')) {
34 34
 		return;
35 35
 	}
36 36
 
37 37
 	// Add main meta box for related entities and 4W.
38 38
 	add_meta_box(
39
-		'wordlift_entities_box', __( 'WordLift', 'wordlift' ), 'wl_entities_box_content', $post_type, 'side', 'high'
39
+		'wordlift_entities_box', __('WordLift', 'wordlift'), 'wl_entities_box_content', $post_type, 'side', 'high'
40 40
 	);
41 41
 }
42 42
 
43
-add_action( 'add_meta_boxes', 'wl_admin_add_entities_meta_box' );
43
+add_action('add_meta_boxes', 'wl_admin_add_entities_meta_box');
44 44
 
45 45
 /**
46 46
  * Displays the meta box contents (called by *add_meta_box* callback).
47 47
  *
48 48
  * @param WP_Post $post The current post.
49 49
  */
50
-function wl_entities_box_content( $post ) {
50
+function wl_entities_box_content($post) {
51 51
 
52 52
 	// Angularjs edit-post widget wrapper.
53 53
 	echo '<div id="wordlift-edit-post-outer-wrapper"></div>';
54 54
 
55 55
 	// Angularjs edit-post widget classification boxes configuration.
56
-	$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
56
+	$classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES);
57 57
 
58 58
 	// Array to store all related entities ids.
59 59
 	$all_referenced_entities_ids = array();
60 60
 
61 61
 	// Add selected entities to classification_boxes.
62
-	foreach ( $classification_boxes as $i => $box ) {
62
+	foreach ($classification_boxes as $i => $box) {
63 63
 		// Build the proper relation name.
64 64
 		$relation_name = $box['id'];
65 65
 
66 66
 		// Get the entity referenced from the post content.
67
-		$entity_uris = Wordlift_Content_Filter_Service::get_instance()->get_entity_uris( $post->post_content );
67
+		$entity_uris = Wordlift_Content_Filter_Service::get_instance()->get_entity_uris($post->post_content);
68 68
 
69 69
 		// Enhance current box selected entities.
70
-		$classification_boxes[ $i ]['selectedEntities'] = $entity_uris;
70
+		$classification_boxes[$i]['selectedEntities'] = $entity_uris;
71 71
 
72 72
 		// Maps the URIs to entity posts.
73 73
 		$entity_service = Wordlift_Entity_Service::get_instance();
74 74
 
75 75
 		// Replace all entity URI's with post ID's if found or null if there is no related post.
76
-		$entity_ids = array_map( function ( $item ) use ( $entity_service ) {
76
+		$entity_ids = array_map(function($item) use ($entity_service) {
77 77
 			// Return entity post by the entity URI or null.
78
-			$post = $entity_service->get_entity_post_by_uri( $item );
78
+			$post = $entity_service->get_entity_post_by_uri($item);
79 79
 
80 80
 			// Check that the post object is not null.
81
-			if ( ! empty( $post ) ) {
81
+			if ( ! empty($post)) {
82 82
 				return $post->ID;
83 83
 			}
84
-		}, $entity_uris );
84
+		}, $entity_uris);
85 85
 		// Store the entity ids for all the 4W.
86
-		$all_referenced_entities_ids = array_merge( $all_referenced_entities_ids, $entity_ids );
86
+		$all_referenced_entities_ids = array_merge($all_referenced_entities_ids, $entity_ids);
87 87
 
88 88
 	}
89 89
 	// Json encoding for classification boxes structure.
90
-	$classification_boxes = wp_json_encode( $classification_boxes );
90
+	$classification_boxes = wp_json_encode($classification_boxes);
91 91
 
92 92
 	// Ensure there are no repetitions of the referenced entities.
93
-	$all_referenced_entities_ids = array_unique( $all_referenced_entities_ids );
93
+	$all_referenced_entities_ids = array_unique($all_referenced_entities_ids);
94 94
 
95 95
 	// Remove all null, false and empty strings.
96 96
 	// NULL is being returned in some cases, when there is not related post, so we need to remove it.
97
-	$all_referenced_entities_ids = array_filter( $all_referenced_entities_ids );
97
+	$all_referenced_entities_ids = array_filter($all_referenced_entities_ids);
98 98
 
99 99
 	// Build the entity storage object.
100 100
 	$referenced_entities_obj = array();
101
-	foreach ( $all_referenced_entities_ids as $referenced_entity ) {
102
-		$entity                                   = wl_serialize_entity( $referenced_entity );
103
-		$referenced_entities_obj[ $entity['id'] ] = $entity;
101
+	foreach ($all_referenced_entities_ids as $referenced_entity) {
102
+		$entity                                   = wl_serialize_entity($referenced_entity);
103
+		$referenced_entities_obj[$entity['id']] = $entity;
104 104
 	}
105 105
 
106
-	$referenced_entities_obj = empty( $referenced_entities_obj ) ?
107
-		'{}' : wp_json_encode( $referenced_entities_obj );
106
+	$referenced_entities_obj = empty($referenced_entities_obj) ?
107
+		'{}' : wp_json_encode($referenced_entities_obj);
108 108
 
109 109
 	$published_place_id  = get_post_meta(
110 110
 		$post->ID, Wordlift_Schema_Service::FIELD_LOCATION_CREATED, true
111 111
 	);
112
-	$published_place_obj = ( $published_place_id ) ?
113
-		wp_json_encode( wl_serialize_entity( $published_place_id ) ) :
114
-		'undefined';
112
+	$published_place_obj = ($published_place_id) ?
113
+		wp_json_encode(wl_serialize_entity($published_place_id)) : 'undefined';
115 114
 
116 115
 	$topic_id  = get_post_meta(
117 116
 		$post->ID, Wordlift_Schema_Service::FIELD_TOPIC, true
118 117
 	);
119
-	$topic_obj = ( $topic_id ) ?
120
-		wp_json_encode( wl_serialize_entity( $topic_id ) ) :
121
-		'undefined';
118
+	$topic_obj = ($topic_id) ?
119
+		wp_json_encode(wl_serialize_entity($topic_id)) : 'undefined';
122 120
 
123 121
 	$configuration_service = Wordlift_Configuration_Service::get_instance();
124 122
 
125 123
 	$default_thumbnail_path = WL_DEFAULT_THUMBNAIL_PATH;
126 124
 	$default_path           = WL_DEFAULT_PATH;
127 125
 	$dataset_uri            = $configuration_service->get_dataset_uri();
128
-	$current_post_uri       = wl_get_entity_uri( $post->ID );
126
+	$current_post_uri       = wl_get_entity_uri($post->ID);
129 127
 
130 128
 	// Retrieve the current post author.
131
-	$post_author = get_userdata( $post->post_author )->display_name;
129
+	$post_author = get_userdata($post->post_author)->display_name;
132 130
 	// Retrive the published date.
133
-	$published_date = get_the_time( 'Y-m-d', $post->ID );
131
+	$published_date = get_the_time('Y-m-d', $post->ID);
134 132
 	// Current language.
135 133
 	$current_language = $configuration_service->get_language_code();
136 134
 
Please login to merge, or discard this patch.
src/includes/class-wordlift.php 1 patch
Indentation   +1369 added lines, -1369 removed lines patch added patch discarded remove patch
@@ -29,1416 +29,1416 @@
 block discarded – undo
29 29
  */
30 30
 class Wordlift {
31 31
 
32
-	/**
33
-	 * The loader that's responsible for maintaining and registering all hooks that power
34
-	 * the plugin.
35
-	 *
36
-	 * @since    1.0.0
37
-	 * @access   protected
38
-	 * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
39
-	 */
40
-	protected $loader;
41
-
42
-	/**
43
-	 * The unique identifier of this plugin.
44
-	 *
45
-	 * @since    1.0.0
46
-	 * @access   protected
47
-	 * @var      string $plugin_name The string used to uniquely identify this plugin.
48
-	 */
49
-	protected $plugin_name;
50
-
51
-	/**
52
-	 * The current version of the plugin.
53
-	 *
54
-	 * @since    1.0.0
55
-	 * @access   protected
56
-	 * @var      string $version The current version of the plugin.
57
-	 */
58
-	protected $version;
59
-
60
-	/**
61
-	 * The {@link Wordlift_Tinymce_Adapter} instance.
62
-	 *
63
-	 * @since  3.12.0
64
-	 * @access protected
65
-	 * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
66
-	 */
67
-	protected $tinymce_adapter;
68
-
69
-	/**
70
-	 * The Thumbnail service.
71
-	 *
72
-	 * @since  3.1.5
73
-	 * @access private
74
-	 * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
75
-	 */
76
-	private $thumbnail_service;
77
-
78
-	/**
79
-	 * The UI service.
80
-	 *
81
-	 * @since  3.2.0
82
-	 * @access private
83
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
84
-	 */
85
-	private $ui_service;
86
-
87
-	/**
88
-	 * The Schema service.
89
-	 *
90
-	 * @since  3.3.0
91
-	 * @access protected
92
-	 * @var \Wordlift_Schema_Service $schema_service The Schema service.
93
-	 */
94
-	protected $schema_service;
95
-
96
-	/**
97
-	 * The Entity service.
98
-	 *
99
-	 * @since  3.1.0
100
-	 * @access protected
101
-	 * @var \Wordlift_Entity_Service $entity_service The Entity service.
102
-	 */
103
-	protected $entity_service;
104
-
105
-	/**
106
-	 * The Topic Taxonomy service.
107
-	 *
108
-	 * @since  3.5.0
109
-	 * @access private
110
-	 * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
111
-	 */
112
-	private $topic_taxonomy_service;
113
-
114
-	/**
115
-	 * The User service.
116
-	 *
117
-	 * @since  3.1.7
118
-	 * @access protected
119
-	 * @var \Wordlift_User_Service $user_service The User service.
120
-	 */
121
-	protected $user_service;
122
-
123
-	/**
124
-	 * The Timeline service.
125
-	 *
126
-	 * @since  3.1.0
127
-	 * @access private
128
-	 * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
129
-	 */
130
-	private $timeline_service;
131
-
132
-	/**
133
-	 * The Redirect service.
134
-	 *
135
-	 * @since  3.2.0
136
-	 * @access private
137
-	 * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
138
-	 */
139
-	private $redirect_service;
140
-
141
-	/**
142
-	 * The Notice service.
143
-	 *
144
-	 * @since  3.3.0
145
-	 * @access private
146
-	 * @var \Wordlift_Notice_Service $notice_service The Notice service.
147
-	 */
148
-	private $notice_service;
149
-
150
-	/**
151
-	 * The Entity list customization.
152
-	 *
153
-	 * @since  3.3.0
154
-	 * @access private
155
-	 * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
156
-	 */
157
-	private $entity_list_service;
158
-
159
-	/**
160
-	 * The Entity Types Taxonomy Walker.
161
-	 *
162
-	 * @since  3.1.0
163
-	 * @access private
164
-	 * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
165
-	 */
166
-	private $entity_types_taxonomy_walker;
167
-
168
-	/**
169
-	 * The ShareThis service.
170
-	 *
171
-	 * @since  3.2.0
172
-	 * @access private
173
-	 * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
174
-	 */
175
-	private $sharethis_service;
176
-
177
-	/**
178
-	 * The PrimaShop adapter.
179
-	 *
180
-	 * @since  3.2.3
181
-	 * @access private
182
-	 * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
183
-	 */
184
-	private $primashop_adapter;
185
-
186
-	/**
187
-	 * The WordLift Dashboard adapter.
188
-	 *
189
-	 * @since  3.4.0
190
-	 * @access private
191
-	 * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
192
-	 */
193
-	private $dashboard_service;
194
-
195
-	/**
196
-	 * The entity type service.
197
-	 *
198
-	 * @since  3.6.0
199
-	 * @access private
200
-	 * @var \Wordlift_Entity_Post_Type_Service
201
-	 */
202
-	private $entity_post_type_service;
203
-
204
-	/**
205
-	 * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
206
-	 *
207
-	 * @since  3.6.0
208
-	 * @access private
209
-	 * @var \Wordlift_Entity_Link_Service
210
-	 */
211
-	private $entity_link_service;
212
-
213
-	/**
214
-	 * A {@link Wordlift_Sparql_Service} instance.
215
-	 *
216
-	 * @var    3.6.0
217
-	 * @access protected
218
-	 * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
219
-	 */
220
-	protected $sparql_service;
221
-
222
-	/**
223
-	 * A {@link Wordlift_Import_Service} instance.
224
-	 *
225
-	 * @since  3.6.0
226
-	 * @access private
227
-	 * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
228
-	 */
229
-	private $import_service;
230
-
231
-	/**
232
-	 * A {@link Wordlift_Rebuild_Service} instance.
233
-	 *
234
-	 * @since  3.6.0
235
-	 * @access private
236
-	 * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
237
-	 */
238
-	private $rebuild_service;
239
-
240
-	/**
241
-	 * A {@link Wordlift_Jsonld_Service} instance.
242
-	 *
243
-	 * @since  3.7.0
244
-	 * @access protected
245
-	 * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
246
-	 */
247
-	protected $jsonld_service;
248
-
249
-	/**
250
-	 * A {@link Wordlift_Website_Jsonld_Converter} instance.
251
-	 *
252
-	 * @since  3.14.0
253
-	 * @access protected
254
-	 * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
255
-	 */
256
-	protected $jsonld_website_converter;
257
-
258
-	/**
259
-	 *
260
-	 * @since  3.7.0
261
-	 * @access private
262
-	 * @var \Wordlift_Property_Factory $property_factory
263
-	 */
264
-	private $property_factory;
265
-
266
-	/**
267
-	 * The 'Download Your Data' page.
268
-	 *
269
-	 * @since  3.6.0
270
-	 * @access private
271
-	 * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
272
-	 */
273
-	private $download_your_data_page;
274
-
275
-	/**
276
-	 * The 'WordLift Settings' page.
277
-	 *
278
-	 * @since  3.11.0
279
-	 * @access protected
280
-	 * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
281
-	 */
282
-	protected $settings_page;
283
-
284
-	/**
285
-	 * The 'WordLift Batch analysis' page.
286
-	 *
287
-	 * @since  3.14.0
288
-	 * @access protected
289
-	 * @var \Wordlift_Batch_Analysis_Page $sbatch_analysis_page The 'WordLift batcch analysis' page.
290
-	 */
291
-	protected $batch_analysis_page;
292
-
293
-	/**
294
-	 * The install wizard page.
295
-	 *
296
-	 * @since  3.9.0
297
-	 * @access private
298
-	 * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
299
-	 */
300
-	private $admin_setup;
301
-
302
-	/**
303
-	 * The Content Filter Service hooks up to the 'the_content' filter and provides
304
-	 * linking of entities to their pages.
305
-	 *
306
-	 * @since  3.8.0
307
-	 * @access private
308
-	 * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
309
-	 */
310
-	private $content_filter_service;
311
-
312
-	/**
313
-	 * A {@link Wordlift_Key_Validation_Service} instance.
314
-	 *
315
-	 * @since  3.9.0
316
-	 * @access private
317
-	 * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
318
-	 */
319
-	private $key_validation_service;
320
-
321
-	/**
322
-	 * A {@link Wordlift_Rating_Service} instance.
323
-	 *
324
-	 * @since  3.10.0
325
-	 * @access private
326
-	 * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
327
-	 */
328
-	private $rating_service;
329
-
330
-	/**
331
-	 * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
332
-	 *
333
-	 * @since  3.10.0
334
-	 * @access protected
335
-	 * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
336
-	 */
337
-	protected $post_to_jsonld_converter;
338
-
339
-	/**
340
-	 * A {@link Wordlift_Configuration_Service} instance.
341
-	 *
342
-	 * @since  3.10.0
343
-	 * @access protected
344
-	 * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance.
345
-	 */
346
-	protected $configuration_service;
347
-
348
-	/**
349
-	 * A {@link Wordlift_Entity_Type_Service} instance.
350
-	 *
351
-	 * @since  3.10.0
352
-	 * @access protected
353
-	 * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance.
354
-	 */
355
-	protected $entity_type_service;
356
-
357
-	/**
358
-	 * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
359
-	 *
360
-	 * @since  3.10.0
361
-	 * @access protected
362
-	 * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
363
-	 */
364
-	protected $entity_post_to_jsonld_converter;
365
-
366
-	/**
367
-	 * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
368
-	 *
369
-	 * @since  3.10.0
370
-	 * @access protected
371
-	 * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
372
-	 */
373
-	protected $postid_to_jsonld_converter;
374
-
375
-	/**
376
-	 * The {@link Wordlift_Admin_Status_Page} class.
377
-	 *
378
-	 * @since  3.9.8
379
-	 * @access private
380
-	 * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class.
381
-	 */
382
-	private $status_page;
383
-
384
-	/**
385
-	 * The {@link Wordlift_Category_Taxonomy_Service} instance.
386
-	 *
387
-	 * @since  3.11.0
388
-	 * @access protected
389
-	 * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
390
-	 */
391
-	protected $category_taxonomy_service;
392
-
393
-	/**
394
-	 * The {@link Wordlift_Entity_Page_Service} instance.
395
-	 *
396
-	 * @since  3.11.0
397
-	 * @access protected
398
-	 * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
399
-	 */
400
-	protected $entity_page_service;
401
-
402
-	/**
403
-	 * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
404
-	 *
405
-	 * @since  3.11.0
406
-	 * @access protected
407
-	 * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
408
-	 */
409
-	protected $settings_page_action_link;
410
-
411
-	/**
412
-	 * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
413
-	 *
414
-	 * @since  3.11.0
415
-	 * @access protected
416
-	 * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
417
-	 */
418
-	protected $publisher_ajax_adapter;
419
-
420
-	/**
421
-	 * The {@link Wordlift_Admin_Input_Element} element renderer.
422
-	 *
423
-	 * @since  3.11.0
424
-	 * @access protected
425
-	 * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
426
-	 */
427
-	protected $input_element;
428
-
429
-	/**
430
-	 * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
431
-	 *
432
-	 * @since  3.13.0
433
-	 * @access protected
434
-	 * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
435
-	 */
436
-	protected $radio_input_element;
437
-
438
-	/**
439
-	 * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
440
-	 *
441
-	 * @since  3.11.0
442
-	 * @access protected
443
-	 * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
444
-	 */
445
-	protected $language_select_element;
446
-
447
-	/**
448
-	 * The {@link Wordlift_Admin_Publisher_Element} element renderer.
449
-	 *
450
-	 * @since  3.11.0
451
-	 * @access protected
452
-	 * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
453
-	 */
454
-	protected $publisher_element;
455
-
456
-	/**
457
-	 * The {@link Wordlift_Admin_Select2_Element} element renderer.
458
-	 *
459
-	 * @since  3.11.0
460
-	 * @access protected
461
-	 * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
462
-	 */
463
-	protected $select2_element;
464
-
465
-	/**
466
-	 * The controller for the entity type list admin page
467
-	 *
468
-	 * @since  3.11.0
469
-	 * @access private
470
-	 * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
471
-	 */
472
-	private $entity_type_admin_page;
473
-
474
-	/**
475
-	 * The controller for the entity type settings admin page
476
-	 *
477
-	 * @since  3.11.0
478
-	 * @access private
479
-	 * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
480
-	 */
481
-	private $entity_type_settings_admin_page;
482
-
483
-	/**
484
-	 * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
485
-	 *
486
-	 * @since  3.11.0
487
-	 * @access protected
488
-	 * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
489
-	 */
490
-	protected $related_entities_cloud_widget;
491
-
492
-	/**
493
-	 * The {@link Wordlift_Admin_Author_Element} instance.
494
-	 *
495
-	 * @since  3.14.0
496
-	 * @access protected
497
-	 * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
498
-	 */
499
-	protected $author_element;
500
-
501
-	/**
502
-	 * The {@link Wordlift_Batch_Analysis_Service} instance.
503
-	 *
504
-	 * @since  3.14.0
505
-	 * @access protected
506
-	 * @var \Wordlift_Batch_Analysis_Service $batch_analysis_service The {@link Wordlift_Batch_Analysis_Service} instance.
507
-	 */
508
-	protected $batch_analysis_service;
509
-
510
-	/**
511
-	 * The {@link Wordlift_Sample_Data_Service} instance.
512
-	 *
513
-	 * @since  3.12.0
514
-	 * @access protected
515
-	 * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
516
-	 */
517
-	protected $sample_data_service;
518
-
519
-	/**
520
-	 * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
521
-	 *
522
-	 * @since  3.12.0
523
-	 * @access protected
524
-	 * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
525
-	 */
526
-	protected $sample_data_ajax_adapter;
527
-
528
-	/**
529
-	 * The {@link Wordlift_Batch_Analysis_Adapter} instance.
530
-	 *
531
-	 * @since  3.14.2
532
-	 * @access protected
533
-	 * @var \Wordlift_Batch_Analysis_Adapter $batch_analysis_adapter The {@link Wordlift_Batch_Analysis_Adapter} instance.
534
-	 */
535
-	private $batch_analysis_adapter;
536
-
537
-	/**
538
-	 * The {@link Wordlift_Relation_Rebuild_Service} instance.
539
-	 *
540
-	 * @since  3.14.3
541
-	 * @access private
542
-	 * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance.
543
-	 */
544
-	private $relation_rebuild_service;
545
-
546
-	/**
547
-	 * The {@link Wordlift_Relation_Rebuild_Adapter} instance.
548
-	 *
549
-	 * @since  3.14.3
550
-	 * @access private
551
-	 * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance.
552
-	 */
553
-	private $relation_rebuild_adapter;
554
-
555
-	/**
556
-	 * {@link Wordlift}'s singleton instance.
557
-	 *
558
-	 * @since  3.15.0
559
-	 * @access protected
560
-	 * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
561
-	 */
562
-	protected $entity_type_adapter;
563
-
564
-	/**
565
-	 * The {@link Wordlift_Linked_Data_Service} instance.
566
-	 *
567
-	 * @since  3.15.0
568
-	 * @access protected
569
-	 * @var \Wordlift_Linked_Data_Service $linked_data_service The {@link Wordlift_Linked_Data_Service} instance.
570
-	 */
571
-	protected $linked_data_service;
572
-
573
-	/**
574
-	 * The {@link Wordlift_Storage_Factory} instance.
575
-	 *
576
-	 * @since  3.15.0
577
-	 * @access protected
578
-	 * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
579
-	 */
580
-	protected $storage_factory;
581
-
582
-	/**
583
-	 * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
584
-	 *
585
-	 * @since  3.15.0
586
-	 * @access protected
587
-	 * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
588
-	 */
589
-	protected $rendition_factory;
590
-
591
-	/**
592
-	 * The {@link Wordlift_Autocomplete_Service} instance.
593
-	 *
594
-	 * @since  3.15.0
595
-	 * @access private
596
-	 * @var \Wordlift_Autocomplete_Service $autocomplete_service The {@link Wordlift_Autocomplete_Service} instance.
597
-	 */
598
-	private $autocomplete_service;
599
-
600
-	/**
601
-	 * The {@link Wordlift_Autocomplete_Adapter} instance.
602
-	 *
603
-	 * @since  3.15.0
604
-	 * @access private
605
-	 * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
606
-	 */
607
-	private $autocomplete_adapter;
608
-
609
-	/**
610
-	 * The {@link Wordlift_Relation_Service} instance.
611
-	 *
612
-	 * @since  3.15.0
613
-	 * @access private
614
-	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
615
-	 */
616
-	private $relation_service;
617
-
618
-	/**
619
-	 * {@link Wordlift}'s singleton instance.
620
-	 *
621
-	 * @since  3.11.2
622
-	 * @access private
623
-	 * @var Wordlift $instance {@link Wordlift}'s singleton instance.
624
-	 */
625
-	private static $instance;
626
-
627
-	/**
628
-	 * Define the core functionality of the plugin.
629
-	 *
630
-	 * Set the plugin name and the plugin version that can be used throughout the plugin.
631
-	 * Load the dependencies, define the locale, and set the hooks for the admin area and
632
-	 * the public-facing side of the site.
633
-	 *
634
-	 * @since    1.0.0
635
-	 */
636
-	public function __construct() {
637
-
638
-		$this->plugin_name = 'wordlift';
639
-		$this->version     = '3.15.2';
640
-		$this->load_dependencies();
641
-		$this->set_locale();
642
-		$this->define_admin_hooks();
643
-		$this->define_public_hooks();
644
-
645
-		self::$instance = $this;
646
-
647
-	}
648
-
649
-	/**
650
-	 * Get the singleton instance.
651
-	 *
652
-	 * @since 3.11.2
653
-	 *
654
-	 * @return Wordlift The {@link Wordlift} singleton instance.
655
-	 */
656
-	public static function get_instance() {
657
-
658
-		return self::$instance;
659
-	}
660
-
661
-	/**
662
-	 * Load the required dependencies for this plugin.
663
-	 *
664
-	 * Include the following files that make up the plugin:
665
-	 *
666
-	 * - Wordlift_Loader. Orchestrates the hooks of the plugin.
667
-	 * - Wordlift_i18n. Defines internationalization functionality.
668
-	 * - Wordlift_Admin. Defines all hooks for the admin area.
669
-	 * - Wordlift_Public. Defines all hooks for the public side of the site.
670
-	 *
671
-	 * Create an instance of the loader which will be used to register the hooks
672
-	 * with WordPress.
673
-	 *
674
-	 * @since    1.0.0
675
-	 * @access   private
676
-	 */
677
-	private function load_dependencies() {
678
-
679
-		/**
680
-		 * The class responsible for orchestrating the actions and filters of the
681
-		 * core plugin.
682
-		 */
683
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
684
-
685
-		/**
686
-		 * The class responsible for defining internationalization functionality
687
-		 * of the plugin.
688
-		 */
689
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
690
-
691
-		/**
692
-		 * WordLift's supported languages.
693
-		 */
694
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
695
-
696
-		/**
697
-		 * Provide support functions to sanitize data.
698
-		 */
699
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
700
-
701
-		/** Services. */
702
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
703
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
704
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
705
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
706
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
707
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
708
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
709
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
710
-
711
-		/**
712
-		 * The Query builder.
713
-		 */
714
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
715
-
716
-		/**
717
-		 * The Schema service.
718
-		 */
719
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
720
-
721
-		/**
722
-		 * The schema:url property service.
723
-		 */
724
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
725
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
726
-
727
-		/**
728
-		 * The UI service.
729
-		 */
730
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
731
-
732
-		/**
733
-		 * The Thumbnail service.
734
-		 */
735
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
736
-
737
-		/**
738
-		 * The Entity Types Taxonomy service.
739
-		 */
740
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
741
-
742
-		/**
743
-		 * The Entity service.
744
-		 */
745
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
746
-
747
-		// Add the entity rating service.
748
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
749
-
750
-		/**
751
-		 * The User service.
752
-		 */
753
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
754
-
755
-		/**
756
-		 * The Timeline service.
757
-		 */
758
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
759
-
760
-		/**
761
-		 * The Topic Taxonomy service.
762
-		 */
763
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
764
-
765
-		/**
766
-		 * The SPARQL service.
767
-		 */
768
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
769
-
770
-		/**
771
-		 * The WordLift import service.
772
-		 */
773
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
774
-
775
-		/**
776
-		 * The WordLift URI service.
777
-		 */
778
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
779
-
780
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
781
-
782
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
783
-
784
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
785
-
786
-		/**
787
-		 * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
788
-		 */
789
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
790
-
791
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
792
-
793
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
794
-
795
-		/**
796
-		 * Load the converters.
797
-		 */
798
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
799
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
800
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
801
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
802
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
803
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
804
-
805
-		/**
806
-		 * Load the content filter.
807
-		 */
808
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
809
-
810
-		/*
32
+    /**
33
+     * The loader that's responsible for maintaining and registering all hooks that power
34
+     * the plugin.
35
+     *
36
+     * @since    1.0.0
37
+     * @access   protected
38
+     * @var      Wordlift_Loader $loader Maintains and registers all hooks for the plugin.
39
+     */
40
+    protected $loader;
41
+
42
+    /**
43
+     * The unique identifier of this plugin.
44
+     *
45
+     * @since    1.0.0
46
+     * @access   protected
47
+     * @var      string $plugin_name The string used to uniquely identify this plugin.
48
+     */
49
+    protected $plugin_name;
50
+
51
+    /**
52
+     * The current version of the plugin.
53
+     *
54
+     * @since    1.0.0
55
+     * @access   protected
56
+     * @var      string $version The current version of the plugin.
57
+     */
58
+    protected $version;
59
+
60
+    /**
61
+     * The {@link Wordlift_Tinymce_Adapter} instance.
62
+     *
63
+     * @since  3.12.0
64
+     * @access protected
65
+     * @var \Wordlift_Tinymce_Adapter $tinymce_adapter The {@link Wordlift_Tinymce_Adapter} instance.
66
+     */
67
+    protected $tinymce_adapter;
68
+
69
+    /**
70
+     * The Thumbnail service.
71
+     *
72
+     * @since  3.1.5
73
+     * @access private
74
+     * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service.
75
+     */
76
+    private $thumbnail_service;
77
+
78
+    /**
79
+     * The UI service.
80
+     *
81
+     * @since  3.2.0
82
+     * @access private
83
+     * @var \Wordlift_UI_Service $ui_service The UI service.
84
+     */
85
+    private $ui_service;
86
+
87
+    /**
88
+     * The Schema service.
89
+     *
90
+     * @since  3.3.0
91
+     * @access protected
92
+     * @var \Wordlift_Schema_Service $schema_service The Schema service.
93
+     */
94
+    protected $schema_service;
95
+
96
+    /**
97
+     * The Entity service.
98
+     *
99
+     * @since  3.1.0
100
+     * @access protected
101
+     * @var \Wordlift_Entity_Service $entity_service The Entity service.
102
+     */
103
+    protected $entity_service;
104
+
105
+    /**
106
+     * The Topic Taxonomy service.
107
+     *
108
+     * @since  3.5.0
109
+     * @access private
110
+     * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service.
111
+     */
112
+    private $topic_taxonomy_service;
113
+
114
+    /**
115
+     * The User service.
116
+     *
117
+     * @since  3.1.7
118
+     * @access protected
119
+     * @var \Wordlift_User_Service $user_service The User service.
120
+     */
121
+    protected $user_service;
122
+
123
+    /**
124
+     * The Timeline service.
125
+     *
126
+     * @since  3.1.0
127
+     * @access private
128
+     * @var \Wordlift_Timeline_Service $timeline_service The Timeline service.
129
+     */
130
+    private $timeline_service;
131
+
132
+    /**
133
+     * The Redirect service.
134
+     *
135
+     * @since  3.2.0
136
+     * @access private
137
+     * @var \Wordlift_Redirect_Service $redirect_service The Redirect service.
138
+     */
139
+    private $redirect_service;
140
+
141
+    /**
142
+     * The Notice service.
143
+     *
144
+     * @since  3.3.0
145
+     * @access private
146
+     * @var \Wordlift_Notice_Service $notice_service The Notice service.
147
+     */
148
+    private $notice_service;
149
+
150
+    /**
151
+     * The Entity list customization.
152
+     *
153
+     * @since  3.3.0
154
+     * @access private
155
+     * @var \Wordlift_Entity_List_Service $entity_list_service The Entity list service.
156
+     */
157
+    private $entity_list_service;
158
+
159
+    /**
160
+     * The Entity Types Taxonomy Walker.
161
+     *
162
+     * @since  3.1.0
163
+     * @access private
164
+     * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker
165
+     */
166
+    private $entity_types_taxonomy_walker;
167
+
168
+    /**
169
+     * The ShareThis service.
170
+     *
171
+     * @since  3.2.0
172
+     * @access private
173
+     * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service.
174
+     */
175
+    private $sharethis_service;
176
+
177
+    /**
178
+     * The PrimaShop adapter.
179
+     *
180
+     * @since  3.2.3
181
+     * @access private
182
+     * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter.
183
+     */
184
+    private $primashop_adapter;
185
+
186
+    /**
187
+     * The WordLift Dashboard adapter.
188
+     *
189
+     * @since  3.4.0
190
+     * @access private
191
+     * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service;
192
+     */
193
+    private $dashboard_service;
194
+
195
+    /**
196
+     * The entity type service.
197
+     *
198
+     * @since  3.6.0
199
+     * @access private
200
+     * @var \Wordlift_Entity_Post_Type_Service
201
+     */
202
+    private $entity_post_type_service;
203
+
204
+    /**
205
+     * The entity link service used to mangle links to entities with a custom slug or even w/o a slug.
206
+     *
207
+     * @since  3.6.0
208
+     * @access private
209
+     * @var \Wordlift_Entity_Link_Service
210
+     */
211
+    private $entity_link_service;
212
+
213
+    /**
214
+     * A {@link Wordlift_Sparql_Service} instance.
215
+     *
216
+     * @var    3.6.0
217
+     * @access protected
218
+     * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance.
219
+     */
220
+    protected $sparql_service;
221
+
222
+    /**
223
+     * A {@link Wordlift_Import_Service} instance.
224
+     *
225
+     * @since  3.6.0
226
+     * @access private
227
+     * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance.
228
+     */
229
+    private $import_service;
230
+
231
+    /**
232
+     * A {@link Wordlift_Rebuild_Service} instance.
233
+     *
234
+     * @since  3.6.0
235
+     * @access private
236
+     * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance.
237
+     */
238
+    private $rebuild_service;
239
+
240
+    /**
241
+     * A {@link Wordlift_Jsonld_Service} instance.
242
+     *
243
+     * @since  3.7.0
244
+     * @access protected
245
+     * @var \Wordlift_Jsonld_Service $jsonld_service A {@link Wordlift_Jsonld_Service} instance.
246
+     */
247
+    protected $jsonld_service;
248
+
249
+    /**
250
+     * A {@link Wordlift_Website_Jsonld_Converter} instance.
251
+     *
252
+     * @since  3.14.0
253
+     * @access protected
254
+     * @var \Wordlift_Website_Jsonld_Converter $jsonld_website_converter A {@link Wordlift_Website_Jsonld_Converter} instance.
255
+     */
256
+    protected $jsonld_website_converter;
257
+
258
+    /**
259
+     *
260
+     * @since  3.7.0
261
+     * @access private
262
+     * @var \Wordlift_Property_Factory $property_factory
263
+     */
264
+    private $property_factory;
265
+
266
+    /**
267
+     * The 'Download Your Data' page.
268
+     *
269
+     * @since  3.6.0
270
+     * @access private
271
+     * @var \Wordlift_Admin_Download_Your_Data_Page $download_your_data_page The 'Download Your Data' page.
272
+     */
273
+    private $download_your_data_page;
274
+
275
+    /**
276
+     * The 'WordLift Settings' page.
277
+     *
278
+     * @since  3.11.0
279
+     * @access protected
280
+     * @var \Wordlift_Admin_Settings_Page $settings_page The 'WordLift Settings' page.
281
+     */
282
+    protected $settings_page;
283
+
284
+    /**
285
+     * The 'WordLift Batch analysis' page.
286
+     *
287
+     * @since  3.14.0
288
+     * @access protected
289
+     * @var \Wordlift_Batch_Analysis_Page $sbatch_analysis_page The 'WordLift batcch analysis' page.
290
+     */
291
+    protected $batch_analysis_page;
292
+
293
+    /**
294
+     * The install wizard page.
295
+     *
296
+     * @since  3.9.0
297
+     * @access private
298
+     * @var \Wordlift_Admin_Setup $admin_setup The Install wizard.
299
+     */
300
+    private $admin_setup;
301
+
302
+    /**
303
+     * The Content Filter Service hooks up to the 'the_content' filter and provides
304
+     * linking of entities to their pages.
305
+     *
306
+     * @since  3.8.0
307
+     * @access private
308
+     * @var \Wordlift_Content_Filter_Service $content_filter_service A {@link Wordlift_Content_Filter_Service} instance.
309
+     */
310
+    private $content_filter_service;
311
+
312
+    /**
313
+     * A {@link Wordlift_Key_Validation_Service} instance.
314
+     *
315
+     * @since  3.9.0
316
+     * @access private
317
+     * @var Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance.
318
+     */
319
+    private $key_validation_service;
320
+
321
+    /**
322
+     * A {@link Wordlift_Rating_Service} instance.
323
+     *
324
+     * @since  3.10.0
325
+     * @access private
326
+     * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
327
+     */
328
+    private $rating_service;
329
+
330
+    /**
331
+     * A {@link Wordlift_Post_To_Jsonld_Converter} instance.
332
+     *
333
+     * @since  3.10.0
334
+     * @access protected
335
+     * @var \Wordlift_Post_To_Jsonld_Converter $post_to_jsonld_converter A {@link Wordlift_Post_To_Jsonld_Converter} instance.
336
+     */
337
+    protected $post_to_jsonld_converter;
338
+
339
+    /**
340
+     * A {@link Wordlift_Configuration_Service} instance.
341
+     *
342
+     * @since  3.10.0
343
+     * @access protected
344
+     * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance.
345
+     */
346
+    protected $configuration_service;
347
+
348
+    /**
349
+     * A {@link Wordlift_Entity_Type_Service} instance.
350
+     *
351
+     * @since  3.10.0
352
+     * @access protected
353
+     * @var \Wordlift_Entity_Type_Service $entity_type_service A {@link Wordlift_Entity_Type_Service} instance.
354
+     */
355
+    protected $entity_type_service;
356
+
357
+    /**
358
+     * A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
359
+     *
360
+     * @since  3.10.0
361
+     * @access protected
362
+     * @var \Wordlift_Entity_Post_To_Jsonld_Converter $entity_post_to_jsonld_converter A {@link Wordlift_Entity_Post_To_Jsonld_Converter} instance.
363
+     */
364
+    protected $entity_post_to_jsonld_converter;
365
+
366
+    /**
367
+     * A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
368
+     *
369
+     * @since  3.10.0
370
+     * @access protected
371
+     * @var \Wordlift_Postid_To_Jsonld_Converter $postid_to_jsonld_converter A {@link Wordlift_Postid_To_Jsonld_Converter} instance.
372
+     */
373
+    protected $postid_to_jsonld_converter;
374
+
375
+    /**
376
+     * The {@link Wordlift_Admin_Status_Page} class.
377
+     *
378
+     * @since  3.9.8
379
+     * @access private
380
+     * @var \Wordlift_Admin_Status_Page $status_page The {@link Wordlift_Admin_Status_Page} class.
381
+     */
382
+    private $status_page;
383
+
384
+    /**
385
+     * The {@link Wordlift_Category_Taxonomy_Service} instance.
386
+     *
387
+     * @since  3.11.0
388
+     * @access protected
389
+     * @var \Wordlift_Category_Taxonomy_Service $category_taxonomy_service The {@link Wordlift_Category_Taxonomy_Service} instance.
390
+     */
391
+    protected $category_taxonomy_service;
392
+
393
+    /**
394
+     * The {@link Wordlift_Entity_Page_Service} instance.
395
+     *
396
+     * @since  3.11.0
397
+     * @access protected
398
+     * @var \Wordlift_Entity_Page_Service $entity_page_service The {@link Wordlift_Entity_Page_Service} instance.
399
+     */
400
+    protected $entity_page_service;
401
+
402
+    /**
403
+     * The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
404
+     *
405
+     * @since  3.11.0
406
+     * @access protected
407
+     * @var \Wordlift_Admin_Settings_Page_Action_Link $settings_page_action_link The {@link Wordlift_Admin_Settings_Page_Action_Link} class.
408
+     */
409
+    protected $settings_page_action_link;
410
+
411
+    /**
412
+     * The {@link Wordlift_Publisher_Ajax_Adapter} instance.
413
+     *
414
+     * @since  3.11.0
415
+     * @access protected
416
+     * @var \Wordlift_Publisher_Ajax_Adapter $publisher_ajax_adapter The {@link Wordlift_Publisher_Ajax_Adapter} instance.
417
+     */
418
+    protected $publisher_ajax_adapter;
419
+
420
+    /**
421
+     * The {@link Wordlift_Admin_Input_Element} element renderer.
422
+     *
423
+     * @since  3.11.0
424
+     * @access protected
425
+     * @var \Wordlift_Admin_Input_Element $input_element The {@link Wordlift_Admin_Input_Element} element renderer.
426
+     */
427
+    protected $input_element;
428
+
429
+    /**
430
+     * The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
431
+     *
432
+     * @since  3.13.0
433
+     * @access protected
434
+     * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element The {@link Wordlift_Admin_Radio_Input_Element} element renderer.
435
+     */
436
+    protected $radio_input_element;
437
+
438
+    /**
439
+     * The {@link Wordlift_Admin_Language_Select_Element} element renderer.
440
+     *
441
+     * @since  3.11.0
442
+     * @access protected
443
+     * @var \Wordlift_Admin_Language_Select_Element $language_select_element The {@link Wordlift_Admin_Language_Select_Element} element renderer.
444
+     */
445
+    protected $language_select_element;
446
+
447
+    /**
448
+     * The {@link Wordlift_Admin_Publisher_Element} element renderer.
449
+     *
450
+     * @since  3.11.0
451
+     * @access protected
452
+     * @var \Wordlift_Admin_Publisher_Element $publisher_element The {@link Wordlift_Admin_Publisher_Element} element renderer.
453
+     */
454
+    protected $publisher_element;
455
+
456
+    /**
457
+     * The {@link Wordlift_Admin_Select2_Element} element renderer.
458
+     *
459
+     * @since  3.11.0
460
+     * @access protected
461
+     * @var \Wordlift_Admin_Select2_Element $select2_element The {@link Wordlift_Admin_Select2_Element} element renderer.
462
+     */
463
+    protected $select2_element;
464
+
465
+    /**
466
+     * The controller for the entity type list admin page
467
+     *
468
+     * @since  3.11.0
469
+     * @access private
470
+     * @var \Wordlift_Admin_Entity_Taxonomy_List_Page $entity_type_admin_page The {@link Wordlift_Admin_Entity_Taxonomy_List_Page} class.
471
+     */
472
+    private $entity_type_admin_page;
473
+
474
+    /**
475
+     * The controller for the entity type settings admin page
476
+     *
477
+     * @since  3.11.0
478
+     * @access private
479
+     * @var \Wordlift_Admin_Entity_Type_Settings $entity_type_settings_admin_page The {@link Wordlift_Admin_Entity_Type_Settings} class.
480
+     */
481
+    private $entity_type_settings_admin_page;
482
+
483
+    /**
484
+     * The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
485
+     *
486
+     * @since  3.11.0
487
+     * @access protected
488
+     * @var \Wordlift_Related_Entities_Cloud_Widget $related_entities_cloud_widget The {@link Wordlift_Related_Entities_Cloud_Widget} instance.
489
+     */
490
+    protected $related_entities_cloud_widget;
491
+
492
+    /**
493
+     * The {@link Wordlift_Admin_Author_Element} instance.
494
+     *
495
+     * @since  3.14.0
496
+     * @access protected
497
+     * @var \Wordlift_Admin_Author_Element $author_element The {@link Wordlift_Admin_Author_Element} instance.
498
+     */
499
+    protected $author_element;
500
+
501
+    /**
502
+     * The {@link Wordlift_Batch_Analysis_Service} instance.
503
+     *
504
+     * @since  3.14.0
505
+     * @access protected
506
+     * @var \Wordlift_Batch_Analysis_Service $batch_analysis_service The {@link Wordlift_Batch_Analysis_Service} instance.
507
+     */
508
+    protected $batch_analysis_service;
509
+
510
+    /**
511
+     * The {@link Wordlift_Sample_Data_Service} instance.
512
+     *
513
+     * @since  3.12.0
514
+     * @access protected
515
+     * @var \Wordlift_Sample_Data_Service $sample_data_service The {@link Wordlift_Sample_Data_Service} instance.
516
+     */
517
+    protected $sample_data_service;
518
+
519
+    /**
520
+     * The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
521
+     *
522
+     * @since  3.12.0
523
+     * @access protected
524
+     * @var \Wordlift_Sample_Data_Ajax_Adapter $sample_data_ajax_adapter The {@link Wordlift_Sample_Data_Ajax_Adapter} instance.
525
+     */
526
+    protected $sample_data_ajax_adapter;
527
+
528
+    /**
529
+     * The {@link Wordlift_Batch_Analysis_Adapter} instance.
530
+     *
531
+     * @since  3.14.2
532
+     * @access protected
533
+     * @var \Wordlift_Batch_Analysis_Adapter $batch_analysis_adapter The {@link Wordlift_Batch_Analysis_Adapter} instance.
534
+     */
535
+    private $batch_analysis_adapter;
536
+
537
+    /**
538
+     * The {@link Wordlift_Relation_Rebuild_Service} instance.
539
+     *
540
+     * @since  3.14.3
541
+     * @access private
542
+     * @var \Wordlift_Relation_Rebuild_Service $relation_rebuild_service The {@link Wordlift_Relation_Rebuild_Service} instance.
543
+     */
544
+    private $relation_rebuild_service;
545
+
546
+    /**
547
+     * The {@link Wordlift_Relation_Rebuild_Adapter} instance.
548
+     *
549
+     * @since  3.14.3
550
+     * @access private
551
+     * @var \Wordlift_Relation_Rebuild_Adapter $relation_rebuild_adapter The {@link Wordlift_Relation_Rebuild_Adapter} instance.
552
+     */
553
+    private $relation_rebuild_adapter;
554
+
555
+    /**
556
+     * {@link Wordlift}'s singleton instance.
557
+     *
558
+     * @since  3.15.0
559
+     * @access protected
560
+     * @var \Wordlift_Entity_Type_Adapter $entity_type_adapter The {@link Wordlift_Entity_Type_Adapter} instance.
561
+     */
562
+    protected $entity_type_adapter;
563
+
564
+    /**
565
+     * The {@link Wordlift_Linked_Data_Service} instance.
566
+     *
567
+     * @since  3.15.0
568
+     * @access protected
569
+     * @var \Wordlift_Linked_Data_Service $linked_data_service The {@link Wordlift_Linked_Data_Service} instance.
570
+     */
571
+    protected $linked_data_service;
572
+
573
+    /**
574
+     * The {@link Wordlift_Storage_Factory} instance.
575
+     *
576
+     * @since  3.15.0
577
+     * @access protected
578
+     * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Storage_Factory} instance.
579
+     */
580
+    protected $storage_factory;
581
+
582
+    /**
583
+     * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
584
+     *
585
+     * @since  3.15.0
586
+     * @access protected
587
+     * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
588
+     */
589
+    protected $rendition_factory;
590
+
591
+    /**
592
+     * The {@link Wordlift_Autocomplete_Service} instance.
593
+     *
594
+     * @since  3.15.0
595
+     * @access private
596
+     * @var \Wordlift_Autocomplete_Service $autocomplete_service The {@link Wordlift_Autocomplete_Service} instance.
597
+     */
598
+    private $autocomplete_service;
599
+
600
+    /**
601
+     * The {@link Wordlift_Autocomplete_Adapter} instance.
602
+     *
603
+     * @since  3.15.0
604
+     * @access private
605
+     * @var \Wordlift_Autocomplete_Adapter $autocomplete_adapter The {@link Wordlift_Autocomplete_Adapter} instance.
606
+     */
607
+    private $autocomplete_adapter;
608
+
609
+    /**
610
+     * The {@link Wordlift_Relation_Service} instance.
611
+     *
612
+     * @since  3.15.0
613
+     * @access private
614
+     * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
615
+     */
616
+    private $relation_service;
617
+
618
+    /**
619
+     * {@link Wordlift}'s singleton instance.
620
+     *
621
+     * @since  3.11.2
622
+     * @access private
623
+     * @var Wordlift $instance {@link Wordlift}'s singleton instance.
624
+     */
625
+    private static $instance;
626
+
627
+    /**
628
+     * Define the core functionality of the plugin.
629
+     *
630
+     * Set the plugin name and the plugin version that can be used throughout the plugin.
631
+     * Load the dependencies, define the locale, and set the hooks for the admin area and
632
+     * the public-facing side of the site.
633
+     *
634
+     * @since    1.0.0
635
+     */
636
+    public function __construct() {
637
+
638
+        $this->plugin_name = 'wordlift';
639
+        $this->version     = '3.15.2';
640
+        $this->load_dependencies();
641
+        $this->set_locale();
642
+        $this->define_admin_hooks();
643
+        $this->define_public_hooks();
644
+
645
+        self::$instance = $this;
646
+
647
+    }
648
+
649
+    /**
650
+     * Get the singleton instance.
651
+     *
652
+     * @since 3.11.2
653
+     *
654
+     * @return Wordlift The {@link Wordlift} singleton instance.
655
+     */
656
+    public static function get_instance() {
657
+
658
+        return self::$instance;
659
+    }
660
+
661
+    /**
662
+     * Load the required dependencies for this plugin.
663
+     *
664
+     * Include the following files that make up the plugin:
665
+     *
666
+     * - Wordlift_Loader. Orchestrates the hooks of the plugin.
667
+     * - Wordlift_i18n. Defines internationalization functionality.
668
+     * - Wordlift_Admin. Defines all hooks for the admin area.
669
+     * - Wordlift_Public. Defines all hooks for the public side of the site.
670
+     *
671
+     * Create an instance of the loader which will be used to register the hooks
672
+     * with WordPress.
673
+     *
674
+     * @since    1.0.0
675
+     * @access   private
676
+     */
677
+    private function load_dependencies() {
678
+
679
+        /**
680
+         * The class responsible for orchestrating the actions and filters of the
681
+         * core plugin.
682
+         */
683
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php';
684
+
685
+        /**
686
+         * The class responsible for defining internationalization functionality
687
+         * of the plugin.
688
+         */
689
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php';
690
+
691
+        /**
692
+         * WordLift's supported languages.
693
+         */
694
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-languages.php';
695
+
696
+        /**
697
+         * Provide support functions to sanitize data.
698
+         */
699
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php';
700
+
701
+        /** Services. */
702
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php';
703
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php';
704
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php';
705
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-type-service.php';
706
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php';
707
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php';
708
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-linked-data-service.php';
709
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-service.php';
710
+
711
+        /**
712
+         * The Query builder.
713
+         */
714
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php';
715
+
716
+        /**
717
+         * The Schema service.
718
+         */
719
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php';
720
+
721
+        /**
722
+         * The schema:url property service.
723
+         */
724
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-service.php';
725
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-url-property-service.php';
726
+
727
+        /**
728
+         * The UI service.
729
+         */
730
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php';
731
+
732
+        /**
733
+         * The Thumbnail service.
734
+         */
735
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php';
736
+
737
+        /**
738
+         * The Entity Types Taxonomy service.
739
+         */
740
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php';
741
+
742
+        /**
743
+         * The Entity service.
744
+         */
745
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php';
746
+
747
+        // Add the entity rating service.
748
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rating-service.php';
749
+
750
+        /**
751
+         * The User service.
752
+         */
753
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php';
754
+
755
+        /**
756
+         * The Timeline service.
757
+         */
758
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php';
759
+
760
+        /**
761
+         * The Topic Taxonomy service.
762
+         */
763
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php';
764
+
765
+        /**
766
+         * The SPARQL service.
767
+         */
768
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php';
769
+
770
+        /**
771
+         * The WordLift import service.
772
+         */
773
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php';
774
+
775
+        /**
776
+         * The WordLift URI service.
777
+         */
778
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php';
779
+
780
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php';
781
+
782
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-property-factory.php';
783
+
784
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-service.php';
785
+
786
+        /**
787
+         * The WordLift rebuild service, used to rebuild the remote dataset using the local data.
788
+         */
789
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php';
790
+
791
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/properties/class-wordlift-property-getter-factory.php';
792
+
793
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-attachment-service.php';
794
+
795
+        /**
796
+         * Load the converters.
797
+         */
798
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/intf-wordlift-post-converter.php';
799
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-abstract-post-to-jsonld-converter.php';
800
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-postid-to-jsonld-converter.php';
801
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-post-to-jsonld-converter.php';
802
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-to-jsonld-converter.php';
803
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-website-converter.php';
804
+
805
+        /**
806
+         * Load the content filter.
807
+         */
808
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-content-filter-service.php';
809
+
810
+        /*
811 811
 		 * Load the excerpt helper.
812 812
 		 */
813
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
814
-
815
-		/**
816
-		 * Load the JSON-LD service to publish entities using JSON-LD.s
817
-		 *
818
-		 * @since 3.8.0
819
-		 */
820
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
821
-
822
-		// The Publisher Service and the AJAX adapter.
823
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
824
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
825
-
826
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
827
-
828
-		/**
829
-		 * Load the WordLift key validation service.
830
-		 */
831
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
832
-
833
-		// Load the `Wordlift_Category_Taxonomy_Service` class definition.
834
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
835
-
836
-		// Load the `Wordlift_Entity_Page_Service` class definition.
837
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
838
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-service.php';
839
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-service.php';
840
-
841
-		/** Linked Data. */
842
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
843
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
844
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
845
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
846
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
847
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
848
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
849
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
850
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
851
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
852
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
853
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php';
854
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
855
-
856
-		/** Adapters. */
857
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
858
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
859
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
860
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
861
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-adapter.php';
862
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-adapter.php';
863
-
864
-		/** Async Tasks. */
865
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/wp-async-task.php';
866
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
867
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php';
868
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php';
869
-
870
-		/** Async Tasks. */
871
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-service.php';
872
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
873
-
874
-		/**
875
-		 * The class responsible for defining all actions that occur in the admin area.
876
-		 */
877
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
878
-
879
-		/**
880
-		 * The class to customize the entity list admin page.
881
-		 */
882
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
883
-
884
-		/**
885
-		 * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
886
-		 */
887
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
888
-
889
-		/**
890
-		 * The Notice service.
891
-		 */
892
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
893
-
894
-		/**
895
-		 * The PrimaShop adapter.
896
-		 */
897
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
898
-
899
-		/**
900
-		 * The WordLift Dashboard service.
901
-		 */
902
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
903
-
904
-		/**
905
-		 * The admin 'Install wizard' page.
906
-		 */
907
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
908
-
909
-		/**
910
-		 * The WordLift entity type list admin page controller.
911
-		 */
912
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
913
-
914
-		/**
915
-		 * The WordLift entity type settings admin page controller.
916
-		 */
917
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
918
-
919
-		/**
920
-		 * The admin 'Download Your Data' page.
921
-		 */
922
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
923
-
924
-		/**
925
-		 * The admin 'Download Your Data' page.
926
-		 */
927
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
928
-
929
-		/**
930
-		 * The admin 'WordLift Settings' page.
931
-		 */
932
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php';
933
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php';
934
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php';
935
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php';
936
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php';
937
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php';
938
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-author-element.php';
939
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php';
940
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
941
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
942
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-batch-analysis-page.php';
943
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
944
-
945
-		/** Admin Pages */
946
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
947
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
948
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
949
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
950
-
951
-		/**
952
-		 * The class responsible for defining all actions that occur in the public-facing
953
-		 * side of the site.
954
-		 */
955
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
956
-
957
-		/**
958
-		 * The shortcode abstract class.
959
-		 */
960
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
961
-
962
-		/**
963
-		 * The Timeline shortcode.
964
-		 */
965
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
966
-
967
-		/**
968
-		 * The Navigator shortcode.
969
-		 */
970
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
971
-
972
-		/**
973
-		 * The chord shortcode.
974
-		 */
975
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
976
-
977
-		/**
978
-		 * The geomap shortcode.
979
-		 */
980
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
981
-
982
-		/**
983
-		 * The entity cloud shortcode.
984
-		 */
985
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
986
-
987
-		/**
988
-		 * The ShareThis service.
989
-		 */
990
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
991
-
992
-		/**
993
-		 * The SEO service.
994
-		 */
995
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
996
-
997
-		/**
998
-		 * The AMP service.
999
-		 */
1000
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1001
-
1002
-		/** Widgets */
1003
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1004
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1005
-
1006
-		$this->loader = new Wordlift_Loader();
1007
-
1008
-		// Instantiate a global logger.
1009
-		global $wl_logger;
1010
-		$wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1011
-
1012
-		/** Services. */
1013
-		// Create the configuration service.
1014
-		$this->configuration_service = new Wordlift_Configuration_Service();
1015
-
1016
-		// Create an entity type service instance. It'll be later bound to the init action.
1017
-		$this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1018
-
1019
-		// Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1020
-		$this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1021
-
1022
-		// Create an instance of the UI service.
1023
-		$this->ui_service = new Wordlift_UI_Service();
1024
-
1025
-		// Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1026
-		$this->thumbnail_service = new Wordlift_Thumbnail_Service();
1027
-
1028
-		$this->sparql_service        = new Wordlift_Sparql_Service();
1029
-		$schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1030
-		$this->notice_service        = new Wordlift_Notice_Service();
1031
-		$this->relation_service      = new Wordlift_Relation_Service();
1032
-		$this->entity_service        = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service );
1033
-		$this->user_service          = new Wordlift_User_Service();
1034
-
1035
-		// Instantiate the JSON-LD service.
1036
-		$property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1037
-
1038
-		/** Linked Data. */
1039
-		$this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1040
-		$this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1041
-
1042
-		$this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1043
-
1044
-		// Create a new instance of the Redirect service.
1045
-		$this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_service );
1046
-		$this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1047
-		$this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1048
-
1049
-		// Create a new instance of the Timeline service and Timeline shortcode.
1050
-		$this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1051
-
1052
-		$this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service );
813
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-excerpt-helper.php';
814
+
815
+        /**
816
+         * Load the JSON-LD service to publish entities using JSON-LD.s
817
+         *
818
+         * @since 3.8.0
819
+         */
820
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-jsonld-service.php';
821
+
822
+        // The Publisher Service and the AJAX adapter.
823
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-service.php';
824
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-publisher-ajax-adapter.php';
825
+
826
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-post-adapter.php';
827
+
828
+        /**
829
+         * Load the WordLift key validation service.
830
+         */
831
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-key-validation-service.php';
832
+
833
+        // Load the `Wordlift_Category_Taxonomy_Service` class definition.
834
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-category-taxonomy-service.php';
835
+
836
+        // Load the `Wordlift_Entity_Page_Service` class definition.
837
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-page-service.php';
838
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-service.php';
839
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-service.php';
840
+
841
+        /** Linked Data. */
842
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage.php';
843
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-storage.php';
844
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-property-storage.php';
845
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-taxonomy-storage.php';
846
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-schema-class-storage.php';
847
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-author-storage.php';
848
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php';
849
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-image-storage.php';
850
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-post-related-storage.php';
851
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-url-property-storage.php';
852
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/storage/class-wordlift-storage-factory.php';
853
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition.php';
854
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/linked-data/rendition/class-wordlift-sparql-tuple-rendition-factory.php';
855
+
856
+        /** Adapters. */
857
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-tinymce-adapter.php';
858
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-newrelic-adapter.php';
859
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sample-data-ajax-adapter.php';
860
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-adapter.php';
861
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-batch-analysis-adapter.php';
862
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-relation-rebuild-adapter.php';
863
+
864
+        /** Async Tasks. */
865
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/wp-async-task.php';
866
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-sparql-query-async-task.php';
867
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-request-async-task.php';
868
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/wp-async-task/class-wordlift-batch-analysis-complete-async-task.php';
869
+
870
+        /** Async Tasks. */
871
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-service.php';
872
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-autocomplete-adapter.php';
873
+
874
+        /**
875
+         * The class responsible for defining all actions that occur in the admin area.
876
+         */
877
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php';
878
+
879
+        /**
880
+         * The class to customize the entity list admin page.
881
+         */
882
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php';
883
+
884
+        /**
885
+         * The Entity Types Taxonomy Walker (transforms checkboxes into radios).
886
+         */
887
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php';
888
+
889
+        /**
890
+         * The Notice service.
891
+         */
892
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php';
893
+
894
+        /**
895
+         * The PrimaShop adapter.
896
+         */
897
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php';
898
+
899
+        /**
900
+         * The WordLift Dashboard service.
901
+         */
902
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php';
903
+
904
+        /**
905
+         * The admin 'Install wizard' page.
906
+         */
907
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-setup.php';
908
+
909
+        /**
910
+         * The WordLift entity type list admin page controller.
911
+         */
912
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-taxonomy-list-page.php';
913
+
914
+        /**
915
+         * The WordLift entity type settings admin page controller.
916
+         */
917
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-settings.php';
918
+
919
+        /**
920
+         * The admin 'Download Your Data' page.
921
+         */
922
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
923
+
924
+        /**
925
+         * The admin 'Download Your Data' page.
926
+         */
927
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-download-your-data-page.php';
928
+
929
+        /**
930
+         * The admin 'WordLift Settings' page.
931
+         */
932
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/intf-wordlift-admin-element.php';
933
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-element.php';
934
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-input-radio-element.php';
935
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-select2-element.php';
936
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-language-select-element.php';
937
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-tabs-element.php';
938
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-author-element.php';
939
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-publisher-element.php';
940
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-page.php';
941
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page.php';
942
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-batch-analysis-page.php';
943
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-settings-page-action-link.php';
944
+
945
+        /** Admin Pages */
946
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-post-edit-page.php';
947
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-user-profile-page.php';
948
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-status-page.php';
949
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-type-admin-service.php';
950
+
951
+        /**
952
+         * The class responsible for defining all actions that occur in the public-facing
953
+         * side of the site.
954
+         */
955
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php';
956
+
957
+        /**
958
+         * The shortcode abstract class.
959
+         */
960
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php';
961
+
962
+        /**
963
+         * The Timeline shortcode.
964
+         */
965
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php';
966
+
967
+        /**
968
+         * The Navigator shortcode.
969
+         */
970
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php';
971
+
972
+        /**
973
+         * The chord shortcode.
974
+         */
975
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php';
976
+
977
+        /**
978
+         * The geomap shortcode.
979
+         */
980
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php';
981
+
982
+        /**
983
+         * The entity cloud shortcode.
984
+         */
985
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-shortcode.php';
986
+
987
+        /**
988
+         * The ShareThis service.
989
+         */
990
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php';
991
+
992
+        /**
993
+         * The SEO service.
994
+         */
995
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-seo-service.php';
996
+
997
+        /**
998
+         * The AMP service.
999
+         */
1000
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-amp-service.php';
1001
+
1002
+        /** Widgets */
1003
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-widget.php';
1004
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-related-entities-cloud-widget.php';
1005
+
1006
+        $this->loader = new Wordlift_Loader();
1007
+
1008
+        // Instantiate a global logger.
1009
+        global $wl_logger;
1010
+        $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' );
1011
+
1012
+        /** Services. */
1013
+        // Create the configuration service.
1014
+        $this->configuration_service = new Wordlift_Configuration_Service();
1015
+
1016
+        // Create an entity type service instance. It'll be later bound to the init action.
1017
+        $this->entity_post_type_service = new Wordlift_Entity_Post_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $this->configuration_service->get_entity_base_path() );
1018
+
1019
+        // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions.
1020
+        $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_post_type_service, $this->configuration_service->get_entity_base_path() );
1021
+
1022
+        // Create an instance of the UI service.
1023
+        $this->ui_service = new Wordlift_UI_Service();
1024
+
1025
+        // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events.
1026
+        $this->thumbnail_service = new Wordlift_Thumbnail_Service();
1027
+
1028
+        $this->sparql_service        = new Wordlift_Sparql_Service();
1029
+        $schema_url_property_service = new Wordlift_Schema_Url_Property_Service( $this->sparql_service );
1030
+        $this->notice_service        = new Wordlift_Notice_Service();
1031
+        $this->relation_service      = new Wordlift_Relation_Service();
1032
+        $this->entity_service        = new Wordlift_Entity_Service( $this->ui_service, $this->relation_service );
1033
+        $this->user_service          = new Wordlift_User_Service();
1034
+
1035
+        // Instantiate the JSON-LD service.
1036
+        $property_getter = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1037
+
1038
+        /** Linked Data. */
1039
+        $this->storage_factory   = new Wordlift_Storage_Factory( $this->entity_service, $this->user_service, $property_getter );
1040
+        $this->rendition_factory = new Wordlift_Sparql_Tuple_Rendition_Factory( $this->entity_service );
1041
+
1042
+        $this->schema_service = new Wordlift_Schema_Service( $this->storage_factory, $this->rendition_factory, $this->configuration_service );
1043
+
1044
+        // Create a new instance of the Redirect service.
1045
+        $this->redirect_service    = new Wordlift_Redirect_Service( $this->entity_service );
1046
+        $this->entity_type_service = new Wordlift_Entity_Type_Service( $this->schema_service );
1047
+        $this->linked_data_service = new Wordlift_Linked_Data_Service( $this->entity_service, $this->entity_type_service, $this->schema_service, $this->sparql_service );
1048
+
1049
+        // Create a new instance of the Timeline service and Timeline shortcode.
1050
+        $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service, $this->entity_type_service );
1051
+
1052
+        $this->batch_analysis_service = new Wordlift_Batch_Analysis_Service( $this, $this->configuration_service );
1053 1053
 
1054
-		$this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1054
+        $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker();
1055 1055
 
1056
-		$this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
1056
+        $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service();
1057 1057
 
1058
-		// Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1059
-		$this->sharethis_service = new Wordlift_ShareThis_Service();
1058
+        // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters.
1059
+        $this->sharethis_service = new Wordlift_ShareThis_Service();
1060 1060
 
1061
-		// Create an instance of the PrimaShop adapter.
1062
-		$this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1061
+        // Create an instance of the PrimaShop adapter.
1062
+        $this->primashop_adapter = new Wordlift_PrimaShop_Adapter();
1063 1063
 
1064
-		// Create an import service instance to hook later to WP's import function.
1065
-		$this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri() );
1064
+        // Create an import service instance to hook later to WP's import function.
1065
+        $this->import_service = new Wordlift_Import_Service( $this->entity_post_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, $this->configuration_service->get_dataset_uri() );
1066 1066
 
1067
-		$uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1067
+        $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] );
1068 1068
 
1069
-		// Create a Rebuild Service instance, which we'll later bound to an ajax call.
1070
-		$this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
1069
+        // Create a Rebuild Service instance, which we'll later bound to an ajax call.
1070
+        $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service );
1071 1071
 
1072
-		// Create the entity rating service.
1073
-		$this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1072
+        // Create the entity rating service.
1073
+        $this->rating_service = new Wordlift_Rating_Service( $this->entity_service, $this->entity_type_service, $this->notice_service );
1074 1074
 
1075
-		// Create entity list customization (wp-admin/edit.php)
1076
-		$this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1075
+        // Create entity list customization (wp-admin/edit.php)
1076
+        $this->entity_list_service = new Wordlift_Entity_List_Service( $this->rating_service );
1077 1077
 
1078
-		// Create a new instance of the Redirect service.
1079
-		$this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1078
+        // Create a new instance of the Redirect service.
1079
+        $this->dashboard_service = new Wordlift_Dashboard_Service( $this->rating_service, $this->entity_service );
1080 1080
 
1081
-		// Create an instance of the Publisher Service and the AJAX Adapter.
1082
-		$publisher_service      = new Wordlift_Publisher_Service();
1083
-		$this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
1084
-		$this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1081
+        // Create an instance of the Publisher Service and the AJAX Adapter.
1082
+        $publisher_service      = new Wordlift_Publisher_Service();
1083
+        $this->property_factory = new Wordlift_Property_Factory( $schema_url_property_service );
1084
+        $this->property_factory->register( Wordlift_Schema_Url_Property_Service::META_KEY, $schema_url_property_service );
1085 1085
 
1086
-		$attachment_service = new Wordlift_Attachment_Service();
1086
+        $attachment_service = new Wordlift_Attachment_Service();
1087 1087
 
1088
-		// Instantiate the JSON-LD service.
1089
-		$property_getter                       = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1090
-		$this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter );
1091
-		$this->post_to_jsonld_converter        = new Wordlift_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service, $this->entity_post_to_jsonld_converter );
1092
-		$this->postid_to_jsonld_converter      = new Wordlift_Postid_To_Jsonld_Converter( $this->entity_service, $this->entity_post_to_jsonld_converter, $this->post_to_jsonld_converter );
1093
-		$this->jsonld_website_converter        = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service, $this->entity_post_to_jsonld_converter );
1094
-		$this->jsonld_service                  = new Wordlift_Jsonld_Service( $this->entity_service, $this->postid_to_jsonld_converter, $this->jsonld_website_converter );
1088
+        // Instantiate the JSON-LD service.
1089
+        $property_getter                       = Wordlift_Property_Getter_Factory::create( $this->entity_service );
1090
+        $this->entity_post_to_jsonld_converter = new Wordlift_Entity_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $property_getter );
1091
+        $this->post_to_jsonld_converter        = new Wordlift_Post_To_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service, $this->entity_post_to_jsonld_converter );
1092
+        $this->postid_to_jsonld_converter      = new Wordlift_Postid_To_Jsonld_Converter( $this->entity_service, $this->entity_post_to_jsonld_converter, $this->post_to_jsonld_converter );
1093
+        $this->jsonld_website_converter        = new Wordlift_Website_Jsonld_Converter( $this->entity_type_service, $this->entity_service, $this->user_service, $attachment_service, $this->configuration_service, $this->entity_post_to_jsonld_converter );
1094
+        $this->jsonld_service                  = new Wordlift_Jsonld_Service( $this->entity_service, $this->postid_to_jsonld_converter, $this->jsonld_website_converter );
1095 1095
 
1096
-		$this->key_validation_service   = new Wordlift_Key_Validation_Service( $this->configuration_service );
1097
-		$this->content_filter_service   = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service );
1098
-		$this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1099
-		$this->sample_data_service      = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service );
1100
-		$this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1096
+        $this->key_validation_service   = new Wordlift_Key_Validation_Service( $this->configuration_service );
1097
+        $this->content_filter_service   = new Wordlift_Content_Filter_Service( $this->entity_service, $this->configuration_service );
1098
+        $this->relation_rebuild_service = new Wordlift_Relation_Rebuild_Service( $this->content_filter_service, $this->entity_service );
1099
+        $this->sample_data_service      = new Wordlift_Sample_Data_Service( $this->entity_type_service, $this->configuration_service );
1100
+        $this->sample_data_ajax_adapter = new Wordlift_Sample_Data_Ajax_Adapter( $this->sample_data_service );
1101 1101
 
1102
-		// Initialize the shortcodes.
1103
-		new Wordlift_Navigator_Shortcode();
1104
-		new Wordlift_Chord_Shortcode();
1105
-		new Wordlift_Geomap_Shortcode();
1106
-		new Wordlift_Timeline_Shortcode();
1107
-		new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1102
+        // Initialize the shortcodes.
1103
+        new Wordlift_Navigator_Shortcode();
1104
+        new Wordlift_Chord_Shortcode();
1105
+        new Wordlift_Geomap_Shortcode();
1106
+        new Wordlift_Timeline_Shortcode();
1107
+        new Wordlift_Related_Entities_Cloud_Shortcode( $this->relation_service );
1108 1108
 
1109
-		// Initialize the SEO service.
1110
-		new Wordlift_Seo_Service();
1109
+        // Initialize the SEO service.
1110
+        new Wordlift_Seo_Service();
1111 1111
 
1112
-		// Initialize the AMP service.
1113
-		new Wordlift_AMP_Service();
1112
+        // Initialize the AMP service.
1113
+        new Wordlift_AMP_Service();
1114 1114
 
1115
-		/** Adapters. */
1116
-		$this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1117
-		$this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $publisher_service );
1118
-		$this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1119
-		$this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service );
1120
-		$this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1115
+        /** Adapters. */
1116
+        $this->entity_type_adapter      = new Wordlift_Entity_Type_Adapter( $this->entity_type_service );
1117
+        $this->publisher_ajax_adapter   = new Wordlift_Publisher_Ajax_Adapter( $publisher_service );
1118
+        $this->tinymce_adapter          = new Wordlift_Tinymce_Adapter( $this );
1119
+        $this->batch_analysis_adapter   = new Wordlift_Batch_Analysis_Adapter( $this->batch_analysis_service );
1120
+        $this->relation_rebuild_adapter = new Wordlift_Relation_Rebuild_Adapter( $this->relation_rebuild_service );
1121 1121
 
1122
-		/** Async Tasks. */
1123
-		new Wordlift_Sparql_Query_Async_Task();
1124
-		new Wordlift_Batch_Analysis_Request_Async_Task();
1125
-		new Wordlift_Batch_Analysis_Complete_Async_Task();
1122
+        /** Async Tasks. */
1123
+        new Wordlift_Sparql_Query_Async_Task();
1124
+        new Wordlift_Batch_Analysis_Request_Async_Task();
1125
+        new Wordlift_Batch_Analysis_Complete_Async_Task();
1126 1126
 
1127
-		/** WL Autocomplete. */
1128
-		$this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service );
1129
-		$this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service );
1127
+        /** WL Autocomplete. */
1128
+        $this->autocomplete_service = new Wordlift_Autocomplete_Service( $this->configuration_service );
1129
+        $this->autocomplete_adapter = new Wordlift_Autocomplete_Adapter( $this->autocomplete_service );
1130 1130
 
1131
-		/** WordPress Admin UI. */
1131
+        /** WordPress Admin UI. */
1132 1132
 
1133
-		// UI elements.
1134
-		$this->input_element           = new Wordlift_Admin_Input_Element();
1135
-		$this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1136
-		$this->select2_element         = new Wordlift_Admin_Select2_Element();
1137
-		$this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1138
-		$tabs_element                  = new Wordlift_Admin_Tabs_Element();
1139
-		$this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element );
1140
-		$this->author_element          = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element );
1133
+        // UI elements.
1134
+        $this->input_element           = new Wordlift_Admin_Input_Element();
1135
+        $this->radio_input_element     = new Wordlift_Admin_Radio_Input_Element();
1136
+        $this->select2_element         = new Wordlift_Admin_Select2_Element();
1137
+        $this->language_select_element = new Wordlift_Admin_Language_Select_Element();
1138
+        $tabs_element                  = new Wordlift_Admin_Tabs_Element();
1139
+        $this->publisher_element       = new Wordlift_Admin_Publisher_Element( $this->configuration_service, $publisher_service, $tabs_element, $this->select2_element );
1140
+        $this->author_element          = new Wordlift_Admin_Author_Element( $publisher_service, $this->select2_element );
1141 1141
 
1142
-		$this->settings_page             = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element );
1143
-		$this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service );
1144
-		$this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1142
+        $this->settings_page             = new Wordlift_Admin_Settings_Page( $this->configuration_service, $this->entity_service, $this->input_element, $this->language_select_element, $this->publisher_element, $this->radio_input_element );
1143
+        $this->batch_analysis_page       = new Wordlift_Batch_Analysis_Page( $this->batch_analysis_service );
1144
+        $this->settings_page_action_link = new Wordlift_Admin_Settings_Page_Action_Link( $this->settings_page );
1145 1145
 
1146
-		// Pages.
1147
-		new Wordlift_Admin_Post_Edit_Page( $this );
1148
-		new Wordlift_Entity_Type_Admin_Service();
1146
+        // Pages.
1147
+        new Wordlift_Admin_Post_Edit_Page( $this );
1148
+        new Wordlift_Entity_Type_Admin_Service();
1149 1149
 
1150
-		// create an instance of the entity type list admin page controller.
1151
-		$this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1150
+        // create an instance of the entity type list admin page controller.
1151
+        $this->entity_type_admin_page = new Wordlift_Admin_Entity_Taxonomy_List_Page();
1152 1152
 
1153
-		// create an instance of the entity type etting admin page controller.
1154
-		$this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1155
-
1156
-		/** Widgets */
1157
-		$this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1158
-
1159
-		//** WordPress Admin */
1160
-		$this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1161
-		$this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1162
-
1163
-		// Create an instance of the install wizard.
1164
-		$this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service );
1165
-
1166
-		$this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1167
-
1168
-		// User Profile.
1169
-		new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1170
-
1171
-		$this->entity_page_service = new Wordlift_Entity_Page_Service();
1172
-
1173
-		// Load the debug service if WP is in debug mode.
1174
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1175
-			require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1176
-			new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1177
-		}
1178
-
1179
-	}
1180
-
1181
-	/**
1182
-	 * Define the locale for this plugin for internationalization.
1183
-	 *
1184
-	 * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1185
-	 * with WordPress.
1186
-	 *
1187
-	 * @since    1.0.0
1188
-	 * @access   private
1189
-	 */
1190
-	private function set_locale() {
1191
-
1192
-		$plugin_i18n = new Wordlift_i18n();
1193
-		$plugin_i18n->set_domain( $this->get_plugin_name() );
1194
-
1195
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1196
-
1197
-	}
1198
-
1199
-	/**
1200
-	 * Register all of the hooks related to the admin area functionality
1201
-	 * of the plugin.
1202
-	 *
1203
-	 * @since    1.0.0
1204
-	 * @access   private
1205
-	 */
1206
-	private function define_admin_hooks() {
1207
-
1208
-		$plugin_admin = new Wordlift_Admin(
1209
-			$this->get_plugin_name(),
1210
-			$this->get_version(),
1211
-			$this->configuration_service,
1212
-			$this->notice_service,
1213
-			$this->user_service
1214
-		);
1215
-
1216
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1217
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
1218
-
1219
-		// Hook the init action to the Topic Taxonomy service.
1220
-		$this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1221
-
1222
-		// Hook the deleted_post_meta action to the Thumbnail service.
1223
-		$this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1224
-
1225
-		// Hook the added_post_meta action to the Thumbnail service.
1226
-		$this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1227
-
1228
-		// Hook the updated_post_meta action to the Thumbnail service.
1229
-		$this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1230
-
1231
-		// Hook the AJAX wl_timeline action to the Timeline service.
1232
-		$this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1233
-
1234
-		// Register custom allowed redirect hosts.
1235
-		$this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1236
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1237
-		$this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1238
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1239
-		$this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1240
-		// Hook the AJAX wordlift_redirect action to the Redirect service.
1241
-		$this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1242
-
1243
-		// Hook save_post to the entity service to update custom fields (such as alternate labels).
1244
-		// We have a priority of 9 because we want to be executed before data is sent to Redlink.
1245
-		$this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1246
-		$this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1247
-
1248
-		$this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1249
-		$this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1250
-
1251
-		// Entity listing customization (wp-admin/edit.php)
1252
-		// Add custom columns
1253
-		$this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1254
-		// no explicit entity as it prevents handling of other post types.
1255
-		$this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1256
-		// Add 4W selection
1257
-		$this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1258
-		$this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1259
-		$this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1260
-		$this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1261
-		$this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1262
-
1263
-		// Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1264
-		// entities.
1265
-		$this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1266
-
1267
-		// Filter imported post meta.
1268
-		$this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1269
-
1270
-		// Notify the import service when an import starts and ends.
1271
-		$this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1272
-		$this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1273
-
1274
-		// Hook the AJAX wl_rebuild action to the Rebuild Service.
1275
-		$this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1276
-
1277
-		// Hook the menu to the Download Your Data page.
1278
-		$this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1279
-		$this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1280
-		$this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1281
-
1282
-		// Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1283
-		$this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1284
-
1285
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1286
-		$this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1287
-
1288
-		// Hook the AJAX wl_validate_key action to the Key Validation service.
1289
-		$this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1290
-
1291
-		// Hook the `admin_init` function to the Admin Setup.
1292
-		$this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1293
-
1294
-		// Hook the admin_init to the settings page.
1295
-		$this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1296
-
1297
-		// Hook the menu creation on the general wordlift menu creation
1298
-		$this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1299
-		if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) {
1300
-			// Add the functionality only if a flag is set in wp-config.php .
1301
-			$this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 );
1302
-		}
1303
-
1304
-		// Hook key update.
1305
-		$this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1306
-		$this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1307
-
1308
-		// Add additional action links to the WordLift plugin in the plugins page.
1309
-		$this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1310
-
1311
-		// Hook the AJAX `wl_publisher` action name.
1312
-		$this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1313
-
1314
-		// Hook row actions for the entity type list admin.
1315
-		$this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1316
-
1317
-		// Hook capabilities manipulation to allow access to entity type admin
1318
-		// page  on wordpress versions before 4.7.
1319
-		global $wp_version;
1320
-		if ( version_compare( $wp_version, '4.7', '<' ) ) {
1321
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1322
-		}
1323
-
1324
-		$this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1325
-
1326
-		/** Adapters. */
1327
-		$this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1328
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_auto_selected_posts', $this->batch_analysis_adapter, 'submit_auto_selected_posts', 10 );
1329
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_all_posts', $this->batch_analysis_adapter, 'submit_all_posts', 10 );
1330
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 );
1331
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 );
1332
-		$this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 );
1333
-		$this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 );
1334
-
1335
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1336
-		$this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1337
-
1338
-		// Handle the autocomplete request.
1339
-		add_action( 'wp_ajax_wl_autocomplete', array( $this->autocomplete_adapter, 'wl_autocomplete' ) );
1340
-		add_action( 'wp_ajax_nopriv_wl_autocomplete', array( $this->autocomplete_adapter, 'wl_autocomplete' ) );
1341
-
1342
-		// Hooks to restrict multisite super admin from manipulating entity types.
1343
-		if ( is_multisite() ) {
1344
-			$this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1345
-		}
1346
-
1347
-	}
1348
-
1349
-	/**
1350
-	 * Register all of the hooks related to the public-facing functionality
1351
-	 * of the plugin.
1352
-	 *
1353
-	 * @since    1.0.0
1354
-	 * @access   private
1355
-	 */
1356
-	private function define_public_hooks() {
1153
+        // create an instance of the entity type etting admin page controller.
1154
+        $this->entity_type_settings_admin_page = new Wordlift_Admin_Entity_Type_Settings();
1155
+
1156
+        /** Widgets */
1157
+        $this->related_entities_cloud_widget = new Wordlift_Related_Entities_Cloud_Widget();
1158
+
1159
+        //** WordPress Admin */
1160
+        $this->download_your_data_page = new Wordlift_Admin_Download_Your_Data_Page( $this->configuration_service );
1161
+        $this->status_page             = new Wordlift_Admin_Status_Page( $this->entity_service, $this->sparql_service );
1162
+
1163
+        // Create an instance of the install wizard.
1164
+        $this->admin_setup = new Wordlift_Admin_Setup( $this->configuration_service, $this->key_validation_service, $this->entity_service );
1165
+
1166
+        $this->category_taxonomy_service = new Wordlift_Category_Taxonomy_Service( $this->entity_post_type_service );
1167
+
1168
+        // User Profile.
1169
+        new Wordlift_Admin_User_Profile_Page( $this->author_element, $this->user_service );
1170
+
1171
+        $this->entity_page_service = new Wordlift_Entity_Page_Service();
1172
+
1173
+        // Load the debug service if WP is in debug mode.
1174
+        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
1175
+            require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-debug-service.php';
1176
+            new Wordlift_Debug_Service( $this->entity_service, $uri_service );
1177
+        }
1178
+
1179
+    }
1180
+
1181
+    /**
1182
+     * Define the locale for this plugin for internationalization.
1183
+     *
1184
+     * Uses the Wordlift_i18n class in order to set the domain and to register the hook
1185
+     * with WordPress.
1186
+     *
1187
+     * @since    1.0.0
1188
+     * @access   private
1189
+     */
1190
+    private function set_locale() {
1191
+
1192
+        $plugin_i18n = new Wordlift_i18n();
1193
+        $plugin_i18n->set_domain( $this->get_plugin_name() );
1194
+
1195
+        $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
1196
+
1197
+    }
1198
+
1199
+    /**
1200
+     * Register all of the hooks related to the admin area functionality
1201
+     * of the plugin.
1202
+     *
1203
+     * @since    1.0.0
1204
+     * @access   private
1205
+     */
1206
+    private function define_admin_hooks() {
1207
+
1208
+        $plugin_admin = new Wordlift_Admin(
1209
+            $this->get_plugin_name(),
1210
+            $this->get_version(),
1211
+            $this->configuration_service,
1212
+            $this->notice_service,
1213
+            $this->user_service
1214
+        );
1215
+
1216
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
1217
+        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
1218
+
1219
+        // Hook the init action to the Topic Taxonomy service.
1220
+        $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 );
1221
+
1222
+        // Hook the deleted_post_meta action to the Thumbnail service.
1223
+        $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 );
1224
+
1225
+        // Hook the added_post_meta action to the Thumbnail service.
1226
+        $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1227
+
1228
+        // Hook the updated_post_meta action to the Thumbnail service.
1229
+        $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 );
1230
+
1231
+        // Hook the AJAX wl_timeline action to the Timeline service.
1232
+        $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1233
+
1234
+        // Register custom allowed redirect hosts.
1235
+        $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' );
1236
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1237
+        $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' );
1238
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1239
+        $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' );
1240
+        // Hook the AJAX wordlift_redirect action to the Redirect service.
1241
+        $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' );
1242
+
1243
+        // Hook save_post to the entity service to update custom fields (such as alternate labels).
1244
+        // We have a priority of 9 because we want to be executed before data is sent to Redlink.
1245
+        $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 );
1246
+        $this->loader->add_action( 'save_post', $this->rating_service, 'set_rating_for', 20, 1 );
1247
+
1248
+        $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 );
1249
+        $this->loader->add_action( 'in_admin_header', $this->rating_service, 'in_admin_header' );
1250
+
1251
+        // Entity listing customization (wp-admin/edit.php)
1252
+        // Add custom columns
1253
+        $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' );
1254
+        // no explicit entity as it prevents handling of other post types.
1255
+        $this->loader->add_filter( 'manage_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 );
1256
+        // Add 4W selection
1257
+        $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' );
1258
+        $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' );
1259
+        $this->loader->add_action( 'pre_get_posts', $this->entity_list_service, 'pre_get_posts' );
1260
+        $this->loader->add_action( 'load-edit.php', $this->entity_list_service, 'load_edit' );
1261
+        $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' );
1262
+
1263
+        // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for
1264
+        // entities.
1265
+        $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 );
1266
+
1267
+        // Filter imported post meta.
1268
+        $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 );
1269
+
1270
+        // Notify the import service when an import starts and ends.
1271
+        $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 );
1272
+        $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 );
1273
+
1274
+        // Hook the AJAX wl_rebuild action to the Rebuild Service.
1275
+        $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' );
1276
+
1277
+        // Hook the menu to the Download Your Data page.
1278
+        $this->loader->add_action( 'admin_menu', $this->download_your_data_page, 'admin_menu', 100, 0 );
1279
+        $this->loader->add_action( 'admin_menu', $this->status_page, 'admin_menu', 100, 0 );
1280
+        $this->loader->add_action( 'admin_menu', $this->entity_type_settings_admin_page, 'admin_menu', 100, 0 );
1281
+
1282
+        // Hook the admin-ajax.php?action=wl_download_your_data&out=xyz links.
1283
+        $this->loader->add_action( 'wp_ajax_wl_download_your_data', $this->download_your_data_page, 'download_your_data', 10 );
1284
+
1285
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1286
+        $this->loader->add_action( 'wp_ajax_wl_jsonld', $this->jsonld_service, 'get' );
1287
+
1288
+        // Hook the AJAX wl_validate_key action to the Key Validation service.
1289
+        $this->loader->add_action( 'wp_ajax_wl_validate_key', $this->key_validation_service, 'validate_key' );
1290
+
1291
+        // Hook the `admin_init` function to the Admin Setup.
1292
+        $this->loader->add_action( 'admin_init', $this->admin_setup, 'admin_init' );
1293
+
1294
+        // Hook the admin_init to the settings page.
1295
+        $this->loader->add_action( 'admin_init', $this->settings_page, 'admin_init' );
1296
+
1297
+        // Hook the menu creation on the general wordlift menu creation
1298
+        $this->loader->add_action( 'wl_admin_menu', $this->settings_page, 'admin_menu', 10, 2 );
1299
+        if ( defined( 'WORDLIFT_BATCH' ) && WORDLIFT_BATCH ) {
1300
+            // Add the functionality only if a flag is set in wp-config.php .
1301
+            $this->loader->add_action( 'wl_admin_menu', $this->batch_analysis_page, 'admin_menu', 10, 2 );
1302
+        }
1303
+
1304
+        // Hook key update.
1305
+        $this->loader->add_action( 'pre_update_option_wl_general_settings', $this->configuration_service, 'maybe_update_dataset_uri', 10, 2 );
1306
+        $this->loader->add_action( 'update_option_wl_general_settings', $this->configuration_service, 'update_key', 10, 2 );
1307
+
1308
+        // Add additional action links to the WordLift plugin in the plugins page.
1309
+        $this->loader->add_filter( 'plugin_action_links_wordlift/wordlift.php', $this->settings_page_action_link, 'action_links', 10, 1 );
1310
+
1311
+        // Hook the AJAX `wl_publisher` action name.
1312
+        $this->loader->add_action( 'wp_ajax_wl_publisher', $this->publisher_ajax_adapter, 'publisher' );
1313
+
1314
+        // Hook row actions for the entity type list admin.
1315
+        $this->loader->add_filter( 'wl_entity_type_row_actions', $this->entity_type_admin_page, 'wl_entity_type_row_actions', 10, 2 );
1316
+
1317
+        // Hook capabilities manipulation to allow access to entity type admin
1318
+        // page  on wordpress versions before 4.7.
1319
+        global $wp_version;
1320
+        if ( version_compare( $wp_version, '4.7', '<' ) ) {
1321
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'enable_admin_access_pre_47', 10, 4 );
1322
+        }
1323
+
1324
+        $this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1325
+
1326
+        /** Adapters. */
1327
+        $this->loader->add_filter( 'mce_external_plugins', $this->tinymce_adapter, 'mce_external_plugins', 10, 1 );
1328
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_auto_selected_posts', $this->batch_analysis_adapter, 'submit_auto_selected_posts', 10 );
1329
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit_all_posts', $this->batch_analysis_adapter, 'submit_all_posts', 10 );
1330
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_submit', $this->batch_analysis_adapter, 'submit', 10 );
1331
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_cancel', $this->batch_analysis_adapter, 'cancel', 10 );
1332
+        $this->loader->add_action( 'wp_ajax_wl_batch_analysis_clear_warning', $this->batch_analysis_adapter, 'clear_warning', 10 );
1333
+        $this->loader->add_action( 'wp_ajax_wl_relation_rebuild_process_all', $this->relation_rebuild_adapter, 'process_all', 10 );
1334
+
1335
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_create', $this->sample_data_ajax_adapter, 'create' );
1336
+        $this->loader->add_action( 'wp_ajax_wl_sample_data_delete', $this->sample_data_ajax_adapter, 'delete' );
1337
+
1338
+        // Handle the autocomplete request.
1339
+        add_action( 'wp_ajax_wl_autocomplete', array( $this->autocomplete_adapter, 'wl_autocomplete' ) );
1340
+        add_action( 'wp_ajax_nopriv_wl_autocomplete', array( $this->autocomplete_adapter, 'wl_autocomplete' ) );
1341
+
1342
+        // Hooks to restrict multisite super admin from manipulating entity types.
1343
+        if ( is_multisite() ) {
1344
+            $this->loader->add_filter( 'map_meta_cap', $this->entity_type_admin_page, 'restrict_super_admin', 10, 4 );
1345
+        }
1346
+
1347
+    }
1348
+
1349
+    /**
1350
+     * Register all of the hooks related to the public-facing functionality
1351
+     * of the plugin.
1352
+     *
1353
+     * @since    1.0.0
1354
+     * @access   private
1355
+     */
1356
+    private function define_public_hooks() {
1357 1357
 
1358
-		$plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1358
+        $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() );
1359 1359
 
1360
-		// Register the entity post type.
1361
-		$this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1360
+        // Register the entity post type.
1361
+        $this->loader->add_action( 'init', $this->entity_post_type_service, 'register' );
1362 1362
 
1363
-		// Bind the link generation and handling hooks to the entity link service.
1364
-		$this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1365
-		$this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1366
-		$this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 );
1367
-		$this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 );
1363
+        // Bind the link generation and handling hooks to the entity link service.
1364
+        $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 );
1365
+        $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', PHP_INT_MAX, 1 );
1366
+        $this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 );
1367
+        $this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 );
1368 1368
 
1369
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1370
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1369
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
1370
+        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
1371 1371
 
1372
-		// Hook the content filter service to add entity links.
1373
-		$this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1372
+        // Hook the content filter service to add entity links.
1373
+        $this->loader->add_filter( 'the_content', $this->content_filter_service, 'the_content' );
1374 1374
 
1375
-		// Hook the AJAX wl_timeline action to the Timeline service.
1376
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1375
+        // Hook the AJAX wl_timeline action to the Timeline service.
1376
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' );
1377 1377
 
1378
-		// Hook the ShareThis service.
1379
-		$this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1380
-		$this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1378
+        // Hook the ShareThis service.
1379
+        $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 );
1380
+        $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 );
1381 1381
 
1382
-		// Hook the AJAX wl_jsonld action to the JSON-LD service.
1383
-		$this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1382
+        // Hook the AJAX wl_jsonld action to the JSON-LD service.
1383
+        $this->loader->add_action( 'wp_ajax_nopriv_wl_jsonld', $this->jsonld_service, 'get' );
1384 1384
 
1385
-		// Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1386
-		// in order to tweak WP's `WP_Query` to include entities in queries related
1387
-		// to categories.
1388
-		$this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1385
+        // Hook the `pre_get_posts` action to the `Wordlift_Category_Taxonomy_Service`
1386
+        // in order to tweak WP's `WP_Query` to include entities in queries related
1387
+        // to categories.
1388
+        $this->loader->add_action( 'pre_get_posts', $this->category_taxonomy_service, 'pre_get_posts', 10, 1 );
1389 1389
 
1390
-		/*
1390
+        /*
1391 1391
 		 * Hook the `pre_get_posts` action to the `Wordlift_Entity_Page_Service`
1392 1392
 		 * in order to tweak WP's `WP_Query` to show event related entities in reverse
1393 1393
 		 * order of start time.
1394 1394
 		 */
1395
-		$this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1396
-
1397
-		$this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1398
-
1399
-		// This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1400
-		$this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1401
-
1402
-	}
1403
-
1404
-	/**
1405
-	 * Run the loader to execute all of the hooks with WordPress.
1406
-	 *
1407
-	 * @since    1.0.0
1408
-	 */
1409
-	public function run() {
1410
-		$this->loader->run();
1411
-	}
1412
-
1413
-	/**
1414
-	 * The name of the plugin used to uniquely identify it within the context of
1415
-	 * WordPress and to define internationalization functionality.
1416
-	 *
1417
-	 * @since     1.0.0
1418
-	 * @return    string    The name of the plugin.
1419
-	 */
1420
-	public function get_plugin_name() {
1421
-		return $this->plugin_name;
1422
-	}
1423
-
1424
-	/**
1425
-	 * The reference to the class that orchestrates the hooks with the plugin.
1426
-	 *
1427
-	 * @since     1.0.0
1428
-	 * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1429
-	 */
1430
-	public function get_loader() {
1431
-		return $this->loader;
1432
-	}
1433
-
1434
-	/**
1435
-	 * Retrieve the version number of the plugin.
1436
-	 *
1437
-	 * @since     1.0.0
1438
-	 * @return    string    The version number of the plugin.
1439
-	 */
1440
-	public function get_version() {
1441
-		return $this->version;
1442
-	}
1395
+        $this->loader->add_action( 'pre_get_posts', $this->entity_page_service, 'pre_get_posts', 10, 1 );
1396
+
1397
+        $this->loader->add_action( 'wp_async_wl_run_sparql_query', $this->sparql_service, 'run_sparql_query', 10, 1 );
1398
+
1399
+        // This hook have to run before the rating service, as otherwise the post might not be a proper entity when rating is done.
1400
+        $this->loader->add_action( 'save_post', $this->entity_type_adapter, 'save_post', 9, 3 );
1401
+
1402
+    }
1403
+
1404
+    /**
1405
+     * Run the loader to execute all of the hooks with WordPress.
1406
+     *
1407
+     * @since    1.0.0
1408
+     */
1409
+    public function run() {
1410
+        $this->loader->run();
1411
+    }
1412
+
1413
+    /**
1414
+     * The name of the plugin used to uniquely identify it within the context of
1415
+     * WordPress and to define internationalization functionality.
1416
+     *
1417
+     * @since     1.0.0
1418
+     * @return    string    The name of the plugin.
1419
+     */
1420
+    public function get_plugin_name() {
1421
+        return $this->plugin_name;
1422
+    }
1423
+
1424
+    /**
1425
+     * The reference to the class that orchestrates the hooks with the plugin.
1426
+     *
1427
+     * @since     1.0.0
1428
+     * @return    Wordlift_Loader    Orchestrates the hooks of the plugin.
1429
+     */
1430
+    public function get_loader() {
1431
+        return $this->loader;
1432
+    }
1433
+
1434
+    /**
1435
+     * Retrieve the version number of the plugin.
1436
+     *
1437
+     * @since     1.0.0
1438
+     * @return    string    The version number of the plugin.
1439
+     */
1440
+    public function get_version() {
1441
+        return $this->version;
1442
+    }
1443 1443
 
1444 1444
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift-entity-service.php 1 patch
Indentation   +605 added lines, -605 removed lines patch added patch discarded remove patch
@@ -7,615 +7,615 @@
 block discarded – undo
7 7
  */
8 8
 class Wordlift_Entity_Service {
9 9
 
10
-	/**
11
-	 * The Log service.
12
-	 *
13
-	 * @since  3.2.0
14
-	 * @access private
15
-	 * @var \Wordlift_Log_Service $log The Log service.
16
-	 */
17
-	private $log;
18
-
19
-	/**
20
-	 * The UI service.
21
-	 *
22
-	 * @since  3.2.0
23
-	 * @access private
24
-	 * @var \Wordlift_UI_Service $ui_service The UI service.
25
-	 */
26
-	private $ui_service;
27
-
28
-	/**
29
-	 * The {@link Wordlift_Relation_Service} instance.
30
-	 *
31
-	 * @since  3.15.0
32
-	 * @access private
33
-	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
34
-	 */
35
-	private $relation_service;
36
-
37
-	/**
38
-	 * The entity post type name.
39
-	 *
40
-	 * @since 3.1.0
41
-	 */
42
-	const TYPE_NAME = 'entity';
43
-
44
-	/**
45
-	 * The alternative label meta key.
46
-	 *
47
-	 * @since 3.2.0
48
-	 */
49
-	const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
50
-
51
-	/**
52
-	 * The alternative label input template.
53
-	 *
54
-	 * @since 3.2.0
55
-	 */
56
-	// TODO: this should be moved to a class that deals with HTML code.
57
-	const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
10
+    /**
11
+     * The Log service.
12
+     *
13
+     * @since  3.2.0
14
+     * @access private
15
+     * @var \Wordlift_Log_Service $log The Log service.
16
+     */
17
+    private $log;
18
+
19
+    /**
20
+     * The UI service.
21
+     *
22
+     * @since  3.2.0
23
+     * @access private
24
+     * @var \Wordlift_UI_Service $ui_service The UI service.
25
+     */
26
+    private $ui_service;
27
+
28
+    /**
29
+     * The {@link Wordlift_Relation_Service} instance.
30
+     *
31
+     * @since  3.15.0
32
+     * @access private
33
+     * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
34
+     */
35
+    private $relation_service;
36
+
37
+    /**
38
+     * The entity post type name.
39
+     *
40
+     * @since 3.1.0
41
+     */
42
+    const TYPE_NAME = 'entity';
43
+
44
+    /**
45
+     * The alternative label meta key.
46
+     *
47
+     * @since 3.2.0
48
+     */
49
+    const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
50
+
51
+    /**
52
+     * The alternative label input template.
53
+     *
54
+     * @since 3.2.0
55
+     */
56
+    // TODO: this should be moved to a class that deals with HTML code.
57
+    const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
58 58
                 <label class="screen-reader-text" id="wl-alternative-label-prompt-text" for="wl-alternative-label">Enter alternative label here</label>
59 59
                 <input name="wl_alternative_label[]" size="30" value="%s" id="wl-alternative-label" type="text">
60 60
                 <button class="button wl-delete-button">%s</button>
61 61
                 </div>';
62 62
 
63
-	/**
64
-	 * A singleton instance of the Entity service.
65
-	 *
66
-	 * @since  3.2.0
67
-	 * @access private
68
-	 * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service.
69
-	 */
70
-	private static $instance;
71
-
72
-	/**
73
-	 * Create a Wordlift_Entity_Service instance.
74
-	 *
75
-	 * @since 3.2.0
76
-	 *
77
-	 * @param \Wordlift_UI_Service       $ui_service       The UI service.
78
-	 * @param \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
79
-	 */
80
-	public function __construct( $ui_service, $relation_service ) {
81
-
82
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
83
-
84
-		$this->ui_service       = $ui_service;
85
-		$this->relation_service = $relation_service;
86
-
87
-		// Set the singleton instance.
88
-		self::$instance = $this;
89
-	}
90
-
91
-	/**
92
-	 * Get the singleton instance of the Entity service.
93
-	 *
94
-	 * @since 3.2.0
95
-	 * @return \Wordlift_Entity_Service The singleton instance of the Entity service.
96
-	 */
97
-	public static function get_instance() {
98
-
99
-		return self::$instance;
100
-	}
101
-
102
-	/**
103
-	 * Determines whether a post is an entity or not. Entity is in this context
104
-	 * something which is not an article.
105
-	 *
106
-	 * @since 3.1.0
107
-	 *
108
-	 * @param int $post_id A post id.
109
-	 *
110
-	 * @return bool Return true if the post is an entity otherwise false.
111
-	 */
112
-	public function is_entity( $post_id ) {
113
-
114
-		$terms = wp_get_object_terms( $post_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
115
-
116
-		if ( 0 === count( $terms ) ) {
117
-			return false;
118
-		}
119
-
120
-		// We don't consider an `article` to be an entity.
121
-		if ( 'article' !== $terms[0]->slug ) {
122
-			return true;
123
-		}
124
-
125
-		return false;
126
-	}
127
-
128
-	/**
129
-	 * Get the proper classification scope for a given entity post
130
-	 *
131
-	 * @since 3.5.0
132
-	 *
133
-	 * @param integer $post_id An entity post id.
134
-	 *
135
-	 * @param string  $default The default classification scope, `what` if not
136
-	 *                         provided.
137
-	 *
138
-	 * @return string Returns a classification scope (e.g. 'what').
139
-	 */
140
-	public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
141
-
142
-		if ( false === $this->is_entity( $post_id ) ) {
143
-			return $default;
144
-		}
145
-
146
-		// Retrieve the entity type
147
-		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
148
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
149
-		// Retrieve classification boxes configuration
150
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
151
-		foreach ( $classification_boxes as $cb ) {
152
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
153
-				return $cb['id'];
154
-			}
155
-		}
156
-
157
-		return $default;
158
-	}
159
-
160
-	/**
161
-	 * Check whether a {@link WP_Post} is used.
162
-	 *
163
-	 * @param int $post_id The {@link WP_Post}'s id.
164
-	 *
165
-	 * @return bool|null Null if it's not an entity, otherwise true if it's used.
166
-	 */
167
-	public function is_used( $post_id ) {
168
-
169
-		if ( false === $this->is_entity( $post_id ) ) {
170
-			return null;
171
-		}
172
-		// Retrieve the post
173
-		$entity = get_post( $post_id );
174
-
175
-		global $wpdb;
176
-		// Retrieve Wordlift relation instances table name
177
-		$table_name = wl_core_get_relation_instances_table_name();
178
-
179
-		// Check is it's referenced / related to another post / entity
180
-		$stmt = $wpdb->prepare(
181
-			"SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
182
-			$entity->ID
183
-		);
184
-
185
-		// Perform the query
186
-		$relation_instances = (int) $wpdb->get_var( $stmt );
187
-		// If there is at least one relation instance for the current entity, then it's used
188
-		if ( 0 < $relation_instances ) {
189
-			return true;
190
-		}
191
-
192
-		// Check if the entity uri is used as meta_value
193
-		$stmt = $wpdb->prepare(
194
-			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
195
-			$entity->ID,
196
-			wl_get_entity_uri( $entity->ID )
197
-		);
198
-		// Perform the query
199
-		$meta_instances = (int) $wpdb->get_var( $stmt );
200
-
201
-		// If there is at least one meta that refers the current entity uri, then current entity is used
202
-		if ( 0 < $meta_instances ) {
203
-			return true;
204
-		}
205
-
206
-		// If we are here, it means the current entity is not used at the moment
207
-		return false;
208
-	}
209
-
210
-	/**
211
-	 * Determines whether a given uri is an internal uri or not.
212
-	 *
213
-	 * @since 3.3.2
214
-	 *
215
-	 * @param int $uri An uri.
216
-	 *
217
-	 * @return true if the uri internal to the current dataset otherwise false.
218
-	 */
219
-	public function is_internal_uri( $uri ) {
220
-
221
-		return ( 0 === strrpos( $uri, wl_configuration_get_redlink_dataset_uri() ) );
222
-	}
223
-
224
-	/**
225
-	 * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
226
-	 *
227
-	 * @since 3.2.0
228
-	 *
229
-	 * @param string $uri The entity URI.
230
-	 *
231
-	 * @return WP_Post|null A WP_Post instance or null if not found.
232
-	 */
233
-	public function get_entity_post_by_uri( $uri ) {
234
-
235
-		// Check if we've been provided with a value otherwise return null.
236
-		if ( empty( $uri ) ) {
237
-			return null;
238
-		}
239
-
240
-		$query_args = array(
241
-			// See https://github.com/insideout10/wordlift-plugin/issues/654.
242
-			'ignore_sticky_posts' => 1,
243
-			'posts_per_page'      => 1,
244
-			'post_status'         => 'any',
245
-			'post_type'           => Wordlift_Entity_Service::valid_entity_post_types(),
246
-			'meta_query'          => array(
247
-				array(
248
-					'key'     => WL_ENTITY_URL_META_NAME,
249
-					'value'   => $uri,
250
-					'compare' => '=',
251
-				),
252
-			),
253
-			'tax_query'           => array(
254
-				array(
255
-					'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
256
-					'field'    => 'slug',
257
-					'terms'    => 'article',
258
-					'operator' => 'NOT IN',
259
-				),
260
-			),
261
-		);
262
-
263
-		// Only if the current uri is not an internal uri, entity search is
264
-		// performed also looking at sameAs values.
265
-		//
266
-		// This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237
267
-		if ( ! $this->is_internal_uri( $uri ) ) {
268
-
269
-			$query_args['meta_query']['relation'] = 'OR';
270
-			$query_args['meta_query'][]           = array(
271
-				'key'     => Wordlift_Schema_Service::FIELD_SAME_AS,
272
-				'value'   => $uri,
273
-				'compare' => '=',
274
-			);
275
-		}
276
-
277
-		$query = new WP_Query( $query_args );
278
-
279
-		// Get the matching entity posts.
280
-		$posts = $query->get_posts();
281
-
282
-		// Return null if no post is found.
283
-		if ( 0 === count( $posts ) ) {
284
-			return null;
285
-		}
286
-
287
-		// Return the found post.
288
-		return $posts[0];
289
-	}
290
-
291
-	/**
292
-	 * Fires once a post has been saved. This function uses the $_REQUEST, therefore
293
-	 * we check that the post we're saving is the current post.
294
-	 *
295
-	 * @see   https://github.com/insideout10/wordlift-plugin/issues/363
296
-	 *
297
-	 * @since 3.2.0
298
-	 *
299
-	 * @param int     $post_id Post ID.
300
-	 * @param WP_Post $post    Post object.
301
-	 * @param bool    $update  Whether this is an existing post being updated or not.
302
-	 */
303
-	public function save_post( $post_id, $post, $update ) {
304
-
305
-		// Avoid doing anything if post is autosave or a revision.
306
-		if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
307
-			return;
308
-		}
309
-
310
-		// We're setting the alternative label that have been provided via the UI
311
-		// (in fact we're using $_REQUEST), while save_post may be also called
312
-		// programmatically by some other function: we need to check therefore if
313
-		// the $post_id in the save_post call matches the post id set in the request.
314
-		//
315
-		// If this is not the current post being saved or if it's not an entity, return.
316
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
317
-			return;
318
-		}
319
-
320
-		// Get the alt labels from the request (or empty array).
321
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
322
-
323
-		// Set the alternative labels.
324
-		$this->set_alternative_labels( $post_id, $alt_labels );
325
-
326
-	}
327
-
328
-	/**
329
-	 * Set the alternative labels.
330
-	 *
331
-	 * @since 3.2.0
332
-	 *
333
-	 * @param int   $post_id    The post id.
334
-	 * @param array $alt_labels An array of labels.
335
-	 */
336
-	public function set_alternative_labels( $post_id, $alt_labels ) {
337
-
338
-		// Force $alt_labels to be an array
339
-		if ( ! is_array( $alt_labels ) ) {
340
-			$alt_labels = array( $alt_labels );
341
-		}
342
-
343
-		$this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
344
-
345
-		// Delete all the existing alternate labels.
346
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
347
-
348
-		// Set the alternative labels.
349
-		foreach ( $alt_labels as $alt_label ) {
350
-			if ( ! empty( $alt_label ) ) {
351
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
352
-			}
353
-		}
354
-
355
-	}
356
-
357
-	/**
358
-	 * Retrieve the alternate labels.
359
-	 *
360
-	 * @since 3.2.0
361
-	 *
362
-	 * @param int $post_id Post id.
363
-	 *
364
-	 * @return mixed An array  of alternative labels.
365
-	 */
366
-	public function get_alternative_labels( $post_id ) {
367
-
368
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
369
-	}
370
-
371
-	/**
372
-	 * Retrieve the labels for an entity, i.e. the title + the synonyms.
373
-	 *
374
-	 * @since 3.12.0
375
-	 *
376
-	 * @param int $post_id The entity {@link WP_Post} id.
377
-	 *
378
-	 * @return array An array with the entity title and labels.
379
-	 */
380
-	public function get_labels( $post_id ) {
381
-
382
-		return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
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
-	 * @since 3.2.0
389
-	 *
390
-	 * @param WP_Post $post Post object.
391
-	 */
392
-	public function edit_form_before_permalink( $post ) {
393
-
394
-		// If it's not an entity, return.
395
-		if ( ! $this->is_entity( $post->ID ) ) {
396
-			return;
397
-		}
398
-
399
-		// Print the input template.
400
-		$this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
401
-
402
-		// Print all the currently set alternative labels.
403
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
404
-
405
-			echo $this->get_alternative_label_input( $alt_label );
406
-
407
-		};
408
-
409
-		// Print the button.
410
-		$this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
411
-
412
-	}
413
-
414
-	/**
415
-	 * Get the URI for the entity with the specified post id.
416
-	 *
417
-	 * @since 3.6.0
418
-	 *
419
-	 * @param int $post_id The entity post id.
420
-	 *
421
-	 * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
422
-	 */
423
-	public function get_uri( $post_id ) {
424
-
425
-		// If a null is given, nothing to do
426
-		if ( null == $post_id ) {
427
-			return null;
428
-		}
429
-
430
-		$uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
431
-
432
-		// If the dataset uri is not properly configured, null is returned
433
-		if ( '' === wl_configuration_get_redlink_dataset_uri() ) {
434
-			return null;
435
-		}
436
-
437
-		// Set the URI if it isn't set yet.
438
-		$post_status = get_post_status( $post_id );
439
-		if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
440
-			$uri = wl_build_entity_uri( $post_id );
441
-			wl_set_entity_uri( $post_id, $uri );
442
-		}
443
-
444
-		return $uri;
445
-	}
446
-
447
-
448
-	/**
449
-	 * Get the alternative label input HTML code.
450
-	 *
451
-	 * @since 3.2.0
452
-	 *
453
-	 * @param string $value The input value.
454
-	 *
455
-	 * @return string The input HTML code.
456
-	 */
457
-	private function get_alternative_label_input( $value = '' ) {
458
-
459
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
460
-	}
461
-
462
-	/**
463
-	 * Get the number of entity posts published in this blog.
464
-	 *
465
-	 * @since 3.6.0
466
-	 *
467
-	 * @return int The number of published entity posts.
468
-	 */
469
-	public function count() {
470
-
471
-		$posts = get_posts( $this->add_criterias( array(
472
-			'post_status' => 'any',
473
-			'numberposts' => - 1,
474
-		) ) );
475
-
476
-		return count( $posts );
477
-	}
478
-
479
-	/**
480
-	 * Add the entity filtering criterias to the arguments for a `get_posts`
481
-	 * call.
482
-	 *
483
-	 * @since 3.15.0
484
-	 *
485
-	 * @param array $args The arguments for a `get_posts` call.
486
-	 *
487
-	 * @return array The arguments for a `get_posts` call.
488
-	 */
489
-	public static function add_criterias( $args ) {
490
-
491
-		return $args + array(
492
-				'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
493
-				'tax_query' => array(
494
-					array(
495
-						'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
496
-						'terms'    => self::get_entity_terms(),
497
-					),
498
-				),
499
-			);
500
-	}
501
-
502
-	/**
503
-	 * Get the entity terms IDs which represent an entity.
504
-	 *
505
-	 * @since 3.15.0
506
-	 *
507
-	 * @return array An array of terms' ids.
508
-	 */
509
-	public static function get_entity_terms() {
510
-
511
-		$terms = get_terms( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
512
-			'hide_empty' => false,
513
-			// Because of #334 (and the AAM plugin) we changed fields from 'id=>slug' to 'all'.
514
-			// An issue has been opened with the AAM plugin author as well.
515
-			//
516
-			// see https://github.com/insideout10/wordlift-plugin/issues/334
517
-			// see https://wordpress.org/support/topic/idslug-not-working-anymore?replies=1#post-8806863
518
-			'fields'     => 'all',
519
-		) );
520
-
521
-		return array_map( function ( $term ) {
522
-			return $term->term_id;
523
-		}, array_filter( $terms, function ( $term ) {
524
-			return 'article' !== $term->slug;
525
-		} ) );
526
-	}
527
-
528
-	/**
529
-	 * Create a new entity.
530
-	 *
531
-	 * @since 3.9.0
532
-	 *
533
-	 * @param string $name     The entity name.
534
-	 * @param string $type_uri The entity's type URI.
535
-	 * @param null   $logo     The entity logo id (or NULL if none).
536
-	 * @param string $status   The post status, by default 'publish'.
537
-	 *
538
-	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
539
-	 */
540
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
541
-
542
-		// Create an entity for the publisher.
543
-		$post_id = wp_insert_post( array(
544
-			'post_type'    => self::TYPE_NAME,
545
-			'post_title'   => $name,
546
-			'post_status'  => $status,
547
-			'post_content' => '',
548
-		) );
549
-
550
-		// Return the error if any.
551
-		if ( is_wp_error( $post_id ) ) {
552
-			return $post_id;
553
-		}
554
-
555
-		// Set the entity logo.
556
-		if ( $logo && is_numeric( $logo ) ) {
557
-			set_post_thumbnail( $post_id, $logo );
558
-		}
559
-
560
-		// Set the entity type.
561
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
562
-
563
-		return $post_id;
564
-	}
565
-
566
-	/**
567
-	 * Get the entities related to the one with the specified id. By default only
568
-	 * published entities will be returned.
569
-	 *
570
-	 * @since 3.10.0
571
-	 *
572
-	 * @param int    $id          The post id.
573
-	 * @param string $post_status The target post status (default = publish).
574
-	 *
575
-	 * @return array An array of post ids.
576
-	 */
577
-	public function get_related_entities( $id, $post_status = 'publish' ) {
578
-
579
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
580
-	}
581
-
582
-	/**
583
-	 * Get the list of entities.
584
-	 *
585
-	 * @since 3.12.2
586
-	 *
587
-	 * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
588
-	 *
589
-	 * @return array An array of entity posts.
590
-	 */
591
-	public function get( $params = array() ) {
592
-
593
-		// Set the defaults.
594
-		$defaults = array( 'post_type' => 'entity' );
595
-
596
-		// Merge the defaults with the provided parameters.
597
-		$args = wp_parse_args( $params, $defaults );
598
-
599
-		// Call the `get_posts` function.
600
-		return get_posts( $args );
601
-	}
602
-
603
-	/**
604
-	 * The list of post type names which can be used for entities
605
-	 *
606
-	 * Criteria is that the post type is public. The list of valid post types
607
-	 * can be overridden with a filter.
608
-	 *
609
-	 * @since 3.15.0
610
-	 *
611
-	 * @return array Array containing the names of the valid post types.
612
-	 */
613
-	static function valid_entity_post_types() {
614
-
615
-		// Ignore builtins in the call to avoid getting attachments.
616
-		$post_types = array( 'post', 'page', self::TYPE_NAME );
617
-
618
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
619
-	}
63
+    /**
64
+     * A singleton instance of the Entity service.
65
+     *
66
+     * @since  3.2.0
67
+     * @access private
68
+     * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service.
69
+     */
70
+    private static $instance;
71
+
72
+    /**
73
+     * Create a Wordlift_Entity_Service instance.
74
+     *
75
+     * @since 3.2.0
76
+     *
77
+     * @param \Wordlift_UI_Service       $ui_service       The UI service.
78
+     * @param \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
79
+     */
80
+    public function __construct( $ui_service, $relation_service ) {
81
+
82
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
83
+
84
+        $this->ui_service       = $ui_service;
85
+        $this->relation_service = $relation_service;
86
+
87
+        // Set the singleton instance.
88
+        self::$instance = $this;
89
+    }
90
+
91
+    /**
92
+     * Get the singleton instance of the Entity service.
93
+     *
94
+     * @since 3.2.0
95
+     * @return \Wordlift_Entity_Service The singleton instance of the Entity service.
96
+     */
97
+    public static function get_instance() {
98
+
99
+        return self::$instance;
100
+    }
101
+
102
+    /**
103
+     * Determines whether a post is an entity or not. Entity is in this context
104
+     * something which is not an article.
105
+     *
106
+     * @since 3.1.0
107
+     *
108
+     * @param int $post_id A post id.
109
+     *
110
+     * @return bool Return true if the post is an entity otherwise false.
111
+     */
112
+    public function is_entity( $post_id ) {
113
+
114
+        $terms = wp_get_object_terms( $post_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME );
115
+
116
+        if ( 0 === count( $terms ) ) {
117
+            return false;
118
+        }
119
+
120
+        // We don't consider an `article` to be an entity.
121
+        if ( 'article' !== $terms[0]->slug ) {
122
+            return true;
123
+        }
124
+
125
+        return false;
126
+    }
127
+
128
+    /**
129
+     * Get the proper classification scope for a given entity post
130
+     *
131
+     * @since 3.5.0
132
+     *
133
+     * @param integer $post_id An entity post id.
134
+     *
135
+     * @param string  $default The default classification scope, `what` if not
136
+     *                         provided.
137
+     *
138
+     * @return string Returns a classification scope (e.g. 'what').
139
+     */
140
+    public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
141
+
142
+        if ( false === $this->is_entity( $post_id ) ) {
143
+            return $default;
144
+        }
145
+
146
+        // Retrieve the entity type
147
+        $entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
148
+        $entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
149
+        // Retrieve classification boxes configuration
150
+        $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
151
+        foreach ( $classification_boxes as $cb ) {
152
+            if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
153
+                return $cb['id'];
154
+            }
155
+        }
156
+
157
+        return $default;
158
+    }
159
+
160
+    /**
161
+     * Check whether a {@link WP_Post} is used.
162
+     *
163
+     * @param int $post_id The {@link WP_Post}'s id.
164
+     *
165
+     * @return bool|null Null if it's not an entity, otherwise true if it's used.
166
+     */
167
+    public function is_used( $post_id ) {
168
+
169
+        if ( false === $this->is_entity( $post_id ) ) {
170
+            return null;
171
+        }
172
+        // Retrieve the post
173
+        $entity = get_post( $post_id );
174
+
175
+        global $wpdb;
176
+        // Retrieve Wordlift relation instances table name
177
+        $table_name = wl_core_get_relation_instances_table_name();
178
+
179
+        // Check is it's referenced / related to another post / entity
180
+        $stmt = $wpdb->prepare(
181
+            "SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
182
+            $entity->ID
183
+        );
184
+
185
+        // Perform the query
186
+        $relation_instances = (int) $wpdb->get_var( $stmt );
187
+        // If there is at least one relation instance for the current entity, then it's used
188
+        if ( 0 < $relation_instances ) {
189
+            return true;
190
+        }
191
+
192
+        // Check if the entity uri is used as meta_value
193
+        $stmt = $wpdb->prepare(
194
+            "SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
195
+            $entity->ID,
196
+            wl_get_entity_uri( $entity->ID )
197
+        );
198
+        // Perform the query
199
+        $meta_instances = (int) $wpdb->get_var( $stmt );
200
+
201
+        // If there is at least one meta that refers the current entity uri, then current entity is used
202
+        if ( 0 < $meta_instances ) {
203
+            return true;
204
+        }
205
+
206
+        // If we are here, it means the current entity is not used at the moment
207
+        return false;
208
+    }
209
+
210
+    /**
211
+     * Determines whether a given uri is an internal uri or not.
212
+     *
213
+     * @since 3.3.2
214
+     *
215
+     * @param int $uri An uri.
216
+     *
217
+     * @return true if the uri internal to the current dataset otherwise false.
218
+     */
219
+    public function is_internal_uri( $uri ) {
220
+
221
+        return ( 0 === strrpos( $uri, wl_configuration_get_redlink_dataset_uri() ) );
222
+    }
223
+
224
+    /**
225
+     * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
226
+     *
227
+     * @since 3.2.0
228
+     *
229
+     * @param string $uri The entity URI.
230
+     *
231
+     * @return WP_Post|null A WP_Post instance or null if not found.
232
+     */
233
+    public function get_entity_post_by_uri( $uri ) {
234
+
235
+        // Check if we've been provided with a value otherwise return null.
236
+        if ( empty( $uri ) ) {
237
+            return null;
238
+        }
239
+
240
+        $query_args = array(
241
+            // See https://github.com/insideout10/wordlift-plugin/issues/654.
242
+            'ignore_sticky_posts' => 1,
243
+            'posts_per_page'      => 1,
244
+            'post_status'         => 'any',
245
+            'post_type'           => Wordlift_Entity_Service::valid_entity_post_types(),
246
+            'meta_query'          => array(
247
+                array(
248
+                    'key'     => WL_ENTITY_URL_META_NAME,
249
+                    'value'   => $uri,
250
+                    'compare' => '=',
251
+                ),
252
+            ),
253
+            'tax_query'           => array(
254
+                array(
255
+                    'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
256
+                    'field'    => 'slug',
257
+                    'terms'    => 'article',
258
+                    'operator' => 'NOT IN',
259
+                ),
260
+            ),
261
+        );
262
+
263
+        // Only if the current uri is not an internal uri, entity search is
264
+        // performed also looking at sameAs values.
265
+        //
266
+        // This solve issues like https://github.com/insideout10/wordlift-plugin/issues/237
267
+        if ( ! $this->is_internal_uri( $uri ) ) {
268
+
269
+            $query_args['meta_query']['relation'] = 'OR';
270
+            $query_args['meta_query'][]           = array(
271
+                'key'     => Wordlift_Schema_Service::FIELD_SAME_AS,
272
+                'value'   => $uri,
273
+                'compare' => '=',
274
+            );
275
+        }
276
+
277
+        $query = new WP_Query( $query_args );
278
+
279
+        // Get the matching entity posts.
280
+        $posts = $query->get_posts();
281
+
282
+        // Return null if no post is found.
283
+        if ( 0 === count( $posts ) ) {
284
+            return null;
285
+        }
286
+
287
+        // Return the found post.
288
+        return $posts[0];
289
+    }
290
+
291
+    /**
292
+     * Fires once a post has been saved. This function uses the $_REQUEST, therefore
293
+     * we check that the post we're saving is the current post.
294
+     *
295
+     * @see   https://github.com/insideout10/wordlift-plugin/issues/363
296
+     *
297
+     * @since 3.2.0
298
+     *
299
+     * @param int     $post_id Post ID.
300
+     * @param WP_Post $post    Post object.
301
+     * @param bool    $update  Whether this is an existing post being updated or not.
302
+     */
303
+    public function save_post( $post_id, $post, $update ) {
304
+
305
+        // Avoid doing anything if post is autosave or a revision.
306
+        if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
307
+            return;
308
+        }
309
+
310
+        // We're setting the alternative label that have been provided via the UI
311
+        // (in fact we're using $_REQUEST), while save_post may be also called
312
+        // programmatically by some other function: we need to check therefore if
313
+        // the $post_id in the save_post call matches the post id set in the request.
314
+        //
315
+        // If this is not the current post being saved or if it's not an entity, return.
316
+        if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
317
+            return;
318
+        }
319
+
320
+        // Get the alt labels from the request (or empty array).
321
+        $alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
322
+
323
+        // Set the alternative labels.
324
+        $this->set_alternative_labels( $post_id, $alt_labels );
325
+
326
+    }
327
+
328
+    /**
329
+     * Set the alternative labels.
330
+     *
331
+     * @since 3.2.0
332
+     *
333
+     * @param int   $post_id    The post id.
334
+     * @param array $alt_labels An array of labels.
335
+     */
336
+    public function set_alternative_labels( $post_id, $alt_labels ) {
337
+
338
+        // Force $alt_labels to be an array
339
+        if ( ! is_array( $alt_labels ) ) {
340
+            $alt_labels = array( $alt_labels );
341
+        }
342
+
343
+        $this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
344
+
345
+        // Delete all the existing alternate labels.
346
+        delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
347
+
348
+        // Set the alternative labels.
349
+        foreach ( $alt_labels as $alt_label ) {
350
+            if ( ! empty( $alt_label ) ) {
351
+                add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
352
+            }
353
+        }
354
+
355
+    }
356
+
357
+    /**
358
+     * Retrieve the alternate labels.
359
+     *
360
+     * @since 3.2.0
361
+     *
362
+     * @param int $post_id Post id.
363
+     *
364
+     * @return mixed An array  of alternative labels.
365
+     */
366
+    public function get_alternative_labels( $post_id ) {
367
+
368
+        return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
369
+    }
370
+
371
+    /**
372
+     * Retrieve the labels for an entity, i.e. the title + the synonyms.
373
+     *
374
+     * @since 3.12.0
375
+     *
376
+     * @param int $post_id The entity {@link WP_Post} id.
377
+     *
378
+     * @return array An array with the entity title and labels.
379
+     */
380
+    public function get_labels( $post_id ) {
381
+
382
+        return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
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
+     * @since 3.2.0
389
+     *
390
+     * @param WP_Post $post Post object.
391
+     */
392
+    public function edit_form_before_permalink( $post ) {
393
+
394
+        // If it's not an entity, return.
395
+        if ( ! $this->is_entity( $post->ID ) ) {
396
+            return;
397
+        }
398
+
399
+        // Print the input template.
400
+        $this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
401
+
402
+        // Print all the currently set alternative labels.
403
+        foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
404
+
405
+            echo $this->get_alternative_label_input( $alt_label );
406
+
407
+        };
408
+
409
+        // Print the button.
410
+        $this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
411
+
412
+    }
413
+
414
+    /**
415
+     * Get the URI for the entity with the specified post id.
416
+     *
417
+     * @since 3.6.0
418
+     *
419
+     * @param int $post_id The entity post id.
420
+     *
421
+     * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
422
+     */
423
+    public function get_uri( $post_id ) {
424
+
425
+        // If a null is given, nothing to do
426
+        if ( null == $post_id ) {
427
+            return null;
428
+        }
429
+
430
+        $uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
431
+
432
+        // If the dataset uri is not properly configured, null is returned
433
+        if ( '' === wl_configuration_get_redlink_dataset_uri() ) {
434
+            return null;
435
+        }
436
+
437
+        // Set the URI if it isn't set yet.
438
+        $post_status = get_post_status( $post_id );
439
+        if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status ) {
440
+            $uri = wl_build_entity_uri( $post_id );
441
+            wl_set_entity_uri( $post_id, $uri );
442
+        }
443
+
444
+        return $uri;
445
+    }
446
+
447
+
448
+    /**
449
+     * Get the alternative label input HTML code.
450
+     *
451
+     * @since 3.2.0
452
+     *
453
+     * @param string $value The input value.
454
+     *
455
+     * @return string The input HTML code.
456
+     */
457
+    private function get_alternative_label_input( $value = '' ) {
458
+
459
+        return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
460
+    }
461
+
462
+    /**
463
+     * Get the number of entity posts published in this blog.
464
+     *
465
+     * @since 3.6.0
466
+     *
467
+     * @return int The number of published entity posts.
468
+     */
469
+    public function count() {
470
+
471
+        $posts = get_posts( $this->add_criterias( array(
472
+            'post_status' => 'any',
473
+            'numberposts' => - 1,
474
+        ) ) );
475
+
476
+        return count( $posts );
477
+    }
478
+
479
+    /**
480
+     * Add the entity filtering criterias to the arguments for a `get_posts`
481
+     * call.
482
+     *
483
+     * @since 3.15.0
484
+     *
485
+     * @param array $args The arguments for a `get_posts` call.
486
+     *
487
+     * @return array The arguments for a `get_posts` call.
488
+     */
489
+    public static function add_criterias( $args ) {
490
+
491
+        return $args + array(
492
+                'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
493
+                'tax_query' => array(
494
+                    array(
495
+                        'taxonomy' => Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME,
496
+                        'terms'    => self::get_entity_terms(),
497
+                    ),
498
+                ),
499
+            );
500
+    }
501
+
502
+    /**
503
+     * Get the entity terms IDs which represent an entity.
504
+     *
505
+     * @since 3.15.0
506
+     *
507
+     * @return array An array of terms' ids.
508
+     */
509
+    public static function get_entity_terms() {
510
+
511
+        $terms = get_terms( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array(
512
+            'hide_empty' => false,
513
+            // Because of #334 (and the AAM plugin) we changed fields from 'id=>slug' to 'all'.
514
+            // An issue has been opened with the AAM plugin author as well.
515
+            //
516
+            // see https://github.com/insideout10/wordlift-plugin/issues/334
517
+            // see https://wordpress.org/support/topic/idslug-not-working-anymore?replies=1#post-8806863
518
+            'fields'     => 'all',
519
+        ) );
520
+
521
+        return array_map( function ( $term ) {
522
+            return $term->term_id;
523
+        }, array_filter( $terms, function ( $term ) {
524
+            return 'article' !== $term->slug;
525
+        } ) );
526
+    }
527
+
528
+    /**
529
+     * Create a new entity.
530
+     *
531
+     * @since 3.9.0
532
+     *
533
+     * @param string $name     The entity name.
534
+     * @param string $type_uri The entity's type URI.
535
+     * @param null   $logo     The entity logo id (or NULL if none).
536
+     * @param string $status   The post status, by default 'publish'.
537
+     *
538
+     * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
539
+     */
540
+    public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
541
+
542
+        // Create an entity for the publisher.
543
+        $post_id = wp_insert_post( array(
544
+            'post_type'    => self::TYPE_NAME,
545
+            'post_title'   => $name,
546
+            'post_status'  => $status,
547
+            'post_content' => '',
548
+        ) );
549
+
550
+        // Return the error if any.
551
+        if ( is_wp_error( $post_id ) ) {
552
+            return $post_id;
553
+        }
554
+
555
+        // Set the entity logo.
556
+        if ( $logo && is_numeric( $logo ) ) {
557
+            set_post_thumbnail( $post_id, $logo );
558
+        }
559
+
560
+        // Set the entity type.
561
+        Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
562
+
563
+        return $post_id;
564
+    }
565
+
566
+    /**
567
+     * Get the entities related to the one with the specified id. By default only
568
+     * published entities will be returned.
569
+     *
570
+     * @since 3.10.0
571
+     *
572
+     * @param int    $id          The post id.
573
+     * @param string $post_status The target post status (default = publish).
574
+     *
575
+     * @return array An array of post ids.
576
+     */
577
+    public function get_related_entities( $id, $post_status = 'publish' ) {
578
+
579
+        return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
580
+    }
581
+
582
+    /**
583
+     * Get the list of entities.
584
+     *
585
+     * @since 3.12.2
586
+     *
587
+     * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
588
+     *
589
+     * @return array An array of entity posts.
590
+     */
591
+    public function get( $params = array() ) {
592
+
593
+        // Set the defaults.
594
+        $defaults = array( 'post_type' => 'entity' );
595
+
596
+        // Merge the defaults with the provided parameters.
597
+        $args = wp_parse_args( $params, $defaults );
598
+
599
+        // Call the `get_posts` function.
600
+        return get_posts( $args );
601
+    }
602
+
603
+    /**
604
+     * The list of post type names which can be used for entities
605
+     *
606
+     * Criteria is that the post type is public. The list of valid post types
607
+     * can be overridden with a filter.
608
+     *
609
+     * @since 3.15.0
610
+     *
611
+     * @return array Array containing the names of the valid post types.
612
+     */
613
+    static function valid_entity_post_types() {
614
+
615
+        // Ignore builtins in the call to avoid getting attachments.
616
+        $post_types = array( 'post', 'page', self::TYPE_NAME );
617
+
618
+        return apply_filters( 'wl_valid_entity_post_types', $post_types );
619
+    }
620 620
 
621 621
 }
Please login to merge, or discard this patch.
src/modules/linked_data/wordlift_linked_data.php 2 patches
Indentation   +334 added lines, -334 removed lines patch added patch discarded remove patch
@@ -18,30 +18,30 @@  discard block
 block discarded – undo
18 18
  */
19 19
 function wl_linked_data_save_post( $post_id ) {
20 20
 
21
-	// If it's not numeric exit from here.
22
-	if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) {
23
-		return;
24
-	}
25
-
26
-	// Get the post type and check whether it supports the editor.
27
-	//
28
-	// See https://github.com/insideout10/wordlift-plugin/issues/659.
29
-	$post_type = get_post_type( $post_id );
30
-	$is_editor_supported = post_type_supports( $post_type, 'editor' );
31
-
32
-	// Bail out if it's not an entity.
33
-	if ( ! $is_editor_supported ) {
34
-		return;
35
-	}
36
-
37
-	// unhook this function so it doesn't loop infinitely
38
-	remove_action( 'save_post', 'wl_linked_data_save_post' );
39
-
40
-	// raise the *wl_linked_data_save_post* event.
41
-	do_action( 'wl_linked_data_save_post', $post_id );
42
-
43
-	// re-hook this function
44
-	add_action( 'save_post', 'wl_linked_data_save_post' );
21
+    // If it's not numeric exit from here.
22
+    if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) {
23
+        return;
24
+    }
25
+
26
+    // Get the post type and check whether it supports the editor.
27
+    //
28
+    // See https://github.com/insideout10/wordlift-plugin/issues/659.
29
+    $post_type = get_post_type( $post_id );
30
+    $is_editor_supported = post_type_supports( $post_type, 'editor' );
31
+
32
+    // Bail out if it's not an entity.
33
+    if ( ! $is_editor_supported ) {
34
+        return;
35
+    }
36
+
37
+    // unhook this function so it doesn't loop infinitely
38
+    remove_action( 'save_post', 'wl_linked_data_save_post' );
39
+
40
+    // raise the *wl_linked_data_save_post* event.
41
+    do_action( 'wl_linked_data_save_post', $post_id );
42
+
43
+    // re-hook this function
44
+    add_action( 'save_post', 'wl_linked_data_save_post' );
45 45
 }
46 46
 
47 47
 add_action( 'save_post', 'wl_linked_data_save_post' );
@@ -55,143 +55,143 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function wl_linked_data_save_post_and_related_entities( $post_id ) {
57 57
 
58
-	// Ignore auto-saves
59
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
60
-		return;
61
-	}
58
+    // Ignore auto-saves
59
+    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
60
+        return;
61
+    }
62 62
 
63
-	// get the current post.
64
-	$post = get_post( $post_id );
63
+    // get the current post.
64
+    $post = get_post( $post_id );
65 65
 
66
-	remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
66
+    remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
67 67
 
68
-	// wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" );
68
+    // wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" );
69 69
 
70
-	// Store mapping between tmp new entities uris and real new entities uri
71
-	$entities_uri_mapping = array();
70
+    // Store mapping between tmp new entities uris and real new entities uri
71
+    $entities_uri_mapping = array();
72 72
 
73
-	// Save the entities coming with POST data.
74
-	if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) {
73
+    // Save the entities coming with POST data.
74
+    if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) {
75 75
 
76
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " );
77
-		wl_write_log( json_encode( $_POST['wl_entities'] ) );
78
-		wl_write_log( "]" );
79
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " );
80
-		wl_write_log( json_encode( $_POST['wl_boxes'], true ) );
81
-		wl_write_log( "]" );
76
+        wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " );
77
+        wl_write_log( json_encode( $_POST['wl_entities'] ) );
78
+        wl_write_log( "]" );
79
+        wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " );
80
+        wl_write_log( json_encode( $_POST['wl_boxes'], true ) );
81
+        wl_write_log( "]" );
82 82
 
83
-		$entities_via_post = $_POST['wl_entities'];
84
-		$boxes_via_post    = $_POST['wl_boxes'];
83
+        $entities_via_post = $_POST['wl_entities'];
84
+        $boxes_via_post    = $_POST['wl_boxes'];
85 85
 
86
-		foreach ( $entities_via_post as $entity_uri => $entity ) {
86
+        foreach ( $entities_via_post as $entity_uri => $entity ) {
87 87
 
88
-			// Only if the current entity is created from scratch let's avoid to
89
-			// create more than one entity with same label & entity type.
90
-			$entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ?
91
-				$entity['main_type'] : null;
92
-
93
-			// Look if current entity uri matches an internal existing entity, meaning:
94
-			// 1. when $entity_uri is an internal uri
95
-			// 2. when $entity_uri is an external uri used as sameAs of an internal entity
96
-			$ie = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $entity_uri );
88
+            // Only if the current entity is created from scratch let's avoid to
89
+            // create more than one entity with same label & entity type.
90
+            $entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ?
91
+                $entity['main_type'] : null;
92
+
93
+            // Look if current entity uri matches an internal existing entity, meaning:
94
+            // 1. when $entity_uri is an internal uri
95
+            // 2. when $entity_uri is an external uri used as sameAs of an internal entity
96
+            $ie = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $entity_uri );
97 97
 
98
-			// Detect the uri depending if is an existing or a new entity
99
-			$uri = ( null === $ie ) ?
100
-				Wordlift_Uri_Service::get_instance()->build_uri(
101
-					$entity['label'],
102
-					Wordlift_Entity_Service::TYPE_NAME,
103
-					$entity_type
104
-				) : wl_get_entity_uri( $ie->ID );
98
+            // Detect the uri depending if is an existing or a new entity
99
+            $uri = ( null === $ie ) ?
100
+                Wordlift_Uri_Service::get_instance()->build_uri(
101
+                    $entity['label'],
102
+                    Wordlift_Entity_Service::TYPE_NAME,
103
+                    $entity_type
104
+                ) : wl_get_entity_uri( $ie->ID );
105 105
 
106
-			wl_write_log( "Map $entity_uri on $uri" );
107
-			$entities_uri_mapping[ $entity_uri ] = $uri;
106
+            wl_write_log( "Map $entity_uri on $uri" );
107
+            $entities_uri_mapping[ $entity_uri ] = $uri;
108 108
 
109
-			// Local entities have a tmp uri with 'local-entity-' prefix
110
-			// These uris need to be rewritten here and replaced in the content
111
-			if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) {
112
-				// Override the entity obj
113
-				$entity['uri'] = $uri;
114
-			}
109
+            // Local entities have a tmp uri with 'local-entity-' prefix
110
+            // These uris need to be rewritten here and replaced in the content
111
+            if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) {
112
+                // Override the entity obj
113
+                $entity['uri'] = $uri;
114
+            }
115 115
 
116
-			// Update entity data with related post
117
-			$entity['related_post_id'] = $post_id;
116
+            // Update entity data with related post
117
+            $entity['related_post_id'] = $post_id;
118 118
 
119
-			// Save the entity if is a new entity
120
-			if ( null === $ie ) {
121
-				wl_save_entity( $entity );
122
-			}
119
+            // Save the entity if is a new entity
120
+            if ( null === $ie ) {
121
+                wl_save_entity( $entity );
122
+            }
123 123
 
124
-		}
124
+        }
125 125
 
126
-	}
126
+    }
127 127
 
128
-	// Replace tmp uris in content post if needed
129
-	$updated_post_content = $post->post_content;
130
-	// Save each entity and store the post id.
131
-	foreach ( $entities_uri_mapping as $tmp_uri => $uri ) {
132
-		$updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content );
133
-	}
128
+    // Replace tmp uris in content post if needed
129
+    $updated_post_content = $post->post_content;
130
+    // Save each entity and store the post id.
131
+    foreach ( $entities_uri_mapping as $tmp_uri => $uri ) {
132
+        $updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content );
133
+    }
134 134
 
135
-	// Update the post content
136
-	wp_update_post( array(
137
-		'ID'           => $post->ID,
138
-		'post_content' => $updated_post_content,
139
-	) );
135
+    // Update the post content
136
+    wp_update_post( array(
137
+        'ID'           => $post->ID,
138
+        'post_content' => $updated_post_content,
139
+    ) );
140 140
 
141
-	// Extract related/referenced entities from text.
142
-	$disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content );
141
+    // Extract related/referenced entities from text.
142
+    $disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content );
143 143
 
144
-	// Reset previously saved instances
145
-	wl_core_delete_relation_instances( $post_id );
144
+    // Reset previously saved instances
145
+    wl_core_delete_relation_instances( $post_id );
146 146
 
147
-	// Save relation instances
148
-	foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) {
147
+    // Save relation instances
148
+    foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) {
149 149
 
150
-		wl_core_add_relation_instance(
151
-			$post_id,
152
-			Wordlift_Entity_Service::get_instance()->get_classification_scope_for( $referenced_entity_id ),
153
-			$referenced_entity_id
154
-		);
150
+        wl_core_add_relation_instance(
151
+            $post_id,
152
+            Wordlift_Entity_Service::get_instance()->get_classification_scope_for( $referenced_entity_id ),
153
+            $referenced_entity_id
154
+        );
155 155
 
156
-	}
156
+    }
157 157
 
158
-	if ( isset( $_POST['wl_entities'] ) ) {
159
-		// Save post metadata if available
160
-		$metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ?
161
-			$_POST['wl_metadata'] : array();
158
+    if ( isset( $_POST['wl_entities'] ) ) {
159
+        // Save post metadata if available
160
+        $metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ?
161
+            $_POST['wl_metadata'] : array();
162 162
 
163
-		$fields = array(
164
-			Wordlift_Schema_Service::FIELD_LOCATION_CREATED,
165
-			Wordlift_Schema_Service::FIELD_TOPIC,
166
-		);
167
-
168
-		// Unlink topic taxonomy terms
169
-		Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID );
170
-
171
-		foreach ( $fields as $field ) {
172
-
173
-			// Delete current values
174
-			delete_post_meta( $post->ID, $field );
175
-			// Retrieve the entity uri
176
-			$uri = ( isset( $metadata_via_post[ $field ] ) ) ?
177
-				stripslashes( $metadata_via_post[ $field ] ) : '';
178
-
179
-			$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri );
180
-
181
-			if ( $entity ) {
182
-				add_post_meta( $post->ID, $field, $entity->ID, true );
183
-				// Set also the topic taxonomy
184
-				if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) {
185
-					Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity );
186
-				}
187
-			}
188
-		}
189
-	}
190
-
191
-	// Push the post to Redlink.
192
-	Wordlift_Linked_Data_Service::get_instance()->push( $post->ID );
193
-
194
-	add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
163
+        $fields = array(
164
+            Wordlift_Schema_Service::FIELD_LOCATION_CREATED,
165
+            Wordlift_Schema_Service::FIELD_TOPIC,
166
+        );
167
+
168
+        // Unlink topic taxonomy terms
169
+        Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID );
170
+
171
+        foreach ( $fields as $field ) {
172
+
173
+            // Delete current values
174
+            delete_post_meta( $post->ID, $field );
175
+            // Retrieve the entity uri
176
+            $uri = ( isset( $metadata_via_post[ $field ] ) ) ?
177
+                stripslashes( $metadata_via_post[ $field ] ) : '';
178
+
179
+            $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri );
180
+
181
+            if ( $entity ) {
182
+                add_post_meta( $post->ID, $field, $entity->ID, true );
183
+                // Set also the topic taxonomy
184
+                if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) {
185
+                    Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity );
186
+                }
187
+            }
188
+        }
189
+    }
190
+
191
+    // Push the post to Redlink.
192
+    Wordlift_Linked_Data_Service::get_instance()->push( $post->ID );
193
+
194
+    add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
195 195
 }
196 196
 
197 197
 add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
@@ -214,185 +214,185 @@  discard block
 block discarded – undo
214 214
  */
215 215
 function wl_save_entity( $entity_data ) {
216 216
 
217
-	$uri              = $entity_data['uri'];
218
-	$label            = $entity_data['label'];
219
-	$type_uri         = $entity_data['main_type'];
220
-	$entity_types     = isset( $entity_data['type'] ) ? $entity_data['type'] : array();
221
-	$description      = $entity_data['description'];
222
-	$images           = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array();
223
-	$same_as          = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array();
224
-	$related_post_id  = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null;
225
-	$other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array();
226
-
227
-	// Get the synonyms.
228
-	$synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array();
229
-
230
-	// Check whether an entity already exists with the provided URI.
231
-	if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) {
232
-		return $post;
233
-	}
234
-
235
-	// Prepare properties of the new entity.
236
-	$params = array(
237
-		'post_status'  => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ),
238
-		'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
239
-		'post_title'   => $label,
240
-		'post_content' => $description,
241
-		'post_excerpt' => '',
242
-		// Ensure we're using a valid slug. We're not overwriting an existing
243
-		// entity with a post_name already set, since this call is made only for
244
-		// new entities.
245
-		//
246
-		// See https://github.com/insideout10/wordlift-plugin/issues/282
247
-		'post_name'    => sanitize_title( $label ),
248
-	);
249
-
250
-	// If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over"
251
-	// the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156)
252
-	// Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148)
253
-	// This does NOT affect saving an entity from the entity admin page since this function is called when an entity
254
-	// is created when saving a post.
255
-	global $wpseo_metabox, $seo_ultimate;
256
-	if ( isset( $wpseo_metabox ) ) {
257
-		remove_action( 'wp_insert_post', array(
258
-			$wpseo_metabox,
259
-			'save_postdata',
260
-		) );
261
-	}
262
-
263
-	if ( isset( $seo_ultimate ) ) {
264
-		remove_action( 'save_post', array(
265
-			$seo_ultimate,
266
-			'save_postmeta_box',
267
-		) );
268
-	}
269
-
270
-	// The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to
271
-	// save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks
272
-	// to the save_post and restore them after we saved the entity.
273
-	// see https://github.com/insideout10/wordlift-plugin/issues/203
274
-	// see https://github.com/insideout10/wordlift-plugin/issues/156
275
-	// see https://github.com/insideout10/wordlift-plugin/issues/148
276
-	global $wp_filter;
277
-	$save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks;
278
-	is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters();
279
-
280
-	// create or update the post.
281
-	$post_id = wp_insert_post( $params, true );
282
-
283
-	// Setting the alternative labels for this entity.
284
-	Wordlift_Entity_Service::get_instance()
285
-						   ->set_alternative_labels( $post_id, $synonyms );
286
-
287
-	// Restore all the existing filters.
288
-	is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters;
289
-
290
-	// If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156)
291
-	if ( isset( $wpseo_metabox ) ) {
292
-		add_action( 'wp_insert_post', array(
293
-			$wpseo_metabox,
294
-			'save_postdata',
295
-		) );
296
-	}
297
-
298
-	// If SEO Ultimate is installed, add back the hook we removed a few lines above.
299
-	if ( isset( $seo_ultimate ) ) {
300
-		add_action( 'save_post', array(
301
-			$seo_ultimate,
302
-			'save_postmeta_box',
303
-		), 10, 2 );
304
-	}
305
-
306
-	// TODO: handle errors.
307
-	if ( is_wp_error( $post_id ) ) {
308
-		wl_write_log( ': error occurred' );
309
-
310
-		// inform an error occurred.
311
-		return null;
312
-	}
313
-
314
-	wl_set_entity_main_type( $post_id, $type_uri );
315
-
316
-	// Save the entity types.
317
-	wl_set_entity_rdf_types( $post_id, $entity_types );
318
-
319
-	// Get a dataset URI for the entity.
320
-	$wl_uri = wl_build_entity_uri( $post_id );
321
-
322
-	// Save the entity URI.
323
-	wl_set_entity_uri( $post_id, $wl_uri );
324
-
325
-	// Add the uri to the sameAs data if it's not a local URI.
326
-	if ( $wl_uri !== $uri ) {
327
-		array_push( $same_as, $uri );
328
-	}
329
-
330
-	$new_uri = wl_get_entity_uri( $post_id );
331
-
332
-	// Save the sameAs data for the entity.
333
-	wl_schema_set_value( $post_id, 'sameAs', $same_as );
334
-
335
-	// Save the other properties (latitude, langitude, startDate, endDate, etc.)
336
-	foreach ( $other_properties as $property_name => $property_value ) {
337
-		wl_schema_set_value( $post_id, $property_name, $property_value );
338
-	}
339
-
340
-	// Call hooks.
341
-	do_action( 'wl_save_entity', $post_id );
342
-
343
-	foreach ( $images as $image_remote_url ) {
344
-
345
-		// Check if image is already present in local DB
346
-		if ( strpos( $image_remote_url, site_url() ) !== false ) {
347
-			// Do nothing.
348
-			continue;
349
-		}
350
-
351
-		// Check if there is an existing attachment for this post ID and source URL.
352
-		$existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url );
353
-
354
-		// Skip if an existing image is found.
355
-		if ( null !== $existing_image ) {
356
-			continue;
357
-		}
358
-
359
-		// Save the image and get the local path.
360
-		$image = wl_save_image( $image_remote_url );
361
-
362
-		// Get the local URL.
363
-		$filename     = $image['path'];
364
-		$url          = $image['url'];
365
-		$content_type = $image['content_type'];
366
-
367
-		$attachment = array(
368
-			'guid'           => $url,
369
-			// post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type
370
-			'post_title'     => $label,
371
-			// Set the title to the post title.
372
-			'post_content'   => '',
373
-			'post_status'    => 'inherit',
374
-			'post_mime_type' => $content_type,
375
-		);
376
-
377
-		// Create the attachment in WordPress and generate the related metadata.
378
-		$attachment_id = wp_insert_attachment( $attachment, $filename, $post_id );
217
+    $uri              = $entity_data['uri'];
218
+    $label            = $entity_data['label'];
219
+    $type_uri         = $entity_data['main_type'];
220
+    $entity_types     = isset( $entity_data['type'] ) ? $entity_data['type'] : array();
221
+    $description      = $entity_data['description'];
222
+    $images           = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array();
223
+    $same_as          = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array();
224
+    $related_post_id  = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null;
225
+    $other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array();
226
+
227
+    // Get the synonyms.
228
+    $synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array();
229
+
230
+    // Check whether an entity already exists with the provided URI.
231
+    if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) {
232
+        return $post;
233
+    }
234
+
235
+    // Prepare properties of the new entity.
236
+    $params = array(
237
+        'post_status'  => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ),
238
+        'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
239
+        'post_title'   => $label,
240
+        'post_content' => $description,
241
+        'post_excerpt' => '',
242
+        // Ensure we're using a valid slug. We're not overwriting an existing
243
+        // entity with a post_name already set, since this call is made only for
244
+        // new entities.
245
+        //
246
+        // See https://github.com/insideout10/wordlift-plugin/issues/282
247
+        'post_name'    => sanitize_title( $label ),
248
+    );
249
+
250
+    // If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over"
251
+    // the local SEO form values to the created entity (https://github.com/insideout10/wordlift-plugin/issues/156)
252
+    // Same thing applies to SEO Ultimate (https://github.com/insideout10/wordlift-plugin/issues/148)
253
+    // This does NOT affect saving an entity from the entity admin page since this function is called when an entity
254
+    // is created when saving a post.
255
+    global $wpseo_metabox, $seo_ultimate;
256
+    if ( isset( $wpseo_metabox ) ) {
257
+        remove_action( 'wp_insert_post', array(
258
+            $wpseo_metabox,
259
+            'save_postdata',
260
+        ) );
261
+    }
262
+
263
+    if ( isset( $seo_ultimate ) ) {
264
+        remove_action( 'save_post', array(
265
+            $seo_ultimate,
266
+            'save_postmeta_box',
267
+        ) );
268
+    }
269
+
270
+    // The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to
271
+    // save_post in order to save additional inputs from the edit page. In order to avoid issues, we pop all the hooks
272
+    // to the save_post and restore them after we saved the entity.
273
+    // see https://github.com/insideout10/wordlift-plugin/issues/203
274
+    // see https://github.com/insideout10/wordlift-plugin/issues/156
275
+    // see https://github.com/insideout10/wordlift-plugin/issues/148
276
+    global $wp_filter;
277
+    $save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks;
278
+    is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters();
279
+
280
+    // create or update the post.
281
+    $post_id = wp_insert_post( $params, true );
282
+
283
+    // Setting the alternative labels for this entity.
284
+    Wordlift_Entity_Service::get_instance()
285
+                            ->set_alternative_labels( $post_id, $synonyms );
286
+
287
+    // Restore all the existing filters.
288
+    is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters;
289
+
290
+    // If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156)
291
+    if ( isset( $wpseo_metabox ) ) {
292
+        add_action( 'wp_insert_post', array(
293
+            $wpseo_metabox,
294
+            'save_postdata',
295
+        ) );
296
+    }
297
+
298
+    // If SEO Ultimate is installed, add back the hook we removed a few lines above.
299
+    if ( isset( $seo_ultimate ) ) {
300
+        add_action( 'save_post', array(
301
+            $seo_ultimate,
302
+            'save_postmeta_box',
303
+        ), 10, 2 );
304
+    }
305
+
306
+    // TODO: handle errors.
307
+    if ( is_wp_error( $post_id ) ) {
308
+        wl_write_log( ': error occurred' );
309
+
310
+        // inform an error occurred.
311
+        return null;
312
+    }
313
+
314
+    wl_set_entity_main_type( $post_id, $type_uri );
315
+
316
+    // Save the entity types.
317
+    wl_set_entity_rdf_types( $post_id, $entity_types );
318
+
319
+    // Get a dataset URI for the entity.
320
+    $wl_uri = wl_build_entity_uri( $post_id );
321
+
322
+    // Save the entity URI.
323
+    wl_set_entity_uri( $post_id, $wl_uri );
324
+
325
+    // Add the uri to the sameAs data if it's not a local URI.
326
+    if ( $wl_uri !== $uri ) {
327
+        array_push( $same_as, $uri );
328
+    }
329
+
330
+    $new_uri = wl_get_entity_uri( $post_id );
331
+
332
+    // Save the sameAs data for the entity.
333
+    wl_schema_set_value( $post_id, 'sameAs', $same_as );
334
+
335
+    // Save the other properties (latitude, langitude, startDate, endDate, etc.)
336
+    foreach ( $other_properties as $property_name => $property_value ) {
337
+        wl_schema_set_value( $post_id, $property_name, $property_value );
338
+    }
339
+
340
+    // Call hooks.
341
+    do_action( 'wl_save_entity', $post_id );
342
+
343
+    foreach ( $images as $image_remote_url ) {
344
+
345
+        // Check if image is already present in local DB
346
+        if ( strpos( $image_remote_url, site_url() ) !== false ) {
347
+            // Do nothing.
348
+            continue;
349
+        }
350
+
351
+        // Check if there is an existing attachment for this post ID and source URL.
352
+        $existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url );
353
+
354
+        // Skip if an existing image is found.
355
+        if ( null !== $existing_image ) {
356
+            continue;
357
+        }
358
+
359
+        // Save the image and get the local path.
360
+        $image = wl_save_image( $image_remote_url );
361
+
362
+        // Get the local URL.
363
+        $filename     = $image['path'];
364
+        $url          = $image['url'];
365
+        $content_type = $image['content_type'];
366
+
367
+        $attachment = array(
368
+            'guid'           => $url,
369
+            // post_title, post_content (the value for this key should be the empty string), post_status and post_mime_type
370
+            'post_title'     => $label,
371
+            // Set the title to the post title.
372
+            'post_content'   => '',
373
+            'post_status'    => 'inherit',
374
+            'post_mime_type' => $content_type,
375
+        );
376
+
377
+        // Create the attachment in WordPress and generate the related metadata.
378
+        $attachment_id = wp_insert_attachment( $attachment, $filename, $post_id );
379 379
 
380
-		// Set the source URL for the image.
381
-		wl_set_source_url( $attachment_id, $image_remote_url );
380
+        // Set the source URL for the image.
381
+        wl_set_source_url( $attachment_id, $image_remote_url );
382 382
 
383
-		$attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
384
-		wp_update_attachment_metadata( $attachment_id, $attachment_data );
383
+        $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
384
+        wp_update_attachment_metadata( $attachment_id, $attachment_data );
385 385
 
386
-		// Set it as the featured image.
387
-		set_post_thumbnail( $post_id, $attachment_id );
388
-	}
386
+        // Set it as the featured image.
387
+        set_post_thumbnail( $post_id, $attachment_id );
388
+    }
389 389
 
390
-	// The entity is pushed to Redlink on save by the function hooked to save_post.
391
-	// save the entity in the triple store.
392
-	Wordlift_Linked_Data_Service::get_instance()->push( $post_id );
390
+    // The entity is pushed to Redlink on save by the function hooked to save_post.
391
+    // save the entity in the triple store.
392
+    Wordlift_Linked_Data_Service::get_instance()->push( $post_id );
393 393
 
394
-	// finally return the entity post.
395
-	return get_post( $post_id );
394
+    // finally return the entity post.
395
+    return get_post( $post_id );
396 396
 }
397 397
 
398 398
 /**
@@ -406,40 +406,40 @@  discard block
 block discarded – undo
406 406
  */
407 407
 function wl_linked_data_content_get_embedded_entities( $content ) {
408 408
 
409
-	// Remove quote escapes.
410
-	$content = str_replace( '\\"', '"', $content );
409
+    // Remove quote escapes.
410
+    $content = str_replace( '\\"', '"', $content );
411 411
 
412
-	// Match all itemid attributes.
413
-	$pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
412
+    // Match all itemid attributes.
413
+    $pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
414 414
 
415
-	//	wl_write_log( "Getting entities embedded into content [ pattern :: $pattern ]" );
415
+    //	wl_write_log( "Getting entities embedded into content [ pattern :: $pattern ]" );
416 416
 
417
-	// Remove the pattern while it is found (match nested annotations).
418
-	$matches = array();
417
+    // Remove the pattern while it is found (match nested annotations).
418
+    $matches = array();
419 419
 
420
-	// In case of errors, return an empty array.
421
-	if ( false === preg_match_all( $pattern, $content, $matches ) ) {
422
-		wl_write_log( "Found no entities embedded in content" );
420
+    // In case of errors, return an empty array.
421
+    if ( false === preg_match_all( $pattern, $content, $matches ) ) {
422
+        wl_write_log( "Found no entities embedded in content" );
423 423
 
424
-		return array();
425
-	}
424
+        return array();
425
+    }
426 426
 
427 427
 //    wl_write_log("wl_update_related_entities [ content :: $content ][ data :: " . var_export($data, true). " ][ matches :: " . var_export($matches, true) . " ]");
428 428
 
429
-	// Collect the entities.
430
-	$entities = array();
431
-	foreach ( $matches[1] as $uri ) {
432
-		$uri_d = html_entity_decode( $uri );
429
+    // Collect the entities.
430
+    $entities = array();
431
+    foreach ( $matches[1] as $uri ) {
432
+        $uri_d = html_entity_decode( $uri );
433 433
 
434
-		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d );
434
+        $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d );
435 435
 
436
-		if ( null !== $entity ) {
437
-			array_push( $entities, $entity->ID );
438
-		}
439
-	}
436
+        if ( null !== $entity ) {
437
+            array_push( $entities, $entity->ID );
438
+        }
439
+    }
440 440
 
441
-	// $count = sizeof( $entities );
442
-	// wl_write_log( "Found $count entities embedded in content" );
441
+    // $count = sizeof( $entities );
442
+    // wl_write_log( "Found $count entities embedded in content" );
443 443
 
444
-	return $entities;
444
+    return $entities;
445 445
 }
Please login to merge, or discard this patch.
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @subpackage Wordlift/modules/linked_data
8 8
  */
9 9
 
10
-require_once( 'wordlift_linked_data_images.php' );
10
+require_once('wordlift_linked_data_images.php');
11 11
 
12 12
 /**
13 13
  * Receive events from post saves, and split them according to the post type.
@@ -16,35 +16,35 @@  discard block
 block discarded – undo
16 16
  *
17 17
  * @param int $post_id The post id.
18 18
  */
19
-function wl_linked_data_save_post( $post_id ) {
19
+function wl_linked_data_save_post($post_id) {
20 20
 
21 21
 	// If it's not numeric exit from here.
22
-	if ( ! is_numeric( $post_id ) || is_numeric( wp_is_post_revision( $post_id ) ) ) {
22
+	if ( ! is_numeric($post_id) || is_numeric(wp_is_post_revision($post_id))) {
23 23
 		return;
24 24
 	}
25 25
 
26 26
 	// Get the post type and check whether it supports the editor.
27 27
 	//
28 28
 	// See https://github.com/insideout10/wordlift-plugin/issues/659.
29
-	$post_type = get_post_type( $post_id );
30
-	$is_editor_supported = post_type_supports( $post_type, 'editor' );
29
+	$post_type = get_post_type($post_id);
30
+	$is_editor_supported = post_type_supports($post_type, 'editor');
31 31
 
32 32
 	// Bail out if it's not an entity.
33
-	if ( ! $is_editor_supported ) {
33
+	if ( ! $is_editor_supported) {
34 34
 		return;
35 35
 	}
36 36
 
37 37
 	// unhook this function so it doesn't loop infinitely
38
-	remove_action( 'save_post', 'wl_linked_data_save_post' );
38
+	remove_action('save_post', 'wl_linked_data_save_post');
39 39
 
40 40
 	// raise the *wl_linked_data_save_post* event.
41
-	do_action( 'wl_linked_data_save_post', $post_id );
41
+	do_action('wl_linked_data_save_post', $post_id);
42 42
 
43 43
 	// re-hook this function
44
-	add_action( 'save_post', 'wl_linked_data_save_post' );
44
+	add_action('save_post', 'wl_linked_data_save_post');
45 45
 }
46 46
 
47
-add_action( 'save_post', 'wl_linked_data_save_post' );
47
+add_action('save_post', 'wl_linked_data_save_post');
48 48
 
49 49
 /**
50 50
  * Save the post to the triple store. Also saves the entities locally and on the triple store.
@@ -53,17 +53,17 @@  discard block
 block discarded – undo
53 53
  *
54 54
  * @param int $post_id The post id being saved.
55 55
  */
56
-function wl_linked_data_save_post_and_related_entities( $post_id ) {
56
+function wl_linked_data_save_post_and_related_entities($post_id) {
57 57
 
58 58
 	// Ignore auto-saves
59
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
59
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
60 60
 		return;
61 61
 	}
62 62
 
63 63
 	// get the current post.
64
-	$post = get_post( $post_id );
64
+	$post = get_post($post_id);
65 65
 
66
-	remove_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
66
+	remove_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities');
67 67
 
68 68
 	// wl_write_log( "[ post id :: $post_id ][ autosave :: false ][ post type :: $post->post_type ]" );
69 69
 
@@ -71,44 +71,44 @@  discard block
 block discarded – undo
71 71
 	$entities_uri_mapping = array();
72 72
 
73 73
 	// Save the entities coming with POST data.
74
-	if ( isset( $_POST['wl_entities'] ) && isset( $_POST['wl_boxes'] ) ) {
74
+	if (isset($_POST['wl_entities']) && isset($_POST['wl_boxes'])) {
75 75
 
76
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_entities) :: " );
77
-		wl_write_log( json_encode( $_POST['wl_entities'] ) );
78
-		wl_write_log( "]" );
79
-		wl_write_log( "[ post id :: $post_id ][ POST(wl_boxes) :: " );
80
-		wl_write_log( json_encode( $_POST['wl_boxes'], true ) );
81
-		wl_write_log( "]" );
76
+		wl_write_log("[ post id :: $post_id ][ POST(wl_entities) :: ");
77
+		wl_write_log(json_encode($_POST['wl_entities']));
78
+		wl_write_log("]");
79
+		wl_write_log("[ post id :: $post_id ][ POST(wl_boxes) :: ");
80
+		wl_write_log(json_encode($_POST['wl_boxes'], true));
81
+		wl_write_log("]");
82 82
 
83 83
 		$entities_via_post = $_POST['wl_entities'];
84 84
 		$boxes_via_post    = $_POST['wl_boxes'];
85 85
 
86
-		foreach ( $entities_via_post as $entity_uri => $entity ) {
86
+		foreach ($entities_via_post as $entity_uri => $entity) {
87 87
 
88 88
 			// Only if the current entity is created from scratch let's avoid to
89 89
 			// create more than one entity with same label & entity type.
90
-			$entity_type = ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) ?
90
+			$entity_type = (preg_match('/^local-entity-.+/', $entity_uri) > 0) ?
91 91
 				$entity['main_type'] : null;
92 92
 
93 93
 			// Look if current entity uri matches an internal existing entity, meaning:
94 94
 			// 1. when $entity_uri is an internal uri
95 95
 			// 2. when $entity_uri is an external uri used as sameAs of an internal entity
96
-			$ie = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $entity_uri );
96
+			$ie = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($entity_uri);
97 97
 
98 98
 			// Detect the uri depending if is an existing or a new entity
99
-			$uri = ( null === $ie ) ?
99
+			$uri = (null === $ie) ?
100 100
 				Wordlift_Uri_Service::get_instance()->build_uri(
101 101
 					$entity['label'],
102 102
 					Wordlift_Entity_Service::TYPE_NAME,
103 103
 					$entity_type
104
-				) : wl_get_entity_uri( $ie->ID );
104
+				) : wl_get_entity_uri($ie->ID);
105 105
 
106
-			wl_write_log( "Map $entity_uri on $uri" );
107
-			$entities_uri_mapping[ $entity_uri ] = $uri;
106
+			wl_write_log("Map $entity_uri on $uri");
107
+			$entities_uri_mapping[$entity_uri] = $uri;
108 108
 
109 109
 			// Local entities have a tmp uri with 'local-entity-' prefix
110 110
 			// These uris need to be rewritten here and replaced in the content
111
-			if ( preg_match( '/^local-entity-.+/', $entity_uri ) > 0 ) {
111
+			if (preg_match('/^local-entity-.+/', $entity_uri) > 0) {
112 112
 				// Override the entity obj
113 113
 				$entity['uri'] = $uri;
114 114
 			}
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 			$entity['related_post_id'] = $post_id;
118 118
 
119 119
 			// Save the entity if is a new entity
120
-			if ( null === $ie ) {
121
-				wl_save_entity( $entity );
120
+			if (null === $ie) {
121
+				wl_save_entity($entity);
122 122
 			}
123 123
 
124 124
 		}
@@ -128,36 +128,36 @@  discard block
 block discarded – undo
128 128
 	// Replace tmp uris in content post if needed
129 129
 	$updated_post_content = $post->post_content;
130 130
 	// Save each entity and store the post id.
131
-	foreach ( $entities_uri_mapping as $tmp_uri => $uri ) {
132
-		$updated_post_content = str_replace( $tmp_uri, $uri, $updated_post_content );
131
+	foreach ($entities_uri_mapping as $tmp_uri => $uri) {
132
+		$updated_post_content = str_replace($tmp_uri, $uri, $updated_post_content);
133 133
 	}
134 134
 
135 135
 	// Update the post content
136
-	wp_update_post( array(
136
+	wp_update_post(array(
137 137
 		'ID'           => $post->ID,
138 138
 		'post_content' => $updated_post_content,
139
-	) );
139
+	));
140 140
 
141 141
 	// Extract related/referenced entities from text.
142
-	$disambiguated_entities = wl_linked_data_content_get_embedded_entities( $updated_post_content );
142
+	$disambiguated_entities = wl_linked_data_content_get_embedded_entities($updated_post_content);
143 143
 
144 144
 	// Reset previously saved instances
145
-	wl_core_delete_relation_instances( $post_id );
145
+	wl_core_delete_relation_instances($post_id);
146 146
 
147 147
 	// Save relation instances
148
-	foreach ( array_unique( $disambiguated_entities ) as $referenced_entity_id ) {
148
+	foreach (array_unique($disambiguated_entities) as $referenced_entity_id) {
149 149
 
150 150
 		wl_core_add_relation_instance(
151 151
 			$post_id,
152
-			Wordlift_Entity_Service::get_instance()->get_classification_scope_for( $referenced_entity_id ),
152
+			Wordlift_Entity_Service::get_instance()->get_classification_scope_for($referenced_entity_id),
153 153
 			$referenced_entity_id
154 154
 		);
155 155
 
156 156
 	}
157 157
 
158
-	if ( isset( $_POST['wl_entities'] ) ) {
158
+	if (isset($_POST['wl_entities'])) {
159 159
 		// Save post metadata if available
160
-		$metadata_via_post = ( isset( $_POST['wl_metadata'] ) ) ?
160
+		$metadata_via_post = (isset($_POST['wl_metadata'])) ?
161 161
 			$_POST['wl_metadata'] : array();
162 162
 
163 163
 		$fields = array(
@@ -166,35 +166,35 @@  discard block
 block discarded – undo
166 166
 		);
167 167
 
168 168
 		// Unlink topic taxonomy terms
169
-		Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for( $post->ID );
169
+		Wordlift_Topic_Taxonomy_Service::get_instance()->unlink_topic_for($post->ID);
170 170
 
171
-		foreach ( $fields as $field ) {
171
+		foreach ($fields as $field) {
172 172
 
173 173
 			// Delete current values
174
-			delete_post_meta( $post->ID, $field );
174
+			delete_post_meta($post->ID, $field);
175 175
 			// Retrieve the entity uri
176
-			$uri = ( isset( $metadata_via_post[ $field ] ) ) ?
177
-				stripslashes( $metadata_via_post[ $field ] ) : '';
176
+			$uri = (isset($metadata_via_post[$field])) ?
177
+				stripslashes($metadata_via_post[$field]) : '';
178 178
 
179
-			$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri );
179
+			$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri);
180 180
 
181
-			if ( $entity ) {
182
-				add_post_meta( $post->ID, $field, $entity->ID, true );
181
+			if ($entity) {
182
+				add_post_meta($post->ID, $field, $entity->ID, true);
183 183
 				// Set also the topic taxonomy
184
-				if ( $field === Wordlift_Schema_Service::FIELD_TOPIC ) {
185
-					Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for( $post->ID, $entity );
184
+				if ($field === Wordlift_Schema_Service::FIELD_TOPIC) {
185
+					Wordlift_Topic_Taxonomy_Service::get_instance()->set_topic_for($post->ID, $entity);
186 186
 				}
187 187
 			}
188 188
 		}
189 189
 	}
190 190
 
191 191
 	// Push the post to Redlink.
192
-	Wordlift_Linked_Data_Service::get_instance()->push( $post->ID );
192
+	Wordlift_Linked_Data_Service::get_instance()->push($post->ID);
193 193
 
194
-	add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
194
+	add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities');
195 195
 }
196 196
 
197
-add_action( 'wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities' );
197
+add_action('wl_linked_data_save_post', 'wl_linked_data_save_post_and_related_entities');
198 198
 
199 199
 /**
200 200
  * Save the specified data as an entity in WordPress. This method only create new entities. When an existing entity is
@@ -212,29 +212,29 @@  discard block
 block discarded – undo
212 212
  *
213 213
  * @return null|WP_Post A post instance or null in case of failure.
214 214
  */
215
-function wl_save_entity( $entity_data ) {
215
+function wl_save_entity($entity_data) {
216 216
 
217 217
 	$uri              = $entity_data['uri'];
218 218
 	$label            = $entity_data['label'];
219 219
 	$type_uri         = $entity_data['main_type'];
220
-	$entity_types     = isset( $entity_data['type'] ) ? $entity_data['type'] : array();
220
+	$entity_types     = isset($entity_data['type']) ? $entity_data['type'] : array();
221 221
 	$description      = $entity_data['description'];
222
-	$images           = isset( $entity_data['image'] ) ? (array) $entity_data['image'] : array();
223
-	$same_as          = isset( $entity_data['sameas'] ) ? (array) $entity_data['sameas'] : array();
224
-	$related_post_id  = isset( $entity_data['related_post_id'] ) ? $entity_data['related_post_id'] : null;
225
-	$other_properties = isset( $entity_data['properties'] ) ? $entity_data['properties'] : array();
222
+	$images           = isset($entity_data['image']) ? (array) $entity_data['image'] : array();
223
+	$same_as          = isset($entity_data['sameas']) ? (array) $entity_data['sameas'] : array();
224
+	$related_post_id  = isset($entity_data['related_post_id']) ? $entity_data['related_post_id'] : null;
225
+	$other_properties = isset($entity_data['properties']) ? $entity_data['properties'] : array();
226 226
 
227 227
 	// Get the synonyms.
228
-	$synonyms = isset( $entity_data['synonym'] ) ? $entity_data['synonym'] : array();
228
+	$synonyms = isset($entity_data['synonym']) ? $entity_data['synonym'] : array();
229 229
 
230 230
 	// Check whether an entity already exists with the provided URI.
231
-	if ( null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri ) ) {
231
+	if (null !== $post = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri)) {
232 232
 		return $post;
233 233
 	}
234 234
 
235 235
 	// Prepare properties of the new entity.
236 236
 	$params = array(
237
-		'post_status'  => ( is_numeric( $related_post_id ) ? get_post_status( $related_post_id ) : 'draft' ),
237
+		'post_status'  => (is_numeric($related_post_id) ? get_post_status($related_post_id) : 'draft'),
238 238
 		'post_type'    => Wordlift_Entity_Service::TYPE_NAME,
239 239
 		'post_title'   => $label,
240 240
 		'post_content' => $description,
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 		// new entities.
245 245
 		//
246 246
 		// See https://github.com/insideout10/wordlift-plugin/issues/282
247
-		'post_name'    => sanitize_title( $label ),
247
+		'post_name'    => sanitize_title($label),
248 248
 	);
249 249
 
250 250
 	// If Yoast is installed and active, we temporary remove the save_postdata hook which causes Yoast to "pass over"
@@ -253,18 +253,18 @@  discard block
 block discarded – undo
253 253
 	// This does NOT affect saving an entity from the entity admin page since this function is called when an entity
254 254
 	// is created when saving a post.
255 255
 	global $wpseo_metabox, $seo_ultimate;
256
-	if ( isset( $wpseo_metabox ) ) {
257
-		remove_action( 'wp_insert_post', array(
256
+	if (isset($wpseo_metabox)) {
257
+		remove_action('wp_insert_post', array(
258 258
 			$wpseo_metabox,
259 259
 			'save_postdata',
260
-		) );
260
+		));
261 261
 	}
262 262
 
263
-	if ( isset( $seo_ultimate ) ) {
264
-		remove_action( 'save_post', array(
263
+	if (isset($seo_ultimate)) {
264
+		remove_action('save_post', array(
265 265
 			$seo_ultimate,
266 266
 			'save_postmeta_box',
267
-		) );
267
+		));
268 268
 	}
269 269
 
270 270
 	// The fact that we're calling here wp_insert_post is causing issues with plugins (and ourselves too) that hook to
@@ -274,90 +274,90 @@  discard block
 block discarded – undo
274 274
 	// see https://github.com/insideout10/wordlift-plugin/issues/156
275 275
 	// see https://github.com/insideout10/wordlift-plugin/issues/148
276 276
 	global $wp_filter;
277
-	$save_post_filters = is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks;
278
-	is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters();
277
+	$save_post_filters = is_array($wp_filter['save_post']) ? $wp_filter['save_post'] : $wp_filter['save_post']->callbacks;
278
+	is_array($wp_filter['save_post']) ? $wp_filter['save_post'] = array() : $wp_filter['save_post']->remove_all_filters();
279 279
 
280 280
 	// create or update the post.
281
-	$post_id = wp_insert_post( $params, true );
281
+	$post_id = wp_insert_post($params, true);
282 282
 
283 283
 	// Setting the alternative labels for this entity.
284 284
 	Wordlift_Entity_Service::get_instance()
285
-						   ->set_alternative_labels( $post_id, $synonyms );
285
+						   ->set_alternative_labels($post_id, $synonyms);
286 286
 
287 287
 	// Restore all the existing filters.
288
-	is_array( $wp_filter['save_post'] ) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters;
288
+	is_array($wp_filter['save_post']) ? $wp_filter['save_post'] = $save_post_filters : $wp_filter['save_post']->callbacks = $save_post_filters;
289 289
 
290 290
 	// If Yoast is installed and active, we restore the Yoast save_postdata hook (https://github.com/insideout10/wordlift-plugin/issues/156)
291
-	if ( isset( $wpseo_metabox ) ) {
292
-		add_action( 'wp_insert_post', array(
291
+	if (isset($wpseo_metabox)) {
292
+		add_action('wp_insert_post', array(
293 293
 			$wpseo_metabox,
294 294
 			'save_postdata',
295
-		) );
295
+		));
296 296
 	}
297 297
 
298 298
 	// If SEO Ultimate is installed, add back the hook we removed a few lines above.
299
-	if ( isset( $seo_ultimate ) ) {
300
-		add_action( 'save_post', array(
299
+	if (isset($seo_ultimate)) {
300
+		add_action('save_post', array(
301 301
 			$seo_ultimate,
302 302
 			'save_postmeta_box',
303
-		), 10, 2 );
303
+		), 10, 2);
304 304
 	}
305 305
 
306 306
 	// TODO: handle errors.
307
-	if ( is_wp_error( $post_id ) ) {
308
-		wl_write_log( ': error occurred' );
307
+	if (is_wp_error($post_id)) {
308
+		wl_write_log(': error occurred');
309 309
 
310 310
 		// inform an error occurred.
311 311
 		return null;
312 312
 	}
313 313
 
314
-	wl_set_entity_main_type( $post_id, $type_uri );
314
+	wl_set_entity_main_type($post_id, $type_uri);
315 315
 
316 316
 	// Save the entity types.
317
-	wl_set_entity_rdf_types( $post_id, $entity_types );
317
+	wl_set_entity_rdf_types($post_id, $entity_types);
318 318
 
319 319
 	// Get a dataset URI for the entity.
320
-	$wl_uri = wl_build_entity_uri( $post_id );
320
+	$wl_uri = wl_build_entity_uri($post_id);
321 321
 
322 322
 	// Save the entity URI.
323
-	wl_set_entity_uri( $post_id, $wl_uri );
323
+	wl_set_entity_uri($post_id, $wl_uri);
324 324
 
325 325
 	// Add the uri to the sameAs data if it's not a local URI.
326
-	if ( $wl_uri !== $uri ) {
327
-		array_push( $same_as, $uri );
326
+	if ($wl_uri !== $uri) {
327
+		array_push($same_as, $uri);
328 328
 	}
329 329
 
330
-	$new_uri = wl_get_entity_uri( $post_id );
330
+	$new_uri = wl_get_entity_uri($post_id);
331 331
 
332 332
 	// Save the sameAs data for the entity.
333
-	wl_schema_set_value( $post_id, 'sameAs', $same_as );
333
+	wl_schema_set_value($post_id, 'sameAs', $same_as);
334 334
 
335 335
 	// Save the other properties (latitude, langitude, startDate, endDate, etc.)
336
-	foreach ( $other_properties as $property_name => $property_value ) {
337
-		wl_schema_set_value( $post_id, $property_name, $property_value );
336
+	foreach ($other_properties as $property_name => $property_value) {
337
+		wl_schema_set_value($post_id, $property_name, $property_value);
338 338
 	}
339 339
 
340 340
 	// Call hooks.
341
-	do_action( 'wl_save_entity', $post_id );
341
+	do_action('wl_save_entity', $post_id);
342 342
 
343
-	foreach ( $images as $image_remote_url ) {
343
+	foreach ($images as $image_remote_url) {
344 344
 
345 345
 		// Check if image is already present in local DB
346
-		if ( strpos( $image_remote_url, site_url() ) !== false ) {
346
+		if (strpos($image_remote_url, site_url()) !== false) {
347 347
 			// Do nothing.
348 348
 			continue;
349 349
 		}
350 350
 
351 351
 		// Check if there is an existing attachment for this post ID and source URL.
352
-		$existing_image = wl_get_attachment_for_source_url( $post_id, $image_remote_url );
352
+		$existing_image = wl_get_attachment_for_source_url($post_id, $image_remote_url);
353 353
 
354 354
 		// Skip if an existing image is found.
355
-		if ( null !== $existing_image ) {
355
+		if (null !== $existing_image) {
356 356
 			continue;
357 357
 		}
358 358
 
359 359
 		// Save the image and get the local path.
360
-		$image = wl_save_image( $image_remote_url );
360
+		$image = wl_save_image($image_remote_url);
361 361
 
362 362
 		// Get the local URL.
363 363
 		$filename     = $image['path'];
@@ -375,24 +375,24 @@  discard block
 block discarded – undo
375 375
 		);
376 376
 
377 377
 		// Create the attachment in WordPress and generate the related metadata.
378
-		$attachment_id = wp_insert_attachment( $attachment, $filename, $post_id );
378
+		$attachment_id = wp_insert_attachment($attachment, $filename, $post_id);
379 379
 
380 380
 		// Set the source URL for the image.
381
-		wl_set_source_url( $attachment_id, $image_remote_url );
381
+		wl_set_source_url($attachment_id, $image_remote_url);
382 382
 
383
-		$attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
384
-		wp_update_attachment_metadata( $attachment_id, $attachment_data );
383
+		$attachment_data = wp_generate_attachment_metadata($attachment_id, $filename);
384
+		wp_update_attachment_metadata($attachment_id, $attachment_data);
385 385
 
386 386
 		// Set it as the featured image.
387
-		set_post_thumbnail( $post_id, $attachment_id );
387
+		set_post_thumbnail($post_id, $attachment_id);
388 388
 	}
389 389
 
390 390
 	// The entity is pushed to Redlink on save by the function hooked to save_post.
391 391
 	// save the entity in the triple store.
392
-	Wordlift_Linked_Data_Service::get_instance()->push( $post_id );
392
+	Wordlift_Linked_Data_Service::get_instance()->push($post_id);
393 393
 
394 394
 	// finally return the entity post.
395
-	return get_post( $post_id );
395
+	return get_post($post_id);
396 396
 }
397 397
 
398 398
 /**
@@ -404,10 +404,10 @@  discard block
 block discarded – undo
404 404
  *
405 405
  * @return array An array of entity posts.
406 406
  */
407
-function wl_linked_data_content_get_embedded_entities( $content ) {
407
+function wl_linked_data_content_get_embedded_entities($content) {
408 408
 
409 409
 	// Remove quote escapes.
410
-	$content = str_replace( '\\"', '"', $content );
410
+	$content = str_replace('\\"', '"', $content);
411 411
 
412 412
 	// Match all itemid attributes.
413 413
 	$pattern = '/<\w+[^>]*\sitemid="([^"]+)"[^>]*>/im';
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	$matches = array();
419 419
 
420 420
 	// In case of errors, return an empty array.
421
-	if ( false === preg_match_all( $pattern, $content, $matches ) ) {
422
-		wl_write_log( "Found no entities embedded in content" );
421
+	if (false === preg_match_all($pattern, $content, $matches)) {
422
+		wl_write_log("Found no entities embedded in content");
423 423
 
424 424
 		return array();
425 425
 	}
@@ -428,13 +428,13 @@  discard block
 block discarded – undo
428 428
 
429 429
 	// Collect the entities.
430 430
 	$entities = array();
431
-	foreach ( $matches[1] as $uri ) {
432
-		$uri_d = html_entity_decode( $uri );
431
+	foreach ($matches[1] as $uri) {
432
+		$uri_d = html_entity_decode($uri);
433 433
 
434
-		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( $uri_d );
434
+		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri($uri_d);
435 435
 
436
-		if ( null !== $entity ) {
437
-			array_push( $entities, $entity->ID );
436
+		if (null !== $entity) {
437
+			array_push($entities, $entity->ID);
438 438
 		}
439 439
 	}
440 440
 
Please login to merge, or discard this patch.