Esempio n. 1
0
    $output = "\t<?php if(tdomf_get_option_form(TDOMF_OPTION_MODERATION,\$tdomf_form_id) && !current_user_can('publish_posts') && !tdomf_current_user_default_author() && !tdomf_current_user_trusted()) { ?>\n\t";
    $output .= $before_widget;
    $output .= "\t\t\t<label for='notifyme'><input type='checkbox' name='notifyme' id='notifyme'";
    $output .= "<?php if(isset(\$notifyme)) { ?> checked <?php } ?>";
    $output .= " /> " . __("Do you wish to be notified when your post is approved (or rejected)?", "tdomf") . "</label>\n";
    $output .= "\t\t<?php if(tdomf_widget_notifyme_show_email_input(%%FORMID%%)) { ?>\n";
    $output .= "\t\t\t<?php if(isset(\$_COOKIE['tdomf_notify_widget_email'])) { \$notifyme_email = \$_COOKIE['tdomf_notify_widget_email']; } ?>\n";
    $output .= "\t\t\t\t<br/>\n\t\t\t\t<label for='notifyme_email'>" . __("Email for notification:", "tdomf") . ' <input type="text" value="';
    $output .= '<?php echo htmlentities($notifyme_email,ENT_QUOTES); ?>' . '" name="notifyme_email" id="notifyme_email" size="40" /></label>' . "\n";
    $output .= "\t\t<?php } ?>";
    $output .= $after_widget;
    $output .= "\t<?php } ?>";
    $output .= $after_widget;
    return $output;
}
tdomf_register_form_widget_hack('notifyme', 'Notify Me', 'tdomf_widget_notifyme_hack', $modes = array('new'));
// Widget validate input
//
function tdomf_widget_notifyme_validate($args, $preview)
{
    extract($args);
    if (!$preview) {
        if (tdomf_widget_notifyme_show_email_input($tdomf_form_id)) {
            if (isset($notifyme) && !tdomf_check_email_address($notifyme_email)) {
                return $before_widget . __("You must specify a valid email address to send the notification to.", "tdomf") . $after_widget;
            }
        }
    }
    return NULL;
}
tdomf_register_form_widget_validate('notifyme', 'Notify Me', 'tdomf_widget_notifyme_validate', $modes = array('new'));
             $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" >';
         }
         $output .= "\n\t\t" . __("Tags (separate multiple tags with commas: cats, pet food, dogs):", "tdomf");
         $output .= '</label>';
         $output .= "\n\t\t<br/>\n\t\t" . '<input type="text" id="tags" name="tags" size="60" value="';
         $output .= "<?php echo htmlentities(\$tags,ENT_QUOTES,get_bloginfo('charset')); ?>" . '" />';
         $output .= $after_widget;
     }
     return $output;
 }
 tdomf_register_form_widget_hack('tags', __('Tags', 'tdomf'), 'tdomf_widget_tags_hack', array("new-post"));
 ///////////////////////////////////////
 // Validate required tags
 //
 function tdomf_widget_tags_validate($args, $preview)
 {
     extract($args);
     $options = tdomf_widget_tags_options($tdomf_form_id);
     $output = "";
     if ($options['user'] && $options['required']) {
         if (empty($tags)) {
             $output .= __('You must specify at least one tag.', 'tdomf');
         }
     }
     // return output if any
     if ($output != "") {
 /**
  * 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;
 }
            //
            // Grab existing data
            $post = wp_get_single_post($post_ID, ARRAY_A);
            $current_cats = $post['post_category'];
            // Now merge existing categories with new category
            $post_cats = array_merge($current_cats, array($args[$tdomf_getcat_var_name]));
        }
        // Update categories on post
        $post = array("ID" => $post_ID, "post_category" => $post_cats);
        wp_update_post($post);
    }
    // no errors so return NULL
    return NULL;
}
tdomf_register_form_widget_post("getcat", __("Set Category from GET variables", "tdomf"), 'tdomf_widget_getcat_post', true, array("new-post"));
function tdomf_widget_getcat_hack($args)
{
    global $tdomf_getcat_var_name;
    extract($args);
    $getcat = tdomf_get_option_form(TDOMF_DEFAULT_CATEGORY, $tdomf_form_id);
    $output = "\t\t<?php \$getcat = {$getcat};\n";
    $output .= "\t\tif(isset(\$_GET['{$tdomf_getcat_var_name}'])) {\n";
    $output .= "\t\t\t\$getcat = intval(\$_GET['{$tdomf_getcat_var_name}']);\n";
    $output .= "\t\t} else if(isset(\$post_args['{$tdomf_getcat_var_name}'])) {\n";
    $output .= "\t\t\$getcat = intval(\$post_args['{$tdomf_getcat_var_name}']); } ?>\n";
    $output .= "\t\t<div><input type='hidden' name='{$tdomf_getcat_var_name}' id='{$tdomf_getcat_var_name}' value='";
    $output .= "<?php echo \$getcat; ?>' /></div>\n";
    return $output;
}
tdomf_register_form_widget_hack("getcat", __("Set Category from GET variables", "tdomf"), 'tdomf_widget_getcat_hack', array("new-post"));
            $output .= "\t\t\t\$checked = '';\n";
            $output .= "\t\t\tif(isset(\$post_args['comments-user-pings'])){\n";
            $output .= "\t\t\t\t\$checked = 'checked';\n";
            $output .= "\t\t} } ?>\n";
            $output .= "\t\t" . '<input type="checkbox" name="comments-user-pings" id="comments-user-pings"';
            $output .= "<?php echo \$checked; ?>";
            $output .= '>';
            $output .= '<label for="comments-user-pings" >';
            $output .= __("Allow Pings and Trackbacks", "tdomf");
            $output .= "</label>";
        }
        $output .= $after_widget;
    }
    return $output;
}
tdomf_register_form_widget_hack('comments', __('Comments Management', "tdomf"), 'tdomf_widget_comments_hack', $modes = array('new'));
function tdomf_widget_comments_preview($args)
{
    extract($args);
    $options = tdomf_widget_comments_get_options($args['tdomf_form_id']);
    $output = "";
    if ($options['user-comments'] || $options['user-pings']) {
        extract($args);
        $output = $before_widget;
        if (!empty($options['title'])) {
            $output .= $before_title;
            $output .= $options['title'];
            $output .= $after_title;
        }
        if ($options['user-comments']) {
            if (isset($args["comments-user-comments"])) {
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);
        }
    }
}
     $output .= "\t\t\t\t\t\$sc_email = \$_COOKIE['tdomf_subscribe_to_comments_widget_email'];\n";
     $output .= "\t\t\t } } ?>\n";
     $output .= "\t\t\t<br/><label for='subscribe_to_comments_email'";
     if ($options['always_subscribe']) {
         $output .= " class='required'>" . __("Email for comment subscription (required):", "tdomf");
     } else {
         $output .= ">" . __("Email for comment subscription:", "tdomf");
     }
     $output .= ' <input type="text" value="<?php echo htmlentities($sc_email,ENT_QUOTES) ?>" name="subscribe_to_comments_email" id="subscribe_to_comments_email" size="40" /></label>';
     if (!$options['show_email_field']) {
         $output .= "\n\t\t<?php } ?>";
     }
     $output .= $after_widget;
     return $output;
 }
 tdomf_register_form_widget_hack('subscribe_to_comments', __('Subscribe to Comments', "tdomf"), 'tdomf_widget_subscribe_to_comments_hack');
 function tdomf_widget_subscribe_to_comments_validate($args, $preview)
 {
     $options = tdomf_widget_subscribe_to_comments_get_options($args['tdomf_form_id']);
     extract($args);
     if (!$preview) {
         if ((tdomf_widget_notifyme_show_email_input($tdomf_form_id) || $options['show_email_field']) && ($options['always_subscribe'] || $subscribe_to_comments)) {
             if (isset($subscribe_to_comments_email) && !tdomf_check_email_address($subscribe_to_comments_email)) {
                 return $before_widget . __("You must specify a valid email address to send the comment notifications to.", "tdomf") . $after_widget;
             }
         }
     }
     return NULL;
 }
 tdomf_register_form_widget_validate('subscribe_to_comments', __('Subscribe to Comments', "tdomf"), 'tdomf_widget_subscribe_to_comments_validate');
 function tdomf_widget_subscribe_to_comments_post($args)