name = 'accordion'; $this->label = __('Accordion Type', 'accordion-acf'); $this->category = 'layout'; $this->defaults = array( 'value' => false, // prevents acf_render_fields() from attempting to load value 'icon_class' => 'dashicons-arrow-right' ); $location = plugin_dir_url(__FILE__); $location = apply_filters("acf/accordion/dir", $location); // Settings $this->settings = array( 'icons' => $location . 'icons/icons.json' ); $this->l10n = array(); parent::__construct(); } /* * aafa_render_field_settings() * * Create extra settings for your field. These are visible when editing a field * * @type action * @since 3.6 * @date 1/11/2022 * * @param $field (array) the $field being edited * @return n/a */ function render_field_settings($field) { /* * acf_render_field_setting * * This function will create a setting for your field. Simply pass the $field parameter and an array of field settings. * The array of settings does not require a `value` or `prefix`; These settings are found from the $field array. * * More than one setting can be added by copy/paste the above code. * Please note that you must also have a matching $defaults value for the field name (font_size) */ $json_file = wp_remote_get($this->settings['icons']); $json_file = wp_remote_retrieve_body($json_file); $json_content = @json_decode($json_file, true); if (!isset($json_content['icons'])) { esc_html_e(' ', 'accordion-addon-for-acf'); // (changed) return; } $icons = array(); foreach ($json_content['icons'] as $icon) { $icons[$icon['icon']['class']] = $icon['icon']['name']; } acf_render_field_setting($field, array( 'label' => __('Icon', 'acf-accordion'), 'type' => 'select', 'id' => $field['ID'] . 'accordion-select', 'name' => 'icon_class', 'choices' => $icons, )); ?>