Completed
Push — develop ( a01e04...dfb4ea )
by David
01:36
created
src/includes/class-wordlift-google-analytics-export-service.php 2 patches
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -18,103 +18,103 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Google_Analytics_Export_Service {
20 20
 
21
-	/**
22
-	 * Export the site data that could be imported in Google Analytics.
23
-	 * It will works only when permalink structure is set to "Postname".
24
-	 *
25
-	 * @since 3.16.0
26
-	 *
27
-	 * @return void
28
-	 */
29
-	public function export() {
30
-		// Bail if the permalink structure is different from "Post name".
31
-		if ( ! $this->is_postname_permalink_structure() ) {
32
-			wp_die( 'The current permalink structure do not allow to export your data. Please change the permalink structure to "Post name".' );
33
-		}
34
-
35
-		// Output the file data. @codingStandardsIgnoreLine
36
-		@ob_end_clean();
37
-
38
-		// Generate unique filename using current timestamp.
39
-		$filename = 'wl-ga-export-' . gmdate( 'Y-m-d-H-i-s' ) . '.csv';
40
-
41
-		// Add proper file headers.
42
-		header( "Content-Disposition: attachment; filename=$filename" );
43
-		header( 'Content-Type: text/csv; charset=' . get_bloginfo( 'charset' ) );
44
-
45
-		// Do not cache the file.
46
-		header( 'Pragma: no-cache' );
47
-		header( 'Expires: 0' );
48
-
49
-		// Build the CSV file.
50
-		$this->create_csv();
51
-
52
-		wp_die();
53
-	}
54
-
55
-	/**
56
-	 * Return site path. Some installations are in subdirectories
57
-	 * and we need add them to expported permalinks.
58
-	 *
59
-	 * @since 3.16.0
60
-	 *
61
-	 * @return string The site path.
62
-	 */
63
-	public function get_site_path() {
64
-		// Get home url from database.
65
-		$home_url = home_url( '/' );
66
-
67
-		// Parse the url.
68
-		$parsed = wp_parse_url( $home_url );
69
-
70
-		// Return the path.
71
-		return $parsed['path'];
72
-	}
73
-
74
-	/**
75
-	 * Check if the current permalink structure is set to "Post name".
76
-	 *
77
-	 * @since 3.16.0
78
-	 *
79
-	 * @return bool whether the structure is "Post name" or not.
80
-	 */
81
-	public static function is_postname_permalink_structure() {
82
-		// Get current permalink structure.
83
-		$structure = get_option( 'permalink_structure' );
84
-
85
-		// The regular expression. It will check if the site structure contains postname.
86
-		$regex = '~^/\%postname\%/$~';
87
-
88
-		// Check if the site structure match the rquired one.
89
-		preg_match( $regex, $structure, $matches );
90
-
91
-		// Bail if the site have different structure.
92
-		if ( empty( $matches ) ) {
93
-			return false;
94
-		}
95
-
96
-		return true;
97
-	}
98
-
99
-	/**
100
-	 * Generate array data, that should be exported as csv.
101
-	 * The data contains the post/page title, entity name and type.
102
-	 *
103
-	 * @since 3.16.0
104
-	 *
105
-	 * @return array $items Content data.
106
-	 */
107
-	public function get_content_data() {
108
-		// Get the global $wpdb.
109
-		global $wpdb;
110
-
111
-		// Site path (optional).
112
-		$path = $this->get_site_path();
113
-
114
-		// Get the data.
115
-		$items = $wpdb->get_results(
116
-			$wpdb->prepare(
117
-				"SELECT
21
+    /**
22
+     * Export the site data that could be imported in Google Analytics.
23
+     * It will works only when permalink structure is set to "Postname".
24
+     *
25
+     * @since 3.16.0
26
+     *
27
+     * @return void
28
+     */
29
+    public function export() {
30
+        // Bail if the permalink structure is different from "Post name".
31
+        if ( ! $this->is_postname_permalink_structure() ) {
32
+            wp_die( 'The current permalink structure do not allow to export your data. Please change the permalink structure to "Post name".' );
33
+        }
34
+
35
+        // Output the file data. @codingStandardsIgnoreLine
36
+        @ob_end_clean();
37
+
38
+        // Generate unique filename using current timestamp.
39
+        $filename = 'wl-ga-export-' . gmdate( 'Y-m-d-H-i-s' ) . '.csv';
40
+
41
+        // Add proper file headers.
42
+        header( "Content-Disposition: attachment; filename=$filename" );
43
+        header( 'Content-Type: text/csv; charset=' . get_bloginfo( 'charset' ) );
44
+
45
+        // Do not cache the file.
46
+        header( 'Pragma: no-cache' );
47
+        header( 'Expires: 0' );
48
+
49
+        // Build the CSV file.
50
+        $this->create_csv();
51
+
52
+        wp_die();
53
+    }
54
+
55
+    /**
56
+     * Return site path. Some installations are in subdirectories
57
+     * and we need add them to expported permalinks.
58
+     *
59
+     * @since 3.16.0
60
+     *
61
+     * @return string The site path.
62
+     */
63
+    public function get_site_path() {
64
+        // Get home url from database.
65
+        $home_url = home_url( '/' );
66
+
67
+        // Parse the url.
68
+        $parsed = wp_parse_url( $home_url );
69
+
70
+        // Return the path.
71
+        return $parsed['path'];
72
+    }
73
+
74
+    /**
75
+     * Check if the current permalink structure is set to "Post name".
76
+     *
77
+     * @since 3.16.0
78
+     *
79
+     * @return bool whether the structure is "Post name" or not.
80
+     */
81
+    public static function is_postname_permalink_structure() {
82
+        // Get current permalink structure.
83
+        $structure = get_option( 'permalink_structure' );
84
+
85
+        // The regular expression. It will check if the site structure contains postname.
86
+        $regex = '~^/\%postname\%/$~';
87
+
88
+        // Check if the site structure match the rquired one.
89
+        preg_match( $regex, $structure, $matches );
90
+
91
+        // Bail if the site have different structure.
92
+        if ( empty( $matches ) ) {
93
+            return false;
94
+        }
95
+
96
+        return true;
97
+    }
98
+
99
+    /**
100
+     * Generate array data, that should be exported as csv.
101
+     * The data contains the post/page title, entity name and type.
102
+     *
103
+     * @since 3.16.0
104
+     *
105
+     * @return array $items Content data.
106
+     */
107
+    public function get_content_data() {
108
+        // Get the global $wpdb.
109
+        global $wpdb;
110
+
111
+        // Site path (optional).
112
+        $path = $this->get_site_path();
113
+
114
+        // Get the data.
115
+        $items = $wpdb->get_results(
116
+            $wpdb->prepare(
117
+                "SELECT
118 118
 					CONCAT( %s, p.post_name, '/' ) AS 'post_name',
119 119
 					p1.post_name AS 'entity_name',
120 120
 					t.slug AS 'entity_type'
@@ -131,43 +131,43 @@  discard block
 block discarded – undo
131 131
 					INNER JOIN {$wpdb->prefix}terms t
132 132
 						ON t.term_id = tt.term_id
133 133
 					WHERE p.post_type IN ( 'page', 'post' );",
134
-				$path
135
-			)
136
-		); // db call ok; no-cache ok.
137
-
138
-		return $items;
139
-	}
140
-
141
-	/**
142
-	 * Create the CSV file that will be downloaded.
143
-	 *
144
-	 * @since 3.16.0
145
-	 *
146
-	 * @return void
147
-	 */
148
-	public function create_csv() {
149
-		// Create a file pointer connected to the output stream.
150
-		// Ignoring linter notices below that complain about file output which do not actually happen.
151
-		$file = fopen( 'php://output', 'w' );
152
-
153
-		// Add the column headers. @codingStandardsIgnoreLine
154
-		fputcsv(
155
-			$file,
156
-			array(
157
-				'ga:pagePath',
158
-				'ga:dimension1',
159
-				'ga:dimension2',
160
-			)
161
-		);
162
-
163
-		// Cycle through items and add each item data to the file.
164
-		foreach ( $this->get_content_data() as $row ) {
165
-			// Add new line in the file. @codingStandardsIgnoreLine
166
-			fputcsv(
167
-				$file,
168
-				(array) $row // convert the object to array.
169
-			);
170
-		}
171
-	}
134
+                $path
135
+            )
136
+        ); // db call ok; no-cache ok.
137
+
138
+        return $items;
139
+    }
140
+
141
+    /**
142
+     * Create the CSV file that will be downloaded.
143
+     *
144
+     * @since 3.16.0
145
+     *
146
+     * @return void
147
+     */
148
+    public function create_csv() {
149
+        // Create a file pointer connected to the output stream.
150
+        // Ignoring linter notices below that complain about file output which do not actually happen.
151
+        $file = fopen( 'php://output', 'w' );
152
+
153
+        // Add the column headers. @codingStandardsIgnoreLine
154
+        fputcsv(
155
+            $file,
156
+            array(
157
+                'ga:pagePath',
158
+                'ga:dimension1',
159
+                'ga:dimension2',
160
+            )
161
+        );
162
+
163
+        // Cycle through items and add each item data to the file.
164
+        foreach ( $this->get_content_data() as $row ) {
165
+            // Add new line in the file. @codingStandardsIgnoreLine
166
+            fputcsv(
167
+                $file,
168
+                (array) $row // convert the object to array.
169
+            );
170
+        }
171
+    }
172 172
 
173 173
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -28,23 +28,23 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function export() {
30 30
 		// Bail if the permalink structure is different from "Post name".
31
-		if ( ! $this->is_postname_permalink_structure() ) {
32
-			wp_die( 'The current permalink structure do not allow to export your data. Please change the permalink structure to "Post name".' );
31
+		if ( ! $this->is_postname_permalink_structure()) {
32
+			wp_die('The current permalink structure do not allow to export your data. Please change the permalink structure to "Post name".');
33 33
 		}
34 34
 
35 35
 		// Output the file data. @codingStandardsIgnoreLine
36 36
 		@ob_end_clean();
37 37
 
38 38
 		// Generate unique filename using current timestamp.
39
-		$filename = 'wl-ga-export-' . gmdate( 'Y-m-d-H-i-s' ) . '.csv';
39
+		$filename = 'wl-ga-export-'.gmdate('Y-m-d-H-i-s').'.csv';
40 40
 
41 41
 		// Add proper file headers.
42
-		header( "Content-Disposition: attachment; filename=$filename" );
43
-		header( 'Content-Type: text/csv; charset=' . get_bloginfo( 'charset' ) );
42
+		header("Content-Disposition: attachment; filename=$filename");
43
+		header('Content-Type: text/csv; charset='.get_bloginfo('charset'));
44 44
 
45 45
 		// Do not cache the file.
46
-		header( 'Pragma: no-cache' );
47
-		header( 'Expires: 0' );
46
+		header('Pragma: no-cache');
47
+		header('Expires: 0');
48 48
 
49 49
 		// Build the CSV file.
50 50
 		$this->create_csv();
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function get_site_path() {
64 64
 		// Get home url from database.
65
-		$home_url = home_url( '/' );
65
+		$home_url = home_url('/');
66 66
 
67 67
 		// Parse the url.
68
-		$parsed = wp_parse_url( $home_url );
68
+		$parsed = wp_parse_url($home_url);
69 69
 
70 70
 		// Return the path.
71 71
 		return $parsed['path'];
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public static function is_postname_permalink_structure() {
82 82
 		// Get current permalink structure.
83
-		$structure = get_option( 'permalink_structure' );
83
+		$structure = get_option('permalink_structure');
84 84
 
85 85
 		// The regular expression. It will check if the site structure contains postname.
86 86
 		$regex = '~^/\%postname\%/$~';
87 87
 
88 88
 		// Check if the site structure match the rquired one.
89
-		preg_match( $regex, $structure, $matches );
89
+		preg_match($regex, $structure, $matches);
90 90
 
91 91
 		// Bail if the site have different structure.
92
-		if ( empty( $matches ) ) {
92
+		if (empty($matches)) {
93 93
 			return false;
94 94
 		}
95 95
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	public function create_csv() {
149 149
 		// Create a file pointer connected to the output stream.
150 150
 		// Ignoring linter notices below that complain about file output which do not actually happen.
151
-		$file = fopen( 'php://output', 'w' );
151
+		$file = fopen('php://output', 'w');
152 152
 
153 153
 		// Add the column headers. @codingStandardsIgnoreLine
154 154
 		fputcsv(
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		);
162 162
 
163 163
 		// Cycle through items and add each item data to the file.
164
-		foreach ( $this->get_content_data() as $row ) {
164
+		foreach ($this->get_content_data() as $row) {
165 165
 			// Add new line in the file. @codingStandardsIgnoreLine
166 166
 			fputcsv(
167 167
 				$file,
Please login to merge, or discard this patch.
src/includes/properties/class-wordlift-duration-property-service.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -19,31 +19,31 @@
 block discarded – undo
19 19
  */
20 20
 class Wordlift_Duration_Property_Service extends Wordlift_Simple_Property_Service {
21 21
 
22
-	/**
23
-	 * {@inheritdoc}
24
-	 */
25
-	public function get( $id, $meta_key, $type ) {
22
+    /**
23
+     * {@inheritdoc}
24
+     */
25
+    public function get( $id, $meta_key, $type ) {
26 26
 
27
-		// Get the values and filter out the empty ones (or the ones with 00:00).
28
-		$values = array_filter(
29
-			parent::get( $id, $meta_key, $type ),
30
-			function ( $item ) {
31
-				return ! empty( $item ) && '00:00' !== $item;
32
-			}
33
-		);
27
+        // Get the values and filter out the empty ones (or the ones with 00:00).
28
+        $values = array_filter(
29
+            parent::get( $id, $meta_key, $type ),
30
+            function ( $item ) {
31
+                return ! empty( $item ) && '00:00' !== $item;
32
+            }
33
+        );
34 34
 
35
-		/*
35
+        /*
36 36
 		 * Map the value in the meta
37 37
 		 * The UI for the meta date enable two forms, a number of minutes
38 38
 		 * or an h:mm format.
39 39
 		 * Both needs to be adjusted to the iso format.
40 40
 		 */
41
-		return array_map(
42
-			function ( $value ) {
43
-				return 'PT' . str_replace( ':', 'H', $value ) . 'M';
44
-			},
45
-			$values
46
-		);
47
-	}
41
+        return array_map(
42
+            function ( $value ) {
43
+                return 'PT' . str_replace( ':', 'H', $value ) . 'M';
44
+            },
45
+            $values
46
+        );
47
+    }
48 48
 
49 49
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
 	/**
23 23
 	 * {@inheritdoc}
24 24
 	 */
25
-	public function get( $id, $meta_key, $type ) {
25
+	public function get($id, $meta_key, $type) {
26 26
 
27 27
 		// Get the values and filter out the empty ones (or the ones with 00:00).
28 28
 		$values = array_filter(
29
-			parent::get( $id, $meta_key, $type ),
30
-			function ( $item ) {
31
-				return ! empty( $item ) && '00:00' !== $item;
29
+			parent::get($id, $meta_key, $type),
30
+			function($item) {
31
+				return ! empty($item) && '00:00' !== $item;
32 32
 			}
33 33
 		);
34 34
 
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 		 * Both needs to be adjusted to the iso format.
40 40
 		 */
41 41
 		return array_map(
42
-			function ( $value ) {
43
-				return 'PT' . str_replace( ':', 'H', $value ) . 'M';
42
+			function($value) {
43
+				return 'PT'.str_replace(':', 'H', $value).'M';
44 44
 			},
45 45
 			$values
46 46
 		);
Please login to merge, or discard this patch.
src/includes/properties/class-wordlift-property-getter.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -9,74 +9,74 @@
 block discarded – undo
9 9
  */
10 10
 class Wordlift_Property_Getter {
11 11
 
12
-	/**
13
-	 * An array of {@link Wordlift_Simple_Property_Service}s which can access a
14
-	 * property.
15
-	 *
16
-	 * @since 3.8.0
17
-	 * @access private
18
-	 * @var Wordlift_Simple_Property_Service[] $services An array of {@link Wordlift_Simple_Property_Service}s.
19
-	 */
20
-	private $services = array();
12
+    /**
13
+     * An array of {@link Wordlift_Simple_Property_Service}s which can access a
14
+     * property.
15
+     *
16
+     * @since 3.8.0
17
+     * @access private
18
+     * @var Wordlift_Simple_Property_Service[] $services An array of {@link Wordlift_Simple_Property_Service}s.
19
+     */
20
+    private $services = array();
21 21
 
22
-	/**
23
-	 * The default {@link Wordlift_Simple_Property_Service} which is used to access
24
-	 * a property when no specific {@link Wordlift_Simple_Property_Service} is found
25
-	 * in the {@see $services} array.
26
-	 *
27
-	 * @var Wordlift_Simple_Property_Service
28
-	 */
29
-	private $default;
22
+    /**
23
+     * The default {@link Wordlift_Simple_Property_Service} which is used to access
24
+     * a property when no specific {@link Wordlift_Simple_Property_Service} is found
25
+     * in the {@see $services} array.
26
+     *
27
+     * @var Wordlift_Simple_Property_Service
28
+     */
29
+    private $default;
30 30
 
31
-	/**
32
-	 * Create a property service with the provided {@link Wordlift_Simple_Property_Service}
33
-	 * as default.
34
-	 *
35
-	 * @param $default
36
-	 *
37
-	 * @since 3.8.0
38
-	 */
39
-	public function __construct( $default ) {
31
+    /**
32
+     * Create a property service with the provided {@link Wordlift_Simple_Property_Service}
33
+     * as default.
34
+     *
35
+     * @param $default
36
+     *
37
+     * @since 3.8.0
38
+     */
39
+    public function __construct( $default ) {
40 40
 
41
-		$this->default = $default;
41
+        $this->default = $default;
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Register a {@link Wordlift_Simple_Property_Service} for the specified meta keys.
47
-	 *
48
-	 * @param \Wordlift_Simple_Property_Service $property_service A {@link Wordlift_Simple_Property_Service} instance.
49
-	 * @param array                             $meta_keys An array of meta keys that the provided {@link Wordlift_Simple_Property_Service} will handle.
50
-	 *
51
-	 * @since 3.8.0
52
-	 */
53
-	public function register( $property_service, $meta_keys ) {
45
+    /**
46
+     * Register a {@link Wordlift_Simple_Property_Service} for the specified meta keys.
47
+     *
48
+     * @param \Wordlift_Simple_Property_Service $property_service A {@link Wordlift_Simple_Property_Service} instance.
49
+     * @param array                             $meta_keys An array of meta keys that the provided {@link Wordlift_Simple_Property_Service} will handle.
50
+     *
51
+     * @since 3.8.0
52
+     */
53
+    public function register( $property_service, $meta_keys ) {
54 54
 
55
-		// Register the specified property service for each meta key.
56
-		foreach ( $meta_keys as $meta_key ) {
57
-			$this->services[ $meta_key ] = $property_service;
58
-		}
55
+        // Register the specified property service for each meta key.
56
+        foreach ( $meta_keys as $meta_key ) {
57
+            $this->services[ $meta_key ] = $property_service;
58
+        }
59 59
 
60
-	}
60
+    }
61 61
 
62
-	/**
63
-	 * Get the value for the specified entity post id and WP's meta key.
64
-	 *
65
-	 * @param int    $post_id The post id.
66
-	 * @param string $meta_key The meta key.
67
-	 *
68
-	 * @param int    $type Term or Post, by default Post is used.
69
-	 *
70
-	 * @return mixed|null The property value or null.
71
-	 * @since 3.8.0
72
-	 */
73
-	public function get( $post_id, $meta_key, $type ) {
62
+    /**
63
+     * Get the value for the specified entity post id and WP's meta key.
64
+     *
65
+     * @param int    $post_id The post id.
66
+     * @param string $meta_key The meta key.
67
+     *
68
+     * @param int    $type Term or Post, by default Post is used.
69
+     *
70
+     * @return mixed|null The property value or null.
71
+     * @since 3.8.0
72
+     */
73
+    public function get( $post_id, $meta_key, $type ) {
74 74
 
75
-		return isset( $this->services[ $meta_key ] )
76
-			// Use a specific property service.
77
-			? $this->services[ $meta_key ]->get( $post_id, $meta_key, $type )
78
-			// Use the default property service.
79
-			: $this->default->get( $post_id, $meta_key, $type );
80
-	}
75
+        return isset( $this->services[ $meta_key ] )
76
+            // Use a specific property service.
77
+            ? $this->services[ $meta_key ]->get( $post_id, $meta_key, $type )
78
+            // Use the default property service.
79
+            : $this->default->get( $post_id, $meta_key, $type );
80
+    }
81 81
 
82 82
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @since 3.8.0
38 38
 	 */
39
-	public function __construct( $default ) {
39
+	public function __construct($default) {
40 40
 
41 41
 		$this->default = $default;
42 42
 
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @since 3.8.0
52 52
 	 */
53
-	public function register( $property_service, $meta_keys ) {
53
+	public function register($property_service, $meta_keys) {
54 54
 
55 55
 		// Register the specified property service for each meta key.
56
-		foreach ( $meta_keys as $meta_key ) {
57
-			$this->services[ $meta_key ] = $property_service;
56
+		foreach ($meta_keys as $meta_key) {
57
+			$this->services[$meta_key] = $property_service;
58 58
 		}
59 59
 
60 60
 	}
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 	 * @return mixed|null The property value or null.
71 71
 	 * @since 3.8.0
72 72
 	 */
73
-	public function get( $post_id, $meta_key, $type ) {
73
+	public function get($post_id, $meta_key, $type) {
74 74
 
75
-		return isset( $this->services[ $meta_key ] )
75
+		return isset($this->services[$meta_key])
76 76
 			// Use a specific property service.
77
-			? $this->services[ $meta_key ]->get( $post_id, $meta_key, $type )
77
+			? $this->services[$meta_key]->get($post_id, $meta_key, $type)
78 78
 			// Use the default property service.
79
-			: $this->default->get( $post_id, $meta_key, $type );
79
+			: $this->default->get($post_id, $meta_key, $type);
80 80
 	}
81 81
 
82 82
 }
Please login to merge, or discard this patch.
src/includes/properties/class-wordlift-property-getter-factory.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -26,60 +26,60 @@
 block discarded – undo
26 26
  */
27 27
 class Wordlift_Property_Getter_Factory {
28 28
 
29
-	/**
30
-	 * Create a {@link Wordlift_Property_Getter} instance.
31
-	 *
32
-	 * @return \Wordlift_Property_Getter A {@link Wordlift_Property_Getter} instance.
33
-	 * @since 3.8.0
34
-	 */
35
-	public static function create() {
29
+    /**
30
+     * Create a {@link Wordlift_Property_Getter} instance.
31
+     *
32
+     * @return \Wordlift_Property_Getter A {@link Wordlift_Property_Getter} instance.
33
+     * @since 3.8.0
34
+     */
35
+    public static function create() {
36 36
 
37
-		$property_getter = new Wordlift_Property_Getter( new Wordlift_Simple_Property_Service() );
38
-		$property_getter->register(
39
-			new Wordlift_Entity_Property_Service(),
40
-			array(
41
-				Wordlift_Schema_Service::FIELD_FOUNDER,
42
-				Wordlift_Schema_Service::FIELD_AUTHOR,
43
-				Wordlift_Schema_Service::FIELD_KNOWS,
44
-				Wordlift_Schema_Service::FIELD_BIRTH_PLACE,
45
-				Wordlift_Schema_Service::FIELD_AFFILIATION,
46
-				Wordlift_Schema_Service::FIELD_PERFORMER,
47
-				Wordlift_Schema_Service::FIELD_OFFERS,
48
-				Wordlift_Schema_Service::FIELD_ITEM_OFFERED,
49
-			)
50
-		);
51
-		$property_getter->register(
52
-			new Wordlift_Location_Property_Service(),
53
-			array(
54
-				Wordlift_Schema_Service::FIELD_LOCATION,
55
-			)
56
-		);
57
-		$property_getter->register( new Wordlift_Url_Property_Service(), array( Wordlift_Url_Property_Service::META_KEY ) );
58
-		$property_getter->register(
59
-			new Wordlift_Double_Property_Service(),
60
-			array(
61
-				Wordlift_Schema_Service::FIELD_GEO_LATITUDE,
62
-				Wordlift_Schema_Service::FIELD_GEO_LONGITUDE,
63
-			)
64
-		);
37
+        $property_getter = new Wordlift_Property_Getter( new Wordlift_Simple_Property_Service() );
38
+        $property_getter->register(
39
+            new Wordlift_Entity_Property_Service(),
40
+            array(
41
+                Wordlift_Schema_Service::FIELD_FOUNDER,
42
+                Wordlift_Schema_Service::FIELD_AUTHOR,
43
+                Wordlift_Schema_Service::FIELD_KNOWS,
44
+                Wordlift_Schema_Service::FIELD_BIRTH_PLACE,
45
+                Wordlift_Schema_Service::FIELD_AFFILIATION,
46
+                Wordlift_Schema_Service::FIELD_PERFORMER,
47
+                Wordlift_Schema_Service::FIELD_OFFERS,
48
+                Wordlift_Schema_Service::FIELD_ITEM_OFFERED,
49
+            )
50
+        );
51
+        $property_getter->register(
52
+            new Wordlift_Location_Property_Service(),
53
+            array(
54
+                Wordlift_Schema_Service::FIELD_LOCATION,
55
+            )
56
+        );
57
+        $property_getter->register( new Wordlift_Url_Property_Service(), array( Wordlift_Url_Property_Service::META_KEY ) );
58
+        $property_getter->register(
59
+            new Wordlift_Double_Property_Service(),
60
+            array(
61
+                Wordlift_Schema_Service::FIELD_GEO_LATITUDE,
62
+                Wordlift_Schema_Service::FIELD_GEO_LONGITUDE,
63
+            )
64
+        );
65 65
 
66
-		$property_getter->register(
67
-			new Wordlift_Duration_Property_Service(),
68
-			array(
69
-				Wordlift_Schema_Service::FIELD_PREP_TIME,
70
-				Wordlift_Schema_Service::FIELD_COOK_TIME,
71
-				Wordlift_Schema_Service::FIELD_TOTAL_TIME,
72
-			)
73
-		);
66
+        $property_getter->register(
67
+            new Wordlift_Duration_Property_Service(),
68
+            array(
69
+                Wordlift_Schema_Service::FIELD_PREP_TIME,
70
+                Wordlift_Schema_Service::FIELD_COOK_TIME,
71
+                Wordlift_Schema_Service::FIELD_TOTAL_TIME,
72
+            )
73
+        );
74 74
 
75
-		add_action(
76
-			'after_setup_theme',
77
-			function () use ( $property_getter ) {
78
-				$property_getter->register( new Wordlift_Required_Property_Service(), apply_filters( 'wl_required_property', array() ) );
79
-			}
80
-		);
75
+        add_action(
76
+            'after_setup_theme',
77
+            function () use ( $property_getter ) {
78
+                $property_getter->register( new Wordlift_Required_Property_Service(), apply_filters( 'wl_required_property', array() ) );
79
+            }
80
+        );
81 81
 
82
-		return $property_getter;
83
-	}
82
+        return $property_getter;
83
+    }
84 84
 
85 85
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	public static function create() {
36 36
 
37
-		$property_getter = new Wordlift_Property_Getter( new Wordlift_Simple_Property_Service() );
37
+		$property_getter = new Wordlift_Property_Getter(new Wordlift_Simple_Property_Service());
38 38
 		$property_getter->register(
39 39
 			new Wordlift_Entity_Property_Service(),
40 40
 			array(
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 				Wordlift_Schema_Service::FIELD_LOCATION,
55 55
 			)
56 56
 		);
57
-		$property_getter->register( new Wordlift_Url_Property_Service(), array( Wordlift_Url_Property_Service::META_KEY ) );
57
+		$property_getter->register(new Wordlift_Url_Property_Service(), array(Wordlift_Url_Property_Service::META_KEY));
58 58
 		$property_getter->register(
59 59
 			new Wordlift_Double_Property_Service(),
60 60
 			array(
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 
75 75
 		add_action(
76 76
 			'after_setup_theme',
77
-			function () use ( $property_getter ) {
78
-				$property_getter->register( new Wordlift_Required_Property_Service(), apply_filters( 'wl_required_property', array() ) );
77
+			function() use ($property_getter) {
78
+				$property_getter->register(new Wordlift_Required_Property_Service(), apply_filters('wl_required_property', array()));
79 79
 			}
80 80
 		);
81 81
 
Please login to merge, or discard this patch.
src/includes/properties/class-wordlift-simple-property-service.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -12,33 +12,33 @@
 block discarded – undo
12 12
  */
13 13
 class Wordlift_Simple_Property_Service {
14 14
 
15
-	/**
16
-	 * The meta key for this property service.
17
-	 *
18
-	 * @since 3.8.0
19
-	 */
20
-	const META_KEY = '*';
15
+    /**
16
+     * The meta key for this property service.
17
+     *
18
+     * @since 3.8.0
19
+     */
20
+    const META_KEY = '*';
21 21
 
22
-	/**
23
-	 * Get the property value for the specified post id and meta with the specified key.
24
-	 *
25
-	 * @param int                   $id The post id.
26
-	 * @param string                $meta_key The meta key.
27
-	 *
28
-	 * @param $type int Post or Term
29
-	 *
30
-	 * @return mixed|null The property value.
31
-	 * @since 3.8.0
32
-	 */
33
-	public function get( $id, $meta_key, $type ) {
22
+    /**
23
+     * Get the property value for the specified post id and meta with the specified key.
24
+     *
25
+     * @param int                   $id The post id.
26
+     * @param string                $meta_key The meta key.
27
+     *
28
+     * @param $type int Post or Term
29
+     *
30
+     * @return mixed|null The property value.
31
+     * @since 3.8.0
32
+     */
33
+    public function get( $id, $meta_key, $type ) {
34 34
 
35
-		if ( Object_Type_Enum::POST === $type ) {
36
-			// Get the value stored in WP.
37
-			return get_post_meta( $id, $meta_key );
38
-		} elseif ( Object_Type_Enum::TERM === $type ) {
39
-			return get_term_meta( $id, $meta_key );
40
-		}
41
-		return null;
42
-	}
35
+        if ( Object_Type_Enum::POST === $type ) {
36
+            // Get the value stored in WP.
37
+            return get_post_meta( $id, $meta_key );
38
+        } elseif ( Object_Type_Enum::TERM === $type ) {
39
+            return get_term_meta( $id, $meta_key );
40
+        }
41
+        return null;
42
+    }
43 43
 
44 44
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@
 block discarded – undo
30 30
 	 * @return mixed|null The property value.
31 31
 	 * @since 3.8.0
32 32
 	 */
33
-	public function get( $id, $meta_key, $type ) {
33
+	public function get($id, $meta_key, $type) {
34 34
 
35
-		if ( Object_Type_Enum::POST === $type ) {
35
+		if (Object_Type_Enum::POST === $type) {
36 36
 			// Get the value stored in WP.
37
-			return get_post_meta( $id, $meta_key );
38
-		} elseif ( Object_Type_Enum::TERM === $type ) {
39
-			return get_term_meta( $id, $meta_key );
37
+			return get_post_meta($id, $meta_key);
38
+		} elseif (Object_Type_Enum::TERM === $type) {
39
+			return get_term_meta($id, $meta_key);
40 40
 		}
41 41
 		return null;
42 42
 	}
Please login to merge, or discard this patch.
src/includes/properties/class-wordlift-double-property-service.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -16,18 +16,18 @@
 block discarded – undo
16 16
  */
17 17
 class Wordlift_Double_Property_Service extends Wordlift_Simple_Property_Service {
18 18
 
19
-	/**
20
-	 * @inheritdoc
21
-	 */
22
-	public function get( $id, $meta_key, $type ) {
19
+    /**
20
+     * @inheritdoc
21
+     */
22
+    public function get( $id, $meta_key, $type ) {
23 23
 
24
-		// Map the result to a numeric value when possible.
25
-		return array_map(
26
-			function ( $value ) {
27
-				return is_numeric( $value ) ? (float) $value : $value;
28
-			},
29
-			parent::get( $id, $meta_key, $type )
30
-		);
31
-	}
24
+        // Map the result to a numeric value when possible.
25
+        return array_map(
26
+            function ( $value ) {
27
+                return is_numeric( $value ) ? (float) $value : $value;
28
+            },
29
+            parent::get( $id, $meta_key, $type )
30
+        );
31
+    }
32 32
 
33 33
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,14 +19,14 @@
 block discarded – undo
19 19
 	/**
20 20
 	 * @inheritdoc
21 21
 	 */
22
-	public function get( $id, $meta_key, $type ) {
22
+	public function get($id, $meta_key, $type) {
23 23
 
24 24
 		// Map the result to a numeric value when possible.
25 25
 		return array_map(
26
-			function ( $value ) {
27
-				return is_numeric( $value ) ? (float) $value : $value;
26
+			function($value) {
27
+				return is_numeric($value) ? (float) $value : $value;
28 28
 			},
29
-			parent::get( $id, $meta_key, $type )
29
+			parent::get($id, $meta_key, $type)
30 30
 		);
31 31
 	}
32 32
 
Please login to merge, or discard this patch.
src/includes/properties/class-wordlift-required-property-service.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,23 +6,23 @@
 block discarded – undo
6 6
  */
7 7
 class Wordlift_Required_Property_Service extends Wordlift_Entity_Property_Service {
8 8
 
9
-	/**
10
-	 * {@inheritdoc}
11
-	 */
12
-	public function get( $id, $meta_key, $type ) {
9
+    /**
10
+     * {@inheritdoc}
11
+     */
12
+    public function get( $id, $meta_key, $type ) {
13 13
 
14
-		return array_map(
15
-			function ( $item ) {
14
+        return array_map(
15
+            function ( $item ) {
16 16
 
17
-				// If this is an entity reference, set that this entity is always required in SD output.
18
-				if ( $item instanceof Wordlift_Property_Entity_Reference ) {
19
-					  $item->set_required( true );
20
-				}
17
+                // If this is an entity reference, set that this entity is always required in SD output.
18
+                if ( $item instanceof Wordlift_Property_Entity_Reference ) {
19
+                        $item->set_required( true );
20
+                }
21 21
 
22
-				return $item;
23
-			},
24
-			parent::get( $id, $meta_key, $type )
25
-		);
26
-	}
22
+                return $item;
23
+            },
24
+            parent::get( $id, $meta_key, $type )
25
+        );
26
+    }
27 27
 
28 28
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,19 +9,19 @@
 block discarded – undo
9 9
 	/**
10 10
 	 * {@inheritdoc}
11 11
 	 */
12
-	public function get( $id, $meta_key, $type ) {
12
+	public function get($id, $meta_key, $type) {
13 13
 
14 14
 		return array_map(
15
-			function ( $item ) {
15
+			function($item) {
16 16
 
17 17
 				// If this is an entity reference, set that this entity is always required in SD output.
18
-				if ( $item instanceof Wordlift_Property_Entity_Reference ) {
19
-					  $item->set_required( true );
18
+				if ($item instanceof Wordlift_Property_Entity_Reference) {
19
+					  $item->set_required(true);
20 20
 				}
21 21
 
22 22
 				return $item;
23 23
 			},
24
-			parent::get( $id, $meta_key, $type )
24
+			parent::get($id, $meta_key, $type)
25 25
 		);
26 26
 	}
27 27
 
Please login to merge, or discard this patch.
src/includes/properties/class-wordlift-location-property-service.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -15,28 +15,28 @@
 block discarded – undo
15 15
  */
16 16
 class Wordlift_Location_Property_Service extends Wordlift_Entity_Property_Service {
17 17
 
18
-	/**
19
-	 * {@inheritdoc}
20
-	 */
21
-	public function get( $id, $meta_key, $type ) {
18
+    /**
19
+     * {@inheritdoc}
20
+     */
21
+    public function get( $id, $meta_key, $type ) {
22 22
 
23
-		return array_map(
24
-			function ( $item ) {
23
+        return array_map(
24
+            function ( $item ) {
25 25
 
26
-				// If this is an entity reference, set that this entity is always required in SD output.
27
-				if ( $item instanceof Wordlift_Property_Entity_Reference ) {
28
-					  $item->set_required( true );
26
+                // If this is an entity reference, set that this entity is always required in SD output.
27
+                if ( $item instanceof Wordlift_Property_Entity_Reference ) {
28
+                        $item->set_required( true );
29 29
 
30
-					  return $item;
31
-				}
30
+                        return $item;
31
+                }
32 32
 
33
-				return array(
34
-					'@type' => 'Place',
35
-					'name'  => $item,
36
-				);
37
-			},
38
-			parent::get( $id, $meta_key, $type )
39
-		);
40
-	}
33
+                return array(
34
+                    '@type' => 'Place',
35
+                    'name'  => $item,
36
+                );
37
+            },
38
+            parent::get( $id, $meta_key, $type )
39
+        );
40
+    }
41 41
 
42 42
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 	/**
19 19
 	 * {@inheritdoc}
20 20
 	 */
21
-	public function get( $id, $meta_key, $type ) {
21
+	public function get($id, $meta_key, $type) {
22 22
 
23 23
 		return array_map(
24
-			function ( $item ) {
24
+			function($item) {
25 25
 
26 26
 				// If this is an entity reference, set that this entity is always required in SD output.
27
-				if ( $item instanceof Wordlift_Property_Entity_Reference ) {
28
-					  $item->set_required( true );
27
+				if ($item instanceof Wordlift_Property_Entity_Reference) {
28
+					  $item->set_required(true);
29 29
 
30 30
 					  return $item;
31 31
 				}
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 					'name'  => $item,
36 36
 				);
37 37
 			},
38
-			parent::get( $id, $meta_key, $type )
38
+			parent::get($id, $meta_key, $type)
39 39
 		);
40 40
 	}
41 41
 
Please login to merge, or discard this patch.
src/includes/class-wordlift-redirect-service.php 2 patches
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -14,143 +14,143 @@
 block discarded – undo
14 14
  */
15 15
 class Wordlift_Redirect_Service {
16 16
 
17
-	const LOD_ENDPOINT = 'http://www.lodview.it';
18
-	const LOD_HOST     = 'www.lodview.it';
19
-
20
-	/**
21
-	 * The Log service.
22
-	 *
23
-	 * @since 3.2.0
24
-	 * @access private
25
-	 * @var \Wordlift_Log_Service $log_service The Log service.
26
-	 */
27
-	private $log_service;
28
-
29
-	/**
30
-	 * The Entity URI service.
31
-	 *
32
-	 * @since 3.2.0
33
-	 * @access private
34
-	 * @var Wordlift_Entity_Uri_Service $entity_uri_service The Entity service.
35
-	 */
36
-	private $entity_uri_service;
37
-
38
-	/**
39
-	 * A singleton instance of the Redirect service (useful for unit tests).
40
-	 *
41
-	 * @since 3.2.0
42
-	 * @access private
43
-	 * @var \Wordlift_Redirect_Service $instance The singleton instance.
44
-	 */
45
-	private static $instance;
46
-
47
-	/**
48
-	 * Create a Wordlift_Redirect_Service instance.
49
-	 *
50
-	 * @param Wordlift_Entity_Uri_Service $entity_uri_service The Entity service.
51
-	 *
52
-	 * @since 3.2.0
53
-	 */
54
-	public function __construct( $entity_uri_service ) {
55
-
56
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Redirect_Service' );
57
-
58
-		$this->entity_uri_service = $entity_uri_service;
59
-
60
-		self::$instance = $this;
61
-
62
-	}
63
-
64
-	/**
65
-	 * Get the singleton instance of the Wordlift_Redirect_Service
66
-	 *
67
-	 * @return \Wordlift_Redirect_Service The singleton instance of the Wordlift_Redirect_Service.
68
-	 * @since 3.2.0
69
-	 */
70
-	public static function get_instance() {
71
-
72
-		return self::$instance;
73
-	}
74
-
75
-	/**
76
-	 * Perform redirect depending on entity uri and target
77
-	 *
78
-	 * @since 3.2.0
79
-	 */
80
-	public function ajax_redirect() {
81
-
82
-		// Check the `uri` parameter.
83
-		$entity_uri = filter_input( INPUT_GET, 'uri', FILTER_VALIDATE_URL );
84
-		if ( ! $entity_uri ) {
85
-			wp_die(
86
-				esc_html__( 'Invalid URI.', 'wordlift' ),
87
-				esc_html__( 'Invalid URI.', 'wordlift' ),
88
-				array(
89
-					'response'  => 400,
90
-					'back_link' => true,
91
-				)
92
-			);
93
-		}
94
-
95
-		// Check the `to` parameter.
96
-		$target = filter_input( INPUT_GET, 'to' );
97
-		if ( ! $target ) {
98
-			wp_die(
99
-				esc_html__( 'Invalid `to` parameter.', 'wordlift' ),
100
-				esc_html__( 'Invalid `to` parameter.', 'wordlift' ),
101
-				array(
102
-					'response'  => 400,
103
-					'back_link' => true,
104
-				)
105
-			);
106
-		}
107
-
108
-		/** @var Wordpress_Content $content */
109
-		$content = Wordpress_Content_Service::get_instance()
110
-											->get_by_entity_id_or_same_as( $entity_uri );
111
-
112
-		if ( ! isset( $content ) ) {
113
-			wp_die(
114
-				esc_html__( 'Entity not found.', 'wordlift' ),
115
-				esc_html__( 'Entity not found.', 'wordlift' ),
116
-				array(
117
-					'response'  => 404,
118
-					'back_link' => true,
119
-				)
120
-			);
121
-		}
122
-
123
-		switch ( $target ) {
124
-			case 'edit':
125
-				$redirect_url = $content->get_edit_link();
126
-				break;
127
-			case 'lod':
128
-				$redirect_url = self::LOD_ENDPOINT . '/lodview/?IRI=' . rawurlencode( $entity_uri );
129
-				break;
130
-			case 'permalink':
131
-				$redirect_url = $content->get_permalink();
132
-				break;
133
-			default:
134
-				wp_die( 'Unsupported redirect target.' );
135
-		}
136
-
137
-		// Perform the redirect
138
-		wp_safe_redirect( $redirect_url );
139
-		exit;
140
-	}
141
-
142
-	/**
143
-	 * Register custom allowed hosts.
144
-	 *
145
-	 * @see https://developer.wordpress.org/reference/functions/wp_safe_redirect/
146
-	 *
147
-	 * @since 3.2.0
148
-	 *
149
-	 * @return array permalink.
150
-	 */
151
-	public function allowed_redirect_hosts( $content ) {
152
-
153
-		return array_merge( $content, array( self::LOD_HOST ) );
154
-	}
17
+    const LOD_ENDPOINT = 'http://www.lodview.it';
18
+    const LOD_HOST     = 'www.lodview.it';
19
+
20
+    /**
21
+     * The Log service.
22
+     *
23
+     * @since 3.2.0
24
+     * @access private
25
+     * @var \Wordlift_Log_Service $log_service The Log service.
26
+     */
27
+    private $log_service;
28
+
29
+    /**
30
+     * The Entity URI service.
31
+     *
32
+     * @since 3.2.0
33
+     * @access private
34
+     * @var Wordlift_Entity_Uri_Service $entity_uri_service The Entity service.
35
+     */
36
+    private $entity_uri_service;
37
+
38
+    /**
39
+     * A singleton instance of the Redirect service (useful for unit tests).
40
+     *
41
+     * @since 3.2.0
42
+     * @access private
43
+     * @var \Wordlift_Redirect_Service $instance The singleton instance.
44
+     */
45
+    private static $instance;
46
+
47
+    /**
48
+     * Create a Wordlift_Redirect_Service instance.
49
+     *
50
+     * @param Wordlift_Entity_Uri_Service $entity_uri_service The Entity service.
51
+     *
52
+     * @since 3.2.0
53
+     */
54
+    public function __construct( $entity_uri_service ) {
55
+
56
+        $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Redirect_Service' );
57
+
58
+        $this->entity_uri_service = $entity_uri_service;
59
+
60
+        self::$instance = $this;
61
+
62
+    }
63
+
64
+    /**
65
+     * Get the singleton instance of the Wordlift_Redirect_Service
66
+     *
67
+     * @return \Wordlift_Redirect_Service The singleton instance of the Wordlift_Redirect_Service.
68
+     * @since 3.2.0
69
+     */
70
+    public static function get_instance() {
71
+
72
+        return self::$instance;
73
+    }
74
+
75
+    /**
76
+     * Perform redirect depending on entity uri and target
77
+     *
78
+     * @since 3.2.0
79
+     */
80
+    public function ajax_redirect() {
81
+
82
+        // Check the `uri` parameter.
83
+        $entity_uri = filter_input( INPUT_GET, 'uri', FILTER_VALIDATE_URL );
84
+        if ( ! $entity_uri ) {
85
+            wp_die(
86
+                esc_html__( 'Invalid URI.', 'wordlift' ),
87
+                esc_html__( 'Invalid URI.', 'wordlift' ),
88
+                array(
89
+                    'response'  => 400,
90
+                    'back_link' => true,
91
+                )
92
+            );
93
+        }
94
+
95
+        // Check the `to` parameter.
96
+        $target = filter_input( INPUT_GET, 'to' );
97
+        if ( ! $target ) {
98
+            wp_die(
99
+                esc_html__( 'Invalid `to` parameter.', 'wordlift' ),
100
+                esc_html__( 'Invalid `to` parameter.', 'wordlift' ),
101
+                array(
102
+                    'response'  => 400,
103
+                    'back_link' => true,
104
+                )
105
+            );
106
+        }
107
+
108
+        /** @var Wordpress_Content $content */
109
+        $content = Wordpress_Content_Service::get_instance()
110
+                                            ->get_by_entity_id_or_same_as( $entity_uri );
111
+
112
+        if ( ! isset( $content ) ) {
113
+            wp_die(
114
+                esc_html__( 'Entity not found.', 'wordlift' ),
115
+                esc_html__( 'Entity not found.', 'wordlift' ),
116
+                array(
117
+                    'response'  => 404,
118
+                    'back_link' => true,
119
+                )
120
+            );
121
+        }
122
+
123
+        switch ( $target ) {
124
+            case 'edit':
125
+                $redirect_url = $content->get_edit_link();
126
+                break;
127
+            case 'lod':
128
+                $redirect_url = self::LOD_ENDPOINT . '/lodview/?IRI=' . rawurlencode( $entity_uri );
129
+                break;
130
+            case 'permalink':
131
+                $redirect_url = $content->get_permalink();
132
+                break;
133
+            default:
134
+                wp_die( 'Unsupported redirect target.' );
135
+        }
136
+
137
+        // Perform the redirect
138
+        wp_safe_redirect( $redirect_url );
139
+        exit;
140
+    }
141
+
142
+    /**
143
+     * Register custom allowed hosts.
144
+     *
145
+     * @see https://developer.wordpress.org/reference/functions/wp_safe_redirect/
146
+     *
147
+     * @since 3.2.0
148
+     *
149
+     * @return array permalink.
150
+     */
151
+    public function allowed_redirect_hosts( $content ) {
152
+
153
+        return array_merge( $content, array( self::LOD_HOST ) );
154
+    }
155 155
 
156 156
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 	 *
52 52
 	 * @since 3.2.0
53 53
 	 */
54
-	public function __construct( $entity_uri_service ) {
54
+	public function __construct($entity_uri_service) {
55 55
 
56
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Redirect_Service' );
56
+		$this->log_service = Wordlift_Log_Service::get_logger('Wordlift_Redirect_Service');
57 57
 
58 58
 		$this->entity_uri_service = $entity_uri_service;
59 59
 
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	public function ajax_redirect() {
81 81
 
82 82
 		// Check the `uri` parameter.
83
-		$entity_uri = filter_input( INPUT_GET, 'uri', FILTER_VALIDATE_URL );
84
-		if ( ! $entity_uri ) {
83
+		$entity_uri = filter_input(INPUT_GET, 'uri', FILTER_VALIDATE_URL);
84
+		if ( ! $entity_uri) {
85 85
 			wp_die(
86
-				esc_html__( 'Invalid URI.', 'wordlift' ),
87
-				esc_html__( 'Invalid URI.', 'wordlift' ),
86
+				esc_html__('Invalid URI.', 'wordlift'),
87
+				esc_html__('Invalid URI.', 'wordlift'),
88 88
 				array(
89 89
 					'response'  => 400,
90 90
 					'back_link' => true,
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 		}
94 94
 
95 95
 		// Check the `to` parameter.
96
-		$target = filter_input( INPUT_GET, 'to' );
97
-		if ( ! $target ) {
96
+		$target = filter_input(INPUT_GET, 'to');
97
+		if ( ! $target) {
98 98
 			wp_die(
99
-				esc_html__( 'Invalid `to` parameter.', 'wordlift' ),
100
-				esc_html__( 'Invalid `to` parameter.', 'wordlift' ),
99
+				esc_html__('Invalid `to` parameter.', 'wordlift'),
100
+				esc_html__('Invalid `to` parameter.', 'wordlift'),
101 101
 				array(
102 102
 					'response'  => 400,
103 103
 					'back_link' => true,
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
 
108 108
 		/** @var Wordpress_Content $content */
109 109
 		$content = Wordpress_Content_Service::get_instance()
110
-											->get_by_entity_id_or_same_as( $entity_uri );
110
+											->get_by_entity_id_or_same_as($entity_uri);
111 111
 
112
-		if ( ! isset( $content ) ) {
112
+		if ( ! isset($content)) {
113 113
 			wp_die(
114
-				esc_html__( 'Entity not found.', 'wordlift' ),
115
-				esc_html__( 'Entity not found.', 'wordlift' ),
114
+				esc_html__('Entity not found.', 'wordlift'),
115
+				esc_html__('Entity not found.', 'wordlift'),
116 116
 				array(
117 117
 					'response'  => 404,
118 118
 					'back_link' => true,
@@ -120,22 +120,22 @@  discard block
 block discarded – undo
120 120
 			);
121 121
 		}
122 122
 
123
-		switch ( $target ) {
123
+		switch ($target) {
124 124
 			case 'edit':
125 125
 				$redirect_url = $content->get_edit_link();
126 126
 				break;
127 127
 			case 'lod':
128
-				$redirect_url = self::LOD_ENDPOINT . '/lodview/?IRI=' . rawurlencode( $entity_uri );
128
+				$redirect_url = self::LOD_ENDPOINT.'/lodview/?IRI='.rawurlencode($entity_uri);
129 129
 				break;
130 130
 			case 'permalink':
131 131
 				$redirect_url = $content->get_permalink();
132 132
 				break;
133 133
 			default:
134
-				wp_die( 'Unsupported redirect target.' );
134
+				wp_die('Unsupported redirect target.');
135 135
 		}
136 136
 
137 137
 		// Perform the redirect
138
-		wp_safe_redirect( $redirect_url );
138
+		wp_safe_redirect($redirect_url);
139 139
 		exit;
140 140
 	}
141 141
 
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return array permalink.
150 150
 	 */
151
-	public function allowed_redirect_hosts( $content ) {
151
+	public function allowed_redirect_hosts($content) {
152 152
 
153
-		return array_merge( $content, array( self::LOD_HOST ) );
153
+		return array_merge($content, array(self::LOD_HOST));
154 154
 	}
155 155
 
156 156
 }
Please login to merge, or discard this patch.