Completed
Pull Request — master (#1641)
by Naveen
01:35
created
src/wordlift/vocabulary/tabs/class-settings-tab.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -14,25 +14,25 @@
 block discarded – undo
14 14
  */
15 15
 class Settings_Tab {
16 16
 
17
-	public function connect_hook() {
18
-		add_filter(
19
-			'wl_admin_page_tabs',
20
-			function ( $tabs ) {
21
-				$tabs[] = array(
22
-					'slug'  => 'match-terms',
23
-					'title' => __( 'Match Terms', 'wordlift' ),
24
-				);
25
-				return $tabs;
26
-			}
27
-		);
17
+    public function connect_hook() {
18
+        add_filter(
19
+            'wl_admin_page_tabs',
20
+            function ( $tabs ) {
21
+                $tabs[] = array(
22
+                    'slug'  => 'match-terms',
23
+                    'title' => __( 'Match Terms', 'wordlift' ),
24
+                );
25
+                return $tabs;
26
+            }
27
+        );
28 28
 
29
-		add_filter(
30
-			'wl_admin_settings',
31
-			function ( $settings ) {
32
-				$settings['matchTerms'] = Api_Config::get_api_config();
33
-				return $settings;
34
-			}
35
-		);
36
-	}
29
+        add_filter(
30
+            'wl_admin_settings',
31
+            function ( $settings ) {
32
+                $settings['matchTerms'] = Api_Config::get_api_config();
33
+                return $settings;
34
+            }
35
+        );
36
+    }
37 37
 
38 38
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 	public function connect_hook() {
18 18
 		add_filter(
19 19
 			'wl_admin_page_tabs',
20
-			function ( $tabs ) {
20
+			function($tabs) {
21 21
 				$tabs[] = array(
22 22
 					'slug'  => 'match-terms',
23
-					'title' => __( 'Match Terms', 'wordlift' ),
23
+					'title' => __('Match Terms', 'wordlift'),
24 24
 				);
25 25
 				return $tabs;
26 26
 			}
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 		add_filter(
30 30
 			'wl_admin_settings',
31
-			function ( $settings ) {
31
+			function($settings) {
32 32
 				$settings['matchTerms'] = Api_Config::get_api_config();
33 33
 				return $settings;
34 34
 			}
Please login to merge, or discard this patch.
src/wordlift/vocabulary/class-terms-compat.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,19 +3,19 @@
 block discarded – undo
3 3
 
4 4
 class Terms_Compat {
5 5
 
6
-	public static function get_terms( $taxonomy, $args ) {
7
-		global $wp_version;
6
+    public static function get_terms( $taxonomy, $args ) {
7
+        global $wp_version;
8 8
 
9
-		if ( version_compare( $wp_version, '4.5', '<' ) ) {
10
-			return get_terms( $taxonomy, $args );
11
-		} else {
12
-			$args['taxonomy'] = $taxonomy;
13
-			return get_terms( $args );
14
-		}
15
-	}
9
+        if ( version_compare( $wp_version, '4.5', '<' ) ) {
10
+            return get_terms( $taxonomy, $args );
11
+        } else {
12
+            $args['taxonomy'] = $taxonomy;
13
+            return get_terms( $args );
14
+        }
15
+    }
16 16
 
17
-	public static function get_public_taxonomies() {
18
-		return get_taxonomies( array( 'public' => true ) );
19
-	}
17
+    public static function get_public_taxonomies() {
18
+        return get_taxonomies( array( 'public' => true ) );
19
+    }
20 20
 
21 21
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -3,19 +3,19 @@
 block discarded – undo
3 3
 
4 4
 class Terms_Compat {
5 5
 
6
-	public static function get_terms( $taxonomy, $args ) {
6
+	public static function get_terms($taxonomy, $args) {
7 7
 		global $wp_version;
8 8
 
9
-		if ( version_compare( $wp_version, '4.5', '<' ) ) {
10
-			return get_terms( $taxonomy, $args );
9
+		if (version_compare($wp_version, '4.5', '<')) {
10
+			return get_terms($taxonomy, $args);
11 11
 		} else {
12 12
 			$args['taxonomy'] = $taxonomy;
13
-			return get_terms( $args );
13
+			return get_terms($args);
14 14
 		}
15 15
 	}
16 16
 
17 17
 	public static function get_public_taxonomies() {
18
-		return get_taxonomies( array( 'public' => true ) );
18
+		return get_taxonomies(array('public' => true));
19 19
 	}
20 20
 
21 21
 }
Please login to merge, or discard this patch.
src/wordlift/vocabulary/class-vocabulary-loader.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -22,54 +22,54 @@
 block discarded – undo
22 22
 
23 23
 class Vocabulary_Loader {
24 24
 
25
-	public function init_vocabulary() {
25
+    public function init_vocabulary() {
26 26
 
27
-		$api_service   = Default_Api_Service::get_instance();
28
-		$cache_service = Cache_Service_Factory::get_cache_service();
27
+        $api_service   = Default_Api_Service::get_instance();
28
+        $cache_service = Cache_Service_Factory::get_cache_service();
29 29
 
30
-		$analysis_service = new Analysis_Service( $api_service, $cache_service );
30
+        $analysis_service = new Analysis_Service( $api_service, $cache_service );
31 31
 
32
-		$term_data_factory = new Term_Data_Factory( $analysis_service );
32
+        $term_data_factory = new Term_Data_Factory( $analysis_service );
33 33
 
34
-		$tag_rest_endpoint = new Tag_Rest_Endpoint( $term_data_factory );
35
-		$tag_rest_endpoint->register_routes();
34
+        $tag_rest_endpoint = new Tag_Rest_Endpoint( $term_data_factory );
35
+        $tag_rest_endpoint->register_routes();
36 36
 
37
-		new Search_Entity_Rest_Endpoint( $analysis_service, $cache_service );
37
+        new Search_Entity_Rest_Endpoint( $analysis_service, $cache_service );
38 38
 
39
-		$entity_rest_endpoint = new Entity_Rest_Endpoint();
40
-		$entity_rest_endpoint->register_routes();
39
+        $entity_rest_endpoint = new Entity_Rest_Endpoint();
40
+        $entity_rest_endpoint->register_routes();
41 41
 
42
-		$post_jsonld = new Post_Jsonld();
43
-		$post_jsonld->enhance_post_jsonld();
42
+        $post_jsonld = new Post_Jsonld();
43
+        $post_jsonld->enhance_post_jsonld();
44 44
 
45
-		$term_jsonld = new Term_Jsonld();
46
-		$term_jsonld->init();
45
+        $term_jsonld = new Term_Jsonld();
46
+        $term_jsonld->init();
47 47
 
48
-		$term_count = Term_Count_Factory::get_instance( Term_Count_Factory::CACHED_TERM_COUNT );
49
-		new Match_Terms( $term_count );
48
+        $term_count = Term_Count_Factory::get_instance( Term_Count_Factory::CACHED_TERM_COUNT );
49
+        new Match_Terms( $term_count );
50 50
 
51
-		$analysis_background_service = new Analysis_Background_Service( $analysis_service );
51
+        $analysis_background_service = new Analysis_Background_Service( $analysis_service );
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
-		$term_page_hook = new Term_Page_Hook( $term_data_factory );
61
-		$term_page_hook->connect_hook();
60
+        $term_page_hook = new Term_Page_Hook( $term_data_factory );
61
+        $term_page_hook->connect_hook();
62 62
 
63
-		$dashboard_widget = new Term_Matches_Widget( $term_count );
64
-		$dashboard_widget->connect_hook();
63
+        $dashboard_widget = new Term_Matches_Widget( $term_count );
64
+        $dashboard_widget->connect_hook();
65 65
 
66
-		$cached_term_count_manager = new Cached_Term_Count_Manager();
67
-		$cached_term_count_manager->connect_hook();
66
+        $cached_term_count_manager = new Cached_Term_Count_Manager();
67
+        $cached_term_count_manager->connect_hook();
68 68
 
69
-		$settings_tab = new Settings_Tab();
70
-		$settings_tab->connect_hook();
69
+        $settings_tab = new Settings_Tab();
70
+        $settings_tab->connect_hook();
71 71
 
72
-	}
72
+    }
73 73
 
74 74
 }
75 75
 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
 		$api_service   = Default_Api_Service::get_instance();
28 28
 		$cache_service = Cache_Service_Factory::get_cache_service();
29 29
 
30
-		$analysis_service = new Analysis_Service( $api_service, $cache_service );
30
+		$analysis_service = new Analysis_Service($api_service, $cache_service);
31 31
 
32
-		$term_data_factory = new Term_Data_Factory( $analysis_service );
32
+		$term_data_factory = new Term_Data_Factory($analysis_service);
33 33
 
34
-		$tag_rest_endpoint = new Tag_Rest_Endpoint( $term_data_factory );
34
+		$tag_rest_endpoint = new Tag_Rest_Endpoint($term_data_factory);
35 35
 		$tag_rest_endpoint->register_routes();
36 36
 
37
-		new Search_Entity_Rest_Endpoint( $analysis_service, $cache_service );
37
+		new Search_Entity_Rest_Endpoint($analysis_service, $cache_service);
38 38
 
39 39
 		$entity_rest_endpoint = new Entity_Rest_Endpoint();
40 40
 		$entity_rest_endpoint->register_routes();
@@ -45,22 +45,22 @@  discard block
 block discarded – undo
45 45
 		$term_jsonld = new Term_Jsonld();
46 46
 		$term_jsonld->init();
47 47
 
48
-		$term_count = Term_Count_Factory::get_instance( Term_Count_Factory::CACHED_TERM_COUNT );
49
-		new Match_Terms( $term_count );
48
+		$term_count = Term_Count_Factory::get_instance(Term_Count_Factory::CACHED_TERM_COUNT);
49
+		new Match_Terms($term_count);
50 50
 
51
-		$analysis_background_service = new Analysis_Background_Service( $analysis_service );
51
+		$analysis_background_service = new Analysis_Background_Service($analysis_service);
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
-		$term_page_hook = new Term_Page_Hook( $term_data_factory );
60
+		$term_page_hook = new Term_Page_Hook($term_data_factory);
61 61
 		$term_page_hook->connect_hook();
62 62
 
63
-		$dashboard_widget = new Term_Matches_Widget( $term_count );
63
+		$dashboard_widget = new Term_Matches_Widget($term_count);
64 64
 		$dashboard_widget->connect_hook();
65 65
 
66 66
 		$cached_term_count_manager = new Cached_Term_Count_Manager();
Please login to merge, or discard this patch.
src/wordlift/vocabulary/api/class-search-entity-rest-endpoint.php 2 patches
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -9,118 +9,118 @@
 block discarded – undo
9 9
 
10 10
 class Search_Entity_Rest_Endpoint {
11 11
 
12
-	/**
13
-	 * @var Analysis_Service
14
-	 */
15
-	private $analysis_service;
16
-
17
-	/**
18
-	 * @var Cache
19
-	 */
20
-	private $cache_service;
21
-
22
-	public function __construct( $api_service, $cache_service ) {
23
-		$this->analysis_service = $api_service;
24
-		$this->cache_service    = $cache_service;
25
-		add_action( 'rest_api_init', array( $this, 'register_route_callback' ) );
26
-	}
27
-
28
-	public function register_route_callback() {
29
-		register_rest_route(
30
-			Api_Config::REST_NAMESPACE,
31
-			'/search-entity',
32
-			array(
33
-				'methods'             => \WP_REST_Server::CREATABLE,
34
-				'callback'            => array( $this, 'get_entities_from_api' ),
35
-				'args'                => array(
36
-					'entity' => array(
37
-						'validate_callback' => function ( $param ) {
38
-							return is_string( $param );
39
-						},
40
-					),
41
-				),
42
-				'permission_callback' => function () {
43
-					return current_user_can( 'manage_options' );
44
-				},
45
-			)
46
-		);
47
-
48
-		register_rest_route(
49
-			Api_Config::REST_NAMESPACE,
50
-			'/add-entity',
51
-			array(
52
-				'methods'             => \WP_REST_Server::CREATABLE,
53
-				'callback'            => array( $this, 'add_entity_to_matches' ),
54
-				'args'                => array(
55
-					'entity_data' => array(
56
-						'validate_callback' => function ( $param ) {
57
-							return is_array( $param );
58
-						},
59
-					),
60
-					'term_id'     => array(
61
-						'validate_callback' => function ( $param ) {
62
-							return is_numeric( $param );
63
-						},
64
-					),
65
-				),
66
-				'permission_callback' => function () {
67
-					return current_user_can( 'manage_options' );
68
-				},
69
-			)
70
-		);
71
-	}
72
-
73
-	public function add_entity_to_matches( $request ) {
74
-		$data                = $request->get_params();
75
-		$entity_data         = $data['entity_data'];
76
-		$term_id             = (int) $data['term_id'];
77
-		$existing_entities   = $this->cache_service->get( $term_id );
78
-		$existing_entities[] = $entity_data;
79
-		$this->cache_service->put( $term_id, $existing_entities );
80
-
81
-		$entity = Entity_List_Factory::get_instance( $term_id );
82
-		$entity->save_jsonld_data( $entity_data );
83
-		update_term_meta( $term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, 1 );
84
-		Ttl_Cache::flush_all();
85
-
86
-		return $existing_entities;
87
-	}
88
-
89
-	public function get_entities_from_api( $request ) {
90
-		$data     = $request->get_params();
91
-		$search   = $data['entity'];
92
-		$entities = $this->analysis_service->get_entities_by_search_query( (string) $search );
93
-
94
-		return $this->convert_to_autocomplete_ui_response( $entities );
95
-	}
96
-
97
-	private function convert_to_autocomplete_ui_response( $entities ) {
98
-
99
-		$autocomplete_entities = array();
100
-
101
-		foreach ( $entities as $entity_id => $entity_data ) {
102
-
103
-			$label                   = $entity_data['label'];
104
-			$types                   = $entity_data['types'];
105
-			$autocomplete_entities[] = array(
106
-				'id'           => $entity_data['entityId'],
107
-				'labels'       => array( $label ),
108
-				'descriptions' => array( $entity_data['description'] ),
109
-				'types'        => $types,
110
-				'urls'         => array( $entity_id ),
111
-				'images'       => array(),
112
-				'sameAss'      => $entity_data['sameAs'],
113
-				'scope'        => 'cloud',
114
-				'description'  => $entity_data['description'],
115
-				'mainType'     => $entity_data['mainType'],
116
-				'label'        => $label,
117
-				'displayTypes' => $types,
118
-				'value'        => $entity_id,
119
-				'confidence'   => $entity_data['confidence'],
120
-				'meta'         => $entity_data['meta'],
121
-			);
122
-		}
123
-
124
-		return $autocomplete_entities;
125
-	}
12
+    /**
13
+     * @var Analysis_Service
14
+     */
15
+    private $analysis_service;
16
+
17
+    /**
18
+     * @var Cache
19
+     */
20
+    private $cache_service;
21
+
22
+    public function __construct( $api_service, $cache_service ) {
23
+        $this->analysis_service = $api_service;
24
+        $this->cache_service    = $cache_service;
25
+        add_action( 'rest_api_init', array( $this, 'register_route_callback' ) );
26
+    }
27
+
28
+    public function register_route_callback() {
29
+        register_rest_route(
30
+            Api_Config::REST_NAMESPACE,
31
+            '/search-entity',
32
+            array(
33
+                'methods'             => \WP_REST_Server::CREATABLE,
34
+                'callback'            => array( $this, 'get_entities_from_api' ),
35
+                'args'                => array(
36
+                    'entity' => array(
37
+                        'validate_callback' => function ( $param ) {
38
+                            return is_string( $param );
39
+                        },
40
+                    ),
41
+                ),
42
+                'permission_callback' => function () {
43
+                    return current_user_can( 'manage_options' );
44
+                },
45
+            )
46
+        );
47
+
48
+        register_rest_route(
49
+            Api_Config::REST_NAMESPACE,
50
+            '/add-entity',
51
+            array(
52
+                'methods'             => \WP_REST_Server::CREATABLE,
53
+                'callback'            => array( $this, 'add_entity_to_matches' ),
54
+                'args'                => array(
55
+                    'entity_data' => array(
56
+                        'validate_callback' => function ( $param ) {
57
+                            return is_array( $param );
58
+                        },
59
+                    ),
60
+                    'term_id'     => array(
61
+                        'validate_callback' => function ( $param ) {
62
+                            return is_numeric( $param );
63
+                        },
64
+                    ),
65
+                ),
66
+                'permission_callback' => function () {
67
+                    return current_user_can( 'manage_options' );
68
+                },
69
+            )
70
+        );
71
+    }
72
+
73
+    public function add_entity_to_matches( $request ) {
74
+        $data                = $request->get_params();
75
+        $entity_data         = $data['entity_data'];
76
+        $term_id             = (int) $data['term_id'];
77
+        $existing_entities   = $this->cache_service->get( $term_id );
78
+        $existing_entities[] = $entity_data;
79
+        $this->cache_service->put( $term_id, $existing_entities );
80
+
81
+        $entity = Entity_List_Factory::get_instance( $term_id );
82
+        $entity->save_jsonld_data( $entity_data );
83
+        update_term_meta( $term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, 1 );
84
+        Ttl_Cache::flush_all();
85
+
86
+        return $existing_entities;
87
+    }
88
+
89
+    public function get_entities_from_api( $request ) {
90
+        $data     = $request->get_params();
91
+        $search   = $data['entity'];
92
+        $entities = $this->analysis_service->get_entities_by_search_query( (string) $search );
93
+
94
+        return $this->convert_to_autocomplete_ui_response( $entities );
95
+    }
96
+
97
+    private function convert_to_autocomplete_ui_response( $entities ) {
98
+
99
+        $autocomplete_entities = array();
100
+
101
+        foreach ( $entities as $entity_id => $entity_data ) {
102
+
103
+            $label                   = $entity_data['label'];
104
+            $types                   = $entity_data['types'];
105
+            $autocomplete_entities[] = array(
106
+                'id'           => $entity_data['entityId'],
107
+                'labels'       => array( $label ),
108
+                'descriptions' => array( $entity_data['description'] ),
109
+                'types'        => $types,
110
+                'urls'         => array( $entity_id ),
111
+                'images'       => array(),
112
+                'sameAss'      => $entity_data['sameAs'],
113
+                'scope'        => 'cloud',
114
+                'description'  => $entity_data['description'],
115
+                'mainType'     => $entity_data['mainType'],
116
+                'label'        => $label,
117
+                'displayTypes' => $types,
118
+                'value'        => $entity_id,
119
+                'confidence'   => $entity_data['confidence'],
120
+                'meta'         => $entity_data['meta'],
121
+            );
122
+        }
123
+
124
+        return $autocomplete_entities;
125
+    }
126 126
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
 	 */
20 20
 	private $cache_service;
21 21
 
22
-	public function __construct( $api_service, $cache_service ) {
22
+	public function __construct($api_service, $cache_service) {
23 23
 		$this->analysis_service = $api_service;
24 24
 		$this->cache_service    = $cache_service;
25
-		add_action( 'rest_api_init', array( $this, 'register_route_callback' ) );
25
+		add_action('rest_api_init', array($this, 'register_route_callback'));
26 26
 	}
27 27
 
28 28
 	public function register_route_callback() {
@@ -31,16 +31,16 @@  discard block
 block discarded – undo
31 31
 			'/search-entity',
32 32
 			array(
33 33
 				'methods'             => \WP_REST_Server::CREATABLE,
34
-				'callback'            => array( $this, 'get_entities_from_api' ),
34
+				'callback'            => array($this, 'get_entities_from_api'),
35 35
 				'args'                => array(
36 36
 					'entity' => array(
37
-						'validate_callback' => function ( $param ) {
38
-							return is_string( $param );
37
+						'validate_callback' => function($param) {
38
+							return is_string($param);
39 39
 						},
40 40
 					),
41 41
 				),
42
-				'permission_callback' => function () {
43
-					return current_user_can( 'manage_options' );
42
+				'permission_callback' => function() {
43
+					return current_user_can('manage_options');
44 44
 				},
45 45
 			)
46 46
 		);
@@ -50,64 +50,64 @@  discard block
 block discarded – undo
50 50
 			'/add-entity',
51 51
 			array(
52 52
 				'methods'             => \WP_REST_Server::CREATABLE,
53
-				'callback'            => array( $this, 'add_entity_to_matches' ),
53
+				'callback'            => array($this, 'add_entity_to_matches'),
54 54
 				'args'                => array(
55 55
 					'entity_data' => array(
56
-						'validate_callback' => function ( $param ) {
57
-							return is_array( $param );
56
+						'validate_callback' => function($param) {
57
+							return is_array($param);
58 58
 						},
59 59
 					),
60 60
 					'term_id'     => array(
61
-						'validate_callback' => function ( $param ) {
62
-							return is_numeric( $param );
61
+						'validate_callback' => function($param) {
62
+							return is_numeric($param);
63 63
 						},
64 64
 					),
65 65
 				),
66
-				'permission_callback' => function () {
67
-					return current_user_can( 'manage_options' );
66
+				'permission_callback' => function() {
67
+					return current_user_can('manage_options');
68 68
 				},
69 69
 			)
70 70
 		);
71 71
 	}
72 72
 
73
-	public function add_entity_to_matches( $request ) {
73
+	public function add_entity_to_matches($request) {
74 74
 		$data                = $request->get_params();
75 75
 		$entity_data         = $data['entity_data'];
76 76
 		$term_id             = (int) $data['term_id'];
77
-		$existing_entities   = $this->cache_service->get( $term_id );
77
+		$existing_entities   = $this->cache_service->get($term_id);
78 78
 		$existing_entities[] = $entity_data;
79
-		$this->cache_service->put( $term_id, $existing_entities );
79
+		$this->cache_service->put($term_id, $existing_entities);
80 80
 
81
-		$entity = Entity_List_Factory::get_instance( $term_id );
82
-		$entity->save_jsonld_data( $entity_data );
83
-		update_term_meta( $term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, 1 );
81
+		$entity = Entity_List_Factory::get_instance($term_id);
82
+		$entity->save_jsonld_data($entity_data);
83
+		update_term_meta($term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, 1);
84 84
 		Ttl_Cache::flush_all();
85 85
 
86 86
 		return $existing_entities;
87 87
 	}
88 88
 
89
-	public function get_entities_from_api( $request ) {
89
+	public function get_entities_from_api($request) {
90 90
 		$data     = $request->get_params();
91 91
 		$search   = $data['entity'];
92
-		$entities = $this->analysis_service->get_entities_by_search_query( (string) $search );
92
+		$entities = $this->analysis_service->get_entities_by_search_query((string) $search);
93 93
 
94
-		return $this->convert_to_autocomplete_ui_response( $entities );
94
+		return $this->convert_to_autocomplete_ui_response($entities);
95 95
 	}
96 96
 
97
-	private function convert_to_autocomplete_ui_response( $entities ) {
97
+	private function convert_to_autocomplete_ui_response($entities) {
98 98
 
99 99
 		$autocomplete_entities = array();
100 100
 
101
-		foreach ( $entities as $entity_id => $entity_data ) {
101
+		foreach ($entities as $entity_id => $entity_data) {
102 102
 
103 103
 			$label                   = $entity_data['label'];
104 104
 			$types                   = $entity_data['types'];
105 105
 			$autocomplete_entities[] = array(
106 106
 				'id'           => $entity_data['entityId'],
107
-				'labels'       => array( $label ),
108
-				'descriptions' => array( $entity_data['description'] ),
107
+				'labels'       => array($label),
108
+				'descriptions' => array($entity_data['description']),
109 109
 				'types'        => $types,
110
-				'urls'         => array( $entity_id ),
110
+				'urls'         => array($entity_id),
111 111
 				'images'       => array(),
112 112
 				'sameAss'      => $entity_data['sameAs'],
113 113
 				'scope'        => 'cloud',
Please login to merge, or discard this patch.
src/wordlift/vocabulary/api/class-tag-rest-endpoint.php 2 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -13,121 +13,121 @@
 block discarded – undo
13 13
  */
14 14
 class Tag_Rest_Endpoint {
15 15
 
16
-	/**
17
-	 * @var Term_Data_Factory
18
-	 */
19
-	private $term_data_factory;
20
-
21
-	/**
22
-	 * Tag_Rest_Endpoint constructor.
23
-	 *
24
-	 * @param Term_Data_Factory $term_data_factory
25
-	 */
26
-	public function __construct( $term_data_factory ) {
27
-
28
-		$this->term_data_factory = $term_data_factory;
29
-
30
-	}
31
-
32
-	public function register_routes() {
33
-		$that = $this;
34
-		add_action(
35
-			'rest_api_init',
36
-			function () use ( $that ) {
37
-				register_rest_route(
38
-					Api_Config::REST_NAMESPACE,
39
-					'/tags',
40
-					array(
41
-						'methods'             => WP_REST_Server::CREATABLE,
42
-						'callback'            => array( $that, 'get_tags' ),
43
-						// @todo : review the permission level
44
-						'permission_callback' => function () {
45
-							return current_user_can( 'manage_options' );
46
-						},
47
-						'args'                => array(
48
-							'limit'  => array(
49
-								// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
50
-								'validate_callback' => function ( $param, $request, $key ) {
51
-									return is_numeric( $param ) && $param;
52
-								},
53
-								'required'          => true,
54
-							),
55
-							'offset' => array(
56
-								// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
57
-								'validate_callback' => function ( $param, $request, $key ) {
58
-									return is_numeric( $param );
59
-								},
60
-								'required'          => true,
61
-							),
62
-						),
63
-					)
64
-				);
65
-			}
66
-		);
67
-
68
-	}
69
-
70
-	public function get_tags( $request ) {
71
-
72
-		$data           = $request->get_params();
73
-		$offset         = (int) $data['offset'];
74
-		$limit          = (int) $data['limit'];
75
-		$tags           = $this->get_terms_from_db( $limit, $offset );
76
-		$term_data_list = array();
77
-
78
-		foreach ( $tags as $tag ) {
79
-
80
-			if ( $this->is_tag_excluded_from_ui( $tag ) ) {
81
-				continue;
82
-			}
83
-
84
-			/**
85
-			 * @param $tag \WP_Term
86
-			 */
87
-			$term_data_instance = $this->term_data_factory->get_term_data( $tag );
88
-			$term_data          = $term_data_instance->get_data();
89
-			if ( $term_data['entities'] ) {
90
-				$term_data_list[] = $term_data;
91
-			}
92
-		}
93
-
94
-		return $term_data_list;
95
-	}
96
-
97
-	/**
98
-	 * @param \WP_Term $tag
99
-	 *
100
-	 * @return bool
101
-	 */
102
-	private function is_tag_excluded_from_ui( $tag ) {
103
-		return (int) get_term_meta( $tag->term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, true ) === 1;
104
-	}
105
-
106
-	/**
107
-	 * @param $limit
108
-	 * @param $offset
109
-	 *
110
-	 * @return int|\WP_Error|\WP_Term[]
111
-	 */
112
-	public function get_terms_from_db( $limit, $offset ) {
113
-
114
-		return Terms_Compat::get_terms(
115
-			Terms_Compat::get_public_taxonomies(),
116
-			array(
117
-				'hide_empty' => false,
118
-				'number'     => $limit,
119
-				'offset'     => $offset,
120
-				'meta_query' => array(
121
-					array(
122
-						'key'     => Analysis_Background_Service::ENTITIES_PRESENT_FOR_TERM,
123
-						'compare' => 'EXISTS',
124
-					),
125
-				),
126
-				'orderby'    => 'count',
127
-				'order'      => 'DESC',
128
-			)
129
-		);
130
-
131
-	}
16
+    /**
17
+     * @var Term_Data_Factory
18
+     */
19
+    private $term_data_factory;
20
+
21
+    /**
22
+     * Tag_Rest_Endpoint constructor.
23
+     *
24
+     * @param Term_Data_Factory $term_data_factory
25
+     */
26
+    public function __construct( $term_data_factory ) {
27
+
28
+        $this->term_data_factory = $term_data_factory;
29
+
30
+    }
31
+
32
+    public function register_routes() {
33
+        $that = $this;
34
+        add_action(
35
+            'rest_api_init',
36
+            function () use ( $that ) {
37
+                register_rest_route(
38
+                    Api_Config::REST_NAMESPACE,
39
+                    '/tags',
40
+                    array(
41
+                        'methods'             => WP_REST_Server::CREATABLE,
42
+                        'callback'            => array( $that, 'get_tags' ),
43
+                        // @todo : review the permission level
44
+                        'permission_callback' => function () {
45
+                            return current_user_can( 'manage_options' );
46
+                        },
47
+                        'args'                => array(
48
+                            'limit'  => array(
49
+                                // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
50
+                                'validate_callback' => function ( $param, $request, $key ) {
51
+                                    return is_numeric( $param ) && $param;
52
+                                },
53
+                                'required'          => true,
54
+                            ),
55
+                            'offset' => array(
56
+                                // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
57
+                                'validate_callback' => function ( $param, $request, $key ) {
58
+                                    return is_numeric( $param );
59
+                                },
60
+                                'required'          => true,
61
+                            ),
62
+                        ),
63
+                    )
64
+                );
65
+            }
66
+        );
67
+
68
+    }
69
+
70
+    public function get_tags( $request ) {
71
+
72
+        $data           = $request->get_params();
73
+        $offset         = (int) $data['offset'];
74
+        $limit          = (int) $data['limit'];
75
+        $tags           = $this->get_terms_from_db( $limit, $offset );
76
+        $term_data_list = array();
77
+
78
+        foreach ( $tags as $tag ) {
79
+
80
+            if ( $this->is_tag_excluded_from_ui( $tag ) ) {
81
+                continue;
82
+            }
83
+
84
+            /**
85
+             * @param $tag \WP_Term
86
+             */
87
+            $term_data_instance = $this->term_data_factory->get_term_data( $tag );
88
+            $term_data          = $term_data_instance->get_data();
89
+            if ( $term_data['entities'] ) {
90
+                $term_data_list[] = $term_data;
91
+            }
92
+        }
93
+
94
+        return $term_data_list;
95
+    }
96
+
97
+    /**
98
+     * @param \WP_Term $tag
99
+     *
100
+     * @return bool
101
+     */
102
+    private function is_tag_excluded_from_ui( $tag ) {
103
+        return (int) get_term_meta( $tag->term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, true ) === 1;
104
+    }
105
+
106
+    /**
107
+     * @param $limit
108
+     * @param $offset
109
+     *
110
+     * @return int|\WP_Error|\WP_Term[]
111
+     */
112
+    public function get_terms_from_db( $limit, $offset ) {
113
+
114
+        return Terms_Compat::get_terms(
115
+            Terms_Compat::get_public_taxonomies(),
116
+            array(
117
+                'hide_empty' => false,
118
+                'number'     => $limit,
119
+                'offset'     => $offset,
120
+                'meta_query' => array(
121
+                    array(
122
+                        'key'     => Analysis_Background_Service::ENTITIES_PRESENT_FOR_TERM,
123
+                        'compare' => 'EXISTS',
124
+                    ),
125
+                ),
126
+                'orderby'    => 'count',
127
+                'order'      => 'DESC',
128
+            )
129
+        );
130
+
131
+    }
132 132
 
133 133
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param Term_Data_Factory $term_data_factory
25 25
 	 */
26
-	public function __construct( $term_data_factory ) {
26
+	public function __construct($term_data_factory) {
27 27
 
28 28
 		$this->term_data_factory = $term_data_factory;
29 29
 
@@ -33,29 +33,29 @@  discard block
 block discarded – undo
33 33
 		$that = $this;
34 34
 		add_action(
35 35
 			'rest_api_init',
36
-			function () use ( $that ) {
36
+			function() use ($that) {
37 37
 				register_rest_route(
38 38
 					Api_Config::REST_NAMESPACE,
39 39
 					'/tags',
40 40
 					array(
41 41
 						'methods'             => WP_REST_Server::CREATABLE,
42
-						'callback'            => array( $that, 'get_tags' ),
42
+						'callback'            => array($that, 'get_tags'),
43 43
 						// @todo : review the permission level
44
-						'permission_callback' => function () {
45
-							return current_user_can( 'manage_options' );
44
+						'permission_callback' => function() {
45
+							return current_user_can('manage_options');
46 46
 						},
47 47
 						'args'                => array(
48 48
 							'limit'  => array(
49 49
 								// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
50
-								'validate_callback' => function ( $param, $request, $key ) {
51
-									return is_numeric( $param ) && $param;
50
+								'validate_callback' => function($param, $request, $key) {
51
+									return is_numeric($param) && $param;
52 52
 								},
53 53
 								'required'          => true,
54 54
 							),
55 55
 							'offset' => array(
56 56
 								// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
57
-								'validate_callback' => function ( $param, $request, $key ) {
58
-									return is_numeric( $param );
57
+								'validate_callback' => function($param, $request, $key) {
58
+									return is_numeric($param);
59 59
 								},
60 60
 								'required'          => true,
61 61
 							),
@@ -67,26 +67,26 @@  discard block
 block discarded – undo
67 67
 
68 68
 	}
69 69
 
70
-	public function get_tags( $request ) {
70
+	public function get_tags($request) {
71 71
 
72 72
 		$data           = $request->get_params();
73 73
 		$offset         = (int) $data['offset'];
74 74
 		$limit          = (int) $data['limit'];
75
-		$tags           = $this->get_terms_from_db( $limit, $offset );
75
+		$tags           = $this->get_terms_from_db($limit, $offset);
76 76
 		$term_data_list = array();
77 77
 
78
-		foreach ( $tags as $tag ) {
78
+		foreach ($tags as $tag) {
79 79
 
80
-			if ( $this->is_tag_excluded_from_ui( $tag ) ) {
80
+			if ($this->is_tag_excluded_from_ui($tag)) {
81 81
 				continue;
82 82
 			}
83 83
 
84 84
 			/**
85 85
 			 * @param $tag \WP_Term
86 86
 			 */
87
-			$term_data_instance = $this->term_data_factory->get_term_data( $tag );
87
+			$term_data_instance = $this->term_data_factory->get_term_data($tag);
88 88
 			$term_data          = $term_data_instance->get_data();
89
-			if ( $term_data['entities'] ) {
89
+			if ($term_data['entities']) {
90 90
 				$term_data_list[] = $term_data;
91 91
 			}
92 92
 		}
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @return bool
101 101
 	 */
102
-	private function is_tag_excluded_from_ui( $tag ) {
103
-		return (int) get_term_meta( $tag->term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, true ) === 1;
102
+	private function is_tag_excluded_from_ui($tag) {
103
+		return (int) get_term_meta($tag->term_id, Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING, true) === 1;
104 104
 	}
105 105
 
106 106
 	/**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return int|\WP_Error|\WP_Term[]
111 111
 	 */
112
-	public function get_terms_from_db( $limit, $offset ) {
112
+	public function get_terms_from_db($limit, $offset) {
113 113
 
114 114
 		return Terms_Compat::get_terms(
115 115
 			Terms_Compat::get_public_taxonomies(),
Please login to merge, or discard this patch.
src/wordlift/vocabulary/api/class-background-analysis-endpoint.php 2 patches
Indentation   +127 added lines, -127 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 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(
35
-			'rest_api_init',
36
-			function () use ( $that ) {
37
-				$that->register_start_route();
38
-				$that->register_stop_route();
39
-				$that->register_stats_route();
40
-				$that->register_restart_route();
41
-			}
42
-		);
43
-	}
44
-
45
-	private function register_start_route() {
46
-		register_rest_route(
47
-			Api_Config::REST_NAMESPACE,
48
-			'/background_analysis/start',
49
-			array(
50
-				'methods'             => WP_REST_Server::CREATABLE,
51
-				'callback'            => array( $this, 'start' ),
52
-				'permission_callback' => function () {
53
-					return current_user_can( 'manage_options' );
54
-				},
55
-			)
56
-		);
57
-	}
58
-
59
-	private function register_stop_route() {
60
-		register_rest_route(
61
-			Api_Config::REST_NAMESPACE,
62
-			'/background_analysis/stop',
63
-			array(
64
-				'methods'             => WP_REST_Server::CREATABLE,
65
-				'callback'            => array( $this, 'stop' ),
66
-				'permission_callback' => function () {
67
-					return current_user_can( 'manage_options' );
68
-				},
69
-			)
70
-		);
71
-	}
72
-
73
-	private function register_stats_route() {
74
-		register_rest_route(
75
-			Api_Config::REST_NAMESPACE,
76
-			'/background_analysis/stats',
77
-			array(
78
-				'methods'             => WP_REST_Server::CREATABLE,
79
-				'callback'            => array( $this, 'get_stats' ),
80
-				'permission_callback' => function () {
81
-					return current_user_can( 'manage_options' );
82
-				},
83
-			)
84
-		);
85
-	}
86
-
87
-	private function register_restart_route() {
88
-		register_rest_route(
89
-			Api_Config::REST_NAMESPACE,
90
-			'/background_analysis/restart',
91
-			array(
92
-				'methods'             => WP_REST_Server::CREATABLE,
93
-				'callback'            => array( $this, 'restart' ),
94
-				'permission_callback' => function () {
95
-					return current_user_can( 'manage_options' );
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
-	public function restart() {
117
-		$this->background_service->cancel();
118
-		// clear the flags and restart again.
119
-		global $wpdb;
120
-
121
-		// Remove the flags, if the tag is already accepted we wont remove that ui flag.
122
-
123
-		$wpdb->query(
124
-			$wpdb->prepare(
125
-				"DELETE FROM $wpdb->termmeta WHERE meta_key=%s OR meta_key=%s",
126
-				array(
127
-					Analysis_Background_Service::ANALYSIS_DONE_FLAG,
128
-					Analysis_Background_Service::ENTITIES_PRESENT_FOR_TERM,
129
-				)
130
-			)
131
-		);
132
-		// clear the cache
133
-		$this->cache_service->flush_all();
134
-		$this->background_service->start();
135
-
136
-		return array( 'status' => 'restart_complete' );
137
-	}
138
-
139
-	public function stop() {
140
-		$this->background_service->stop();
141
-
142
-		return true;
143
-	}
17
+    /**
18
+     * @var Analysis_Background_Service
19
+     */
20
+    private $background_service;
21
+    /**
22
+     * @var 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(
35
+            'rest_api_init',
36
+            function () use ( $that ) {
37
+                $that->register_start_route();
38
+                $that->register_stop_route();
39
+                $that->register_stats_route();
40
+                $that->register_restart_route();
41
+            }
42
+        );
43
+    }
44
+
45
+    private function register_start_route() {
46
+        register_rest_route(
47
+            Api_Config::REST_NAMESPACE,
48
+            '/background_analysis/start',
49
+            array(
50
+                'methods'             => WP_REST_Server::CREATABLE,
51
+                'callback'            => array( $this, 'start' ),
52
+                'permission_callback' => function () {
53
+                    return current_user_can( 'manage_options' );
54
+                },
55
+            )
56
+        );
57
+    }
58
+
59
+    private function register_stop_route() {
60
+        register_rest_route(
61
+            Api_Config::REST_NAMESPACE,
62
+            '/background_analysis/stop',
63
+            array(
64
+                'methods'             => WP_REST_Server::CREATABLE,
65
+                'callback'            => array( $this, 'stop' ),
66
+                'permission_callback' => function () {
67
+                    return current_user_can( 'manage_options' );
68
+                },
69
+            )
70
+        );
71
+    }
72
+
73
+    private function register_stats_route() {
74
+        register_rest_route(
75
+            Api_Config::REST_NAMESPACE,
76
+            '/background_analysis/stats',
77
+            array(
78
+                'methods'             => WP_REST_Server::CREATABLE,
79
+                'callback'            => array( $this, 'get_stats' ),
80
+                'permission_callback' => function () {
81
+                    return current_user_can( 'manage_options' );
82
+                },
83
+            )
84
+        );
85
+    }
86
+
87
+    private function register_restart_route() {
88
+        register_rest_route(
89
+            Api_Config::REST_NAMESPACE,
90
+            '/background_analysis/restart',
91
+            array(
92
+                'methods'             => WP_REST_Server::CREATABLE,
93
+                'callback'            => array( $this, 'restart' ),
94
+                'permission_callback' => function () {
95
+                    return current_user_can( 'manage_options' );
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
+    public function restart() {
117
+        $this->background_service->cancel();
118
+        // clear the flags and restart again.
119
+        global $wpdb;
120
+
121
+        // Remove the flags, if the tag is already accepted we wont remove that ui flag.
122
+
123
+        $wpdb->query(
124
+            $wpdb->prepare(
125
+                "DELETE FROM $wpdb->termmeta WHERE meta_key=%s OR meta_key=%s",
126
+                array(
127
+                    Analysis_Background_Service::ANALYSIS_DONE_FLAG,
128
+                    Analysis_Background_Service::ENTITIES_PRESENT_FOR_TERM,
129
+                )
130
+            )
131
+        );
132
+        // clear the cache
133
+        $this->cache_service->flush_all();
134
+        $this->background_service->start();
135
+
136
+        return array( 'status' => 'restart_complete' );
137
+    }
138
+
139
+    public function stop() {
140
+        $this->background_service->stop();
141
+
142
+        return true;
143
+    }
144 144
 
145 145
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 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();
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		$that = $this;
34 34
 		add_action(
35 35
 			'rest_api_init',
36
-			function () use ( $that ) {
36
+			function() use ($that) {
37 37
 				$that->register_start_route();
38 38
 				$that->register_stop_route();
39 39
 				$that->register_stats_route();
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 			'/background_analysis/start',
49 49
 			array(
50 50
 				'methods'             => WP_REST_Server::CREATABLE,
51
-				'callback'            => array( $this, 'start' ),
52
-				'permission_callback' => function () {
53
-					return current_user_can( 'manage_options' );
51
+				'callback'            => array($this, 'start'),
52
+				'permission_callback' => function() {
53
+					return current_user_can('manage_options');
54 54
 				},
55 55
 			)
56 56
 		);
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
 			'/background_analysis/stop',
63 63
 			array(
64 64
 				'methods'             => WP_REST_Server::CREATABLE,
65
-				'callback'            => array( $this, 'stop' ),
66
-				'permission_callback' => function () {
67
-					return current_user_can( 'manage_options' );
65
+				'callback'            => array($this, 'stop'),
66
+				'permission_callback' => function() {
67
+					return current_user_can('manage_options');
68 68
 				},
69 69
 			)
70 70
 		);
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 			'/background_analysis/stats',
77 77
 			array(
78 78
 				'methods'             => WP_REST_Server::CREATABLE,
79
-				'callback'            => array( $this, 'get_stats' ),
80
-				'permission_callback' => function () {
81
-					return current_user_can( 'manage_options' );
79
+				'callback'            => array($this, 'get_stats'),
80
+				'permission_callback' => function() {
81
+					return current_user_can('manage_options');
82 82
 				},
83 83
 			)
84 84
 		);
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 			'/background_analysis/restart',
91 91
 			array(
92 92
 				'methods'             => WP_REST_Server::CREATABLE,
93
-				'callback'            => array( $this, 'restart' ),
94
-				'permission_callback' => function () {
95
-					return current_user_can( 'manage_options' );
93
+				'callback'            => array($this, 'restart'),
94
+				'permission_callback' => function() {
95
+					return current_user_can('manage_options');
96 96
 				},
97 97
 			)
98 98
 		);
@@ -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
 	}
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		$this->cache_service->flush_all();
134 134
 		$this->background_service->start();
135 135
 
136
-		return array( 'status' => 'restart_complete' );
136
+		return array('status' => 'restart_complete');
137 137
 	}
138 138
 
139 139
 	public function stop() {
Please login to merge, or discard this patch.
src/wordlift/vocabulary/api/class-entity-rest-endpoint.php 2 patches
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -16,158 +16,158 @@
 block discarded – undo
16 16
  */
17 17
 class Entity_Rest_Endpoint {
18 18
 
19
-	const SAME_AS_META_KEY           = 'entity_same_as';
20
-	const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
21
-	const DESCRIPTION_META_KEY       = 'entity_description';
22
-	const TYPE_META_KEY              = 'entity_type';
23
-	const EXTERNAL_ENTITY_META_KEY   = '_wl_is_external';
24
-	const IGNORE_TAG_FROM_LISTING    = '_wl_cmkg_ignore_tag_from_ui';
25
-
26
-	public function register_routes() {
27
-		$that = $this;
28
-		add_action(
29
-			'rest_api_init',
30
-			function () use ( $that ) {
31
-				$that->register_accept_route();
32
-				$that->register_undo_route();
33
-				$that->register_nomatch_route();
34
-				$that->register_reject_route();
35
-			}
36
-		);
37
-	}
38
-
39
-	public function accept_entity( $request ) {
40
-		$data        = $request->get_params();
41
-		$term_id     = (int) $data['term_id'];
42
-		$entity_data = (array) $data['entity'];
43
-		$entity      = Entity_List_Factory::get_instance( $term_id );
44
-		$entity->save_jsonld_data( $entity_data );
45
-		update_term_meta( $term_id, self::IGNORE_TAG_FROM_LISTING, 1 );
46
-		Ttl_Cache::flush_all();
47
-
48
-		return $term_id;
49
-	}
50
-
51
-	public function undo( $request ) {
52
-		$data    = $request->get_params();
53
-		$term_id = (int) $data['term_id'];
54
-		$entity  = Entity_List_Factory::get_instance( $term_id );
55
-		$entity->clear_data();
56
-		delete_term_meta( $term_id, self::IGNORE_TAG_FROM_LISTING );
57
-		Ttl_Cache::flush_all();
58
-
59
-		return $term_id;
60
-	}
61
-
62
-	public function mark_as_no_match( $request ) {
63
-		$data    = $request->get_params();
64
-		$term_id = (int) $data['term_id'];
65
-		Ttl_Cache::flush_all();
66
-
67
-		return update_term_meta( $term_id, self::IGNORE_TAG_FROM_LISTING, 1 );
68
-	}
69
-
70
-	private function register_undo_route() {
71
-		register_rest_route(
72
-			Api_Config::REST_NAMESPACE,
73
-			'/entity/undo',
74
-			array(
75
-				'methods'             => WP_REST_Server::CREATABLE,
76
-				'callback'            => array( $this, 'undo' ),
77
-				'permission_callback' => function () {
78
-					return current_user_can( 'manage_options' );
79
-				},
80
-				'args'                => array(
81
-					'term_id' => array(
82
-						// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
83
-						'validate_callback' => function ( $param, $request, $key ) {
84
-							return is_numeric( $param ) && $param;
85
-						},
86
-						'required'          => true,
87
-					),
88
-				),
89
-			)
90
-		);
91
-	}
92
-
93
-	private function register_accept_route() {
94
-		$route = '/entity/accept';
95
-		$this->register_entity_accept_or_reject_route( $route, array( $this, 'accept_entity' ) );
96
-	}
97
-
98
-	private function register_reject_route() {
99
-		$route = '/entity/reject';
100
-		$this->register_entity_accept_or_reject_route( $route, array( $this, 'reject_entity' ) );
101
-	}
102
-
103
-	public function reject_entity( $request ) {
104
-		$data        = $request->get_params();
105
-		$term_id     = (int) $data['term_id'];
106
-		$entity_data = (array) $data['entity'];
107
-		$entity      = Entity_List_Factory::get_instance( $term_id );
108
-
109
-		$entity_id = array_key_exists( '@id', $entity_data ) ? $entity_data['@id'] : $entity_data['entityId'];
110
-		$entity->remove_entity_by_id( $entity_id );
111
-		Ttl_Cache::flush_all();
112
-		return $term_id;
113
-	}
114
-
115
-	private function register_nomatch_route() {
116
-		register_rest_route(
117
-			Api_Config::REST_NAMESPACE,
118
-			'/entity/no_match',
119
-			array(
120
-				'methods'             => WP_REST_Server::CREATABLE,
121
-				'callback'            => array( $this, 'mark_as_no_match' ),
122
-				'permission_callback' => function () {
123
-					return current_user_can( 'manage_options' );
124
-				},
125
-				'args'                => array(
126
-					'term_id' => array(
127
-						// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
128
-						'validate_callback' => function ( $param, $request, $key ) {
129
-							return is_numeric( $param ) && $param;
130
-						},
131
-						'required'          => true,
132
-					),
133
-				),
134
-			)
135
-		);
136
-	}
137
-
138
-	/**
139
-	 * @param $accept_route
140
-	 */
141
-	private function register_entity_accept_or_reject_route( $accept_route, $callback ) {
142
-
143
-		register_rest_route(
144
-			Api_Config::REST_NAMESPACE,
145
-			$accept_route,
146
-			array(
147
-				'methods'             => WP_REST_Server::CREATABLE,
148
-				'callback'            => $callback,
149
-				'permission_callback' => function () {
150
-					return current_user_can( 'manage_options' );
151
-				},
152
-				'args'                => array(
153
-					'term_id' => array(
154
-						// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
155
-						'validate_callback' => function ( $param, $request, $key ) {
156
-							return is_numeric( $param ) && $param;
157
-						},
158
-						'required'          => true,
159
-					),
160
-					'entity'  => array(
161
-						// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
162
-						'validate_callback' => function ( $param, $request, $key ) {
163
-							return is_array( $param );
164
-						},
165
-						'required'          => true,
166
-					),
167
-				),
168
-			)
169
-		);
170
-
171
-	}
19
+    const SAME_AS_META_KEY           = 'entity_same_as';
20
+    const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
21
+    const DESCRIPTION_META_KEY       = 'entity_description';
22
+    const TYPE_META_KEY              = 'entity_type';
23
+    const EXTERNAL_ENTITY_META_KEY   = '_wl_is_external';
24
+    const IGNORE_TAG_FROM_LISTING    = '_wl_cmkg_ignore_tag_from_ui';
25
+
26
+    public function register_routes() {
27
+        $that = $this;
28
+        add_action(
29
+            'rest_api_init',
30
+            function () use ( $that ) {
31
+                $that->register_accept_route();
32
+                $that->register_undo_route();
33
+                $that->register_nomatch_route();
34
+                $that->register_reject_route();
35
+            }
36
+        );
37
+    }
38
+
39
+    public function accept_entity( $request ) {
40
+        $data        = $request->get_params();
41
+        $term_id     = (int) $data['term_id'];
42
+        $entity_data = (array) $data['entity'];
43
+        $entity      = Entity_List_Factory::get_instance( $term_id );
44
+        $entity->save_jsonld_data( $entity_data );
45
+        update_term_meta( $term_id, self::IGNORE_TAG_FROM_LISTING, 1 );
46
+        Ttl_Cache::flush_all();
47
+
48
+        return $term_id;
49
+    }
50
+
51
+    public function undo( $request ) {
52
+        $data    = $request->get_params();
53
+        $term_id = (int) $data['term_id'];
54
+        $entity  = Entity_List_Factory::get_instance( $term_id );
55
+        $entity->clear_data();
56
+        delete_term_meta( $term_id, self::IGNORE_TAG_FROM_LISTING );
57
+        Ttl_Cache::flush_all();
58
+
59
+        return $term_id;
60
+    }
61
+
62
+    public function mark_as_no_match( $request ) {
63
+        $data    = $request->get_params();
64
+        $term_id = (int) $data['term_id'];
65
+        Ttl_Cache::flush_all();
66
+
67
+        return update_term_meta( $term_id, self::IGNORE_TAG_FROM_LISTING, 1 );
68
+    }
69
+
70
+    private function register_undo_route() {
71
+        register_rest_route(
72
+            Api_Config::REST_NAMESPACE,
73
+            '/entity/undo',
74
+            array(
75
+                'methods'             => WP_REST_Server::CREATABLE,
76
+                'callback'            => array( $this, 'undo' ),
77
+                'permission_callback' => function () {
78
+                    return current_user_can( 'manage_options' );
79
+                },
80
+                'args'                => array(
81
+                    'term_id' => array(
82
+                        // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
83
+                        'validate_callback' => function ( $param, $request, $key ) {
84
+                            return is_numeric( $param ) && $param;
85
+                        },
86
+                        'required'          => true,
87
+                    ),
88
+                ),
89
+            )
90
+        );
91
+    }
92
+
93
+    private function register_accept_route() {
94
+        $route = '/entity/accept';
95
+        $this->register_entity_accept_or_reject_route( $route, array( $this, 'accept_entity' ) );
96
+    }
97
+
98
+    private function register_reject_route() {
99
+        $route = '/entity/reject';
100
+        $this->register_entity_accept_or_reject_route( $route, array( $this, 'reject_entity' ) );
101
+    }
102
+
103
+    public function reject_entity( $request ) {
104
+        $data        = $request->get_params();
105
+        $term_id     = (int) $data['term_id'];
106
+        $entity_data = (array) $data['entity'];
107
+        $entity      = Entity_List_Factory::get_instance( $term_id );
108
+
109
+        $entity_id = array_key_exists( '@id', $entity_data ) ? $entity_data['@id'] : $entity_data['entityId'];
110
+        $entity->remove_entity_by_id( $entity_id );
111
+        Ttl_Cache::flush_all();
112
+        return $term_id;
113
+    }
114
+
115
+    private function register_nomatch_route() {
116
+        register_rest_route(
117
+            Api_Config::REST_NAMESPACE,
118
+            '/entity/no_match',
119
+            array(
120
+                'methods'             => WP_REST_Server::CREATABLE,
121
+                'callback'            => array( $this, 'mark_as_no_match' ),
122
+                'permission_callback' => function () {
123
+                    return current_user_can( 'manage_options' );
124
+                },
125
+                'args'                => array(
126
+                    'term_id' => array(
127
+                        // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
128
+                        'validate_callback' => function ( $param, $request, $key ) {
129
+                            return is_numeric( $param ) && $param;
130
+                        },
131
+                        'required'          => true,
132
+                    ),
133
+                ),
134
+            )
135
+        );
136
+    }
137
+
138
+    /**
139
+     * @param $accept_route
140
+     */
141
+    private function register_entity_accept_or_reject_route( $accept_route, $callback ) {
142
+
143
+        register_rest_route(
144
+            Api_Config::REST_NAMESPACE,
145
+            $accept_route,
146
+            array(
147
+                'methods'             => WP_REST_Server::CREATABLE,
148
+                'callback'            => $callback,
149
+                'permission_callback' => function () {
150
+                    return current_user_can( 'manage_options' );
151
+                },
152
+                'args'                => array(
153
+                    'term_id' => array(
154
+                        // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
155
+                        'validate_callback' => function ( $param, $request, $key ) {
156
+                            return is_numeric( $param ) && $param;
157
+                        },
158
+                        'required'          => true,
159
+                    ),
160
+                    'entity'  => array(
161
+                        // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
162
+                        'validate_callback' => function ( $param, $request, $key ) {
163
+                            return is_array( $param );
164
+                        },
165
+                        'required'          => true,
166
+                    ),
167
+                ),
168
+            )
169
+        );
170
+
171
+    }
172 172
 
173 173
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		$that = $this;
28 28
 		add_action(
29 29
 			'rest_api_init',
30
-			function () use ( $that ) {
30
+			function() use ($that) {
31 31
 				$that->register_accept_route();
32 32
 				$that->register_undo_route();
33 33
 				$that->register_nomatch_route();
@@ -36,35 +36,35 @@  discard block
 block discarded – undo
36 36
 		);
37 37
 	}
38 38
 
39
-	public function accept_entity( $request ) {
39
+	public function accept_entity($request) {
40 40
 		$data        = $request->get_params();
41 41
 		$term_id     = (int) $data['term_id'];
42 42
 		$entity_data = (array) $data['entity'];
43
-		$entity      = Entity_List_Factory::get_instance( $term_id );
44
-		$entity->save_jsonld_data( $entity_data );
45
-		update_term_meta( $term_id, self::IGNORE_TAG_FROM_LISTING, 1 );
43
+		$entity      = Entity_List_Factory::get_instance($term_id);
44
+		$entity->save_jsonld_data($entity_data);
45
+		update_term_meta($term_id, self::IGNORE_TAG_FROM_LISTING, 1);
46 46
 		Ttl_Cache::flush_all();
47 47
 
48 48
 		return $term_id;
49 49
 	}
50 50
 
51
-	public function undo( $request ) {
51
+	public function undo($request) {
52 52
 		$data    = $request->get_params();
53 53
 		$term_id = (int) $data['term_id'];
54
-		$entity  = Entity_List_Factory::get_instance( $term_id );
54
+		$entity  = Entity_List_Factory::get_instance($term_id);
55 55
 		$entity->clear_data();
56
-		delete_term_meta( $term_id, self::IGNORE_TAG_FROM_LISTING );
56
+		delete_term_meta($term_id, self::IGNORE_TAG_FROM_LISTING);
57 57
 		Ttl_Cache::flush_all();
58 58
 
59 59
 		return $term_id;
60 60
 	}
61 61
 
62
-	public function mark_as_no_match( $request ) {
62
+	public function mark_as_no_match($request) {
63 63
 		$data    = $request->get_params();
64 64
 		$term_id = (int) $data['term_id'];
65 65
 		Ttl_Cache::flush_all();
66 66
 
67
-		return update_term_meta( $term_id, self::IGNORE_TAG_FROM_LISTING, 1 );
67
+		return update_term_meta($term_id, self::IGNORE_TAG_FROM_LISTING, 1);
68 68
 	}
69 69
 
70 70
 	private function register_undo_route() {
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
 			'/entity/undo',
74 74
 			array(
75 75
 				'methods'             => WP_REST_Server::CREATABLE,
76
-				'callback'            => array( $this, 'undo' ),
77
-				'permission_callback' => function () {
78
-					return current_user_can( 'manage_options' );
76
+				'callback'            => array($this, 'undo'),
77
+				'permission_callback' => function() {
78
+					return current_user_can('manage_options');
79 79
 				},
80 80
 				'args'                => array(
81 81
 					'term_id' => array(
82 82
 						// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
83
-						'validate_callback' => function ( $param, $request, $key ) {
84
-							return is_numeric( $param ) && $param;
83
+						'validate_callback' => function($param, $request, $key) {
84
+							return is_numeric($param) && $param;
85 85
 						},
86 86
 						'required'          => true,
87 87
 					),
@@ -92,22 +92,22 @@  discard block
 block discarded – undo
92 92
 
93 93
 	private function register_accept_route() {
94 94
 		$route = '/entity/accept';
95
-		$this->register_entity_accept_or_reject_route( $route, array( $this, 'accept_entity' ) );
95
+		$this->register_entity_accept_or_reject_route($route, array($this, 'accept_entity'));
96 96
 	}
97 97
 
98 98
 	private function register_reject_route() {
99 99
 		$route = '/entity/reject';
100
-		$this->register_entity_accept_or_reject_route( $route, array( $this, 'reject_entity' ) );
100
+		$this->register_entity_accept_or_reject_route($route, array($this, 'reject_entity'));
101 101
 	}
102 102
 
103
-	public function reject_entity( $request ) {
103
+	public function reject_entity($request) {
104 104
 		$data        = $request->get_params();
105 105
 		$term_id     = (int) $data['term_id'];
106 106
 		$entity_data = (array) $data['entity'];
107
-		$entity      = Entity_List_Factory::get_instance( $term_id );
107
+		$entity      = Entity_List_Factory::get_instance($term_id);
108 108
 
109
-		$entity_id = array_key_exists( '@id', $entity_data ) ? $entity_data['@id'] : $entity_data['entityId'];
110
-		$entity->remove_entity_by_id( $entity_id );
109
+		$entity_id = array_key_exists('@id', $entity_data) ? $entity_data['@id'] : $entity_data['entityId'];
110
+		$entity->remove_entity_by_id($entity_id);
111 111
 		Ttl_Cache::flush_all();
112 112
 		return $term_id;
113 113
 	}
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 			'/entity/no_match',
119 119
 			array(
120 120
 				'methods'             => WP_REST_Server::CREATABLE,
121
-				'callback'            => array( $this, 'mark_as_no_match' ),
122
-				'permission_callback' => function () {
123
-					return current_user_can( 'manage_options' );
121
+				'callback'            => array($this, 'mark_as_no_match'),
122
+				'permission_callback' => function() {
123
+					return current_user_can('manage_options');
124 124
 				},
125 125
 				'args'                => array(
126 126
 					'term_id' => array(
127 127
 						// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
128
-						'validate_callback' => function ( $param, $request, $key ) {
129
-							return is_numeric( $param ) && $param;
128
+						'validate_callback' => function($param, $request, $key) {
129
+							return is_numeric($param) && $param;
130 130
 						},
131 131
 						'required'          => true,
132 132
 					),
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	/**
139 139
 	 * @param $accept_route
140 140
 	 */
141
-	private function register_entity_accept_or_reject_route( $accept_route, $callback ) {
141
+	private function register_entity_accept_or_reject_route($accept_route, $callback) {
142 142
 
143 143
 		register_rest_route(
144 144
 			Api_Config::REST_NAMESPACE,
@@ -146,21 +146,21 @@  discard block
 block discarded – undo
146 146
 			array(
147 147
 				'methods'             => WP_REST_Server::CREATABLE,
148 148
 				'callback'            => $callback,
149
-				'permission_callback' => function () {
150
-					return current_user_can( 'manage_options' );
149
+				'permission_callback' => function() {
150
+					return current_user_can('manage_options');
151 151
 				},
152 152
 				'args'                => array(
153 153
 					'term_id' => array(
154 154
 						// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
155
-						'validate_callback' => function ( $param, $request, $key ) {
156
-							return is_numeric( $param ) && $param;
155
+						'validate_callback' => function($param, $request, $key) {
156
+							return is_numeric($param) && $param;
157 157
 						},
158 158
 						'required'          => true,
159 159
 					),
160 160
 					'entity'  => array(
161 161
 						// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
162
-						'validate_callback' => function ( $param, $request, $key ) {
163
-							return is_array( $param );
162
+						'validate_callback' => function($param, $request, $key) {
163
+							return is_array($param);
164 164
 						},
165 165
 						'required'          => true,
166 166
 					),
Please login to merge, or discard this patch.
src/wordlift/vocabulary/api/class-reconcile-progress-endpoint.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -14,70 +14,70 @@
 block discarded – undo
14 14
  */
15 15
 class Reconcile_Progress_Endpoint {
16 16
 
17
-	public function register_routes() {
18
-		$that = $this;
19
-		add_action(
20
-			'rest_api_init',
21
-			function () use ( $that ) {
22
-				$that->register_progress_route();
23
-			}
24
-		);
25
-	}
17
+    public function register_routes() {
18
+        $that = $this;
19
+        add_action(
20
+            'rest_api_init',
21
+            function () use ( $that ) {
22
+                $that->register_progress_route();
23
+            }
24
+        );
25
+    }
26 26
 
27
-	public function progress() {
27
+    public function progress() {
28 28
 
29
-		$total_tags = count(
30
-			Terms_Compat::get_terms(
31
-				Terms_Compat::get_public_taxonomies(),
32
-				array(
33
-					'hide_empty' => false,
34
-					'fields'     => 'ids',
35
-					'meta_query' => array(
36
-						array(
37
-							'key'     => Analysis_Background_Service::ENTITIES_PRESENT_FOR_TERM,
38
-							'compare' => '=',
39
-							'value'   => '1',
40
-						),
41
-					),
42
-				)
43
-			)
44
-		);
29
+        $total_tags = count(
30
+            Terms_Compat::get_terms(
31
+                Terms_Compat::get_public_taxonomies(),
32
+                array(
33
+                    'hide_empty' => false,
34
+                    'fields'     => 'ids',
35
+                    'meta_query' => array(
36
+                        array(
37
+                            'key'     => Analysis_Background_Service::ENTITIES_PRESENT_FOR_TERM,
38
+                            'compare' => '=',
39
+                            'value'   => '1',
40
+                        ),
41
+                    ),
42
+                )
43
+            )
44
+        );
45 45
 
46
-		$completed = count(
47
-			Terms_Compat::get_terms(
48
-				Terms_Compat::get_public_taxonomies(),
49
-				array(
50
-					'hide_empty' => false,
51
-					'fields'     => 'ids',
52
-					'meta_query' => array(
53
-						array(
54
-							'key'     => Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING,
55
-							'compare' => '=',
56
-							'value'   => '1',
57
-						),
58
-					),
59
-				)
60
-			)
61
-		);
46
+        $completed = count(
47
+            Terms_Compat::get_terms(
48
+                Terms_Compat::get_public_taxonomies(),
49
+                array(
50
+                    'hide_empty' => false,
51
+                    'fields'     => 'ids',
52
+                    'meta_query' => array(
53
+                        array(
54
+                            'key'     => Entity_Rest_Endpoint::IGNORE_TAG_FROM_LISTING,
55
+                            'compare' => '=',
56
+                            'value'   => '1',
57
+                        ),
58
+                    ),
59
+                )
60
+            )
61
+        );
62 62
 
63
-		return array(
64
-			'completed' => $completed,
65
-			'total'     => $total_tags,
66
-		);
67
-	}
63
+        return array(
64
+            'completed' => $completed,
65
+            'total'     => $total_tags,
66
+        );
67
+    }
68 68
 
69
-	private function register_progress_route() {
70
-		register_rest_route(
71
-			Api_Config::REST_NAMESPACE,
72
-			'/reconcile_progress/progress',
73
-			array(
74
-				'methods'             => \WP_REST_Server::CREATABLE,
75
-				'callback'            => array( $this, 'progress' ),
76
-				'permission_callback' => function () {
77
-					return current_user_can( 'manage_options' );
78
-				},
79
-			)
80
-		);
81
-	}
69
+    private function register_progress_route() {
70
+        register_rest_route(
71
+            Api_Config::REST_NAMESPACE,
72
+            '/reconcile_progress/progress',
73
+            array(
74
+                'methods'             => \WP_REST_Server::CREATABLE,
75
+                'callback'            => array( $this, 'progress' ),
76
+                'permission_callback' => function () {
77
+                    return current_user_can( 'manage_options' );
78
+                },
79
+            )
80
+        );
81
+    }
82 82
 
83 83
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 		$that = $this;
19 19
 		add_action(
20 20
 			'rest_api_init',
21
-			function () use ( $that ) {
21
+			function() use ($that) {
22 22
 				$that->register_progress_route();
23 23
 			}
24 24
 		);
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 			'/reconcile_progress/progress',
73 73
 			array(
74 74
 				'methods'             => \WP_REST_Server::CREATABLE,
75
-				'callback'            => array( $this, 'progress' ),
76
-				'permission_callback' => function () {
77
-					return current_user_can( 'manage_options' );
75
+				'callback'            => array($this, 'progress'),
76
+				'permission_callback' => function() {
77
+					return current_user_can('manage_options');
78 78
 				},
79 79
 			)
80 80
 		);
Please login to merge, or discard this patch.
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
-			self::REST_NAMESPACE . '/tags'
19
-		);
20
-		$settings['baseUrl'] = get_rest_url( null, self::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
+            self::REST_NAMESPACE . '/tags'
19
+        );
20
+        $settings['baseUrl'] = get_rest_url( null, self::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
-			self::REST_NAMESPACE . '/tags'
18
+			self::REST_NAMESPACE.'/tags'
19 19
 		);
20
-		$settings['baseUrl'] = get_rest_url( null, self::REST_NAMESPACE );
21
-		$settings['nonce']   = wp_create_nonce( 'wp_rest' );
20
+		$settings['baseUrl'] = get_rest_url(null, self::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.