Completed
Pull Request — develop (#1683)
by Naveen
01:17
created
src/wordlift/dataset/class-sync-hooks-entity-relation.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -15,62 +15,62 @@
 block discarded – undo
15 15
  */
16 16
 class Sync_Hooks_Entity_Relation {
17 17
 
18
-	/**
19
-	 * @var \Wordlift_Entity_Service
20
-	 */
21
-	private $entity_service;
22
-
23
-	/**
24
-	 * Entity_Dct_Relation constructor.
25
-	 *
26
-	 * @param $entity_service \Wordlift_Entity_Service
27
-	 */
28
-	public function __construct( $entity_service ) {
29
-		$this->entity_service = $entity_service;
30
-
31
-		add_filter( 'wl_dataset__sync_service__sync_item__jsonld', array( $this, 'jsonld' ), 10, 3 );
32
-	}
33
-
34
-	public function jsonld( $jsonld, $type, $post_id ) {
35
-
36
-		// @@todo add support anything that isn't a POST.
37
-		if ( Object_Type_Enum::POST !== $type ) {
38
-			return $jsonld;
39
-		}
40
-
41
-		// Choose the dcterm property according to the post type.
42
-		$property = $this->entity_service->is_entity( $post_id )
43
-			? 'http://purl.org/dc/terms/relation'
44
-			: 'http://purl.org/dc/terms/references';
45
-
46
-		$references = array_unique( $this->entity_service->get_related_entities( $post_id ) );
47
-
48
-		// Bail out if there are no references.
49
-		if ( empty( $references ) ) {
50
-			return $jsonld;
51
-		}
52
-
53
-		if ( ! isset( $jsonld[0][ $property ] ) ) {
54
-			$jsonld[0][ $property ] = array();
55
-		}
56
-
57
-		if ( ! is_array( $jsonld[0][ $property ] ) ) {
58
-			$jsonld[0][ $property ] = array( $jsonld[0][ $property ] );
59
-		}
60
-
61
-		$that             = $this;
62
-		$references_array = array_values(
63
-			array_map(
64
-				function ( $item ) use ( $that ) {
65
-					return array( '@id' => $that->entity_service->get_uri( $item ) );
66
-				},
67
-				$references
68
-			)
69
-		);
70
-
71
-		$jsonld[0][ $property ] = array_merge( $jsonld[0][ $property ], $references_array );
72
-
73
-		return $jsonld;
74
-	}
18
+    /**
19
+     * @var \Wordlift_Entity_Service
20
+     */
21
+    private $entity_service;
22
+
23
+    /**
24
+     * Entity_Dct_Relation constructor.
25
+     *
26
+     * @param $entity_service \Wordlift_Entity_Service
27
+     */
28
+    public function __construct( $entity_service ) {
29
+        $this->entity_service = $entity_service;
30
+
31
+        add_filter( 'wl_dataset__sync_service__sync_item__jsonld', array( $this, 'jsonld' ), 10, 3 );
32
+    }
33
+
34
+    public function jsonld( $jsonld, $type, $post_id ) {
35
+
36
+        // @@todo add support anything that isn't a POST.
37
+        if ( Object_Type_Enum::POST !== $type ) {
38
+            return $jsonld;
39
+        }
40
+
41
+        // Choose the dcterm property according to the post type.
42
+        $property = $this->entity_service->is_entity( $post_id )
43
+            ? 'http://purl.org/dc/terms/relation'
44
+            : 'http://purl.org/dc/terms/references';
45
+
46
+        $references = array_unique( $this->entity_service->get_related_entities( $post_id ) );
47
+
48
+        // Bail out if there are no references.
49
+        if ( empty( $references ) ) {
50
+            return $jsonld;
51
+        }
52
+
53
+        if ( ! isset( $jsonld[0][ $property ] ) ) {
54
+            $jsonld[0][ $property ] = array();
55
+        }
56
+
57
+        if ( ! is_array( $jsonld[0][ $property ] ) ) {
58
+            $jsonld[0][ $property ] = array( $jsonld[0][ $property ] );
59
+        }
60
+
61
+        $that             = $this;
62
+        $references_array = array_values(
63
+            array_map(
64
+                function ( $item ) use ( $that ) {
65
+                    return array( '@id' => $that->entity_service->get_uri( $item ) );
66
+                },
67
+                $references
68
+            )
69
+        );
70
+
71
+        $jsonld[0][ $property ] = array_merge( $jsonld[0][ $property ], $references_array );
72
+
73
+        return $jsonld;
74
+    }
75 75
 
76 76
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,50 +25,50 @@
 block discarded – undo
25 25
 	 *
26 26
 	 * @param $entity_service \Wordlift_Entity_Service
27 27
 	 */
28
-	public function __construct( $entity_service ) {
28
+	public function __construct($entity_service) {
29 29
 		$this->entity_service = $entity_service;
30 30
 
31
-		add_filter( 'wl_dataset__sync_service__sync_item__jsonld', array( $this, 'jsonld' ), 10, 3 );
31
+		add_filter('wl_dataset__sync_service__sync_item__jsonld', array($this, 'jsonld'), 10, 3);
32 32
 	}
33 33
 
34
-	public function jsonld( $jsonld, $type, $post_id ) {
34
+	public function jsonld($jsonld, $type, $post_id) {
35 35
 
36 36
 		// @@todo add support anything that isn't a POST.
37
-		if ( Object_Type_Enum::POST !== $type ) {
37
+		if (Object_Type_Enum::POST !== $type) {
38 38
 			return $jsonld;
39 39
 		}
40 40
 
41 41
 		// Choose the dcterm property according to the post type.
42
-		$property = $this->entity_service->is_entity( $post_id )
42
+		$property = $this->entity_service->is_entity($post_id)
43 43
 			? 'http://purl.org/dc/terms/relation'
44 44
 			: 'http://purl.org/dc/terms/references';
45 45
 
46
-		$references = array_unique( $this->entity_service->get_related_entities( $post_id ) );
46
+		$references = array_unique($this->entity_service->get_related_entities($post_id));
47 47
 
48 48
 		// Bail out if there are no references.
49
-		if ( empty( $references ) ) {
49
+		if (empty($references)) {
50 50
 			return $jsonld;
51 51
 		}
52 52
 
53
-		if ( ! isset( $jsonld[0][ $property ] ) ) {
54
-			$jsonld[0][ $property ] = array();
53
+		if ( ! isset($jsonld[0][$property])) {
54
+			$jsonld[0][$property] = array();
55 55
 		}
56 56
 
57
-		if ( ! is_array( $jsonld[0][ $property ] ) ) {
58
-			$jsonld[0][ $property ] = array( $jsonld[0][ $property ] );
57
+		if ( ! is_array($jsonld[0][$property])) {
58
+			$jsonld[0][$property] = array($jsonld[0][$property]);
59 59
 		}
60 60
 
61 61
 		$that             = $this;
62 62
 		$references_array = array_values(
63 63
 			array_map(
64
-				function ( $item ) use ( $that ) {
65
-					return array( '@id' => $that->entity_service->get_uri( $item ) );
64
+				function($item) use ($that) {
65
+					return array('@id' => $that->entity_service->get_uri($item));
66 66
 				},
67 67
 				$references
68 68
 			)
69 69
 		);
70 70
 
71
-		$jsonld[0][ $property ] = array_merge( $jsonld[0][ $property ], $references_array );
71
+		$jsonld[0][$property] = array_merge($jsonld[0][$property], $references_array);
72 72
 
73 73
 		return $jsonld;
74 74
 	}
Please login to merge, or discard this patch.
src/wordlift/dataset/class-abstract-sync-hooks.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,27 +4,27 @@
 block discarded – undo
4 4
 
5 5
 abstract class Abstract_Sync_Hooks {
6 6
 
7
-	private $queue = array();
7
+    private $queue = array();
8 8
 
9
-	public function __construct() {
9
+    public function __construct() {
10 10
 
11
-		// To sync at the end of the usual WordPress lifecycle
12
-		add_action( 'shutdown', array( $this, 'shutdown' ) );
11
+        // To sync at the end of the usual WordPress lifecycle
12
+        add_action( 'shutdown', array( $this, 'shutdown' ) );
13 13
 
14
-	}
14
+    }
15 15
 
16
-	protected function enqueue( $item ) {
16
+    protected function enqueue( $item ) {
17 17
 
18
-		if ( empty( $this->queue ) || $item !== $this->queue[ count( $this->queue ) - 1 ] ) {
19
-			$this->queue[] = $item;
20
-		}
18
+        if ( empty( $this->queue ) || $item !== $this->queue[ count( $this->queue ) - 1 ] ) {
19
+            $this->queue[] = $item;
20
+        }
21 21
 
22
-	}
22
+    }
23 23
 
24
-	public function shutdown() {
25
-		foreach ( $this->queue as $callback ) {
26
-			call_user_func( array( $this, $callback[0] ), $callback[1] );
27
-		}
28
-	}
24
+    public function shutdown() {
25
+        foreach ( $this->queue as $callback ) {
26
+            call_user_func( array( $this, $callback[0] ), $callback[1] );
27
+        }
28
+    }
29 29
 
30 30
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,21 +9,21 @@
 block discarded – undo
9 9
 	public function __construct() {
10 10
 
11 11
 		// To sync at the end of the usual WordPress lifecycle
12
-		add_action( 'shutdown', array( $this, 'shutdown' ) );
12
+		add_action('shutdown', array($this, 'shutdown'));
13 13
 
14 14
 	}
15 15
 
16
-	protected function enqueue( $item ) {
16
+	protected function enqueue($item) {
17 17
 
18
-		if ( empty( $this->queue ) || $item !== $this->queue[ count( $this->queue ) - 1 ] ) {
18
+		if (empty($this->queue) || $item !== $this->queue[count($this->queue) - 1]) {
19 19
 			$this->queue[] = $item;
20 20
 		}
21 21
 
22 22
 	}
23 23
 
24 24
 	public function shutdown() {
25
-		foreach ( $this->queue as $callback ) {
26
-			call_user_func( array( $this, $callback[0] ), $callback[1] );
25
+		foreach ($this->queue as $callback) {
26
+			call_user_func(array($this, $callback[0]), $callback[1]);
27 27
 		}
28 28
 	}
29 29
 
Please login to merge, or discard this patch.
dataset/background/class-abstract-sync-background-process-state.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -4,33 +4,33 @@
 block discarded – undo
4 4
 
5 5
 abstract class Abstract_Sync_Background_Process_State implements Sync_Background_Process_State {
6 6
 
7
-	private $state;
8
-
9
-	public function __construct( $state ) {
10
-		$this->state = $state;
11
-	}
12
-
13
-	public function get_info() {
14
-		$started     = get_option( '_wl_sync_background_process_started' );
15
-		$offset      = get_option( '_wl_sync_background_process_offset' );
16
-		$stage       = get_option( '_wl_sync_background_process_stage' );
17
-		$counts      = get_option( '_wl_sync_background_process_count', array( 0 ) );
18
-		$last_update = get_option( '_wl_sync_background_process_updated' );
19
-
20
-		// Calculate the overall index by adding the count of completed stages.
21
-		$index = $offset + 1;
22
-		for ( $i = 0; $i < $stage; $i ++ ) {
23
-			$index += $counts[ $i ];
24
-		}
25
-
26
-		// Get the total count.
27
-		$total_count = array_sum( $counts );
28
-
29
-		return new Sync_Background_Process_Info( $this->state, $started, $index, $total_count, $last_update );
30
-	}
31
-
32
-	public function resume() {
33
-		// do nothing.
34
-	}
7
+    private $state;
8
+
9
+    public function __construct( $state ) {
10
+        $this->state = $state;
11
+    }
12
+
13
+    public function get_info() {
14
+        $started     = get_option( '_wl_sync_background_process_started' );
15
+        $offset      = get_option( '_wl_sync_background_process_offset' );
16
+        $stage       = get_option( '_wl_sync_background_process_stage' );
17
+        $counts      = get_option( '_wl_sync_background_process_count', array( 0 ) );
18
+        $last_update = get_option( '_wl_sync_background_process_updated' );
19
+
20
+        // Calculate the overall index by adding the count of completed stages.
21
+        $index = $offset + 1;
22
+        for ( $i = 0; $i < $stage; $i ++ ) {
23
+            $index += $counts[ $i ];
24
+        }
25
+
26
+        // Get the total count.
27
+        $total_count = array_sum( $counts );
28
+
29
+        return new Sync_Background_Process_Info( $this->state, $started, $index, $total_count, $last_update );
30
+    }
31
+
32
+    public function resume() {
33
+        // do nothing.
34
+    }
35 35
 
36 36
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@
 block discarded – undo
6 6
 
7 7
 	private $state;
8 8
 
9
-	public function __construct( $state ) {
9
+	public function __construct($state) {
10 10
 		$this->state = $state;
11 11
 	}
12 12
 
13 13
 	public function get_info() {
14
-		$started     = get_option( '_wl_sync_background_process_started' );
15
-		$offset      = get_option( '_wl_sync_background_process_offset' );
16
-		$stage       = get_option( '_wl_sync_background_process_stage' );
17
-		$counts      = get_option( '_wl_sync_background_process_count', array( 0 ) );
18
-		$last_update = get_option( '_wl_sync_background_process_updated' );
14
+		$started     = get_option('_wl_sync_background_process_started');
15
+		$offset      = get_option('_wl_sync_background_process_offset');
16
+		$stage       = get_option('_wl_sync_background_process_stage');
17
+		$counts      = get_option('_wl_sync_background_process_count', array(0));
18
+		$last_update = get_option('_wl_sync_background_process_updated');
19 19
 
20 20
 		// Calculate the overall index by adding the count of completed stages.
21 21
 		$index = $offset + 1;
22
-		for ( $i = 0; $i < $stage; $i ++ ) {
23
-			$index += $counts[ $i ];
22
+		for ($i = 0; $i < $stage; $i++) {
23
+			$index += $counts[$i];
24 24
 		}
25 25
 
26 26
 		// Get the total count.
27
-		$total_count = array_sum( $counts );
27
+		$total_count = array_sum($counts);
28 28
 
29
-		return new Sync_Background_Process_Info( $this->state, $started, $index, $total_count, $last_update );
29
+		return new Sync_Background_Process_Info($this->state, $started, $index, $total_count, $last_update);
30 30
 	}
31 31
 
32 32
 	public function resume() {
Please login to merge, or discard this patch.
src/wordlift/dataset/background/class-sync-background-process-state.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,29 +4,29 @@
 block discarded – undo
4 4
 
5 5
 interface Sync_Background_Process_State {
6 6
 
7
-	public function enter();
8
-
9
-	public function leave();
10
-
11
-	/**
12
-	 * Task
13
-	 *
14
-	 * Override this method to perform any actions required on each
15
-	 * queue item. Return the modified item for further processing
16
-	 * in the next pass through. Or, return false to remove the
17
-	 * item from the queue.
18
-	 *
19
-	 * @param mixed $item Queue item to iterate over.
20
-	 *
21
-	 * @return mixed
22
-	 */
23
-	public function task( $item );
24
-
25
-	public function get_info();
26
-
27
-	/**
28
-	 * Try to resume an interrupted task.
29
-	 */
30
-	public function resume();
7
+    public function enter();
8
+
9
+    public function leave();
10
+
11
+    /**
12
+     * Task
13
+     *
14
+     * Override this method to perform any actions required on each
15
+     * queue item. Return the modified item for further processing
16
+     * in the next pass through. Or, return false to remove the
17
+     * item from the queue.
18
+     *
19
+     * @param mixed $item Queue item to iterate over.
20
+     *
21
+     * @return mixed
22
+     */
23
+    public function task( $item );
24
+
25
+    public function get_info();
26
+
27
+    /**
28
+     * Try to resume an interrupted task.
29
+     */
30
+    public function resume();
31 31
 
32 32
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 	 *
21 21
 	 * @return mixed
22 22
 	 */
23
-	public function task( $item );
23
+	public function task($item);
24 24
 
25 25
 	public function get_info();
26 26
 
Please login to merge, or discard this patch.
dataset/background/class-sync-background-process-wpjson-endpoint.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -6,82 +6,82 @@
 block discarded – undo
6 6
 
7 7
 class Sync_Background_Process_Wpjson_Endpoint {
8 8
 
9
-	/**
10
-	 * @var Sync_Background_Process
11
-	 */
12
-	private $sync_background_process;
13
-
14
-	/**
15
-	 * Sync_Background_Process_Wpjson_Endpoint constructor.
16
-	 *
17
-	 * @param Sync_Background_Process $sync_background_process
18
-	 */
19
-	public function __construct( $sync_background_process ) {
20
-
21
-		add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
22
-
23
-		$this->sync_background_process = $sync_background_process;
24
-
25
-	}
26
-
27
-	public function rest_api_init() {
28
-
29
-		register_rest_route(
30
-			'wordlift/v1',
31
-			'/dataset/background/sync',
32
-			array(
33
-				'methods'             => WP_REST_Server::CREATABLE,
34
-				'callback'            => array( $this->sync_background_process, 'start' ),
35
-				'permission_callback' => function () {
36
-					$user = wp_get_current_user();
37
-
38
-					return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles, true );
39
-				},
40
-			)
41
-		);
42
-
43
-		register_rest_route(
44
-			'wordlift/v1',
45
-			'/dataset/background/sync',
46
-			array(
47
-				'methods'             => WP_REST_Server::READABLE,
48
-				'callback'            => array( $this->sync_background_process, 'get_info' ),
49
-				'permission_callback' => function () {
50
-					$user = wp_get_current_user();
51
-
52
-					return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles, true );
53
-				},
54
-			)
55
-		);
56
-
57
-		register_rest_route(
58
-			'wordlift/v1',
59
-			'/dataset/background/sync',
60
-			array(
61
-				'methods'             => WP_REST_Server::DELETABLE,
62
-				'callback'            => array( $this->sync_background_process, 'stop' ),
63
-				'permission_callback' => function () {
64
-					$user = wp_get_current_user();
65
-
66
-					return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles, true );
67
-				},
68
-			)
69
-		);
70
-
71
-		register_rest_route(
72
-			'wordlift/v1',
73
-			'/dataset/background/sync',
74
-			array(
75
-				'methods'             => 'PUT',
76
-				'callback'            => array( $this->sync_background_process, 'resume' ),
77
-				'permission_callback' => function () {
78
-					$user = wp_get_current_user();
79
-
80
-					return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles, true );
81
-				},
82
-			)
83
-		);
84
-
85
-	}
9
+    /**
10
+     * @var Sync_Background_Process
11
+     */
12
+    private $sync_background_process;
13
+
14
+    /**
15
+     * Sync_Background_Process_Wpjson_Endpoint constructor.
16
+     *
17
+     * @param Sync_Background_Process $sync_background_process
18
+     */
19
+    public function __construct( $sync_background_process ) {
20
+
21
+        add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
22
+
23
+        $this->sync_background_process = $sync_background_process;
24
+
25
+    }
26
+
27
+    public function rest_api_init() {
28
+
29
+        register_rest_route(
30
+            'wordlift/v1',
31
+            '/dataset/background/sync',
32
+            array(
33
+                'methods'             => WP_REST_Server::CREATABLE,
34
+                'callback'            => array( $this->sync_background_process, 'start' ),
35
+                'permission_callback' => function () {
36
+                    $user = wp_get_current_user();
37
+
38
+                    return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles, true );
39
+                },
40
+            )
41
+        );
42
+
43
+        register_rest_route(
44
+            'wordlift/v1',
45
+            '/dataset/background/sync',
46
+            array(
47
+                'methods'             => WP_REST_Server::READABLE,
48
+                'callback'            => array( $this->sync_background_process, 'get_info' ),
49
+                'permission_callback' => function () {
50
+                    $user = wp_get_current_user();
51
+
52
+                    return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles, true );
53
+                },
54
+            )
55
+        );
56
+
57
+        register_rest_route(
58
+            'wordlift/v1',
59
+            '/dataset/background/sync',
60
+            array(
61
+                'methods'             => WP_REST_Server::DELETABLE,
62
+                'callback'            => array( $this->sync_background_process, 'stop' ),
63
+                'permission_callback' => function () {
64
+                    $user = wp_get_current_user();
65
+
66
+                    return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles, true );
67
+                },
68
+            )
69
+        );
70
+
71
+        register_rest_route(
72
+            'wordlift/v1',
73
+            '/dataset/background/sync',
74
+            array(
75
+                'methods'             => 'PUT',
76
+                'callback'            => array( $this->sync_background_process, 'resume' ),
77
+                'permission_callback' => function () {
78
+                    $user = wp_get_current_user();
79
+
80
+                    return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles, true );
81
+                },
82
+            )
83
+        );
84
+
85
+    }
86 86
 
87 87
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 	 *
17 17
 	 * @param Sync_Background_Process $sync_background_process
18 18
 	 */
19
-	public function __construct( $sync_background_process ) {
19
+	public function __construct($sync_background_process) {
20 20
 
21
-		add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
21
+		add_action('rest_api_init', array($this, 'rest_api_init'));
22 22
 
23 23
 		$this->sync_background_process = $sync_background_process;
24 24
 
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 			'/dataset/background/sync',
32 32
 			array(
33 33
 				'methods'             => WP_REST_Server::CREATABLE,
34
-				'callback'            => array( $this->sync_background_process, 'start' ),
35
-				'permission_callback' => function () {
34
+				'callback'            => array($this->sync_background_process, 'start'),
35
+				'permission_callback' => function() {
36 36
 					$user = wp_get_current_user();
37 37
 
38
-					return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles, true );
38
+					return is_super_admin($user->ID) || in_array('administrator', (array) $user->roles, true);
39 39
 				},
40 40
 			)
41 41
 		);
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 			'/dataset/background/sync',
46 46
 			array(
47 47
 				'methods'             => WP_REST_Server::READABLE,
48
-				'callback'            => array( $this->sync_background_process, 'get_info' ),
49
-				'permission_callback' => function () {
48
+				'callback'            => array($this->sync_background_process, 'get_info'),
49
+				'permission_callback' => function() {
50 50
 					$user = wp_get_current_user();
51 51
 
52
-					return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles, true );
52
+					return is_super_admin($user->ID) || in_array('administrator', (array) $user->roles, true);
53 53
 				},
54 54
 			)
55 55
 		);
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 			'/dataset/background/sync',
60 60
 			array(
61 61
 				'methods'             => WP_REST_Server::DELETABLE,
62
-				'callback'            => array( $this->sync_background_process, 'stop' ),
63
-				'permission_callback' => function () {
62
+				'callback'            => array($this->sync_background_process, 'stop'),
63
+				'permission_callback' => function() {
64 64
 					$user = wp_get_current_user();
65 65
 
66
-					return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles, true );
66
+					return is_super_admin($user->ID) || in_array('administrator', (array) $user->roles, true);
67 67
 				},
68 68
 			)
69 69
 		);
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 			'/dataset/background/sync',
74 74
 			array(
75 75
 				'methods'             => 'PUT',
76
-				'callback'            => array( $this->sync_background_process, 'resume' ),
77
-				'permission_callback' => function () {
76
+				'callback'            => array($this->sync_background_process, 'resume'),
77
+				'permission_callback' => function() {
78 78
 					$user = wp_get_current_user();
79 79
 
80
-					return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles, true );
80
+					return is_super_admin($user->ID) || in_array('administrator', (array) $user->roles, true);
81 81
 				},
82 82
 			)
83 83
 		);
Please login to merge, or discard this patch.
dataset/background/stages/class-sync-background-process-terms-stage.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -7,42 +7,42 @@  discard block
 block discarded – undo
7 7
 
8 8
 class Sync_Background_Process_Terms_Stage {
9 9
 
10
-	/**
11
-	 * @var Sync_Object_Adapter_Factory
12
-	 */
13
-	private $sync_object_adapter_factory;
14
-
15
-	/**
16
-	 * Sync_Background_Process_Posts_Stage constructor.
17
-	 *
18
-	 * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory
19
-	 */
20
-	public function __construct( $sync_object_adapter_factory ) {
21
-		$this->sync_object_adapter_factory = $sync_object_adapter_factory;
22
-	}
23
-
24
-	public function count() {
25
-
26
-		$taxonomies    = get_taxonomies( array( 'public' => true ) );
27
-		$in_taxonomies = implode( "','", array_map( 'esc_sql', $taxonomies ) );
28
-
29
-		global $wpdb;
30
-		$sql = "
10
+    /**
11
+     * @var Sync_Object_Adapter_Factory
12
+     */
13
+    private $sync_object_adapter_factory;
14
+
15
+    /**
16
+     * Sync_Background_Process_Posts_Stage constructor.
17
+     *
18
+     * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory
19
+     */
20
+    public function __construct( $sync_object_adapter_factory ) {
21
+        $this->sync_object_adapter_factory = $sync_object_adapter_factory;
22
+    }
23
+
24
+    public function count() {
25
+
26
+        $taxonomies    = get_taxonomies( array( 'public' => true ) );
27
+        $in_taxonomies = implode( "','", array_map( 'esc_sql', $taxonomies ) );
28
+
29
+        global $wpdb;
30
+        $sql = "
31 31
 			SELECT COUNT( 1 )
32 32
 			FROM $wpdb->term_taxonomy
33 33
 			WHERE taxonomy IN ('$in_taxonomies')
34 34
 			";
35 35
 
36
-		return $wpdb->get_var( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
37
-	}
36
+        return $wpdb->get_var( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
37
+    }
38 38
 
39
-	public function get_sync_object_adapters( $offset, $limit ) {
39
+    public function get_sync_object_adapters( $offset, $limit ) {
40 40
 
41
-		$taxonomies    = get_taxonomies( array( 'public' => true ) );
42
-		$in_taxonomies = implode( "','", array_map( 'esc_sql', $taxonomies ) );
41
+        $taxonomies    = get_taxonomies( array( 'public' => true ) );
42
+        $in_taxonomies = implode( "','", array_map( 'esc_sql', $taxonomies ) );
43 43
 
44
-		global $wpdb;
45
-		$sql = "
44
+        global $wpdb;
45
+        $sql = "
46 46
 			SELECT term_id
47 47
 			FROM $wpdb->term_taxonomy
48 48
 		    WHERE taxonomy IN ('$in_taxonomies')
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 			LIMIT %d, %d
51 51
 			";
52 52
 
53
-		$ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
53
+        $ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
54 54
 
55
-		return $this->sync_object_adapter_factory->create_many( Object_Type_Enum::TERM, $ids );
56
-	}
55
+        return $this->sync_object_adapter_factory->create_many( Object_Type_Enum::TERM, $ids );
56
+    }
57 57
 
58 58
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory
19 19
 	 */
20
-	public function __construct( $sync_object_adapter_factory ) {
20
+	public function __construct($sync_object_adapter_factory) {
21 21
 		$this->sync_object_adapter_factory = $sync_object_adapter_factory;
22 22
 	}
23 23
 
24 24
 	public function count() {
25 25
 
26
-		$taxonomies    = get_taxonomies( array( 'public' => true ) );
27
-		$in_taxonomies = implode( "','", array_map( 'esc_sql', $taxonomies ) );
26
+		$taxonomies    = get_taxonomies(array('public' => true));
27
+		$in_taxonomies = implode("','", array_map('esc_sql', $taxonomies));
28 28
 
29 29
 		global $wpdb;
30 30
 		$sql = "
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
 			WHERE taxonomy IN ('$in_taxonomies')
34 34
 			";
35 35
 
36
-		return $wpdb->get_var( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
36
+		return $wpdb->get_var($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
37 37
 	}
38 38
 
39
-	public function get_sync_object_adapters( $offset, $limit ) {
39
+	public function get_sync_object_adapters($offset, $limit) {
40 40
 
41
-		$taxonomies    = get_taxonomies( array( 'public' => true ) );
42
-		$in_taxonomies = implode( "','", array_map( 'esc_sql', $taxonomies ) );
41
+		$taxonomies    = get_taxonomies(array('public' => true));
42
+		$in_taxonomies = implode("','", array_map('esc_sql', $taxonomies));
43 43
 
44 44
 		global $wpdb;
45 45
 		$sql = "
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 			LIMIT %d, %d
51 51
 			";
52 52
 
53
-		$ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
53
+		$ids = $wpdb->get_col($wpdb->prepare($sql, $offset, $limit)); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
54 54
 
55
-		return $this->sync_object_adapter_factory->create_many( Object_Type_Enum::TERM, $ids );
55
+		return $this->sync_object_adapter_factory->create_many(Object_Type_Enum::TERM, $ids);
56 56
 	}
57 57
 
58 58
 }
Please login to merge, or discard this patch.
dataset/background/stages/class-sync-background-process-posts-stage.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -8,49 +8,49 @@  discard block
 block discarded – undo
8 8
 
9 9
 class Sync_Background_Process_Posts_Stage {
10 10
 
11
-	/**
12
-	 * @var Sync_Object_Adapter_Factory
13
-	 */
14
-	private $sync_object_adapter_factory;
11
+    /**
12
+     * @var Sync_Object_Adapter_Factory
13
+     */
14
+    private $sync_object_adapter_factory;
15 15
 
16
-	/**
17
-	 * Sync_Background_Process_Posts_Stage constructor.
18
-	 *
19
-	 * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory
20
-	 */
21
-	public function __construct( $sync_object_adapter_factory ) {
22
-		$this->sync_object_adapter_factory = $sync_object_adapter_factory;
23
-	}
16
+    /**
17
+     * Sync_Background_Process_Posts_Stage constructor.
18
+     *
19
+     * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory
20
+     */
21
+    public function __construct( $sync_object_adapter_factory ) {
22
+        $this->sync_object_adapter_factory = $sync_object_adapter_factory;
23
+    }
24 24
 
25
-	public function count() {
25
+    public function count() {
26 26
 
27
-		$post_types = get_post_types( array( 'public' => true ) );
27
+        $post_types = get_post_types( array( 'public' => true ) );
28 28
 
29
-		global $wpdb;
30
-		$in_post_type = implode( "','", array_map( 'esc_sql', $post_types ) );
31
-		$sql          = "
29
+        global $wpdb;
30
+        $in_post_type = implode( "','", array_map( 'esc_sql', $post_types ) );
31
+        $sql          = "
32 32
 			SELECT COUNT( 1 )
33 33
 			FROM $wpdb->posts
34 34
 			WHERE post_type IN ('$in_post_type')
35 35
 				AND post_status IN ( 'publish',  'future', 'draft', 'pending', 'private' )
36 36
 			";
37 37
 
38
-		return $wpdb->get_var( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
39
-	}
38
+        return $wpdb->get_var( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
39
+    }
40 40
 
41
-	/**
42
-	 * @param int $offset
43
-	 * @param int $limit
44
-	 *
45
-	 * @return Sync_Object_Adapter[]
46
-	 */
47
-	public function get_sync_object_adapters( $offset, $limit ) {
41
+    /**
42
+     * @param int $offset
43
+     * @param int $limit
44
+     *
45
+     * @return Sync_Object_Adapter[]
46
+     */
47
+    public function get_sync_object_adapters( $offset, $limit ) {
48 48
 
49
-		$post_types = get_post_types( array( 'public' => true ) );
49
+        $post_types = get_post_types( array( 'public' => true ) );
50 50
 
51
-		global $wpdb;
52
-		$in_post_type = implode( "','", array_map( 'esc_sql', $post_types ) );
53
-		$sql          = "
51
+        global $wpdb;
52
+        $in_post_type = implode( "','", array_map( 'esc_sql', $post_types ) );
53
+        $sql          = "
54 54
 			SELECT ID
55 55
 			FROM $wpdb->posts
56 56
 			WHERE post_type IN ('$in_post_type')
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 			LIMIT %d, %d
60 60
 			";
61 61
 
62
-		$ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
62
+        $ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
63 63
 
64
-		return $this->sync_object_adapter_factory
65
-			->create_many( Object_Type_Enum::POST, array_map( 'intval', $ids ) );
66
-	}
64
+        return $this->sync_object_adapter_factory
65
+            ->create_many( Object_Type_Enum::POST, array_map( 'intval', $ids ) );
66
+    }
67 67
 
68 68
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -18,16 +18,16 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory
20 20
 	 */
21
-	public function __construct( $sync_object_adapter_factory ) {
21
+	public function __construct($sync_object_adapter_factory) {
22 22
 		$this->sync_object_adapter_factory = $sync_object_adapter_factory;
23 23
 	}
24 24
 
25 25
 	public function count() {
26 26
 
27
-		$post_types = get_post_types( array( 'public' => true ) );
27
+		$post_types = get_post_types(array('public' => true));
28 28
 
29 29
 		global $wpdb;
30
-		$in_post_type = implode( "','", array_map( 'esc_sql', $post_types ) );
30
+		$in_post_type = implode("','", array_map('esc_sql', $post_types));
31 31
 		$sql          = "
32 32
 			SELECT COUNT( 1 )
33 33
 			FROM $wpdb->posts
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 				AND post_status IN ( 'publish',  'future', 'draft', 'pending', 'private' )
36 36
 			";
37 37
 
38
-		return $wpdb->get_var( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
38
+		return $wpdb->get_var($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
39 39
 	}
40 40
 
41 41
 	/**
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 	 *
45 45
 	 * @return Sync_Object_Adapter[]
46 46
 	 */
47
-	public function get_sync_object_adapters( $offset, $limit ) {
47
+	public function get_sync_object_adapters($offset, $limit) {
48 48
 
49
-		$post_types = get_post_types( array( 'public' => true ) );
49
+		$post_types = get_post_types(array('public' => true));
50 50
 
51 51
 		global $wpdb;
52
-		$in_post_type = implode( "','", array_map( 'esc_sql', $post_types ) );
52
+		$in_post_type = implode("','", array_map('esc_sql', $post_types));
53 53
 		$sql          = "
54 54
 			SELECT ID
55 55
 			FROM $wpdb->posts
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 			LIMIT %d, %d
60 60
 			";
61 61
 
62
-		$ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
62
+		$ids = $wpdb->get_col($wpdb->prepare($sql, $offset, $limit)); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
63 63
 
64 64
 		return $this->sync_object_adapter_factory
65
-			->create_many( Object_Type_Enum::POST, array_map( 'intval', $ids ) );
65
+			->create_many(Object_Type_Enum::POST, array_map('intval', $ids));
66 66
 	}
67 67
 
68 68
 }
Please login to merge, or discard this patch.
dataset/background/stages/class-sync-background-process-users-stage.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -7,39 +7,39 @@  discard block
 block discarded – undo
7 7
 
8 8
 class Sync_Background_Process_Users_Stage {
9 9
 
10
-	/**
11
-	 * @var Sync_Object_Adapter_Factory
12
-	 */
13
-	private $sync_object_adapter_factory;
10
+    /**
11
+     * @var Sync_Object_Adapter_Factory
12
+     */
13
+    private $sync_object_adapter_factory;
14 14
 
15
-	/**
16
-	 * Sync_Background_Process_Posts_Stage constructor.
17
-	 *
18
-	 * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory
19
-	 */
20
-	public function __construct( $sync_object_adapter_factory ) {
21
-		$this->sync_object_adapter_factory = $sync_object_adapter_factory;
22
-	}
15
+    /**
16
+     * Sync_Background_Process_Posts_Stage constructor.
17
+     *
18
+     * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory
19
+     */
20
+    public function __construct( $sync_object_adapter_factory ) {
21
+        $this->sync_object_adapter_factory = $sync_object_adapter_factory;
22
+    }
23 23
 
24
-	public function count() {
24
+    public function count() {
25 25
 
26
-		global $wpdb;
27
-		$in_post_type = $this->get_post_types_string();
28
-		$sql          = "
26
+        global $wpdb;
27
+        $in_post_type = $this->get_post_types_string();
28
+        $sql          = "
29 29
 			SELECT COUNT( DISTINCT post_author )
30 30
 			FROM $wpdb->posts
31 31
 			WHERE post_type IN ('$in_post_type')
32 32
 			AND post_status IN ( 'publish',  'future', 'draft', 'pending', 'private' )
33 33
 			";
34 34
 
35
-		return $wpdb->get_var( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
36
-	}
35
+        return $wpdb->get_var( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
36
+    }
37 37
 
38
-	public function get_sync_object_adapters( $offset, $limit ) {
38
+    public function get_sync_object_adapters( $offset, $limit ) {
39 39
 
40
-		global $wpdb;
41
-		$in_post_type = $this->get_post_types_string();
42
-		$sql          = "
40
+        global $wpdb;
41
+        $in_post_type = $this->get_post_types_string();
42
+        $sql          = "
43 43
 			SELECT DISTINCT post_author
44 44
 			FROM $wpdb->posts
45 45
 			WHERE post_type IN ('$in_post_type')
@@ -47,18 +47,18 @@  discard block
 block discarded – undo
47 47
 			LIMIT %d, %d
48 48
 			";
49 49
 
50
-		$ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
50
+        $ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
51 51
 
52
-		return $this->sync_object_adapter_factory->create_many( Object_Type_Enum::USER, $ids );
53
-	}
52
+        return $this->sync_object_adapter_factory->create_many( Object_Type_Enum::USER, $ids );
53
+    }
54 54
 
55
-	/**
56
-	 * @return string
57
-	 */
58
-	protected function get_post_types_string() {
59
-		$post_types = get_post_types( array( 'public' => true ) );
55
+    /**
56
+     * @return string
57
+     */
58
+    protected function get_post_types_string() {
59
+        $post_types = get_post_types( array( 'public' => true ) );
60 60
 
61
-		return implode( "','", array_map( 'esc_sql', $post_types ) );
62
-	}
61
+        return implode( "','", array_map( 'esc_sql', $post_types ) );
62
+    }
63 63
 
64 64
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory
19 19
 	 */
20
-	public function __construct( $sync_object_adapter_factory ) {
20
+	public function __construct($sync_object_adapter_factory) {
21 21
 		$this->sync_object_adapter_factory = $sync_object_adapter_factory;
22 22
 	}
23 23
 
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 			AND post_status IN ( 'publish',  'future', 'draft', 'pending', 'private' )
33 33
 			";
34 34
 
35
-		return $wpdb->get_var( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
35
+		return $wpdb->get_var($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
36 36
 	}
37 37
 
38
-	public function get_sync_object_adapters( $offset, $limit ) {
38
+	public function get_sync_object_adapters($offset, $limit) {
39 39
 
40 40
 		global $wpdb;
41 41
 		$in_post_type = $this->get_post_types_string();
@@ -47,18 +47,18 @@  discard block
 block discarded – undo
47 47
 			LIMIT %d, %d
48 48
 			";
49 49
 
50
-		$ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
50
+		$ids = $wpdb->get_col($wpdb->prepare($sql, $offset, $limit)); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
51 51
 
52
-		return $this->sync_object_adapter_factory->create_many( Object_Type_Enum::USER, $ids );
52
+		return $this->sync_object_adapter_factory->create_many(Object_Type_Enum::USER, $ids);
53 53
 	}
54 54
 
55 55
 	/**
56 56
 	 * @return string
57 57
 	 */
58 58
 	protected function get_post_types_string() {
59
-		$post_types = get_post_types( array( 'public' => true ) );
59
+		$post_types = get_post_types(array('public' => true));
60 60
 
61
-		return implode( "','", array_map( 'esc_sql', $post_types ) );
61
+		return implode("','", array_map('esc_sql', $post_types));
62 62
 	}
63 63
 
64 64
 }
Please login to merge, or discard this patch.
src/wordlift/dataset/background/stages/class-sync-background-stage.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 
5 5
 interface Sync_Background_Process_Stage {
6 6
 
7
-	public function count();
7
+    public function count();
8 8
 
9
-	public function get_sync_object_adapters( $offset, $batch_size );
9
+    public function get_sync_object_adapters( $offset, $batch_size );
10 10
 
11 11
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,6 +6,6 @@
 block discarded – undo
6 6
 
7 7
 	public function count();
8 8
 
9
-	public function get_sync_object_adapters( $offset, $batch_size );
9
+	public function get_sync_object_adapters($offset, $batch_size);
10 10
 
11 11
 }
Please login to merge, or discard this patch.