Skip to content

Add support for taxonomy-filtered association fields (not part of the main repo) #714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/REST_API/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,20 @@ public function get_association_data() {
$options = array_map( function ( $option ) {
$option = explode( ':', $option );

return [
$res = [
'id' => $option[0],
'type' => $option[1],
'subtype' => $option[2],
];
if ( ! empty( $option[3] ) ) {
$res['taxTerm'] = intval( $option[3] );
}
return $res;
}, $options );

foreach ( $options as $option ) {
$item = array(
'taxTerm' => ! empty( $option['taxTerm'] ) ? $option['taxTerm'] : 0,
'type' => $option['type'],
'subtype' => $option['subtype'],
'thumbnail' => $field->get_thumbnail_by_type( $option['id'], $option['type'], $option['subtype'] ),
Expand Down
28 changes: 18 additions & 10 deletions languages/carbon-fields-ui.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,30 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"X-Generator: babel-plugin-makepot\n"

#: packages/blocks/components/block-edit/index.js:201
#: packages/blocks/components/block-edit/index.js:214
msgid "Show preview"
msgstr ""

#: packages/blocks/components/block-edit/index.js:202
#: packages/blocks/components/block-edit/index.js:215
msgid "Hide preview"
msgstr ""

#: packages/blocks/components/block-edit/index.js:271
#: packages/blocks/components/block-edit/index.js:286
msgid "Fields"
msgstr ""

#: packages/blocks/components/not-supported-field/index.js:14
msgid "Field of type '%s' is not supported in Gutenberg."
msgstr ""

#: packages/blocks/components/server-side-render/index.js:129
msgid "Error loading block: %s"
msgstr ""

#: packages/blocks/components/server-side-render/index.js:135
msgid "No results found."
msgstr ""

#: packages/blocks/fields/datetime/index.js:59
#: packages/core/fields/date/index.js:15
#: packages/metaboxes/fields/datetime/index.js:9
Expand Down Expand Up @@ -63,29 +71,29 @@ msgstr ""
msgid "Search..."
msgstr ""

#: packages/core/fields/association/index.js:113
#: packages/core/fields/association/index.js:168
msgid "Maximum number of items reached (%s items)"
msgstr ""

#: packages/core/fields/association/index.js:204
#: packages/core/fields/association/index.js:266
msgid "Showing %1$d of %2$d results"
msgstr ""

#: packages/core/fields/association/index.js:380
#: packages/core/fields/association/index.js:449
msgid "An error occurred while trying to fetch association options."
msgstr ""

#: packages/core/fields/association/index.js:430
#: packages/core/fields/association/index.js:506
#: packages/core/fields/complex/index.js:428
#: packages/core/hocs/with-validation/required.js:20
msgid "This field is required."
msgstr ""

#: packages/core/fields/association/index.js:434
#: packages/core/fields/association/index.js:510
msgid "Minimum number of items not reached (%s items)"
msgstr ""

#: packages/core/fields/color/index.js:86
#: packages/core/fields/color/index.js:92
msgid "Select a color"
msgstr ""

Expand Down Expand Up @@ -197,7 +205,7 @@ msgstr ""
msgid "An error occurred while trying to fetch files data."
msgstr ""

#: packages/metaboxes/containers/index.js:52
#: packages/metaboxes/containers/index.js:55
msgid "Could not find DOM element for container \"%1$s\"."
msgstr ""

Expand Down
3 changes: 3 additions & 0 deletions packages/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ setLocaleData( window.cf.config.locale, 'carbon-fields-ui' );
export { createRegistry } from './registry';
export { getFieldType, registerFieldType } from './registry/fields';
export { default as Field } from './components/field';
export { default as SearchInput } from './components/search-input';
export { default as Sortable } from './components/sortable';
export { default as withFilters } from './hocs/with-filters';
export { default as withProps } from './hocs/with-props';
export { default as withValidation } from './hocs/with-validation';
export { default as withConditionalLogic } from './hocs/with-conditional-logic';
export { default as uniqueId } from './utils/unique-id';
export { default as fromSelector } from './utils/from-selector';
export { default as apiFetch } from './utils/api-fetch';

/**
* Triggers the initialization of Carbon Fields.
Expand Down
1 change: 1 addition & 0 deletions packages/metaboxes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import isGutenberg from './utils/is-gutenberg';
* Public API.
*/
export { registerContainerType, getContainerType } from './containers/registry';
export { default as stripCompactInputPrefix } from './utils/strip-compact-input-prefix';

/**
* Sets the locale data for the package type
Expand Down