Plugin Directory

Changeset 911152


Ignore:
Timestamp:
05/09/2014 04:00:05 PM (12 years ago)
Author:
PaoloBe
Message:

added post_type support

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

Legend:

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

    r808984 r911152  
    44Plugin URI: http://paolo.bz/post-via-dropbox
    55Description: Post to WordPress blog via Dropbox
    6 Version: 2.00
     6Version: 2.10
    77Author: Paolo Bernardi
    88Author URI: http://paolo.bz
     
    3030
    3131            if (!get_option('pvd_options')) {
    32                 add_option('pvd_options', array('interval' => 3600, 'ext' => 'txt', 'markdown' => 1, 'status' => 'publish'));
     32                add_option('pvd_options', array('interval' => 3600, 'ext' => 'txt', 'markdown' => 1, 'status' => 'publish', 'post_type' => 'post'));
    3333            }
    3434            if (!get_option('pvd_errors')) {
     
    7575                $newValues['cat'] = intval($input['cat']);
    7676                $newValues['ext'] = preg_replace('#[^A-z0-9]#', '', $input['ext']);
     77
     78                $post_types = get_post_types();
     79                $post_type = 'post';
     80                foreach ($post_types as $post_type_) {
     81                    if ($input['post_type'] == $post_type_) {
     82                        $post_type = $input['post_type'];
     83                        break;
     84                    }
     85                }
     86
     87                $newValues['post_type'] = $post_type;
    7788               
    7889                $statuses = array('publish', 'draft', 'private', 'pending', 'future');
     
    118129        if (isset($_GET['pvd_manual']) && is_admin()) {
    119130            if ($_GET['pvd_manual'] == sha1($this->encryptkey)) {
     131                if (version_compare($wp_version, '3.9', '>=') >= 0) { #workaround for manual posting (since wp 3.9)
     132                    include_once(ABSPATH . WPINC . '/pluggable.php');
     133                }
     134                global $wp_rewrite;
     135                $wp_rewrite = new WP_Rewrite();
    120136                $this->init();
    121137            }
     
    274290                </tr>
    275291
     292                <tr valign='top'>
     293                    <th scope='row'><laber for=''> Default Post Type </label> </th>
     294                    <td>
     295                        <select name='pvd_options[post_type]'>
     296                            <?php
     297                                $post_types = get_post_types();
     298                                foreach ($post_types as $post_type) {
     299                                    echo '<option value=\''.$post_type.'\''.($options['post_type'] == $post_type ? ' selected' : null).'>'.$post_type.'</option>';
     300                                }
     301
     302                            ?>
     303                        </select>
     304                    </td>
     305                </tr>
    276306
    277307                <tr valign='top'>
     
    384414        <p>
    385415        <strong>Where do I put my text files?</strong><br />
    386         Text files must be uploaded inside <strong>Dropbox/Apps/Post_via_Dropbox/</strong> . The text file may have whatever extensions you want (default .txt) and it is strongly recommended that it has UTF-8 encoding.
     416        Text files must be uploaded inside <strong>Dropbox/Apps/Post_via_Dropbox/</strong> . The text file may have whatever extensions you want (default .txt) and it should have UTF-8 encoding.
    387417        </p>
    388418
     
    417447<li><strong>[comment]</strong> comments status (use word 'open' or 'closed') <strong>[/comment]</strong></li>
    418448<li><strong>[ping]</strong> ping status (use word 'open' or 'closed') <strong>[/ping]</strong></li>
     449<li><strong>[post_type]</strong> Post Type (e.g. 'post', 'page', etc) <strong>[/post_type]</strong></li>
    419450        </ul>
    420451        The only necessary tags are <strong>[title]</strong> and <strong>[content]</strong>
    421452        <br /><br />
    422453
    423 
    424    
    425454        </div>
    426455            <?php
     
    533562                                    'post_name'         =>  ( $slug ? $slug : null),
    534563                                    'comment_status'    =>  ( $comment == 'open' ? 'open' : ($comment == 'closed' ? 'closed' : null) ),
    535                                     'ping_status'       =>  ( $ping == 'open' ? 'open' : ($ping == 'closed' ? 'closed' : null) )
     564                                    'ping_status'       =>  ( $ping == 'open' ? 'open' : ($ping == 'closed' ? 'closed' : null) ),
     565                                    'post_type'         =>  ( in_array($post_type, get_post_types()) ? $post_type : ($options['post_type'] ? $options['post_type'] : 'post'))
    536566                                );
    537567           
     
    607637                    'comment'       =>      '#\[comment\](.*?)\[/comment\]#s',
    608638                    'ping'          =>      '#\[ping\](.*?)\[/ping\]#s',
     639                    'post_type'     =>      '#\[post_type\](.*?)\[/post_type\]#s'
    609640            );
    610641        foreach ($tag as $key => $value) {
     
    715746// Where all starts! :-)
    716747$Post_via_Dropbox = new Post_via_Dropbox();
    717 
    718748?>
  • post-via-dropbox/trunk/readme.txt

    r903583 r911152  
    33Tags: dropbox, post via dropbox, remote update, post, posting, remote
    44Requires at least: 3.0.0
    5 Tested up to: 3.9
    6 Stable tag: 2.00
     5Tested up to: 3.9.1
     6Stable tag: 2.10
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4242There're many ways of using it: text files are very flexible and they can adapt without much efforts.
    4343
    44 = Where do I upload my text files? =
     44= Where do I put my text files? =
    4545
    46 Text files must be uploaded inside **Dropbox/Apps/Post_via_Dropbox/** . Once posted, the text files is moved into subidirectory "posted", if you have not selected "delete" option.
     46Text files must be uploaded inside **Dropbox/Apps/Post_via_Dropbox/** . Once posted, the text files is moved into subidirectory "posted", if you have not selected "delete" option. The text file may have whatever extensions you want (default .txt) and it should have UTF-8 encoding.
    4747
    4848= How should be the text files? =
     
    5555
    5656You need to specify the ID of the post, there're two ways: 1) using [id] tag or 2) prepend to filename the ID (example: 500-filename.txt).
    57 The quickest way to edit an existing post, already posted via Dropbox, is move the file from the subfolder 'posted' to the principal folder.
     57The quickest way to edit an existing post, already posted via Dropbox, is to move the file from the subfolder 'posted' to the principal folder.
    5858
    5959= This is the list of the tags that you can use (if you have not selected "Simplified posting"): =
     
    7373* **[comment]** comments status (use word 'open' or 'closed') **[/comment]**
    7474* **[ping]** ping status (use word 'open' or 'closed') **[/ping]**
     75* **[post_type]** Post Type (e.g. 'post', 'page'..) **[/post_type]**
    7576
    7677The only necessary tags are [title] and [content]
     
    8283== Changelog ==
    8384
     85= 2.10 =
     86*   Added Post Type support
     87*   Fixed minor bug in manual mode for WP 3.9+
     88
    8489= 2.00 =
    8590*   Added Markdown support
    8691*   Added new feature (Simplified posting)
    87 *   Fixed minor bus
     92*   Fixed minor bug
    8893
    8994= 1.10 =
Note: See TracChangeset for help on using the changeset viewer.