Completed
Pull Request — master (#1445)
by Naveen
57s
created
src/wordlift/vocabulary-terms/jsonld/class-post-jsonld.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -11,78 +11,78 @@
 block discarded – undo
11 11
 
12 12
 class Post_Jsonld {
13 13
 
14
-	public function init() {
15
-		add_filter( 'wl_post_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 10, 2 );
16
-	}
14
+    public function init() {
15
+        add_filter( 'wl_post_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 10, 2 );
16
+    }
17 17
 
18
-	public function wl_post_jsonld_array( $data, $post_id ) {
18
+    public function wl_post_jsonld_array( $data, $post_id ) {
19 19
 
20
-		$term_references = $this->get_term_references( $post_id );
20
+        $term_references = $this->get_term_references( $post_id );
21 21
 
22
-		if ( ! $term_references ) {
23
-			return $data;
24
-		}
22
+        if ( ! $term_references ) {
23
+            return $data;
24
+        }
25 25
 
26
-		$references         = $data['references'];
27
-		$jsonld             = $data['jsonld'];
26
+        $references         = $data['references'];
27
+        $jsonld             = $data['jsonld'];
28 28
 
29
-		$jsonld['mentions'] = $this->append_term_mentions( $jsonld, $term_references );
29
+        $jsonld['mentions'] = $this->append_term_mentions( $jsonld, $term_references );
30 30
 
31
-		return array(
32
-			'jsonld'     => $jsonld,
33
-			'references' => array_merge( $references, $term_references )
34
-		);
35
-	}
31
+        return array(
32
+            'jsonld'     => $jsonld,
33
+            'references' => array_merge( $references, $term_references )
34
+        );
35
+    }
36 36
 
37
-	/**
38
-	 * @param $post_id
39
-	 *
40
-	 * @return array Returns a list of term references, Returns empty array if none found.
41
-	 */
42
-	private function get_term_references( $post_id ) {
37
+    /**
38
+     * @param $post_id
39
+     *
40
+     * @return array Returns a list of term references, Returns empty array if none found.
41
+     */
42
+    private function get_term_references( $post_id ) {
43 43
 
44
-		$taxonomies_for_post = get_object_taxonomies( get_post_type( $post_id ) );
44
+        $taxonomies_for_post = get_object_taxonomies( get_post_type( $post_id ) );
45 45
 
46
-		// now we need to collect all terms attached to this post.
47
-		$terms = array();
46
+        // now we need to collect all terms attached to this post.
47
+        $terms = array();
48 48
 
49
-		foreach ( $taxonomies_for_post as $taxonomy ) {
50
-			$taxonomy_terms = get_the_terms( $post_id, $taxonomy );
51
-			if ( is_array( $taxonomy_terms ) ) {
52
-				$terms = array_merge( $terms, $taxonomy_terms );
53
-			}
54
-		}
49
+        foreach ( $taxonomies_for_post as $taxonomy ) {
50
+            $taxonomy_terms = get_the_terms( $post_id, $taxonomy );
51
+            if ( is_array( $taxonomy_terms ) ) {
52
+                $terms = array_merge( $terms, $taxonomy_terms );
53
+            }
54
+        }
55 55
 
56
-		// Convert everything to the Term Reference.
57
-		return array_filter( array_map( function ( $term ) {
58
-			/**
59
-			 * @var \WP_Term $term
60
-			 */
61
-			if ( wl_get_term_entity_uri( $term->term_id ) ) {
62
-				return new Term_Reference( $term->term_id );
63
-			}
56
+        // Convert everything to the Term Reference.
57
+        return array_filter( array_map( function ( $term ) {
58
+            /**
59
+             * @var \WP_Term $term
60
+             */
61
+            if ( wl_get_term_entity_uri( $term->term_id ) ) {
62
+                return new Term_Reference( $term->term_id );
63
+            }
64 64
 
65
-			return false;
66
-		}, $terms ) );
65
+            return false;
66
+        }, $terms ) );
67 67
 
68
-	}
68
+    }
69 69
 
70
-	/**
71
-	 * @param $jsonld array
72
-	 * @param $term_references array<Term_Reference>
73
-	 */
74
-	private function append_term_mentions( $jsonld, $term_references ) {
70
+    /**
71
+     * @param $jsonld array
72
+     * @param $term_references array<Term_Reference>
73
+     */
74
+    private function append_term_mentions( $jsonld, $term_references ) {
75 75
 
76
-		$existing_mentions = array_key_exists( 'mentions', $jsonld ) ? $jsonld['mentions'] : array();
76
+        $existing_mentions = array_key_exists( 'mentions', $jsonld ) ? $jsonld['mentions'] : array();
77 77
 
78 78
 
79
-		$term_mentions = array_map( function ( $term_reference ) {
80
-			return array(
81
-				'@id' => $term_reference->get_id()
82
-			);
83
-		}, $term_references );
79
+        $term_mentions = array_map( function ( $term_reference ) {
80
+            return array(
81
+                '@id' => $term_reference->get_id()
82
+            );
83
+        }, $term_references );
84 84
 
85
-		return array_merge( $existing_mentions, $term_mentions );
86
-	}
85
+        return array_merge( $existing_mentions, $term_mentions );
86
+    }
87 87
 
88 88
 }
89 89
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -12,25 +12,25 @@  discard block
 block discarded – undo
12 12
 class Post_Jsonld {
13 13
 
14 14
 	public function init() {
15
-		add_filter( 'wl_post_jsonld_array', array( $this, 'wl_post_jsonld_array' ), 10, 2 );
15
+		add_filter('wl_post_jsonld_array', array($this, 'wl_post_jsonld_array'), 10, 2);
16 16
 	}
17 17
 
18
-	public function wl_post_jsonld_array( $data, $post_id ) {
18
+	public function wl_post_jsonld_array($data, $post_id) {
19 19
 
20
-		$term_references = $this->get_term_references( $post_id );
20
+		$term_references = $this->get_term_references($post_id);
21 21
 
22
-		if ( ! $term_references ) {
22
+		if ( ! $term_references) {
23 23
 			return $data;
24 24
 		}
25 25
 
26 26
 		$references         = $data['references'];
27 27
 		$jsonld             = $data['jsonld'];
28 28
 
29
-		$jsonld['mentions'] = $this->append_term_mentions( $jsonld, $term_references );
29
+		$jsonld['mentions'] = $this->append_term_mentions($jsonld, $term_references);
30 30
 
31 31
 		return array(
32 32
 			'jsonld'     => $jsonld,
33
-			'references' => array_merge( $references, $term_references )
33
+			'references' => array_merge($references, $term_references)
34 34
 		);
35 35
 	}
36 36
 
@@ -39,31 +39,31 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @return array Returns a list of term references, Returns empty array if none found.
41 41
 	 */
42
-	private function get_term_references( $post_id ) {
42
+	private function get_term_references($post_id) {
43 43
 
44
-		$taxonomies_for_post = get_object_taxonomies( get_post_type( $post_id ) );
44
+		$taxonomies_for_post = get_object_taxonomies(get_post_type($post_id));
45 45
 
46 46
 		// now we need to collect all terms attached to this post.
47 47
 		$terms = array();
48 48
 
49
-		foreach ( $taxonomies_for_post as $taxonomy ) {
50
-			$taxonomy_terms = get_the_terms( $post_id, $taxonomy );
51
-			if ( is_array( $taxonomy_terms ) ) {
52
-				$terms = array_merge( $terms, $taxonomy_terms );
49
+		foreach ($taxonomies_for_post as $taxonomy) {
50
+			$taxonomy_terms = get_the_terms($post_id, $taxonomy);
51
+			if (is_array($taxonomy_terms)) {
52
+				$terms = array_merge($terms, $taxonomy_terms);
53 53
 			}
54 54
 		}
55 55
 
56 56
 		// Convert everything to the Term Reference.
57
-		return array_filter( array_map( function ( $term ) {
57
+		return array_filter(array_map(function($term) {
58 58
 			/**
59 59
 			 * @var \WP_Term $term
60 60
 			 */
61
-			if ( wl_get_term_entity_uri( $term->term_id ) ) {
62
-				return new Term_Reference( $term->term_id );
61
+			if (wl_get_term_entity_uri($term->term_id)) {
62
+				return new Term_Reference($term->term_id);
63 63
 			}
64 64
 
65 65
 			return false;
66
-		}, $terms ) );
66
+		}, $terms));
67 67
 
68 68
 	}
69 69
 
@@ -71,18 +71,18 @@  discard block
 block discarded – undo
71 71
 	 * @param $jsonld array
72 72
 	 * @param $term_references array<Term_Reference>
73 73
 	 */
74
-	private function append_term_mentions( $jsonld, $term_references ) {
74
+	private function append_term_mentions($jsonld, $term_references) {
75 75
 
76
-		$existing_mentions = array_key_exists( 'mentions', $jsonld ) ? $jsonld['mentions'] : array();
76
+		$existing_mentions = array_key_exists('mentions', $jsonld) ? $jsonld['mentions'] : array();
77 77
 
78 78
 
79
-		$term_mentions = array_map( function ( $term_reference ) {
79
+		$term_mentions = array_map(function($term_reference) {
80 80
 			return array(
81 81
 				'@id' => $term_reference->get_id()
82 82
 			);
83
-		}, $term_references );
83
+		}, $term_references);
84 84
 
85
-		return array_merge( $existing_mentions, $term_mentions );
85
+		return array_merge($existing_mentions, $term_mentions);
86 86
 	}
87 87
 
88 88
 }
89 89
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift/vocabulary-terms/class-vocabulary-terms-loader.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -13,47 +13,47 @@
 block discarded – undo
13 13
 
14 14
 
15 15
 class Vocabulary_Terms_Loader extends Default_Loader {
16
-	/**
17
-	 * @var \Wordlift_Entity_Type_Service
18
-	 */
19
-	private $entity_type_service;
20
-	/**
21
-	 * @var \Wordlift_Property_Getter
22
-	 */
23
-	private $property_getter;
24
-
25
-
26
-	/**
27
-	 * Vocabulary_Terms_Loader constructor.
28
-	 *
29
-	 * @param $entity_type_service \Wordlift_Entity_Type_Service
30
-	 * @param \Wordlift_Property_Getter $property_getter
31
-	 */
32
-	public function __construct( $entity_type_service, $property_getter ) {
33
-		parent::__construct();
34
-		$this->entity_type_service = $entity_type_service;
35
-		$this->property_getter     = $property_getter;
36
-	}
37
-
38
-
39
-	public function init_all_dependencies() {
40
-		new Entity_Type();
41
-		new Term_Metabox();
42
-		$jsonld = new Jsonld_Generator( $this->entity_type_service, $this->property_getter );
43
-		$jsonld->init();
44
-		$term_save_hook = new Term_Save();
45
-		$term_save_hook->init();
46
-		$post_jsonld = new Post_Jsonld();
47
-		$post_jsonld->init();
48
-	}
49
-
50
-	protected function get_feature_slug() {
51
-		return 'no-vocabulary-terms';
52
-	}
53
-
54
-	protected function get_feature_default_value() {
55
-		return false;
56
-	}
16
+    /**
17
+     * @var \Wordlift_Entity_Type_Service
18
+     */
19
+    private $entity_type_service;
20
+    /**
21
+     * @var \Wordlift_Property_Getter
22
+     */
23
+    private $property_getter;
24
+
25
+
26
+    /**
27
+     * Vocabulary_Terms_Loader constructor.
28
+     *
29
+     * @param $entity_type_service \Wordlift_Entity_Type_Service
30
+     * @param \Wordlift_Property_Getter $property_getter
31
+     */
32
+    public function __construct( $entity_type_service, $property_getter ) {
33
+        parent::__construct();
34
+        $this->entity_type_service = $entity_type_service;
35
+        $this->property_getter     = $property_getter;
36
+    }
37
+
38
+
39
+    public function init_all_dependencies() {
40
+        new Entity_Type();
41
+        new Term_Metabox();
42
+        $jsonld = new Jsonld_Generator( $this->entity_type_service, $this->property_getter );
43
+        $jsonld->init();
44
+        $term_save_hook = new Term_Save();
45
+        $term_save_hook->init();
46
+        $post_jsonld = new Post_Jsonld();
47
+        $post_jsonld->init();
48
+    }
49
+
50
+    protected function get_feature_slug() {
51
+        return 'no-vocabulary-terms';
52
+    }
53
+
54
+    protected function get_feature_default_value() {
55
+        return false;
56
+    }
57 57
 
58 58
 
59 59
 }
60 60
\ No newline at end of file
Please login to merge, or discard this patch.