Completed
Push — develop ( f5cfcc...e2baaf )
by Naveen
01:17
created
src/admin/class-wordlift-admin-settings-analytics-page-action-link.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -19,52 +19,52 @@
 block discarded – undo
19 19
  */
20 20
 class Wordlift_Admin_Settings_Analytics_Page_Action_Link {
21 21
 
22
-	/**
23
-	 * The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
24
-	 *
25
-	 * @since  3.11.0
26
-	 * @access private
27
-	 * @var \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
28
-	 */
29
-	private $settings_page;
22
+    /**
23
+     * The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
24
+     *
25
+     * @since  3.11.0
26
+     * @access private
27
+     * @var \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
28
+     */
29
+    private $settings_page;
30 30
 
31
-	/**
32
-	 * Create a {@link Wordlift_Admin_Settings_Analytics_Page_Action_Link} instance.
33
-	 *
34
-	 * @since  3.11.0
35
-	 *
36
-	 * @param \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
37
-	 */
38
-	public function __construct( $settings_page ) {
31
+    /**
32
+     * Create a {@link Wordlift_Admin_Settings_Analytics_Page_Action_Link} instance.
33
+     *
34
+     * @since  3.11.0
35
+     *
36
+     * @param \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
37
+     */
38
+    public function __construct( $settings_page ) {
39 39
 
40
-		$this->settings_page = $settings_page;
40
+        $this->settings_page = $settings_page;
41 41
 
42
-	}
42
+    }
43 43
 
44
-	/**
45
-	 * Create a link to the WordLift settings page.
46
-	 *
47
-	 * @since 3.11.0
48
-	 *
49
-	 * @param array $links An array of links.
50
-	 *
51
-	 * @return array An array of links including those added by the plugin.
52
-	 */
53
-	public function action_links( $links ) {
44
+    /**
45
+     * Create a link to the WordLift settings page.
46
+     *
47
+     * @since 3.11.0
48
+     *
49
+     * @param array $links An array of links.
50
+     *
51
+     * @return array An array of links including those added by the plugin.
52
+     */
53
+    public function action_links( $links ) {
54 54
 
55
-		// Get the menu slug from the page, then prepare the path, hence the url.
56
-		$menu_slug = $this->settings_page->get_menu_slug();
57
-		$path      = "admin.php?page=$menu_slug";
58
-		$url       = get_admin_url( null, $path );
55
+        // Get the menu slug from the page, then prepare the path, hence the url.
56
+        $menu_slug = $this->settings_page->get_menu_slug();
57
+        $path      = "admin.php?page=$menu_slug";
58
+        $url       = get_admin_url( null, $path );
59 59
 
60
-		// Add our own link to the list of links.
61
-		return array_merge( $links, array(
62
-			sprintf(
63
-				'<a href="%1$s">%2$s</a>',
64
-				esc_url( $url ),
65
-				esc_html__( 'Analytics Settings', 'wordlift' )
66
-			),
67
-		) );
68
-	}
60
+        // Add our own link to the list of links.
61
+        return array_merge( $links, array(
62
+            sprintf(
63
+                '<a href="%1$s">%2$s</a>',
64
+                esc_url( $url ),
65
+                esc_html__( 'Analytics Settings', 'wordlift' )
66
+            ),
67
+        ) );
68
+    }
69 69
 
70 70
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
37 37
 	 */
38
-	public function __construct( $settings_page ) {
38
+	public function __construct($settings_page) {
39 39
 
40 40
 		$this->settings_page = $settings_page;
41 41
 
@@ -50,21 +50,21 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @return array An array of links including those added by the plugin.
52 52
 	 */
53
-	public function action_links( $links ) {
53
+	public function action_links($links) {
54 54
 
55 55
 		// Get the menu slug from the page, then prepare the path, hence the url.
56 56
 		$menu_slug = $this->settings_page->get_menu_slug();
57 57
 		$path      = "admin.php?page=$menu_slug";
58
-		$url       = get_admin_url( null, $path );
58
+		$url       = get_admin_url(null, $path);
59 59
 
60 60
 		// Add our own link to the list of links.
61
-		return array_merge( $links, array(
61
+		return array_merge($links, array(
62 62
 			sprintf(
63 63
 				'<a href="%1$s">%2$s</a>',
64
-				esc_url( $url ),
65
-				esc_html__( 'Analytics Settings', 'wordlift' )
64
+				esc_url($url),
65
+				esc_html__('Analytics Settings', 'wordlift')
66 66
 			),
67
-		) );
67
+		));
68 68
 	}
69 69
 
70 70
 }
Please login to merge, or discard this patch.
src/includes/analytics/class-wordlift-analytics-connect.php 2 patches
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -14,89 +14,89 @@
 block discarded – undo
14 14
  */
15 15
 class Wordlift_Analytics_Connect {
16 16
 
17
-	/**
18
-	 * Gets an array of related entities with their post IDs and titles.
19
-	 *
20
-	 * @method get_analytics_event_data
21
-	 * @since  3.21.0
22
-	 *
23
-	 * @param  int $post_id post id we want related data for.
24
-	 *
25
-	 * @return array
26
-	 */
27
-	public static function get_analytics_event_data( $post_id ) {
28
-		// If no ID was passed get current ID.
29
-		if ( ! $post_id ) {
30
-			$post_id = get_queried_object_id();
31
-		}
32
-		/**
33
-		 * TODO: set/get this from cache.
34
-		 */
35
-		$related_items = array();
36
-		$related_ids   = wl_core_get_related_entity_ids( $post_id );
17
+    /**
18
+     * Gets an array of related entities with their post IDs and titles.
19
+     *
20
+     * @method get_analytics_event_data
21
+     * @since  3.21.0
22
+     *
23
+     * @param  int $post_id post id we want related data for.
24
+     *
25
+     * @return array
26
+     */
27
+    public static function get_analytics_event_data( $post_id ) {
28
+        // If no ID was passed get current ID.
29
+        if ( ! $post_id ) {
30
+            $post_id = get_queried_object_id();
31
+        }
32
+        /**
33
+         * TODO: set/get this from cache.
34
+         */
35
+        $related_items = array();
36
+        $related_ids   = wl_core_get_related_entity_ids( $post_id );
37 37
 
38
-		$entity_service = Wordlift_Entity_Service::get_instance();
39
-		// If the current item is also an entity then add it to the list of IDs.
40
-		if ( $entity_service->is_entity( $post_id ) ) {
41
-			$related_ids[] = $post_id;
42
-		}
43
-		$entity_type_service = Wordlift_Entity_Type_Service::get_instance();
44
-		// Get the post titles of related items and connect them in an array.
45
-		foreach ( $related_ids as $related_id ) {
46
-			$type  = $entity_type_service->get( $related_id );
47
-			$type  = isset( $type['uri'] ) ? $type['uri'] : 'unknown';
48
-			$label = $entity_service->get_labels( $related_id );
49
-			$label = $label[0];
38
+        $entity_service = Wordlift_Entity_Service::get_instance();
39
+        // If the current item is also an entity then add it to the list of IDs.
40
+        if ( $entity_service->is_entity( $post_id ) ) {
41
+            $related_ids[] = $post_id;
42
+        }
43
+        $entity_type_service = Wordlift_Entity_Type_Service::get_instance();
44
+        // Get the post titles of related items and connect them in an array.
45
+        foreach ( $related_ids as $related_id ) {
46
+            $type  = $entity_type_service->get( $related_id );
47
+            $type  = isset( $type['uri'] ) ? $type['uri'] : 'unknown';
48
+            $label = $entity_service->get_labels( $related_id );
49
+            $label = $label[0];
50 50
 
51
-			$related_items[ $related_id ] = array(
52
-				'uri'   => $entity_service->get_uri( $related_id ),
53
-				'type'  => $type,
54
-				'label' => $label,
55
-			);
56
-		}
51
+            $related_items[ $related_id ] = array(
52
+                'uri'   => $entity_service->get_uri( $related_id ),
53
+                'type'  => $type,
54
+                'label' => $label,
55
+            );
56
+        }
57 57
 
58
-		return $related_items;
59
-	}
58
+        return $related_items;
59
+    }
60 60
 
61
-	/**
62
-	 * Gets the configuration data assosiated with the analytics settings. For
63
-	 * frontend script use primarily.
64
-	 *
65
-	 * @method get_analytics_config_data
66
-	 * @since  3.21.0
67
-	 * @return array
68
-	 */
69
-	public static function get_analytics_config_data() {
70
-		$configuration_service = Wordlift_Configuration_Service::get_instance();
71
-		// get some values from the config service.
72
-		$config = array(
73
-			'entity_uri_dimension'  => $configuration_service->get_analytics_entity_uri_dimension(),
74
-			'entity_type_dimension' => $configuration_service->get_analytics_entity_type_dimension(),
75
-		);
61
+    /**
62
+     * Gets the configuration data assosiated with the analytics settings. For
63
+     * frontend script use primarily.
64
+     *
65
+     * @method get_analytics_config_data
66
+     * @since  3.21.0
67
+     * @return array
68
+     */
69
+    public static function get_analytics_config_data() {
70
+        $configuration_service = Wordlift_Configuration_Service::get_instance();
71
+        // get some values from the config service.
72
+        $config = array(
73
+            'entity_uri_dimension'  => $configuration_service->get_analytics_entity_uri_dimension(),
74
+            'entity_type_dimension' => $configuration_service->get_analytics_entity_type_dimension(),
75
+        );
76 76
 
77
-		return $config;
78
-	}
77
+        return $config;
78
+    }
79 79
 
80
-	/**
81
-	 * Enqueues our scripts for the frontend analytics handling and attaches
82
-	 * any data we will want to use there.
83
-	 *
84
-	 * @method enqueue_scripts
85
-	 * @since  3.21.0
86
-	 */
87
-	public function enqueue_scripts() {
88
-		$entity_data = self::get_analytics_event_data( get_the_ID() );
89
-		// Bail early if there is no event data that we would send.
90
-		if ( ! $entity_data ) {
91
-			return;
92
-		}
93
-		$data = self::get_analytics_config_data();
94
-		/**
95
-		 * TODO: Look into using a constant for defining pase plugin url.
96
-		 */
97
-		$plugin_name = Wordlift::get_instance()->get_plugin_name();
98
-		wp_enqueue_script( $plugin_name, plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'js/wordlift-analytics.js', array(), '1.0.0', true );
99
-		wp_localize_script( $plugin_name, 'wordliftAnalyticsConfigData', $data );
100
-		wp_localize_script( $plugin_name, 'wordliftAnalyticsEntityData', $entity_data );
101
-	}
80
+    /**
81
+     * Enqueues our scripts for the frontend analytics handling and attaches
82
+     * any data we will want to use there.
83
+     *
84
+     * @method enqueue_scripts
85
+     * @since  3.21.0
86
+     */
87
+    public function enqueue_scripts() {
88
+        $entity_data = self::get_analytics_event_data( get_the_ID() );
89
+        // Bail early if there is no event data that we would send.
90
+        if ( ! $entity_data ) {
91
+            return;
92
+        }
93
+        $data = self::get_analytics_config_data();
94
+        /**
95
+         * TODO: Look into using a constant for defining pase plugin url.
96
+         */
97
+        $plugin_name = Wordlift::get_instance()->get_plugin_name();
98
+        wp_enqueue_script( $plugin_name, plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'js/wordlift-analytics.js', array(), '1.0.0', true );
99
+        wp_localize_script( $plugin_name, 'wordliftAnalyticsConfigData', $data );
100
+        wp_localize_script( $plugin_name, 'wordliftAnalyticsEntityData', $entity_data );
101
+    }
102 102
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -24,32 +24,32 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @return array
26 26
 	 */
27
-	public static function get_analytics_event_data( $post_id ) {
27
+	public static function get_analytics_event_data($post_id) {
28 28
 		// If no ID was passed get current ID.
29
-		if ( ! $post_id ) {
29
+		if ( ! $post_id) {
30 30
 			$post_id = get_queried_object_id();
31 31
 		}
32 32
 		/**
33 33
 		 * TODO: set/get this from cache.
34 34
 		 */
35 35
 		$related_items = array();
36
-		$related_ids   = wl_core_get_related_entity_ids( $post_id );
36
+		$related_ids   = wl_core_get_related_entity_ids($post_id);
37 37
 
38 38
 		$entity_service = Wordlift_Entity_Service::get_instance();
39 39
 		// If the current item is also an entity then add it to the list of IDs.
40
-		if ( $entity_service->is_entity( $post_id ) ) {
40
+		if ($entity_service->is_entity($post_id)) {
41 41
 			$related_ids[] = $post_id;
42 42
 		}
43 43
 		$entity_type_service = Wordlift_Entity_Type_Service::get_instance();
44 44
 		// Get the post titles of related items and connect them in an array.
45
-		foreach ( $related_ids as $related_id ) {
46
-			$type  = $entity_type_service->get( $related_id );
47
-			$type  = isset( $type['uri'] ) ? $type['uri'] : 'unknown';
48
-			$label = $entity_service->get_labels( $related_id );
45
+		foreach ($related_ids as $related_id) {
46
+			$type  = $entity_type_service->get($related_id);
47
+			$type  = isset($type['uri']) ? $type['uri'] : 'unknown';
48
+			$label = $entity_service->get_labels($related_id);
49 49
 			$label = $label[0];
50 50
 
51
-			$related_items[ $related_id ] = array(
52
-				'uri'   => $entity_service->get_uri( $related_id ),
51
+			$related_items[$related_id] = array(
52
+				'uri'   => $entity_service->get_uri($related_id),
53 53
 				'type'  => $type,
54 54
 				'label' => $label,
55 55
 			);
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	 * @since  3.21.0
86 86
 	 */
87 87
 	public function enqueue_scripts() {
88
-		$entity_data = self::get_analytics_event_data( get_the_ID() );
88
+		$entity_data = self::get_analytics_event_data(get_the_ID());
89 89
 		// Bail early if there is no event data that we would send.
90
-		if ( ! $entity_data ) {
90
+		if ( ! $entity_data) {
91 91
 			return;
92 92
 		}
93 93
 		$data = self::get_analytics_config_data();
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 		 * TODO: Look into using a constant for defining pase plugin url.
96 96
 		 */
97 97
 		$plugin_name = Wordlift::get_instance()->get_plugin_name();
98
-		wp_enqueue_script( $plugin_name, plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'js/wordlift-analytics.js', array(), '1.0.0', true );
99
-		wp_localize_script( $plugin_name, 'wordliftAnalyticsConfigData', $data );
100
-		wp_localize_script( $plugin_name, 'wordliftAnalyticsEntityData', $entity_data );
98
+		wp_enqueue_script($plugin_name, plugin_dir_url(dirname(dirname(__FILE__))).'js/wordlift-analytics.js', array(), '1.0.0', true);
99
+		wp_localize_script($plugin_name, 'wordliftAnalyticsConfigData', $data);
100
+		wp_localize_script($plugin_name, 'wordliftAnalyticsEntityData', $entity_data);
101 101
 	}
102 102
 }
Please login to merge, or discard this patch.
src/includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -18,50 +18,50 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Post_Meta_Uri_Storage extends Wordlift_Post_Meta_Storage {
20 20
 
21
-	/**
22
-	 * The {@link Wordlift_Entity_Service} instance.
23
-	 *
24
-	 * @since  3.15.0
25
-	 * @access private
26
-	 * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
27
-	 */
28
-	private $entity_service;
21
+    /**
22
+     * The {@link Wordlift_Entity_Service} instance.
23
+     *
24
+     * @since  3.15.0
25
+     * @access private
26
+     * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
27
+     */
28
+    private $entity_service;
29 29
 
30
-	/**
31
-	 * Create a {@link Wordlift_Post_Meta_Uri_Storage} instance.
32
-	 *
33
-	 * @since 3.15.0
34
-	 *
35
-	 * @param string                   $meta_key       The meta key to read data from.
36
-	 * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
37
-	 */
38
-	public function __construct( $meta_key, $entity_service ) {
39
-		parent::__construct( $meta_key );
30
+    /**
31
+     * Create a {@link Wordlift_Post_Meta_Uri_Storage} instance.
32
+     *
33
+     * @since 3.15.0
34
+     *
35
+     * @param string                   $meta_key       The meta key to read data from.
36
+     * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
37
+     */
38
+    public function __construct( $meta_key, $entity_service ) {
39
+        parent::__construct( $meta_key );
40 40
 
41
-		$this->entity_service = $entity_service;
41
+        $this->entity_service = $entity_service;
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Get the value for the specified meta key.
47
-	 *
48
-	 * The value is expected to be an entity post, for which the URI is loaded
49
-	 * and returned.
50
-	 *
51
-	 * @since 3.15.0
52
-	 *
53
-	 * @param int $post_id The {@link WP_Post}'s id.
54
-	 *
55
-	 * @return array An array of URIs (or an empty array if nothing is set).
56
-	 */
57
-	public function get( $post_id ) {
58
-		$values = parent::get( $post_id );
45
+    /**
46
+     * Get the value for the specified meta key.
47
+     *
48
+     * The value is expected to be an entity post, for which the URI is loaded
49
+     * and returned.
50
+     *
51
+     * @since 3.15.0
52
+     *
53
+     * @param int $post_id The {@link WP_Post}'s id.
54
+     *
55
+     * @return array An array of URIs (or an empty array if nothing is set).
56
+     */
57
+    public function get( $post_id ) {
58
+        $values = parent::get( $post_id );
59 59
 
60
-		$entity_service = $this->entity_service;
60
+        $entity_service = $this->entity_service;
61 61
 
62
-		return array_map( function ( $item ) use ( $entity_service ) {
63
-			return $entity_service->get_uri( $item );
64
-		}, $values );
65
-	}
62
+        return array_map( function ( $item ) use ( $entity_service ) {
63
+            return $entity_service->get_uri( $item );
64
+        }, $values );
65
+    }
66 66
 
67 67
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 	 * @param string                   $meta_key       The meta key to read data from.
36 36
 	 * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
37 37
 	 */
38
-	public function __construct( $meta_key, $entity_service ) {
39
-		parent::__construct( $meta_key );
38
+	public function __construct($meta_key, $entity_service) {
39
+		parent::__construct($meta_key);
40 40
 
41 41
 		$this->entity_service = $entity_service;
42 42
 
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return array An array of URIs (or an empty array if nothing is set).
56 56
 	 */
57
-	public function get( $post_id ) {
58
-		$values = parent::get( $post_id );
57
+	public function get($post_id) {
58
+		$values = parent::get($post_id);
59 59
 
60 60
 		$entity_service = $this->entity_service;
61 61
 
62
-		return array_map( function ( $item ) use ( $entity_service ) {
63
-			return $entity_service->get_uri( $item );
64
-		}, $values );
62
+		return array_map(function($item) use ($entity_service) {
63
+			return $entity_service->get_uri($item);
64
+		}, $values);
65 65
 	}
66 66
 
67 67
 }
Please login to merge, or discard this patch.
src/admin/partials/wordlift-admin-settings-analytics-page.php 2 patches
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 	<?php settings_errors(); ?>
12 12
 	<form action="options.php" method="post">
13 13
 		<?php
14
-		settings_fields( 'wl_analytics_settings' );
15
-		do_settings_sections( 'wl_analytics_settings' );
16
-		submit_button();
17
-		?>
14
+        settings_fields( 'wl_analytics_settings' );
15
+        do_settings_sections( 'wl_analytics_settings' );
16
+        submit_button();
17
+        ?>
18 18
 	</form>
19 19
 	<div class="info">
20 20
 		<b><?php esc_html_e( 'For Google Tag Manager there is additional setup steps needed in the GTM interface. These are the general instructions:', 'wordlift' ); ?></b>
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
 			<li><?php esc_html_e( 'You should already have a configuration variable setup to pass data along to your provider. This is assumed to be Google Analytics and a google analytics configuration object. If you don\'t have this setup then set it up now.', 'wordlift' ); ?></li>
23 23
 			<li>
24 24
 				<?php
25
-				printf(
26
-					esc_html__( 'Visit the GTM dashboard and head to the %1$s menu. Add a new user-defined variable of type %2$s for each of the following items:', 'wordlift' ),
27
-					'<b>Variables</b>',
28
-					'<i>Data Layer Variable</i>'
29
-				);
30
-				?>
25
+                printf(
26
+                    esc_html__( 'Visit the GTM dashboard and head to the %1$s menu. Add a new user-defined variable of type %2$s for each of the following items:', 'wordlift' ),
27
+                    '<b>Variables</b>',
28
+                    '<i>Data Layer Variable</i>'
29
+                );
30
+                ?>
31 31
 				<ol>
32 32
 					<li><i>event</i></li>
33 33
 					<li><i>wl_event_action</i></li>
@@ -43,51 +43,51 @@  discard block
 block discarded – undo
43 43
 			</li>
44 44
 			<li>
45 45
 				<?php
46
-				printf(
47
-					esc_html__( 'Create another variable to pass along the 2 custom dimensions with the type %1$s. For each of the 2 items set the following:', 'wordlift' ),
48
-					'<i>Google Analytics Settings</i>'
49
-				);
50
-				?>
46
+                printf(
47
+                    esc_html__( 'Create another variable to pass along the 2 custom dimensions with the type %1$s. For each of the 2 items set the following:', 'wordlift' ),
48
+                    '<i>Google Analytics Settings</i>'
49
+                );
50
+                ?>
51 51
 				<ol>
52 52
 					<li><?php esc_html_e( 'Set the index to the index of the custom event you want to push this into at Google Analytics, this will usually be a number between 1 and 9.', 'wordlift' ); ?></li>
53 53
 					<li>
54 54
 						<?php
55
-						printf(
56
-							esc_html__( 'Set the values of each one to the %1$s and the %2$s respectively.', 'wordlift' ),
57
-							'<i>wl_index_uri</i> - <i>wl_event_uri</i>',
58
-							'<i>wl_index_type</i> - <i>wl_event_type</i>'
59
-						);
60
-						?>
55
+                        printf(
56
+                            esc_html__( 'Set the values of each one to the %1$s and the %2$s respectively.', 'wordlift' ),
57
+                            '<i>wl_index_uri</i> - <i>wl_event_uri</i>',
58
+                            '<i>wl_index_type</i> - <i>wl_event_type</i>'
59
+                        );
60
+                        ?>
61 61
 					</li>
62 62
 				</ol>
63 63
 			</li>
64 64
 			<li>
65 65
 				<?php
66
-				printf(
67
-					esc_html__( 'Go to the %1$s menu and create a new trigger of the type: %2$s.', 'wordlift' ),
68
-					'<b>Triggers</b>',
69
-					'<i>Custom Event</i>'
70
-				);
71
-				?>
66
+                printf(
67
+                    esc_html__( 'Go to the %1$s menu and create a new trigger of the type: %2$s.', 'wordlift' ),
68
+                    '<b>Triggers</b>',
69
+                    '<i>Custom Event</i>'
70
+                );
71
+                ?>
72 72
 				<ol>
73 73
 					<li>
74 74
 
75 75
 						<?php
76
-						printf(
77
-							esc_html__( 'In the %1$s field input %2$s.', 'wordlift' ),
78
-							'<i>Event name</i>',
79
-							'<i>Mentions</i>'
80
-						);
81
-						?>
76
+                        printf(
77
+                            esc_html__( 'In the %1$s field input %2$s.', 'wordlift' ),
78
+                            '<i>Event name</i>',
79
+                            '<i>Mentions</i>'
80
+                        );
81
+                        ?>
82 82
 					</li>
83 83
 					<li>
84 84
 
85 85
 						<?php
86
-						printf(
87
-							esc_html__( 'Set this to fire on %1$s and in the filter set:', 'wordlift' ),
88
-							'<i>Some Custom Events</i>'
89
-						);
90
-						?>
86
+                        printf(
87
+                            esc_html__( 'Set this to fire on %1$s and in the filter set:', 'wordlift' ),
88
+                            '<i>Some Custom Events</i>'
89
+                        );
90
+                        ?>
91 91
 						<ol>
92 92
 							<li><i>event_action</i> - <i>equals</i> - <i>Mentions</i>.</li>
93 93
 						</ol>
@@ -96,77 +96,77 @@  discard block
 block discarded – undo
96 96
 			</li>
97 97
 			<li>
98 98
 				<?php
99
-				printf(
100
-					esc_html__( 'Go to the %1$s menu and create a new tag.', 'wordlift' ),
101
-					'<b>Tags</b>'
102
-				);
103
-				?>
99
+                printf(
100
+                    esc_html__( 'Go to the %1$s menu and create a new tag.', 'wordlift' ),
101
+                    '<b>Tags</b>'
102
+                );
103
+                ?>
104 104
 				<ol>
105 105
 					<li>
106 106
 
107 107
 						<?php
108
-						printf(
109
-							esc_html__( 'In the tag configuration section choose %1$s. Assuming you have used variable names that match those mentioned enter:', 'wordlift' ),
110
-							'<i>Google Analytics - Universal Analytics</i>'
111
-						);
112
-						?>
108
+                        printf(
109
+                            esc_html__( 'In the tag configuration section choose %1$s. Assuming you have used variable names that match those mentioned enter:', 'wordlift' ),
110
+                            '<i>Google Analytics - Universal Analytics</i>'
111
+                        );
112
+                        ?>
113 113
 						<ol>
114 114
 							<li>
115 115
 								<?php
116
-								printf(
117
-									esc_html__( 'Set the %1$s to %2$s.', 'wordlift' ),
118
-									'Track Type',
119
-									'<i>Event</i>'
120
-								);
121
-								?>
116
+                                printf(
117
+                                    esc_html__( 'Set the %1$s to %2$s.', 'wordlift' ),
118
+                                    'Track Type',
119
+                                    '<i>Event</i>'
120
+                                );
121
+                                ?>
122 122
 							</li>
123 123
 							<li>
124 124
 								<?php
125
-								printf(
126
-									esc_html__( 'Set Category to %1$s.', 'wordlift' ),
127
-									'<i>{{wl_event_category}}</i>'
128
-								);
129
-								?>
125
+                                printf(
126
+                                    esc_html__( 'Set Category to %1$s.', 'wordlift' ),
127
+                                    '<i>{{wl_event_category}}</i>'
128
+                                );
129
+                                ?>
130 130
 							</li>
131 131
 							<li>
132 132
 								<?php
133
-								printf(
134
-									esc_html__( 'Set Action to %1$s.', 'wordlift' ),
135
-									'<i>{{wl_event_action}}</i>'
136
-								);
137
-								?>
133
+                                printf(
134
+                                    esc_html__( 'Set Action to %1$s.', 'wordlift' ),
135
+                                    '<i>{{wl_event_action}}</i>'
136
+                                );
137
+                                ?>
138 138
 							</li>
139 139
 							<li>
140 140
 								<?php
141
-								printf(
142
-									esc_html__( 'Set Label to %1$s.', 'wordlift' ),
143
-									'<i>{{wl_event_label}}</i>'
144
-								);
145
-								?>
141
+                                printf(
142
+                                    esc_html__( 'Set Label to %1$s.', 'wordlift' ),
143
+                                    '<i>{{wl_event_label}}</i>'
144
+                                );
145
+                                ?>
146 146
 							</li>
147 147
 							<li>
148 148
 								<?php
149
-								printf(
150
-									esc_html__( 'Set Value to %1$s.', 'wordlift' ),
151
-									'<i>{{wl_event_value}}</i>'
152
-								);
153
-								?>
149
+                                printf(
150
+                                    esc_html__( 'Set Value to %1$s.', 'wordlift' ),
151
+                                    '<i>{{wl_event_value}}</i>'
152
+                                );
153
+                                ?>
154 154
 							</li>
155 155
 							<li>
156 156
 								<?php
157
-								printf(
158
-									esc_html__( 'Set Non-Interaction Hit to %1$s.', 'wordlift' ),
159
-									'<i>True</i>'
160
-								);
161
-								?>
157
+                                printf(
158
+                                    esc_html__( 'Set Non-Interaction Hit to %1$s.', 'wordlift' ),
159
+                                    '<i>True</i>'
160
+                                );
161
+                                ?>
162 162
 							</li>
163 163
 							<li>
164 164
 								<?php
165
-								printf(
166
-									esc_html__( 'Set the %1$s dropdown to the settings object for the Google Analytics tracking.', 'wordlift' ),
167
-									'<i>Google Analytics Settings</i>'
168
-								);
169
-								?>
165
+                                printf(
166
+                                    esc_html__( 'Set the %1$s dropdown to the settings object for the Google Analytics tracking.', 'wordlift' ),
167
+                                    '<i>Google Analytics Settings</i>'
168
+                                );
169
+                                ?>
170 170
 							</li>
171 171
 						</ol>
172 172
 					</li>
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
 	<?php settings_errors(); ?>
12 12
 	<form action="options.php" method="post">
13 13
 		<?php
14
-		settings_fields( 'wl_analytics_settings' );
15
-		do_settings_sections( 'wl_analytics_settings' );
14
+		settings_fields('wl_analytics_settings');
15
+		do_settings_sections('wl_analytics_settings');
16 16
 		submit_button();
17 17
 		?>
18 18
 	</form>
19 19
 	<div class="info">
20
-		<b><?php esc_html_e( 'For Google Tag Manager there is additional setup steps needed in the GTM interface. These are the general instructions:', 'wordlift' ); ?></b>
20
+		<b><?php esc_html_e('For Google Tag Manager there is additional setup steps needed in the GTM interface. These are the general instructions:', 'wordlift'); ?></b>
21 21
 		<ol>
22
-			<li><?php esc_html_e( 'You should already have a configuration variable setup to pass data along to your provider. This is assumed to be Google Analytics and a google analytics configuration object. If you don\'t have this setup then set it up now.', 'wordlift' ); ?></li>
22
+			<li><?php esc_html_e('You should already have a configuration variable setup to pass data along to your provider. This is assumed to be Google Analytics and a google analytics configuration object. If you don\'t have this setup then set it up now.', 'wordlift'); ?></li>
23 23
 			<li>
24 24
 				<?php
25 25
 				printf(
26
-					esc_html__( 'Visit the GTM dashboard and head to the %1$s menu. Add a new user-defined variable of type %2$s for each of the following items:', 'wordlift' ),
26
+					esc_html__('Visit the GTM dashboard and head to the %1$s menu. Add a new user-defined variable of type %2$s for each of the following items:', 'wordlift'),
27 27
 					'<b>Variables</b>',
28 28
 					'<i>Data Layer Variable</i>'
29 29
 				);
@@ -34,26 +34,26 @@  discard block
 block discarded – undo
34 34
 					<li><i>wl_event_category</i></li>
35 35
 					<li><i>wl_event_label</i></li>
36 36
 					<li><i>wl_event_value</i></li>
37
-					<li><i>wl_event_uri</i> <?php esc_html_e( '(which is the first custom dimension number the plugin offers)', 'wordlift' ); ?></li>
38
-					<li><i>wl_index_uri</i> <?php esc_html_e( '(this is the index number sent to use as the custom dimention for uri)', 'wordlift' ); ?></li>
39
-					<li><i>wl_event_type</i> <?php esc_html_e( '(which is the second custom dimension number the plugin offers)', 'wordlift' ); ?></li>
40
-					<li><i>wl_index_type</i> <?php esc_html_e( '(this is the index number sent to use as the custom dimention for type)', 'wordlift' ); ?></li>
37
+					<li><i>wl_event_uri</i> <?php esc_html_e('(which is the first custom dimension number the plugin offers)', 'wordlift'); ?></li>
38
+					<li><i>wl_index_uri</i> <?php esc_html_e('(this is the index number sent to use as the custom dimention for uri)', 'wordlift'); ?></li>
39
+					<li><i>wl_event_type</i> <?php esc_html_e('(which is the second custom dimension number the plugin offers)', 'wordlift'); ?></li>
40
+					<li><i>wl_index_type</i> <?php esc_html_e('(this is the index number sent to use as the custom dimention for type)', 'wordlift'); ?></li>
41 41
 
42 42
 				</ol>
43 43
 			</li>
44 44
 			<li>
45 45
 				<?php
46 46
 				printf(
47
-					esc_html__( 'Create another variable to pass along the 2 custom dimensions with the type %1$s. For each of the 2 items set the following:', 'wordlift' ),
47
+					esc_html__('Create another variable to pass along the 2 custom dimensions with the type %1$s. For each of the 2 items set the following:', 'wordlift'),
48 48
 					'<i>Google Analytics Settings</i>'
49 49
 				);
50 50
 				?>
51 51
 				<ol>
52
-					<li><?php esc_html_e( 'Set the index to the index of the custom event you want to push this into at Google Analytics, this will usually be a number between 1 and 9.', 'wordlift' ); ?></li>
52
+					<li><?php esc_html_e('Set the index to the index of the custom event you want to push this into at Google Analytics, this will usually be a number between 1 and 9.', 'wordlift'); ?></li>
53 53
 					<li>
54 54
 						<?php
55 55
 						printf(
56
-							esc_html__( 'Set the values of each one to the %1$s and the %2$s respectively.', 'wordlift' ),
56
+							esc_html__('Set the values of each one to the %1$s and the %2$s respectively.', 'wordlift'),
57 57
 							'<i>wl_index_uri</i> - <i>wl_event_uri</i>',
58 58
 							'<i>wl_index_type</i> - <i>wl_event_type</i>'
59 59
 						);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 			<li>
65 65
 				<?php
66 66
 				printf(
67
-					esc_html__( 'Go to the %1$s menu and create a new trigger of the type: %2$s.', 'wordlift' ),
67
+					esc_html__('Go to the %1$s menu and create a new trigger of the type: %2$s.', 'wordlift'),
68 68
 					'<b>Triggers</b>',
69 69
 					'<i>Custom Event</i>'
70 70
 				);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 
75 75
 						<?php
76 76
 						printf(
77
-							esc_html__( 'In the %1$s field input %2$s.', 'wordlift' ),
77
+							esc_html__('In the %1$s field input %2$s.', 'wordlift'),
78 78
 							'<i>Event name</i>',
79 79
 							'<i>Mentions</i>'
80 80
 						);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 						<?php
86 86
 						printf(
87
-							esc_html__( 'Set this to fire on %1$s and in the filter set:', 'wordlift' ),
87
+							esc_html__('Set this to fire on %1$s and in the filter set:', 'wordlift'),
88 88
 							'<i>Some Custom Events</i>'
89 89
 						);
90 90
 						?>
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			<li>
98 98
 				<?php
99 99
 				printf(
100
-					esc_html__( 'Go to the %1$s menu and create a new tag.', 'wordlift' ),
100
+					esc_html__('Go to the %1$s menu and create a new tag.', 'wordlift'),
101 101
 					'<b>Tags</b>'
102 102
 				);
103 103
 				?>
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
 						<?php
108 108
 						printf(
109
-							esc_html__( 'In the tag configuration section choose %1$s. Assuming you have used variable names that match those mentioned enter:', 'wordlift' ),
109
+							esc_html__('In the tag configuration section choose %1$s. Assuming you have used variable names that match those mentioned enter:', 'wordlift'),
110 110
 							'<i>Google Analytics - Universal Analytics</i>'
111 111
 						);
112 112
 						?>
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 							<li>
115 115
 								<?php
116 116
 								printf(
117
-									esc_html__( 'Set the %1$s to %2$s.', 'wordlift' ),
117
+									esc_html__('Set the %1$s to %2$s.', 'wordlift'),
118 118
 									'Track Type',
119 119
 									'<i>Event</i>'
120 120
 								);
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 							<li>
124 124
 								<?php
125 125
 								printf(
126
-									esc_html__( 'Set Category to %1$s.', 'wordlift' ),
126
+									esc_html__('Set Category to %1$s.', 'wordlift'),
127 127
 									'<i>{{wl_event_category}}</i>'
128 128
 								);
129 129
 								?>
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 							<li>
132 132
 								<?php
133 133
 								printf(
134
-									esc_html__( 'Set Action to %1$s.', 'wordlift' ),
134
+									esc_html__('Set Action to %1$s.', 'wordlift'),
135 135
 									'<i>{{wl_event_action}}</i>'
136 136
 								);
137 137
 								?>
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 							<li>
140 140
 								<?php
141 141
 								printf(
142
-									esc_html__( 'Set Label to %1$s.', 'wordlift' ),
142
+									esc_html__('Set Label to %1$s.', 'wordlift'),
143 143
 									'<i>{{wl_event_label}}</i>'
144 144
 								);
145 145
 								?>
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 							<li>
148 148
 								<?php
149 149
 								printf(
150
-									esc_html__( 'Set Value to %1$s.', 'wordlift' ),
150
+									esc_html__('Set Value to %1$s.', 'wordlift'),
151 151
 									'<i>{{wl_event_value}}</i>'
152 152
 								);
153 153
 								?>
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 							<li>
156 156
 								<?php
157 157
 								printf(
158
-									esc_html__( 'Set Non-Interaction Hit to %1$s.', 'wordlift' ),
158
+									esc_html__('Set Non-Interaction Hit to %1$s.', 'wordlift'),
159 159
 									'<i>True</i>'
160 160
 								);
161 161
 								?>
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 							<li>
164 164
 								<?php
165 165
 								printf(
166
-									esc_html__( 'Set the %1$s dropdown to the settings object for the Google Analytics tracking.', 'wordlift' ),
166
+									esc_html__('Set the %1$s dropdown to the settings object for the Google Analytics tracking.', 'wordlift'),
167 167
 									'<i>Google Analytics Settings</i>'
168 168
 								);
169 169
 								?>
170 170
 							</li>
171 171
 						</ol>
172 172
 					</li>
173
-					<li><?php esc_html_e( 'In the triggering tag select the firing trigger you created previously.', 'wordlift' ); ?></li>
173
+					<li><?php esc_html_e('In the triggering tag select the firing trigger you created previously.', 'wordlift'); ?></li>
174 174
 				</ol>
175 175
 			</li>
176 176
 		</ol>
Please login to merge, or discard this patch.
src/public/class-wordlift-sharethis-service.php 2 patches
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -17,116 +17,116 @@
 block discarded – undo
17 17
  */
18 18
 class Wordlift_ShareThis_Service {
19 19
 
20
-	/**
21
-	 * The ShareThis function which prints the buttons.
22
-	 *
23
-	 * @since 3.2.0
24
-	 */
25
-	const ADD_WIDGET_FUNCTION_NAME = 'st_add_widget';
26
-
27
-	/**
28
-	 * The Log service.
29
-	 *
30
-	 * @since  3.2.0
31
-	 * @access private
32
-	 * @var \Wordlift_Log_Service $log_service The Log service.
33
-	 */
34
-	private $log_service;
35
-
36
-	/**
37
-	 * Create an instance of the ShareThis service.
38
-	 *
39
-	 * @since 3.2.0
40
-	 */
41
-	public function __construct() {
42
-
43
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_ShareThis_Service' );
44
-
45
-	}
46
-
47
-	/**
48
-	 * Receive <em>the_content</em> filter calls from WordPress.
49
-	 *
50
-	 * @since 3.2.0
51
-	 *
52
-	 * @param string $content The post content.
53
-	 *
54
-	 * @return string The updated post content.
55
-	 */
56
-	public function the_content( $content ) {
57
-
58
-		return $this->call_sharethis( 'the_content', $content );
59
-	}
60
-
61
-	/**
62
-	 * Receive <em>the_excerpt</em> filter calls from WordPress.
63
-	 *
64
-	 * @since 3.2.0
65
-	 *
66
-	 * @param string $content The post excerpt.
67
-	 *
68
-	 * @return string The updated post excerpt.
69
-	 */
70
-	public function the_excerpt( $content ) {
71
-
72
-		return $this->call_sharethis( 'the_excerpt', $content );
73
-	}
74
-
75
-	/**
76
-	 * Call the ShareThis function.
77
-	 *
78
-	 * @since 3.2.0
79
-	 *
80
-	 * @param string $tag The filter tag.
81
-	 * @param string $content The post content.
82
-	 *
83
-	 * @return string The updated post content.
84
-	 */
85
-	private function call_sharethis( $tag, $content ) {
86
-
87
-		// Get the current post.
88
-		global $post;
89
-
90
-		// Bail out if the global $post instance isn't set.
91
-		if ( !isset( $post ) ) {
92
-			return $content;
93
-		}
94
-
95
-		// Bail out if the current entity is a post/page since this is already handled by ShareThis.
96
-		//
97
-		// See https://github.com/insideout10/wordlift-plugin/issues/819
98
-		if ( 'post' === $post->post_type || 'page' === $post->post_type ) {
99
-			return $content;
100
-		}
101
-
102
-		// If it's not the entity type, return.
103
-		$entity_service = Wordlift_Entity_Service::get_instance();
104
-		if ( null === $post || ! $entity_service->is_entity( get_the_ID() ) ) {
105
-			return $content;
106
-		}
107
-
108
-		// If the ShareThis function doesn't exist, return.
109
-		if ( ! function_exists( self::ADD_WIDGET_FUNCTION_NAME ) ) {
110
-			return $content;
111
-		}
112
-
113
-		// If ShareThis hasn't been added as a filter, return.
114
-		if ( ! has_filter( $tag, self::ADD_WIDGET_FUNCTION_NAME ) ) {
115
-			return $content;
116
-		}
117
-
118
-		// Temporary pop the post type and replace it with post.
119
-		$post_type       = $post->post_type;
120
-		$post->post_type = 'post';
121
-
122
-		// Call ShareThis (disguised as a post).
123
-		$content = call_user_func_array( self::ADD_WIDGET_FUNCTION_NAME, array( $content ) );
124
-
125
-		// Restore our post type.
126
-		$post->post_type = $post_type;
127
-
128
-		// Finally return the content.
129
-		return $content;
130
-	}
20
+    /**
21
+     * The ShareThis function which prints the buttons.
22
+     *
23
+     * @since 3.2.0
24
+     */
25
+    const ADD_WIDGET_FUNCTION_NAME = 'st_add_widget';
26
+
27
+    /**
28
+     * The Log service.
29
+     *
30
+     * @since  3.2.0
31
+     * @access private
32
+     * @var \Wordlift_Log_Service $log_service The Log service.
33
+     */
34
+    private $log_service;
35
+
36
+    /**
37
+     * Create an instance of the ShareThis service.
38
+     *
39
+     * @since 3.2.0
40
+     */
41
+    public function __construct() {
42
+
43
+        $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_ShareThis_Service' );
44
+
45
+    }
46
+
47
+    /**
48
+     * Receive <em>the_content</em> filter calls from WordPress.
49
+     *
50
+     * @since 3.2.0
51
+     *
52
+     * @param string $content The post content.
53
+     *
54
+     * @return string The updated post content.
55
+     */
56
+    public function the_content( $content ) {
57
+
58
+        return $this->call_sharethis( 'the_content', $content );
59
+    }
60
+
61
+    /**
62
+     * Receive <em>the_excerpt</em> filter calls from WordPress.
63
+     *
64
+     * @since 3.2.0
65
+     *
66
+     * @param string $content The post excerpt.
67
+     *
68
+     * @return string The updated post excerpt.
69
+     */
70
+    public function the_excerpt( $content ) {
71
+
72
+        return $this->call_sharethis( 'the_excerpt', $content );
73
+    }
74
+
75
+    /**
76
+     * Call the ShareThis function.
77
+     *
78
+     * @since 3.2.0
79
+     *
80
+     * @param string $tag The filter tag.
81
+     * @param string $content The post content.
82
+     *
83
+     * @return string The updated post content.
84
+     */
85
+    private function call_sharethis( $tag, $content ) {
86
+
87
+        // Get the current post.
88
+        global $post;
89
+
90
+        // Bail out if the global $post instance isn't set.
91
+        if ( !isset( $post ) ) {
92
+            return $content;
93
+        }
94
+
95
+        // Bail out if the current entity is a post/page since this is already handled by ShareThis.
96
+        //
97
+        // See https://github.com/insideout10/wordlift-plugin/issues/819
98
+        if ( 'post' === $post->post_type || 'page' === $post->post_type ) {
99
+            return $content;
100
+        }
101
+
102
+        // If it's not the entity type, return.
103
+        $entity_service = Wordlift_Entity_Service::get_instance();
104
+        if ( null === $post || ! $entity_service->is_entity( get_the_ID() ) ) {
105
+            return $content;
106
+        }
107
+
108
+        // If the ShareThis function doesn't exist, return.
109
+        if ( ! function_exists( self::ADD_WIDGET_FUNCTION_NAME ) ) {
110
+            return $content;
111
+        }
112
+
113
+        // If ShareThis hasn't been added as a filter, return.
114
+        if ( ! has_filter( $tag, self::ADD_WIDGET_FUNCTION_NAME ) ) {
115
+            return $content;
116
+        }
117
+
118
+        // Temporary pop the post type and replace it with post.
119
+        $post_type       = $post->post_type;
120
+        $post->post_type = 'post';
121
+
122
+        // Call ShareThis (disguised as a post).
123
+        $content = call_user_func_array( self::ADD_WIDGET_FUNCTION_NAME, array( $content ) );
124
+
125
+        // Restore our post type.
126
+        $post->post_type = $post_type;
127
+
128
+        // Finally return the content.
129
+        return $content;
130
+    }
131 131
 
132 132
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function __construct() {
42 42
 
43
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_ShareThis_Service' );
43
+		$this->log_service = Wordlift_Log_Service::get_logger('Wordlift_ShareThis_Service');
44 44
 
45 45
 	}
46 46
 
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return string The updated post content.
55 55
 	 */
56
-	public function the_content( $content ) {
56
+	public function the_content($content) {
57 57
 
58
-		return $this->call_sharethis( 'the_content', $content );
58
+		return $this->call_sharethis('the_content', $content);
59 59
 	}
60 60
 
61 61
 	/**
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @return string The updated post excerpt.
69 69
 	 */
70
-	public function the_excerpt( $content ) {
70
+	public function the_excerpt($content) {
71 71
 
72
-		return $this->call_sharethis( 'the_excerpt', $content );
72
+		return $this->call_sharethis('the_excerpt', $content);
73 73
 	}
74 74
 
75 75
 	/**
@@ -82,36 +82,36 @@  discard block
 block discarded – undo
82 82
 	 *
83 83
 	 * @return string The updated post content.
84 84
 	 */
85
-	private function call_sharethis( $tag, $content ) {
85
+	private function call_sharethis($tag, $content) {
86 86
 
87 87
 		// Get the current post.
88 88
 		global $post;
89 89
 
90 90
 		// Bail out if the global $post instance isn't set.
91
-		if ( !isset( $post ) ) {
91
+		if ( ! isset($post)) {
92 92
 			return $content;
93 93
 		}
94 94
 
95 95
 		// Bail out if the current entity is a post/page since this is already handled by ShareThis.
96 96
 		//
97 97
 		// See https://github.com/insideout10/wordlift-plugin/issues/819
98
-		if ( 'post' === $post->post_type || 'page' === $post->post_type ) {
98
+		if ('post' === $post->post_type || 'page' === $post->post_type) {
99 99
 			return $content;
100 100
 		}
101 101
 
102 102
 		// If it's not the entity type, return.
103 103
 		$entity_service = Wordlift_Entity_Service::get_instance();
104
-		if ( null === $post || ! $entity_service->is_entity( get_the_ID() ) ) {
104
+		if (null === $post || ! $entity_service->is_entity(get_the_ID())) {
105 105
 			return $content;
106 106
 		}
107 107
 
108 108
 		// If the ShareThis function doesn't exist, return.
109
-		if ( ! function_exists( self::ADD_WIDGET_FUNCTION_NAME ) ) {
109
+		if ( ! function_exists(self::ADD_WIDGET_FUNCTION_NAME)) {
110 110
 			return $content;
111 111
 		}
112 112
 
113 113
 		// If ShareThis hasn't been added as a filter, return.
114
-		if ( ! has_filter( $tag, self::ADD_WIDGET_FUNCTION_NAME ) ) {
114
+		if ( ! has_filter($tag, self::ADD_WIDGET_FUNCTION_NAME)) {
115 115
 			return $content;
116 116
 		}
117 117
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$post->post_type = 'post';
121 121
 
122 122
 		// Call ShareThis (disguised as a post).
123
-		$content = call_user_func_array( self::ADD_WIDGET_FUNCTION_NAME, array( $content ) );
123
+		$content = call_user_func_array(self::ADD_WIDGET_FUNCTION_NAME, array($content));
124 124
 
125 125
 		// Restore our post type.
126 126
 		$post->post_type = $post_type;
Please login to merge, or discard this patch.
src/admin/partials/wordlift-admin-deactivation-feedback-popup.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -1,62 +1,62 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 $too_complicate_reason_label = sprintf(
3
-	'<a target="_blank" href="%s">%s</a>',
4
-	/* translators: the link https://wordlift.io/contact-us/ should be changed to language version of the page */
5
-	esc_attr__( 'https://wordlift.io/contact-us/', 'wordlift' ),
6
-	esc_html__( 'Contact Us', 'wordlift' )
3
+    '<a target="_blank" href="%s">%s</a>',
4
+    /* translators: the link https://wordlift.io/contact-us/ should be changed to language version of the page */
5
+    esc_attr__( 'https://wordlift.io/contact-us/', 'wordlift' ),
6
+    esc_html__( 'Contact Us', 'wordlift' )
7 7
 );
8 8
 
9 9
 $reasons = array(
10
-	array(
11
-		'id'      => 'TOO_COMPLICATED',
12
-		'text'    => esc_html__( 'It was too complicated and unclear to me', 'wordlift' ),
13
-		'message' => array(
14
-			'text' => sprintf(
15
-				esc_html__( 'Need help? We are ready to answer your questions. %s', 'wordlift' ),
16
-				$too_complicate_reason_label
17
-			),
18
-		),
19
-	),
20
-	array(
21
-		'id'      => 'NOT_ENOUGH_FEATURES',
22
-		'text'    => esc_html__( 'It misses some important feature to me', 'wordlift' ),
23
-		'message' => array(
24
-			'field' => 'text',
25
-			'text'  => esc_html__( 'Tell us what this feature is.', 'wordlift' ),
26
-		),
27
-	),
28
-	array(
29
-		'id'      => 'COSTS_TOO_MUCH',
30
-		'text'    => esc_html__( 'It costs too much', 'wordlift' ),
31
-		'message' => array(
32
-			'field' => 'text',
33
-			'text'  => esc_html__( 'How much you would like to pay?', 'wordlift' ),
34
-		),
35
-	),
36
-	array(
37
-		'id'      => 'FOUND_ANOTHER_TOOL',
38
-		'text'    => esc_html__( 'I found another tool that I like better', 'wordlift' ),
39
-		'message' => array(
40
-			'field' => 'text',
41
-			'text'  => esc_html__( 'Please tell us some more details.', 'wordlift' ),
42
-		),
43
-	),
44
-	array(
45
-		'id'   => 'I_DONT_USE_IT',
46
-		'text' => esc_html__( 'I\'m not using it right now', 'wordlift' ),
47
-	),
48
-	array(
49
-		'id'   => 'SOMETHING_DIDNT_WORK',
50
-		'text' => esc_html__( 'Something didn\'t work right', 'wordlift' ),
51
-	),
52
-	array(
53
-		'id'      => 'ANOTHER_REASON',
54
-		'text'    => esc_html__( 'Another reason', 'wordlift' ),
55
-		'message' => array(
56
-			'field' => 'textarea',
57
-			'text'  => esc_html__( 'Please tell us the reason so we can improve it.', 'wordlift' ),
58
-		),
59
-	),
10
+    array(
11
+        'id'      => 'TOO_COMPLICATED',
12
+        'text'    => esc_html__( 'It was too complicated and unclear to me', 'wordlift' ),
13
+        'message' => array(
14
+            'text' => sprintf(
15
+                esc_html__( 'Need help? We are ready to answer your questions. %s', 'wordlift' ),
16
+                $too_complicate_reason_label
17
+            ),
18
+        ),
19
+    ),
20
+    array(
21
+        'id'      => 'NOT_ENOUGH_FEATURES',
22
+        'text'    => esc_html__( 'It misses some important feature to me', 'wordlift' ),
23
+        'message' => array(
24
+            'field' => 'text',
25
+            'text'  => esc_html__( 'Tell us what this feature is.', 'wordlift' ),
26
+        ),
27
+    ),
28
+    array(
29
+        'id'      => 'COSTS_TOO_MUCH',
30
+        'text'    => esc_html__( 'It costs too much', 'wordlift' ),
31
+        'message' => array(
32
+            'field' => 'text',
33
+            'text'  => esc_html__( 'How much you would like to pay?', 'wordlift' ),
34
+        ),
35
+    ),
36
+    array(
37
+        'id'      => 'FOUND_ANOTHER_TOOL',
38
+        'text'    => esc_html__( 'I found another tool that I like better', 'wordlift' ),
39
+        'message' => array(
40
+            'field' => 'text',
41
+            'text'  => esc_html__( 'Please tell us some more details.', 'wordlift' ),
42
+        ),
43
+    ),
44
+    array(
45
+        'id'   => 'I_DONT_USE_IT',
46
+        'text' => esc_html__( 'I\'m not using it right now', 'wordlift' ),
47
+    ),
48
+    array(
49
+        'id'   => 'SOMETHING_DIDNT_WORK',
50
+        'text' => esc_html__( 'Something didn\'t work right', 'wordlift' ),
51
+    ),
52
+    array(
53
+        'id'      => 'ANOTHER_REASON',
54
+        'text'    => esc_html__( 'Another reason', 'wordlift' ),
55
+        'message' => array(
56
+            'field' => 'textarea',
57
+            'text'  => esc_html__( 'Please tell us the reason so we can improve it.', 'wordlift' ),
58
+        ),
59
+    ),
60 60
 );
61 61
 ?>
62 62
 <div class="wl-modal-deactivation-feedback" style="display: none">
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
 							<?php if ( ! empty( $reason['message'] ) ) : ?>
92 92
 								<div class="additional-info <?php echo ( ! empty( $reason['message']['field'] ) ) ? 'has-field' : ''; ?>">
93 93
 									<?php
94
-									if ( ! empty( $reason['message']['field'] ) ) {
95
-										if ( $reason['message']['field'] === 'text' ) {
96
-											echo '<input type="text" name="wl-details" class="wl-details"/>';
97
-										} else {
98
-											echo '<textarea name="wl-details" class="wl-details"></textarea>';
99
-										}
100
-									}
101
-									echo wpautop( $reason['message']['text'] )
102
-									?>
94
+                                    if ( ! empty( $reason['message']['field'] ) ) {
95
+                                        if ( $reason['message']['field'] === 'text' ) {
96
+                                            echo '<input type="text" name="wl-details" class="wl-details"/>';
97
+                                        } else {
98
+                                            echo '<textarea name="wl-details" class="wl-details"></textarea>';
99
+                                        }
100
+                                    }
101
+                                    echo wpautop( $reason['message']['text'] )
102
+                                    ?>
103 103
 								</div>
104 104
 							<?php endif ?>
105 105
 						</li>
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 			<div class="notes">
111 111
 				<p>
112 112
 					<?php
113
-					printf(
114
-						__( 'Important notice: Uninstalling the plugin will delete your vocabulary.<br>Maybe you would like to <a href="%s" target="_blank">download your data</a> first.', 'wordlift' ),
115
-						add_query_arg( array( 'page' => 'wl_download_your_data' ), admin_url( 'admin.php' ) )
116
-					);
117
-					?>
113
+                    printf(
114
+                        __( 'Important notice: Uninstalling the plugin will delete your vocabulary.<br>Maybe you would like to <a href="%s" target="_blank">download your data</a> first.', 'wordlift' ),
115
+                        add_query_arg( array( 'page' => 'wl_download_your_data' ), admin_url( 'admin.php' ) )
116
+                    );
117
+                    ?>
118 118
 				</p>
119 119
 			</div>
120 120
 
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -2,59 +2,59 @@  discard block
 block discarded – undo
2 2
 $too_complicate_reason_label = sprintf(
3 3
 	'<a target="_blank" href="%s">%s</a>',
4 4
 	/* translators: the link https://wordlift.io/contact-us/ should be changed to language version of the page */
5
-	esc_attr__( 'https://wordlift.io/contact-us/', 'wordlift' ),
6
-	esc_html__( 'Contact Us', 'wordlift' )
5
+	esc_attr__('https://wordlift.io/contact-us/', 'wordlift'),
6
+	esc_html__('Contact Us', 'wordlift')
7 7
 );
8 8
 
9 9
 $reasons = array(
10 10
 	array(
11 11
 		'id'      => 'TOO_COMPLICATED',
12
-		'text'    => esc_html__( 'It was too complicated and unclear to me', 'wordlift' ),
12
+		'text'    => esc_html__('It was too complicated and unclear to me', 'wordlift'),
13 13
 		'message' => array(
14 14
 			'text' => sprintf(
15
-				esc_html__( 'Need help? We are ready to answer your questions. %s', 'wordlift' ),
15
+				esc_html__('Need help? We are ready to answer your questions. %s', 'wordlift'),
16 16
 				$too_complicate_reason_label
17 17
 			),
18 18
 		),
19 19
 	),
20 20
 	array(
21 21
 		'id'      => 'NOT_ENOUGH_FEATURES',
22
-		'text'    => esc_html__( 'It misses some important feature to me', 'wordlift' ),
22
+		'text'    => esc_html__('It misses some important feature to me', 'wordlift'),
23 23
 		'message' => array(
24 24
 			'field' => 'text',
25
-			'text'  => esc_html__( 'Tell us what this feature is.', 'wordlift' ),
25
+			'text'  => esc_html__('Tell us what this feature is.', 'wordlift'),
26 26
 		),
27 27
 	),
28 28
 	array(
29 29
 		'id'      => 'COSTS_TOO_MUCH',
30
-		'text'    => esc_html__( 'It costs too much', 'wordlift' ),
30
+		'text'    => esc_html__('It costs too much', 'wordlift'),
31 31
 		'message' => array(
32 32
 			'field' => 'text',
33
-			'text'  => esc_html__( 'How much you would like to pay?', 'wordlift' ),
33
+			'text'  => esc_html__('How much you would like to pay?', 'wordlift'),
34 34
 		),
35 35
 	),
36 36
 	array(
37 37
 		'id'      => 'FOUND_ANOTHER_TOOL',
38
-		'text'    => esc_html__( 'I found another tool that I like better', 'wordlift' ),
38
+		'text'    => esc_html__('I found another tool that I like better', 'wordlift'),
39 39
 		'message' => array(
40 40
 			'field' => 'text',
41
-			'text'  => esc_html__( 'Please tell us some more details.', 'wordlift' ),
41
+			'text'  => esc_html__('Please tell us some more details.', 'wordlift'),
42 42
 		),
43 43
 	),
44 44
 	array(
45 45
 		'id'   => 'I_DONT_USE_IT',
46
-		'text' => esc_html__( 'I\'m not using it right now', 'wordlift' ),
46
+		'text' => esc_html__('I\'m not using it right now', 'wordlift'),
47 47
 	),
48 48
 	array(
49 49
 		'id'   => 'SOMETHING_DIDNT_WORK',
50
-		'text' => esc_html__( 'Something didn\'t work right', 'wordlift' ),
50
+		'text' => esc_html__('Something didn\'t work right', 'wordlift'),
51 51
 	),
52 52
 	array(
53 53
 		'id'      => 'ANOTHER_REASON',
54
-		'text'    => esc_html__( 'Another reason', 'wordlift' ),
54
+		'text'    => esc_html__('Another reason', 'wordlift'),
55 55
 		'message' => array(
56 56
 			'field' => 'textarea',
57
-			'text'  => esc_html__( 'Please tell us the reason so we can improve it.', 'wordlift' ),
57
+			'text'  => esc_html__('Please tell us the reason so we can improve it.', 'wordlift'),
58 58
 		),
59 59
 	),
60 60
 );
@@ -63,42 +63,42 @@  discard block
 block discarded – undo
63 63
 	<div class="wl-modal">
64 64
 		<div class="wl-modal-body">
65 65
 			<h2>
66
-				<?php _e( 'We\'re sorry to see you go!', 'wordlift' ); ?>
66
+				<?php _e('We\'re sorry to see you go!', 'wordlift'); ?>
67 67
 			</h2>
68 68
 
69 69
 			<div class="wl-modal-panel active">
70 70
 				<h4>
71
-					<?php _e( 'If you have a moment, please let us know why you are deactivating', 'wordlift' ); ?>:
71
+					<?php _e('If you have a moment, please let us know why you are deactivating', 'wordlift'); ?>:
72 72
 				</h4>
73 73
 
74 74
 				<ul>
75
-					<?php foreach ( $reasons as $reason ) : ?>
76
-						<li class="wl-reason-item <?php echo ( $reason['id'] == 'I_DONT_USE_IT' ) ? 'selected' : ''; ?>">
75
+					<?php foreach ($reasons as $reason) : ?>
76
+						<li class="wl-reason-item <?php echo ($reason['id'] == 'I_DONT_USE_IT') ? 'selected' : ''; ?>">
77 77
 							<label>
78 78
 								<input
79 79
 									type="radio"
80 80
 									name="wl-code"
81 81
 									class="wl-code"
82
-									<?php checked( 'I_DONT_USE_IT', $reason['id'], true ); ?>
83
-									value="<?php echo esc_attr( $reason['id'] ); ?>"
82
+									<?php checked('I_DONT_USE_IT', $reason['id'], true); ?>
83
+									value="<?php echo esc_attr($reason['id']); ?>"
84 84
 								/>
85 85
 
86 86
 								<span class="description">
87
-									<?php echo esc_html( $reason['text'] ); ?>
87
+									<?php echo esc_html($reason['text']); ?>
88 88
 								</span>
89 89
 							</label>
90 90
 
91
-							<?php if ( ! empty( $reason['message'] ) ) : ?>
92
-								<div class="additional-info <?php echo ( ! empty( $reason['message']['field'] ) ) ? 'has-field' : ''; ?>">
91
+							<?php if ( ! empty($reason['message'])) : ?>
92
+								<div class="additional-info <?php echo ( ! empty($reason['message']['field'])) ? 'has-field' : ''; ?>">
93 93
 									<?php
94
-									if ( ! empty( $reason['message']['field'] ) ) {
95
-										if ( $reason['message']['field'] === 'text' ) {
94
+									if ( ! empty($reason['message']['field'])) {
95
+										if ($reason['message']['field'] === 'text') {
96 96
 											echo '<input type="text" name="wl-details" class="wl-details"/>';
97 97
 										} else {
98 98
 											echo '<textarea name="wl-details" class="wl-details"></textarea>';
99 99
 										}
100 100
 									}
101
-									echo wpautop( $reason['message']['text'] )
101
+									echo wpautop($reason['message']['text'])
102 102
 									?>
103 103
 								</div>
104 104
 							<?php endif ?>
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 				<p>
112 112
 					<?php
113 113
 					printf(
114
-						__( 'Important notice: Uninstalling the plugin will delete your vocabulary.<br>Maybe you would like to <a href="%s" target="_blank">download your data</a> first.', 'wordlift' ),
115
-						add_query_arg( array( 'page' => 'wl_download_your_data' ), admin_url( 'admin.php' ) )
114
+						__('Important notice: Uninstalling the plugin will delete your vocabulary.<br>Maybe you would like to <a href="%s" target="_blank">download your data</a> first.', 'wordlift'),
115
+						add_query_arg(array('page' => 'wl_download_your_data'), admin_url('admin.php'))
116 116
 					);
117 117
 					?>
118 118
 				</p>
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 
124 124
 		<div class="wl-modal-footer">
125 125
 			<a href="#" class="button button-secondary wl-modal-button-close">
126
-				<?php esc_html_e( 'Cancel', 'wordlift' ); ?>
126
+				<?php esc_html_e('Cancel', 'wordlift'); ?>
127 127
 			</a>
128 128
 
129 129
 			<a href="#" class="button button-primary wl-modal-button-deactivate">
130
-				<?php esc_html_e( 'Deactivate', 'wordlift' ); ?>
130
+				<?php esc_html_e('Deactivate', 'wordlift'); ?>
131 131
 			</a>
132 132
 			<div class="clear"></div>
133 133
 		</div>
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 			type="hidden"
137 137
 			name="wl_deactivation_feedback_nonce"
138 138
 			class="wl_deactivation_feedback_nonce"
139
-			value="<?php echo esc_attr( wp_create_nonce( 'wl_deactivation_feedback_nonce' ) ); ?>"
139
+			value="<?php echo esc_attr(wp_create_nonce('wl_deactivation_feedback_nonce')); ?>"
140 140
 		>
141 141
 	</div>
142 142
 </div>
Please login to merge, or discard this patch.
src/includes/class-wordlift-schema-service.php 2 patches
Indentation   +1682 added lines, -1682 removed lines patch added patch discarded remove patch
@@ -18,1687 +18,1687 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Schema_Service {
20 20
 
21
-	/**
22
-	 * The 'location created' field name.
23
-	 *
24
-	 * @since 3.5.0
25
-	 */
26
-	const FIELD_LOCATION_CREATED = 'wl_location_created';
27
-
28
-	/**
29
-	 * The 'topic' field name.
30
-	 *
31
-	 * @since 3.5.0
32
-	 */
33
-	const FIELD_TOPIC = 'wl_topic';
34
-
35
-	/**
36
-	 * The 'author' field name.
37
-	 *
38
-	 * @since 3.1.0
39
-	 */
40
-	const FIELD_AUTHOR = 'wl_author';
41
-
42
-	/**
43
-	 * The 'same as' field name.
44
-	 *
45
-	 * @since 3.1.0
46
-	 */
47
-	const FIELD_SAME_AS = 'entity_same_as';
48
-
49
-	/**
50
-	 * The 'date start' field name.
51
-	 *
52
-	 * @since 3.1.0
53
-	 */
54
-	const FIELD_DATE_START = 'wl_cal_date_start';
55
-
56
-	/**
57
-	 * The 'date end' field name.
58
-	 *
59
-	 * @since 3.1.0
60
-	 */
61
-	const FIELD_DATE_END = 'wl_cal_date_end';
62
-
63
-	/**
64
-	 * The 'location' field name.
65
-	 *
66
-	 * @since 3.1.0
67
-	 */
68
-	const FIELD_LOCATION = 'wl_location';
69
-
70
-	/**
71
-	 * The 'founder' field name.
72
-	 *
73
-	 * @since 3.1.0
74
-	 */
75
-	const FIELD_FOUNDER = 'wl_founder';
76
-
77
-	/**
78
-	 * The 'knows' field name.
79
-	 *
80
-	 * @since 3.1.0
81
-	 */
82
-	const FIELD_KNOWS = 'wl_knows';
83
-
84
-	/**
85
-	 * The 'birth date' field name.
86
-	 *
87
-	 * @since 3.1.0
88
-	 */
89
-	const FIELD_BIRTH_DATE = 'wl_birth_date';
90
-
91
-	/**
92
-	 * The 'birth place' field name.
93
-	 *
94
-	 * @since 3.1.0
95
-	 */
96
-	const FIELD_BIRTH_PLACE = 'wl_birth_place';
97
-
98
-	/**
99
-	 * The 'latitude' field name.
100
-	 *
101
-	 * @since 3.1.0
102
-	 */
103
-	const FIELD_GEO_LATITUDE = 'wl_geo_latitude';
104
-
105
-	/**
106
-	 * The 'longitude' field name.
107
-	 *
108
-	 * @since 3.1.0
109
-	 */
110
-	const FIELD_GEO_LONGITUDE = 'wl_geo_longitude';
111
-
112
-	/**
113
-	 * The 'streetAddress' field name.
114
-	 *
115
-	 * @since 3.1.0
116
-	 */
117
-	const FIELD_ADDRESS = 'wl_address';
118
-
119
-	/**
120
-	 * The 'postOfficeBoxNumber' field name.
121
-	 *
122
-	 * @since 3.3.0
123
-	 */
124
-	const FIELD_ADDRESS_PO_BOX = 'wl_address_post_office_box';
125
-
126
-	/**
127
-	 * The 'postalCode' field name.
128
-	 *
129
-	 * @since 3.3.0
130
-	 */
131
-	const FIELD_ADDRESS_POSTAL_CODE = 'wl_address_postal_code';
132
-
133
-	/**
134
-	 * The 'addressLocality' field name.
135
-	 *
136
-	 * @since 3.3.0
137
-	 */
138
-	const FIELD_ADDRESS_LOCALITY = 'wl_address_locality';
139
-	/**
140
-	 * The 'addressRegion' field name.
141
-	 *
142
-	 * @since 3.3.0
143
-	 */
144
-	const FIELD_ADDRESS_REGION = 'wl_address_region';
145
-
146
-	/**
147
-	 * The 'addressCountry' field name.
148
-	 *
149
-	 * @since 3.3.0
150
-	 */
151
-	const FIELD_ADDRESS_COUNTRY = 'wl_address_country';
152
-
153
-	/**
154
-	 * The 'entity type' field name.
155
-	 *
156
-	 * @since 3.1.0
157
-	 */
158
-	const FIELD_ENTITY_TYPE = 'wl_entity_type_uri';
159
-
160
-	/**
161
-	 * The 'email' field name.
162
-	 *
163
-	 * @since 3.2.0
164
-	 */
165
-	const FIELD_EMAIL = 'wl_email';
166
-
167
-	/**
168
-	 * The 'affiliation' field name.
169
-	 *
170
-	 * @since 3.2.0
171
-	 */
172
-	const FIELD_AFFILIATION = 'wl_affiliation';
173
-
174
-	/**
175
-	 * The 'telephone' field name.
176
-	 *
177
-	 * @since 3.8.0
178
-	 */
179
-	const FIELD_TELEPHONE = 'wl_schema_telephone';
180
-
181
-	/**
182
-	 * The 'legalName' field name.
183
-	 *
184
-	 * @since 3.12.0
185
-	 */
186
-	const FIELD_LEGAL_NAME = 'wl_schema_legal_name';
187
-
188
-	/**
189
-	 * The 'recipeCuisine' field name.
190
-	 *
191
-	 * @since 3.14.0
192
-	 */
193
-	const FIELD_RECIPE_CUISINE = 'wl_schema_recipe_cuisine';
194
-
195
-	/**
196
-	 * The 'recipeIngredient' field name.
197
-	 *
198
-	 * @since 3.14.0
199
-	 */
200
-	const FIELD_RECIPE_INGREDIENT = 'wl_schema_recipe_ingredient';
201
-
202
-	/**
203
-	 * The 'calories' field name.
204
-	 *
205
-	 * @since 3.14.0
206
-	 */
207
-	const FIELD_NUTRITION_INFO_CALORIES = 'wl_schema_nutrition_information_calories';
208
-
209
-	/**
210
-	 * The 'recipeInstructions' field name.
211
-	 *
212
-	 * @since 3.14.0
213
-	 */
214
-	const FIELD_RECIPE_INSTRUCTIONS = 'wl_schema_recipe_instructions';
215
-
216
-	/**
217
-	 * The 'recipeYield' field name.
218
-	 *
219
-	 * @since 3.14.0
220
-	 */
221
-	const FIELD_RECIPE_YIELD = 'wl_schema_recipe_yield';
222
-
223
-	/**
224
-	 * The 'prepTime' field name.
225
-	 *
226
-	 * @since 3.14.0
227
-	 */
228
-	const FIELD_PREP_TIME = 'wl_schema_prep_time';
229
-
230
-	/**
231
-	 * The 'cookTime' field name.
232
-	 *
233
-	 * @since 3.14.0
234
-	 */
235
-	const FIELD_COOK_TIME = 'wl_schema_cook_time';
236
-
237
-	/**
238
-	 * The 'totalTime' field name.
239
-	 *
240
-	 * @since 3.14.0
241
-	 */
242
-	const FIELD_TOTAL_TIME = 'wl_schema_total_time';
243
-
244
-	/**
245
-	 * The 'performer' field name.
246
-	 *
247
-	 * @since 3.18.0
248
-	 */
249
-	const FIELD_PERFORMER = 'wl_schema_performer';
250
-
251
-	/**
252
-	 * The 'offers' field name.
253
-	 *
254
-	 * @since 3.18.0
255
-	 */
256
-	const FIELD_OFFERS = 'wl_schema_offers';
257
-
258
-	/**
259
-	 * The 'availablity' field name.
260
-	 *
261
-	 * @since 3.18.0
262
-	 */
263
-	const FIELD_AVAILABILITY = 'wl_schema_availability';
264
-
265
-	/**
266
-	 * The 'inventoryLevel' field name.
267
-	 *
268
-	 * @since 3.18.0
269
-	 */
270
-	const FIELD_INVENTORY_LEVEL = 'wl_schema_inventory_level';
271
-
272
-	/**
273
-	 * The 'price' field name.
274
-	 *
275
-	 * @since 3.18.0
276
-	 */
277
-	const FIELD_PRICE = 'wl_schema_price';
278
-
279
-	/**
280
-	 * The 'priceCurrency' field name.
281
-	 *
282
-	 * @since 3.18.0
283
-	 */
284
-	const FIELD_PRICE_CURRENCY = 'wl_schema_price_currency';
285
-
286
-	/**
287
-	 * The 'availabilityStarts' field name.
288
-	 *
289
-	 * @since 3.18.0
290
-	 */
291
-	const FIELD_AVAILABILITY_STARTS = 'wl_schema_availability_starts';
292
-
293
-	/**
294
-	 * The 'availabilityEnds' field name.
295
-	 *
296
-	 * @since 3.18.0
297
-	 */
298
-	const FIELD_AVAILABILITY_ENDS = 'wl_schema_availability_ends';
299
-
300
-	/**
301
-	 * The 'validFrom' field name.
302
-	 *
303
-	 * @since 3.18.0
304
-	 */
305
-	const FIELD_VALID_FROM = 'wl_schema_valid_from';
306
-
307
-	/**
308
-	 * The 'priceValidUntil' field name.
309
-	 *
310
-	 * @since 3.18.0
311
-	 */
312
-	const FIELD_PRICE_VALID_UNTIL = 'wl_schema_valid_until';
313
-
314
-	/**
315
-	 * The 'itemOffered' field name.
316
-	 *
317
-	 * @since 3.18.0
318
-	 */
319
-	const FIELD_ITEM_OFFERED = 'wl_schema_item_offered';
320
-
321
-	/**
322
-	 * The 'URI' data type name.
323
-	 *
324
-	 * @since 3.1.0
325
-	 */
326
-	const DATA_TYPE_URI = 'uri';
327
-
328
-	/**
329
-	 * The 'date' data type name.
330
-	 *
331
-	 * @since 3.1.0
332
-	 */
333
-	const DATA_TYPE_DATE = 'date';
334
-
335
-	/**
336
-	 * The 'dateTime' data type name.
337
-	 *
338
-	 * @since 3.15.0
339
-	 */
340
-	const DATA_TYPE_DATE_TIME = 'dateTime';
341
-
342
-	/**
343
-	 * The 'time' data type name.
344
-	 *
345
-	 * @since 3.14.0
346
-	 */
347
-	const DATA_TYPE_DURATION = 'duration';
348
-
349
-	/**
350
-	 * The 'double' data type name.
351
-	 *
352
-	 * @since 3.1.0
353
-	 */
354
-	const DATA_TYPE_DOUBLE = 'double';
355
-
356
-	/**
357
-	 * The 'string' data type name.
358
-	 *
359
-	 * @since 3.1.0
360
-	 */
361
-	const DATA_TYPE_STRING = 'string';
362
-
363
-	/**
364
-	 * The multiline text data type name.
365
-	 *
366
-	 * @since 3.14.0
367
-	 */
368
-	const DATA_TYPE_MULTILINE = 'multiline';
369
-
370
-	/**
371
-	 * The 'integer' data type name.
372
-	 *
373
-	 * @since 3.1.0
374
-	 */
375
-	const DATA_TYPE_INTEGER = 'int';
376
-
377
-	/**
378
-	 * The 'boolean' data type name.
379
-	 *
380
-	 * @since 3.1.0
381
-	 */
382
-	const DATA_TYPE_BOOLEAN = 'bool';
383
-
384
-	/**
385
-	 * The schema.org Event type URI.
386
-	 *
387
-	 * @since 3.1.0
388
-	 */
389
-	const SCHEMA_EVENT_TYPE = 'http://schema.org/Event';
390
-
391
-	/**
392
-	 * The schema.org Offer type URI.
393
-	 *
394
-	 * @since 3.18.0
395
-	 */
396
-	const SCHEMA_OFFER_TYPE = 'http://schema.org/Offer';
397
-
398
-	/**
399
-	 * The Schema service singleton instance.
400
-	 *
401
-	 * @since  3.1.0
402
-	 * @access private
403
-	 * @var \Wordlift_Schema_Service $instance The Schema service singleton instance.
404
-	 */
405
-	private static $instance;
406
-
407
-	/**
408
-	 * WordLift's schema.
409
-	 *
410
-	 * @since  3.1.0
411
-	 * @access private
412
-	 * @var array $schema WordLift's schema.
413
-	 */
414
-	private $schema;
415
-
416
-	/**
417
-	 * The Log service.
418
-	 *
419
-	 * @since  3.1.0
420
-	 * @access private
421
-	 * @var \Wordlift_Log_Service $log The Log service.
422
-	 */
423
-	private $log;
424
-
425
-	/**
426
-	 * The {@link Wordlift_Post_Property_Storage_Factory} instance.
427
-	 *
428
-	 * @since  3.15.0
429
-	 * @access private
430
-	 * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Post_Property_Storage_Factory} instance.
431
-	 */
432
-	private $storage_factory;
433
-
434
-	/**
435
-	 * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
436
-	 *
437
-	 * @since  3.15.0
438
-	 * @access private
439
-	 * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
440
-	 */
441
-	private $rendition_factory;
442
-
443
-	/**
444
-	 * The {@link Wordlift_Configuration_Service} instance.
445
-	 *
446
-	 * @since  3.15.0
447
-	 * @access private
448
-	 * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
449
-	 */
450
-	private $configuration_service;
451
-
452
-	/**
453
-	 * The web site configured language code.
454
-	 *
455
-	 * @since  3.15.0
456
-	 * @access private
457
-	 * @var string $language_code The web site configured language code.
458
-	 */
459
-	private $language_code;
460
-
461
-	/**
462
-	 * Wordlift_Schema_Service constructor.
463
-	 *
464
-	 * @since 3.1.0
465
-	 *
466
-	 * @param \Wordlift_Storage_Factory                $storage_factory The {@link Wordlift_Post_Property_Storage_Factory} instance.
467
-	 * @param \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
468
-	 * @param \Wordlift_Configuration_Service          $configuration_service The {@link Wordlift_Configuration_Service} instance.
469
-	 */
470
-	public function __construct( $storage_factory, $rendition_factory, $configuration_service ) {
471
-
472
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Schema_Service' );
473
-
474
-		$this->storage_factory       = $storage_factory;
475
-		$this->rendition_factory     = $rendition_factory;
476
-		$this->configuration_service = $configuration_service;
477
-		$this->language_code         = $this->configuration_service->get_language_code();
478
-
479
-		$schemas = array(
480
-			'article'        => $this->get_article_schema(),
481
-			'thing'          => $this->get_thing_schema(),
482
-			'creative-work'  => $this->get_creative_work_schema(),
483
-			'event'          => $this->get_event_schema(),
484
-			'organization'   => $this->get_organization_schema(),
485
-			'person'         => $this->get_person_schema(),
486
-			'place'          => $this->get_place_schema(),
487
-			'local-business' => $this->get_local_business_schema(),
488
-			'recipe'         => $this->get_recipe_schema(),
489
-			'web-page'       => $this->get_web_page_schema(),
490
-			'offer'          => $this->get_offer_schema(),
491
-		);
492
-
493
-		// Set the taxonomy data.
494
-		// Note: parent types must be defined before child types.
495
-		/**
496
-		 * Alter the configured schemas.
497
-		 *
498
-		 * Enable 3rd parties to alter WordLift's schemas array.
499
-		 *
500
-		 * @since  3.19.1
501
-		 *
502
-		 * @param    array $schemas The array of schemas.
503
-		 */
504
-		$this->schema = apply_filters( 'wl_schemas', $schemas );
505
-
506
-		// Create a singleton instance of the Schema service, useful to provide static functions to global functions.
507
-		self::$instance = $this;
508
-
509
-		// Hook the `init` to allow plugins to add their schemas.
510
-		add_action( 'init', array( $this, 'init' ) );
511
-
512
-	}
513
-
514
-	/**
515
-	 * Hook to the `init`, allow late binding plugins to add their schema.
516
-	 *
517
-	 * @since 3.19.2
518
-	 */
519
-	public function init() {
520
-
521
-		$this->schema = apply_filters( 'wl_schemas_init', $this->schema );
522
-
523
-	}
524
-
525
-	/**
526
-	 * Get a reference to the Schema service.
527
-	 *
528
-	 * @since 3.1.0
529
-	 *
530
-	 * @return Wordlift_Schema_Service A reference to the Schema service.
531
-	 */
532
-	public static function get_instance() {
533
-
534
-		return self::$instance;
535
-	}
536
-
537
-	/**
538
-	 * Get the properties for a field with the specified key. The key is used as
539
-	 * meta key when the field's value is stored in WordPress meta data table.
540
-	 *
541
-	 * @since 3.6.0
542
-	 *
543
-	 * @param string $key The field's key.
544
-	 *
545
-	 * @return null|array An array of field's properties or null if the field is not found.
546
-	 */
547
-	public function get_field( $key ) {
548
-
549
-		// Parse each schema's fields until we find the one we're looking for, then
550
-		// return its properties.
551
-		foreach ( $this->schema as $_ => $schema ) {
552
-
553
-			if ( ! isset( $schema['custom_fields'] ) ) {
554
-				break;
555
-			}
556
-
557
-			foreach ( $schema['custom_fields'] as $field => $props ) {
558
-				if ( $key === $field ) {
559
-					return $props;
560
-				}
561
-			}
562
-		}
563
-
564
-		return null;
565
-	}
566
-
567
-	/**
568
-	 * Get all renditions for each WordLift's schema.
569
-	 *
570
-	 * @since 3.18.0
571
-	 *
572
-	 * @return array An array with the schema renditions.
573
-	 */
574
-	public function get_renditions() {
575
-		// Get the custom fields.
576
-		$renditions = array_reduce(
577
-			$this->schema,
578
-			function ( $carry, $item ) {
579
-				return array_merge( $carry, $item['linked_data'] );
580
-			},
581
-			array()
582
-		);
583
-
584
-		// Return the schemas.
585
-		return $renditions;
586
-	}
587
-
588
-	/**
589
-	 * Get the WordLift's schema.
590
-	 *
591
-	 * @param string $name The schema name.
592
-	 *
593
-	 * @return array|null An array with the schema configuration or NULL if the schema is not found.
594
-	 *
595
-	 * @since 3.1.0
596
-	 */
597
-	public function get_schema( $name ) {
598
-		// Check if the schema exists and, if not, return NULL.
599
-		if ( ! isset( $this->schema[ $name ] ) ) {
600
-			return null;
601
-		}
602
-
603
-		// Return the requested schema.
604
-		return $this->schema[ $name ];
605
-	}
606
-
607
-	/**
608
-	 * Get the WordLift's schema trough schema type uri.
609
-	 *
610
-	 * @param string $uri The schema uri.
611
-	 *
612
-	 * @return array|null An array with the schema configuration or NULL if the schema is not found.
613
-	 *
614
-	 * @since 3.3.0
615
-	 */
616
-	public function get_schema_by_uri( $uri ) {
617
-
618
-		foreach ( $this->schema as $name => $schema ) {
619
-			if ( $schema['uri'] === $uri ) {
620
-				return $schema;
621
-			}
622
-		}
623
-
624
-		return null;
625
-	}
626
-
627
-	/**
628
-	 * Get the 'thing' schema.
629
-	 *
630
-	 * @return array An array with the schema configuration.
631
-	 *
632
-	 * @since 3.1.0
633
-	 */
634
-	private function get_thing_schema() {
635
-
636
-		return array(
637
-			'css_class'     => 'wl-thing',
638
-			'uri'           => 'http://schema.org/Thing',
639
-			'same_as'       => array( '*' ),
640
-			// set as default.
641
-			'custom_fields' => array(
642
-				self::FIELD_SAME_AS                            => array(
643
-					'predicate'   => 'http://schema.org/sameAs',
644
-					'type'        => self::DATA_TYPE_URI,
645
-					'export_type' => 'http://schema.org/Thing',
646
-					'constraints' => array(
647
-						'cardinality' => INF,
648
-					),
649
-					// We need a custom metabox.
650
-					'input_field' => 'sameas',
651
-				),
652
-				// Add the schema:url property.
653
-				Wordlift_Schema_Url_Property_Service::META_KEY => Wordlift_Schema_Url_Property_Service::get_instance()
654
-				                                                                                      ->get_compat_definition(),
655
-			),
656
-			// {{sameAs}} not present in the microdata template,
657
-			// because it is treated separately in *wl_content_embed_item_microdata*
658
-			'templates'     => array(
659
-				'subtitle' => '{{id}}',
660
-			),
661
-			'linked_data'   => array(
662
-				// ### Title to rdfs:label.
663
-				$this->rendition_factory->create(
664
-					$this->storage_factory->post_title(),
665
-					Wordlift_Query_Builder::RDFS_LABEL_URI,
666
-					null,
667
-					$this->language_code
668
-				),
669
-				// ### Title to dct:title.
670
-				$this->rendition_factory->create(
671
-					$this->storage_factory->post_title(),
672
-					'http://purl.org/dc/terms/title',
673
-					null,
674
-					$this->language_code
675
-				),
676
-				// ### Alternative title to rdfs:label.
677
-				$this->rendition_factory->create(
678
-					$this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ),
679
-					Wordlift_Query_Builder::RDFS_LABEL_URI,
680
-					null,
681
-					$this->language_code
682
-				),
683
-				// ### Alternative title to dct:title.
684
-				$this->rendition_factory->create(
685
-					$this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ),
686
-					'http://purl.org/dc/terms/title',
687
-					null,
688
-					$this->language_code
689
-				),
690
-				// ### Title to schema:name.
691
-				$this->rendition_factory->create(
692
-					$this->storage_factory->post_title(),
693
-					'http://schema.org/name',
694
-					null,
695
-					$this->language_code
696
-				),
697
-				// ### Alternative title to schema:alterName.
698
-				$this->rendition_factory->create(
699
-					$this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ),
700
-					'http://schema.org/alternateName',
701
-					null,
702
-					$this->language_code
703
-				),
704
-				// ### schema:url.
705
-				$this->rendition_factory->create(
706
-					$this->storage_factory->url_property(),
707
-					Wordlift_Query_Builder::SCHEMA_URL_URI,
708
-					self::DATA_TYPE_URI
709
-				),
710
-				// ### schema:description.
711
-				$this->rendition_factory->create(
712
-					$this->storage_factory->post_description_no_tags_no_shortcodes(),
713
-					'http://schema.org/description',
714
-					null,
715
-					$this->language_code
716
-				),
717
-				// ### owl:sameAs.
718
-				$this->rendition_factory->create(
719
-					$this->storage_factory->post_meta( self::FIELD_SAME_AS ),
720
-					'http://www.w3.org/2002/07/owl#sameAs',
721
-					self::DATA_TYPE_URI
722
-				),
723
-				// ### schema:sameAs.
724
-				$this->rendition_factory->create(
725
-					$this->storage_factory->post_meta( self::FIELD_SAME_AS ),
726
-					'http://schema.org/sameAs',
727
-					self::DATA_TYPE_URI
728
-				),
729
-				// ### rdf:type.
730
-				$this->rendition_factory->create(
731
-					$this->storage_factory->schema_class(),
732
-					Wordlift_Query_Builder::RDFS_TYPE_URI,
733
-					self::DATA_TYPE_URI
734
-				),
735
-				// ### schema:image.
736
-				$this->rendition_factory->create(
737
-					$this->storage_factory->post_images(),
738
-					Wordlift_Query_Builder::SCHEMA_IMAGE_URI,
739
-					self::DATA_TYPE_URI
740
-				),
741
-				// ### dct:relation.
742
-				$this->rendition_factory->create(
743
-					$this->storage_factory->relations(),
744
-					Wordlift_Query_Builder::DCTERMS_RELATION_URI,
745
-					self::DATA_TYPE_URI
746
-				),
747
-			),
748
-		);
749
-
750
-	}
751
-
752
-	/**
753
-	 * Get the 'web-page' schema.
754
-	 *
755
-	 * @return array An array with the schema configuration.
756
-	 *
757
-	 * @since 3.18.0
758
-	 */
759
-	private function get_web_page_schema() {
760
-
761
-		return array(
762
-			'css_class'   => 'wl-webpage',
763
-			'uri'         => 'http://schema.org/WebPage',
764
-			'linked_data' => array(
765
-				// ### schema:headline.
766
-				$this->rendition_factory->create(
767
-					$this->storage_factory->post_title(),
768
-					'http://schema.org/headline',
769
-					null,
770
-					$this->language_code
771
-				),
772
-				// ### schema:url.
773
-				$this->rendition_factory->create(
774
-					$this->storage_factory->url_property(),
775
-					Wordlift_Query_Builder::SCHEMA_URL_URI,
776
-					self::DATA_TYPE_URI
777
-				),
778
-				// ### rdf:type.
779
-				$this->rendition_factory->create(
780
-					$this->storage_factory->schema_class(),
781
-					Wordlift_Query_Builder::RDFS_TYPE_URI,
782
-					self::DATA_TYPE_URI
783
-				),
784
-				// ### dcterms:references.
785
-				$this->rendition_factory->create(
786
-					$this->storage_factory->relations(),
787
-					Wordlift_Query_Builder::DCTERMS_REFERENCES_URI,
788
-					self::DATA_TYPE_URI,
789
-					$this->language_code
790
-				),
791
-			),
792
-		);
793
-
794
-	}
795
-
796
-	/**
797
-	 * Get the 'creative work' schema.
798
-	 *
799
-	 * @return array An array with the schema configuration.
800
-	 *
801
-	 * @since 3.1.0
802
-	 */
803
-	private function get_creative_work_schema() {
804
-
805
-		$schema = array(
806
-			'label'         => 'CreativeWork',
807
-			'description'   => 'A creative work (or a Music Album).',
808
-			'parents'       => array( 'thing' ),
809
-			// Give term slug as parent.
810
-			'css_class'     => 'wl-creative-work',
811
-			'uri'           => 'http://schema.org/CreativeWork',
812
-			'same_as'       => array(
813
-				'http://schema.org/MusicAlbum',
814
-				'http://schema.org/Product',
815
-			),
816
-			'custom_fields' => array(
817
-				self::FIELD_AUTHOR => array(
818
-					'predicate'   => 'http://schema.org/author',
819
-					'type'        => self::DATA_TYPE_URI,
820
-					'export_type' => 'http://schema.org/Person',
821
-					'constraints' => array(
822
-						'uri_type'    => array( 'Person', 'Organization' ),
823
-						'cardinality' => INF,
824
-					),
825
-				),
826
-			),
827
-			'linked_data'   => array(
828
-				// ### schema:author.
829
-				$this->rendition_factory->create(
830
-					$this->storage_factory->author_uri(),
831
-					Wordlift_Query_Builder::SCHEMA_AUTHOR_URI,
832
-					self::DATA_TYPE_URI
833
-				),
834
-			),
835
-			'templates'     => array(
836
-				'subtitle' => '{{id}}',
837
-			),
838
-		);
839
-
840
-		// Merge the custom fields with those provided by the thing schema.
841
-		$parent_schema           = $this->get_thing_schema();
842
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
843
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
844
-
845
-		return $schema;
846
-	}
847
-
848
-	/**
849
-	 * Get the 'event' schema.
850
-	 *
851
-	 * @return array An array with the schema configuration.
852
-	 *
853
-	 * @since 3.1.0
854
-	 */
855
-	private function get_event_schema() {
856
-
857
-		$schema = array(
858
-			'label'         => 'Event',
859
-			'description'   => 'An event . ',
860
-			'parents'       => array( 'thing' ),
861
-			'css_class'     => 'wl-event',
862
-			'uri'           => self::SCHEMA_EVENT_TYPE,
863
-			'same_as'       => array( 'http://dbpedia.org/ontology/Event' ),
864
-			'custom_fields' => array(
865
-				self::FIELD_DATE_START => array(
866
-					'predicate'   => 'http://schema.org/startDate',
867
-					'type'        => self::DATA_TYPE_DATE,
868
-					'export_type' => 'xsd:dateTime',
869
-					'constraints' => '',
870
-				),
871
-				self::FIELD_DATE_END   => array(
872
-					'predicate'   => 'http://schema.org/endDate',
873
-					'type'        => self::DATA_TYPE_DATE,
874
-					'export_type' => 'xsd:dateTime',
875
-					'constraints' => '',
876
-				),
877
-				self::FIELD_LOCATION   => array(
878
-					'predicate'   => 'http://schema.org/location',
879
-					'type'        => self::DATA_TYPE_URI,
880
-					'export_type' => 'http://schema.org/PostalAddress',
881
-					'constraints' => array(
882
-						'uri_type'    => array( 'Place', 'LocalBusiness' ),
883
-						'cardinality' => INF,
884
-					),
885
-				),
886
-				self::FIELD_PERFORMER  => array(
887
-					'predicate'   => 'http://schema.org/performer',
888
-					'type'        => self::DATA_TYPE_URI,
889
-					'export_type' => 'http://schema.org/Person',
890
-					'constraints' => array(
891
-						'uri_type'    => array( 'Person', 'Organization' ),
892
-						'cardinality' => INF,
893
-					),
894
-				),
895
-				self::FIELD_OFFERS     => array(
896
-					'predicate'   => 'http://schema.org/offers',
897
-					'type'        => self::DATA_TYPE_URI,
898
-					'export_type' => 'http://schema.org/Offer',
899
-					'constraints' => array(
900
-						'uri_type'    => array( 'Offer' ),
901
-						'cardinality' => INF,
902
-					),
903
-				),
904
-			),
905
-			'linked_data'   => array(
906
-				// ### schema:startDate.
907
-				$this->rendition_factory->create(
908
-					$this->storage_factory->post_meta( self::FIELD_DATE_START ),
909
-					'http://schema.org/startDate',
910
-					self::DATA_TYPE_DATE_TIME
911
-				),
912
-				// ### schema:endDate.
913
-				$this->rendition_factory->create(
914
-					$this->storage_factory->post_meta( self::FIELD_DATE_END ),
915
-					'http://schema.org/endDate',
916
-					self::DATA_TYPE_DATE_TIME
917
-				),
918
-				// ### schema:location.
919
-				$this->rendition_factory->create(
920
-					$this->storage_factory->post_meta_to_uri( self::FIELD_LOCATION ),
921
-					'http://schema.org/location',
922
-					self::DATA_TYPE_URI
923
-				),
924
-				// ### schema:performer.
925
-				$this->rendition_factory->create(
926
-					$this->storage_factory->post_meta_to_uri( self::FIELD_PERFORMER ),
927
-					'http://schema.org/performer',
928
-					self::DATA_TYPE_URI
929
-				),
930
-				// ### schema:offers.
931
-				$this->rendition_factory->create(
932
-					$this->storage_factory->post_meta_to_uri( self::FIELD_OFFERS ),
933
-					'http://schema.org/offers',
934
-					self::DATA_TYPE_URI
935
-				),
936
-			),
937
-			'templates'     => array(
938
-				'subtitle' => '{{id}}',
939
-			),
940
-		);
941
-
942
-		// Merge the custom fields with those provided by the thing schema.
943
-		$parent_schema           = $this->get_thing_schema();
944
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
945
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
946
-
947
-		return $schema;
948
-	}
949
-
950
-	/**
951
-	 * Get the 'organization' schema.
952
-	 *
953
-	 * @return array An array with the schema configuration.
954
-	 *
955
-	 * @since 3.1.0
956
-	 */
957
-	private function get_organization_schema() {
958
-
959
-		$schema = array(
960
-			'label'         => 'Organization',
961
-			'description'   => 'An organization, including a government or a newspaper.',
962
-			'parents'       => array( 'thing' ),
963
-			'css_class'     => 'wl-organization',
964
-			'uri'           => 'http://schema.org/Organization',
965
-			'same_as'       => array(
966
-				'http://rdf.freebase.com/ns/organization.organization',
967
-				'http://rdf.freebase.com/ns/government.government',
968
-				'http://schema.org/Newspaper',
969
-			),
970
-			'custom_fields' => array(
971
-				self::FIELD_LEGAL_NAME          => array(
972
-					'predicate'   => 'http://schema.org/legalName',
973
-					'type'        => self::DATA_TYPE_STRING,
974
-					'export_type' => 'xsd:string',
975
-					'constraints' => '',
976
-				),
977
-				self::FIELD_FOUNDER             => array(
978
-					'predicate'   => 'http://schema.org/founder',
979
-					'type'        => self::DATA_TYPE_URI,
980
-					'export_type' => 'http://schema.org/Person',
981
-					'constraints' => array(
982
-						'uri_type'    => 'Person',
983
-						'cardinality' => INF,
984
-					),
985
-				),
986
-				self::FIELD_ADDRESS             => array(
987
-					'predicate'   => 'http://schema.org/streetAddress',
988
-					'type'        => self::DATA_TYPE_STRING,
989
-					'export_type' => 'xsd:string',
990
-					'constraints' => '',
991
-					// To build custom metabox.
992
-					'input_field' => 'address',
993
-				),
994
-				self::FIELD_ADDRESS_PO_BOX      => array(
995
-					'predicate'   => 'http://schema.org/postOfficeBoxNumber',
996
-					'type'        => self::DATA_TYPE_STRING,
997
-					'export_type' => 'xsd:string',
998
-					'constraints' => '',
999
-					// To build custom metabox.
1000
-					'input_field' => 'address',
1001
-				),
1002
-				self::FIELD_ADDRESS_POSTAL_CODE => array(
1003
-					'predicate'   => 'http://schema.org/postalCode',
1004
-					'type'        => self::DATA_TYPE_STRING,
1005
-					'export_type' => 'xsd:string',
1006
-					'constraints' => '',
1007
-					// To build custom metabox.
1008
-					'input_field' => 'address',
1009
-				),
1010
-				self::FIELD_ADDRESS_LOCALITY    => array(
1011
-					'predicate'   => 'http://schema.org/addressLocality',
1012
-					'type'        => self::DATA_TYPE_STRING,
1013
-					'export_type' => 'xsd:string',
1014
-					'constraints' => '',
1015
-					// To build custom metabox.
1016
-					'input_field' => 'address',
1017
-				),
1018
-				self::FIELD_ADDRESS_REGION      => array(
1019
-					'predicate'   => 'http://schema.org/addressRegion',
1020
-					'type'        => self::DATA_TYPE_STRING,
1021
-					'export_type' => 'xsd:string',
1022
-					'constraints' => '',
1023
-					// To build custom metabox.
1024
-					'input_field' => 'address',
1025
-				),
1026
-				self::FIELD_ADDRESS_COUNTRY     => array(
1027
-					'predicate'   => 'http://schema.org/addressCountry',
1028
-					'type'        => self::DATA_TYPE_STRING,
1029
-					'export_type' => 'xsd:string',
1030
-					'constraints' => '',
1031
-					// To build custom metabox.
1032
-					'input_field' => 'address',
1033
-				),
1034
-				self::FIELD_EMAIL               => array(
1035
-					'predicate'   => 'http://schema.org/email',
1036
-					'type'        => self::DATA_TYPE_STRING,
1037
-					'export_type' => 'xsd:string',
1038
-					'constraints' => '',
1039
-				),
1040
-				self::FIELD_TELEPHONE           => array(
1041
-					'predicate'   => 'http://schema.org/telephone',
1042
-					'type'        => self::DATA_TYPE_STRING,
1043
-					'export_type' => 'xsd:string',
1044
-					'constraints' => '',
1045
-				),
1046
-			),
1047
-			'linked_data'   => array(
1048
-				// ### schema:legalName.
1049
-				$this->rendition_factory->create(
1050
-					$this->storage_factory->post_meta( self::FIELD_LEGAL_NAME ),
1051
-					'http://schema.org/legalName'
1052
-				),
1053
-				// ### schema:founder.
1054
-				$this->rendition_factory->create(
1055
-					$this->storage_factory->post_meta_to_uri( self::FIELD_FOUNDER ),
1056
-					'http://schema.org/founder',
1057
-					self::DATA_TYPE_URI
1058
-				),
1059
-				// ### schema:email.
1060
-				$this->rendition_factory->create(
1061
-					$this->storage_factory->post_meta( self::FIELD_EMAIL ),
1062
-					'http://schema.org/email'
1063
-				),
1064
-				// ### schema:telephone.
1065
-				$this->rendition_factory->create(
1066
-					$this->storage_factory->post_meta( self::FIELD_TELEPHONE ),
1067
-					'http://schema.org/telephone'
1068
-				),
1069
-			),
1070
-			'templates'     => array(
1071
-				'subtitle' => '{{id}}',
1072
-			),
1073
-		);
1074
-
1075
-		// Merge the custom fields with those provided by the thing schema.
1076
-		$parent_schema           = $this->get_thing_schema();
1077
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1078
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1079
-
1080
-		return $schema;
1081
-	}
1082
-
1083
-	/**
1084
-	 * Get the 'person' schema.
1085
-	 *
1086
-	 * @return array An array with the schema configuration.
1087
-	 *
1088
-	 * @since 3.1.0
1089
-	 */
1090
-	private function get_person_schema() {
1091
-
1092
-		$schema = array(
1093
-			'label'         => 'Person',
1094
-			'description'   => 'A person (or a music artist).',
1095
-			'parents'       => array( 'thing' ),
1096
-			'css_class'     => 'wl-person',
1097
-			'uri'           => 'http://schema.org/Person',
1098
-			'same_as'       => array(
1099
-				'http://rdf.freebase.com/ns/people.person',
1100
-				'http://rdf.freebase.com/ns/music.artist',
1101
-				'http://dbpedia.org/class/yago/LivingPeople',
1102
-			),
1103
-			'custom_fields' => array(
1104
-				self::FIELD_KNOWS       => array(
1105
-					'predicate'   => 'http://schema.org/knows',
1106
-					'type'        => self::DATA_TYPE_URI,
1107
-					'export_type' => 'http://schema.org/Person',
1108
-					'constraints' => array(
1109
-						'uri_type'    => 'Person',
1110
-						'cardinality' => INF,
1111
-					),
1112
-				),
1113
-				self::FIELD_BIRTH_DATE  => array(
1114
-					'predicate'   => 'http://schema.org/birthDate',
1115
-					'type'        => self::DATA_TYPE_DATE,
1116
-					'export_type' => 'xsd:date',
1117
-					'constraints' => '',
1118
-				),
1119
-				self::FIELD_BIRTH_PLACE => array(
1120
-					'predicate'   => 'http://schema.org/birthPlace',
1121
-					'type'        => self::DATA_TYPE_URI,
1122
-					'export_type' => 'http://schema.org/Place',
1123
-					'constraints' => array(
1124
-						'uri_type' => 'Place',
1125
-					),
1126
-				),
1127
-				self::FIELD_AFFILIATION => array(
1128
-					'predicate'   => 'http://schema.org/affiliation',
1129
-					'type'        => self::DATA_TYPE_URI,
1130
-					'export_type' => 'http://schema.org/Organization',
1131
-					'constraints' => array(
1132
-						'uri_type'    => array(
1133
-							'Organization',
1134
-							'LocalBusiness',
1135
-						),
1136
-						'cardinality' => INF,
1137
-					),
1138
-				),
1139
-				self::FIELD_EMAIL       => array(
1140
-					'predicate'   => 'http://schema.org/email',
1141
-					'type'        => self::DATA_TYPE_STRING,
1142
-					'export_type' => 'xsd:string',
1143
-					'constraints' => array(
1144
-						'cardinality' => INF,
1145
-					),
1146
-				),
1147
-			),
1148
-			'linked_data'   => array(
1149
-				// ### schema:knows.
1150
-				$this->rendition_factory->create(
1151
-					$this->storage_factory->post_meta_to_uri( self::FIELD_KNOWS ),
1152
-					'http://schema.org/knows',
1153
-					self::DATA_TYPE_URI
1154
-				),
1155
-				// ### schema:birthDate.
1156
-				$this->rendition_factory->create(
1157
-					$this->storage_factory->post_meta( self::FIELD_BIRTH_DATE ),
1158
-					'http://schema.org/birthDate',
1159
-					self::DATA_TYPE_DATE
1160
-				),
1161
-				// ### schema:birthPlace.
1162
-				$this->rendition_factory->create(
1163
-					$this->storage_factory->post_meta_to_uri( self::FIELD_BIRTH_PLACE ),
1164
-					'http://schema.org/birthPlace',
1165
-					self::DATA_TYPE_URI
1166
-				),
1167
-				// ### schema:affiliation.
1168
-				$this->rendition_factory->create(
1169
-					$this->storage_factory->post_meta_to_uri( self::FIELD_AFFILIATION ),
1170
-					'http://schema.org/affiliation',
1171
-					self::DATA_TYPE_URI
1172
-				),
1173
-				// ### schema:email.
1174
-				$this->rendition_factory->create(
1175
-					$this->storage_factory->post_meta( self::FIELD_EMAIL ),
1176
-					'http://schema.org/email'
1177
-				),
1178
-			),
1179
-			'templates'     => array(
1180
-				'subtitle' => '{{id}}',
1181
-			),
1182
-		);
1183
-
1184
-		// Merge the custom fields with those provided by the thing schema.
1185
-		$parent_schema           = $this->get_thing_schema();
1186
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1187
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1188
-
1189
-		return $schema;
1190
-
1191
-	}
1192
-
1193
-	/**
1194
-	 * Get the 'place' schema.
1195
-	 *
1196
-	 * @return array An array with the schema configuration.
1197
-	 *
1198
-	 * @since 3.1.0
1199
-	 */
1200
-	private function get_place_schema() {
1201
-
1202
-		$schema = array(
1203
-			'label'         => 'Place',
1204
-			'description'   => 'A place.',
1205
-			'parents'       => array( 'thing' ),
1206
-			'css_class'     => 'wl-place',
1207
-			'uri'           => 'http://schema.org/Place',
1208
-			'same_as'       => array(
1209
-				'http://rdf.freebase.com/ns/location.location',
1210
-				'http://www.opengis.net/gml/_Feature',
1211
-			),
1212
-			'custom_fields' => array(
1213
-				self::FIELD_GEO_LATITUDE        => array(
1214
-					'predicate'   => 'http://schema.org/latitude',
1215
-					'type'        => self::DATA_TYPE_DOUBLE,
1216
-					'export_type' => 'xsd:double',
1217
-					'constraints' => '',
1218
-					// To build custom metabox.
1219
-					'input_field' => 'coordinates',
1220
-				),
1221
-				self::FIELD_GEO_LONGITUDE       => array(
1222
-					'predicate'   => 'http://schema.org/longitude',
1223
-					'type'        => self::DATA_TYPE_DOUBLE,
1224
-					'export_type' => 'xsd:double',
1225
-					'constraints' => '',
1226
-					// To build custom metabox.
1227
-					'input_field' => 'coordinates',
1228
-				),
1229
-				self::FIELD_ADDRESS             => array(
1230
-					'predicate'   => 'http://schema.org/streetAddress',
1231
-					'type'        => self::DATA_TYPE_STRING,
1232
-					'export_type' => 'xsd:string',
1233
-					'constraints' => '',
1234
-					// To build custom metabox.
1235
-					'input_field' => 'address',
1236
-				),
1237
-				self::FIELD_ADDRESS_PO_BOX      => array(
1238
-					'predicate'   => 'http://schema.org/postOfficeBoxNumber',
1239
-					'type'        => self::DATA_TYPE_STRING,
1240
-					'export_type' => 'xsd:string',
1241
-					'constraints' => '',
1242
-					// To build custom metabox.
1243
-					'input_field' => 'address',
1244
-				),
1245
-				self::FIELD_ADDRESS_POSTAL_CODE => array(
1246
-					'predicate'   => 'http://schema.org/postalCode',
1247
-					'type'        => self::DATA_TYPE_STRING,
1248
-					'export_type' => 'xsd:string',
1249
-					'constraints' => '',
1250
-					// To build custom metabox.
1251
-					'input_field' => 'address',
1252
-				),
1253
-				self::FIELD_ADDRESS_LOCALITY    => array(
1254
-					'predicate'   => 'http://schema.org/addressLocality',
1255
-					'type'        => self::DATA_TYPE_STRING,
1256
-					'export_type' => 'xsd:string',
1257
-					'constraints' => '',
1258
-					// To build custom metabox.
1259
-					'input_field' => 'address',
1260
-				),
1261
-				self::FIELD_ADDRESS_REGION      => array(
1262
-					'predicate'   => 'http://schema.org/addressRegion',
1263
-					'type'        => self::DATA_TYPE_STRING,
1264
-					'export_type' => 'xsd:string',
1265
-					'constraints' => '',
1266
-					// To build custom metabox.
1267
-					'input_field' => 'address',
1268
-				),
1269
-				self::FIELD_ADDRESS_COUNTRY     => array(
1270
-					'predicate'   => 'http://schema.org/addressCountry',
1271
-					'type'        => self::DATA_TYPE_STRING,
1272
-					'export_type' => 'xsd:string',
1273
-					'constraints' => '',
1274
-					// To build custom metabox.
1275
-					'input_field' => 'address',
1276
-				),
1277
-			),
1278
-			'linked_data'   => array(
1279
-				$this->rendition_factory->create_address(
1280
-					$this->storage_factory,
1281
-					$this->language_code
1282
-				),
1283
-			),
1284
-			'templates'     => array(
1285
-				'subtitle' => '{{id}}',
1286
-			),
1287
-		);
1288
-
1289
-		// Merge the custom fields with those provided by the thing schema.
1290
-		$parent_schema           = $this->get_thing_schema();
1291
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1292
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1293
-
1294
-		return $schema;
1295
-	}
1296
-
1297
-	/**
1298
-	 * Get the 'local business' schema.
1299
-	 *
1300
-	 * @return array An array with the schema configuration.
1301
-	 *
1302
-	 * @since 3.1.0
1303
-	 */
1304
-	private function get_local_business_schema() {
1305
-
1306
-		$schema = array(
1307
-			'label'         => 'LocalBusiness',
1308
-			'description'   => 'A local business.',
1309
-			'parents'       => array( 'place', 'organization' ),
1310
-			'css_class'     => 'wl-local-business',
1311
-			'uri'           => 'http://schema.org/LocalBusiness',
1312
-			'same_as'       => array(
1313
-				'http://rdf.freebase.com/ns/business/business_location',
1314
-				'https://schema.org/Store',
1315
-			),
1316
-			'custom_fields' => array(),
1317
-			'linked_data'   => array(),
1318
-			'templates'     => array(
1319
-				'subtitle' => '{{id}}',
1320
-			),
1321
-		);
1322
-
1323
-		// Merge the custom fields with those provided by the place and organization schema.
1324
-		$place_schema            = $this->get_place_schema();
1325
-		$organization_schema     = $this->get_organization_schema();
1326
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields'] );
1327
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $place_schema['linked_data'], $organization_schema['linked_data'] );
1328
-
1329
-		return $schema;
1330
-	}
1331
-
1332
-	/**
1333
-	 * Get the 'recipe' schema.
1334
-	 *
1335
-	 * @return array An array with the schema configuration.
1336
-	 *
1337
-	 * @since 3.14.0
1338
-	 */
1339
-	private function get_recipe_schema() {
1340
-
1341
-		$schema = array(
1342
-			'label'         => 'Recipe',
1343
-			'description'   => 'A Recipe.',
1344
-			'parents'       => array( 'CreativeWork' ),
1345
-			'css_class'     => 'wl-recipe',
1346
-			'uri'           => 'http://schema.org/Recipe',
1347
-			'same_as'       => array(),
1348
-			'templates'     => array(
1349
-				'subtitle' => '{{id}}',
1350
-			),
1351
-			'custom_fields' => array(
1352
-				self::FIELD_RECIPE_CUISINE          => array(
1353
-					'predicate'   => 'http://schema.org/recipeCuisine',
1354
-					'type'        => self::DATA_TYPE_STRING,
1355
-					'export_type' => 'xsd:string',
1356
-					'constraints' => '',
1357
-					'metabox'     => array(
1358
-						'label' => __( 'Recipe cuisine', 'wordlift' ),
1359
-					),
1360
-				),
1361
-				self::FIELD_RECIPE_INGREDIENT       => array(
1362
-					'predicate'   => 'http://schema.org/recipeIngredient',
1363
-					'type'        => self::DATA_TYPE_STRING,
1364
-					'export_type' => 'xsd:string',
1365
-					'constraints' => array(
1366
-						'cardinality' => INF,
1367
-					),
1368
-					'metabox'     => array(
1369
-						'label' => __( 'Recipe ingredient', 'wordlift' ),
1370
-					),
1371
-				),
1372
-				self::FIELD_RECIPE_INSTRUCTIONS     => array(
1373
-					'predicate'   => 'http://schema.org/recipeInstructions',
1374
-					'type'        => self::DATA_TYPE_MULTILINE,
1375
-					'export_type' => 'xsd:string',
1376
-					'constraints' => '',
1377
-					'metabox'     => array(
1378
-						'class' => 'Wordlift_Metabox_Field_Multiline',
1379
-						'label' => __( 'Recipe instructions', 'wordlift' ),
1380
-					),
1381
-				),
1382
-				self::FIELD_RECIPE_YIELD            => array(
1383
-					'predicate'   => 'http://schema.org/recipeYield',
1384
-					'type'        => self::DATA_TYPE_STRING,
1385
-					'export_type' => 'xsd:string',
1386
-					'constraints' => '',
1387
-					'metabox'     => array(
1388
-						'label' => __( 'Recipe number of servings', 'wordlift' ),
1389
-					),
1390
-				),
1391
-				self::FIELD_RECIPE_INGREDIENT       => array(
1392
-					'predicate'   => 'http://schema.org/recipeIngredient',
1393
-					'type'        => self::DATA_TYPE_STRING,
1394
-					'export_type' => 'xsd:string',
1395
-					'constraints' => array(
1396
-						'cardinality' => INF,
1397
-					),
1398
-					'metabox'     => array(
1399
-						'label' => __( 'Recipe ingredient', 'wordlift' ),
1400
-					),
1401
-				),
1402
-				self::FIELD_NUTRITION_INFO_CALORIES => array(
1403
-					'predicate'   => 'http://schema.org/calories',
1404
-					'type'        => self::DATA_TYPE_STRING,
1405
-					'export_type' => 'xsd:string',
1406
-					'constraints' => '',
1407
-					'metabox'     => array(
1408
-						'label' => __( 'Calories (e.g. 240 calories)', 'wordlift' ),
1409
-					),
1410
-				),
1411
-				self::FIELD_PREP_TIME               => array(
1412
-					'predicate'   => 'http://schema.org/prepTime',
1413
-					'type'        => self::DATA_TYPE_DURATION,
1414
-					'export_type' => 'xsd:time',
1415
-					'constraints' => '',
1416
-					'metabox'     => array(
1417
-						'class' => 'Wordlift_Metabox_Field_Duration',
1418
-						'label' => __( 'Recipe preparation time (e.g. 1:30)', 'wordlift' ),
1419
-					),
1420
-				),
1421
-				self::FIELD_COOK_TIME               => array(
1422
-					'predicate'   => 'http://schema.org/cookTime',
1423
-					'type'        => self::DATA_TYPE_DURATION,
1424
-					'export_type' => 'xsd:time',
1425
-					'constraints' => '',
1426
-					'metabox'     => array(
1427
-						'class' => 'Wordlift_Metabox_Field_Duration',
1428
-						'label' => __( 'Recipe cook time (e.g. 1:30)', 'wordlift' ),
1429
-					),
1430
-				),
1431
-				self::FIELD_TOTAL_TIME              => array(
1432
-					'predicate'   => 'http://schema.org/totalTime',
1433
-					'type'        => self::DATA_TYPE_DURATION,
1434
-					'export_type' => 'xsd:time',
1435
-					'constraints' => '',
1436
-					'metabox'     => array(
1437
-						'class' => 'Wordlift_Metabox_Field_Duration',
1438
-						'label' => __( 'Recipe total time (e.g. 1:30)', 'wordlift' ),
1439
-					),
1440
-				),
1441
-			),
1442
-			'linked_data'   => array(
1443
-				// ### schema:recipeCuisine.
1444
-				$this->rendition_factory->create(
1445
-					$this->storage_factory->post_meta( self::FIELD_RECIPE_CUISINE ),
1446
-					'http://schema.org/recipeCuisine'
1447
-				),
1448
-				// ### schema:recipeIngredient.
1449
-				$this->rendition_factory->create(
1450
-					$this->storage_factory->post_meta( self::FIELD_RECIPE_INGREDIENT ),
1451
-					'http://schema.org/recipeIngredient'
1452
-				),
1453
-				// ### schema:recipeInstructions.
1454
-				$this->rendition_factory->create(
1455
-					$this->storage_factory->post_meta( self::FIELD_RECIPE_INSTRUCTIONS ),
1456
-					'http://schema.org/recipeInstructions'
1457
-				),
1458
-				// ### schema:recipeYield.
1459
-				$this->rendition_factory->create(
1460
-					$this->storage_factory->post_meta( self::FIELD_RECIPE_YIELD ),
1461
-					'http://schema.org/recipeYield'
1462
-				),
1463
-				// ### schema:prepTime.
1464
-				$this->rendition_factory->create(
1465
-					$this->storage_factory->post_meta( self::FIELD_PREP_TIME ),
1466
-					'http://schema.org/prepTime',
1467
-					self::DATA_TYPE_DURATION
1468
-				),
1469
-				// ### schema:cookTime.
1470
-				$this->rendition_factory->create(
1471
-					$this->storage_factory->post_meta( self::FIELD_COOK_TIME ),
1472
-					'http://schema.org/cookTime',
1473
-					self::DATA_TYPE_DURATION
1474
-				),
1475
-				// ### schema:totalTime.
1476
-				$this->rendition_factory->create(
1477
-					$this->storage_factory->post_meta( self::FIELD_TOTAL_TIME ),
1478
-					'http://schema.org/totalTime',
1479
-					self::DATA_TYPE_DURATION
1480
-				),
1481
-			),
1482
-		);
1483
-
1484
-		// Merge the custom fields with those provided by the parent schema.
1485
-		$parent_schema           = $this->get_creative_work_schema();
1486
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1487
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1488
-
1489
-		return $schema;
1490
-	}
1491
-
1492
-	/**
1493
-	 * Get the 'offer' schema.
1494
-	 *
1495
-	 * @return array An array with the schema configuration.
1496
-	 *
1497
-	 * @since 3.18.0
1498
-	 */
1499
-	private function get_offer_schema() {
1500
-
1501
-		$schema = array(
1502
-			'label'         => 'Offer',
1503
-			'description'   => 'An offer. ',
1504
-			'parents'       => array( 'thing' ),
1505
-			'css_class'     => 'wl-offer',
1506
-			'uri'           => self::SCHEMA_OFFER_TYPE,
1507
-			'same_as'       => array(),
1508
-			'templates'     => array(
1509
-				'subtitle' => '{{id}}',
1510
-			),
1511
-			'custom_fields' => array(
1512
-				self::FIELD_AVAILABILITY        => array(
1513
-					'predicate'   => 'http://schema.org/availability',
1514
-					'type'        => self::DATA_TYPE_STRING,
1515
-					'export_type' => 'xsd:string',
1516
-					'metabox'     => array(
1517
-						'class' => 'Wordlift_Metabox_Field_Select',
1518
-					),
1519
-					'options'     => array(
1520
-						'Discontinued'        => esc_html__( 'Discontinued', 'wordlift' ),
1521
-						'InStock'             => esc_html__( 'In Stock', 'wordlift' ),
1522
-						'InStoreOnly'         => esc_html__( 'In Store Only', 'wordlift' ),
1523
-						'LimitedAvailability' => esc_html__( 'Limited Availability', 'wordlift' ),
1524
-						'OnlineOnly'          => esc_html__( 'Online Only', 'wordlift' ),
1525
-						'OutOfStock'          => esc_html__( 'Out of Stock', 'wordlift' ),
1526
-						'PreOrder'            => esc_html__( 'Pre Order', 'wordlift' ),
1527
-						'PreSale'             => esc_html__( 'Pre Sale', 'wordlift' ),
1528
-						'SoldOut'             => esc_html__( 'Sold Out', 'wordlift' ),
1529
-					),
1530
-				),
1531
-				self::FIELD_PRICE               => array(
1532
-					'predicate'   => 'http://schema.org/price',
1533
-					'type'        => self::DATA_TYPE_STRING,
1534
-					'export_type' => 'xsd:integer',
1535
-					'metabox'     => array(
1536
-						'class' => 'Wordlift_Metabox_Field_Integer',
1537
-					),
1538
-				),
1539
-				self::FIELD_PRICE_CURRENCY      => array(
1540
-					'predicate'   => 'http://schema.org/priceCurrency',
1541
-					'type'        => self::DATA_TYPE_STRING,
1542
-					'export_type' => 'xsd:string',
1543
-				),
1544
-				self::FIELD_AVAILABILITY_STARTS => array(
1545
-					'predicate'   => 'http://schema.org/availabilityStarts',
1546
-					'type'        => self::DATA_TYPE_DATE,
1547
-					'export_type' => 'xsd:dateTime',
1548
-				),
1549
-				self::FIELD_AVAILABILITY_ENDS   => array(
1550
-					'predicate'   => 'http://schema.org/availabilityEnds',
1551
-					'type'        => self::DATA_TYPE_DATE,
1552
-					'export_type' => 'xsd:dateTime',
1553
-				),
1554
-				self::FIELD_INVENTORY_LEVEL     => array(
1555
-					'predicate'   => 'http://schema.org/inventoryLevel',
1556
-					'type'        => self::DATA_TYPE_STRING,
1557
-					'export_type' => 'xsd:integer',
1558
-					'metabox'     => array(
1559
-						'class' => 'Wordlift_Metabox_Field_Integer',
1560
-					),
1561
-				),
1562
-				self::FIELD_VALID_FROM          => array(
1563
-					'predicate'   => 'http://schema.org/validFrom',
1564
-					'type'        => self::DATA_TYPE_DATE,
1565
-					'export_type' => 'xsd:dateTime',
1566
-				),
1567
-				self::FIELD_PRICE_VALID_UNTIL   => array(
1568
-					'predicate'   => 'http://schema.org/priceValidUntil',
1569
-					'type'        => self::DATA_TYPE_DATE,
1570
-					'export_type' => 'xsd:dateTime',
1571
-				),
1572
-				self::FIELD_ITEM_OFFERED        => array(
1573
-					'predicate'   => 'http://schema.org/itemOffered',
1574
-					'type'        => self::DATA_TYPE_URI,
1575
-					'export_type' => 'http://schema.org/Thing',
1576
-					'constraints' => array(
1577
-						'uri_type'    => array(
1578
-							'Event',
1579
-							'Thing',
1580
-						),
1581
-						'cardinality' => INF,
1582
-					),
1583
-				),
1584
-			),
1585
-			'linked_data'   => array(
1586
-				// ### schema:availability.
1587
-				$this->rendition_factory->create(
1588
-					$this->storage_factory->post_meta( self::FIELD_AVAILABILITY ),
1589
-					'http://schema.org/availability',
1590
-					null
1591
-				),
1592
-				// ### schema:availabilityStarts.
1593
-				$this->rendition_factory->create(
1594
-					$this->storage_factory->post_meta( self::FIELD_AVAILABILITY_STARTS ),
1595
-					'http://schema.org/availabilityStarts',
1596
-					self::DATA_TYPE_DATE_TIME
1597
-				),
1598
-				// ### schema:availabilityEnds.
1599
-				$this->rendition_factory->create(
1600
-					$this->storage_factory->post_meta( self::FIELD_AVAILABILITY_ENDS ),
1601
-					'http://schema.org/availabilityEnds',
1602
-					self::DATA_TYPE_DATE_TIME
1603
-				),
1604
-				// ### schema:inventoryLevel.
1605
-				$this->rendition_factory->create(
1606
-					$this->storage_factory->post_meta( self::FIELD_INVENTORY_LEVEL ),
1607
-					'http://schema.org/inventoryLevel',
1608
-					self::DATA_TYPE_INTEGER
1609
-				),
1610
-				// ### schema:price.
1611
-				$this->rendition_factory->create(
1612
-					$this->storage_factory->post_meta( self::FIELD_PRICE ),
1613
-					'http://schema.org/price',
1614
-					self::DATA_TYPE_INTEGER
1615
-				),
1616
-				// ### schema:priceCurrency.
1617
-				$this->rendition_factory->create(
1618
-					$this->storage_factory->post_meta( self::FIELD_PRICE_CURRENCY ),
1619
-					'http://schema.org/priceCurrency',
1620
-					null
1621
-				),
1622
-				// ### schema:validFrom.
1623
-				$this->rendition_factory->create(
1624
-					$this->storage_factory->post_meta( self::FIELD_VALID_FROM ),
1625
-					'http://schema.org/validFrom',
1626
-					null
1627
-				),
1628
-				// ### schema:priceValidUntil.
1629
-				$this->rendition_factory->create(
1630
-					$this->storage_factory->post_meta( self::FIELD_PRICE_VALID_UNTIL ),
1631
-					'http://schema.org/priceValidUntil',
1632
-					null
1633
-				),
1634
-				// ### schema:itemOffered.
1635
-				$this->rendition_factory->create(
1636
-					$this->storage_factory->post_meta_to_uri( self::FIELD_ITEM_OFFERED ),
1637
-					'http://schema.org/itemOffered',
1638
-					self::DATA_TYPE_URI
1639
-				),
1640
-			),
1641
-		);
1642
-
1643
-		// Merge the custom fields with those provided by the thing schema.
1644
-		$parent_schema           = $this->get_thing_schema();
1645
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1646
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1647
-
1648
-		return $schema;
1649
-	}
1650
-
1651
-	/**
1652
-	 * Get the 'article' schema.
1653
-	 *
1654
-	 * @return array An array with the schema configuration.
1655
-	 *
1656
-	 * @since 3.15.0
1657
-	 */
1658
-	private function get_article_schema() {
1659
-
1660
-		$schema = array(
1661
-			'label'         => 'Article',
1662
-			'description'   => 'An Article.',
1663
-			'parents'       => array(),
1664
-			'css_class'     => 'wl-article',
1665
-			'uri'           => 'http://schema.org/Article',
1666
-			'same_as'       => array(),
1667
-			'templates'     => array(
1668
-				'subtitle' => '{{id}}',
1669
-			),
1670
-			'custom_fields' => array(),
1671
-			'linked_data'   => array(
1672
-				// ### schema:headline.
1673
-				$this->rendition_factory->create(
1674
-					$this->storage_factory->post_title(),
1675
-					'http://schema.org/headline',
1676
-					null,
1677
-					$this->language_code
1678
-				),
1679
-				// ### schema:url.
1680
-				$this->rendition_factory->create(
1681
-					$this->storage_factory->url_property(),
1682
-					Wordlift_Query_Builder::SCHEMA_URL_URI,
1683
-					self::DATA_TYPE_URI
1684
-				),
1685
-				// ### rdf:type.
1686
-				$this->rendition_factory->create(
1687
-					$this->storage_factory->schema_class(),
1688
-					Wordlift_Query_Builder::RDFS_TYPE_URI,
1689
-					self::DATA_TYPE_URI
1690
-				),
1691
-				// ### dcterms:references.
1692
-				$this->rendition_factory->create(
1693
-					$this->storage_factory->relations(),
1694
-					Wordlift_Query_Builder::DCTERMS_REFERENCES_URI,
1695
-					self::DATA_TYPE_URI,
1696
-					$this->language_code
1697
-				),
1698
-			),
1699
-		);
1700
-
1701
-		return $schema;
1702
-	}
21
+    /**
22
+     * The 'location created' field name.
23
+     *
24
+     * @since 3.5.0
25
+     */
26
+    const FIELD_LOCATION_CREATED = 'wl_location_created';
27
+
28
+    /**
29
+     * The 'topic' field name.
30
+     *
31
+     * @since 3.5.0
32
+     */
33
+    const FIELD_TOPIC = 'wl_topic';
34
+
35
+    /**
36
+     * The 'author' field name.
37
+     *
38
+     * @since 3.1.0
39
+     */
40
+    const FIELD_AUTHOR = 'wl_author';
41
+
42
+    /**
43
+     * The 'same as' field name.
44
+     *
45
+     * @since 3.1.0
46
+     */
47
+    const FIELD_SAME_AS = 'entity_same_as';
48
+
49
+    /**
50
+     * The 'date start' field name.
51
+     *
52
+     * @since 3.1.0
53
+     */
54
+    const FIELD_DATE_START = 'wl_cal_date_start';
55
+
56
+    /**
57
+     * The 'date end' field name.
58
+     *
59
+     * @since 3.1.0
60
+     */
61
+    const FIELD_DATE_END = 'wl_cal_date_end';
62
+
63
+    /**
64
+     * The 'location' field name.
65
+     *
66
+     * @since 3.1.0
67
+     */
68
+    const FIELD_LOCATION = 'wl_location';
69
+
70
+    /**
71
+     * The 'founder' field name.
72
+     *
73
+     * @since 3.1.0
74
+     */
75
+    const FIELD_FOUNDER = 'wl_founder';
76
+
77
+    /**
78
+     * The 'knows' field name.
79
+     *
80
+     * @since 3.1.0
81
+     */
82
+    const FIELD_KNOWS = 'wl_knows';
83
+
84
+    /**
85
+     * The 'birth date' field name.
86
+     *
87
+     * @since 3.1.0
88
+     */
89
+    const FIELD_BIRTH_DATE = 'wl_birth_date';
90
+
91
+    /**
92
+     * The 'birth place' field name.
93
+     *
94
+     * @since 3.1.0
95
+     */
96
+    const FIELD_BIRTH_PLACE = 'wl_birth_place';
97
+
98
+    /**
99
+     * The 'latitude' field name.
100
+     *
101
+     * @since 3.1.0
102
+     */
103
+    const FIELD_GEO_LATITUDE = 'wl_geo_latitude';
104
+
105
+    /**
106
+     * The 'longitude' field name.
107
+     *
108
+     * @since 3.1.0
109
+     */
110
+    const FIELD_GEO_LONGITUDE = 'wl_geo_longitude';
111
+
112
+    /**
113
+     * The 'streetAddress' field name.
114
+     *
115
+     * @since 3.1.0
116
+     */
117
+    const FIELD_ADDRESS = 'wl_address';
118
+
119
+    /**
120
+     * The 'postOfficeBoxNumber' field name.
121
+     *
122
+     * @since 3.3.0
123
+     */
124
+    const FIELD_ADDRESS_PO_BOX = 'wl_address_post_office_box';
125
+
126
+    /**
127
+     * The 'postalCode' field name.
128
+     *
129
+     * @since 3.3.0
130
+     */
131
+    const FIELD_ADDRESS_POSTAL_CODE = 'wl_address_postal_code';
132
+
133
+    /**
134
+     * The 'addressLocality' field name.
135
+     *
136
+     * @since 3.3.0
137
+     */
138
+    const FIELD_ADDRESS_LOCALITY = 'wl_address_locality';
139
+    /**
140
+     * The 'addressRegion' field name.
141
+     *
142
+     * @since 3.3.0
143
+     */
144
+    const FIELD_ADDRESS_REGION = 'wl_address_region';
145
+
146
+    /**
147
+     * The 'addressCountry' field name.
148
+     *
149
+     * @since 3.3.0
150
+     */
151
+    const FIELD_ADDRESS_COUNTRY = 'wl_address_country';
152
+
153
+    /**
154
+     * The 'entity type' field name.
155
+     *
156
+     * @since 3.1.0
157
+     */
158
+    const FIELD_ENTITY_TYPE = 'wl_entity_type_uri';
159
+
160
+    /**
161
+     * The 'email' field name.
162
+     *
163
+     * @since 3.2.0
164
+     */
165
+    const FIELD_EMAIL = 'wl_email';
166
+
167
+    /**
168
+     * The 'affiliation' field name.
169
+     *
170
+     * @since 3.2.0
171
+     */
172
+    const FIELD_AFFILIATION = 'wl_affiliation';
173
+
174
+    /**
175
+     * The 'telephone' field name.
176
+     *
177
+     * @since 3.8.0
178
+     */
179
+    const FIELD_TELEPHONE = 'wl_schema_telephone';
180
+
181
+    /**
182
+     * The 'legalName' field name.
183
+     *
184
+     * @since 3.12.0
185
+     */
186
+    const FIELD_LEGAL_NAME = 'wl_schema_legal_name';
187
+
188
+    /**
189
+     * The 'recipeCuisine' field name.
190
+     *
191
+     * @since 3.14.0
192
+     */
193
+    const FIELD_RECIPE_CUISINE = 'wl_schema_recipe_cuisine';
194
+
195
+    /**
196
+     * The 'recipeIngredient' field name.
197
+     *
198
+     * @since 3.14.0
199
+     */
200
+    const FIELD_RECIPE_INGREDIENT = 'wl_schema_recipe_ingredient';
201
+
202
+    /**
203
+     * The 'calories' field name.
204
+     *
205
+     * @since 3.14.0
206
+     */
207
+    const FIELD_NUTRITION_INFO_CALORIES = 'wl_schema_nutrition_information_calories';
208
+
209
+    /**
210
+     * The 'recipeInstructions' field name.
211
+     *
212
+     * @since 3.14.0
213
+     */
214
+    const FIELD_RECIPE_INSTRUCTIONS = 'wl_schema_recipe_instructions';
215
+
216
+    /**
217
+     * The 'recipeYield' field name.
218
+     *
219
+     * @since 3.14.0
220
+     */
221
+    const FIELD_RECIPE_YIELD = 'wl_schema_recipe_yield';
222
+
223
+    /**
224
+     * The 'prepTime' field name.
225
+     *
226
+     * @since 3.14.0
227
+     */
228
+    const FIELD_PREP_TIME = 'wl_schema_prep_time';
229
+
230
+    /**
231
+     * The 'cookTime' field name.
232
+     *
233
+     * @since 3.14.0
234
+     */
235
+    const FIELD_COOK_TIME = 'wl_schema_cook_time';
236
+
237
+    /**
238
+     * The 'totalTime' field name.
239
+     *
240
+     * @since 3.14.0
241
+     */
242
+    const FIELD_TOTAL_TIME = 'wl_schema_total_time';
243
+
244
+    /**
245
+     * The 'performer' field name.
246
+     *
247
+     * @since 3.18.0
248
+     */
249
+    const FIELD_PERFORMER = 'wl_schema_performer';
250
+
251
+    /**
252
+     * The 'offers' field name.
253
+     *
254
+     * @since 3.18.0
255
+     */
256
+    const FIELD_OFFERS = 'wl_schema_offers';
257
+
258
+    /**
259
+     * The 'availablity' field name.
260
+     *
261
+     * @since 3.18.0
262
+     */
263
+    const FIELD_AVAILABILITY = 'wl_schema_availability';
264
+
265
+    /**
266
+     * The 'inventoryLevel' field name.
267
+     *
268
+     * @since 3.18.0
269
+     */
270
+    const FIELD_INVENTORY_LEVEL = 'wl_schema_inventory_level';
271
+
272
+    /**
273
+     * The 'price' field name.
274
+     *
275
+     * @since 3.18.0
276
+     */
277
+    const FIELD_PRICE = 'wl_schema_price';
278
+
279
+    /**
280
+     * The 'priceCurrency' field name.
281
+     *
282
+     * @since 3.18.0
283
+     */
284
+    const FIELD_PRICE_CURRENCY = 'wl_schema_price_currency';
285
+
286
+    /**
287
+     * The 'availabilityStarts' field name.
288
+     *
289
+     * @since 3.18.0
290
+     */
291
+    const FIELD_AVAILABILITY_STARTS = 'wl_schema_availability_starts';
292
+
293
+    /**
294
+     * The 'availabilityEnds' field name.
295
+     *
296
+     * @since 3.18.0
297
+     */
298
+    const FIELD_AVAILABILITY_ENDS = 'wl_schema_availability_ends';
299
+
300
+    /**
301
+     * The 'validFrom' field name.
302
+     *
303
+     * @since 3.18.0
304
+     */
305
+    const FIELD_VALID_FROM = 'wl_schema_valid_from';
306
+
307
+    /**
308
+     * The 'priceValidUntil' field name.
309
+     *
310
+     * @since 3.18.0
311
+     */
312
+    const FIELD_PRICE_VALID_UNTIL = 'wl_schema_valid_until';
313
+
314
+    /**
315
+     * The 'itemOffered' field name.
316
+     *
317
+     * @since 3.18.0
318
+     */
319
+    const FIELD_ITEM_OFFERED = 'wl_schema_item_offered';
320
+
321
+    /**
322
+     * The 'URI' data type name.
323
+     *
324
+     * @since 3.1.0
325
+     */
326
+    const DATA_TYPE_URI = 'uri';
327
+
328
+    /**
329
+     * The 'date' data type name.
330
+     *
331
+     * @since 3.1.0
332
+     */
333
+    const DATA_TYPE_DATE = 'date';
334
+
335
+    /**
336
+     * The 'dateTime' data type name.
337
+     *
338
+     * @since 3.15.0
339
+     */
340
+    const DATA_TYPE_DATE_TIME = 'dateTime';
341
+
342
+    /**
343
+     * The 'time' data type name.
344
+     *
345
+     * @since 3.14.0
346
+     */
347
+    const DATA_TYPE_DURATION = 'duration';
348
+
349
+    /**
350
+     * The 'double' data type name.
351
+     *
352
+     * @since 3.1.0
353
+     */
354
+    const DATA_TYPE_DOUBLE = 'double';
355
+
356
+    /**
357
+     * The 'string' data type name.
358
+     *
359
+     * @since 3.1.0
360
+     */
361
+    const DATA_TYPE_STRING = 'string';
362
+
363
+    /**
364
+     * The multiline text data type name.
365
+     *
366
+     * @since 3.14.0
367
+     */
368
+    const DATA_TYPE_MULTILINE = 'multiline';
369
+
370
+    /**
371
+     * The 'integer' data type name.
372
+     *
373
+     * @since 3.1.0
374
+     */
375
+    const DATA_TYPE_INTEGER = 'int';
376
+
377
+    /**
378
+     * The 'boolean' data type name.
379
+     *
380
+     * @since 3.1.0
381
+     */
382
+    const DATA_TYPE_BOOLEAN = 'bool';
383
+
384
+    /**
385
+     * The schema.org Event type URI.
386
+     *
387
+     * @since 3.1.0
388
+     */
389
+    const SCHEMA_EVENT_TYPE = 'http://schema.org/Event';
390
+
391
+    /**
392
+     * The schema.org Offer type URI.
393
+     *
394
+     * @since 3.18.0
395
+     */
396
+    const SCHEMA_OFFER_TYPE = 'http://schema.org/Offer';
397
+
398
+    /**
399
+     * The Schema service singleton instance.
400
+     *
401
+     * @since  3.1.0
402
+     * @access private
403
+     * @var \Wordlift_Schema_Service $instance The Schema service singleton instance.
404
+     */
405
+    private static $instance;
406
+
407
+    /**
408
+     * WordLift's schema.
409
+     *
410
+     * @since  3.1.0
411
+     * @access private
412
+     * @var array $schema WordLift's schema.
413
+     */
414
+    private $schema;
415
+
416
+    /**
417
+     * The Log service.
418
+     *
419
+     * @since  3.1.0
420
+     * @access private
421
+     * @var \Wordlift_Log_Service $log The Log service.
422
+     */
423
+    private $log;
424
+
425
+    /**
426
+     * The {@link Wordlift_Post_Property_Storage_Factory} instance.
427
+     *
428
+     * @since  3.15.0
429
+     * @access private
430
+     * @var \Wordlift_Storage_Factory $storage_factory The {@link Wordlift_Post_Property_Storage_Factory} instance.
431
+     */
432
+    private $storage_factory;
433
+
434
+    /**
435
+     * The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
436
+     *
437
+     * @since  3.15.0
438
+     * @access private
439
+     * @var \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
440
+     */
441
+    private $rendition_factory;
442
+
443
+    /**
444
+     * The {@link Wordlift_Configuration_Service} instance.
445
+     *
446
+     * @since  3.15.0
447
+     * @access private
448
+     * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
449
+     */
450
+    private $configuration_service;
451
+
452
+    /**
453
+     * The web site configured language code.
454
+     *
455
+     * @since  3.15.0
456
+     * @access private
457
+     * @var string $language_code The web site configured language code.
458
+     */
459
+    private $language_code;
460
+
461
+    /**
462
+     * Wordlift_Schema_Service constructor.
463
+     *
464
+     * @since 3.1.0
465
+     *
466
+     * @param \Wordlift_Storage_Factory                $storage_factory The {@link Wordlift_Post_Property_Storage_Factory} instance.
467
+     * @param \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
468
+     * @param \Wordlift_Configuration_Service          $configuration_service The {@link Wordlift_Configuration_Service} instance.
469
+     */
470
+    public function __construct( $storage_factory, $rendition_factory, $configuration_service ) {
471
+
472
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Schema_Service' );
473
+
474
+        $this->storage_factory       = $storage_factory;
475
+        $this->rendition_factory     = $rendition_factory;
476
+        $this->configuration_service = $configuration_service;
477
+        $this->language_code         = $this->configuration_service->get_language_code();
478
+
479
+        $schemas = array(
480
+            'article'        => $this->get_article_schema(),
481
+            'thing'          => $this->get_thing_schema(),
482
+            'creative-work'  => $this->get_creative_work_schema(),
483
+            'event'          => $this->get_event_schema(),
484
+            'organization'   => $this->get_organization_schema(),
485
+            'person'         => $this->get_person_schema(),
486
+            'place'          => $this->get_place_schema(),
487
+            'local-business' => $this->get_local_business_schema(),
488
+            'recipe'         => $this->get_recipe_schema(),
489
+            'web-page'       => $this->get_web_page_schema(),
490
+            'offer'          => $this->get_offer_schema(),
491
+        );
492
+
493
+        // Set the taxonomy data.
494
+        // Note: parent types must be defined before child types.
495
+        /**
496
+         * Alter the configured schemas.
497
+         *
498
+         * Enable 3rd parties to alter WordLift's schemas array.
499
+         *
500
+         * @since  3.19.1
501
+         *
502
+         * @param    array $schemas The array of schemas.
503
+         */
504
+        $this->schema = apply_filters( 'wl_schemas', $schemas );
505
+
506
+        // Create a singleton instance of the Schema service, useful to provide static functions to global functions.
507
+        self::$instance = $this;
508
+
509
+        // Hook the `init` to allow plugins to add their schemas.
510
+        add_action( 'init', array( $this, 'init' ) );
511
+
512
+    }
513
+
514
+    /**
515
+     * Hook to the `init`, allow late binding plugins to add their schema.
516
+     *
517
+     * @since 3.19.2
518
+     */
519
+    public function init() {
520
+
521
+        $this->schema = apply_filters( 'wl_schemas_init', $this->schema );
522
+
523
+    }
524
+
525
+    /**
526
+     * Get a reference to the Schema service.
527
+     *
528
+     * @since 3.1.0
529
+     *
530
+     * @return Wordlift_Schema_Service A reference to the Schema service.
531
+     */
532
+    public static function get_instance() {
533
+
534
+        return self::$instance;
535
+    }
536
+
537
+    /**
538
+     * Get the properties for a field with the specified key. The key is used as
539
+     * meta key when the field's value is stored in WordPress meta data table.
540
+     *
541
+     * @since 3.6.0
542
+     *
543
+     * @param string $key The field's key.
544
+     *
545
+     * @return null|array An array of field's properties or null if the field is not found.
546
+     */
547
+    public function get_field( $key ) {
548
+
549
+        // Parse each schema's fields until we find the one we're looking for, then
550
+        // return its properties.
551
+        foreach ( $this->schema as $_ => $schema ) {
552
+
553
+            if ( ! isset( $schema['custom_fields'] ) ) {
554
+                break;
555
+            }
556
+
557
+            foreach ( $schema['custom_fields'] as $field => $props ) {
558
+                if ( $key === $field ) {
559
+                    return $props;
560
+                }
561
+            }
562
+        }
563
+
564
+        return null;
565
+    }
566
+
567
+    /**
568
+     * Get all renditions for each WordLift's schema.
569
+     *
570
+     * @since 3.18.0
571
+     *
572
+     * @return array An array with the schema renditions.
573
+     */
574
+    public function get_renditions() {
575
+        // Get the custom fields.
576
+        $renditions = array_reduce(
577
+            $this->schema,
578
+            function ( $carry, $item ) {
579
+                return array_merge( $carry, $item['linked_data'] );
580
+            },
581
+            array()
582
+        );
583
+
584
+        // Return the schemas.
585
+        return $renditions;
586
+    }
587
+
588
+    /**
589
+     * Get the WordLift's schema.
590
+     *
591
+     * @param string $name The schema name.
592
+     *
593
+     * @return array|null An array with the schema configuration or NULL if the schema is not found.
594
+     *
595
+     * @since 3.1.0
596
+     */
597
+    public function get_schema( $name ) {
598
+        // Check if the schema exists and, if not, return NULL.
599
+        if ( ! isset( $this->schema[ $name ] ) ) {
600
+            return null;
601
+        }
602
+
603
+        // Return the requested schema.
604
+        return $this->schema[ $name ];
605
+    }
606
+
607
+    /**
608
+     * Get the WordLift's schema trough schema type uri.
609
+     *
610
+     * @param string $uri The schema uri.
611
+     *
612
+     * @return array|null An array with the schema configuration or NULL if the schema is not found.
613
+     *
614
+     * @since 3.3.0
615
+     */
616
+    public function get_schema_by_uri( $uri ) {
617
+
618
+        foreach ( $this->schema as $name => $schema ) {
619
+            if ( $schema['uri'] === $uri ) {
620
+                return $schema;
621
+            }
622
+        }
623
+
624
+        return null;
625
+    }
626
+
627
+    /**
628
+     * Get the 'thing' schema.
629
+     *
630
+     * @return array An array with the schema configuration.
631
+     *
632
+     * @since 3.1.0
633
+     */
634
+    private function get_thing_schema() {
635
+
636
+        return array(
637
+            'css_class'     => 'wl-thing',
638
+            'uri'           => 'http://schema.org/Thing',
639
+            'same_as'       => array( '*' ),
640
+            // set as default.
641
+            'custom_fields' => array(
642
+                self::FIELD_SAME_AS                            => array(
643
+                    'predicate'   => 'http://schema.org/sameAs',
644
+                    'type'        => self::DATA_TYPE_URI,
645
+                    'export_type' => 'http://schema.org/Thing',
646
+                    'constraints' => array(
647
+                        'cardinality' => INF,
648
+                    ),
649
+                    // We need a custom metabox.
650
+                    'input_field' => 'sameas',
651
+                ),
652
+                // Add the schema:url property.
653
+                Wordlift_Schema_Url_Property_Service::META_KEY => Wordlift_Schema_Url_Property_Service::get_instance()
654
+                                                                                                        ->get_compat_definition(),
655
+            ),
656
+            // {{sameAs}} not present in the microdata template,
657
+            // because it is treated separately in *wl_content_embed_item_microdata*
658
+            'templates'     => array(
659
+                'subtitle' => '{{id}}',
660
+            ),
661
+            'linked_data'   => array(
662
+                // ### Title to rdfs:label.
663
+                $this->rendition_factory->create(
664
+                    $this->storage_factory->post_title(),
665
+                    Wordlift_Query_Builder::RDFS_LABEL_URI,
666
+                    null,
667
+                    $this->language_code
668
+                ),
669
+                // ### Title to dct:title.
670
+                $this->rendition_factory->create(
671
+                    $this->storage_factory->post_title(),
672
+                    'http://purl.org/dc/terms/title',
673
+                    null,
674
+                    $this->language_code
675
+                ),
676
+                // ### Alternative title to rdfs:label.
677
+                $this->rendition_factory->create(
678
+                    $this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ),
679
+                    Wordlift_Query_Builder::RDFS_LABEL_URI,
680
+                    null,
681
+                    $this->language_code
682
+                ),
683
+                // ### Alternative title to dct:title.
684
+                $this->rendition_factory->create(
685
+                    $this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ),
686
+                    'http://purl.org/dc/terms/title',
687
+                    null,
688
+                    $this->language_code
689
+                ),
690
+                // ### Title to schema:name.
691
+                $this->rendition_factory->create(
692
+                    $this->storage_factory->post_title(),
693
+                    'http://schema.org/name',
694
+                    null,
695
+                    $this->language_code
696
+                ),
697
+                // ### Alternative title to schema:alterName.
698
+                $this->rendition_factory->create(
699
+                    $this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ),
700
+                    'http://schema.org/alternateName',
701
+                    null,
702
+                    $this->language_code
703
+                ),
704
+                // ### schema:url.
705
+                $this->rendition_factory->create(
706
+                    $this->storage_factory->url_property(),
707
+                    Wordlift_Query_Builder::SCHEMA_URL_URI,
708
+                    self::DATA_TYPE_URI
709
+                ),
710
+                // ### schema:description.
711
+                $this->rendition_factory->create(
712
+                    $this->storage_factory->post_description_no_tags_no_shortcodes(),
713
+                    'http://schema.org/description',
714
+                    null,
715
+                    $this->language_code
716
+                ),
717
+                // ### owl:sameAs.
718
+                $this->rendition_factory->create(
719
+                    $this->storage_factory->post_meta( self::FIELD_SAME_AS ),
720
+                    'http://www.w3.org/2002/07/owl#sameAs',
721
+                    self::DATA_TYPE_URI
722
+                ),
723
+                // ### schema:sameAs.
724
+                $this->rendition_factory->create(
725
+                    $this->storage_factory->post_meta( self::FIELD_SAME_AS ),
726
+                    'http://schema.org/sameAs',
727
+                    self::DATA_TYPE_URI
728
+                ),
729
+                // ### rdf:type.
730
+                $this->rendition_factory->create(
731
+                    $this->storage_factory->schema_class(),
732
+                    Wordlift_Query_Builder::RDFS_TYPE_URI,
733
+                    self::DATA_TYPE_URI
734
+                ),
735
+                // ### schema:image.
736
+                $this->rendition_factory->create(
737
+                    $this->storage_factory->post_images(),
738
+                    Wordlift_Query_Builder::SCHEMA_IMAGE_URI,
739
+                    self::DATA_TYPE_URI
740
+                ),
741
+                // ### dct:relation.
742
+                $this->rendition_factory->create(
743
+                    $this->storage_factory->relations(),
744
+                    Wordlift_Query_Builder::DCTERMS_RELATION_URI,
745
+                    self::DATA_TYPE_URI
746
+                ),
747
+            ),
748
+        );
749
+
750
+    }
751
+
752
+    /**
753
+     * Get the 'web-page' schema.
754
+     *
755
+     * @return array An array with the schema configuration.
756
+     *
757
+     * @since 3.18.0
758
+     */
759
+    private function get_web_page_schema() {
760
+
761
+        return array(
762
+            'css_class'   => 'wl-webpage',
763
+            'uri'         => 'http://schema.org/WebPage',
764
+            'linked_data' => array(
765
+                // ### schema:headline.
766
+                $this->rendition_factory->create(
767
+                    $this->storage_factory->post_title(),
768
+                    'http://schema.org/headline',
769
+                    null,
770
+                    $this->language_code
771
+                ),
772
+                // ### schema:url.
773
+                $this->rendition_factory->create(
774
+                    $this->storage_factory->url_property(),
775
+                    Wordlift_Query_Builder::SCHEMA_URL_URI,
776
+                    self::DATA_TYPE_URI
777
+                ),
778
+                // ### rdf:type.
779
+                $this->rendition_factory->create(
780
+                    $this->storage_factory->schema_class(),
781
+                    Wordlift_Query_Builder::RDFS_TYPE_URI,
782
+                    self::DATA_TYPE_URI
783
+                ),
784
+                // ### dcterms:references.
785
+                $this->rendition_factory->create(
786
+                    $this->storage_factory->relations(),
787
+                    Wordlift_Query_Builder::DCTERMS_REFERENCES_URI,
788
+                    self::DATA_TYPE_URI,
789
+                    $this->language_code
790
+                ),
791
+            ),
792
+        );
793
+
794
+    }
795
+
796
+    /**
797
+     * Get the 'creative work' schema.
798
+     *
799
+     * @return array An array with the schema configuration.
800
+     *
801
+     * @since 3.1.0
802
+     */
803
+    private function get_creative_work_schema() {
804
+
805
+        $schema = array(
806
+            'label'         => 'CreativeWork',
807
+            'description'   => 'A creative work (or a Music Album).',
808
+            'parents'       => array( 'thing' ),
809
+            // Give term slug as parent.
810
+            'css_class'     => 'wl-creative-work',
811
+            'uri'           => 'http://schema.org/CreativeWork',
812
+            'same_as'       => array(
813
+                'http://schema.org/MusicAlbum',
814
+                'http://schema.org/Product',
815
+            ),
816
+            'custom_fields' => array(
817
+                self::FIELD_AUTHOR => array(
818
+                    'predicate'   => 'http://schema.org/author',
819
+                    'type'        => self::DATA_TYPE_URI,
820
+                    'export_type' => 'http://schema.org/Person',
821
+                    'constraints' => array(
822
+                        'uri_type'    => array( 'Person', 'Organization' ),
823
+                        'cardinality' => INF,
824
+                    ),
825
+                ),
826
+            ),
827
+            'linked_data'   => array(
828
+                // ### schema:author.
829
+                $this->rendition_factory->create(
830
+                    $this->storage_factory->author_uri(),
831
+                    Wordlift_Query_Builder::SCHEMA_AUTHOR_URI,
832
+                    self::DATA_TYPE_URI
833
+                ),
834
+            ),
835
+            'templates'     => array(
836
+                'subtitle' => '{{id}}',
837
+            ),
838
+        );
839
+
840
+        // Merge the custom fields with those provided by the thing schema.
841
+        $parent_schema           = $this->get_thing_schema();
842
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
843
+        $schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
844
+
845
+        return $schema;
846
+    }
847
+
848
+    /**
849
+     * Get the 'event' schema.
850
+     *
851
+     * @return array An array with the schema configuration.
852
+     *
853
+     * @since 3.1.0
854
+     */
855
+    private function get_event_schema() {
856
+
857
+        $schema = array(
858
+            'label'         => 'Event',
859
+            'description'   => 'An event . ',
860
+            'parents'       => array( 'thing' ),
861
+            'css_class'     => 'wl-event',
862
+            'uri'           => self::SCHEMA_EVENT_TYPE,
863
+            'same_as'       => array( 'http://dbpedia.org/ontology/Event' ),
864
+            'custom_fields' => array(
865
+                self::FIELD_DATE_START => array(
866
+                    'predicate'   => 'http://schema.org/startDate',
867
+                    'type'        => self::DATA_TYPE_DATE,
868
+                    'export_type' => 'xsd:dateTime',
869
+                    'constraints' => '',
870
+                ),
871
+                self::FIELD_DATE_END   => array(
872
+                    'predicate'   => 'http://schema.org/endDate',
873
+                    'type'        => self::DATA_TYPE_DATE,
874
+                    'export_type' => 'xsd:dateTime',
875
+                    'constraints' => '',
876
+                ),
877
+                self::FIELD_LOCATION   => array(
878
+                    'predicate'   => 'http://schema.org/location',
879
+                    'type'        => self::DATA_TYPE_URI,
880
+                    'export_type' => 'http://schema.org/PostalAddress',
881
+                    'constraints' => array(
882
+                        'uri_type'    => array( 'Place', 'LocalBusiness' ),
883
+                        'cardinality' => INF,
884
+                    ),
885
+                ),
886
+                self::FIELD_PERFORMER  => array(
887
+                    'predicate'   => 'http://schema.org/performer',
888
+                    'type'        => self::DATA_TYPE_URI,
889
+                    'export_type' => 'http://schema.org/Person',
890
+                    'constraints' => array(
891
+                        'uri_type'    => array( 'Person', 'Organization' ),
892
+                        'cardinality' => INF,
893
+                    ),
894
+                ),
895
+                self::FIELD_OFFERS     => array(
896
+                    'predicate'   => 'http://schema.org/offers',
897
+                    'type'        => self::DATA_TYPE_URI,
898
+                    'export_type' => 'http://schema.org/Offer',
899
+                    'constraints' => array(
900
+                        'uri_type'    => array( 'Offer' ),
901
+                        'cardinality' => INF,
902
+                    ),
903
+                ),
904
+            ),
905
+            'linked_data'   => array(
906
+                // ### schema:startDate.
907
+                $this->rendition_factory->create(
908
+                    $this->storage_factory->post_meta( self::FIELD_DATE_START ),
909
+                    'http://schema.org/startDate',
910
+                    self::DATA_TYPE_DATE_TIME
911
+                ),
912
+                // ### schema:endDate.
913
+                $this->rendition_factory->create(
914
+                    $this->storage_factory->post_meta( self::FIELD_DATE_END ),
915
+                    'http://schema.org/endDate',
916
+                    self::DATA_TYPE_DATE_TIME
917
+                ),
918
+                // ### schema:location.
919
+                $this->rendition_factory->create(
920
+                    $this->storage_factory->post_meta_to_uri( self::FIELD_LOCATION ),
921
+                    'http://schema.org/location',
922
+                    self::DATA_TYPE_URI
923
+                ),
924
+                // ### schema:performer.
925
+                $this->rendition_factory->create(
926
+                    $this->storage_factory->post_meta_to_uri( self::FIELD_PERFORMER ),
927
+                    'http://schema.org/performer',
928
+                    self::DATA_TYPE_URI
929
+                ),
930
+                // ### schema:offers.
931
+                $this->rendition_factory->create(
932
+                    $this->storage_factory->post_meta_to_uri( self::FIELD_OFFERS ),
933
+                    'http://schema.org/offers',
934
+                    self::DATA_TYPE_URI
935
+                ),
936
+            ),
937
+            'templates'     => array(
938
+                'subtitle' => '{{id}}',
939
+            ),
940
+        );
941
+
942
+        // Merge the custom fields with those provided by the thing schema.
943
+        $parent_schema           = $this->get_thing_schema();
944
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
945
+        $schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
946
+
947
+        return $schema;
948
+    }
949
+
950
+    /**
951
+     * Get the 'organization' schema.
952
+     *
953
+     * @return array An array with the schema configuration.
954
+     *
955
+     * @since 3.1.0
956
+     */
957
+    private function get_organization_schema() {
958
+
959
+        $schema = array(
960
+            'label'         => 'Organization',
961
+            'description'   => 'An organization, including a government or a newspaper.',
962
+            'parents'       => array( 'thing' ),
963
+            'css_class'     => 'wl-organization',
964
+            'uri'           => 'http://schema.org/Organization',
965
+            'same_as'       => array(
966
+                'http://rdf.freebase.com/ns/organization.organization',
967
+                'http://rdf.freebase.com/ns/government.government',
968
+                'http://schema.org/Newspaper',
969
+            ),
970
+            'custom_fields' => array(
971
+                self::FIELD_LEGAL_NAME          => array(
972
+                    'predicate'   => 'http://schema.org/legalName',
973
+                    'type'        => self::DATA_TYPE_STRING,
974
+                    'export_type' => 'xsd:string',
975
+                    'constraints' => '',
976
+                ),
977
+                self::FIELD_FOUNDER             => array(
978
+                    'predicate'   => 'http://schema.org/founder',
979
+                    'type'        => self::DATA_TYPE_URI,
980
+                    'export_type' => 'http://schema.org/Person',
981
+                    'constraints' => array(
982
+                        'uri_type'    => 'Person',
983
+                        'cardinality' => INF,
984
+                    ),
985
+                ),
986
+                self::FIELD_ADDRESS             => array(
987
+                    'predicate'   => 'http://schema.org/streetAddress',
988
+                    'type'        => self::DATA_TYPE_STRING,
989
+                    'export_type' => 'xsd:string',
990
+                    'constraints' => '',
991
+                    // To build custom metabox.
992
+                    'input_field' => 'address',
993
+                ),
994
+                self::FIELD_ADDRESS_PO_BOX      => array(
995
+                    'predicate'   => 'http://schema.org/postOfficeBoxNumber',
996
+                    'type'        => self::DATA_TYPE_STRING,
997
+                    'export_type' => 'xsd:string',
998
+                    'constraints' => '',
999
+                    // To build custom metabox.
1000
+                    'input_field' => 'address',
1001
+                ),
1002
+                self::FIELD_ADDRESS_POSTAL_CODE => array(
1003
+                    'predicate'   => 'http://schema.org/postalCode',
1004
+                    'type'        => self::DATA_TYPE_STRING,
1005
+                    'export_type' => 'xsd:string',
1006
+                    'constraints' => '',
1007
+                    // To build custom metabox.
1008
+                    'input_field' => 'address',
1009
+                ),
1010
+                self::FIELD_ADDRESS_LOCALITY    => array(
1011
+                    'predicate'   => 'http://schema.org/addressLocality',
1012
+                    'type'        => self::DATA_TYPE_STRING,
1013
+                    'export_type' => 'xsd:string',
1014
+                    'constraints' => '',
1015
+                    // To build custom metabox.
1016
+                    'input_field' => 'address',
1017
+                ),
1018
+                self::FIELD_ADDRESS_REGION      => array(
1019
+                    'predicate'   => 'http://schema.org/addressRegion',
1020
+                    'type'        => self::DATA_TYPE_STRING,
1021
+                    'export_type' => 'xsd:string',
1022
+                    'constraints' => '',
1023
+                    // To build custom metabox.
1024
+                    'input_field' => 'address',
1025
+                ),
1026
+                self::FIELD_ADDRESS_COUNTRY     => array(
1027
+                    'predicate'   => 'http://schema.org/addressCountry',
1028
+                    'type'        => self::DATA_TYPE_STRING,
1029
+                    'export_type' => 'xsd:string',
1030
+                    'constraints' => '',
1031
+                    // To build custom metabox.
1032
+                    'input_field' => 'address',
1033
+                ),
1034
+                self::FIELD_EMAIL               => array(
1035
+                    'predicate'   => 'http://schema.org/email',
1036
+                    'type'        => self::DATA_TYPE_STRING,
1037
+                    'export_type' => 'xsd:string',
1038
+                    'constraints' => '',
1039
+                ),
1040
+                self::FIELD_TELEPHONE           => array(
1041
+                    'predicate'   => 'http://schema.org/telephone',
1042
+                    'type'        => self::DATA_TYPE_STRING,
1043
+                    'export_type' => 'xsd:string',
1044
+                    'constraints' => '',
1045
+                ),
1046
+            ),
1047
+            'linked_data'   => array(
1048
+                // ### schema:legalName.
1049
+                $this->rendition_factory->create(
1050
+                    $this->storage_factory->post_meta( self::FIELD_LEGAL_NAME ),
1051
+                    'http://schema.org/legalName'
1052
+                ),
1053
+                // ### schema:founder.
1054
+                $this->rendition_factory->create(
1055
+                    $this->storage_factory->post_meta_to_uri( self::FIELD_FOUNDER ),
1056
+                    'http://schema.org/founder',
1057
+                    self::DATA_TYPE_URI
1058
+                ),
1059
+                // ### schema:email.
1060
+                $this->rendition_factory->create(
1061
+                    $this->storage_factory->post_meta( self::FIELD_EMAIL ),
1062
+                    'http://schema.org/email'
1063
+                ),
1064
+                // ### schema:telephone.
1065
+                $this->rendition_factory->create(
1066
+                    $this->storage_factory->post_meta( self::FIELD_TELEPHONE ),
1067
+                    'http://schema.org/telephone'
1068
+                ),
1069
+            ),
1070
+            'templates'     => array(
1071
+                'subtitle' => '{{id}}',
1072
+            ),
1073
+        );
1074
+
1075
+        // Merge the custom fields with those provided by the thing schema.
1076
+        $parent_schema           = $this->get_thing_schema();
1077
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1078
+        $schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1079
+
1080
+        return $schema;
1081
+    }
1082
+
1083
+    /**
1084
+     * Get the 'person' schema.
1085
+     *
1086
+     * @return array An array with the schema configuration.
1087
+     *
1088
+     * @since 3.1.0
1089
+     */
1090
+    private function get_person_schema() {
1091
+
1092
+        $schema = array(
1093
+            'label'         => 'Person',
1094
+            'description'   => 'A person (or a music artist).',
1095
+            'parents'       => array( 'thing' ),
1096
+            'css_class'     => 'wl-person',
1097
+            'uri'           => 'http://schema.org/Person',
1098
+            'same_as'       => array(
1099
+                'http://rdf.freebase.com/ns/people.person',
1100
+                'http://rdf.freebase.com/ns/music.artist',
1101
+                'http://dbpedia.org/class/yago/LivingPeople',
1102
+            ),
1103
+            'custom_fields' => array(
1104
+                self::FIELD_KNOWS       => array(
1105
+                    'predicate'   => 'http://schema.org/knows',
1106
+                    'type'        => self::DATA_TYPE_URI,
1107
+                    'export_type' => 'http://schema.org/Person',
1108
+                    'constraints' => array(
1109
+                        'uri_type'    => 'Person',
1110
+                        'cardinality' => INF,
1111
+                    ),
1112
+                ),
1113
+                self::FIELD_BIRTH_DATE  => array(
1114
+                    'predicate'   => 'http://schema.org/birthDate',
1115
+                    'type'        => self::DATA_TYPE_DATE,
1116
+                    'export_type' => 'xsd:date',
1117
+                    'constraints' => '',
1118
+                ),
1119
+                self::FIELD_BIRTH_PLACE => array(
1120
+                    'predicate'   => 'http://schema.org/birthPlace',
1121
+                    'type'        => self::DATA_TYPE_URI,
1122
+                    'export_type' => 'http://schema.org/Place',
1123
+                    'constraints' => array(
1124
+                        'uri_type' => 'Place',
1125
+                    ),
1126
+                ),
1127
+                self::FIELD_AFFILIATION => array(
1128
+                    'predicate'   => 'http://schema.org/affiliation',
1129
+                    'type'        => self::DATA_TYPE_URI,
1130
+                    'export_type' => 'http://schema.org/Organization',
1131
+                    'constraints' => array(
1132
+                        'uri_type'    => array(
1133
+                            'Organization',
1134
+                            'LocalBusiness',
1135
+                        ),
1136
+                        'cardinality' => INF,
1137
+                    ),
1138
+                ),
1139
+                self::FIELD_EMAIL       => array(
1140
+                    'predicate'   => 'http://schema.org/email',
1141
+                    'type'        => self::DATA_TYPE_STRING,
1142
+                    'export_type' => 'xsd:string',
1143
+                    'constraints' => array(
1144
+                        'cardinality' => INF,
1145
+                    ),
1146
+                ),
1147
+            ),
1148
+            'linked_data'   => array(
1149
+                // ### schema:knows.
1150
+                $this->rendition_factory->create(
1151
+                    $this->storage_factory->post_meta_to_uri( self::FIELD_KNOWS ),
1152
+                    'http://schema.org/knows',
1153
+                    self::DATA_TYPE_URI
1154
+                ),
1155
+                // ### schema:birthDate.
1156
+                $this->rendition_factory->create(
1157
+                    $this->storage_factory->post_meta( self::FIELD_BIRTH_DATE ),
1158
+                    'http://schema.org/birthDate',
1159
+                    self::DATA_TYPE_DATE
1160
+                ),
1161
+                // ### schema:birthPlace.
1162
+                $this->rendition_factory->create(
1163
+                    $this->storage_factory->post_meta_to_uri( self::FIELD_BIRTH_PLACE ),
1164
+                    'http://schema.org/birthPlace',
1165
+                    self::DATA_TYPE_URI
1166
+                ),
1167
+                // ### schema:affiliation.
1168
+                $this->rendition_factory->create(
1169
+                    $this->storage_factory->post_meta_to_uri( self::FIELD_AFFILIATION ),
1170
+                    'http://schema.org/affiliation',
1171
+                    self::DATA_TYPE_URI
1172
+                ),
1173
+                // ### schema:email.
1174
+                $this->rendition_factory->create(
1175
+                    $this->storage_factory->post_meta( self::FIELD_EMAIL ),
1176
+                    'http://schema.org/email'
1177
+                ),
1178
+            ),
1179
+            'templates'     => array(
1180
+                'subtitle' => '{{id}}',
1181
+            ),
1182
+        );
1183
+
1184
+        // Merge the custom fields with those provided by the thing schema.
1185
+        $parent_schema           = $this->get_thing_schema();
1186
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1187
+        $schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1188
+
1189
+        return $schema;
1190
+
1191
+    }
1192
+
1193
+    /**
1194
+     * Get the 'place' schema.
1195
+     *
1196
+     * @return array An array with the schema configuration.
1197
+     *
1198
+     * @since 3.1.0
1199
+     */
1200
+    private function get_place_schema() {
1201
+
1202
+        $schema = array(
1203
+            'label'         => 'Place',
1204
+            'description'   => 'A place.',
1205
+            'parents'       => array( 'thing' ),
1206
+            'css_class'     => 'wl-place',
1207
+            'uri'           => 'http://schema.org/Place',
1208
+            'same_as'       => array(
1209
+                'http://rdf.freebase.com/ns/location.location',
1210
+                'http://www.opengis.net/gml/_Feature',
1211
+            ),
1212
+            'custom_fields' => array(
1213
+                self::FIELD_GEO_LATITUDE        => array(
1214
+                    'predicate'   => 'http://schema.org/latitude',
1215
+                    'type'        => self::DATA_TYPE_DOUBLE,
1216
+                    'export_type' => 'xsd:double',
1217
+                    'constraints' => '',
1218
+                    // To build custom metabox.
1219
+                    'input_field' => 'coordinates',
1220
+                ),
1221
+                self::FIELD_GEO_LONGITUDE       => array(
1222
+                    'predicate'   => 'http://schema.org/longitude',
1223
+                    'type'        => self::DATA_TYPE_DOUBLE,
1224
+                    'export_type' => 'xsd:double',
1225
+                    'constraints' => '',
1226
+                    // To build custom metabox.
1227
+                    'input_field' => 'coordinates',
1228
+                ),
1229
+                self::FIELD_ADDRESS             => array(
1230
+                    'predicate'   => 'http://schema.org/streetAddress',
1231
+                    'type'        => self::DATA_TYPE_STRING,
1232
+                    'export_type' => 'xsd:string',
1233
+                    'constraints' => '',
1234
+                    // To build custom metabox.
1235
+                    'input_field' => 'address',
1236
+                ),
1237
+                self::FIELD_ADDRESS_PO_BOX      => array(
1238
+                    'predicate'   => 'http://schema.org/postOfficeBoxNumber',
1239
+                    'type'        => self::DATA_TYPE_STRING,
1240
+                    'export_type' => 'xsd:string',
1241
+                    'constraints' => '',
1242
+                    // To build custom metabox.
1243
+                    'input_field' => 'address',
1244
+                ),
1245
+                self::FIELD_ADDRESS_POSTAL_CODE => array(
1246
+                    'predicate'   => 'http://schema.org/postalCode',
1247
+                    'type'        => self::DATA_TYPE_STRING,
1248
+                    'export_type' => 'xsd:string',
1249
+                    'constraints' => '',
1250
+                    // To build custom metabox.
1251
+                    'input_field' => 'address',
1252
+                ),
1253
+                self::FIELD_ADDRESS_LOCALITY    => array(
1254
+                    'predicate'   => 'http://schema.org/addressLocality',
1255
+                    'type'        => self::DATA_TYPE_STRING,
1256
+                    'export_type' => 'xsd:string',
1257
+                    'constraints' => '',
1258
+                    // To build custom metabox.
1259
+                    'input_field' => 'address',
1260
+                ),
1261
+                self::FIELD_ADDRESS_REGION      => array(
1262
+                    'predicate'   => 'http://schema.org/addressRegion',
1263
+                    'type'        => self::DATA_TYPE_STRING,
1264
+                    'export_type' => 'xsd:string',
1265
+                    'constraints' => '',
1266
+                    // To build custom metabox.
1267
+                    'input_field' => 'address',
1268
+                ),
1269
+                self::FIELD_ADDRESS_COUNTRY     => array(
1270
+                    'predicate'   => 'http://schema.org/addressCountry',
1271
+                    'type'        => self::DATA_TYPE_STRING,
1272
+                    'export_type' => 'xsd:string',
1273
+                    'constraints' => '',
1274
+                    // To build custom metabox.
1275
+                    'input_field' => 'address',
1276
+                ),
1277
+            ),
1278
+            'linked_data'   => array(
1279
+                $this->rendition_factory->create_address(
1280
+                    $this->storage_factory,
1281
+                    $this->language_code
1282
+                ),
1283
+            ),
1284
+            'templates'     => array(
1285
+                'subtitle' => '{{id}}',
1286
+            ),
1287
+        );
1288
+
1289
+        // Merge the custom fields with those provided by the thing schema.
1290
+        $parent_schema           = $this->get_thing_schema();
1291
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1292
+        $schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1293
+
1294
+        return $schema;
1295
+    }
1296
+
1297
+    /**
1298
+     * Get the 'local business' schema.
1299
+     *
1300
+     * @return array An array with the schema configuration.
1301
+     *
1302
+     * @since 3.1.0
1303
+     */
1304
+    private function get_local_business_schema() {
1305
+
1306
+        $schema = array(
1307
+            'label'         => 'LocalBusiness',
1308
+            'description'   => 'A local business.',
1309
+            'parents'       => array( 'place', 'organization' ),
1310
+            'css_class'     => 'wl-local-business',
1311
+            'uri'           => 'http://schema.org/LocalBusiness',
1312
+            'same_as'       => array(
1313
+                'http://rdf.freebase.com/ns/business/business_location',
1314
+                'https://schema.org/Store',
1315
+            ),
1316
+            'custom_fields' => array(),
1317
+            'linked_data'   => array(),
1318
+            'templates'     => array(
1319
+                'subtitle' => '{{id}}',
1320
+            ),
1321
+        );
1322
+
1323
+        // Merge the custom fields with those provided by the place and organization schema.
1324
+        $place_schema            = $this->get_place_schema();
1325
+        $organization_schema     = $this->get_organization_schema();
1326
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields'] );
1327
+        $schema['linked_data']   = array_merge( $schema['linked_data'], $place_schema['linked_data'], $organization_schema['linked_data'] );
1328
+
1329
+        return $schema;
1330
+    }
1331
+
1332
+    /**
1333
+     * Get the 'recipe' schema.
1334
+     *
1335
+     * @return array An array with the schema configuration.
1336
+     *
1337
+     * @since 3.14.0
1338
+     */
1339
+    private function get_recipe_schema() {
1340
+
1341
+        $schema = array(
1342
+            'label'         => 'Recipe',
1343
+            'description'   => 'A Recipe.',
1344
+            'parents'       => array( 'CreativeWork' ),
1345
+            'css_class'     => 'wl-recipe',
1346
+            'uri'           => 'http://schema.org/Recipe',
1347
+            'same_as'       => array(),
1348
+            'templates'     => array(
1349
+                'subtitle' => '{{id}}',
1350
+            ),
1351
+            'custom_fields' => array(
1352
+                self::FIELD_RECIPE_CUISINE          => array(
1353
+                    'predicate'   => 'http://schema.org/recipeCuisine',
1354
+                    'type'        => self::DATA_TYPE_STRING,
1355
+                    'export_type' => 'xsd:string',
1356
+                    'constraints' => '',
1357
+                    'metabox'     => array(
1358
+                        'label' => __( 'Recipe cuisine', 'wordlift' ),
1359
+                    ),
1360
+                ),
1361
+                self::FIELD_RECIPE_INGREDIENT       => array(
1362
+                    'predicate'   => 'http://schema.org/recipeIngredient',
1363
+                    'type'        => self::DATA_TYPE_STRING,
1364
+                    'export_type' => 'xsd:string',
1365
+                    'constraints' => array(
1366
+                        'cardinality' => INF,
1367
+                    ),
1368
+                    'metabox'     => array(
1369
+                        'label' => __( 'Recipe ingredient', 'wordlift' ),
1370
+                    ),
1371
+                ),
1372
+                self::FIELD_RECIPE_INSTRUCTIONS     => array(
1373
+                    'predicate'   => 'http://schema.org/recipeInstructions',
1374
+                    'type'        => self::DATA_TYPE_MULTILINE,
1375
+                    'export_type' => 'xsd:string',
1376
+                    'constraints' => '',
1377
+                    'metabox'     => array(
1378
+                        'class' => 'Wordlift_Metabox_Field_Multiline',
1379
+                        'label' => __( 'Recipe instructions', 'wordlift' ),
1380
+                    ),
1381
+                ),
1382
+                self::FIELD_RECIPE_YIELD            => array(
1383
+                    'predicate'   => 'http://schema.org/recipeYield',
1384
+                    'type'        => self::DATA_TYPE_STRING,
1385
+                    'export_type' => 'xsd:string',
1386
+                    'constraints' => '',
1387
+                    'metabox'     => array(
1388
+                        'label' => __( 'Recipe number of servings', 'wordlift' ),
1389
+                    ),
1390
+                ),
1391
+                self::FIELD_RECIPE_INGREDIENT       => array(
1392
+                    'predicate'   => 'http://schema.org/recipeIngredient',
1393
+                    'type'        => self::DATA_TYPE_STRING,
1394
+                    'export_type' => 'xsd:string',
1395
+                    'constraints' => array(
1396
+                        'cardinality' => INF,
1397
+                    ),
1398
+                    'metabox'     => array(
1399
+                        'label' => __( 'Recipe ingredient', 'wordlift' ),
1400
+                    ),
1401
+                ),
1402
+                self::FIELD_NUTRITION_INFO_CALORIES => array(
1403
+                    'predicate'   => 'http://schema.org/calories',
1404
+                    'type'        => self::DATA_TYPE_STRING,
1405
+                    'export_type' => 'xsd:string',
1406
+                    'constraints' => '',
1407
+                    'metabox'     => array(
1408
+                        'label' => __( 'Calories (e.g. 240 calories)', 'wordlift' ),
1409
+                    ),
1410
+                ),
1411
+                self::FIELD_PREP_TIME               => array(
1412
+                    'predicate'   => 'http://schema.org/prepTime',
1413
+                    'type'        => self::DATA_TYPE_DURATION,
1414
+                    'export_type' => 'xsd:time',
1415
+                    'constraints' => '',
1416
+                    'metabox'     => array(
1417
+                        'class' => 'Wordlift_Metabox_Field_Duration',
1418
+                        'label' => __( 'Recipe preparation time (e.g. 1:30)', 'wordlift' ),
1419
+                    ),
1420
+                ),
1421
+                self::FIELD_COOK_TIME               => array(
1422
+                    'predicate'   => 'http://schema.org/cookTime',
1423
+                    'type'        => self::DATA_TYPE_DURATION,
1424
+                    'export_type' => 'xsd:time',
1425
+                    'constraints' => '',
1426
+                    'metabox'     => array(
1427
+                        'class' => 'Wordlift_Metabox_Field_Duration',
1428
+                        'label' => __( 'Recipe cook time (e.g. 1:30)', 'wordlift' ),
1429
+                    ),
1430
+                ),
1431
+                self::FIELD_TOTAL_TIME              => array(
1432
+                    'predicate'   => 'http://schema.org/totalTime',
1433
+                    'type'        => self::DATA_TYPE_DURATION,
1434
+                    'export_type' => 'xsd:time',
1435
+                    'constraints' => '',
1436
+                    'metabox'     => array(
1437
+                        'class' => 'Wordlift_Metabox_Field_Duration',
1438
+                        'label' => __( 'Recipe total time (e.g. 1:30)', 'wordlift' ),
1439
+                    ),
1440
+                ),
1441
+            ),
1442
+            'linked_data'   => array(
1443
+                // ### schema:recipeCuisine.
1444
+                $this->rendition_factory->create(
1445
+                    $this->storage_factory->post_meta( self::FIELD_RECIPE_CUISINE ),
1446
+                    'http://schema.org/recipeCuisine'
1447
+                ),
1448
+                // ### schema:recipeIngredient.
1449
+                $this->rendition_factory->create(
1450
+                    $this->storage_factory->post_meta( self::FIELD_RECIPE_INGREDIENT ),
1451
+                    'http://schema.org/recipeIngredient'
1452
+                ),
1453
+                // ### schema:recipeInstructions.
1454
+                $this->rendition_factory->create(
1455
+                    $this->storage_factory->post_meta( self::FIELD_RECIPE_INSTRUCTIONS ),
1456
+                    'http://schema.org/recipeInstructions'
1457
+                ),
1458
+                // ### schema:recipeYield.
1459
+                $this->rendition_factory->create(
1460
+                    $this->storage_factory->post_meta( self::FIELD_RECIPE_YIELD ),
1461
+                    'http://schema.org/recipeYield'
1462
+                ),
1463
+                // ### schema:prepTime.
1464
+                $this->rendition_factory->create(
1465
+                    $this->storage_factory->post_meta( self::FIELD_PREP_TIME ),
1466
+                    'http://schema.org/prepTime',
1467
+                    self::DATA_TYPE_DURATION
1468
+                ),
1469
+                // ### schema:cookTime.
1470
+                $this->rendition_factory->create(
1471
+                    $this->storage_factory->post_meta( self::FIELD_COOK_TIME ),
1472
+                    'http://schema.org/cookTime',
1473
+                    self::DATA_TYPE_DURATION
1474
+                ),
1475
+                // ### schema:totalTime.
1476
+                $this->rendition_factory->create(
1477
+                    $this->storage_factory->post_meta( self::FIELD_TOTAL_TIME ),
1478
+                    'http://schema.org/totalTime',
1479
+                    self::DATA_TYPE_DURATION
1480
+                ),
1481
+            ),
1482
+        );
1483
+
1484
+        // Merge the custom fields with those provided by the parent schema.
1485
+        $parent_schema           = $this->get_creative_work_schema();
1486
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1487
+        $schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1488
+
1489
+        return $schema;
1490
+    }
1491
+
1492
+    /**
1493
+     * Get the 'offer' schema.
1494
+     *
1495
+     * @return array An array with the schema configuration.
1496
+     *
1497
+     * @since 3.18.0
1498
+     */
1499
+    private function get_offer_schema() {
1500
+
1501
+        $schema = array(
1502
+            'label'         => 'Offer',
1503
+            'description'   => 'An offer. ',
1504
+            'parents'       => array( 'thing' ),
1505
+            'css_class'     => 'wl-offer',
1506
+            'uri'           => self::SCHEMA_OFFER_TYPE,
1507
+            'same_as'       => array(),
1508
+            'templates'     => array(
1509
+                'subtitle' => '{{id}}',
1510
+            ),
1511
+            'custom_fields' => array(
1512
+                self::FIELD_AVAILABILITY        => array(
1513
+                    'predicate'   => 'http://schema.org/availability',
1514
+                    'type'        => self::DATA_TYPE_STRING,
1515
+                    'export_type' => 'xsd:string',
1516
+                    'metabox'     => array(
1517
+                        'class' => 'Wordlift_Metabox_Field_Select',
1518
+                    ),
1519
+                    'options'     => array(
1520
+                        'Discontinued'        => esc_html__( 'Discontinued', 'wordlift' ),
1521
+                        'InStock'             => esc_html__( 'In Stock', 'wordlift' ),
1522
+                        'InStoreOnly'         => esc_html__( 'In Store Only', 'wordlift' ),
1523
+                        'LimitedAvailability' => esc_html__( 'Limited Availability', 'wordlift' ),
1524
+                        'OnlineOnly'          => esc_html__( 'Online Only', 'wordlift' ),
1525
+                        'OutOfStock'          => esc_html__( 'Out of Stock', 'wordlift' ),
1526
+                        'PreOrder'            => esc_html__( 'Pre Order', 'wordlift' ),
1527
+                        'PreSale'             => esc_html__( 'Pre Sale', 'wordlift' ),
1528
+                        'SoldOut'             => esc_html__( 'Sold Out', 'wordlift' ),
1529
+                    ),
1530
+                ),
1531
+                self::FIELD_PRICE               => array(
1532
+                    'predicate'   => 'http://schema.org/price',
1533
+                    'type'        => self::DATA_TYPE_STRING,
1534
+                    'export_type' => 'xsd:integer',
1535
+                    'metabox'     => array(
1536
+                        'class' => 'Wordlift_Metabox_Field_Integer',
1537
+                    ),
1538
+                ),
1539
+                self::FIELD_PRICE_CURRENCY      => array(
1540
+                    'predicate'   => 'http://schema.org/priceCurrency',
1541
+                    'type'        => self::DATA_TYPE_STRING,
1542
+                    'export_type' => 'xsd:string',
1543
+                ),
1544
+                self::FIELD_AVAILABILITY_STARTS => array(
1545
+                    'predicate'   => 'http://schema.org/availabilityStarts',
1546
+                    'type'        => self::DATA_TYPE_DATE,
1547
+                    'export_type' => 'xsd:dateTime',
1548
+                ),
1549
+                self::FIELD_AVAILABILITY_ENDS   => array(
1550
+                    'predicate'   => 'http://schema.org/availabilityEnds',
1551
+                    'type'        => self::DATA_TYPE_DATE,
1552
+                    'export_type' => 'xsd:dateTime',
1553
+                ),
1554
+                self::FIELD_INVENTORY_LEVEL     => array(
1555
+                    'predicate'   => 'http://schema.org/inventoryLevel',
1556
+                    'type'        => self::DATA_TYPE_STRING,
1557
+                    'export_type' => 'xsd:integer',
1558
+                    'metabox'     => array(
1559
+                        'class' => 'Wordlift_Metabox_Field_Integer',
1560
+                    ),
1561
+                ),
1562
+                self::FIELD_VALID_FROM          => array(
1563
+                    'predicate'   => 'http://schema.org/validFrom',
1564
+                    'type'        => self::DATA_TYPE_DATE,
1565
+                    'export_type' => 'xsd:dateTime',
1566
+                ),
1567
+                self::FIELD_PRICE_VALID_UNTIL   => array(
1568
+                    'predicate'   => 'http://schema.org/priceValidUntil',
1569
+                    'type'        => self::DATA_TYPE_DATE,
1570
+                    'export_type' => 'xsd:dateTime',
1571
+                ),
1572
+                self::FIELD_ITEM_OFFERED        => array(
1573
+                    'predicate'   => 'http://schema.org/itemOffered',
1574
+                    'type'        => self::DATA_TYPE_URI,
1575
+                    'export_type' => 'http://schema.org/Thing',
1576
+                    'constraints' => array(
1577
+                        'uri_type'    => array(
1578
+                            'Event',
1579
+                            'Thing',
1580
+                        ),
1581
+                        'cardinality' => INF,
1582
+                    ),
1583
+                ),
1584
+            ),
1585
+            'linked_data'   => array(
1586
+                // ### schema:availability.
1587
+                $this->rendition_factory->create(
1588
+                    $this->storage_factory->post_meta( self::FIELD_AVAILABILITY ),
1589
+                    'http://schema.org/availability',
1590
+                    null
1591
+                ),
1592
+                // ### schema:availabilityStarts.
1593
+                $this->rendition_factory->create(
1594
+                    $this->storage_factory->post_meta( self::FIELD_AVAILABILITY_STARTS ),
1595
+                    'http://schema.org/availabilityStarts',
1596
+                    self::DATA_TYPE_DATE_TIME
1597
+                ),
1598
+                // ### schema:availabilityEnds.
1599
+                $this->rendition_factory->create(
1600
+                    $this->storage_factory->post_meta( self::FIELD_AVAILABILITY_ENDS ),
1601
+                    'http://schema.org/availabilityEnds',
1602
+                    self::DATA_TYPE_DATE_TIME
1603
+                ),
1604
+                // ### schema:inventoryLevel.
1605
+                $this->rendition_factory->create(
1606
+                    $this->storage_factory->post_meta( self::FIELD_INVENTORY_LEVEL ),
1607
+                    'http://schema.org/inventoryLevel',
1608
+                    self::DATA_TYPE_INTEGER
1609
+                ),
1610
+                // ### schema:price.
1611
+                $this->rendition_factory->create(
1612
+                    $this->storage_factory->post_meta( self::FIELD_PRICE ),
1613
+                    'http://schema.org/price',
1614
+                    self::DATA_TYPE_INTEGER
1615
+                ),
1616
+                // ### schema:priceCurrency.
1617
+                $this->rendition_factory->create(
1618
+                    $this->storage_factory->post_meta( self::FIELD_PRICE_CURRENCY ),
1619
+                    'http://schema.org/priceCurrency',
1620
+                    null
1621
+                ),
1622
+                // ### schema:validFrom.
1623
+                $this->rendition_factory->create(
1624
+                    $this->storage_factory->post_meta( self::FIELD_VALID_FROM ),
1625
+                    'http://schema.org/validFrom',
1626
+                    null
1627
+                ),
1628
+                // ### schema:priceValidUntil.
1629
+                $this->rendition_factory->create(
1630
+                    $this->storage_factory->post_meta( self::FIELD_PRICE_VALID_UNTIL ),
1631
+                    'http://schema.org/priceValidUntil',
1632
+                    null
1633
+                ),
1634
+                // ### schema:itemOffered.
1635
+                $this->rendition_factory->create(
1636
+                    $this->storage_factory->post_meta_to_uri( self::FIELD_ITEM_OFFERED ),
1637
+                    'http://schema.org/itemOffered',
1638
+                    self::DATA_TYPE_URI
1639
+                ),
1640
+            ),
1641
+        );
1642
+
1643
+        // Merge the custom fields with those provided by the thing schema.
1644
+        $parent_schema           = $this->get_thing_schema();
1645
+        $schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1646
+        $schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1647
+
1648
+        return $schema;
1649
+    }
1650
+
1651
+    /**
1652
+     * Get the 'article' schema.
1653
+     *
1654
+     * @return array An array with the schema configuration.
1655
+     *
1656
+     * @since 3.15.0
1657
+     */
1658
+    private function get_article_schema() {
1659
+
1660
+        $schema = array(
1661
+            'label'         => 'Article',
1662
+            'description'   => 'An Article.',
1663
+            'parents'       => array(),
1664
+            'css_class'     => 'wl-article',
1665
+            'uri'           => 'http://schema.org/Article',
1666
+            'same_as'       => array(),
1667
+            'templates'     => array(
1668
+                'subtitle' => '{{id}}',
1669
+            ),
1670
+            'custom_fields' => array(),
1671
+            'linked_data'   => array(
1672
+                // ### schema:headline.
1673
+                $this->rendition_factory->create(
1674
+                    $this->storage_factory->post_title(),
1675
+                    'http://schema.org/headline',
1676
+                    null,
1677
+                    $this->language_code
1678
+                ),
1679
+                // ### schema:url.
1680
+                $this->rendition_factory->create(
1681
+                    $this->storage_factory->url_property(),
1682
+                    Wordlift_Query_Builder::SCHEMA_URL_URI,
1683
+                    self::DATA_TYPE_URI
1684
+                ),
1685
+                // ### rdf:type.
1686
+                $this->rendition_factory->create(
1687
+                    $this->storage_factory->schema_class(),
1688
+                    Wordlift_Query_Builder::RDFS_TYPE_URI,
1689
+                    self::DATA_TYPE_URI
1690
+                ),
1691
+                // ### dcterms:references.
1692
+                $this->rendition_factory->create(
1693
+                    $this->storage_factory->relations(),
1694
+                    Wordlift_Query_Builder::DCTERMS_REFERENCES_URI,
1695
+                    self::DATA_TYPE_URI,
1696
+                    $this->language_code
1697
+                ),
1698
+            ),
1699
+        );
1700
+
1701
+        return $schema;
1702
+    }
1703 1703
 
1704 1704
 }
Please login to merge, or discard this patch.
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
 	 * @param \Wordlift_Sparql_Tuple_Rendition_Factory $rendition_factory The {@link Wordlift_Sparql_Tuple_Rendition_Factory} instance.
468 468
 	 * @param \Wordlift_Configuration_Service          $configuration_service The {@link Wordlift_Configuration_Service} instance.
469 469
 	 */
470
-	public function __construct( $storage_factory, $rendition_factory, $configuration_service ) {
470
+	public function __construct($storage_factory, $rendition_factory, $configuration_service) {
471 471
 
472
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Schema_Service' );
472
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Schema_Service');
473 473
 
474 474
 		$this->storage_factory       = $storage_factory;
475 475
 		$this->rendition_factory     = $rendition_factory;
@@ -501,13 +501,13 @@  discard block
 block discarded – undo
501 501
 		 *
502 502
 		 * @param    array $schemas The array of schemas.
503 503
 		 */
504
-		$this->schema = apply_filters( 'wl_schemas', $schemas );
504
+		$this->schema = apply_filters('wl_schemas', $schemas);
505 505
 
506 506
 		// Create a singleton instance of the Schema service, useful to provide static functions to global functions.
507 507
 		self::$instance = $this;
508 508
 
509 509
 		// Hook the `init` to allow plugins to add their schemas.
510
-		add_action( 'init', array( $this, 'init' ) );
510
+		add_action('init', array($this, 'init'));
511 511
 
512 512
 	}
513 513
 
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 	 */
519 519
 	public function init() {
520 520
 
521
-		$this->schema = apply_filters( 'wl_schemas_init', $this->schema );
521
+		$this->schema = apply_filters('wl_schemas_init', $this->schema);
522 522
 
523 523
 	}
524 524
 
@@ -544,18 +544,18 @@  discard block
 block discarded – undo
544 544
 	 *
545 545
 	 * @return null|array An array of field's properties or null if the field is not found.
546 546
 	 */
547
-	public function get_field( $key ) {
547
+	public function get_field($key) {
548 548
 
549 549
 		// Parse each schema's fields until we find the one we're looking for, then
550 550
 		// return its properties.
551
-		foreach ( $this->schema as $_ => $schema ) {
551
+		foreach ($this->schema as $_ => $schema) {
552 552
 
553
-			if ( ! isset( $schema['custom_fields'] ) ) {
553
+			if ( ! isset($schema['custom_fields'])) {
554 554
 				break;
555 555
 			}
556 556
 
557
-			foreach ( $schema['custom_fields'] as $field => $props ) {
558
-				if ( $key === $field ) {
557
+			foreach ($schema['custom_fields'] as $field => $props) {
558
+				if ($key === $field) {
559 559
 					return $props;
560 560
 				}
561 561
 			}
@@ -575,8 +575,8 @@  discard block
 block discarded – undo
575 575
 		// Get the custom fields.
576 576
 		$renditions = array_reduce(
577 577
 			$this->schema,
578
-			function ( $carry, $item ) {
579
-				return array_merge( $carry, $item['linked_data'] );
578
+			function($carry, $item) {
579
+				return array_merge($carry, $item['linked_data']);
580 580
 			},
581 581
 			array()
582 582
 		);
@@ -594,14 +594,14 @@  discard block
 block discarded – undo
594 594
 	 *
595 595
 	 * @since 3.1.0
596 596
 	 */
597
-	public function get_schema( $name ) {
597
+	public function get_schema($name) {
598 598
 		// Check if the schema exists and, if not, return NULL.
599
-		if ( ! isset( $this->schema[ $name ] ) ) {
599
+		if ( ! isset($this->schema[$name])) {
600 600
 			return null;
601 601
 		}
602 602
 
603 603
 		// Return the requested schema.
604
-		return $this->schema[ $name ];
604
+		return $this->schema[$name];
605 605
 	}
606 606
 
607 607
 	/**
@@ -613,10 +613,10 @@  discard block
 block discarded – undo
613 613
 	 *
614 614
 	 * @since 3.3.0
615 615
 	 */
616
-	public function get_schema_by_uri( $uri ) {
616
+	public function get_schema_by_uri($uri) {
617 617
 
618
-		foreach ( $this->schema as $name => $schema ) {
619
-			if ( $schema['uri'] === $uri ) {
618
+		foreach ($this->schema as $name => $schema) {
619
+			if ($schema['uri'] === $uri) {
620 620
 				return $schema;
621 621
 			}
622 622
 		}
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 		return array(
637 637
 			'css_class'     => 'wl-thing',
638 638
 			'uri'           => 'http://schema.org/Thing',
639
-			'same_as'       => array( '*' ),
639
+			'same_as'       => array('*'),
640 640
 			// set as default.
641 641
 			'custom_fields' => array(
642 642
 				self::FIELD_SAME_AS                            => array(
@@ -675,14 +675,14 @@  discard block
 block discarded – undo
675 675
 				),
676 676
 				// ### Alternative title to rdfs:label.
677 677
 				$this->rendition_factory->create(
678
-					$this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ),
678
+					$this->storage_factory->post_meta(Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY),
679 679
 					Wordlift_Query_Builder::RDFS_LABEL_URI,
680 680
 					null,
681 681
 					$this->language_code
682 682
 				),
683 683
 				// ### Alternative title to dct:title.
684 684
 				$this->rendition_factory->create(
685
-					$this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ),
685
+					$this->storage_factory->post_meta(Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY),
686 686
 					'http://purl.org/dc/terms/title',
687 687
 					null,
688 688
 					$this->language_code
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 				),
697 697
 				// ### Alternative title to schema:alterName.
698 698
 				$this->rendition_factory->create(
699
-					$this->storage_factory->post_meta( Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY ),
699
+					$this->storage_factory->post_meta(Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY),
700 700
 					'http://schema.org/alternateName',
701 701
 					null,
702 702
 					$this->language_code
@@ -716,13 +716,13 @@  discard block
 block discarded – undo
716 716
 				),
717 717
 				// ### owl:sameAs.
718 718
 				$this->rendition_factory->create(
719
-					$this->storage_factory->post_meta( self::FIELD_SAME_AS ),
719
+					$this->storage_factory->post_meta(self::FIELD_SAME_AS),
720 720
 					'http://www.w3.org/2002/07/owl#sameAs',
721 721
 					self::DATA_TYPE_URI
722 722
 				),
723 723
 				// ### schema:sameAs.
724 724
 				$this->rendition_factory->create(
725
-					$this->storage_factory->post_meta( self::FIELD_SAME_AS ),
725
+					$this->storage_factory->post_meta(self::FIELD_SAME_AS),
726 726
 					'http://schema.org/sameAs',
727 727
 					self::DATA_TYPE_URI
728 728
 				),
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 		$schema = array(
806 806
 			'label'         => 'CreativeWork',
807 807
 			'description'   => 'A creative work (or a Music Album).',
808
-			'parents'       => array( 'thing' ),
808
+			'parents'       => array('thing'),
809 809
 			// Give term slug as parent.
810 810
 			'css_class'     => 'wl-creative-work',
811 811
 			'uri'           => 'http://schema.org/CreativeWork',
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 					'type'        => self::DATA_TYPE_URI,
820 820
 					'export_type' => 'http://schema.org/Person',
821 821
 					'constraints' => array(
822
-						'uri_type'    => array( 'Person', 'Organization' ),
822
+						'uri_type'    => array('Person', 'Organization'),
823 823
 						'cardinality' => INF,
824 824
 					),
825 825
 				),
@@ -839,8 +839,8 @@  discard block
 block discarded – undo
839 839
 
840 840
 		// Merge the custom fields with those provided by the thing schema.
841 841
 		$parent_schema           = $this->get_thing_schema();
842
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
843
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
842
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
843
+		$schema['linked_data']   = array_merge($schema['linked_data'], $parent_schema['linked_data']);
844 844
 
845 845
 		return $schema;
846 846
 	}
@@ -857,10 +857,10 @@  discard block
 block discarded – undo
857 857
 		$schema = array(
858 858
 			'label'         => 'Event',
859 859
 			'description'   => 'An event . ',
860
-			'parents'       => array( 'thing' ),
860
+			'parents'       => array('thing'),
861 861
 			'css_class'     => 'wl-event',
862 862
 			'uri'           => self::SCHEMA_EVENT_TYPE,
863
-			'same_as'       => array( 'http://dbpedia.org/ontology/Event' ),
863
+			'same_as'       => array('http://dbpedia.org/ontology/Event'),
864 864
 			'custom_fields' => array(
865 865
 				self::FIELD_DATE_START => array(
866 866
 					'predicate'   => 'http://schema.org/startDate',
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
 					'type'        => self::DATA_TYPE_URI,
880 880
 					'export_type' => 'http://schema.org/PostalAddress',
881 881
 					'constraints' => array(
882
-						'uri_type'    => array( 'Place', 'LocalBusiness' ),
882
+						'uri_type'    => array('Place', 'LocalBusiness'),
883 883
 						'cardinality' => INF,
884 884
 					),
885 885
 				),
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 					'type'        => self::DATA_TYPE_URI,
889 889
 					'export_type' => 'http://schema.org/Person',
890 890
 					'constraints' => array(
891
-						'uri_type'    => array( 'Person', 'Organization' ),
891
+						'uri_type'    => array('Person', 'Organization'),
892 892
 						'cardinality' => INF,
893 893
 					),
894 894
 				),
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 					'type'        => self::DATA_TYPE_URI,
898 898
 					'export_type' => 'http://schema.org/Offer',
899 899
 					'constraints' => array(
900
-						'uri_type'    => array( 'Offer' ),
900
+						'uri_type'    => array('Offer'),
901 901
 						'cardinality' => INF,
902 902
 					),
903 903
 				),
@@ -905,31 +905,31 @@  discard block
 block discarded – undo
905 905
 			'linked_data'   => array(
906 906
 				// ### schema:startDate.
907 907
 				$this->rendition_factory->create(
908
-					$this->storage_factory->post_meta( self::FIELD_DATE_START ),
908
+					$this->storage_factory->post_meta(self::FIELD_DATE_START),
909 909
 					'http://schema.org/startDate',
910 910
 					self::DATA_TYPE_DATE_TIME
911 911
 				),
912 912
 				// ### schema:endDate.
913 913
 				$this->rendition_factory->create(
914
-					$this->storage_factory->post_meta( self::FIELD_DATE_END ),
914
+					$this->storage_factory->post_meta(self::FIELD_DATE_END),
915 915
 					'http://schema.org/endDate',
916 916
 					self::DATA_TYPE_DATE_TIME
917 917
 				),
918 918
 				// ### schema:location.
919 919
 				$this->rendition_factory->create(
920
-					$this->storage_factory->post_meta_to_uri( self::FIELD_LOCATION ),
920
+					$this->storage_factory->post_meta_to_uri(self::FIELD_LOCATION),
921 921
 					'http://schema.org/location',
922 922
 					self::DATA_TYPE_URI
923 923
 				),
924 924
 				// ### schema:performer.
925 925
 				$this->rendition_factory->create(
926
-					$this->storage_factory->post_meta_to_uri( self::FIELD_PERFORMER ),
926
+					$this->storage_factory->post_meta_to_uri(self::FIELD_PERFORMER),
927 927
 					'http://schema.org/performer',
928 928
 					self::DATA_TYPE_URI
929 929
 				),
930 930
 				// ### schema:offers.
931 931
 				$this->rendition_factory->create(
932
-					$this->storage_factory->post_meta_to_uri( self::FIELD_OFFERS ),
932
+					$this->storage_factory->post_meta_to_uri(self::FIELD_OFFERS),
933 933
 					'http://schema.org/offers',
934 934
 					self::DATA_TYPE_URI
935 935
 				),
@@ -941,8 +941,8 @@  discard block
 block discarded – undo
941 941
 
942 942
 		// Merge the custom fields with those provided by the thing schema.
943 943
 		$parent_schema           = $this->get_thing_schema();
944
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
945
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
944
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
945
+		$schema['linked_data']   = array_merge($schema['linked_data'], $parent_schema['linked_data']);
946 946
 
947 947
 		return $schema;
948 948
 	}
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 		$schema = array(
960 960
 			'label'         => 'Organization',
961 961
 			'description'   => 'An organization, including a government or a newspaper.',
962
-			'parents'       => array( 'thing' ),
962
+			'parents'       => array('thing'),
963 963
 			'css_class'     => 'wl-organization',
964 964
 			'uri'           => 'http://schema.org/Organization',
965 965
 			'same_as'       => array(
@@ -1047,23 +1047,23 @@  discard block
 block discarded – undo
1047 1047
 			'linked_data'   => array(
1048 1048
 				// ### schema:legalName.
1049 1049
 				$this->rendition_factory->create(
1050
-					$this->storage_factory->post_meta( self::FIELD_LEGAL_NAME ),
1050
+					$this->storage_factory->post_meta(self::FIELD_LEGAL_NAME),
1051 1051
 					'http://schema.org/legalName'
1052 1052
 				),
1053 1053
 				// ### schema:founder.
1054 1054
 				$this->rendition_factory->create(
1055
-					$this->storage_factory->post_meta_to_uri( self::FIELD_FOUNDER ),
1055
+					$this->storage_factory->post_meta_to_uri(self::FIELD_FOUNDER),
1056 1056
 					'http://schema.org/founder',
1057 1057
 					self::DATA_TYPE_URI
1058 1058
 				),
1059 1059
 				// ### schema:email.
1060 1060
 				$this->rendition_factory->create(
1061
-					$this->storage_factory->post_meta( self::FIELD_EMAIL ),
1061
+					$this->storage_factory->post_meta(self::FIELD_EMAIL),
1062 1062
 					'http://schema.org/email'
1063 1063
 				),
1064 1064
 				// ### schema:telephone.
1065 1065
 				$this->rendition_factory->create(
1066
-					$this->storage_factory->post_meta( self::FIELD_TELEPHONE ),
1066
+					$this->storage_factory->post_meta(self::FIELD_TELEPHONE),
1067 1067
 					'http://schema.org/telephone'
1068 1068
 				),
1069 1069
 			),
@@ -1074,8 +1074,8 @@  discard block
 block discarded – undo
1074 1074
 
1075 1075
 		// Merge the custom fields with those provided by the thing schema.
1076 1076
 		$parent_schema           = $this->get_thing_schema();
1077
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1078
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1077
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
1078
+		$schema['linked_data']   = array_merge($schema['linked_data'], $parent_schema['linked_data']);
1079 1079
 
1080 1080
 		return $schema;
1081 1081
 	}
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 		$schema = array(
1093 1093
 			'label'         => 'Person',
1094 1094
 			'description'   => 'A person (or a music artist).',
1095
-			'parents'       => array( 'thing' ),
1095
+			'parents'       => array('thing'),
1096 1096
 			'css_class'     => 'wl-person',
1097 1097
 			'uri'           => 'http://schema.org/Person',
1098 1098
 			'same_as'       => array(
@@ -1148,31 +1148,31 @@  discard block
 block discarded – undo
1148 1148
 			'linked_data'   => array(
1149 1149
 				// ### schema:knows.
1150 1150
 				$this->rendition_factory->create(
1151
-					$this->storage_factory->post_meta_to_uri( self::FIELD_KNOWS ),
1151
+					$this->storage_factory->post_meta_to_uri(self::FIELD_KNOWS),
1152 1152
 					'http://schema.org/knows',
1153 1153
 					self::DATA_TYPE_URI
1154 1154
 				),
1155 1155
 				// ### schema:birthDate.
1156 1156
 				$this->rendition_factory->create(
1157
-					$this->storage_factory->post_meta( self::FIELD_BIRTH_DATE ),
1157
+					$this->storage_factory->post_meta(self::FIELD_BIRTH_DATE),
1158 1158
 					'http://schema.org/birthDate',
1159 1159
 					self::DATA_TYPE_DATE
1160 1160
 				),
1161 1161
 				// ### schema:birthPlace.
1162 1162
 				$this->rendition_factory->create(
1163
-					$this->storage_factory->post_meta_to_uri( self::FIELD_BIRTH_PLACE ),
1163
+					$this->storage_factory->post_meta_to_uri(self::FIELD_BIRTH_PLACE),
1164 1164
 					'http://schema.org/birthPlace',
1165 1165
 					self::DATA_TYPE_URI
1166 1166
 				),
1167 1167
 				// ### schema:affiliation.
1168 1168
 				$this->rendition_factory->create(
1169
-					$this->storage_factory->post_meta_to_uri( self::FIELD_AFFILIATION ),
1169
+					$this->storage_factory->post_meta_to_uri(self::FIELD_AFFILIATION),
1170 1170
 					'http://schema.org/affiliation',
1171 1171
 					self::DATA_TYPE_URI
1172 1172
 				),
1173 1173
 				// ### schema:email.
1174 1174
 				$this->rendition_factory->create(
1175
-					$this->storage_factory->post_meta( self::FIELD_EMAIL ),
1175
+					$this->storage_factory->post_meta(self::FIELD_EMAIL),
1176 1176
 					'http://schema.org/email'
1177 1177
 				),
1178 1178
 			),
@@ -1183,8 +1183,8 @@  discard block
 block discarded – undo
1183 1183
 
1184 1184
 		// Merge the custom fields with those provided by the thing schema.
1185 1185
 		$parent_schema           = $this->get_thing_schema();
1186
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1187
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1186
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
1187
+		$schema['linked_data']   = array_merge($schema['linked_data'], $parent_schema['linked_data']);
1188 1188
 
1189 1189
 		return $schema;
1190 1190
 
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
 		$schema = array(
1203 1203
 			'label'         => 'Place',
1204 1204
 			'description'   => 'A place.',
1205
-			'parents'       => array( 'thing' ),
1205
+			'parents'       => array('thing'),
1206 1206
 			'css_class'     => 'wl-place',
1207 1207
 			'uri'           => 'http://schema.org/Place',
1208 1208
 			'same_as'       => array(
@@ -1288,8 +1288,8 @@  discard block
 block discarded – undo
1288 1288
 
1289 1289
 		// Merge the custom fields with those provided by the thing schema.
1290 1290
 		$parent_schema           = $this->get_thing_schema();
1291
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1292
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1291
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
1292
+		$schema['linked_data']   = array_merge($schema['linked_data'], $parent_schema['linked_data']);
1293 1293
 
1294 1294
 		return $schema;
1295 1295
 	}
@@ -1306,7 +1306,7 @@  discard block
 block discarded – undo
1306 1306
 		$schema = array(
1307 1307
 			'label'         => 'LocalBusiness',
1308 1308
 			'description'   => 'A local business.',
1309
-			'parents'       => array( 'place', 'organization' ),
1309
+			'parents'       => array('place', 'organization'),
1310 1310
 			'css_class'     => 'wl-local-business',
1311 1311
 			'uri'           => 'http://schema.org/LocalBusiness',
1312 1312
 			'same_as'       => array(
@@ -1323,8 +1323,8 @@  discard block
 block discarded – undo
1323 1323
 		// Merge the custom fields with those provided by the place and organization schema.
1324 1324
 		$place_schema            = $this->get_place_schema();
1325 1325
 		$organization_schema     = $this->get_organization_schema();
1326
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields'] );
1327
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $place_schema['linked_data'], $organization_schema['linked_data'] );
1326
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $place_schema['custom_fields'], $organization_schema['custom_fields']);
1327
+		$schema['linked_data']   = array_merge($schema['linked_data'], $place_schema['linked_data'], $organization_schema['linked_data']);
1328 1328
 
1329 1329
 		return $schema;
1330 1330
 	}
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
 		$schema = array(
1342 1342
 			'label'         => 'Recipe',
1343 1343
 			'description'   => 'A Recipe.',
1344
-			'parents'       => array( 'CreativeWork' ),
1344
+			'parents'       => array('CreativeWork'),
1345 1345
 			'css_class'     => 'wl-recipe',
1346 1346
 			'uri'           => 'http://schema.org/Recipe',
1347 1347
 			'same_as'       => array(),
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
 					'export_type' => 'xsd:string',
1356 1356
 					'constraints' => '',
1357 1357
 					'metabox'     => array(
1358
-						'label' => __( 'Recipe cuisine', 'wordlift' ),
1358
+						'label' => __('Recipe cuisine', 'wordlift'),
1359 1359
 					),
1360 1360
 				),
1361 1361
 				self::FIELD_RECIPE_INGREDIENT       => array(
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
 						'cardinality' => INF,
1367 1367
 					),
1368 1368
 					'metabox'     => array(
1369
-						'label' => __( 'Recipe ingredient', 'wordlift' ),
1369
+						'label' => __('Recipe ingredient', 'wordlift'),
1370 1370
 					),
1371 1371
 				),
1372 1372
 				self::FIELD_RECIPE_INSTRUCTIONS     => array(
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 					'constraints' => '',
1377 1377
 					'metabox'     => array(
1378 1378
 						'class' => 'Wordlift_Metabox_Field_Multiline',
1379
-						'label' => __( 'Recipe instructions', 'wordlift' ),
1379
+						'label' => __('Recipe instructions', 'wordlift'),
1380 1380
 					),
1381 1381
 				),
1382 1382
 				self::FIELD_RECIPE_YIELD            => array(
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 					'export_type' => 'xsd:string',
1386 1386
 					'constraints' => '',
1387 1387
 					'metabox'     => array(
1388
-						'label' => __( 'Recipe number of servings', 'wordlift' ),
1388
+						'label' => __('Recipe number of servings', 'wordlift'),
1389 1389
 					),
1390 1390
 				),
1391 1391
 				self::FIELD_RECIPE_INGREDIENT       => array(
@@ -1396,7 +1396,7 @@  discard block
 block discarded – undo
1396 1396
 						'cardinality' => INF,
1397 1397
 					),
1398 1398
 					'metabox'     => array(
1399
-						'label' => __( 'Recipe ingredient', 'wordlift' ),
1399
+						'label' => __('Recipe ingredient', 'wordlift'),
1400 1400
 					),
1401 1401
 				),
1402 1402
 				self::FIELD_NUTRITION_INFO_CALORIES => array(
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
 					'export_type' => 'xsd:string',
1406 1406
 					'constraints' => '',
1407 1407
 					'metabox'     => array(
1408
-						'label' => __( 'Calories (e.g. 240 calories)', 'wordlift' ),
1408
+						'label' => __('Calories (e.g. 240 calories)', 'wordlift'),
1409 1409
 					),
1410 1410
 				),
1411 1411
 				self::FIELD_PREP_TIME               => array(
@@ -1415,7 +1415,7 @@  discard block
 block discarded – undo
1415 1415
 					'constraints' => '',
1416 1416
 					'metabox'     => array(
1417 1417
 						'class' => 'Wordlift_Metabox_Field_Duration',
1418
-						'label' => __( 'Recipe preparation time (e.g. 1:30)', 'wordlift' ),
1418
+						'label' => __('Recipe preparation time (e.g. 1:30)', 'wordlift'),
1419 1419
 					),
1420 1420
 				),
1421 1421
 				self::FIELD_COOK_TIME               => array(
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
 					'constraints' => '',
1426 1426
 					'metabox'     => array(
1427 1427
 						'class' => 'Wordlift_Metabox_Field_Duration',
1428
-						'label' => __( 'Recipe cook time (e.g. 1:30)', 'wordlift' ),
1428
+						'label' => __('Recipe cook time (e.g. 1:30)', 'wordlift'),
1429 1429
 					),
1430 1430
 				),
1431 1431
 				self::FIELD_TOTAL_TIME              => array(
@@ -1435,46 +1435,46 @@  discard block
 block discarded – undo
1435 1435
 					'constraints' => '',
1436 1436
 					'metabox'     => array(
1437 1437
 						'class' => 'Wordlift_Metabox_Field_Duration',
1438
-						'label' => __( 'Recipe total time (e.g. 1:30)', 'wordlift' ),
1438
+						'label' => __('Recipe total time (e.g. 1:30)', 'wordlift'),
1439 1439
 					),
1440 1440
 				),
1441 1441
 			),
1442 1442
 			'linked_data'   => array(
1443 1443
 				// ### schema:recipeCuisine.
1444 1444
 				$this->rendition_factory->create(
1445
-					$this->storage_factory->post_meta( self::FIELD_RECIPE_CUISINE ),
1445
+					$this->storage_factory->post_meta(self::FIELD_RECIPE_CUISINE),
1446 1446
 					'http://schema.org/recipeCuisine'
1447 1447
 				),
1448 1448
 				// ### schema:recipeIngredient.
1449 1449
 				$this->rendition_factory->create(
1450
-					$this->storage_factory->post_meta( self::FIELD_RECIPE_INGREDIENT ),
1450
+					$this->storage_factory->post_meta(self::FIELD_RECIPE_INGREDIENT),
1451 1451
 					'http://schema.org/recipeIngredient'
1452 1452
 				),
1453 1453
 				// ### schema:recipeInstructions.
1454 1454
 				$this->rendition_factory->create(
1455
-					$this->storage_factory->post_meta( self::FIELD_RECIPE_INSTRUCTIONS ),
1455
+					$this->storage_factory->post_meta(self::FIELD_RECIPE_INSTRUCTIONS),
1456 1456
 					'http://schema.org/recipeInstructions'
1457 1457
 				),
1458 1458
 				// ### schema:recipeYield.
1459 1459
 				$this->rendition_factory->create(
1460
-					$this->storage_factory->post_meta( self::FIELD_RECIPE_YIELD ),
1460
+					$this->storage_factory->post_meta(self::FIELD_RECIPE_YIELD),
1461 1461
 					'http://schema.org/recipeYield'
1462 1462
 				),
1463 1463
 				// ### schema:prepTime.
1464 1464
 				$this->rendition_factory->create(
1465
-					$this->storage_factory->post_meta( self::FIELD_PREP_TIME ),
1465
+					$this->storage_factory->post_meta(self::FIELD_PREP_TIME),
1466 1466
 					'http://schema.org/prepTime',
1467 1467
 					self::DATA_TYPE_DURATION
1468 1468
 				),
1469 1469
 				// ### schema:cookTime.
1470 1470
 				$this->rendition_factory->create(
1471
-					$this->storage_factory->post_meta( self::FIELD_COOK_TIME ),
1471
+					$this->storage_factory->post_meta(self::FIELD_COOK_TIME),
1472 1472
 					'http://schema.org/cookTime',
1473 1473
 					self::DATA_TYPE_DURATION
1474 1474
 				),
1475 1475
 				// ### schema:totalTime.
1476 1476
 				$this->rendition_factory->create(
1477
-					$this->storage_factory->post_meta( self::FIELD_TOTAL_TIME ),
1477
+					$this->storage_factory->post_meta(self::FIELD_TOTAL_TIME),
1478 1478
 					'http://schema.org/totalTime',
1479 1479
 					self::DATA_TYPE_DURATION
1480 1480
 				),
@@ -1483,8 +1483,8 @@  discard block
 block discarded – undo
1483 1483
 
1484 1484
 		// Merge the custom fields with those provided by the parent schema.
1485 1485
 		$parent_schema           = $this->get_creative_work_schema();
1486
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1487
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1486
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
1487
+		$schema['linked_data']   = array_merge($schema['linked_data'], $parent_schema['linked_data']);
1488 1488
 
1489 1489
 		return $schema;
1490 1490
 	}
@@ -1501,7 +1501,7 @@  discard block
 block discarded – undo
1501 1501
 		$schema = array(
1502 1502
 			'label'         => 'Offer',
1503 1503
 			'description'   => 'An offer. ',
1504
-			'parents'       => array( 'thing' ),
1504
+			'parents'       => array('thing'),
1505 1505
 			'css_class'     => 'wl-offer',
1506 1506
 			'uri'           => self::SCHEMA_OFFER_TYPE,
1507 1507
 			'same_as'       => array(),
@@ -1517,15 +1517,15 @@  discard block
 block discarded – undo
1517 1517
 						'class' => 'Wordlift_Metabox_Field_Select',
1518 1518
 					),
1519 1519
 					'options'     => array(
1520
-						'Discontinued'        => esc_html__( 'Discontinued', 'wordlift' ),
1521
-						'InStock'             => esc_html__( 'In Stock', 'wordlift' ),
1522
-						'InStoreOnly'         => esc_html__( 'In Store Only', 'wordlift' ),
1523
-						'LimitedAvailability' => esc_html__( 'Limited Availability', 'wordlift' ),
1524
-						'OnlineOnly'          => esc_html__( 'Online Only', 'wordlift' ),
1525
-						'OutOfStock'          => esc_html__( 'Out of Stock', 'wordlift' ),
1526
-						'PreOrder'            => esc_html__( 'Pre Order', 'wordlift' ),
1527
-						'PreSale'             => esc_html__( 'Pre Sale', 'wordlift' ),
1528
-						'SoldOut'             => esc_html__( 'Sold Out', 'wordlift' ),
1520
+						'Discontinued'        => esc_html__('Discontinued', 'wordlift'),
1521
+						'InStock'             => esc_html__('In Stock', 'wordlift'),
1522
+						'InStoreOnly'         => esc_html__('In Store Only', 'wordlift'),
1523
+						'LimitedAvailability' => esc_html__('Limited Availability', 'wordlift'),
1524
+						'OnlineOnly'          => esc_html__('Online Only', 'wordlift'),
1525
+						'OutOfStock'          => esc_html__('Out of Stock', 'wordlift'),
1526
+						'PreOrder'            => esc_html__('Pre Order', 'wordlift'),
1527
+						'PreSale'             => esc_html__('Pre Sale', 'wordlift'),
1528
+						'SoldOut'             => esc_html__('Sold Out', 'wordlift'),
1529 1529
 					),
1530 1530
 				),
1531 1531
 				self::FIELD_PRICE               => array(
@@ -1585,55 +1585,55 @@  discard block
 block discarded – undo
1585 1585
 			'linked_data'   => array(
1586 1586
 				// ### schema:availability.
1587 1587
 				$this->rendition_factory->create(
1588
-					$this->storage_factory->post_meta( self::FIELD_AVAILABILITY ),
1588
+					$this->storage_factory->post_meta(self::FIELD_AVAILABILITY),
1589 1589
 					'http://schema.org/availability',
1590 1590
 					null
1591 1591
 				),
1592 1592
 				// ### schema:availabilityStarts.
1593 1593
 				$this->rendition_factory->create(
1594
-					$this->storage_factory->post_meta( self::FIELD_AVAILABILITY_STARTS ),
1594
+					$this->storage_factory->post_meta(self::FIELD_AVAILABILITY_STARTS),
1595 1595
 					'http://schema.org/availabilityStarts',
1596 1596
 					self::DATA_TYPE_DATE_TIME
1597 1597
 				),
1598 1598
 				// ### schema:availabilityEnds.
1599 1599
 				$this->rendition_factory->create(
1600
-					$this->storage_factory->post_meta( self::FIELD_AVAILABILITY_ENDS ),
1600
+					$this->storage_factory->post_meta(self::FIELD_AVAILABILITY_ENDS),
1601 1601
 					'http://schema.org/availabilityEnds',
1602 1602
 					self::DATA_TYPE_DATE_TIME
1603 1603
 				),
1604 1604
 				// ### schema:inventoryLevel.
1605 1605
 				$this->rendition_factory->create(
1606
-					$this->storage_factory->post_meta( self::FIELD_INVENTORY_LEVEL ),
1606
+					$this->storage_factory->post_meta(self::FIELD_INVENTORY_LEVEL),
1607 1607
 					'http://schema.org/inventoryLevel',
1608 1608
 					self::DATA_TYPE_INTEGER
1609 1609
 				),
1610 1610
 				// ### schema:price.
1611 1611
 				$this->rendition_factory->create(
1612
-					$this->storage_factory->post_meta( self::FIELD_PRICE ),
1612
+					$this->storage_factory->post_meta(self::FIELD_PRICE),
1613 1613
 					'http://schema.org/price',
1614 1614
 					self::DATA_TYPE_INTEGER
1615 1615
 				),
1616 1616
 				// ### schema:priceCurrency.
1617 1617
 				$this->rendition_factory->create(
1618
-					$this->storage_factory->post_meta( self::FIELD_PRICE_CURRENCY ),
1618
+					$this->storage_factory->post_meta(self::FIELD_PRICE_CURRENCY),
1619 1619
 					'http://schema.org/priceCurrency',
1620 1620
 					null
1621 1621
 				),
1622 1622
 				// ### schema:validFrom.
1623 1623
 				$this->rendition_factory->create(
1624
-					$this->storage_factory->post_meta( self::FIELD_VALID_FROM ),
1624
+					$this->storage_factory->post_meta(self::FIELD_VALID_FROM),
1625 1625
 					'http://schema.org/validFrom',
1626 1626
 					null
1627 1627
 				),
1628 1628
 				// ### schema:priceValidUntil.
1629 1629
 				$this->rendition_factory->create(
1630
-					$this->storage_factory->post_meta( self::FIELD_PRICE_VALID_UNTIL ),
1630
+					$this->storage_factory->post_meta(self::FIELD_PRICE_VALID_UNTIL),
1631 1631
 					'http://schema.org/priceValidUntil',
1632 1632
 					null
1633 1633
 				),
1634 1634
 				// ### schema:itemOffered.
1635 1635
 				$this->rendition_factory->create(
1636
-					$this->storage_factory->post_meta_to_uri( self::FIELD_ITEM_OFFERED ),
1636
+					$this->storage_factory->post_meta_to_uri(self::FIELD_ITEM_OFFERED),
1637 1637
 					'http://schema.org/itemOffered',
1638 1638
 					self::DATA_TYPE_URI
1639 1639
 				),
@@ -1642,8 +1642,8 @@  discard block
 block discarded – undo
1642 1642
 
1643 1643
 		// Merge the custom fields with those provided by the thing schema.
1644 1644
 		$parent_schema           = $this->get_thing_schema();
1645
-		$schema['custom_fields'] = array_merge( $schema['custom_fields'], $parent_schema['custom_fields'] );
1646
-		$schema['linked_data']   = array_merge( $schema['linked_data'], $parent_schema['linked_data'] );
1645
+		$schema['custom_fields'] = array_merge($schema['custom_fields'], $parent_schema['custom_fields']);
1646
+		$schema['linked_data']   = array_merge($schema['linked_data'], $parent_schema['linked_data']);
1647 1647
 
1648 1648
 		return $schema;
1649 1649
 	}
Please login to merge, or discard this patch.
src/includes/mapping/class-wordlift-mapping-service.php 2 patches
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -14,205 +14,205 @@
 block discarded – undo
14 14
  */
15 15
 class Wordlift_Mapping_Service {
16 16
 
17
-	/**
18
-	 * The mapping's options.
19
-	 *
20
-	 * @since 3.20.0
21
-	 * @access private
22
-	 * @var array $options The mapping's options.
23
-	 */
24
-	private $options;
25
-
26
-	/**
27
-	 * The {@link Wordlift_Entity_Type_Service} instance.
28
-	 *
29
-	 * @since 3.20.0
30
-	 * @access private
31
-	 * @var \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance.
32
-	 */
33
-	private $entity_type_service;
34
-
35
-	/**
36
-	 * The singleton instance.
37
-	 *
38
-	 * @since 3.20.0
39
-	 * @access private
40
-	 * @var \Wordlift_Mapping_Service $instance The singleton instance.
41
-	 */
42
-	private static $instance;
43
-
44
-	/**
45
-	 * Create a {@link Wordlift_Mapping_Service} instance.
46
-	 *
47
-	 * @since 3.20.0
48
-	 *
49
-	 * @param \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance.
50
-	 */
51
-	public function __construct( $entity_type_service ) {
52
-
53
-		// Set the entity type service instance.
54
-		$this->entity_type_service = $entity_type_service;
55
-
56
-		// Load the options.
57
-		$this->options = get_option( 'wl_mappings', array() );
58
-
59
-		// Hook to `wl_valid_entity_post_types` and to `wl_default_entity_types_for_post_type`.
60
-		add_filter( 'wl_valid_entity_post_types', array( $this, 'valid_entity_post_types', ), 9 );
61
-		add_filter( 'wl_default_entity_types_for_post_type', array(
62
-			$this,
63
-			'default_entity_types_for_post_type',
64
-		), 9, 2 );
65
-
66
-		// Set the singleton instance.
67
-		self::$instance = $this;
68
-
69
-	}
70
-
71
-	/**
72
-	 * Get the singleton instance.
73
-	 *
74
-	 * @since 3.20.0
75
-	 *
76
-	 * @return \Wordlift_Mapping_Service The singleton instance.
77
-	 */
78
-	public static function get_instance() {
79
-
80
-		return self::$instance;
81
-	}
82
-
83
-	/**
84
-	 * Save the options.
85
-	 *
86
-	 * @since 3.20.0
87
-	 */
88
-	private function save_options() {
89
-
90
-		update_option( 'wl_mappings', $this->options, true );
91
-
92
-	}
93
-
94
-	/**
95
-	 * Set the default entity types for a post type.
96
-	 *
97
-	 * @since 3.20.0
98
-	 *
99
-	 * @param string $post_type Post type.
100
-	 * @param array  $entity_types An array of entity types slugs.
101
-	 */
102
-	public function set_entity_types_for_post_type( $post_type, $entity_types ) {
103
-
104
-		$this->options[ $post_type ] = $entity_types;
105
-		$this->save_options();
106
-
107
-	}
108
-
109
-	/**
110
-	 * Hook to `wl_valid_entity_post_types` to declare schema.org support for the configured post types.
111
-	 *
112
-	 * @since 3.20.0
113
-	 *
114
-	 * @param array $post_types The default post types.
115
-	 *
116
-	 * @return array The supported post types.
117
-	 */
118
-	public function valid_entity_post_types( $post_types ) {
119
-
120
-		return array_merge( $post_types, array_keys( $this->options ) );
121
-	}
122
-
123
-	/**
124
-	 * Hook to `wl_default_entity_types_for_post_type` to declare the entity types for a post type.
125
-	 *
126
-	 * @since 3.20.0
127
-	 *
128
-	 * @param array  $default The default entity types.
129
-	 * @param string $post_type The post type.
130
-	 *
131
-	 * @return array The default entity types.
132
-	 */
133
-	public function default_entity_types_for_post_type( $default, $post_type ) {
134
-
135
-		return isset( $this->options[ $post_type ] ) ? $this->options[ $post_type ] : $default;
136
-	}
137
-
138
-	/**
139
-	 * Update the post type with the entity types, starting at the specified offset.
140
-	 *
141
-	 * @since 3.20.0
142
-	 *
143
-	 * @param string $post_type The post type.
144
-	 * @param array  $entity_types The entity types.
145
-	 * @param int    $offset The offset (0 by default).
146
-	 *
147
-	 * @return array {
148
-	 * The result array.
149
-	 *
150
-	 * @type int     $current The current offset.
151
-	 * @type int     $next The next offset.
152
-	 * @type int     $count The total element count.
153
-	 * }
154
-	 */
155
-	public function update( $post_type, $entity_types, $offset = 0 ) {
156
-
157
-		$entity_type_service = $this->entity_type_service;
158
-		$tax_query           = $this->get_tax_query( $entity_types );
159
-
160
-		return Wordlift_Batch_Action::process( $post_type, $offset, $tax_query, function ( $post_id ) use ( $entity_type_service, $entity_types ) {
161
-			foreach ( $entity_types as $entity_type ) {
162
-				$entity_type_service->set( $post_id, $entity_type, false );
163
-			}
164
-		} );
165
-	}
166
-
167
-	/**
168
-	 * Count the number of posts that need to be assigned with the entity types.
169
-	 *
170
-	 * @since 3.20.0
171
-	 *
172
-	 * @param string $post_type The post type.
173
-	 * @param array  $entity_types An array of entity types.
174
-	 *
175
-	 * @return int The number of posts to be assigned with entity types.
176
-	 */
177
-	public function count( $post_type, $entity_types ) {
178
-
179
-		$tax_query = $this->get_tax_query( $entity_types );
180
-
181
-		return Wordlift_Batch_Action::count( $post_type, $tax_query );
182
-	}
183
-
184
-	/**
185
-	 * Get the taxonomy query for the specified entity types.
186
-	 *
187
-	 * @since 3.20.0
188
-	 *
189
-	 * @param array $entity_types The entity types.
190
-	 *
191
-	 * @return array The tax query.
192
-	 */
193
-	private function get_tax_query( $entity_types ) {
194
-
195
-		$entity_type_service = $this->entity_type_service;
196
-		$entity_types_terms  = array_filter( array_map( function ( $item ) use ( $entity_type_service ) {
197
-			return $entity_type_service->get_term_by_uri( $item );
198
-		}, $entity_types ) );
199
-
200
-		$entity_types_terms_ids = array_map( function ( $term ) {
201
-			return $term->term_id;
202
-		}, $entity_types_terms );
203
-
204
-		$tax_query = array(
205
-			'tax_query' => array(
206
-				array(
207
-					'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
208
-					'field'    => 'term_id',
209
-					'terms'    => $entity_types_terms_ids,
210
-					'operator' => 'NOT IN',
211
-				),
212
-			),
213
-		);
214
-
215
-		return $tax_query;
216
-	}
17
+    /**
18
+     * The mapping's options.
19
+     *
20
+     * @since 3.20.0
21
+     * @access private
22
+     * @var array $options The mapping's options.
23
+     */
24
+    private $options;
25
+
26
+    /**
27
+     * The {@link Wordlift_Entity_Type_Service} instance.
28
+     *
29
+     * @since 3.20.0
30
+     * @access private
31
+     * @var \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance.
32
+     */
33
+    private $entity_type_service;
34
+
35
+    /**
36
+     * The singleton instance.
37
+     *
38
+     * @since 3.20.0
39
+     * @access private
40
+     * @var \Wordlift_Mapping_Service $instance The singleton instance.
41
+     */
42
+    private static $instance;
43
+
44
+    /**
45
+     * Create a {@link Wordlift_Mapping_Service} instance.
46
+     *
47
+     * @since 3.20.0
48
+     *
49
+     * @param \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance.
50
+     */
51
+    public function __construct( $entity_type_service ) {
52
+
53
+        // Set the entity type service instance.
54
+        $this->entity_type_service = $entity_type_service;
55
+
56
+        // Load the options.
57
+        $this->options = get_option( 'wl_mappings', array() );
58
+
59
+        // Hook to `wl_valid_entity_post_types` and to `wl_default_entity_types_for_post_type`.
60
+        add_filter( 'wl_valid_entity_post_types', array( $this, 'valid_entity_post_types', ), 9 );
61
+        add_filter( 'wl_default_entity_types_for_post_type', array(
62
+            $this,
63
+            'default_entity_types_for_post_type',
64
+        ), 9, 2 );
65
+
66
+        // Set the singleton instance.
67
+        self::$instance = $this;
68
+
69
+    }
70
+
71
+    /**
72
+     * Get the singleton instance.
73
+     *
74
+     * @since 3.20.0
75
+     *
76
+     * @return \Wordlift_Mapping_Service The singleton instance.
77
+     */
78
+    public static function get_instance() {
79
+
80
+        return self::$instance;
81
+    }
82
+
83
+    /**
84
+     * Save the options.
85
+     *
86
+     * @since 3.20.0
87
+     */
88
+    private function save_options() {
89
+
90
+        update_option( 'wl_mappings', $this->options, true );
91
+
92
+    }
93
+
94
+    /**
95
+     * Set the default entity types for a post type.
96
+     *
97
+     * @since 3.20.0
98
+     *
99
+     * @param string $post_type Post type.
100
+     * @param array  $entity_types An array of entity types slugs.
101
+     */
102
+    public function set_entity_types_for_post_type( $post_type, $entity_types ) {
103
+
104
+        $this->options[ $post_type ] = $entity_types;
105
+        $this->save_options();
106
+
107
+    }
108
+
109
+    /**
110
+     * Hook to `wl_valid_entity_post_types` to declare schema.org support for the configured post types.
111
+     *
112
+     * @since 3.20.0
113
+     *
114
+     * @param array $post_types The default post types.
115
+     *
116
+     * @return array The supported post types.
117
+     */
118
+    public function valid_entity_post_types( $post_types ) {
119
+
120
+        return array_merge( $post_types, array_keys( $this->options ) );
121
+    }
122
+
123
+    /**
124
+     * Hook to `wl_default_entity_types_for_post_type` to declare the entity types for a post type.
125
+     *
126
+     * @since 3.20.0
127
+     *
128
+     * @param array  $default The default entity types.
129
+     * @param string $post_type The post type.
130
+     *
131
+     * @return array The default entity types.
132
+     */
133
+    public function default_entity_types_for_post_type( $default, $post_type ) {
134
+
135
+        return isset( $this->options[ $post_type ] ) ? $this->options[ $post_type ] : $default;
136
+    }
137
+
138
+    /**
139
+     * Update the post type with the entity types, starting at the specified offset.
140
+     *
141
+     * @since 3.20.0
142
+     *
143
+     * @param string $post_type The post type.
144
+     * @param array  $entity_types The entity types.
145
+     * @param int    $offset The offset (0 by default).
146
+     *
147
+     * @return array {
148
+     * The result array.
149
+     *
150
+     * @type int     $current The current offset.
151
+     * @type int     $next The next offset.
152
+     * @type int     $count The total element count.
153
+     * }
154
+     */
155
+    public function update( $post_type, $entity_types, $offset = 0 ) {
156
+
157
+        $entity_type_service = $this->entity_type_service;
158
+        $tax_query           = $this->get_tax_query( $entity_types );
159
+
160
+        return Wordlift_Batch_Action::process( $post_type, $offset, $tax_query, function ( $post_id ) use ( $entity_type_service, $entity_types ) {
161
+            foreach ( $entity_types as $entity_type ) {
162
+                $entity_type_service->set( $post_id, $entity_type, false );
163
+            }
164
+        } );
165
+    }
166
+
167
+    /**
168
+     * Count the number of posts that need to be assigned with the entity types.
169
+     *
170
+     * @since 3.20.0
171
+     *
172
+     * @param string $post_type The post type.
173
+     * @param array  $entity_types An array of entity types.
174
+     *
175
+     * @return int The number of posts to be assigned with entity types.
176
+     */
177
+    public function count( $post_type, $entity_types ) {
178
+
179
+        $tax_query = $this->get_tax_query( $entity_types );
180
+
181
+        return Wordlift_Batch_Action::count( $post_type, $tax_query );
182
+    }
183
+
184
+    /**
185
+     * Get the taxonomy query for the specified entity types.
186
+     *
187
+     * @since 3.20.0
188
+     *
189
+     * @param array $entity_types The entity types.
190
+     *
191
+     * @return array The tax query.
192
+     */
193
+    private function get_tax_query( $entity_types ) {
194
+
195
+        $entity_type_service = $this->entity_type_service;
196
+        $entity_types_terms  = array_filter( array_map( function ( $item ) use ( $entity_type_service ) {
197
+            return $entity_type_service->get_term_by_uri( $item );
198
+        }, $entity_types ) );
199
+
200
+        $entity_types_terms_ids = array_map( function ( $term ) {
201
+            return $term->term_id;
202
+        }, $entity_types_terms );
203
+
204
+        $tax_query = array(
205
+            'tax_query' => array(
206
+                array(
207
+                    'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
208
+                    'field'    => 'term_id',
209
+                    'terms'    => $entity_types_terms_ids,
210
+                    'operator' => 'NOT IN',
211
+                ),
212
+            ),
213
+        );
214
+
215
+        return $tax_query;
216
+    }
217 217
 
218 218
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -48,20 +48,20 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @param \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance.
50 50
 	 */
51
-	public function __construct( $entity_type_service ) {
51
+	public function __construct($entity_type_service) {
52 52
 
53 53
 		// Set the entity type service instance.
54 54
 		$this->entity_type_service = $entity_type_service;
55 55
 
56 56
 		// Load the options.
57
-		$this->options = get_option( 'wl_mappings', array() );
57
+		$this->options = get_option('wl_mappings', array());
58 58
 
59 59
 		// Hook to `wl_valid_entity_post_types` and to `wl_default_entity_types_for_post_type`.
60
-		add_filter( 'wl_valid_entity_post_types', array( $this, 'valid_entity_post_types', ), 9 );
61
-		add_filter( 'wl_default_entity_types_for_post_type', array(
60
+		add_filter('wl_valid_entity_post_types', array($this, 'valid_entity_post_types',), 9);
61
+		add_filter('wl_default_entity_types_for_post_type', array(
62 62
 			$this,
63 63
 			'default_entity_types_for_post_type',
64
-		), 9, 2 );
64
+		), 9, 2);
65 65
 
66 66
 		// Set the singleton instance.
67 67
 		self::$instance = $this;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	private function save_options() {
89 89
 
90
-		update_option( 'wl_mappings', $this->options, true );
90
+		update_option('wl_mappings', $this->options, true);
91 91
 
92 92
 	}
93 93
 
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	 * @param string $post_type Post type.
100 100
 	 * @param array  $entity_types An array of entity types slugs.
101 101
 	 */
102
-	public function set_entity_types_for_post_type( $post_type, $entity_types ) {
102
+	public function set_entity_types_for_post_type($post_type, $entity_types) {
103 103
 
104
-		$this->options[ $post_type ] = $entity_types;
104
+		$this->options[$post_type] = $entity_types;
105 105
 		$this->save_options();
106 106
 
107 107
 	}
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @return array The supported post types.
117 117
 	 */
118
-	public function valid_entity_post_types( $post_types ) {
118
+	public function valid_entity_post_types($post_types) {
119 119
 
120
-		return array_merge( $post_types, array_keys( $this->options ) );
120
+		return array_merge($post_types, array_keys($this->options));
121 121
 	}
122 122
 
123 123
 	/**
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @return array The default entity types.
132 132
 	 */
133
-	public function default_entity_types_for_post_type( $default, $post_type ) {
133
+	public function default_entity_types_for_post_type($default, $post_type) {
134 134
 
135
-		return isset( $this->options[ $post_type ] ) ? $this->options[ $post_type ] : $default;
135
+		return isset($this->options[$post_type]) ? $this->options[$post_type] : $default;
136 136
 	}
137 137
 
138 138
 	/**
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
 	 * @type int     $count The total element count.
153 153
 	 * }
154 154
 	 */
155
-	public function update( $post_type, $entity_types, $offset = 0 ) {
155
+	public function update($post_type, $entity_types, $offset = 0) {
156 156
 
157 157
 		$entity_type_service = $this->entity_type_service;
158
-		$tax_query           = $this->get_tax_query( $entity_types );
158
+		$tax_query           = $this->get_tax_query($entity_types);
159 159
 
160
-		return Wordlift_Batch_Action::process( $post_type, $offset, $tax_query, function ( $post_id ) use ( $entity_type_service, $entity_types ) {
161
-			foreach ( $entity_types as $entity_type ) {
162
-				$entity_type_service->set( $post_id, $entity_type, false );
160
+		return Wordlift_Batch_Action::process($post_type, $offset, $tax_query, function($post_id) use ($entity_type_service, $entity_types) {
161
+			foreach ($entity_types as $entity_type) {
162
+				$entity_type_service->set($post_id, $entity_type, false);
163 163
 			}
164 164
 		} );
165 165
 	}
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 	 *
175 175
 	 * @return int The number of posts to be assigned with entity types.
176 176
 	 */
177
-	public function count( $post_type, $entity_types ) {
177
+	public function count($post_type, $entity_types) {
178 178
 
179
-		$tax_query = $this->get_tax_query( $entity_types );
179
+		$tax_query = $this->get_tax_query($entity_types);
180 180
 
181
-		return Wordlift_Batch_Action::count( $post_type, $tax_query );
181
+		return Wordlift_Batch_Action::count($post_type, $tax_query);
182 182
 	}
183 183
 
184 184
 	/**
@@ -190,16 +190,16 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @return array The tax query.
192 192
 	 */
193
-	private function get_tax_query( $entity_types ) {
193
+	private function get_tax_query($entity_types) {
194 194
 
195 195
 		$entity_type_service = $this->entity_type_service;
196
-		$entity_types_terms  = array_filter( array_map( function ( $item ) use ( $entity_type_service ) {
197
-			return $entity_type_service->get_term_by_uri( $item );
198
-		}, $entity_types ) );
196
+		$entity_types_terms  = array_filter(array_map(function($item) use ($entity_type_service) {
197
+			return $entity_type_service->get_term_by_uri($item);
198
+		}, $entity_types));
199 199
 
200
-		$entity_types_terms_ids = array_map( function ( $term ) {
200
+		$entity_types_terms_ids = array_map(function($term) {
201 201
 			return $term->term_id;
202
-		}, $entity_types_terms );
202
+		}, $entity_types_terms);
203 203
 
204 204
 		$tax_query = array(
205 205
 			'tax_query' => array(
Please login to merge, or discard this patch.
src/cli/class-wordlift-push-reference-data-command.php 2 patches
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -16,131 +16,131 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class Wordlift_Push_Reference_Data_Command {
18 18
 
19
-	/**
20
-	 * The {@link Wordlift_Relation_Service} instance.
21
-	 *
22
-	 * @since  3.18.0
23
-	 * @access private
24
-	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
25
-	 */
26
-	private $relation_service;
27
-
28
-	/**
29
-	 * The {@link Wordlift_Entity_Service} instance.
30
-	 *
31
-	 * @since  3.18.0
32
-	 * @access private
33
-	 * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
34
-	 */
35
-	private $entity_service;
36
-
37
-	/**
38
-	 * The {@link Wordlift_Sparql_Service} instance.
39
-	 *
40
-	 * @since  3.18.0
41
-	 * @access private
42
-	 * @var \Wordlift_Sparql_Service $sparql_service The {@link Wordlift_Sparql_Service} instance.
43
-	 */
44
-	private $sparql_service;
45
-
46
-	/**
47
-	 * The {@link Wordlift_Configuration_Service} instance.
48
-	 *
49
-	 * @since  3.18.0
50
-	 * @access private
51
-	 * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
52
-	 */
53
-	private $configuration_service;
54
-	/**
55
-	 * @var Wordlift_Entity_Type_Service
56
-	 */
57
-	private $entity_type_service;
58
-
59
-	/**
60
-	 * Wordlift_Push_Reference_Data_Command constructor.
61
-	 *
62
-	 * @param \Wordlift_Relation_Service      $relation_service The {@link Wordlift_Relation_Service} instance.
63
-	 * @param \Wordlift_Entity_Service        $entity_service The {@link Wordlift_Entity_Service} instance.
64
-	 * @param \Wordlift_Sparql_Service        $sparql_service The {@link Wordlift_Sparql_Service} instance.
65
-	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
66
-	 * @param \Wordlift_Entity_Type_Service   $entity_type_service The {@link Wordlift_Entity_Type_Service} instance.
67
-	 *
68
-	 * @since 3.18.0
69
-	 *
70
-	 */
71
-	public function __construct( $relation_service, $entity_service, $sparql_service, $configuration_service, $entity_type_service ) {
72
-
73
-		$this->relation_service      = $relation_service;
74
-		$this->entity_service        = $entity_service;
75
-		$this->sparql_service        = $sparql_service;
76
-		$this->configuration_service = $configuration_service;
77
-		$this->entity_type_service   = $entity_type_service;
78
-
79
-	}
80
-
81
-	public function __invoke( $args ) {
82
-
83
-		$relations    = $this->relation_service->find_all_grouped_by_subject_id();
84
-		$progress_bar = \WP_CLI\Utils\make_progress_bar( 'Processing...', count( $relations ) );
85
-
86
-		foreach ( $relations as $relation ) {
87
-			$progress_bar->tick();
88
-
89
-			// Get the post.
90
-			$post = get_post( $relation->subject_id );
91
-
92
-			// Bail out if the post isn't found.
93
-			if ( null == $post ) {
94
-				continue;
95
-			}
96
-
97
-			// Bail out if it's an entity: we're only interested in articles
98
-			// *referencing* entities.
99
-			if ( $this->entity_service->is_entity( $post->ID ) ) {
100
-				continue;
101
-			}
102
-
103
-			// Get the article URI.
104
-			$uri = $this->entity_service->get_uri( $post->ID );
105
-
106
-			// Prepare the DELETE query to delete existing data.
107
-			$query = self::get_delete_query( $uri )
108
-			         . $this->get_insert_query( $post, $uri, explode( ',', $relation->object_ids ) );
109
-
110
-			$this->sparql_service->execute( $query, false );
111
-
112
-		}
113
-
114
-		$progress_bar->finish();
115
-
116
-	}
117
-
118
-	private static function get_delete_query( $uri ) {
119
-
120
-		return Wordlift_Query_Builder
121
-			       ::new_instance()
122
-			       ->delete()->statement( $uri, Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, '?o' )
123
-			       ->build()
124
-		       . Wordlift_Query_Builder
125
-			       ::new_instance()
126
-			       ->delete()->statement( $uri, Wordlift_Query_Builder::RDFS_TYPE_URI, '?o' )
127
-			       ->build()
128
-		       . Wordlift_Query_Builder
129
-			       ::new_instance()
130
-			       ->delete()->statement( $uri, Wordlift_Query_Builder::SCHEMA_HEADLINE_URI, '?o' )
131
-			       ->build()
132
-		       . Wordlift_Query_Builder
133
-			       ::new_instance()
134
-			       ->delete()->statement( $uri, Wordlift_Query_Builder::SCHEMA_URL_URI, '?o' )
135
-			       ->build();
136
-	}
137
-
138
-	private function get_insert_query( $post, $uri, $object_ids ) {
139
-
140
-		$language_code = $this->configuration_service->get_language_code();
141
-		$type          = $this->entity_type_service->get( $post->ID );
142
-
143
-		/*
19
+    /**
20
+     * The {@link Wordlift_Relation_Service} instance.
21
+     *
22
+     * @since  3.18.0
23
+     * @access private
24
+     * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
25
+     */
26
+    private $relation_service;
27
+
28
+    /**
29
+     * The {@link Wordlift_Entity_Service} instance.
30
+     *
31
+     * @since  3.18.0
32
+     * @access private
33
+     * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
34
+     */
35
+    private $entity_service;
36
+
37
+    /**
38
+     * The {@link Wordlift_Sparql_Service} instance.
39
+     *
40
+     * @since  3.18.0
41
+     * @access private
42
+     * @var \Wordlift_Sparql_Service $sparql_service The {@link Wordlift_Sparql_Service} instance.
43
+     */
44
+    private $sparql_service;
45
+
46
+    /**
47
+     * The {@link Wordlift_Configuration_Service} instance.
48
+     *
49
+     * @since  3.18.0
50
+     * @access private
51
+     * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
52
+     */
53
+    private $configuration_service;
54
+    /**
55
+     * @var Wordlift_Entity_Type_Service
56
+     */
57
+    private $entity_type_service;
58
+
59
+    /**
60
+     * Wordlift_Push_Reference_Data_Command constructor.
61
+     *
62
+     * @param \Wordlift_Relation_Service      $relation_service The {@link Wordlift_Relation_Service} instance.
63
+     * @param \Wordlift_Entity_Service        $entity_service The {@link Wordlift_Entity_Service} instance.
64
+     * @param \Wordlift_Sparql_Service        $sparql_service The {@link Wordlift_Sparql_Service} instance.
65
+     * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
66
+     * @param \Wordlift_Entity_Type_Service   $entity_type_service The {@link Wordlift_Entity_Type_Service} instance.
67
+     *
68
+     * @since 3.18.0
69
+     *
70
+     */
71
+    public function __construct( $relation_service, $entity_service, $sparql_service, $configuration_service, $entity_type_service ) {
72
+
73
+        $this->relation_service      = $relation_service;
74
+        $this->entity_service        = $entity_service;
75
+        $this->sparql_service        = $sparql_service;
76
+        $this->configuration_service = $configuration_service;
77
+        $this->entity_type_service   = $entity_type_service;
78
+
79
+    }
80
+
81
+    public function __invoke( $args ) {
82
+
83
+        $relations    = $this->relation_service->find_all_grouped_by_subject_id();
84
+        $progress_bar = \WP_CLI\Utils\make_progress_bar( 'Processing...', count( $relations ) );
85
+
86
+        foreach ( $relations as $relation ) {
87
+            $progress_bar->tick();
88
+
89
+            // Get the post.
90
+            $post = get_post( $relation->subject_id );
91
+
92
+            // Bail out if the post isn't found.
93
+            if ( null == $post ) {
94
+                continue;
95
+            }
96
+
97
+            // Bail out if it's an entity: we're only interested in articles
98
+            // *referencing* entities.
99
+            if ( $this->entity_service->is_entity( $post->ID ) ) {
100
+                continue;
101
+            }
102
+
103
+            // Get the article URI.
104
+            $uri = $this->entity_service->get_uri( $post->ID );
105
+
106
+            // Prepare the DELETE query to delete existing data.
107
+            $query = self::get_delete_query( $uri )
108
+                        . $this->get_insert_query( $post, $uri, explode( ',', $relation->object_ids ) );
109
+
110
+            $this->sparql_service->execute( $query, false );
111
+
112
+        }
113
+
114
+        $progress_bar->finish();
115
+
116
+    }
117
+
118
+    private static function get_delete_query( $uri ) {
119
+
120
+        return Wordlift_Query_Builder
121
+                    ::new_instance()
122
+                    ->delete()->statement( $uri, Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, '?o' )
123
+                    ->build()
124
+                . Wordlift_Query_Builder
125
+                    ::new_instance()
126
+                    ->delete()->statement( $uri, Wordlift_Query_Builder::RDFS_TYPE_URI, '?o' )
127
+                    ->build()
128
+                . Wordlift_Query_Builder
129
+                    ::new_instance()
130
+                    ->delete()->statement( $uri, Wordlift_Query_Builder::SCHEMA_HEADLINE_URI, '?o' )
131
+                    ->build()
132
+                . Wordlift_Query_Builder
133
+                    ::new_instance()
134
+                    ->delete()->statement( $uri, Wordlift_Query_Builder::SCHEMA_URL_URI, '?o' )
135
+                    ->build();
136
+    }
137
+
138
+    private function get_insert_query( $post, $uri, $object_ids ) {
139
+
140
+        $language_code = $this->configuration_service->get_language_code();
141
+        $type          = $this->entity_type_service->get( $post->ID );
142
+
143
+        /*
144 144
 		 * When inserting the schema:url property in the triple store, we want to use the production
145 145
 		 * URL, i.e. we must take into consideration that the current URL is a staging one and that
146 146
 		 * 3rd parties may want to update the URL with a production one.
@@ -149,24 +149,24 @@  discard block
 block discarded – undo
149 149
 		 *
150 150
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/850.
151 151
 		 */
152
-		$builder = Wordlift_Query_Builder
153
-			::new_instance()
154
-			->insert()
155
-			->statement( $uri, Wordlift_Query_Builder::SCHEMA_HEADLINE_URI, $post->post_title, Wordlift_Query_Builder::OBJECT_VALUE, null, $language_code )
156
-			->statement( $uri, Wordlift_Query_Builder::RDFS_TYPE_URI, $type['uri'] );
157
-
158
-		$permalink = Wordlift_Post_Adapter::get_production_permalink( $post->ID );
159
-		if ( ! empty( $permalink ) ) {
160
-			$builder->statement( $uri, Wordlift_Query_Builder::SCHEMA_URL_URI, $permalink );
161
-		}
162
-
163
-		$entity_service = $this->entity_service;
164
-		array_walk( $object_ids, function ( $item ) use ( $entity_service, $builder, $uri ) {
165
-			$object_uri = $entity_service->get_uri( $item );
166
-			$builder->statement( $uri, Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, $object_uri );
167
-		} );
168
-
169
-		return $builder->build();
170
-	}
152
+        $builder = Wordlift_Query_Builder
153
+            ::new_instance()
154
+            ->insert()
155
+            ->statement( $uri, Wordlift_Query_Builder::SCHEMA_HEADLINE_URI, $post->post_title, Wordlift_Query_Builder::OBJECT_VALUE, null, $language_code )
156
+            ->statement( $uri, Wordlift_Query_Builder::RDFS_TYPE_URI, $type['uri'] );
157
+
158
+        $permalink = Wordlift_Post_Adapter::get_production_permalink( $post->ID );
159
+        if ( ! empty( $permalink ) ) {
160
+            $builder->statement( $uri, Wordlift_Query_Builder::SCHEMA_URL_URI, $permalink );
161
+        }
162
+
163
+        $entity_service = $this->entity_service;
164
+        array_walk( $object_ids, function ( $item ) use ( $entity_service, $builder, $uri ) {
165
+            $object_uri = $entity_service->get_uri( $item );
166
+            $builder->statement( $uri, Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, $object_uri );
167
+        } );
168
+
169
+        return $builder->build();
170
+    }
171 171
 
172 172
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @since 3.18.0
69 69
 	 *
70 70
 	 */
71
-	public function __construct( $relation_service, $entity_service, $sparql_service, $configuration_service, $entity_type_service ) {
71
+	public function __construct($relation_service, $entity_service, $sparql_service, $configuration_service, $entity_type_service) {
72 72
 
73 73
 		$this->relation_service      = $relation_service;
74 74
 		$this->entity_service        = $entity_service;
@@ -78,36 +78,36 @@  discard block
 block discarded – undo
78 78
 
79 79
 	}
80 80
 
81
-	public function __invoke( $args ) {
81
+	public function __invoke($args) {
82 82
 
83 83
 		$relations    = $this->relation_service->find_all_grouped_by_subject_id();
84
-		$progress_bar = \WP_CLI\Utils\make_progress_bar( 'Processing...', count( $relations ) );
84
+		$progress_bar = \WP_CLI\Utils\make_progress_bar('Processing...', count($relations));
85 85
 
86
-		foreach ( $relations as $relation ) {
86
+		foreach ($relations as $relation) {
87 87
 			$progress_bar->tick();
88 88
 
89 89
 			// Get the post.
90
-			$post = get_post( $relation->subject_id );
90
+			$post = get_post($relation->subject_id);
91 91
 
92 92
 			// Bail out if the post isn't found.
93
-			if ( null == $post ) {
93
+			if (null == $post) {
94 94
 				continue;
95 95
 			}
96 96
 
97 97
 			// Bail out if it's an entity: we're only interested in articles
98 98
 			// *referencing* entities.
99
-			if ( $this->entity_service->is_entity( $post->ID ) ) {
99
+			if ($this->entity_service->is_entity($post->ID)) {
100 100
 				continue;
101 101
 			}
102 102
 
103 103
 			// Get the article URI.
104
-			$uri = $this->entity_service->get_uri( $post->ID );
104
+			$uri = $this->entity_service->get_uri($post->ID);
105 105
 
106 106
 			// Prepare the DELETE query to delete existing data.
107
-			$query = self::get_delete_query( $uri )
108
-			         . $this->get_insert_query( $post, $uri, explode( ',', $relation->object_ids ) );
107
+			$query = self::get_delete_query($uri)
108
+			         . $this->get_insert_query($post, $uri, explode(',', $relation->object_ids));
109 109
 
110
-			$this->sparql_service->execute( $query, false );
110
+			$this->sparql_service->execute($query, false);
111 111
 
112 112
 		}
113 113
 
@@ -115,30 +115,30 @@  discard block
 block discarded – undo
115 115
 
116 116
 	}
117 117
 
118
-	private static function get_delete_query( $uri ) {
118
+	private static function get_delete_query($uri) {
119 119
 
120 120
 		return Wordlift_Query_Builder
121 121
 			       ::new_instance()
122
-			       ->delete()->statement( $uri, Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, '?o' )
122
+			       ->delete()->statement($uri, Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, '?o')
123 123
 			       ->build()
124 124
 		       . Wordlift_Query_Builder
125 125
 			       ::new_instance()
126
-			       ->delete()->statement( $uri, Wordlift_Query_Builder::RDFS_TYPE_URI, '?o' )
126
+			       ->delete()->statement($uri, Wordlift_Query_Builder::RDFS_TYPE_URI, '?o')
127 127
 			       ->build()
128 128
 		       . Wordlift_Query_Builder
129 129
 			       ::new_instance()
130
-			       ->delete()->statement( $uri, Wordlift_Query_Builder::SCHEMA_HEADLINE_URI, '?o' )
130
+			       ->delete()->statement($uri, Wordlift_Query_Builder::SCHEMA_HEADLINE_URI, '?o')
131 131
 			       ->build()
132 132
 		       . Wordlift_Query_Builder
133 133
 			       ::new_instance()
134
-			       ->delete()->statement( $uri, Wordlift_Query_Builder::SCHEMA_URL_URI, '?o' )
134
+			       ->delete()->statement($uri, Wordlift_Query_Builder::SCHEMA_URL_URI, '?o')
135 135
 			       ->build();
136 136
 	}
137 137
 
138
-	private function get_insert_query( $post, $uri, $object_ids ) {
138
+	private function get_insert_query($post, $uri, $object_ids) {
139 139
 
140 140
 		$language_code = $this->configuration_service->get_language_code();
141
-		$type          = $this->entity_type_service->get( $post->ID );
141
+		$type          = $this->entity_type_service->get($post->ID);
142 142
 
143 143
 		/*
144 144
 		 * When inserting the schema:url property in the triple store, we want to use the production
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
 		$builder = Wordlift_Query_Builder
153 153
 			::new_instance()
154 154
 			->insert()
155
-			->statement( $uri, Wordlift_Query_Builder::SCHEMA_HEADLINE_URI, $post->post_title, Wordlift_Query_Builder::OBJECT_VALUE, null, $language_code )
156
-			->statement( $uri, Wordlift_Query_Builder::RDFS_TYPE_URI, $type['uri'] );
155
+			->statement($uri, Wordlift_Query_Builder::SCHEMA_HEADLINE_URI, $post->post_title, Wordlift_Query_Builder::OBJECT_VALUE, null, $language_code)
156
+			->statement($uri, Wordlift_Query_Builder::RDFS_TYPE_URI, $type['uri']);
157 157
 
158
-		$permalink = Wordlift_Post_Adapter::get_production_permalink( $post->ID );
159
-		if ( ! empty( $permalink ) ) {
160
-			$builder->statement( $uri, Wordlift_Query_Builder::SCHEMA_URL_URI, $permalink );
158
+		$permalink = Wordlift_Post_Adapter::get_production_permalink($post->ID);
159
+		if ( ! empty($permalink)) {
160
+			$builder->statement($uri, Wordlift_Query_Builder::SCHEMA_URL_URI, $permalink);
161 161
 		}
162 162
 
163 163
 		$entity_service = $this->entity_service;
164
-		array_walk( $object_ids, function ( $item ) use ( $entity_service, $builder, $uri ) {
165
-			$object_uri = $entity_service->get_uri( $item );
166
-			$builder->statement( $uri, Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, $object_uri );
164
+		array_walk($object_ids, function($item) use ($entity_service, $builder, $uri) {
165
+			$object_uri = $entity_service->get_uri($item);
166
+			$builder->statement($uri, Wordlift_Query_Builder::DCTERMS_REFERENCES_URI, $object_uri);
167 167
 		} );
168 168
 
169 169
 		return $builder->build();
Please login to merge, or discard this patch.