Completed
Push — develop ( da88bb...920195 )
by
unknown
09:07 queued 05:56
created
wordlift/dataset/background/class-sync-background-process-stopped-state.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -9,6 +9,9 @@
 block discarded – undo
9 9
 	 */
10 10
 	private $context;
11 11
 
12
+	/**
13
+	 * @param Sync_Background_Process $context
14
+	 */
12 15
 	function __construct( $context ) {
13 16
 		parent::__construct( Sync_Background_Process::STATE_STOPPED );
14 17
 
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -4,30 +4,30 @@
 block discarded – undo
4 4
 
5 5
 class Sync_Background_Process_Stopped_State extends Abstract_Sync_Background_Process_State {
6 6
 
7
-	/**
8
-	 * @var Sync_Background_Process
9
-	 */
10
-	private $context;
7
+    /**
8
+     * @var Sync_Background_Process
9
+     */
10
+    private $context;
11 11
 
12
-	function __construct( $context ) {
13
-		parent::__construct( Sync_Background_Process::STATE_STOPPED );
12
+    function __construct( $context ) {
13
+        parent::__construct( Sync_Background_Process::STATE_STOPPED );
14 14
 
15
-		$this->context = $context;
16
-	}
15
+        $this->context = $context;
16
+    }
17 17
 
18
-	function enter() {
19
-		$this->context->set_state( Sync_Background_Process::STATE_STOPPED );
20
-	}
18
+    function enter() {
19
+        $this->context->set_state( Sync_Background_Process::STATE_STOPPED );
20
+    }
21 21
 
22
-	function leave() {
23
-		$this->context->set_state( null );
24
-	}
22
+    function leave() {
23
+        $this->context->set_state( null );
24
+    }
25 25
 
26
-	function task( $item ) {
26
+    function task( $item ) {
27 27
 
28
-		$this->context->cancel_process();
28
+        $this->context->cancel_process();
29 29
 
30
-		return false;
31
-	}
30
+        return false;
31
+    }
32 32
 
33 33
 }
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
 	 */
10 10
 	private $context;
11 11
 
12
-	function __construct( $context ) {
13
-		parent::__construct( Sync_Background_Process::STATE_STOPPED );
12
+	function __construct($context) {
13
+		parent::__construct(Sync_Background_Process::STATE_STOPPED);
14 14
 
15 15
 		$this->context = $context;
16 16
 	}
17 17
 
18 18
 	function enter() {
19
-		$this->context->set_state( Sync_Background_Process::STATE_STOPPED );
19
+		$this->context->set_state(Sync_Background_Process::STATE_STOPPED);
20 20
 	}
21 21
 
22 22
 	function leave() {
23
-		$this->context->set_state( null );
23
+		$this->context->set_state(null);
24 24
 	}
25 25
 
26
-	function task( $item ) {
26
+	function task($item) {
27 27
 
28 28
 		$this->context->cancel_process();
29 29
 
Please login to merge, or discard this patch.
src/wordlift/cache/class-ttl-cache.php 2 patches
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -17,177 +17,177 @@
 block discarded – undo
17 17
 // @@todo: add a hook to clear the cached files now and then.
18 18
 class Ttl_Cache {
19 19
 
20
-	/**
21
-	 * The cache name.
22
-	 *
23
-	 * @var string $name The cache name.
24
-	 * @access private
25
-	 * @since 3.21.2
26
-	 */
27
-	private $name;
28
-
29
-	/**
30
-	 * The TTL of cached responses in seconds.
31
-	 *
32
-	 * @var int $ttl The TTL in seconds.
33
-	 * @access private
34
-	 * @since 3.21.2
35
-	 */
36
-	private $ttl;
37
-
38
-	/**
39
-	 * The cache dir where the cached data is written.
40
-	 *
41
-	 * @since 3.21.2
42
-	 * @access private
43
-	 * @var string $cache_dir The cache dir where the cached responses are written.
44
-	 */
45
-	private $cache_dir;
46
-
47
-	/**
48
-	 * A {@link Wordlift_Log_Service} instance.
49
-	 *
50
-	 * @var Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
51
-	 * @access private
52
-	 * @since 3.21.2
53
-	 */
54
-	private $log;
55
-
56
-	/**
57
-	 * @var array
58
-	 */
59
-	private static $caches = array();
60
-
61
-	/**
62
-	 * Create a {@link Ttl_Cache} with the specified TTL, default 900 secs.
63
-	 *
64
-	 * @param string $name The cache name.
65
-	 * @param int $ttl The cache TTL, default 900 secs.
66
-	 *
67
-	 * @since 3.21.2
68
-	 */
69
-	public function __construct( $name, $ttl = 900 ) {
70
-
71
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
72
-
73
-		$this->name = $name;
74
-		$this->ttl  = $ttl;
75
-
76
-		$this->cache_dir = self::get_cache_folder() . DIRECTORY_SEPARATOR . md5( $name );
77
-
78
-		$this->log->trace( "Creating the cache folder {$this->cache_dir}..." );
79
-		wp_mkdir_p( $this->cache_dir );
80
-
81
-		self::$caches[ $name ] = $this;
82
-
83
-	}
84
-
85
-	/**
86
-	 * Get the root cache folder.
87
-	 *
88
-	 * This is useful to introduce a cache cleaning procedure which will scan and delete older stale cache files.
89
-	 *
90
-	 * @return string The root cache folder.
91
-	 * @since 3.22.5
92
-	 */
93
-	public static function get_cache_folder() {
94
-
95
-		// Get the temp dir and add the directory separator if missing.
96
-		$temp_dir = get_temp_dir();
97
-		if ( DIRECTORY_SEPARATOR !== substr( $temp_dir, - strlen( DIRECTORY_SEPARATOR ) ) ) {
98
-			$temp_dir .= DIRECTORY_SEPARATOR;
99
-		}
100
-
101
-		return $temp_dir . 'wl.cache' . DIRECTORY_SEPARATOR . md5( home_url() );
102
-	}
103
-
104
-	/**
105
-	 * Get the cached data for the specified key.
106
-	 *
107
-	 * @param mixed $key A serializable key.
108
-	 *
109
-	 * @return mixed|null
110
-	 * @since 3.21.2
111
-	 */
112
-	public function get( $key ) {
113
-
114
-		$filename = $this->get_filename( $key );
115
-
116
-		// If the cache file exists and it's not too old, then return it.
117
-		if ( file_exists( $filename ) && $this->ttl >= time() - filemtime( $filename ) ) {
118
-			$this->log->trace( "Cache HIT.\n" );
119
-
120
-			return json_decode( file_get_contents( $filename ), true );
121
-		}
122
-
123
-		$this->log->trace( "Cache MISS, filename $filename.\n" );
124
-
125
-		return null;
126
-	}
127
-
128
-	public function put( $key, $data ) {
129
-
130
-		$filename = $this->get_filename( $key );
131
-
132
-		// Cache.
133
-		if ( file_exists( $filename ) ) {
134
-			@unlink( $filename );
135
-		}
136
-		@file_put_contents( $filename, wp_json_encode( $data ) );
20
+    /**
21
+     * The cache name.
22
+     *
23
+     * @var string $name The cache name.
24
+     * @access private
25
+     * @since 3.21.2
26
+     */
27
+    private $name;
28
+
29
+    /**
30
+     * The TTL of cached responses in seconds.
31
+     *
32
+     * @var int $ttl The TTL in seconds.
33
+     * @access private
34
+     * @since 3.21.2
35
+     */
36
+    private $ttl;
37
+
38
+    /**
39
+     * The cache dir where the cached data is written.
40
+     *
41
+     * @since 3.21.2
42
+     * @access private
43
+     * @var string $cache_dir The cache dir where the cached responses are written.
44
+     */
45
+    private $cache_dir;
46
+
47
+    /**
48
+     * A {@link Wordlift_Log_Service} instance.
49
+     *
50
+     * @var Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
51
+     * @access private
52
+     * @since 3.21.2
53
+     */
54
+    private $log;
55
+
56
+    /**
57
+     * @var array
58
+     */
59
+    private static $caches = array();
60
+
61
+    /**
62
+     * Create a {@link Ttl_Cache} with the specified TTL, default 900 secs.
63
+     *
64
+     * @param string $name The cache name.
65
+     * @param int $ttl The cache TTL, default 900 secs.
66
+     *
67
+     * @since 3.21.2
68
+     */
69
+    public function __construct( $name, $ttl = 900 ) {
70
+
71
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
72
+
73
+        $this->name = $name;
74
+        $this->ttl  = $ttl;
75
+
76
+        $this->cache_dir = self::get_cache_folder() . DIRECTORY_SEPARATOR . md5( $name );
77
+
78
+        $this->log->trace( "Creating the cache folder {$this->cache_dir}..." );
79
+        wp_mkdir_p( $this->cache_dir );
80
+
81
+        self::$caches[ $name ] = $this;
82
+
83
+    }
84
+
85
+    /**
86
+     * Get the root cache folder.
87
+     *
88
+     * This is useful to introduce a cache cleaning procedure which will scan and delete older stale cache files.
89
+     *
90
+     * @return string The root cache folder.
91
+     * @since 3.22.5
92
+     */
93
+    public static function get_cache_folder() {
94
+
95
+        // Get the temp dir and add the directory separator if missing.
96
+        $temp_dir = get_temp_dir();
97
+        if ( DIRECTORY_SEPARATOR !== substr( $temp_dir, - strlen( DIRECTORY_SEPARATOR ) ) ) {
98
+            $temp_dir .= DIRECTORY_SEPARATOR;
99
+        }
100
+
101
+        return $temp_dir . 'wl.cache' . DIRECTORY_SEPARATOR . md5( home_url() );
102
+    }
103
+
104
+    /**
105
+     * Get the cached data for the specified key.
106
+     *
107
+     * @param mixed $key A serializable key.
108
+     *
109
+     * @return mixed|null
110
+     * @since 3.21.2
111
+     */
112
+    public function get( $key ) {
113
+
114
+        $filename = $this->get_filename( $key );
115
+
116
+        // If the cache file exists and it's not too old, then return it.
117
+        if ( file_exists( $filename ) && $this->ttl >= time() - filemtime( $filename ) ) {
118
+            $this->log->trace( "Cache HIT.\n" );
119
+
120
+            return json_decode( file_get_contents( $filename ), true );
121
+        }
122
+
123
+        $this->log->trace( "Cache MISS, filename $filename.\n" );
124
+
125
+        return null;
126
+    }
127
+
128
+    public function put( $key, $data ) {
129
+
130
+        $filename = $this->get_filename( $key );
131
+
132
+        // Cache.
133
+        if ( file_exists( $filename ) ) {
134
+            @unlink( $filename );
135
+        }
136
+        @file_put_contents( $filename, wp_json_encode( $data ) );
137 137
 
138
-	}
139
-
140
-	public function delete( $key ) {
138
+    }
139
+
140
+    public function delete( $key ) {
141 141
 
142
-		$filename = $this->get_filename( $key );
142
+        $filename = $this->get_filename( $key );
143 143
 
144
-		// Delete.
145
-		if ( file_exists( $filename ) ) {
146
-			@unlink( $filename );
147
-		}
144
+        // Delete.
145
+        if ( file_exists( $filename ) ) {
146
+            @unlink( $filename );
147
+        }
148 148
 
149
-	}
149
+    }
150 150
 
151
-	public function flush() {
151
+    public function flush() {
152 152
 
153
-		$files = glob( $this->cache_dir . DIRECTORY_SEPARATOR . '*' );
154
-		foreach ( $files as $file ) { // iterate files
155
-			if ( is_file( $file ) ) {
156
-				@unlink( $file );
157
-			}
158
-		}
153
+        $files = glob( $this->cache_dir . DIRECTORY_SEPARATOR . '*' );
154
+        foreach ( $files as $file ) { // iterate files
155
+            if ( is_file( $file ) ) {
156
+                @unlink( $file );
157
+            }
158
+        }
159 159
 
160
-	}
160
+    }
161 161
 
162
-	public static function flush_all() {
162
+    public static function flush_all() {
163 163
 
164
-		/** @var Ttl_Cache $cache */
165
-		foreach ( self::$caches as $cache ) {
166
-			$cache->flush();
167
-		}
164
+        /** @var Ttl_Cache $cache */
165
+        foreach ( self::$caches as $cache ) {
166
+            $cache->flush();
167
+        }
168 168
 
169
-	}
169
+    }
170 170
 
171
-	/**
172
-	 * Get the full path for the given `$hash`. The file is not checked for its existence.
173
-	 *
174
-	 * @param string $hash A file hash.
175
-	 *
176
-	 * @return string The full path to the file.
177
-	 * @since 3.21.2
178
-	 */
179
-	private function get_path( $hash ) {
171
+    /**
172
+     * Get the full path for the given `$hash`. The file is not checked for its existence.
173
+     *
174
+     * @param string $hash A file hash.
175
+     *
176
+     * @return string The full path to the file.
177
+     * @since 3.21.2
178
+     */
179
+    private function get_path( $hash ) {
180 180
 
181
-		return $this->cache_dir . DIRECTORY_SEPARATOR . $hash;
182
-	}
181
+        return $this->cache_dir . DIRECTORY_SEPARATOR . $hash;
182
+    }
183 183
 
184
-	private function get_filename( $key ) {
184
+    private function get_filename( $key ) {
185 185
 
186
-		// Create a hash and a path to the cache file.
187
-		$hash     = md5( json_encode( $key ) );
188
-		$filename = $this->get_path( $hash );
186
+        // Create a hash and a path to the cache file.
187
+        $hash     = md5( json_encode( $key ) );
188
+        $filename = $this->get_path( $hash );
189 189
 
190
-		return $filename;
191
-	}
190
+        return $filename;
191
+    }
192 192
 
193 193
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -66,19 +66,19 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @since 3.21.2
68 68
 	 */
69
-	public function __construct( $name, $ttl = 900 ) {
69
+	public function __construct($name, $ttl = 900) {
70 70
 
71
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
71
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
72 72
 
73 73
 		$this->name = $name;
74 74
 		$this->ttl  = $ttl;
75 75
 
76
-		$this->cache_dir = self::get_cache_folder() . DIRECTORY_SEPARATOR . md5( $name );
76
+		$this->cache_dir = self::get_cache_folder().DIRECTORY_SEPARATOR.md5($name);
77 77
 
78
-		$this->log->trace( "Creating the cache folder {$this->cache_dir}..." );
79
-		wp_mkdir_p( $this->cache_dir );
78
+		$this->log->trace("Creating the cache folder {$this->cache_dir}...");
79
+		wp_mkdir_p($this->cache_dir);
80 80
 
81
-		self::$caches[ $name ] = $this;
81
+		self::$caches[$name] = $this;
82 82
 
83 83
 	}
84 84
 
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 
95 95
 		// Get the temp dir and add the directory separator if missing.
96 96
 		$temp_dir = get_temp_dir();
97
-		if ( DIRECTORY_SEPARATOR !== substr( $temp_dir, - strlen( DIRECTORY_SEPARATOR ) ) ) {
97
+		if (DIRECTORY_SEPARATOR !== substr($temp_dir, - strlen(DIRECTORY_SEPARATOR))) {
98 98
 			$temp_dir .= DIRECTORY_SEPARATOR;
99 99
 		}
100 100
 
101
-		return $temp_dir . 'wl.cache' . DIRECTORY_SEPARATOR . md5( home_url() );
101
+		return $temp_dir.'wl.cache'.DIRECTORY_SEPARATOR.md5(home_url());
102 102
 	}
103 103
 
104 104
 	/**
@@ -109,51 +109,51 @@  discard block
 block discarded – undo
109 109
 	 * @return mixed|null
110 110
 	 * @since 3.21.2
111 111
 	 */
112
-	public function get( $key ) {
112
+	public function get($key) {
113 113
 
114
-		$filename = $this->get_filename( $key );
114
+		$filename = $this->get_filename($key);
115 115
 
116 116
 		// If the cache file exists and it's not too old, then return it.
117
-		if ( file_exists( $filename ) && $this->ttl >= time() - filemtime( $filename ) ) {
118
-			$this->log->trace( "Cache HIT.\n" );
117
+		if (file_exists($filename) && $this->ttl >= time() - filemtime($filename)) {
118
+			$this->log->trace("Cache HIT.\n");
119 119
 
120
-			return json_decode( file_get_contents( $filename ), true );
120
+			return json_decode(file_get_contents($filename), true);
121 121
 		}
122 122
 
123
-		$this->log->trace( "Cache MISS, filename $filename.\n" );
123
+		$this->log->trace("Cache MISS, filename $filename.\n");
124 124
 
125 125
 		return null;
126 126
 	}
127 127
 
128
-	public function put( $key, $data ) {
128
+	public function put($key, $data) {
129 129
 
130
-		$filename = $this->get_filename( $key );
130
+		$filename = $this->get_filename($key);
131 131
 
132 132
 		// Cache.
133
-		if ( file_exists( $filename ) ) {
134
-			@unlink( $filename );
133
+		if (file_exists($filename)) {
134
+			@unlink($filename);
135 135
 		}
136
-		@file_put_contents( $filename, wp_json_encode( $data ) );
136
+		@file_put_contents($filename, wp_json_encode($data));
137 137
 
138 138
 	}
139 139
 
140
-	public function delete( $key ) {
140
+	public function delete($key) {
141 141
 
142
-		$filename = $this->get_filename( $key );
142
+		$filename = $this->get_filename($key);
143 143
 
144 144
 		// Delete.
145
-		if ( file_exists( $filename ) ) {
146
-			@unlink( $filename );
145
+		if (file_exists($filename)) {
146
+			@unlink($filename);
147 147
 		}
148 148
 
149 149
 	}
150 150
 
151 151
 	public function flush() {
152 152
 
153
-		$files = glob( $this->cache_dir . DIRECTORY_SEPARATOR . '*' );
154
-		foreach ( $files as $file ) { // iterate files
155
-			if ( is_file( $file ) ) {
156
-				@unlink( $file );
153
+		$files = glob($this->cache_dir.DIRECTORY_SEPARATOR.'*');
154
+		foreach ($files as $file) { // iterate files
155
+			if (is_file($file)) {
156
+				@unlink($file);
157 157
 			}
158 158
 		}
159 159
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	public static function flush_all() {
163 163
 
164 164
 		/** @var Ttl_Cache $cache */
165
-		foreach ( self::$caches as $cache ) {
165
+		foreach (self::$caches as $cache) {
166 166
 			$cache->flush();
167 167
 		}
168 168
 
@@ -176,16 +176,16 @@  discard block
 block discarded – undo
176 176
 	 * @return string The full path to the file.
177 177
 	 * @since 3.21.2
178 178
 	 */
179
-	private function get_path( $hash ) {
179
+	private function get_path($hash) {
180 180
 
181
-		return $this->cache_dir . DIRECTORY_SEPARATOR . $hash;
181
+		return $this->cache_dir.DIRECTORY_SEPARATOR.$hash;
182 182
 	}
183 183
 
184
-	private function get_filename( $key ) {
184
+	private function get_filename($key) {
185 185
 
186 186
 		// Create a hash and a path to the cache file.
187
-		$hash     = md5( json_encode( $key ) );
188
-		$filename = $this->get_path( $hash );
187
+		$hash     = md5(json_encode($key));
188
+		$filename = $this->get_path($hash);
189 189
 
190 190
 		return $filename;
191 191
 	}
Please login to merge, or discard this patch.
src/wordlift/dataset/index.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -12,31 +12,31 @@
 block discarded – undo
12 12
 use Wordlift\Jsonld\Jsonld_Service;
13 13
 
14 14
 if ( ! defined( 'ABSPATH' ) ) {
15
-	exit;
15
+    exit;
16 16
 }
17 17
 // Register the Dataset JSON Endpoint. The `$api_service` variable must be defined in the calling file (wordlift.php).
18 18
 if ( apply_filters( 'wl_feature__enable__dataset-ng', false ) ) {
19 19
 
20
-	$sync_object_adapter_factory = new Sync_Object_Adapter_Factory();
21
-	$sync_service                = new Sync_Service( $api_service, $sync_object_adapter_factory, Jsonld_Service::get_instance(), Wordlift_Entity_Service::get_instance() );
22
-	new Sync_Post_Hooks( $sync_service, $sync_object_adapter_factory );
23
-	new Sync_User_Hooks( $sync_service );
20
+    $sync_object_adapter_factory = new Sync_Object_Adapter_Factory();
21
+    $sync_service                = new Sync_Service( $api_service, $sync_object_adapter_factory, Jsonld_Service::get_instance(), Wordlift_Entity_Service::get_instance() );
22
+    new Sync_Post_Hooks( $sync_service, $sync_object_adapter_factory );
23
+    new Sync_User_Hooks( $sync_service );
24 24
 
25
-	/**
26
-	 * @since 3.28.0
27
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/1186
28
-	 */
29
-	new Sync_Hooks_Entity_Relation( Wordlift_Entity_Service::get_instance() );
25
+    /**
26
+     * @since 3.28.0
27
+     * @see https://github.com/insideout10/wordlift-plugin/issues/1186
28
+     */
29
+    new Sync_Hooks_Entity_Relation( Wordlift_Entity_Service::get_instance() );
30 30
 
31
-	if ( apply_filters( 'wl_feature__enable__wordpress-ontology', false ) ) {
32
-		new Sync_Hooks_Wordpress_Ontology();
33
-	}
31
+    if ( apply_filters( 'wl_feature__enable__wordpress-ontology', false ) ) {
32
+        new Sync_Hooks_Wordpress_Ontology();
33
+    }
34 34
 
35
-	if ( apply_filters( 'wl_feature__enable__sync-background', false ) ) {
36
-		// Set up the sync background process.
37
-		$sync_background_process = new Sync_Background_Process( $sync_service, $sync_object_adapter_factory );
38
-		new Sync_Background_Process_Wpjson_Endpoint( $sync_background_process );
39
-		new Sync_Page();
40
-	}
35
+    if ( apply_filters( 'wl_feature__enable__sync-background', false ) ) {
36
+        // Set up the sync background process.
37
+        $sync_background_process = new Sync_Background_Process( $sync_service, $sync_object_adapter_factory );
38
+        new Sync_Background_Process_Wpjson_Endpoint( $sync_background_process );
39
+        new Sync_Page();
40
+    }
41 41
 
42 42
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,31 +11,31 @@
 block discarded – undo
11 11
 use Wordlift\Dataset\Sync_User_Hooks;
12 12
 use Wordlift\Jsonld\Jsonld_Service;
13 13
 
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 // Register the Dataset JSON Endpoint. The `$api_service` variable must be defined in the calling file (wordlift.php).
18
-if ( apply_filters( 'wl_feature__enable__dataset-ng', false ) ) {
18
+if (apply_filters('wl_feature__enable__dataset-ng', false)) {
19 19
 
20 20
 	$sync_object_adapter_factory = new Sync_Object_Adapter_Factory();
21
-	$sync_service                = new Sync_Service( $api_service, $sync_object_adapter_factory, Jsonld_Service::get_instance(), Wordlift_Entity_Service::get_instance() );
22
-	new Sync_Post_Hooks( $sync_service, $sync_object_adapter_factory );
23
-	new Sync_User_Hooks( $sync_service );
21
+	$sync_service                = new Sync_Service($api_service, $sync_object_adapter_factory, Jsonld_Service::get_instance(), Wordlift_Entity_Service::get_instance());
22
+	new Sync_Post_Hooks($sync_service, $sync_object_adapter_factory);
23
+	new Sync_User_Hooks($sync_service);
24 24
 
25 25
 	/**
26 26
 	 * @since 3.28.0
27 27
 	 * @see https://github.com/insideout10/wordlift-plugin/issues/1186
28 28
 	 */
29
-	new Sync_Hooks_Entity_Relation( Wordlift_Entity_Service::get_instance() );
29
+	new Sync_Hooks_Entity_Relation(Wordlift_Entity_Service::get_instance());
30 30
 
31
-	if ( apply_filters( 'wl_feature__enable__wordpress-ontology', false ) ) {
31
+	if (apply_filters('wl_feature__enable__wordpress-ontology', false)) {
32 32
 		new Sync_Hooks_Wordpress_Ontology();
33 33
 	}
34 34
 
35
-	if ( apply_filters( 'wl_feature__enable__sync-background', false ) ) {
35
+	if (apply_filters('wl_feature__enable__sync-background', false)) {
36 36
 		// Set up the sync background process.
37
-		$sync_background_process = new Sync_Background_Process( $sync_service, $sync_object_adapter_factory );
38
-		new Sync_Background_Process_Wpjson_Endpoint( $sync_background_process );
37
+		$sync_background_process = new Sync_Background_Process($sync_service, $sync_object_adapter_factory);
38
+		new Sync_Background_Process_Wpjson_Endpoint($sync_background_process);
39 39
 		new Sync_Page();
40 40
 	}
41 41
 
Please login to merge, or discard this patch.
src/wordlift/dataset/class-sync-hooks-wordpress-ontology.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -6,47 +6,47 @@
 block discarded – undo
6 6
 
7 7
 class Sync_Hooks_Wordpress_Ontology {
8 8
 
9
-	const HTTP_PURL_ORG_WORDPRESS_1_0 = 'http://purl.org/wordpress/1.0/';
9
+    const HTTP_PURL_ORG_WORDPRESS_1_0 = 'http://purl.org/wordpress/1.0/';
10 10
 
11
-	public function __construct() {
12
-		add_filter( 'wl_dataset__sync_service__sync_item__jsonld', array( $this, 'jsonld' ), 10, 3 );
13
-	}
11
+    public function __construct() {
12
+        add_filter( 'wl_dataset__sync_service__sync_item__jsonld', array( $this, 'jsonld' ), 10, 3 );
13
+    }
14 14
 
15
-	public function jsonld( $jsonld, $type, $object_id ) {
15
+    public function jsonld( $jsonld, $type, $object_id ) {
16 16
 
17
-		$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'id' ] = $object_id;
17
+        $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'id' ] = $object_id;
18 18
 
19
-		switch ( $type ) {
19
+        switch ( $type ) {
20 20
 
21
-			case Object_Type_Enum::TERM:
22
-				$term = get_term( $object_id );
21
+            case Object_Type_Enum::TERM:
22
+                $term = get_term( $object_id );
23 23
 
24
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'contentType' ] = 'term';
25
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'name' ]        = $term->name;
26
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'description' ] = $term->description;
27
-				break;
24
+                $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'contentType' ] = 'term';
25
+                $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'name' ]        = $term->name;
26
+                $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'description' ] = $term->description;
27
+                break;
28 28
 
29
-			case Object_Type_Enum::USER:
30
-				$user = get_userdata( $object_id );
29
+            case Object_Type_Enum::USER:
30
+                $user = get_userdata( $object_id );
31 31
 
32
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'contentType' ] = 'user';
33
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'displayName' ] = $user->display_name;
34
-				break;
32
+                $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'contentType' ] = 'user';
33
+                $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'displayName' ] = $user->display_name;
34
+                break;
35 35
 
36
-			case Object_Type_Enum::POST:
37
-				$post = get_post( $object_id );
36
+            case Object_Type_Enum::POST:
37
+                $post = get_post( $object_id );
38 38
 
39
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'contentType' ] = 'post';
40
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'postType' ]    = $post->post_type;
41
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'postTitle' ]   = $post->post_title;
42
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'postStatus' ]  = $post->post_status;
43
-				break;
39
+                $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'contentType' ] = 'post';
40
+                $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'postType' ]    = $post->post_type;
41
+                $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'postTitle' ]   = $post->post_title;
42
+                $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'postStatus' ]  = $post->post_status;
43
+                break;
44 44
 
45
-			default:
45
+            default:
46 46
 
47
-		}
47
+        }
48 48
 
49
-		return $jsonld;
50
-	}
49
+        return $jsonld;
50
+    }
51 51
 
52 52
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -9,37 +9,37 @@
 block discarded – undo
9 9
 	const HTTP_PURL_ORG_WORDPRESS_1_0 = 'http://purl.org/wordpress/1.0/';
10 10
 
11 11
 	public function __construct() {
12
-		add_filter( 'wl_dataset__sync_service__sync_item__jsonld', array( $this, 'jsonld' ), 10, 3 );
12
+		add_filter('wl_dataset__sync_service__sync_item__jsonld', array($this, 'jsonld'), 10, 3);
13 13
 	}
14 14
 
15
-	public function jsonld( $jsonld, $type, $object_id ) {
15
+	public function jsonld($jsonld, $type, $object_id) {
16 16
 
17
-		$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'id' ] = $object_id;
17
+		$jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'id'] = $object_id;
18 18
 
19
-		switch ( $type ) {
19
+		switch ($type) {
20 20
 
21 21
 			case Object_Type_Enum::TERM:
22
-				$term = get_term( $object_id );
22
+				$term = get_term($object_id);
23 23
 
24
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'contentType' ] = 'term';
25
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'name' ]        = $term->name;
26
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'description' ] = $term->description;
24
+				$jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'contentType'] = 'term';
25
+				$jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'name']        = $term->name;
26
+				$jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'description'] = $term->description;
27 27
 				break;
28 28
 
29 29
 			case Object_Type_Enum::USER:
30
-				$user = get_userdata( $object_id );
30
+				$user = get_userdata($object_id);
31 31
 
32
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'contentType' ] = 'user';
33
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'displayName' ] = $user->display_name;
32
+				$jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'contentType'] = 'user';
33
+				$jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'displayName'] = $user->display_name;
34 34
 				break;
