Completed
Push — master ( f880b8...364110 )
by David
02:55
created
src/public/class-wordlift-navigator-shortcode.php 2 patches
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -17,146 +17,146 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class Wordlift_Navigator_Shortcode extends Wordlift_Shortcode {
19 19
 
20
-	/**
21
-	 * {@inheritdoc}
22
-	 */
23
-	const SHORTCODE = 'wl_navigator';
24
-
25
-	/**
26
-	 * {@inheritdoc}
27
-	 */
28
-	public function render( $atts ) {
29
-
30
-		return Wordlift_AMP_Service::is_amp_endpoint() ? $this->amp_shortcode( $atts )
31
-			: $this->web_shortcode( $atts );
32
-	}
33
-
34
-	/**
35
-	 * Shared function used by web_shortcode and amp_shortcode
36
-	 * Bootstrap logic for attributes extraction and boolean filtering
37
-	 *
38
-	 * @param array $atts Shortcode attributes.
39
-	 *
40
-	 * @return array $shortcode_atts
41
-	 * @since      3.20.0
42
-	 *
43
-	 */
44
-	private function make_shortcode_atts( $atts ) {
45
-
46
-		// Extract attributes and set default values.
47
-		$shortcode_atts = shortcode_atts( array(
48
-			'title'       => __( 'Related articles', 'wordlift' ),
49
-			'limit'       => 4,
50
-			'offset'      => 0,
51
-			'template_id' => '',
52
-			'post_id'     => '',
53
-			'uniqid'      => uniqid( 'wl-navigator-widget-' ),
54
-			'order_by'    => 'ID DESC'
55
-		), $atts );
56
-
57
-		return $shortcode_atts;
58
-	}
59
-
60
-	/**
61
-	 * Function in charge of diplaying the [wl-navigator] in web mode.
62
-	 *
63
-	 * @param array $atts Shortcode attributes.
64
-	 *
65
-	 * @return string Shortcode HTML for web
66
-	 * @since 3.20.0
67
-	 *
68
-	 */
69
-	private function web_shortcode( $atts ) {
70
-
71
-		// attributes extraction and boolean filtering
72
-		$shortcode_atts = $this->make_shortcode_atts( $atts );
73
-
74
-		// avoid building the widget when no post_id is specified and there is a list of posts.
75
-		if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) {
76
-			return;
77
-		}
78
-
79
-		$post         = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( $shortcode_atts['post_id'] ) ) : get_post();
80
-		$navigator_id = $shortcode_atts['uniqid'];
81
-		// Changed `order_by` to `sort` for Presslabs cache nodes compatibility.
82
-		$rest_url     = $post ? admin_url( sprintf( 'admin-ajax.php?action=wl_navigator&uniqid=%s&post_id=%s&limit=%s&offset=%s&sort=%s', $navigator_id, $post->ID, $shortcode_atts['limit'], $shortcode_atts['offset'], $shortcode_atts['order_by'] ) ) : false;
83
-
84
-		// avoid building the widget when no valid $rest_url
85
-		if ( ! $rest_url ) {
86
-			return;
87
-		}
88
-
89
-		wp_enqueue_script( 'wordlift-cloud' );
90
-		$json_navigator_id = wp_json_encode( $navigator_id );
91
-		echo "<script type='application/javascript'>window.wlNavigators = window.wlNavigators || []; wlNavigators.push( $json_navigator_id );</script>";
92
-
93
-		return sprintf(
94
-			'<div id="%s" class="%s" data-rest-url="%s" data-title="%s" data-template-id="%s" data-limit="%s"></div>',
95
-			$navigator_id,
96
-			'wl-navigator',
97
-			$rest_url,
98
-			$shortcode_atts['title'],
99
-			$shortcode_atts['template_id'],
100
-			$shortcode_atts['limit']
101
-		);
102
-	}
103
-
104
-	/**
105
-	 * Function in charge of diplaying the [wl-faceted-search] in amp mode.
106
-	 *
107
-	 * @param array $atts Shortcode attributes.
108
-	 *
109
-	 * @return string Shortcode HTML for amp
110
-	 * @since 3.20.0
111
-	 *
112
-	 */
113
-	private function amp_shortcode( $atts ) {
114
-
115
-		// attributes extraction and boolean filtering
116
-		$shortcode_atts = $this->make_shortcode_atts( $atts );
117
-
118
-		// avoid building the widget when there is a list of posts.
119
-		if ( ! is_singular() ) {
120
-			return '';
121
-		}
122
-
123
-		$current_post = get_post();
124
-
125
-		$post         = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( $shortcode_atts['post_id'] ) ) : get_post();
126
-		$navigator_id = $shortcode_atts['uniqid'];
127
-
128
-		$wp_json_base = get_rest_url() . WL_REST_ROUTE_DEFAULT_NAMESPACE;
129
-
130
-		$navigator_query = array(
131
-			'uniqid'  => $navigator_id,
132
-			'post_id' => $post->ID,
133
-			'limit'   => $shortcode_atts['limit'],
134
-			'offset'  => $shortcode_atts['offset'],
135
-			// Changed to `sort` for Presslabs cache nodes compatibility.
136
-			'sort'    => $shortcode_atts['order_by']
137
-		);
138
-
139
-		if ( strpos( $wp_json_base, 'wp-json/' . WL_REST_ROUTE_DEFAULT_NAMESPACE ) ) {
140
-			$delimiter = '?';
141
-		} else {
142
-			$delimiter = '&';
143
-		}
144
-
145
-		// Use a protocol-relative URL as amp-list spec says that URL's protocol must be HTTPS.
146
-		// This is a hackish way, but this works for http and https URLs
147
-		$wp_json_url_posts = str_replace( array(
148
-				'http:',
149
-				'https:',
150
-			), '', $wp_json_base ) . '/navigator' . $delimiter . http_build_query( $navigator_query );
151
-
152
-		if ( ! empty( $shortcode_atts['template_id'] ) ) {
153
-			$template_id = $shortcode_atts['template_id'];
154
-		} else {
155
-			$template_id = "template-" . $navigator_id;
156
-			add_action( 'amp_post_template_css', array( $this, 'amp_post_template_css' ) );
157
-		}
158
-
159
-		return <<<HTML
20
+    /**
21
+     * {@inheritdoc}
22
+     */
23
+    const SHORTCODE = 'wl_navigator';
24
+
25
+    /**
26
+     * {@inheritdoc}
27
+     */
28
+    public function render( $atts ) {
29
+
30
+        return Wordlift_AMP_Service::is_amp_endpoint() ? $this->amp_shortcode( $atts )
31
+            : $this->web_shortcode( $atts );
32
+    }
33
+
34
+    /**
35
+     * Shared function used by web_shortcode and amp_shortcode
36
+     * Bootstrap logic for attributes extraction and boolean filtering
37
+     *
38
+     * @param array $atts Shortcode attributes.
39
+     *
40
+     * @return array $shortcode_atts
41
+     * @since      3.20.0
42
+     *
43
+     */
44
+    private function make_shortcode_atts( $atts ) {
45
+
46
+        // Extract attributes and set default values.
47
+        $shortcode_atts = shortcode_atts( array(
48
+            'title'       => __( 'Related articles', 'wordlift' ),
49
+            'limit'       => 4,
50
+            'offset'      => 0,
51
+            'template_id' => '',
52
+            'post_id'     => '',
53
+            'uniqid'      => uniqid( 'wl-navigator-widget-' ),
54
+            'order_by'    => 'ID DESC'
55
+        ), $atts );
56
+
57
+        return $shortcode_atts;
58
+    }
59
+
60
+    /**
61
+     * Function in charge of diplaying the [wl-navigator] in web mode.
62
+     *
63
+     * @param array $atts Shortcode attributes.
64
+     *
65
+     * @return string Shortcode HTML for web
66
+     * @since 3.20.0
67
+     *
68
+     */
69
+    private function web_shortcode( $atts ) {
70
+
71
+        // attributes extraction and boolean filtering
72
+        $shortcode_atts = $this->make_shortcode_atts( $atts );
73
+
74
+        // avoid building the widget when no post_id is specified and there is a list of posts.
75
+        if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) {
76
+            return;
77
+        }
78
+
79
+        $post         = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( $shortcode_atts['post_id'] ) ) : get_post();
80
+        $navigator_id = $shortcode_atts['uniqid'];
81
+        // Changed `order_by` to `sort` for Presslabs cache nodes compatibility.
82
+        $rest_url     = $post ? admin_url( sprintf( 'admin-ajax.php?action=wl_navigator&uniqid=%s&post_id=%s&limit=%s&offset=%s&sort=%s', $navigator_id, $post->ID, $shortcode_atts['limit'], $shortcode_atts['offset'], $shortcode_atts['order_by'] ) ) : false;
83
+
84
+        // avoid building the widget when no valid $rest_url
85
+        if ( ! $rest_url ) {
86
+            return;
87
+        }
88
+
89
+        wp_enqueue_script( 'wordlift-cloud' );
90
+        $json_navigator_id = wp_json_encode( $navigator_id );
91
+        echo "<script type='application/javascript'>window.wlNavigators = window.wlNavigators || []; wlNavigators.push( $json_navigator_id );</script>";
92
+
93
+        return sprintf(
94
+            '<div id="%s" class="%s" data-rest-url="%s" data-title="%s" data-template-id="%s" data-limit="%s"></div>',
95
+            $navigator_id,
96
+            'wl-navigator',
97
+            $rest_url,
98
+            $shortcode_atts['title'],
99
+            $shortcode_atts['template_id'],
100
+            $shortcode_atts['limit']
101
+        );
102
+    }
103
+
104
+    /**
105
+     * Function in charge of diplaying the [wl-faceted-search] in amp mode.
106
+     *
107
+     * @param array $atts Shortcode attributes.
108
+     *
109
+     * @return string Shortcode HTML for amp
110
+     * @since 3.20.0
111
+     *
112
+     */
113
+    private function amp_shortcode( $atts ) {
114
+
115
+        // attributes extraction and boolean filtering
116
+        $shortcode_atts = $this->make_shortcode_atts( $atts );
117
+
118
+        // avoid building the widget when there is a list of posts.
119
+        if ( ! is_singular() ) {
120
+            return '';
121
+        }
122
+
123
+        $current_post = get_post();
124
+
125
+        $post         = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( $shortcode_atts['post_id'] ) ) : get_post();
126
+        $navigator_id = $shortcode_atts['uniqid'];
127
+
128
+        $wp_json_base = get_rest_url() . WL_REST_ROUTE_DEFAULT_NAMESPACE;
129
+
130
+        $navigator_query = array(
131
+            'uniqid'  => $navigator_id,
132
+            'post_id' => $post->ID,
133
+            'limit'   => $shortcode_atts['limit'],
134
+            'offset'  => $shortcode_atts['offset'],
135
+            // Changed to `sort` for Presslabs cache nodes compatibility.
136
+            'sort'    => $shortcode_atts['order_by']
137
+        );
138
+
139
+        if ( strpos( $wp_json_base, 'wp-json/' . WL_REST_ROUTE_DEFAULT_NAMESPACE ) ) {
140
+            $delimiter = '?';
141
+        } else {
142
+            $delimiter = '&';
143
+        }
144
+
145
+        // Use a protocol-relative URL as amp-list spec says that URL's protocol must be HTTPS.
146
+        // This is a hackish way, but this works for http and https URLs
147
+        $wp_json_url_posts = str_replace( array(
148
+                'http:',
149
+                'https:',
150
+            ), '', $wp_json_base ) . '/navigator' . $delimiter . http_build_query( $navigator_query );
151
+
152
+        if ( ! empty( $shortcode_atts['template_id'] ) ) {
153
+            $template_id = $shortcode_atts['template_id'];
154
+        } else {
155
+            $template_id = "template-" . $navigator_id;
156
+            add_action( 'amp_post_template_css', array( $this, 'amp_post_template_css' ) );
157
+        }
158
+
159
+        return <<<HTML
160 160
 		<div id="{$navigator_id}" class="wl-amp-navigator" style="width: 100%">
