Skip to content

Commit

Permalink
PHPCS FIX
Browse files Browse the repository at this point in the history
  • Loading branch information
benazeer-ben committed Dec 5, 2024
1 parent 4d15da9 commit 37cf3a2
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions lib/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,39 @@ function gutenberg_register_edit_site_export_controller_endpoints() {
$edit_site_export_controller->register_routes();
}
add_action( 'rest_api_init', 'gutenberg_register_edit_site_export_controller_endpoints' );
add_action( 'rest_api_init', function () {
register_rest_route(
'page-options/v1',
'/options',
[
'methods' => 'GET',
'callback' => 'get_page_options',
'permission_callback' => '__return_true', // Adjust permissions as necessary
]
);
} );
add_action(
'rest_api_init',
function () {
register_rest_route(
'page-options/v1',
'/options',
array(
'methods' => 'GET',
'callback' => 'get_page_options',
'permission_callback' => '__return_true',
)
);
}
);

/**
* Returns an array of page IDs used in various parts of WordPress.
*
* The pages included are:
* - Privacy policy page ID
* - Cart page ID (from WooCommerce)
* - Checkout page ID (from WooCommerce)
* - Account page ID (from WooCommerce)
* - Shop page ID (from WooCommerce)
*
* @return array IDs of the pages in the format: array( 'privacyPolicyPageId' => int, ... )
*/
function get_page_options() {

Check failure on line 66 in lib/rest-api.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

The "get_page_options()" function should be guarded against redeclaration.
return [
'privacyPolicyPageId' => get_option( 'wp_page_for_privacy_policy' ),
'cartPageId' => get_option( 'woocommerce_cart_page_id' ),
'checkoutPageId' => get_option( 'woocommerce_checkout_page_id' ),
'accountPageId' => get_option( 'woocommerce_myaccount_page_id' ),
'shopPageId' => get_option( 'woocommerce_shop_page_id' ),
];
return array(
'privacyPolicyPageId' => get_option( 'wp_page_for_privacy_policy' ),
'cartPageId' => get_option( 'woocommerce_cart_page_id' ),
'checkoutPageId' => get_option( 'woocommerce_checkout_page_id' ),
'accountPageId' => get_option( 'woocommerce_myaccount_page_id' ),
'shopPageId' => get_option( 'woocommerce_shop_page_id' ),
);
}

0 comments on commit 37cf3a2

Please sign in to comment.