function tdomf_widget_tags_adminemail($args)
 {
     extract($args);
     $tags = wp_get_post_tags($post_ID);
     if (!empty($tags)) {
         $output = $before_widget;
         $output .= __("Post tagged with\r\n", "tdomf");
         foreach ($tags as $tag) {
             $output .= $tag->name . ", ";
         }
         $output .= $after_widget;
         return $output;
     }
     return "";
 }
 tdomf_register_form_widget_adminemail('tags', __('Tags', 'tdomf'), 'tdomf_widget_tags_adminemail', array("new-post"));
 function tdomf_widget_tags_hack($args)
 {
     extract($args);
     $options = tdomf_widget_tags_options($tdomf_form_id);
     $output = "";
     if ($options['user']) {
         $output = $before_widget;
         if ($options['title'] != '') {
             $output .= $before_title . $options['title'] . $after_title;
         }
         if ($options['required']) {
             $output .= "\t\t" . '<label for="tags" class="required">';
         } else {
             $output .= "\t\t" . '<label for="tags" >';
         }
    $post = wp_get_single_post($post_ID, ARRAY_A);
    if ($post['comment_status'] == 'closed') {
        $output .= __("Comments off", "tdomf");
    } else {
        $output .= __("Comments on", "tdomf");
    }
    $output .= "\n";
    if ($post['ping_status'] == 'closed') {
        $output .= __("Pings and Trackbacks off", "tdomf");
    } else {
        $output .= __("Pings and Trackbacks on", "tdomf");
    }
    $output .= $after_widget;
    return $output;
}
tdomf_register_form_widget_adminemail('comments', __('Comments Management', "tdomf"), 'tdomf_widget_comments_adminemail', $modes = array('new'));
function tdomf_widget_comments_post($args)
{
    $options = tdomf_widget_comments_get_options($args['tdomf_form_id']);
    extract($args);
    $comment_status = get_option('default_comment_status');
    $ping_status = get_option('default_ping_status');
    if ($options['overwrite']) {
        $comment_status = 'closed';
        if ($options['comments']) {
            $comment_status = 'open';
        }
        $ping_status = 'closed';
        if ($options['pings']) {
            $ping_status = 'open';
        }
 /**
  * Start widget
  *
  * @access public
  */
 function start()
 {
     $retVal = false;
     if (!$this->started || !$this->internalName || !$this->displayName) {
         $retVal = true;
         if ($this->multipleInstances) {
             add_action('tdomf_generate_form_start', array($this, '_multipleInstancesInit'), 10, 2);
             add_action('tdomf_create_post_start', array($this, '_multipleInstancesInit'), 10, 2);
             add_action('tdomf_control_form_start', array($this, '_multipleInstancesInit'), 10, 2);
             add_action('tdomf_preview_form_start', array($this, '_multipleInstancesInit'), 10, 2);
             add_action('tdomf_validate_form_start', array($this, '_multipleInstancesInit'), 10, 2);
             add_action('tdomf_control_form_start', array($this, '_multipleInstancesHandler'), 10, 2);
             add_action('tdomf_widget_page_bottom', array($this, '_multipleInstancesForm'), 10, 2);
             add_action('tdomf_upload_inline_form_start', array($this, '_multipleInstancesInit'), 10, 2);
             // for multiple instances, init is handled in _multipleInstancesInit function
         } else {
             tdomf_register_form_widget($this->internalName, $this->displayName, array($this, '_form'), $this->modes);
             if ($this->hack) {
                 tdomf_register_form_widget_hack($this->internalName, $this->displayName, array($this, '_formHack'), $this->modes);
             }
             if ($this->control) {
                 tdomf_register_form_widget_control($this->internalName, $this->displayName, array($this, '_control'), $this->controlWidth, $this->controlHeight, $this->modes);
             }
             if ($this->preview) {
                 tdomf_register_form_widget_preview($this->internalName, $this->displayName, array($this, '_preview'), $this->modes);
             }
             if ($this->previewHack) {
                 tdomf_register_form_widget_preview_hack($this->internalName, $this->displayName, array($this, '_previewHack'), $this->modes);
             }
             if ($this->validate) {
                 tdomf_register_form_widget_validate($this->internalName, $this->displayName, array($this, '_validate'), $this->modes);
             }
             if ($this->post) {
                 tdomf_register_form_widget_post($this->internalName, $this->displayName, array($this, '_post'), $this->modes);
             }
             if ($this->adminEmail) {
                 tdomf_register_form_widget_adminemail($this->internalName, $this->displayName, array($this, '_adminEmail'), $this->modes);
             }
             if ($this->adminError) {
                 tdomf_register_form_widget_admin_error($this->internalName, $this->displayName, array($this, '_adminError'), $this->modes);
             }
         }
     }
     return $retVal;
 }
function tdomf_widget_categories_init($form_id, $mode)
{
    if (tdomf_form_exists($form_id) && strpos($mode, 'new-post') !== false) {
        $count = tdomf_get_option_widget('tdomf_categories_widget_count', $form_id);
        $max = tdomf_get_option_form(TDOMF_OPTION_WIDGET_INSTANCES, $form_id);
        if ($max <= 1) {
            $count = 1;
        } else {
            if ($count > $max + 1) {
                $count = $max + 1;
            }
        }
        tdomf_register_form_widget("categories", "Categories 1", 'tdomf_widget_categories', array(), 1);
        tdomf_register_form_widget_hack("categories", "Categories 1", 'tdomf_widget_categories', array(), 1);
        tdomf_register_form_widget_control("categories", "Categories 1", 'tdomf_widget_categories_control', 370, 610, array(), 1);
        tdomf_register_form_widget_preview("categories", "Categories 1", 'tdomf_widget_categories_preview', array(), 1);
        tdomf_register_form_widget_preview_hack("categories", "Categories 1", 'tdomf_widget_categories_preview_hack', array(), 1);
        tdomf_register_form_widget_post("categories", "Categories 1", 'tdomf_widget_categories_post', array(), 1);
        tdomf_register_form_widget_adminemail("categories", "Categories 1", 'tdomf_widget_categories_adminemail', array(), 1);
        tdomf_register_form_widget_admin_error("categories", "Categories 1", 'tdomf_widget_categories_admin_error', array(), 1);
        for ($i = 2; $i <= $count; $i++) {
            tdomf_register_form_widget("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories', array(), $i);
            tdomf_register_form_widget_hack("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories', array(), $i);
            tdomf_register_form_widget_control("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_control', 370, 610, array(), $i);
            tdomf_register_form_widget_preview("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_preview', array(), $i);
            tdomf_register_form_widget_preview_hack("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_preview_hack', array(), $i);
            tdomf_register_form_widget_post("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_post', array(), $i);
            tdomf_register_form_widget_adminemail("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_adminemail', array(), $i);
            tdomf_register_form_widget_admin_error("categories-{$i}", "Categories {$i}", 'tdomf_widget_categories_admin_error', array(), $i);
        }
    }
}