コード例 #1
0
 public function __construct($campaign_id)
 {
     global $wpdb, $campaign_log_message, $jobwarnings, $joberrors;
     $jobwarnings = 0;
     $joberrors = 0;
     @ini_set('safe_mode', 'Off');
     //disable safe mode
     @ini_set('ignore_user_abort', 'Off');
     //Set PHP ini setting
     ignore_user_abort(true);
     //user can't abort script (close windows or so.)
     $this->campaign_id = $campaign_id;
     //set campaign id
     $this->campaign = WPeMatico::get_campaign($this->campaign_id);
     //$this->fetched_posts = $this->campaign['postscount'];
     $this->cfg = get_option(WPeMatico::OPTION_KEY);
     // new actions
     if ((int) $this->cfg['throttle'] > 0) {
         add_action('wpematico_inserted_post', array('WPeMatico', 'throttling_inserted_post'));
     }
     //set function for PHP user defined error handling
     if (defined('WP_DEBUG') and WP_DEBUG) {
         set_error_handler('wpematico_joberrorhandler', E_ALL | E_STRICT);
     } else {
         set_error_handler('wpematico_joberrorhandler', E_ALL & ~E_NOTICE);
     }
     //Set job start settings
     $this->campaign['starttime'] = current_time('timestamp');
     //set start time for job
     $this->campaign['cronnextrun'] = WPeMatico::time_cron_next($this->campaign['cron']);
     //set next run
     $this->campaign['lastpostscount'] = 0;
     // Lo pone en 0 y lo asigna al final
     WPeMatico::update_campaign($this->campaign_id, $this->campaign);
     //Save start time data
     if (has_action('Wpematico_init_fetching')) {
         do_action('Wpematico_init_fetching', $this->campaign);
     }
     //check max script execution tme
     if (ini_get('safe_mode') or strtolower(ini_get('safe_mode')) == 'on' or ini_get('safe_mode') == '1') {
         trigger_error(sprintf(__('PHP Safe Mode is on!!! Max exec time is %1$d sec.', WPeMatico::TEXTDOMAIN), ini_get('max_execution_time')), E_USER_WARNING);
     }
     // check function for memorylimit
     if (!function_exists('memory_get_usage')) {
         ini_set('memory_limit', apply_filters('admin_memory_limit', '256M'));
         //Wordpress default
         trigger_error(sprintf(__('Memory limit set to %1$s ,because can not use PHP: memory_get_usage() function to dynamically increase the Memory!', WPeMatico::TEXTDOMAIN), ini_get('memory_limit')), E_USER_WARNING);
     }
     //run job parts
     $postcount = 0;
     $this->feeds = $this->campaign['campaign_feeds'];
     // --- Obtengo los feeds de la campaña
     foreach ($this->feeds as $feed) {
         $postcount += $this->processFeed($feed);
         #- ---- Proceso todos los feeds
     }
     $this->fetched_posts += $postcount;
     $this->fetch_end();
     // if everything ok call fetch_end  and end class
 }
