Completed
Push — develop ( 8ce8eb...2b850c )
by Naveen
03:08
created
src/wordlift/widgets/navigator/class-navigator-data.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -7,39 +7,39 @@  discard block
 block discarded – undo
7 7
  */
8 8
 class Navigator_Data {
9 9
 
10
-	public static function get_post_types_as_string( $post_types ) {
11
-		if ( $post_types === array() ) {
12
-			$post_types = get_post_types();
13
-		}
14
-		$post_types = array_map( function ( $post_type ) {
15
-			return "'" . esc_sql( $post_type ) . "'";
16
-		}, $post_types );
17
-
18
-		return implode( ',', $post_types );
19
-	}
20
-
21
-	public static function post_navigator_get_results(
22
-		$post_id, $fields = array(
23
-		'ID',
24
-		'post_title',
25
-	), $order_by = 'ID DESC', $limit = 10, $offset = 0, $post_types = array()
26
-	) {
27
-
28
-		$post_types = self::get_post_types_as_string( $post_types );
29
-		global $wpdb;
30
-
31
-		$select = implode( ', ', array_map( function ( $item ) {
32
-			return "p.$item AS $item";
33
-		}, (array) $fields ) );
34
-
35
-		$order_by = implode( ', ', array_map( function ( $item ) {
36
-			return "p.$item";
37
-		}, (array) $order_by ) );
38
-
39
-
40
-		/** @noinspection SqlNoDataSourceInspection */
41
-		return $wpdb->get_results(
42
-			$wpdb->prepare( <<<EOF
10
+    public static function get_post_types_as_string( $post_types ) {
11
+        if ( $post_types === array() ) {
12
+            $post_types = get_post_types();
13
+        }
14
+        $post_types = array_map( function ( $post_type ) {
15
+            return "'" . esc_sql( $post_type ) . "'";
16
+        }, $post_types );
17
+
18
+        return implode( ',', $post_types );
19
+    }
20
+
21
+    public static function post_navigator_get_results(
22
+        $post_id, $fields = array(
23
+        'ID',
24
+        'post_title',
25
+    ), $order_by = 'ID DESC', $limit = 10, $offset = 0, $post_types = array()
26
+    ) {
27
+
28
+        $post_types = self::get_post_types_as_string( $post_types );
29
+        global $wpdb;
30
+
31
+        $select = implode( ', ', array_map( function ( $item ) {
32
+            return "p.$item AS $item";
33
+        }, (array) $fields ) );
34
+
35
+        $order_by = implode( ', ', array_map( function ( $item ) {
36
+            return "p.$item";
37
+        }, (array) $order_by ) );
38
+
39
+
40
+        /** @noinspection SqlNoDataSourceInspection */
41
+        return $wpdb->get_results(
42
+            $wpdb->prepare( <<<EOF
43 43
 SELECT %4\$s, p2.ID as entity_id
44 44
  FROM {$wpdb->prefix}wl_relation_instances r1
45 45
     INNER JOIN {$wpdb->prefix}wl_relation_instances r2
@@ -73,33 +73,33 @@  discard block
 block discarded – undo
73 73
  LIMIT %2\$d
74 74
  OFFSET %3\$d
75 75
 EOF
76
-				, $post_id, $limit, $offset, $select, $order_by )
77
-		);
76
+                , $post_id, $limit, $offset, $select, $order_by )
77
+        );
78 78
 
79
-	}
79
+    }
80 80
 
81 81
 
82
-	public static function entity_navigator_get_results(
83
-		$post_id, $fields = array(
84
-		'ID',
85
-		'post_title',
86
-	), $order_by = 'ID DESC', $limit = 10, $offset = 0, $post_types = array()
87
-	) {
88
-		global $wpdb;
82
+    public static function entity_navigator_get_results(
83
+        $post_id, $fields = array(
84
+        'ID',
85
+        'post_title',
86
+    ), $order_by = 'ID DESC', $limit = 10, $offset = 0, $post_types = array()
87
+    ) {
88
+        global $wpdb;
89 89
 
90
-		$select = implode( ', ', array_map( function ( $item ) {
91
-			return "p.$item AS $item";
92
-		}, (array) $fields ) );
90
+        $select = implode( ', ', array_map( function ( $item ) {
91
+            return "p.$item AS $item";
92
+        }, (array) $fields ) );
93 93
 
94
-		$order_by = implode( ', ', array_map( function ( $item ) {
95
-			return "p.$item";
96
-		}, (array) $order_by ) );
94
+        $order_by = implode( ', ', array_map( function ( $item ) {
95
+            return "p.$item";
96
+        }, (array) $order_by ) );
97 97
 
98
-		$post_types = self::get_post_types_as_string( $post_types );
98
+        $post_types = self::get_post_types_as_string( $post_types );
99 99
 
100
-		/** @noinspection SqlNoDataSourceInspection */
101
-		return $wpdb->get_results(
102
-			$wpdb->prepare( <<<EOF
100
+        /** @noinspection SqlNoDataSourceInspection */
101
+        return $wpdb->get_results(
102
+            $wpdb->prepare( <<<EOF
103 103
 SELECT %4\$s, p2.ID as entity_id
104 104
  FROM {$wpdb->prefix}wl_relation_instances r1
105 105
 	-- get the ID of the post entity in common between the object and the subject 2. 
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
  LIMIT %2\$d
131 131
  OFFSET %3\$d
132 132
 EOF
133
-				, $post_id, $limit, $offset, $select, $order_by )
134
-		);
135
-	}
133
+                , $post_id, $limit, $offset, $select, $order_by )
134
+        );
135
+    }
136 136
 
137 137
 
138 138
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
 class Navigator_Data {
9 9
 
10
-	public static function get_post_types_as_string( $post_types ) {
11
-		if ( $post_types === array() ) {
10
+	public static function get_post_types_as_string($post_types) {
11
+		if ($post_types === array()) {
12 12
 			$post_types = get_post_types();
13 13
 		}
14
-		$post_types = array_map( function ( $post_type ) {
15
-			return "'" . esc_sql( $post_type ) . "'";
16
-		}, $post_types );
14
+		$post_types = array_map(function($post_type) {
15
+			return "'".esc_sql($post_type)."'";
16
+		}, $post_types);
17 17
 
18
-		return implode( ',', $post_types );
18
+		return implode(',', $post_types);
19 19
 	}
20 20
 
21 21
 	public static function post_navigator_get_results(
@@ -25,21 +25,21 @@  discard block
 block discarded – undo
25 25
 	), $order_by = 'ID DESC', $limit = 10, $offset = 0, $post_types = array()
26 26
 	) {
27 27
 
28
-		$post_types = self::get_post_types_as_string( $post_types );
28
+		$post_types = self::get_post_types_as_string($post_types);
29 29
 		global $wpdb;
30 30
 
31
-		$select = implode( ', ', array_map( function ( $item ) {
31
+		$select = implode(', ', array_map(function($item) {
32 32
 			return "p.$item AS $item";
33
-		}, (array) $fields ) );
33
+		}, (array) $fields));
34 34
 
35
-		$order_by = implode( ', ', array_map( function ( $item ) {
35
+		$order_by = implode(', ', array_map(function($item) {
36 36
 			return "p.$item";
37
-		}, (array) $order_by ) );
37
+		}, (array) $order_by));
38 38
 
39 39
 
40 40
 		/** @noinspection SqlNoDataSourceInspection */
41 41
 		return $wpdb->get_results(
42
-			$wpdb->prepare( <<<EOF
42
+			$wpdb->prepare(<<<EOF
43 43
 SELECT %4\$s, p2.ID as entity_id
44 44
  FROM {$wpdb->prefix}wl_relation_instances r1
45 45
     INNER JOIN {$wpdb->prefix}wl_relation_instances r2
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
  LIMIT %2\$d
74 74
  OFFSET %3\$d
75 75
 EOF
76
-				, $post_id, $limit, $offset, $select, $order_by )
76
+				, $post_id, $limit, $offset, $select, $order_by)
77 77
 		);
78 78
 
79 79
 	}
@@ -87,19 +87,19 @@  discard block
 block discarded – undo
87 87
 	) {
88 88
 		global $wpdb;
89 89
 
90
-		$select = implode( ', ', array_map( function ( $item ) {
90
+		$select = implode(', ', array_map(function($item) {
91 91
 			return "p.$item AS $item";
92
-		}, (array) $fields ) );
92
+		}, (array) $fields));
93 93
 
94
-		$order_by = implode( ', ', array_map( function ( $item ) {
94
+		$order_by = implode(', ', array_map(function($item) {
95 95
 			return "p.$item";
96
-		}, (array) $order_by ) );
96
+		}, (array) $order_by));
97 97
 
98
-		$post_types = self::get_post_types_as_string( $post_types );
98
+		$post_types = self::get_post_types_as_string($post_types);
99 99
 
100 100
 		/** @noinspection SqlNoDataSourceInspection */
101 101
 		return $wpdb->get_results(
102
-			$wpdb->prepare( <<<EOF
102
+			$wpdb->prepare(<<<EOF
103 103
 SELECT %4\$s, p2.ID as entity_id
104 104
  FROM {$wpdb->prefix}wl_relation_instances r1
105 105
 	-- get the ID of the post entity in common between the object and the subject 2. 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
  LIMIT %2\$d
131 131
  OFFSET %3\$d
132 132
 EOF
133
-				, $post_id, $limit, $offset, $select, $order_by )
133
+				, $post_id, $limit, $offset, $select, $order_by)
134 134
 		);
135 135
 	}
136 136
 
Please login to merge, or discard this patch.