@@ -12,33 +12,33 @@ discard block |
||
12 | 12 | * @author Naveen Muthusamy <[email protected]> |
13 | 13 | */ |
14 | 14 | class Term_Matches_Widget { |
15 | - /** |
|
16 | - * @var Term_Count |
|
17 | - */ |
|
18 | - private $term_count; |
|
19 | - |
|
20 | - /** |
|
21 | - * Term_Matches_Widget constructor. |
|
22 | - * |
|
23 | - * @param $term_count Term_Count |
|
24 | - */ |
|
25 | - public function __construct( $term_count ) { |
|
26 | - $this->term_count = $term_count; |
|
27 | - } |
|
28 | - |
|
29 | - public function connect_hook() { |
|
30 | - add_action( 'wl_admin_dashboard_widgets', array( $this, 'render_widget' ) ); |
|
31 | - } |
|
32 | - |
|
33 | - public function render_widget() { |
|
34 | - $term_count = $this->term_count->get_term_count(); |
|
35 | - if ( $term_count <= 0 ) { |
|
36 | - return; |
|
37 | - } |
|
38 | - |
|
39 | - $match_terms_url = menu_page_url( 'wl-vocabulary-match-terms', false ); |
|
40 | - |
|
41 | - ?> |
|
15 | + /** |
|
16 | + * @var Term_Count |
|
17 | + */ |
|
18 | + private $term_count; |
|
19 | + |
|
20 | + /** |
|
21 | + * Term_Matches_Widget constructor. |
|
22 | + * |
|
23 | + * @param $term_count Term_Count |
|
24 | + */ |
|
25 | + public function __construct( $term_count ) { |
|
26 | + $this->term_count = $term_count; |
|
27 | + } |
|
28 | + |
|
29 | + public function connect_hook() { |
|
30 | + add_action( 'wl_admin_dashboard_widgets', array( $this, 'render_widget' ) ); |
|
31 | + } |
|
32 | + |
|
33 | + public function render_widget() { |
|
34 | + $term_count = $this->term_count->get_term_count(); |
|
35 | + if ( $term_count <= 0 ) { |
|
36 | + return; |
|
37 | + } |
|
38 | + |
|
39 | + $match_terms_url = menu_page_url( 'wl-vocabulary-match-terms', false ); |
|
40 | + |
|
41 | + ?> |
|
42 | 42 | <div id="wl-match-terms" class="wl-dashboard__block wl-dashboard__block--match-terms"> |
43 | 43 | <header> |
44 | 44 | <h3><?php esc_html_e( 'Match terms', 'wordlift' ); ?></h3> |
@@ -48,6 +48,6 @@ discard block |
||
48 | 48 | </p> |
49 | 49 | </div> |
50 | 50 | <?php |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | 53 | } |
@@ -22,29 +22,29 @@ |
||
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 | $this->term_count = $term_count; |
27 | 27 | } |
28 | 28 | |
29 | 29 | public function connect_hook() { |
30 | - add_action( 'wl_admin_dashboard_widgets', array( $this, 'render_widget' ) ); |
|
30 | + add_action('wl_admin_dashboard_widgets', array($this, 'render_widget')); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function render_widget() { |
34 | 34 | $term_count = $this->term_count->get_term_count(); |
35 | - if ( $term_count <= 0 ) { |
|
35 | + if ($term_count <= 0) { |
|
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
39 | - $match_terms_url = menu_page_url( 'wl-vocabulary-match-terms', false ); |
|
39 | + $match_terms_url = menu_page_url('wl-vocabulary-match-terms', false); |
|
40 | 40 | |
41 | 41 | ?> |
42 | 42 | <div id="wl-match-terms" class="wl-dashboard__block wl-dashboard__block--match-terms"> |
43 | 43 | <header> |
44 | - <h3><?php esc_html_e( 'Match terms', 'wordlift' ); ?></h3> |
|
44 | + <h3><?php esc_html_e('Match terms', 'wordlift'); ?></h3> |
|
45 | 45 | </header> |
46 | 46 | <p> |
47 | - <strong><a href='<?php echo esc_attr( $match_terms_url ); ?>'><?php echo esc_html( Badge_Generator::get_formatted_count_string( $term_count ) ); ?> term(s)</a></strong> <?php esc_html_e( ' waiting to be matched with entities.', 'wordlift' ); ?> |
|
47 | + <strong><a href='<?php echo esc_attr($match_terms_url); ?>'><?php echo esc_html(Badge_Generator::get_formatted_count_string($term_count)); ?> term(s)</a></strong> <?php esc_html_e(' waiting to be matched with entities.', 'wordlift'); ?> |
|
48 | 48 | </p> |
49 | 49 | </div> |
50 | 50 | <?php |
@@ -7,26 +7,26 @@ |
||
7 | 7 | |
8 | 8 | class Tag_Created_Hook { |
9 | 9 | |
10 | - /** |
|
11 | - * @var $analysis_background_service Analysis_Background_Service |
|
12 | - */ |
|
13 | - private $analysis_background_service; |
|
10 | + /** |
|
11 | + * @var $analysis_background_service Analysis_Background_Service |
|
12 | + */ |
|
13 | + private $analysis_background_service; |
|
14 | 14 | |
15 | - /** |
|
16 | - * Tag_Created_Hook constructor. |
|
17 | - * |
|
18 | - * @param $analysis_background_service Analysis_Background_Service |
|
19 | - */ |
|
20 | - public function __construct( $analysis_background_service ) { |
|
21 | - $this->analysis_background_service = $analysis_background_service; |
|
22 | - $taxonomies = Terms_Compat::get_public_taxonomies(); |
|
23 | - foreach ( $taxonomies as $taxonomy ) { |
|
24 | - add_action( "created_${taxonomy}", array( $this, 'created_term' ) ); |
|
25 | - } |
|
26 | - } |
|
15 | + /** |
|
16 | + * Tag_Created_Hook constructor. |
|
17 | + * |
|
18 | + * @param $analysis_background_service Analysis_Background_Service |
|
19 | + */ |
|
20 | + public function __construct( $analysis_background_service ) { |
|
21 | + $this->analysis_background_service = $analysis_background_service; |
|
22 | + $taxonomies = Terms_Compat::get_public_taxonomies(); |
|
23 | + foreach ( $taxonomies as $taxonomy ) { |
|
24 | + add_action( "created_${taxonomy}", array( $this, 'created_term' ) ); |
|
25 | + } |
|
26 | + } |
|
27 | 27 | |
28 | - public function created_term() { |
|
29 | - $this->analysis_background_service->start(); |
|
30 | - } |
|
28 | + public function created_term() { |
|
29 | + $this->analysis_background_service->start(); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | } |
@@ -17,11 +17,11 @@ |
||
17 | 17 | * |
18 | 18 | * @param $analysis_background_service Analysis_Background_Service |
19 | 19 | */ |
20 | - public function __construct( $analysis_background_service ) { |
|
20 | + public function __construct($analysis_background_service) { |
|
21 | 21 | $this->analysis_background_service = $analysis_background_service; |
22 | 22 | $taxonomies = Terms_Compat::get_public_taxonomies(); |
23 | - foreach ( $taxonomies as $taxonomy ) { |
|
24 | - add_action( "created_${taxonomy}", array( $this, 'created_term' ) ); |
|
23 | + foreach ($taxonomies as $taxonomy) { |
|
24 | + add_action("created_${taxonomy}", array($this, 'created_term')); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 |
@@ -14,68 +14,68 @@ |
||
14 | 14 | */ |
15 | 15 | class Term_Page_Hook { |
16 | 16 | |
17 | - const HANDLE = 'wl-vocabulary-term-page-handle'; |
|
18 | - |
|
19 | - const LOCALIZED_KEY = '_wlVocabularyTermPageSettings'; |
|
20 | - |
|
21 | - private $term_data_factory; |
|
22 | - |
|
23 | - /** |
|
24 | - * Term_Page_Hook constructor. |
|
25 | - * |
|
26 | - * @param $term_data_factory Term_Data_Factory |
|
27 | - */ |
|
28 | - public function __construct( $term_data_factory ) { |
|
29 | - $this->term_data_factory = $term_data_factory; |
|
30 | - } |
|
31 | - |
|
32 | - public function connect_hook() { |
|
33 | - $taxonomies = Terms_Compat::get_public_taxonomies(); |
|
34 | - foreach ( $taxonomies as $taxonomy ) { |
|
35 | - add_action( "${taxonomy}_edit_form_fields", array( $this, 'load_scripts' ), 2, PHP_INT_MAX ); |
|
36 | - } |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * @param $term \WP_Term |
|
41 | - */ |
|
42 | - public function load_scripts( $term ) { |
|
43 | - |
|
44 | - $term_data = $this->term_data_factory->get_term_data( $term ); |
|
45 | - |
|
46 | - Scripts_Helper::enqueue_based_on_wordpress_version( |
|
47 | - self::HANDLE, |
|
48 | - plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/vocabulary-term-page', |
|
49 | - array( 'react', 'react-dom', 'wp-polyfill', 'wp-i18n' ), |
|
50 | - true |
|
51 | - ); |
|
52 | - |
|
53 | - wp_enqueue_style( self::HANDLE, plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/vocabulary-term-page.full.css', array(), WORDLIFT_VERSION ); |
|
54 | - |
|
55 | - $term_data_arr = $term_data->get_data(); |
|
56 | - |
|
57 | - $term_data_arr['entities'] = Entity_List_Utils::mark_is_active_for_entities( $term->term_id, $term_data_arr['entities'] ); |
|
58 | - |
|
59 | - wp_localize_script( |
|
60 | - self::HANDLE, |
|
61 | - self::LOCALIZED_KEY, |
|
62 | - array( |
|
63 | - 'termData' => $term_data_arr, |
|
64 | - 'apiConfig' => Api_Config::get_api_config(), |
|
65 | - 'restUrl' => get_rest_url( null, Api_Config::REST_NAMESPACE . '/search-entity/' ), |
|
66 | - 'nonce' => wp_create_nonce( 'wp_rest' ), |
|
67 | - ) |
|
68 | - ); |
|
69 | - |
|
70 | - echo "<tr class=\"form-field\"> |
|
17 | + const HANDLE = 'wl-vocabulary-term-page-handle'; |
|
18 | + |
|
19 | + const LOCALIZED_KEY = '_wlVocabularyTermPageSettings'; |
|
20 | + |
|
21 | + private $term_data_factory; |
|
22 | + |
|
23 | + /** |
|
24 | + * Term_Page_Hook constructor. |
|
25 | + * |
|
26 | + * @param $term_data_factory Term_Data_Factory |
|
27 | + */ |
|
28 | + public function __construct( $term_data_factory ) { |
|
29 | + $this->term_data_factory = $term_data_factory; |
|
30 | + } |
|
31 | + |
|
32 | + public function connect_hook() { |
|
33 | + $taxonomies = Terms_Compat::get_public_taxonomies(); |
|
34 | + foreach ( $taxonomies as $taxonomy ) { |
|
35 | + add_action( "${taxonomy}_edit_form_fields", array( $this, 'load_scripts' ), 2, PHP_INT_MAX ); |
|
36 | + } |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * @param $term \WP_Term |
|
41 | + */ |
|
42 | + public function load_scripts( $term ) { |
|
43 | + |
|
44 | + $term_data = $this->term_data_factory->get_term_data( $term ); |
|
45 | + |
|
46 | + Scripts_Helper::enqueue_based_on_wordpress_version( |
|
47 | + self::HANDLE, |
|
48 | + plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/vocabulary-term-page', |
|
49 | + array( 'react', 'react-dom', 'wp-polyfill', 'wp-i18n' ), |
|
50 | + true |
|
51 | + ); |
|
52 | + |
|
53 | + wp_enqueue_style( self::HANDLE, plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/vocabulary-term-page.full.css', array(), WORDLIFT_VERSION ); |
|
54 | + |
|
55 | + $term_data_arr = $term_data->get_data(); |
|
56 | + |
|
57 | + $term_data_arr['entities'] = Entity_List_Utils::mark_is_active_for_entities( $term->term_id, $term_data_arr['entities'] ); |
|
58 | + |
|
59 | + wp_localize_script( |
|
60 | + self::HANDLE, |
|
61 | + self::LOCALIZED_KEY, |
|
62 | + array( |
|
63 | + 'termData' => $term_data_arr, |
|
64 | + 'apiConfig' => Api_Config::get_api_config(), |
|
65 | + 'restUrl' => get_rest_url( null, Api_Config::REST_NAMESPACE . '/search-entity/' ), |
|
66 | + 'nonce' => wp_create_nonce( 'wp_rest' ), |
|
67 | + ) |
|
68 | + ); |
|
69 | + |
|
70 | + echo "<tr class=\"form-field\"> |
|
71 | 71 | <th>Match</th> |
72 | 72 | <td style='width: 100%;' id='wl_vocabulary_terms_widget'></td> |
73 | 73 | </tr>"; |
74 | 74 | |
75 | - echo "<tr class=\"form-field\"> |
|
75 | + echo "<tr class=\"form-field\"> |
|
76 | 76 | <th></th> |
77 | 77 | <td id='wl_vocabulary_terms_autocomplete_select'></td></tr>"; |
78 | 78 | |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | 81 | } |
@@ -25,36 +25,36 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @param $term_data_factory Term_Data_Factory |
27 | 27 | */ |
28 | - public function __construct( $term_data_factory ) { |
|
28 | + public function __construct($term_data_factory) { |
|
29 | 29 | $this->term_data_factory = $term_data_factory; |
30 | 30 | } |
31 | 31 | |
32 | 32 | public function connect_hook() { |
33 | 33 | $taxonomies = Terms_Compat::get_public_taxonomies(); |
34 | - foreach ( $taxonomies as $taxonomy ) { |
|
35 | - add_action( "${taxonomy}_edit_form_fields", array( $this, 'load_scripts' ), 2, PHP_INT_MAX ); |
|
34 | + foreach ($taxonomies as $taxonomy) { |
|
35 | + add_action("${taxonomy}_edit_form_fields", array($this, 'load_scripts'), 2, PHP_INT_MAX); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @param $term \WP_Term |
41 | 41 | */ |
42 | - public function load_scripts( $term ) { |
|
42 | + public function load_scripts($term) { |
|
43 | 43 | |
44 | - $term_data = $this->term_data_factory->get_term_data( $term ); |
|
44 | + $term_data = $this->term_data_factory->get_term_data($term); |
|
45 | 45 | |
46 | 46 | Scripts_Helper::enqueue_based_on_wordpress_version( |
47 | 47 | self::HANDLE, |
48 | - plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/vocabulary-term-page', |
|
49 | - array( 'react', 'react-dom', 'wp-polyfill', 'wp-i18n' ), |
|
48 | + plugin_dir_url(dirname(dirname(__DIR__))).'js/dist/vocabulary-term-page', |
|
49 | + array('react', 'react-dom', 'wp-polyfill', 'wp-i18n'), |
|
50 | 50 | true |
51 | 51 | ); |
52 | 52 | |
53 | - wp_enqueue_style( self::HANDLE, plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/vocabulary-term-page.full.css', array(), WORDLIFT_VERSION ); |
|
53 | + wp_enqueue_style(self::HANDLE, plugin_dir_url(dirname(dirname(__DIR__))).'js/dist/vocabulary-term-page.full.css', array(), WORDLIFT_VERSION); |
|
54 | 54 | |
55 | 55 | $term_data_arr = $term_data->get_data(); |
56 | 56 | |
57 | - $term_data_arr['entities'] = Entity_List_Utils::mark_is_active_for_entities( $term->term_id, $term_data_arr['entities'] ); |
|
57 | + $term_data_arr['entities'] = Entity_List_Utils::mark_is_active_for_entities($term->term_id, $term_data_arr['entities']); |
|
58 | 58 | |
59 | 59 | wp_localize_script( |
60 | 60 | self::HANDLE, |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | array( |
63 | 63 | 'termData' => $term_data_arr, |
64 | 64 | 'apiConfig' => Api_Config::get_api_config(), |
65 | - 'restUrl' => get_rest_url( null, Api_Config::REST_NAMESPACE . '/search-entity/' ), |
|
66 | - 'nonce' => wp_create_nonce( 'wp_rest' ), |
|
65 | + 'restUrl' => get_rest_url(null, Api_Config::REST_NAMESPACE.'/search-entity/'), |
|
66 | + 'nonce' => wp_create_nonce('wp_rest'), |
|
67 | 67 | ) |
68 | 68 | ); |
69 | 69 |
@@ -14,25 +14,25 @@ |
||
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 | } |
@@ -17,10 +17,10 @@ discard block |
||
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 |
||
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 | } |
@@ -3,19 +3,19 @@ |
||
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 | } |
@@ -3,19 +3,19 @@ |
||
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 | } |
@@ -22,54 +22,54 @@ |
||
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 |
@@ -27,14 +27,14 @@ discard block |
||
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 |
||
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(); |
@@ -9,118 +9,118 @@ |
||
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 | } |
@@ -19,10 +19,10 @@ discard block |
||
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 |
||
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 |
||
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', |
@@ -13,121 +13,121 @@ |
||
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 | } |
@@ -23,7 +23,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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(), |
@@ -14,132 +14,132 @@ |
||
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 | } |
@@ -23,7 +23,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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() { |