Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 81 lines (70 sloc) 3.033 kb
4f9b238 @zachgraves initial commit
zachgraves authored
1 <?php
e54b9da @zachgraves added license headers
zachgraves authored
2 /**
3 * Yahoo! Updates Wordpress Plugin
4 *
5 * Find documentation and support on Yahoo! Developer Network: http://developer.yahoo.com
6 *
7 * Hosted on GitHub: http://github.com/yahoo/yos-updates-wordpress/tree/master
8 *
9 * @package yos-updates-wordpress
10 * @subpackage yahoo
11 *
2428313 @zachgraves updated authors
zachgraves authored
12 * @author Ryan Kennedy
13 * @author Lawrence Morrisroe <lem@yahoo-inc.com>,
6304536 @zachgraves fixed my email address in the comments, also updated the ico warning
zachgraves authored
14 * @author Zach Graves <zachg@yahoo-inc.com>
e54b9da @zachgraves added license headers
zachgraves authored
15 * @copyright Copyrights for code authored by Yahoo! Inc. is licensed under the following terms:
16 * @license BSD Open Source License
17 *
18 * Permission is hereby granted, free of charge, to any person obtaining a copy
19 * of this software and associated documentation files (the "Software"), to deal
20 * in the Software without restriction, including without limitation the rights
21 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22 * copies of the Software, and to permit persons to whom the Software is
23 * furnished to do so, subject to the following conditions:
24 *
25 * The above copyright notice and this permission notice shall be included in
26 * all copies or substantial portions of the Software.
27 *
28 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 * THE SOFTWARE.
35 **/
4f9b238 @zachgraves initial commit
zachgraves authored
36
9e4d21d @zachgraves soft tabs
zachgraves authored
37 function yupdates_delete_post($postid)
38 {
31c43b5 @zachgraves minor optimizations
zachgraves authored
39 // TODO
4f9b238 @zachgraves initial commit
zachgraves authored
40 }
41
9e4d21d @zachgraves soft tabs
zachgraves authored
42 function yupdates_edit_post($postid)
43 {
31c43b5 @zachgraves minor optimizations
zachgraves authored
44 // TODO
4f9b238 @zachgraves initial commit
zachgraves authored
45 }
46
9e4d21d @zachgraves soft tabs
zachgraves authored
47 function yupdates_publish_post($postid)
48 {
1f94fa8 @zachgraves don't push a new update when a blog post is updated.
zachgraves authored
49 $post_status = $_POST['post_status'];
50 $original_post_status = $_POST['original_post_status'];
e86aeed @zachgraves final update
zachgraves authored
51
1f94fa8 @zachgraves don't push a new update when a blog post is updated.
zachgraves authored
52 // Secret Hint: if you want to publish a *new* update whenever you update a blog post,
53 // set this var below to FALSE;
54 $block_update_publish = TRUE;
e86aeed @zachgraves final update
zachgraves authored
55
1f94fa8 @zachgraves don't push a new update when a blog post is updated.
zachgraves authored
56 if($block_update_publish && $post_status == 'publish' && $original_post_status != 'publish') {
57 $post = get_post($postid);
58 $permalink = get_permalink($postid);
59
60 $bitly_options = yupdates_get_bitly_options();
61 if($bitly_options->apiKey && $bitly_options->login) {
62 $bitly_permalink = yupdates_bitly_shorten($permalink, $bitly_options->apiKey, $bitly_options->login);
63 $permalink = $bitly_permalink;
64 }
65
66 $title_template = get_option("yupdates_title_template");
67 $title_patterns = array('/%blog_title%/', '/%blog_name%/');
68 $title_replacements = array($post->post_title, get_bloginfo("name"));
69
70 $update = new stdclass();
71 $update->title = preg_replace($title_patterns, $title_replacements, $title_template);
72 $update->description = substr($post->post_excerpt, 0, 256);
73 $update->link = $permalink;
74
75 $suid = yupdates_insertUpdate($update);
76
77 return $suid;
78 }
4f9b238 @zachgraves initial commit
zachgraves authored
79 }
80 ?>
Something went wrong with that request. Please try again.