Completed
Pull Request — develop (#1369)
by
unknown
03:28
created
src/wordlift/vocabulary/jsonld/class-post-jsonld.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,6 @@
 block discarded – undo
7 7
 namespace Wordlift\Vocabulary\Jsonld;
8 8
 
9 9
 use Wordlift\Vocabulary\Api\Entity_Rest_Endpoint;
10
-use Wordlift\Vocabulary\Data\Entity_List\Entity_List_Factory;
11 10
 use Wordlift\Vocabulary\Terms_Compat;
12 11
 
13 12
 class Post_Jsonld {
Please login to merge, or discard this patch.
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -14,106 +14,106 @@
 block discarded – undo
14 14
 
15 15
 
16 16
 
17
-	public function enhance_post_jsonld() {
18
-		add_filter( 'wl_post_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 11, 2 );
19
-		add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 11, 2 );
20
-	}
17
+    public function enhance_post_jsonld() {
18
+        add_filter( 'wl_post_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 11, 2 );
19
+        add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 11, 2 );
20
+    }
21 21
 
22
-	public function wl_post_jsonld_array( $arr, $post_id ) {
22
+    public function wl_post_jsonld_array( $arr, $post_id ) {
23 23
 
24
-		$jsonld     = $arr['jsonld'];
25
-		$references = $arr['references'];
24
+        $jsonld     = $arr['jsonld'];
25
+        $references = $arr['references'];
26 26
 
27
-		$this->add_mentions( $post_id, $jsonld, $references );
27
+        $this->add_mentions( $post_id, $jsonld, $references );
28 28
 
29
-		return array(
30
-			'jsonld'     => $jsonld,
31
-			'references' => $references
32
-		);
29
+        return array(
30
+            'jsonld'     => $jsonld,
31
+            'references' => $references
32
+        );
33 33
 
34
-	}
34
+    }
35 35
 
36
-	public function add_mentions( $post_id, &$jsonld, &$references ) {
36
+    public function add_mentions( $post_id, &$jsonld, &$references ) {
37 37
 
38
-		$taxonomies = Terms_Compat::get_public_taxonomies();
39
-		$terms      = array();
38
+        $taxonomies = Terms_Compat::get_public_taxonomies();
39
+        $terms      = array();
40 40
 
41
-		foreach ( $taxonomies as $taxonomy ) {
42
-			$taxonomy_terms = get_the_terms( $post_id, $taxonomy );
43
-			if ( ! $taxonomy_terms ) {
44
-				continue;
45
-			}
46
-			$terms = array_merge( $taxonomy_terms, $terms );
47
-		}
41
+        foreach ( $taxonomies as $taxonomy ) {
42
+            $taxonomy_terms = get_the_terms( $post_id, $taxonomy );
43
+            if ( ! $taxonomy_terms ) {
44
+                continue;
45
+            }
46
+            $terms = array_merge( $taxonomy_terms, $terms );
47
+        }
48 48
 
49
-		if ( ! $terms ) {
50
-			return;
51
-		}
49
+        if ( ! $terms ) {
50
+            return;
51
+        }
52 52
 
53
-		if ( ! array_key_exists( 'mentions', $jsonld ) ) {
54
-			$jsonld['mentions'] = array();
55
-		}
53
+        if ( ! array_key_exists( 'mentions', $jsonld ) ) {
54
+            $jsonld['mentions'] = array();
55
+        }
56 56
 
57
-		foreach ( $terms as $term ) {
57
+        foreach ( $terms as $term ) {
58 58
 
59
-			$is_matched = intval( get_term_meta( $term->term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, true ) ) === 1;
59
+            $is_matched = intval( get_term_meta( $term->term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, true ) ) === 1;
60 60
 
61
-			if ( ! $is_matched ) {
62
-				continue;
63
-			}
61
+            if ( ! $is_matched ) {
62
+                continue;
63
+            }
64 64
 
65
-			$entities = Jsonld_Utils::get_matched_entities_for_term( $term->term_id );
65
+            $entities = Jsonld_Utils::get_matched_entities_for_term( $term->term_id );
66 66
 
67
-			if ( count( $entities ) === 0 ) {
68
-				continue;
69
-			}
67
+            if ( count( $entities ) === 0 ) {
68
+                continue;
69
+            }
70 70
 
71
-			$jsonld['mentions'] = array_merge( $jsonld['mentions'], self::add_additional_attrs( $term, $entities ) );
72
-		}
71
+            $jsonld['mentions'] = array_merge( $jsonld['mentions'], self::add_additional_attrs( $term, $entities ) );
72
+        }
73 73
 
74
-	}
74
+    }
75 75
 
76
-	/**
77
-	 * @param $term \WP_Term
78
-	 * @param $entities
79
-	 *
80
-	 * @return array
81
-	 */
82
-	public static function add_additional_attrs( $term, $entities ) {
76
+    /**
77
+     * @param $term \WP_Term
78
+     * @param $entities
79
+     *
80
+     * @return array
81
+     */
82
+    public static function add_additional_attrs( $term, $entities ) {
83 83
 
84
-		return array_map( function ( $entity ) use ( $term ) {
85
-			$entity['@id'] = get_term_link( $term->term_id ) . '#id';
86
-			if ( ! empty( $term->description ) ) {
87
-				$entity['description'] = $term->description;
88
-			}
84
+        return array_map( function ( $entity ) use ( $term ) {
85
+            $entity['@id'] = get_term_link( $term->term_id ) . '#id';
86
+            if ( ! empty( $term->description ) ) {
87
+                $entity['description'] = $term->description;
88
+            }
89 89
 
90
-			return $entity;
90
+            return $entity;
91 91
 
92
-		}, $entities );
92
+        }, $entities );
93 93
 
94
-	}
94
+    }
95 95
 
96
-	public function wl_after_get_jsonld( $jsonld, $post_id ) {
96
+    public function wl_after_get_jsonld( $jsonld, $post_id ) {
97 97
 
98
-		if ( ! is_array( $jsonld ) || count( $jsonld ) === 0 ) {
99
-			return $jsonld;
100
-		}
98
+        if ( ! is_array( $jsonld ) || count( $jsonld ) === 0 ) {
99
+            return $jsonld;
100
+        }
101 101
 
102
-		foreach ( $jsonld as $key => $value ) {
103
-			if ( $value['@type'] === 'Article' && isset( $value['image'] ) ) {
104
-				$image = $value['image'];
105
-			}
106
-			if ( $value['@type'] === 'Recipe' && ! isset( $value['image'] ) ) {
107
-				$index = $key;
108
-			}
109
-		}
102
+        foreach ( $jsonld as $key => $value ) {
103
+            if ( $value['@type'] === 'Article' && isset( $value['image'] ) ) {
104
+                $image = $value['image'];
105
+            }
106
+            if ( $value['@type'] === 'Recipe' && ! isset( $value['image'] ) ) {
107
+                $index = $key;
108
+            }
109
+        }
110 110
 
111
-		if ( isset( $index ) && ! empty( $image ) ) {
112
-			$jsonld[ $index ]['image'] = $image;
113
-		}
111
+        if ( isset( $index ) && ! empty( $image ) ) {
112
+            $jsonld[ $index ]['image'] = $image;
113
+        }
114 114
 
115
-		return $jsonld;
115
+        return $jsonld;
116 116
 
117
-	}
117
+    }
118 118
 
119 119
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
 
16 16
 
17 17
 	public function enhance_post_jsonld() {
18
-		add_filter( 'wl_post_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 11, 2 );
19
-		add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 11, 2 );
18
+		add_filter('wl_post_jsonld_array', array($this, 'wl_post_jsonld_array'), 11, 2);
19
+		add_filter('wl_after_get_jsonld', array($this, 'wl_after_get_jsonld'), 11, 2);
20 20
 	}
21 21
 
22
-	public function wl_post_jsonld_array( $arr, $post_id ) {
22
+	public function wl_post_jsonld_array($arr, $post_id) {
23 23
 
24 24
 		$jsonld     = $arr['jsonld'];
25 25
 		$references = $arr['references'];
26 26
 
27
-		$this->add_mentions( $post_id, $jsonld, $references );
27
+		$this->add_mentions($post_id, $jsonld, $references);
28 28
 
29 29
 		return array(
30 30
 			'jsonld'     => $jsonld,
@@ -33,42 +33,42 @@  discard block
 block discarded – undo
33 33
 
34 34
 	}
35 35
 
36
-	public function add_mentions( $post_id, &$jsonld, &$references ) {
36
+	public function add_mentions($post_id, &$jsonld, &$references) {
37 37
 
38 38
 		$taxonomies = Terms_Compat::get_public_taxonomies();
39 39
 		$terms      = array();
40 40
 
41
-		foreach ( $taxonomies as $taxonomy ) {
42
-			$taxonomy_terms = get_the_terms( $post_id, $taxonomy );
43
-			if ( ! $taxonomy_terms ) {
41
+		foreach ($taxonomies as $taxonomy) {
42
+			$taxonomy_terms = get_the_terms($post_id, $taxonomy);
43
+			if ( ! $taxonomy_terms) {
44 44
 				continue;
45 45
 			}
46
-			$terms = array_merge( $taxonomy_terms, $terms );
46
+			$terms = array_merge($taxonomy_terms, $terms);
47 47
 		}
48 48
 
49
-		if ( ! $terms ) {
49
+		if ( ! $terms) {
50 50
 			return;
51 51
 		}
52 52
 
53
-		if ( ! array_key_exists( 'mentions', $jsonld ) ) {
53
+		if ( ! array_key_exists('mentions', $jsonld)) {
54 54
 			$jsonld['mentions'] = array();
55 55
 		}
56 56
 
57
-		foreach ( $terms as $term ) {
57
+		foreach ($terms as $term) {
58 58
 
59
-			$is_matched = intval( get_term_meta( $term->term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, true ) ) === 1;
59
+			$is_matched = intval(get_term_meta($term->term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, true)) === 1;
60 60
 
61
-			if ( ! $is_matched ) {
61
+			if ( ! $is_matched) {
62 62
 				continue;
63 63
 			}
64 64
 
65
-			$entities = Jsonld_Utils::get_matched_entities_for_term( $term->term_id );
65
+			$entities = Jsonld_Utils::get_matched_entities_for_term($term->term_id);
66 66
 
67
-			if ( count( $entities ) === 0 ) {
67
+			if (count($entities) === 0) {
68 68
 				continue;
69 69
 			}
70 70
 
71
-			$jsonld['mentions'] = array_merge( $jsonld['mentions'], self::add_additional_attrs( $term, $entities ) );
71
+			$jsonld['mentions'] = array_merge($jsonld['mentions'], self::add_additional_attrs($term, $entities));
72 72
 		}
73 73
 
74 74
 	}
@@ -79,37 +79,37 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @return array
81 81
 	 */
82
-	public static function add_additional_attrs( $term, $entities ) {
82
+	public static function add_additional_attrs($term, $entities) {
83 83
 
84
-		return array_map( function ( $entity ) use ( $term ) {
85
-			$entity['@id'] = get_term_link( $term->term_id ) . '#id';
86
-			if ( ! empty( $term->description ) ) {
84
+		return array_map(function($entity) use ($term) {
85
+			$entity['@id'] = get_term_link($term->term_id).'#id';
86
+			if ( ! empty($term->description)) {
87 87
 				$entity['description'] = $term->description;
88 88
 			}
89 89
 
90 90
 			return $entity;
91 91
 
92
-		}, $entities );
92
+		}, $entities);
93 93
 
94 94
 	}
95 95
 
96
-	public function wl_after_get_jsonld( $jsonld, $post_id ) {
96
+	public function wl_after_get_jsonld($jsonld, $post_id) {
97 97
 
98
-		if ( ! is_array( $jsonld ) || count( $jsonld ) === 0 ) {
98
+		if ( ! is_array($jsonld) || count($jsonld) === 0) {
99 99
 			return $jsonld;
100 100
 		}
101 101
 
102
-		foreach ( $jsonld as $key => $value ) {
103
-			if ( $value['@type'] === 'Article' && isset( $value['image'] ) ) {
102
+		foreach ($jsonld as $key => $value) {
103
+			if ($value['@type'] === 'Article' && isset($value['image'])) {
104 104
 				$image = $value['image'];
105 105
 			}
106
-			if ( $value['@type'] === 'Recipe' && ! isset( $value['image'] ) ) {
106
+			if ($value['@type'] === 'Recipe' && ! isset($value['image'])) {
107 107
 				$index = $key;
108 108
 			}
109 109
 		}
110 110
 
111
-		if ( isset( $index ) && ! empty( $image ) ) {
112
-			$jsonld[ $index ]['image'] = $image;
111
+		if (isset($index) && ! empty($image)) {
112
+			$jsonld[$index]['image'] = $image;
113 113
 		}
114 114
 
115 115
 		return $jsonld;
Please login to merge, or discard this patch.
src/wordlift/vocabulary/class-vocabulary-loader.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -22,63 +22,63 @@
 block discarded – undo
22 22
 
23 23
 class Vocabulary_Loader {
24 24
 
25
-	public function init_vocabulary() {
25
+    public function init_vocabulary() {
26 26
 
27
-		$configuration_service = \Wordlift_Configuration_Service::get_instance();
27
+        $configuration_service = \Wordlift_Configuration_Service::get_instance();
28 28
 
29
-		$api_service = new Default_Api_Service(
30
-			apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ),
31
-			60,
32
-			User_Agent::get_user_agent(),
33
-			$configuration_service->get_key()
34
-		);
29
+        $api_service = new Default_Api_Service(
30
+            apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ),
31
+            60,
32
+            User_Agent::get_user_agent(),
33
+            $configuration_service->get_key()
34
+        );
35 35
 
36
-		$cache_service    = Cache_Service_Factory::get_cache_service();
36
+        $cache_service    = Cache_Service_Factory::get_cache_service();
37 37
 
38 38
 
39
-		$analysis_service = new Analysis_Service( $api_service, $cache_service );
39
+        $analysis_service = new Analysis_Service( $api_service, $cache_service );
40 40
 
41
-		$term_data_factory = new Term_Data_Factory( $analysis_service );
41
+        $term_data_factory = new Term_Data_Factory( $analysis_service );
42 42
 
43
-		$tag_rest_endpoint = new Tag_Rest_Endpoint( $term_data_factory );
44
-		$tag_rest_endpoint->register_routes();
43
+        $tag_rest_endpoint = new Tag_Rest_Endpoint( $term_data_factory );
44
+        $tag_rest_endpoint->register_routes();
45 45
 
46
-		$entity_rest_endpoint = new Entity_Rest_Endpoint();
47
-		$entity_rest_endpoint->register_routes();
46
+        $entity_rest_endpoint = new Entity_Rest_Endpoint();
47
+        $entity_rest_endpoint->register_routes();
48 48
 
49
-		$post_jsonld = new Post_Jsonld();
50
-		$post_jsonld->enhance_post_jsonld();
49
+        $post_jsonld = new Post_Jsonld();
50
+        $post_jsonld->enhance_post_jsonld();
51 51
 
52
-		$term_jsonld = new Term_Jsonld();
53
-		$term_jsonld->init();
52
+        $term_jsonld = new Term_Jsonld();
53
+        $term_jsonld->init();
54 54
 
55
-		$term_count = Term_Count_Factory::get_instance( Term_Count_Factory::CACHED_TERM_COUNT );
56
-		new Match_Terms( $term_count );
55
+        $term_count = Term_Count_Factory::get_instance( Term_Count_Factory::CACHED_TERM_COUNT );
56
+        new Match_Terms( $term_count );
57 57
 
58
-		$analysis_background_service = new Analysis_Background_Service( $analysis_service );
58
+        $analysis_background_service = new Analysis_Background_Service( $analysis_service );
59 59
 
60 60
 
61
-		new Tag_Created_Hook( $analysis_background_service );
61
+        new Tag_Created_Hook( $analysis_background_service );
62 62
 
63
-		new Background_Analysis_Endpoint( $analysis_background_service, $cache_service );
63
+        new Background_Analysis_Endpoint( $analysis_background_service, $cache_service );
64 64
 
65
-		$reconcile_progress_endpoint = new Reconcile_Progress_Endpoint();
66
-		$reconcile_progress_endpoint->register_routes();
65
+        $reconcile_progress_endpoint = new Reconcile_Progress_Endpoint();
66
+        $reconcile_progress_endpoint->register_routes();
67 67
 
68 68
 
69
-		$term_page_hook = new Term_Page_Hook( $term_data_factory );
70
-		$term_page_hook->connect_hook();
69
+        $term_page_hook = new Term_Page_Hook( $term_data_factory );
70
+        $term_page_hook->connect_hook();
71 71
 
72
-		$dashboard_widget = new Term_Matches_Widget( $term_count );
73
-		$dashboard_widget->connect_hook();
72
+        $dashboard_widget = new Term_Matches_Widget( $term_count );
73
+        $dashboard_widget->connect_hook();
74 74
 
75
-		$cached_term_count_manager = new Cached_Term_count_Manager();
76
-		$cached_term_count_manager->connect_hook();
75
+        $cached_term_count_manager = new Cached_Term_count_Manager();
76
+        $cached_term_count_manager->connect_hook();
77 77
 
78
-		$settings_tab = new Settings_Tab();
79
-		$settings_tab->connect_hook();
78
+        $settings_tab = new Settings_Tab();
79
+        $settings_tab->connect_hook();
80 80
 
81
-	}
81
+    }
82 82
 
83 83
 }
84 84
 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		$configuration_service = \Wordlift_Configuration_Service::get_instance();
28 28
 
29 29
 		$api_service = new Default_Api_Service(
30
-			apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ),
30
+			apply_filters('wl_api_base_url', 'https://api.wordlift.io'),
31 31
 			60,
32 32
 			User_Agent::get_user_agent(),
33 33
 			$configuration_service->get_key()
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 		$cache_service    = Cache_Service_Factory::get_cache_service();
37 37
 
38 38
 
39
-		$analysis_service = new Analysis_Service( $api_service, $cache_service );
39
+		$analysis_service = new Analysis_Service($api_service, $cache_service);
40 40
 
41
-		$term_data_factory = new Term_Data_Factory( $analysis_service );
41
+		$term_data_factory = new Term_Data_Factory($analysis_service);
42 42
 
43
-		$tag_rest_endpoint = new Tag_Rest_Endpoint( $term_data_factory );
43
+		$tag_rest_endpoint = new Tag_Rest_Endpoint($term_data_factory);
44 44
 		$tag_rest_endpoint->register_routes();
45 45
 
46 46
 		$entity_rest_endpoint = new Entity_Rest_Endpoint();
@@ -52,24 +52,24 @@  discard block
 block discarded – undo
52 52
 		$term_jsonld = new Term_Jsonld();
53 53
 		$term_jsonld->init();
54 54
 
55
-		$term_count = Term_Count_Factory::get_instance( Term_Count_Factory::CACHED_TERM_COUNT );
56
-		new Match_Terms( $term_count );
55
+		$term_count = Term_Count_Factory::get_instance(Term_Count_Factory::CACHED_TERM_COUNT);
56
+		new Match_Terms($term_count);
57 57
 
58
-		$analysis_background_service = new Analysis_Background_Service( $analysis_service );
58
+		$analysis_background_service = new Analysis_Background_Service($analysis_service);
59 59
 
60 60
 
61
-		new Tag_Created_Hook( $analysis_background_service );
61
+		new Tag_Created_Hook($analysis_background_service);
62 62
 
63
-		new Background_Analysis_Endpoint( $analysis_background_service, $cache_service );
63
+		new Background_Analysis_Endpoint($analysis_background_service, $cache_service);
64 64
 
65 65
 		$reconcile_progress_endpoint = new Reconcile_Progress_Endpoint();
66 66
 		$reconcile_progress_endpoint->register_routes();
67 67
 
68 68
 
69
-		$term_page_hook = new Term_Page_Hook( $term_data_factory );
69
+		$term_page_hook = new Term_Page_Hook($term_data_factory);
70 70
 		$term_page_hook->connect_hook();
71 71
 
72
-		$dashboard_widget = new Term_Matches_Widget( $term_count );
72
+		$dashboard_widget = new Term_Matches_Widget($term_count);
73 73
 		$dashboard_widget->connect_hook();
74 74
 
75 75
 		$cached_term_count_manager = new Cached_Term_count_Manager();
Please login to merge, or discard this patch.
src/wordlift/vocabulary/jsonld/class-jsonld-utils.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,16 +12,16 @@
 block discarded – undo
12 12
 
13 13
 class Jsonld_Utils {
14 14
 
15
-	/**
16
-	 * @param $term_id
17
-	 *
18
-	 * @return array|array[]|mixed
19
-	 */
20
-	public static function get_matched_entities_for_term( $term_id ) {
15
+    /**
16
+     * @param $term_id
17
+     *
18
+     * @return array|array[]|mixed
19
+     */
20
+    public static function get_matched_entities_for_term( $term_id ) {
21 21
 
22
-		$entity = Entity_List_Factory::get_instance( $term_id );
22
+        $entity = Entity_List_Factory::get_instance( $term_id );
23 23
 
24
-		return $entity->get_jsonld_data();
25
-	}
24
+        return $entity->get_jsonld_data();
25
+    }
26 26
 
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@
 block discarded – undo
17 17
 	 *
18 18
 	 * @return array|array[]|mixed
19 19
 	 */
20
-	public static function get_matched_entities_for_term( $term_id ) {
20
+	public static function get_matched_entities_for_term($term_id) {
21 21
 
22
-		$entity = Entity_List_Factory::get_instance( $term_id );
22
+		$entity = Entity_List_Factory::get_instance($term_id);
23 23
 
24 24
 		return $entity->get_jsonld_data();
25 25
 	}
Please login to merge, or discard this patch.
src/wordlift/vocabulary/jsonld/class-term-jsonld.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@
 block discarded – undo
8 8
 
9 9
 class Term_Jsonld {
10 10
 
11
-	public function init() {
12
-		add_action( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
13
-	}
11
+    public function init() {
12
+        add_action( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
13
+    }
14 14
 
15
-	public function wl_term_jsonld_array( $jsonld_array, $term_id ) {
15
+    public function wl_term_jsonld_array( $jsonld_array, $term_id ) {
16 16
 
17
-		$entities = Jsonld_Utils::get_matched_entities_for_term( $term_id );
17
+        $entities = Jsonld_Utils::get_matched_entities_for_term( $term_id );
18 18
 
19
-		if ( count( $entities ) > 0 ) {
20
-			$entity                     = array_shift( $entities );
21
-			$entity['@context']         = 'http://schema.org';
22
-			$entity['@id']              = get_term_link( $term_id ) . "/#id";
23
-			$entity['url']              = get_term_link( $term_id );
24
-			$entity['mainEntityOfPage'] = get_term_link( $term_id );
25
-			$jsonld_array['jsonld'][] = $entity;
26
-		}
19
+        if ( count( $entities ) > 0 ) {
20
+            $entity                     = array_shift( $entities );
21
+            $entity['@context']         = 'http://schema.org';
22
+            $entity['@id']              = get_term_link( $term_id ) . "/#id";
23
+            $entity['url']              = get_term_link( $term_id );
24
+            $entity['mainEntityOfPage'] = get_term_link( $term_id );
25
+            $jsonld_array['jsonld'][] = $entity;
26
+        }
27 27
 
28
-		return $jsonld_array;
29
-	}
28
+        return $jsonld_array;
29
+    }
30 30
 
31 31
 }
32 32
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,19 +9,19 @@
 block discarded – undo
9 9
 class Term_Jsonld {
10 10
 
11 11
 	public function init() {
12
-		add_action( 'wl_term_jsonld_array', array( $this, 'wl_term_jsonld_array' ), 10, 2 );
12
+		add_action('wl_term_jsonld_array', array($this, 'wl_term_jsonld_array'), 10, 2);
13 13
 	}
14 14
 
15
-	public function wl_term_jsonld_array( $jsonld_array, $term_id ) {
15
+	public function wl_term_jsonld_array($jsonld_array, $term_id) {
16 16
 
17
-		$entities = Jsonld_Utils::get_matched_entities_for_term( $term_id );
17
+		$entities = Jsonld_Utils::get_matched_entities_for_term($term_id);
18 18
 
19
-		if ( count( $entities ) > 0 ) {
20
-			$entity                     = array_shift( $entities );
19
+		if (count($entities) > 0) {
20
+			$entity                     = array_shift($entities);
21 21
 			$entity['@context']         = 'http://schema.org';
22
-			$entity['@id']              = get_term_link( $term_id ) . "/#id";
23
-			$entity['url']              = get_term_link( $term_id );
24
-			$entity['mainEntityOfPage'] = get_term_link( $term_id );
22
+			$entity['@id']              = get_term_link($term_id)."/#id";
23
+			$entity['url']              = get_term_link($term_id);
24
+			$entity['mainEntityOfPage'] = get_term_link($term_id);
25 25
 			$jsonld_array['jsonld'][] = $entity;
26 26
 		}
27 27
 
Please login to merge, or discard this patch.