WordPress.org

Plugin Directory

Changeset 487351


Ignore:
Timestamp:
01/10/12 05:20:19 (2 years ago)
Author:
ryelle
Message:

adding 3.0

Location:
post-from-site
Files:
12 added
6 edited

Legend:

Unmodified
Added
Removed
  • post-from-site/trunk/includes/minimal.css

    r432018 r487351  
     1/* Tried getting an in-admin link... didn't work well. todo for later version? 
    12#wpadminbar .quicklinks #wp-admin-bar-post_from_site ul { 
    23    width:550px; 
     
    1920    background:white; 
    2021} 
     22*/ 
    2123 
    2224.pfs_postform { 
     
    2527} 
    2628.pfs-post-box{ 
    27     background-color:#ddd; 
    28     border:1px solid #d3d3d3; 
    29     -moz-border-radius:3px; 
    30     -webkit-border-radius:3px; 
    31     border-radius:3px; 
     29    background-color:white; 
    3230    position:absolute; 
    3331    width:600px; 
    34     z-index:100; 
     32    z-index:9999; 
    3533    padding:20px 20px 10px; 
    36     font-family:Verdana,Arial,"Bitstream Vera Sans",sans-serif; 
    37     font-size:12px; 
    38     line-height:18px; 
    39     font-weight:normal; 
    4034} 
    41 .pfs_postform { 
    42     color:#522A00; 
     35#pfs_form .input-text { 
     36    display: block; 
     37    width: 97%; 
    4338} 
    44 .pfs-post-box .closex { 
    45     position:absolute; 
    46     top:0; 
    47     right:0; 
    48     font-size:25px; 
    49     line-height:13px; 
    50     font-weight:bold; 
    51     text-decoration:none; 
    52     color:#EEE; 
    53     text-shadow: 0 1px 3px rgba(204, 204, 204, 0.95); 
    54     padding:5px; 
    55     margin:15px; 
    56     cursor:pointer; 
     39#recaptcha_response_field { left:0 !important; } 
     40#recaptcha_area input { 
     41    text-indent: 0; 
     42    margin: 0; 
    5743} 
    58 .pfs-post-box input[type=text], .pfs-post-box textarea { 
    59     background: none repeat scroll 0 0 #FFFFFF; 
    60     border: 4px solid #EEEEEE; 
    61     border-radius: 5px 5px 5px 5px; 
    62     box-shadow: 0 1px 3px rgba(204, 204, 204, 0.95) inset; 
    63     padding: 10px; 
    64     position: relative; 
    65     text-indent: 80px; 
    66     width:95%; 
     44#recaptcha_area label { 
     45    margin:0; 
    6746} 
    68 .pfs-post-box input[type=text] { 
    69    display: block; 
    70     height: 24px; 
    71 } 
    72 .pfs-post-box textarea { 
    73     resize: vertical; 
    74 } 
    75 .pfs-post-box label { 
    76     background: none repeat scroll 0 0 #EEEEEE; 
    77     box-shadow: 1px 2px 2px rgba(204, 204, 204, 0.8); 
    78     color: #555555; 
    79     display: inline-block; 
    80     font-size: 13px; 
    81     left: 4px; 
    82     min-width: 60px; 
    83     padding: 4px 10px; 
    84     position: relative; 
    85     top: 40px; 
    86     z-index: 1; 
    87     line-height:2.2em; 
    88 } 
    89 .pfs-post-box input.submit { 
    90     background: none repeat scroll 0 0 #222222; 
    91     border: medium none; 
    92     border-radius: 3px 3px 3px 3px; 
    93     box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); 
    94     color: #EEEEEE; 
    95     cursor: pointer; 
    96     font-size: 15px; 
    97     left: 30px; 
    98     margin: 20px 0; 
    99     padding: 5px 42px 5px 22px; 
    100     position: relative; 
    101     text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3); 
    102 } 
    103  
    104 #recaptcha_response_field { left:0 !important; } 
    10547 
    10648#alert,.error{ 
  • post-from-site/trunk/includes/pfs-script.js

    r432018 r487351  
    22    jQuery(".pfs-post-link").click(function(){ 
    33        var $box = jQuery(this).siblings('div'); 
    4         var top = ( jQuery(window).height() - $box.height() )/2; 
    5         var left = ( jQuery(window).width() - $box.width() )/2; 
     4        if ('relative' == jQuery(this).parents('article').css('position')) { 
     5            var top = 0; 
     6            var diff = jQuery(this).parents('article').offset(); 
     7            var left = ( jQuery(window).width() - $box.width() )/2 - diff.left;  
     8        } else { 
     9            var top = 90; 
     10            var left = ( jQuery(window).width() - $box.width() )/2; 
     11        } 
    612        if (top<0) top = 50; 
    713        $box.css({top:top+"px",left:left+"px"}).show(); 
    8          
    914    }); 
    1015    jQuery(".closex").click(function(){ 
     
    2227                data = jQuery.parseJSON(request.responseText); 
    2328                if (data && data.error) { 
     29                    //alert(data); 
    2430                    jQuery('#pfs-alert').addClass('error').html('<p>'+data.error+'</p>').show(); 
    2531                    jQuery('.pfs-post-form #post').val('Post'); 
  • post-from-site/trunk/pfs-submit.php

    r432018 r487351  
    66 */ 
    77require('../../../wp-load.php'); 
     8error_reporting(E_ALL); 
     9ini_set('display_errors',1); 
    810 
    911/** 
     
    1416 */ 
    1517function pfs_submit($post,$files){ 
    16     $pfs_options = get_option('pfs_options'); 
     18    $pfs_options_arr = get_option('pfs_options'); 
     19    $pfs_options = $pfs_options_arr[0]; 
    1720    $pfs_data = $post; 
    1821    $pfs_files = $files; 
    19     $pfs_options = get_option('pfs_options'); 
    2022    //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($pfs_data, true)."</pre>\n"; 
    2123    //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($pfs_files, true)."</pre>\n"; 
     
    2325    $title = $pfs_data['title']; 
    2426    $postcontent = $pfs_data['postcontent']; 
    25     $name = wp_kses($pfs_data['name'],array()); 
    26     $email = wp_kses($pfs_data['email'],array()); 
    27     $cats = array(5); 
    28     $newcats = ''; 
    29     $tags = ''; 
    30     $newtags = ''; 
     27     
     28    $name = (array_key_exists('name',$pfs_data)) ? esc_html($pfs_data['name'],array()) : ''; 
     29    $email = (array_key_exists('email',$pfs_data)) ? sanitize_email($pfs_data['email']) : ''; 
     30     
     31    $taxonomies = array(); 
    3132 
    3233    $imgAllowed = 0; 
     
    3839    ); 
    3940    $success = False; 
    40     require_once('recaptchalib.php'); 
    41     $privatekey = "6LfvqcASAAAAAALRhWqQkH2IQ8IqnbJY637X1-1p"; 
    42     $resp = recaptcha_check_answer ($privatekey, 
    43                                 $_SERVER["REMOTE_ADDR"], 
    44                                 $_POST["recaptcha_challenge_field"], 
    45                                 $_POST["recaptcha_response_field"]); 
    46      
    47     if (!$resp->is_valid) { 
     41    $upload = False; 
     42     
     43    if ( !current_user_can('publish_posts') && $pfs_options['allow_anon'] && $pfs_options['enable_captcha'] ){ 
     44        require_once('recaptchalib.php'); 
     45        $privatekey = $pfs_options_arr['recaptcha_private_key']; 
     46        $resp = recaptcha_check_answer ($privatekey, 
     47                                    $_SERVER["REMOTE_ADDR"], 
     48                                    $_POST["recaptcha_challenge_field"], 
     49                                    $_POST["recaptcha_response_field"]); 
     50    } 
     51    if ( !current_user_can('publish_posts') && $pfs_options['allow_anon'] && $pfs_options['enable_captcha'] && !$resp->is_valid ) { 
    4852        // What happens when the CAPTCHA was entered incorrectly 
    49         $result['error'] = "Incorrect reCAPTCHA: " . $resp->error; 
     53        $result['error'] = printf(__("Incorrect reCAPTCHA: %s",'pfs_domain'), $resp->error); 
    5054    } else { 
     55        //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($pfs_files['image']['name'], true)."</pre>\n"; 
    5156        if (array_key_exists('image',$pfs_files)) {  
    5257            /* play with the image */ 
     
    6065                        $imgAllowed = (getimagesize($file['tmp_name'][$i])) ? True : (''==$file['name'][$i]); 
    6166                        if ($imgAllowed){ 
    62                             upload_image(array('name'=>$pfs_files["image"]["name"][$i], 'tmp_name'=>$pfs_files["image"]["tmp_name"][$i])); 
     67                            $upload[$i+1] = upload_image(array('name'=>$pfs_files["image"]["name"][$i], 'tmp_name'=>$pfs_files["image"]["tmp_name"][$i])); 
     68                            if (False === $upload[$i+1]){ 
     69                                $result['error'] = __("There was an error uploading the image.",'pfs_domain'); 
     70                            } else { 
     71                                $success[$i+1] = True; 
     72                            } 
    6373                        } else { 
    64                             $result['error'] = "Incorrect filetype. Only images (.gif, .png, .jpg, .jpeg) are allowed."; 
     74                            $result['error'] = __("Incorrect filetype. Only images (.gif, .png, .jpg, .jpeg) are allowed.",'pfs_domain'); 
    6575                        } 
    6676                    } 
     
    7383                $imgAllowed = (getimagesize($file['tmp_name'][0])) ? True : (''==$file['name'][0]); 
    7484                if ($imgAllowed){ 
    75                     $upload[1] = wp_upload_bits($file["name"][0], null, file_get_contents($file["tmp_name"][0])); 
     85                    $upload[1] = upload_image( array( 'name'=>$file["name"][0], 'tmp_name'=>$file["tmp_name"][0] ) ); 
    7686                    //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($upload, true)."</pre>\n"; 
    77                     if (False === $upload[1]['error']){ 
     87                    if (False === $upload[1]){ 
     88                        $result['error'] = __("There was an error uploading the image.",'pfs_domain'); 
     89                    } else { 
    7890                        $success[1] = True; 
    79                     } else { 
    80                         $result['error'] = "There was an error uploading the image: {$upload[1]['error']}"; 
    81                         return $result; 
    8291                    } 
    8392                } else { 
    84                     $result['error'] = "Incorrect filetype. Only images (.gif, .png, .jpg, .jpeg) are allowed."; 
     93                    $result['error'] = __("Incorrect filetype. Only images (.gif, .png, .jpg, .jpeg) are allowed.",'pfs_domain'); 
    8594                } 
    8695                break; 
     
    8998            } 
    9099        } 
    91         if ( ('' != $result['error']) && ($pfs_options['pfs_imgfaildie']) )return $result; 
     100        if ( '' != $result['error'] ) return $result; // fail if the image upload failed. 
     101         
    92102        //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($upload, true)."</pre>\n"; 
    93103        //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($success, true)."</pre>\n"; 
     104         
    94105        /* manipulate $pfs_data into proper post array */ 
    95         if ($title != '' && $postcontent != '' && $name != '' && $email != '') { 
    96             $content = $postcontent."<p>Suggested by <a href='mailto:$email'>$name</a></p>"; 
    97             global $user_ID; 
    98             get_currentuserinfo(); 
     106        $has_content_things = ($title != '') && ($postcontent != ''); 
     107        if ( !current_user_can('publish_posts') && $pfs_options['allow_anon'] ) $has_content_things = $has_content_things && ($name != '') && is_email($email); 
     108        if ( $has_content_things ) { 
     109            $content = $postcontent; 
     110            if ( !current_user_can('publish_posts') && $pfs_options['allow_anon'] ) $content .= apply_filters('pfs_submittedby_text',"<p>Submitted by <a href='mailto:$email'>$name</a></p>"); 
     111            if ( is_user_logged_in() ){ 
     112                global $user_ID; 
     113                get_currentuserinfo(); 
     114            } 
    99115            if (is_array($success)){ 
    100116                foreach(array_keys($success) as $i){ 
    101                     //$i++; 
    102117                    $imgtag = "[!--image$i--]"; 
    103                     if (False === strpos($content,$imgtag)) $content .= "<br />$imgtag"; 
    104                     $content = str_replace($imgtag, "<img src='{$upload[$i]['url']}' class='pfs-image' />", $content); 
     118                    if (False === strpos($content,$imgtag)) $content .= "\n\n$imgtag"; 
     119                    $content = str_replace($imgtag, wp_get_attachment_link( $upload[$i], $pfs_options['wp_image_size']), $content); 
    105120                } 
    106             } else { 
    107                 /* success is always an array if there was an image upload. If it's not an array, there was no image. 
    108                 $imgtag = "[!--image1--]"; 
    109                 if (False === strpos($content,$imgtag)) $content .= "<br />$imgtag"; 
    110                 $content = str_replace($imgtag, "<img src='{$upload[1]['url']}' class='pfs-image' />", $content); 
    111                 */ 
    112             } 
     121            }  
    113122            //if any [!--image#--] tags remain, they are invalid and should just be deleted. 
    114123            $content = preg_replace('/\[\!--image\d*--\]/','',$content); 
    115             $categories = $cats; 
    116             $newcats = explode(',',$newcats); 
    117             foreach ($newcats as $cat) $categories[] = wp_insert_category(array('cat_name' => trim($cat), 'category_parent' => 0)); 
    118             $newtags = explode(',',$newtags); 
    119             foreach ($newtags as $tag) { 
    120                 wp_create_tag(trim($tag)); 
    121                 $tags[] = trim($tag); 
    122             } 
     124 
     125            // $terms[{tax name}] = array(term1, term2, etc) 
     126            if ( array_key_exists('terms',$pfs_data) ) { 
     127                foreach ($pfs_data['terms'] as $taxon => $terms){ 
     128                    if ( !is_taxonomy_hierarchical($taxon) ) { 
     129                        $pfs_data['terms'][$taxon] = implode(',',$terms); 
     130                    } 
     131                } 
     132            } 
     133 
    123134            $postarr = array(); 
    124135            $postarr['post_title'] = $title; 
    125136            $postarr['post_content'] = apply_filters('comment_text', $content); 
    126             $postarr['comment_status'] = $pfs_options['pfs_comment_status']; 
    127             $postarr['post_status'] = $pfs_options['pfs_post_status']; 
    128             $postarr['post_author'] = 5; //$user_ID; 
    129             $postarr['post_category'] = $categories; 
    130             $postarr['tags_input'] = implode(',',$tags); 
    131             $postarr['post_type'] = $pfs_options['pfs_post_type']; 
     137            $postarr['comment_status'] = $pfs_options['comment_status']; 
     138            $postarr['post_status'] = $pfs_options['post_status']; 
     139            $postarr['post_author'] = ( is_user_logged_in() ) ? $user_ID : $pfs_options['default_author']; 
     140            $postarr['tax_input'] = (array_key_exists('terms',$pfs_data)) ? $pfs_data['terms'] : array(); 
     141            $postarr['post_type'] = $pfs_options['post_type']; 
    132142            //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($postarr, true)."</pre>\n"; 
    133143            $post_id = wp_insert_post($postarr); 
     
    151161function upload_image($image){ 
    152162    $file = wp_upload_bits( $image["name"], null, file_get_contents($image["tmp_name"])); 
     163    //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">"; 
     164    //var_dump($file); 
     165    //echo "</pre>\n"; 
    153166    if (false === $file['error']) { 
    154167        $wp_filetype = wp_check_filetype(basename($file['file']), null ); 
     
    168181    } else { 
    169182        //TODO: er, error handling? 
    170         return "error"; 
     183        return false; 
    171184    } 
    172185} 
     
    178191} else { 
    179192    /* TODO: translate following */ 
    180     echo "You should not be seeing this page, something went wrong. <a href='".get_bloginfo('url')."'>Go home</a>?"; 
     193    _e('You should not be seeing this page, something went wrong.','pfs_domain'); 
     194    echo "<a href='".get_bloginfo('url')."'>" . __('Go home?','pfs_domain') . "</a>"; 
    181195} 
    182196 
  • post-from-site/trunk/pfs-widget.php

    r432018 r487351  
    11<?php 
     2// register PfsWidget widget 
     3add_action('widgets_init', create_function('', 'return register_widget("PfsWidget");')); 
     4 
    25/** 
    36 * Post From Site extends the widget class to create widget. 
     
    1922        if ( $title ) echo $before_title . $title . $after_title; 
    2023        echo "<ul><li>"; 
    21         $pfs = new PostFromSite($category,$link,$popup); 
     24        $pfs = new PostFromSite(0,$link,$popup,$category); 
    2225        $pfs->form(); 
    2326        echo "</li></ul>"; 
     
    3639 
    3740    /** @see WP_Widget::form */ 
    38     function form($instance) {               
    39         $title = esc_attr($instance['title']); 
    40         $category = esc_attr($instance['category']); 
    41         $link = esc_attr($instance['link']); 
    42         $popup = $instance['popup']; 
     41    function form($instance) { 
     42        if ( $instance ) { 
     43            $title = esc_attr($instance['title']); 
     44            $category = esc_attr($instance['category']); 
     45            $link = esc_attr($instance['link']); 
     46            $popup = $instance['popup']; 
     47        } else { 
     48            $title = ''; 
     49            $category = ''; 
     50            $link = ''; 
     51            $popup = 0; 
     52        } 
    4353        ?> 
    4454        <p><label for="<?php echo $this->get_field_id('title'); ?>"> 
     
    7080    <?php } 
    7181} // class PfsWidget 
    72  
    73  
    74 // register PfsWidget widget 
    75 add_action('widgets_init', create_function('', 'return register_widget("PfsWidget");')); 
    7682?> 
  • post-from-site/trunk/post-from-site.class.php

    r432018 r487351  
    33 * Plugin Name: Post From Site 
    44 * Plugin URI: http://me.redradar.net/category/plugins/post-from-site/ 
    5  * Description: Add a new post directly from your website - no need to go to the admin side. 
     5 * Description: Add a new post/page/{your custom post type} directly from your website. 
    66 * Author: Kelly Dwan 
    7  * Version: 2.1.1 
    8  * Date: 07.17.11 
     7 * Version: 3.0.0 
     8 * Date: 11.20.11 
    99 * Author URI: http://me.redradar.net/ 
    1010 */ 
     
    1212/* 
    1313TODO 
    14 style popup & non popup boxes 
    15 add filters/actions 
    16 put link in admin bar, and post-box slides down. -- call it 3.0. remove settings, most 
     14    Focus in Chrome 
     15    Move over to using WP's AJAX handling 
     16    Add ability to post from the toolbar? 
    1717*/ 
    1818 
     
    2323class PostFromSite { 
    2424    /* global variables */ 
    25     protected $cat = ''; 
    2625    protected $linktext = ''; 
    2726    protected $popup = true; 
     27    protected $cat = ''; 
     28    protected $form_id = 0; 
    2829     
    29     public function __construct($cat = '', $linktext = '', $popup = true) { 
    30         $this->cat = $cat; 
     30    public function __construct($id = 0, $linktext = '', $popup = true, $cat = '') { 
     31        $this->form_id = $id; 
    3132        $this->linktext = $linktext; 
    3233        $this->popup = $popup; 
     34        $this->cat = $cat; 
    3335     
    3436        register_activation_hook( __FILE__, array($this,'install') ); 
     
    3739        load_plugin_textdomain('pfs_domain'); 
    3840         
    39         // add pfs_options group & apply validation filter 
    40         register_setting( 'pfs_options', 'pfs_options', array($this, 'validate') ); 
     41        // add pfs_options group & apply validation filter, add settings fields & section 
     42        add_action('admin_init', array($this, 'admin_init') ); 
    4143         
    4244        // add js & css 
     
    4951        add_shortcode( 'post-from-site', array($this, 'shortcode') ); 
    5052         
    51         // add admin menu item 
    52         add_action( 'admin_bar_menu', array($this, 'add_admin_link'), 1000 ); 
     53        // add admin menu item. Probably not going to happen. 
     54        //add_action( 'admin_bar_menu', array($this, 'add_admin_link'), 1000 ); 
    5355    } 
    5456     
     
    5759    } 
    5860 
    59     /** 
    60      * Sanitize and validate input.  
    61      * @param array $input an array to sanitize 
    62      * @return array a valid array. 
    63      */ 
    64     public function validate($input) { 
    65         $ok = Array('publish','pending','draft'); 
    66         $input['pfs_linktext'] = wp_filter_nohtml_kses($input['pfs_linktext']); 
    67         $input['pfs_excats'] = wp_filter_nohtml_kses($input['pfs_excats']);; 
    68         $input['pfs_allowimg'] = ($input['pfs_allowimg'] == 1 ? 1 : 0); 
    69         $input['pfs_imgfaildie'] = ($input['pfs_imgfaildie'] == 1 ? 1 : 0); 
    70         $input['pfs_allowtag'] = ($input['pfs_allowtag'] == 1 ? 1 : 0); 
    71         $input['pfs_post_status'] = (in_array($input['pfs_post_status'],$ok) ? $input['pfs_post_status'] : 'pending'); 
    72         $input['pfs_post_type'] = (post_type_exists($input['pfs_post_type']) ? $input['pfs_post_type'] : 'post'); 
    73         $input['pfs_comment_status'] = ($input['pfs_comment_status'] == 'open' ? 'open' : 'closed'); 
    74         $input['pfs_maxfilesize'] = intval($input['pfs_maxfilesize']); 
    75         $input['enablecaptcha'] = ($input['enablecaptcha'] == 1 ? 1 : 0); 
    76         $input['pfs_allow_anon'] = ($input['pfs_allow_anon'] == 1 ? 1 : 0); 
    77         return $input; 
    78     } 
    79  
    80     /** 
    81      * Add javascript and css to header files. 
    82      */ 
    83     public function includes(){ 
    84         wp_enqueue_script( 'jquery-multi-upload', plugins_url("includes/jquery.MultiFile.pack.js",__FILE__), array('jquery','jquery-form') ); 
    85         wp_enqueue_script( 'pfs-script', plugins_url("includes/pfs-script.js",__FILE__) ); 
    86         //wp_enqueue_style( 'pfs-style',  plugins_url("includes/pfs-style.php",__FILE__) ); 
    87         wp_enqueue_style( 'pfs-min-style',  plugins_url("includes/minimal.css",__FILE__) ); 
    88     } 
    89      
    9061    /** 
    9162     * Add options to databases with defaults 
     
    9566         
    9667        if (!get_option("pfs_options")) { 
    97             $pfs_options['pfs_linktext'] = 'quick post'; 
    98             $pfs_options['pfs_excats'] = ''; 
    99             $pfs_options['pfs_allowimg'] = 1; 
    100             $pfs_options['pfs_imgfaildie'] = 1; 
    101             $pfs_options['pfs_allowtag'] = 1; 
    102             $pfs_options['pfs_post_status'] = 'publish'; 
    103             $pfs_options['pfs_post_type'] = 'post'; 
    104             $pfs_options['pfs_comment_status'] = 'open'; 
    105             $pfs_options['pfs_maxfilesize'] = 3000000; 
    106             $pfs_options['enablecaptcha'] = false; 
    107             $pfs_options['pfs_allow_anon'] = false; 
    108             add_option ("pfs_options", $pfs_options) ; 
     68            $options= array( 0 => array() ); 
     69            $options[0]['default_author'] = ''; 
     70            $options[0]['allow_image'] = true; 
     71            $options[0]['wp_image_size'] = 'medium'; 
     72             
     73            $options[0]['post_status'] = 'publish'; 
     74            $options[0]['post_type'] = 'post'; 
     75            $options[0]['comment_status'] = 'open'; 
     76            $options[0]['taxonomy'] = array(); 
     77             
     78            $options[0]['enable_captcha'] = false; 
     79            $options[0]['allow_anon'] = false; 
     80            $options['recaptcha_public_key'] = ''; 
     81            $options['recaptcha_private_key'] = ''; 
     82            add_option ("pfs_options", $options) ; 
    10983        } 
     84    } 
     85     
     86    /** 
     87     * What to display in the admin menu 
     88     */ 
     89    public function settings() { ?> 
     90        <div class="wrap pfs"> 
     91            <h2><?php _e('Post From Site Settings','pfs_domain'); ?></h2> 
     92     
     93            <form method="post" action="options.php" id="options"> 
     94                <?php settings_fields('pfs_options'); ?> 
     95                 
     96                <?php do_settings_sections('pfs'); ?> 
     97                 
     98                <?php submit_button(); ?> 
     99            </form> 
     100             
     101        </div> 
     102    <?php  
     103    } 
     104 
     105    function admin_init(){ 
     106        register_setting( 'pfs_options', 'pfs_options', array($this, 'validate') ); 
     107        add_settings_section('pfs_users', 'User Settings', array($this, 'setting_section_users'), 'pfs'); 
     108        add_settings_field('pfs_allow_anon', 'Allow anonymous (not logged in) users to create posts?', array($this, 'setting_allow_anon'), 'pfs', 'pfs_users'); 
     109        add_settings_field('pfs_default_user', 'Posts by anonymous users should be created by this author:<br /><small><a href="user-new.php">Create new user?</a></small>', array($this, 'setting_default_author'), 'pfs', 'pfs_users'); 
     110        add_settings_field('pfs_enable_captcha', 'Enable <a href="http://www.google.com/recaptcha">Recaptcha</a> for not logged in users? (recommended)', array($this, 'setting_enable_captcha'), 'pfs', 'pfs_users'); 
     111        add_settings_field('pfs_recaptcha_public_key', '<a href="http://www.google.com/recaptcha">Recaptcha API</a> public key:', array($this, 'setting_recaptcha_public_key'), 'pfs', 'pfs_users'); 
     112        add_settings_field('pfs_recaptcha_private_key', '<a href="http://www.google.com/recaptcha">Recaptcha API</a> private key:', array($this, 'setting_recaptcha_private_key'), 'pfs', 'pfs_users'); 
     113 
     114        add_settings_section('pfs_post', 'Post Creation Settings', array($this, 'setting_section_post'), 'pfs'); 
     115        add_settings_field('pfs_post_status', 'Post status:', array($this, 'setting_post_status'), 'pfs', 'pfs_post'); 
     116        add_settings_field('pfs_post_type', 'Post type:<br /><small><a href="http://codex.wordpress.org/Custom_Post_Types">Custom Post Types</a> supported!</small>', array($this, 'setting_post_type'), 'pfs', 'pfs_post'); 
     117        add_settings_field('pfs_comment_status', 'Comment status:', array($this, 'setting_comment_status'), 'pfs', 'pfs_post'); 
     118        add_settings_field('pfs_taxonomy', 'Allowed taxonomies:', array($this, 'setting_taxonomy'), 'pfs', 'pfs_post'); 
     119                         
     120        add_settings_section('pfs_image', 'Image Upload Settings', array($this, 'setting_section_image'), 'pfs'); 
     121        add_settings_field('pfs_allow_image', 'Allow users to upload an image?', array($this, 'setting_allow_image'), 'pfs', 'pfs_image'); 
     122        add_settings_field('pfs_wp_image_size', 'Image size setting to use:', array($this, 'setting_wp_image_size'), 'pfs', 'pfs_image'); 
     123         
     124 
     125    } 
     126    function setting_section_users() { 
     127        echo '<p>By default, all logged-in users can use the post-from-site interface to create a post.</p>'; 
     128    } 
     129    function setting_allow_anon() { 
     130        $options = get_option('pfs_options'); 
     131        $options = $options[0]; 
     132        echo "<input id='pfs_allow_anon' name='pfs_options[0][allow_anon]' size='40' type='checkbox' value='1' "; 
     133        if ( $options['allow_anon'] == true ) echo "checked='checked'"; 
     134        echo "/>"; 
     135    } 
     136    function setting_default_author() { 
     137        $options = get_option('pfs_options'); 
     138        $options = $options[0]; 
     139        /* listing of authors */ 
     140        wp_dropdown_users( array( 
     141            'blog_id' => get_current_blog_id(), 
     142            'name' => 'pfs_options[0][default_author]', 
     143            'id' => 'pfs_default_author', 
     144            'selected' => $options['default_author'] 
     145        ) ); 
     146    } 
     147    function setting_enable_captcha() { 
     148        $options = get_option('pfs_options'); 
     149        $options = $options[0]; 
     150        echo "<input id='pfs_enable_captcha' name='pfs_options[0][enable_captcha]' size='40' type='checkbox' value='1' "; 
     151        if ( $options['enable_captcha'] == true ) echo "checked='checked'"; 
     152        echo "/>"; 
     153    } 
     154    function setting_recaptcha_public_key() { 
     155        $options = get_option('pfs_options'); 
     156        echo "<input id='pfs_recaptcha_public_key' name='pfs_options[recaptcha_public_key]' size='40' type='text' value='{$options['recaptcha_public_key']}' />"; 
     157    } 
     158    function setting_recaptcha_private_key() { 
     159        $options = get_option('pfs_options'); 
     160        echo "<input id='pfs_recaptcha_private_key' name='pfs_options[recaptcha_private_key]' size='40' type='text' value='{$options['recaptcha_private_key']}' />"; 
     161    } 
     162 
     163    function setting_section_post() { 
     164        echo '<p>Settings for posts created by Post From Site. Defaults to a published Post with comments open, and no taxonomies.</p>'; 
     165    } 
     166    function setting_post_status() { 
     167        $options = get_option('pfs_options'); 
     168        $options = $options[0]; 
     169        echo "<select name='pfs_options[0][post_status]'>"; 
     170        echo "<option value='draft' "; 
     171        echo ('draft' == $options['post_status']) ? 'selected' : '' ; 
     172        echo ">". __('Draft','pfs_domain')."</option>"; 
     173        echo "<option value='pending' "; 
     174        echo ('pending' == $options['post_status']) ? 'selected' : '' ; 
     175        echo ">".__('Pending','pfs_domain')."</option>"; 
     176        echo "<option value='publish' "; 
     177        echo ('publish' == $options['post_status']) ? 'selected' : '' ; 
     178        echo ">". __('Publish','pfs_domain')."</option>"; 
     179        echo "</select>"; 
     180    } 
     181    function setting_post_type() { 
     182        $options = get_option('pfs_options'); 
     183        $options = $options[0]; 
     184        echo "<select id='pfs_post_type' name='pfs_options[0][post_type]'>"; 
     185        $post_types = get_post_types(array('public'=>true),'object');  
     186        foreach ($post_types as $post_type ) { 
     187            if ("attachment" == $post_type->name) continue; 
     188            if ($post_type->name == $options['post_type']) { 
     189                echo '<option value="'.$post_type->name.'" selected>'.$post_type->labels->singular_name.'</option>'; 
     190            } else { 
     191                echo '<option value="'.$post_type->name.'">'.$post_type->labels->singular_name.'</option>'; 
     192            } 
     193        } 
     194        echo "</select>"; 
     195    } 
     196    function setting_comment_status() { 
     197        $options = get_option('pfs_options'); 
     198        $options = $options[0]; 
     199        echo "<select id='pfs_comment_status' name='pfs_options[0][comment_status]'>"; 
     200        echo "<option value='closed' "; 
     201        echo ('closed' == $options['comment_status']) ? 'selected' : '' ; 
     202        echo ">".__('Closed','pfs_domain')."</option>"; 
     203        echo "<option value='open' "; 
     204        echo ('open' == $options['comment_status']) ? 'selected' : '' ; 
     205        echo ">".__('Open','pfs_domain')."</option>"; 
     206        echo "</select>"; 
     207    } 
     208    function setting_taxonomy() { 
     209        $options = get_option('pfs_options'); 
     210        $options = $options[0]; 
     211        $taxonomies = get_taxonomies(array( 'public' => true ),'object');  
     212        echo "<ul>"; 
     213        foreach ($taxonomies as $taxonomy ) { 
     214          echo '<li><label><input type="checkbox" name="pfs_options[0][taxonomy][]" value="'.$taxonomy->name.'" '; 
     215          if ( array_key_exists('taxonomy',$options) && is_array($options['taxonomy']) && in_array($taxonomy->name, $options['taxonomy']) ) echo ' checked="checked"'; 
     216          echo '/> '. $taxonomy->labels->name. '</label></li>'; 
     217        } 
     218        echo "</ul>"; 
     219    } 
     220 
     221    function setting_section_image() { 
     222        echo '<p>Main description of this section here.</p>'; 
     223    } 
     224    function setting_allow_image() { 
     225        $options = get_option('pfs_options'); 
     226        $options = $options[0]; 
     227        echo "<input id='pfs_allow_image' name='pfs_options[0][allow_image]' size='40' type='checkbox' value='1' "; 
     228        if ( $options['allow_image'] == 1 ) echo "checked='checked'"; 
     229        echo "/>"; 
     230    } 
     231    function setting_wp_image_size() { 
     232        $options = get_option('pfs_options'); 
     233        $options = $options[0]; 
     234        $sizes = get_intermediate_image_sizes(); 
     235        echo "<select id='pfs_wp_image_size' name='pfs_options[0][wp_image_size]'>"; 
     236        foreach ($sizes as $size ) { 
     237            if ($size == $options['wp_image_size']) { 
     238                echo '<option value="'.$size.'" selected>'.$size.'</option>'; 
     239            } else { 
     240                echo '<option value="'.$size.'">'.$size.'</option>'; 
     241            } 
     242        } 
     243        echo "</select>"; 
     244    } 
     245 
     246    /** 
     247     * Sanitize and validate input.  
     248     * @param array $input an array to sanitize 
     249     * @return array a valid array. 
     250     */ 
     251    public function validate($input) { 
     252        $ok = array('publish','pending','draft'); 
     253        $users = array(); 
     254        $user_objs = get_users( array( 
     255            'blog_id'   => $GLOBALS['blog_id'], 
     256            'fields'    => array( 'ID', 'user_login' ) 
     257        ) ); 
     258        foreach ( $user_objs as $u ){ 
     259            $users[] = $u->ID; 
     260        } 
     261 
     262        foreach ($input as $i => $val) { 
     263            if (is_array($val)){ 
     264                $input[$i]['allow_anon'] = array_key_exists('allow_anon',$val); 
     265                $input[$i]['default_author'] = (in_array($val['default_author'], $users)) ? $val['default_author'] : 'anon' ; 
     266                $input[$i]['enable_captcha'] = array_key_exists('enable_captcha',$val); 
     267 
     268                $input[$i]['post_status'] = (in_array($val['post_status'],$ok) ? $val['post_status'] : 'pending'); 
     269                $input[$i]['post_type'] = (post_type_exists($val['post_type']) ? $val['post_type'] : 'post'); 
     270                $input[$i]['comment_status'] = ($val['comment_status'] == 'open' ? 'open' : 'closed'); 
     271                if ( array_key_exists('taxonomy',$val) ){ 
     272                    foreach ( $input[$i]['taxonomy'] as $j => $tax) { 
     273                        if (!taxonomy_exists($tax)) { 
     274                            unset($input[$i]['taxonomy'][$j]); 
     275                        } 
     276                    } 
     277                } 
     278                 
     279                $input[$i]['allow_image'] = array_key_exists('allow_image', $val); 
     280                $input[$i]['wp_image_size'] = (in_array($val['wp_image_size'],get_intermediate_image_sizes())) ? $val['wp_image_size'] : 'medium'; 
     281            } 
     282        } 
     283        $input['recaptcha_public_key'] = urlencode($input['recaptcha_public_key']); 
     284        $input['recaptcha_private_key'] = urlencode($input['recaptcha_private_key']); 
     285        return $input; 
     286    } 
     287 
     288    /** 
     289     * Add javascript and css to header files. 
     290     */ 
     291    public function includes(){ 
     292        wp_enqueue_script( 'jquery-multi-upload', plugins_url("includes/jquery.MultiFile.pack.js",__FILE__), array('jquery','jquery-form') ); 
     293        wp_enqueue_script( 'pfs-script', plugins_url("includes/pfs-script.js",__FILE__) ); 
     294        wp_enqueue_style( 'pfs-min-style',  plugins_url("includes/minimal.css",__FILE__) ); 
     295        $theme_css = apply_filters( 'pfs_theme_css', plugins_url("includes/twentyeleven.css",__FILE__) ); 
     296        wp_enqueue_style( 'pfs-style',  $theme_css ); 
    110297    } 
    111298 
     
    118305    function shortcode($atts, $content=null, $code="") { 
    119306        $a = shortcode_atts( array( 
    120             'cat' => '', 
    121307            'link' => 'quick post', 
    122             'popup' => false 
     308            'popup' => false, 
     309            'cat' => '' 
    123310        ), $atts ); 
    124         $pfs = new PostFromSite($a['cat'],$a['link'],$a['popup']); 
     311        $pfs = new PostFromSite(0, $a['link'], $a['popup'], $a['cat']); 
    125312        return $pfs->get_form(); 
    126313    } 
    127314 
    128315    /** 
    129      * Add a link to show the form from the admin bar 
    130      */ 
     316     * Add a link to show the form from the admin bar     
    131317    function add_admin_link() { 
    132318        global $wp_admin_bar, $wpdb; 
     
    135321        $this->popup = false; 
    136322        $form = "</a>".$this->get_form(); 
    137         /* Add the main siteadmin menu item */ 
     323        / * Add the main siteadmin menu item * / 
    138324        $wp_admin_bar->add_menu( array( 'id' => 'post_from_site', 'title' => __( 'Write a Post', 'pfs_domain' ), 'href' => FALSE ) ); 
    139325        $wp_admin_bar->add_menu( array( 'parent' => 'post_from_site', 'title' => $form, 'href' => FALSE ) ); 
    140     } 
     326    } */ 
    141327 
    142328    /** 
     
    160346        $cat = $this->cat; 
    161347        $popup = $this->popup; 
     348        $id = $this->form_id; 
    162349        $pfs_options = get_option('pfs_options'); 
    163         if (''==$linktext) $linktext = $pfs_options['pfs_linktext']; 
    164         $idtext = $cat.preg_replace('/[^A-Za-z0-9]/','',$linktext); 
     350        $options = $pfs_options[0]; 
     351         
     352        if (''==$linktext) $linktext = apply_filters( 'pfs_default_link_text', __('Click to post.','pfs_domain') ); 
     353        $idtext = $cat.sanitize_html_class($linktext); 
     354 
    165355        // Javascript displays the box when the link is clicked  
    166         $out = ($popup) ? "<a href='#' class='pfs-post-link clearfix' id='$idtext-link'>$linktext</a>" : ''; 
     356        $out = ($popup) ? "<a href='#' class='pfs-post-link' id='$idtext-link'>$linktext</a>" : ''; 
    167357        $out .= "<div id='pfs-post-box-$idtext' "; 
    168358        $out .= ($popup) ? "style='display:none' class='pfs-post-box pfs_postbox'" : "class='pfs-post-box pfs_postform'"; 
    169359        $out .= ">\n"; 
    170360        $out .= ($popup) ? "<div class='closex'>&times;</div>\n" : ''; 
    171         $out .= "<div id='pfs-alert' style='display:none;'></div> \n"; 
    172         $out .= "<form class='pfs' id='pfs_form' method='post' action='".plugins_url("pfs-submit.php",__FILE__). "' enctype='multipart/form-data'>\n"; 
    173         $out .= "<input type='hidden' name='MAX_FILE_SIZE' value='" .$pfs_options['pfs_maxfilesize']. "' />\n"; 
    174         $out .= "<label for='pfs_title'>". __('Title:','pfs_domain'). "</label> <input name='title' id='pfs_title' value='' type='text' />\n"; 
    175         if (current_user_can('publish_posts') && $pfs_options['pfs_allow_anon']){ 
    176             $out .= "<label for='pfs_name'>".__('Name:','pfs_domain')."</label> <input name='name' id='pfs_title' value='' />"; 
    177             $out .= "<label for='pfs_email'>".__('Email:','pfs_domain')."</label> <input name='email' id='pfs_email' value='' />\n"; 
     361        if (current_user_can('publish_posts') || $options['allow_anon']){ 
     362            $out .= "<div id='pfs-alert' style='display:none;'></div> \n"; 
     363            $out .= apply_filters( 'pfs_before_form', '', $idtext ); 
     364            $out .= "<form class='pfs' id='pfs_form' method='post' action='".plugins_url("pfs-submit.php",__FILE__). "' enctype='multipart/form-data'>\n"; 
     365            $out .= "<input type='hidden' name='MAX_FILE_SIZE' value='" .apply_filters('pfs_maxfilesize',3000000). "' />\n"; 
     366            $out .= apply_filters( 'pfs_form_start', '', $idtext ); 
     367            $out .= "<label for='pfs_title'>". __('Title:','pfs_domain'). "</label> <input name='title' id='pfs_title' value='' type='text' class='input-text' />\n"; 
     368            if (!current_user_can('publish_posts') && $options['allow_anon']){ //if not logged in/able to publish posts, and anon posting allowed, show name/email 
     369                $out .= "<label for='pfs_name'>".__('Name:','pfs_domain')."</label> <input name='name' id='pfs_name' class='input-text' value='' type='text' />"; 
     370                $out .= "<label for='pfs_email'>".__('Email:','pfs_domain')."</label> <input name='email' id='pfs_email' class='input-text' value='' type='email' />\n"; 
     371            } 
     372            $out .= "<label for='postcontent'>". __('Content:','pfs_domain'). "</label><textarea id='postcontent' name='postcontent' rows='12' cols='50'></textarea>\n"; 
     373            if ( array_key_exists('taxonomy',$options) ){ 
     374                foreach ($options['taxonomy'] as $i => $tax){ 
     375                    $out .= $this->get_taxonomy_list($tax); 
     376                } 
     377            }        
     378            if ($options['allow_image']) { 
     379                $out .= "<label for='pfs_imgdiv$idtext'>". __('Image:','pfs_domain') ."</label>"; 
     380                /*$out .= "<script>function ".$idtext."pfs_auto_browse(){ inputs = document.getElementsByName(\"".$idtext."-image[]\"); inputs[inputs.length-1].click(); }</script>"; 
     381                $out .= "<input type='button' name='not-image' value='".__('Upload an image','pfs_domain')."' onclick='".$idtext."pfs_auto_browse();' />";*/ 
     382                $out .= "<div id='pfs-imgdiv'><input id ='pfs-imgdiv-input' type='file' class='multi' name='image[]' accept='png|gif|jpg|jpeg'/></div>\n"; 
     383            } 
     384            $out .= "<div class='clear'></div>\n"; 
     385            if ($options['enable_captcha'] && !current_user_can('publish_posts') && $options['allow_anon'] ){ 
     386                if ( !empty($pfs_options['recaptcha_public_key']) ) { 
     387                    require_once('recaptchalib.php'); 
     388                    $publickey = $pfs_options['recaptcha_public_key']; // you got this from the signup page 
     389                    $out .= recaptcha_get_html($publickey); 
     390                } else { 
     391                    return "<div id='pfs-alert' style='display:none;'>Need recaptcha</div>"; 
     392                } 
     393            } 
     394            $out .= apply_filters( 'pfs_before_submit', '', $idtext ); 
     395            $out .= "<input type='submit' id='post' class='submit' name='post' value='".__("Post","pfs_domain")."' />\n"; 
     396            $out .= apply_filters( 'pfs_form_end', '', $idtext ); 
     397            $out .= "</form>\n<div class='clear'></div>\n"; 
     398            $out .= apply_filters( 'pfs_after_form', '', $idtext ); 
     399        } else { 
     400            $out .= apply_filters( 'pfs_alert_login', "<p>You must be logged in to post.</p>" ); 
    178401        } 
    179         $out .= "<label for='postcontent'>". __('Content:','pfs_domain'). "</label><textarea id='postcontent' class='theEditor large-text' name='postcontent' rows='12' cols='50'></textarea>\n"; 
    180          
    181         $out .= $this->get_categories_list($pfs_options['pfs_excats']); 
    182         $out .= $this->get_tags_list($pfs_options['pfs_extags']); 
    183          
    184         if ($pfs_options['pfs_allowimg']) $out .=  __('Image:','pfs_domain')." <div id='pfs-imgdiv$idtext'><input type='file' class='multi' name='image[]' accept='png|gif|jpg|jpeg'/></div>\n"; 
    185         $out .= "<div class='clear'></div>\n"; 
    186         if ($pfs_options['enablecaptcha'] || $pfs_options['pfs_allow_anon']){ 
    187             require_once('recaptchalib.php'); 
    188             $publickey = '6LfvqcASAAAAAF9DN4HzPkjIhKeRgI78iJXJL606'; // you got this from the signup page 
    189             $out .= recaptcha_get_html($publickey); 
    190         } 
    191         $out .= "<input type='submit' id='post' class='submit' name='post' value='".__("Post","pfs_domain")."' />\n"; 
    192         $out .= "</form>\n<div class='clear'></div>\n"; 
    193         $out .= "<small>Powered by <a href='http://me.redradar.net/category/plugins/post-from-site/'>post-from-site</a> &amp; <a href='http://www.redradar.net/wp'>redradar</a></small>\n"; 
    194402        $out .= "</div>\n\n"; 
    195403        return $out; 
    196404    } 
    197405 
    198  
    199     /** 
    200      * What to display in the admin menu 
    201      */ 
    202     public function settings() { ?> 
    203         <script language="Javascript"> 
    204         function filesize_bytes() { 
    205             document.getElementById('pfs_mfs').value = document.getElementById('pfs_mfs').value.toUpperCase(); 
    206             var re = /^([0-9.]*)([KMGT]?B)?$/; 
    207             var KB = 1; 
    208             var MB = 2; 
    209             var GB = 3; 
    210             var TB = 4; 
    211             var m = re.exec(document.getElementById('pfs_mfs').value); 
    212             if (m == null) { 
    213                 document.getElementById('pfs_mfs').style.border="1px solid #880000"; 
    214                 document.getElementById('filesize_alert').innerHTML='<?php _e('Default: 30MB','pfs_domain'); echo "<br />"; _e('Not a valid filesize','pfs_domain'); ?>'; 
    215             } else { 
    216                 var size = 0; 
    217                 if (m[2] == null) size = m[1]; 
    218                 else if (m[2] == 'B') size = m[1]; 
    219                 else if (m[2] == 'KB') size = m[1]*1024; 
    220                 else if (m[2] == 'MB') size = m[1]*1024*1024; 
    221                 else if (m[2] == 'GB') size = m[1]*1024*1024*1024; 
    222                 else if (m[2] == 'TB') size = m[1]*1024*1024*1024*1024; 
    223                 document.getElementById('pfs_mfs').style.border="1px solid #DFDFDF"; 
    224                 document.getElementById('filesize_alert').innerHTML='<?php _e('Default: 30MB','pfs_domain');?>'; 
    225                 document.getElementById('pfs_mfsHidden').value = size; 
    226             } 
     406    /** 
     407     * return the categories 
     408     * @param string $excluded Categories which are excluded  
     409     */ 
     410    public function get_taxonomy_list( $taxonomy ){ 
     411        $terms = get_terms($taxonomy, array( 
     412            'hide_empty' => 0 
     413        )); 
     414        if (!$terms || empty($terms)) return ''; 
     415        //preg_match_all('/\s*<option class="(\S*)" value="(\S*)">(.*)<\/option>\s*/', $terms, $matches, PREG_SET_ORDER); 
     416        $out = apply_filters( 'pfs_taxonomy_label', "<label for='terms_$taxonomy'>$taxonomy</label>", $taxonomy ); 
     417        $out .= "<select id='terms_$taxonomy' name='terms[$taxonomy][]' size='4' multiple='multiple'>"; 
     418        foreach ($terms as $term){ 
     419            if (is_taxonomy_hierarchical($taxonomy)) 
     420                $out .= "<option value='{$term->term_taxonomy_id}'>{$term->name}</option>"; 
     421            else 
     422                $out .= "<option value='{$term->name}'>{$term->name}</option>"; 
    227423        } 
    228         function genCode(){ 
    229             if (document.getElementById("cat").value == ''){cat = "''";} else {cat=document.getElementById("cat").value;} 
    230             linktext = document.getElementById('pfs_indlinktxt').value.replace(/'/g, "\\'"); 
    231             linktext = linktext.replace(/"/g, "&amp;quot;"); 
    232             document.getElementById('gendCode').innerHTML = "&lt;?php if (function_exists('post_from_site')) {post_from_site("+cat+",'"+linktext+"');} ?&gt;"; 
    233         } 
    234         </script> 
    235         <style type='text/css'> 
    236         .pfs th { 
    237             font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; 
    238             font-size:12pt; 
    239             font-style:italic; 
    240             font-weight:bold; 
    241         } 
    242         .pfs td { 
    243             font-size:13px; 
    244         } 
    245         .pfs td input, .pfs td select { width:156px; } 
    246         </style> 
    247         <div class="wrap pfs"> 
    248             <h2><?php _e('Post From Site Settings','pfs_domain'); ?></h2> 
    249      
    250             <form method="post" action="options.php" id="options"> 
    251                 <?php settings_fields('pfs_options'); ?> 
    252                 <?php $pfs_options = get_option('pfs_options'); ?> 
    253      
    254                 <table class="form-table"> 
    255                     <tr><th colspan='2'><?php _e('User Permissions','pfs_domain');?></th></tr> 
    256                     <tr><td><?php _e("What categories can't users post to (ie, which to exclude)?",'pfs_domain');?><br /><small><?php _e('use cat IDs, comma seperated values, please.','pfs_domain');?></small></td><td><input type='text' name='pfs_options[pfs_excats]' value='<?php echo $pfs_options['pfs_excats'];?>' /></td><td class='notes'><?php _e('Default: none','pfs_domain');?></td></tr> 
    257                     <tr><td><?php _e('Allow post tags (includes ability to create new tags)?','pfs_domain');?></td><td><select name='pfs_options[pfs_allowtag]'><option value='1' <?php echo ($pfs_options['pfs_allowtag'])?'selected':'';?>><?php _e('Yes','pfs_domain');?></option><option value='0' <?php echo ($pfs_options['pfs_allowtag'])?'':'selected';?>><?php _e('No','pfs_domain');?></option></select></td><td class='notes'></td></tr> 
    258                     <tr><td><?php _e('Allow users to upload an image?','pfs_domain');?></td><td><select name='pfs_options[pfs_allowimg]'><option value='1' <?php echo ($pfs_options['pfs_allowimg'])?'selected':'';?>><?php _e('Yes','pfs_domain');?></option><option value='0' <?php echo ($pfs_options['pfs_allowimg'])?'':'selected';?>><?php _e('No','pfs_domain');?></option></select></td><td class='notes'><?php _e("Note: Images automatically uploaded to 'uploads' directory of wp-content -- just like uploading through the write-post/write-page pages.",'pfs_domain');?></td></tr> 
    259                     <tr><td><?php _e('Maximum file size for uploaded images?','pfs_domain');?></td><td><input type='text' id='pfs_mfs' onblur='javascript:filesize_bytes()' value='<?php echo display_filesize($pfs_options['pfs_maxfilesize']);?>' /></td><td class='notes' id="filesize_alert"><?php _e('Default: 3MB','pfs_domain');?></td></tr> 
    260                     <input type="hidden" id='pfs_mfsHidden' name='pfs_options[pfs_maxfilesize]' value='' /> 
    261                     <tr><td><?php _e('If image upload fails, should the post still be posted (without the image)?','pfs_domain');?></td><td><select name='pfs_options[pfs_imgfaildie]'><option value='1' <?php echo ($pfs_options['pfs_imgfaildie'])?'selected':'';?>><?php _e('Yes','pfs_domain');?></option><option value='0' <?php echo ($pfs_options['pfs_imgfaildie'])?'':'selected';?>><?php _e('No','pfs_domain');?></option></select></td><td class='notes'><?php _e("Note: If you select no, your post will not be created.",'pfs_domain'); ?></td></tr> 
    262                     <tr><td><?php _e("Post status? (set to draft or pending if you don't want these posts seen before approval)",'pfs_domain');?></td><td><select name='pfs_options[pfs_post_status]'> 
    263                         <option value='draft' <?php echo ('draft'==$pfs_options['pfs_post_status'])?'selected':'';?>><?php _e('Draft','pfs_domain');?></option> 
    264                         <option value='pending'<?php echo ('pending'==$pfs_options['pfs_post_status'])?'selected':'';?>><?php _e('Pending','pfs_domain');?></option> 
    265                         <option value='publish' <?php echo ('publish'==$pfs_options['pfs_post_status'])?'selected':'';?>><?php _e('Publish','pfs_domain');?></option> 
    266                     </select></td><td class='notes'><?php _e('Default: Publish','pfs_domain');?></td></tr> 
    267                     <tr><td><?php _e('Comment status? (closed means no one can comment on these posts)','pfs_domain');?></td><td><select name='pfs_options[pfs_comment_status]'> 
    268                         <option value='closed' <?php echo ('closed'==$pfs_options['pfs_comment_status'])?'selected':'';?>><?php _e('Closed','pfs_domain');?></option> 
    269                         <option value='open' <?php echo ('open'==$pfs_options['pfs_comment_status'])?'selected':'';?>><?php _e('Open','pfs_domain');?></option> 
    270                     </select></td><td class='notes'><?php _e('Default: Open','pfs_domain');?></td></tr> 
    271                     <tr><td><?php _e("Post type?",'pfs_domain');?></td><td><select name='pfs_options[pfs_post_type]'> 
    272                         <?php $post_types=get_post_types('','names');  
    273                         foreach ($post_types as $post_type ) { 
    274                             if ($post_type == $pfs_options['pfs_post_type']) { 
    275                                 echo '<option value="'.$post_type.'" selected>'.$post_type.'</option>'; 
    276                             } else { 
    277                                 echo '<option value="'.$post_type.'">'.$post_type.'</option>'; 
    278                             } 
    279                         } ?> 
    280                     </select></td><td class='notes'><?php _e('Set this to control what kind of post type your form will process as (post, page, any custom post types, etc).','pfs_domain'); ?><br /><?php _e('Default: post','pfs_domain'); ?></td></tr> 
    281                 </table> 
    282                  
    283                 <p class="submit"> 
    284                     <input type="submit" name="Submit" value="<?php _e('Save Changes','pfs_domain') ?>" /> 
    285                 </p> 
    286             </form> 
    287              
    288             <h2><?php _e('Installation','pfs_domain');?></h2> 
    289             <p><?php _e('Add the following code wherever you want the link to appear in your theme.','pfs_domain');?></p> 
    290             <p><code>&lt;?php if (function_exists('post_from_site')) {post_from_site();} ?&gt;</code></p> 
    291             <p><?php _e('To generate individual links to specific category posts:','pfs_domain');?> <small><?php _e("(like, 'click here to post in the general category')",'pfs_domain');?></small></p>  
    292             <p><?php _e('Category:','pfs_domain');?> <select id="cat" class="postform"><?php  
    293                 $categories = wp_dropdown_categories("echo=0&hide_empty=0"); 
    294                 preg_match_all('/\s*<option class="(\S*)" value="(\S*)">(.*)<\/option>\s*/', $categories, $matches, PREG_SET_ORDER); 
    295                 echo "<option class='{$matches[0][1]}' value=''></option>"; 
    296                 foreach ($matches as $match) echo $match[0];  
    297             ?></select> &nbsp; <?php _e('Link Text:','pfs_domain'); ?> <input type="text" id="pfs_indlinktxt" /> &nbsp; <input type="submit" value="<?php _e('generate code','pfs_domain');?>" onclick="javascript:genCode();"/></p> 
    298             <p><code id="gendCode"></code></p> 
    299         </div> 
    300     <?php  
     424        $out .= "</select><br />\n"; 
     425        return apply_filters("pfs_{$taxonomy}_list",$out); 
    301426    } 
    302427 
     
    305430 
    306431/**  === === HELPER FUNCTIONS === ===  **/ 
    307  
     432/**  unused, but left in, 'just in case'  **/ 
    308433/** 
    309434 * Convert number in bytes into human readable format (KB, MB etc) 
  • post-from-site/trunk/readme.txt

    r433414 r487351  
    22Contributors: ryelle 
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=YB5AWJMBLCCVC&lc=US&item_name=redradar%2enet&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted 
    4 Tags: quick post, frontend, insert post, post, Post 
    5 Requires at least: 2.8 
    6 Tested up to: 3.1 
     4Tags: quick post, frontend, insert post, post, Post, custom post type 
     5Requires at least: 3.2 
     6Tested up to: 3.3.1 
    77Stable tag: 2.0.3 
    88 
    9 This plugin allows you to post straight from your front-end (i.e. website) - perfect for a quick update, or if you just don't want to deal with the backend. 
     9Write a post without leaving your site! 
    1010 
    1111== Description == 
    1212 
    13 Versions 2.0.1+ are compatible with 3.0! 2.0.1 corrects an error from 2.0.0, which caused a conflict with 3.0. Newer versions are compatible with previous versions of WordPress, though you should be using 3.0. 
     13Add an interface on your site to write a post (or page, or anything), without having to go into the admin section. Also allows for 'anonymous' posting (not logged in users, still asks for name/email) with a recaptcha. This makes Post From Site a perfect plugin for your user reviews, a suggestion box, or even a very basic forum site.  
    1414 
    15 This new wordpress plugin allows you to post straight from your front-end (i.e. website) - perfect for a quick update! Also useful if you have multiple users and don’t need them to see the admin side of things. It creates a link on your website which, when clicked, will bring up a simple text-box. Users can enter a post title (required), content (also required), add categories and tags (including created new ones), and upload images. Images can be placed in your post with custom tags (`[!--image1--]`), or all appended to the end of the post. 
    16  
    17 On the admin side, there is a settings page where you can edit the plugin to your preferences. You can customize the link text, post-box background color, title/text color, and even add your own CSS to tailor pfs to your site. As for permissions, you can limit the categories pfs can post to and allow/disallow uploading of images. If you'd rather have pfs's posts approved before they are visible, you can set the post status to ‘pending’ or ‘draft’. Same with the comment status, it can default to ‘open’ (allowing comments) or ‘closed’ (not allowing comments). 
     15After install, you can display a form on your site via a widget, shortcode, or PHP code in your theme. See [this page for further documentation](http://me.redradar.net/category/plugins/post-from-site/). 
    1816 
    1917== Installation == 
     
    22201. Upload all files to the `/wp-content/plugins/post-from-site` directory 
    23211. Activate the plugin through the 'Plugins' menu in WordPress 
    24 1. Place `<?php if (function_exists('post_from_site')) {post_from_site();} ?>` in your templates where you want to see the link. 
     22 
     23= Use your choice of include: = 
     241. Add a widget in the [Widgets section](http://codex.wordpress.org/Appearance_Widgets_Screen) 
     252. Add a shortcode to a page/post/CPT 
     26 * Post From Site's basic shortcode is `[post-from-site]`. It has three options: `popup` defines whether the form will show on the site, or only after clicking a link (defaults to false, not a popup). `link` defines that link's text (defaults to 'quick post'). `cat` restricts the post to a specific category (defaults to none). 
     273. Add PHP code to your template files.  
     28 * `<?php $pfs = new PostFromSite(); $pfs->form(); ?>` will output the form. You can pass the same variables as in the shortcode. 
    2529 
    2630== Changelog == 
    27 2.1.0 
     31= 3.0 = 
     32* Rewrote code (again) into a class. 
     33* Added Custom Post Type functionality, along with support for all taxonomies. 
     34* Added widget functionality 
     35* Added actions and filters to allow extension 
     36* Images are uploaded correctly to gallery, and included image size is customizable 
    2837 
    29 * Adding widget functionality 
     38= 2.0.3 = 
     39* Fixed the call to the non-existent 'pfs-widget.php'. 
    3040 
    31 * Add actions and filters to create an 'API' 
    32  
    33 2.0.3 
    34  
    35 * Fixed the call to the non-existant 'pfs-widget.php'. 
    36  
    37 2.0.2 
    38  
     41= 2.0.2 = 
    3942* Fixed an issue with headers 
    40  
    4143* Changed the `div` tag back to an `a` tag. 
    4244 
    43 2.0.1 
    44  
     45= 2.0.1 = 
    4546* Compatibility with 3.0 
    4647 
    47 2.0.0 
    48  
     48= 2.0.0 = 
    4949* scrapped a lot of code, most of it never made a release 
    50  
    5150* moved over to strictly using jQuery 
    52  
    5351* multiple file upload support 
    54  
    5552* submits using ajax, then refreshes page, so you can see you addition immediately 
    56  
    5753* also gets rid of the double-post if you refresh the page 
    58  
    5954* default style has been changed 
    6055 
    61 1.9.0  
    62  
     56= 1.9.0 = 
    6357* fixes double posting;  
    64  
    6558* better image support;  
    66  
    6759* introduction of '[!--image--]' tag;  
    68  
    6960* existing category/tag dropdown with multiple selection;   
    70  
    7161* ability to create new categories/tags;   
    72  
    7362* other minor adjustments 
    7463 
    75 1.7.0 
    76  
     64= 1.7.0 = 
    7765* addition of tags  
    78  
    7966* bugfixes 
    8067 
    81 1.6.x 
    82  
     68= 1.6.x = 
    8369* Initial releases 
    8470 
    8571== Frequently Asked Questions == 
    8672 
    87 This is left over from versions 1.x of the plugin. 
    88  
    89 1. The pop-up won't pop-up! (aka there is a link, but clicking it does nothing.) 
     73= The popup won't show up / I'm redirected to a white page on submit = 
    9074 
    9175Check that you have the javascript and css files in the plugin's folder (`post-from-site`). A problem with the first version of this plugin was that the plugin was looking for the files in the wrong directory. For other people it was also a problem with my code assuming a Linux filestructure, so on Windows servers it broke. 2.0.0+ shouldn't have this problem, as I'm using a different method of calling other files. 
    9276 
    93 [ask a question](http://www.redradar.net/wp/?p=95)? 
     77[ask a question](http://wordpress.org/tags/post-from-site?forum_id=10)? 
    9478 
    9579== Screenshots == 
    9680 
    97 1. Post-from-site's setting page in admin 
    98 2. Post-from-site in action - *note: you can customize the CSS yourself so it doesn't need to look like the above.* 
     811. Post-from-site in action, using 'twentyeleven' theme 
Note: See TracChangeset for help on using the changeset viewer.