Changeset 200305
- Timestamp:
- 01/31/2010 11:22:37 PM (16 years ago)
- Location:
- twitterpad
- Files:
-
- 7 added
- 2 edited
-
tags/1.3.2 (added)
-
tags/1.3.2/readme.txt (added)
-
tags/1.3.2/screenshot-1.gif (added)
-
tags/1.3.2/simplepie.php (added)
-
tags/1.3.2/twpad-panel.php (added)
-
tags/1.3.2/twpad.php (added)
-
tags/1.3/screenshot-1.png (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/twpad.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
twitterpad/trunk/readme.txt
r196628 r200305 4 4 Requires at least: 2.5 5 5 Tested up to: 2.9.1 6 Stable tag: 1.3. 16 Stable tag: 1.3.2 7 7 8 8 TwitterPad allows twitter users to automatically collect tweets using custom search strings which are added to a specified page or as a new blog post … … 38 38 39 39 == Changelog == 40 **1.3.2** - Minor bug fix 41 40 42 **1.3.1** - Changed code to allow users to use twiiter RSS feeds manimpulated by services like Yahoo Pipes. Option to also exclude tweet profile pictures. 41 43 -
twitterpad/trunk/twpad.php
r196628 r200305 1 1 <?php 2 3 /* 4 Plugin Name: TwitterPad 5 Plugin URI: http://www.rsc-ne-scotland.org.uk/mashe/twitterpad-plugin/ 6 Description: TwitterPad allows twitter users to automatically collect tweets using custom search strings which are added to a specified page or as a new post. 7 Author: Martin Hawksey 8 Author URI: http://www.rsc-ne-scotland.org.uk/mashe 9 Version: 1.3.1 10 */ 11 12 13 /* Copyright 2009 Martin Hawksey (email : martin.hawksey@gmail.com) 14 The code used in TwitterPad is based on: 15 Plugin Name: Shared Items Post 16 Plugin URI: http://www.googletutor.com/shared-items-post/ 17 Description: Scheduled automatic posting of Google Reader Shared Items. 18 Version: 1.3.0 19 Author: Craig Fifield, Google Tutor 20 Author URI: http://www.googletutor.com/ 21 22 This program is free software; you can redistribute it and/or modify 23 it under the terms of the GNU General Public License as published by 24 the Free Software Foundation; either version 2 of the License, or 25 (at your option) any later version. 26 27 This program is distributed in the hope that it will be useful, 28 but WITHOUT ANY WARRANTY; without even the implied warranty of 29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30 GNU General Public License for more details. 31 32 You should have received a copy of the GNU General Public License 33 along with this program; if not, write to the Free Software 34 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 35 */ 36 if(! class_exists('SimplePie')) 37 require_once(dirname(__FILE__).'/simplepie.php'); 38 39 if (!class_exists('Twitterpad')) { 40 class Twitterpad 41 { 42 var $plugin_url; 43 var $plugin_path; 44 var $status = ""; 45 46 var $o; 47 48 var $default_options = array( 49 'tp_revision' => 1, 50 'tp_last_refresh' => 0, 51 'tp_item_style' =>'border-bottom: 1px dashed #cccccc; padding: 10px 5px;', 52 'tp_refresh_period' =>'24', 53 'tp_feeds' => array(), 54 'tp_post_days' => '12345', 55 'tp_post_time' => '16:00', 56 'tp_post_title' => 'Summary of tweets for %DATE%', 57 'tp_post_content' => '<p>Below is a summary of tweets from %DATE%</p>%TWPAD%', 58 'tp_post_status' => 'publish', 59 'tp_post_category' => '', 60 'tp_post_tags' => '', 2 /* 3 Plugin Name: TwitterPad 4 Plugin URI: http://www.rsc-ne-scotland.org.uk/mashe/twitterpad-plugin/ 5 Description: TwitterPad allows twitter users to automatically collect tweets using custom search strings which are added to a specified page or as a new post. 6 Author: Martin Hawksey 7 Author URI: http://www.rsc-ne-scotland.org.uk/mashe 8 Version: 1.3.2 9 */ 10 11 /* Copyright 2009 Martin Hawksey (email : martin.hawksey@gmail.com) 12 The code used in TwitterPad is based on: 13 Plugin Name: Shared Items Post 14 Plugin URI: http://www.googletutor.com/shared-items-post/ 15 Description: Scheduled automatic posting of Google Reader Shared Items. 16 Version: 1.3.0 17 Author: Craig Fifield, Google Tutor 18 Author URI: http://www.googletutor.com/ 19 20 This program is free software; you can redistribute it and/or modify 21 it under the terms of the GNU General Public License as published by 22 the Free Software Foundation; either version 2 of the License, or 23 (at your option) any later version. 24 25 This program is distributed in the hope that it will be useful, 26 but WITHOUT ANY WARRANTY; without even the implied warranty of 27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 GNU General Public License for more details. 29 30 You should have received a copy of the GNU General Public License 31 along with this program; if not, write to the Free Software 32 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 33 */ 34 if (!class_exists('SimplePie')) 35 require_once(dirname(__FILE__) . '/simplepie.php'); 36 if (!class_exists('Twitterpad')) { 37 class Twitterpad 38 { 39 var $plugin_url; 40 var $plugin_path; 41 var $status = ""; 42 var $o; 43 var $default_options = array( 44 'tp_revision' => 1, 45 'tp_last_refresh' => 0, 46 'tp_item_style' => 'border-bottom: 1px dashed #cccccc; padding: 10px 5px;', 47 'tp_refresh_period' => '24', 48 'tp_feeds' => array(), 49 'tp_post_days' => '12345', 50 'tp_post_time' => '16:00', 51 'tp_post_title' => 'Summary of tweets for %DATE%', 52 'tp_post_content' => '<p>Below is a summary of tweets from %DATE%</p>%TWPAD%', 53 'tp_post_status' => 'publish', 54 'tp_post_category' => '', 55 'tp_post_tags' => '', 61 56 'tp_item_image' => 1 62 ); 63 64 function Twitterpad() { 65 $this->plugin_path_url(); 66 $this->install_plugin(); 67 $this->actions_filters(); 68 } 69 70 71 function plugin_path_url() { 72 $this->plugin_url = WP_PLUGIN_URL.'/twitterpad/'; 73 $this->plugin_path = dirname(__FILE__).'/'; 74 define('RSSEVERPOST_URL', $this->plugin_url); 75 define('RSSEVERPOST_PATH', $this->plugin_path); 76 } 77 78 function install_plugin() { 79 $this->o = get_option('twitterpad-options'); 80 81 if (!is_array($this->o)) { 82 update_option('twitterpad-options', $this->default_options); 83 $this->o = get_option('twitterpad-options'); 84 } 85 else { 86 foreach ($this->default_options as $key => $value) 87 if (!isset($this->o[$key])) $this->o[$key] = $value; 88 $this->o["tp_revision"] = $this->default_options["tp_revision"]; 89 update_option('twitterpad-options', $this->o); 90 } 91 } 92 93 function actions_filters() { 94 add_action('init', array(&$this, 'init')); 95 add_action('admin_menu', array(&$this, 'admin_menu')); 96 } 97 98 function init() { 99 if ($_POST['tp_action'] == 'runow') { 100 check_admin_referer('twpad-2'); 101 $this->status .= "All feeds refreshed"; 102 $this->generate_post(); 103 } 104 else { 105 if ($_POST['tp_action'] == 'reset') { 106 check_admin_referer('twpad-3'); 107 $this->status .= "Reset"; 108 $this->o = $this->default_options; 109 update_option("twitterpad-options", $this->default_options); 110 } elseif ($_POST['tp_action'] == 'delete') { 111 check_admin_referer('twpad-4'); 112 foreach( (array) $_POST['tpfeed'] as $post_id_del ) { 113 unset($this->o["tp_feeds"][$post_id_del]); 114 } 115 $this->o["tp_feeds"] = array_values($this->o["tp_feeds"]); 116 update_option("twitterpad-options", $this->o); 117 $this->status = "Feed removed"; 118 } elseif ($_POST['tp_action'] == 'stylenow') { 119 check_admin_referer('twpad-5'); 120 $this->o["tp_item_style"]=$_POST['tp_item_style']; 121 $this->o["tp_item_image"] = isset($_POST['tp_item_image']) ? 1 : 0; 122 $this->o["tp_refresh_period"]=$_POST['tp_refresh_period']; 123 $this->status .= "Options updated."; 124 update_option("twitterpad-options", $this->o); 125 } elseif ($_POST['tp_action'] == 'post_template') { 126 check_admin_referer('twpad-6'); 127 $this->o["tp_post_days"] =$_POST['d1'].$_POST['d2'].$_POST['d3'].$_POST['d4'].$_POST['d5'].$_POST['d6'].$_POST['d0']; 128 $this->o["tp_post_time"]=$_POST['tp_post_time']; 129 $this->o["tp_post_title"]=$_POST['tp_post_title']; 130 $this->o["tp_post_content"]=$_POST['tp_post_content']; 131 $this->o["tp_post_status"]=$_POST['tp_post_status']; 132 $this->o["tp_post_category"]=$_POST['tp_post_category']; 133 $this->o["tp_post_tags"]=$_POST['tp_post_tags']; 134 if ($this->o["tp_post_days"] ==""){ 135 $this->status .= "OOPS. You need to select at least one day for the post template"; 136 } 137 $this->status .= "Post template updated.<br>"; 138 update_option("twitterpad-options", $this->o); 139 } elseif ($_POST['tp_action'] == 'add') { 140 check_admin_referer('twpad-1', 'twpad-main'); 141 if (isset($_POST['tp_url']) && $_POST['tp_page']!=""){ 142 if ($this->valid_tp_feed($_POST['tp_url'])){ 143 $idx=sizeof($this->o["tp_feeds"]); 144 $this->o["tp_feeds"][$idx]['url']=$_POST['tp_url']; 145 $this->o["tp_feeds"][$idx]['page']=$_POST['tp_page']; 146 $this->o["tp_feeds"][$idx]['refresh']=0; 147 $this->o["tp_feeds"][$idx]["lastItemDate"]=0; 148 $this->status = "Feed added."; 149 } else { 150 $this->status = "Feed is not valid."; 151 } 152 } else { 153 $this->status = "Please enter a valid url and page."; 154 } 155 update_option("twitterpad-options", $this->o); 156 } 157 $this->generate_post(); 158 } 159 } 160 161 162 function valid_tp_feed($url) { 163 if ($url == "") return; 164 $rss_status = false; 165 $rss = new SimplePie(); 166 $rss->set_feed_url($url); 167 $rss->enable_cache(false); 168 $rss->init(); 169 if ($rss->get_type() & SIMPLEPIE_TYPE_ALL){ 170 $rss_status = true; 171 } 172 return $rss_status; 173 } 174 175 176 function generate_post() { 177 if(empty($this->o['tp_feeds'])) return; 178 foreach ($this->o['tp_feeds'] as $key => $t) { 179 if ($this->o["tp_feeds"][$key]["refresh"] < mktime()){ 180 $rss = new SimplePie(); 181 $rss->set_feed_url($t["url"]); 182 $rss->enable_cache(false); 183 $rss->enable_order_by_date(false); 184 $rss->init(); 185 if ($t["page"] != "[New Post]") { 186 $page = get_post($t["page"]); 187 $content = $page->post_content; 188 } 189 /* 190 $gen = $rss->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'); 191 if ($gen[0]['data'] == "Pipes Output"){ 192 $pipes = 'true'; 193 } 194 195 $updated = $rss->get_channel_tags('http://www.w3.org/2005/Atom', 'updated'); 196 $feedDate = strtotime($updated[0]["data"]); 197 */ 198 if ($rss->get_item()){ 199 $newestItem = strtotime($rss->get_item()->get_date()); 200 } else { 201 $newestItem = $t["lastItemDate"]; 202 } 203 $new = ""; 204 $rel='image'; 205 foreach ($rss->get_items() as $item) { 206 $imgstr = ""; 207 $itemDate = strtotime($item->get_date()); 208 $img = $item->get_links($rel); 209 if(($itemDate-$t["lastItemDate"]) > 0 ){ 210 // new content 211 //$img = $item->get_links($rel); 212 $author = $item->get_item_tags('', 'author'); 213 if (isset($author[0]['data'])){ 214 $author = $author[0]['data']; 215 }else{ 216 if ($author = $item->get_author()){ 217 $author = $author->get_name(); 218 } 219 } 220 $name = preg_replace('` \([^\]]*\)`', '', $author); 221 if (isset($img[0]) && $this->o["tp_item_image"] == 1){ 222 $imgstr = "<div style='float:left; padding-right:5px;' class='twPadItmImg'><img src='".$img[0]."' alt='".$name." - Profile Pic' height='48px' width='48px' \></div>"; 223 } 224 $new .= "<div style='".$this->o["tp_item_style"]."' class='twPadItm'>".$imgstr."<div class='twPadItmTxt'>@<a href='".$item->get_link(0)."'>".$name."</a>: ".$item->get_content(). " - <em>".date("d M y H:i", $itemDate)."</em><br style='clear:both;' /></div></div>"; 225 } 226 } 227 if ($new !=""){ 228 $insertBegin = "<div class=\"twPad\">"; 229 // Update page 230 if ($t["page"] != "[New Post]") { 231 $up_post = array(); 232 $up_post['ID'] = $t["page"]; 233 234 if (strpos($content, $insertBegin) !== false){ 235 $up_post['post_content'] = str_replace($insertBegin, $insertBegin.$new, $content); 236 } else { 237 $up_post['post_content'] = $content.$insertBegin.$new."</div>"; 238 } 239 240 wp_update_post( $up_post ); 241 $nextFeedDate = mktime(date("H") + $this->o["tp_refresh_period"], date("i"), date("s"), date("m") , date("d"), date("Y")); 242 } else { 243 // New post 244 $my_post = array(); 245 $dateString = date("F jS, Y"); 246 $my_post['post_title'] = str_replace('%DATE%', $dateString, $this->o["tp_post_title"]); 247 $import = $insertBegin.$new."</div>"; 248 $import = str_replace('%TWPAD%', $import, $this->o["tp_post_content"]); 249 $import = str_replace('%DATE%', $dateString, $import); 250 $my_post['post_content'] = $import; 251 $my_post['post_status'] = $this->o["tp_post_status"]; 252 $my_post['post_author'] = 1; 253 $my_post['post_category'] = array($this->o["tp_post_category"]); 254 $my_post['tags_input'] = $this->o["tp_post_tags"]; 255 256 // Insert the post into the database 257 wp_insert_post( $my_post ); 258 $dayofWeek = date("w"); 259 $i=1; 260 while (($i <= 6) && ($foundit == false)) { 261 if (($i+$dayofWeek) <=6 ){ 262 $weekidx = $i+$dayofWeek; 263 } else { 264 $weekidx = $i+$dayofWeek-6; 265 } 266 if (strpos($this->o['tp_post_days'],strval($weekidx))!== false){ 267 $nextFeedDate = strtotime("next ".date("l", mktime(12, 0, 0, 1, $weekidx+4, 1970))." ".$this->o['tp_post_time']); 268 $foundit = true; 269 } 270 $i++; 271 } 272 } 273 } 274 275 $this->o["tp_feeds"][$key]["lastItemDate"] = $newestItem; 276 $this->o["tp_feeds"][$key]["refresh"] = $nextFeedDate; 277 update_option("twitterpad-options", $this->o); 278 } 279 } 280 281 $this->o["tp_last_refresh"] = mktime(); 282 update_option("twitterpad-options", $this->o); 283 } 284 285 function admin_menu() { 286 add_submenu_page('options-general.php','TwitterPad', 'TwitterPad', 9, __FILE__, array($this, 'options_panel')); 287 } 288 289 function options_panel() { 290 $options = $this->o; 291 $status = $this->status; 292 include($this->plugin_path.'twpad-panel.php'); 293 } 294 } 295 296 $rssShare = new Twitterpad(); 297 } 298 57 ); 58 function Twitterpad() 59 { 60 $this->plugin_path_url(); 61 $this->install_plugin(); 62 $this->actions_filters(); 63 } 64 function plugin_path_url() 65 { 66 $this->plugin_url = WP_PLUGIN_URL . '/twitterpad/'; 67 $this->plugin_path = dirname(__FILE__) . '/'; 68 define('RSSEVERPOST_URL', $this->plugin_url); 69 define('RSSEVERPOST_PATH', $this->plugin_path); 70 } 71 function install_plugin() 72 { 73 $this->o = get_option('twitterpad-options'); 74 if (!is_array($this->o)) { 75 update_option('twitterpad-options', $this->default_options); 76 $this->o = get_option('twitterpad-options'); 77 } else { 78 foreach ($this->default_options as $key => $value) 79 if (!isset($this->o[$key])) 80 $this->o[$key] = $value; 81 $this->o["tp_revision"] = $this->default_options["tp_revision"]; 82 update_option('twitterpad-options', $this->o); 83 } 84 } 85 function actions_filters() 86 { 87 add_action('init', array(&$this, 'init')); 88 add_action('admin_menu', array(&$this, 'admin_menu')); 89 } 90 function init() 91 { 92 if ($_POST['tp_action'] == 'runow') { 93 check_admin_referer('twpad-2'); 94 $this->status .= "All feeds refreshed"; 95 $this->generate_post(); 96 } else { 97 if ($_POST['tp_action'] == 'reset') { 98 check_admin_referer('twpad-3'); 99 $this->status .= "Reset"; 100 $this->o = $this->default_options; 101 update_option("twitterpad-options", $this->default_options); 102 } elseif ($_POST['tp_action'] == 'delete') { 103 check_admin_referer('twpad-4'); 104 foreach ((array)$_POST['tpfeed'] as $post_id_del) { 105 unset($this->o["tp_feeds"][$post_id_del]); 106 } 107 $this->o["tp_feeds"] = array_values($this->o["tp_feeds"]); 108 update_option("twitterpad-options", $this->o); 109 $this->status = "Feed removed"; 110 } elseif ($_POST['tp_action'] == 'stylenow') { 111 check_admin_referer('twpad-5'); 112 $this->o["tp_item_style"] = $_POST['tp_item_style']; 113 $this->o["tp_item_image"] = isset($_POST['tp_item_image']) ? 1 : 0; 114 $this->o["tp_refresh_period"] = $_POST['tp_refresh_period']; 115 $this->status .= "Options updated."; 116 update_option("twitterpad-options", $this->o); 117 } elseif ($_POST['tp_action'] == 'post_template') { 118 check_admin_referer('twpad-6'); 119 $this->o["tp_post_days"] = $_POST['d1'] . $_POST['d2'] . $_POST['d3'] . $_POST['d4'] . $_POST['d5'] . $_POST['d6'] . $_POST['d0']; 120 $this->o["tp_post_time"] = $_POST['tp_post_time']; 121 $this->o["tp_post_title"] = $_POST['tp_post_title']; 122 $this->o["tp_post_content"] = $_POST['tp_post_content']; 123 $this->o["tp_post_status"] = $_POST['tp_post_status']; 124 $this->o["tp_post_category"] = $_POST['tp_post_category']; 125 $this->o["tp_post_tags"] = $_POST['tp_post_tags']; 126 if ($this->o["tp_post_days"] == "") { 127 $this->status .= "OOPS. You need to select at least one day for the post template"; 128 } 129 $this->status .= "Post template updated.<br>"; 130 update_option("twitterpad-options", $this->o); 131 } elseif ($_POST['tp_action'] == 'add') { 132 check_admin_referer('twpad-1', 'twpad-main'); 133 if (isset($_POST['tp_url']) && $_POST['tp_page'] != "") { 134 if ($this->valid_tp_feed($_POST['tp_url'])) { 135 $idx = sizeof($this->o["tp_feeds"]); 136 $this->o["tp_feeds"][$idx]['url'] = $_POST['tp_url']; 137 $this->o["tp_feeds"][$idx]['page'] = $_POST['tp_page']; 138 $this->o["tp_feeds"][$idx]['refresh'] = 0; 139 $this->o["tp_feeds"][$idx]["lastItemDate"] = 0; 140 $this->status = "Feed added."; 141 } else { 142 $this->status = "Feed is not valid."; 143 } 144 } else { 145 $this->status = "Please enter a valid url and page."; 146 } 147 update_option("twitterpad-options", $this->o); 148 } 149 $this->generate_post(); 150 } 151 } 152 function valid_tp_feed($url) 153 { 154 if ($url == "") 155 return; 156 $rss_status = false; 157 $rss = new SimplePie(); 158 $rss->set_feed_url($url); 159 $rss->enable_cache(false); 160 $rss->init(); 161 if ($rss->get_type() & SIMPLEPIE_TYPE_ALL) { 162 $rss_status = true; 163 } 164 return $rss_status; 165 } 166 function generate_post() 167 { 168 if (empty($this->o['tp_feeds'])) 169 return; 170 foreach ($this->o['tp_feeds'] as $key => $t) { 171 if ($this->o["tp_feeds"][$key]["refresh"] < mktime()) { 172 $rss = new SimplePie(); 173 $rss->set_feed_url($t["url"]); 174 $rss->enable_cache(false); 175 $rss->enable_order_by_date(false); 176 $rss->init(); 177 if ($t["page"] != "[New Post]") { 178 $page = get_post($t["page"]); 179 $content = $page->post_content; 180 } 181 /* 182 $gen = $rss->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description'); 183 if ($gen[0]['data'] == "Pipes Output"){ 184 $pipes = 'true'; 185 } 186 187 $updated = $rss->get_channel_tags('http://www.w3.org/2005/Atom', 'updated'); 188 $feedDate = strtotime($updated[0]["data"]); 189 */ 190 if ($rss->get_item()) { 191 $newestItem = strtotime($rss->get_item()->get_date()); 192 } else { 193 $newestItem = $t["lastItemDate"]; 194 } 195 $new = ""; 196 $rel = 'image'; 197 foreach ($rss->get_items() as $item) { 198 $imgstr = ""; 199 $itemDate = strtotime($item->get_date()); 200 $img = $item->get_links($rel); 201 if (($itemDate - $t["lastItemDate"]) > 0) { 202 // new content 203 //$img = $item->get_links($rel); 204 $author = $item->get_item_tags('', 'author'); 205 if (isset($author[0]['data'])) { 206 $author = $author[0]['data']; 207 } else { 208 if ($author = $item->get_author()) { 209 $author = $author->get_name(); 210 } 211 } 212 $name = preg_replace('` \([^\]]*\)`', '', $author); 213 if (isset($img[0]) && $this->o["tp_item_image"] == 1) { 214 $imgstr = "<div style='float:left; padding-right:5px;' class='twPadItmImg'><img src='" . $img[0] . "' alt='" . $name . " - Profile Pic' height='48px' width='48px' \></div>"; 215 } 216 $new .= "<div style='" . $this->o["tp_item_style"] . "' class='twPadItm'>" . $imgstr . "<div class='twPadItmTxt'>@<a href='" . $item->get_link(0) . "'>" . $name . "</a>: " . $item->get_content() . " - <em>" . date("d M y H:i", $itemDate) . "</em><br style='clear:both;' /></div></div>"; 217 } 218 } 219 if ($new != "") { 220 $insertBegin = "<div class=\"twPad\">"; 221 // Update page 222 if ($t["page"] != "[New Post]") { 223 $up_post = array(); 224 $up_post['ID'] = $t["page"]; 225 if (strpos($content, $insertBegin) !== false) { 226 $up_post['post_content'] = str_replace($insertBegin, $insertBegin . $new, $content); 227 } else { 228 $up_post['post_content'] = $content . $insertBegin . $new . "</div>"; 229 } 230 wp_update_post($up_post); 231 $nextFeedDate = mktime(date("H") + $this->o["tp_refresh_period"], date("i"), date("s"), date("m"), date("d"), date("Y")); 232 } else { 233 // New post 234 $my_post = array(); 235 $dateString = date("F jS, Y"); 236 $my_post['post_title'] = str_replace('%DATE%', $dateString, $this->o["tp_post_title"]); 237 $import = $insertBegin . $new . "</div>"; 238 $import = str_replace('%TWPAD%', $import, $this->o["tp_post_content"]); 239 $import = str_replace('%DATE%', $dateString, $import); 240 $my_post['post_content'] = $import; 241 $my_post['post_status'] = $this->o["tp_post_status"]; 242 $my_post['post_author'] = 1; 243 $my_post['post_category'] = array($this->o["tp_post_category"]); 244 $my_post['tags_input'] = $this->o["tp_post_tags"]; 245 // Insert the post into the database 246 wp_insert_post($my_post); 247 $dayofWeek = date("w"); 248 $i = 1; 249 while (($i <= 6) && ($foundit == false)) { 250 if (($i + $dayofWeek) <= 6) { 251 $weekidx = $i + $dayofWeek; 252 } else { 253 $weekidx = $i + $dayofWeek - 7; 254 } 255 if (strpos($this->o['tp_post_days'], strval($weekidx)) !== false) { 256 $nextFeedDate = strtotime("next " . date("l", mktime(12, 0, 0, 1, $weekidx + 4, 1970)) . " " . $this->o['tp_post_time']); 257 $foundit = true; 258 } 259 $i++; 260 } 261 } 262 } 263 $this->o["tp_feeds"][$key]["lastItemDate"] = $newestItem; 264 $this->o["tp_feeds"][$key]["refresh"] = $nextFeedDate; 265 update_option("twitterpad-options", $this->o); 266 } 267 } 268 $this->o["tp_last_refresh"] = mktime(); 269 update_option("twitterpad-options", $this->o); 270 } 271 function admin_menu() 272 { 273 add_submenu_page('options-general.php', 'TwitterPad', 'TwitterPad', 9, __FILE__, array($this, 'options_panel')); 274 } 275 function options_panel() 276 { 277 $options = $this->o; 278 $status = $this->status; 279 include($this->plugin_path . 'twpad-panel.php'); 280 } 281 } 282 $rssShare = new Twitterpad(); 283 } 299 284 ?>
Note: See TracChangeset
for help on using the changeset viewer.