我使用Wordpress中的插件工作,該插件自動從亞馬遜導入信息,以便在我的網站上顯示爲單獨的帖子。該插件旨在爲每個將在亞馬遜上運行的搜索提供「廣告系列」。該插件有一個內置的功能,允許我重置每個活動個別當它達到亞馬遜的最大頁面。這可以讓廣告系列繼續搜索產品並創建帖子。如何重置wordpress插件中的數組
問題是,我有超過1000個廣告系列需要每隔幾天重置一次。我想在插件中設置一個「全部重置」功能。下面是我們到目前爲止有:
這是實際復位表示將競選上次運行值的功能:
function ResetKeywordPages($post_id)
{
$custom = $this->get_post_custom($post_id);
$this->update_post_meta($post_id, 'last_processed', time());
if(!$custom['amazon_product_keywords'])
return;
$keyword_bits = array();
if($custom['amazon_product_keywords'])
{
if($custom['amazon_keyword_logic'] == 'and')
$keyword_bits[] = $custom['amazon_product_keywords'];
else
$keyword_bits = explode(',', $custom['amazon_product_keywords']);
}
else
{
$keyword_bits[] = 'empty'; // just so the logic works for category-only campaigns
}
foreach($keyword_bits as $key => $value)
{
if(!is_array($value))
$value = trim($value);
if(!$value)
continue;
if($value == 'empty')
$value = '';
$node_string = $custom['amazon_product_node'];
$search_hash = $this->SearchSlug($value, $node_string);
update_post_meta($post_id, 'page_iter_'.$search_hash, 1);
}
}
這是現有reset.php從而完成了定義「功能item_id':
<?php require_once(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))).'/wp-load.php');
$response = array();
$item_id = $_GET['item_id'];
if($item_id)
{
$qodys_pinner->PostType('amazon-campaign')->ResetKeywordPages($item_id);
update_post_meta($item_id, 'last_processed', 0);
}
/*
$response['results'][] = 'Amazon campaign keyword pages reset successfully';
$qodys_pinner->Helper('postman')->SetMessage($response);*/
$url = $qodys_pinner->Helper('tools')->GetPreviousPage();
header("Location: ".$url);
exit;
?>
我對PHP還很新,所以在修改數組和其他類似的函數時我很茫然。我全神貫注地看了一些能夠幫助我的東西,但什麼都沒有發現;我認爲這是因爲這個插件非常適合它的工作方式?
在此先感謝您提供的任何幫助! :)
-Chase
嘿,什麼祕訣? :) – ChaseBLL 2012-07-18 14:18:20