components
1 year ago
block.json
1 year ago
edit.js
1 year ago
index.js
1 year ago
looper.js
1 year ago
query-parameters.js
1 year ago
save.js
1 year ago
templates.js
1 year ago
toolbar-appenders.js
1 year ago
query-parameters.js
203 lines
| 1 | import { __ } from '@wordpress/i18n'; |
| 2 | import { applyFilters } from '@wordpress/hooks'; |
| 3 | |
| 4 | export function getParameters() { |
| 5 | return applyFilters( 'generateblocks.editor.query.query-parameters', [ |
| 6 | { |
| 7 | id: 'post_type', |
| 8 | type: 'postTypeSelect', |
| 9 | default: [ 'post' ], |
| 10 | label: __( 'Post type', 'generateblocks' ), |
| 11 | description: __( 'Retrieves posts by post types.', 'generateblocks' ), |
| 12 | group: __( 'Post type', 'generateblocks' ), |
| 13 | isSticky: true, |
| 14 | }, |
| 15 | { |
| 16 | id: 'posts_per_page', |
| 17 | type: 'number', |
| 18 | default: 10, |
| 19 | label: __( 'Posts per page', 'generateblocks' ), |
| 20 | description: __( 'Number of post to show per page.', 'generateblocks' ), |
| 21 | group: __( 'Pagination', 'generateblocks' ), |
| 22 | isSticky: true, |
| 23 | }, |
| 24 | { |
| 25 | id: 'paged', |
| 26 | type: 'number', |
| 27 | default: 1, |
| 28 | label: __( 'Page', 'generateblocks' ), |
| 29 | description: __( 'Display posts from page.', 'generateblocks' ), |
| 30 | group: __( 'Pagination', 'generateblocks' ), |
| 31 | }, |
| 32 | { |
| 33 | id: 'offset', |
| 34 | type: 'number', |
| 35 | default: undefined, |
| 36 | label: __( 'Offset', 'generateblocks' ), |
| 37 | description: __( 'Offset the result set by a specific number of items.', 'generateblocks' ), |
| 38 | group: __( 'Pagination', 'generateblocks' ), |
| 39 | }, |
| 40 | { |
| 41 | id: 's', |
| 42 | type: 'text', |
| 43 | default: '', |
| 44 | label: __( 'Search', 'generateblocks' ), |
| 45 | description: __( 'Show posts based on a keyword search.', 'generateblocks' ), |
| 46 | group: __( 'Search', 'generateblocks' ), |
| 47 | }, |
| 48 | { |
| 49 | id: 'order', |
| 50 | type: 'select', |
| 51 | default: 'desc', |
| 52 | selectOptions: [ |
| 53 | { value: 'DESC', label: 'DESC' }, |
| 54 | { value: 'ASC', label: 'ASC' }, |
| 55 | ], |
| 56 | label: __( 'Order', 'generateblocks' ), |
| 57 | description: __( 'Designates the ascending or descending order of the ‘orderby‘ parameter.', 'generateblocks' ), |
| 58 | group: __( 'Order & Order by', 'generateblocks' ), |
| 59 | }, |
| 60 | { |
| 61 | id: 'orderby', |
| 62 | type: 'select', |
| 63 | default: 'date', |
| 64 | selectOptions: [ |
| 65 | { value: 'id', label: 'Id' }, |
| 66 | { value: 'title', label: 'Title' }, |
| 67 | { value: 'name', label: 'Slug' }, |
| 68 | { value: 'author', label: 'Author' }, |
| 69 | { value: 'date', label: 'Date' }, |
| 70 | { value: 'modified', label: 'Last modified date' }, |
| 71 | { value: 'parent', label: 'Parent id' }, |
| 72 | { value: 'menu_order', label: 'Menu order' }, |
| 73 | { value: 'rand', label: 'Random' }, |
| 74 | ], |
| 75 | label: __( 'Order by', 'generateblocks' ), |
| 76 | description: __( 'Sort retrieved posts by parameter.', 'generateblocks' ), |
| 77 | group: __( 'Order & Order by', 'generateblocks' ), |
| 78 | }, |
| 79 | { |
| 80 | id: 'author__in', |
| 81 | type: 'authorsSelect', |
| 82 | default: [], |
| 83 | dependencies: { |
| 84 | filterName: 'generateblocks.editor.query.author--in', |
| 85 | }, |
| 86 | label: __( 'Authors', 'generateblocks' ), |
| 87 | description: __( 'Show posts from authors. Search by name or ID.', 'generateblocks' ), |
| 88 | group: __( 'Author', 'generateblocks' ), |
| 89 | }, |
| 90 | { |
| 91 | id: 'author__not_in', |
| 92 | type: 'authorsSelect', |
| 93 | default: [], |
| 94 | dependencies: { |
| 95 | filterName: 'generateblocks.editor.query.author--not-in', |
| 96 | }, |
| 97 | label: __( 'Exclude authors', 'generateblocks' ), |
| 98 | description: __( 'Exclude posts from authors. Search by name or ID.', 'generateblocks' ), |
| 99 | group: __( 'Author', 'generateblocks' ), |
| 100 | }, |
| 101 | { |
| 102 | id: 'tax_query', |
| 103 | type: 'taxonomySelect', |
| 104 | default: [], |
| 105 | label: __( 'Taxonomies', 'generateblocks' ), |
| 106 | description: __( 'Include or exclude posts from a list of taxonomies. Search by name or ID.', 'generateblocks' ), |
| 107 | group: __( 'Taxonomy', 'generateblocks' ), |
| 108 | isRepeatable: true, |
| 109 | repeatableDefaultValue: { taxonomy: '', terms: [], rest: '', include_children: true, operator: 'IN' }, |
| 110 | }, |
| 111 | { |
| 112 | id: 'post_status', |
| 113 | type: 'multiSelect', |
| 114 | default: [], |
| 115 | selectOptions: [ |
| 116 | { value: 'publish', label: __( 'Publish', 'generateblocks' ) }, |
| 117 | { value: 'pending', label: __( 'Pending', 'generateblocks' ) }, |
| 118 | { value: 'draft', label: __( 'Draft', 'generateblocks' ) }, |
| 119 | { value: 'auto-draft', label: __( 'Auto draft', 'generateblocks' ) }, |
| 120 | { value: 'future', label: __( 'Future', 'generateblocks' ) }, |
| 121 | { value: 'private', label: __( 'Private', 'generateblocks' ) }, |
| 122 | { value: 'inherit', label: __( 'Inherit', 'generateblocks' ) }, |
| 123 | { value: 'trash', label: __( 'Trash', 'generateblocks' ) }, |
| 124 | { value: 'any', label: __( 'Any', 'generateblocks' ) }, |
| 125 | ], |
| 126 | label: __( 'Post status', 'generateblocks' ), |
| 127 | description: __( 'Show posts by post status.', 'generateblocks' ), |
| 128 | group: __( 'Status', 'generateblocks' ), |
| 129 | }, |
| 130 | { |
| 131 | id: 'post_parent__in', |
| 132 | type: 'includePosts', |
| 133 | default: [], |
| 134 | dependencies: { |
| 135 | postType: 'post_type', |
| 136 | filterName: 'generateblocks.editor.query.post-parent--in', |
| 137 | }, |
| 138 | label: __( 'Parent', 'generateblocks' ), |
| 139 | description: __( 'Show posts from parents. Search by name or ID.', 'generateblocks' ), |
| 140 | group: __( 'Post', 'generateblocks' ), |
| 141 | }, |
| 142 | { |
| 143 | id: 'post_parent__not_in', |
| 144 | type: 'excludePosts', |
| 145 | default: [], |
| 146 | dependencies: { |
| 147 | postType: 'post_type', |
| 148 | filterName: 'generateblocks.editor.query.post-parent--not-in', |
| 149 | }, |
| 150 | label: __( 'Parent exclude', 'generateblocks' ), |
| 151 | description: __( 'Do not show posts from parents. Search by name or ID.', 'generateblocks' ), |
| 152 | group: __( 'Post', 'generateblocks' ), |
| 153 | }, |
| 154 | { |
| 155 | id: 'post__in', |
| 156 | type: 'includePosts', |
| 157 | default: [], |
| 158 | dependencies: { |
| 159 | postType: 'post_type', |
| 160 | }, |
| 161 | label: __( 'Include posts', 'generateblocks' ), |
| 162 | description: __( 'Limit result set to specific posts. Search by name or ID.', 'generateblocks' ), |
| 163 | group: __( 'Post', 'generateblocks' ), |
| 164 | }, |
| 165 | { |
| 166 | id: 'post__not_in', |
| 167 | type: 'excludePosts', |
| 168 | default: [], |
| 169 | dependencies: { |
| 170 | postType: 'post_type', |
| 171 | filterName: 'generateblocks.editor.query.post--not-in', |
| 172 | }, |
| 173 | label: __( 'Exclude posts', 'generateblocks' ), |
| 174 | description: __( 'Ensure result set excludes specific posts. Search by name or ID.', 'generateblocks' ), |
| 175 | group: __( 'Post', 'generateblocks' ), |
| 176 | }, |
| 177 | { |
| 178 | id: 'stickyPosts', |
| 179 | type: 'select', |
| 180 | default: 'include', |
| 181 | selectOptions: [ |
| 182 | { value: 'include', label: 'Include' }, |
| 183 | { value: 'exclude', label: 'Exclude' }, |
| 184 | { value: 'ignore', label: 'Ignore' }, |
| 185 | { value: 'only', label: 'Only' }, |
| 186 | ], |
| 187 | label: __( 'Sticky posts', 'generateblocks' ), |
| 188 | description: __( 'Configure how sticky posts should show in the query.', 'generateblocks' ), |
| 189 | group: __( 'Post', 'generateblocks' ), |
| 190 | }, |
| 191 | { |
| 192 | id: 'date_query', |
| 193 | type: 'dateQuery', |
| 194 | label: __( 'Date', 'generateblocks' ), |
| 195 | description: __( 'Limit response to posts published before or after a given date.', 'generateblocks' ), |
| 196 | group: __( 'Date', 'generateblocks' ), |
| 197 | default: [], |
| 198 | isRepeatable: true, |
| 199 | repeatableDefaultValue: { before: new Date().toLocaleString(), inclusive: true }, |
| 200 | }, |
| 201 | ] ); |
| 202 | } |
| 203 |