Changeset 579290
- Timestamp:
- 07/30/2012 03:41:43 PM (14 years ago)
- Location:
- my-trending-post/trunk
- Files:
-
- 4 edited
-
admin_settings.php (modified) (5 diffs)
-
my-trending-post-lite.php (modified) (5 diffs)
-
readme.txt (modified) (4 diffs)
-
styles.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
my-trending-post/trunk/admin_settings.php
r572990 r579290 1 <?php 2 $cats = explode(",",$options['cats']); 3 ?> 1 4 <div class=wrap> 2 5 <div class="icon32" id="icon-edit"> … … 28 31 </div> 29 32 33 <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>"> 30 34 <div id="post-body-content"> 31 35 <div id="normal-sortables" … … 38 42 39 43 <?php 40 echo "<table class='form-table mptadmin'>";41 42 if($headdisplay)43 {44 echo "<tr><td></td><td>".$headdisplay."</td></tr>";45 }46 echo "</table>";47 48 44 echo "<b>What you have with My Trending Post Lite:</b><br /> 49 45 <ul class='mptadmin'> … … 52 48 <li>A <b>smart algorithm</b> to separate concatenated camel words<br />(e.g. #10FavouriteBands ==> 10 Favourite Bands) and so increase the matching between yours posts and the trending topics (often concatenated)</li> 53 49 <li>The post sent will be flagged and so won't be sent again until 7 days</li> 50 <li>The possibility of <b>excluding one or more categories</b> of article to be tweeted <span class='new'>(Now available in the Lite version!!)</span></li> 54 51 </ul> 55 52 <b>What you have in addition with My Trending Post (Full Version):</b><br /> … … 62 59 <li>The choice of a delay before retweeting the same article</li> 63 60 <li>The possibility to <b>use an url shortener</b> in your tweets (tinyurl or Bit.ly) to prevent exceeding the 140char limit of Twitter</li> 64 <li>The possibility of <b>excluding one or more categories</b> of article to be tweeted</li>65 61 </ul> 66 62 "; 63 64 echo "<table class='form-table mptadmin'>"; 67 65 66 if($headdisplay) 67 { 68 echo "<tr><td></td><td>".$headdisplay."</td></tr>"; 69 } 68 70 if($bConnected) 69 71 { 72 $list_cat = get_categories(); 73 echo "<tr><th>".__("Categories to exclude:","mytrendingpost")."</th><td>"; 74 foreach ($list_cat as $cat) 75 { 76 echo "<input type='checkbox' value='".$cat->cat_ID."' name='cats[]'"; 77 if(in_array($cat->cat_ID, $cats)) 78 { 79 echo " checked"; 80 } 81 echo " /> ".$cat->cat_name."<br />"; 82 } 83 echo "</td></tr>"; 84 echo "</table>"; 85 70 86 $this->setTweet(false);//va affiche le tweet mais ne va pas le creer 71 87 }else{ 72 88 _e("You must be logged with a Twitter account in order to continue the settings", 'mytrendingpost'); 89 echo "</table>"; 73 90 } 91 74 92 ?> 75 93 76 94 </div> 77 95 </div> 96 <?php if($bConnected):?> 97 <div class="submit"> 98 <input class="button-primary action" type="submit" name="update_myTrendingPostSettings" 99 value="<?php _e('Update', 'mytrendingpost') ?>" /> 100 </div> 101 <?php endif;?> 78 102 </div> 79 103 </div> 80 104 </form> 81 105 </div> 82 106 -
my-trending-post/trunk/my-trending-post-lite.php
r572990 r579290 5 5 Description: Allow you to search for trending topics on Twitter, and add a tweet with a content-related link to your blog 6 6 Author: Jean-Marc BIANCA (tranchesdunet) 7 Version: 0. 17 Version: 0.2 8 8 Author URI: http://www.tranchesdunet.com/ 9 9 TODO: … … 150 150 } 151 151 } 152 152 153 //sauvegarde des options 154 if(isset($_POST['update_myTrendingPostSettings'])) 155 { 156 if(isset($_POST['cats'])) 157 { 158 $cats = implode(",",$_POST['cats']); 159 $options['cats'] = $cats; 160 }else{ 161 $options['cats'] = ''; 162 } 163 164 update_option($this->adminOptionName, $options); 165 print '<div class="updated"><p><strong>'; 166 _e("Settings updated","myTrendingPost"); 167 print '</strong></p></div>'; 168 } 169 153 170 include('admin_settings.php'); 154 171 }//printadminpage … … 160 177 global $connection; 161 178 global $wpdb; 179 $cats = $options['cats']; 162 180 $topics = array(); 163 $current = "http://api.twitter.com/1/trends/1.json"; 164 165 $json_output = json_decode(file_get_contents($current)); 166 foreach ($json_output[0]->trends as $trend ) 181 $current = $connection->get("trends/1"); 182 foreach ($current[0]->trends as $trend ) 167 183 { 168 184 $topics[] = array('name' => $trend->name, 'url' => $trend->url); … … 188 204 echo "</h4>"; 189 205 $datelimit = current_time('timestamp') - $options['delay'];//en timestamp 206 $selectcat = ""; 207 $querycat = ""; 208 209 if(strlen($cats) > 0) 210 { 211 $selectcat = " LEFT JOIN ".$wpdb->term_relationships." rcat ON p.id = rcat.object_id 212 LEFT JOIN ".$wpdb->term_taxonomy." tcat ON rcat.term_taxonomy_id = tcat.term_taxonomy_id 213 LEFT JOIN ".$wpdb->terms." tscat ON tcat.term_id = tscat.term_id "; 214 $querycat = " AND tcat.taxonomy = 'category' AND tscat.term_id NOT IN (".$cats.") "; 215 } 190 216 191 217 $sql = "SELECT DISTINCT p.post_title, p.post_name, CONCAT('#','".$t."') AS hashtag, p.post_date AS post_date, p.id 192 218 FROM ".$wpdb->posts." p 193 LEFT JOIN ".$wpdb->postmeta." m ON p.ID = m.post_id AND m.meta_key = 'MTP_DATE' 219 LEFT JOIN ".$wpdb->postmeta." m ON p.ID = m.post_id AND m.meta_key = 'MTP_DATE'" 220 .$selectcat." 194 221 WHERE p.post_status = 'publish' AND p.post_type = 'post' AND p.post_title REGEXP '[[:<:]]".$t."[[:>:]]' 195 AND (m.meta_value IS NULL OR m.meta_value < ".$datelimit.") 222 AND (m.meta_value IS NULL OR m.meta_value < ".$datelimit.")" 223 .$querycat." 196 224 UNION 197 225 SELECT DISTINCT p.post_title, p.post_name, CONCAT('#','".$t."') AS hashtag, p.post_date AS post_date, p.id … … 200 228 INNER JOIN ".$wpdb->term_taxonomy." t ON r.term_taxonomy_id = t.term_taxonomy_id 201 229 INNER JOIN ".$wpdb->terms." ts ON t.term_id = ts.term_id AND ts.name = '".$t."' 202 LEFT JOIN ".$wpdb->postmeta." m ON p.ID = m.post_id AND m.meta_key = 'MTP_DATE' 230 LEFT JOIN ".$wpdb->postmeta." m ON p.ID = m.post_id AND m.meta_key = 'MTP_DATE'" 231 .$selectcat." 203 232 WHERE p.post_status = 'publish' AND p.post_type = 'post' 204 AND (m.meta_value IS NULL OR m.meta_value < ".$datelimit.") 233 AND (m.meta_value IS NULL OR m.meta_value < ".$datelimit.")" 234 .$querycat." 205 235 ORDER BY RAND() DESC LIMIT 1"; 206 236 //print_r($sql); -
my-trending-post/trunk/readme.txt
r572990 r579290 8 8 Requires at least: 3.1 9 9 Tested up to: 3.4.1 10 Stable tag: 0. 110 Stable tag: 0.2 11 11 12 12 Automatically searches the Trending Topic on Twitter and send a tweet with a link to an article related in your blog … … 23 23 * A **smart algorithm** to separate concatenated camel words (e.g. #10FavouriteBands ==> 10 Favourite Bands) and so increase the matching between yours posts and the trending topics (often concatenated) 24 24 * The post sent will be flagged and so won't be sent again until 7 days 25 * The possibility of **excluding one or more categories** of article to be tweeted **(Now available in the Lite version)** 25 26 26 27 Additionaly, if you get the Full Version, you will have: … … 55 56 2. Activate the plugin through the 'Plugins' menu in WordPress 56 57 3. Go to the admin interface and authenticate you to a Twitter account 58 4. If you want to exclude some categories from being tweeted, just check them and update your settings 57 59 4. You're done! 58 60 … … 83 85 = 0.1 = 84 86 * First public release 87 88 = 0.2 = 89 * Swapping the "Excluding categories" feature from Full version to Lite version -
my-trending-post/trunk/styles.css
r572990 r579290 5 5 .form-table {clear: none;} 6 6 .mptadmin LI {padding-left:20px; list-style-type: disc; list-style-position: inside;} 7 .mptadmin .new {color: #f80303; font-weight: bold;}
Note: See TracChangeset
for help on using the changeset viewer.