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