name = 'accordion'; $this->label = __('Accordion Tab', 'acf-accordion'); $this->category = 'layout'; $this->defaults = array( 'value' => false, // prevents acf_render_fields() from attempting to load value 'icon_class' => 'dashicons-arrow-right' ); $dir = plugin_dir_url( __FILE__ ); $dir = apply_filters( "acf/accordion/dir", $dir ); // Settings $this->settings = array( 'icons' => $dir . 'icons/icons.json' ); $this->l10n = array(); parent::__construct(); } /* * render_field_settings() * * Create extra settings for your field. These are visible when editing a field * * @type action * @since 3.6 * @date 23/01/13 * * @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) */ // acf_render_field_setting( $field, array( // 'label' => __('Icon class','acf-accordion'), // 'instructions' => __('You can add any icon class from the Developer Resources: Dashicons','acf-accordion'), // 'type' => 'text', // 'name' => 'icon_class', // )); $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'] ) ){ _e('No icons found', 'acf-accordion'); 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, )); ?>