diff --git a/includes/RestApi/UserController.php b/includes/RestApi/UserController.php index 63c7bbc6..a9af709b 100644 --- a/includes/RestApi/UserController.php +++ b/includes/RestApi/UserController.php @@ -14,26 +14,30 @@ class UserController { protected $rest_base = '/user'; public function register_routes() { - \register_rest_route( - $this->namespace, - $this->rest_base . '/page-status', - array( - array( - 'methods' => \WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_page_status' ), - 'permission_callback' => array( Permissions::class, 'rest_is_authorized_admin' ), - ), - ) - ); - } + \register_rest_route( + $this->namespace, + $this->rest_base . '/page-status', + array( + array( + 'methods' => \WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_page_status' ), + 'permission_callback' => array( Permissions::class, 'rest_is_authorized_admin' ), + ), + ) + ); + } - public function get_page_status() { - global $wpdb; - return $wpdb->get_results( - $wpdb->prepare( - "select post_id, meta_value from wp_postmeta where meta_key LIKE 'nf_dc_page'") - ); - } + public function get_page_status() { + $args = array( + 'posts_per_page' => 3, + 'post_type' => 'page', + 'meta_key' => 'nf_dc_page', + 'meta_value' => array('home', 'about', 'contact'), + 'meta_compare' => 'IN' + ); + $query = new \WP_Query( $args ); + return $query->get_posts(); + } /** * Connect to UAPI with token via AccessToken Class in Bluehost Plugin diff --git a/src/components/CustomizeStore.js b/src/components/CustomizeStore.js index 965c4e3d..81edd72b 100644 --- a/src/components/CustomizeStore.js +++ b/src/components/CustomizeStore.js @@ -17,7 +17,7 @@ export function CustomizeStore(props) { let { data: pluginsOnSite } = useSWR("/newfold-ecommerce/v1/plugins/status"); let { data: postsMeta } = useSWR("/newfold-ecommerce/v1/user/page-status"); let postsByName = Object.fromEntries( - postsMeta?.map((_) => [_["meta_value"], _["post_id"]]) ?? [] + postsMeta?.map((_) => [_["post_name"], _["ID"]]) ?? [] ); return (