From f01c3ee96c284bded663de777a1d8c208198a56b Mon Sep 17 00:00:00 2001 From: marcusforsberg Date: Mon, 17 Sep 2018 13:20:39 +0200 Subject: [PATCH] - support custom metaboxes by allowing user to input their own ID --- acf-native-field-type.php | 42 +++++++++++++++++++++++++++++---------- js/acf-native-fields.js | 9 ++++++++- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/acf-native-field-type.php b/acf-native-field-type.php index c17f4c3..fff921f 100644 --- a/acf-native-field-type.php +++ b/acf-native-field-type.php @@ -26,24 +26,44 @@ function render_field_settings($field) { 'instructions' => __('The native WordPress field to move into this placeholder.', 'acf-native-fields'), 'type' => 'select', 'name' => 'native_field', + 'required' => 1, // TODO: Implement backend and frontend functionality for custom native fields (hooks) 'choices' => array( - 'content' => __('Content Editor', 'acf-native-fields'), - 'excerpt' => __('Excerpt', 'acf-native-fields'), - 'featured_image' => __('Featured Image', 'acf-native-fields'), - 'yoast_seo' => __('Yoast SEO', 'acf-native-fields'), - 'publish_box' => __('Publish Box', 'acf-native-fields'), - 'permalink' => __('Permalink', 'acf-native-fields'), - 'discussion' => __('Discussion', 'acf-native-fields'), - 'trackbacks' => __('Trackbacks', 'acf-native-fields'), - 'format' => __('Format', 'acf-native-fields'), - 'page_attributes'=> __('Page Attributes', 'acf-native-fields'), + 'content' => __('Content Editor', 'acf-native-fields'), + 'excerpt' => __('Excerpt', 'acf-native-fields'), + 'featured_image' => __('Featured Image', 'acf-native-fields'), + 'yoast_seo' => __('Yoast SEO', 'acf-native-fields'), + 'publish_box' => __('Publish Box', 'acf-native-fields'), + 'permalink' => __('Permalink', 'acf-native-fields'), + 'discussion' => __('Discussion', 'acf-native-fields'), + 'trackbacks' => __('Trackbacks', 'acf-native-fields'), + 'format' => __('Format', 'acf-native-fields'), + 'page_attributes' => __('Page Attributes', 'acf-native-fields'), + 'custom' => __('Custom', 'acf-native-fields'), + ), + )); + + acf_render_field_setting($field, array( + 'label' => __('Custom Meta Box ID', 'acf-native-fields'), + 'instructions' => __('The ID of the custom metabox to target.', 'acf-native-fields'), + 'type' => 'text', + 'name' => 'metabox_id', + 'prefix' => '#', + 'required' => 1, + 'conditional_logic' => array( + array( + array( + 'field' => 'native_field', + 'operator' => '==', + 'value' => 'custom', + ), + ), ), )); } function render_field($field) {?> -
+
>