コード例 #2
0
 public static function create_meta_boxes()
 {
     global $post, $campaign_data, $cfg;
     $campaign_data = WPeMatico::get_campaign($post->ID);
     //$campaign_data = self :: check_campaigndata($campaign_data);
     $cfg = get_option(WPeMatico::OPTION_KEY);
     $cfg = WPeMatico::check_options($cfg);
     //	add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args );
     add_meta_box('cron-box', __('Campaign Schedule', WPeMatico::TEXTDOMAIN), array('WPeMatico_Campaign_edit', 'cron_box'), 'wpematico', 'side', 'default');
     add_meta_box('cat-box', __('Campaign Categories', WPeMatico::TEXTDOMAIN), array('WPeMatico_Campaign_edit', 'cat_box'), 'wpematico', 'side', 'default');
     add_meta_box('tags-box', __('Tags generation', WPeMatico::TEXTDOMAIN), array('WPeMatico_Campaign_edit', 'tags_box'), 'wpematico', 'side', 'default');
     add_meta_box('log-box', __('Send log', WPeMatico::TEXTDOMAIN), array('WPeMatico_Campaign_edit', 'log_box'), 'wpematico', 'side', 'default');
     add_meta_box('feeds-box', __('Feeds for this Campaign', WPeMatico::TEXTDOMAIN), array('WPeMatico_Campaign_edit', 'feeds_box'), 'wpematico', 'normal', 'default');
     add_meta_box('options-box', __('Options for this campaign', WPeMatico::TEXTDOMAIN), array('WPeMatico_Campaign_edit', 'options_box'), 'wpematico', 'normal', 'default');
     add_meta_box('images-box', __('Options for images', WPeMatico::TEXTDOMAIN), array('WPeMatico_Campaign_edit', 'images_box'), 'wpematico', 'normal', 'default');
     add_meta_box('template-box', __('Post Template', WPeMatico::TEXTDOMAIN), array('WPeMatico_Campaign_edit', 'template_box'), 'wpematico', 'normal', 'default');
     if ($cfg['enableword2cats']) {
         // Si está habilitado en settings, lo muestra
         add_meta_box('word2cats-box', __('Word to Category options', WPeMatico::TEXTDOMAIN), array('WPeMatico_Campaign_edit', 'word2cats_box'), 'wpematico', 'normal', 'default');
     }
     if ($cfg['enablerewrite']) {
         // Si está habilitado en settings, lo muestra
         add_meta_box('rewrite-box', __('Rewrite options', WPeMatico::TEXTDOMAIN), array('WPeMatico_Campaign_edit', 'rewrite_box'), 'wpematico', 'normal', 'default');
     }
     //***** Call nonstatic
     if ($cfg['nonstatic']) {
         NoNStatic::meta_boxes($campaign_data, $cfg);
     }
     // Publish Meta_box edited
     add_action('post_submitbox_start', array(__CLASS__, 'post_submitbox_start'));
 }
コード例 #3
0
    public static function create_meta_boxes()
    {
        global $post, $campaign_data, $cfg, $helptip;
        $campaign_data = WPeMatico::get_campaign($post->ID);
        $campaign_data = apply_filters('wpematico_check_campaigndata', $campaign_data);
        $cfg = get_option(WPeMatico::OPTION_KEY);
        $cfg = apply_filters('wpematico_check_options', $cfg);
        $helptip = array('rewrites' => __('The rewrite feature allow you to replace words or phrases of the content with the text you specify.', WPeMatico::TEXTDOMAIN) . ' ' . __('Also can use this feature to make simple links from some words with origin and re-link fields.', WPeMatico::TEXTDOMAIN) . '<br>' . __('For examples click on [?] below.', WPeMatico::TEXTDOMAIN), 'feeds' => __('You must type at least one feed url.', WPeMatico::TEXTDOMAIN) . '  ' . __('(Less feeds equal less used resources when fetching).', WPeMatico::TEXTDOMAIN) . ' ' . __('Type the domain name to try to autodetect the feed url.', WPeMatico::TEXTDOMAIN), 'itemfetch' => __('Items to fetch PER every feed above.', WPeMatico::TEXTDOMAIN) . '  ' . __('Recommended values are between 3 and 5 fetching more times to not lose items.', WPeMatico::TEXTDOMAIN) . '  ' . __('Set it to 0 for unlimited.', WPeMatico::TEXTDOMAIN), 'itemdate' => __('Use the original date from the post instead of the time the post is created by WPeMatico.', WPeMatico::TEXTDOMAIN) . '  ' . __('To avoid incoherent dates due to lousy setup feeds, WPeMatico will use the feed date only if these conditions are met:', WPeMatico::TEXTDOMAIN) . '  ' . '<ul style=\'list-style-type: square;margin:0 0 5px 20px;font:0.92em "Lucida Grande","Verdana";\'>
				<li>' . __('The feed item date is not too far in the past (specifically, as much time as the campaign frequency).', WPeMatico::TEXTDOMAIN) . ' </li>
				<li>' . __('The fetched feed item date is not in the future.', WPeMatico::TEXTDOMAIN) . ' </li></ul>', 'itemautor' => __('The created posts will be assigned to this author.', WPeMatico::TEXTDOMAIN), 'linktosource' => __('This option make the title permalink to original URL.', WPeMatico::TEXTDOMAIN) . '<br />' . __('This feature will be ignored if you deactivate Campaign Custom Fields on settings.', WPeMatico::TEXTDOMAIN), 'striplinks' => __('This option take out clickable links from content, leaving just the text.', WPeMatico::TEXTDOMAIN), 'postsauthor' => __('The posts created by this campaign will be assigned to this author.', WPeMatico::TEXTDOMAIN), 'allowpings' => __('Allows pinbacks and trackbacks in the posts created by this campaign.', WPeMatico::TEXTDOMAIN), 'commentstatus' => __('Comments options to these posts.', WPeMatico::TEXTDOMAIN), 'woutfilter' => '<b><i>' . __('Skip the Wordpress post content filters.', WPeMatico::TEXTDOMAIN) . '</i></b>' . '<br>' . __('Save the content exactly how to Simplepie gets it.', WPeMatico::TEXTDOMAIN) . '<br>' . __('Not recommended.', WPeMatico::TEXTDOMAIN), 'schedule' => __('Activate Automatic Mode.', WPeMatico::TEXTDOMAIN) . '<br>' . __('You can define here on what times you wants to fetch this feeds.  This has 5 min. of margin on WP-cron schedules.  If you set up an external cron en WPeMatico Settings, you\'ll get better preciseness.', WPeMatico::TEXTDOMAIN), 'imgoptions' => __('This features will be overridden only for this campaign the general Settings options for images.', WPeMatico::TEXTDOMAIN), 'cancel_imgcache' => __('Checked do not upload the images to your server just for the posts of this campaign.', WPeMatico::TEXTDOMAIN), 'imgcache' => __('All images found in &lt;img&gt; tags will be updated to your current WP Upload Folder, added to Wordpress Media and replaced urls in content. Otherwise remains links to source host server.', WPeMatico::TEXTDOMAIN), 'imgattach' => __('All images will be attached to the owner post in WP media library; necessary for Featured image, but if you see that the job process is too slowly you can deactivate this here.', WPeMatico::TEXTDOMAIN), 'gralnolinkimg' => __('If selected and image upload get error, then delete the \'src\' attribute of the &lt;img&gt;. Check this for don\'t link images from external sites.', WPeMatico::TEXTDOMAIN), 'postemplate' => __('Campaign post template allow to modify the content fetched by adding extra information, such as text, images, campaign data, etc. before save it as post content.', WPeMatico::TEXTDOMAIN) . '<br>' . __('You can use some tags that will be replaced for current value. Click on [?] below to see description and examples on how to use this feature.', WPeMatico::TEXTDOMAIN), 'wordcateg' => __('Allow to assign a singular category to the post if a word is found in the content.', WPeMatico::TEXTDOMAIN), 'category' => __('Add categories from the source post and/or assign already existing categories.', WPeMatico::TEXTDOMAIN), 'autocats' => __('If categories are found on source item, these categories will be added to the post; If category does not exist, then will be created.', WPeMatico::TEXTDOMAIN), 'tags' => __('You can insert here the tags for every post of this campaign.', WPeMatico::TEXTDOMAIN), 'sendlog' => __('An email will be sent with the events of campaign fetching. You can also filter the emails only if an error occurred or left blank to not send emails of this campaign.', WPeMatico::TEXTDOMAIN), 'postformat' => __('If your theme supports post formats you can select one for the posts of this campaign, otherwise left on Standard.', WPeMatico::TEXTDOMAIN));
        foreach ($helptip as $key => $value) {
            $helptip[$key] = htmlentities($value);
        }
        //	add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args );
        add_meta_box('format-box', __('Campaign Posts Format', WPeMatico::TEXTDOMAIN) . '<span class="mya4_sprite infoIco help_tip" title="' . $helptip['postformat'] . '"></span>', array('WPeMatico_Campaign_edit', 'format_box'), 'wpematico', 'side', 'default');
        add_meta_box('cat-box', __('Campaign Categories', WPeMatico::TEXTDOMAIN) . '<span class="mya4_sprite infoIco help_tip" title="' . $helptip['category'] . '"></span>', array('WPeMatico_Campaign_edit', 'cat_box'), 'wpematico', 'side', 'default');
        add_meta_box('tags-box', __('Tags generation', WPeMatico::TEXTDOMAIN) . '<span class="mya4_sprite infoIco help_tip" title="' . $helptip['tags'] . '"></span>', array('WPeMatico_Campaign_edit', 'tags_box'), 'wpematico', 'side', 'default');
        add_meta_box('log-box', __('Send log', WPeMatico::TEXTDOMAIN) . '<span class="mya4_sprite infoIco help_tip" title="' . $helptip['sendlog'] . '"></span>', array('WPeMatico_Campaign_edit', 'log_box'), 'wpematico', 'side', 'default');
        add_meta_box('feeds-box', __('Feeds for this Campaign', WPeMatico::TEXTDOMAIN) . '<span class="mya4_sprite infoIco help_tip" title="' . $helptip['feeds'] . '"></span>', array('WPeMatico_Campaign_edit', 'feeds_box'), 'wpematico', 'normal', 'default');
        add_meta_box('options-box', __('Options for this campaign', WPeMatico::TEXTDOMAIN), array('WPeMatico_Campaign_edit', 'options_box'), 'wpematico', 'normal', 'default');
        add_meta_box('images-box', __('Options for images', WPeMatico::TEXTDOMAIN) . '<span class="mya4_sprite infoIco help_tip" title="' . $helptip['imgoptions'] . '"></span>', array('WPeMatico_Campaign_edit', 'images_box'), 'wpematico', 'normal', 'default');
        add_meta_box('template-box', __('Post Template', WPeMatico::TEXTDOMAIN) . '<span class="mya4_sprite infoIco help_tip" title="' . $helptip['postemplate'] . '"></span>', array('WPeMatico_Campaign_edit', 'template_box'), 'wpematico', 'normal', 'default');
        if ($cfg['enableword2cats']) {
            // Si está habilitado en settings, lo muestra
            add_meta_box('word2cats-box', __('Word to Category options', WPeMatico::TEXTDOMAIN) . '<span class="mya4_sprite infoIco help_tip" title="' . $helptip['wordcateg'] . '"></span>', array('WPeMatico_Campaign_edit', 'word2cats_box'), 'wpematico', 'normal', 'default');
        }
        if ($cfg['enablerewrite']) {
            // Si está habilitado en settings, lo muestra
            add_meta_box('rewrite-box', __('Rewrite options', WPeMatico::TEXTDOMAIN) . '<span class="mya4_sprite infoIco help_tip" title="' . $helptip['rewrites'] . '"></span>', array('WPeMatico_Campaign_edit', 'rewrite_box'), 'wpematico', 'normal', 'default');
        }
        //***** Call nonstatic
        if ($cfg['nonstatic']) {
            NoNStatic::meta_boxes($campaign_data, $cfg);
        }
        // Publish Meta_box edited
        add_action('post_submitbox_start', array(__CLASS__, 'post_submitbox_start'));
    }
コード例 #4
0
 static function save_quick_edit_post($post_id)
 {
     //wp_die('save_quick_edit_post'.print_r($_POST,1));
     $slug = 'wpematico';
     if (!isset($_POST['post_type']) || $slug !== $_POST['post_type']) {
         return $post_id;
     }
     if (!current_user_can('edit_post', $post_id)) {
         return $post_id;
     }
     $_POST += array("{$slug}_edit_nonce" => '');
     if (!wp_verify_nonce($_POST["{$slug}_edit_nonce"], plugin_basename(__FILE__))) {
         wp_die('No verify nonce');
         return;
     }
     $nivelerror = error_reporting(E_ERROR | E_WARNING | E_PARSE);
     $campaign = WPeMatico::get_campaign($post_id);
     $posdata = $_POST;
     //apply_filters('wpematico_check_campaigndata', $_POST );
     //parse disabled checkfields that dont send any data
     $posdata['campaign_feeddate'] = !isset($posdata['campaign_feeddate']) || empty($posdata['campaign_feeddate']) ? false : $posdata['campaign_feeddate'] == 1 ? true : false;
     $posdata['campaign_allowpings'] = !isset($posdata['campaign_allowpings']) || empty($posdata['campaign_allowpings']) ? false : $posdata['campaign_allowpings'] == 1 ? true : false;
     $posdata['campaign_linktosource'] = !isset($posdata['campaign_linktosource']) || empty($posdata['campaign_linktosource']) ? false : $posdata['campaign_linktosource'] == 1 ? true : false;
     $posdata['campaign_strip_links'] = !isset($posdata['campaign_strip_links']) || empty($posdata['campaign_strip_links']) ? false : $posdata['campaign_strip_links'] == 1 ? true : false;
     $campaign = array_merge($campaign, $posdata);
     $campaign = apply_filters('wpematico_check_campaigndata', $campaign);
     error_reporting($nivelerror);
     WPeMatico::update_campaign($post_id, $campaign);
     return $post_id;
 }
コード例 #5
0
}
$cfg = WPeMatico::check_options(get_option('WPeMatico_Options'));
if ($cfg['logexternalcron']) {
    $upload_dir = wp_upload_dir();
    //try open log file on uploads dir
    if ($upload_dir['error'] == FALSE) {
        $filedir = $upload_dir['basedir'] . '/';
    } else {
        //if can't open in uploads dir try in this dir
        $filedir = '';
    }
}
$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')) {
        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;
        }
コード例 #6
0
	function custom_wpematico_column( $column, $post_id ) {
		$cfg = get_option( WPeMatico :: OPTION_KEY);
		$campaign_data = WPeMatico :: get_campaign ( $post_id );
		switch ( $column ) {
		  case 'status':
			echo $campaign_data['campaign_posttype']; 
			break;
		  case 'count':
			echo $campaign_data['postscount']; 
			break;
		  case 'next':
			$starttime = @$campaign_data['starttime']; 
			//print_r($campaign_data);
			$activated = $campaign_data['activated']; 
			if ($starttime>0) {
				$runtime=current_time('timestamp')-$starttime;
				// Aca agregar control de tiempo y sacarla de en ejecucion ***********************************************************************
				if(($cfg['campaign_timeout'] <= $runtime) && ($cfg['campaign_timeout']>0)) {
					$campaign_data['lastrun'] = $starttime;
					$campaign_data['lastruntime'] = ' <span style="color:red;">Timeout: '.$cfg['campaign_timeout'].'</span>';
					$campaign_data['starttime']   = '';
					$campaign_data['lastpostscount'] = 0; //  posts procesados esta vez
					WPeMatico :: update_campaign($post_id, $campaign_data);  //Save Campaign new data
				}
				echo __('Running since:', WPeMatico :: TEXTDOMAIN ).' '.$runtime.' '.__('sec.', WPeMatico :: TEXTDOMAIN );
			} elseif ($activated) {
				//$campaign_data['cronnextrun']= WPeMatico :: time_cron_next($campaign_data['cron']); //set next run, ver por que no actualizae el cron
				$cronnextrun = $campaign_data['cronnextrun']; 
				echo date_i18n(get_option('date_format'),$cronnextrun).'-'. date_i18n(get_option('time_format'),$cronnextrun);
			} else {
				echo __('Inactive', WPeMatico :: TEXTDOMAIN );
			}
			break;
		  case 'last':
			$lastrun = @$campaign_data['lastrun']; 
			$lastruntime = @$campaign_data['lastruntime']; 
			if ($lastrun) {
				echo date_i18n(get_option('date_format'),$lastrun).'-'. date_i18n(get_option('time_format'),$lastrun); 
				if (isset($lastruntime))
					echo '<br />'.__('Runtime:', WPeMatico :: TEXTDOMAIN ).' <span id="lastruntime">'.$lastruntime.'</span> '.__('sec.', WPeMatico :: TEXTDOMAIN );
			} else {
				echo __('None', WPeMatico :: TEXTDOMAIN );
			}
			break;
		}
	}
コード例 #7
0
ファイル: campaigns_edit.php プロジェクト: bcbroussard/POST
 public static function save_campaigndata($post_id)
 {
     global $post;
     // Stop WP from clearing custom fields on autosave, and also during ajax requests (e.g. quick edit) and bulk edits.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || defined('DOING_AJAX') && DOING_AJAX || isset($_REQUEST['bulk_edit'])) {
         return $post_id;
     }
     if (!wp_verify_nonce(@$_POST['wpematico_nonce'], 'edit-campaign')) {
         return $post_id;
     }
     if ($post->post_type != 'wpematico') {
         return $post_id;
     }
     $nivelerror = error_reporting(E_ERROR | E_WARNING | E_PARSE);
     $cfg = get_option(WPeMatico::OPTION_KEY);
     $campaign = array();
     $campaign = WPeMatico::get_campaign($post_id);
     $campaign['campaign_posttype'] = $_POST['campaign_posttype'];
     $campaign['campaign_customposttype'] = $_POST['campaign_customposttype'];
     $campaign['activated'] = $_POST['activated'] == 1 ? true : false;
     $campaign['campaign_feeddate'] = $_POST['campaign_feeddate'] == 1 ? true : false;
     $campaign['cron'] = WPeMatico::cron_string($_POST);
     $campaign['cronnextrun'] = WPeMatico::time_cron_next($campaign['cron']);
     // Direccion de e-mail donde enviar los logs
     $campaign['mailaddresslog'] = sanitize_email($_POST['mailaddresslog']);
     $campaign['mailerroronly'] = $_POST['mailerroronly'] == 1 ? true : false;
     // Process categories
     $campaign['campaign_autocats'] = $_POST['campaign_autocats'] == 1 ? true : false;
     // Primero proceso las categorias nuevas si las hay y las agrego al final del array
     # New categories
     if (isset($_POST['campaign_newcat'])) {
         foreach ($_POST['campaign_newcat'] as $k => $on) {
             $catname = $_POST['campaign_newcatname'][$k];
             if (!empty($catname)) {
                 //$_POST['campaign_categories'][] = wp_insert_category(array('cat_name' => $catname));
                 $arg = array('description' => "Auto Added by WPeMatico", 'parent' => "0");
                 $_POST['campaign_categories'][] = wp_insert_term($catname, "category", $arg);
             }
         }
     }
     # All: Las elegidas + las nuevas ya agregadas
     if (isset($_POST['campaign_categories'])) {
         $campaign['campaign_categories'] = (array) $_POST['campaign_categories'];
     }
     //if(isset($_POST['campaign_tags'])) {
     $campaign['campaign_tags'] = $_POST['campaign_tags'];
     //}
     #Proceso las Words to Category sacando los que estan en blanco
     //campaign_wrd2cat, campaign_wrd2cat_regex, campaign_wrd2cat_category
     if (isset($_POST['campaign_wrd2cat'])) {
         foreach ($_POST['campaign_wrd2cat'] as $id => $w2cword) {
             $word = addslashes($_POST['campaign_wrd2cat'][$id]);
             $regex = $_POST['campaign_wrd2cat_regex'][$id] == 1 ? true : false;
             $cases = $_POST['campaign_wrd2cat_cases'][$id] == 1 ? true : false;
             $w2ccateg = $_POST['campaign_wrd2cat_category'][$id];
             if (!empty($word)) {
                 if (!isset($campaign_wrd2cat)) {
                     $campaign_wrd2cat = array();
                 }
                 $campaign_wrd2cat['word'][] = $word;
                 $campaign_wrd2cat['regex'][] = $regex;
                 $campaign_wrd2cat['cases'][] = $cases;
                 $campaign_wrd2cat['w2ccateg'][] = $w2ccateg;
             }
         }
     }
     $campaign['campaign_wrd2cat'] = (array) $campaign_wrd2cat;
     // Proceso los feeds sacando los que estan en blanco
     if (isset($_POST['campaign_feeds'])) {
         foreach ($_POST['campaign_feeds'] as $k => $on) {
             $feedname = $_POST['campaign_feeds'][$k];
             if (!empty($feedname)) {
                 if (!isset($campaign_feeds)) {
                     $campaign_feeds = array();
                 }
                 $campaign_feeds[] = $feedname;
             }
         }
     }
     // Jamas llegaria aca si no hay feeds por el check ajax
     $campaign['campaign_feeds'] = (array) $campaign_feeds;
     // *** Campaign Options
     $campaign['campaign_max'] = (int) $_POST['campaign_max'];
     $campaign['campaign_author'] = $_POST['campaign_author'];
     $campaign['campaign_linktosource'] = $_POST['campaign_linktosource'] == 1 ? true : false;
     $campaign['campaign_strip_links'] = $_POST['campaign_strip_links'] == 1 ? true : false;
     $campaign['campaign_commentstatus'] = $_POST['campaign_commentstatus'];
     $campaign['campaign_allowpings'] = $_POST['campaign_allowpings'] == 1 ? true : false;
     $campaign['campaign_woutfilter'] = $_POST['campaign_woutfilter'] == 1 ? true : false;
     // *** Campaign Images
     $campaign['campaign_imgcache'] = $_POST['campaign_imgcache'] == 1 ? true : false;
     $campaign['campaign_cancel_imgcache'] = $_POST['campaign_cancel_imgcache'] == 1 ? true : false;
     if ($cfg['imgcache']) {
         if ($campaign['campaign_cancel_imgcache']) {
             $campaign['campaign_imgcache'] = false;
         }
     } else {
         if ($campaign['campaign_imgcache']) {
             $campaign['campaign_cancel_imgcache'] = false;
         }
     }
     $campaign['campaign_nolinkimg'] = $_POST['campaign_nolinkimg'] == 1 ? true : false;
     $campaign['campaign_solo1ra'] = $_POST['campaign_solo1ra'] == 1 ? true : false;
     // *** Campaign Template
     $campaign['campaign_enable_template'] = $_POST['campaign_enable_template'] == 1 ? true : false;
     if (isset($_POST['campaign_template'])) {
         $campaign['campaign_template'] = $_POST['campaign_template'];
     } else {
         $campaign['campaign_enable_template'] = false;
         $campaign['campaign_template'] = '';
     }
     // *** Campaign Rewrites
     // Proceso los rewrites sacando los que estan en blanco
     if (isset($_POST['campaign_word_origin'])) {
         foreach ($_POST['campaign_word_origin'] as $id => $rewrite) {
             $origin = addslashes($_POST['campaign_word_origin'][$id]);
             $regex = $_POST['campaign_word_option_regex'][$id] == 1 ? true : false;
             $title = $_POST['campaign_word_option_title'][$id] == 1 ? true : false;
             $rewrite = addslashes($_POST['campaign_word_rewrite'][$id]);
             $relink = addslashes($_POST['campaign_word_relink'][$id]);
             if (!empty($origin)) {
                 if (!isset($campaign_rewrites)) {
                     $campaign_rewrites = array();
                 }
                 $campaign_rewrites['origin'][] = $origin;
                 $campaign_rewrites['regex'][] = $regex;
                 $campaign_rewrites['title'][] = $title;
                 $campaign_rewrites['rewrite'][] = $rewrite;
                 $campaign_rewrites['relink'][] = $relink;
             }
         }
     }
     $campaign['campaign_rewrites'] = (array) $campaign_rewrites;
     //***** Call nonstatic
     if ($cfg['nonstatic']) {
         $campaign = NoNStatic::save_data($campaign, $_POST);
     }
     // check and correct all fields
     $campaign = self::check_campaigndata($campaign);
     error_reporting($nivelerror);
     // Grabo la campaña
     add_post_meta($post_id, 'campaign_data', $campaign, true) or update_post_meta($post_id, 'campaign_data', $campaign);
     return $post_id;
 }
