Example #1
0
            if (is_user_logged_in() && tdomf_check_email_address($current_user->user_email)) {
                $notifyme_email = $current_user->user_email;
            } else {
                if (isset($whoami_email)) {
                    $notifyme_email = $whoami_email;
                } else {
                    tdomf_log_message("Could not find a email address to store for notification!", TDOMF_LOG_ERROR);
                }
            }
        }
        setcookie("tdomf_notify_widget_email", $notifyme_email, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
        add_post_meta($post_ID, TDOMF_KEY_NOTIFY_EMAIL, $notifyme_email, true);
    }
    return NULL;
}
tdomf_register_form_widget_post('notifyme', 'Notify Me', 'tdomf_widget_notifyme_post', $modes = array('new'));
function tdomf_widget_notify_get_message($form_id, $type, $process = false, $post_id = false)
{
    $options = tdomf_get_option_widget('notifyme', $form_id);
    $message = "";
    if ($options == false) {
        switch ($type) {
            case 'approved':
                $message = sprintf(__("This is just a quick email to notify you that your post has been approved and published online. You can see it at %s.\n\n", "tdomf"), TDOMF_MACRO_SUBMISSIONURL);
                $message .= __("Best Regards", "tdomf") . "\n";
                $message .= "<?php echo get_bloginfo(\"title\"); ?>";
                break;
            case 'rejected':
                $message = sprintf(__("We are sorry to inform you that your post \"%s\" has been rejected.\n\n", "tdomf"), TDOMF_MACRO_SUBMISSIONTITLE);
                $message .= __("Best Regards", "tdomf") . "\n";
                $message .= "<?php echo get_bloginfo(\"title\"); ?>";
     if ($options['default']) {
         $tagslist = strip_tags($options['default']);
     }
     if (isset($tags) && !empty($tags)) {
         if (!empty($tagslist)) {
             $tagslist .= ',';
         }
         $tagslist .= strip_tags($tags);
     }
     if (!empty($tagslist)) {
         # set last var to true to just append
         wp_set_post_tags($post_ID, strip_tags($tagslist), false);
     }
     return NULL;
 }
 tdomf_register_form_widget_post('tags', __('Tags', 'tdomf'), 'tdomf_widget_tags_post', array("new-post"));
 //////////////////////////////
 // Control options
 //
 function tdomf_widget_tags_control($form_id)
 {
     $options = tdomf_widget_tags_options($form_id);
     // Store settings for this widget
     if ($_POST['tags-submit']) {
         $newoptions['title'] = strip_tags(stripslashes($_POST['tags-title']));
         $newoptions['required'] = isset($_POST['tags-required']);
         $newoptions['user'] = isset($_POST['tags-user']);
         $newoptions['default'] = $_POST['tags-default'];
         if ($options != $newoptions) {
             $options = $newoptions;
             tdomf_set_option_widget('tdomf_tags_widget', $options, $form_id);
 /**
  * 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;
 }
            // Append to existing categories
            //
            // 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"));
            $comment_status = 'open';
        }
    }
    if ($options['user-pings']) {
        $ping_status = 'closed';
        if (isset($args['comments-user-pings'])) {
            $ping_status = 'open';
        }
    }
    if ($options['overwrite'] || $options['user-pings'] || $options['user-comments']) {
        $post = array("ID" => $post_ID, "comment_status" => $comment_status, "ping_status" => $ping_status);
        wp_update_post($post);
    }
    return NULL;
}
tdomf_register_form_widget_post('comments', __('Comments Management', "tdomf"), 'tdomf_widget_comments_post', $modes = array('new'));
function tdomf_widget_comments_get_options($form_id)
{
    $options = tdomf_get_option_widget('tdomf_comment_widget', $form_id);
    if ($options == false) {
        $options = array();
        $options['title'] = "";
        $options['overwrite'] = false;
        $options['comments'] = get_option('default_comment_status');
        $options['pings'] = get_option('default_ping_status');
        $options['user-comments'] = false;
        $options['user-pings'] = false;
    }
    return $options;
}
function tdomf_widget_comments_control($form_id)
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);
        }
    }
}
                        $errors = $err . "<br/>";
                    }
                    return $error;
                } else {
                    return $sg_subscribe->errors['solo_subscribe'][0];
                }
            }*/
         // this is how subscibe to email works
         add_post_meta($post_ID, '_sg_subscribe-to-comments', $subscribe_to_comments_email);
         // set comment email so that you can "unsubscribe"
         setcookie('comment_author_email_' . COOKIEHASH, $subscribe_to_comments_email, time() + 30000000, COOKIEPATH);
         setcookie('tdomf_subscribe_to_comments_widget_email', $subscribe_to_comments_email, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
     }
     return NULL;
 }
 tdomf_register_form_widget_post('subscribe_to_comments', __('Subscribe to Comments', "tdomf"), 'tdomf_widget_subscribe_to_comments_post');
 function tdomf_widget_subscribe_to_comments_get_options($form_id)
 {
     $options = tdomf_get_option_widget('tdomf_subscribe_to_comments_widget', $form_id);
     if ($options == false) {
         $options = array();
         $options['title'] = "";
         $options['show_email_field'] = false;
         $options['always_subscribe'] = false;
     }
     return $options;
 }
 function tdomf_widget_subscribe_to_comments_control($form_id)
 {
     $options = tdomf_widget_subscribe_to_comments_get_options($form_id);
     // Store settings for this widget