Plugin Directory

Changeset 579290


Ignore:
Timestamp:
07/30/2012 03:41:43 PM (14 years ago)
Author:
tranchesdunet
Message:

version 0.2 : integration du choix des categories a exclure dans la version gratuite

Location:
my-trending-post/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • my-trending-post/trunk/admin_settings.php

    r572990 r579290  
     1<?php
     2$cats = explode(",",$options['cats']);
     3?>
    14<div class=wrap>
    25  <div class="icon32" id="icon-edit">
     
    2831      </div>
    2932     
     33      <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
    3034      <div id="post-body-content">
    3135        <div id="normal-sortables"
     
    3842             
    3943            <?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              
    4844              echo "<b>What you have with My Trending Post Lite:</b><br />
    4945              <ul class='mptadmin'>
     
    5248                <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>
    5349                <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>
    5451              </ul>
    5552              <b>What you have in addition with My Trending Post (Full Version):</b><br />
     
    6259                <li>The choice of a delay before retweeting the same article</li>
    6360                <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>
    6561              </ul>
    6662              ";
     63           
     64              echo "<table class='form-table mptadmin'>";
    6765             
     66              if($headdisplay)
     67              {
     68                echo "<tr><td></td><td>".$headdisplay."</td></tr>";
     69              }
    6870              if($bConnected)
    6971              {
     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               
    7086                $this->setTweet(false);//va affiche le tweet mais ne va pas le creer
    7187              }else{
    7288                _e("You must be logged with a Twitter account in order to continue the settings", 'mytrendingpost');
     89                echo "</table>";
    7390              }
     91             
    7492            ?>
    7593             
    7694            </div>
    7795          </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;?>
    78102        </div>
    79103      </div>
    80      
     104      </form>
    81105    </div>
    82106 
  • my-trending-post/trunk/my-trending-post-lite.php

    r572990 r579290  
    55Description: Allow you to search for trending topics on Twitter, and add a tweet with a content-related link to your blog
    66Author: Jean-Marc BIANCA (tranchesdunet)
    7 Version: 0.1
     7Version: 0.2
    88Author URI: http://www.tranchesdunet.com/
    99TODO:
     
    150150        }
    151151      }
    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     
    153170      include('admin_settings.php');
    154171    }//printadminpage
     
    160177      global $connection;
    161178      global $wpdb;
     179      $cats = $options['cats'];
    162180      $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 )
    167183      {
    168184        $topics[] = array('name' => $trend->name, 'url' => $trend->url);
     
    188204        echo "</h4>";
    189205        $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        }
    190216       
    191217        $sql = "SELECT DISTINCT p.post_title, p.post_name, CONCAT('#','".$t."') AS hashtag, p.post_date AS post_date, p.id
    192218                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."               
    194221                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."
    196224                UNION
    197225                SELECT DISTINCT p.post_title, p.post_name, CONCAT('#','".$t."') AS hashtag, p.post_date AS post_date, p.id
     
    200228                INNER JOIN ".$wpdb->term_taxonomy." t ON r.term_taxonomy_id = t.term_taxonomy_id
    201229                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."
    203232                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."
    205235                ORDER BY RAND() DESC LIMIT 1";
    206236        //print_r($sql);
  • my-trending-post/trunk/readme.txt

    r572990 r579290  
    88Requires at least: 3.1
    99Tested up to: 3.4.1
    10 Stable tag: 0.1
     10Stable tag: 0.2
    1111
    1212Automatically searches the Trending Topic on Twitter and send a tweet with a link to an article related in your blog
     
    2323* 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)
    2424* 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)**
    2526
    2627Additionaly, if you get the Full Version, you will have:
     
    55562. Activate the plugin through the 'Plugins' menu in WordPress
    56573. Go to the admin interface and authenticate you to a Twitter account
     584. If you want to exclude some categories from being tweeted, just check them and update your settings
    57594. You're done!
    5860
     
    8385= 0.1 =
    8486* 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  
    55.form-table {clear: none;}
    66.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.