Plugin Directory

Changeset 756431


Ignore:
Timestamp:
08/15/2013 01:10:23 AM (13 years ago)
Author:
titopandub
Message:

Change option for scheduling tweets from interval based to days and times scheduling.

Location:
evergreen-post-tweeter/trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • evergreen-post-tweeter/trunk/css/evergreen-post-tweeter.css

    r748326 r756431  
    4747    text-align: left;
    4848}
     49
     50
     51#ept_opt .option ul.option-schedule-days {
     52    float: left;
     53    width: 650px;
     54    padding-top: 5px;
     55    padding-left: 0px;
     56    margin-top: 0px;
     57}
     58
     59#ept_opt .option ul.option-schedule-days label {
     60    text-align: left;
     61}
     62
     63#ept_opt .option ul.option-schedule-days .schedule-day-checkbox {
     64    float: left;
     65    width: 90px;
     66    text-align: center;
     67    border: solid 1px #808080;
     68}
     69
     70#ept_opt .option ul.option-schedule-days li.checked {
     71    background-color: #eeefff;
     72}
     73
     74#ept_opt .option ul.option-schedule-days li.schedule-day-checkbox input {
     75    display: none;
     76}
     77
     78#ept_opt .option ul.option-schedule-days li.schedule-day-checkbox label {
     79    width: 90px;
     80    text-align: center;
     81    font-weight: bold;
     82    padding-bottom: 5px;
     83}
     84
     85#ept_opt .option ol.option-schedule-times {
     86    float: left;
     87    width: 200px;
     88    padding-top: 5px;
     89    padding-left: 0px;
     90    margin-top: 5px;
     91    margin-left: 0px;
     92    list-style: none;
     93}
     94
     95#ept_opt .option ul.option-schedule-times label {
     96    text-align: left;
     97}
     98
    4999#ept_opt .option span {
    50100    display: block;
     
    53103    margin-top: 6px;**/
    54104    clear: left;
     105    color: #666;
    55106}
    56107
    57108#ept_opt p.submit {
    58109    overflow: hidden;
    59 }
    60 #ept_opt .option span {
    61     color: #666;
    62     display: block;
    63110}
    64111
     
    124171}
    125172
     173#add-item {
     174    float: left;
     175}
     176
     177#ept_opt .option span#scheduled-days {
     178    float: none;
     179    display: inline;
     180    color: #333;
     181}
     182
     183#schedule-times li  {
     184    position: relative;
     185}
     186
     187#schedule-times li .remove-time {
     188    position: absolute;
     189    top: 0px;
     190    cursor: pointer;
     191    font-size: 26px;
     192    padding: 3px 3px 3px 5px;
     193}
     194
    126195.updated a {
    127196    text-decoration: underline;
  • evergreen-post-tweeter/trunk/ept-admin.php

    r748326 r756431  
    9292
    9393       
    94         if(get_option('next_tweet_time')=='0'){
    95             $next_tweet_time = time()+ get_option('ept_opt_interval') * 60 * 60;
     94        if ( get_option('next_tweet_time')=='0' ){
     95            $next_tweet_time = ept_determine_next_update();
    9696            update_option('next_tweet_time', $next_tweet_time);
    9797        }
     98
    9899        //if submit and if bitly selected its fields are filled then save
    99100        if (isset($_POST['submit']) && $save) {
     
    229230            }
    230231           
    231             //tweet interval
    232             if (isset($_POST['ept_opt_interval'])) {
    233                 if (is_numeric($_POST['ept_opt_interval']) && $_POST['ept_opt_interval'] > 0) {
    234                     update_option('ept_opt_interval', $_POST['ept_opt_interval']);
    235                 } else {
    236                     update_option('ept_opt_interval', "4");
    237                 }
    238             }
    239            
    240         $next_tweet_time = time()+ get_option('ept_opt_interval') * 60 * 60;
    241         update_option('next_tweet_time', $next_tweet_time);
    242 
    243             //random interval
    244             if (isset($_POST['ept_opt_interval_slop'])) {
    245                 if (is_numeric($_POST['ept_opt_interval_slop']) && $_POST['ept_opt_interval_slop'] > 0) {
    246                     update_option('ept_opt_interval_slop', $_POST['ept_opt_interval_slop']);
    247                 } else {
    248                     update_option('ept_opt_interval_slop', "2");
    249                 }
    250             }
     232            $next_tweet_time = ept_determine_next_update();
     233            update_option('next_tweet_time', $next_tweet_time);
    251234
    252235            //minimum post age to tweet
     
    255238                    update_option('ept_opt_age_limit', $_POST['ept_opt_age_limit']);
    256239                } else {
    257                     update_option('ept_opt_age_limit', "30");
     240                    update_option('ept_opt_age_limit', "0");
    258241                }
    259242            }
     
    293276                }
    294277            }
     278
     279            // set schedule day - monday
     280            if (isset($_POST['ept_opt_schedule_day_mon'])) {
     281                update_option('ept_opt_schedule_day_mon', $_POST['ept_opt_schedule_day_mon']);
     282            } else {
     283                update_option('ept_opt_schedule_day_mon', "");
     284            }
     285
     286            // set schedule day - tuesday
     287            if (isset($_POST['ept_opt_schedule_day_tue'])) {
     288                update_option('ept_opt_schedule_day_tue', $_POST['ept_opt_schedule_day_tue']);
     289            } else {
     290                update_option('ept_opt_schedule_day_tue', "");
     291            }
     292
     293            // set schedule day - wednesday
     294            if (isset($_POST['ept_opt_schedule_day_wed'])) {
     295                update_option('ept_opt_schedule_day_wed', $_POST['ept_opt_schedule_day_wed']);
     296            } else {
     297                update_option('ept_opt_schedule_day_wed', "");
     298            }
     299
     300            // set schedule day - thursday
     301            if (isset($_POST['ept_opt_schedule_day_thu'])) {
     302                update_option('ept_opt_schedule_day_thu', $_POST['ept_opt_schedule_day_thu']);
     303            } else {
     304                update_option('ept_opt_schedule_day_thu', "");
     305            }
     306
     307            // set schedule day - friday
     308            if (isset($_POST['ept_opt_schedule_day_fri'])) {
     309                update_option('ept_opt_schedule_day_fri', $_POST['ept_opt_schedule_day_fri']);
     310            } else {
     311                update_option('ept_opt_schedule_day_fri', "");
     312            }
     313
     314            // set schedule day - saturday
     315            if (isset($_POST['ept_opt_schedule_day_sat'])) {
     316                update_option('ept_opt_schedule_day_sat', $_POST['ept_opt_schedule_day_sat']);
     317            } else {
     318                update_option('ept_opt_schedule_day_sat', "");
     319            }
     320
     321            // set schedule day - sunday
     322            if (isset($_POST['ept_opt_schedule_day_sun'])) {
     323                update_option('ept_opt_schedule_day_sun', $_POST['ept_opt_schedule_day_sun']);
     324            } else {
     325                update_option('ept_opt_schedule_day_sun', "");
     326            }
     327
     328            // set schedule time - counter
     329            if (isset($_POST['ept_opt_schedule_times_counter'])) {
     330                update_option('ept_opt_schedule_times_counter', $_POST['ept_opt_schedule_times_counter']);
     331            } else {
     332                update_option('ept_opt_schedule_times_counter', array());
     333            }
     334
     335            // set schedule time - hour
     336            if (isset($_POST['ept_opt_schedule_times_hour'])) {
     337                update_option('ept_opt_schedule_times_hour', $_POST['ept_opt_schedule_times_hour']);
     338            } else {
     339                update_option('ept_opt_schedule_times_hour', array());
     340            }
     341
     342            // set schedule time - minute
     343            if (isset($_POST['ept_opt_schedule_times_minute'])) {
     344                update_option('ept_opt_schedule_times_minute', $_POST['ept_opt_schedule_times_minute']);
     345            } else {
     346                update_option('ept_opt_schedule_times_minute', array());
     347            }
    295348       
    296349            //option to enable log
    297350            if ( isset($_POST['ept_enable_log'])) {
    298351                update_option('ept_enable_log', true);
    299         global $ept_debug;                                             
    300         $ept_debug->enable( true );
    301                
    302             }
    303             else{
     352                global $ept_debug;                                             
     353                $ept_debug->enable( true );
     354            } else{
    304355                update_option('ept_enable_log', false);
    305356                global $ept_debug;
    306         $ept_debug->enable( false );   
     357                $ept_debug->enable( false );   
    307358            }
    308359       
     
    322373        //tweet now clicked
    323374        elseif (isset($_POST['tweet'])) {
    324             update_option('ept_opt_last_update',time());
     375            update_option('ept_opt_last_update',time() );
    325376            $tweet_msg = ept_opt_tweet_old_post();
    326377            print('
     
    464515        if (!isset($twitter_hashtags)) {
    465516            $twitter_hashtags = ept_opt_HASHTAGS;
    466         }
    467 
    468         //interval
    469         $interval = get_option('ept_opt_interval');
    470         if (!(isset($interval) && is_numeric($interval))) {
    471             $interval = ept_opt_INTERVAL;
    472         }
    473 
    474         //random interval
    475         $slop = get_option('ept_opt_interval_slop');
    476         if (!(isset($slop) && is_numeric($slop))) {
    477             $slop = ept_opt_INTERVAL_SLOP;
    478517        }
    479518
     
    526565        }
    527566
     567        // get schedule day - monday
     568        $ept_opt_schedule_day_mon = get_option('ept_opt_schedule_day_mon');
     569        if (!(isset($ept_opt_schedule_day_mon))) {
     570            $ept_opt_schedule_day_mon = "";
     571        }
     572
     573        // get schedule day - tuesday
     574        $ept_opt_schedule_day_tue = get_option('ept_opt_schedule_day_tue');
     575        if (!(isset($ept_opt_schedule_day_tue))) {
     576            $ept_opt_schedule_day_tue = "";
     577        }
     578
     579        // get schedule day - wednesday
     580        $ept_opt_schedule_day_wed = get_option('ept_opt_schedule_day_wed');
     581        if (!(isset($ept_opt_schedule_day_wed))) {
     582            $ept_opt_schedule_day_wed = "";
     583        }
     584
     585        // get schedule day - thursday
     586        $ept_opt_schedule_day_thu = get_option('ept_opt_schedule_day_thu');
     587        if (!(isset($ept_opt_schedule_day_thu))) {
     588            $ept_opt_schedule_day_thu = "";
     589        }
     590
     591        // get schedule day - friday
     592        $ept_opt_schedule_day_fri = get_option('ept_opt_schedule_day_fri');
     593        if (!(isset($ept_opt_schedule_day_fri))) {
     594            $ept_opt_schedule_day_fri = "";
     595        }
     596
     597        // get schedule day - saturday
     598        $ept_opt_schedule_day_sat = get_option('ept_opt_schedule_day_sat');
     599        if (!(isset($ept_opt_schedule_day_sat))) {
     600            $ept_opt_schedule_day_sat = "";
     601        }
     602
     603        // get schedule day - sunday
     604        $ept_opt_schedule_day_sun = get_option('ept_opt_schedule_day_sun');
     605        if (!(isset($ept_opt_schedule_day_sun))) {
     606            $ept_opt_schedule_day_sun = "";
     607        }
     608
     609        $ept_opt_schedule_times_counter = get_option( 'ept_opt_schedule_times_counter' );
     610        if (!(isset($ept_opt_schedule_times_counter)) || ! is_array($ept_opt_schedule_times_counter)) {
     611            $ept_opt_schedule_times_counter = array();
     612        }
     613
     614        $ept_opt_schedule_times_hour = get_option( 'ept_opt_schedule_times_hour' );
     615        if (!(isset($ept_opt_schedule_times_hour)) || ! is_array($ept_opt_schedule_times_hour)) {
     616            $ept_opt_schedule_times_hour = array();
     617        }
     618
     619        $ept_opt_schedule_times_minute = get_option( 'ept_opt_schedule_times_minute' );
     620        if (!(isset($ept_opt_schedule_times_minute)) || ! is_array($ept_opt_schedule_times_minute)) {
     621            $ept_opt_schedule_times_minute = array();
     622        }
     623
    528624        $x = WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__));
    529625
     
    568664        $ept_tag_tweet = get_option('ept_tag_tweet');
    569665       
    570        
    571666        print('</div>
    572667                        </div>
    573668                                               
    574                         <div class="countdown_opt" style="width:100%;height:auto;overflow: hidden;float:none;border-bottom: dashed 1px #ccc;"><br />
     669                        <div class="countdown_opt" style="width:100%;height:auto;overflow: hidden;float:none;border-bottom: dotted 3px #eeefff;"><br />
    575670                        <label style="margin-left:40px;"><strong>Next Tweet coming in:</strong></label>
    576671                        <div id="defaultCountdown" style="width:20%;margin-left:15%;margin-bottom:40px;"></div>
     
    635730                    </div>
    636731                    </div>
    637                        
    638                         <div class="option" >
    639                             <label for="ept_opt_interval">' . __('Time Between Tweets: ', 'Evergreen') . '</label>
    640                             <input type="text" id="ept_opt_interval" maxlength="5" value="' . $interval . '" name="ept_opt_interval" /> Hour / Hours <strong>(0 will default to 4 hours.)</strong>
    641                                                        
    642                         </div>
    643732                        <div class="option" >
    644733                            <label for="ept_opt_age_limit">' . __('Minimum Age of Post: ', 'Evergreen') . '</label>
     
    684773
    685774                        <div class="option">
    686                             <label for="ept_opt_use_pause_tweet">' . __('Prevent Automatic Tweeting Between Certain Hours?: ', 'Evergreen') . '</label>
    687                             <input onchange="return showPauseTweet()" type="checkbox" name="ept_opt_use_pause_tweet" id="ept_opt_use_pause_tweet" ' . $use_pause_tweet . ' />
    688                         </div>
    689 
    690                         <div id="pausetweet">
    691                             <div class="option">
    692                                 <label class="ttip">' . __('Start Time to Pause Tweet: ', 'Evergreen') . ': </label>
    693                                     <input type="text" id="ept_opt_start_pause_time" value="' . $ept_opt_start_pause_time . '" name="ept_opt_start_pause_time" />
    694                                     <strong>Default 22:00</strong>
    695                             </div>
    696 
    697                             <div class="option">
    698                                 <label class="ttip">' . __('End Time to Pause Tweet: ', 'Evergreen') . ': </label>
    699                                     <input type="text" id="ept_opt_end_pause_time" value="' . $ept_opt_end_pause_time . '" name="ept_opt_end_pause_time" />
    700                                     <strong>Default 05:00</strong>
    701                             </div>
     775                            <label for="ept_opt_schedule_tweet">' . __('Schedule Tweets: ', 'Evergreen') . '</label>
     776                            <ul id="schedule-days-table" class="option-schedule-days">
     777                                <li class="schedule-day-checkbox' . (1 == $ept_opt_schedule_day_mon ? ' checked' : '') . '">
     778                                    <label><input type="checkbox" name="ept_opt_schedule_day_mon" value="1" id="day1" ' . checked( 1, $ept_opt_schedule_day_mon, false ) . ' />Monday</label>
     779                                </li>
     780                                <li class="schedule-day-checkbox' . (2 == $ept_opt_schedule_day_tue ? ' checked' : '') . '">
     781                                    <label><input type="checkbox" name="ept_opt_schedule_day_tue" value="2" id="day2" ' . checked( 2, $ept_opt_schedule_day_tue, false ) . ' />Tuesday</label>
     782                                </li>
     783                                <li class="schedule-day-checkbox' . (3 == $ept_opt_schedule_day_wed ? ' checked' : '') . '">
     784                                    <label><input type="checkbox" name="ept_opt_schedule_day_wed" value="3" id="day3" ' . checked( 3, $ept_opt_schedule_day_wed, false ) . ' />Wednesday</label>
     785                                </li>
     786                                <li class="schedule-day-checkbox' . (4 == $ept_opt_schedule_day_thu ? ' checked' : '') . '">
     787                                    <label><input type="checkbox" name="ept_opt_schedule_day_thu" value="4" id="day4" ' . checked( 4, $ept_opt_schedule_day_thu, false ) . ' />Thursday</label>
     788                                </li>
     789                                <li class="schedule-day-checkbox' . (5 == $ept_opt_schedule_day_fri ? ' checked' : '') . '">
     790                                    <label><input type="checkbox" name="ept_opt_schedule_day_fri" value="5" id="day5" ' . checked( 5, $ept_opt_schedule_day_fri, false ) . ' />Friday</label>
     791                                </li>
     792                                <li class="schedule-day-checkbox' . (6 == $ept_opt_schedule_day_sat ? ' checked' : '') . '">
     793                                    <label><input type="checkbox" name="ept_opt_schedule_day_sat" value="6" id="day6" ' . checked( 6, $ept_opt_schedule_day_sat, false ) . ' />Saturday</label>
     794                                </li>
     795                                <li class="schedule-day-checkbox' . (7 == $ept_opt_schedule_day_sun ? ' checked' : '') . '">
     796                                    <label><input type="checkbox" name="ept_opt_schedule_day_sun" value="7" id="day7" ' . checked( 7, $ept_opt_schedule_day_sun, false ) . ' />Sunday</label>
     797                                </li>
     798                            </ul>
     799                            <div style="clear: left;"></div>
     800                            <label></label>
     801                            <div>Tweet at these times on <span id="scheduled-days"></span><div>
     802                            <div style="clear: left;"></div>
     803                            <label></label>
     804                            <ol id="schedule-times" class="option-schedule-times">');
     805                                foreach ($ept_opt_schedule_times_counter as $key => $time) {
     806                                    print('
     807                                        <li>
     808                                            <input type="hidden" name="ept_opt_schedule_times_counter[]" />
     809                                            <select name="ept_opt_schedule_times_hour[]" style="width: 60px">
     810                                                ');
     811                                                for ($i=0; $i < 24; $i++) {
     812                                                    if ($i < 10)
     813                                                        $index = "0" . $i;
     814                                                    else
     815                                                        $index = "" . $i;
     816                                                    print('<option value="' . $index . '" ' . selected( $ept_opt_schedule_times_hour[$key], (String)$index ) . '>' . $index . '</option>');
     817                                                }
     818                                                print('
     819                                            </select>
     820                                            <select name="ept_opt_schedule_times_minute[]" style="width: 60px">
     821                                                ');
     822                                                for ($i=0; $i < 60; $i++) {
     823                                                    if ($i <= 9)
     824                                                        $index = "0" . $i;
     825                                                    else
     826                                                        $index = "" . $i;
     827                                                    print('<option value="' . $index . '" ' . selected( $ept_opt_schedule_times_minute[$key], (String)$index ) . '>' . $index . '</option>');
     828                                                }
     829                                                print('
     830                                            </select>
     831                                            <a class="remove-time tooltip" original-title="Remove posting time">×</a>
     832                                        </li>
     833                                    ');
     834                                }
     835                            print('
     836                            </ol>
     837                            <div style="clear: left;"></div>
     838                            <label></label>
     839                            <a id="add-time" class="button">Add Tweeting Time</a>
    702840                        </div>
    703841                                       
     
    752890        }
    753891    }
    754  if(trim(document.getElementById("ept_opt_interval").value) != "" && !isNumber(trim(document.getElementById("ept_opt_interval").value)))
    755         {
    756             alert("Enter only numeric in Minimum interval between tweet");
    757         document.getElementById("ept_opt_interval").focus();
    758         return false;
    759         }
     892
    760893        if(trim(document.getElementById("ept_opt_age_limit").value) != "" && !isNumber(trim(document.getElementById("ept_opt_age_limit").value)))
    761894        {
     
    809942}
    810943
    811 function showPauseTweet()
    812 {
    813                        
    814 
    815     if((document.getElementById("ept_opt_use_pause_tweet").checked))
    816         {
    817             document.getElementById("pausetweet").style.display="block";
    818         }
    819         else
    820         {
    821             document.getElementById("pausetweet").style.display="none";
    822         }
    823 }
    824944function setFormAction()
    825945{
     
    838958showURLAPI();
    839959showshortener();
    840 showPauseTweet();
    841960
    842961</script>');
    843 
    844 
    845 //echo "<script type='text/javascript' src='".plugins_url('countdown/jquery-1.7.1.min.js', __FILE__)."'></script>";
    846 
    847 // echo "<script type='text/javascript' src='".plugins_url('countdown/jquery.countdown.pack.js', __FILE__)."'></script>";
    848 
    849 
    850 // echo "<script type='text/javascript'>
    851 
    852 // </script>";
    853 
    854962    } else {
    855963        print('
  • evergreen-post-tweeter/trunk/ept-core.php

    r748326 r756431  
    133133    //check last tweet time against set interval and span
    134134    //also check if it isn't in pause time
    135     if (ept_opt_update_time() && ! ept_in_pause_time()) {
    136         update_option('ept_opt_last_update', time());
    137         ept_opt_tweet_old_post();
     135    // if (ept_opt_update_time() && ! ept_in_pause_time()) {
     136    //     update_option('ept_opt_last_update', current_time('timestamp', 0));
     137       //  ept_opt_tweet_old_post();
     138    // }
     139
     140    // if ( ept_opt_update_time() ) {
     141    //     update_option('ept_opt_last_update', current_time('timestamp', 0));
     142    //     ept_opt_tweet_old_post();
     143    // }
     144   
     145    if ( ept_check_day_update() && ept_new_to_update() ) {
     146        update_option('ept_opt_last_update', current_time('timestamp', 0));
     147        ept_opt_tweet_old_post();
    138148    }
    139149}
     
    281291        ept_w3tc_cache_flush();
    282292
    283         $next_tweet_time = time()+ get_option('ept_opt_interval') * 60 * 60;
     293        $next_tweet_time = ept_determine_next_update();
    284294        update_option('next_tweet_time', $next_tweet_time);
    285295
     
    560570//check time and update the last tweet time
    561571function ept_opt_update_time() {
    562 
    563    
    564         return ept_to_update();
    565    
     572    return ept_to_update();
    566573}
    567574
    568575ept_w3tc_cache_flush();
     576
     577function ept_new_to_update()
     578{
     579    global $wpdb;
     580    $last  = $wpdb->get_var("select SQL_NO_CACHE option_value from $wpdb->options where option_name = 'ept_opt_last_update';");
     581
     582    $ept_opt_schedule_times_counter = get_option( 'ept_opt_schedule_times_counter' );
     583    if (!(isset($ept_opt_schedule_times_counter)) || ! is_array($ept_opt_schedule_times_counter)) {
     584        $ept_opt_schedule_times_counter = array();
     585    }
     586
     587    $ept_opt_schedule_times_hour = get_option( 'ept_opt_schedule_times_hour' );
     588    if (!(isset($ept_opt_schedule_times_hour)) || ! is_array($ept_opt_schedule_times_hour)) {
     589        $ept_opt_schedule_times_hour = array();
     590    }
     591
     592    $ept_opt_schedule_times_minute = get_option( 'ept_opt_schedule_times_minute' );
     593    if (!(isset($ept_opt_schedule_times_minute)) || ! is_array($ept_opt_schedule_times_minute)) {
     594        $ept_opt_schedule_times_minute = array();
     595    }
     596
     597    $ret = false;
     598
     599
     600    foreach ($ept_opt_schedule_times_counter as $key => $time) {
     601        $ept_time_start = strtotime($ept_opt_schedule_times_hour[$key] . ':' . $ept_opt_schedule_times_minute[$key]);
     602        $ept_time_end = $ept_time_start + (60 * 10);
     603        if (
     604            $ept_time_start < current_time('timestamp', 0) &&
     605            current_time('timestamp', 0) < $ept_time_end &&
     606            ( ! ( $ept_time_start < $last && $last < $ept_time_end ) )
     607            ) {
     608            $ret = true;
     609            break;
     610        }
     611    }
     612
     613    return $ret;
     614}
     615
     616function ept_determine_next_update()
     617{
     618    $ept_opt_schedule_times_counter = get_option( 'ept_opt_schedule_times_counter' );
     619    if (!(isset($ept_opt_schedule_times_counter)) || ! is_array($ept_opt_schedule_times_counter)) {
     620        $ept_opt_schedule_times_counter = array();
     621    }
     622
     623    $ept_opt_schedule_times_hour = get_option( 'ept_opt_schedule_times_hour' );
     624    if (!(isset($ept_opt_schedule_times_hour)) || ! is_array($ept_opt_schedule_times_hour)) {
     625        $ept_opt_schedule_times_hour = array();
     626    }
     627
     628    $ept_opt_schedule_times_minute = get_option( 'ept_opt_schedule_times_minute' );
     629    if (!(isset($ept_opt_schedule_times_minute)) || ! is_array($ept_opt_schedule_times_minute)) {
     630        $ept_opt_schedule_times_minute = array();
     631    }
     632
     633    $ept_times = array();
     634
     635    foreach ($ept_opt_schedule_times_counter as $key => $value) {
     636   
     637        $ept_time_start = strtotime($ept_opt_schedule_times_hour[$key] . ':' . $ept_opt_schedule_times_minute[$key], current_time('timestamp', 0));
     638        $remaining_time = $ept_time_start - current_time('timestamp', 0);
     639        if ( 0 < $remaining_time ) {
     640            $ept_times[] = $remaining_time;
     641        }
     642    }
     643
     644    // return $ept_times;
     645
     646    if ( empty($ept_times) ) {
     647        return 0;
     648    }
     649
     650    return (Integer)(time() + $ept_times[min(array_keys($ept_times, min($ept_times)))]);
     651}
     652
     653function ept_check_day_update()
     654{
     655    $current_day = date( 'N', current_time('timestamp', 0) );
     656    $ept_opt_schedule_day_mon = get_option('ept_opt_schedule_day_mon');
     657    $ept_opt_schedule_day_tue = get_option('ept_opt_schedule_day_tue');
     658    $ept_opt_schedule_day_wed = get_option('ept_opt_schedule_day_wed');
     659    $ept_opt_schedule_day_thu = get_option('ept_opt_schedule_day_thu');
     660    $ept_opt_schedule_day_fri = get_option('ept_opt_schedule_day_fri');
     661    $ept_opt_schedule_day_sat = get_option('ept_opt_schedule_day_sat');
     662    $ept_opt_schedule_day_sun = get_option('ept_opt_schedule_day_sun');
     663    $ret = false;
     664
     665    if ($current_day == $ept_opt_schedule_day_mon) {
     666        $ret = true;
     667    } else if ($current_day == $ept_opt_schedule_day_tue) {
     668        $ret = true;
     669    } else if ($current_day == $ept_opt_schedule_day_wed) {
     670        $ret = true;
     671    } else if ($current_day == $ept_opt_schedule_day_thu) {
     672        $ret = true;
     673    } else if ($current_day == $ept_opt_schedule_day_fri) {
     674        $ret = true;
     675    } else if ($current_day == $ept_opt_schedule_day_sat) {
     676        $ret = true;
     677    } else if ($current_day == $ept_opt_schedule_day_sun) {
     678        $ret = true;
     679    }
     680   
     681    return $ret;
     682}
    569683
    570684function ept_to_update() {
     
    572686    //have to use normal query to prevent the caching plug-in from caching the last update time
    573687    $last  = $wpdb->get_var("select SQL_NO_CACHE option_value from $wpdb->options where option_name = 'ept_opt_last_update';");
    574     //$last_test = get_option('ept_opt_last_update');
    575688    $interval = get_option('ept_opt_interval');
    576689    $slop = get_option('ept_opt_interval_slop');
     
    584697    }
    585698   
    586    
    587699    if (!(isset($slop))) {
    588700        $slop = ept_opt_INTERVAL_SLOP;
     
    593705    }
    594706   
    595    
    596     $passed = time() - $last;
    597         //old testing code to test the actual values going into the DB
    598     //$wpdb->query("insert into wp_timetable (time,last,ret,url) values('".time()."',$last,$passed,'".$_SERVER['PHP_SELF']."');");
     707    $passed = current_time('timestamp', 0) - $last;
    599708
    600709    $interval = $interval * 60 * 60;
     
    699808    update_option('ept_opt_add_text','');
    700809    update_option('ept_opt_add_text_at','beginning');
    701     update_option('ept_opt_age_limit',30);
    702810    update_option('ept_opt_bitly_key','');
    703811    update_option('ept_opt_bitly_user','');
     
    710818    update_option('ept_opt_hashtag_length','20');
    711819    update_option('ept_opt_include_link','yes');
    712     update_option('ept_opt_interval',4);
    713     update_option('ept_opt_interval_slop',2);
    714820    delete_option('ept_opt_last_update');
    715     update_option('ept_opt_max_age_limit',60);
     821    update_option('ept_opt_age_limit', 0);
     822    update_option('ept_opt_max_age_limit', 0);
    716823    update_option('ept_opt_omit_cats','');
    717824    update_option('ept_opt_tweet_type','title');
     
    723830    update_option('ept_cat_tweet', '');
    724831    update_option('ept_tag_tweet', '');
    725     update_option('ept_opt_start_pause_time', "22:00");
    726     update_option('ept_opt_end_pause_time', "05:00");
    727832}
    728833
  • evergreen-post-tweeter/trunk/evergreen.php

    r748326 r756431  
    55Description: Evergreen Post Tweeter enables you to automatically tweet out links to old posts based upon a tag or tags.
    66Author: Tom Ewer
    7 Version: 1.7
     7Version: 1.8
    88Author URI: http://www.leavingworkbehind.com/about-me/
    99*/ 
     
    3030    wp_register_script( 'ept_plugin_script_countdown', plugins_url( 'countdown/jquery.countdown.min.js', __FILE__ ) );
    3131    // don't finish
    32     wp_register_script( 'ept_plugin_script_app', plugins_url( 'countdown/ept-app.js', __FILE__) );
     32    // wp_register_script( 'ept_plugin_script_app', plugins_url( 'countdown/ept-app.js', __FILE__) );
    3333}
    3434
     
    3636    /* Link our already registered script to a page */
    3737    wp_enqueue_script( 'ept_plugin_script_countdown' );
    38     wp_enqueue_script( 'ept_plugin_script_app' );
     38    wp_enqueue_script( 'ept_plugin_script_app', plugins_url( 'countdown/ept-app.js', __FILE__), array( 'jquery', 'ept_plugin_script_countdown' ) );
     39    wp_enqueue_script( 'ept_plugin_application', plugins_url( 'js/application.js', __FILE__ ), array( 'jquery' ) );
    3940    $next_tweet_time = get_option('next_tweet_time') ;
    4041    wp_localize_script( 'ept_plugin_script_app', 'nextTweetTime', $next_tweet_time );
     
    5657define('ept_opt_INTERVAL', 4);
    5758define('ept_opt_INTERVAL_SLOP', 4);
    58 define('ept_opt_AGE_LIMIT', 30); // 120 days
    59 define('ept_opt_MAX_AGE_LIMIT', 60); // 120 days
     59define('ept_opt_AGE_LIMIT', 0); // 0 days
     60define('ept_opt_MAX_AGE_LIMIT', 0); // 0 days
    6061define('ept_opt_OMIT_CATS', "");
    6162define('ept_opt_TWEET_PREFIX',"");
     
    7071$ept_db_version = "1.0";
    7172
    72    function ept_admin_actions() { 
    73         $page_hook_suffix = add_submenu_page(
    74                                 'options-general.php',
    75                                 "Evergreen Post Tweeter Settings",
    76                                 "Evergreen Post Tweeter",
    77                                 1,
    78                                 "Evergreen",
    79                                 "ept_admin"
    80                             );
    81         add_action('admin_print_scripts-' . $page_hook_suffix, 'ept_admin_scripts');
    82    
    83    
    84     add_action('admin_menu', 'ept_admin_actions'); 
    85     add_action('admin_head', 'ept_opt_head_admin');
    86     add_action('init','ept_tweet_old_post');
    87     add_action('admin_init','ept_authorize',1);
     73function ept_admin_actions() { 
     74    $page_hook_suffix = add_submenu_page(
     75                            'options-general.php',
     76                            "Evergreen Post Tweeter Settings",
     77                            "Evergreen Post Tweeter",
     78                            1,
     79                            "Evergreen",
     80                            "ept_admin"
     81                        );
     82    add_action('admin_print_scripts-' . $page_hook_suffix, 'ept_admin_scripts');
     83
     84
     85add_action('admin_menu', 'ept_admin_actions'); 
     86add_action('admin_head', 'ept_opt_head_admin');
     87add_action('init','ept_tweet_old_post');
     88add_action('admin_init','ept_authorize',1);
    8889       
    89         function ept_authorize()
    90         {
    91              
     90function ept_authorize()
     91{
     92     
     93
     94    if ( isset( $_REQUEST['oauth_token'] ) ) {
     95        $auth_url= str_replace('oauth_token', 'oauth_token1', ept_currentPageURL());
     96        $ept_url = get_option('ept_opt_admin_url') . substr($auth_url,strrpos($auth_url, "page=Evergreen") + strlen("page=Evergreen"));
     97        echo '<script language="javascript">window.open ("'.$ept_url.'","_self")</script>';
    9298       
    93             if ( isset( $_REQUEST['oauth_token'] ) ) {
    94                 $auth_url= str_replace('oauth_token', 'oauth_token1', ept_currentPageURL());
    95                 $ept_url = get_option('ept_opt_admin_url') . substr($auth_url,strrpos($auth_url, "page=Evergreen") + strlen("page=Evergreen"));
    96                 echo '<script language="javascript">window.open ("'.$ept_url.'","_self")</script>';
    97                
    98                 die;
    99             }
    100        
    101         }
     99        die;
     100    }
     101
     102}
    102103       
    103104add_filter('plugin_action_links', 'ept_plugin_action_links', 10, 2);
  • evergreen-post-tweeter/trunk/readme.txt

    r748326 r756431  
    55Tags: twitter, auto tweet
    66Requires at least: 3.5
    7 Tested up to: 3.5.2
    8 Stable tag: 1.7
     7Tested up to: 3.6
     8Stable tag: 1.8
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5656== Upgrade Notice ==
    5757
     58= 1.8 =
     59* Change option for scheduling tweets from interval based to days and times scheduling.
     60* Remove option Time Between Tweets.
     61* Remove option to Prevent Automatic Tweeting Between Certain Hours.
     62
    5863= 1.7 =
    5964* Add option to tracking url click on Twitter (Google Analytics).
     
    95100== Changelog ==
    96101
     102= 1.8 =
     103* Change option for scheduling tweets from interval based to days and times scheduling.
     104* Remove option Time Between Tweets.
     105* Remove option to Prevent Automatic Tweeting Between Certain Hours.
     106
    97107= 1.7 =
    98108* Add option to tracking url click on Twitter (Google Analytics).
Note: See TracChangeset for help on using the changeset viewer.