@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | protected function get_data_for_response( $object, $request ) { |
| 68 | 68 | $formatter = new OrderResponse(); |
| 69 | 69 | |
| 70 | - if ( ! is_null( $request['dp'] ) ) { |
|
| 71 | - $formatter->set_dp( $request['dp'] ); |
|
| 70 | + if ( ! is_null( $request[ 'dp' ] ) ) { |
|
| 71 | + $formatter->set_dp( $request[ 'dp' ] ); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | return $formatter->prepare_response( $object, $this->get_request_context( $request ) ); |
@@ -92,13 +92,13 @@ discard block |
||
| 92 | 92 | ); |
| 93 | 93 | |
| 94 | 94 | if ( 0 !== (int) $item->get_customer_id() ) { |
| 95 | - $links['customer'] = array( |
|
| 95 | + $links[ 'customer' ] = array( |
|
| 96 | 96 | 'href' => rest_url( sprintf( '/%s/customers/%d', $this->namespace, $item->get_customer_id() ) ), |
| 97 | 97 | ); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | if ( 0 !== (int) $item->get_parent_id() ) { |
| 101 | - $links['up'] = array( |
|
| 101 | + $links[ 'up' ] = array( |
|
| 102 | 102 | 'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $item->get_parent_id() ) ), |
| 103 | 103 | ); |
| 104 | 104 | } |
@@ -117,71 +117,71 @@ discard block |
||
| 117 | 117 | global $wpdb; |
| 118 | 118 | |
| 119 | 119 | // This is needed to get around an array to string notice in \WC_REST_Orders_V2_Controller::prepare_objects_query. |
| 120 | - $statuses = $request['status']; |
|
| 121 | - unset( $request['status'] ); |
|
| 120 | + $statuses = $request[ 'status' ]; |
|
| 121 | + unset( $request[ 'status' ] ); |
|
| 122 | 122 | $args = parent::prepare_objects_query( $request ); |
| 123 | 123 | |
| 124 | - $args['post_status'] = array(); |
|
| 124 | + $args[ 'post_status' ] = array(); |
|
| 125 | 125 | foreach ( $statuses as $status ) { |
| 126 | 126 | if ( in_array( $status, $this->get_order_statuses(), true ) ) { |
| 127 | - $args['post_status'][] = 'wc-' . $status; |
|
| 127 | + $args[ 'post_status' ][ ] = 'wc-' . $status; |
|
| 128 | 128 | } elseif ( 'any' === $status ) { |
| 129 | 129 | // Set status to "any" and short-circuit out. |
| 130 | - $args['post_status'] = 'any'; |
|
| 130 | + $args[ 'post_status' ] = 'any'; |
|
| 131 | 131 | break; |
| 132 | 132 | } else { |
| 133 | - $args['post_status'][] = $status; |
|
| 133 | + $args[ 'post_status' ][ ] = $status; |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // Put the statuses back for further processing (next/prev links, etc). |
| 138 | - $request['status'] = $statuses; |
|
| 138 | + $request[ 'status' ] = $statuses; |
|
| 139 | 139 | |
| 140 | 140 | // Customer. |
| 141 | - if ( isset( $request['customer'] ) ) { |
|
| 142 | - if ( ! empty( $args['meta_query'] ) ) { |
|
| 143 | - $args['meta_query'] = array(); // WPCS: slow query ok. |
|
| 141 | + if ( isset( $request[ 'customer' ] ) ) { |
|
| 142 | + if ( ! empty( $args[ 'meta_query' ] ) ) { |
|
| 143 | + $args[ 'meta_query' ] = array(); // WPCS: slow query ok. |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $args['meta_query'][] = array( |
|
| 146 | + $args[ 'meta_query' ][ ] = array( |
|
| 147 | 147 | 'key' => '_customer_user', |
| 148 | - 'value' => $request['customer'], |
|
| 148 | + 'value' => $request[ 'customer' ], |
|
| 149 | 149 | 'type' => 'NUMERIC', |
| 150 | 150 | ); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Search by product. |
| 154 | - if ( ! empty( $request['product'] ) ) { |
|
| 154 | + if ( ! empty( $request[ 'product' ] ) ) { |
|
| 155 | 155 | $order_ids = $wpdb->get_col( |
| 156 | 156 | $wpdb->prepare( |
| 157 | 157 | "SELECT order_id |
| 158 | 158 | FROM {$wpdb->prefix}woocommerce_order_items |
| 159 | 159 | WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = '_product_id' AND meta_value = %d ) |
| 160 | 160 | AND order_item_type = 'line_item'", |
| 161 | - $request['product'] |
|
| 161 | + $request[ 'product' ] |
|
| 162 | 162 | ) |
| 163 | 163 | ); |
| 164 | 164 | |
| 165 | 165 | // Force WP_Query return empty if don't found any order. |
| 166 | 166 | $order_ids = ! empty( $order_ids ) ? $order_ids : array( 0 ); |
| 167 | 167 | |
| 168 | - $args['post__in'] = $order_ids; |
|
| 168 | + $args[ 'post__in' ] = $order_ids; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // Search. |
| 172 | - if ( ! empty( $args['s'] ) ) { |
|
| 173 | - $order_ids = wc_order_search( $args['s'] ); |
|
| 172 | + if ( ! empty( $args[ 's' ] ) ) { |
|
| 173 | + $order_ids = wc_order_search( $args[ 's' ] ); |
|
| 174 | 174 | |
| 175 | 175 | if ( ! empty( $order_ids ) ) { |
| 176 | - unset( $args['s'] ); |
|
| 177 | - $args['post__in'] = array_merge( $order_ids, array( 0 ) ); |
|
| 176 | + unset( $args[ 's' ] ); |
|
| 177 | + $args[ 'post__in' ] = array_merge( $order_ids, array( 0 ) ); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Search by partial order number. |
| 182 | - if ( ! empty( $request['number'] ) ) { |
|
| 183 | - $partial_number = trim( $request['number'] ); |
|
| 184 | - $limit = intval( $args['posts_per_page'] ); |
|
| 182 | + if ( ! empty( $request[ 'number' ] ) ) { |
|
| 183 | + $partial_number = trim( $request[ 'number' ] ); |
|
| 184 | + $limit = intval( $args[ 'posts_per_page' ] ); |
|
| 185 | 185 | $order_ids = $wpdb->get_col( |
| 186 | 186 | $wpdb->prepare( |
| 187 | 187 | "SELECT ID |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | // Force \WP_Query return empty if don't found any order. |
| 198 | 198 | $order_ids = empty( $order_ids ) ? array( 0 ) : $order_ids; |
| 199 | - $args['post__in'] = $order_ids; |
|
| 199 | + $args[ 'post__in' ] = $order_ids; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | return $args; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | $object->calculate_totals(); |
| 257 | 257 | } else { |
| 258 | 258 | // If items have changed, recalculate order totals. |
| 259 | - if ( isset( $request['billing'] ) || isset( $request['shipping'] ) || isset( $request['line_items'] ) || isset( $request['shipping_lines'] ) || isset( $request['fee_lines'] ) || isset( $request['coupon_lines'] ) ) { |
|
| 259 | + if ( isset( $request[ 'billing' ] ) || isset( $request[ 'shipping' ] ) || isset( $request[ 'line_items' ] ) || isset( $request[ 'shipping_lines' ] ) || isset( $request[ 'fee_lines' ] ) || isset( $request[ 'coupon_lines' ] ) ) { |
|
| 260 | 260 | $object->calculate_totals( true ); |
| 261 | 261 | } |
| 262 | 262 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | $object->save(); |
| 265 | 265 | |
| 266 | 266 | // Actions for after the order is saved. |
| 267 | - if ( true === $request['set_paid'] && ( $creating || $object->needs_payment() ) ) { |
|
| 267 | + if ( true === $request[ 'set_paid' ] && ( $creating || $object->needs_payment() ) ) { |
|
| 268 | 268 | $object->payment_complete(); |
| 269 | 269 | } |
| 270 | 270 | |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | $order_statuses = array(); |
| 286 | 286 | |
| 287 | 287 | foreach ( array_keys( wc_get_order_statuses() ) as $status ) { |
| 288 | - $order_statuses[] = str_replace( 'wc-', '', $status ); |
|
| 288 | + $order_statuses[ ] = str_replace( 'wc-', '', $status ); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | return $order_statuses; |
@@ -1144,7 +1144,7 @@ discard block |
||
| 1144 | 1144 | public function get_collection_params() { |
| 1145 | 1145 | $params = parent::get_collection_params(); |
| 1146 | 1146 | |
| 1147 | - $params['status'] = array( |
|
| 1147 | + $params[ 'status' ] = array( |
|
| 1148 | 1148 | 'default' => 'any', |
| 1149 | 1149 | 'description' => __( 'Limit result set to orders which have specific statuses.', 'woocommerce' ), |
| 1150 | 1150 | 'type' => 'array', |
@@ -1154,19 +1154,19 @@ discard block |
||
| 1154 | 1154 | ), |
| 1155 | 1155 | 'validate_callback' => 'rest_validate_request_arg', |
| 1156 | 1156 | ); |
| 1157 | - $params['customer'] = array( |
|
| 1157 | + $params[ 'customer' ] = array( |
|
| 1158 | 1158 | 'description' => __( 'Limit result set to orders assigned a specific customer.', 'woocommerce' ), |
| 1159 | 1159 | 'type' => 'integer', |
| 1160 | 1160 | 'sanitize_callback' => 'absint', |
| 1161 | 1161 | 'validate_callback' => 'rest_validate_request_arg', |
| 1162 | 1162 | ); |
| 1163 | - $params['product'] = array( |
|
| 1163 | + $params[ 'product' ] = array( |
|
| 1164 | 1164 | 'description' => __( 'Limit result set to orders assigned a specific product.', 'woocommerce' ), |
| 1165 | 1165 | 'type' => 'integer', |
| 1166 | 1166 | 'sanitize_callback' => 'absint', |
| 1167 | 1167 | 'validate_callback' => 'rest_validate_request_arg', |
| 1168 | 1168 | ); |
| 1169 | - $params['dp'] = array( |
|
| 1169 | + $params[ 'dp' ] = array( |
|
| 1170 | 1170 | 'default' => wc_get_price_decimals(), |
| 1171 | 1171 | 'description' => __( 'Number of decimal points to use in each resource.', 'woocommerce' ), |
| 1172 | 1172 | 'type' => 'integer', |
@@ -1174,7 +1174,7 @@ discard block |
||
| 1174 | 1174 | 'validate_callback' => 'rest_validate_request_arg', |
| 1175 | 1175 | ); |
| 1176 | 1176 | // This needs to remain a string to support extensions that filter Order Number. |
| 1177 | - $params['number'] = array( |
|
| 1177 | + $params[ 'number' ] = array( |
|
| 1178 | 1178 | 'description' => __( 'Limit result set to orders matching part of an order number.', 'woocommerce' ), |
| 1179 | 1179 | 'type' => 'string', |
| 1180 | 1180 | 'validate_callback' => 'rest_validate_request_arg', |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | foreach ( $wc_shipping->get_shipping_methods() as $id => $shipping_method ) { |
| 85 | 85 | $method = $this->prepare_item_for_response( $shipping_method, $request ); |
| 86 | 86 | $method = $this->prepare_response_for_collection( $method ); |
| 87 | - $response[] = $method; |
|
| 87 | + $response[ ] = $method; |
|
| 88 | 88 | } |
| 89 | 89 | return rest_ensure_response( $response ); |
| 90 | 90 | } |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | public function get_item( $request ) { |
| 99 | 99 | $wc_shipping = \WC_Shipping::instance(); |
| 100 | 100 | $methods = $wc_shipping->get_shipping_methods(); |
| 101 | - if ( empty( $methods[ $request['id'] ] ) ) { |
|
| 101 | + if ( empty( $methods[ $request[ 'id' ] ] ) ) { |
|
| 102 | 102 | return new \WP_Error( 'woocommerce_rest_shipping_method_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - $method = $methods[ $request['id'] ]; |
|
| 105 | + $method = $methods[ $request[ 'id' ] ]; |
|
| 106 | 106 | $response = $this->prepare_item_for_response( $method, $request ); |
| 107 | 107 | |
| 108 | 108 | return rest_ensure_response( $response ); |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | * @param array $methods Supported methods. read, create. |
| 56 | 56 | */ |
| 57 | 57 | protected function register_items_route( $methods = [ 'read', 'create' ] ) { |
| 58 | - $routes = []; |
|
| 59 | - $routes['schema'] = [ $this, 'get_public_item_schema' ]; |
|
| 58 | + $routes = [ ]; |
|
| 59 | + $routes[ 'schema' ] = [ $this, 'get_public_item_schema' ]; |
|
| 60 | 60 | |
| 61 | 61 | if ( in_array( 'read', $methods, true ) ) { |
| 62 | - $routes[] = array( |
|
| 62 | + $routes[ ] = array( |
|
| 63 | 63 | 'methods' => \WP_REST_Server::READABLE, |
| 64 | 64 | 'callback' => array( $this, 'get_items' ), |
| 65 | 65 | 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | if ( in_array( 'create', $methods, true ) ) { |
| 71 | - $routes[] = array( |
|
| 71 | + $routes[ ] = array( |
|
| 72 | 72 | 'methods' => \WP_REST_Server::CREATABLE, |
| 73 | 73 | 'callback' => array( $this, 'create_item' ), |
| 74 | 74 | 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | * @param array $methods Supported methods. read, create. |
| 91 | 91 | */ |
| 92 | 92 | protected function register_item_route( $methods = [ 'read', 'edit', 'delete' ] ) { |
| 93 | - $routes = []; |
|
| 94 | - $routes['schema'] = [ $this, 'get_public_item_schema' ]; |
|
| 95 | - $routes['args'] = [ |
|
| 93 | + $routes = [ ]; |
|
| 94 | + $routes[ 'schema' ] = [ $this, 'get_public_item_schema' ]; |
|
| 95 | + $routes[ 'args' ] = [ |
|
| 96 | 96 | 'id' => [ |
| 97 | 97 | 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), |
| 98 | 98 | 'type' => 'integer', |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | ]; |
| 101 | 101 | |
| 102 | 102 | if ( in_array( 'read', $methods, true ) ) { |
| 103 | - $routes[] = array( |
|
| 103 | + $routes[ ] = array( |
|
| 104 | 104 | 'methods' => \WP_REST_Server::READABLE, |
| 105 | 105 | 'callback' => array( $this, 'get_item' ), |
| 106 | 106 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | if ( in_array( 'edit', $methods, true ) ) { |
| 118 | - $routes[] = array( |
|
| 118 | + $routes[ ] = array( |
|
| 119 | 119 | 'methods' => \WP_REST_Server::EDITABLE, |
| 120 | 120 | 'callback' => array( $this, 'update_item' ), |
| 121 | 121 | 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | if ( in_array( 'delete', $methods, true ) ) { |
| 127 | - $routes[] = array( |
|
| 127 | + $routes[ ] = array( |
|
| 128 | 128 | 'methods' => \WP_REST_Server::DELETABLE, |
| 129 | 129 | 'callback' => array( $this, 'delete_item' ), |
| 130 | 130 | 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | protected function add_additional_fields_schema( $schema ) { |
| 156 | 156 | $schema = parent::add_additional_fields_schema( $schema ); |
| 157 | - $object_type = $schema['title']; |
|
| 158 | - $schema['properties'] = apply_filters( 'woocommerce_rest_' . $object_type . '_schema', $schema['properties'] ); |
|
| 157 | + $object_type = $schema[ 'title' ]; |
|
| 158 | + $schema[ 'properties' ] = apply_filters( 'woocommerce_rest_' . $object_type . '_schema', $schema[ 'properties' ] ); |
|
| 159 | 159 | return $schema; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * @return string |
| 272 | 272 | */ |
| 273 | 273 | protected function get_request_context( $request ) { |
| 274 | - return ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
| 274 | + return ! empty( $request[ 'context' ] ) ? $request[ 'context' ] : 'view'; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | protected function get_item_title() { |
| 314 | 314 | $schema = $this->get_item_schema(); |
| 315 | - return $schema['title']; |
|
| 315 | + return $schema[ 'title' ]; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | foreach ( $attributes as $attribute_obj ) { |
| 128 | 128 | $attribute = $this->prepare_item_for_response( $attribute_obj, $request ); |
| 129 | 129 | $attribute = $this->prepare_response_for_collection( $attribute ); |
| 130 | - $data[] = $attribute; |
|
| 130 | + $data[ ] = $attribute; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | return rest_ensure_response( $data ); |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $id = wc_create_attribute( |
| 146 | 146 | array( |
| 147 | - 'name' => $request['name'], |
|
| 148 | - 'slug' => wc_sanitize_taxonomy_name( stripslashes( $request['slug'] ) ), |
|
| 149 | - 'type' => ! empty( $request['type'] ) ? $request['type'] : 'select', |
|
| 150 | - 'order_by' => ! empty( $request['order_by'] ) ? $request['order_by'] : 'menu_order', |
|
| 151 | - 'has_archives' => true === $request['has_archives'], |
|
| 147 | + 'name' => $request[ 'name' ], |
|
| 148 | + 'slug' => wc_sanitize_taxonomy_name( stripslashes( $request[ 'slug' ] ) ), |
|
| 149 | + 'type' => ! empty( $request[ 'type' ] ) ? $request[ 'type' ] : 'select', |
|
| 150 | + 'order_by' => ! empty( $request[ 'order_by' ] ) ? $request[ 'order_by' ] : 'menu_order', |
|
| 151 | + 'has_archives' => true === $request[ 'has_archives' ], |
|
| 152 | 152 | ) |
| 153 | 153 | ); |
| 154 | 154 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @return \WP_REST_Request|\WP_Error |
| 191 | 191 | */ |
| 192 | 192 | public function get_item( $request ) { |
| 193 | - $attribute = $this->get_attribute( (int) $request['id'] ); |
|
| 193 | + $attribute = $this->get_attribute( (int) $request[ 'id' ] ); |
|
| 194 | 194 | |
| 195 | 195 | if ( is_wp_error( $attribute ) ) { |
| 196 | 196 | return $attribute; |
@@ -210,15 +210,15 @@ discard block |
||
| 210 | 210 | public function update_item( $request ) { |
| 211 | 211 | global $wpdb; |
| 212 | 212 | |
| 213 | - $id = (int) $request['id']; |
|
| 213 | + $id = (int) $request[ 'id' ]; |
|
| 214 | 214 | $edited = wc_update_attribute( |
| 215 | 215 | $id, |
| 216 | 216 | array( |
| 217 | - 'name' => $request['name'], |
|
| 218 | - 'slug' => wc_sanitize_taxonomy_name( stripslashes( $request['slug'] ) ), |
|
| 219 | - 'type' => $request['type'], |
|
| 220 | - 'order_by' => $request['order_by'], |
|
| 221 | - 'has_archives' => $request['has_archives'], |
|
| 217 | + 'name' => $request[ 'name' ], |
|
| 218 | + 'slug' => wc_sanitize_taxonomy_name( stripslashes( $request[ 'slug' ] ) ), |
|
| 219 | + 'type' => $request[ 'type' ], |
|
| 220 | + 'order_by' => $request[ 'order_by' ], |
|
| 221 | + 'has_archives' => $request[ 'has_archives' ], |
|
| 222 | 222 | ) |
| 223 | 223 | ); |
| 224 | 224 | |
@@ -257,14 +257,14 @@ discard block |
||
| 257 | 257 | * @return \WP_REST_Response|\WP_Error |
| 258 | 258 | */ |
| 259 | 259 | public function delete_item( $request ) { |
| 260 | - $force = isset( $request['force'] ) ? (bool) $request['force'] : false; |
|
| 260 | + $force = isset( $request[ 'force' ] ) ? (bool) $request[ 'force' ] : false; |
|
| 261 | 261 | |
| 262 | 262 | // We don't support trashing for this type, error out. |
| 263 | 263 | if ( ! $force ) { |
| 264 | 264 | return new \WP_Error( 'woocommerce_rest_trash_not_supported', __( 'Resource does not support trashing.', 'woocommerce' ), array( 'status' => 501 ) ); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - $attribute = $this->get_attribute( (int) $request['id'] ); |
|
| 267 | + $attribute = $this->get_attribute( (int) $request[ 'id' ] ); |
|
| 268 | 268 | |
| 269 | 269 | if ( is_wp_error( $attribute ) ) { |
| 270 | 270 | return $attribute; |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | */ |
| 404 | 404 | public function get_collection_params() { |
| 405 | 405 | $params = array(); |
| 406 | - $params['context'] = $this->get_context_param( array( 'default' => 'view' ) ); |
|
| 406 | + $params[ 'context' ] = $this->get_context_param( array( 'default' => 'view' ) ); |
|
| 407 | 407 | |
| 408 | 408 | return $params; |
| 409 | 409 | } |
@@ -419,8 +419,8 @@ discard block |
||
| 419 | 419 | return $this->attribute; |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - if ( $request['id'] ) { |
|
| 423 | - $name = wc_attribute_taxonomy_name_by_id( (int) $request['id'] ); |
|
| 422 | + if ( $request[ 'id' ] ) { |
|
| 423 | + $name = wc_attribute_taxonomy_name_by_id( (int) $request[ 'id' ] ); |
|
| 424 | 424 | |
| 425 | 425 | $this->attribute = $name; |
| 426 | 426 | } |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | // Check if WooCommerce.com account is connected. |
| 37 | 37 | $woo_com_connected = 'no'; |
| 38 | 38 | $helper_options = get_option( 'woocommerce_helper_data', array() ); |
| 39 | - if ( array_key_exists( 'auth', $helper_options ) && ! empty( $helper_options['auth'] ) ) { |
|
| 39 | + if ( array_key_exists( 'auth', $helper_options ) && ! empty( $helper_options[ 'auth' ] ) ) { |
|
| 40 | 40 | $woo_com_connected = 'yes'; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -55,19 +55,19 @@ discard block |
||
| 55 | 55 | * @return array |
| 56 | 56 | */ |
| 57 | 57 | public function get_dropin_and_mu_plugin_data() { |
| 58 | - $plugins = [ |
|
| 59 | - 'dropins' => [], |
|
| 60 | - 'mu_plugins' => [], |
|
| 58 | + $plugins = [ |
|
| 59 | + 'dropins' => [ ], |
|
| 60 | + 'mu_plugins' => [ ], |
|
| 61 | 61 | ]; |
| 62 | 62 | |
| 63 | 63 | foreach ( get_dropins() as $plugin => $data ) { |
| 64 | - $data['plugin_file'] = $plugin; |
|
| 65 | - $plugins['dropins'][] = $this->format_plugin_data( $data ); |
|
| 64 | + $data[ 'plugin_file' ] = $plugin; |
|
| 65 | + $plugins[ 'dropins' ][ ] = $this->format_plugin_data( $data ); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | foreach ( get_mu_plugins() as $plugin => $data ) { |
| 69 | - $data['plugin_file'] = $plugin; |
|
| 70 | - $plugins['mu_plugins'][] = $this->format_plugin_data( $data ); |
|
| 69 | + $data[ 'plugin_file' ] = $plugin; |
|
| 70 | + $plugins[ 'mu_plugins' ][ ] = $this->format_plugin_data( $data ); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | return $plugins; |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | protected function get_inactive_plugins() { |
| 98 | 98 | $plugins = get_plugins(); |
| 99 | 99 | $active_plugins = $this->get_active_plugins(); |
| 100 | - $inactive_plugins = []; |
|
| 100 | + $inactive_plugins = [ ]; |
|
| 101 | 101 | |
| 102 | 102 | foreach ( $plugins as $plugin => $data ) { |
| 103 | 103 | if ( in_array( $plugin, $active_plugins, true ) ) { |
| 104 | 104 | continue; |
| 105 | 105 | } |
| 106 | - $inactive_plugins[] = $plugin; |
|
| 106 | + $inactive_plugins[ ] = $plugin; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | return $inactive_plugins; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | protected function get_plugin_data( $plugin ) { |
| 119 | 119 | $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
| 120 | - $data['plugin_file'] = $plugin; |
|
| 120 | + $data[ 'plugin_file' ] = $plugin; |
|
| 121 | 121 | return $data; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -128,22 +128,22 @@ discard block |
||
| 128 | 128 | * @return array Formatted data. |
| 129 | 129 | */ |
| 130 | 130 | protected function format_plugin_data( $data ) { |
| 131 | - $version_latest = $data['Version']; |
|
| 131 | + $version_latest = $data[ 'Version' ]; |
|
| 132 | 132 | |
| 133 | 133 | // Find latest version. |
| 134 | - if ( isset( $this->available_updates[ $data['plugin_file'] ]->update->new_version ) ) { |
|
| 135 | - $version_latest = $this->available_updates[ $data['plugin_file'] ]->update->new_version; |
|
| 134 | + if ( isset( $this->available_updates[ $data[ 'plugin_file' ] ]->update->new_version ) ) { |
|
| 135 | + $version_latest = $this->available_updates[ $data[ 'plugin_file' ] ]->update->new_version; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | return array( |
| 139 | - 'plugin' => $data['plugin_file'], |
|
| 140 | - 'name' => $data['Name'], |
|
| 141 | - 'version' => $data['Version'], |
|
| 139 | + 'plugin' => $data[ 'plugin_file' ], |
|
| 140 | + 'name' => $data[ 'Name' ], |
|
| 141 | + 'version' => $data[ 'Version' ], |
|
| 142 | 142 | 'version_latest' => $version_latest, |
| 143 | - 'url' => $data['PluginURI'], |
|
| 144 | - 'author_name' => $data['AuthorName'], |
|
| 145 | - 'author_url' => esc_url_raw( $data['AuthorURI'] ), |
|
| 146 | - 'network_activated' => $data['Network'], |
|
| 143 | + 'url' => $data[ 'PluginURI' ], |
|
| 144 | + 'author_name' => $data[ 'AuthorName' ], |
|
| 145 | + 'author_url' => esc_url_raw( $data[ 'AuthorURI' ] ), |
|
| 146 | + 'network_activated' => $data[ 'Network' ], |
|
| 147 | 147 | ); |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -44,18 +44,18 @@ discard block |
||
| 44 | 44 | 'curl_version' => $this->get_curl_version(), |
| 45 | 45 | 'suhosin_installed' => extension_loaded( 'suhosin' ), |
| 46 | 46 | 'max_upload_size' => wp_max_upload_size(), |
| 47 | - 'mysql_version' => $database_version['number'], |
|
| 48 | - 'mysql_version_string' => $database_version['string'], |
|
| 47 | + 'mysql_version' => $database_version[ 'number' ], |
|
| 48 | + 'mysql_version_string' => $database_version[ 'string' ], |
|
| 49 | 49 | 'default_timezone' => date_default_timezone_get(), |
| 50 | 50 | 'fsockopen_or_curl_enabled' => $this->fsockopen_or_curl_enabled(), |
| 51 | 51 | 'soapclient_enabled' => class_exists( 'SoapClient' ), |
| 52 | 52 | 'domdocument_enabled' => class_exists( 'DOMDocument' ), |
| 53 | 53 | 'gzip_enabled' => is_callable( 'gzopen' ), |
| 54 | 54 | 'mbstring_enabled' => extension_loaded( 'mbstring' ), |
| 55 | - 'remote_post_successful' => $post_request['success'], |
|
| 56 | - 'remote_post_response' => $post_request['response'], |
|
| 57 | - 'remote_get_successful' => $get_request['success'], |
|
| 58 | - 'remote_get_response' => $get_request['response'], |
|
| 55 | + 'remote_post_successful' => $post_request[ 'success' ], |
|
| 56 | + 'remote_post_response' => $post_request[ 'response' ], |
|
| 57 | + 'remote_get_successful' => $get_request[ 'success' ], |
|
| 58 | + 'remote_get_response' => $get_request[ 'response' ], |
|
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ) |
| 81 | 81 | ); |
| 82 | 82 | if ( ! is_wp_error( $response ) ) { |
| 83 | - $post_response_code = $response['response']['code']; |
|
| 83 | + $post_response_code = $response[ 'response' ][ 'code' ]; |
|
| 84 | 84 | } |
| 85 | 85 | set_transient( 'woocommerce_test_remote_post', $post_response_code, HOUR_IN_SECONDS ); |
| 86 | 86 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | if ( false === $get_response_code || is_wp_error( $get_response_code ) ) { |
| 110 | 110 | $response = wp_safe_remote_get( 'https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ) ); |
| 111 | 111 | if ( ! is_wp_error( $response ) ) { |
| 112 | - $get_response_code = $response['response']['code']; |
|
| 112 | + $get_response_code = $response[ 'response' ][ 'code' ]; |
|
| 113 | 113 | } |
| 114 | 114 | set_transient( 'woocommerce_test_remote_get', $get_response_code, HOUR_IN_SECONDS ); |
| 115 | 115 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @return string |
| 144 | 144 | */ |
| 145 | 145 | protected function get_server_software() { |
| 146 | - return isset( $_SERVER['SERVER_SOFTWARE'] ) ? wc_clean( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : ''; |
|
| 146 | + return isset( $_SERVER[ 'SERVER_SOFTWARE' ] ) ? wc_clean( wp_unslash( $_SERVER[ 'SERVER_SOFTWARE' ] ) ) : ''; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $curl_version = ''; |
| 156 | 156 | if ( function_exists( 'curl_version' ) ) { |
| 157 | 157 | $curl_version = curl_version(); |
| 158 | - $curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version']; |
|
| 158 | + $curl_version = $curl_version[ 'version' ] . ', ' . $curl_version[ 'ssl_version' ]; |
|
| 159 | 159 | } elseif ( extension_loaded( 'curl' ) ) { |
| 160 | 160 | $curl_version = __( 'cURL installed but unable to retrieve version.', 'woocommerce' ); |
| 161 | 161 | } |
@@ -102,8 +102,8 @@ |
||
| 102 | 102 | 'engine' => $table->engine, |
| 103 | 103 | ); |
| 104 | 104 | |
| 105 | - $database_size['data'] += $table->data; |
|
| 106 | - $database_size['index'] += $table->index; |
|
| 105 | + $database_size[ 'data' ] += $table->data; |
|
| 106 | + $database_size[ 'index' ] += $table->index; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // Return all database info. Described by JSON Schema. |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $pages_output = array(); |
| 72 | 72 | foreach ( $check_pages as $page_name => $values ) { |
| 73 | - $page_id = get_option( $values['option'] ); |
|
| 73 | + $page_id = get_option( $values[ 'option' ] ); |
|
| 74 | 74 | $page_set = false; |
| 75 | 75 | $page_exists = false; |
| 76 | 76 | $page_visible = false; |
@@ -89,22 +89,22 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Shortcode checks. |
| 92 | - if ( $values['shortcode'] && get_post( $page_id ) ) { |
|
| 92 | + if ( $values[ 'shortcode' ] && get_post( $page_id ) ) { |
|
| 93 | 93 | $shortcode_required = true; |
| 94 | 94 | $page = get_post( $page_id ); |
| 95 | - if ( strstr( $page->post_content, $values['shortcode'] ) ) { |
|
| 95 | + if ( strstr( $page->post_content, $values[ 'shortcode' ] ) ) { |
|
| 96 | 96 | $shortcode_present = true; |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Wrap up our findings into an output array. |
| 101 | - $pages_output[] = array( |
|
| 101 | + $pages_output[ ] = array( |
|
| 102 | 102 | 'page_name' => $page_name, |
| 103 | 103 | 'page_id' => $page_id, |
| 104 | 104 | 'page_set' => $page_set, |
| 105 | 105 | 'page_exists' => $page_exists, |
| 106 | 106 | 'page_visible' => $page_visible, |
| 107 | - 'shortcode' => $values['shortcode'], |
|
| 107 | + 'shortcode' => $values[ 'shortcode' ], |
|
| 108 | 108 | 'shortcode_required' => $shortcode_required, |
| 109 | 109 | 'shortcode_present' => $shortcode_present, |
| 110 | 110 | ); |