Changeset 620514
- Timestamp:
- 11/02/2012 09:37:27 PM (13 years ago)
- Location:
- post-via-dropbox/trunk
- Files:
-
- 2 edited
-
pvd.php (modified) (9 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
post-via-dropbox/trunk/pvd.php
r616390 r620514 2 2 /* 3 3 Plugin Name: Post via Dropbox 4 Plugin URI: http://paolo.bz 4 Plugin URI: http://paolo.bz/post-via-dropbox 5 5 Description: Post to WordPress blog via Dropbox 6 Version: 1. 006 Version: 1.10 7 7 Author: Paolo Bernardi 8 8 Author URI: http://paolo.bz … … 167 167 jQuery(document).ready(function() { 168 168 jQuery('.pvd_linkAccount').click(function() { 169 window.open('<?php echo $url_popup; ?>', 'Dropbox', 'width=8 00,height=600');169 window.open('<?php echo $url_popup; ?>', 'Dropbox', 'width=850,height=600'); 170 170 }); 171 171 }); … … 259 259 260 260 <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> 262 262 <td> 263 263 <select id='interval_cron' name='pvd_options[interval]'> … … 358 358 This is the list of the tags that you can use: 359 359 <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> 362 362 <li> <strong>[category]</strong> category, divided by comma <strong>[/category]</strong> </li> 363 363 <li> <strong>[tag]</strong> tag, divided by comma <strong>[/tag]</strong> </li> 364 364 <li> <strong>[status]</strong> post status (publish, draft, private, pending, future) <strong>[/status]</strong> </li> 365 365 <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> 367 374 </ul> 368 375 The only necessary tags are <strong>[title]</strong> and <strong>[content]</strong> … … 454 461 } 455 462 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) ) 464 476 ); 465 477 466 478 $id = wp_insert_post( $post_array ); 467 479 480 //extra features 468 481 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 469 507 if ($options['delete']) { 470 508 try { … … 481 519 } 482 520 } 483 } else { // post not inserted 521 } else { // post not inserted, probably there was an error 484 522 $this->report_error('File '.$post.' was not posted'); 485 523 } … … 494 532 $results = array(); 495 533 $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', 503 548 ); 504 549 foreach ($tag as $key => $value) { … … 544 589 } 545 590 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 546 610 public function init() { 547 611 … … 563 627 if ($results) { 564 628 $logs = get_option('pvd_logs'); 565 update_option('pvd_logs', array_merge ($logs, $results));629 update_option('pvd_logs', array_merge_recursive($logs, $results)); 566 630 } 567 631 -
post-via-dropbox/trunk/readme.txt
r616468 r620514 4 4 Requires at least: 3.0.0 5 5 Tested up to: 3.4 6 Stable tag: 1. 06 Stable tag: 1.10 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 14 14 **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. 15 15 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).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). 17 17 18 18 Everything happens automatically and without further actions on your part. … … 47 47 * **[content]** the content of the post **[/content]** (mandatory) 48 48 * **[category]** category, divided by comma **[/category]** 49 * **[tag]** tag , divided by comma **[/tag]**49 * **[tag]** tags, divided by comma **[/tag]** 50 50 * **[status]** post status (publish, draft, private, pending, future) **[/status]** 51 51 * **[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]** 53 60 54 61 The only necessary tags are [title] and [content] … … 66 73 == Changelog == 67 74 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.