function add_widget_style_dropdown($args) { $styles = builder_get_widget_styles(); echo "<pre>Args: " . print_r($args, true) . "</pre>\n"; it_classes_load('it-form.php'); $form = new ITForm(); $description = apply_filters('builder_filter_widget_style_input_description', __('Your Builder child theme offers different widget styles. Select one from the drop down for a different look for this widget.', 'it-l10n-Builder-Madison') . '<br />'); ?> <p> <label><?php echo $description; ?> <?php $form->add_drop_down('it-style', $styles); ?> <br /></label> </p> <?php }
function form($instance) { $defaults = array('title' => '', 'entry_id' => '', 'style' => ''); $instance = wp_parse_args((array) $instance, $defaults); $form = new ITForm($instance, array('widget_instance' => $this)); $posts = get_posts(array('post_type' => 'widget_content', 'numberposts' => '1000')); $entries = array(); foreach ((array) $posts as $post) { $title = $post->post_title; if (strlen($title) > 80) { $title = substr($title, 0, 80) . '...'; } $entries[$post->ID] = $title; } asort($entries); $styles = builder_get_widget_styles(); if (!empty($styles)) { $styles = array_merge(array('' => 'Default'), $styles); } ?> <?php if (!empty($entries)) { ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'it-l10n-Builder-Madison'); ?> </label> <?php $form->add_text_box('title', array('class' => 'widefat')); ?> </p> <p> <label for="<?php echo $this->get_field_id('entry_id'); ?> "><?php _e('Widget Content Entry:', 'it-l10n-Builder-Madison'); ?> </label><br /> <?php $form->add_drop_down('entry_id', $entries); ?> </p> <?php if (!empty($styles)) { ?> <p> <label for="<?php echo $this->get_field_id('style'); ?> "><?php _e('Widget Style:', 'it-l10n-Builder-Madison'); ?> </label><br /> <?php $form->add_drop_down('style', $styles); ?> </p> <?php } else { ?> <?php $form->add_hidden('style'); ?> <?php } ?> <p> <em>Note: Use the <a href="<?php echo admin_url('edit.php?post_type=widget_content'); ?> ">Widget Content editor</a> to manage content for the Widget Content widgets.</em> </p> <?php } else { ?> <p> This widget allows you to easily add advanced content to a sidebar. </p> <p> Currently, your site doesn't have any Widget Content entries. Use the <a href="<?php echo admin_url('edit.php?post_type=widget_content'); ?> ">Widget Content editor</a> to create new entries. Once you have created one or more new Widget Content entries, edit this widget again to select the desired entry and customize the widget. </p> <?php $form->add_hidden('title'); ?> <?php $form->add_hidden('entry_id'); ?> <?php $form->add_hidden('style'); ?> <?php } }
function form($instance) { $defaults = array('show_site_title' => '1', 'custom_site_title' => '', 'site_title_tag' => 'div', 'home_title_tag' => 'h1', 'show_tagline' => '1', 'custom_tagline' => '', 'site_tagline_tag' => 'div', 'home_tagline_tag' => 'div'); $instance = wp_parse_args((array) $instance, $defaults); $form = new ITForm($instance, array('widget_instance' => $this)); $use_default_tag_settings_options = array('1' => __('Yes'), '' => __('No, use custom tag settings', 'it-l10n-Builder-Paige')); $generic_tag_options = array('div' => '<div> (Recommended)', 'h1' => '<h1> (Not Recommended)', 'h2' => '<h2>', 'h3' => '<h3>', 'h4' => '<h4>', 'h5' => '<h5>', 'h6' => '<h6>'); $home_title_tag_options = array('div' => '<div>', 'h1' => '<h1> (Recommended)'); $home_title_tag_options = array_merge($generic_tag_options, $home_title_tag_options); foreach ($generic_tag_options as $tag => $description) { $generic_tag_options[$tag] = htmlentities($description); } foreach ($home_title_tag_options as $tag => $description) { $home_title_tag_options[$tag] = htmlentities($description); } $styles = builder_get_widget_styles(); if (!empty($styles)) { $styles = array_merge(array('' => 'Default'), $styles); } ?> <p> <label for="<?php echo $this->get_field_id('show_site_title'); ?> "><?php printf(__('Show Site Title (configured in <a href="%s">Settings > General</a>):', 'it-l10n-Builder-Paige'), admin_url('options-general.php')); ?> </label><br /> <?php $form->add_yes_no_drop_down('show_site_title'); ?> </p> <p> <label for="<?php echo $this->get_field_id('custom_site_title'); ?> "><?php _e('Customize Site Title (leave blank for default Site Title):', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_text_box('custom_site_title'); ?> </p> <p> <label for="<?php echo $this->get_field_id('show_tagline'); ?> "><?php printf(__('Show Tagline (configured in <a href="%s">Settings > General</a>):', 'it-l10n-Builder-Paige'), admin_url('options-general.php')); ?> </label><br /> <?php $form->add_yes_no_drop_down('show_tagline'); ?> </p> <p> <label for="<?php echo $this->get_field_id('custom_tagline'); ?> "><?php _e('Customize Tagline (leave blank for default Tagline):', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_text_box('custom_tagline'); ?> </p> <p> <label for="<?php echo $this->get_field_id('home_title_tag'); ?> "><?php _e('Site Title tag (when on the home page):', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_drop_down('home_title_tag', $home_title_tag_options); ?> </p> <p> <label for="<?php echo $this->get_field_id('home_tagline_tag'); ?> "><?php _e('Tagline tag (when on the home page):', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_drop_down('home_tagline_tag', $generic_tag_options); ?> </p> <p> <label for="<?php echo $this->get_field_id('site_title_tag'); ?> "><?php _e('Site Title tag (on other site views):', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_drop_down('site_title_tag', $generic_tag_options); ?> </p> <p> <label for="<?php echo $this->get_field_id('site_tagline_tag'); ?> "><?php _e('Tagline tag (on other site views):', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_drop_down('site_tagline_tag', $generic_tag_options); ?> </p> <?php if (!empty($styles)) { ?> <p> <label for="<?php echo $this->get_field_id('style'); ?> "><?php _e('Widget Style:', 'it-l10n-Builder-Paige'); ?> </label><br /> <?php $form->add_drop_down('style', $styles); ?> </p> <?php } else { ?> <?php $form->add_hidden('style'); ?> <?php } }