Returning selected widget area name
-
hello.
I’v modified your plugin so i could not echo widget area but return wigdet are name, here’s the code:
line from 88
<?php // new field for returning just name of sidebar ?> <tr class="field_option field_option_<?php echo $this->name; ?>"> <td class="label"> <label><?php _ex("Return",'acf_field_widget_area return type','acf'); ?></label> </td> <td> <?php do_action('acf/create_field', array( 'type' => 'radio', 'name' => 'fields['.$key.'][return]', 'value' => $field['return'], 'choices' => array( 1 => _x("Widget area (html)",'acf_field_widget_area return type widget area','acf'), 0 => _x("Widget area name",'acf_field_widget_area return type widget area name','acf'), ), 'layout' => 'horizontal', )); ?> </td> </tr>
and return for api function compleately
function format_value_for_api($value, $post_id, $field) { $value = ''; if( $field['return'] ){ if ( is_active_sidebar( $field['value'] ) ) : $value .= '<div id="secondary" class="widget-area" role="complementary">'; dynamic_sidebar( $field['value'] ); $value .= '</div><!-- #secondary -->'; endif; } else { $value = $field['value']; } return $value; }
Hope these will be in your plugin, becouse i need to use sidebar with my own html markup and classes.
http://wordpress.org/plugins/advanced-custom-fields-widget-area-field/
- The topic ‘Returning selected widget area name’ is closed to new replies.