Completed
Pull Request — develop (#1328)
by Naveen
02:53
created
src/wordlift/vocabulary/api/class-api-config.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,19 +8,19 @@
 block discarded – undo
8 8
  */
9 9
 class Api_Config {
10 10
 
11
-	const REST_NAMESPACE = '/cafemediakg/v1';
11
+    const REST_NAMESPACE = '/cafemediakg/v1';
12 12
 
13
-	public static function get_api_config() {
14
-		// Create ui settings array to be used by js client.
15
-		$settings            = array();
16
-		$settings['restUrl'] = get_rest_url(
17
-			null,
18
-			Api_Config::REST_NAMESPACE . '/tags'
19
-		);
20
-		$settings['baseUrl'] = get_rest_url( null, Api_Config::REST_NAMESPACE );
21
-		$settings['nonce']   = wp_create_nonce( 'wp_rest' );
13
+    public static function get_api_config() {
14
+        // Create ui settings array to be used by js client.
15
+        $settings            = array();
16
+        $settings['restUrl'] = get_rest_url(
17
+            null,
18
+            Api_Config::REST_NAMESPACE . '/tags'
19
+        );
20
+        $settings['baseUrl'] = get_rest_url( null, Api_Config::REST_NAMESPACE );
21
+        $settings['nonce']   = wp_create_nonce( 'wp_rest' );
22 22
 
23
-		return $settings;
24
-	}
23
+        return $settings;
24
+    }
25 25
 
26 26
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@
 block discarded – undo
15 15
 		$settings            = array();
16 16
 		$settings['restUrl'] = get_rest_url(
17 17
 			null,
18
-			Api_Config::REST_NAMESPACE . '/tags'
18
+			Api_Config::REST_NAMESPACE.'/tags'
19 19
 		);
20
-		$settings['baseUrl'] = get_rest_url( null, Api_Config::REST_NAMESPACE );
21
-		$settings['nonce']   = wp_create_nonce( 'wp_rest' );
20
+		$settings['baseUrl'] = get_rest_url(null, Api_Config::REST_NAMESPACE);
21
+		$settings['nonce']   = wp_create_nonce('wp_rest');
22 22
 
23 23
 		return $settings;
24 24
 	}
Please login to merge, or discard this patch.
src/wordlift/vocabulary/api/class-background-analysis-endpoint.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -14,132 +14,132 @@
 block discarded – undo
14 14
 
15 15
 class Background_Analysis_Endpoint {
16 16
 
17
-	/**
18
-	 * @var Analysis_Background_Service
19
-	 */
20
-	private $background_service;
21
-	/**
22
-	 * @var Options_Cache
23
-	 */
24
-	private $cache_service;
25
-
26
-	public function __construct( $background_service, $cache_service ) {
27
-		$this->background_service = $background_service;
28
-		$this->cache_service = $cache_service;
29
-		$this->register_routes();
30
-	}
31
-
32
-	public function register_routes() {
33
-		$that = $this;
34
-		add_action( 'rest_api_init',
35
-			function () use ( $that ) {
36
-				$that->register_start_route();
37
-				$that->register_stop_route();
38
-				$that->register_stats_route();
39
-				$that->register_restart_route();
40
-			} );
41
-	}
42
-
43
-	private function register_start_route() {
44
-		register_rest_route(
45
-			Api_Config::REST_NAMESPACE,
46
-			'/background_analysis/start',
47
-			array(
48
-				'methods'             => WP_REST_Server::CREATABLE,
49
-				'callback'            => array( $this, 'start' ),
50
-				'permission_callback' => function () {
51
-					return current_user_can( 'manage_options' );
52
-				},
53
-			)
54
-		);
55
-	}
56
-
57
-	private function register_stop_route() {
58
-		register_rest_route(
59
-			Api_Config::REST_NAMESPACE,
60
-			'/background_analysis/stop',
61
-			array(
62
-				'methods'             => WP_REST_Server::CREATABLE,
63
-				'callback'            => array( $this, 'stop' ),
64
-				'permission_callback' => function () {
65
-					return current_user_can( 'manage_options' );
66
-				},
67
-			)
68
-		);
69
-	}
70
-
71
-	private function register_stats_route() {
72
-		register_rest_route(
73
-			Api_Config::REST_NAMESPACE,
74
-			'/background_analysis/stats',
75
-			array(
76
-				'methods'             => WP_REST_Server::CREATABLE,
77
-				'callback'            => array( $this, 'get_stats' ),
78
-				'permission_callback' => function () {
79
-					return current_user_can( 'manage_options' );
80
-				},
81
-			)
82
-		);
83
-	}
84
-
85
-
86
-	private function register_restart_route() {
87
-		register_rest_route(
88
-			Api_Config::REST_NAMESPACE,
89
-			'/background_analysis/restart',
90
-			array(
91
-				'methods'             => WP_REST_Server::CREATABLE,
92
-				'callback'            => array( $this, 'restart' ),
93
-				'permission_callback' => function () {
94
-					return current_user_can( 'manage_options' );
95
-				},
96
-			)
97
-		);
98
-	}
99
-
100
-
101
-	public function get_stats() {
102
-		/**
103
-		 * @var $state Sync_State
104
-		 */
105
-		$state = get_option( Analysis_Background_Process::WL_CMKG_ANALYSIS_BACKGROUND_PROCESS, Sync_State::unknown() );
106
-
107
-		return $state->get_array();
108
-	}
109
-
110
-	public function start() {
111
-		$this->background_service->start();
112
-
113
-		return true;
114
-	}
115
-
116
-
117
-	public function restart() {
118
-		$this->background_service->cancel();
119
-		// clear the flags and restart again.
120
-		global $wpdb;
121
-		$query = <<<EOF
17
+    /**
18
+     * @var Analysis_Background_Service
19
+     */
20
+    private $background_service;
21
+    /**
22
+     * @var Options_Cache
23
+     */
24
+    private $cache_service;
25
+
26
+    public function __construct( $background_service, $cache_service ) {
27
+        $this->background_service = $background_service;
28
+        $this->cache_service = $cache_service;
29
+        $this->register_routes();
30
+    }
31
+
32
+    public function register_routes() {
33
+        $that = $this;
34
+        add_action( 'rest_api_init',
35
+            function () use ( $that ) {
36
+                $that->register_start_route();
37
+                $that->register_stop_route();
38
+                $that->register_stats_route();
39
+                $that->register_restart_route();
40
+            } );
41
+    }
42
+
43
+    private function register_start_route() {
44
+        register_rest_route(
45
+            Api_Config::REST_NAMESPACE,
46
+            '/background_analysis/start',
47
+            array(
48
+                'methods'             => WP_REST_Server::CREATABLE,
49
+                'callback'            => array( $this, 'start' ),
50
+                'permission_callback' => function () {
51
+                    return current_user_can( 'manage_options' );
52
+                },
53
+            )
54
+        );
55
+    }
56
+
57
+    private function register_stop_route() {
58
+        register_rest_route(
59
+            Api_Config::REST_NAMESPACE,
60
+            '/background_analysis/stop',
61
+            array(
62
+                'methods'             => WP_REST_Server::CREATABLE,
63
+                'callback'            => array( $this, 'stop' ),
64
+                'permission_callback' => function () {
65
+                    return current_user_can( 'manage_options' );
66
+                },
67
+            )
68
+        );
69
+    }
70
+
71
+    private function register_stats_route() {
72
+        register_rest_route(
73
+            Api_Config::REST_NAMESPACE,
74
+            '/background_analysis/stats',
75
+            array(
76
+                'methods'             => WP_REST_Server::CREATABLE,
77
+                'callback'            => array( $this, 'get_stats' ),
78
+                'permission_callback' => function () {
79
+                    return current_user_can( 'manage_options' );
80
+                },
81
+            )
82
+        );
83
+    }
84
+
85
+
86
+    private function register_restart_route() {
87
+        register_rest_route(
88
+            Api_Config::REST_NAMESPACE,
89
+            '/background_analysis/restart',
90
+            array(
91
+                'methods'             => WP_REST_Server::CREATABLE,
92
+                'callback'            => array( $this, 'restart' ),
93
+                'permission_callback' => function () {
94
+                    return current_user_can( 'manage_options' );
95
+                },
96
+            )
97
+        );
98
+    }
99
+
100
+
101
+    public function get_stats() {
102
+        /**
103
+         * @var $state Sync_State
104
+         */
105
+        $state = get_option( Analysis_Background_Process::WL_CMKG_ANALYSIS_BACKGROUND_PROCESS, Sync_State::unknown() );
106
+
107
+        return $state->get_array();
108
+    }
109
+
110
+    public function start() {
111
+        $this->background_service->start();
112
+
113
+        return true;
114
+    }
115
+
116
+
117
+    public function restart() {
118
+        $this->background_service->cancel();
119
+        // clear the flags and restart again.
120
+        global $wpdb;
121
+        $query = <<<EOF
122 122
 DELETE FROM $wpdb->termmeta WHERE meta_key=%s OR meta_key=%s
123 123
 EOF;
124
-		// Remove the flags, if the tag is already accepted we wont remove that ui flag.
125
-		$query = $wpdb->prepare( $query, array(
126
-			Analysis_Background_Service::ANALYSIS_DONE_FLAG,
127
-			Analysis_Background_Service::ENTITIES_PRESENT_FOR_TERM
128
-		) );
129
-		$wpdb->query( $query );
130
-		// clear the cache
131
-		$this->cache_service->flush_all();
132
-		$this->background_service->start();
124
+        // Remove the flags, if the tag is already accepted we wont remove that ui flag.
125
+        $query = $wpdb->prepare( $query, array(
126
+            Analysis_Background_Service::ANALYSIS_DONE_FLAG,
127
+            Analysis_Background_Service::ENTITIES_PRESENT_FOR_TERM
128
+        ) );
129
+        $wpdb->query( $query );
130
+        // clear the cache
131
+        $this->cache_service->flush_all();
132
+        $this->background_service->start();
133 133
 
134
-		return array( 'status' => 'restart_complete' );
135
-	}
134
+        return array( 'status' => 'restart_complete' );
135
+    }
136 136
 
137 137
 
138
-	public function stop() {
139
-		$this->background_service->stop();
138
+    public function stop() {
139
+        $this->background_service->stop();
140 140
 
141
-		return true;
142
-	}
141
+        return true;
142
+    }
143 143
 
144 144
 
145 145
 }
146 146
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	private $cache_service;
25 25
 
26
-	public function __construct( $background_service, $cache_service ) {
26
+	public function __construct($background_service, $cache_service) {
27 27
 		$this->background_service = $background_service;
28 28
 		$this->cache_service = $cache_service;
29 29
 		$this->register_routes();
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 
32 32
 	public function register_routes() {
33 33
 		$that = $this;
34
-		add_action( 'rest_api_init',
35
-			function () use ( $that ) {
34
+		add_action('rest_api_init',
35
+			function() use ($that) {
36 36
 				$that->register_start_route();
37 37
 				$that->register_stop_route();
38 38
 				$that->register_stats_route();
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
 			'/background_analysis/start',
47 47
 			array(
48 48
 				'methods'             => WP_REST_Server::CREATABLE,
49
-				'callback'            => array( $this, 'start' ),
50
-				'permission_callback' => function () {
51
-					return current_user_can( 'manage_options' );
49
+				'callback'            => array($this, 'start'),
50
+				'permission_callback' => function() {
51
+					return current_user_can('manage_options');
52 52
 				},
53 53
 			)
54 54
 		);
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 			'/background_analysis/stop',
61 61
 			array(
62 62
 				'methods'             => WP_REST_Server::CREATABLE,
63
-				'callback'            => array( $this, 'stop' ),
64
-				'permission_callback' => function () {
65
-					return current_user_can( 'manage_options' );
63
+				'callback'            => array($this, 'stop'),
64
+				'permission_callback' => function() {
65
+					return current_user_can('manage_options');
66 66
 				},
67 67
 			)
68 68
 		);
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 			'/background_analysis/stats',
75 75
 			array(
76 76
 				'methods'             => WP_REST_Server::CREATABLE,
77
-				'callback'            => array( $this, 'get_stats' ),
78
-				'permission_callback' => function () {
79
-					return current_user_can( 'manage_options' );
77
+				'callback'            => array($this, 'get_stats'),
78
+				'permission_callback' => function() {
79
+					return current_user_can('manage_options');
80 80
 				},
81 81
 			)
82 82
 		);
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 			'/background_analysis/restart',
90 90
 			array(
91 91
 				'methods'             => WP_REST_Server::CREATABLE,
92
-				'callback'            => array( $this, 'restart' ),
93
-				'permission_callback' => function () {
94
-					return current_user_can( 'manage_options' );
92
+				'callback'            => array($this, 'restart'),
93
+				'permission_callback' => function() {
94
+					return current_user_can('manage_options');
95 95
 				},
96 96
 			)
97 97
 		);
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 		/**
103 103
 		 * @var $state Sync_State
104 104
 		 */
105
-		$state = get_option( Analysis_Background_Process::WL_CMKG_ANALYSIS_BACKGROUND_PROCESS, Sync_State::unknown() );
105
+		$state = get_option(Analysis_Background_Process::WL_CMKG_ANALYSIS_BACKGROUND_PROCESS, Sync_State::unknown());
106 106
 
107 107
 		return $state->get_array();
108 108
 	}
@@ -122,16 +122,16 @@  discard block
 block discarded – undo
122 122
 DELETE FROM $wpdb->termmeta WHERE meta_key=%s OR meta_key=%s
123 123
 EOF;
124 124
 		// Remove the flags, if the tag is already accepted we wont remove that ui flag.
125
-		$query = $wpdb->prepare( $query, array(
125
+		$query = $wpdb->prepare($query, array(
126 126
 			Analysis_Background_Service::ANALYSIS_DONE_FLAG,
127 127
 			Analysis_Background_Service::ENTITIES_PRESENT_FOR_TERM
128
-		) );
129
-		$wpdb->query( $query );
128
+		));
129
+		$wpdb->query($query);
130 130
 		// clear the cache
131 131
 		$this->cache_service->flush_all();
132 132
 		$this->background_service->start();
133 133
 
134
-		return array( 'status' => 'restart_complete' );
134
+		return array('status' => 'restart_complete');
135 135
 	}
136 136
 
137 137
 
Please login to merge, or discard this patch.
src/wordlift/vocabulary/class-sync-state.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -4,56 +4,56 @@
 block discarded – undo
4 4
 
5 5
 class Sync_State {
6 6
 
7
-	public $started;
8
-	public $index;
9
-	public $count;
10
-	public $last_update;
11
-	public $state;
12
-
13
-	/**
14
-	 * Sync_Model constructor.
15
-	 *
16
-	 * @param $started
17
-	 * @param $index
18
-	 * @param $count
19
-	 * @param $last_update
20
-	 * @param $state
21
-	 */
22
-	public function __construct( $started, $index, $count, $last_update, $state ) {
23
-		$this->started     = $started;
24
-		$this->index       = $index;
25
-		$this->count       = (int) $count;
26
-		$this->last_update = $last_update;
27
-		$this->state       = $state;
28
-	}
29
-
30
-	public function increment_index( $count ) {
31
-		$this->index       += $count;
32
-		$this->last_update = time();
33
-
34
-		return $this;
35
-	}
36
-
37
-	public function set_state( $value ) {
38
-		$this->state       = $value;
39
-		$this->last_update = time();
40
-
41
-		return $this;
42
-	}
43
-
44
-	public function get_array() {
45
-		return array(
46
-			'started'     => $this->started,
47
-			'index'       => $this->index,
48
-			'count'       => $this->count,
49
-			'last_update' => $this->last_update,
50
-			'state'       => $this->state
51
-		);
52
-	}
53
-
54
-	public static function unknown() {
55
-
56
-		return new self( time(), 0, 0, time(), 'unknown' );
57
-	}
7
+    public $started;
8
+    public $index;
9
+    public $count;
10
+    public $last_update;
11
+    public $state;
12
+
13
+    /**
14
+     * Sync_Model constructor.
15
+     *
16
+     * @param $started
17
+     * @param $index
18
+     * @param $count
19
+     * @param $last_update
20
+     * @param $state
21
+     */
22
+    public function __construct( $started, $index, $count, $last_update, $state ) {
23
+        $this->started     = $started;
24
+        $this->index       = $index;
25
+        $this->count       = (int) $count;
26
+        $this->last_update = $last_update;
27
+        $this->state       = $state;
28
+    }
29
+
30
+    public function increment_index( $count ) {
31
+        $this->index       += $count;
32
+        $this->last_update = time();
33
+
34
+        return $this;
35
+    }
36
+
37
+    public function set_state( $value ) {
38
+        $this->state       = $value;
39
+        $this->last_update = time();
40
+
41
+        return $this;
42
+    }
43
+
44
+    public function get_array() {
45
+        return array(
46
+            'started'     => $this->started,
47
+            'index'       => $this->index,
48
+            'count'       => $this->count,
49
+            'last_update' => $this->last_update,
50
+            'state'       => $this->state
51
+        );
52
+    }
53
+
54
+    public static function unknown() {
55
+
56
+        return new self( time(), 0, 0, time(), 'unknown' );
57
+    }
58 58
 
59 59
 }
60 60
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @param $last_update
20 20
 	 * @param $state
21 21
 	 */
22
-	public function __construct( $started, $index, $count, $last_update, $state ) {
22
+	public function __construct($started, $index, $count, $last_update, $state) {
23 23
 		$this->started     = $started;
24 24
 		$this->index       = $index;
25 25
 		$this->count       = (int) $count;
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
 		$this->state       = $state;
28 28
 	}
29 29
 
30
-	public function increment_index( $count ) {
31
-		$this->index       += $count;
30
+	public function increment_index($count) {
31
+		$this->index += $count;
32 32
 		$this->last_update = time();
33 33
 
34 34
 		return $this;
35 35
 	}
36 36
 
37
-	public function set_state( $value ) {
37
+	public function set_state($value) {
38 38
 		$this->state       = $value;
39 39
 		$this->last_update = time();
40 40
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 	public static function unknown() {
45 45
 
46
-		return new self( time(), 0, 0, time(), 'unknown' );
46
+		return new self(time(), 0, 0, time(), 'unknown');
47 47
 	}
48 48
 
49 49
 }
50 50
\ No newline at end of file
Please login to merge, or discard this patch.
src/wordlift/vocabulary/class-analysis-background-service.php 2 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -6,135 +6,135 @@
 block discarded – undo
6 6
 class Analysis_Background_Service {
7 7
 
8 8
 
9
-	const ANALYSIS_DONE_FLAG = '_wl_cmkg_analysis_complete_for_term_options_cache';
10
-	const TERMS_COUNT_TRANSIENT = '_wl_cmkg_analysis_background_service_terms_count';
11
-	const ENTITIES_PRESENT_FOR_TERM = '_wl_cmkg_analysis_entities_present_for_term_options_cache';
12
-
13
-	/**
14
-	 * @var Analysis_Service
15
-	 */
16
-	private $analysis_service;
17
-	/**
18
-	 * @var Analysis_Background_Process
19
-	 */
20
-	private $analysis_background_process;
21
-
22
-	/**
23
-	 * @var \Wordlift_Log_Service
24
-	 */
25
-	private $log;
26
-
27
-
28
-	public function __construct( $analysis_service ) {
29
-
30
-		$this->analysis_service = $analysis_service;
31
-
32
-		$this->analysis_background_process = new Analysis_Background_Process( $this );
33
-
34
-		$this->log = \Wordlift_Log_Service::get_logger( get_class() );
35
-	}
36
-
37
-	public function start() {
38
-		$this->analysis_background_process->start();
39
-	}
40
-
41
-	public function cancel() {
42
-		$this->analysis_background_process->cancel();
43
-	}
44
-
45
-	public function stop() {
46
-		$this->analysis_background_process->cancel();
47
-		$this->analysis_background_process->request_cancel();
48
-	}
49
-
50
-	/**
51
-	 * A list of term ids.
52
-	 * @return int|\WP_Error|\WP_Term[]
53
-	 */
54
-	public function next() {
55
-
56
-		$state = $this->info();
57
-
58
-		return get_terms( array(
59
-			'fields'     => 'ids',
60
-			'taxonomy'   => 'post_tag',
61
-			'hide_empty' => false,
62
-			'number'     => $this->get_batch_size(),
63
-			'offset'     => $state->index,
64
-			'meta_query' => array(
65
-				array(
66
-					'key'     => self::ANALYSIS_DONE_FLAG,
67
-					'compare' => 'NOT EXISTS'
68
-				)
69
-			),
70
-		) );
71
-	}
72
-
73
-	public function count() {
74
-
75
-		$count = count( get_terms( array(
76
-			'fields'     => 'ids',
77
-			'taxonomy'   => 'post_tag',
78
-			'hide_empty' => false,
79
-			// return all terms, we cant pass -1 here.
80
-			'number'     => 0,
81
-			'meta_query' => array(
82
-				array(
83
-					'key'     => self::ANALYSIS_DONE_FLAG,
84
-					'compare' => 'NOT EXISTS'
85
-				)
86
-			),
87
-		) ) );
88
-
89
-		$this->log->debug( "Count returned as $count" );
90
-
91
-
92
-		return $count;
93
-	}
94
-
95
-	public function get_batch_size() {
96
-		return 10;
97
-	}
98
-
99
-	public function info() {
100
-		return Analysis_Background_Process::get_state();
101
-	}
102
-
103
-	/**
104
-	 * @param $term_ids
105
-	 *
106
-	 * @return bool
107
-	 */
108
-	public function perform_analysis_for_terms( $term_ids ) {
109
-
110
-		foreach ( $term_ids as $term_id ) {
111
-
112
-			$tag = get_term( $term_id );
113
-
114
-			// This adds the entities to ttl cache
115
-			$result = $this->analysis_service->get_entities( $tag );
9
+    const ANALYSIS_DONE_FLAG = '_wl_cmkg_analysis_complete_for_term_options_cache';
10
+    const TERMS_COUNT_TRANSIENT = '_wl_cmkg_analysis_background_service_terms_count';
11
+    const ENTITIES_PRESENT_FOR_TERM = '_wl_cmkg_analysis_entities_present_for_term_options_cache';
12
+
13
+    /**
14
+     * @var Analysis_Service
15
+     */
16
+    private $analysis_service;
17
+    /**
18
+     * @var Analysis_Background_Process
19
+     */
20
+    private $analysis_background_process;
21
+
22
+    /**
23
+     * @var \Wordlift_Log_Service
24
+     */
25
+    private $log;
26
+
27
+
28
+    public function __construct( $analysis_service ) {
29
+
30
+        $this->analysis_service = $analysis_service;
31
+
32
+        $this->analysis_background_process = new Analysis_Background_Process( $this );
33
+
34
+        $this->log = \Wordlift_Log_Service::get_logger( get_class() );
35
+    }
36
+
37
+    public function start() {
38
+        $this->analysis_background_process->start();
39
+    }
40
+
41
+    public function cancel() {
42
+        $this->analysis_background_process->cancel();
43
+    }
44
+
45
+    public function stop() {
46
+        $this->analysis_background_process->cancel();
47
+        $this->analysis_background_process->request_cancel();
48
+    }
49
+
50
+    /**
51
+     * A list of term ids.
52
+     * @return int|\WP_Error|\WP_Term[]
53
+     */
54
+    public function next() {
55
+
56
+        $state = $this->info();
57
+
58
+        return get_terms( array(
59
+            'fields'     => 'ids',
60
+            'taxonomy'   => 'post_tag',
61
+            'hide_empty' => false,
62
+            'number'     => $this->get_batch_size(),
63
+            'offset'     => $state->index,
64
+            'meta_query' => array(
65
+                array(
66
+                    'key'     => self::ANALYSIS_DONE_FLAG,
67
+                    'compare' => 'NOT EXISTS'
68
+                )
69
+            ),
70
+        ) );
71
+    }
72
+
73
+    public function count() {
74
+
75
+        $count = count( get_terms( array(
76
+            'fields'     => 'ids',
77
+            'taxonomy'   => 'post_tag',
78
+            'hide_empty' => false,
79
+            // return all terms, we cant pass -1 here.
80
+            'number'     => 0,
81
+            'meta_query' => array(
82
+                array(
83
+                    'key'     => self::ANALYSIS_DONE_FLAG,
84
+                    'compare' => 'NOT EXISTS'
85
+                )
86
+            ),
87
+        ) ) );
88
+
89
+        $this->log->debug( "Count returned as $count" );
90
+
91
+
92
+        return $count;
93
+    }
94
+
95
+    public function get_batch_size() {
96
+        return 10;
97
+    }
98
+
99
+    public function info() {
100
+        return Analysis_Background_Process::get_state();
101
+    }
102
+
103
+    /**
104
+     * @param $term_ids
105
+     *
106
+     * @return bool
107
+     */
108
+    public function perform_analysis_for_terms( $term_ids ) {
109
+
110
+        foreach ( $term_ids as $term_id ) {
111
+
112
+            $tag = get_term( $term_id );
113
+
114
+            // This adds the entities to ttl cache
115
+            $result = $this->analysis_service->get_entities( $tag );
116 116
 
117
-			$this->log->debug( "Received result " . var_export( $result ) . " for ${term_id}" );
117
+            $this->log->debug( "Received result " . var_export( $result ) . " for ${term_id}" );
118 118
 
119
-			if ( $result !== false ) {
120
-				// then set the analysis complete flag.
121
-				update_term_meta( $term_id, self::ANALYSIS_DONE_FLAG, 1 );
122
-				if ( count( $result ) > 0 ) {
123
-					update_term_meta( $term_id, self::ENTITIES_PRESENT_FOR_TERM, 1 );
124
-				}
125
-			}
119
+            if ( $result !== false ) {
120
+                // then set the analysis complete flag.
121
+                update_term_meta( $term_id, self::ANALYSIS_DONE_FLAG, 1 );
122
+                if ( count( $result ) > 0 ) {
123
+                    update_term_meta( $term_id, self::ENTITIES_PRESENT_FOR_TERM, 1 );
124
+                }
125
+            }
126 126
 
127
-		}
127
+        }
128 128
 
129
-		/**
130
-		 * This action fires when the analysis is complete for the current batch
131
-		 * @since 3.30.0
132
-		 */
133
-		do_action( 'wordlift_vocabulary_analysis_complete_for_terms_batch' );
134
-
135
-		return true;
136
-
137
-
138
-	}
129
+        /**
130
+         * This action fires when the analysis is complete for the current batch
131
+         * @since 3.30.0
132
+         */
133
+        do_action( 'wordlift_vocabulary_analysis_complete_for_terms_batch' );
134
+
135
+        return true;
136
+
137
+
138
+    }
139 139
 
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
 	private $log;
26 26
 
27 27
 
28
-	public function __construct( $analysis_service ) {
28
+	public function __construct($analysis_service) {
29 29
 
30 30
 		$this->analysis_service = $analysis_service;
31 31
 
32
-		$this->analysis_background_process = new Analysis_Background_Process( $this );
32
+		$this->analysis_background_process = new Analysis_Background_Process($this);
33 33
 
34
-		$this->log = \Wordlift_Log_Service::get_logger( get_class() );
34
+		$this->log = \Wordlift_Log_Service::get_logger(get_class());
35 35
 	}
36 36
 
37 37
 	public function start() {
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
 		$state = $this->info();
57 57
 
58
-		return get_terms( array(
58
+		return get_terms(array(
59 59
 			'fields'     => 'ids',
60 60
 			'taxonomy'   => 'post_tag',
61 61
 			'hide_empty' => false,
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
 					'compare' => 'NOT EXISTS'
68 68
 				)
69 69
 			),
70
-		) );
70
+		));
71 71
 	}
72 72
 
73 73
 	public function count() {
74 74
 
75
-		$count = count( get_terms( array(
75
+		$count = count(get_terms(array(
76 76
 			'fields'     => 'ids',
77 77
 			'taxonomy'   => 'post_tag',
78 78
 			'hide_empty' => false,
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 					'compare' => 'NOT EXISTS'
85 85
 				)
86 86
 			),
87
-		) ) );
87
+		)));
88 88
 
89
-		$this->log->debug( "Count returned as $count" );
89
+		$this->log->debug("Count returned as $count");
90 90
 
91 91
 
92 92
 		return $count;
@@ -105,22 +105,22 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @return bool
107 107
 	 */
108
-	public function perform_analysis_for_terms( $term_ids ) {
108
+	public function perform_analysis_for_terms($term_ids) {
109 109
 
110
-		foreach ( $term_ids as $term_id ) {
110
+		foreach ($term_ids as $term_id) {
111 111
 
112
-			$tag = get_term( $term_id );
112
+			$tag = get_term($term_id);
113 113
 
114 114
 			// This adds the entities to ttl cache
115
-			$result = $this->analysis_service->get_entities( $tag );
115
+			$result = $this->analysis_service->get_entities($tag);
116 116
 
117
-			$this->log->debug( "Received result " . var_export( $result ) . " for ${term_id}" );
117
+			$this->log->debug("Received result ".var_export($result)." for ${term_id}");
118 118
 
119
-			if ( $result !== false ) {
119
+			if ($result !== false) {
120 120
 				// then set the analysis complete flag.
121
-				update_term_meta( $term_id, self::ANALYSIS_DONE_FLAG, 1 );
122
-				if ( count( $result ) > 0 ) {
123
-					update_term_meta( $term_id, self::ENTITIES_PRESENT_FOR_TERM, 1 );
121
+				update_term_meta($term_id, self::ANALYSIS_DONE_FLAG, 1);
122
+				if (count($result) > 0) {
123
+					update_term_meta($term_id, self::ENTITIES_PRESENT_FOR_TERM, 1);
124 124
 				}
125 125
 			}
126 126
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		 * This action fires when the analysis is complete for the current batch
131 131
 		 * @since 3.30.0
132 132
 		 */
133
-		do_action( 'wordlift_vocabulary_analysis_complete_for_terms_batch' );
133
+		do_action('wordlift_vocabulary_analysis_complete_for_terms_batch');
134 134
 
135 135
 		return true;
136 136
 
Please login to merge, or discard this patch.
src/wordlift/vocabulary/pages/class-match-terms.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -12,55 +12,55 @@
 block discarded – undo
12 12
  * @author Naveen Muthusamy <[email protected]>
13 13
  */
14 14
 class Match_Terms {
15
-	/**
16
-	 * @var Term_Count
17
-	 */
18
-	private $term_count;
15
+    /**
16
+     * @var Term_Count
17
+     */
18
+    private $term_count;
19 19
 
20
-	/**
21
-	 * Match_Terms constructor.
22
-	 *
23
-	 * @param $term_count Term_Count
24
-	 */
25
-	public function __construct( $term_count ) {
20
+    /**
21
+     * Match_Terms constructor.
22
+     *
23
+     * @param $term_count Term_Count
24
+     */
25
+    public function __construct( $term_count ) {
26 26
 
27
-		$this->term_count = $term_count;
28
-		add_action( 'admin_menu', array( $this, 'admin_menu', ) );
27
+        $this->term_count = $term_count;
28
+        add_action( 'admin_menu', array( $this, 'admin_menu', ) );
29 29
 
30
-	}
30
+    }
31 31
 
32
-	public function admin_menu() {
33
-		$number = $this->term_count->get_term_count();
34
-		add_submenu_page(
35
-			'wl_admin_menu',
36
-			__( 'Match Terms', 'wordlift' ),
37
-			__( 'Match Terms', 'wordlift' ) . " " . Badge_Generator::generate_html($number),
38
-			'manage_options',
39
-			'wl-vocabulary-match-terms',
40
-			array( $this, 'submenu_page_callback' )
41
-		);
42
-	}
32
+    public function admin_menu() {
33
+        $number = $this->term_count->get_term_count();
34
+        add_submenu_page(
35
+            'wl_admin_menu',
36
+            __( 'Match Terms', 'wordlift' ),
37
+            __( 'Match Terms', 'wordlift' ) . " " . Badge_Generator::generate_html($number),
38
+            'manage_options',
39
+            'wl-vocabulary-match-terms',
40
+            array( $this, 'submenu_page_callback' )
41
+        );
42
+    }
43 43
 
44 44
 
45 45
 
46 46
 
47 47
 
48
-	public function submenu_page_callback() {
48
+    public function submenu_page_callback() {
49 49
 
50
-		Scripts_Helper::enqueue_based_on_wordpress_version(
51
-			'wl-vocabulary-reconcile-script',
52
-			plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/vocabulary',
53
-			array( 'react', 'react-dom', 'wp-polyfill' ),
54
-			true
55
-		);
50
+        Scripts_Helper::enqueue_based_on_wordpress_version(
51
+            'wl-vocabulary-reconcile-script',
52
+            plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/vocabulary',
53
+            array( 'react', 'react-dom', 'wp-polyfill' ),
54
+            true
55
+        );
56 56
 
57 57
 
58
-		wp_enqueue_style( 'wl-vocabulary-reconcile-script',
59
-			plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . "js/dist/vocabulary.full.css" );
60
-		wp_localize_script( 'wl-vocabulary-reconcile-script', '_wlVocabularyMatchTermsConfig', Api_Config::get_api_config() );
61
-		echo "<div id='wl_cmkg_background_process' class='wrap'></div>";
62
-		echo "<div id='wl_cmkg_reconcile_progress' class='wrap'></div>";
63
-		echo "<div id='wl_cmkg_table' class='wrap'></div>";
64
-	}
58
+        wp_enqueue_style( 'wl-vocabulary-reconcile-script',
59
+            plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . "js/dist/vocabulary.full.css" );
60
+        wp_localize_script( 'wl-vocabulary-reconcile-script', '_wlVocabularyMatchTermsConfig', Api_Config::get_api_config() );
61
+        echo "<div id='wl_cmkg_background_process' class='wrap'></div>";
62
+        echo "<div id='wl_cmkg_reconcile_progress' class='wrap'></div>";
63
+        echo "<div id='wl_cmkg_table' class='wrap'></div>";
64
+    }
65 65
 
66 66
 }
67 67
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param $term_count Term_Count
24 24
 	 */
25
-	public function __construct( $term_count ) {
25
+	public function __construct($term_count) {
26 26
 
27 27
 		$this->term_count = $term_count;
28
-		add_action( 'admin_menu', array( $this, 'admin_menu', ) );
28
+		add_action('admin_menu', array($this, 'admin_menu',));
29 29
 
30 30
 	}
31 31
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 		$number = $this->term_count->get_term_count();
34 34
 		add_submenu_page(
35 35
 			'wl_admin_menu',
36
-			__( 'Match Terms', 'wordlift' ),
37
-			__( 'Match Terms', 'wordlift' ) . " " . Badge_Generator::generate_html($number),
36
+			__('Match Terms', 'wordlift'),
37
+			__('Match Terms', 'wordlift')." ".Badge_Generator::generate_html($number),
38 38
 			'manage_options',
39 39
 			'wl-vocabulary-match-terms',
40
-			array( $this, 'submenu_page_callback' )
40
+			array($this, 'submenu_page_callback')
41 41
 		);
42 42
 	}
43 43
 
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
 
50 50
 		Scripts_Helper::enqueue_based_on_wordpress_version(
51 51
 			'wl-vocabulary-reconcile-script',
52
-			plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/vocabulary',
53
-			array( 'react', 'react-dom', 'wp-polyfill' ),
52
+			plugin_dir_url(dirname(dirname(__DIR__))).'js/dist/vocabulary',
53
+			array('react', 'react-dom', 'wp-polyfill'),
54 54
 			true
55 55
 		);
56 56
 
57 57
 
58
-		wp_enqueue_style( 'wl-vocabulary-reconcile-script',
59
-			plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . "js/dist/vocabulary.full.css" );
60
-		wp_localize_script( 'wl-vocabulary-reconcile-script', '_wlVocabularyMatchTermsConfig', Api_Config::get_api_config() );
58
+		wp_enqueue_style('wl-vocabulary-reconcile-script',
59
+			plugin_dir_url(dirname(dirname(__DIR__)))."js/dist/vocabulary.full.css");
60
+		wp_localize_script('wl-vocabulary-reconcile-script', '_wlVocabularyMatchTermsConfig', Api_Config::get_api_config());
61 61
 		echo "<div id='wl_cmkg_background_process' class='wrap'></div>";
62 62
 		echo "<div id='wl_cmkg_reconcile_progress' class='wrap'></div>";
63 63
 		echo "<div id='wl_cmkg_table' class='wrap'></div>";
Please login to merge, or discard this patch.
src/wordlift/vocabulary/dashboard/class-term-matches-widget.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -9,35 +9,35 @@  discard block
 block discarded – undo
9 9
  * @author Naveen Muthusamy <[email protected]>
10 10
  */
11 11
 class Term_Matches_Widget {
12
-	/**
13
-	 * @var Term_Count
14
-	 */
15
-	private $term_count;
12
+    /**
13
+     * @var Term_Count
14
+     */
15
+    private $term_count;
16 16
 
17
-	/**
18
-	 * Term_Matches_Widget constructor.
19
-	 *
20
-	 * @param $term_count Term_Count
21
-	 */
22
-	public function __construct( $term_count ) {
23
-		$this->term_count = $term_count;
24
-	}
17
+    /**
18
+     * Term_Matches_Widget constructor.
19
+     *
20
+     * @param $term_count Term_Count
21
+     */
22
+    public function __construct( $term_count ) {
23
+        $this->term_count = $term_count;
24
+    }
25 25
 
26
-	public function connect_hook() {
27
-		add_action( 'wl_admin_dashboard_widgets', array( $this, 'render_widget' ) );
28
-	}
26
+    public function connect_hook() {
27
+        add_action( 'wl_admin_dashboard_widgets', array( $this, 'render_widget' ) );
28
+    }
29 29
 
30
-	public function render_widget() {
31
-		$term_count  = $this->term_count->get_term_count();
32
-		if ( $term_count <= 0 ) {
33
-			return;
34
-		}
30
+    public function render_widget() {
31
+        $term_count  = $this->term_count->get_term_count();
32
+        if ( $term_count <= 0 ) {
33
+            return;
34
+        }
35 35
 
36
-		$match_terms_url = menu_page_url('wl-vocabulary-match-terms', false);
37
-		$term_count_link = "<a href='$match_terms_url'>" . $term_count . " term(s)</a>";
38
-		$match_terms = __('Match terms', 'wordlift');
39
-		$additional_text = __(' waiting to be matched with entities.', 'wordlift');
40
-		echo <<<EOF
36
+        $match_terms_url = menu_page_url('wl-vocabulary-match-terms', false);
37
+        $term_count_link = "<a href='$match_terms_url'>" . $term_count . " term(s)</a>";
38
+        $match_terms = __('Match terms', 'wordlift');
39
+        $additional_text = __(' waiting to be matched with entities.', 'wordlift');
40
+        echo <<<EOF
41 41
         <div id="wl-match-terms" class="wl-dashboard__block wl-dashboard__block--match-terms">
42 42
             <header>
43 43
                 <h3>$match_terms</h3>
@@ -47,6 +47,6 @@  discard block
 block discarded – undo
47 47
                 </p>
48 48
         </div>
49 49
 EOF;
50
-	}
50
+    }
51 51
 
52 52
 }
53 53
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,22 +19,22 @@
 block discarded – undo
19 19
 	 *
20 20
 	 * @param $term_count Term_Count
21 21
 	 */
22
-	public function __construct( $term_count ) {
22
+	public function __construct($term_count) {
23 23
 		$this->term_count = $term_count;
24 24
 	}
25 25
 
26 26
 	public function connect_hook() {
27
-		add_action( 'wl_admin_dashboard_widgets', array( $this, 'render_widget' ) );
27
+		add_action('wl_admin_dashboard_widgets', array($this, 'render_widget'));
28 28
 	}
29 29
 
30 30
 	public function render_widget() {
31
-		$term_count  = $this->term_count->get_term_count();
32
-		if ( $term_count <= 0 ) {
31
+		$term_count = $this->term_count->get_term_count();
32
+		if ($term_count <= 0) {
33 33
 			return;
34 34
 		}
35 35
 
36 36
 		$match_terms_url = menu_page_url('wl-vocabulary-match-terms', false);
37
-		$term_count_link = "<a href='$match_terms_url'>" . $term_count . " term(s)</a>";
37
+		$term_count_link = "<a href='$match_terms_url'>".$term_count." term(s)</a>";
38 38
 		$match_terms = __('Match terms', 'wordlift');
39 39
 		$additional_text = __(' waiting to be matched with entities.', 'wordlift');
40 40
 		echo <<<EOF
Please login to merge, or discard this patch.
src/wordlift/vocabulary/hooks/class-tag-created-hook.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,23 +6,23 @@
 block discarded – undo
6 6
 
7 7
 class Tag_Created_Hook {
8 8
 
9
-	/**
10
-	 * @var $analysis_background_service Analysis_Background_Service
11
-	 */
12
-	private $analysis_background_service;
9
+    /**
10
+     * @var $analysis_background_service Analysis_Background_Service
11
+     */
12
+    private $analysis_background_service;
13 13
 
14
-	/**
15
-	 * Tag_Created_Hook constructor.
16
-	 *
17
-	 * @param $analysis_background_service Analysis_Background_Service
18
-	 */
19
-	public function __construct( $analysis_background_service ) {
20
-		$this->analysis_background_service = $analysis_background_service;
21
-		add_action( 'created_post_tag', array( $this, 'created_post_tag' ) );
22
-	}
14
+    /**
15
+     * Tag_Created_Hook constructor.
16
+     *
17
+     * @param $analysis_background_service Analysis_Background_Service
18
+     */
19
+    public function __construct( $analysis_background_service ) {
20
+        $this->analysis_background_service = $analysis_background_service;
21
+        add_action( 'created_post_tag', array( $this, 'created_post_tag' ) );
22
+    }
23 23
 
24
-	public function created_post_tag() {
25
-		$this->analysis_background_service->start();
26
-	}
24
+    public function created_post_tag() {
25
+        $this->analysis_background_service->start();
26
+    }
27 27
 
28 28
 }
29 29
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
 	 *
17 17
 	 * @param $analysis_background_service Analysis_Background_Service
18 18
 	 */
19
-	public function __construct( $analysis_background_service ) {
19
+	public function __construct($analysis_background_service) {
20 20
 		$this->analysis_background_service = $analysis_background_service;
21
-		add_action( 'created_post_tag', array( $this, 'created_post_tag' ) );
21
+		add_action('created_post_tag', array($this, 'created_post_tag'));
22 22
 	}
23 23
 
24 24
 	public function created_post_tag() {
Please login to merge, or discard this patch.
src/wordlift/vocabulary/class-options-cache.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,40 +4,40 @@
 block discarded – undo
4 4
 
5 5
 class Options_Cache {
6 6
 
7
-	private $namespace;
7
+    private $namespace;
8 8
 
9
-	/**
10
-	 * Options_Cache constructor.
11
-	 *
12
-	 * @param $namespace
13
-	 */
14
-	public function __construct( $namespace ) {
15
-		$this->namespace = $namespace;
16
-	}
9
+    /**
10
+     * Options_Cache constructor.
11
+     *
12
+     * @param $namespace
13
+     */
14
+    public function __construct( $namespace ) {
15
+        $this->namespace = $namespace;
16
+    }
17 17
 
18 18
 
19
-	public function get( $cache_key ) {
19
+    public function get( $cache_key ) {
20 20
 
21
-		return get_option( $this->namespace . '__' . $cache_key, false );
21
+        return get_option( $this->namespace . '__' . $cache_key, false );
22 22
 
23
-	}
23
+    }
24 24
 
25 25
 
26
-	public function put( $cache_key, $value ) {
26
+    public function put( $cache_key, $value ) {
27 27
 
28
-		return update_option( $this->namespace . '__' . $cache_key, $value );
28
+        return update_option( $this->namespace . '__' . $cache_key, $value );
29 29
 
30
-	}
30
+    }
31 31
 
32
-	public function flush_all() {
33
-		if ( $this->namespace !== '' ) {
34
-			global $wpdb;
35
-			$options_table_name = $wpdb->options;
36
-			$namespace_esc = $wpdb->esc_like( $this->namespace ) . '__%';
37
-			$sql         = $wpdb->prepare( "DELETE FROM $options_table_name WHERE option_name LIKE %s", $namespace_esc );
38
-			$wpdb->query( $sql );
39
-		}
40
-	}
32
+    public function flush_all() {
33
+        if ( $this->namespace !== '' ) {
34
+            global $wpdb;
35
+            $options_table_name = $wpdb->options;
36
+            $namespace_esc = $wpdb->esc_like( $this->namespace ) . '__%';
37
+            $sql         = $wpdb->prepare( "DELETE FROM $options_table_name WHERE option_name LIKE %s", $namespace_esc );
38
+            $wpdb->query( $sql );
39
+        }
40
+    }
41 41
 
42 42
 
43 43
 }
44 44
\ 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
@@ -11,31 +11,31 @@
 block discarded – undo
11 11
 	 *
12 12
 	 * @param $namespace
13 13
 	 */
14
-	public function __construct( $namespace ) {
14
+	public function __construct($namespace) {
15 15
 		$this->namespace = $namespace;
16 16
 	}
17 17
 
18 18
 
19
-	public function get( $cache_key ) {
19
+	public function get($cache_key) {
20 20
 
21
-		return get_option( $this->namespace . '__' . $cache_key, false );
21
+		return get_option($this->namespace.'__'.$cache_key, false);
22 22
 
23 23
 	}
24 24
 
25 25
 
26
-	public function put( $cache_key, $value ) {
26
+	public function put($cache_key, $value) {
27 27
 
28
-		return update_option( $this->namespace . '__' . $cache_key, $value );
28
+		return update_option($this->namespace.'__'.$cache_key, $value);
29 29
 
30 30
 	}
31 31
 
32 32
 	public function flush_all() {
33
-		if ( $this->namespace !== '' ) {
33
+		if ($this->namespace !== '') {
34 34
 			global $wpdb;
35 35
 			$options_table_name = $wpdb->options;
36
-			$namespace_esc = $wpdb->esc_like( $this->namespace ) . '__%';
37
-			$sql         = $wpdb->prepare( "DELETE FROM $options_table_name WHERE option_name LIKE %s", $namespace_esc );
38
-			$wpdb->query( $sql );
36
+			$namespace_esc = $wpdb->esc_like($this->namespace).'__%';
37
+			$sql = $wpdb->prepare("DELETE FROM $options_table_name WHERE option_name LIKE %s", $namespace_esc);
38
+			$wpdb->query($sql);
39 39
 		}
40 40
 	}
41 41
 
Please login to merge, or discard this patch.
src/wordlift/vocabulary/class-vocabulary-loader.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -19,56 +19,56 @@
 block discarded – undo
19 19
 
20 20
 class Vocabulary_Loader {
21 21
 
22
-	public function init_vocabulary() {
22
+    public function init_vocabulary() {
23 23
 
24
-		$configuration_service = \Wordlift_Configuration_Service::get_instance();
24
+        $configuration_service = \Wordlift_Configuration_Service::get_instance();
25 25
 
26
-		$api_service = new Default_Api_Service(
27
-			apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ),
28
-			60,
29
-			User_Agent::get_user_agent(),
30
-			$configuration_service->get_key()
31
-		);
26
+        $api_service = new Default_Api_Service(
27
+            apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ),
28
+            60,
29
+            User_Agent::get_user_agent(),
30
+            $configuration_service->get_key()
31
+        );
32 32
 
33
-		$cache_service    = new Options_Cache( "wordlift-cmkg" );
34
-		$analysis_service = new Analysis_Service( $api_service, $cache_service );
33
+        $cache_service    = new Options_Cache( "wordlift-cmkg" );
34
+        $analysis_service = new Analysis_Service( $api_service, $cache_service );
35 35
 
36
-		$term_data_factory = new Term_Data_Factory( $analysis_service );
36
+        $term_data_factory = new Term_Data_Factory( $analysis_service );
37 37
 
38
-		$tag_rest_endpoint = new Tag_Rest_Endpoint( $term_data_factory );
39
-		$tag_rest_endpoint->register_routes();
38
+        $tag_rest_endpoint = new Tag_Rest_Endpoint( $term_data_factory );
39
+        $tag_rest_endpoint->register_routes();
40 40
 
41
-		$entity_rest_endpoint = new Entity_Rest_Endpoint();
42
-		$entity_rest_endpoint->register_routes();
41
+        $entity_rest_endpoint = new Entity_Rest_Endpoint();
42
+        $entity_rest_endpoint->register_routes();
43 43
 
44
-		$post_jsonld = new Post_Jsonld();
45
-		$post_jsonld->enhance_post_jsonld();
44
+        $post_jsonld = new Post_Jsonld();
45
+        $post_jsonld->enhance_post_jsonld();
46 46
 
47
-		$term_count = Term_Count_Factory::get_instance( Term_Count_Factory::CACHED_TERM_COUNT );
48
-		new Match_Terms( $term_count );
47
+        $term_count = Term_Count_Factory::get_instance( Term_Count_Factory::CACHED_TERM_COUNT );
48
+        new Match_Terms( $term_count );
49 49
 
50
-		$analysis_background_service = new Analysis_Background_Service( $analysis_service );
50
+        $analysis_background_service = new Analysis_Background_Service( $analysis_service );
51 51
 
52 52
 
53
-		new Tag_Created_Hook( $analysis_background_service );
53
+        new Tag_Created_Hook( $analysis_background_service );
54 54
 
55
-		new Background_Analysis_Endpoint( $analysis_background_service, $cache_service );
55
+        new Background_Analysis_Endpoint( $analysis_background_service, $cache_service );
56 56
 
57
-		$reconcile_progress_endpoint = new Reconcile_Progress_Endpoint();
58
-		$reconcile_progress_endpoint->register_routes();
57
+        $reconcile_progress_endpoint = new Reconcile_Progress_Endpoint();
58
+        $reconcile_progress_endpoint->register_routes();
59 59
 
60 60
 
61
-		$term_page_hook = new Term_Page_Hook( $term_data_factory );
62
-		$term_page_hook->connect_hook();
61
+        $term_page_hook = new Term_Page_Hook( $term_data_factory );
62
+        $term_page_hook->connect_hook();
63 63
 
64
-		$dashboard_widget = new Term_Matches_Widget( $term_count );
65
-		$dashboard_widget->connect_hook();
64
+        $dashboard_widget = new Term_Matches_Widget( $term_count );
65
+        $dashboard_widget->connect_hook();
66 66
 
67
-		$cached_term_count_manager = new Cached_Term_count_Manager();
68
-		$cached_term_count_manager->connect_hook();
67
+        $cached_term_count_manager = new Cached_Term_count_Manager();
68
+        $cached_term_count_manager->connect_hook();
69 69
 
70 70
 
71
-	}
71
+    }
72 72
 
73 73
 }
74 74
 
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,18 +24,18 @@  discard block
 block discarded – undo
24 24
 		$configuration_service = \Wordlift_Configuration_Service::get_instance();
25 25
 
26 26
 		$api_service = new Default_Api_Service(
27
-			apply_filters( 'wl_api_base_url', 'https://api.wordlift.io' ),
27
+			apply_filters('wl_api_base_url', 'https://api.wordlift.io'),
28 28
 			60,
29 29
 			User_Agent::get_user_agent(),
30 30
 			$configuration_service->get_key()
31 31
 		);
32 32
 
33
-		$cache_service    = new Options_Cache( "wordlift-cmkg" );
34
-		$analysis_service = new Analysis_Service( $api_service, $cache_service );
33
+		$cache_service    = new Options_Cache("wordlift-cmkg");
34
+		$analysis_service = new Analysis_Service($api_service, $cache_service);
35 35
 
36
-		$term_data_factory = new Term_Data_Factory( $analysis_service );
36
+		$term_data_factory = new Term_Data_Factory($analysis_service);
37 37
 
38
-		$tag_rest_endpoint = new Tag_Rest_Endpoint( $term_data_factory );
38
+		$tag_rest_endpoint = new Tag_Rest_Endpoint($term_data_factory);
39 39
 		$tag_rest_endpoint->register_routes();
40 40
 
41 41
 		$entity_rest_endpoint = new Entity_Rest_Endpoint();
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
 		$post_jsonld = new Post_Jsonld();
45 45
 		$post_jsonld->enhance_post_jsonld();
46 46
 
47
-		$term_count = Term_Count_Factory::get_instance( Term_Count_Factory::CACHED_TERM_COUNT );
48
-		new Match_Terms( $term_count );
47
+		$term_count = Term_Count_Factory::get_instance(Term_Count_Factory::CACHED_TERM_COUNT);
48
+		new Match_Terms($term_count);
49 49
 
50
-		$analysis_background_service = new Analysis_Background_Service( $analysis_service );
50
+		$analysis_background_service = new Analysis_Background_Service($analysis_service);
51 51
 
52 52
 
53
-		new Tag_Created_Hook( $analysis_background_service );
53
+		new Tag_Created_Hook($analysis_background_service);
54 54
 
55
-		new Background_Analysis_Endpoint( $analysis_background_service, $cache_service );
55
+		new Background_Analysis_Endpoint($analysis_background_service, $cache_service);
56 56
 
57 57
 		$reconcile_progress_endpoint = new Reconcile_Progress_Endpoint();
58 58
 		$reconcile_progress_endpoint->register_routes();
59 59
 
60 60
 
61
-		$term_page_hook = new Term_Page_Hook( $term_data_factory );
61
+		$term_page_hook = new Term_Page_Hook($term_data_factory);
62 62
 		$term_page_hook->connect_hook();
63 63
 
64
-		$dashboard_widget = new Term_Matches_Widget( $term_count );
64
+		$dashboard_widget = new Term_Matches_Widget($term_count);
65 65
 		$dashboard_widget->connect_hook();
66 66
 
67 67
 		$cached_term_count_manager = new Cached_Term_count_Manager();
Please login to merge, or discard this patch.