35 35
 
36 36
 			case Object_Type_Enum::POST:
37
-				$post = get_post( $object_id );
37
+				$post = get_post($object_id);
38 38
 
39
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'contentType' ] = 'post';
40
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'postType' ]    = $post->post_type;
41
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'postTitle' ]   = $post->post_title;
42
-				$jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'postStatus' ]  = $post->post_status;
39
+				$jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'contentType'] = 'post';
40
+				$jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'postType']    = $post->post_type;
41
+				$jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'postTitle']   = $post->post_title;
42
+				$jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'postStatus']  = $post->post_status;
43 43
 				break;
44 44
 
45 45
 			default:
Please login to merge, or discard this patch.
src/wordlift/dataset/class-sync-object-adapter-factory.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -6,34 +6,34 @@
 block discarded – undo
6 6
 
7 7
 class Sync_Object_Adapter_Factory {
8 8
 
9
-	/**
10
-	 * @param int $type One of Object_Type_Enum::POST, Object_Type_Enum::USER, ...
11
-	 * @param int $object_id The object id.
12
-	 *
13
-	 * @return Sync_Object_Adapter
14
-	 * @throws \Exception
15
-	 */
16
-	function create( $type, $object_id ) {
17
-
18
-		switch ( $type ) {
19
-			case Object_Type_Enum::POST:
20
-				return new Sync_Post_Adapter( $object_id );
21
-			case Object_Type_Enum::USER:
22
-				return new Sync_User_Adapter( $object_id );
23
-			case Object_Type_Enum::TERM:
24
-				return new Sync_Term_Adapter( $object_id );
25
-			default:
26
-				throw new \Exception( "Unsupported type $type." );
27
-		}
28
-
29
-	}
30
-
31
-	function create_many( $type, $object_ids ) {
32
-		$that = $this;
33
-
34
-		return array_map( function ( $item ) use ( $type, $that ) {
35
-			return $that->create( $type, $item );
36
-		}, (array) $object_ids );
37
-	}
9
+    /**
10
+     * @param int $type One of Object_Type_Enum::POST, Object_Type_Enum::USER, ...
11
+     * @param int $object_id The object id.
12
+     *
13
+     * @return Sync_Object_Adapter
14
+     * @throws \Exception
15
+     */
16
+    function create( $type, $object_id ) {
17
+
18
+        switch ( $type ) {
19
+            case Object_Type_Enum::POST:
20
+                return new Sync_Post_Adapter( $object_id );
21
+            case Object_Type_Enum::USER:
22
+                return new Sync_User_Adapter( $object_id );
23
+            case Object_Type_Enum::TERM:
24
+                return new Sync_Term_Adapter( $object_id );
25
+            default:
26
+                throw new \Exception( "Unsupported type $type." );
27
+        }
28
+
29
+    }
30
+
31
+    function create_many( $type, $object_ids ) {
32
+        $that = $this;
33
+
34
+        return array_map( function ( $item ) use ( $type, $that ) {
35
+            return $that->create( $type, $item );
36
+        }, (array) $object_ids );
37
+    }
38 38
 
39 39
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,27 +13,27 @@
 block discarded – undo
13 13
 	 * @return Sync_Object_Adapter
14 14
 	 * @throws \Exception
15 15
 	 */
16
-	function create( $type, $object_id ) {
16
+	function create($type, $object_id) {
17 17
 
18
-		switch ( $type ) {
18
+		switch ($type) {
19 19
 			case Object_Type_Enum::POST:
20
-				return new Sync_Post_Adapter( $object_id );
20
+				return new Sync_Post_Adapter($object_id);
21 21
 			case Object_Type_Enum::USER:
22
-				return new Sync_User_Adapter( $object_id );
22
+				return new Sync_User_Adapter($object_id);
23 23
 			case Object_Type_Enum::TERM:
24
-				return new Sync_Term_Adapter( $object_id );
24
+				return new Sync_Term_Adapter($object_id);
25 25
 			default:
26
-				throw new \Exception( "Unsupported type $type." );
26
+				throw new \Exception("Unsupported type $type.");
27 27
 		}
28 28
 
29 29
 	}
30 30
 
31
-	function create_many( $type, $object_ids ) {
31
+	function create_many($type, $object_ids) {
32 32
 		$that = $this;
33 33
 
34
-		return array_map( function ( $item ) use ( $type, $that ) {
35
-			return $that->create( $type, $item );
36
-		}, (array) $object_ids );
34
+		return array_map(function($item) use ($type, $that) {
35
+			return $that->create($type, $item);
36
+		}, (array) $object_ids);
37 37
 	}
38 38
 
39 39
 }
Please login to merge, or discard this patch.
src/wordlift/dataset/class-sync-post-adapter.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -5,34 +5,34 @@
 block discarded – undo
5 5
 use Wordlift\Object_Type_Enum;
6 6
 
7 7
 class Sync_Post_Adapter extends Abstract_Sync_Object_Adapter {
8
-	/**
9
-	 * @var int
10
-	 */
11
-	private $post_id;
12
-
13
-	/**
14
-	 * Sync_Term_Adapter constructor.
15
-	 *
16
-	 * @param int $post_id
17
-	 *
18
-	 * @throws \Exception
19
-	 */
20
-	function __construct( $post_id ) {
21
-		parent::__construct( Object_Type_Enum::POST, $post_id );
22
-
23
-		$this->post_id = $post_id;
24
-	}
25
-
26
-	function is_published() {
27
-		return ( 'publish' === get_post_status( $this->post_id ) );
28
-	}
29
-
30
-	function is_public() {
31
-		// Check if the post type is public.
32
-		$post_type     = get_post_type( $this->post_id );
33
-		$post_type_obj = get_post_type_object( $post_type );
34
-
35
-		return $post_type_obj->public;
36
-	}
8
+    /**
9
+     * @var int
10
+     */
11
+    private $post_id;
12
+
13
+    /**
14
+     * Sync_Term_Adapter constructor.
15
+     *
16
+     * @param int $post_id
17
+     *
18
+     * @throws \Exception
19
+     */
20
+    function __construct( $post_id ) {
21
+        parent::__construct( Object_Type_Enum::POST, $post_id );
22
+
23
+        $this->post_id = $post_id;
24
+    }
25
+
26
+    function is_published() {
27
+        return ( 'publish' === get_post_status( $this->post_id ) );
28
+    }
29
+
30
+    function is_public() {
31
+        // Check if the post type is public.
32
+        $post_type     = get_post_type( $this->post_id );
33
+        $post_type_obj = get_post_type_object( $post_type );
34
+
35
+        return $post_type_obj->public;
36
+    }
37 37
 
38 38
 }
Please login to merge, or discard this patch.
src/wordlift/dataset/class-sync-page.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -4,39 +4,39 @@  discard block
 block discarded – undo
4 4
 
5 5
 class Sync_Page {
6 6
 
7
-	/**
8
-	 * Sync_Page constructor.
9
-	 */
10
-	public function __construct() {
7
+    /**
8
+     * Sync_Page constructor.
9
+     */
10
+    public function __construct() {
11 11
 
12
-		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
12
+        add_action( 'admin_menu', array( $this, 'admin_menu' ) );
13 13
 
14
-	}
14
+    }
15 15
 
16
-	public function admin_menu() {
16
+    public function admin_menu() {
17 17
 
18
-		add_submenu_page( 'wl_admin_menu', __( 'Synchronize Dataset', 'wordlift' ), __( 'Synchronize Dataset', 'wordlift' ), 'manage_options', 'wl_dataset_sync', array(
19
-			$this,
20
-			'render'
21
-		) );
18
+        add_submenu_page( 'wl_admin_menu', __( 'Synchronize Dataset', 'wordlift' ), __( 'Synchronize Dataset', 'wordlift' ), 'manage_options', 'wl_dataset_sync', array(
19
+            $this,
20
+            'render'
21
+        ) );
22 22
 
23
-	}
23
+    }
24 24
 
25
-	public function render() {
25
+    public function render() {
26 26
 
27
-		wp_enqueue_style(
28
-			'wl-tasks-page',
29
-			plugin_dir_url( dirname( __FILE__ ) ) . 'tasks/admin/assets/tasks-page.css',
30
-			array(),
31
-			\Wordlift::get_instance()->get_version(),
32
-			'all' );
33
-		wp_enqueue_script(
34
-			'wl-dataset-sync-page',
35
-			plugin_dir_url( __FILE__ ) . 'assets/sync-page.js',
36
-			array( 'wp-api' ),
37
-			\Wordlift::get_instance()->get_version() );
27
+        wp_enqueue_style(
28
+            'wl-tasks-page',
29
+            plugin_dir_url( dirname( __FILE__ ) ) . 'tasks/admin/assets/tasks-page.css',
30
+            array(),
31
+            \Wordlift::get_instance()->get_version(),
32
+            'all' );
33
+        wp_enqueue_script(
34
+            'wl-dataset-sync-page',
35
+            plugin_dir_url( __FILE__ ) . 'assets/sync-page.js',
36
+            array( 'wp-api' ),
37
+            \Wordlift::get_instance()->get_version() );
38 38
 
39
-		?>
39
+        ?>
40 40
         <div class="wrap">
41 41
             <h2><?php esc_html_e( 'Synchronize Dataset', 'wordlift' ); ?></h2>
42 42
 
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
             </div>
47 47
 
48 48
             <button id="wl-start-btn" type="button" class="button button-large button-primary"><?php
49
-				esc_html_e( 'Start', 'wordlift-framework' ); ?></button>
49
+                esc_html_e( 'Start', 'wordlift-framework' ); ?></button>
50 50
             <button id="wl-stop-btn" type="button" class="button button-large button-primary hidden"><?php
51
-				esc_html_e( 'Stop', 'wordlift-framework' ); ?></button>
51
+                esc_html_e( 'Stop', 'wordlift-framework' ); ?></button>
52 52
 
53 53
         </div>
54 54
 		<?php
55
-	}
55
+    }
56 56
 
57 57
 }
58 58
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
 	 */
10 10
 	public function __construct() {
11 11
 
12
-		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
12
+		add_action('admin_menu', array($this, 'admin_menu'));
13 13
 
14 14
 	}
15 15
 
16 16
 	public function admin_menu() {
17 17
 
18
-		add_submenu_page( 'wl_admin_menu', __( 'Synchronize Dataset', 'wordlift' ), __( 'Synchronize Dataset', 'wordlift' ), 'manage_options', 'wl_dataset_sync', array(
18
+		add_submenu_page('wl_admin_menu', __('Synchronize Dataset', 'wordlift'), __('Synchronize Dataset', 'wordlift'), 'manage_options', 'wl_dataset_sync', array(
19 19
 			$this,
20 20
 			'render'
21
-		) );
21
+		));
22 22
 
23 23
 	}
24 24
 
@@ -26,19 +26,19 @@  discard block
 block discarded – undo
26 26
 
27 27
 		wp_enqueue_style(
28 28
 			'wl-tasks-page',
29
-			plugin_dir_url( dirname( __FILE__ ) ) . 'tasks/admin/assets/tasks-page.css',
29
+			plugin_dir_url(dirname(__FILE__)).'tasks/admin/assets/tasks-page.css',
30 30
 			array(),
31 31
 			\Wordlift::get_instance()->get_version(),
32 32
 			'all' );
33 33
 		wp_enqueue_script(
34 34
 			'wl-dataset-sync-page',
35
-			plugin_dir_url( __FILE__ ) . 'assets/sync-page.js',
36
-			array( 'wp-api' ),
35
+			plugin_dir_url(__FILE__).'assets/sync-page.js',
36
+			array('wp-api'),
37 37
 			\Wordlift::get_instance()->get_version() );
38 38
 
39 39
 		?>
40 40
         <div class="wrap">
41
-            <h2><?php esc_html_e( 'Synchronize Dataset', 'wordlift' ); ?></h2>
41
+            <h2><?php esc_html_e('Synchronize Dataset', 'wordlift'); ?></h2>
42 42
 
43 43
             <div class="wl-task__progress" style="border: 1px solid #23282D; height: 20px; margin: 8px 0;">
44 44
                 <div class="wl-task__progress__bar"
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
             </div>
47 47
 
48 48
             <button id="wl-start-btn" type="button" class="button button-large button-primary"><?php
49
-				esc_html_e( 'Start', 'wordlift-framework' ); ?></button>
49
+				esc_html_e('Start', 'wordlift-framework'); ?></button>
50 50
             <button id="wl-stop-btn" type="button" class="button button-large button-primary hidden"><?php
51
-				esc_html_e( 'Stop', 'wordlift-framework' ); ?></button>
51
+				esc_html_e('Stop', 'wordlift-framework'); ?></button>
52 52
 
53 53
         </div>
54 54
 		<?php
Please login to merge, or discard this patch.
src/wordlift/dataset/class-sync-term-adapter.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -5,32 +5,32 @@
 block discarded – undo
5 5
 use Wordlift\Object_Type_Enum;
6 6
 
7 7
 class Sync_Term_Adapter extends Abstract_Sync_Object_Adapter {
8
-	/**
9
-	 * @var int
10
-	 */
11
-	private $term_id;
12
-
13
-	/**
14
-	 * Sync_Term_Adapter constructor.
15
-	 *
16
-	 * @param int $term_id
17
-	 *
18
-	 * @throws \Exception
19
-	 */
20
-	function __construct( $term_id ) {
21
-		parent::__construct( Object_Type_Enum::TERM, $term_id );
22
-
23
-		$this->term_id = $term_id;
24
-	}
25
-
26
-	function is_published() {
27
-		return $this->is_public();
28
-	}
29
-
30
-	function is_public() {
31
-		$term = get_term( $this->term_id );
32
-
33
-		return get_taxonomy( $term->taxonomy )->public;
34
-	}
8
+    /**
9
+     * @var int
10
+     */
11
+    private $term_id;
12
+
13
+    /**
14
+     * Sync_Term_Adapter constructor.
15
+     *
16
+     * @param int $term_id
17
+     *
18
+     * @throws \Exception
19
+     */
20
+    function __construct( $term_id ) {
21
+        parent::__construct( Object_Type_Enum::TERM, $term_id );
22
+
23
+        $this->term_id = $term_id;
24
+    }
25
+
26
+    function is_published() {
27
+        return $this->is_public();
28
+    }
29
+
30
+    function is_public() {
31
+        $term = get_term( $this->term_id );
32
+
33
+        return get_taxonomy( $term->taxonomy )->public;
34
+    }
35 35
 
36 36
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @throws \Exception
19 19
 	 */
20
-	function __construct( $term_id ) {
21
-		parent::__construct( Object_Type_Enum::TERM, $term_id );
20
+	function __construct($term_id) {
21
+		parent::__construct(Object_Type_Enum::TERM, $term_id);
22 22
 
23 23
 		$this->term_id = $term_id;
24 24
 	}
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 	}
29 29
 
30 30
 	function is_public() {
31
-		$term = get_term( $this->term_id );
31
+		$term = get_term($this->term_id);
32 32
 
33
-		return get_taxonomy( $term->taxonomy )->public;
33
+		return get_taxonomy($term->taxonomy)->public;
34 34
 	}
35 35
 
36 36
 }
Please login to merge, or discard this patch.
dataset/background/class-sync-background-process-wpjson-endpoint.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -6,56 +6,56 @@
 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;
9
+    /**
10
+     * @var Sync_Background_Process
11
+     */
12
+    private $sync_background_process;
13 13
 
14
-	/**
15
-	 * Sync_Background_Process_Wpjson_Endpoint constructor.
16
-	 *
17
-	 * @param Sync_Background_Process $sync_background_process
18
-	 */
19
-	function __construct( $sync_background_process ) {
14
+    /**
15
+     * Sync_Background_Process_Wpjson_Endpoint constructor.
16
+     *
17
+     * @param Sync_Background_Process $sync_background_process
18
+     */
19
+    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
-		$this->sync_background_process = $sync_background_process;
23
+        $this->sync_background_process = $sync_background_process;
24 24
 
25
-	}
25
+    }
26 26
 
27
-	function rest_api_init() {
27
+    function rest_api_init() {
28 28
 
29
-		register_rest_route( 'wordlift/v1', '/dataset/background/sync', array(
30
-			'methods'             => WP_REST_Server::CREATABLE,
31
-			'callback'            => array( $this->sync_background_process, 'start' ),
32
-			'permission_callback' => function () {
33
-				$user = wp_get_current_user();
29
+        register_rest_route( 'wordlift/v1', '/dataset/background/sync', array(
30
+            'methods'             => WP_REST_Server::CREATABLE,
31
+            'callback'            => array( $this->sync_background_process, 'start' ),
32
+            'permission_callback' => function () {
33
+                $user = wp_get_current_user();
34 34
 
35
-				return in_array( 'administrator', (array) $user->roles );
36
-			}
37
-		) );
35
+                return in_array( 'administrator', (array) $user->roles );
36
+            }
37
+        ) );
38 38
 
39
-		register_rest_route( 'wordlift/v1', '/dataset/background/sync', array(
40
-			'methods'             => WP_REST_Server::READABLE,
41
-			'callback'            => array( $this->sync_background_process, 'get_info' ),
42
-			'permission_callback' => function () {
43
-				$user = wp_get_current_user();
39
+        register_rest_route( 'wordlift/v1', '/dataset/background/sync', array(
40
+            'methods'             => WP_REST_Server::READABLE,
41
+            'callback'            => array( $this->sync_background_process, 'get_info' ),
42
+            'permission_callback' => function () {
43
+                $user = wp_get_current_user();
44 44
 
45
-				return in_array( 'administrator', (array) $user->roles );
46
-			}
47
-		) );
45
+                return in_array( 'administrator', (array) $user->roles );
46
+            }
47
+        ) );
48 48
 
49
-		register_rest_route( 'wordlift/v1', '/dataset/background/sync', array(
50
-			'methods'             => WP_REST_Server::DELETABLE,
51
-			'callback'            => array( $this->sync_background_process, 'stop' ),
52
-			'permission_callback' => function () {
53
-				$user = wp_get_current_user();
49
+        register_rest_route( 'wordlift/v1', '/dataset/background/sync', array(
50
+            'methods'             => WP_REST_Server::DELETABLE,
51
+            'callback'            => array( $this->sync_background_process, 'stop' ),
52
+            'permission_callback' => function () {
53
+                $user = wp_get_current_user();
54 54
 
55
-				return in_array( 'administrator', (array) $user->roles );
56
-			}
57
-		) );
55
+                return in_array( 'administrator', (array) $user->roles );
56
+            }
57
+        ) );
58 58
 
59
-	}
59
+    }
60 60
 
61 61
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 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
-	function __construct( $sync_background_process ) {
19
+	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
 
@@ -26,35 +26,35 @@  discard block
 block discarded – undo
26 26
 
27 27
 	function rest_api_init() {
28 28
 
29
-		register_rest_route( 'wordlift/v1', '/dataset/background/sync', array(
29
+		register_rest_route('wordlift/v1', '/dataset/background/sync', array(
30 30
 			'methods'             => WP_REST_Server::CREATABLE,
31
-			'callback'            => array( $this->sync_background_process, 'start' ),
32
-			'permission_callback' => function () {
31
+			'callback'            => array($this->sync_background_process, 'start'),
32
+			'permission_callback' => function() {
33 33
 				$user = wp_get_current_user();
34 34
 
35
-				return in_array( 'administrator', (array) $user->roles );
35
+				return in_array('administrator', (array) $user->roles);
36 36
 			}
37
-		) );
37
+		));
38 38
 
39
-		register_rest_route( 'wordlift/v1', '/dataset/background/sync', array(
39
+		register_rest_route('wordlift/v1', '/dataset/background/sync', array(
40 40
 			'methods'             => WP_REST_Server::READABLE,
41
-			'callback'            => array( $this->sync_background_process, 'get_info' ),
42
-			'permission_callback' => function () {
41
+			'callback'            => array($this->sync_background_process, 'get_info'),
42
+			'permission_callback' => function() {
43 43
 				$user = wp_get_current_user();
44 44
 
45
-				return in_array( 'administrator', (array) $user->roles );
45
+				return in_array('administrator', (array) $user->roles);
46 46
 			}
47
-		) );
47
+		));
48 48
 
49
-		register_rest_route( 'wordlift/v1', '/dataset/background/sync', array(
49
+		register_rest_route('wordlift/v1', '/dataset/background/sync', array(
50 50
 			'methods'             => WP_REST_Server::DELETABLE,
51
-			'callback'            => array( $this->sync_background_process, 'stop' ),
52
-			'permission_callback' => function () {
51
+			'callback'            => array($this->sync_background_process, 'stop'),
52
+			'permission_callback' => function() {
53 53
 				$user = wp_get_current_user();
54 54
 
55
-				return in_array( 'administrator', (array) $user->roles );
55
+				return in_array('administrator', (array) $user->roles);
56 56
 			}
57
-		) );
57
+		));
58 58
 
59 59
 	}
60 60
 
Please login to merge, or discard this patch.