@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | class Post_Entity_Match_Service extends Match_Service { |
10 | 10 | |
11 | - public function list_items( $args ) { |
|
11 | + public function list_items($args) { |
|
12 | 12 | global $wpdb; |
13 | 13 | |
14 | 14 | $params = wp_parse_args( |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @var $sort Sort |
29 | 29 | */ |
30 | - $sort = new Sort( $params['sort'] ); |
|
30 | + $sort = new Sort($params['sort']); |
|
31 | 31 | |
32 | 32 | $query_builder = new Query_Builder( |
33 | 33 | $params, |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | $items = $wpdb->get_results( |
38 | 38 | // Each function above is preparing `$sql` by using `$wpdb->prepare`. |
39 | 39 | // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
40 | - $wpdb->prepare( $query_builder->get(), Object_Type_Enum::POST ) |
|
40 | + $wpdb->prepare($query_builder->get(), Object_Type_Enum::POST) |
|
41 | 41 | ); |
42 | 42 | |
43 | - $sort->apply( $items ); |
|
43 | + $sort->apply($items); |
|
44 | 44 | |
45 | - return $this->map( $items ); |
|
45 | + return $this->map($items); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** Returns an array of rows where each row contains |
@@ -59,20 +59,20 @@ discard block |
||
59 | 59 | * 'match_jsonld' => The matched `about_jsonld` column from wl_entities. |
60 | 60 | * 'match_id' => This id points to id column of wl_entities table. |
61 | 61 | */ |
62 | - private function map( array $items ) { |
|
62 | + private function map(array $items) { |
|
63 | 63 | return array_map( |
64 | - function ( $item ) { |
|
65 | - $data = json_decode( $item->match_jsonld, true ); |
|
66 | - $item->match_name = $data && is_array( $data ) && array_key_exists( 'name', $data ) ? $data['name'] : null; |
|
64 | + function($item) { |
|
65 | + $data = json_decode($item->match_jsonld, true); |
|
66 | + $item->match_name = $data && is_array($data) && array_key_exists('name', $data) ? $data['name'] : null; |
|
67 | 67 | |
68 | - if ( $item->id ) { |
|
69 | - $item->post_link = get_edit_post_link( $item->id, 'ui' ); |
|
70 | - $item->view_link = get_permalink( $item->id ); |
|
71 | - $item->preview_link = get_preview_post_link( $item->id ); |
|
68 | + if ($item->id) { |
|
69 | + $item->post_link = get_edit_post_link($item->id, 'ui'); |
|
70 | + $item->view_link = get_permalink($item->id); |
|
71 | + $item->preview_link = get_preview_post_link($item->id); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( $item->parent_post_id ) { |
|
75 | - $item->parent_post_link = get_edit_post_link( $item->parent_post_id, 'ui' ); |
|
74 | + if ($item->parent_post_id) { |
|
75 | + $item->parent_post_link = get_edit_post_link($item->parent_post_id, 'ui'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return $item; |
@@ -61,16 +61,16 @@ discard block |
||
61 | 61 | global $wpdb; |
62 | 62 | |
63 | 63 | // If a value has been provided and it's either 'draft' or 'publish', we add the related filter. |
64 | - if ( is_string( $this->params['post_status'] ) && in_array( |
|
64 | + if (is_string($this->params['post_status']) && in_array( |
|
65 | 65 | $this->params['post_status'], |
66 | 66 | array( |
67 | 67 | 'publish', |
68 | 68 | 'draft', |
69 | 69 | ), |
70 | 70 | true |
71 | - ) ) { |
|
71 | + )) { |
|
72 | 72 | |
73 | - $this->sql .= $wpdb->prepare( ' AND p.post_status = %s', $this->params['post_status'] ); |
|
73 | + $this->sql .= $wpdb->prepare(' AND p.post_status = %s', $this->params['post_status']); |
|
74 | 74 | |
75 | 75 | return $this; |
76 | 76 | } |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | public function post_type() { |
85 | 85 | $post_types = $this->params['post_types']; |
86 | 86 | |
87 | - if ( ! isset( $post_types ) ) { |
|
87 | + if ( ! isset($post_types)) { |
|
88 | 88 | return $this; |
89 | 89 | } |
90 | - $post_types_sql = Escape::sql_array( $post_types ); |
|
90 | + $post_types_sql = Escape::sql_array($post_types); |
|
91 | 91 | $this->sql .= " AND p.post_type IN ({$post_types_sql}) "; |
92 | 92 | |
93 | 93 | return $this; |
@@ -7,8 +7,8 @@ |
||
7 | 7 | class Sort extends Match_Sort { |
8 | 8 | |
9 | 9 | public function get_field_name() { |
10 | - $tmp_sort_field_name = substr( $this->sort, 1 ); |
|
11 | - if ( 'id' === $tmp_sort_field_name ) { |
|
10 | + $tmp_sort_field_name = substr($this->sort, 1); |
|
11 | + if ('id' === $tmp_sort_field_name) { |
|
12 | 12 | return 'p.ID'; |
13 | 13 | } |
14 | 14 | elseif ('date_modified_gmt' === $tmp_sort_field_name) { |
@@ -16,12 +16,12 @@ discard block |
||
16 | 16 | */ |
17 | 17 | private $match_service; |
18 | 18 | |
19 | - public function __construct( $match_service ) { |
|
19 | + public function __construct($match_service) { |
|
20 | 20 | $this->match_service = $match_service; |
21 | 21 | } |
22 | 22 | |
23 | 23 | public function register_hooks() { |
24 | - add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
|
24 | + add_action('rest_api_init', array($this, 'register_routes')); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | '/post-matches', |
36 | 36 | array( |
37 | 37 | 'methods' => 'GET', |
38 | - 'callback' => array( $this, 'get_post_matches' ), |
|
38 | + 'callback' => array($this, 'get_post_matches'), |
|
39 | 39 | 'args' => array( |
40 | 40 | 'cursor' => array( |
41 | 41 | 'type' => 'string', |
42 | 42 | 'default' => Cursor::EMPTY_CURSOR_AS_BASE64_STRING, |
43 | 43 | 'validate_callback' => 'rest_validate_request_arg', |
44 | - 'sanitize_callback' => array( Cursor::class, 'rest_sanitize_request_arg' ), |
|
44 | + 'sanitize_callback' => array(Cursor::class, 'rest_sanitize_request_arg'), |
|
45 | 45 | ), |
46 | 46 | 'limit' => array( |
47 | 47 | 'type' => 'integer', |
@@ -63,19 +63,19 @@ discard block |
||
63 | 63 | 'post_status' => array( |
64 | 64 | 'type' => 'string', |
65 | 65 | 'required' => false, |
66 | - 'enum' => array( 'publish', 'draft' ), |
|
66 | + 'enum' => array('publish', 'draft'), |
|
67 | 67 | 'validate_callback' => 'rest_validate_request_arg', |
68 | 68 | ), |
69 | 69 | 'sort' => array( |
70 | 70 | 'type' => 'string', |
71 | 71 | 'required' => false, |
72 | - 'enum' => array( '+date_modified_gmt', '-date_modified_gmt' ), |
|
72 | + 'enum' => array('+date_modified_gmt', '-date_modified_gmt'), |
|
73 | 73 | 'validate_callback' => 'rest_validate_request_arg', |
74 | 74 | 'default' => '+date_modified_gmt', |
75 | 75 | ), |
76 | 76 | ), |
77 | - 'permission_callback' => function () { |
|
78 | - return current_user_can( 'manage_options' ); |
|
77 | + 'permission_callback' => function() { |
|
78 | + return current_user_can('manage_options'); |
|
79 | 79 | }, |
80 | 80 | ) |
81 | 81 | ); |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | '/post-matches/(?P<post_id>\d+)/matches', |
87 | 87 | array( |
88 | 88 | 'methods' => 'POST', |
89 | - 'callback' => array( $this, 'create_post_match' ), |
|
89 | + 'callback' => array($this, 'create_post_match'), |
|
90 | 90 | 'args' => array( |
91 | 91 | 'post_id' => array( |
92 | 92 | 'required' => true, |
93 | 93 | 'validate_callback' => 'rest_validate_request_arg', |
94 | 94 | ), |
95 | 95 | ), |
96 | - 'permission_callback' => function () { |
|
97 | - return current_user_can( 'manage_options' ); |
|
96 | + 'permission_callback' => function() { |
|
97 | + return current_user_can('manage_options'); |
|
98 | 98 | }, |
99 | 99 | ) |
100 | 100 | ); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | '/post-matches/(?P<post_id>\d+)/matches/(?P<match_id>\d+)', |
106 | 106 | array( |
107 | 107 | 'methods' => 'PUT', |
108 | - 'callback' => array( $this, 'update_post_match' ), |
|
108 | + 'callback' => array($this, 'update_post_match'), |
|
109 | 109 | 'args' => array( |
110 | 110 | 'post_id' => array( |
111 | 111 | 'required' => true, |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | 'validate_callback' => 'rest_validate_request_arg', |
117 | 117 | ), |
118 | 118 | ), |
119 | - 'permission_callback' => function () { |
|
119 | + 'permission_callback' => function() { |
|
120 | 120 | |
121 | - return current_user_can( 'manage_options' ); |
|
121 | + return current_user_can('manage_options'); |
|
122 | 122 | }, |
123 | 123 | ) |
124 | 124 | ); |
@@ -129,36 +129,36 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @var $request \WP_REST_Request |
131 | 131 | */ |
132 | - public function get_post_matches( $request ) { |
|
132 | + public function get_post_matches($request) { |
|
133 | 133 | |
134 | - $cursor = $request->get_param( 'cursor' ); |
|
135 | - if ( $request->has_param( 'limit' ) ) { |
|
136 | - $cursor['limit'] = $request->get_param( 'limit' ); |
|
134 | + $cursor = $request->get_param('cursor'); |
|
135 | + if ($request->has_param('limit')) { |
|
136 | + $cursor['limit'] = $request->get_param('limit'); |
|
137 | 137 | } |
138 | - if ( $request->has_param( 'sort' ) ) { |
|
139 | - $cursor['sort'] = $request->get_param( 'sort' ); |
|
138 | + if ($request->has_param('sort')) { |
|
139 | + $cursor['sort'] = $request->get_param('sort'); |
|
140 | 140 | } |
141 | - if ( $request->has_param( 'post_types' ) ) { |
|
142 | - $cursor['query']['post_types'] = $request->get_param( 'post_types' ); |
|
141 | + if ($request->has_param('post_types')) { |
|
142 | + $cursor['query']['post_types'] = $request->get_param('post_types'); |
|
143 | 143 | } |
144 | - if ( $request->has_param( 'has_match' ) ) { |
|
145 | - $cursor['query']['has_match'] = $request->get_param( 'has_match' ); |
|
144 | + if ($request->has_param('has_match')) { |
|
145 | + $cursor['query']['has_match'] = $request->get_param('has_match'); |
|
146 | 146 | } |
147 | - if ( $request->has_param( 'post_status' ) ) { |
|
148 | - $cursor['query']['post_status'] = $request->get_param( 'post_status' ); |
|
147 | + if ($request->has_param('post_status')) { |
|
148 | + $cursor['query']['post_status'] = $request->get_param('post_status'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // Query. |
152 | - $post_types = isset( $cursor['query']['post_types'] ) ? $cursor['query']['post_types'] : apply_filters( |
|
152 | + $post_types = isset($cursor['query']['post_types']) ? $cursor['query']['post_types'] : apply_filters( |
|
153 | 153 | 'wl_dashboard__post_entity_match__post_types', |
154 | 154 | array( |
155 | 155 | 'post', |
156 | 156 | 'page', |
157 | 157 | ) |
158 | 158 | ); |
159 | - $has_match = isset( $cursor['query']['has_match'] ) ? $cursor['query']['has_match'] : null; |
|
159 | + $has_match = isset($cursor['query']['has_match']) ? $cursor['query']['has_match'] : null; |
|
160 | 160 | |
161 | - $post_status = isset( $cursor['query']['post_status'] ) ? $cursor['query']['post_status'] : null; |
|
161 | + $post_status = isset($cursor['query']['post_status']) ? $cursor['query']['post_status'] : null; |
|
162 | 162 | |
163 | 163 | $items = $this->match_service->list_items( |
164 | 164 | array( |
@@ -192,15 +192,15 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @var $request \WP_REST_Request |
194 | 194 | */ |
195 | - public function create_post_match( $request ) { |
|
196 | - $post_id = $request->get_param( 'post_id' ); |
|
195 | + public function create_post_match($request) { |
|
196 | + $post_id = $request->get_param('post_id'); |
|
197 | 197 | |
198 | 198 | // If we dont have a entry on the match table, then add one. |
199 | - $content_id = Wordpress_Content_Id::create_post( $post_id ); |
|
199 | + $content_id = Wordpress_Content_Id::create_post($post_id); |
|
200 | 200 | if ( ! Wordpress_Content_Service::get_instance() |
201 | - ->get_entity_id( $content_id ) ) { |
|
202 | - $uri = Entity_Uri_Generator::create_uri( $content_id->get_type(), $content_id->get_id() ); |
|
203 | - Wordpress_Content_Service::get_instance()->set_entity_id( $content_id, $uri ); |
|
201 | + ->get_entity_id($content_id)) { |
|
202 | + $uri = Entity_Uri_Generator::create_uri($content_id->get_type(), $content_id->get_id()); |
|
203 | + Wordpress_Content_Service::get_instance()->set_entity_id($content_id, $uri); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | $match_id = $this->match_service->get_id( |
@@ -219,12 +219,12 @@ discard block |
||
219 | 219 | /** |
220 | 220 | * @var $request \WP_REST_Request |
221 | 221 | */ |
222 | - public function update_post_match( $request ) { |
|
222 | + public function update_post_match($request) { |
|
223 | 223 | |
224 | 224 | return $this->match_service->set_jsonld( |
225 | - $request->get_param( 'post_id' ), |
|
225 | + $request->get_param('post_id'), |
|
226 | 226 | Object_Type_Enum::POST, |
227 | - $request->get_param( 'match_id' ), |
|
227 | + $request->get_param('match_id'), |
|
228 | 228 | $request->get_json_params() |
229 | 229 | ); |
230 | 230 | } |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | public function taxonomy() { |
38 | 38 | $taxonomies = $this->params['taxonomies']; |
39 | 39 | |
40 | - if ( ! isset( $taxonomies ) ) { |
|
40 | + if ( ! isset($taxonomies)) { |
|
41 | 41 | return $this; |
42 | 42 | } |
43 | - $sql = Escape::sql_array( $taxonomies ); |
|
43 | + $sql = Escape::sql_array($taxonomies); |
|
44 | 44 | $this->sql .= " AND tt.taxonomy IN ($sql)"; |
45 | 45 | return $this; |
46 | 46 | } |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | global $wpdb; |
50 | 50 | |
51 | 51 | // If the ingredient_name_contains value is a non-empty string, add the filter |
52 | - if ( is_string( $this->params['ingredient_name_contains'] ) && ! empty( $this->params['ingredient_name_contains'] ) ) { |
|
52 | + if (is_string($this->params['ingredient_name_contains']) && ! empty($this->params['ingredient_name_contains'])) { |
|
53 | 53 | $ingredient_name_contains = $this->params['ingredient_name_contains']; |
54 | - $this->sql .= $wpdb->prepare( ' AND t.name LIKE %s', '%' . $ingredient_name_contains . '%' ); |
|
54 | + $this->sql .= $wpdb->prepare(' AND t.name LIKE %s', '%'.$ingredient_name_contains.'%'); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | return $this; |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | |
14 | 14 | private $match_service; |
15 | 15 | |
16 | - public function __construct( $match_service ) { |
|
16 | + public function __construct($match_service) { |
|
17 | 17 | $this->match_service = $match_service; |
18 | 18 | } |
19 | 19 | |
20 | 20 | public function register_hooks() { |
21 | - add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
|
21 | + add_action('rest_api_init', array($this, 'register_routes')); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | '/term-matches', |
33 | 33 | array( |
34 | 34 | 'methods' => 'GET', |
35 | - 'callback' => array( $this, 'get_term_matches' ), |
|
35 | + 'callback' => array($this, 'get_term_matches'), |
|
36 | 36 | 'args' => array( |
37 | 37 | 'cursor' => array( |
38 | 38 | 'type' => 'string', |
39 | 39 | 'default' => Cursor::EMPTY_CURSOR_AS_BASE64_STRING, |
40 | 40 | 'validate_callback' => 'rest_validate_request_arg', |
41 | - 'sanitize_callback' => array( Cursor::class, 'rest_sanitize_request_arg' ), |
|
41 | + 'sanitize_callback' => array(Cursor::class, 'rest_sanitize_request_arg'), |
|
42 | 42 | ), |
43 | 43 | 'limit' => array( |
44 | 44 | 'type' => 'integer', |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | 'sort' => array( |
66 | 66 | 'type' => 'string', |
67 | 67 | 'required' => 'false', |
68 | - 'enum' => array( '+ingredient_term', '-ingredient_term', '+matched_ingredient', '-matched_ingredient', '+occurrences', '-occurrences'), |
|
68 | + 'enum' => array('+ingredient_term', '-ingredient_term', '+matched_ingredient', '-matched_ingredient', '+occurrences', '-occurrences'), |
|
69 | 69 | 'validate_callback' => 'rest_validate_request_arg', |
70 | 70 | ) |
71 | 71 | ), |
72 | - 'permission_callback' => function () { |
|
73 | - return current_user_can( 'manage_options' ); |
|
72 | + 'permission_callback' => function() { |
|
73 | + return current_user_can('manage_options'); |
|
74 | 74 | }, |
75 | 75 | ) |
76 | 76 | ); |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | '/term-matches/(?P<term_id>\d+)/matches', |
82 | 82 | array( |
83 | 83 | 'methods' => 'POST', |
84 | - 'callback' => array( $this, 'create_term_match' ), |
|
84 | + 'callback' => array($this, 'create_term_match'), |
|
85 | 85 | 'args' => array( |
86 | 86 | 'term_id' => array( |
87 | 87 | 'required' => true, |
88 | 88 | 'validate_callback' => 'rest_validate_request_arg', |
89 | 89 | ), |
90 | 90 | ), |
91 | - 'permission_callback' => function () { |
|
92 | - return current_user_can( 'manage_options' ); |
|
91 | + 'permission_callback' => function() { |
|
92 | + return current_user_can('manage_options'); |
|
93 | 93 | }, |
94 | 94 | ) |
95 | 95 | ); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | '/term-matches/(?P<term_id>\d+)/matches/(?P<match_id>\d+)', |
101 | 101 | array( |
102 | 102 | 'methods' => 'PUT', |
103 | - 'callback' => array( $this, 'update_term_match' ), |
|
103 | + 'callback' => array($this, 'update_term_match'), |
|
104 | 104 | 'args' => array( |
105 | 105 | 'term_id' => array( |
106 | 106 | 'required' => true, |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | 'validate_callback' => 'rest_validate_request_arg', |
112 | 112 | ), |
113 | 113 | ), |
114 | - 'permission_callback' => function () { |
|
114 | + 'permission_callback' => function() { |
|
115 | 115 | |
116 | - return current_user_can( 'manage_options' ); |
|
116 | + return current_user_can('manage_options'); |
|
117 | 117 | }, |
118 | 118 | ) |
119 | 119 | ); |
@@ -124,27 +124,27 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @var $request \WP_REST_Request |
126 | 126 | */ |
127 | - public function get_term_matches( $request ) { |
|
127 | + public function get_term_matches($request) { |
|
128 | 128 | |
129 | - $cursor = $request->get_param( 'cursor' ); |
|
130 | - if ( $request->has_param( 'limit' ) ) { |
|
131 | - $cursor['limit'] = $request->get_param( 'limit' ); |
|
129 | + $cursor = $request->get_param('cursor'); |
|
130 | + if ($request->has_param('limit')) { |
|
131 | + $cursor['limit'] = $request->get_param('limit'); |
|
132 | 132 | } |
133 | - if ( $request->has_param( 'sort' ) ) { |
|
134 | - $cursor['sort'] = $request->get_param( 'sort' ); |
|
133 | + if ($request->has_param('sort')) { |
|
134 | + $cursor['sort'] = $request->get_param('sort'); |
|
135 | 135 | } |
136 | - if ( $request->has_param( 'taxonomies' ) ) { |
|
137 | - $cursor['query']['taxonomies'] = $request->get_param( 'taxonomies' ); |
|
136 | + if ($request->has_param('taxonomies')) { |
|
137 | + $cursor['query']['taxonomies'] = $request->get_param('taxonomies'); |
|
138 | 138 | } |
139 | - if ( $request->has_param( 'has_match' ) ) { |
|
140 | - $cursor['query']['has_match'] = $request->get_param( 'has_match' ); |
|
139 | + if ($request->has_param('has_match')) { |
|
140 | + $cursor['query']['has_match'] = $request->get_param('has_match'); |
|
141 | 141 | } |
142 | - if ( $request->has_param( 'ingredient_name_contains' )) { |
|
142 | + if ($request->has_param('ingredient_name_contains')) { |
|
143 | 143 | $cursor['query']['ingredient_name_contains'] = $request->get_param('ingredient_name_contains'); |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Query. |
147 | - $taxonomies = isset( $cursor['query']['taxonomies'] ) ? $cursor['query']['taxonomies'] : apply_filters( |
|
147 | + $taxonomies = isset($cursor['query']['taxonomies']) ? $cursor['query']['taxonomies'] : apply_filters( |
|
148 | 148 | 'wl_dashboard__post_entity_match__taxonomies', |
149 | 149 | array( |
150 | 150 | 'post_tag', |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | ) |
153 | 153 | ); |
154 | 154 | |
155 | - $has_match = isset( $cursor['query']['has_match'] ) ? $cursor['query']['has_match'] : null; |
|
156 | - $ingredient_name_contains = isset( $cursor['query']['ingredient_name_contains']) ? $cursor['query']['ingredient_name_contains'] : null; |
|
155 | + $has_match = isset($cursor['query']['has_match']) ? $cursor['query']['has_match'] : null; |
|
156 | + $ingredient_name_contains = isset($cursor['query']['ingredient_name_contains']) ? $cursor['query']['ingredient_name_contains'] : null; |
|
157 | 157 | |
158 | 158 | $items = $this->match_service->list_items( |
159 | 159 | array( |
@@ -187,16 +187,16 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @var $request \WP_REST_Request |
189 | 189 | */ |
190 | - public function create_term_match( $request ) { |
|
190 | + public function create_term_match($request) { |
|
191 | 191 | |
192 | - $term_id = $request->get_param( 'term_id' ); |
|
192 | + $term_id = $request->get_param('term_id'); |
|
193 | 193 | |
194 | 194 | // If we dont have a entry on the match table, then add one. |
195 | - $content_id = Wordpress_Content_Id::create_term( $term_id ); |
|
195 | + $content_id = Wordpress_Content_Id::create_term($term_id); |
|
196 | 196 | if ( ! Wordpress_Content_Service::get_instance() |
197 | - ->get_entity_id( $content_id ) ) { |
|
198 | - $uri = Entity_Uri_Generator::create_uri( $content_id->get_type(), $content_id->get_id() ); |
|
199 | - Wordpress_Content_Service::get_instance()->set_entity_id( $content_id, $uri ); |
|
197 | + ->get_entity_id($content_id)) { |
|
198 | + $uri = Entity_Uri_Generator::create_uri($content_id->get_type(), $content_id->get_id()); |
|
199 | + Wordpress_Content_Service::get_instance()->set_entity_id($content_id, $uri); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | $match_id = $this->match_service->get_id( |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | /** |
217 | 217 | * @var $request \WP_REST_Request |
218 | 218 | */ |
219 | - public function update_term_match( $request ) { |
|
219 | + public function update_term_match($request) { |
|
220 | 220 | |
221 | 221 | return $this->match_service->set_jsonld( |
222 | - $request->get_param( 'term_id' ), |
|
222 | + $request->get_param('term_id'), |
|
223 | 223 | Object_Type_Enum::TERM, |
224 | - $request->get_param( 'match_id' ), |
|
224 | + $request->get_param('match_id'), |
|
225 | 225 | $request->get_json_params() |
226 | 226 | ); |
227 | 227 | } |
@@ -7,14 +7,14 @@ |
||
7 | 7 | class Sort extends Match_Sort { |
8 | 8 | |
9 | 9 | public function get_field_name() { |
10 | - $tmp_sort_field_name = substr( $this->sort, 1 ); |
|
11 | - if ( 'id' === $tmp_sort_field_name ) { |
|
10 | + $tmp_sort_field_name = substr($this->sort, 1); |
|
11 | + if ('id' === $tmp_sort_field_name) { |
|
12 | 12 | return 't.term_id'; |
13 | - } elseif ( 'ingredient_term' ) { |
|
13 | + } elseif ('ingredient_term') { |
|
14 | 14 | return 't.name'; |
15 | - } elseif ( 'matched_ingredient' ) { |
|
15 | + } elseif ('matched_ingredient') { |
|
16 | 16 | //@todo -not sure what this is |
17 | - } elseif ( 'occurrences' ) { |
|
17 | + } elseif ('occurrences') { |
|
18 | 18 | //@todo |
19 | 19 | } else { |
20 | 20 | return 't.name'; |