This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add product query support for Stock indicator block (#7734)
* Add product query support for Stock indicator block On the client side, when the Stock indicator block is used within the product query block, the markup will be rendered on the server side - No javascript related to Stock indicator block will be rendered. * Escape all values in output string Whenever we are rendering data, we should escape it. Escaping output prevents XSS (Cross-site scripting) attacks. * Change $is_on_backorder type & escape just before printing For more info: #7734 (comment) #7734 (comment)
- Loading branch information
1 parent
e3c491b
commit a136ff3
Showing
5 changed files
with
128 additions
and
17 deletions.
There are no files selected for viewing
22 changes: 15 additions & 7 deletions
22
assets/js/atomic/blocks/product-elements/stock-indicator/attributes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
interface BlockAttributes { | ||
productId: { | ||
type: string; | ||
default: number; | ||
}; | ||
} | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { BlockAttributes } from './types'; | ||
|
||
export const blockAttributes: BlockAttributes = { | ||
export const blockAttributes: Record< | ||
keyof BlockAttributes, | ||
{ | ||
type: string; | ||
default: unknown; | ||
} | ||
> = { | ||
productId: { | ||
type: 'number', | ||
default: 0, | ||
}, | ||
isDescendentOfQueryLoop: { | ||
type: 'boolean', | ||
default: false, | ||
}, | ||
}; | ||
|
||
export default blockAttributes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
assets/js/atomic/blocks/product-elements/stock-indicator/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export interface BlockAttributes { | ||
productId: number; | ||
isDescendentOfQueryLoop: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters