Beispiel #1
0
 function RunNowX()
 {
     if (!isset($_POST['campaign_ID'])) {
         die('ERROR: ID no encontrado.');
     }
     $campaign_ID = $_POST['campaign_ID'];
     echo substr(WPeMatico::wpematico_dojob($campaign_ID), 0, -1);
     // borro el ultimo caracter que es un 0
     return '';
 }
    $activated = $campaign['activated'];
    $cronnextrun = $campaign['cronnextrun'];
    if (!$activated) {
        continue;
    }
    if ($cronnextrun >= current_time('timestamp')) {
        if ($cfg['logexternalcron']) {
            @($file_handle = fopen($filedir . sanitize_file_name($post->post_title . ".txt.log"), "w+"));
            $msg = 'Running WPeMatico external WP-Cron' . "\n";
            linelog($file_handle, $msg . PHP_EOL);
            echo $msg;
            $msg = $post->post_title . ' ' . "\n";
            linelog($file_handle, $msg . PHP_EOL);
            echo $msg;
        }
        $msg = WPeMatico::wpematico_dojob($post->ID);
        if ($cfg['logexternalcron']) {
            $msg = strip_tags($msg);
            $msg .= "\n";
            linelog($file_handle, $msg . PHP_EOL);
            echo '<pre>' . $msg . '</pre>';
        }
    }
}
if ($cfg['logexternalcron'] && $file_handle != false) {
    $msg = ' Success !' . "\n";
    linelog($file_handle, $msg . PHP_EOL);
    echo $msg;
    if ($file_handle !== FALSE) {
        fclose($file_handle);
    }
 public static function processAll()
 {
     $args = array('post_type' => 'wpematico', 'orderby' => 'ID', 'order' => 'ASC');
     $campaignsid = get_posts($args);
     $msglogs = "";
     foreach ($campaignsid as $campaignid) {
         @set_time_limit(0);
         $msglogs .= WPeMatico::wpematico_dojob($campaignid->ID);
     }
     return $msglogs;
 }
 static function wpem_cron_callback()
 {
     $args = array('post_type' => 'wpematico', 'orderby' => 'ID', 'order' => 'ASC', 'numberposts' => -1);
     $campaigns = get_posts($args);
     foreach ($campaigns as $post) {
         $campaign = WPeMatico::get_campaign($post->ID);
         $activated = $campaign['activated'];
         $cronnextrun = $campaign['cronnextrun'];
         if (!$activated) {
             continue;
         }
         if ($cronnextrun <= current_time('timestamp')) {
             WPeMatico::wpematico_dojob($post->ID);
         }
     }
 }