Plugin Directory

Changeset 620514


Ignore:
Timestamp:
11/02/2012 09:37:27 PM (13 years ago)
Author:
PaoloBe
Message:

Version update (1.10): new features

Location:
post-via-dropbox/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • post-via-dropbox/trunk/pvd.php

    r616390 r620514  
    22/*
    33Plugin Name: Post via Dropbox
    4 Plugin URI: http://paolo.bz
     4Plugin URI: http://paolo.bz/post-via-dropbox
    55Description: Post to WordPress blog via Dropbox
    6 Version: 1.00
     6Version: 1.10
    77Author: Paolo Bernardi
    88Author URI: http://paolo.bz
     
    167167            jQuery(document).ready(function() {
    168168                jQuery('.pvd_linkAccount').click(function() {
    169                     window.open('<?php echo $url_popup; ?>', 'Dropbox', 'width=800,height=600');
     169                    window.open('<?php echo $url_popup; ?>', 'Dropbox', 'width=850,height=600');
    170170                });
    171171            });
     
    259259
    260260                <tr valign='top'>
    261                     <th scope='row'><laber for=''> Interval Cron </label> </th>
     261                    <th scope='row'><laber for=''> Check your Dropbox folder: </label> </th>
    262262                    <td>
    263263                        <select id='interval_cron' name='pvd_options[interval]'>
     
    358358        This is the list of the tags that you can use:
    359359        <ul>
    360         <li><strong>[title]</strong></strong> post title <strong><strong>[/title]</strong></strong> (mandatory)
    361             <li> <strong>[content]</strong> the content of the post <strong>[/content]</strong> </li> (mandatory)
     360        <li><strong>[title]</strong></strong> post title <strong><strong>[/title]</strong></strong> (mandatory) </li>
     361            <li> <strong>[content]</strong> the content of the post <strong>[/content]</strong> (mandatory) </li>
    362362            <li> <strong>[category]</strong> category, divided by comma <strong>[/category]</strong> </li>
    363363            <li> <strong>[tag]</strong> tag, divided by comma <strong>[/tag]</strong> </li>
    364364            <li> <strong>[status]</strong> post status (publish, draft, private, pending, future) <strong>[/status]</strong> </li>
    365365            <li> <strong>[excerpt]</strong> post excerpt <strong>[/excerpt]</strong> </li>
    366             <li> <strong>[id]</strong> if you want to modify an existing post, you should put here the ID of the post to edit <strong>[/id]</strong> </li>
     366            <li> <strong>[id]</strong> if you want to modify an existing post, you should put here the ID of the post <strong>[/id]</strong> </li>
     367            <li> <strong>[date]</strong> the date of the post (it supports english date format, like 1/1/1970 00:00 or 1 jan 1970 and so on, or UNIX timestamp) <strong>[/date]</strong></li>
     368            <li><strong>[sticky]</strong> stick or unstick the post (use word 'yes' / 'y' or 'no' / 'n') <strong>[/sticky]</strong></li>
     369<li> <strong>[customfield]</strong> custom fields (you must use this format: field_name1=value & field_name2=value ) <strong>[/customfield]</strong></li>
     370<li><strong>[taxonomy]</strong> taxonomies (you must use this format: taxonomy_slug1=term1,term2,term3 & taxonomy_slug2=term1,term2,term3) <strong>[/taxonomy]</strong></li>
     371<li><strong>[slug]</strong> the name (slug) for you post <strong>[/slug]</strong></li>
     372<li><strong>[comment]</strong> comments status (use word 'open' or 'closed') <strong>[/comment]</strong></li>
     373<li><strong>[ping]</strong> ping status (use word 'open' or 'closed') <strong>[/ping]</strong></li>
    367374        </ul>
    368375        The only necessary tags are <strong>[title]</strong> and <strong>[content]</strong>
     
    454461            }
    455462            extract( $this->parse($res['data']) );
    456             $post_array = array(    'ID'            =>  ( $id ? intval($id) : (preg_match('#^(\d+)-#', pathinfo($post, PATHINFO_BASENAME), $matched) ? $matched[1] : null ) ),
    457                                     'post_title'    =>  wp_strip_all_tags($title),
    458                                     'post_content'  =>  $content,
    459                                     'post_excerpt'  =>  ( $excerpt ? $excerpt : null ),
    460                                     'post_category' =>  ( $category ? array_map(function($el) {return get_cat_ID(trim($el));}, explode(',', $category) ) : ($options['cat'] ? array($options['cat']) : null) ),
    461                                     'tags_input'    =>  ( $tag ? $tag : null),
    462                                     'post_status'   =>  ( $status == 'draft' || $status == 'publish' || $status == 'pending' || $status == 'future' || $status == 'private' ? $status : ($options['status'] ? $options['status'] : 'draft') ),
    463                                     'post_author'   =>  ( $options['author'] ? $options['author'] : null )
     463            $post_array = array(    'ID'                =>  ( $id ? intval($id) : (preg_match('#^(\d+)-#', pathinfo($post, PATHINFO_BASENAME), $matched) ? $matched[1] : null ) ),
     464                                    'post_title'        =>  wp_strip_all_tags($title),
     465                                    'post_content'      =>  $content,
     466                                    'post_excerpt'      =>  ( $excerpt ? $excerpt : null ),
     467                                    'post_category'     =>  ( $category ? array_map(function($el) {return get_cat_ID(trim($el));}, explode(',', $category) ) : ($options['cat'] ? array($options['cat']) : null) ),
     468                                    'tags_input'        =>  ( $tag ? $tag : null),
     469                                    'post_status'       =>  ( $status == 'draft' || $status == 'publish' || $status == 'pending' || $status == 'future' || $status == 'private' ? $status : ($options['status'] ? $options['status'] : 'draft') ),
     470                                    'post_author'       =>  ( $options['author'] ? $options['author'] : null ),
     471                                //  'post_author'       =>  ( $author ? )
     472                                    'post_date'         =>  ( $date ? strftime( "%Y-%m-%d %H:%M:%S", ( $this->isValidTimeStamp($date) ? $date : strtotime($date) ) ) : null ),
     473                                    'post_name'         =>  ( $slug ? $slug : null),
     474                                    'comment_status'    =>  ( $comment == 'open' ? 'open' : ($comment == 'closed' ? 'closed' : null) ),
     475                                    'ping_status'       =>  ( $ping == 'open' ? 'open' : ($ping == 'closed' ? 'closed' : null) )
    464476                                );
    465477           
    466478            $id = wp_insert_post( $post_array );
    467479
     480            //extra features
    468481            if ($id) { // post inserted
     482                if ($sticky && ( $sticky == 'yes' || $sticky == 'y' )) {
     483                    stick_post( $id );
     484                } elseif ($sticky && ( $sticky == 'no' || $sticky == 'n' )) {
     485                    unstick_post( $id );
     486                }
     487
     488                if ($customfield) {
     489                    $customfield_array = array();
     490                    parse_str($customfield, $customfield_array);
     491                    foreach ($customfield_array as $field => $value) {
     492                        $this->post_meta_helper( $id , $field, $value );
     493                    }
     494                }
     495
     496                if ($taxonomy) {
     497                    $taxonomy_array = array();
     498                    parse_str($taxonomy, $taxonomy_array);
     499                    foreach ($taxonomy_array as $tax_slug => $value) {
     500                        wp_set_post_terms($id, $value, $tax_slug, $append = false);
     501                    }
     502                }
     503            }
     504
     505            if ($id) { // post inserted
     506                // delete or move to 'posted' subfolder original text file
    469507                if ($options['delete']) {
    470508                    try {
     
    481519                    }
    482520                }
    483             } else { // post not inserted
     521            } else { // post not inserted, probably there was an error
    484522                $this->report_error('File '.$post.' was not posted');
    485523            }
     
    494532        $results = array();
    495533        $tag = array(
    496                     'title'     =>      '#\[title\](.*?)\[/title\]#s',
    497                     'status'    =>      '#\[status\](.*?)\[/status\]#s',
    498                     'category'  =>      '#\[category\](.*?)\[/category\]#s',
    499                     'tag'       =>      '#\[tag\](.*?)\[/tag\]#s',
    500                     'content'   =>      '#\[content\](.*?)\[/content\]#s',
    501                     'excerpt'   =>      '#\[excerpt\](.*?)\[/excerpt\]#s',
    502                     'id'        =>      '#\[id\](.*?)\[/id\]#s'
     534                    'title'         =>      '#\[title\](.*?)\[/title\]#s',
     535                    'status'        =>      '#\[status\](.*?)\[/status\]#s',
     536                    'category'      =>      '#\[category\](.*?)\[/category\]#s',
     537                    'tag'           =>      '#\[tag\](.*?)\[/tag\]#s',
     538                    'content'       =>      '#\[content\](.*?)\[/content\]#s',
     539                    'excerpt'       =>      '#\[excerpt\](.*?)\[/excerpt\]#s',
     540                    'id'            =>      '#\[id\](.*?)\[/id\]#s',
     541                    'sticky'        =>      '#\[sticky\](.*?)\[/sticky\]#s',
     542                    'date'          =>      '#\[date\](.*?)\[/date\]#s',
     543                    'slug'          =>      '#\[slug\](.*?)\[/slug\]#s',
     544                    'customfield'   =>      '#\[customfield\](.*?)\[/customfield\]#s',
     545                    'taxonomy'      =>      '#\[taxonomy\](.*?)\[/taxonomy\]#s',
     546                    'comment'       =>      '#\[comment\](.*?)\[/comment\]#s',
     547                    'ping'          =>      '#\[ping\](.*?)\[/ping\]#s',
    503548            );
    504549        foreach ($tag as $key => $value) {
     
    544589    }
    545590
     591    private function isValidTimeStamp($timestamp) {
     592        return ( (string) (int) $timestamp === $timestamp) && ($timestamp <= PHP_INT_MAX) && ($timestamp >= ~PHP_INT_MAX);
     593    }
     594
     595    public function post_meta_helper( $post_id, $field_name, $value = '' ) {
     596        if ( empty( $value ) || ! $value )
     597        {
     598            delete_post_meta( $post_id, $field_name );
     599        }
     600        elseif ( ! get_post_meta( $post_id, $field_name ) )
     601        {
     602            add_post_meta( $post_id, $field_name, $value );
     603        }
     604        else
     605        {
     606            update_post_meta( $post_id, $field_name, $value );
     607        }
     608    }
     609
    546610    public function init() {
    547611
     
    563627        if ($results) {
    564628            $logs = get_option('pvd_logs');
    565             update_option('pvd_logs', array_merge($logs, $results));
     629            update_option('pvd_logs', array_merge_recursive($logs, $results));
    566630        }
    567631
  • post-via-dropbox/trunk/readme.txt

    r616468 r620514  
    44Requires at least: 3.0.0
    55Tested up to: 3.4
    6 Stable tag: 1.0
     6Stable tag: 1.10
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1414**Post via Dropbox** is a easy way to update your blog using **Dropbox**, the famous cloud sharing service. It permits to add or edit your posts with text files uploaded via Dropbox.
    1515
    16 Once you linked your Dropbox' Account, you can upload text files into your Dropbox' folder for updating your blog. Inside text files you should use some specific tags, like [title] [/title] and [content] [/content] for adding or modifying informations of the post (please, read faqs for more information).
     16Once you linked your Dropbox Account, you can upload text files into your Dropbox folder for updating your blog. Inside text files you should use some specific tags, like [title] [/title] and [content] [/content] for adding or modifying informations of the post (please, read faqs for more information).
    1717
    1818Everything happens automatically and without further actions on your part.
     
    4747* **[content]** the content of the post **[/content]** (mandatory)
    4848* **[category]** category, divided by comma **[/category]**
    49 * **[tag]** tag, divided by comma **[/tag]**
     49* **[tag]** tags, divided by comma **[/tag]**
    5050* **[status]** post status (publish, draft, private, pending, future) **[/status]**
    5151* **[excerpt]** post excerpt **[/excerpt]**
    52 * **[id]** if you want to modify an existing post, you should put here the ID of the post to edit **[/id]**
     52* **[id]** if you want to modify an existing post, you should put here the ID of the post **[/id]**
     53* **[date]** the date of the post (it supports english date format, like 1/1/1970 00:00 or 1 jan 1970 and so on, or UNIX timestamp) **[/date]**
     54* **[sticky]** stick or unstick the post (use word 'yes' / 'y' or 'no' / 'n') **[/sticky]**
     55* **[customfield]** custom fields (you must use this format: field_name1=value & field_name2=value ) **[/customfield]**
     56* **[taxonomy]** taxonomies (you must use this format: taxonomy_slug1=term1,term2,term3 & taxonomy_slug2=term1,term2,term3) **[/taxonomy]**
     57* **[slug]** the name (slug) for you post **[/slug]**
     58* **[comment]** comments status (use word 'open' or 'closed') **[/comment]**
     59* **[ping]** ping status (use word 'open' or 'closed') **[/ping]**
    5360
    5461The only necessary tags are [title] and [content]
     
    6673== Changelog ==
    6774
    68 Nothing yet
     75**1.10**
     76* Fixed minor bugs
     77* Added new features (Date, Custom fields, Taxonomies, Sticky, Comment/Ping status, Slug name support)
     78
     79
     80
     81**1.00**
     82* Initial release
Note: See TracChangeset for help on using the changeset viewer.