コード例 #8
0
	function wpematico_cron() {
		$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 );
			}
		}
	}
コード例 #9
0
 public static function save_campaigndata($post_id)
 {
     global $post, $cfg;
     //wp_die('save_campaigndata<br>DOING_AUTOSAVE:'.DOING_AUTOSAVE.'<br>DOING_AJAX:'.DOING_AJAX.'<br>$_REQUEST[bulk_edit]:'.$_REQUEST['bulk_edit']);
     if (defined('DOING_AJAX') && DOING_AJAX || isset($_REQUEST['bulk_edit']) || isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
         WPeMatico_Campaigns::save_quick_edit_post($post_id);
         //wp_die('save_campaigndata<br>DOING_AUTOSAVE:'.DOING_AUTOSAVE.'<br>DOING_AJAX:'.DOING_AJAX.'<br>$_REQUEST[bulk_edit]:'.$_REQUEST['bulk_edit']);
         return $post_id;
     }
     //http://news.google.com.pe/news?pz=1&cf=all&ned=es_pe&hl=es&output=rss
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || defined('DOING_AJAX') && DOING_AJAX || isset($_REQUEST['bulk_edit'])) {
         return $post_id;
     }
     if (!wp_verify_nonce(@$_POST['wpematico_nonce'], 'edit-campaign')) {
         return $post_id;
     }
     if ($post->post_type != 'wpematico') {
         return $post_id;
     }
     $nivelerror = error_reporting(E_ERROR | E_WARNING | E_PARSE);
     //$cfg = get_option(WPeMatico :: OPTION_KEY);
     //		$campaign['cron'] = WPeMatico :: cron_string($_POST);
     $campaign = WPeMatico::get_campaign($post_id);
     $_POST['postscount'] = !isset($campaign['postscount']) ? 0 : (int) $campaign['postscount'];
     $_POST['lastpostscount'] = !isset($campaign['lastpostscount']) ? 0 : (int) $campaign['lastpostscount'];
     $_POST['lastrun'] = !isset($campaign['lastrun']) ? 0 : (int) $campaign['lastrun'];
     $_POST['lastruntime'] = !isset($campaign['lastruntime']) ? 0 : (int) $campaign['lastruntime'];
     $campaign = array();
     $campaign = apply_filters('wpematico_check_campaigndata', $_POST);
     //***** Call nonstatic
     //		if( $cfg['nonstatic'] ) { $campaign = NoNStatic :: save_data($campaign, $_POST); }
     error_reporting($nivelerror);
     if (has_filter('wpematico_presave_campaign')) {
         $campaign = apply_filters('wpematico_presave_campaign', $campaign);
     }
     // Grabo la campaña
     WPeMatico::update_campaign($post_id, $campaign);
     return $post_id;
 }