161 161
 			<h3 class="wl-headline">{$shortcode_atts['title']}</h3>
162 162
 			<amp-list 
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
 			</div>
187 187
 		</template>
188 188
 HTML;
189
-	}
189
+    }
190 190
 
191
-	public function amp_post_template_css() {
192
-		// Default CSS for default template
193
-		echo <<<CSS
191
+    public function amp_post_template_css() {
192
+        // Default CSS for default template
193
+        echo <<<CSS
194 194
 	        .wordlift-navigator .title{font-size:16px;margin:0.5rem 0}
195 195
 	        .wordlift-navigator .cards{display:flex;flex-wrap:wrap}
196 196
 	        .wordlift-navigator .cards .card{background:white;flex:1 0 300px;box-sizing:border-box;margin:1rem .25em}
@@ -206,6 +206,6 @@  discard block
 block discarded – undo
206 206
 	        .wordlift-navigator .cards .card .thumbnail img{display:block;border:0;width:100%;height:auto}
207 207
 	        .wordlift-navigator .cards .card .card-content .title{font-size:14px;margin:0.3rem 0}
208 208
 CSS;
209
-	}
209
+    }
210 210
 
211 211
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * {@inheritdoc}
27 27
 	 */
28
-	public function render( $atts ) {
28
+	public function render($atts) {
29 29
 
30
-		return Wordlift_AMP_Service::is_amp_endpoint() ? $this->amp_shortcode( $atts )
31
-			: $this->web_shortcode( $atts );
30
+		return Wordlift_AMP_Service::is_amp_endpoint() ? $this->amp_shortcode($atts)
31
+			: $this->web_shortcode($atts);
32 32
 	}
33 33
 
34 34
 	/**
@@ -41,18 +41,18 @@  discard block
 block discarded – undo
41 41
 	 * @since      3.20.0
42 42
 	 *
43 43
 	 */
44
-	private function make_shortcode_atts( $atts ) {
44
+	private function make_shortcode_atts($atts) {
45 45
 
46 46
 		// Extract attributes and set default values.
47
-		$shortcode_atts = shortcode_atts( array(
48
-			'title'       => __( 'Related articles', 'wordlift' ),
47
+		$shortcode_atts = shortcode_atts(array(
48
+			'title'       => __('Related articles', 'wordlift'),
49 49
 			'limit'       => 4,
50 50
 			'offset'      => 0,
51 51
 			'template_id' => '',
52 52
 			'post_id'     => '',
53
-			'uniqid'      => uniqid( 'wl-navigator-widget-' ),
53
+			'uniqid'      => uniqid('wl-navigator-widget-'),
54 54
 			'order_by'    => 'ID DESC'
55
-		), $atts );
55
+		), $atts);
56 56
 
57 57
 		return $shortcode_atts;
58 58
 	}
@@ -66,28 +66,28 @@  discard block
 block discarded – undo
66 66
 	 * @since 3.20.0
67 67
 	 *
68 68
 	 */
69
-	private function web_shortcode( $atts ) {
69
+	private function web_shortcode($atts) {
70 70
 
71 71
 		// attributes extraction and boolean filtering
72
-		$shortcode_atts = $this->make_shortcode_atts( $atts );
72
+		$shortcode_atts = $this->make_shortcode_atts($atts);
73 73
 
74 74
 		// avoid building the widget when no post_id is specified and there is a list of posts.
75
-		if ( empty( $shortcode_atts['post_id'] ) && ! is_singular() ) {
75
+		if (empty($shortcode_atts['post_id']) && ! is_singular()) {
76 76
 			return;
77 77
 		}
78 78
 
79
-		$post         = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( $shortcode_atts['post_id'] ) ) : get_post();
79
+		$post         = ! empty($shortcode_atts['post_id']) ? get_post(intval($shortcode_atts['post_id'])) : get_post();
80 80
 		$navigator_id = $shortcode_atts['uniqid'];
81 81
 		// Changed `order_by` to `sort` for Presslabs cache nodes compatibility.
82
-		$rest_url     = $post ? admin_url( sprintf( 'admin-ajax.php?action=wl_navigator&uniqid=%s&post_id=%s&limit=%s&offset=%s&sort=%s', $navigator_id, $post->ID, $shortcode_atts['limit'], $shortcode_atts['offset'], $shortcode_atts['order_by'] ) ) : false;
82
+		$rest_url     = $post ? admin_url(sprintf('admin-ajax.php?action=wl_navigator&uniqid=%s&post_id=%s&limit=%s&offset=%s&sort=%s', $navigator_id, $post->ID, $shortcode_atts['limit'], $shortcode_atts['offset'], $shortcode_atts['order_by'])) : false;
83 83
 
84 84
 		// avoid building the widget when no valid $rest_url
85
-		if ( ! $rest_url ) {
85
+		if ( ! $rest_url) {
86 86
 			return;
87 87
 		}
88 88
 
89
-		wp_enqueue_script( 'wordlift-cloud' );
90
-		$json_navigator_id = wp_json_encode( $navigator_id );
89
+		wp_enqueue_script('wordlift-cloud');
90
+		$json_navigator_id = wp_json_encode($navigator_id);
91 91
 		echo "<script type='application/javascript'>window.wlNavigators = window.wlNavigators || []; wlNavigators.push( $json_navigator_id );</script>";
92 92
 
93 93
 		return sprintf(
@@ -110,22 +110,22 @@  discard block
 block discarded – undo
110 110
 	 * @since 3.20.0
111 111
 	 *
112 112
 	 */
113
-	private function amp_shortcode( $atts ) {
113
+	private function amp_shortcode($atts) {
114 114
 
115 115
 		// attributes extraction and boolean filtering
116
-		$shortcode_atts = $this->make_shortcode_atts( $atts );
116
+		$shortcode_atts = $this->make_shortcode_atts($atts);
117 117
 
118 118
 		// avoid building the widget when there is a list of posts.
119
-		if ( ! is_singular() ) {
119
+		if ( ! is_singular()) {
120 120
 			return '';
121 121
 		}
122 122
 
123 123
 		$current_post = get_post();
124 124
 
125
-		$post         = ! empty( $shortcode_atts['post_id'] ) ? get_post( intval( $shortcode_atts['post_id'] ) ) : get_post();
125
+		$post         = ! empty($shortcode_atts['post_id']) ? get_post(intval($shortcode_atts['post_id'])) : get_post();
126 126
 		$navigator_id = $shortcode_atts['uniqid'];
127 127
 
128
-		$wp_json_base = get_rest_url() . WL_REST_ROUTE_DEFAULT_NAMESPACE;
128
+		$wp_json_base = get_rest_url().WL_REST_ROUTE_DEFAULT_NAMESPACE;
129 129
 
130 130
 		$navigator_query = array(
131 131
 			'uniqid'  => $navigator_id,
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 			'sort'    => $shortcode_atts['order_by']
137 137
 		);
138 138
 
139
-		if ( strpos( $wp_json_base, 'wp-json/' . WL_REST_ROUTE_DEFAULT_NAMESPACE ) ) {
139
+		if (strpos($wp_json_base, 'wp-json/'.WL_REST_ROUTE_DEFAULT_NAMESPACE)) {
140 140
 			$delimiter = '?';
141 141
 		} else {
142 142
 			$delimiter = '&';
@@ -144,16 +144,16 @@  discard block
 block discarded – undo
144 144
 
145 145
 		// Use a protocol-relative URL as amp-list spec says that URL's protocol must be HTTPS.
146 146
 		// This is a hackish way, but this works for http and https URLs
147
-		$wp_json_url_posts = str_replace( array(
147
+		$wp_json_url_posts = str_replace(array(
148 148
 				'http:',
149 149
 				'https:',
150
-			), '', $wp_json_base ) . '/navigator' . $delimiter . http_build_query( $navigator_query );
150
+			), '', $wp_json_base).'/navigator'.$delimiter.http_build_query($navigator_query);
151 151
 
152
-		if ( ! empty( $shortcode_atts['template_id'] ) ) {
152
+		if ( ! empty($shortcode_atts['template_id'])) {
153 153
 			$template_id = $shortcode_atts['template_id'];
154 154
 		} else {
155
-			$template_id = "template-" . $navigator_id;
156
-			add_action( 'amp_post_template_css', array( $this, 'amp_post_template_css' ) );
155
+			$template_id = "template-".$navigator_id;
156
+			add_action('amp_post_template_css', array($this, 'amp_post_template_css'));
157 157
 		}
158 158
 
159 159
 		return <<<HTML
Please login to merge, or discard this patch.
src/shortcodes/wordlift_shortcode_navigator.php 2 patches
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -16,29 +16,29 @@  discard block
 block discarded – undo
16 16
  */
17 17
 function wl_shortcode_navigator_data() {
18 18
 
19
-	// Create the cache key.
20
-	$cache_key_params = $_REQUEST;
21
-	unset( $cache_key_params['uniqid'] );
22
-	$cache_key = array( 'request_params' => $cache_key_params );
19
+    // Create the cache key.
20
+    $cache_key_params = $_REQUEST;
21
+    unset( $cache_key_params['uniqid'] );
22
+    $cache_key = array( 'request_params' => $cache_key_params );
23 23
 
24
-	// Create the TTL cache and try to get the results.
25
-	$cache         = new Ttl_Cache( "navigator", 24 * 60 * 60 ); // 24 hours.
26
-	$cache_results = $cache->get( $cache_key );
24
+    // Create the TTL cache and try to get the results.
25
+    $cache         = new Ttl_Cache( "navigator", 24 * 60 * 60 ); // 24 hours.
26
+    $cache_results = $cache->get( $cache_key );
27 27
 
28
-	if ( isset( $cache_results ) ) {
29
-		header( 'X-WordLift-Cache: HIT' );
28
+    if ( isset( $cache_results ) ) {
29
+        header( 'X-WordLift-Cache: HIT' );
30 30
 
31
-		return $cache_results;
32
-	}
31
+        return $cache_results;
32
+    }
33 33
 
34
-	header( 'X-WordLift-Cache: MISS' );
34
+    header( 'X-WordLift-Cache: MISS' );
35 35
 
36
-	$results = _wl_navigator_get_data();
36
+    $results = _wl_navigator_get_data();
37 37
 
38
-	// Put the result before sending the json to the client, since sending the json will terminate us.
39
-	$cache->put( $cache_key, $results );
38
+    // Put the result before sending the json to the client, since sending the json will terminate us.
39
+    $cache->put( $cache_key, $results );
40 40
 
41
-	return $results;
41
+    return $results;
42 42
 }
43 43
 
44 44
 /**
@@ -53,195 +53,195 @@  discard block
 block discarded – undo
53 53
  */
54 54
 function wl_network_navigator_wp_json( $request ) {
55 55
 
56
-	// Create the cache key.
57
-	$cache_key_params = $_REQUEST;
58
-	unset( $cache_key_params['uniqid'] );
59
-	$cache_key = array( 'request_params' => $cache_key_params );
56
+    // Create the cache key.
57
+    $cache_key_params = $_REQUEST;
58
+    unset( $cache_key_params['uniqid'] );
59
+    $cache_key = array( 'request_params' => $cache_key_params );
60 60
 
61
-	// Create the TTL cache and try to get the results.
62
-	$cache         = new Ttl_Cache( "network-navigator", 24 * 60 * 60 ); // 24 hours.
63
-	$cache_results = $cache->get( $cache_key );
61
+    // Create the TTL cache and try to get the results.
62
+    $cache         = new Ttl_Cache( "network-navigator", 24 * 60 * 60 ); // 24 hours.
63
+    $cache_results = $cache->get( $cache_key );
64 64
 
65
-	if ( isset( $cache_results ) ) {
66
-		header( 'X-WordLift-Cache: HIT' );
65
+    if ( isset( $cache_results ) ) {
66
+        header( 'X-WordLift-Cache: HIT' );
67 67
 
68
-		return $cache_results;
69
-	}
68
+        return $cache_results;
69
+    }
70 70
 
71
-	header( 'X-WordLift-Cache: MISS' );
71
+    header( 'X-WordLift-Cache: MISS' );
72 72
 
73
-	$results = _wl_network_navigator_get_data( $request );
73
+    $results = _wl_network_navigator_get_data( $request );
74 74
 
75
-	// Put the result before sending the json to the client, since sending the json will terminate us.
76
-	$cache->put( $cache_key, $results );
75
+    // Put the result before sending the json to the client, since sending the json will terminate us.
76
+    $cache->put( $cache_key, $results );
77 77
 
78
-	return $results;
78
+    return $results;
79 79
 
80 80
 }
81 81
 
82 82
 function _wl_navigator_get_data() {
83 83
 
84
-	// Post ID must be defined
85
-	if ( ! isset( $_GET['post_id'] ) ) {
86
-		wp_send_json_error( 'No post_id given' );
87
-
88
-		return array();
89
-	}
90
-
91
-	// Limit the results (defaults to 4)
92
-	$navigator_length = isset( $_GET['limit'] ) ? intval( $_GET['limit'] ) : 4;
93
-	$navigator_offset = isset( $_GET['offset'] ) ? intval( $_GET['offset'] ) : 0;
94
-	$order_by         = isset( $_GET['sort'] ) ? sanitize_sql_orderby( $_GET['sort'] ) : 'ID DESC';
95
-
96
-	$current_post_id = $_GET['post_id'];
97
-	$current_post    = get_post( $current_post_id );
98
-
99
-	$navigator_id = $_GET['uniqid'];
100
-
101
-	// Post ID has to match an existing item
102
-	if ( null === $current_post ) {
103
-		wp_send_json_error( 'No valid post_id given' );
104
-
105
-		return array();
106
-	}
107
-
108
-	// Determine navigator type and call respective _get_results
109
-	if ( get_post_type( $current_post_id ) === Wordlift_Entity_Service::TYPE_NAME ) {
110
-		$referencing_posts = _wl_entity_navigator_get_results( $current_post_id, array(
111
-			'ID',
112
-			'post_title',
113
-		), $order_by, $navigator_length, $navigator_offset );
114
-	} else {
115
-		$referencing_posts = _wl_navigator_get_results( $current_post_id, array(
116
-			'ID',
117
-			'post_title',
118
-		), $order_by, $navigator_length, $navigator_offset );
119
-	}
120
-
121
-	// loop over them and take the first one which is not already in the $related_posts
122
-	$results = array();
123
-	foreach ( $referencing_posts as $referencing_post ) {
124
-		$serialized_entity = wl_serialize_entity( $referencing_post->entity_id );
125
-
126
-		/**
127
-		 * Use the thumbnail.
128
-		 *
129
-		 * @see https://github.com/insideout10/wordlift-plugin/issues/825 related issue.
130
-		 * @see https://github.com/insideout10/wordlift-plugin/issues/837
131
-		 *
132
-		 * @since 3.19.3 We're using the medium size image.
133
-		 */
134
-		$thumbnail = get_the_post_thumbnail_url( $referencing_post, 'medium' );
135
-
136
-		$result = array(
137
-			'post'   => array(
138
-				'permalink' => get_permalink( $referencing_post->ID ),
139
-				'title'     => $referencing_post->post_title,
140
-				'thumbnail' => $thumbnail,
141
-			),
142
-			'entity' => array(
143
-				'label'     => $serialized_entity['label'],
144
-				'mainType'  => $serialized_entity['mainType'],
145
-				'permalink' => get_permalink( $referencing_post->entity_id ),
146
-			),
147
-		);
148
-
149
-		$result['post']   = apply_filters( 'wl_navigator_data_post', $result['post'], intval( $referencing_post->ID ), $navigator_id );
150
-		$result['entity'] = apply_filters( 'wl_navigator_data_entity', $result['entity'], intval( $referencing_post->entity_id ), $navigator_id );
151
-
152
-		$results[] = $result;
153
-	}
154
-
155
-	if ( count( $results ) < $navigator_length ) {
156
-		$results = apply_filters( 'wl_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length );
157
-	}
158
-
159
-	return $results;
84
+    // Post ID must be defined
85
+    if ( ! isset( $_GET['post_id'] ) ) {
86
+        wp_send_json_error( 'No post_id given' );
87
+
88
+        return array();
89
+    }
90
+
91
+    // Limit the results (defaults to 4)
92
+    $navigator_length = isset( $_GET['limit'] ) ? intval( $_GET['limit'] ) : 4;
93
+    $navigator_offset = isset( $_GET['offset'] ) ? intval( $_GET['offset'] ) : 0;
94
+    $order_by         = isset( $_GET['sort'] ) ? sanitize_sql_orderby( $_GET['sort'] ) : 'ID DESC';
95
+
96
+    $current_post_id = $_GET['post_id'];
97
+    $current_post    = get_post( $current_post_id );
98
+
99
+    $navigator_id = $_GET['uniqid'];
100
+
101
+    // Post ID has to match an existing item
102
+    if ( null === $current_post ) {
103
+        wp_send_json_error( 'No valid post_id given' );
104
+
105
+        return array();
106
+    }
107
+
108
+    // Determine navigator type and call respective _get_results
109
+    if ( get_post_type( $current_post_id ) === Wordlift_Entity_Service::TYPE_NAME ) {
110
+        $referencing_posts = _wl_entity_navigator_get_results( $current_post_id, array(
111
+            'ID',
112
+            'post_title',
113
+        ), $order_by, $navigator_length, $navigator_offset );
114
+    } else {
115
+        $referencing_posts = _wl_navigator_get_results( $current_post_id, array(
116
+            'ID',
117
+            'post_title',
118
+        ), $order_by, $navigator_length, $navigator_offset );
119
+    }
120
+
121
+    // loop over them and take the first one which is not already in the $related_posts
122
+    $results = array();
123
+    foreach ( $referencing_posts as $referencing_post ) {
124
+        $serialized_entity = wl_serialize_entity( $referencing_post->entity_id );
125
+
126
+        /**
127
+         * Use the thumbnail.
128
+         *
129
+         * @see https://github.com/insideout10/wordlift-plugin/issues/825 related issue.
130
+         * @see https://github.com/insideout10/wordlift-plugin/issues/837
131
+         *
132
+         * @since 3.19.3 We're using the medium size image.
133
+         */
134
+        $thumbnail = get_the_post_thumbnail_url( $referencing_post, 'medium' );
135
+
136
+        $result = array(
137
+            'post'   => array(
138
+                'permalink' => get_permalink( $referencing_post->ID ),
139
+                'title'     => $referencing_post->post_title,
140
+                'thumbnail' => $thumbnail,
141
+            ),
142
+            'entity' => array(
143
+                'label'     => $serialized_entity['label'],
144
+                'mainType'  => $serialized_entity['mainType'],
145
+                'permalink' => get_permalink( $referencing_post->entity_id ),
146
+            ),
147
+        );
148
+
149
+        $result['post']   = apply_filters( 'wl_navigator_data_post', $result['post'], intval( $referencing_post->ID ), $navigator_id );
150
+        $result['entity'] = apply_filters( 'wl_navigator_data_entity', $result['entity'], intval( $referencing_post->entity_id ), $navigator_id );
151
+
152
+        $results[] = $result;
153
+    }
154
+
155
+    if ( count( $results ) < $navigator_length ) {
156
+        $results = apply_filters( 'wl_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length );
157
+    }
158
+
159
+    return $results;
160 160
 }
161 161
 
162 162
 function _wl_network_navigator_get_data( $request ) {
163 163
 
164
-	// Limit the results (defaults to 4)
165
-	$navigator_length = isset( $request['limit'] ) ? intval( $request['limit'] ) : 4;
166
-	$navigator_offset = isset( $request['offset'] ) ? intval( $request['offset'] ) : 0;
167
-	$navigator_id     = $request['uniqid'];
168
-	$order_by         = isset( $_GET['sort'] ) ? sanitize_sql_orderby( $_GET['sort'] ) : 'ID DESC';
169
-
170
-	$entities = $request['entities'];
171
-
172
-	// Post ID has to match an existing item
173
-	if ( ! isset( $entities ) || empty( $entities ) ) {
174
-		wp_send_json_error( 'No valid entities provided' );
175
-	}
176
-
177
-	$referencing_posts = _wl_network_navigator_get_results( $entities, array(
178
-		'ID',
179
-		'post_title',
180
-	), $order_by, $navigator_length, $navigator_offset );
181
-
182
-	// loop over them and take the first one which is not already in the $related_posts
183
-	$results = array();
184
-	foreach ( $referencing_posts as $referencing_post ) {
185
-		$serialized_entity = wl_serialize_entity( $referencing_post->entity_id );
186
-
187
-		/**
188
-		 * Use the thumbnail.
189
-		 *
190
-		 * @see https://github.com/insideout10/wordlift-plugin/issues/825 related issue.
191
-		 * @see https://github.com/insideout10/wordlift-plugin/issues/837
192
-		 *
193
-		 * @since 3.19.3 We're using the medium size image.
194
-		 */
195
-		$thumbnail = get_the_post_thumbnail_url( $referencing_post, 'medium' );
196
-
197
-		$result = array(
198
-			'post'   => array(
199
-				'permalink' => get_permalink( $referencing_post->ID ),
200
-				'title'     => $referencing_post->post_title,
201
-				'thumbnail' => $thumbnail,
202
-			),
203
-			'entity' => array(
204
-				'label'     => $serialized_entity['label'],
205
-				'mainType'  => $serialized_entity['mainType'],
206
-				'permalink' => get_permalink( $referencing_post->entity_id ),
207
-			),
208
-		);
209
-
210
-		$result['post']   = apply_filters( 'wl_network_navigator_data_post', $result['post'], intval( $referencing_post->ID ), $navigator_id );
211
-		$result['entity'] = apply_filters( 'wl_network_navigator_data_entity', $result['entity'], intval( $referencing_post->entity_id ), $navigator_id );
212
-
213
-		$results[] = $result;
214
-
215
-	}
216
-
217
-	if ( count( $results ) < $navigator_length ) {
218
-		$results = apply_filters( 'wl_network_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length );
219
-	}
220
-
221
-	return $results;
164
+    // Limit the results (defaults to 4)
165
+    $navigator_length = isset( $request['limit'] ) ? intval( $request['limit'] ) : 4;
166
+    $navigator_offset = isset( $request['offset'] ) ? intval( $request['offset'] ) : 0;
167
+    $navigator_id     = $request['uniqid'];
168
+    $order_by         = isset( $_GET['sort'] ) ? sanitize_sql_orderby( $_GET['sort'] ) : 'ID DESC';
169
+
170
+    $entities = $request['entities'];
171
+
172
+    // Post ID has to match an existing item
173
+    if ( ! isset( $entities ) || empty( $entities ) ) {
174
+        wp_send_json_error( 'No valid entities provided' );
175
+    }
176
+
177
+    $referencing_posts = _wl_network_navigator_get_results( $entities, array(
178
+        'ID',
179
+        'post_title',
180
+    ), $order_by, $navigator_length, $navigator_offset );
181
+
182
+    // loop over them and take the first one which is not already in the $related_posts
183
+    $results = array();
184
+    foreach ( $referencing_posts as $referencing_post ) {
185
+        $serialized_entity = wl_serialize_entity( $referencing_post->entity_id );
186
+
187
+        /**
188
+         * Use the thumbnail.
189
+         *
190
+         * @see https://github.com/insideout10/wordlift-plugin/issues/825 related issue.
191
+         * @see https://github.com/insideout10/wordlift-plugin/issues/837
192
+         *
193
+         * @since 3.19.3 We're using the medium size image.
194
+         */
195
+        $thumbnail = get_the_post_thumbnail_url( $referencing_post, 'medium' );
196
+
197
+        $result = array(
198
+            'post'   => array(
199
+                'permalink' => get_permalink( $referencing_post->ID ),
200
+                'title'     => $referencing_post->post_title,
201
+                'thumbnail' => $thumbnail,
202
+            ),
203
+            'entity' => array(
204
+                'label'     => $serialized_entity['label'],
205
+                'mainType'  => $serialized_entity['mainType'],
206
+                'permalink' => get_permalink( $referencing_post->entity_id ),
207
+            ),
208
+        );
209
+
210
+        $result['post']   = apply_filters( 'wl_network_navigator_data_post', $result['post'], intval( $referencing_post->ID ), $navigator_id );
211
+        $result['entity'] = apply_filters( 'wl_network_navigator_data_entity', $result['entity'], intval( $referencing_post->entity_id ), $navigator_id );
212
+
213
+        $results[] = $result;
214
+
215
+    }
216
+
217
+    if ( count( $results ) < $navigator_length ) {
218
+        $results = apply_filters( 'wl_network_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length );
219
+    }
220
+
221
+    return $results;
222 222
 
223 223
 }
224 224
 
225 225
 
226 226
 function _wl_navigator_get_results(
227
-	$post_id, $fields = array(
228
-	'ID',
229
-	'post_title',
227
+    $post_id, $fields = array(
228
+    'ID',
229
+    'post_title',
230 230
 ), $order_by = 'ID DESC', $limit = 10, $offset = 0
231 231
 ) {
232
-	global $wpdb;
232
+    global $wpdb;
233 233
 
234
-	$select = implode( ', ', array_map( function ( $item ) {
235
-		return "p.$item AS $item";
236
-	}, (array) $fields ) );
234
+    $select = implode( ', ', array_map( function ( $item ) {
235
+        return "p.$item AS $item";
236
+    }, (array) $fields ) );
237 237
 
238
-	$order_by = implode( ', ', array_map( function ( $item ) {
239
-		return "p.$item";
240
-	}, (array) $order_by ) );
238
+    $order_by = implode( ', ', array_map( function ( $item ) {
239
+        return "p.$item";
240
+    }, (array) $order_by ) );
241 241
 
242
-	/** @noinspection SqlNoDataSourceInspection */
243
-	return $wpdb->get_results(
244
-		$wpdb->prepare( <<<EOF
242
+    /** @noinspection SqlNoDataSourceInspection */
243
+    return $wpdb->get_results(
244
+        $wpdb->prepare( <<<EOF
245 245
 SELECT %4\$s, p2.ID as entity_id
246 246
  FROM {$wpdb->prefix}wl_relation_instances r1
247 247
     INNER JOIN {$wpdb->prefix}wl_relation_instances r2
@@ -273,30 +273,30 @@  discard block
 block discarded – undo
273 273
  LIMIT %2\$d
274 274
  OFFSET %3\$d
275 275
 EOF
276
-			, $post_id, $limit, $offset, $select, $order_by )
277
-	);
276
+            , $post_id, $limit, $offset, $select, $order_by )
277
+    );
278 278
 
279 279
 }
280 280
 
281 281
 function _wl_entity_navigator_get_results(
282
-	$post_id, $fields = array(
283
-	'ID',
284
-	'post_title',
282
+    $post_id, $fields = array(
283
+    'ID',
284
+    'post_title',
285 285
 ), $order_by = 'ID DESC', $limit = 10, $offset = 0
286 286
 ) {
287
-	global $wpdb;
287
+    global $wpdb;
288 288
 
289
-	$select = implode( ', ', array_map( function ( $item ) {
290
-		return "p.$item AS $item";
291
-	}, (array) $fields ) );
289
+    $select = implode( ', ', array_map( function ( $item ) {
290
+        return "p.$item AS $item";
291
+    }, (array) $fields ) );
292 292
 
293
-	$order_by = implode( ', ', array_map( function ( $item ) {
294
-		return "p.$item";
295
-	}, (array) $order_by ) );
293
+    $order_by = implode( ', ', array_map( function ( $item ) {
294
+        return "p.$item";
295
+    }, (array) $order_by ) );
296 296
 
297
-	/** @noinspection SqlNoDataSourceInspection */
298
-	return $wpdb->get_results(
299
-		$wpdb->prepare( <<<EOF
297
+    /** @noinspection SqlNoDataSourceInspection */
298
+    return $wpdb->get_results(
299
+        $wpdb->prepare( <<<EOF
300 300
 SELECT %4\$s, p2.ID as entity_id
301 301
  FROM {$wpdb->prefix}wl_relation_instances r1
302 302
 	-- get the ID of the post entity in common between the object and the subject 2. 
@@ -325,36 +325,36 @@  discard block
 block discarded – undo
325 325
  LIMIT %2\$d
326 326
  OFFSET %3\$d
327 327
 EOF
328
-			, $post_id, $limit, $offset, $select, $order_by )
329
-	);
328
+            , $post_id, $limit, $offset, $select, $order_by )
329
+    );
330 330
 }
331 331
 
332 332
 function _wl_network_navigator_get_results(
333
-	$entities, $fields = array(
334
-	'ID',
335
-	'post_title',
333
+    $entities, $fields = array(
334
+    'ID',
335
+    'post_title',
336 336
 ), $order_by = 'ID DESC', $limit = 10, $offset = 0
337 337
 ) {
338
-	global $wpdb;
339
-
340
-	$select = implode( ', ', array_map( function ( $item ) {
341
-		return "p.$item AS $item";
342
-	}, (array) $fields ) );
343
-
344
-	$order_by = implode( ', ', array_map( function ( $item ) {
345
-		return "p.$item";
346
-	}, (array) $order_by ) );
347
-
348
-	$entities_in = implode( ',', array_map( function ( $item ) {
349
-		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( urldecode( $item ) );
350
-		if ( isset( $entity ) ) {
351
-			return $entity->ID;
352
-		}
353
-	}, $entities ) );
354
-
355
-	/** @noinspection SqlNoDataSourceInspection */
356
-	return $wpdb->get_results(
357
-		$wpdb->prepare( <<<EOF
338
+    global $wpdb;
339
+
340
+    $select = implode( ', ', array_map( function ( $item ) {
341
+        return "p.$item AS $item";
342
+    }, (array) $fields ) );
343
+
344
+    $order_by = implode( ', ', array_map( function ( $item ) {
345
+        return "p.$item";
346
+    }, (array) $order_by ) );
347
+
348
+    $entities_in = implode( ',', array_map( function ( $item ) {
349
+        $entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( urldecode( $item ) );
350
+        if ( isset( $entity ) ) {
351
+            return $entity->ID;
352
+        }
353
+    }, $entities ) );
354
+
355
+    /** @noinspection SqlNoDataSourceInspection */
356
+    return $wpdb->get_results(
357
+        $wpdb->prepare( <<<EOF
358 358
 SELECT %3\$s, p2.ID as entity_id
359 359
  FROM {$wpdb->prefix}wl_relation_instances r1
360 360
 	-- get the ID of the post entity in common between the object and the subject 2. 
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
  LIMIT %1\$d
381 381
  OFFSET %2\$d
382 382
 EOF
383
-			, $limit, $offset, $select, $order_by )
384
-	);
383
+            , $limit, $offset, $select, $order_by )
384
+    );
385 385
 
386 386
 }
387 387
 
@@ -392,9 +392,9 @@  discard block
 block discarded – undo
392 392
  */
393 393
 function wl_shortcode_navigator_ajax() {
394 394
 
395
-	// Temporary blocking the Navigator.
396
-	$results = wl_shortcode_navigator_data();
397
-	wl_core_send_json( $results );
395
+    // Temporary blocking the Navigator.
396
+    $results = wl_shortcode_navigator_data();
397
+    wl_core_send_json( $results );
398 398
 
399 399
 }
400 400
 
@@ -406,16 +406,16 @@  discard block
 block discarded – undo
406 406
  */
407 407
 function wl_shortcode_navigator_wp_json() {
408 408
 
409
-	$results = wl_shortcode_navigator_data();
410
-	if ( ob_get_contents() ) {
411
-		ob_clean();
412
-	}
409
+    $results = wl_shortcode_navigator_data();
410
+    if ( ob_get_contents() ) {
411
+        ob_clean();
412
+    }
413 413
 
414
-	return array(
415
-		'items' => array(
416
-			array( 'values' => $results ),
417
-		),
418
-	);
414
+    return array(
415
+        'items' => array(
416
+            array( 'values' => $results ),
417
+        ),
418
+    );
419 419
 
420 420
 }
421 421
 
@@ -423,66 +423,66 @@  discard block
 block discarded – undo
423 423
  * Adding `rest_api_init` action for amp backend of navigator
424 424
  */
425 425
 add_action( 'rest_api_init', function () {
426
-	register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/navigator', array(
427
-		'methods'  => 'GET',
428
-		'callback' => 'wl_shortcode_navigator_wp_json',
429
-	) );
426
+    register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/navigator', array(
427
+        'methods'  => 'GET',
428
+        'callback' => 'wl_shortcode_navigator_wp_json',
429
+    ) );
430 430
 } );
431 431
 
432 432
 /**
433 433
  * Adding `rest_api_init` action for backend of network navigator
434 434
  */
435 435
 add_action( 'rest_api_init', function () {
436
-	register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/network-navigator', array(
437
-		'methods'  => 'GET',
438
-		'callback' => 'wl_network_navigator_wp_json',
439
-	) );
436
+    register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/network-navigator', array(
437
+        'methods'  => 'GET',
438
+        'callback' => 'wl_network_navigator_wp_json',
439
+    ) );
440 440
 } );
441 441
 
442 442
 /**
443 443
  * register_block_type for Gutenberg blocks
444 444
  */
445 445
 add_action( 'init', function () {
446
-	// Bail out if the `register_block_type` function isn't available.
447
-	if ( ! function_exists( 'register_block_type' ) ) {
448
-		return;
449
-	}
450
-
451
-	register_block_type( 'wordlift/navigator', array(
452
-		'editor_script'   => 'wl-block-editor',
453
-		'render_callback' => function ( $attributes ) {
454
-			$attr_code = '';
455
-			foreach ( $attributes as $key => $value ) {
456
-				$attr_code .= $key . '="' . $value . '" ';
457
-			}
458
-
459
-			return '[wl_navigator ' . $attr_code . ']';
460
-		},
461
-		'attributes'      => array(
462
-			'title'       => array(
463
-				'type'    => 'string',
464
-				'default' => __( 'Related articles', 'wordlift' ),
465
-			),
466
-			'limit'       => array(
467
-				'type'    => 'number',
468
-				'default' => 4,
469
-			),
470
-			'template_id' => array(
471
-				'type' => 'string',
472
-			),
473
-			'post_id'     => array(
474
-				'type' => 'number',
475
-			),
476
-			'offset'      => array(
477
-				'type'    => 'number',
478
-				'default' => 0,
479
-			),
480
-			'uniqid'      => array(
481
-				'type'    => 'string',
482
-				'default' => uniqid( 'wl-navigator-widget-' ),
483
-			),
484
-		),
485
-	) );
446
+    // Bail out if the `register_block_type` function isn't available.
447
+    if ( ! function_exists( 'register_block_type' ) ) {
448
+        return;
449
+    }
450
+
451
+    register_block_type( 'wordlift/navigator', array(
452
+        'editor_script'   => 'wl-block-editor',
453
+        'render_callback' => function ( $attributes ) {
454
+            $attr_code = '';
455
+            foreach ( $attributes as $key => $value ) {
456
+                $attr_code .= $key . '="' . $value . '" ';
457
+            }
458
+
459
+            return '[wl_navigator ' . $attr_code . ']';
460
+        },
461
+        'attributes'      => array(
462
+            'title'       => array(
463
+                'type'    => 'string',
464
+                'default' => __( 'Related articles', 'wordlift' ),
465
+            ),
466
+            'limit'       => array(
467
+                'type'    => 'number',
468
+                'default' => 4,
469
+            ),
470
+            'template_id' => array(
471
+                'type' => 'string',
472
+            ),
473
+            'post_id'     => array(
474
+                'type' => 'number',
475
+            ),
476
+            'offset'      => array(
477
+                'type'    => 'number',
478
+                'default' => 0,
479
+            ),
480
+            'uniqid'      => array(
481
+                'type'    => 'string',
482
+                'default' => uniqid( 'wl-navigator-widget-' ),
483
+            ),
484
+        ),
485
+    ) );
486 486
 } );
487 487
 
488 488
 /**
@@ -492,22 +492,22 @@  discard block
 block discarded – undo
492 492
  */
493 493
 add_action( 'plugins_loaded', function () {
494 494
 
495
-	if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action'] ) {
496
-		return;
497
-	}
495
+    if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action'] ) {
496
+        return;
497
+    }
498 498
 
499
-	remove_action( 'plugins_loaded', 'rocket_init' );
500
-	remove_action( 'plugins_loaded', 'wpseo_premium_init', 14 );
501
-	remove_action( 'plugins_loaded', 'wpseo_init', 14 );
499
+    remove_action( 'plugins_loaded', 'rocket_init' );
500
+    remove_action( 'plugins_loaded', 'wpseo_premium_init', 14 );
501
+    remove_action( 'plugins_loaded', 'wpseo_init', 14 );
502 502
 }, 0 );
503 503
 
504 504
 add_action( 'init', function () {
505 505
 
506
-	if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action'] ) {
507
-		return;
508
-	}
506
+    if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action'] ) {
507
+        return;
508
+    }
509 509
 
510
-	remove_action( 'init', 'wp_widgets_init', 1 );
511
-	remove_action( 'init', 'gglcptch_init' );
510
+    remove_action( 'init', 'wp_widgets_init', 1 );
511
+    remove_action( 'init', 'gglcptch_init' );
512 512
 }, 0 );
513 513
 
Please login to merge, or discard this patch.
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -18,25 +18,25 @@  discard block
 block discarded – undo
18 18
 
19 19
 	// Create the cache key.
20 20
 	$cache_key_params = $_REQUEST;
21
-	unset( $cache_key_params['uniqid'] );
22
-	$cache_key = array( 'request_params' => $cache_key_params );
21
+	unset($cache_key_params['uniqid']);
22
+	$cache_key = array('request_params' => $cache_key_params);
23 23
 
24 24
 	// Create the TTL cache and try to get the results.
25
-	$cache         = new Ttl_Cache( "navigator", 24 * 60 * 60 ); // 24 hours.
26
-	$cache_results = $cache->get( $cache_key );
25
+	$cache         = new Ttl_Cache("navigator", 24 * 60 * 60); // 24 hours.
26
+	$cache_results = $cache->get($cache_key);
27 27
 
28
-	if ( isset( $cache_results ) ) {
29
-		header( 'X-WordLift-Cache: HIT' );
28
+	if (isset($cache_results)) {
29
+		header('X-WordLift-Cache: HIT');
30 30
 
31 31
 		return $cache_results;
32 32
 	}
33 33
 
34
-	header( 'X-WordLift-Cache: MISS' );
34
+	header('X-WordLift-Cache: MISS');
35 35
 
36 36
 	$results = _wl_navigator_get_data();
37 37
 
38 38
 	// Put the result before sending the json to the client, since sending the json will terminate us.
39
-	$cache->put( $cache_key, $results );
39
+	$cache->put($cache_key, $results);
40 40
 
41 41
 	return $results;
42 42
 }
@@ -51,29 +51,29 @@  discard block
 block discarded – undo
51 51
  * @since 3.22.6
52 52
  *
53 53
  */
54
-function wl_network_navigator_wp_json( $request ) {
54
+function wl_network_navigator_wp_json($request) {
55 55
 
56 56
 	// Create the cache key.
57 57
 	$cache_key_params = $_REQUEST;
58
-	unset( $cache_key_params['uniqid'] );
59
-	$cache_key = array( 'request_params' => $cache_key_params );
58
+	unset($cache_key_params['uniqid']);
59
+	$cache_key = array('request_params' => $cache_key_params);
60 60
 
61 61
 	// Create the TTL cache and try to get the results.
62
-	$cache         = new Ttl_Cache( "network-navigator", 24 * 60 * 60 ); // 24 hours.
63
-	$cache_results = $cache->get( $cache_key );
62
+	$cache         = new Ttl_Cache("network-navigator", 24 * 60 * 60); // 24 hours.
63
+	$cache_results = $cache->get($cache_key);
64 64
 
65
-	if ( isset( $cache_results ) ) {
66
-		header( 'X-WordLift-Cache: HIT' );
65
+	if (isset($cache_results)) {
66
+		header('X-WordLift-Cache: HIT');
67 67
 
68 68
 		return $cache_results;
69 69
 	}
70 70
 
71
-	header( 'X-WordLift-Cache: MISS' );
71
+	header('X-WordLift-Cache: MISS');
72 72
 
73
-	$results = _wl_network_navigator_get_data( $request );
73
+	$results = _wl_network_navigator_get_data($request);
74 74
 
75 75
 	// Put the result before sending the json to the client, since sending the json will terminate us.
76
-	$cache->put( $cache_key, $results );
76
+	$cache->put($cache_key, $results);
77 77
 
78 78
 	return $results;
79 79
 
@@ -82,46 +82,46 @@  discard block
 block discarded – undo
82 82
 function _wl_navigator_get_data() {
83 83
 
84 84
 	// Post ID must be defined
85
-	if ( ! isset( $_GET['post_id'] ) ) {
86
-		wp_send_json_error( 'No post_id given' );
85
+	if ( ! isset($_GET['post_id'])) {
86
+		wp_send_json_error('No post_id given');
87 87
 
88 88
 		return array();
89 89
 	}
90 90
 
91 91
 	// Limit the results (defaults to 4)
92
-	$navigator_length = isset( $_GET['limit'] ) ? intval( $_GET['limit'] ) : 4;
93
-	$navigator_offset = isset( $_GET['offset'] ) ? intval( $_GET['offset'] ) : 0;
94
-	$order_by         = isset( $_GET['sort'] ) ? sanitize_sql_orderby( $_GET['sort'] ) : 'ID DESC';
92
+	$navigator_length = isset($_GET['limit']) ? intval($_GET['limit']) : 4;
93
+	$navigator_offset = isset($_GET['offset']) ? intval($_GET['offset']) : 0;
94
+	$order_by         = isset($_GET['sort']) ? sanitize_sql_orderby($_GET['sort']) : 'ID DESC';
95 95
 
96 96
 	$current_post_id = $_GET['post_id'];
97
-	$current_post    = get_post( $current_post_id );
97
+	$current_post    = get_post($current_post_id);
98 98
 
99 99
 	$navigator_id = $_GET['uniqid'];
100 100
 
101 101
 	// Post ID has to match an existing item
102
-	if ( null === $current_post ) {
103
-		wp_send_json_error( 'No valid post_id given' );
102
+	if (null === $current_post) {
103
+		wp_send_json_error('No valid post_id given');
104 104
 
105 105
 		return array();
106 106
 	}
107 107
 
108 108
 	// Determine navigator type and call respective _get_results
109
-	if ( get_post_type( $current_post_id ) === Wordlift_Entity_Service::TYPE_NAME ) {
110
-		$referencing_posts = _wl_entity_navigator_get_results( $current_post_id, array(
109
+	if (get_post_type($current_post_id) === Wordlift_Entity_Service::TYPE_NAME) {
110
+		$referencing_posts = _wl_entity_navigator_get_results($current_post_id, array(
111 111
 			'ID',
112 112
 			'post_title',
113
-		), $order_by, $navigator_length, $navigator_offset );
113
+		), $order_by, $navigator_length, $navigator_offset);
114 114
 	} else {
115
-		$referencing_posts = _wl_navigator_get_results( $current_post_id, array(
115
+		$referencing_posts = _wl_navigator_get_results($current_post_id, array(
116 116
 			'ID',
117 117
 			'post_title',
118
-		), $order_by, $navigator_length, $navigator_offset );
118
+		), $order_by, $navigator_length, $navigator_offset);
119 119
 	}
120 120
 
121 121
 	// loop over them and take the first one which is not already in the $related_posts
122 122
 	$results = array();
123
-	foreach ( $referencing_posts as $referencing_post ) {
124
-		$serialized_entity = wl_serialize_entity( $referencing_post->entity_id );
123
+	foreach ($referencing_posts as $referencing_post) {
124
+		$serialized_entity = wl_serialize_entity($referencing_post->entity_id);
125 125
 
126 126
 		/**
127 127
 		 * Use the thumbnail.
@@ -131,58 +131,58 @@  discard block
 block discarded – undo
131 131
 		 *
132 132
 		 * @since 3.19.3 We're using the medium size image.
133 133
 		 */
134
-		$thumbnail = get_the_post_thumbnail_url( $referencing_post, 'medium' );
134
+		$thumbnail = get_the_post_thumbnail_url($referencing_post, 'medium');
135 135
 
136 136
 		$result = array(
137 137
 			'post'   => array(
138
-				'permalink' => get_permalink( $referencing_post->ID ),
138
+				'permalink' => get_permalink($referencing_post->ID),
139 139
 				'title'     => $referencing_post->post_title,
140 140
 				'thumbnail' => $thumbnail,
141 141
 			),
142 142
 			'entity' => array(
143 143
 				'label'     => $serialized_entity['label'],
144 144
 				'mainType'  => $serialized_entity['mainType'],
145
-				'permalink' => get_permalink( $referencing_post->entity_id ),
145
+				'permalink' => get_permalink($referencing_post->entity_id),
146 146
 			),
147 147
 		);
148 148
 
149
-		$result['post']   = apply_filters( 'wl_navigator_data_post', $result['post'], intval( $referencing_post->ID ), $navigator_id );
150
-		$result['entity'] = apply_filters( 'wl_navigator_data_entity', $result['entity'], intval( $referencing_post->entity_id ), $navigator_id );
149
+		$result['post']   = apply_filters('wl_navigator_data_post', $result['post'], intval($referencing_post->ID), $navigator_id);
150
+		$result['entity'] = apply_filters('wl_navigator_data_entity', $result['entity'], intval($referencing_post->entity_id), $navigator_id);
151 151
 
152 152
 		$results[] = $result;
153 153
 	}
154 154
 
155
-	if ( count( $results ) < $navigator_length ) {
156
-		$results = apply_filters( 'wl_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length );
155
+	if (count($results) < $navigator_length) {
156
+		$results = apply_filters('wl_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length);
157 157
 	}
158 158
 
159 159
 	return $results;
160 160
 }
161 161
 
162
-function _wl_network_navigator_get_data( $request ) {
162
+function _wl_network_navigator_get_data($request) {
163 163
 
164 164
 	// Limit the results (defaults to 4)
165
-	$navigator_length = isset( $request['limit'] ) ? intval( $request['limit'] ) : 4;
166
-	$navigator_offset = isset( $request['offset'] ) ? intval( $request['offset'] ) : 0;
165
+	$navigator_length = isset($request['limit']) ? intval($request['limit']) : 4;
166
+	$navigator_offset = isset($request['offset']) ? intval($request['offset']) : 0;
167 167
 	$navigator_id     = $request['uniqid'];
168
-	$order_by         = isset( $_GET['sort'] ) ? sanitize_sql_orderby( $_GET['sort'] ) : 'ID DESC';
168
+	$order_by         = isset($_GET['sort']) ? sanitize_sql_orderby($_GET['sort']) : 'ID DESC';
169 169
 
170 170
 	$entities = $request['entities'];
171 171
 
172 172
 	// Post ID has to match an existing item
173
-	if ( ! isset( $entities ) || empty( $entities ) ) {
174
-		wp_send_json_error( 'No valid entities provided' );
173
+	if ( ! isset($entities) || empty($entities)) {
174
+		wp_send_json_error('No valid entities provided');
175 175
 	}
176 176
 
177
-	$referencing_posts = _wl_network_navigator_get_results( $entities, array(
177
+	$referencing_posts = _wl_network_navigator_get_results($entities, array(
178 178
 		'ID',
179 179
 		'post_title',
180
-	), $order_by, $navigator_length, $navigator_offset );
180
+	), $order_by, $navigator_length, $navigator_offset);
181 181
 
182 182
 	// loop over them and take the first one which is not already in the $related_posts
183 183
 	$results = array();
184
-	foreach ( $referencing_posts as $referencing_post ) {
185
-		$serialized_entity = wl_serialize_entity( $referencing_post->entity_id );
184
+	foreach ($referencing_posts as $referencing_post) {
185
+		$serialized_entity = wl_serialize_entity($referencing_post->entity_id);
186 186
 
187 187
 		/**
188 188
 		 * Use the thumbnail.
@@ -192,30 +192,30 @@  discard block
 block discarded – undo
192 192
 		 *
193 193
 		 * @since 3.19.3 We're using the medium size image.
194 194
 		 */
195
-		$thumbnail = get_the_post_thumbnail_url( $referencing_post, 'medium' );
195
+		$thumbnail = get_the_post_thumbnail_url($referencing_post, 'medium');
196 196
 
197 197
 		$result = array(
198 198
 			'post'   => array(
199
-				'permalink' => get_permalink( $referencing_post->ID ),
199
+				'permalink' => get_permalink($referencing_post->ID),
200 200
 				'title'     => $referencing_post->post_title,
201 201
 				'thumbnail' => $thumbnail,
202 202
 			),
203 203
 			'entity' => array(
204 204
 				'label'     => $serialized_entity['label'],
205 205
 				'mainType'  => $serialized_entity['mainType'],
206
-				'permalink' => get_permalink( $referencing_post->entity_id ),
206
+				'permalink' => get_permalink($referencing_post->entity_id),
207 207
 			),
208 208
 		);
209 209
 
210
-		$result['post']   = apply_filters( 'wl_network_navigator_data_post', $result['post'], intval( $referencing_post->ID ), $navigator_id );
211
-		$result['entity'] = apply_filters( 'wl_network_navigator_data_entity', $result['entity'], intval( $referencing_post->entity_id ), $navigator_id );
210
+		$result['post']   = apply_filters('wl_network_navigator_data_post', $result['post'], intval($referencing_post->ID), $navigator_id);
211
+		$result['entity'] = apply_filters('wl_network_navigator_data_entity', $result['entity'], intval($referencing_post->entity_id), $navigator_id);
212 212
 
213 213
 		$results[] = $result;
214 214
 
215 215
 	}
216 216
 
217
-	if ( count( $results ) < $navigator_length ) {
218
-		$results = apply_filters( 'wl_network_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length );
217
+	if (count($results) < $navigator_length) {
218
+		$results = apply_filters('wl_network_navigator_data_placeholder', $results, $navigator_id, $navigator_offset, $navigator_length);
219 219
 	}
220 220
 
221 221
 	return $results;
@@ -231,17 +231,17 @@  discard block
 block discarded – undo
231 231
 ) {
232 232
 	global $wpdb;
233 233
 
234
-	$select = implode( ', ', array_map( function ( $item ) {
234
+	$select = implode(', ', array_map(function($item) {
235 235
 		return "p.$item AS $item";
236
-	}, (array) $fields ) );
236
+	}, (array) $fields));
237 237
 
238
-	$order_by = implode( ', ', array_map( function ( $item ) {
238
+	$order_by = implode(', ', array_map(function($item) {
239 239
 		return "p.$item";
240
-	}, (array) $order_by ) );
240
+	}, (array) $order_by));
241 241
 
242 242
 	/** @noinspection SqlNoDataSourceInspection */
243 243
 	return $wpdb->get_results(
244
-		$wpdb->prepare( <<<EOF
244
+		$wpdb->prepare(<<<EOF
245 245
 SELECT %4\$s, p2.ID as entity_id
246 246
  FROM {$wpdb->prefix}wl_relation_instances r1
247 247
     INNER JOIN {$wpdb->prefix}wl_relation_instances r2
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
  LIMIT %2\$d
274 274
  OFFSET %3\$d
275 275
 EOF
276
-			, $post_id, $limit, $offset, $select, $order_by )
276
+			, $post_id, $limit, $offset, $select, $order_by)
277 277
 	);
278 278
 
279 279
 }
@@ -286,17 +286,17 @@  discard block
 block discarded – undo
286 286
 ) {
287 287
 	global $wpdb;
288 288
 
289
-	$select = implode( ', ', array_map( function ( $item ) {
289
+	$select = implode(', ', array_map(function($item) {
290 290
 		return "p.$item AS $item";
291
-	}, (array) $fields ) );
291
+	}, (array) $fields));
292 292
 
293
-	$order_by = implode( ', ', array_map( function ( $item ) {
293
+	$order_by = implode(', ', array_map(function($item) {
294 294
 		return "p.$item";
295
-	}, (array) $order_by ) );
295
+	}, (array) $order_by));
296 296
 
297 297
 	/** @noinspection SqlNoDataSourceInspection */
298 298
 	return $wpdb->get_results(
299
-		$wpdb->prepare( <<<EOF
299
+		$wpdb->prepare(<<<EOF
300 300
 SELECT %4\$s, p2.ID as entity_id
301 301
  FROM {$wpdb->prefix}wl_relation_instances r1
302 302
 	-- get the ID of the post entity in common between the object and the subject 2. 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
  LIMIT %2\$d
326 326
  OFFSET %3\$d
327 327
 EOF
328
-			, $post_id, $limit, $offset, $select, $order_by )
328
+			, $post_id, $limit, $offset, $select, $order_by)
329 329
 	);
330 330
 }
331 331
 
@@ -337,24 +337,24 @@  discard block
 block discarded – undo
337 337
 ) {
338 338
 	global $wpdb;
339 339
 
340
-	$select = implode( ', ', array_map( function ( $item ) {
340
+	$select = implode(', ', array_map(function($item) {
341 341
 		return "p.$item AS $item";
342
-	}, (array) $fields ) );
342
+	}, (array) $fields));
343 343
 
344
-	$order_by = implode( ', ', array_map( function ( $item ) {
344
+	$order_by = implode(', ', array_map(function($item) {
345 345
 		return "p.$item";
346
-	}, (array) $order_by ) );
346
+	}, (array) $order_by));
347 347
 
348
-	$entities_in = implode( ',', array_map( function ( $item ) {
349
-		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri( urldecode( $item ) );
350
-		if ( isset( $entity ) ) {
348
+	$entities_in = implode(',', array_map(function($item) {
349
+		$entity = Wordlift_Entity_Service::get_instance()->get_entity_post_by_uri(urldecode($item));
350
+		if (isset($entity)) {
351 351
 			return $entity->ID;
352 352
 		}
353
-	}, $entities ) );
353
+	}, $entities));
354 354
 
355 355
 	/** @noinspection SqlNoDataSourceInspection */
356 356
 	return $wpdb->get_results(
357
-		$wpdb->prepare( <<<EOF
357
+		$wpdb->prepare(<<<EOF
358 358
 SELECT %3\$s, p2.ID as entity_id
359 359
  FROM {$wpdb->prefix}wl_relation_instances r1
360 360
 	-- get the ID of the post entity in common between the object and the subject 2. 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
  LIMIT %1\$d
381 381
  OFFSET %2\$d
382 382
 EOF
383
-			, $limit, $offset, $select, $order_by )
383
+			, $limit, $offset, $select, $order_by)
384 384
 	);
385 385
 
386 386
 }
@@ -394,12 +394,12 @@  discard block
 block discarded – undo
394 394
 
395 395
 	// Temporary blocking the Navigator.
396 396
 	$results = wl_shortcode_navigator_data();
397
-	wl_core_send_json( $results );
397
+	wl_core_send_json($results);
398 398
 
399 399
 }
400 400
 
401
-add_action( 'wp_ajax_wl_navigator', 'wl_shortcode_navigator_ajax' );
402
-add_action( 'wp_ajax_nopriv_wl_navigator', 'wl_shortcode_navigator_ajax' );
401
+add_action('wp_ajax_wl_navigator', 'wl_shortcode_navigator_ajax');
402
+add_action('wp_ajax_nopriv_wl_navigator', 'wl_shortcode_navigator_ajax');
403 403
 
404 404
 /**
405 405
  * wp-json call for the navigator widget
@@ -407,13 +407,13 @@  discard block
 block discarded – undo
407 407
 function wl_shortcode_navigator_wp_json() {
408 408
 
409 409
 	$results = wl_shortcode_navigator_data();
410
-	if ( ob_get_contents() ) {
410
+	if (ob_get_contents()) {
411 411
 		ob_clean();
412 412
 	}
413 413
 
414 414
 	return array(
415 415
 		'items' => array(
416
-			array( 'values' => $results ),
416
+			array('values' => $results),
417 417
 		),
418 418
 	);
419 419
 
@@ -422,46 +422,46 @@  discard block
 block discarded – undo
422 422
 /**
423 423
  * Adding `rest_api_init` action for amp backend of navigator
424 424
  */
425
-add_action( 'rest_api_init', function () {
426
-	register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/navigator', array(
425
+add_action('rest_api_init', function() {
426
+	register_rest_route(WL_REST_ROUTE_DEFAULT_NAMESPACE, '/navigator', array(
427 427
 		'methods'  => 'GET',
428 428
 		'callback' => 'wl_shortcode_navigator_wp_json',
429
-	) );
429
+	));
430 430
 } );
431 431
 
432 432
 /**
433 433
  * Adding `rest_api_init` action for backend of network navigator
434 434
  */
435
-add_action( 'rest_api_init', function () {
436
-	register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/network-navigator', array(
435
+add_action('rest_api_init', function() {
436
+	register_rest_route(WL_REST_ROUTE_DEFAULT_NAMESPACE, '/network-navigator', array(
437 437
 		'methods'  => 'GET',
438 438
 		'callback' => 'wl_network_navigator_wp_json',
439
-	) );
439
+	));
440 440
 } );
441 441
 
442 442
 /**
443 443
  * register_block_type for Gutenberg blocks
444 444
  */
445
-add_action( 'init', function () {
445
+add_action('init', function() {
446 446
 	// Bail out if the `register_block_type` function isn't available.
447
-	if ( ! function_exists( 'register_block_type' ) ) {
447
+	if ( ! function_exists('register_block_type')) {
448 448
 		return;
449 449
 	}
450 450
 
451
-	register_block_type( 'wordlift/navigator', array(
451
+	register_block_type('wordlift/navigator', array(
452 452
 		'editor_script'   => 'wl-block-editor',
453
-		'render_callback' => function ( $attributes ) {
453
+		'render_callback' => function($attributes) {
454 454
 			$attr_code = '';
455
-			foreach ( $attributes as $key => $value ) {
456
-				$attr_code .= $key . '="' . $value . '" ';
455
+			foreach ($attributes as $key => $value) {
456
+				$attr_code .= $key.'="'.$value.'" ';
457 457
 			}
458 458
 
459
-			return '[wl_navigator ' . $attr_code . ']';
459
+			return '[wl_navigator '.$attr_code.']';
460 460
 		},
461 461
 		'attributes'      => array(
462 462
 			'title'       => array(
463 463
 				'type'    => 'string',
464
-				'default' => __( 'Related articles', 'wordlift' ),
464
+				'default' => __('Related articles', 'wordlift'),
465 465
 			),
466 466
 			'limit'       => array(
467 467
 				'type'    => 'number',
@@ -479,10 +479,10 @@  discard block
 block discarded – undo
479 479
 			),
480 480
 			'uniqid'      => array(
481 481
 				'type'    => 'string',
482
-				'default' => uniqid( 'wl-navigator-widget-' ),
482
+				'default' => uniqid('wl-navigator-widget-'),
483 483
 			),
484 484
 		),
485
-	) );
485
+	));
486 486
 } );
487 487
 
488 488
 /**
@@ -490,24 +490,24 @@  discard block
 block discarded – undo
490 490
  *
491 491
  * @since 2.2.0
492 492
  */
493
-add_action( 'plugins_loaded', function () {
493
+add_action('plugins_loaded', function() {
494 494
 
495
-	if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action'] ) {
495
+	if ( ! defined('DOING_AJAX') || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action']) {
496 496
 		return;
497 497
 	}
498 498
 
499
-	remove_action( 'plugins_loaded', 'rocket_init' );
500
-	remove_action( 'plugins_loaded', 'wpseo_premium_init', 14 );
501
-	remove_action( 'plugins_loaded', 'wpseo_init', 14 );
502
-}, 0 );
499
+	remove_action('plugins_loaded', 'rocket_init');
500
+	remove_action('plugins_loaded', 'wpseo_premium_init', 14);
501
+	remove_action('plugins_loaded', 'wpseo_init', 14);
502
+}, 0);
503 503
 
504
-add_action( 'init', function () {
504
+add_action('init', function() {
505 505
 
506
-	if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action'] ) {
506
+	if ( ! defined('DOING_AJAX') || ! DOING_AJAX || 'wl_navigator' !== $_REQUEST['action']) {
507 507
 		return;
508 508
 	}
509 509
 
510
-	remove_action( 'init', 'wp_widgets_init', 1 );
511
-	remove_action( 'init', 'gglcptch_init' );
512
-}, 0 );
510
+	remove_action('init', 'wp_widgets_init', 1);
511
+	remove_action('init', 'gglcptch_init');
512
+}, 0);
513 513
 
Please login to merge, or discard this patch.