Completed
Push — develop ( f98d9a...8ce8eb )
by Naveen
03:01
created
src/wordlift/widgets/navigator/class-navigator-data.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -7,36 +7,36 @@  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
-		$sql = $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
+        $sql = $wpdb->prepare( <<<EOF
40 40
 SELECT %4\$s, p2.ID as entity_id
41 41
  FROM {$wpdb->prefix}wl_relation_instances r1
42 42
     INNER JOIN {$wpdb->prefix}wl_relation_instances r2
@@ -70,37 +70,37 @@  discard block
 block discarded – undo
70 70
  LIMIT %2\$d
71 71
  OFFSET %3\$d
72 72
 EOF
73
-			, $post_id, $limit, $offset, $select, $order_by );
74
-		var_dump($sql);
75
-		/** @noinspection SqlNoDataSourceInspection */
76
-		return $wpdb->get_results(
77
-			$sql
78
-		);
73
+            , $post_id, $limit, $offset, $select, $order_by );
74
+        var_dump($sql);
75
+        /** @noinspection SqlNoDataSourceInspection */
76
+        return $wpdb->get_results(
77
+            $sql
78
+        );
79 79
 
80
-	}
80
+    }
81 81
 
82 82
 
83
-	public static function entity_navigator_get_results(
84
-		$post_id, $fields = array(
85
-		'ID',
86
-		'post_title',
87
-	), $order_by = 'ID DESC', $limit = 10, $offset = 0, $post_types = array()
88
-	) {
89
-		global $wpdb;
83
+    public static function entity_navigator_get_results(
84
+        $post_id, $fields = array(
85
+        'ID',
86
+        'post_title',
87
+    ), $order_by = 'ID DESC', $limit = 10, $offset = 0, $post_types = array()
88
+    ) {
89
+        global $wpdb;
90 90
 
91
-		$select = implode( ', ', array_map( function ( $item ) {
92
-			return "p.$item AS $item";
93
-		}, (array) $fields ) );
91
+        $select = implode( ', ', array_map( function ( $item ) {
92
+            return "p.$item AS $item";
93
+        }, (array) $fields ) );
94 94
 
95
-		$order_by = implode( ', ', array_map( function ( $item ) {
96
-			return "p.$item";
97
-		}, (array) $order_by ) );
95
+        $order_by = implode( ', ', array_map( function ( $item ) {
96
+            return "p.$item";
97
+        }, (array) $order_by ) );
98 98
 
99
-		$post_types = self::get_post_types_as_string( $post_types );
99
+        $post_types = self::get_post_types_as_string( $post_types );
100 100
 
101
-		/** @noinspection SqlNoDataSourceInspection */
102
-		return $wpdb->get_results(
103
-			$wpdb->prepare( <<<EOF
101
+        /** @noinspection SqlNoDataSourceInspection */
102
+        return $wpdb->get_results(
103
+            $wpdb->prepare( <<<EOF
104 104
 SELECT %4\$s, p2.ID as entity_id
105 105
  FROM {$wpdb->prefix}wl_relation_instances r1
106 106
 	-- get the ID of the post entity in common between the object and the subject 2. 
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
  LIMIT %2\$d
132 132
  OFFSET %3\$d
133 133
 EOF
134
-				, $post_id, $limit, $offset, $select, $order_by )
135
-		);
136
-	}
134
+                , $post_id, $limit, $offset, $select, $order_by )
135
+        );
136
+    }
137 137
 
138 138
 
139 139
 }
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,18 +25,18 @@  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
-		$sql = $wpdb->prepare( <<<EOF
39
+		$sql = $wpdb->prepare(<<<EOF
40 40
 SELECT %4\$s, p2.ID as entity_id
41 41
  FROM {$wpdb->prefix}wl_relation_instances r1
42 42
     INNER JOIN {$wpdb->prefix}wl_relation_instances r2
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
  LIMIT %2\$d
71 71
  OFFSET %3\$d
72 72
 EOF
73
-			, $post_id, $limit, $offset, $select, $order_by );
73
+			, $post_id, $limit, $offset, $select, $order_by);
74 74
 		var_dump($sql);
75 75
 		/** @noinspection SqlNoDataSourceInspection */
76 76
 		return $wpdb->get_results(
@@ -88,19 +88,19 @@  discard block
 block discarded – undo
88 88
 	) {
89 89
 		global $wpdb;
90 90
 
91
-		$select = implode( ', ', array_map( function ( $item ) {
91
+		$select = implode(', ', array_map(function($item) {
92 92
 			return "p.$item AS $item";
93
-		}, (array) $fields ) );
93
+		}, (array) $fields));
94 94
 
95
-		$order_by = implode( ', ', array_map( function ( $item ) {
95
+		$order_by = implode(', ', array_map(function($item) {
96 96
 			return "p.$item";
97
-		}, (array) $order_by ) );
97
+		}, (array) $order_by));
98 98
 
99
-		$post_types = self::get_post_types_as_string( $post_types );
99
+		$post_types = self::get_post_types_as_string($post_types);
100 100
 
101 101
 		/** @noinspection SqlNoDataSourceInspection */
102 102
 		return $wpdb->get_results(
103
-			$wpdb->prepare( <<<EOF
103
+			$wpdb->prepare(<<<EOF
104 104
 SELECT %4\$s, p2.ID as entity_id
105 105
  FROM {$wpdb->prefix}wl_relation_instances r1
106 106
 	-- get the ID of the post entity in common between the object and the subject 2. 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
  LIMIT %2\$d
132 132
  OFFSET %3\$d
133 133
 EOF
134
-				, $post_id, $limit, $offset, $select, $order_by )
134
+				, $post_id, $limit, $offset, $select, $order_by)
135 135
 		);
136 136
 	}
137 137
 
Please login to merge, or discard this patch.