ddress' ), array( 'geolocation_ajax', 'geolocation', ), true ), 'taxonomies' => $term_response, 'product_visibility_terms' => $product_visibility_terms, 'woocommerce_com_connected' => ConnectionHelper::is_connected() ? 'yes' : 'no', 'enforce_approved_download_dirs' => wc_get_container()->get( Download_Directories::class )->get_mode() === Download_Directories::MODE_ENABLED, 'order_datastore' => WC_Data_Store::load( 'order' )->get_current_class_name(), 'HPOS_feature_screen_enabled' => wc_get_container()->get( Automattic\WooCommerce\Internal\Features\FeaturesController::class )->feature_is_enabled( 'custom_order_tables' ), 'HPOS_enabled' => OrderUtil::custom_orders_table_usage_is_enabled(), 'HPOS_sync_enabled' => wc_get_container()->get( Order_DataSynchronizer::class )->data_sync_is_enabled(), ); } /** * Returns security tips. * * @return array */ public function get_security_info() { $check_page = wc_get_page_permalink( 'shop' ); return array( 'secure_connection' => 'https' === substr( $check_page, 0, 5 ), 'hide_errors' => ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), ); } /** * Returns a mini-report on WC pages and if they are configured correctly: * Present, visible, and including the correct shortcode or block. * * @return array */ public function get_pages() { // WC pages to check against. $check_pages = array( _x( 'Shop base', 'Page setting', 'woocommerce' ) => array( 'option' => 'woocommerce_shop_page_id', 'shortcode' => '', 'block' => '', ), _x( 'Cart', 'Page setting', 'woocommerce' ) => array( 'option' => 'woocommerce_cart_page_id', 'shortcode' => '[' . apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) . ']', 'block' => 'woocommerce/cart', ), _x( 'Checkout', 'Page setting', 'woocommerce' ) => array( 'option' => 'woocommerce_checkout_page_id', 'shortcode' => '[' . apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) . ']', 'block' => 'woocommerce/checkout', ), _x( 'My account', 'Page setting', 'woocommerce' ) => array( 'option' => 'woocommerce_myaccount_page_id', 'shortcode' => '[' . apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) . ']', 'block' => '', ), _x( 'Terms and conditions', 'Page setting', 'woocommerce' ) => array( 'option' => 'woocommerce_terms_page_id', 'shortcode' => '', 'block' => '', ), ); $pages_output = array(); foreach ( $check_pages as $page_name => $values ) { $page_id = get_option( $values['option'] ); $page_set = false; $page_exists = false; $page_visible = false; $shortcode_present = false; $shortcode_required = false; $block_present = false; $block_required = false; // Page checks. if ( $page_id ) { $page_set = true; } if ( get_post( $page_id ) ) { $page_exists = true; } if ( 'publish' === get_post_status( $page_id ) ) { $page_visible = true; } // Shortcode checks. if ( $values['shortcode'] && get_post( $page_id ) ) { $shortcode_required = true; $page = get_post( $page_id ); if ( strstr( $page->post_content, $values['shortcode'] ) ) { $shortcode_present = true; } } // Block checks. if ( $values['block'] && get_post( $page_id ) ) { $block_required = true; $block_present = WC_Blocks_Utils::has_block_in_page( $page_id, $values['block'] ); } // Wrap up our findings into an output array. $pages_output[] = array( 'page_name' => $page_name, 'page_id' => $page_id, 'page_set' => $page_set, 'page_exists' => $page_exists, 'page_visible' => $page_visible, 'shortcode' => $values['shortcode'], 'block' => $values['block'], 'shortcode_required' => $shortcode_required, 'shortcode_present' => $shortcode_present, 'block_present' => $block_present, 'block_required' => $block_required, ); } return $pages_output; } /** * Get any query params needed. * * @return array */ public function get_collection_params() { return array( 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ); } /** * Prepare the system status response * * @param array $system_status System status data. * @param WP_REST_Request $request Request object. * @return WP_REST_Response */ public function prepare_item_for_response( $system_status, $request ) { $data = $this->add_additional_fields_to_object( $system_status, $request ); $data = $this->filter_response_by_context( $data, 'view' ); $response = rest_ensure_response( $data ); /** * Filter the system status returned from the REST API. * * @param WP_REST_Response $response The response object. * @param mixed $system_status System status * @param WP_REST_Request $request Request object. */ return apply_filters( 'woocommerce_rest_prepare_system_status', $response, $system_status, $request ); } }