Completed
Push — master ( 80407d...f7fe8e )
by David
05:28
created
src/includes/class-wordlift-content-filter-service.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -18,85 +18,85 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Content_Filter_Service {
20 20
 
21
-	/**
22
-	 * The pattern to find entities in text.
23
-	 *
24
-	 * @since 3.8.0
25
-	 */
26
-	const PATTERN = '/<(\\w+)[^<]* itemid=\"([^"]+)\"[^>]*>([^<]*)<\\/\\1>/i';
21
+    /**
22
+     * The pattern to find entities in text.
23
+     *
24
+     * @since 3.8.0
25
+     */
26
+    const PATTERN = '/<(\\w+)[^<]* itemid=\"([^"]+)\"[^>]*>([^<]*)<\\/\\1>/i';
27 27
 
28
-	/**
29
-	 * A {@link Wordlift_Entity_Service} instance.
30
-	 *
31
-	 * @since  3.8.0
32
-	 * @access private
33
-	 * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
34
-	 */
35
-	private $entity_service;
28
+    /**
29
+     * A {@link Wordlift_Entity_Service} instance.
30
+     *
31
+     * @since  3.8.0
32
+     * @access private
33
+     * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance.
34
+     */
35
+    private $entity_service;
36 36
 
37
-	/**
38
-	 * Wordlift_Content_Filter_Service constructor.
39
-	 *
40
-	 * @since 3.8.0
41
-	 *
42
-	 * @param $entity_service
43
-	 */
44
-	public function __construct( $entity_service ) {
37
+    /**
38
+     * Wordlift_Content_Filter_Service constructor.
39
+     *
40
+     * @since 3.8.0
41
+     *
42
+     * @param $entity_service
43
+     */
44
+    public function __construct( $entity_service ) {
45 45
 
46
-		$this->entity_service = $entity_service;
46
+        $this->entity_service = $entity_service;
47 47
 
48
-	}
48
+    }
49 49
 
50
-	/**
51
-	 * Mangle the content by adding links to the entity pages. This function is
52
-	 * hooked to the 'the_content' WP's filter.
53
-	 *
54
-	 * @since 3.8.0
55
-	 *
56
-	 * @param string $content The content being filtered.
57
-	 *
58
-	 * @return string The filtered content.
59
-	 */
60
-	public function the_content( $content ) {
50
+    /**
51
+     * Mangle the content by adding links to the entity pages. This function is
52
+     * hooked to the 'the_content' WP's filter.
53
+     *
54
+     * @since 3.8.0
55
+     *
56
+     * @param string $content The content being filtered.
57
+     *
58
+     * @return string The filtered content.
59
+     */
60
+    public function the_content( $content ) {
61 61
 
62
-		// Replace each match of the entity tag with the entity link. If an error
63
-		// occurs fail silently returning the original content.
64
-		return preg_replace_callback( self::PATTERN, array(
65
-			$this,
66
-			'link',
67
-		), $content ) ?: $content;
68
-	}
62
+        // Replace each match of the entity tag with the entity link. If an error
63
+        // occurs fail silently returning the original content.
64
+        return preg_replace_callback( self::PATTERN, array(
65
+            $this,
66
+            'link',
67
+        ), $content ) ?: $content;
68
+    }
69 69
 
70
-	/**
71
-	 * Get the entity match and replace it with a page link.
72
-	 *
73
-	 * @since 3.8.0
74
-	 *
75
-	 * @param array $matches An array of matches.
76
-	 *
77
-	 * @return string The replaced text with the link to the entity page.
78
-	 */
79
-	private function link( $matches ) {
70
+    /**
71
+     * Get the entity match and replace it with a page link.
72
+     *
73
+     * @since 3.8.0
74
+     *
75
+     * @param array $matches An array of matches.
76
+     *
77
+     * @return string The replaced text with the link to the entity page.
78
+     */
79
+    private function link( $matches ) {
80 80
 
81
-		// Get the entity itemid URI and label.
82
-		$uri   = $matches[2];
83
-		$label = $matches[3];
81
+        // Get the entity itemid URI and label.
82
+        $uri   = $matches[2];
83
+        $label = $matches[3];
84 84
 
85
-		// Get the entity post by URI.
86
-		if ( null === ( $post = $this->entity_service->get_entity_post_by_uri( $uri ) ) ) {
85
+        // Get the entity post by URI.
86
+        if ( null === ( $post = $this->entity_service->get_entity_post_by_uri( $uri ) ) ) {
87 87
 
88
-			// If the entity post is not found return the label w/o the markup
89
-			// around it.
90
-			//
91
-			// See https://github.com/insideout10/wordlift-plugin/issues/461
92
-			return $label;
93
-		}
88
+            // If the entity post is not found return the label w/o the markup
89
+            // around it.
90
+            //
91
+            // See https://github.com/insideout10/wordlift-plugin/issues/461
92
+            return $label;
93
+        }
94 94
 
95
-		// Get the link.
96
-		$link = get_permalink( $post );
95
+        // Get the link.
96
+        $link = get_permalink( $post );
97 97
 
98
-		// Return the link.
99
-		return "<a class='wl-entity-page-link' href='$link'>$label</a>";
100
-	}
98
+        // Return the link.
99
+        return "<a class='wl-entity-page-link' href='$link'>$label</a>";
100
+    }
101 101
 
102 102
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @param $entity_service
43 43
 	 */
44
-	public function __construct( $entity_service ) {
44
+	public function __construct($entity_service) {
45 45
 
46 46
 		$this->entity_service = $entity_service;
47 47
 
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @return string The filtered content.
59 59
 	 */
60
-	public function the_content( $content ) {
60
+	public function the_content($content) {
61 61
 
62 62
 		// Replace each match of the entity tag with the entity link. If an error
63 63
 		// occurs fail silently returning the original content.
64
-		return preg_replace_callback( self::PATTERN, array(
64
+		return preg_replace_callback(self::PATTERN, array(
65 65
 			$this,
66 66
 			'link',
67
-		), $content ) ?: $content;
67
+		), $content) ?: $content;
68 68
 	}
69 69
 
70 70
 	/**
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return string The replaced text with the link to the entity page.
78 78
 	 */
79
-	private function link( $matches ) {
79
+	private function link($matches) {
80 80
 
81 81
 		// Get the entity itemid URI and label.
82 82
 		$uri   = $matches[2];
83 83
 		$label = $matches[3];
84 84
 
85 85
 		// Get the entity post by URI.
86
-		if ( null === ( $post = $this->entity_service->get_entity_post_by_uri( $uri ) ) ) {
86
+		if (null === ($post = $this->entity_service->get_entity_post_by_uri($uri))) {
87 87
 
88 88
 			// If the entity post is not found return the label w/o the markup
89 89
 			// around it.
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		}
94 94
 
95 95
 		// Get the link.
96
-		$link = get_permalink( $post );
96
+		$link = get_permalink($post);
97 97
 
98 98
 		// Return the link.
99 99
 		return "<a class='wl-entity-page-link' href='$link'>$label</a>";
Please login to merge, or discard this patch.