Completed
Pull Request — master (#64)
by
unknown
44s
created
wp-api-menus.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
31 31
  */
32 32
 
33
-if ( ! defined( 'ABSPATH' ) ) {
33
+if ( ! defined('ABSPATH')) {
34 34
 	exit; // Exit if accessed directly
35 35
 }
36 36
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 // WP API v2.
40 40
 include_once 'includes/wp-api-menus-v2.php';
41 41
 
42
-if ( ! function_exists( 'wp_rest_menus_init' ) ) :
42
+if ( ! function_exists('wp_rest_menus_init')) :
43 43
 	/**
44 44
 	 * Init JSON REST API Menu routes.
45 45
 	 *
@@ -47,21 +47,21 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	function wp_rest_menus_init() {
49 49
 
50
-		if ( ! defined( 'JSON_API_VERSION' ) &&
51
-		     ! in_array( 'json-rest-api/plugin.php', get_option( 'active_plugins', array() ) )
50
+		if ( ! defined('JSON_API_VERSION') &&
51
+		     ! in_array('json-rest-api/plugin.php', get_option('active_plugins', array()))
52 52
 		) {
53 53
 			$class = new WP_REST_Menus();
54
-			add_filter( 'rest_api_init', array( $class, 'register_routes' ) );
54
+			add_filter('rest_api_init', array($class, 'register_routes'));
55 55
 		} else {
56 56
 			$class = new WP_JSON_Menus();
57
-			add_filter( 'json_endpoints', array( $class, 'register_routes' ) );
57
+			add_filter('json_endpoints', array($class, 'register_routes'));
58 58
 		}
59 59
 	}
60 60
 
61
-	add_action( 'init', 'wp_rest_menus_init' );
61
+	add_action('init', 'wp_rest_menus_init');
62 62
 endif;
63 63
 
64
-if ( ! function_exists( '_wp_rest_menus_doing_it_wrong' ) ) :
64
+if ( ! function_exists('_wp_rest_menus_doing_it_wrong')) :
65 65
 	/**
66 66
 	 * Mark a function as "deprecated" using doing_it_wrong().
67 67
 	 *
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 	 * @since 1.4.0
74 74
 	 * @uses _doing_it_wrong()
75 75
 	 */
76
-	function _wp_rest_menus_doing_it_wrong( $function, $route, $replacement ) {
76
+	function _wp_rest_menus_doing_it_wrong($function, $route, $replacement) {
77 77
 		if (
78 78
 			_wp_rest_menus_allow_legacy_menus() ||
79
-			is_wp_version_compatible( '5.9' ) && _wp_rest_menus_allow_legacy_menus()
79
+			is_wp_version_compatible('5.9') && _wp_rest_menus_allow_legacy_menus()
80 80
 		) {
81 81
 			return;
82 82
 		}
@@ -85,16 +85,16 @@  discard block
 block discarded – undo
85 85
 			$function,
86 86
 			sprintf(
87 87
 			/* translators: 1: The REST API route namespace, 2: The plugin version. */
88
-				__( 'The REST API Menu route %1$s is "deprecated". Please use WordPres cores menu route replacement found in WP >= 5.9: %2$s' ),
88
+				__('The REST API Menu route %1$s is "deprecated". Please use WordPres cores menu route replacement found in WP >= 5.9: %2$s'),
89 89
 				sprintf('<code>%1$s%2$s</code>', WP_REST_Menus::get_plugin_namespace(), $route),
90
-				'<code>' . $replacement . '</code>'
90
+				'<code>'.$replacement.'</code>'
91 91
 			),
92 92
 			'1.4.0'
93 93
 		);
94 94
 	}
95 95
 endif;
96 96
 
97
-if ( ! function_exists( '_wp_rest_menus_allow_legacy_menus' ) ) :
97
+if ( ! function_exists('_wp_rest_menus_allow_legacy_menus')) :
98 98
 	/**
99 99
 	 * Allow legacy menus "filter".
100 100
 	 *
@@ -110,6 +110,6 @@  discard block
 block discarded – undo
110 110
 		 *
111 111
 		 * @return bool
112 112
 		 */
113
-		return apply_filters( 'rest_menus_allow_legacy_menus', false ) === true;
113
+		return apply_filters('rest_menus_allow_legacy_menus', false) === true;
114 114
 	}
115 115
 endif;
Please login to merge, or discard this patch.
includes/wp-api-menus-v2.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -5,11 +5,11 @@  discard block
 block discarded – undo
5 5
  * @package WP_API_Menus
6 6
  */
7 7
 
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if ( ! defined('ABSPATH')) {
9 9
     exit; // Exit if accessed directly
10 10
 }
11 11
 
12
-if ( ! class_exists( 'WP_REST_Menus' ) ) :
12
+if ( ! class_exists('WP_REST_Menus')) :
13 13
 
14 14
 
15 15
     /**
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
          */
51 51
         public function register_routes() {
52 52
 
53
-	        $this->register_rest_route( '/menus', array(
53
+	        $this->register_rest_route('/menus', array(
54 54
 		        array(
55 55
 			        'methods'             => WP_REST_Server::READABLE,
56
-			        'callback'            => array( $this, 'get_menus' ),
56
+			        'callback'            => array($this, 'get_menus'),
57 57
 			        'permission_callback' => '__return_true',
58 58
 		        )
59
-	        ) );
59
+	        ));
60 60
 
61
-	        $this->register_rest_route( '/menus/(?P<id>\d+)', array(
61
+	        $this->register_rest_route('/menus/(?P<id>\d+)', array(
62 62
 		        array(
63 63
 			        'methods'             => WP_REST_Server::READABLE,
64
-			        'callback'            => array( $this, 'get_menu' ),
64
+			        'callback'            => array($this, 'get_menu'),
65 65
 			        'permission_callback' => '__return_true',
66 66
 			        'args'                => array(
67 67
 				        'context' => array(
@@ -69,23 +69,23 @@  discard block
 block discarded – undo
69 69
 				        ),
70 70
 			        ),
71 71
 		        )
72
-	        ) );
72
+	        ));
73 73
 
74
-	        $this->register_rest_route( '/menu-locations', array(
74
+	        $this->register_rest_route('/menu-locations', array(
75 75
 		        array(
76 76
 			        'methods'             => WP_REST_Server::READABLE,
77
-			        'callback'            => array( $this, 'get_menu_locations' ),
77
+			        'callback'            => array($this, 'get_menu_locations'),
78 78
 			        'permission_callback' => '__return_true',
79 79
 		        )
80
-	        ) );
80
+	        ));
81 81
 
82
-	        $this->register_rest_route( '/menu-locations/(?P<location>[a-zA-Z0-9_-]+)', array(
82
+	        $this->register_rest_route('/menu-locations/(?P<location>[a-zA-Z0-9_-]+)', array(
83 83
 		        array(
84 84
 			        'methods'             => WP_REST_Server::READABLE,
85
-			        'callback'            => array( $this, 'get_menu_location' ),
85
+			        'callback'            => array($this, 'get_menu_location'),
86 86
 			        'permission_callback' => '__return_true',
87 87
 		        )
88
-	        ) );
88
+	        ));
89 89
         }
90 90
 
91 91
         /**
@@ -95,29 +95,29 @@  discard block
 block discarded – undo
95 95
          * @return array All registered menus
96 96
          */
97 97
         public function get_menus() {
98
-            $rest_url = trailingslashit( get_rest_url() . self::get_plugin_namespace() . '/menus/' );
98
+            $rest_url = trailingslashit(get_rest_url().self::get_plugin_namespace().'/menus/');
99 99
             $wp_menus = wp_get_nav_menus();
100 100
 
101 101
             $i = 0;
102 102
             $rest_menus = array();
103
-            foreach ( $wp_menus as $wp_menu ) :
103
+            foreach ($wp_menus as $wp_menu) :
104 104
 
105 105
                 $menu = (array) $wp_menu;
106 106
 
107
-                $rest_menus[ $i ]                = $menu;
108
-                $rest_menus[ $i ]['ID']          = $menu['term_id'];
109
-                $rest_menus[ $i ]['name']        = $menu['name'];
110
-                $rest_menus[ $i ]['slug']        = $menu['slug'];
111
-                $rest_menus[ $i ]['description'] = $menu['description'];
112
-                $rest_menus[ $i ]['count']       = $menu['count'];
107
+                $rest_menus[$i]                = $menu;
108
+                $rest_menus[$i]['ID']          = $menu['term_id'];
109
+                $rest_menus[$i]['name']        = $menu['name'];
110
+                $rest_menus[$i]['slug']        = $menu['slug'];
111
+                $rest_menus[$i]['description'] = $menu['description'];
112
+                $rest_menus[$i]['count']       = $menu['count'];
113 113
 
114
-                $rest_menus[ $i ]['meta']['links']['collection'] = $rest_url;
115
-                $rest_menus[ $i ]['meta']['links']['self']       = $rest_url . $menu['term_id'];
114
+                $rest_menus[$i]['meta']['links']['collection'] = $rest_url;
115
+                $rest_menus[$i]['meta']['links']['self']       = $rest_url.$menu['term_id'];
116 116
 
117
-                $i ++;
117
+                $i++;
118 118
             endforeach;
119 119
 
120
-            return apply_filters( 'rest_menus_format_menus', $rest_menus );
120
+            return apply_filters('rest_menus_format_menus', $rest_menus);
121 121
         }
122 122
 
123 123
 
@@ -128,37 +128,37 @@  discard block
 block discarded – undo
128 128
          * @param  $request
129 129
          * @return array Menu data
130 130
          */
131
-        public function get_menu( $request ) {
131
+        public function get_menu($request) {
132 132
             $id             = (int) $request['id'];
133
-            $rest_url       = get_rest_url() . self::get_plugin_namespace() . '/menus/';
134
-            $wp_menu_object = $id ? wp_get_nav_menu_object( $id ) : array();
135
-            $wp_menu_items  = $id ? wp_get_nav_menu_items( $id ) : array();
133
+            $rest_url       = get_rest_url().self::get_plugin_namespace().'/menus/';
134
+            $wp_menu_object = $id ? wp_get_nav_menu_object($id) : array();
135
+            $wp_menu_items  = $id ? wp_get_nav_menu_items($id) : array();
136 136
 
137 137
             $rest_menu = array();
138 138
 
139
-            if ( $wp_menu_object ) :
139
+            if ($wp_menu_object) :
140 140
 
141 141
                 $menu = (array) $wp_menu_object;
142
-                $rest_menu['ID']          = abs( $menu['term_id'] );
142
+                $rest_menu['ID']          = abs($menu['term_id']);
143 143
                 $rest_menu['name']        = $menu['name'];
144 144
                 $rest_menu['slug']        = $menu['slug'];
145 145
                 $rest_menu['description'] = $menu['description'];
146
-                $rest_menu['count']       = abs( $menu['count'] );
146
+                $rest_menu['count']       = abs($menu['count']);
147 147
 
148 148
                 $rest_menu_items = array();
149
-                foreach ( $wp_menu_items as $item_object ) {
150
-	                $rest_menu_items[] = $this->format_menu_item( $item_object );
149
+                foreach ($wp_menu_items as $item_object) {
150
+	                $rest_menu_items[] = $this->format_menu_item($item_object);
151 151
                 }
152 152
 
153 153
                 $rest_menu_items = $this->nested_menu_items($rest_menu_items, 0);
154 154
 
155 155
                 $rest_menu['items']                       = $rest_menu_items;
156 156
                 $rest_menu['meta']['links']['collection'] = $rest_url;
157
-                $rest_menu['meta']['links']['self']       = $rest_url . $id;
157
+                $rest_menu['meta']['links']['self']       = $rest_url.$id;
158 158
 
159 159
             endif;
160 160
 
161
-            return apply_filters( 'rest_menus_format_menu', $rest_menu );
161
+            return apply_filters('rest_menus_format_menu', $rest_menu);
162 162
         }
163 163
 
164 164
 
@@ -173,24 +173,24 @@  discard block
 block discarded – undo
173 173
          * @param  $parent
174 174
          * @return array
175 175
          */
176
-        private function nested_menu_items( &$menu_items, $parent = null ) {
176
+        private function nested_menu_items(&$menu_items, $parent = null) {
177 177
 
178 178
             $parents = array();
179 179
             $children = array();
180 180
 
181 181
             // Separate menu_items into parents & children.
182
-            array_map( function( $i ) use ( $parent, &$children, &$parents ){
183
-                if ( $i['id'] != $parent && $i['parent'] == $parent ) {
182
+            array_map(function($i) use ($parent, &$children, &$parents){
183
+                if ($i['id'] != $parent && $i['parent'] == $parent) {
184 184
                     $parents[] = $i;
185 185
                 } else {
186 186
                     $children[] = $i;
187 187
                 }
188
-            }, $menu_items );
188
+            }, $menu_items);
189 189
 
190
-            foreach ( $parents as &$parent ) {
190
+            foreach ($parents as &$parent) {
191 191
 
192
-                if ( $this->has_children( $children, $parent['id'] ) ) {
193
-                    $parent['children'] = $this->nested_menu_items( $children, $parent['id'] );
192
+                if ($this->has_children($children, $parent['id'])) {
193
+                    $parent['children'] = $this->nested_menu_items($children, $parent['id']);
194 194
                 }
195 195
             }
196 196
 
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
          * @param  int $id
207 207
          * @return array
208 208
          */
209
-        private function has_children( $items, $id ) {
210
-            return array_filter( $items, function( $i ) use ( $id ) {
209
+        private function has_children($items, $id) {
210
+            return array_filter($items, function($i) use ($id) {
211 211
                 return $i['parent'] == $id;
212 212
             } );
213 213
         }
@@ -220,25 +220,25 @@  discard block
 block discarded – undo
220 220
          * @param  $request
221 221
          * @return array All registered menus locations
222 222
          */
223
-        public function get_menu_locations( $request ) {
223
+        public function get_menu_locations($request) {
224 224
             $locations        = get_nav_menu_locations();
225 225
             $registered_menus = get_registered_nav_menus();
226
-	        $rest_url         = get_rest_url() . self::get_plugin_namespace() . '/menu-locations/';
226
+	        $rest_url = get_rest_url().self::get_plugin_namespace().'/menu-locations/';
227 227
             $rest_menus       = array();
228 228
 
229
-            if ( $locations && $registered_menus ) :
229
+            if ($locations && $registered_menus) :
230 230
 
231
-                foreach ( $registered_menus as $slug => $label ) :
231
+                foreach ($registered_menus as $slug => $label) :
232 232
 
233 233
 	                // Sanity check
234
-	                if ( ! isset( $locations[ $slug ] ) ) {
234
+	                if ( ! isset($locations[$slug])) {
235 235
 		                continue;
236 236
 	                }
237 237
 
238
-	                $rest_menus[ $slug ]['ID']                          = $locations[ $slug ];
239
-                    $rest_menus[ $slug ]['label']                       = $label;
240
-                    $rest_menus[ $slug ]['meta']['links']['collection'] = $rest_url;
241
-                    $rest_menus[ $slug ]['meta']['links']['self']       = $rest_url . $slug;
238
+	                $rest_menus[$slug]['ID'] = $locations[$slug];
239
+                    $rest_menus[$slug]['label']                       = $label;
240
+                    $rest_menus[$slug]['meta']['links']['collection'] = $rest_url;
241
+                    $rest_menus[$slug]['meta']['links']['self']       = $rest_url.$slug;
242 242
 
243 243
                 endforeach;
244 244
 
@@ -255,69 +255,69 @@  discard block
 block discarded – undo
255 255
          * @param  $request
256 256
          * @return array The menu for the corresponding location
257 257
          */
258
-        public function get_menu_location( $request ) {
258
+        public function get_menu_location($request) {
259 259
             $params     = $request->get_params();
260 260
             $location   = $params['location'];
261 261
             $locations  = get_nav_menu_locations();
262 262
 
263
-            if ( empty( $locations[ $location ] ) ) {
263
+            if (empty($locations[$location])) {
264 264
 	            return array();
265 265
             }
266 266
 
267
-            $wp_menu = wp_get_nav_menu_object( $locations[ $location ] );
268
-            $menu_items = wp_get_nav_menu_items( $wp_menu->term_id );
267
+            $wp_menu = wp_get_nav_menu_object($locations[$location]);
268
+            $menu_items = wp_get_nav_menu_items($wp_menu->term_id);
269 269
 
270 270
 			/**
271 271
 			 * wp_get_nav_menu_items() outputs a list that's already sequenced correctly.
272 272
 			 * So the easiest thing to do is to reverse the list and then build our tree
273 273
 			 * from the ground up
274 274
 			 */
275
-			$rev_items = array_reverse ( $menu_items );
275
+			$rev_items = array_reverse($menu_items);
276 276
 			$rev_menu  = array();
277 277
 			$cache     = array();
278 278
 
279
-			foreach ( $rev_items as $item ) :
279
+			foreach ($rev_items as $item) :
280 280
 
281 281
 				$formatted = array(
282
-					'ID'          => abs( $item->ID ),
282
+					'ID'          => abs($item->ID),
283 283
 					'order'       => (int) $item->menu_order,
284
-					'parent'      => abs( $item->menu_item_parent ),
284
+					'parent'      => abs($item->menu_item_parent),
285 285
 					'title'       => $item->title,
286 286
 					'url'         => $item->url,
287 287
 					'attr'        => $item->attr_title,
288 288
 					'target'      => $item->target,
289
-					'classes'     => implode( ' ', $item->classes ),
289
+					'classes'     => implode(' ', $item->classes),
290 290
 					'xfn'         => $item->xfn,
291 291
 					'description' => $item->description,
292
-					'object_id'   => abs( $item->object_id ),
292
+					'object_id'   => abs($item->object_id),
293 293
 					'object'      => $item->object,
294 294
 					'type'        => $item->type,
295 295
 					'type_label'  => $item->type_label,
296 296
 					'children'    => array(),
297 297
 				);
298 298
 
299
-				if ( array_key_exists( $item->ID , $cache ) ) {
300
-					$formatted['children'] = array_reverse( $cache[ $item->ID ] );
299
+				if (array_key_exists($item->ID, $cache)) {
300
+					$formatted['children'] = array_reverse($cache[$item->ID]);
301 301
 				}
302 302
 
303
-            	$formatted = apply_filters( 'rest_menus_format_menu_item', $formatted );
303
+            	$formatted = apply_filters('rest_menus_format_menu_item', $formatted);
304 304
 
305
-				if ( $item->menu_item_parent != 0 ) {
305
+				if ($item->menu_item_parent != 0) {
306 306
 
307
-					if ( array_key_exists( $item->menu_item_parent , $cache ) ) {
308
-						array_push( $cache[ $item->menu_item_parent ], $formatted );
307
+					if (array_key_exists($item->menu_item_parent, $cache)) {
308
+						array_push($cache[$item->menu_item_parent], $formatted);
309 309
 					} else {
310
-						$cache[ $item->menu_item_parent ] = array( $formatted, );
310
+						$cache[$item->menu_item_parent] = array($formatted,);
311 311
 					}
312 312
 
313 313
 				} else {
314 314
 
315
-					array_push( $rev_menu, $formatted );
315
+					array_push($rev_menu, $formatted);
316 316
 				}
317 317
 
318 318
 			endforeach;
319 319
 
320
-			return array_reverse ( $rev_menu );
320
+			return array_reverse($rev_menu);
321 321
         }
322 322
 
323 323
 
@@ -330,19 +330,19 @@  discard block
 block discarded – undo
330 330
          * @param bool  $depth          Gives all children or direct children only
331 331
          * @return array	returns filtered array of nav_menu_items
332 332
          */
333
-        public function get_nav_menu_item_children( $parent_id, $nav_menu_items, $depth = true ) {
333
+        public function get_nav_menu_item_children($parent_id, $nav_menu_items, $depth = true) {
334 334
 
335 335
             $nav_menu_item_list = array();
336 336
 
337
-            foreach ( (array) $nav_menu_items as $nav_menu_item ) :
337
+            foreach ((array) $nav_menu_items as $nav_menu_item) :
338 338
 
339
-                if ( $nav_menu_item->menu_item_parent == $parent_id ) :
339
+                if ($nav_menu_item->menu_item_parent == $parent_id) :
340 340
 
341
-                    $nav_menu_item_list[] = $this->format_menu_item( $nav_menu_item, true, $nav_menu_items );
341
+                    $nav_menu_item_list[] = $this->format_menu_item($nav_menu_item, true, $nav_menu_items);
342 342
 
343
-                    if ( $depth ) {
344
-                        if ( $children = $this->get_nav_menu_item_children( $nav_menu_item->ID, $nav_menu_items ) ) {
345
-                            $nav_menu_item_list = array_merge( $nav_menu_item_list, $children );
343
+                    if ($depth) {
344
+                        if ($children = $this->get_nav_menu_item_children($nav_menu_item->ID, $nav_menu_items)) {
345
+                            $nav_menu_item_list = array_merge($nav_menu_item_list, $children);
346 346
                         }
347 347
                     }
348 348
 
@@ -363,35 +363,35 @@  discard block
 block discarded – undo
363 363
          * @param  array        $menu       The menu the item belongs to (used when $children is set to true)
364 364
          * @return array	a formatted menu item for REST
365 365
          */
366
-        public function format_menu_item( $menu_item, $children = false, $menu = array() ) {
366
+        public function format_menu_item($menu_item, $children = false, $menu = array()) {
367 367
 
368 368
             $item = (array) $menu_item;
369
-            $object_post = get_post( $item['object_id'] );
369
+            $object_post = get_post($item['object_id']);
370 370
 
371 371
 
372 372
             $menu_item = array(
373
-                'id'          => abs( $item['ID'] ),
373
+                'id'          => abs($item['ID']),
374 374
                 'order'       => (int) $item['menu_order'],
375
-                'parent'      => abs( $item['menu_item_parent'] ),
375
+                'parent'      => abs($item['menu_item_parent']),
376 376
                 'title'       => $item['title'],
377 377
                 'url'         => $item['url'],
378 378
                 'attr'        => $item['attr_title'],
379 379
                 'target'      => $item['target'],
380
-                'classes'     => implode( ' ', $item['classes'] ),
380
+                'classes'     => implode(' ', $item['classes']),
381 381
                 'xfn'         => $item['xfn'],
382 382
                 'description' => $item['description'],
383
-                'object_id'   => abs( $item['object_id'] ),
383
+                'object_id'   => abs($item['object_id']),
384 384
                 'object'      => $item['object'],
385
-                'object_slug' => !empty($object_post) ? $object_post->post_name : null,
385
+                'object_slug' => ! empty($object_post) ? $object_post->post_name : null,
386 386
                 'type'        => $item['type'],
387 387
                 'type_label'  => $item['type_label'],
388 388
             );
389 389
 
390
-            if ( $children === true && ! empty( $menu ) ) {
391
-	            $menu_item['children'] = $this->get_nav_menu_item_children( $item['ID'], $menu );
390
+            if ($children === true && ! empty($menu)) {
391
+	            $menu_item['children'] = $this->get_nav_menu_item_children($item['ID'], $menu);
392 392
             }
393 393
 
394
-            return apply_filters( 'rest_menus_format_menu_item', $menu_item );
394
+            return apply_filters('rest_menus_format_menu_item', $menu_item);
395 395
         }
396 396
 
397 397
 	    /**
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
 	     * @param array  $args      Optional. Either an array of options for the endpoint, or an array of arrays for
402 402
 	     *                          multiple methods. Default empty array.
403 403
 	     */
404
-	    private function register_rest_route( $route, $args = array() ) {
405
-		    _wp_rest_menus_doing_it_wrong( __METHOD__, $route, $this->replacements[ $route ] );
406
-		    register_rest_route( self::get_plugin_namespace(), $route, $args );
404
+	    private function register_rest_route($route, $args = array()) {
405
+		    _wp_rest_menus_doing_it_wrong(__METHOD__, $route, $this->replacements[$route]);
406
+		    register_rest_route(self::get_plugin_namespace(), $route, $args);
407 407
 	    }
408 408
     }
409 409
 
Please login to merge, or discard this patch.