get_api_namespace(); register_rest_route( $namespace, $this->rest_base, array( array( 'methods' => \WP_REST_Server::READABLE, 'callback' => array( $this, 'get_common_settings' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => array(), ), 'schema' => array( $this, 'get_public_item_schema' ), ) ); } /** * Get common settings. * * @param WP_REST_Request $request Full details about the request. */ public function get_common_settings( $request ) { $settings = GlobalSettings::get_global_settings_fields(); $options = AdminHelper::get_options(); $global_settings = array( 'settings' => $settings, 'options' => $options, ); return $global_settings; } /** * Check whether a given request has permission to read notes. * * @param WP_REST_Request $request Full details about the request. * @return WP_Error|boolean */ public function get_items_permissions_check( $request ) { if ( ! current_user_can( 'cartflows_manage_flows_steps' ) ) { return new \WP_Error( 'cartflows_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'cartflows' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } }